Core: Hide About dialog definition in .cpp

Change-Id: Ic8bd2535868319eb78ba61e90f35bf63b74b7b2e
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2024-07-31 16:25:21 +02:00
parent 10b17940c8
commit 714cedf945
3 changed files with 40 additions and 47 deletions

View File

@@ -272,7 +272,6 @@ public:
void aboutToShowRecentFiles(); void aboutToShowRecentFiles();
static void setFocusToEditor(); static void setFocusToEditor();
void aboutQtCreator();
void changeLog(); void changeLog();
void contact(); void contact();
void updateFocusWidget(QWidget *old, QWidget *now); void updateFocusWidget(QWidget *old, QWidget *now);
@@ -309,7 +308,6 @@ public:
NavigationWidget *m_leftNavigationWidget = nullptr; NavigationWidget *m_leftNavigationWidget = nullptr;
NavigationWidget *m_rightNavigationWidget = nullptr; NavigationWidget *m_rightNavigationWidget = nullptr;
RightPaneWidget *m_rightPaneWidget = nullptr; RightPaneWidget *m_rightPaneWidget = nullptr;
VersionDialog *m_versionDialog = nullptr;
QList<IContext *> m_activeContext; QList<IContext *> m_activeContext;
@@ -2036,7 +2034,7 @@ void ICorePrivate::registerDefaultActions()
aboutIdeAction.setMenuRole(QAction::AboutRole); aboutIdeAction.setMenuRole(QAction::AboutRole);
aboutIdeAction.addToContainer(Constants::M_HELP, Constants::G_HELP_ABOUT); aboutIdeAction.addToContainer(Constants::M_HELP, Constants::G_HELP_ABOUT);
aboutIdeAction.setEnabled(true); aboutIdeAction.setEnabled(true);
aboutIdeAction.addOnTriggered(this, [this] { aboutQtCreator(); }); aboutIdeAction.addOnTriggered(this, &showAboutQtCreator);
// About Plugins Action // About Plugins Action
ActionBuilder aboutPluginsAction(this, Constants::ABOUT_PLUGINS); ActionBuilder aboutPluginsAction(this, Constants::ABOUT_PLUGINS);
@@ -2429,27 +2427,6 @@ void ICorePrivate::aboutToShowRecentFiles()
} }
} }
void ICorePrivate::aboutQtCreator()
{
if (!m_versionDialog) {
m_versionDialog = new VersionDialog(m_mainwindow);
connect(m_versionDialog, &QDialog::finished,
this, &ICorePrivate::destroyVersionDialog);
ICore::registerWindow(m_versionDialog, Context("Core.VersionDialog"));
m_versionDialog->show();
} else {
ICore::raiseWindow(m_versionDialog);
}
}
void ICorePrivate::destroyVersionDialog()
{
if (m_versionDialog) {
m_versionDialog->deleteLater();
m_versionDialog = nullptr;
}
}
class LogDialog : public QDialog class LogDialog : public QDialog
{ {
public: public:

View File

@@ -16,6 +16,7 @@
#include <utils/stringutils.h> #include <utils/stringutils.h>
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
#include <QDialog>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QGridLayout> #include <QGridLayout>
#include <QGuiApplication> #include <QGuiApplication>
@@ -23,11 +24,18 @@
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
using namespace Core; namespace Core::Internal {
using namespace Core::Internal;
VersionDialog::VersionDialog(QWidget *parent) class VersionDialog final : public QDialog
: QDialog(parent) {
public:
VersionDialog();
bool event(QEvent *event) final;
};
VersionDialog::VersionDialog()
: QDialog(ICore::dialogParent())
{ {
// We need to set the window icon explicitly here since for some reason the // We need to set the window icon explicitly here since for some reason the
// application icon isn't used when the size of the dialog is fixed (at least not on X11/GNOME) // application icon isn't used when the size of the dialog is fixed (at least not on X11/GNOME)
@@ -78,3 +86,27 @@ bool VersionDialog::event(QEvent *event)
} }
return QDialog::event(event); return QDialog::event(event);
} }
static QDialog *s_versionDialog = nullptr;
static void destroyVersionDialog()
{
if (s_versionDialog) {
s_versionDialog->deleteLater();
s_versionDialog = nullptr;
}
}
void showAboutQtCreator()
{
if (s_versionDialog) {
ICore::raiseWindow(s_versionDialog);
} else {
s_versionDialog = new VersionDialog;
QObject::connect(s_versionDialog, &QDialog::finished, &destroyVersionDialog);
ICore::registerWindow(s_versionDialog, Context("Core.VersionDialog"));
s_versionDialog->show();
}
}
} // Core::Internal

View File

@@ -3,24 +3,8 @@
#pragma once #pragma once
#include <QDialog> namespace Core::Internal {
QT_BEGIN_NAMESPACE void showAboutQtCreator();
class QEvent;
QT_END_NAMESPACE
namespace Core { } // Core::Internal
namespace Internal {
class VersionDialog : public QDialog
{
Q_OBJECT
public:
explicit VersionDialog(QWidget *parent);
bool event(QEvent *event) override;
};
} // namespace Internal
} // namespace Core