mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Another fix for "dialog closing closes swift",
see https://discordapp.com/channels/539048679160676382/567139633964646411/620776182027386880 The signal for the navigator dialog closed is not send or received in some cases, not clear why. Using a reference directly to the main window as workaround.
This commit is contained in:
committed by
Mat Sutcliffe
parent
af1b933e5c
commit
4fc151f4cb
@@ -18,6 +18,7 @@
|
||||
#include <QAction>
|
||||
#include <QEvent>
|
||||
#include <QFrame>
|
||||
#include <QMainWindow>
|
||||
#include <QGridLayout>
|
||||
#include <QIcon>
|
||||
#include <QList>
|
||||
@@ -30,6 +31,7 @@
|
||||
#include <QVariant>
|
||||
#include <Qt>
|
||||
#include <QStringBuilder>
|
||||
#include <QGuiApplication>
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace BlackGui;
|
||||
@@ -57,6 +59,9 @@ namespace BlackGui
|
||||
m_marginMenuAction = new QWidgetAction(this);
|
||||
m_marginMenuAction->setDefaultWidget(m_input);
|
||||
|
||||
// Quit on window hack
|
||||
m_originalQuitOnLastWindow = QGuiApplication::quitOnLastWindowClosed();
|
||||
|
||||
// timer
|
||||
m_watchdog.setObjectName(this->objectName() + ":m_timer");
|
||||
connect(&m_watchdog, &QTimer::timeout, this, &CNavigatorDialog::onWatchdog);
|
||||
@@ -118,6 +123,14 @@ namespace BlackGui
|
||||
|
||||
void CNavigatorDialog::reject()
|
||||
{
|
||||
// workaround to avoid "closing issue with navigator",
|
||||
// https://discordapp.com/channels/539048679160676382/567139633964646411/620776182027386880
|
||||
if (m_mainWindow)
|
||||
{
|
||||
QGuiApplication::setQuitOnLastWindowClosed(m_originalQuitOnLastWindow);
|
||||
m_mainWindow->show();
|
||||
}
|
||||
|
||||
this->hide();
|
||||
m_watchdog.stop();
|
||||
emit this->navigatorClosed();
|
||||
@@ -133,6 +146,7 @@ namespace BlackGui
|
||||
this->setVisible(visible);
|
||||
CGuiUtility::stayOnTop(visible, this);
|
||||
this->show();
|
||||
QGuiApplication::setQuitOnLastWindowClosed(visible ? false : m_originalQuitOnLastWindow); // avoid issues with a dialog closing everything
|
||||
|
||||
if (visible)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
class QEvent;
|
||||
class QMenu;
|
||||
class QMouseEvent;
|
||||
class QWidget;
|
||||
class QMainWindow;
|
||||
|
||||
namespace Ui { class CNavigatorDialog; }
|
||||
namespace BlackGui
|
||||
@@ -73,6 +73,9 @@ namespace BlackGui
|
||||
//! Save to settings
|
||||
void saveToSettings();
|
||||
|
||||
//! The main window
|
||||
void setMainWindow(QMainWindow *window) { m_mainWindow = window; }
|
||||
|
||||
signals:
|
||||
//! Navigator closed
|
||||
void navigatorClosed();
|
||||
@@ -126,12 +129,14 @@ namespace BlackGui
|
||||
//! On watchdog
|
||||
void onWatchdog();
|
||||
|
||||
QScopedPointer<Ui::CNavigatorDialog> ui;
|
||||
bool m_firstBuild = true;
|
||||
bool m_originalQuitOnLastWindow = false;
|
||||
int m_currentColumns = 1;
|
||||
QScopedPointer<Ui::CNavigatorDialog> ui;
|
||||
QMainWindow *m_mainWindow = nullptr;
|
||||
QWidgetAction *m_marginMenuAction = nullptr; //!< menu widget(!) action for margin widget
|
||||
CMarginsInput *m_input = nullptr; //!< margins widget
|
||||
QTimer m_watchdog; //!< navigator watchdog
|
||||
CMarginsInput *m_input = nullptr; //!< margins widget
|
||||
QTimer m_watchdog; //!< navigator watchdog
|
||||
BlackMisc::CSetting<BlackGui::Settings::TNavigator> m_settings { this, &CNavigatorDialog::onSettingsChanged };
|
||||
};
|
||||
} // ns
|
||||
|
||||
@@ -228,6 +228,7 @@ void SwiftGuiStd::initGuiSignals()
|
||||
connect(ui->menu_ModelBrowser, &QAction::triggered, this, &SwiftGuiStd::startModelBrowser, Qt::QueuedConnection);
|
||||
|
||||
connect(m_navigator.data(), &CNavigatorDialog::navigatorClosed, this, &SwiftGuiStd::onNavigatorClosed, Qt::QueuedConnection);
|
||||
m_navigator->setMainWindow(this);
|
||||
|
||||
// settings (GUI component), styles
|
||||
connect(ui->comp_MainInfoArea->getSettingsComponent(), &CSettingsComponent::changedWindowsOpacity, this, &SwiftGuiStd::onChangedWindowOpacity);
|
||||
|
||||
Reference in New Issue
Block a user