diff options
author | ConfuSomu | 2024-05-29 22:46:29 -0400 |
---|---|---|
committer | ConfuSomu | 2024-05-29 22:46:29 -0400 |
commit | e3efc04807f946cc75b06ec84b4af79d66b23cce (patch) | |
tree | 27ee6d0aefe5ce7e45abb8e92f403eeff5d5aaa4 | |
parent | 294f7f78fe3e81bef2c23750426b53354b1b20a6 (diff) | |
download | ActorViewer-e3efc04807f946cc75b06ec84b4af79d66b23cce.tar ActorViewer-e3efc04807f946cc75b06ec84b4af79d66b23cce.tar.gz ActorViewer-e3efc04807f946cc75b06ec84b4af79d66b23cce.zip |
Implement basic Welcome tab for greeting user
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/mainwindow.cpp | 14 | ||||
-rw-r--r-- | src/mainwindow.h | 4 | ||||
-rw-r--r-- | src/widgets/tab_welcome.cpp | 24 | ||||
-rw-r--r-- | src/widgets/tab_welcome.h | 29 | ||||
-rw-r--r-- | src/widgets/tab_welcome.ui | 73 |
6 files changed, 145 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e95c601..55418ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,9 @@ set(PROJECT_SOURCES src/widgets/tab_actor_info.cpp src/widgets/tab_actor_info.h src/widgets/tab_actor_info.ui + src/widgets/tab_welcome.cpp + src/widgets/tab_welcome.h + src/widgets/tab_welcome.ui src/archive/base_archive.cpp src/archive/base_archive.h src/archive/mastodon.cpp diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 296c961..89351ae 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -27,6 +27,12 @@ MainWindow::~MainWindow() } void MainWindow::create_initial_tabs() { + welcome_tab = new TabWelcome(); + ui->tabWidget->addTab(welcome_tab, tr("Welcome")); + connect(welcome_tab, &TabWelcome::show_file_open_dialog, this, &MainWindow::on_actionOpen_triggered); + // TODO: recent files + //connect(welcome_tab, &TabWelcome::show_recent_files, this, &MainWindow::); + activity_list_tab = new TabActivityList(&data_archive); ui->tabWidget->addTab(activity_list_tab, tr("Activity List")); activity_list_tab->view_actions = { @@ -88,13 +94,19 @@ void MainWindow::act_command_line(CommandLineParsedOptions &options, QCommandLin } } -void MainWindow::on_actionOpen_triggered(bool checked) { +void MainWindow::on_actionOpen_triggered() { QFileDialog fileDialog; fileDialog.setFileMode(QFileDialog::AnyFile); fileDialog.setNameFilter(tr("Mastodon data export directory (outbox.json)")); if (fileDialog.exec()) { QStringList files = fileDialog.selectedFiles(); open_file(files[0]); + + // Close the welcome tab as it's not needed anymore + if (welcome_tab) { + welcome_tab->deleteLater(); + welcome_tab = nullptr; + } } } diff --git a/src/mainwindow.h b/src/mainwindow.h index cc43176..03daaad 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -10,6 +10,7 @@ #include "src/settingsdialog.h" #include "src/widgets/tab_activity_list.h" #include "src/widgets/tab_actor_info.h" +#include "src/widgets/tab_welcome.h" #include "command_line.h" QT_BEGIN_NAMESPACE @@ -35,7 +36,7 @@ signals: void new_archive_opened(bool is_valid); private slots: - void on_actionOpen_triggered(bool checked); + void on_actionOpen_triggered(); void on_actionSettings_triggered(bool checked); void on_actionQuit_triggered(bool checked); void on_actionAbout_triggered(bool checked); @@ -52,6 +53,7 @@ private: void settingsDialog_done(int result); SettingsDialog* settings_dialog = nullptr; + TabWelcome* welcome_tab = nullptr; TabActivityList* activity_list_tab = nullptr; TabActorInfo* actor_info_tab = nullptr; diff --git a/src/widgets/tab_welcome.cpp b/src/widgets/tab_welcome.cpp new file mode 100644 index 0000000..2c8dc56 --- /dev/null +++ b/src/widgets/tab_welcome.cpp @@ -0,0 +1,24 @@ +#include "tab_welcome.h" + +TabWelcome::TabWelcome(QWidget* parent) + : QWidget(parent), ui(new Ui::TabWelcome) +{ + ui->setupUi(this); + ui->horizontalLayout->setContentsMargins(0, 0, 0, 0); + + ui->welcomeLabel->setText(ui->welcomeLabel->text() + .arg(tr("Welcome to ActorViewer!")) + .arg(tr("Start by opening a Fediverse data export, using a button below."))); +} + +TabWelcome::~TabWelcome() { + delete ui; +} + +void TabWelcome::on_openFileButton_clicked(bool checked) { + emit show_file_open_dialog(); +} + +void TabWelcome::on_openRecentButton_clicked(bool checked) { + emit show_recent_files(); +} diff --git a/src/widgets/tab_welcome.h b/src/widgets/tab_welcome.h new file mode 100644 index 0000000..effc84f --- /dev/null +++ b/src/widgets/tab_welcome.h @@ -0,0 +1,29 @@ +#pragma once +#include <QWidget> +#include "./ui_tab_welcome.h" + +QT_BEGIN_NAMESPACE +namespace Ui { class TabWelcome; } +QT_END_NAMESPACE + +class TabWelcome : public QWidget { + Q_OBJECT + +public: + TabWelcome(QWidget* parent = nullptr); + ~TabWelcome(); + +signals: + // Show Open file dialog + void show_file_open_dialog(); + + // Show recents dropdown + void show_recent_files(); + +private slots: + void on_openFileButton_clicked(bool checked); + void on_openRecentButton_clicked(bool checked); + +private: + Ui::TabWelcome* ui; +}; diff --git a/src/widgets/tab_welcome.ui b/src/widgets/tab_welcome.ui new file mode 100644 index 0000000..2f1e514 --- /dev/null +++ b/src/widgets/tab_welcome.ui @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>TabWelcome</class> + <widget class="QWidget" name="TabWelcome"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="welcomeLabel"> + <property name="text"> + <string><html><head/><body><p align="center">%1<p/><p>%2</p></body></html></string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QPushButton" name="openFileButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="sizeIncrement"> + <size> + <width>30</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Open file…</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="openRecentButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="sizeIncrement"> + <size> + <width>30</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Recent files…</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> |