From 41b7873263d575aebf90be49fae2a4023b77532a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 18 Jul 2025 14:51:33 +0200 Subject: [PATCH] Setting to control whether the time is shown in the 'current page/total' label. Apparently I am going to make millions with this new feature :D --- CHANGELOG.md | 3 ++- YACReader/configuration.h | 2 ++ YACReader/options_dialog.cpp | 11 +++++++++ YACReader/options_dialog.h | 3 +++ YACReader/page_label_widget.cpp | 41 ++++++++++++++++++--------------- YACReader/viewer.cpp | 12 ++++++++-- common/yacreader_global_gui.h | 1 + 7 files changed, 51 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2eb03cf..8a700da3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ Version counting is based on semantic versioning (Major.Feature.Patch) ### YACReader * Don't use scroll animations on macos by default, it where hdpi scroll is most likely to be used. * New toolbar on macos. -* New mouse modes to turn pages. You can setup the app to use the left/right buttons to turn pages directly or you can click on the left/right part of the screen to turn pages. +* New mouse modes to turn pages. You can setup the app to use the left/right buttons to turn pages directly or you can click on the left/right part of the screen to turn pages. +* New setting to control whether the time is shown in the 'current page/total' label. ### YACReaderLibrary * Improve flexibility of the open comic in third party app setting so more complex commands can be used. e.g. `open -a "/Applications/My Reader.app" "{comic_file_path}"`. diff --git a/YACReader/configuration.h b/YACReader/configuration.h index f4afdbad..2845b122 100644 --- a/YACReader/configuration.h +++ b/YACReader/configuration.h @@ -91,6 +91,8 @@ public: void setShowToolbars(bool b) { settings->setValue(SHOW_TOOLBARS, b); } bool getShowInformation() { return settings->value(SHOW_INFO, false).toBool(); } void setShowInformation(bool b) { settings->setValue(SHOW_INFO, b); } + bool getShowTimeInInformation() { return settings->value(SHOW_TIME_IN_INFO, true).toBool(); } + void setShowTimeInInformation(bool b) { settings->setValue(SHOW_TIME_IN_INFO, b); } QDate getLastVersionCheck() { return settings->value(LAST_VERSION_CHECK).toDate(); } void setLastVersionCheck(const QDate &date) { settings->setValue(LAST_VERSION_CHECK, date); } int getNumDaysBetweenVersionChecks() { return settings->value(NUM_DAYS_BETWEEN_VERSION_CHECKS, 1).toInt(); } diff --git a/YACReader/options_dialog.cpp b/YACReader/options_dialog.cpp index ec5b2744..611ce8d3 100644 --- a/YACReader/options_dialog.cpp +++ b/YACReader/options_dialog.cpp @@ -38,6 +38,12 @@ OptionsDialog::OptionsDialog(QWidget *parent) path->addWidget(pathFindButton = new QPushButton(QIcon(":/images/find_folder.png"), "")); pathBox->setLayout(path); + QGroupBox *displayBox = new QGroupBox(tr("Display")); + auto displayLayout = new QHBoxLayout(); + showTimeInInformationLabel = new QCheckBox(tr("Show time in current page information label")); + displayLayout->addWidget(showTimeInInformationLabel); + displayBox->setLayout(displayLayout); + connect(pathFindButton, &QAbstractButton::clicked, this, &OptionsDialog::findFolder); QGroupBox *slideSizeBox = new QGroupBox(tr("\"Go to flow\" size")); @@ -95,6 +101,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) mouseModeBox->setLayout(mouseModeLayout); layoutGeneral->addWidget(pathBox); + layoutGeneral->addWidget(displayBox); layoutGeneral->addWidget(slideSizeBox); // layoutGeneral->addWidget(fitBox); layoutGeneral->addWidget(colorBox); @@ -251,6 +258,8 @@ void OptionsDialog::saveOptions() settings->setValue(PATH, pathEdit->text()); + Configuration::getConfiguration().setShowTimeInInformation(showTimeInInformationLabel->isChecked()); + settings->setValue(BACKGROUND_COLOR, currentColor); // settings->setValue(FIT_TO_WIDTH_RATIO,fitToWidthRatioS->sliderPosition()/100.0); settings->setValue(QUICK_NAVI_MODE, quickNavi->isChecked()); @@ -297,6 +306,8 @@ void OptionsDialog::restoreOptions(QSettings *settings) pathEdit->setText(settings->value(PATH).toString()); + showTimeInInformationLabel->setChecked(Configuration::getConfiguration().getShowTimeInInformation()); + updateColor(settings->value(BACKGROUND_COLOR).value()); // fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100); diff --git a/YACReader/options_dialog.h b/YACReader/options_dialog.h index a3f04cc1..0f15e196 100644 --- a/YACReader/options_dialog.h +++ b/YACReader/options_dialog.h @@ -22,6 +22,9 @@ private: // QLabel * pathLabel; QLineEdit *pathEdit; QPushButton *pathFindButton; + + QCheckBox *showTimeInInformationLabel; + QCheckBox *quickNavi; QCheckBox *disableShowOnMouseOver; QCheckBox *scaleCheckbox; diff --git a/YACReader/page_label_widget.cpp b/YACReader/page_label_widget.cpp index f257a201..e0a7ee34 100644 --- a/YACReader/page_label_widget.cpp +++ b/YACReader/page_label_widget.cpp @@ -18,32 +18,35 @@ PageLabelWidget::PageLabelWidget(QWidget *parent) auto layout = new QHBoxLayout; layout->setContentsMargins(0, 0, 0, 0); - setContentsMargins(0, 0, 0, 0); - - QSize labelSize; - if (verticalRes <= 1024) - labelSize = QSize(135, 30); - else if (verticalRes <= 1200) - labelSize = QSize(170, 35); - else - labelSize = QSize(205, 45); textLabel = new QLabel(this); textLabel->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); - if (verticalRes <= 1024) - textLabel->setStyleSheet("QLabel { color : white; font-size:12px; padding-left:8px; }"); - else if (verticalRes <= 1200) - textLabel->setStyleSheet("QLabel { color : white; font-size:16px; padding-left:8px;}"); - else - textLabel->setStyleSheet("QLabel { color : white; font-size:20px; padding-left:8px; }"); + textLabel->setWordWrap(true); // Allow wrapping - setFixedSize(labelSize); + int contentMargin = 0; + if (verticalRes <= 1024) { + textLabel->setStyleSheet("QLabel { color : white; font-size:12px; }"); + contentMargin = 12; + } else if (verticalRes <= 1200) { + textLabel->setStyleSheet("QLabel { color : white; font-size:16px; }"); + contentMargin = 16; + } else { + textLabel->setStyleSheet("QLabel { color : white; font-size:20px; }"); + contentMargin = 20; + } + + setContentsMargins(contentMargin * 2.3, contentMargin / 2.3, contentMargin * 2.3, contentMargin / 2.3); + + // Instead of fixed size, allow dynamic sizing + textLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + layout->addWidget(textLabel, 0, Qt::AlignCenter); + setLayout(layout); + + adjustSize(); // Resize to fit content if (parent != nullptr) move(QPoint((parent->geometry().size().width() - this->width()), -this->height())); - - layout->addWidget(textLabel, 0, Qt::AlignCenter); - setLayout(layout); } void PageLabelWidget::show() diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index e3552e8f..b8ac3ccd 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -825,6 +825,7 @@ void Viewer::setMagnifyingGlassShown(bool shown) void Viewer::informationSwitch() { + informationLabel->updatePosition(); information ? informationLabel->hide() : informationLabel->show(); // informationLabel->move(QPoint((width()-informationLabel->width())/2,0)); information = !information; @@ -837,9 +838,16 @@ void Viewer::informationSwitch() void Viewer::updateInformation() { if (render->hasLoadedComic()) { - informationLabel->setText(render->getCurrentPagesInformation() + " - " + QTime::currentTime().toString("HH:mm")); + auto displayTime = Configuration::getConfiguration().getShowTimeInInformation(); + if (displayTime) { + informationLabel->setText(render->getCurrentPagesInformation() + " - " + QTime::currentTime().toString("HH:mm")); + } else { + informationLabel->setText(render->getCurrentPagesInformation()); + } + informationLabel->adjustSize(); informationLabel->update(); // TODO it shouldn't be neccesary + informationLabel->updatePosition(); } } @@ -1024,10 +1032,10 @@ void Viewer::showCursor() void Viewer::updateOptions() { - goToFlow->setFlowType(Configuration::getConfiguration().getFlowType()); updateBackgroundColor(Configuration::getConfiguration().getBackgroundColor()); updateContentSize(); + updateInformation(); } void Viewer::updateBackgroundColor(const QColor &color) diff --git a/common/yacreader_global_gui.h b/common/yacreader_global_gui.h index b6bedfd4..8d3639e0 100644 --- a/common/yacreader_global_gui.h +++ b/common/yacreader_global_gui.h @@ -30,6 +30,7 @@ #define CONTRAST "CONTRAST" #define GAMMA "GAMMA" #define SHOW_INFO "SHOW_INFO" +#define SHOW_TIME_IN_INFO "SHOW_TIME_IN_INFO" #define QUICK_NAVI_MODE "QUICK_NAVI_MODE" #define DISABLE_MOUSE_OVER_GOTO_FLOW "DISABLE_MOUSE_OVER_GOTO_FLOW" #define ENLARGE_IMAGES "ENLARGE_IMAGES"