summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-09-16 12:40:06 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-09-16 12:40:06 -0500
commit04dbfdc97e94e6f477675b9d3135164752a7cfef (patch)
treea95a3dede17c4fc9b6cb60369c3be51929dfbb2c /src
parent107d96690b37a6e4803f02117f22244d53c56706 (diff)
Abort minizip attempt
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp12
-rw-r--r--src/main_window.cpp74
-rw-r--r--src/main_window.hpp22
3 files changed, 79 insertions, 29 deletions
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