Exemple #1
0
bool MWMDIManagerImpl::eventFilter(QObject *obj, QEvent *event) {
    QEvent::Type t = event->type();
    if ( t == QEvent::Close) {
        QMdiSubWindow* qw = qobject_cast<QMdiSubWindow*>(obj);
        MDIItem* item = getMDIItem(qw);
        uiLog.trace(QString("Processing close window request for '%1'").arg(getWindowName(item)));

        //check if user really wants to close the window, ignore event if not
        if (!onCloseEvent(item->w)) {
            uiLog.trace(QString("Ignoring close window request for '%1'").arg(getWindowName(item)));
            event->ignore();
            return true;
        }

        // here we sure that window will be closed
        emit si_windowClosing(item->w);

        if (item == mdiContentOwner) { // if 'current' window is closed -> clear MDI
            clearMDIContent(true);
        }
        items.removeAll(item);
        delete item;
        updateState();
    } else if (t == QEvent::WindowStateChange) {
        QMdiSubWindow* qw = qobject_cast<QMdiSubWindow*>(obj);
        defaultIsMaximized = qw->isMaximized();
    }
    return QObject::eventFilter(obj, event);
}
Exemple #2
0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::setWidthOfMdiWindow(QWidget* mdiWindowWidget, int newWidth)
{
    QMdiSubWindow* mdiWindow = findMdiSubWindow(mdiWindowWidget);
    if (mdiWindow)
    {
        QSize subWindowSize = mdiWindow->size();

        subWindowSize.setWidth(std::max(newWidth, 100));
        mdiWindow->resize(subWindowSize);

        if (mdiWindow->isMaximized())
        {
            // Set window temporarily to normal state and back to maximized
            // to redo layout so the whole window canvas is filled
            // Tried to activate layout, did not work as expected
            // Tested code:
            //   m_layout->activate();
            //   mdiWindow->layout()->activate();

            mdiWindow->showNormal();
            mdiWindow->showMaximized();
        }
    }
}