swaymux/mainwindow.cpp

65 lines
2.4 KiB
C++
Raw Normal View History

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"
#include "Keys/HelpKeyListener.h"
#include "Keys/CloseHelpKeyListener.h"
2024-03-08 10:53:30 +01:00
#include "Keys/CreateWorkspaceKeyListener.h"
#include "Keys/CloseSwaymuxKeyListener.h"
#include "Keys/SwitchToKeybindListener.h"
#include "Keys/PrevOutputKeyListener.h"
#include "Keys/NextOutputKeyListener.h"
#include "Keys/NextOutputKeyListener.h"
2024-03-02 22:33:27 +01:00
#include <QTimer>
#include <iostream>
2024-03-02 22:33:27 +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);
// 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();
ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
ui->treeView->selectionModel()->setCurrentIndex(model->findFocusedWindowIndex(), QItemSelectionModel::ClearAndSelect);
2024-03-02 22:33:27 +01:00
for (int c = 0; c < model->columnCount(); ++c)
ui->treeView->resizeColumnToContents(c);
swayTreeKeyHandler = new KeyHandler();
swayTreeKeyHandler->addListener(new HelpKeyListener(ui->help_page));
swayTreeKeyHandler->addListener(new CloseSwaymuxKeyListener());
2024-03-08 10:53:30 +01:00
swayTreeKeyHandler->addListener(new CreateWorkspaceKeyListener(model, ui->treeView));
swayTreeKeyHandler->addListener(new SwitchToKeybindListener(model, ui->treeView));
swayTreeKeyHandler->addListener(new PrevOutputKeyListener(model, ui->treeView));
swayTreeKeyHandler->addListener(new NextOutputKeyListener(model, ui->treeView));
2024-03-07 20:44:00 +01:00
closeHelpKeyHandler = new KeyHandler(ui->tree_page);
closeHelpKeyHandler->addListener(new CloseHelpKeyListener(ui->tree_page));
2024-03-07 20:44:00 +01:00
ui->stackedWidget->setCurrentWidget(ui->tree_page);
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;
delete swayTreeKeyHandler;
delete closeHelpKeyHandler;
2024-03-02 22:33:27 +01:00
}
void MainWindow::keyPressEvent(QKeyEvent *event) {
if (event->key() == Qt::Key_W) {
qDebug() << "hi";
}
}