From 0dfab2456b2dcd33f1879ac7d5606dd65cdb8e40 Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Mon, 26 Jun 2023 20:11:24 -0400 Subject: Create QActions for Random & Copy buttons --- src/mainwindow.cpp | 6 ++++-- src/mainwindow.h | 4 ++-- src/mainwindow.ui | 38 +++++++++++++++++++++++++++++++------- 3 files changed, 37 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b9b268c..b9c4e8e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -15,6 +15,8 @@ MainWindow::MainWindow(QWidget *parent) , ui(new Ui::MainWindow) { ui->setupUi(this); + connect(ui->buttonCopy, &QPushButton::clicked, ui->actionCopy_status, &QAction::trigger); + connect(ui->buttonRandom, &QPushButton::clicked, ui->actionRandom_status, &QAction::trigger); } MainWindow::~MainWindow() @@ -66,7 +68,7 @@ void MainWindow::on_listWidget_itemActivated(QListWidgetItem *item) { } } -void MainWindow::on_buttonRandom_clicked() { +void MainWindow::on_actionRandom_status_triggered(bool checked) { if (data_archive == nullptr) return; // No archive open, avoids crashing int index = QRandomGenerator::global()->bounded(ui->listWidget->count()); @@ -75,7 +77,7 @@ void MainWindow::on_buttonRandom_clicked() { ui->listWidget->setCurrentItem(item); } -void MainWindow::on_buttonCopy_clicked() { +void MainWindow::on_actionCopy_status_triggered(bool checked) { if (data_archive == nullptr or ui->listWidget->selectedItems().isEmpty()) return; StatusListItem* item = dynamic_cast(ui->listWidget->selectedItems()[0]); diff --git a/src/mainwindow.h b/src/mainwindow.h index a856dbe..f1de2d7 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -34,9 +34,9 @@ private slots: void on_actionDirect_messages_triggered(bool checked); void on_actionOnly_with_attachment_triggered(bool checked); void on_actionReblogs_triggered(bool checked); + void on_actionRandom_status_triggered(bool checked); + void on_actionCopy_status_triggered(bool checked); - void on_buttonRandom_clicked(); - void on_buttonCopy_clicked(); void on_buttonSearch_clicked(); void on_menuView_aboutToHide(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 0dbf777..f4a9263 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -29,6 +29,13 @@ + + + + true + + + @@ -47,13 +54,6 @@ - - - - true - - - @@ -114,8 +114,22 @@ p, li { white-space: pre-wrap; } + + + Go + + + + + + Edit + + + + + @@ -223,6 +237,16 @@ p, li { white-space: pre-wrap; } Show reblogs + + + Random status + + + + + Copy status text + + listWidget -- cgit v1.2.3-54-g00ecf