#include "main_window.hpp" #include #include #include #include namespace getsuyomi { GetsuyomiApp::GetsuyomiApp() : m_getsuyomi{new Getsuyomi()} { setCentralWidget(m_getsuyomi); setup(); } void GetsuyomiApp::setup() { createActions(); createMenus(); QCoreApplication::setApplicationName(AppName); QCoreApplication::setApplicationVersion(AppVersionString); setWindowTitle(AppName); show(); } void GetsuyomiApp::createActions() { 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, &GetsuyomiApp::quit); } void GetsuyomiApp::createMenus() { m_fileMenu = menuBar()->addMenu(tr("&File")); m_fileMenu->addAction(m_openFile); m_fileMenu->addAction(m_openDirectory); m_fileMenu->addAction(m_quitAction); } 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() { 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 GetsuyomiApp::quit() { printf("Quit!\n"); QCoreApplication::quit(); } Getsuyomi::Getsuyomi() { m_layout = new QVBoxLayout(); auto* label = new QLabel(AppName); m_layout->addWidget(label); setLayout(m_layout); } } // namespace getsuyomi