Пример #1
0
void RegionGrab::init()
{
  m_pixmap = m_grabber->grabFullScreen();

  QDesktopWidget *desktop = QApplication::desktop();
  QRect rect;

  if (desktop->screenCount() > 1) {
    for (int i = 0; i < desktop->screenCount(); ++i) {
      if (rect.isNull())
        rect = desktop->screenGeometry(i);
      else
        rect = rect.united(desktop->screenGeometry(i));
    }
  }
  else
    rect = QRect(QPoint(0, 0), m_pixmap.size());

  resize(rect.size());
  move(rect.topLeft());
  setCursor(Qt::CrossCursor);

# ifdef Q_OS_MAC
  showFullScreen();
# else
  show();
# endif

  raise();
  activateWindow();
  setFocus();
}
Пример #2
0
void WaveformWidget::setSoundFile(QString filename)
{
    QPainterPath waveformMax(QPointF(0,0));
    QPainterPath waveformMin(QPointF(0,0));
    SndfileHandle soundFile(filename.toStdString());
    if (soundFile.error()) qDebug() << soundFile.strError();

    QDesktopWidget *desk = QApplication::desktop();
    int totalPixelCount = (desk->screenGeometry().width()*desk->screenCount());
    sf_count_t framesPerPixel = soundFile.frames()/totalPixelCount;
    Q_ASSERT(framesPerPixel >= 1);
    float samples[framesPerPixel*soundFile.channels()];
    sf_count_t totalFrames = 0;
    while (soundFile.readf(samples, framesPerPixel) != 0) {
        float maximum = 0;
        float minimum = 0;
        for (int f=0; f<framesPerPixel; f++) {
            for (int c=0; c<soundFile.channels(); c++) {
                maximum = samples[f*c+c] > maximum ? samples[f*c+c] : maximum;
                minimum = samples[f*c+c] < minimum ? samples[f*c+c] : minimum;
            }
        }
        waveformMax.lineTo(double(totalFrames)/(framesPerPixel*totalPixelCount), maximum);
        waveformMin.lineTo(double(totalFrames)/(framesPerPixel*totalPixelCount), minimum);
        totalFrames += framesPerPixel;
    }
    maxWave.swap(waveformMax);
    minWave.swap(waveformMin);
}
Пример #3
0
static void test_systemdisplayinfo(void)
{
  QSystemDisplayInfo displayinfo;
  QDesktopWidget wid;
  for( int display = 0; display < wid.screenCount(); ++display )
  {
    qDebug() << "";
    qDebug() << "Display:" << display;
    int depth = displayinfo.colorDepth(display);
    qDebug() << "  displayinfo.colorDepth() ->" << depth;
    int value = displayinfo.displayBrightness(display);
    qDebug() << "  displayinfo.displayBrightness() ->" << value;
    QSystemDisplayInfo::DisplayOrientation orientation = displayinfo.orientation(display);
    qDebug() << "  displayinfo.orientation() ->" << orientation;
    float contrast = displayinfo.contrast(display);
    qDebug() << "  displayinfo.getContrast() ->" << contrast;
    int dpiWidth = displayinfo.getDPIWidth(display);
    qDebug() << "  displayinfo.getDPIWidth() ->" << dpiWidth;
    int dpiHeight = displayinfo.getDPIHeight(display);
    qDebug() << "  displayinfo.getDPIHeight() ->" << dpiHeight;
    int physicalHeight = displayinfo.physicalHeight(display);
    qDebug() << "  displayinfo.physicalHeight() ->" << physicalHeight;
    int physicalWidth = displayinfo.physicalWidth(display);
    qDebug() << "  displayinfo.physicalWidth() ->" << physicalWidth;
    QSystemDisplayInfo::BacklightState state = displayinfo.backlightStatus(display);
    qDebug() << "  displayinfo.backlightStatus() ->" << state;

  }
}
Пример #4
0
QPoint InviwoApplicationQt::movePointOntoDesktop(const QPoint& point, const QSize& size,
                                                 bool decorationOffset) {
    QPoint pos(point);
    if (movePointsOn_) {
        QDesktopWidget* desktop = QApplication::desktop();
        int primaryScreenIndex = desktop->primaryScreen();
        QRect wholeScreen = desktop->screenGeometry(primaryScreenIndex);

        for (int i = 0; i < desktop->screenCount(); i++) {
            if (i != primaryScreenIndex) wholeScreen = wholeScreen.united(desktop->screenGeometry(i));
        }

        wholeScreen.setRect(wholeScreen.x() - 10, wholeScreen.y() - 10, wholeScreen.width() + 20,
            wholeScreen.height() + 20);
        QPoint bottomRight = QPoint(point.x() + size.width(), point.y() + size.height());
        QPoint appPos = getMainWindow()->pos();

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
        if (decorationOffset) {
            QPoint offset = getWindowDecorationOffset();
            pos -= offset;
        }
#endif

        if (!wholeScreen.contains(pos) || !wholeScreen.contains(bottomRight)) {
            // If the widget is outside visible screen
            pos = appPos;
            pos += offsetWidget();
        }
    }
    return pos;
}
Пример #5
0
int CaptureDialog::update_screen_combo(void)
{
    //disable signals
    screen_combo->blockSignals(true);

    //save current value
    int current = screen_combo->currentIndex();

    //update combo
    QStringList list;
    screen_combo->clear();
    QDesktopWidget * desktop = QApplication::desktop();
    int screens =  desktop->screenCount();
    for (int i=0; i<screens; i++)
    {
        const QRect rect = desktop->screenGeometry(i);
        list.append(QString("Screen %1 [%2x%3]").arg(i).arg(rect.width()).arg(rect.height()));
    }
    screen_combo->addItems(list);

    //set current value
    int saved_value = APP->config.value("capture/projector_screen", 1).toInt();
    int default_screen = (saved_value<screen_combo->count() ? saved_value : 0);
    screen_combo->setCurrentIndex((-1<current && current<screen_combo->count() ? current : default_screen));

    //enable signals
    screen_combo->blockSignals(false);

    return screen_combo->count();
}
Пример #6
0
void PCDMgui::fillScreens(){
    //Set a background image on any other available screens
    QDesktopWidget *DE = QApplication::desktop();
    screens.clear();
    //Generate the background style sheet
    //QString tmpIcon = currentTheme->itemIcon("background");
    //if( tmpIcon.isEmpty() || !QFile::exists(tmpIcon) ){ tmpIcon = ":/images/backgroundimage.jpg"; }
    //QString bgstyle = "QWidget#BGSCREEN{border-image: url(BGIMAGE) stretch;}"; 
      //bgstyle.replace("BGIMAGE", tmpIcon);
    //this->setStyleSheet(bgstyle);
    //Now apply the background to all the other screens   
    // - Keep track of the total width/height of all screens combined (need to set the QMainWindow to this size)
    int wid, high;
    wid = high = 0;
    for(int i=0; i<DE->screenCount(); i++){
      //if(i != DE->screenNumber(this)){
        //Just show a generic QWidget with the proper background image on every screen
	QWidget *screen = new QWidget(this->centralWidget());
	screen->setObjectName("BGSCREEN");
	QRect rec = DE->screenGeometry(i);
	screen->setGeometry( rec );
	if(rec.height() > high){ high = rec.height(); }
	wid += rec.width();
	//screen->setStyleSheet(bgstyle);
	screen->show();
	screens << screen;
      /*}else{
        //Now move the mouse cursor over this window (fix for multi-monitor setups)
        QCursor::setPos( DE->screenGeometry(i).center() );	      
      }*/
    }
    this->setGeometry(0,0,wid,high);
    this->activateWindow();
    QCursor::setPos( DE->screenGeometry(0).center() );	  
}
int CalibrationDialog::update_screen_combo(void)//更新投影仪屏幕分辨率的选项
{
    //disable signals
    screen_combo->blockSignals(true);//禁止screen_combo接收信号

    //save current value
    int current = screen_combo->currentIndex();//得到现在所选的屏幕

    //update combo
    QStringList list;//存储的是显示器都有哪些可用,及其分辨率大小
    screen_combo->clear();
    QDesktopWidget * desktop = QApplication::desktop();
    int screens =  desktop->screenCount();//统计有多少个桌面,有多少个屏幕可用
    for (int i=0; i<screens; i++)
    {
        const QRect rect = desktop->screenGeometry(i);//屏幕几何大小(分辨率)
        list.append(QString("Screen %1 [%2x%3]").arg(i).arg(rect.width()).arg(rect.height()));//显示屏幕的分辨率Screen 0[1920*1080]
    }
    screen_combo->addItems(list);

    //set current value
    int saved_value = 1;
    int default_screen = (saved_value<screen_combo->count() ? saved_value : 0);//默认的选择屏幕号为0,否则为saved_value
    screen_combo->setCurrentIndex((-1<current && current<screen_combo->count() ? current : default_screen));//从所选的屏幕和默认的屏幕中决定是哪一个

    //enable signals
    screen_combo->blockSignals(false);

    return screen_combo->count();//返回屏幕的个数(总数)
}
Пример #8
0
ConfigureDialog::ConfigureDialog(QSettings *settings, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ConfigureDialog),
    mSettings(settings),
    mOldSettings(new RazorSettingsCache(settings))
{
    ui->setupUi(this);

    connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), this, SLOT(resetSettings()));

    // Position .................................
    ui->positionCbx->addItem(tr("Top edge of screen"), QVariant(ConfigureDialog::PositionTop));
    ui->positionCbx->addItem(tr("Center of screen"), QVariant(ConfigureDialog::PositionCenter));
    connect(ui->positionCbx, SIGNAL(currentIndexChanged(int)), this, SLOT(positionCbxChanged(int)));

    // Monitor ..................................
    QDesktopWidget *desktop = qApp->desktop();

    ui->monitorCbx->addItem(tr("Monitor where the mouse"), QVariant(0));

    int monCnt = desktop->screenCount();
    for (int i=0; i<monCnt; ++i)
    {
        ui->monitorCbx->addItem(tr("Always on %1 monitor").arg(i+1), QVariant(i+1));
    }
    ui->monitorCbx->setEnabled(monCnt > 1);
    connect(ui->monitorCbx, SIGNAL(currentIndexChanged(int)), this, SLOT(monitorCbxChanged(int)));


    // Shortcut .................................
    connect(ui->shortcutEd, SIGNAL(keySequenceChanged(QString)), this, SLOT(shortcutChanged(QString)));
    settingsChanged();
}
Пример #9
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);
	}
}
Пример #10
0
int main(int argc,char * argv[])
{
    QApplication app(argc,argv);

    QDesktopWidget * desktopWidget = QApplication::desktop();
    int screenNum = desktopWidget->screenCount();

    if (screenNum == 3)
    {
        QRect rect;
        int i;

        Dialog window0;
        Dialog window1(&window0);
        Dialog window2(&window1);

        qDebug()<<"window0 "<<window0.winId();
        qDebug()<<"window1 "<<window1.winId();
        qDebug()<<"window2 "<<window2.winId();

        for (i=0;i<screenNum;i++)
        {
            rect = desktopWidget->screenGeometry(i);
            qDebug()<<i<<" "<<rect;

            switch(rect.width())
            {
            case SCREEN0:
            {
                window0.move(rect.topLeft());
                window0.resize(rect.width(),rect.height());

                break;
            }
            case SCREEN1:
            {
                window1.move(rect.topLeft());
                window1.resize(rect.width(),rect.height());
                break;
            }
            case SCREEN2:
            {
                window2.move(rect.topLeft());
                window2.resize(rect.width(),rect.height());
                break;
            }
            }
        }

        window0.show();
        window1.show();
        window2.show();

        window2.startTimer();

        return app.exec();
    }
}
Пример #11
0
	cv::Rect* getSecondMonitorGeometry() {
		QDesktopWidget* desktop = QApplication::desktop();

		// Return last monitor geometry
		return getMonitorGeometryByIndex(desktop->screenCount()-1);

		// For replaying experiment videos, return false geometry for 1920x1080 monitor
		//return new cv::Rect(0, 0, 1280, 777);
	}
