void MusicVideoPlayWidget::resizeWindow(bool resize)
{
    if(resize)
    {
        showFullScreen();
    }
    else
    {
        showNormal();
        setGeometry(250, 150, WINDOW_WIDTH, WINDOW_HEIGHT);
    }
    QSize s = size();
#ifdef Q_OS_UNIX
    QDesktopWidget* desktopWidget = QApplication::desktop();
    if(isFullScreen() && desktopWidget && desktopWidget->screen())
    {
        s = desktopWidget->screen()->size();
    }
    else
    {
        s = QSize(WINDOW_WIDTH, WINDOW_HEIGHT);
        showNormal();
    }
#endif
    resizeWindow(s.width() - WINDOW_WIDTH, s.height() - WINDOW_HEIGHT);
}
void MusicVideoPlayWidget::resizeWindow(bool resize)
{
    if(resize)
    {
        showFullScreen();
    }
    else
    {
        showNormal();
        setGeometry(250, 150, 541, 460);
    }
    QSize s =  size();
#ifdef Q_OS_UNIX
    QDesktopWidget* desktopWidget = QApplication::desktop();
    if(desktopWidget && desktopWidget->screen())
    {
        s = desktopWidget->screen()->size();
    }
    else
    {
        s = QSize(541, 460);
        showNormal();
    }
#endif
    m_videoView->resizeWindow(resize, s);
    m_videoTable->resizeWindow(s.width() / 541.0);
}
void BubbleManager::consumeEntities()
{
    if (!m_currentNotify.isNull()) {
        m_currentNotify->deleteLater();
        m_currentNotify = nullptr;
    }

    if (m_entities.isEmpty()) {
        m_currentNotify = nullptr;
        return;
    }

    m_currentNotify = m_entities.dequeue();

    QDesktopWidget *desktop = QApplication::desktop();
    int pointerScreen = desktop->screenNumber(QCursor::pos());
    int primaryScreen = desktop->primaryScreen();
    QWidget *pScreenWidget = desktop->screen(primaryScreen);

    if (checkDockExistence()) {
        m_dockGeometry = m_dbusdockinterface->geometry();
    }

    if (checkControlCenterExistence())
        m_ccGeometry = m_dbusControlCenter->rect();

    if (checkControlCenterExistence() && pointerScreen == primaryScreen)
        bindControlCenterX();

    if (pointerScreen != primaryScreen)
        pScreenWidget = desktop->screen(pointerScreen);

    m_bubble->setBasePosition(getX(), getY(), pScreenWidget->geometry());
    m_bubble->setEntity(m_currentNotify);
}
Ejemplo n.º 4
0
SynthesisWindow::SynthesisWindow(QString travelTitle, QMainWindow * parentWindow, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::SynthesisWindow)
{
    QDesktopWidget screen;
    int screen_width = screen.screen()->width();
    int screen_height = screen.screen()->height();

    ui->setupUi(this);
    this->parentWindow = parentWindow;
    this->title = travelTitle;
    this->isArchived = false;
    this->setupTabs();
    this->currentTab = GENERAL;
    this->total = 0;
    this->setMinimumSize(QSize(540, 758));
    this->setMaximumSize(QSize(540, 758));
    this->move(screen_width/2 - this->width()/2, screen_height/2 - this->height()/2);

    QPixmap background(":/synthesisImages/travel.jpg");
    background = background.scaled(this->size(), Qt::IgnoreAspectRatio);
    QPalette palette;
    palette.setBrush(QPalette::Background, background);
    this->setPalette(palette);
    //this->ui->travelTitle->setStyleSheet("background-color: rgba(0,0,0,0%)");

    QFont totalFont ("Arial", 15, QFont::Bold);
    this->ui->totalLabel->setFont(totalFont);
    this->ui->totalLabel->setText(" Total = ");
    this->ui->totalLabel->setFixedWidth(125);
    this->ui->totalLabel->setFixedHeight(50);
    this->ui->totalLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    this->ui->totalLabel->setStyleSheet("QLabel { background-color : #3257a3; border-radius : 6px;  }");
    this->ui->totalValueLabel->setFont(totalFont);
    this->ui->totalValueLabel->setFixedHeight(50);
    this->ui->totalValueLabel->setStyleSheet("QLabel { background-color : #3257a3; border-radius : 6px;  }");//{ background-color : transparent; }");
    this->ui->totalValueLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

    QObject::connect(this->ui->generalButton, SIGNAL(clicked()), this, SLOT(onGeneralButtonClick()));
    QObject::connect(this->ui->transportButton, SIGNAL(clicked()), this, SLOT(onTransportButtonClick()));
    QObject::connect(this->ui->housingButton, SIGNAL(clicked()), this, SLOT(onHousingButtonClick()));
    QObject::connect(this->ui->restaurantButton, SIGNAL(clicked()), this, SLOT(onRestaurantButtonClick()));
    QObject::connect(this->ui->othersButton, SIGNAL(clicked()), this, SLOT(onOthersButtonClick()));
    QObject::connect(this, SIGNAL(changeTab()), this, SLOT(updateSelectedTab()));

    QFont titleFont("Arial", 22, QFont::Black);
    this->ui->travelTitle->setFont(titleFont);
    this->ui->travelTitle->setText(this->title);
    this->setMinimumSize(parentWindow->minimumWidth(), parentWindow->minimumHeight());
    this->ui->activityList->show();

    //this->ui->generalButton->setIcon(*(this->generateIcon(GENERAL)));

    this->updateSelectedTab();
    this->updateActivityList();


}
Ejemplo n.º 5
0
// set window position at center of screen
void CMainWindow::centerWindow() {
    int width  = this->frameGeometry().width(),
        height = this->frameGeometry().height();

    QDesktopWidget wid;
    int screenWidth = wid.screen()->width(),
        screenHeight = wid.screen()->height();

    this->setGeometry((screenWidth/2) - (width/2), (screenHeight/2) - (height/2), width, height);
}
Ejemplo n.º 6
0
void Widget_Padre::centra_finestra(){
       int width = frameGeometry().width();
       int height = frameGeometry().height();

       QDesktopWidget wid;

       int screenWidth = wid.screen()->width();
       int screenHeight = wid.screen()->height();

       int x=static_cast<int>((screenWidth-width)/2);
       int y=static_cast<int>((screenHeight-height)/2);

       move(x,y);
}
Ejemplo n.º 7
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    // ================= Setting Windows Size =================
    QDesktopWidget wid;
    int screenW = 1000;
    int screenH = 563;
    w.setGeometry(wid.screen()->width()/2 - (screenW/2) , wid.screen()->height()/2 - (screenH/2) , screenW , screenH);
    // ================= Setting Windows Title and Icon =================
    w.setWindowTitle("Taiko Drum Master");
    w.setWindowIcon(QIcon(":/image/img/icon.jpg"));
    w.setFixedSize(screenW , screenH);
    w.show();
    return a.exec();
}
Ejemplo n.º 8
0
/*
 * Constructor
 */
