1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#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 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
|