diff options
author | ConfuSomu | 2022-12-26 01:58:10 -0500 |
---|---|---|
committer | ConfuSomu | 2022-12-26 01:58:10 -0500 |
commit | 0063f4f7885fe33b99728434241f6ef28168b245 (patch) | |
tree | 5b73a92ad9d8082da4a26cab9e82aca5edd04d1d /src | |
parent | 54216c4c28b81d33bd5c8b6e3b5a6083b53093fd (diff) | |
download | ActorViewer-0063f4f7885fe33b99728434241f6ef28168b245.tar ActorViewer-0063f4f7885fe33b99728434241f6ef28168b245.tar.gz ActorViewer-0063f4f7885fe33b99728434241f6ef28168b245.zip |
Work on basic gui
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 75 | ||||
-rw-r--r-- | src/mainwindow.h | 22 | ||||
-rw-r--r-- | src/mainwindow.ui | 4 |
3 files changed, 95 insertions, 6 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 156df67..58ea9d9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include "./ui_mainwindow.h" +#include <QFileDialog> #include <QMessageBox> MainWindow::MainWindow(QWidget *parent) @@ -8,7 +9,6 @@ MainWindow::MainWindow(QWidget *parent) , ui(new Ui::MainWindow) { ui->setupUi(this); - QMetaObject::connectSlotsByName(this); } MainWindow::~MainWindow() @@ -17,7 +17,74 @@ MainWindow::~MainWindow() } void MainWindow::on_actionOpen_triggered(bool checked) { - QMessageBox msgBox; - msgBox.setText("It works!"); - msgBox.exec(); + QFileDialog fileDialog; + fileDialog.setFileMode(QFileDialog::AnyFile); + fileDialog.setNameFilter(tr("Mastodon data export directory (outbox.json)")); + if (fileDialog.exec()) { + QStringList files = fileDialog.selectedFiles(); + outbox_filename = files[0]; + ui->statusInfoText->setText(outbox_filename); + } +} + +void MainWindow::on_actionQuit_triggered(bool checked) { + QCoreApplication::quit(); +} + +void MainWindow::on_actionAbout_triggered(bool checked) { + QMessageBox::information(this, "title", "text"); +} + +void MainWindow::reset_view_filters() { + if (ui->actionAll_toots->isChecked()) + view_filters = {true, true, true, true, view_filters.onlyWithAttachment}; + else + view_filters = {false, false, false, false, view_filters.onlyWithAttachment}; +} + +void MainWindow::on_actionAll_toots_triggered(bool checked) { + ui->actionAll_toots->setChecked(true); + ui->actionPublic_toots->setChecked(false); + ui->actionUnlisted_toots->setChecked(false); + ui->actionPrivate_toots->setChecked(false); + ui->actionDirect_messages->setChecked(false); + ui->actionOnly_with_attachment->setChecked(false); + + reset_view_filters(); +} + +void MainWindow::on_actionPublic_toots_triggered(bool checked) { + if (ui->actionAll_toots->isChecked()) { + ui->actionAll_toots->setChecked(false); + reset_view_filters(); + } + view_filters.includePublic = checked; +} + +void MainWindow::on_actionUnlisted_toots_triggered(bool checked) { + if (ui->actionAll_toots->isChecked()) { + ui->actionAll_toots->setChecked(false); + reset_view_filters(); + } + view_filters.includeUnlisted = checked; +} + +void MainWindow::on_actionPrivate_toots_triggered(bool checked) { + if (ui->actionAll_toots->isChecked()) { + ui->actionAll_toots->setChecked(false); + reset_view_filters(); + } + view_filters.includePrivate = checked; +} + +void MainWindow::on_actionDirect_messages_triggered(bool checked) { + if (ui->actionAll_toots->isChecked()) { + ui->actionAll_toots->setChecked(false); + reset_view_filters(); + } + view_filters.includeDirect = checked; +} + +void MainWindow::on_actionOnly_with_attachment_triggered(bool checked) { + view_filters.onlyWithAttachment = checked; } diff --git a/src/mainwindow.h b/src/mainwindow.h index c2ab2b3..d9c62bf 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -4,6 +4,14 @@ #include <QMainWindow> #include <qobjectdefs.h> +struct ViewTootTypes { + bool includePublic = true; + bool includeUnlisted = true; + bool includePrivate = true; + bool includeDirect = true; + bool onlyWithAttachment = false; +}; + QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE @@ -18,8 +26,22 @@ public: private slots: void on_actionOpen_triggered(bool checked); + void on_actionQuit_triggered(bool checked); + void on_actionAbout_triggered(bool checked); + + void on_actionAll_toots_triggered(bool checked); + void on_actionPublic_toots_triggered(bool checked); + void on_actionUnlisted_toots_triggered(bool checked); + void on_actionPrivate_toots_triggered(bool checked); + void on_actionDirect_messages_triggered(bool checked); + void on_actionOnly_with_attachment_triggered(bool checked); private: + void reset_view_filters(); + Ui::MainWindow *ui; + + QString outbox_filename; + ViewTootTypes view_filters; }; #endif // MAINWINDOW_H diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 3e949cf..a89812b 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -19,7 +19,7 @@ <widget class="QListWidget" name="listWidget"/> </item> <item> - <widget class="QTextBrowser" name="textBrowser"> + <widget class="QTextBrowser" name="statusInfoText"> <property name="html"> <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> @@ -166,7 +166,7 @@ p, li { white-space: pre-wrap; } </widget> <tabstops> <tabstop>listWidget</tabstop> - <tabstop>textBrowser</tabstop> + <tabstop>statusInfoText</tabstop> </tabstops> <resources/> <connections/> |