Beispiel #1
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    //declare and initialize the stack that will hold the windows
    CUNavigationStack *stack = new CUNavigationStack();

    //declare the navigation element that will manage the control flow
    CUNavigationProvisioning *navigation = new CUNavigationProvisioning(stack);

    LoginForm *initialPage = new LoginForm(navigation);
    stack->addWidget(initialPage);
    stack->setCurrentWidget(initialPage);

    QMainWindow mainWindow;
    mainWindow.setWindowTitle(QString("CUCare"));
    mainWindow.setCentralWidget(stack);

    QRect geo = mainWindow.geometry();
    QPoint center = QApplication::desktop()->availableGeometry().center();
    center.setX(center.x() - 100);
    center.setY(center.y() - 100);
    geo.moveCenter(center);
    mainWindow.setGeometry(geo);

    mainWindow.show();
    return app.exec();
}
Beispiel #2
0
bool ToolWindow::event(QEvent* event) {
    QEvent::Type type = event->type();
    if (type == QEvent::Show) {
        if (!_hasShown) {
            _hasShown = true;

            QMainWindow* mainWindow = Application::getInstance()->getWindow();
            QRect mainGeometry = mainWindow->geometry();

            int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
            int menuBarHeight = Menu::getInstance()->geometry().height();
            int topMargin = titleBarHeight + menuBarHeight;

            _lastGeometry = QRect(mainGeometry.topLeft().x(),  mainGeometry.topLeft().y() + topMargin,
                                  DEFAULT_WIDTH, mainGeometry.height() - topMargin);
        }
        setGeometry(_lastGeometry);
        return true;
    } else if (type == QEvent::Hide) {
        _lastGeometry = geometry();
        return true;
    }

    return QMainWindow::event(event);
}