Config::Config(QSettings *settings,GetConfig* getConfig,QWidget *parent)
    : QWidget(parent,Qt::WindowCloseButtonHint)
{
    QDesktopWidget *dw = QApplication::desktop();
    QSize s = dw->screen(dw->primaryScreen())->size();
    setupUi(this);

    this->getConfig = getConfig;
    this->settings = settings;

    move(s.width() / 2 - 235, s.height()/ 2 - 241) ;
    show();

    connect(adminPasswordLE,SIGNAL(returnPressed()),this,SLOT(adminAuthentication()));
    connect(okButton,SIGNAL(clicked()),this,SLOT(saveSettings()));
    //print page
    connect(bonafideRB1,SIGNAL(clicked()),this,SLOT(decideCert1()));
    connect(conductRB1,SIGNAL(clicked()),this,SLOT(decideCert1()));
    connect(tcRB1,SIGNAL(clicked()),this,SLOT(decideCert1()));

    connect(fieldCombo,SIGNAL(currentIndexChanged(int)),this,SLOT(setXY(int)));
    connect(xSB,SIGNAL(editingFinished()),this,SLOT(setPrintPositionsFlag()));
    connect(ySB,SIGNAL(editingFinished()),this,SLOT(setPrintPositionsFlag()));

    //database page
    connect(databasenameLE,SIGNAL(editingFinished()),this,SLOT(databaseSettingsChanged()));
    connect(hostnameLE,SIGNAL(editingFinished()),this,SLOT(databaseSettingsChanged()));
    connect(portLE,SIGNAL(editingFinished()),this,SLOT(databaseSettingsChanged()));
    connect(usernameLE,SIGNAL(editingFinished()),this,SLOT(databaseSettingsChanged()));
    connect(passwordLE,SIGNAL(editingFinished()),this,SLOT(databaseSettingsChanged()));

    connect(connectButton,SIGNAL(clicked()),this,SLOT(checkConnectivity()));

    //Certificate page
    connect(bonafideRB2,SIGNAL(clicked()),this,SLOT(decideCert2()));
    connect(conductRB2,SIGNAL(clicked()),this,SLOT(decideCert2()));
    connect(tcRB2,SIGNAL(clicked()),this,SLOT(decideCert2()));

    connect(fromSB,SIGNAL(editingFinished()),this,SLOT(setAcademicYearFlag()));
    connect(toSB,SIGNAL(editingFinished()),this,SLOT(setAcademicYearFlag()));

    //General Settings
    connect(printersCombo,SIGNAL(currentIndexChanged( const QString &)),this,SLOT(setPrinterFlag( const QString&)));

    connect(databaseRB,SIGNAL(clicked()),this,SLOT(setModeFlag()));
    connect(manualRB,SIGNAL(clicked()),this,SLOT(setModeFlag()));

    connect(stackedWidget,SIGNAL(currentChanged(int)),this,SLOT(selectFunction(int)));//,Qt::UniqueConnection);

    //ensuring that all flags are reset
    for(int i = 0; i < 7; ++i )
        f[i] = false;

    for(int i = 0; i < 6; ++i)
        flag[i] = false;

    preparePrintSettings();
    adminPasswordLE->setFocus();
}
Ejemplo n.º 9
0
void Interface::PrintScreen()
{
QDesktopWidget *desk = qApp->desktop();
QPixmap desktopscreen = QPixmap::grabWindow(desk->screen()->winId());
desktopscreen.save( origImageFilename, extension.data() , qualvalue->value() ); 
BaseReset();
showMaximized();
}
Ejemplo n.º 10
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(open()));
    connect(ui->actionSave_As,SIGNAL(triggered()),this,SLOT(save_as()));
    connect(ui->actionGrayscale, SIGNAL(triggered()), this, SLOT(gray_scale()));
    connect(ui->actionHistogram, SIGNAL(triggered()), this, SLOT(show_histogram()));
    connect(ui->actionBinarization, SIGNAL(triggered()), this, SLOT(show_binarization()));
    connect(ui->actionRecognition, SIGNAL(triggered()), this, SLOT(show_recognition()));

    connect(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(subwindow_changed(QMdiSubWindow*)));

    //Window
    QDesktopWidget desktop;

    int width = geometry().width();
    int height = geometry().height();

    int screenWidth = desktop.screen()->width();
    int screenHeight = desktop.screen()->height();

    setGeometry((screenWidth/2)-(width/2),(screenHeight/2)-(height/2),width,height);
    setCentralWidget(&mdiArea);

    // Histogram dialog
    histogramDlg = new dlgHistogram(&mdiArea);
    mdiArea.addSubWindow(histogramDlg);

    histogramDlg->parentWidget()->hide();

    // Binarization dialog
    binarizationDlg = new dlgBinarization(&mdiArea);
    mdiArea.addSubWindow(binarizationDlg);

    binarizationDlg->parentWidget()->hide();

    // Recognition dialog
    recognitionDlg = new dlgRecognition(&mdiArea);
    mdiArea.addSubWindow(recognitionDlg);

    recognitionDlg->parentWidget()->hide();
}
Ejemplo n.º 11
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Taiko w;

    QDesktopWidget setsize;
    int sizex = 1000;
    int sizey = 500;
    w.setGeometry(setsize.screen()->width()/2-(sizex/2),setsize.screen()->height()/2-(sizey/2),sizex,sizey);
    w.show();


    /*QPushButton *start= new QPushButton("START!") ;
    start->resize(100,50);
    start->show();*/

    return a.exec();
}
Ejemplo n.º 12
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;


    QDesktopWidget widget;
    int screenW=710;//寬
    int screenH=410;//高
    w.setGeometry(widget.screen()->width()/2-(screenW/2),widget.screen()->height()/2-(screenH/2),screenW,screenH);//x,y,W,H
    w.setWindowTitle("angrybug");
    w.setFixedSize(screenW,screenH);//限制視窗大小不可任意更改
    w.show();



    return a.exec();
}
Ejemplo n.º 13
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    /***set window size***/
    QDesktopWidget window;
    int screenW = 800;
    int screenH = 600;
    w.setGeometry(window.screen()->width()/2 - (screenW/2),window.screen()->height()/2 - (screenH/2),screenW,screenH);

    /***set window title and icon***/
    w.setWindowTitle("Taiko Master");
    w.setWindowIcon(QIcon(":/image/pics/icon.png"));
    w.setFixedSize(screenW,screenH);
    w.show();

    return a.exec();
}
Ejemplo n.º 14
0
void Window::setupImagePosition()
{
    QPoint cursorPos = QCursor::pos();

    QDesktopWidget * desktop = QApplication::desktop();
    int screenNum = desktop->screenNumber(cursorPos);
    QWidget * screen = desktop->screen(screenNum);

    m_image->move(screen->geometry().center() - m_image->rect().center());
}
Ejemplo n.º 15
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    Scene S;

    S.setBackgroundBrush(Qt::black);

    QDesktopWidget wid;
    //Set window size
    int screenW = 835;
    int screenH = 523;
    w.setGeometry(wid.screen()->width()/2 - (screenW/2) , wid.screen()->height()/2 - (screenH/2) , screenW , screenH );
