From 5dbf23b0181cc53d2e38d1b5d930c722bec45c04 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 14 Oct 2018 04:29:11 +0200 Subject: [PATCH] Qt: Moved the signal-setup to the .ui-files, UI tweaks --- CMakeLists.txt | 2 +- src/interface_qt.cpp | 15 +---- src/interface_qt.hpp | 3 +- src/whyblocked.ui | 142 +++++++++++++++++++++++++++++++++++++++++- src/whyblocked_add.ui | 50 ++++++++++++--- 5 files changed, 187 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 109a27c..cd3ced6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.6) project (whyblocked - VERSION 0.7.5 + VERSION 0.7.6 LANGUAGES CXX ) diff --git a/src/interface_qt.cpp b/src/interface_qt.cpp index 89546d6..0a107aa 100644 --- a/src/interface_qt.cpp +++ b/src/interface_qt.cpp @@ -27,17 +27,7 @@ MainWindow::MainWindow(QMainWindow *parent) : QMainWindow(parent) _model = new QStandardItemModel; tableview->setModel(_model); - tableview->setSelectionBehavior(QAbstractItemView::SelectRows); populate_tableview(); - - connect(action_add, &QAction::triggered, this, &MainWindow::add); - connect(action_remove, &QAction::triggered, this, &MainWindow::remove); - connect(action_reload, &QAction::triggered, this, &MainWindow::populate_tableview); - connect(action_about, &QAction::triggered, this, &MainWindow::about); - connect(action_quit, &QAction::triggered, this, &MainWindow::close); - - connect(tableview, &QTableView::clicked, this, &MainWindow::show_details); - connect(tableview, &QTableView::activated, this, &MainWindow::show_details); } void MainWindow::populate_tableview() @@ -57,7 +47,7 @@ void MainWindow::populate_tableview() _model->setHeaderData(0, Qt::Horizontal, tr("User/Instance")); _model->setHeaderData(1, Qt::Horizontal, tr("Blocked/Silenced?")); _model->setHeaderData(2, Qt::Horizontal, tr("Reason")); - tableview->horizontalHeader()->resizeSection(0, 300); + tableview->horizontalHeader()->resizeSection(0, 250); statusBar()->showMessage(tr("Database loaded.")); } @@ -152,9 +142,6 @@ DialogAdd::DialogAdd(QMainWindow *parent) , _parent(static_cast(parent)) { setupUi(this); - - connect(button_receipt_add, &QPushButton::clicked, this, &DialogAdd::add_receipt); - connect(button_receipt_remove, &QPushButton::clicked, this, &DialogAdd::remove_receipt); } const dialogdata DialogAdd::get_data() diff --git a/src/interface_qt.hpp b/src/interface_qt.hpp index 8d21fdd..409069f 100644 --- a/src/interface_qt.hpp +++ b/src/interface_qt.hpp @@ -41,7 +41,6 @@ public: void add_row(const QString &user, const int &blocked, const QString &reason); private: - void populate_tableview(); const string urls_to_hyperlinks(const string &text); QStandardItemModel *_model; @@ -51,6 +50,7 @@ private slots: void remove(); void about(); void show_details(QModelIndex index); + void populate_tableview(); }; @@ -63,6 +63,7 @@ public: private: const dialogdata get_data(); + MainWindow *_parent; private slots: diff --git a/src/whyblocked.ui b/src/whyblocked.ui index 668fb06..f83cec6 100644 --- a/src/whyblocked.ui +++ b/src/whyblocked.ui @@ -26,8 +26,23 @@ QAbstractItemView::NoEditTriggers + + true + + + QAbstractItemView::SelectRows + + + false + + + true + + + true + - 100 + 125 true @@ -35,6 +50,9 @@ true + + false + @@ -176,5 +194,125 @@ - + + + action_about + triggered() + MainWindow + about() + + + -1 + -1 + + + 299 + 299 + + + + + action_add + triggered() + MainWindow + add() + + + -1 + -1 + + + 299 + 299 + + + + + action_quit + triggered() + MainWindow + close() + + + -1 + -1 + + + 299 + 299 + + + + + action_reload + triggered() + MainWindow + populate_tableview() + + + -1 + -1 + + + 299 + 299 + + + + + action_remove + triggered() + MainWindow + remove() + + + -1 + -1 + + + 299 + 299 + + + + + tableview + activated(QModelIndex) + MainWindow + show_details(QModelIndex) + + + 182 + 390 + + + 203 + 551 + + + + + tableview + clicked(QModelIndex) + MainWindow + show_details(QModelIndex) + + + 387 + 408 + + + 412 + 551 + + + + + + add() + remove() + populate_tableview() + about() + show_details(QModelIndex) + diff --git a/src/whyblocked_add.ui b/src/whyblocked_add.ui index 04c930e..5013110 100644 --- a/src/whyblocked_add.ui +++ b/src/whyblocked_add.ui @@ -186,12 +186,12 @@ accept() - 227 - 256 + 324 + 268 - 157 - 169 + 331 + 226 @@ -202,14 +202,50 @@ reject() - 290 + 255 262 - 286 - 169 + 265 + 224 + + + + + button_receipt_add + clicked() + DialogAdd + add_receipt() + + + 41 + 207 + + + 115 + 156 + + + + + button_receipt_remove + clicked() + DialogAdd + remove_receipt() + + + 95 + 245 + + + 135 + 190 + + add_receipt() + remove_receipt() +