Example #1
0
void QtToaster::changeToasterPosition() {
	QDesktopWidget * desktop = QApplication::desktop();
	QPoint p = _toaster->pos();

	//Toaster is showing slowly
	if (_show) {
		_toaster->move(p.x(), p.y() - 3);

		QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen());

		if (p.y() < (desktopGeometry.bottom() - _toaster->size().height() - 5)) {
			//Toaster should be hidden now
			_show = false;
			_timer->stop();
			//Waits 5 seconds with the toaster on top
			_timer->start(_timeOnTop);
		}
	}

	//Toaster is hiding slowly
	else {
		_toaster->move(p.x(), p.y() + 3);
		_toaster->repaint();
		QRect screenGeometry = desktop->screenGeometry(desktop->primaryScreen());

		_timer->stop();
		_timer->start(TIME_TO_SHOW);

		if (p.y() > (screenGeometry.bottom())) {
			//Closes the toaster -> hide it completely
			close();
		}
	}
}
// 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;
}
SCConfigurePresenterViewDialog::SCConfigurePresenterViewDialog(SCDocument *document, QWidget *parent)
    : KDialog(parent)
    , m_document(document)
{
    QWidget *widget = new QWidget(this);

    ui.setupUi(widget);

    QDesktopWidget desktop;
    int numScreens = desktop.numScreens();
    int primaryScreen = desktop.primaryScreen();
    for (int i = 0; i < numScreens; i++) {
        if (i == primaryScreen) {
            ui.monitorComboBox->addItem(i18n("Monitor %1 (primary)", i + 1));
        }
        else {
            ui.monitorComboBox->addItem(i18n("Monitor %1", i + 1));
        }
    }

    if (numScreens <= 1)
        ui.presenterViewCheckBox->setEnabled(false);

    setMainWidget(widget);

    setCaption(i18n("Configure Presenter View"));

    ui.monitorComboBox->setCurrentIndex(document->presentationMonitor());
    ui.presenterViewCheckBox->setChecked(
            document->isPresenterViewEnabled() ? Qt::Checked : Qt::Unchecked);
}
Example #4
0
VideoOutWindow::VideoOutWindow() :
    // DB settings
    db_move(0, 0), db_scale_horiz(0.0f), db_scale_vert(0.0f),
    db_pip_size(26),
    db_scaling_allowed(true),

    using_xinerama(false), screen_num(0), screen_geom(0, 0, 1024, 768),

    // Manual Zoom
    mz_scale_v(1.0f), mz_scale_h(1.0f), mz_move(0, 0),

    // Physical dimensions
    display_dim(400, 300), display_aspect(1.3333f),

    // Video dimensions
    video_dim(640, 480),     video_disp_dim(640, 480),
    video_dim_act(640, 480), video_aspect(1.3333f),

    // Aspect override
    overriden_video_aspect(1.3333f), aspectoverride(kAspect_Off),

    // Adjust Fill
    adjustfill(kAdjustFill_Off),

    // Screen settings
    video_rect(0, 0, 0, 0),
    display_video_rect(0, 0, 0, 0),
    display_visible_rect(0, 0, 0, 0),
    tmp_display_visible_rect(0, 0, 0, 0),

    // Various state variables
    embedding(false), needrepaint(false),
    allowpreviewepg(true), pip_state(kPIPOff)
{
    db_pip_size = gCoreContext->GetNumSetting("PIPSize", 26);

    db_move = QPoint(gCoreContext->GetNumSetting("xScanDisplacement", 0),
                     gCoreContext->GetNumSetting("yScanDisplacement", 0));
    db_use_gui_size = gCoreContext->GetNumSetting("GuiSizeForTV", 0);

    QDesktopWidget *desktop = NULL;
    if (QApplication::type() == QApplication::GuiClient)
        desktop = QApplication::desktop();

    if (desktop)
    {
        screen_num = desktop->primaryScreen();
        using_xinerama  = (GetNumberXineramaScreens() > 1);
        if (using_xinerama)
        {
            screen_num = gCoreContext->GetNumSetting("XineramaScreen", screen_num);
            if (screen_num >= desktop->numScreens())
                screen_num = 0;
        }

        screen_geom = desktop->geometry();
        if (screen_num >= 0)
            screen_geom = desktop->screenGeometry(screen_num);
    }
}
Example #5
0
bool Worker::setImage(QString &path)
{
    QImage source(path), dest;
    if (source.isNull())
        return false;

    QDesktopWidget *desktop = QApplication::desktop();
    QRect geo = desktop->screenGeometry(desktop->primaryScreen());
    int lw = geo.width();
    int lh = geo.height();
    float iw = source.width();
    float ih = source.height();

    if ((iw <= lw) && (ih <= lh))
        dest = source;
    else
        if ((iw / lw) > (ih / lh))
            dest = source.scaledToWidth(lw, Qt::SmoothTransformation);
        else
            dest = source.scaledToHeight(lh, Qt::SmoothTransformation);

    setPixmap(QPixmap::fromImage(dest));

    return true;
}
void QModernProgressDialog::createWidgets() {
    setWindowTitle(tr("Progress"));
    setWindowIcon(QIcon());
    m_wasCancel=false;
    label=new QLabel(this);
    longmessage=new QTextEdit(this);
    longmessage->setVisible(false);
    progress=new QModernProgressWidget(this);
    progress->setMinimumSize(QSize(48,48));
    cancel=new QPushButton(tr("Cancel"), this);
    connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));

    QVBoxLayout* vbl=new QVBoxLayout;
    setLayout(vbl);
    QHBoxLayout* hbl=new QHBoxLayout;
    hbl->addWidget(progress);
    hbl->addWidget(label);
    hbl->addStretch();
    vbl->addLayout(hbl);
    vbl->addWidget(longmessage);
    hbl=new QHBoxLayout;
    hbl->addStretch();
    hbl->addWidget(cancel);
    vbl->addLayout(hbl);
    connect(&timerDelay, SIGNAL(timeout()), this, SLOT(open()));

    QDesktopWidget desktopWidget;
    QRect desktopRect(desktopWidget.availableGeometry(desktopWidget.primaryScreen()));
    QRect widgetRect=rect();
    move(desktopRect.center() - widgetRect.center());
}
int QtWidgetsTweakletImpl::GetPrimaryScreenNumber()
{
  QDesktopWidget *desktop = QApplication::desktop();
  // get the primary screen
  int primaryScreenNr = desktop->primaryScreen();
  return primaryScreenNr;
}
Example #8
0
ObjKsTheme::ObjKsTheme( const QString& theme )
  :mActiveTheme (theme), mThemeDir("/"), mThemeConfig (0L), mThemePrefix( "Themes/" ), d(0)
{
  // Get Xinerama config.
  KConfig *config = kapp->config();
  config->setGroup( "Xinerama" );
  QDesktopWidget *desktop = kapp->desktop();
  mXineramaScreen = config->readNumEntry("KSplashScreen", desktop->primaryScreen());

  // For Xinerama, let's put the mouse on the first head.  Otherwise it could appear anywhere!
  if (desktop->isVirtualDesktop() && mXineramaScreen != -2)
  {
    QRect rect = desktop->screenGeometry( mXineramaScreen );
    if (!rect.contains(QCursor::pos()))
      QCursor::setPos(rect.center());
  }

  // Does the active theme exist?
  if( !loadThemeRc( mActiveTheme, false ) )
    if( !loadLocalConfig( mActiveTheme, false ) )
      if( !loadThemeRc( "Default", false ) )
        loadLocalConfig( "Default", true ); //force: we need some defaults
  loadCmdLineArgs(KCmdLineArgs::parsedArgs());
  mThemePrefix += ( mActiveTheme + "/" );
}
DBoxFE_ProfileWizard::DBoxFE_ProfileWizard( QDialog *parent, Qt::WFlags flags )
    : QDialog( parent, flags ) {

  // setup grafical user interface (gui)
  setupUi( this );

  page = 0;

  // for download game database file
  m_http = new QHttp( this );
  connect( m_http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( httpRequestFinished( int, bool ) ) );
  connect( m_http, SIGNAL( responseHeaderReceived( const QHttpResponseHeader & ) ), this, SLOT( readResponseHeader( const QHttpResponseHeader & ) ) );

  // connection
  connect( btnBack, SIGNAL( clicked() ), this, SLOT( slotBack() ) );
  connect( btnNext, SIGNAL( clicked() ), this, SLOT( slotNext() ) );
  connect( btnNext, SIGNAL( clicked() ), this, SLOT( slotFinish() ) );

  connect( btnHelp, SIGNAL( clicked() ), this, SLOT( slotHelp() ) );
  connect( btnAbort, SIGNAL( clicked() ), this, SLOT( slotAbort() ) );
  connect( btnSelectDir, SIGNAL( clicked() ), this, SLOT( slotSelectDir() ) );
  connect( btnSearch, SIGNAL( clicked() ), this, SLOT( slotSearch() ) );

  // enable button
  btnNext->setEnabled( true );

  // center the wiget on desktop screen
  QDesktopWidget *desktop = qApp->desktop();
  const QRect rect = desktop->availableGeometry( desktop->primaryScreen() );
  int left = ( rect.width() - width() ) / 2;
  int top = ( rect.height() - height() ) / 2;
  setGeometry( left, top, width(), height() );

  downloadFile();
}
Example #10
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;
}
GameDosBoxDialog::GameDosBoxDialog( QDialog *parent, Qt::WFlags flags ) : QDialog( parent, flags )
{
	setupUi( this );

	gd_sql = new GameDatabaseSql( this );

	XMLPreferences xmlPreferences( "DBoxFE - GDB", "Alexander Saal" );
	xmlPreferences.load( QDir::homePath() + "/.dboxfe-gdb/dboxfegdb.xml" );

	database = xmlPreferences.getString( "Database", "DatabaseFile" );	

	gd_sql->createConnection( database );

	connect( btnAccept, SIGNAL ( clicked() ), this, SLOT ( select() ) );
	connect( btnCancel, SIGNAL ( clicked() ), this, SLOT ( cancel() ) );

	connect( lineEditSearch, SIGNAL( textChanged( const QString & ) ), this, SLOT( lineEditSearchTextChanged( const QString & ) ) );
	connect( comboBoxDosboxVersion, SIGNAL ( currentIndexChanged( const QString & ) ), this, SLOT ( comboBoxDosboxVersionCurrentIndexChanged( const QString & ) ) );
	connect( treeWidgetDosboxGames, SIGNAL ( itemClicked( QTreeWidgetItem *, int ) ), this, SLOT ( treeWidgetDosboxGamesItemClicked( QTreeWidgetItem *, int ) ) );

	QDesktopWidget *desktop = qApp->desktop();
	const QRect rect = desktop->availableGeometry ( desktop->primaryScreen() );
	int left = ( rect.width() - width() ) / 2;
	int top = ( rect.height() - height() ) / 2;
	setGeometry ( left, top, width(), height() );

	getDosboxVersion();
}
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);
}
Example #13
0
MainWindow::MainWindow(const std::string& title) : _viewStack(0),
	_updatePending(false)
{
	setContentsMargins(4,4,4,4) ;

	_viewStack = new ViewStack(this);

	//limit the MainWindow size to approximatly the size of the desktop
	QDesktopWidget* desktop = QApplication::desktop() ;
	QRect rect = desktop->availableGeometry(desktop->primaryScreen()) ;
	_viewStack->setMaximumSize(rect.size()- QSize(40,60)) ;

	this->setCentralWidget(_viewStack);
	this->setWindowTitle("ArgosDisplay : " + QString::fromStdString(title));
	QLabel* dimBar = new QLabel(this) ;
	dimBar->setText("0 x 0 x 0 x 0 x 0 | 100%") ;
	this->statusBar()->addPermanentWidget(dimBar, 0 ) ;
	QObject::connect(
			_viewStack, SIGNAL(exportStatusMessage(QString)),
			this->statusBar(),SLOT(showMessage(QString)));
	QObject::connect(
			_viewStack, SIGNAL(exportDimensionsMessage(QString)),
			dimBar, SLOT(setText(QString))) ;
	QObject::connect(this, SIGNAL(dockWidgetAdded()), this, SLOT(_addDockWidgets()), Qt::QueuedConnection) ;
	QObject::connect(this, SIGNAL(overlayWidgetAdded()), this, SLOT(_addOverlayWidgets()), Qt::QueuedConnection) ;

	_createMenus() ;
}
GrabResolutions MediaSourceDesktop::GetSupportedVideoGrabResolutions()
{
    VideoFormatDescriptor tFormat;

    mSupportedVideoFormats.clear();

    tFormat.Name="CIF";        //      352 × 288
    tFormat.ResX = 352;
    tFormat.ResY = 288;
    mSupportedVideoFormats.push_back(tFormat);

    tFormat.Name="VGA";       //      640 * 480
    tFormat.ResX = 640;
    tFormat.ResY = 480;
    mSupportedVideoFormats.push_back(tFormat);

    tFormat.Name="DVD";        //      720 × 576
    tFormat.ResX = 720;
    tFormat.ResY = 576;
    mSupportedVideoFormats.push_back(tFormat);

    tFormat.Name="CIF9";       //     1056 × 864
    tFormat.ResX = 1056;
    tFormat.ResY = 864;
    mSupportedVideoFormats.push_back(tFormat);

    tFormat.Name="SXGA";       //     1280 × 1024
    tFormat.ResX = 1280;
    tFormat.ResY = 1024;
    mSupportedVideoFormats.push_back(tFormat);

    tFormat.Name="WXGA+";      //     1440 × 900
    tFormat.ResX = 1440;
    tFormat.ResY = 900;
    mSupportedVideoFormats.push_back(tFormat);

    tFormat.Name="SXGA+";       //     1440 × 1050
    tFormat.ResX = 1440;
    tFormat.ResY = 1050;
    mSupportedVideoFormats.push_back(tFormat);

    tFormat.Name="WUXGA";       //     1920 * 1200
    tFormat.ResX = 1920;
    tFormat.ResY = 1200;
    mSupportedVideoFormats.push_back(tFormat);

    QDesktopWidget *tDesktop = QApplication::desktop();
    tFormat.Name="Desktop";
    tFormat.ResX = tDesktop->screenGeometry(tDesktop->primaryScreen()).width();
    tFormat.ResY = tDesktop->screenGeometry(tDesktop->primaryScreen()).height();
    mSupportedVideoFormats.push_back(tFormat);

    tFormat.Name="Segment";
    tFormat.ResX = mSourceResX;
    tFormat.ResY = mSourceResY;
    mSupportedVideoFormats.push_back(tFormat);

    return mSupportedVideoFormats;
}
Example #15
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();
}
PresenterConfiguration::PresenterConfiguration(IEventBus * bus) {
	QDesktopWidget * desktopWidget = QApplication::desktop();
	this->mainScreen = desktopWidget->primaryScreen();
	this->auxScreen = desktopWidget->primaryScreen();

	for (int i = 0 ; i < desktopWidget->numScreens() ; i++) {
		if (i != this->mainScreen) {
			this->auxScreen = i;
			break;
		}
	}

	this->parser = NULL;
	this->document = NULL;
	this->renderer = NULL;
	this->bus = bus;
}
void SliderWindow::initializePosition() {
	
	QDesktopWidget desktopWidget;
	QRect availableGeometry = desktopWidget.availableGeometry(desktopWidget.primaryScreen());
	
	m_d->left = availableGeometry.width() - sliderRightOffset - sliderWidth;
	m_d->bottom = availableGeometry.height() - m_d->index * sliderHeight;
}
DashboardWindow::DashboardWindow() {
    ui.setupUi(this);
	
	//set size to 70% of total screen size
    QDesktopWidget dw;
    QRect mainScreen = dw.availableGeometry(dw.primaryScreen());
    this->resize(mainScreen.width()*0.7, mainScreen.height()*0.7);
}
Example #19
0
void QKineticScroller::setDpiFromWidget(QWidget *widget)
{
    Q_D(QKineticScroller);

    QDesktopWidget *dw = QApplication::desktop();
    QPointF dpi = d->realDpi(widget ? dw->screenNumber(widget) : dw->primaryScreen());
    setDpi((dpi.x() + dpi.y()) / qreal(2));
}
Example #20
0
void MainWindow::moveToCenter()
{
    QDesktopWidget desktop;
    QRect rect = desktop.availableGeometry(desktop.primaryScreen()); // прямоугольник с размерами экрана
    QPoint center = rect.center(); //координаты центра экрана
    center.setX(center.x() - (this->width()/2));  // учитываем половину ширины окна
    center.setY(center.y() - (this->height()/2));  // .. половину высоты
    move(center);
}
Example #21
0
void MockupEyetracker::generateNewPointFromCursorPos()
{
    const QDesktopWidget widget;
    const QRect mainScreenSize = widget.screenGeometry(widget.primaryScreen());
    const QPoint mousePos = QCursor::pos();
    const QPointF pos(qreal(mousePos.x()) / qreal(mainScreenSize.width()),
                      qreal(mousePos.y()) / qreal(mainScreenSize.height()));
    emitNewPoint(cv::Point2d(pos.x(), pos.y()));
}
int SecondaryViewLayoutWindow::findSmallestSecondaryScreen()
{
	QDesktopWidget* desktop = QApplication::desktop();

	int best = 0;
	for (int i=1; i<desktop->screenCount(); ++i)
	{
		if (desktop->primaryScreen()==i)
			continue;
		QRect last = desktop->screenGeometry(best);
		QRect current = desktop->screenGeometry(i);
		if (current.height()*current.width() < last.height()*last.width())
			best = i;
		if (desktop->primaryScreen()==best)
			best = i;
	}

	return best;
}
QPair<QRect, bool> BubbleManager::screensInfo(const QPoint &point) const
{
    QDesktopWidget *desktop = QApplication::desktop();
    int pointScreen = desktop->screenNumber(point);
    int primaryScreen = desktop->primaryScreen();

    QRect rect = desktop->screenGeometry(pointScreen);

    return QPair<QRect, bool>(rect, (pointScreen == primaryScreen));
}
Example #24
0
Window::Window () : QMainWindow (NULL) {
    try {
        viewer = new GLViewer;
    } catch (GLViewer::Exception e) {
        cerr << e.getMessage () << endl;
        exit (1);
    }
    setCentralWidget (viewer);

#if DEBUG
    cout << "/ ! \\ Building in Debug mode. Performance will be impacted" << endl;
#else
    viewer->setBaseSize(500, 500);
#endif
    
    initControlWidget ();
    
    QDockWidget * controlDockWidget = new QDockWidget (this);
    
    controlDockWidget->setWidget (controlWidget);
    controlDockWidget->adjustSize ();
    addDockWidget (Qt::RightDockWidgetArea, controlDockWidget);
    controlDockWidget->setFloating(true);
    controlDockWidget->setFeatures (QDockWidget::AllDockWidgetFeatures);
    controlDockWidget->adjustSize();
    controlDockWidget->move(0, 0);
    
    QDockWidget * focalDockWidget = new QDockWidget (this);
    focalDockWidget->setWidget(focalWidget);
    focalDockWidget->adjustSize ();
    addDockWidget (Qt::LeftDockWidgetArea, focalDockWidget);
    focalDockWidget->setFloating(true);
    focalDockWidget->setFeatures (QDockWidget::AllDockWidgetFeatures);
    focalDockWidget->adjustSize();
    focalDockWidget->move(200, 0);

    QDockWidget* rayTracerDockWidget = new QDockWidget(this);
    rayTracerDockWidget->setWidget(rayTracerWidget);
    rayTracerDockWidget->adjustSize ();
    addDockWidget (Qt::TopDockWidgetArea, rayTracerDockWidget);
    rayTracerDockWidget->setFloating(true);
    rayTracerDockWidget->setFeatures (QDockWidget::AllDockWidgetFeatures);
    rayTracerDockWidget->adjustSize();

    // Move widgets around the raytracer
    
    QDesktopWidget desktop;
    QRect mainScreenSize = desktop.availableGeometry(desktop.primaryScreen());
    
    controlDockWidget->move(mainScreenSize.width() - 200, 0);
    rayTracerDockWidget->move(0, 0);
    focalDockWidget->move(0, mainScreenSize.height() - focalDockWidget->height());
    
    statusBar()->showMessage("");
}
    ImageRectificator::ImageRectificator(int maxSelectedPixels)
    {
		m_maxSelectedPixels = maxSelectedPixels;
		
        QLabel* projectedImageSubtitle = new QLabel();
        projectedImageSubtitle->setText("Projected image");

        // TODO: eliminate these magic constants.
        QDir::setCurrent(QCoreApplication::applicationDirPath());
        const QString& iconFileName = tr("../../src/images/icon.png");
        projectedImageLabel = new ClickableLabel(m_maxSelectedPixels, iconFileName);
        projectedImageLabel->setBackgroundRole(QPalette::Base);
        projectedImageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
        projectedImageLabel->setScaledContents(true);

        projectedScroll = new QScrollArea;
        projectedScroll->setBackgroundRole(QPalette::Dark);
        projectedScroll->setAlignment(Qt::AlignCenter);
        projectedScroll->setWidget(projectedImageLabel);

        QLabel* rectifiedImageSubtitle = new QLabel();
        rectifiedImageSubtitle->setText("Rectified image");

        rectifiedImageLabel = new QLabel;
        rectifiedImageLabel->setBackgroundRole(QPalette::Base);
        rectifiedImageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
        rectifiedImageLabel->setScaledContents(true);

        rectifiedScroll = new QScrollArea;
        rectifiedScroll->setBackgroundRole(QPalette::Dark);
        rectifiedScroll->setWidget(rectifiedImageLabel);
        rectifiedScroll->setAlignment(Qt::AlignCenter);

        QGridLayout *imagesLayout = new QGridLayout();

        imagesLayout->addWidget(projectedImageSubtitle, 0, 0);
        imagesLayout->addWidget(projectedScroll, 1, 0);
        imagesLayout->addWidget(rectifiedImageSubtitle, 2, 0);
        imagesLayout->addWidget(rectifiedScroll, 3, 0);

        QWidget *window = new QWidget();
        window->setLayout(imagesLayout);

        setCentralWidget(window);

        createActions();
        createMenus();

        setWindowTitle(tr("Image Rectificator"));

        QDesktopWidget desktop;
        QRect res = desktop.availableGeometry(desktop.primaryScreen());
        resize(res.width(), res.height());
    }
