mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Add settings to the options dialog to control the mouse behavior
This commit is contained in:
parent
25a569cfa6
commit
a51252ca0d
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ public slots:
|
||||
void increasePageZoomLevel();
|
||||
void decreasePageZoomLevel();
|
||||
void reloadOptions();
|
||||
void updateContextMenuPolicy();
|
||||
void fitToWidth();
|
||||
void fitToHeight();
|
||||
void toggleWidthHeight();
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user