//  start in the middle of the window

    w.setWindowTitle("TaikoTest");
    w.setFixedSize(screenW , screenH);
    w.show();
    return a.exec();

}
Ejemplo n.º 16
0
void DDockInternalWidget::addWidget(const QString &title, QWidget *widget)
{
	QPixmap pm = widget->windowIcon().pixmap(16,16);
	Ideal::Button *button;
	if (!pm.isNull())
	{
		button = new Ideal::Button(m_bar, title, pm);
	}
	else
	{
		button = new Ideal::Button(m_bar, title);
	}

	m_bar->addButton(button);

	QDesktopWidget *desktop = new QDesktopWidget();
	
	if (widget->height() > desktop->screen(desktop->primaryScreen ())->height()-230)
	{
		QScrollArea *area = new QScrollArea(m_widgetStack);
		widget->adjustSize();
		area->setWidget(widget);
		area->setWidgetResizable(true);
		m_widgetStack->addWidget(area);
		m_widgets[button] = area;
		m_buttons[area] = button;
// 		area->setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOn );
	}
	else
	{
		m_widgets[button] = widget;
		widget->setParent(m_widgetStack);
		m_widgetStack->addWidget(widget);
		m_buttons[widget] = button;
	}
    
	connect(button, SIGNAL(clicked()), this, SLOT(selectWidget()));
    
    //if the widget was selected last time the dock is deleted 
    //we need to show it

	QSettings config;
	config.beginGroup("DLSLib-"+objectName());
    
	if ( config.value("ViewLastWidget").toString() == title)
	{
		button->setChecked(true);
		selectWidget(button);
	}

	widget->show();
}
Ejemplo n.º 17
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    angrybird w;
    // ================= Calculate for frame size =================
    int width = w.frameGeometry().width();
    int height = w.frameGeometry().height();
    // ================= Calculate the QMainWindow =================
    QDesktopWidget wid;
    int screenWidth = wid.screen()->width();
    int screenHeight = wid.screen()->height();
    // ================= Setting to central =================
    w.setGeometry((screenWidth/2)-(width/2) , (screenHeight/2) - (height/2) , width , height);
    // ================= Setting the Background =================
    QPixmap bgImg ("/home/kevin/桌面/Qt-workspace/Image_Src/bgImg.jpg");
    bgImg = bgImg.scaled(w.size(),Qt::IgnoreAspectRatio);
    QPalette palette;
    palette.setBrush(QPalette::Background,bgImg);
    w.setPalette(palette);
    // ================= End up Setting =================
    w.show();
    return a.exec();
}
void MediaSourceDesktop::getVideoDevices(VideoDevices &pVList)
{
    static bool tFirstCall = true;
    VideoDeviceDescriptor tDevice;

    #ifdef MSD_DEBUG_PACKETS
        tFirstCall = true;
    #endif

    if (tFirstCall)
        LOG(LOG_VERBOSE, "Enumerating hardware..");

    //#############################
    //### screen segment
    //#############################
    tDevice.Name = MEDIA_SOURCE_DESKTOP;
    tDevice.Card = "segment";
	#ifdef APPLE
    	tDevice.Desc = "OSX Cocoa based screen segment capturing";
	#else
		tDevice.Desc = "Qt based screen segment capturing";
	#endif
	if (tFirstCall)
        LOG(LOG_VERBOSE, "Found video device: %s (card: %s)", tDevice.Name.c_str(), tDevice.Card.c_str());
    pVList.push_back(tDevice);


    QDesktopWidget *tDesktop = QApplication::desktop();
    if (tDesktop != NULL)
    {
        if (tFirstCall)
        {
            LOG(LOG_VERBOSE, "Desktop found..");
            LOG(LOG_VERBOSE, "  ..resolution: %d * %d", tDesktop->width(), tDesktop->height());
            LOG(LOG_VERBOSE, "  ..screens: %d", tDesktop->numScreens());
            LOG(LOG_VERBOSE, "  ..virtualized: %d", tDesktop->isVirtualDesktop());
        }

        for (int i = 0; i < tDesktop->numScreens(); i++)
        {
            QWidget *tScreen = tDesktop->screen(i);
            if (tFirstCall)
            {
                LOG(LOG_VERBOSE, "  ..screen %d: resolution=%d*%d, available resolution=%d*%d, position=(%d, %d)", i, tDesktop->screenGeometry(i).width(), tDesktop->screenGeometry(i).height(), tDesktop->availableGeometry(i).width(), tDesktop->availableGeometry(i).height(), tDesktop->screenGeometry(i).x(), tDesktop->screenGeometry(i).y());
            }
        }
    }

    tFirstCall = false;
}
Ejemplo n.º 19
0
void Window::setupSize()
{
    QDesktopWidget * desktop = QApplication::desktop();
    int screenCount = desktop->screenCount();

    int totalWidth = 0;
    int totalHeight = 0;
    for (int i = 0; i < screenCount; i++) {
        QWidget * screen = desktop->screen(i);
        totalWidth = qMax(totalWidth, screen->x() + screen->width());
        totalHeight = qMax(totalHeight, screen->y() + screen->height());
    }

    setFixedSize(totalWidth, totalHeight);
}
Ejemplo n.º 20
0
int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	
	QDesktopWidget *desktop = QApplication::desktop();
	QWidget *screen = desktop->screen(desktop->primaryScreen());	
	ApplicationWindow window;
	
	window.resize(screen->height(),screen->height()*2/3);
	window.move((screen->width()-window.width())/2,(screen->height()-window.height())/2);
	window.setWindowTitle("JoyPrompter");
	window.setWindowIcon(QIcon("../Icons/joyland32x32.png"));
	window.show();
	
	return app.exec();
}
Ejemplo n.º 21
0
void MainWindowActions::shootScreen()
{
	QDesktopWidget* desktop = qApp->desktop();
	QList<QScreen*> screens = qApp->screens();

	for (int i=0; i<desktop->screenCount(); ++i)
	{
		QWidget* screenWidget = desktop->screen(i);
		WId screenWinId = screenWidget->winId();
		QRect geo = desktop->screenGeometry(i);
		QString name = "";
		if (desktop->screenCount()>1)
			name = screens[i]->name().split(" ").join("");
		this->saveScreenShot(screens[i]->grabWindow(screenWinId, geo.left(), geo.top(), geo.width(), geo.height()), name);
	}
}
Ejemplo n.º 22
0
void ScreenVideoProvider::setWidgetToNiceSizeInLowerRightCorner(QSize size)
{
	QDesktopWidget* desktop = qApp->desktop();
	QList<QScreen*> screens = qApp->screens();

	QWidget* screen = desktop->screen(desktop->screenNumber(mSecondaryViewLayoutWindow));
	QRect geo = screen->geometry();

	if (size.width()==0 || size.height()==0)
	{
		size = QSize(geo.width()/3, geo.height()/3);
	}

	QRect rect = QRect(QPoint(geo.width()-size.width(),geo.height()-size.height()), size);
	mSecondaryViewLayoutWindow->setGeometry(rect);
	rect = mSecondaryViewLayoutWindow->frameGeometry();
	mSecondaryViewLayoutWindow->move(geo.width()-rect.width(),geo.height()-rect.height());
}
Ejemplo n.º 23
0
void AppUtil::ensureWidgetIsVisible(QWidget* widget)
{
    if (widget == NULL)
        return;

    QWidget* parent = widget->parentWidget();
    if (widget->windowFlags() & Qt::Window)
    {
        // The widget is a top-level window (a dialog, for instance)
        // @todo Use the screen where the main application currently is?
        QDesktopWidget dw;
        QWidget* screen(dw.screen());
        if (screen != NULL)
        {
            // Move the widget to the center of the default screen
            const QRect screenRect(screen->rect());
            if (screenRect.contains(widget->pos()) == false)
            {
                QRect widgetRect(widget->rect());
                widgetRect.moveCenter(screenRect.center());
                widget->setGeometry(widgetRect);
            }
        }
        else
        {
            // Last resort: move to top left and hope the widget is visible
            widget->move(0, 0);
        }
    }
    else if (parent != NULL)
    {
        // The widget's placement is bounded by a parent
        const QRect parentRect(parent->rect());
        if (parentRect.contains(widget->pos()) == false)
        {
            // Move the widget to the center of the parent if wouldn't
            // otherwise be visible
            QRect widgetRect(widget->rect());
            widgetRect.moveCenter(parentRect.center());
            widget->setGeometry(widgetRect);
        }
    }
}
Ejemplo n.º 24
0
void InfoView::loaded(bool ok) {
    if (!ok || !shouldShow()) {
        deleteLater();
        return;
    }
    
    QDesktopWidget* desktop = Application::getInstance()->desktop();
    QWebFrame* mainFrame = page()->mainFrame();
    
    int height = mainFrame->contentsSize().height() > desktop->height() ?
        desktop->height() * MAX_DIALOG_HEIGHT_RATIO :
        mainFrame->contentsSize().height();
    
    resize(mainFrame->contentsSize().width(), height);
    move(desktop->screen()->rect().center() - rect().center());
    setWindowTitle(title());
    setAttribute(Qt::WA_DeleteOnClose);
    show();
}
Ejemplo n.º 25
0
void Completer::invokeCompletion( QPlainTextEdit* editor )
{
    if ( !isVisible() )
    {
        mEditor = editor;
        setParent( mEditor, windowFlags() );
        QPoint position = mEditor->mapToGlobal( mEditor->cursorRect().topLeft() );
        int h = mEditor->cursorRect().height();
        QDesktopWidget *dw = QApplication::desktop();

        if(position.ry() < (dw->screen()->height()-height()))
            position.ry() += h;
        else
            position.ry() -= (h+height());

        move( position );
        if ( prepareCompletion() )
        {
            show();
            lwItems->setFocus();
        }
    }
}
Ejemplo n.º 26
0
	void ScreenshotSpreader::Handle(const Client& client, mc::IProtocolRef protocol, IServerControlRef /* server */)
	{
        if ( !client.IsScreenCaptureEnabled() )
            return;

        // Acquire mouse cursor position.
        RemotePC::ScreenPoint position = RemotePC::HardwareProvider::Instance().GetMouseControl()->GetPosition();

        // Calculate bounding box around current mouse position.
        float blockSize = 256.0f;
        float zoomLevel = client.GetZoomLevel();
        int imageSize = (int)( blockSize * zoomLevel );
        int leftX = position.x_ - imageSize / 2;
        int topY = position.y_ - imageSize / 2;
        int rightX = leftX + imageSize;
        int bottomY = topY + imageSize;

        // Find screen to which cursor currently belongs.
        QDesktopWidget* desktop = QApplication::desktop();
        int screenNumber = desktop->screenNumber(QPoint(position.x_, position.y_));
        QWidget* screen = desktop->screen(screenNumber);
        QRect geometry = screen->geometry();

        // Cut areas beyond the surface of the screen.
        int leftdX = ( leftX < geometry.left() ) ? ( geometry.left() - leftX ) : 0;
        int topdY = ( topY < geometry.top() ) ? ( geometry.top() - topY ) : 0;
        int rightdX = ( rightX > geometry.right() ) ? ( rightX - geometry.right() ) : 0;
        int bottomdY = ( bottomY >= geometry.bottom() ) ? ( bottomY - geometry.bottom() ) : 0;
        leftX += leftdX;
        topY += topdY;
        rightX += rightdX;
        bottomY += bottomdY;
        int fragmentWidth = imageSize - leftdX - rightdX;
        int fragmentHeight = imageSize - topdY - bottomdY;
        bool isBoundary = ( leftdX > 0 ) || ( topdY > 0 ) || ( rightdX > 0 ) || ( bottomdY > 0 );

        // Grab part of the screen.
        QPixmap fragment = QApplication::primaryScreen()->grabWindow(
            QApplication::desktop()->winId(),
            leftX, topY, fragmentWidth, fragmentHeight);

        // Check to see if anything was actually grabbed.
        fragmentWidth = fragment.width();
        fragmentHeight = fragment.height();
        if ( fragmentWidth <= 0 || fragmentHeight <= 0 )
        {
            return;
        }

        if ( isBoundary )
        {
            // Image was grabbed right next to one of screen edges.

            // Scale image first. QPainter's scaling does not always work even with QPainter::SmoothPixmapTransform.
            fragment = fragment.scaled(
                QSize(fragmentWidth * blockSize / imageSize, fragmentHeight * blockSize / imageSize),
                Qt::KeepAspectRatio,
                Qt::SmoothTransformation);

            // Locate grabbed fragment appropriately in the resulting image.
            QPixmap temp(blockSize, blockSize);
            QPainter painter(&temp);
            painter.fillRect(0, 0, blockSize, blockSize, QColor(Qt::black));
            painter.drawPixmap(QPoint(leftdX * blockSize / imageSize, topdY * blockSize / imageSize), fragment);
            fragment = temp;
        }
        else
        {
            if ( imageSize != (int)blockSize )
            {
                // Image was grabbed from within the screen.
                fragment = fragment.scaled(
                    QSize(blockSize, blockSize),
                    Qt::KeepAspectRatio,
                    Qt::SmoothTransformation);
            }
        }

        // Construct screenshot message from QT image.
        QByteArray imageBytes;
        QBuffer imageBuffer(&imageBytes);
        imageBuffer.open(QIODevice::WriteOnly);
        #if !defined(IREMOTE_NO_QT_PLUGINS)
            fragment.save(&imageBuffer, "JPG", Config::Instance().GetSFBCompression());
        #else
            fragment.save(&imageBuffer, "PNG", Config::Instance().GetSFBCompression());
        #endif

        // Construct message object.
        mc::IMessagePtr message(
            mc::Class< RemotePC::ScreenshotMessage >::Create(
                imageBytes.size(), imageBytes.constData() ) );

        // Send image to the client.
        protocol->Send( message );
	}
