2024-03-02 22:33:27 +01:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "./ui_mainwindow.h"
|
2024-03-04 00:27:05 +01:00
|
|
|
#include "tree/SwayTreeModel.h"
|
2024-03-07 17:37:18 +01:00
|
|
|
#include "Keys/HelpKeyListener.h"
|
|
|
|
#include "Keys/CloseHelpKeyListener.h"
|
2024-03-08 10:53:30 +01:00
|
|
|
#include "Keys/CreateWorkspaceKeyListener.h"
|
2024-03-08 13:13:28 +01:00
|
|
|
#include "Keys/CloseSwaymuxKeyListener.h"
|
2024-03-09 12:55:29 +01:00
|
|
|
#include "Keys/SwitchToKeybindListener.h"
|
2024-03-09 23:44:43 +01:00
|
|
|
#include "Keys/PrevOutputKeyListener.h"
|
|
|
|
#include "Keys/NextOutputKeyListener.h"
|
|
|
|
#include "Keys/NextOutputKeyListener.h"
|
2024-03-02 22:33:27 +01:00
|
|
|
#include <QTimer>
|
2024-03-06 23:40:48 +01:00
|
|
|
#include <iostream>
|
2024-03-02 22:33:27 +01:00
|
|
|
|
2024-03-07 17:37:18 +01:00
|
|
|
|
2024-03-02 22:33:27 +01:00
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
|
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2024-03-04 00:27:05 +01:00
|
|
|
model = new SwayTreeModel(ui->treeView);
|
2024-03-07 17:37:18 +01:00
|
|
|
// modelUpdateTimer = new QTimer(this);
|
|
|
|
// connect(modelUpdateTimer, &QTimer::timeout, this, QOverload<>::of(&MainWindow::update));
|
|
|
|
// modelUpdateTimer->start(1000);
|
2024-03-02 22:33:27 +01:00
|
|
|
|
2024-03-09 17:58:15 +01:00
|
|
|
ui->statusbar->showMessage(QString::fromStdString("Press ? for keybind listing"));
|
2024-03-02 22:33:27 +01:00
|
|
|
ui->treeView->setModel(model);
|
|
|
|
ui->treeView->expandAll();
|
|
|
|
|
2024-03-06 23:40:48 +01:00
|
|
|
ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
2024-03-09 18:48:04 +01:00
|
|
|
ui->treeView->selectionModel()->setCurrentIndex(model->findFocusedWindowIndex(), QItemSelectionModel::ClearAndSelect);
|
2024-03-06 23:40:48 +01:00
|
|
|
|
2024-03-02 22:33:27 +01:00
|
|
|
for (int c = 0; c < model->columnCount(); ++c)
|
|
|
|
ui->treeView->resizeColumnToContents(c);
|
2024-03-07 17:37:18 +01:00
|
|
|
|
|
|
|
swayTreeKeyHandler = new KeyHandler();
|
|
|
|
swayTreeKeyHandler->addListener(new HelpKeyListener(ui->help_page));
|
2024-03-08 13:13:28 +01:00
|
|
|
swayTreeKeyHandler->addListener(new CloseSwaymuxKeyListener());
|
2024-03-08 10:53:30 +01:00
|
|
|
swayTreeKeyHandler->addListener(new CreateWorkspaceKeyListener(model, ui->treeView));
|
2024-03-09 12:55:29 +01:00
|
|
|
swayTreeKeyHandler->addListener(new SwitchToKeybindListener(model, ui->treeView));
|
2024-03-09 23:44:43 +01:00
|
|
|
swayTreeKeyHandler->addListener(new PrevOutputKeyListener(model, ui->treeView));
|
|
|
|
swayTreeKeyHandler->addListener(new NextOutputKeyListener(model, ui->treeView));
|
2024-03-07 17:37:18 +01:00
|
|
|
|
2024-03-07 20:44:00 +01:00
|
|
|
closeHelpKeyHandler = new KeyHandler(ui->tree_page);
|
2024-03-07 17:37:18 +01:00
|
|
|
closeHelpKeyHandler->addListener(new CloseHelpKeyListener(ui->tree_page));
|
|
|
|
|
2024-03-07 20:44:00 +01:00
|
|
|
ui->stackedWidget->setCurrentWidget(ui->tree_page);
|
2024-03-07 17:37:18 +01:00
|
|
|
ui->treeView->installEventFilter(swayTreeKeyHandler);
|
2024-03-07 20:44:00 +01:00
|
|
|
|
|
|
|
ui->tableView->setModel(swayTreeKeyHandler);
|
|
|
|
ui->tableView->resizeColumnsToContents();
|
|
|
|
ui->tableView->installEventFilter(closeHelpKeyHandler);
|
2024-03-02 22:33:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow() {
|
|
|
|
delete ui;
|
|
|
|
delete model;
|
2024-03-07 17:37:18 +01:00
|
|
|
delete swayTreeKeyHandler;
|
|
|
|
delete closeHelpKeyHandler;
|
2024-03-02 22:33:27 +01:00
|
|
|
}
|
|
|
|
|
2024-03-07 17:37:18 +01:00
|
|
|
void MainWindow::keyPressEvent(QKeyEvent *event) {
|
|
|
|
if (event->key() == Qt::Key_W) {
|
|
|
|
qDebug() << "hi";
|
|
|
|
}
|
|
|
|
}
|