diff options
Diffstat (limited to 'src/main_window.cpp')
-rw-r--r-- | src/main_window.cpp | 74 |
1 files changed, 57 insertions, 17 deletions
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 |