diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-10-20 14:15:43 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-11-02 09:53:57 +0000 |
commit | 39c45f6f38281c33efc151c94054ad38d0640d17 (patch) | |
tree | bd75ddfef24a69f7f296bf1d21c162bfb1be9099 | |
parent | d39545896f67927fd8c6fb2aa6661d1e47c39e32 (diff) |
Qt Designer: Centralize handling of the New Form Dialog
There were 2 functions in class QDesignerWorkbench and QDesigner
opening the New Form Dialog. Move them to QDesignerWorkbench and give
it a bool m_suppressNewFormShow for later use. Handle suppressing the
dialog from the command line parsing locally in class QDesigner.
Remove the temporary setting of m_suppressNewFormShow from the file
open event since it had no influence on QDesignerWorkbench and the Qt
3 conversion dialog mentioned in the comment no longer exists.
Task-number: QTBUG-118473
Change-Id: Ia673d98227bf762a4b732b75076da2469ff06d60
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
(cherry picked from commit 36c189a9119d5af40ef6f186088e405b0b80bd2e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/designer/src/designer/qdesigner.cpp | 21 | ||||
-rw-r--r-- | src/designer/src/designer/qdesigner.h | 4 | ||||
-rw-r--r-- | src/designer/src/designer/qdesigner_workbench.cpp | 12 | ||||
-rw-r--r-- | src/designer/src/designer/qdesigner_workbench.h | 5 |
4 files changed, 19 insertions, 23 deletions
diff --git a/src/designer/src/designer/qdesigner.cpp b/src/designer/src/designer/qdesigner.cpp index 8a2336060..7b7aae0b0 100644 --- a/src/designer/src/designer/qdesigner.cpp +++ b/src/designer/src/designer/qdesigner.cpp @@ -227,7 +227,7 @@ QDesigner::ParseArgumentsResult QDesigner::parseCommandLineArguments() previousMessageHandler = qInstallMessageHandler(designerMessageHandler); // Warn when loading faulty forms Q_ASSERT(previousMessageHandler); - m_suppressNewFormShow = m_workbench->readInBackup(); + bool suppressNewFormShow = m_workbench->readInBackup(); for (auto fileName : std::as_const(options.files)) { // Ensure absolute paths for recent file list to be unique @@ -237,13 +237,13 @@ QDesigner::ParseArgumentsResult QDesigner::parseCommandLineArguments() m_workbench->readInForm(fileName); } - if ( m_workbench->formWindowCount()) - m_suppressNewFormShow = true; + if (m_workbench->formWindowCount() > 0) + suppressNewFormShow = true; // Show up error box with parent now if something went wrong if (m_initializationErrors.isEmpty()) { - if (!m_suppressNewFormShow && QDesignerSettings(m_workbench->core()).showNewFormOnStartup()) - QTimer::singleShot(100, this, &QDesigner::callCreateForm); // won't show anything if suppressed + if (!suppressNewFormShow) + m_workbench->showNewForm(); } else { showErrorMessageBox(m_initializationErrors); m_initializationErrors.clear(); @@ -256,10 +256,7 @@ bool QDesigner::event(QEvent *ev) bool eaten; switch (ev->type()) { case QEvent::FileOpen: - // Set it true first since, if it's a Qt 3 form, the messagebox from convert will fire the timer. - m_suppressNewFormShow = true; - if (!m_workbench->readInForm(static_cast<QFileOpenEvent *>(ev)->file())) - m_suppressNewFormShow = false; + m_workbench->readInForm(static_cast<QFileOpenEvent *>(ev)->file()); eaten = true; break; case QEvent::Close: { @@ -291,10 +288,4 @@ MainWindowBase *QDesigner::mainWindow() const return m_mainWindow; } -void QDesigner::callCreateForm() -{ - if (!m_suppressNewFormShow) - m_workbench->actionManager()->createForm(); -} - QT_END_NAMESPACE diff --git a/src/designer/src/designer/qdesigner.h b/src/designer/src/designer/qdesigner.h index 4a12e48f3..5b763d7a1 100644 --- a/src/designer/src/designer/qdesigner.h +++ b/src/designer/src/designer/qdesigner.h @@ -50,9 +50,6 @@ signals: public slots: void showErrorMessage(const QString &message); -private slots: - void callCreateForm(); - private: void showErrorMessageBox(const QString &); @@ -64,7 +61,6 @@ private: QString m_initializationErrors; QString m_lastErrorMessage; - bool m_suppressNewFormShow = false; }; QT_END_NAMESPACE diff --git a/src/designer/src/designer/qdesigner_workbench.cpp b/src/designer/src/designer/qdesigner_workbench.cpp index 18ab1b5ea..e6970b418 100644 --- a/src/designer/src/designer/qdesigner_workbench.cpp +++ b/src/designer/src/designer/qdesigner_workbench.cpp @@ -599,13 +599,17 @@ void QDesignerWorkbench::removeFormWindow(QDesignerFormWindow *formWindow) if (m_formWindows.isEmpty()) { m_actionManager->setWindowListSeparatorVisible(false); // Show up new form dialog unless closing - if (loadOk && m_state == StateUp - && QDesignerSettings(m_core).showNewFormOnStartup()) { - QTimer::singleShot(200, m_actionManager, &QDesignerActions::createForm); - } + if (loadOk && m_state == StateUp) + showNewForm(); } } +void QDesignerWorkbench::showNewForm() +{ + if (!m_suppressNewFormShow && QDesignerSettings(m_core).showNewFormOnStartup()) + QTimer::singleShot(100, m_actionManager, &QDesignerActions::createForm); +} + void QDesignerWorkbench::initializeCorePlugins() { QObjectList plugins = QPluginLoader::staticInstances(); diff --git a/src/designer/src/designer/qdesigner_workbench.h b/src/designer/src/designer/qdesigner_workbench.h index d80fe730b..faf735e88 100644 --- a/src/designer/src/designer/qdesigner_workbench.h +++ b/src/designer/src/designer/qdesigner_workbench.h @@ -77,6 +77,9 @@ public: void updateBackup(QDesignerFormWindowInterface* fwi); void applyUiSettings(); + bool suppressNewFormShow() const { return m_suppressNewFormShow; } + void setSuppressNewFormShow(bool v) { m_suppressNewFormShow = v; } + signals: void modeChanged(UIMode mode); void initialized(); @@ -86,6 +89,7 @@ public slots: void removeFormWindow(QDesignerFormWindow *formWindow); void bringAllToFront(); void toggleFormMinimizationState(); + void showNewForm(); private slots: void switchToNeutralMode(); @@ -167,6 +171,7 @@ private: enum State { StateInitializing, StateUp, StateClosing }; State m_state = StateInitializing; bool m_uiSettingsChanged = false; // UI mode changed in preference dialog, trigger delayed slot. + bool m_suppressNewFormShow = false; }; QT_END_NAMESPACE |