Less cramped keybind descriptions, also explain multi-selection

This commit is contained in:
LordGrimmauld 2024-03-13 21:43:57 +01:00
parent 62b7f88a86
commit 4e6afa08fd
16 changed files with 71 additions and 26 deletions

View File

@ -49,6 +49,7 @@ set(PROJECT_SOURCES
Keys/ToggleDetailsKeyListener.h Keys/ToggleDetailsKeyListener.h
sway_bindings/SwayRecords.cpp sway_bindings/SwayRecords.cpp
sway_bindings/SwayRecords.h sway_bindings/SwayRecords.h
Keys/DummyKeyListener.h
) )
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)

View File

@ -22,9 +22,9 @@ public:
return false; 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; [[nodiscard]] virtual bool canAcceptKey(int key) const = 0;
}; };

View File

@ -19,11 +19,11 @@ public:
} }
} }
std::string getDescription() override { const std::string getDescription() override {
return "Close help menu"; return "Close help menu";
} }
std::string getKeyText() override { const std::string getKeyText() override {
return "?, ESC, q"; return "?, ESC, q";
} }

View File

@ -31,11 +31,11 @@ public:
updateMainWindow(); updateMainWindow();
} }
std::string getDescription() override { const std::string getDescription() override {
return "Close selected windows"; return "Close selected windows";
} }
std::string getKeyText() override { const std::string getKeyText() override {
return "Q / DEL"; return "Q / DEL";
} }

View File

@ -13,11 +13,11 @@ public:
QApplication::quit(); QApplication::quit();
} }
std::string getDescription() override { const std::string getDescription() override {
return "Exit Swaymux"; return "Exit Swaymux";
} }
std::string getKeyText() override { const std::string getKeyText() override {
return "ESC"; return "ESC";
} }

View File

@ -29,11 +29,11 @@ public:
QApplication::quit(); QApplication::quit();
} }
std::string getDescription() override { const std::string getDescription() override {
return "Create and switch to new empty workspace on selected output"; return "Create and switch to new empty workspace on selected output";
} }
std::string getKeyText() override { const std::string getKeyText() override {
return "C"; return "C";
} }

41
Keys/DummyKeyListener.h Normal file
View File

@ -0,0 +1,41 @@
//
// Created by grimmauld on 11.03.24.
//
#ifndef SWAYMUX_DUMMYKEYLISTENER_H
#define SWAYMUX_DUMMYKEYLISTENER_H
#include <utility>
#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

View File

@ -18,11 +18,11 @@ public:
} }
} }
std::string getDescription() override { const std::string getDescription() override {
return "View this help menu"; return "View this help menu";
} }
std::string getKeyText() override { const std::string getKeyText() override {
return "?"; return "?";
} }

View File

@ -33,11 +33,11 @@ public:
updateMainWindow(); updateMainWindow();
} }
std::string getDescription() override { const std::string getDescription() override {
return "Move selected windows to scratchpad"; return "Move selected windows to scratchpad";
} }
std::string getKeyText() override { const std::string getKeyText() override {
return "-"; return "-";
} }

View File

@ -11,11 +11,11 @@ public:
explicit NextOutputKeyListener(SwayTreeModel *swayTreeModel, QTreeView *treeView) : JumpOutputKeyListener( explicit NextOutputKeyListener(SwayTreeModel *swayTreeModel, QTreeView *treeView) : JumpOutputKeyListener(
swayTreeModel, treeView) {}; swayTreeModel, treeView) {};
std::string getDescription() override { const std::string getDescription() override {
return "Jump focus to output below"; return "Jump focus to output below";
} }
std::string getKeyText() override { const std::string getKeyText() override {
return "Page Down"; return "Page Down";
} }

View File