Ejemplo n.º 27
0
int WebCore::screenDepth(Widget *w)
{
    QDesktopWidget *d = QApplication::desktop();
    return d->screen(d->screenNumber(w->qwidget()))->depth();
}
void KPrViewModePresentation::activate( KoPAViewMode * previousViewMode )
{
    if (!m_baseCanvas) return;

    m_savedViewMode = previousViewMode;               // store the previous view mode
    m_savedParent = m_baseCanvas->parentWidget();
    m_baseCanvas->setParent( ( QWidget* )0, Qt::Window ); // set parent to 0 and

    QDesktopWidget desktop;

    KPrDocument *document = static_cast<KPrDocument *>( m_view->kopaDocument() );
    bool presenterViewEnabled = document->isPresenterViewEnabled();
    int presentationscreen = document->presentationMonitor();

    // add end off slideshow page
    m_endOfSlideShowPage = new KPrEndOfSlideShowPage( desktop.screenGeometry( presentationscreen ), document );
    QList<KoPAPageBase*> pages = document->slideShow();
    pages.append( m_endOfSlideShowPage );

    QRect presentationRect = desktop.screenGeometry( presentationscreen );

#ifdef Q_OS_LINUX
    // This breaks and is not required on Windows platforms
    m_baseCanvas->setParent(desktop.screen(presentationscreen), Qt::Window); // detach widget to the presentation screen
#endif

    m_baseCanvas->setWindowFlags( Qt::Window ); // make it a window

    // the main animation director needs to be created first since it will set the active page
    // of the presentation
    // the animation director needs to be set before m_baseCanvas->move is called as this might try to call
    // viewConverter.
    m_animationDirector = new KPrAnimationDirector( m_view, m_baseCanvas, pages, m_view->activePage() );
    // move and resize now as otherwise it is not set when we call activate on the tool.
    m_baseCanvas->setGeometry(presentationRect);
    m_baseCanvas->setWindowState( m_baseCanvas->windowState() | Qt::WindowFullScreen ); // make it show full screen

    // show and setFocus needs to be done after move and resize as otherwise the move and resize have no effect
    m_baseCanvas->show();
    m_baseCanvas->setFocus();

    KoCursor::setAutoHideCursor( m_baseCanvas, true );

    if ( presenterViewEnabled ) {

        if ( desktop.numScreens() > 1 ) {
            int newscreen = desktop.numScreens() - presentationscreen - 1; // What if we have > 2 screens?
            QRect pvRect = desktop.screenGeometry( newscreen );

            m_presenterViewCanvas = new KoPACanvas( m_view, document );
            m_presenterViewWidget = new KPrPresenterViewWidget( this, pages, m_presenterViewCanvas );
#ifdef Q_OS_LINUX
            // This breaks and is not required on Windows platforms
            m_presenterViewWidget->setParent( desktop.screen(newscreen), Qt::Window );
#endif
            m_presenterViewWidget->setGeometry(pvRect);
            m_presenterViewWidget->setWindowState(
                m_presenterViewWidget->windowState() | Qt::WindowFullScreen );
            m_presenterViewWidget->updateWidget( pvRect.size(), presentationRect.size() );
            m_presenterViewWidget->show();
            m_presenterViewWidget->setFocus();                             // it shown full screen

            m_pvAnimationDirector = new KPrAnimationDirector( m_view,
                    m_presenterViewCanvas, pages, m_view->activePage() );
        }
        else {
            kWarning() << "Presenter View is enabled but only found one monitor";
            document->setPresenterViewEnabled( false );
        }
    }

    m_tool->activate(KoToolBase::DefaultActivation, QSet<KoShape*>());

    emit activated();
    emit pageChanged( m_animationDirector->currentPage(), m_animationDirector->numStepsInPage() );
    emit stepChanged( m_animationDirector->currentStep() );
}
Ejemplo n.º 29
0
bool WebCore::screenIsMonochrome(Widget *w)
{
    QDesktopWidget *d = QApplication::desktop();
    return d->screen(d->screenNumber(w->qwidget()))->numColors() < 2;
}
QRect QtWidgetsTweakletImpl::GetAvailableScreenSize(int i)
{
  QDesktopWidget *desktop = QApplication::desktop();
  if (i < 0) return desktop->screen()->geometry();
  return desktop->availableGeometry(i);
}