diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2024-09-29 12:51:41 -0500 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2024-09-29 12:51:41 -0500 |
commit | dacd752bbf46f2afb08b4b8d730ba3619528dda4 (patch) | |
tree | 2554b12d3a6cb6d66fe28a89ccf132f6ae4b4aad /src/main_window.cpp | |
parent | 06663d34c7678aa723955e64cd82a2e399c4b8c6 (diff) |
Add more functionality in paging.
Diffstat (limited to 'src/main_window.cpp')
-rw-r--r-- | src/main_window.cpp | 59 |
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"}; |