From 0ea8a789aee1cc4136bdd455d4abae229a228b09 Mon Sep 17 00:00:00 2001 From: Neshura Date: Sat, 23 Nov 2024 22:36:47 +0100 Subject: [PATCH] Initial Commit --- .gitignore | 1 + .idea/.gitignore | 8 + .idea/KavitaUploader.iml | 2 + .idea/QtSettings.xml | 18 + .idea/editor.xml | 580 +++++++++++++++++++++++++++ .idea/material_theme_project_new.xml | 12 + .idea/misc.xml | 7 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + CMakeLists.txt | 30 ++ main.cpp | 15 + main_window.cpp | 111 +++++ main_window.h | 39 ++ main_window.ui | 174 ++++++++ metadata_widget.cpp | 20 + metadata_widget.h | 27 ++ metadata_widget.ui | 433 ++++++++++++++++++++ 17 files changed, 1491 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/KavitaUploader.iml create mode 100644 .idea/QtSettings.xml create mode 100644 .idea/editor.xml create mode 100644 .idea/material_theme_project_new.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 CMakeLists.txt create mode 100644 main.cpp create mode 100644 main_window.cpp create mode 100644 main_window.h create mode 100644 main_window.ui create mode 100644 metadata_widget.cpp create mode 100644 metadata_widget.h create mode 100644 metadata_widget.ui diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..314b094 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +cmake-build-debug/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/KavitaUploader.iml b/.idea/KavitaUploader.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/KavitaUploader.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/QtSettings.xml b/.idea/QtSettings.xml new file mode 100644 index 0000000..b10bcf6 --- /dev/null +++ b/.idea/QtSettings.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..1f0ef49 --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,580 @@ + + + + + \ No newline at end of file diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml new file mode 100644 index 0000000..9deb3c9 --- /dev/null +++ b/.idea/material_theme_project_new.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0b76fe5 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..fe65e42 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6ffdc6d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.30) +project(KavitaUploader) + +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + + +find_package(Qt6 COMPONENTS + Core + Gui + Widgets + Designer + REQUIRED) + +add_executable(KavitaUploader main.cpp + main_window.cpp + main_window.h + main_window.ui + metadata_widget.cpp + metadata_widget.h + metadata_widget.ui) +target_link_libraries(KavitaUploader + Qt::Core + Qt::Gui + Qt::Widgets + Qt::Designer +) + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..a03ba94 --- /dev/null +++ b/main.cpp @@ -0,0 +1,15 @@ +#include +#include + +#include "main_window.h" +#include "metadata_widget.h" + +int main(int argc, char *argv[]) { + QApplication a(argc, argv); + main_window:kuwindow::main_window(w); + metadata_widget m_widget = metadata_widget(w.centralWidget()->findChild("current_view")); + m_widget.hide(); + w.show(); + + return QApplication::exec(); +} \ No newline at end of file diff --git a/main_window.cpp b/main_window.cpp new file mode 100644 index 0000000..156ea39 --- /dev/null +++ b/main_window.cpp @@ -0,0 +1,111 @@ +// +// Created by neshura on 21.11.24. +// + +// You may need to build the project (run Qt uic code generator) to get "ui_main_window.h" resolved + +#include "main_window.h" + +#include +#include + +#include "ui_main_window.h" +#include +#include +#include +#include +#include + +namespace kuwindow { + uint main_window::increment_active_widget() { + const QString& previous_widget_name = this->available_views[this->active_widget_id]; + + this->active_widget_id += 1; + + const QString& next_widget_name = this->available_views[this->active_widget_id]; + + this->findChild("label_" + next_widget_name)->setEnabled(true); + this->findChild("line_" + previous_widget_name + "_" + next_widget_name)->setEnabled(true); + + QWidget* view = this->ui->current_view; + if (view->findChild(next_widget_name.toStdString()) != nullptr) { + view->findChild(next_widget_name)->show(); + } + if (view->findChild(previous_widget_name.toStdString()) != nullptr) { + view->findChild(previous_widget_name)->hide(); + } + + if (this->active_widget_id >= this->available_views.size() - 1) { + this->ui->button_next->setEnabled(false); + } + if (this->active_widget_id > 0) { + this->ui->button_previous->setEnabled(true); + } + + return this->active_widget_id; + } + + uint main_window::decrement_active_widget() { + const QString& previous_widget_name = this->available_views[this->active_widget_id]; + + this->active_widget_id -= 1; + + const QString& next_widget_name = this->available_views[this->active_widget_id]; + + this->findChild("label_" + previous_widget_name)->setEnabled(false); + this->findChild("line_" + next_widget_name + "_" + previous_widget_name)->setEnabled(false); + + QWidget* view = this->ui->current_view; + if (view->findChild(next_widget_name.toStdString()) != nullptr) { + view->findChild(next_widget_name)->show(); + } + if (view->findChild(previous_widget_name.toStdString()) != nullptr) { + view->findChild(previous_widget_name)->hide(); + } + + if (this->active_widget_id < this->available_views.size() - 1) { + this->ui->button_next->setEnabled(true); + } + if (this->active_widget_id <= 0) { + this->ui->button_previous->setEnabled(false); + } + + return this->active_widget_id; + } + + uint main_window::get_active_widget() { + return this->active_widget_id; + } + + main_window::main_window(QWidget *parent) : QMainWindow(parent), ui(new Ui::main_window) { + ui->setupUi(this); + this->available_views = this->property("available_widgets").toStringList(); + + for(const auto & available_view : available_views) { + this->findChild("listWidget")->addItem(available_view); + } + + QWidget* view_widget = this->ui->current_view; + + view_widget = this->findChild("current_view"); + std::cout << "Kids after Init" << std::endl; + foreach(QObject* kid, view_widget->children()) { + std::cout << kid->objectName().toStdString() << std::endl; + } + + const QPushButton* next_button = this->findChild("button_next"); + connect(next_button, &QPushButton::clicked, this, &main_window::increment_active_widget); + + const QPushButton* previous_button = this->findChild("button_previous"); + connect(previous_button, &QPushButton::clicked, this, &main_window::decrement_active_widget); + + } + + void main_window::on_submit_clicked() { + this->centralWidget()->findChild("label")->setText(this->centralWidget()->findChild("lineEdit")->text()); + } + + main_window::~main_window() { + delete ui; + } +} // kuwindow diff --git a/main_window.h b/main_window.h new file mode 100644 index 0000000..b5f463c --- /dev/null +++ b/main_window.h @@ -0,0 +1,39 @@ +// +// Created by neshura on 21.11.24. +// + +#ifndef MAIN_WINDOW_H +#define MAIN_WINDOW_H + +#include +#include + +namespace kuwindow { +QT_BEGIN_NAMESPACE +namespace Ui { class main_window; } +QT_END_NAMESPACE + +class main_window : public QMainWindow { +Q_OBJECT + +public: + uint increment_active_widget(); + + uint decrement_active_widget(); + + uint get_active_widget(); + + explicit main_window(QWidget *parent = nullptr); + + void on_submit_clicked(); + + ~main_window() override; + +private: + Ui::main_window *ui{}; + uint active_widget_id{0}; + QStringList available_views; +}; +} // kuwindow + +#endif //MAIN_WINDOW_H diff --git a/main_window.ui b/main_window.ui new file mode 100644 index 0000000..0b2e20e --- /dev/null +++ b/main_window.ui @@ -0,0 +1,174 @@ + + + kuwindow::main_window + + + + 0 + 0 + 1105 + 534 + + + + main_window + + + + file_widget + metadata_widget + upload_widget + + + + + + + 850 + 10 + 88 + 34 + + + + Settings + + + + + false + + + + 50 + 20 + 331 + 20 + + + + Qt::Orientation::Horizontal + + + + + true + + + + 20 + 20 + 21 + 18 + + + + File + + + + + false + + + + 400 + 20 + 58 + 18 + + + + Metadata + + + + + false + + + + 480 + 20 + 271 + 20 + + + + Qt::Orientation::Horizontal + + + + + false + + + + 760 + 20 + 51 + 18 + + + + Upload + + + + + false + + + + 630 + 460 + 88 + 34 + + + + Previous + + + + + + 730 + 460 + 88 + 34 + + + + Next + + + + + + 850 + 60 + 141 + 101 + + + + true + + + + + + 20 + 60 + 800 + 380 + + + + + + + + + diff --git a/metadata_widget.cpp b/metadata_widget.cpp new file mode 100644 index 0000000..6bfeb0b --- /dev/null +++ b/metadata_widget.cpp @@ -0,0 +1,20 @@ +// +// Created by neshura on 22.11.24. +// + +// You may need to build the project (run Qt uic code generator) to get "ui_metadata_widget.h" resolved + +#include "metadata_widget.h" +#include "ui_metadata_widget.h" +#include + + +metadata_widget::metadata_widget(QWidget *parent) : + QWidget(parent), ui(new Ui::metadata_widget) { + ui->setupUi(this); +} + +metadata_widget::~metadata_widget() { + qDebug("child destroyed"); + delete ui; +} diff --git a/metadata_widget.h b/metadata_widget.h new file mode 100644 index 0000000..69141f8 --- /dev/null +++ b/metadata_widget.h @@ -0,0 +1,27 @@ +// +// Created by neshura on 22.11.24. +// + +#ifndef METADATA_WIDGET_H +#define METADATA_WIDGET_H + +#include + + +QT_BEGIN_NAMESPACE +namespace Ui { class metadata_widget; } +QT_END_NAMESPACE + +class metadata_widget : public QWidget { +Q_OBJECT + +public: + explicit metadata_widget(QWidget *parent = nullptr); + ~metadata_widget() override; + +private: + Ui::metadata_widget *ui; +}; + + +#endif //METADATA_WIDGET_H diff --git a/metadata_widget.ui b/metadata_widget.ui new file mode 100644 index 0000000..0ac66d6 --- /dev/null +++ b/metadata_widget.ui @@ -0,0 +1,433 @@ + + + metadata_widget + + + + 0 + 0 + 800 + 380 + + + + Form + + + + + 130 + 10 + 121 + 32 + + + + Title + + + + + + 0 + 10 + 121 + 32 + + + + Series + + + + + + 0 + 50 + 71 + 32 + + + + 2 + + + 0.000000000000000 + + + + + + 100 + 50 + 51 + 32 + + + + -1 + + + -1 + + + + + + 200 + 50 + 52 + 32 + + + + + + + 0 + 130 + 251 + 241 + + + + Summary... + + + + + + 0 + 90 + 61 + 32 + + + + 0 + + + 3000 + + + 0 + + + + + + 70 + 90 + 51 + 32 + + + + 0 + + + 12 + + + + + + 130 + 90 + 52 + 32 + + + + + + + Qt::LayoutDirection::LeftToRight + + + false + + + 0 + + + 31 + + + 0 + + + + + + 270 + 10 + 121 + 32 + + + + Author + + + + + + 270 + 50 + 121 + 32 + + + + Letterer + + + + + + 270 + 90 + 121 + 32 + + + + Editor + + + + + + 400 + 10 + 121 + 32 + + + + Translator + + + + + + 400 + 50 + 121 + 32 + + + + Publisher + + + + + + 400 + 90 + 121 + 32 + + + + Genre + + + + + + 540 + 10 + 91 + 32 + + + + Pages + + + + + + 999 + + + 0 + + + + + + 640 + 50 + 113 + 32 + + + + + + true + + + + 640 + 10 + 113 + 32 + + + + true + + + false + + + + + + 540 + 50 + 87 + 32 + + + + + + + 270 + 130 + 251 + 241 + + + + Tags + + + + + 10 + 70 + 221 + 161 + + + + true + + + + + 0 + 0 + 221 + 161 + + + + + + + + 10 + 30 + 113 + 32 + + + + + + + 130 + 30 + 31 + 34 + + + + + + + + + + + + 540 + 130 + 251 + 241 + + + + Characters + + + + + 10 + 70 + 221 + 161 + + + + true + + + + + 0 + 0 + 221 + 161 + + + + + + + + 10 + 30 + 113 + 32 + + + + + + + 130 + 30 + 31 + 34 + + + + + + + + + + + + 80 + 50 + 20 + 31 + + + + / + + + + + +