mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +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 <QAction>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
#include <QMainWindow>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@@ -30,6 +31,7 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
|
#include <QGuiApplication>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
using namespace BlackGui;
|
using namespace BlackGui;
|
||||||
@@ -57,6 +59,9 @@ namespace BlackGui
|
|||||||
m_marginMenuAction = new QWidgetAction(this);
|
m_marginMenuAction = new QWidgetAction(this);
|
||||||
m_marginMenuAction->setDefaultWidget(m_input);
|
m_marginMenuAction->setDefaultWidget(m_input);
|
||||||
|
|
||||||
|
// Quit on window hack
|
||||||
|
m_originalQuitOnLastWindow = QGuiApplication::quitOnLastWindowClosed();
|
||||||
|
|
||||||
// timer
|
// timer
|
||||||
m_watchdog.setObjectName(this->objectName() + ":m_timer");
|
m_watchdog.setObjectName(this->objectName() + ":m_timer");
|
||||||
connect(&m_watchdog, &QTimer::timeout, this, &CNavigatorDialog::onWatchdog);
|
connect(&m_watchdog, &QTimer::timeout, this, &CNavigatorDialog::onWatchdog);
|
||||||
@@ -118,6 +123,14 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CNavigatorDialog::reject()
|
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();
|
this->hide();
|
||||||
m_watchdog.stop();
|
m_watchdog.stop();
|
||||||
emit this->navigatorClosed();
|
emit this->navigatorClosed();
|
||||||
@@ -133,6 +146,7 @@ namespace BlackGui
|
|||||||
this->setVisible(visible);
|
this->setVisible(visible);
|
||||||
CGuiUtility::stayOnTop(visible, this);
|
CGuiUtility::stayOnTop(visible, this);
|
||||||
this->show();
|
this->show();
|
||||||
|
QGuiApplication::setQuitOnLastWindowClosed(visible ? false : m_originalQuitOnLastWindow); // avoid issues with a dialog closing everything
|
||||||
|
|
||||||
if (visible)
|
if (visible)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
class QEvent;
|
class QEvent;
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
class QWidget;
|
class QMainWindow;
|
||||||
|
|
||||||
namespace Ui { class CNavigatorDialog; }
|
namespace Ui { class CNavigatorDialog; }
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
@@ -73,6 +73,9 @@ namespace BlackGui
|
|||||||
//! Save to settings
|
//! Save to settings
|
||||||
void saveToSettings();
|
void saveToSettings();
|
||||||
|
|
||||||
|
//! The main window
|
||||||
|
void setMainWindow(QMainWindow *window) { m_mainWindow = window; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Navigator closed
|
//! Navigator closed
|
||||||
void navigatorClosed();
|
void navigatorClosed();
|
||||||
@@ -126,12 +129,14 @@ namespace BlackGui
|
|||||||
//! On watchdog
|
//! On watchdog
|
||||||
void onWatchdog();
|
void onWatchdog();
|
||||||
|
|
||||||
QScopedPointer<Ui::CNavigatorDialog> ui;
|
|
||||||
bool m_firstBuild = true;
|
bool m_firstBuild = true;
|
||||||
|
bool m_originalQuitOnLastWindow = false;
|
||||||
int m_currentColumns = 1;
|
int m_currentColumns = 1;
|
||||||
|
QScopedPointer<Ui::CNavigatorDialog> ui;
|
||||||
|
QMainWindow *m_mainWindow = nullptr;
|
||||||
QWidgetAction *m_marginMenuAction = nullptr; //!< menu widget(!) action for margin widget
|
QWidgetAction *m_marginMenuAction = nullptr; //!< menu widget(!) action for margin widget
|
||||||
CMarginsInput *m_input = nullptr; //!< margins widget
|
CMarginsInput *m_input = nullptr; //!< margins widget
|
||||||
QTimer m_watchdog; //!< navigator watchdog
|
QTimer m_watchdog; //!< navigator watchdog
|
||||||
BlackMisc::CSetting<BlackGui::Settings::TNavigator> m_settings { this, &CNavigatorDialog::onSettingsChanged };
|
BlackMisc::CSetting<BlackGui::Settings::TNavigator> m_settings { this, &CNavigatorDialog::onSettingsChanged };
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -228,6 +228,7 @@ void SwiftGuiStd::initGuiSignals()
|
|||||||
connect(ui->menu_ModelBrowser, &QAction::triggered, this, &SwiftGuiStd::startModelBrowser, Qt::QueuedConnection);
|
connect(ui->menu_ModelBrowser, &QAction::triggered, this, &SwiftGuiStd::startModelBrowser, Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(m_navigator.data(), &CNavigatorDialog::navigatorClosed, this, &SwiftGuiStd::onNavigatorClosed, Qt::QueuedConnection);
|
connect(m_navigator.data(), &CNavigatorDialog::navigatorClosed, this, &SwiftGuiStd::onNavigatorClosed, Qt::QueuedConnection);
|
||||||
|
m_navigator->setMainWindow(this);
|
||||||
|
|
||||||
// settings (GUI component), styles
|
// settings (GUI component), styles
|
||||||
connect(ui->comp_MainInfoArea->getSettingsComponent(), &CSettingsComponent::changedWindowsOpacity, this, &SwiftGuiStd::onChangedWindowOpacity);
|
connect(ui->comp_MainInfoArea->getSettingsComponent(), &CSettingsComponent::changedWindowsOpacity, this, &SwiftGuiStd::onChangedWindowOpacity);
|
||||||
|
|||||||
Reference in New Issue
Block a user