diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2024-09-18 21:59:54 -0500 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2024-09-18 21:59:54 -0500 |
commit | fa4b4097d3283e1d6e6376c70910e245f0b1f6ec (patch) | |
tree | 74dff4ded82d3f4854b3f10d5dd2e5be1f69b95e /src/main_window.cpp | |
parent | 04dbfdc97e94e6f477675b9d3135164752a7cfef (diff) |
Save progress of qt6 implementation.
Diffstat (limited to 'src/main_window.cpp')
-rw-r--r-- | src/main_window.cpp | 91 |
1 files changed, 57 insertions, 34 deletions
diff --git a/src/main_window.cpp b/src/main_window.cpp index 61b3b65..b05507c 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -1,9 +1,7 @@ #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> +#include <zip.h> namespace getsuyomi { @@ -15,13 +13,18 @@ GetsuyomiApp::GetsuyomiApp() : m_getsuyomi{new Getsuyomi()} void GetsuyomiApp::setup() { - createActions(); - createMenus(); - QCoreApplication::setApplicationName(AppName); QCoreApplication::setApplicationVersion(AppVersionString); setWindowTitle(AppName); + createActions(); + createMenus(); + createToolBar(); + + constexpr int minimumWidth = 640; + constexpr int minimumHeight = 480; + setMinimumSize(minimumWidth, minimumHeight); + show(); } @@ -41,14 +44,39 @@ void GetsuyomiApp::createActions() m_quitAction->setShortcuts(QKeySequence::Quit); m_quitAction->setStatusTip(tr("Quit")); connect(m_quitAction, &QAction::triggered, this, &GetsuyomiApp::quit); + + auto nextShortcuts = QList<QKeySequence>{}; + nextShortcuts.append(QKeySequence{Qt::Key_L}); + nextShortcuts.append(QKeySequence{Qt::Key_Right}); + nextShortcuts.append(QKeySequence{Qt::Key_Down}); + m_nextAction = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::GoNext), tr("Next"), this); + m_nextAction->setShortcuts(nextShortcuts); + m_nextAction->setStatusTip(tr("Next")); + connect(m_nextAction, &QAction::triggered, this, &GetsuyomiApp::next); + + auto backShortcuts = QList<QKeySequence>{}; + backShortcuts.append(QKeySequence{Qt::Key_H}); + backShortcuts.append(QKeySequence{Qt::Key_Left}); + backShortcuts.append(QKeySequence{Qt::Key_Up}); + m_backAction = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::GoPrevious), tr("Back"), this); + m_backAction->setShortcuts(backShortcuts); + m_backAction->setStatusTip(tr("Back")); + connect(m_backAction, &QAction::triggered, this, &GetsuyomiApp::back); } void GetsuyomiApp::createMenus() { - m_fileMenu = menuBar()->addMenu(tr("&File")); - m_fileMenu->addAction(m_openFile); - m_fileMenu->addAction(m_openDirectory); - m_fileMenu->addAction(m_quitAction); + m_menuBar = menuBar()->addMenu(tr("&File")); + m_menuBar->addAction(m_openFile); + m_menuBar->addAction(m_openDirectory); + m_menuBar->addAction(m_quitAction); +} + +void GetsuyomiApp::createToolBar() +{ + m_toolBar = addToolBar(tr("&Navigation")); + m_toolBar->addAction(m_backAction); + m_toolBar->addAction(m_nextAction); } void GetsuyomiApp::openFile() @@ -58,7 +86,17 @@ void GetsuyomiApp::openFile() tr("Open Archive"), QDir::homePath(), tr("Archive types (*.zip *.cbz *.cbr *.gz)")); - qDebug("Open file %s\n", qPrintable(filename)); + + if (filename.endsWith(".zip")) { + try { + auto* archive = new ZipArchive(filename); + m_getsuyomi->setArchive(archive); + } catch (std::runtime_error& exc) { + qCritical("Failed to change archive"); + } + } else { + qCritical("Unsupported file extension"); + } } void GetsuyomiApp::openDirectory() @@ -69,38 +107,23 @@ void GetsuyomiApp::openDirectory() 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 GetsuyomiApp::quit() { - printf("Quit!\n"); QCoreApplication::quit(); } -Getsuyomi::Getsuyomi() +void GetsuyomiApp::next() { - m_layout = new QVBoxLayout(); - - auto* label = new QLabel(AppName); - m_layout->addWidget(label); + qDebug("Next"); + m_getsuyomi->next(); +} - setLayout(m_layout); +void GetsuyomiApp::back() +{ + qDebug("Back"); + m_getsuyomi->back(); } } // namespace getsuyomi |