From 0fad89dc030a5306191d35b6015f594b01cb37c7 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Mon, 8 Mar 2021 11:25:01 +0200 Subject: [PATCH] Simplify code that disables previous/next comic actions --- YACReader/main_window_viewer.cpp | 24 ++++++++++-------------- YACReader/main_window_viewer.h | 1 + 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index bc6d5e23..7f0140ce 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -179,6 +179,7 @@ void MainWindowViewer::setupUI() createActions(); setUpShortcutsManagement(); disableActions(); + disablePreviousNextComicActions(); createToolBars(); @@ -957,9 +958,12 @@ void MainWindowViewer::enableActions() void MainWindowViewer::disableActions() { setActionsEnabled(false); - for (auto *a : { setBookmarkAction, - openComicOnTheLeftAction, - openComicOnTheRightAction }) + setBookmarkAction->setEnabled(false); +} + +void MainWindowViewer::disablePreviousNextComicActions() +{ + for (auto *a : { openComicOnTheLeftAction, openComicOnTheRightAction }) a->setEnabled(false); } @@ -1125,17 +1129,9 @@ void MainWindowViewer::checkNewVersion() void MainWindowViewer::processReset() { - if (isClient) { - if (siblingComics.count() > 1) { - bool openNextB = openComicOnTheRightAction->isEnabled(); - bool openPrevB = openComicOnTheLeftAction->isEnabled(); - disableActions(); - openComicOnTheRightAction->setEnabled(openNextB); - openComicOnTheLeftAction->setEnabled(openPrevB); - } else - disableActions(); - } else - disableActions(); + disableActions(); + if (!isClient || siblingComics.size() <= 1) + disablePreviousNextComicActions(); } void MainWindowViewer::setUpShortcutsManagement() diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h index 4bfc76c7..23c26683 100644 --- a/YACReader/main_window_viewer.h +++ b/YACReader/main_window_viewer.h @@ -45,6 +45,7 @@ public slots: void showToolBars(); void enableActions(); void disableActions(); + void disablePreviousNextComicActions(); void toggleFullScreen(); void toFullScreen(); void toNormal();