Less cramped keybind descriptions, also explain multi-selection
This commit is contained in:
parent
62b7f88a86
commit
4e6afa08fd
16 changed files with 71 additions and 26 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
41
Keys/DummyKeyListener.h
Normal file
41
Keys/DummyKeyListener.h
Normal 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
|
|
@ -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 "?";
|
||||
}
|
||||
|
||||
|
|
|
@ -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 "-";
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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 "+";
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
2
main.cpp
2
main.cpp
|
@ -2,8 +2,6 @@
|
|||
|
||||
#include <QApplication>
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "Keys/MoveToScratchpadKeyListener.h"
|
||||
#include "Keys/RestoreKeyListener.h"
|
||||
#include "Keys/ToggleDetailsKeyListener.h"
|
||||
#include "Keys/DummyKeyListener.h"
|
||||
#include <QTimer>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue