From 14730ed20819093edec4b2fe8dd30fd7ac5c12ce Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 21 Aug 2022 22:57:46 +0200 Subject: [PATCH] gui: mainwindow: Add vertical scroll option, default to it Seems horizontal mode is too unusual according to multiple feedback. Allow choosing this the mode in the settings --- gui/mainwindow.cpp | 16 ++++++++++- gui/mainwindow.ui | 72 +++++++++++++++++++++++++++++++++++----------- shared/common.h | 1 + 3 files changed, 71 insertions(+), 18 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 4f5d7b0..e3e106a 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -585,6 +585,9 @@ void MainWindow::initSettingsTabs() ui->txtSettingMountPaths->setText(mountPaths); ui->spinSettingNumerPerPages->setValue(numPagesPerPreview); ui->txtSettingDatabasePath->setText(databasePath); + bool horizontalScroll = settings.value(SETTINGS_KEY_PREVIEWS_SCROLL_HORIZONTALLY).toBool(); + ui->radioScrollHorizontally->setChecked(horizontalScroll); + ui->radioScrollVertically->setChecked(!horizontalScroll); } void MainWindow::saveSettings() @@ -612,6 +615,7 @@ void MainWindow::saveSettings() settings.setValue(SETTINGS_KEY_MOUNTPATHS, mountPaths); settings.setValue(SETTINGS_KEY_PREVIEWSPERPAGE, ui->spinSettingNumerPerPages->value()); settings.setValue(SETTINGS_KEY_DBPATH, databasePath); + settings.setValue(SETTINGS_KEY_PREVIEWS_SCROLL_HORIZONTALLY, ui->radioScrollHorizontally->isChecked()); settings.sync(); @@ -866,7 +870,17 @@ void MainWindow::makePreviews(int page) } qDeleteAll(ui->scrollAreaWidgetContents->children()); - ui->scrollAreaWidgetContents->setLayout(new QHBoxLayout()); + QSettings settings; + bool horizontalScroll = settings.value(SETTINGS_KEY_PREVIEWS_SCROLL_HORIZONTALLY, false).toBool(); + if(horizontalScroll) + { + ui->scrollAreaWidgetContents->setLayout(new QHBoxLayout()); + } + else + { + ui->scrollAreaWidgetContents->setLayout(new QVBoxLayout()); + ui->scrollAreaWidgetContents->layout()->setAlignment(Qt::AlignCenter); + } ui->previewProcessBar->setMaximum(this->previewableSearchResults.size()); processedPdfPreviews = 0; diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 24a98ac..9f5d27b 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 1280 - 855 + 888 @@ -27,7 +27,7 @@ QTabWidget::South - 1 + 3 @@ -82,7 +82,7 @@ 0 0 1244 - 565 + 598 @@ -542,6 +542,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -551,7 +564,7 @@ - + Max number of previews per 'page' in 'Previews' tab: @@ -575,22 +588,47 @@ + + + + + + Scroll mode for previews: + + + + + + + Vertically + + + + + + + Horizontally + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/shared/common.h b/shared/common.h index 1338560..0b60dc4 100644 --- a/shared/common.h +++ b/shared/common.h @@ -10,6 +10,7 @@ #define SETTINGS_KEY_MOUNTPATHS "mountpaths" #define SETTINGS_KEY_PREVIEWSPERPAGE "previewsPerPage" #define SETTINGS_KEY_SEARCHHISTORY "searchhistory" +#define SETTINGS_KEY_PREVIEWS_SCROLL_HORIZONTALLY "horizontalscroll" namespace Common {