diff --git a/CMakeLists.txt b/CMakeLists.txt index b137ca7..c8de539 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,7 @@ set(PROJECT_SOURCES Keys/ToggleDetailsKeyListener.h sway_bindings/SwayRecords.cpp sway_bindings/SwayRecords.h + Keys/DummyKeyListener.h ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) diff --git a/Keys/AbstractKeyListener.h b/Keys/AbstractKeyListener.h index 783cfb7..3269128 100644 --- a/Keys/AbstractKeyListener.h +++ b/Keys/AbstractKeyListener.h @@ -22,9 +22,9 @@ public: return false; } - virtual std::string getDescription() = 0; + virtual const std::string getDescription() = 0; - virtual std::string getKeyText() = 0; + virtual const std::string getKeyText() = 0; [[nodiscard]] virtual bool canAcceptKey(int key) const = 0; }; diff --git a/Keys/CloseHelpKeyListener.h b/Keys/CloseHelpKeyListener.h index 8e7e8c7..87b0f2b 100644 --- a/Keys/CloseHelpKeyListener.h +++ b/Keys/CloseHelpKeyListener.h @@ -19,11 +19,11 @@ public: } } - std::string getDescription() override { + const std::string getDescription() override { return "Close help menu"; } - std::string getKeyText() override { + const std::string getKeyText() override { return "?, ESC, q"; } diff --git a/Keys/CloseKeyListener.h b/Keys/CloseKeyListener.h index 84de6ef..d42dba8 100644 --- a/Keys/CloseKeyListener.h +++ b/Keys/CloseKeyListener.h @@ -31,11 +31,11 @@ public: updateMainWindow(); } - std::string getDescription() override { + const std::string getDescription() override { return "Close selected windows"; } - std::string getKeyText() override { + const std::string getKeyText() override { return "Q / DEL"; } diff --git a/Keys/CloseSwaymuxKeyListener.h b/Keys/CloseSwaymuxKeyListener.h index 15bf7b8..a3bd182 100644 --- a/Keys/CloseSwaymuxKeyListener.h +++ b/Keys/CloseSwaymuxKeyListener.h @@ -13,11 +13,11 @@ public: QApplication::quit(); } - std::string getDescription() override { + const std::string getDescription() override { return "Exit Swaymux"; } - std::string getKeyText() override { + const std::string getKeyText() override { return "ESC"; } diff --git a/Keys/CreateWorkspaceKeyListener.h b/Keys/CreateWorkspaceKeyListener.h index e5b2401..9ebd673 100644 --- a/Keys/CreateWorkspaceKeyListener.h +++ b/Keys/CreateWorkspaceKeyListener.h @@ -29,11 +29,11 @@ public: QApplication::quit(); } - std::string getDescription() override { + const std::string getDescription() override { return "Create and switch to new empty workspace on selected output"; } - std::string getKeyText() override { + const std::string getKeyText() override { return "C"; } diff --git a/Keys/DummyKeyListener.h b/Keys/DummyKeyListener.h new file mode 100644 index 0000000..5c7c95d --- /dev/null +++ b/Keys/DummyKeyListener.h @@ -0,0 +1,41 @@ +// +// Created by grimmauld on 11.03.24. +// + +#ifndef SWAYMUX_DUMMYKEYLISTENER_H +#define SWAYMUX_DUMMYKEYLISTENER_H + + +#include + +#include "AbstractKeyListener.h" + +class DummyKeyListener : public AbstractKeyListener { +public: + explicit DummyKeyListener(std::string description, std::string keyText) : description(std::move(description)), + keyText(std::move(keyText)), + AbstractKeyListener() {} + + void handleKeyEvent(const QKeyEvent *keyEvent) const override {} + + const std::string getDescription() override { + return description; + } + + const std::string getKeyText() override { + return keyText; + } + + [[nodiscard]] bool canAcceptKey(int key) const override { + return false; + } + + +private: + const std::string description; + const std::string keyText; + +}; + + +#endif //SWAYMUX_DUMMYKEYLISTENER_H diff --git a/Keys/HelpKeyListener.h b/Keys/HelpKeyListener.h index 20947eb..f16c4b8 100644 --- a/Keys/HelpKeyListener.h +++ b/Keys/HelpKeyListener.h @@ -18,11 +18,11 @@ public: } } - std::string getDescription() override { + const std::string getDescription() override { return "View this help menu"; } - std::string getKeyText() override { + const std::string getKeyText() override { return "?"; } diff --git a/Keys/MoveToScratchpadKeyListener.h b/Keys/MoveToScratchpadKeyListener.h index 92e5ff6..3090c0a 100644 --- a/Keys/MoveToScratchpadKeyListener.h +++ b/Keys/MoveToScratchpadKeyListener.h @@ -33,11 +33,11 @@ public: updateMainWindow(); } - std::string getDescription() override { + const std::string getDescription() override { return "Move selected windows to scratchpad"; } - std::string getKeyText() override { + const std::string getKeyText() override { return "-"; } diff --git a/Keys/NextOutputKeyListener.h b/Keys/NextOutputKeyListener.h index fb44bed..538812b 100644 --- a/Keys/NextOutputKeyListener.h +++ b/Keys/NextOutputKeyListener.h @@ -11,11 +11,11 @@ public: explicit NextOutputKeyListener(SwayTreeModel *swayTreeModel, QTreeView *treeView) : JumpOutputKeyListener( swayTreeModel, treeView) {}; - std::string getDescription() override { + const std::string getDescription() override { return "Jump focus to output below"; } - std::string getKeyText() override { + const std::string getKeyText() override { return "Page Down"; } diff --git a/Keys/PrevOutputKeyListener.h b/Keys/PrevOutputKeyListener.h index 24109ae..fc668a6 100644 --- a/Keys/PrevOutputKeyListener.h +++ b/Keys/PrevOutputKeyListener.h @@ -18,11 +18,11 @@ public: explicit PrevOutputKeyListener(SwayTreeModel *swayTreeModel, QTreeView *treeView) : JumpOutputKeyListener( swayTreeModel, treeView) {}; - std::string getDescription() override { + const std::string getDescription() override { return "Jump focus to output above"; } - std::string getKeyText() override { + const std::string getKeyText() override { return "Page Up"; } diff --git a/Keys/RestoreKeyListener.h b/Keys/RestoreKeyListener.h index 00116fd..e3d16db 100644 --- a/Keys/RestoreKeyListener.h +++ b/Keys/RestoreKeyListener.h @@ -35,11 +35,11 @@ public: updateMainWindow(); } - std::string getDescription() override { + const std::string getDescription() override { return "Restore selected windows to a new workspace"; } - std::string getKeyText() override { + const std::string getKeyText() override { return "+"; } diff --git a/Keys/SwitchToKeybindListener.h b/Keys/SwitchToKeybindListener.h index acbdc48..1f28272 100644 --- a/Keys/SwitchToKeybindListener.h +++ b/Keys/SwitchToKeybindListener.h @@ -80,11 +80,11 @@ public: QApplication::quit(); } - std::string getDescription() override { + const std::string getDescription() override { return "Switch to selected container(s)"; } - std::string getKeyText() override { + const std::string getKeyText() override { return "Enter"; } diff --git a/Keys/ToggleDetailsKeyListener.h b/Keys/ToggleDetailsKeyListener.h index b353b19..c3368aa 100644 --- a/Keys/ToggleDetailsKeyListener.h +++ b/Keys/ToggleDetailsKeyListener.h @@ -18,11 +18,11 @@ public: window->ui->windowDetails->hide(); } - std::string getDescription() override { + const std::string getDescription() override { return "toggle window detail view"; } - std::string getKeyText() override { + const std::string getKeyText() override { return "Tab"; } diff --git a/main.cpp b/main.cpp index ac52d58..c970eff 100644 --- a/main.cpp +++ b/main.cpp @@ -2,8 +2,6 @@ #include -using namespace Qt::StringLiterals; - #include using json = nlohmann::json; diff --git a/mainwindow.cpp b/mainwindow.cpp index 4be571a..54d3a44 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -12,6 +12,7 @@ #include "Keys/MoveToScratchpadKeyListener.h" #include "Keys/RestoreKeyListener.h" #include "Keys/ToggleDetailsKeyListener.h" +#include "Keys/DummyKeyListener.h" #include #include @@ -36,6 +37,8 @@ MainWindow::MainWindow(QWidget *parent) swayTreeKeyHandler->addListener(new MoveToScratchpadKeyListener(this)); swayTreeKeyHandler->addListener(new RestoreKeyListener(this)); swayTreeKeyHandler->addListener(new ToggleDetailsKeyListener(this)); + swayTreeKeyHandler->addListener(new DummyKeyListener("While navigating: keep old selection", "Ctrl")); + swayTreeKeyHandler->addListener(new DummyKeyListener("Toggle selection state in multi-selection", "Space")); closeHelpKeyHandler = new KeyHandler(ui->tree_page); closeHelpKeyHandler->addListener(new CloseHelpKeyListener(ui->tree_page)); @@ -45,6 +48,7 @@ MainWindow::MainWindow(QWidget *parent) ui->tableView->setModel(swayTreeKeyHandler); ui->tableView->resizeColumnsToContents(); + ui->tableView->resizeRowsToContents(); ui->tableView->installEventFilter(closeHelpKeyHandler); ui->windowDetails->hide(); @@ -96,5 +100,6 @@ void MainWindow::selChanged() const { ui->windowDetails->setModel(nullptr); ui->windowDetails->setModel(&selected->node); ui->windowDetails->resizeColumnsToContents(); + ui->windowDetails->resizeRowsToContents(); ui->windowDetails->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); } \ No newline at end of file