@ -18,11 +18,11 @@ public:
explicit PrevOutputKeyListener(SwayTreeModel *swayTreeModel, QTreeView *treeView) : JumpOutputKeyListener( explicit PrevOutputKeyListener(SwayTreeModel *swayTreeModel, QTreeView *treeView) : JumpOutputKeyListener(
swayTreeModel, treeView) {}; swayTreeModel, treeView) {};
std::string getDescription() override { const std::string getDescription() override {
return "Jump focus to output above"; return "Jump focus to output above";
} }
std::string getKeyText() override { const std::string getKeyText() override {
return "Page Up"; return "Page Up";
} }

View File

@ -35,11 +35,11 @@ public:
updateMainWindow(); updateMainWindow();
} }
std::string getDescription() override { const std::string getDescription() override {
return "Restore selected windows to a new workspace"; return "Restore selected windows to a new workspace";
} }
std::string getKeyText() override { const std::string getKeyText() override {
return "+"; return "+";
} }

View File

@ -80,11 +80,11 @@ public:
QApplication::quit(); QApplication::quit();
} }
std::string getDescription() override { const std::string getDescription() override {
return "Switch to selected container(s)"; return "Switch to selected container(s)";
} }
std::string getKeyText() override { const std::string getKeyText() override {
return "Enter"; return "Enter";
} }

View File

@ -18,11 +18,11 @@ public:
window->ui->windowDetails->hide(); window->ui->windowDetails->hide();
} }
std::string getDescription() override { const std::string getDescription() override {
return "toggle window detail view"; return "toggle window detail view";
} }
std::string getKeyText() override { const std::string getKeyText() override {
return "Tab"; return "Tab";
} }

View File

@ -2,8 +2,6 @@
#include <QApplication> #include <QApplication>
using namespace Qt::StringLiterals;
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using json = nlohmann::json;

View File

@ -12,6 +12,7 @@
#include "Keys/MoveToScratchpadKeyListener.h" #include "Keys/MoveToScratchpadKeyListener.h"
#include "Keys/RestoreKeyListener.h" #include "Keys/RestoreKeyListener.h"
#include "Keys/ToggleDetailsKeyListener.h" #include "Keys/ToggleDetailsKeyListener.h"
#include "Keys/DummyKeyListener.h"
#include <QTimer> #include <QTimer>
#include <iostream> #include <iostream>
@ -36,6 +37,8 @@ MainWindow::MainWindow(QWidget *parent)
swayTreeKeyHandler->addListener(new MoveToScratchpadKeyListener(this)); swayTreeKeyHandler->addListener(new MoveToScratchpadKeyListener(this));
swayTreeKeyHandler->addListener(new RestoreKeyListener(this)); swayTreeKeyHandler->addListener(new RestoreKeyListener(this));
swayTreeKeyHandler->addListener(new ToggleDetailsKeyListener(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 = new KeyHandler(ui->tree_page);
closeHelpKeyHandler->addListener(new CloseHelpKeyListener(ui->tree_page)); closeHelpKeyHandler->addListener(new CloseHelpKeyListener(ui->tree_page));
@ -45,6 +48,7 @@ MainWindow::MainWindow(QWidget *parent)
ui->tableView->setModel(swayTreeKeyHandler); ui->tableView->setModel(swayTreeKeyHandler);
ui->tableView->resizeColumnsToContents(); ui->tableView->resizeColumnsToContents();
ui->tableView->resizeRowsToContents();
ui->tableView->installEventFilter(closeHelpKeyHandler); ui->tableView->installEventFilter(closeHelpKeyHandler);
ui->windowDetails->hide(); ui->windowDetails->hide();
@ -96,5 +100,6 @@ void MainWindow::selChanged() const {
ui->windowDetails->setModel(nullptr); ui->windowDetails->setModel(nullptr);
ui->windowDetails->setModel(&selected->node); ui->windowDetails->setModel(&selected->node);
ui->windowDetails->resizeColumnsToContents(); ui->windowDetails->resizeColumnsToContents();
ui->windowDetails->resizeRowsToContents();
ui->windowDetails->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); ui->windowDetails->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
} }