Пример #12
0
void ScreensModel::loadScreens()
{
    beginResetModel();
    m_screens.clear();
    QDesktopWidget *dw = QApplication::desktop();
    for (int i=0;i<dw->screenCount();i++) {
        m_screens.append(dw->screenGeometry(i));
    }
    endResetModel();
}
Пример #13
0
bool rect_on_screen(const QRect &rect)
{
    QDesktopWidget *desktop = qApp->desktop();
    for (int i = 0; i < desktop->screenCount(); i++) {
        if (desktop->availableGeometry(i).contains(rect))
            return true;
    }

    return false;
}
int main(int argc, char ** argv)
{
    //Setup any pre-QApplication initialization values
    LXDG::setEnvironmentVars();
    setenv("DESKTOP_SESSION","LUMINA",1);
    setenv("XDG_CURRENT_DESKTOP","LUMINA",1);
    //Check is this is the first run
    bool firstrun = false;
    if(!QFile::exists(logfile.fileName())){ firstrun = true; }
    //Setup the log file
    qDebug() << "Lumina Log File:" << logfile.fileName();
    if(logfile.exists()){ logfile.remove(); } //remove any old one
      //Make sure the parent directory exists
      if(!QFile::exists(QDir::homePath()+"/.lumina/logs")){
        QDir dir;
        dir.mkpath(QDir::homePath()+"/.lumina/logs");
      }
    logfile.open(QIODevice::WriteOnly | QIODevice::Append);
    //Startup the Application
    LSession a(argc, argv);
    //Setup Log File
    qInstallMsgHandler(MessageOutput);
    //Setup the QSettings
    QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, QDir::homePath()+"/.lumina/settings");
    qDebug() << "Initializing Lumina";
    //Start up the Window Manager
    qDebug() << " - Start Window Manager";
    WMProcess WM;
    WM.startWM();
    QObject::connect(&WM, SIGNAL(WMShutdown()), &a, SLOT(closeAllWindows()) );
    //Load the initial translations
    QTranslator translator;
    QLocale mylocale;
    QString langCode = mylocale.name();
    
    if ( ! QFile::exists(PREFIX + "/share/Lumina-DE/i18n/lumina-desktop_" + langCode + ".qm" ) )  langCode.truncate(langCode.indexOf("_"));
    translator.load( QString("lumina-desktop_") + langCode, PREFIX + "/share/Lumina-DE/i18n/" );
    a.installTranslator( &translator );
    qDebug() << "Locale:" << langCode;
    //Now start the desktop
    QDesktopWidget DW;
    QList<LDesktop*> screens;
    for(int i=0; i<DW.screenCount(); i++){
      qDebug() << " - Start Desktop " << i;
      screens << new LDesktop(i);
      a.processEvents();
    }
    qDebug() << " --exec";
    int retCode = a.exec();
    qDebug() << "Stopping the window manager";
    WM.stopWM();
    qDebug() << "Finished Closing Down Lumina";
    logfile.close();
    return retCode;
}
Пример #15
0
RazorDeskManager::RazorDeskManager(const QString & configId, RazorSettings * config)
    : DesktopPlugin(configId, config)
{
    m_launchMode = DesktopPlugin::launchModeFromString(config->value("icon-launch-mode").toString());

    config->beginGroup(configId);
    bool makeIcons = config->value("icons", false).toBool();
    //now we got the desktop we need to determine if the user wants a defined picture there
    QString finalPixmap = config->value("wallpaper", "").toString();
    config->endGroup();

    if (finalPixmap.isEmpty() || !QFile::exists(finalPixmap))
    {
        //now we want to use the system default - we still need to find that one out though
        finalPixmap = razorTheme.desktopBackground();
        qDebug() << "trying to get system-defaults" << finalPixmap;
    }

    if (! finalPixmap.isEmpty())
    {
        qDebug() << "Creating wallpaper";
        int width,height;
        QDesktopWidget * dw = QApplication::desktop();
        if (dw->screenCount() == 1)
        {
            width=dw->width();
            height = dw->height();
        }
        else
        {
            width=dw->screenGeometry(-1).width();
            height=dw->screenGeometry(-1).height();
        }

        QPixmap pixmap(finalPixmap);
        pixmap = pixmap.scaled(width,height);
        Pixmap p = pixmap.handle();
        XGrabServer(QX11Info::display());
        XChangeProperty(QX11Info::display(), QX11Info::appRootWindow(), XfitMan::atom("_XROOTPMAP_ID"), XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1);
        XChangeProperty(QX11Info::display(), QX11Info::appRootWindow(), XfitMan::atom("ESETROOT_PMAP_ID"), XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &p, 1);
        XSetCloseDownMode(QX11Info::display(), RetainPermanent);
        XSetWindowBackgroundPixmap(QX11Info::display(), QX11Info::appRootWindow(), p);
        XClearWindow(QX11Info::display(), QX11Info::appRootWindow());
        XUngrabServer(QX11Info::display());
        XFlush(QX11Info::display());
    }
    
    if (makeIcons)
    {
        deskicons = new RazorSettings("deskicons", this);    
        m_fsw = new QFileSystemWatcher(QStringList() << QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), this);
        connect(m_fsw, SIGNAL(directoryChanged(const QString&)), this, SLOT(updateIconList()));
        updateIconList();
    }
}
Пример #16
0
void tst_QSystemScreenSaver::tst_setScreenSaverInhibit()
{
    QSystemScreenSaver si;
    QDesktopWidget wid;
    bool enabled = si.setScreenSaverInhibit();
    if(wid.screenCount() > 0) {
        QVERIFY(enabled);
    } else{
        QVERIFY(!enabled);
    }
}
Пример #17
0
int main(int argc, char *argv[])
{
    QApplication::setAttribute(Qt::AA_UseOpenGLES,true);
    QApplication a(argc, argv);

    // MODEL
    SubteState * m_subte = new SubteState();
    // CONTROLLER DISPATCHER
    EventHandler *m_eventHandler = new EventHandler();

    // VIEWS
    BoardCenter * m_c = new BoardCenter(0);
    BoardAtp *m_a = new BoardAtp(0);
    BoardMac *m_m = new BoardMac(0,m_subte,m_eventHandler);
    BoardBottom *m_b = new BoardBottom(0);
    BoardHardware *m_h = new BoardHardware(0,m_subte,m_eventHandler);

    QTabWidget *m_tabs = new QTabWidget(0);
    m_tabs->addTab(m_h,QObject::tr("HARDWARE"));
    m_tabs->addTab(m_b,QObject::tr("BOTTOM"));
    m_tabs->setMinimumWidth(1024);
    m_tabs->setMinimumHeight(768);

    QDesktopWidget *desktop = a.desktop();
    if(desktop->screenCount() == 4){
        QRect s0 = desktop->screenGeometry(0);
        QRect s1 = desktop->screenGeometry(1);
        QRect s2 = desktop->screenGeometry(2);
        QRect s3 = desktop->screenGeometry(3);

        m_c->showFullScreen();
        m_a->showFullScreen();
        m_m->showFullScreen();
        m_tabs->showFullScreen();

        m_c->move(s0.topLeft());
        m_a->move(s2.topLeft());
        m_m->move(s3.topLeft());
        m_tabs->move(s1.topLeft());

    }else{
        m_c->showNormal();
        m_a->showNormal();
        m_m->showNormal();
        m_tabs->showNormal();
    }

    m_eventHandler->setModel(m_subte);
    m_subte->setHandler(m_eventHandler);
    m_eventHandler->initConnection(qApp->applicationDirPath());

    QObject::connect(m_eventHandler,SIGNAL(closeApp()),qApp,SLOT(quit()));
    return a.exec();
}
void MainWindow::getScreenGeometry()
{
    QDesktopWidget* desktopWidget = QApplication::desktop();
    int screencount = desktopWidget->screenCount();//get screen amount
    if(screencount == 1)
        QMessageBox::information(this,tr("Info"),tr("Only one screen detected."));
    else{
        QRect screenRect = desktopWidget->screenGeometry(0);
        screenWidth = screenRect.width();
        screenHeight = screenRect.height();
    }
}
Пример #19
0
void tst_QSystemScreenSaver::tst_setScreenSaverInhibited()
{
    QSystemScreenSaver si;
    QDesktopWidget wid;
    si.setScreenSaverInhibited(true);
    if(wid.screenCount() > 0) {
        QVERIFY(si.screenSaverInhibited());
    } else{
        QVERIFY(!si.screenSaverInhibited());
    }
    si.setScreenSaverInhibited(false);
    QVERIFY(!si.screenSaverInhibited());
}
// Return geometry of user's screen selection
bool screenSelectDialog::getFullscreenGeometry( QWidget* target, QRect& geom )
{
    // Determine number of screens
    QDesktopWidget* desktop = QApplication::desktop();
    int numScreens = desktop->screenCount();

    // If more than one screen, ask the user where to go fullscreen
    if( numScreens > 1 )
    {
        // construct the dialog
        screenSelectDialog* screenSelect = new screenSelectDialog( numScreens, target );

        // Get user's choice of screen
        if( screenSelect->exec() == QDialog::Rejected )
        {
            return false;
        }

        // Determine the geometry of the user's choice
        int screenId = screenSelect->getScreenNum();
        switch( screenId )
        {
            case screenSelectDialog::PRIMARY_SCREEN:
                geom = desktop->screenGeometry( desktop->primaryScreen() );
                break;

            case screenSelectDialog::THIS_SCREEN:
                geom = desktop->screenGeometry( target );
                break;

            case screenSelectDialog::ALL_SCREENS:
                geom = desktop->geometry();
                break;

            default:
                geom = desktop->screenGeometry( screenId );
                break;
        }
    }

    // If only one screen, just get it's geometry
    else
    {
        geom = desktop->screenGeometry( desktop->primaryScreen() );
    }

    // All done
    return true;
}
Пример #21
0
//! Pick a random place on the screen to move the dialog.  This is supposed to work on multiple monitors
//! but I've only been able to test it with two.
void PoppyUpper::moveItSomewhere()
{
  // get the desktop object so we can get geometry to figure out where this will land
  QDesktopWidget  *theDesktop = QApplication::desktop();

  // Pick from any number of screens!
  unsigned int screens = theDesktop->screenCount();
  unsigned int whichScreen = Randoid::getRand(0, screens - 1);  // screens start at zero

  const QRect screenGeometry = theDesktop->availableGeometry(whichScreen);
  const QRect dialogGeometry = this->geometry();

  bool positioned = false;

  //! Pick a random point on the screen
  QRect newRect;
  Randoid screenRandThingX(screenGeometry.topLeft().x(), screenGeometry.topRight().x());
  Randoid screenRandThingY(screenGeometry.topLeft().y(), screenGeometry.bottomLeft().y());

  //! \todo This loop can probably be eliminated and replaced with some calculation that would choose random coordinates
  //! such that the dialog doesn't get clipped by an edge of the screen
  do
    {
      // pick a point on the screen... this will be the top left point
      QPoint newLocation(screenRandThingX.getRand(),
                           screenRandThingY.getRand());

      qDebug() << "newLocation " << newLocation;

      // Now figure out the bottom right point for the new QRect
      QPoint bottomRight(newLocation.x() + dialogGeometry.width() - 1,
                         newLocation.y() + dialogGeometry.height() - 1);

      // Now create a QRect that represents the dialog at this position
      newRect = QRect(newLocation, bottomRight);

      qDebug() << "newRect " << newRect;

      // Now, if this new rectangle is completely contained within the screen geometry, we're done!
      positioned = screenGeometry.contains(newRect, true);

      // If not, we try again
    } while (!positioned);

  qDebug() << "Old location: " << dialogGeometry;
  qDebug() << "New location: " << newRect;

  setGeometry(newRect);
}
Пример #22
0
LayerManager::LayerManager(ItemDB *itemDb, QWidget *parent) :
    QDockWidget(parent),
    ui(new Ui::LayerManager),
    m_itemDb(itemDb),
    m_clipboardIndex()
{
    ui->setupUi(this);

    this->setStyleSheet(StylesheetProvider::getStylesheet("QTreeView,LayerManager"));

    QDesktopWidget desktopWidget;
    QRect rightScreenRect = desktopWidget.screenGeometry(desktopWidget.numScreens() -1);
    if (desktopWidget.screenCount() > 1) {
        this->resize(this->width(), rightScreenRect.height());
        this->move(rightScreenRect.topLeft());
    }

    ui->treeView_layer->setItemDelegate(new TreeViewItemDelegate(this));
    ui->treeView_layer->setModel(m_itemDb);
    ui->treeView_layer->setColumnWidth(1, 24);
    ui->treeView_layer->setColumnWidth(2, 24);
    ui->treeView_layer->setColumnWidth(3, 24);
    ui->treeView_layer->header()->setSectionResizeMode(0, QHeaderView::Stretch);
    ui->treeView_layer->header()->setSectionResizeMode(1, QHeaderView::Fixed);
    ui->treeView_layer->header()->setSectionResizeMode(2, QHeaderView::Fixed);
    ui->treeView_layer->header()->setSectionResizeMode(3, QHeaderView::Fixed);
    ui->treeView_layer->header()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
    ui->treeView_layer->header()->setSectionResizeMode(5, QHeaderView::ResizeToContents);
    ui->treeView_layer->header()->setSectionResizeMode(6, QHeaderView::ResizeToContents);
    ui->treeView_layer->header()->setSectionResizeMode(7, QHeaderView::ResizeToContents);

    m_menuNoItem = new QMenu(this);
    m_menuNoItem->addAction(tr("New layer"), this, SLOT(slot_appendNewLayer()));

    m_menuOnItem = new QMenu(this);
    m_menuOnItem->addAction(tr("Edit name"), this, SLOT(slot_editLayerName()));
    m_menuOnItem->addAction(tr("Edit line width"), this, SLOT(slot_editLayerLineWidth()));
    m_menuOnItem->addAction(tr("Edit line type"), this, SLOT(slot_editLayerLineType()));
    m_menuOnItem->addSeparator();
    m_menuOnItem->addAction(tr("Append new Layer"), this, SLOT(slot_appendNewLayer()));
    m_menuOnItem->addAction(tr("Append new Layer as child"), this, SLOT(slot_appendNewLayerAsChild()));
    m_menuOnItem->addAction(tr("Delete layer"), this, SLOT(slot_deleteLayer()));
    m_menuOnItem->addSeparator();
    m_actionCut = m_menuOnItem->addAction(tr("Cut"), this, SLOT(slot_cutLayer()));
    m_actionPasteHere = m_menuOnItem->addAction(tr("Paste here"), this, SLOT(slot_pasteLayerHere()));
    m_actionPasteAsChild = m_menuOnItem->addAction(tr("Paste as child"), this, SLOT(slot_pasteLayerAsChild()));
    m_actionPasteHere->setDisabled(true);
    m_actionPasteAsChild->setDisabled(true);
}
Пример #23
0
    QPixmap ScreenShooter::captureScreen(int screenIndex)
    {
        QDesktopWidget *desktop = QApplication::desktop();

        if(screenIndex < 0 || screenIndex >= desktop->screenCount())
            return QPixmap();

        const QRect &screenGeometry = desktop->screenGeometry(screenIndex);

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
        return QGuiApplication::primaryScreen()->grabWindow(0, screenGeometry.x(), screenGeometry.y(), screenGeometry.width(), screenGeometry.height());
#else
        return QPixmap::grabWindow(desktop->winId(), screenGeometry.x(), screenGeometry.y(), screenGeometry.width(), screenGeometry.height());
#endif
    }
