diff options
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/main.cpp | 12 | ||||
-rw-r--r-- | src/main_window.cpp | 74 | ||||
-rw-r--r-- | src/main_window.hpp | 22 |
4 files changed, 83 insertions, 30 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3908a43..dfb9afb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,10 @@ qt_add_executable(getsuyomi src/main.cpp ) -target_link_libraries(getsuyomi PRIVATE Qt6::Widgets) +# find_dependency(minizip-ng REQUIRED) + +target_include_directories(getsuyomi PRIVATE minizip-ng) +target_link_libraries(getsuyomi PRIVATE Qt6::Widgets minizip-ng) # set_target_properties(getsuyomi PROPERTIES # WIN32_EXECUTABLE ON diff --git a/src/main.cpp b/src/main.cpp index bb08972..9a57bfc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,16 @@ #include "main_window.hpp" -int main(int argc, char* argv[]) { +int main(int argc, char* argv[]) +{ QApplication app{argc, argv}; - getsuyobi::GetsuyobiApp getsuyobi{}; + getsuyomi::GetsuyomiApp getsuyobi{}; + + QCommandLineParser parser; + parser.setApplicationDescription(QApplication::translate("main", "A comic book and manga reader")); + parser.addHelpOption(); + parser.addVersionOption(); + + parser.process(app); return app.exec(); } diff --git a/src/main_window.cpp b/src/main_window.cpp index 796b4fc..61b3b65 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -1,16 +1,19 @@ #include "main_window.hpp" #include <QString> +#include <minizip-ng/mz.h> +#include <minizip-ng/mz_strm_buf.h> +#include <minizip-ng/mz_strm_os.h> -namespace getsuyobi { +namespace getsuyomi { -GetsuyobiApp::GetsuyobiApp() : m_getsuyobi{new Getsuyobi()} +GetsuyomiApp::GetsuyomiApp() : m_getsuyomi{new Getsuyomi()} { - setCentralWidget(m_getsuyobi); + setCentralWidget(m_getsuyomi); setup(); } -void GetsuyobiApp::setup() +void GetsuyomiApp::setup() { createActions(); createMenus(); @@ -22,38 +25,75 @@ void GetsuyobiApp::setup() show(); } -void GetsuyobiApp::createActions() +void GetsuyomiApp::createActions() { - m_openAction = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::DocumentOpen), tr("&Open"), this); - m_openAction->setShortcuts(QKeySequence::Open); - m_openAction->setStatusTip(tr("Open a file")); - connect(m_openAction, &QAction::triggered, this, &GetsuyobiApp::openFile); + m_openFile = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::DocumentOpen), tr("&Open File"), this); + m_openFile->setShortcuts(QKeySequence::Open); + m_openFile->setStatusTip(tr("Open a file")); + connect(m_openFile, &QAction::triggered, this, &GetsuyomiApp::openFile); + + m_openDirectory = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::FolderOpen), tr("Open Directory"), this); + m_openDirectory->setShortcut(Qt::CTRL | Qt::ALT | Qt::Key_O); + m_openDirectory->setStatusTip(tr("Open a directory")); + connect(m_openDirectory, &QAction::triggered, this, &GetsuyomiApp::openDirectory); m_quitAction = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::ApplicationExit), tr("&Quit"), this); m_quitAction->setShortcuts(QKeySequence::Quit); m_quitAction->setStatusTip(tr("Quit")); - connect(m_quitAction, &QAction::triggered, this, &GetsuyobiApp::quit); + connect(m_quitAction, &QAction::triggered, this, &GetsuyomiApp::quit); } -void GetsuyobiApp::createMenus() +void GetsuyomiApp::createMenus() { m_fileMenu = menuBar()->addMenu(tr("&File")); - m_fileMenu->addAction(m_openAction); + m_fileMenu->addAction(m_openFile); + m_fileMenu->addAction(m_openDirectory); m_fileMenu->addAction(m_quitAction); } -void GetsuyobiApp::openFile() +void GetsuyomiApp::openFile() +{ + auto filename = QFileDialog::getOpenFileName( + this, + tr("Open Archive"), + QDir::homePath(), + tr("Archive types (*.zip *.cbz *.cbr *.gz)")); + qDebug("Open file %s\n", qPrintable(filename)); +} + +void GetsuyomiApp::openDirectory() { - printf("Open file!\n"); + QString directory = QFileDialog::getExistingDirectory( + this, + tr("Open Directory"), + QDir::homePath(), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + qDebug("Open directory %s", qPrintable(directory)); + + auto* stream = mz_stream_os_create(); + if (stream == nullptr) { + qCritical("Nullpointer - stream"); + return; + } + + auto* bufStream = mz_stream_buffered_create(); + if (stream == nullptr) { + qCritical("Nullpointer - bufStream"); + return; + } + + mz_stream_buffered_open(bufStream, nullptr, MZ_OPEN_MODE_READ); + mz_stream_buffered_set_base(bufStream, stream); + } -void GetsuyobiApp::quit() +void GetsuyomiApp::quit() { printf("Quit!\n"); QCoreApplication::quit(); } -Getsuyobi::Getsuyobi() +Getsuyomi::Getsuyomi() { m_layout = new QVBoxLayout(); @@ -63,4 +103,4 @@ Getsuyobi::Getsuyobi() setLayout(m_layout); } -} // namespace getsuyobi +} // namespace getsuyomi diff --git a/src/main_window.hpp b/src/main_window.hpp index 0bd074a..886ba42 100644 --- a/src/main_window.hpp +++ b/src/main_window.hpp @@ -1,42 +1,44 @@ #include <QtWidgets> -namespace getsuyobi { +namespace getsuyomi { -constexpr const char* AppName = "GetsuYobi"; +constexpr const char* AppName = "GetsuYomi"; constexpr const char* AppVersionString = "1.0.0"; -class Getsuyobi; +class Getsuyomi; -class GetsuyobiApp : public QMainWindow { +class GetsuyomiApp : public QMainWindow { Q_OBJECT public: - GetsuyobiApp(); + GetsuyomiApp(); private: void setup(); void createActions(); void createMenus(); - Getsuyobi* m_getsuyobi; + Getsuyomi* m_getsuyomi; - QAction* m_openAction; + QAction* m_openFile; + QAction* m_openDirectory; QAction* m_quitAction; QMenu* m_fileMenu; private slots: void openFile(); + void openDirectory(); void quit(); }; -class Getsuyobi : public QWidget { +class Getsuyomi : public QWidget { Q_OBJECT public: - Getsuyobi(); + Getsuyomi(); private: QLayout* m_layout{nullptr}; }; -} // namespace getsuyobi +} // namespace getsuyomi |