From 7152119014da1c3e95e942acfecf6ab3c6945e23 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 4 Jan 2025 23:05:43 -0500 Subject: [PATCH] refactor: ActionDialog, Only show Action relevent options --- .../deskflow-gui/dialogs/ActionDialog.cpp | 39 ++- src/apps/deskflow-gui/dialogs/ActionDialog.ui | 296 ++++++++---------- 2 files changed, 150 insertions(+), 185 deletions(-) diff --git a/src/apps/deskflow-gui/dialogs/ActionDialog.cpp b/src/apps/deskflow-gui/dialogs/ActionDialog.cpp index 9156c4586..efc176f27 100644 --- a/src/apps/deskflow-gui/dialogs/ActionDialog.cpp +++ b/src/apps/deskflow-gui/dialogs/ActionDialog.cpp @@ -25,6 +25,8 @@ #include "KeySequence.h" #include "ServerConfig.h" +#include + ActionDialog::ActionDialog(QWidget *parent, const ServerConfig &config, Hotkey &hotkey, Action &action) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), ui{std::make_unique()}, @@ -42,8 +44,8 @@ ActionDialog::ActionDialog(QWidget *parent, const ServerConfig &config, Hotkey & ui->keySequenceWidget->setText(m_action.keySequence().toString()); ui->keySequenceWidget->setKeySequence(m_action.keySequence()); - ui->m_pComboSwitchInDirection->setCurrentIndex(m_action.switchDirection()); - ui->m_pComboLockCursorToScreen->setCurrentIndex(m_action.lockCursorMode()); + ui->comboSwitchInDirection->setCurrentIndex(m_action.switchDirection()); + ui->comboLockCursorToScreen->setCurrentIndex(m_action.lockCursorMode()); ui->comboActionType->setCurrentIndex(m_action.type()); ui->comboTriggerOn->setCurrentIndex(m_action.activeOnRelease()); @@ -59,10 +61,19 @@ ActionDialog::ActionDialog(QWidget *parent, const ServerConfig &config, Hotkey & ui->listScreens->addItem(newListItem); - ui->m_pComboSwitchToScreen->addItem(screen.name()); + ui->comboSwitchToScreen->addItem(tr("Switch to %1").arg(screen.name())); if (screen.name() == m_action.switchScreenName()) - ui->m_pComboSwitchToScreen->setCurrentIndex(ui->m_pComboSwitchToScreen->count() - 1); + ui->comboSwitchToScreen->setCurrentIndex(ui->comboSwitchToScreen->count() - 1); } + + ui->keySequenceWidget->setVisible(false); + ui->groupScreens->setVisible(false); + ui->listScreens->setEnabled(!ui->keySequenceWidget->keySequence().isMouseButton()); + ui->comboSwitchToScreen->setVisible(false); + ui->comboSwitchInDirection->setVisible(false); + ui->comboLockCursorToScreen->setVisible(false); + + actionTypeChanged(ui->comboActionType->currentIndex()); } void ActionDialog::accept() @@ -92,9 +103,9 @@ void ActionDialog::accept() m_action.setHaveScreens(screenCount); - m_action.setSwitchScreenName(ui->m_pComboSwitchToScreen->currentText()); - m_action.setSwitchDirection(ui->m_pComboSwitchInDirection->currentIndex()); - m_action.setLockCursorMode(ui->m_pComboLockCursorToScreen->currentIndex()); + m_action.setSwitchScreenName(ui->comboSwitchToScreen->currentText().remove(tr("Switch to "))); + m_action.setSwitchDirection(ui->comboSwitchInDirection->currentIndex()); + m_action.setLockCursorMode(ui->comboLockCursorToScreen->currentIndex()); m_action.setActiveOnRelease(ui->comboTriggerOn->currentIndex()); m_action.setRestartServer(ui->comboActionType->currentIndex() == ActionTypes::RestartServer); @@ -103,16 +114,18 @@ void ActionDialog::accept() void ActionDialog::keySequenceChanged() { - ui->listScreens->setEnabled(ui->keySequenceWidget->valid() && !ui->keySequenceWidget->keySequence().isMouseButton()); + ui->listScreens->setEnabled(!ui->keySequenceWidget->keySequence().isMouseButton()); } void ActionDialog::actionTypeChanged(int index) { - ui->keySequenceWidget->setEnabled(isKeyAction(index)); - ui->listScreens->setEnabled(isKeyAction(index)); - ui->m_pComboSwitchToScreen->setEnabled(index == ActionTypes::SwitchTo); - ui->m_pComboSwitchInDirection->setEnabled(index == ActionTypes::SwitchInDirection); - ui->m_pComboLockCursorToScreen->setEnabled(index == ActionTypes::ModifyCursorLock); + ui->keySequenceWidget->setVisible(isKeyAction(index)); + ui->groupScreens->setVisible(isKeyAction(index)); + ui->listScreens->setEnabled(!ui->keySequenceWidget->keySequence().isMouseButton()); + ui->comboSwitchToScreen->setVisible(index == ActionTypes::SwitchTo); + ui->comboSwitchInDirection->setVisible(index == ActionTypes::SwitchInDirection); + ui->comboLockCursorToScreen->setVisible(index == ActionTypes::ModifyCursorLock); + QTimer::singleShot(1, this, &ActionDialog::adjustSize); } bool ActionDialog::isKeyAction(int index) diff --git a/src/apps/deskflow-gui/dialogs/ActionDialog.ui b/src/apps/deskflow-gui/dialogs/ActionDialog.ui index 03838af1f..8edad09e2 100644 --- a/src/apps/deskflow-gui/dialogs/ActionDialog.ui +++ b/src/apps/deskflow-gui/dialogs/ActionDialog.ui @@ -6,18 +6,33 @@ 0 0 - 521 - 428 + 0 + 0 + + + 0 + 0 + + Configure Action + + 6 + + + + 0 + 0 + + When the hotkey is pressed @@ -32,6 +47,12 @@ + + + 0 + 0 + + Press key(s) @@ -44,7 +65,7 @@ - Toggle key(s) + Press and release key(s) @@ -72,184 +93,115 @@ - - - + + + + + true + + + + + + + true + + + + 0 + 0 + + + + + Move to the screen on the left + + + + + Move to the screen on the right + + + + + Move to the screen above + + + + + Move to the screen below + + + + + + + + true + + + + 0 + 0 + + + + + Toggle the cursor lock + + + + + Enable the cursor lock + + + + + Disable the cursor lock + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + 0 + 0 + - + + Computers to recieve this event + + - + - - 1 + + 0 0 - - - 256 - 0 - - - - + + QAbstractScrollArea::AdjustToContents - - - - Computers to recieve this event - - - - - - QAbstractScrollArea::AdjustToContents - - - QAbstractItemView::NoSelection - - - - - - - - - - Qt::Horizontal - - - - - - - - - Switch to - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - - - - - - - - - Direction to move - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - - left - - - - - right - - - - - up - - - - - down - - - - - - - - - - - - Cursor lock will - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - - toggle - - - - - on - - - - - off - - - - - -