Пример #24
0
void tst_QSystemDisplayInfo::tst_colorDepth()
{
    QSystemDisplayInfo di;
    int depth = di.colorDepth(0);
    QDesktopWidget wid;
    if(wid.screenCount() > 1) {
        QVERIFY(depth == 0
                || depth == 8
                || depth == 16
                || depth == 24
                || depth == 32
                || depth == 64);
        }
    QVERIFY(di.colorDepth(999) == -1);
}
Пример #25
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);
}
Пример #26
0
/*! \mainpage X11 Info for Razor-qt.
 * This tool allows to gather various useful X11/screen information.
 * Sometimes it would be useful to attach output of this command line
 * application to the bugreport.
 *
 * \note This program is not useful for end-users. It's a helper
 *       for Razor development.
 */
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    qDebug() << "Razor-qt (" << RAZOR_VERSION << ") environment summary\n";

#ifdef Q_WS_X11
    // collect QX11
    qDebug() << "* X11 Information";
    QX11Info x11;
    qDebug() << "X11 display:\t\t" << x11.display();
    qDebug() << "X11 colormap:\t\t" << x11.colormap();
    qDebug() << "X11 depth:\t\t" << x11.depth();
    qDebug() << "X11 composite:\t\t" << x11.isCompositingManagerRunning();
    qDebug() << "X11 ScreenCount:\t" << ScreenCount(QX11Info::display());
    qDebug() << "";
