diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index fdbd31c5..9d33de47 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -625,7 +625,7 @@ void MainWindowViewer::createToolBars() viewer->addAction(closeAction); - viewer->setContextMenuPolicy(Qt::ActionsContextMenu); + updateContextMenuPolicy(); // MacOSX app menus #ifdef Q_OS_MACOS @@ -777,9 +777,25 @@ void MainWindowViewer::openComicFromRecentAction(QAction *action) void MainWindowViewer::reloadOptions() { + updateContextMenuPolicy(); viewer->updateConfig(settings); } +void MainWindowViewer::updateContextMenuPolicy() +{ + auto mouseMode = Configuration::getConfiguration().getMouseMode(); + switch (mouseMode) { + + case Normal: + case HotAreas: + viewer->setContextMenuPolicy(Qt::ActionsContextMenu); + break; + case LeftRightNavigation: + viewer->setContextMenuPolicy(Qt::NoContextMenu); + break; + } +} + void MainWindowViewer::open() { QFileDialog openDialog; @@ -970,9 +986,11 @@ void MainWindowViewer::disablePreviousNextComicActions() void MainWindowViewer::mouseDoubleClickEvent(QMouseEvent *event) { - if (event->button() == Qt::LeftButton) { - toggleFullScreen(); - event->accept(); + if (Configuration::getConfiguration().getMouseMode() == MouseMode::Normal) { + if (event->button() == Qt::LeftButton) { + toggleFullScreen(); + event->accept(); + } } } diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h index 17011c36..b2d08663 100644 --- a/YACReader/main_window_viewer.h +++ b/YACReader/main_window_viewer.h @@ -67,6 +67,7 @@ public slots: void increasePageZoomLevel(); void decreasePageZoomLevel(); void reloadOptions(); + void updateContextMenuPolicy(); void fitToWidth(); void fitToHeight(); void toggleWidthHeight(); diff --git a/YACReader/options_dialog.cpp b/YACReader/options_dialog.cpp index 6f443dbb..ec5b2744 100644 --- a/YACReader/options_dialog.cpp +++ b/YACReader/options_dialog.cpp @@ -81,11 +81,25 @@ OptionsDialog::OptionsDialog(QWidget *parent) scrollBox->setLayout(scrollLayout); + auto mouseModeBox = new QGroupBox(tr("Mouse mode")); + auto mouseModeLayout = new QVBoxLayout(); + + normalMouseModeRadioButton = new QRadioButton(tr("Only Back/Forward buttons can turn pages")); + leftRightNavigationMouseModeRadioButton = new QRadioButton(tr("Use the Left/Right buttons to turn pages.")); + hotAreasMouseModeRadioButton = new QRadioButton(tr("Click left or right half of the screen to turn pages.")); + + mouseModeLayout->addWidget(normalMouseModeRadioButton); + mouseModeLayout->addWidget(leftRightNavigationMouseModeRadioButton); + mouseModeLayout->addWidget(hotAreasMouseModeRadioButton); + + mouseModeBox->setLayout(mouseModeLayout); + layoutGeneral->addWidget(pathBox); layoutGeneral->addWidget(slideSizeBox); // layoutGeneral->addWidget(fitBox); layoutGeneral->addWidget(colorBox); layoutGeneral->addWidget(scrollBox); + layoutGeneral->addWidget(mouseModeBox); layoutGeneral->addWidget(shortcutsBox); layoutGeneral->addStretch(); @@ -246,6 +260,18 @@ void OptionsDialog::saveOptions() settings->setValue(USE_SINGLE_SCROLL_STEP_TO_TURN_PAGE, useSingleScrollStepToTurnPage->isChecked()); settings->setValue(DISABLE_SCROLL_ANIMATION, disableScrollAnimations->isChecked()); + // get checked radio button to get the mouse mode + YACReader::MouseMode mouseMode = Normal; + if (normalMouseModeRadioButton->isChecked()) { + mouseMode = Normal; + ; + } else if (leftRightNavigationMouseModeRadioButton->isChecked()) { + mouseMode = LeftRightNavigation; + } else if (hotAreasMouseModeRadioButton->isChecked()) { + mouseMode = HotAreas; + } + Configuration::getConfiguration().setMouseMode(mouseMode); + YACReaderOptionsDialog::saveOptions(); } @@ -293,6 +319,20 @@ void OptionsDialog::restoreOptions(QSettings *settings) auto defaultDisableScrollAnimationsValue = false; #endif disableScrollAnimations->setChecked(settings->value(DISABLE_SCROLL_ANIMATION, defaultDisableScrollAnimationsValue).toBool()); + + auto mouseMode = Configuration::getConfiguration().getMouseMode(); + + switch (mouseMode) { + case Normal: + normalMouseModeRadioButton->setChecked(true); + break; + case LeftRightNavigation: + leftRightNavigationMouseModeRadioButton->setChecked(true); + break; + case HotAreas: + hotAreasMouseModeRadioButton->setChecked(true); + break; + } } void OptionsDialog::updateColor(const QColor &color) diff --git a/YACReader/options_dialog.h b/YACReader/options_dialog.h index db1e858c..a3f04cc1 100644 --- a/YACReader/options_dialog.h +++ b/YACReader/options_dialog.h @@ -51,6 +51,11 @@ private: YACReaderSpinSliderWidget *gammaS; QColor currentColor; + + QRadioButton *normalMouseModeRadioButton; + QRadioButton *leftRightNavigationMouseModeRadioButton; + QRadioButton *hotAreasMouseModeRadioButton; + public slots: void saveOptions() override; void restoreOptions(QSettings *settings) override; diff --git a/common/yacreader_global_gui.h b/common/yacreader_global_gui.h index b793c136..0b61d42f 100644 --- a/common/yacreader_global_gui.h +++ b/common/yacreader_global_gui.h @@ -36,6 +36,7 @@ #define DO_NOT_TURN_PAGE_ON_SCROLL "DO_NOT_TURN_PAGE_ON_SCROLL" #define USE_SINGLE_SCROLL_STEP_TO_TURN_PAGE "USE_SINGLE_SCROLL_STEP_TO_TURN_PAGE" #define DISABLE_SCROLL_ANIMATION "DISABLE_SCROLL_ANIMATION" +#define MOUSE_MODE "MOUSE_MODE" #define FLOW_TYPE_GL "FLOW_TYPE_GL" #define Y_POSITION "Y_POSITION"