Example #26
0
inline void move_to_center(QWidget *w)
{
    QDesktopWidget *dw = QApplication::desktop();
    QRect parent_rect = dw->availableGeometry(dw->primaryScreen());

    if (w->parentWidget()) {
        parent_rect = w->parentWidget()->geometry();
    }

    w->move(parent_rect.center() - w->rect().center());
}
Example #27
0
RenderArea::RenderArea(QWidget *parent)
            : QWidget(parent), ui(new Ui::RenderArea)
{
    ui->setupUi(this);
    QDesktopWidget desktop; // Get the resolution od the main screen
    this->xRes = desktop.availableGeometry(desktop.primaryScreen()).width();
    this->yRes = desktop.availableGeometry(desktop.primaryScreen()).height();
    img = QImage(this->xRes, this->yRes, QImage::Format_ARGB32);
    fraktal = new Fraktal_Manager(xRes, yRes);
    currentFraktal = Mandelbrot;
    setEnabled(true);   // Must be enabled to recieve mouse wheel event
}
void GLWidget::resizeGL(int width, int height){
  QDesktopWidget widget;
  QRect screenDimension = widget.availableGeometry(widget.primaryScreen());
  //height = screenDimension.height();
  //width = screenDimension.width();

  SettingsManager::Instance()->SetFrameWidth(width);
  SettingsManager::Instance()->SetFrameHeight(height);
  int side = qMin(width, height);
  glViewport(0,0,width,height);
  //glViewport((width - side) / 2, (height - side) / 2, side, side);
}
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();
}
Example #30
0
void tst_QDesktopWidget::availableGeometry()
{
    QDesktopWidget desktop;
    QTest::ignoreMessage(QtWarningMsg, "QDesktopWidget::availableGeometry(): Attempt "
                                       "to get the available geometry of a null widget");
    desktop.availableGeometry((QWidget *)0);

    QRect total;
    QRect available;

    for (int i = 0; i < desktop.screenCount(); ++i) {
        total = desktop.screenGeometry(i);
        available = desktop.availableGeometry(i);
        QVERIFY(total.contains(available));
    }

    total = desktop.screenGeometry();
    available = desktop.availableGeometry();
    QVERIFY(total.contains(available));
    QCOMPARE(desktop.availableGeometry(desktop.primaryScreen()), available);
    QCOMPARE(desktop.screenGeometry(desktop.primaryScreen()), total);
}