#endif

    qDebug() << "* QDesktopWidget Information";
    QDesktopWidget *dw = QApplication::desktop();
    qDebug() << "QD virtual desktop:\t" << dw->isVirtualDesktop();
    qDebug() << "QD primary screen:\t" << dw->primaryScreen();
    qDebug() << "QD screen count:\t" << dw->screenCount();
    qDebug() << "** QD screens";
    for (int i = 0; i < dw->screenCount(); ++i)
    {
        qDebug() << "\tScreen" << i << "availableGeometry:\t" << dw->availableGeometry(i);
        qDebug() << "\tScreen" << i << "screenGeometry:\t" << dw->screenGeometry(i);
        qDebug() << "";
    }
    
    qDebug() << "* XfitMan information";
    qDebug() << "getActiveDesktop:\t" << xfitMan().getActiveDesktop();
    qDebug() << "getNumDesktop:\t" << xfitMan().getNumDesktop();

    return 0;
}
Пример #27
0
void tst_QDeclarativeDisplayInfo::tst_colorDepth()
{
    QDeclarativeDisplayInfo di;
    int depth = di.colorDepth();
    QDesktopWidget wid;
    if(wid.screenCount() > 1) {
        QVERIFY(depth == 0
                || depth == 8
                || depth == 16
                || depth == 24
                || depth == 32
                || depth == 64);
        }
    di.setCurrentScreen(999);
    QVERIFY(di.colorDepth() == -1);
}
Пример #28
0
// =======================
//             PRIVATE
// =======================
void TermWindow::CalculateGeom() {
    QDesktopWidget *desk = QApplication::desktop();
    if(desk->screenCount() <= screennum) {
        screennum = desk->primaryScreen();    //invalid screen detected
    }
    //Now align the window with the proper screen edge
    QRect workarea = desk->availableGeometry(screennum); //this respects the WORKAREA property
    if(onTop) {
        this->setGeometry( workarea.x(), workarea.y(), workarea.width(), this->height()); //maintain current hight of window

    } else {
        this->setGeometry( workarea.x(), workarea.y() + workarea.height() - this->height(), workarea.width(), this->height()); //maintain current hight of window
    }
    this->setFixedWidth(this->width()); //Make sure the window is not re-sizeable in the width dimension
    this->setMinimumHeight(0);
}
Пример #29
0
    QList< QPair<QPixmap, QRect> > ScreenShooter::captureScreens()
    {
        QDesktopWidget *desktop = QApplication::desktop();
        QList< QPair<QPixmap, QRect> > result;

        for(int screenIndex = 0; screenIndex < desktop->screenCount(); ++screenIndex)
        {
            const QRect &screenGeometry = desktop->screenGeometry(screenIndex);

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
            result.append(qMakePair(QGuiApplication::primaryScreen()->grabWindow(0, screenGeometry.x(), screenGeometry.y(), screenGeometry.width(), screenGeometry.height()), screenGeometry));
#else
            result.append(qMakePair(QPixmap::grabWindow(desktop->winId(), screenGeometry.x(), screenGeometry.y(), screenGeometry.width(), screenGeometry.height()), screenGeometry));
#endif
        }

        return result;
    }
int checkBugfixYOffsetForMac()
{
    QDesktopWidget DeskWidget;
    int nPrimary = DeskWidget.primaryScreen();
    QRect rcPrimaryMon = DeskWidget.screenGeometry( nPrimary );
    int nShiftY = rcPrimaryMon.height();
    for( int i=0; i<DeskWidget.screenCount(); i++ )
    {
        if( nPrimary == i ) continue;
        if( nShiftY < DeskWidget.screenGeometry(i).height() )
            nShiftY = DeskWidget.screenGeometry(i).height();
    }
    nShiftY -= rcPrimaryMon.height();
    if( nShiftY < 0 )
        nShiftY = 0;

    return nShiftY;
}