summaryrefslogtreecommitdiff
path: root/src/main_window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main_window.cpp')
-rw-r--r--src/main_window.cpp59
1 files changed, 53 insertions, 6 deletions
diff --git a/src/main_window.cpp b/src/main_window.cpp
index 4feb240..a554358 100644
--- a/src/main_window.cpp
+++ b/src/main_window.cpp
@@ -86,6 +86,27 @@ void GetsuyomiApp::createActions()
m_backAction->setShortcuts(backShortcuts);
m_backAction->setStatusTip(tr("Back"));
connect(m_backAction, &QAction::triggered, this, &GetsuyomiApp::back);
+
+ m_setSinglePageLayout = new QAction(QIcon("../resources/pageSingle.png"), tr("Single Page Layout"), this);
+ m_setSinglePageLayout->setShortcut(QKeySequence{Qt::Key_S});
+ m_setSinglePageLayout->setStatusTip(tr("Set Single Page Layout"));
+ connect(m_setSinglePageLayout, &QAction::triggered, this, &GetsuyomiApp::setSinglePageLayout);
+
+ m_setDualPageLayout = new QAction(QIcon("../resources/pageDual.png"), tr("Dual Page Layout"), this);
+ m_setDualPageLayout->setShortcut(QKeySequence{Qt::Key_D});
+ m_setDualPageLayout->setStatusTip(tr("Set Dual Page Layout"));
+ connect(m_setDualPageLayout, &QAction::triggered, this, &GetsuyomiApp::setDualPageLayout);
+
+ m_setMangaLayout = new QAction(QIcon("../resources/pageManga.png"), tr("Manga Page Layout"), this);
+ m_setMangaLayout->setShortcut(QKeySequence{Qt::Key_M});
+ m_setMangaLayout->setStatusTip(tr("Set Manga Page Layout"));
+ connect(m_setMangaLayout, &QAction::triggered, this, &GetsuyomiApp::setMangaLayout);
+
+ m_setPageLayoutGroup = new QActionGroup(this);
+ m_setPageLayoutGroup->addAction(m_setSinglePageLayout);
+ m_setPageLayoutGroup->addAction(m_setDualPageLayout);
+ m_setPageLayoutGroup->addAction(m_setMangaLayout);
+ m_setPageLayoutGroup->setExclusionPolicy(QActionGroup::ExclusionPolicy::Exclusive);
}
void GetsuyomiApp::createMenus()
@@ -101,6 +122,12 @@ void GetsuyomiApp::createToolBar()
m_toolBar = addToolBar(tr("&Navigation"));
m_toolBar->addAction(m_backAction);
m_toolBar->addAction(m_nextAction);
+
+ m_toolBar->addSeparator();
+
+ m_toolBar->addAction(m_setSinglePageLayout);
+ m_toolBar->addAction(m_setDualPageLayout);
+ m_toolBar->addAction(m_setMangaLayout);
}
void GetsuyomiApp::openFile()
@@ -174,16 +201,38 @@ void GetsuyomiApp::quit()
void GetsuyomiApp::next()
{
- qDebug("Next");
m_getsuyomi->next();
}
void GetsuyomiApp::back()
{
- qDebug("Back");
m_getsuyomi->back();
}
+void GetsuyomiApp::setSinglePageLayout()
+{
+ m_getsuyomi->setPageLayout(PageLayout::Single);
+ m_setSinglePageLayout->setEnabled(false);
+ m_setDualPageLayout->setEnabled(true);
+ m_setMangaLayout->setEnabled(true);
+}
+
+void GetsuyomiApp::setDualPageLayout()
+{
+ m_getsuyomi->setPageLayout(PageLayout::Dual);
+ m_setSinglePageLayout->setEnabled(true);
+ m_setDualPageLayout->setEnabled(false);
+ m_setMangaLayout->setEnabled(true);
+}
+
+void GetsuyomiApp::setMangaLayout()
+{
+ m_getsuyomi->setPageLayout(PageLayout::Manga);
+ m_setSinglePageLayout->setEnabled(true);
+ m_setDualPageLayout->setEnabled(true);
+ m_setMangaLayout->setEnabled(false);
+}
+
void GetsuyomiApp::closeEvent(QCloseEvent* event)
{
writeSettings();
@@ -197,7 +246,6 @@ void GetsuyomiApp::readSettings()
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("windowState").toByteArray());
m_lastOpenedDirectory = settings.value("lastOpenedDirectory", QDir::homePath()).toString();
- qDebug("ReadSettings - last directory is %s", qPrintable(m_lastOpenedDirectory));
}
void GetsuyomiApp::writeSettings()
@@ -207,7 +255,6 @@ void GetsuyomiApp::writeSettings()
settings.setValue("windowState", saveState());
settings.setValue("lastOpenedDirectory", m_lastOpenedDirectory);
settings.sync();
- qDebug() << "Called writeSettings, last dir is " << settings.value("lastOpenedDirectory");
}
std::optional<std::string> getEnvVar(const char* envVar)
@@ -233,7 +280,7 @@ void getEnvVar(const std::string envVar, std::string& envValue, const char* back
} else {
envValue = *envValueOpt;
}
- qDebug("%s is %s", envVar.c_str(), envValue.c_str());
+ // qDebug("%s is %s", envVar.c_str(), envValue.c_str());
}
GetEnvResult getEnvironment()
@@ -246,7 +293,7 @@ GetEnvResult getEnvironment()
return GetEnvResult::error(FudStatus::Failure);
}
config.home = *homeOpt;
- qDebug("Home is %s", config.home.c_str());
+ // qDebug("Home is %s", config.home.c_str());
/* If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used. */
const std::string XdgDataHome{"XDG_DATA_HOME"};