/*! \reimp */
QString Q3AccessibleTitleBar::text(Text t, int child) const
{
    QString str = QAccessibleWidget::text(t, child);
    if (str.size())
        return str;

    QWidget *window = titleBar()->window();
    switch (t) {
    case Name:
        switch (child) {
        case 1:
            return Q3TitleBar::tr("System");
        case 3:
            if (window && window->isMinimized())
                return Q3TitleBar::tr("Restore up");
            return Q3TitleBar::tr("Minimize");
        case 4:
            if (window && window->isMaximized())
                return Q3TitleBar::tr("Restore down");
            return Q3TitleBar::tr("Maximize");
        case 5:
            return Q3TitleBar::tr("Close");
        default:
            break;
        }
        break;
    case Value:
        if (!child || child == 2)
            return window ? window->windowTitle() : QString();
        break;
/*
    case DefaultAction:
        if (child > 2)
            return Q3TitleBar::tr("Press");
        break;
*/
    case Description:
        switch (child) {
        case 1:
            return Q3TitleBar::tr("Contains commands to manipulate the window");
        case 3:
            if (window && window->isMinimized())
                return Q3TitleBar::tr("Puts a minimized window back to normal");
            return Q3TitleBar::tr("Moves the window out of the way");
        case 4:
            if (window && window->isMaximized())
                return Q3TitleBar::tr("Puts a maximized window back to normal");
            return Q3TitleBar::tr("Makes the window full screen");
        case 5:
            return Q3TitleBar::tr("Closes the window");
        default:
            return Q3TitleBar::tr("Displays the name of the window and contains controls to manipulate it");
        }
    default:
        break;
    }
    return str;
}
Example #2
0
void bringToFront(QWidget *widget, bool)
{
	Q_ASSERT(widget);
	QWidget* w = widget->window();

#ifdef Q_WS_X11
	// If we're not on the current desktop, do the hide/show trick
	long dsk, curr_dsk;
	Window win = w->winId();
	if(desktopOfWindow(&win, &dsk) && currentDesktop(&curr_dsk)) {
		if((dsk != curr_dsk) && (dsk != -1)) {  // second condition for sticky windows
			w->hide();
		}
	}

	// FIXME: multi-desktop hacks for Win and Mac required
#endif

	if(w->isMaximized())
		w->showMaximized();
	else
		w->showNormal();

	//if(grabFocus)
	//	w->setActiveWindow();
	w->raise();
	w->activateWindow();

#ifdef Q_WS_WIN
	// TODO: unify with AdvancedWidget::bringToFront()
	ForceForegroundWindow(w->winId());
#endif
}
Example #3
0
void UIMachineViewNormal::normalizeGeometry(bool bAdjustPosition)
{
#ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1
    QWidget *pTopLevelWidget = window();

    /* Make no normalizeGeometry in case we are in manual resize mode or main window is maximized: */
    if (pTopLevelWidget->isMaximized())
        return;

    /* Calculate client window offsets: */
    QRect frameGeo = pTopLevelWidget->frameGeometry();
    QRect geo = pTopLevelWidget->geometry();
    int dl = geo.left() - frameGeo.left();
    int dt = geo.top() - frameGeo.top();
    int dr = frameGeo.right() - geo.right();
    int db = frameGeo.bottom() - geo.bottom();

    /* Get the best size w/o scroll bars: */
    QSize s = pTopLevelWidget->sizeHint();

    /* Resize the frame to fit the contents: */
    s -= pTopLevelWidget->size();
    frameGeo.setRight(frameGeo.right() + s.width());
    frameGeo.setBottom(frameGeo.bottom() + s.height());

    if (bAdjustPosition)
    {
        QRegion availableGeo;
        QDesktopWidget *dwt = QApplication::desktop();
        if (dwt->isVirtualDesktop())
            /* Compose complex available region */
            for (int i = 0; i < dwt->numScreens(); ++ i)
                availableGeo += dwt->availableGeometry(i);
        else
            /* Get just a simple available rectangle */
            availableGeo = dwt->availableGeometry(pTopLevelWidget->pos());

        frameGeo = VBoxGlobal::normalizeGeometry(frameGeo, availableGeo, vboxGlobal().vmRenderMode() != SDLMode /* can resize? */);
    }

#if 0
    /* Center the frame on the desktop: */
    frameGeo.moveCenter(availableGeo.center());
#endif

    /* Finally, set the frame geometry */
    pTopLevelWidget->setGeometry(frameGeo.left() + dl, frameGeo.top() + dt, frameGeo.width() - dl - dr, frameGeo.height() - dt - db);

#else /* !VBOX_GUI_WITH_CUSTOMIZATIONS1 */
    Q_UNUSED(bAdjustPosition);
#endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */
}
Example #4
0
void MediaView::adjustWindowSize() {
    qDebug() << "Adjusting window size";
    Video *video = playlistModel->activeVideo();
    if (!video) return;
    QWidget *window = this->window();
    if (!window->isMaximized() && !window->isFullScreen()) {
        const double ratio = 16. / 9.;
        const double w = (double)videoAreaWidget->width();
        const double h = (double)videoAreaWidget->height();
        const double currentVideoRatio = w / h;
        if (currentVideoRatio != ratio) {
            qDebug() << "Adjust size";
            int newHeight = std::round((window->height() - h) + (w / ratio));
            window->resize(window->width(), newHeight);
        }
    }
}
Example #5
0
/** Store the settings of this window in the given CProfileWindow object. */
void CDisplayWindow::storeProfileSettings(const QString & windowGroup) {
    BtConfig & conf = btConfig();

    conf.beginGroup(windowGroup);

    QWidget * w = getProfileWindow();

    /**
      \note We don't use saveGeometry/restoreGeometry for MDI subwindows,
            because they give slightly incorrect results with some window
            managers. Might be related to Qt bug QTBUG-7634.
    */
    const QRect rect(w->x(), w->y(), w->width(), w->height());
    conf.setSessionValue<QRect>("windowRect", rect);

    conf.setSessionValue("maximized", w->isMaximized());

    bool hasFocus = (w == dynamic_cast<CDisplayWindow *>(mdi()->activeSubWindow()));
    conf.setSessionValue("hasFocus", hasFocus);
    // conf.setSessionValue("type", static_cast<int>(modules().first()->type()));

    // Save current key:
    if (key()) {
        CSwordKey * k = key();
        sword::VerseKey * vk = dynamic_cast<sword::VerseKey*>(k);
        QString oldLang;
        if (vk) {
            // Save keys in english only:
            const QString oldLang = QString::fromLatin1(vk->getLocale());
            vk->setLocale("en");
            conf.setSessionValue("key", k->key());
            vk->setLocale(oldLang.toLatin1());
        } else {
            conf.setSessionValue("key", k->key());
        }
    }

    // Save list of modules:
    QStringList mods;
    Q_FOREACH (const CSwordModuleInfo * module, modules())
        mods.append(module->name());
    conf.setSessionValue("modules", mods);

    conf.endGroup();
}
Example #6
0
void BfCompany::guardaConf()
{
    BL_FUNC_DEBUG
    QFile file ( g_confpr->value( CONF_DIR_USER ) + "bulmafact_" + dbName() + ".cfn" );
    /// Guardado del orden y de configuraciones varias.
    if ( file.open ( QIODevice::WriteOnly ) ) {

	 /// Saber si una ventana est&aacuta; maximizada
	 bool isMaximized = false;
	 if ( m_bulmafact->windowState() == Qt::WindowMaximized
	   || m_bulmafact->windowState() == Qt::WindowFullScreen )
	     isMaximized = true;

        QTextStream stream ( &file );
        stream << "<CONFIG>\n";
        stream << "\t<PRINCIPAL>\n";
        stream << "\t\t\t<X>" + QString::number ( m_bulmafact->geometry().x() ) + "</X>\n";
	  stream << "\t\t\t<Y>" + QString::number ( m_bulmafact->geometry().y() ) + "</Y>\n";
        stream << "\t\t\t<WIDTH>" + QString::number ( m_bulmafact->width() ) + "</WIDTH>\n";
        stream << "\t\t\t<HEIGHT>" + QString::number ( m_bulmafact->height() ) + "</HEIGHT>\n";
	  stream << "\t\t\t<INDEXADOR>" + ( QString ( m_bulmafact->actionIndexador->isChecked() ? "true" : "false" ) ) + "</INDEXADOR>\n";
        stream << "\t\t\t<TOOLBARSDOCKWIDGETS>" + QString ( m_bulmafact->saveState().toBase64() ) + "</TOOLBARSDOCKWIDGETS>\n";
	  stream << "\t\t\t<MAXIMIZED>" + QString ( isMaximized ? "true" : "false" ) + "</MAXIMIZED>\n";
        stream << "\t</PRINCIPAL>\n";

        for ( int i = 0; i < m_windowListDock->numVentanas(); i++ ) {
            QObject *obj = m_windowListDock->ventana ( i );
            QWidget *wid = ( QWidget * ) obj;
            stream << "\t<VENTANA>\n";
            stream << "\t\t<VNAME>" + obj->objectName() + "</VNAME>\n";
            stream << "\t\t<VX>" + QString::number ( wid->parentWidget() ->x() ) + "</VX>\n";
            stream << "\t\t<VY>" + QString::number ( wid->parentWidget() ->y() ) + "</VY>\n";
            stream << "\t\t<VWIDTH>" + QString::number ( wid->width() ) + "</VWIDTH>\n";
            stream << "\t\t<VHEIGHT>" + QString::number ( wid->height() ) + "</VHEIGHT>\n";
            stream << "\t\t<VVISIBLE>" + ( wid->isVisible() ? QString ( "true" ) : QString ( "false" ) ) + "</VVISIBLE>\n";
            stream << "\t\t<VMAXIMIZED>" + ( wid->isMaximized() ? QString ( "true" ) : QString ( "false" ) ) + "</VMAXIMIZED>\n";
            stream << "\t\t<VACTIVEWINDOW>" + ( m_bulmafact->workspace() ->activeWindow() == wid ? QString ( "true" ) : QString ( "false" ) ) + "</VACTIVEWINDOW>\n";
            stream << "\t</VENTANA>\n";
        } // end for

        stream << "</CONFIG>\n";
        file.close();
    } // end if
    
}
void NcWidgetData::updateCursorShape( const QPoint& globalMousePos )
{
  if ( mWidget->isFullScreen() || mWidget->isMaximized() )
  {
    if ( mCursorShapeChanged )
      mWidget->unsetCursor();

    return;
  }

  mMoveMousePos.recalculate( globalMousePos, mWidget->frameGeometry() );

  if( mMoveMousePos.onTopLeftEdge || mMoveMousePos.onBottomRightEdge )
  {
    mWidget->setCursor( Qt::SizeFDiagCursor );
    mCursorShapeChanged = true;
  }
  else if( mMoveMousePos.onTopRightEdge || mMoveMousePos.onBottomLeftEdge )
  {
    mWidget->setCursor( Qt::SizeBDiagCursor );
    mCursorShapeChanged = true;
  }
  else if( mMoveMousePos.onLeftEdge || mMoveMousePos.onRightEdge )
  {
    mWidget->setCursor( Qt::SizeHorCursor );
    mCursorShapeChanged = true;
  }
  else if( mMoveMousePos.onTopEdge || mMoveMousePos.onBottomEdge )
  {
    mWidget->setCursor( Qt::SizeVerCursor );
    mCursorShapeChanged = true;
  }
  else
  {
    if ( mCursorShapeChanged )
    {
      mWidget->unsetCursor();
      mCursorShapeChanged = false;
    }
  }
}
void QApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e)
{
    // This operation only makes sense after the QApplication constructor runs
    if (QCoreApplication::startingUp())
        return;

    QApplication::desktop()->d_func()->updateScreenList();

    // signal anything listening for screen geometry changes
    QDesktopWidget *desktop = QApplication::desktop();
    emit desktop->resized(e->index);

    // make sure maximized and fullscreen windows are updated
    QWidgetList list = QApplication::topLevelWidgets();
    for (int i = list.size() - 1; i >= 0; --i) {
        QWidget *w = list.at(i);
        if (w->isFullScreen())
            w->d_func()->setFullScreenSize_helper();
        else if (w->isMaximized())
            w->d_func()->setMaxWindowState_helper();
    }
}
Example #9
0
void AdvancedWidget<BaseClass>::mouseMoveEvent(QMouseEvent *event)
{
	if(!isUseBorder()) {
		bool isLeftButton = (event->buttons() & Qt::LeftButton);
		const QPoint pg = event->globalPos();
		QWidget *window = BaseClass::window();

		if(!isLeftButton) {
			Qt::WindowFrameSection region = getMouseRegion(pg.x(), pg.y(), window->geometry());

			updateCursor(region, window);
		}
		else if (isLeftButton && _action == WinAction::Resizing) {
			doWindowResize(window, pg, _region);
		}
		else if(isLeftButton && _action == WinAction::Dragging && !window->isMaximized()) {
			window->setCursor(QCursor(Qt::SizeAllCursor));
			window->move(pg - _movePath);
		}
	}

	BaseClass::mouseMoveEvent(event);
}
bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee)
{
    if (!isActive()
        || (ee->type() != QEvent::MouseButtonPress
            && ee->type() != QEvent::MouseButtonRelease
            && ee->type() != QEvent::MouseMove
            && ee->type() != QEvent::KeyPress
            && ee->type() != QEvent::ShortcutOverride)
        )
        return false;

    Q_ASSERT(o == widget);
    QWidget *w = widget;
    if (QApplication::activePopupWidget()) {
        if (buttonDown && ee->type() == QEvent::MouseButtonRelease)
            buttonDown = false;
        return false;
    }

    QMouseEvent *e = (QMouseEvent*)ee;
    switch (e->type()) {
    case QEvent::MouseButtonPress: {
        if (w->isMaximized())
            break;
        if (!widget->rect().contains(widget->mapFromGlobal(e->globalPos())))
            return false;
        if (e->button() == Qt::LeftButton) {
#if defined(Q_WS_X11)
            /*
               Implicit grabs do not stop the X server from changing
               the cursor in children, which looks *really* bad when
               doing resizingk, so we grab the cursor. Note that we do
               not do this on Windows since double clicks are lost due
               to the grab (see change 198463).
            */
            if (e->spontaneous())
#  if !defined(QT_NO_CURSOR)
                widget->grabMouse(widget->cursor());
#  else
                widget->grabMouse();
#  endif // QT_NO_CURSOR
#endif // Q_WS_X11
            buttonDown = false;
            emit activate();
            bool me = movingEnabled;
            movingEnabled = (me && o == widget);
            mouseMoveEvent(e);
            movingEnabled = me;
            buttonDown = true;
            moveOffset = widget->mapFromGlobal(e->globalPos());
            invertedMoveOffset = widget->rect().bottomRight() - moveOffset;
            if (mode == Center) {
                if (movingEnabled)
                    return true;
            } else {
                return true;
            }
        }
    } break;
    case QEvent::MouseButtonRelease:
        if (w->isMaximized())
            break;
        if (e->button() == Qt::LeftButton) {
            moveResizeMode = false;
            buttonDown = false;
            widget->releaseMouse();
            widget->releaseKeyboard();
            if (mode == Center) {
                if (movingEnabled)
                    return true;
            } else {
                return true;
            }
        }
        break;
    case QEvent::MouseMove: {
        if (w->isMaximized())
            break;
        buttonDown = buttonDown && (e->buttons() & Qt::LeftButton); // safety, state machine broken!
        bool me = movingEnabled;
        movingEnabled = (me && o == widget && (buttonDown || moveResizeMode));
        mouseMoveEvent(e);
        movingEnabled = me;
        if (mode == Center) {
            if (movingEnabled)
                return true;
        } else {
            return true;
        }
    } break;
    case QEvent::KeyPress:
        keyPressEvent((QKeyEvent*)e);
        break;
    case QEvent::ShortcutOverride:
        if (buttonDown) {
            ((QKeyEvent*)ee)->accept();
            return true;
        }
        break;
    default:
        break;
    }

    return false;
}
/* FUNCTION: showWindow */
void TrajectoryGraphicsTreeItem::showWindow()
{
	QWidget *activeWidget = resultsWindow->workspace->activeWindow();
	bool activeWidgetIsMaximized =
		(activeWidget != 0) && (activeWidget->isMaximized());
	if(activeWidgetIsMaximized)
		activeWidget->showNormal();
	
	if (trajWindow == NULL) {
		NXEntityManager* entityManager = resultsWindow->entityManager;
		NXDataStoreInfo* dataStoreInfo = entityManager->getDataStoreInfo();
		NXGraphicsManager* graphicsManager = resultsWindow->graphicsManager;
		
		int trajId = dataStoreInfo->getTrajectoryId(trajectoryName);
		trajWindow =
			new TrajectoryGraphicsWindow((QWidget*)0,
			                             entityManager,
			                             graphicsManager);
		/// @fixme Trap errors
		resultsWindow->workspace->addWindow(trajWindow);
		
		trajWindow->resize((resultsWindow->workspace->size()) *= 0.75);
		trajWindow->setWindowTitle(QString(trajectoryName.c_str()));
		
		resultsWindow->workspace->setActiveWindow(trajWindow);
		trajWindow->show();
		
		trajWindow->setFrameSetId(trajId);
		
		// set initial view
		if(dataStoreInfo->hasLastView()) {
			NXNamedView const& lastView = dataStoreInfo->getLastView();
			trajWindow->setNamedView(lastView);
			NXLOG_DEBUG("TrajectoryGraphicsWindow", "Setting NE1 last-view");
		}
		else if(dataStoreInfo->hasHomeView()) {
			NXNamedView const& homeView = dataStoreInfo->getHomeView();
			trajWindow->setNamedView(homeView);
			NXLOG_DEBUG("TrajectoryGraphicsWindow", "Setting NE1 home-view");
		}
		else {
			trajWindow->resetView();
			NXLOG_DEBUG("TrajectoryGraphicsWindow",
			            "Inferring default view from atom layout");
		}
		
		if (!dataStoreInfo->storeIsComplete(trajId)) {
			QObject::connect(entityManager,
			                 SIGNAL(newFrameAdded(int, int, NXMoleculeSet*)),
			                 trajWindow,
			                 SLOT(newFrame(int, int, NXMoleculeSet*)));
		}
		// resultsWindow->workspace->update();
	}
// 	else
// 		trajWindow->show();
	
	if(activeWidgetIsMaximized)
		trajWindow->showMaximized();
	else
		trajWindow->showNormal();
	
}