From b937f10992ec3aad1589d3fd0d158ba48901dba0 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 13 Nov 2018 22:49:18 +0100 Subject: [PATCH] Hotkey dialog style --- src/blackgui/components/hotkeydialog.cpp | 49 ++++++++++++------------ src/blackgui/components/hotkeydialog.h | 2 +- src/blackgui/components/hotkeydialog.ui | 18 ++++----- src/blackgui/models/actionmodel.h | 2 +- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/blackgui/components/hotkeydialog.cpp b/src/blackgui/components/hotkeydialog.cpp index 1a246faa8..9ce8460a0 100644 --- a/src/blackgui/components/hotkeydialog.cpp +++ b/src/blackgui/components/hotkeydialog.cpp @@ -46,23 +46,6 @@ namespace BlackGui { namespace Components { - CKeySelectionBox::CKeySelectionBox(QWidget *parent) : CHorizontalComboBox(parent) - { - connect(this, static_cast(&CKeySelectionBox::currentIndexChanged), this, &CKeySelectionBox::updateSelectedIndex); - } - - void CKeySelectionBox::setSelectedIndex(int index) - { - m_oldIndex = index; - setCurrentIndex(m_oldIndex); - } - - void CKeySelectionBox::updateSelectedIndex(int index) - { - emit keySelectionChanged(m_oldIndex, index); - m_oldIndex = index; - } - CHotkeyDialog::CHotkeyDialog(const CActionHotkey &actionHotkey, const CIdentifierList &identifiers, QWidget *parent) : QDialog(parent), ui(new Ui::CHotkeyDialog), @@ -74,8 +57,8 @@ namespace BlackGui ui->setupUi(this); ui->qf_Advanced->hide(); - ui->tv_Actions->setModel(&m_actionModel); ui->pb_AdvancedMode->setIcon(CIcons::arrowMediumSouth16()); + ui->tv_Actions->setModel(&m_actionModel); selectAction(); if (!actionHotkey.getCombination().isEmpty()) { ui->pb_SelectedHotkey->setText(actionHotkey.getCombination().toQString()); } @@ -131,6 +114,23 @@ namespace BlackGui CHotkeyDialog::~CHotkeyDialog() { } + CKeySelectionBox::CKeySelectionBox(QWidget *parent) : CHorizontalComboBox(parent) + { + connect(this, static_cast(&CKeySelectionBox::currentIndexChanged), this, &CKeySelectionBox::updateSelectedIndex); + } + + void CKeySelectionBox::setSelectedIndex(int index) + { + m_oldIndex = index; + setCurrentIndex(m_oldIndex); + } + + void CKeySelectionBox::updateSelectedIndex(int index) + { + emit keySelectionChanged(m_oldIndex, index); + m_oldIndex = index; + } + void CHotkeyDialog::initStyleSheet() { if (!sGui) { return; } @@ -196,7 +196,7 @@ namespace BlackGui void CHotkeyDialog::changeApplicableMachine(int index) { Q_UNUSED(index); - QVariant userData = ui->cb_Identifier->currentData(); + const QVariant userData = ui->cb_Identifier->currentData(); Q_ASSERT(userData.canConvert()); m_actionHotkey.setApplicableMachine(userData.value()); } @@ -299,16 +299,15 @@ namespace BlackGui void CHotkeyDialog::selectAction() { - if (m_actionHotkey.getAction().isEmpty()) return; - - const auto tokens = m_actionHotkey.getAction().split("/", QString::SkipEmptyParts); + if (m_actionHotkey.getAction().isEmpty()) { return; } + const QStringList tokens = m_actionHotkey.getAction().split("/", QString::SkipEmptyParts); QModelIndex parentIndex = QModelIndex(); - for (const auto &token : tokens) + for (const QString &token : tokens) { const QModelIndex startIndex = m_actionModel.index(0, 0, parentIndex); - const auto indexList = m_actionModel.match(startIndex, Qt::DisplayRole, QVariant::fromValue(token)); - if (indexList.isEmpty()) return; + const QModelIndexList indexList = m_actionModel.match(startIndex, Qt::DisplayRole, QVariant::fromValue(token)); + if (indexList.isEmpty()) { return; } parentIndex = indexList.first(); ui->tv_Actions->expand(parentIndex); } diff --git a/src/blackgui/components/hotkeydialog.h b/src/blackgui/components/hotkeydialog.h index 011ae72d6..1a3bfdf87 100644 --- a/src/blackgui/components/hotkeydialog.h +++ b/src/blackgui/components/hotkeydialog.h @@ -105,7 +105,7 @@ namespace BlackGui QScopedPointer ui; BlackMisc::Input::CActionHotkey m_actionHotkey; - BlackGui::Models::CActionModel m_actionModel; + BlackGui::Models::CActionModel m_actionModel; }; } // ns } // ns diff --git a/src/blackgui/components/hotkeydialog.ui b/src/blackgui/components/hotkeydialog.ui index 5a46795aa..39c91c379 100644 --- a/src/blackgui/components/hotkeydialog.ui +++ b/src/blackgui/components/hotkeydialog.ui @@ -6,8 +6,8 @@ 0 0 - 269 - 384 + 290 + 430 @@ -136,6 +136,13 @@ + + + + Ok + + + @@ -149,13 +156,6 @@ - - - - Ok - - - diff --git a/src/blackgui/models/actionmodel.h b/src/blackgui/models/actionmodel.h index 386fe131d..3132b2e51 100644 --- a/src/blackgui/models/actionmodel.h +++ b/src/blackgui/models/actionmodel.h @@ -46,7 +46,7 @@ namespace BlackGui CActionModel(QObject *parent = nullptr); //! Destructor - virtual ~CActionModel(); + virtual ~CActionModel() override; //! \copydoc QAbstractItemModel::data QVariant data(const QModelIndex &index, int role) const override;