mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T447, navigator dialog improvements
* slots -> normal functions * watchdog to bring back navigator in case it gets in background
This commit is contained in:
@@ -58,6 +58,10 @@ namespace BlackGui
|
||||
m_marginMenuAction = new QWidgetAction(this);
|
||||
m_marginMenuAction->setDefaultWidget(m_input);
|
||||
|
||||
// timer
|
||||
m_watchdog.setObjectName(this->objectName() + ":m_timer");
|
||||
connect(&m_watchdog, &QTimer::timeout, this, &CNavigatorDialog::onWatchdog);
|
||||
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_input, &CMarginsInput::changedMargins, this, &CNavigatorDialog::menuChangeMargins);
|
||||
connect(this, &CNavigatorDialog::customContextMenuRequested, this, &CNavigatorDialog::showContextMenu);
|
||||
@@ -116,7 +120,8 @@ namespace BlackGui
|
||||
void CNavigatorDialog::reject()
|
||||
{
|
||||
this->hide();
|
||||
emit navigatorClosed();
|
||||
m_watchdog.stop();
|
||||
emit this->navigatorClosed();
|
||||
}
|
||||
|
||||
void CNavigatorDialog::toggleFrameless()
|
||||
@@ -124,9 +129,26 @@ namespace BlackGui
|
||||
this->setFrameless(!this->isFrameless());
|
||||
}
|
||||
|
||||
void CNavigatorDialog::toggleNavigator()
|
||||
void CNavigatorDialog::showNavigator(bool visible)
|
||||
{
|
||||
this->setVisible(!this->isVisible());
|
||||
this->setVisible(visible);
|
||||
CGuiUtility::stayOnTop(visible, this);
|
||||
this->show();
|
||||
|
||||
if (visible)
|
||||
{
|
||||
m_watchdog.start(4000);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_watchdog.stop();
|
||||
}
|
||||
}
|
||||
|
||||
void CNavigatorDialog::toggleNavigatorVisibility()
|
||||
{
|
||||
const bool visible = !this->isVisible();
|
||||
this->showNavigator(visible);
|
||||
}
|
||||
|
||||
void CNavigatorDialog::restoreFromSettings()
|
||||
@@ -309,6 +331,13 @@ namespace BlackGui
|
||||
this->adjustSize();
|
||||
}
|
||||
|
||||
void CNavigatorDialog::onWatchdog()
|
||||
{
|
||||
// if (!this->isVisible()) { return; }
|
||||
CGuiUtility::stayOnTop(true, this);
|
||||
this->show();
|
||||
}
|
||||
|
||||
void CNavigatorDialog::addToContextMenu(QMenu *contextMenu) const
|
||||
{
|
||||
QAction *a = contextMenu->addAction(CIcons::resize16(), "1 row", this, &CNavigatorDialog::changeLayout);
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
#include <QWidgetAction>
|
||||
#include <QTimer>
|
||||
#include <QGridLayout>
|
||||
#include <QTimer>
|
||||
|
||||
class QEvent;
|
||||
class QMenu;
|
||||
@@ -57,16 +59,14 @@ namespace BlackGui
|
||||
//! Called when dialog is closed
|
||||
virtual void reject() override;
|
||||
|
||||
signals:
|
||||
//! Navigator closed
|
||||
void navigatorClosed();
|
||||
|
||||
public slots:
|
||||
//! Toggle frameless mode
|
||||
void toggleFrameless();
|
||||
|
||||
//! Visibility visibility
|
||||
void showNavigator(bool visible);
|
||||
|
||||
//! Toggle visibility
|
||||
void toggleNavigator();
|
||||
void toggleNavigatorVisibility();
|
||||
|
||||
//! Restore from settings
|
||||
void restoreFromSettings();
|
||||
@@ -74,6 +74,10 @@ namespace BlackGui
|
||||
//! Save to settings
|
||||
void saveToSettings();
|
||||
|
||||
signals:
|
||||
//! Navigator closed
|
||||
void navigatorClosed();
|
||||
|
||||
protected:
|
||||
//! \name Base class events
|
||||
//! @{
|
||||
@@ -119,11 +123,15 @@ namespace BlackGui
|
||||
//! Adjust navigator size
|
||||
void adjustNavigatorSize(QGridLayout *layout = nullptr);
|
||||
|
||||
//! On watchdog
|
||||
void onWatchdog();
|
||||
|
||||
QScopedPointer<Ui::CNavigatorDialog> ui;
|
||||
bool m_firstBuild = true;
|
||||
int m_currentColumns = 1;
|
||||
QWidgetAction *m_marginMenuAction = nullptr; //!< menu widget(!) action for margin widget
|
||||
CMarginsInput *m_input = nullptr; //!< margins widget
|
||||
QTimer m_watchdog;
|
||||
BlackMisc::CSetting<BlackGui::Settings::TNavigator> m_settings { this, &CNavigatorDialog::onSettingsChanged };
|
||||
};
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user