From 402182275384db16118297ce329c33a00d9deee1 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 28 May 2018 21:41:05 +0200 Subject: [PATCH] Setting UI improvement * pressing shift while clicking the button shows overview * hint in overview, that there are shortcuts --- .../components/maininfoareacomponent.cpp | 15 ++ .../components/maininfoareacomponent.h | 2 +- .../components/mainkeypadareacomponent.cpp | 6 +- .../components/mainkeypadareacomponent.h | 3 +- .../components/mainkeypadareacomponent.ui | 30 ++-- src/blackgui/components/settingscomponent.cpp | 44 +++--- src/blackgui/components/settingscomponent.h | 23 +-- src/blackgui/components/settingscomponent.ui | 141 +++++++++--------- .../components/statusmessagesdetail.cpp | 6 +- src/blackgui/dockwidget.cpp | 8 +- src/blackgui/dockwidgetinfoarea.h | 3 +- 11 files changed, 154 insertions(+), 127 deletions(-) diff --git a/src/blackgui/components/maininfoareacomponent.cpp b/src/blackgui/components/maininfoareacomponent.cpp index e00f2117a..74cd7bef2 100644 --- a/src/blackgui/components/maininfoareacomponent.cpp +++ b/src/blackgui/components/maininfoareacomponent.cpp @@ -14,6 +14,7 @@ #include "ui_maininfoareacomponent.h" #include +#include using namespace BlackMisc; using namespace BlackGui; @@ -108,6 +109,20 @@ namespace BlackGui this->selectArea(InfoAreaLog); } + void CMainInfoAreaComponent::selectArea(CMainInfoAreaComponent::InfoArea infoArea) + { + CInfoArea::selectArea(static_cast(infoArea)); + if (infoArea == InfoAreaSettings) + { + // pressing shift will go to overview + const Qt::KeyboardModifiers km = QGuiApplication::queryKeyboardModifiers(); + if (km.testFlag(Qt::ShiftModifier)) + { + ui->comp_Settings->setSettingsOverviewTab(); + } + } + } + void CMainInfoAreaComponent::selectLog() { this->selectArea(InfoAreaLog); diff --git a/src/blackgui/components/maininfoareacomponent.h b/src/blackgui/components/maininfoareacomponent.h index 431222b5e..2f3cab1f1 100644 --- a/src/blackgui/components/maininfoareacomponent.h +++ b/src/blackgui/components/maininfoareacomponent.h @@ -118,7 +118,7 @@ namespace BlackGui void toggleFloating(InfoArea infoArea) { CInfoArea::toggleFloatingByIndex(static_cast(infoArea)); } //! Select area - void selectArea(InfoArea infoArea) { CInfoArea::selectArea(static_cast(infoArea)); } + void selectArea(InfoArea infoArea); //! Select log void selectLog(); diff --git a/src/blackgui/components/mainkeypadareacomponent.cpp b/src/blackgui/components/mainkeypadareacomponent.cpp index 124ddfafb..3a2f4ec22 100644 --- a/src/blackgui/components/mainkeypadareacomponent.cpp +++ b/src/blackgui/components/mainkeypadareacomponent.cpp @@ -116,15 +116,15 @@ namespace BlackGui } else if (senderButton == ui->pb_CockpitIdent && sGui->getIContextOwnAircraft()) { - emit identPressed(); + emit this->identPressed(); } else if (senderButton == ui->pb_Opacity050) { - emit changedOpacity(50); + emit this->changedOpacity(50); } else if (senderButton == ui->pb_Opacity100) { - emit changedOpacity(100); + emit this->changedOpacity(100); } else if (senderButton == ui->pb_SoundMaxVolume && sGui->getIContextAudio()) { diff --git a/src/blackgui/components/mainkeypadareacomponent.h b/src/blackgui/components/mainkeypadareacomponent.h index 3a007c798..ec18be4f3 100644 --- a/src/blackgui/components/mainkeypadareacomponent.h +++ b/src/blackgui/components/mainkeypadareacomponent.h @@ -34,8 +34,7 @@ namespace BlackGui { //! Main keypad area as used with main info area //! \sa CMainInfoAreaComponent - class BLACKGUI_EXPORT CMainKeypadAreaComponent : - public QFrame + class BLACKGUI_EXPORT CMainKeypadAreaComponent : public QFrame { Q_OBJECT diff --git a/src/blackgui/components/mainkeypadareacomponent.ui b/src/blackgui/components/mainkeypadareacomponent.ui index ea88e66cc..7358d4db5 100644 --- a/src/blackgui/components/mainkeypadareacomponent.ui +++ b/src/blackgui/components/mainkeypadareacomponent.ui @@ -259,12 +259,6 @@ 0 - - - 62 - 22 - - 100% @@ -307,6 +301,9 @@ 0 + + Use "SHIFT" for overview + Qt::LeftToRight @@ -326,12 +323,6 @@ 0 - - - 62 - 22 - - 50% @@ -423,7 +414,22 @@ pb_MainAircrafts pb_MainAtc pb_MainUsers + pb_MainCockpit pb_MainSimulator + pb_MainMappings + pb_MainInterpolation + pb_MainTextMessages + pb_MainFlightplan + pb_MainLog + pb_MainSettings + pb_MainWeather + pb_Empty + pb_SoundMaxVolume + pb_Opacity100 + pb_CockpitIdent + pb_Audio + pb_SoundMute + pb_Opacity050 diff --git a/src/blackgui/components/settingscomponent.cpp b/src/blackgui/components/settingscomponent.cpp index d7418f32c..3c72dfbba 100644 --- a/src/blackgui/components/settingscomponent.cpp +++ b/src/blackgui/components/settingscomponent.cpp @@ -54,16 +54,16 @@ namespace BlackGui ui->comp_DataLoadOverview->showVisibleLoadAllButtons(false, false); connect(ui->comp_SettingsGuiGeneral, &CSettingsGuiComponent::changedWindowsOpacity, this, &CSettingsComponent::changedWindowsOpacity); - connect(ui->pb_Advanced, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); - connect(ui->pb_Audio, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); - connect(ui->pb_Gui, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); - connect(ui->pb_Hotkeys, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); - connect(ui->pb_Network, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); - connect(ui->pb_Servers, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); - connect(ui->pb_Simulator, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); - connect(ui->pb_SimulatorBasics, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); - connect(ui->pb_DataLoadAndCaches, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); - connect(ui->pb_SimulatorMessages, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); + connect(ui->pb_Advanced, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked); + connect(ui->pb_Audio, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked); + connect(ui->pb_Gui, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked); + connect(ui->pb_Hotkeys, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked); + connect(ui->pb_Network, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked); + connect(ui->pb_Servers, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked); + connect(ui->pb_Simulator, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked); + connect(ui->pb_SimulatorBasics, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked); + connect(ui->pb_DataLoadAndCaches, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked); + connect(ui->pb_SimulatorMessages, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked); this->initActions(); } @@ -77,49 +77,50 @@ namespace BlackGui a = new QAction(this); a->setObjectName("overview"); a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_O)); - connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + connect(a, &QAction::triggered, this, &CSettingsComponent::onActionTriggered); this->addAction(a); + ui->lbl_Hint->setText("Hint: See tooltips for shortcuts, \"ALT+S, O\" for overview."); a = new QAction(this); a->setObjectName("audio"); a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_A)); ui->pb_Audio->setToolTip(a->shortcut().toString()); - connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + connect(a, &QAction::triggered, this, &CSettingsComponent::onActionTriggered); this->addAction(a); a = new QAction(this); a->setObjectName("data"); a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_D)); ui->pb_DataLoadAndCaches->setToolTip(a->shortcut().toString()); - connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + connect(a, &QAction::triggered, this, &CSettingsComponent::onActionTriggered); this->addAction(a); a = new QAction(this); a->setObjectName("gui"); a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_G)); ui->pb_Gui->setToolTip(a->shortcut().toString()); - connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + connect(a, &QAction::triggered, this, &CSettingsComponent::onActionTriggered); this->addAction(a); a = new QAction(this); a->setObjectName("hotkeys"); a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_H)); ui->pb_Hotkeys->setToolTip(a->shortcut().toString()); - connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + connect(a, &QAction::triggered, this, &CSettingsComponent::onActionTriggered); this->addAction(a); a = new QAction(this); a->setObjectName("network"); a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_N)); ui->pb_Network->setToolTip(a->shortcut().toString()); - connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + connect(a, &QAction::triggered, this, &CSettingsComponent::onActionTriggered); this->addAction(a); a = new QAction(this); a->setObjectName("simulator"); a->setShortcut(QKeySequence(Qt::ALT + Qt::Key_S, Qt::Key_S)); ui->pb_Simulator->setToolTip(a->shortcut().toString()); - connect(a, &QAction::triggered, this, &CSettingsComponent::ps_actionTriggered); + connect(a, &QAction::triggered, this, &CSettingsComponent::onActionTriggered); this->addAction(a); } @@ -138,12 +139,17 @@ namespace BlackGui this->setCurrentIndex(static_cast(tab)); } + void CSettingsComponent::setSettingsOverviewTab() + { + this->setSettingsTab(SettingTabOverview); + } + void CSettingsComponent::setGuiOpacity(double value) { ui->comp_SettingsGuiGeneral->setGuiOpacity(value); } - void CSettingsComponent::ps_overviewButtonClicked() + void CSettingsComponent::onOverviewButtonClicked() { const QObject *sender = QObject::sender(); if (sender == ui->pb_Advanced) { this->setCurrentIndex(SettingTabAdvanced); return; } @@ -159,7 +165,7 @@ namespace BlackGui this->setCurrentIndex(SettingTabOverview); } - void CSettingsComponent::ps_actionTriggered() + void CSettingsComponent::onActionTriggered() { const QString a = QObject::sender()->objectName().toLower().trimmed(); if (a.isEmpty()) { return; } diff --git a/src/blackgui/components/settingscomponent.h b/src/blackgui/components/settingscomponent.h index 7c119af6e..90b064a13 100644 --- a/src/blackgui/components/settingscomponent.h +++ b/src/blackgui/components/settingscomponent.h @@ -61,6 +61,15 @@ namespace BlackGui //! Settings for given simulator BlackMisc::Simulation::Settings::CSpecializedSimulatorSettings getSimulatorSettings(const BlackMisc::Simulation::CSimulatorInfo &simulator) const; + //! Set the tab + void setSettingsTab(SettingTab tab); + + //! Set the overview tab + void setSettingsOverviewTab(); + + //! GUI Opacity 0-100% + void setGuiOpacity(double value); + signals: //! Change the windows opacity 0..100 void changedWindowsOpacity(int opacity); @@ -74,21 +83,13 @@ namespace BlackGui //! Update interval changed (users) void changedUsersUpdateInterval(int seconds); - public slots: - //! Set the tab - void setSettingsTab(SettingTab tab); - - //! GUI Opacity 0-100% - void setGuiOpacity(double value); - - private slots: + private: //! An overview button was clicked - void ps_overviewButtonClicked(); + void onOverviewButtonClicked(); //! Action triggered - void ps_actionTriggered(); + void onActionTriggered(); - private: //! Init actions void initActions(); diff --git a/src/blackgui/components/settingscomponent.ui b/src/blackgui/components/settingscomponent.ui index 4babb426a..6c0f2d85c 100644 --- a/src/blackgui/components/settingscomponent.ui +++ b/src/blackgui/components/settingscomponent.ui @@ -6,8 +6,8 @@ 0 0 - 236 - 337 + 204 + 340 @@ -30,7 +30,7 @@ 20 - + Qt::Vertical @@ -43,20 +43,7 @@ - - - - - 0 - 0 - - - - Network - - - - + @@ -69,7 +56,7 @@ - + @@ -82,8 +69,8 @@ - - + + 0 @@ -91,24 +78,11 @@ - Audio + Network - - - - - 0 - 0 - - - - GUI - - - - + @@ -121,8 +95,8 @@ - - + + 0 @@ -130,11 +104,24 @@ - Simulator + Audio + + + + 0 + 0 + + + + GUI + + + + @@ -147,33 +134,7 @@ - - - - - 0 - 0 - - - - Hotkeys - - - - - - - - 0 - 0 - - - - Simulator (messages) - - - - + Qt::Vertical @@ -189,6 +150,52 @@ + + + + + 0 + 0 + + + + Hotkeys + + + + + + + + 0 + 0 + + + + Simulator (messages) + + + + + + + + 0 + 0 + + + + Simulator + + + + + + + Hint: see tooltips for shortcuts. + + + @@ -532,8 +539,8 @@ 0 0 - 228 - 295 + 196 + 298 diff --git a/src/blackgui/components/statusmessagesdetail.cpp b/src/blackgui/components/statusmessagesdetail.cpp index cc7057529..e449514c5 100644 --- a/src/blackgui/components/statusmessagesdetail.cpp +++ b/src/blackgui/components/statusmessagesdetail.cpp @@ -120,10 +120,10 @@ namespace BlackGui const bool v = messagesDetail->ui->form_StatusMessage->isVisible(); const QString formString(v ? "Hide log details" : "Show log details"); - this->m_action = menuActions.addAction(this->m_action, BlackMisc::CIcons::databaseTable16(), formString, + m_action = menuActions.addAction(m_action, BlackMisc::CIcons::databaseTable16(), formString, CMenuAction::pathLog(), { messagesDetail->ui->form_StatusMessage, &CStatusMessageForm::toggleVisibility}); - this->m_action->setCheckable(true); - this->m_action->setChecked(v); + m_action->setCheckable(true); + m_action->setChecked(v); } } // ns } // ns diff --git a/src/blackgui/dockwidget.cpp b/src/blackgui/dockwidget.cpp index d1fdaa362..26877b35c 100644 --- a/src/blackgui/dockwidget.cpp +++ b/src/blackgui/dockwidget.cpp @@ -321,13 +321,7 @@ namespace BlackGui void CDockWidget::keyPressEvent(QKeyEvent *event) { - if (event->key() == Qt::Key_Escape) - { - if (this->isFloating()) - { - this->toggleFloating(); - } - } + if (event->key() == Qt::Key_Escape && this->isFloating()) { this->toggleFloating(); } QDockWidget::keyPressEvent(event); } diff --git a/src/blackgui/dockwidgetinfoarea.h b/src/blackgui/dockwidgetinfoarea.h index b9e6484d7..6b3ab973b 100644 --- a/src/blackgui/dockwidgetinfoarea.h +++ b/src/blackgui/dockwidgetinfoarea.h @@ -44,7 +44,7 @@ namespace BlackGui //! The parent info area CInfoArea *getParentInfoArea(); - //! Is this the selected widget, means it is not floating, and the one selected + //! Is this the selected widget, means it is not floating, and it is the one selected bool isSelectedDockWidget() const; //! Visible widget @@ -69,7 +69,6 @@ namespace BlackGui //! The parent info areas const QList findParentInfoAreas() const; }; - } // namespace #endif // guard