From 2abe5e01d1bc786cf177b0db2645818f57d4f540 Mon Sep 17 00:00:00 2001 From: keshavbhatt Date: Wed, 12 May 2021 19:04:43 +0530 Subject: implemented page zoom feature, - in settings widget. --- src/mainwindow.cpp | 9 ++ src/settingswidget.cpp | 33 ++++ src/settingswidget.h | 6 + src/settingswidget.ui | 422 +++++++++++++++++++++++++++++++------------------ 4 files changed, 318 insertions(+), 152 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cdeab28..a2a7770 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -203,6 +203,12 @@ void MainWindow::init_settingWidget() } }); + connect(settingsWidget,&SettingsWidget::zoomChanged,[=]() + { + double currentFactor = settings.value("zoomFactor",1.0).toDouble(); + webEngine->page()->setZoomFactor(currentFactor); + }); + connect(settingsWidget,&SettingsWidget::notificationPopupTimeOutChanged,[=](){ setNotificationPresenter(this->webEngine->page()->profile()); }); @@ -593,6 +599,9 @@ void MainWindow::createWebPage(bool offTheRecord) connect(webEngine->page(), SIGNAL(fullScreenRequested(QWebEngineFullScreenRequest)), this, SLOT(fullScreenRequested(QWebEngineFullScreenRequest))); + + double currentFactor = settings.value("zoomFactor",1.0).toDouble(); + webEngine->page()->setZoomFactor(currentFactor); } void MainWindow::setNotificationPresenter(QWebEngineProfile* profile) diff --git a/src/settingswidget.cpp b/src/settingswidget.cpp index 79394aa..9d4904a 100644 --- a/src/settingswidget.cpp +++ b/src/settingswidget.cpp @@ -19,6 +19,10 @@ SettingsWidget::SettingsWidget(QWidget *parent, QString engineCachePath, QString this->engineCachePath = engineCachePath; this->enginePersistentStoragePath = enginePersistentStoragePath; + ui->zoomFactorSpinBox->setRange(0.25,5.0); + ui->zoomFactorSpinBox->setValue(settings.value("zoomFactor",1.0).toDouble()); + //emit zoomChanged(); + ui->closeButtonActionComboBox->setCurrentIndex(settings.value("closeButtonActionCombo",0).toInt()); ui->notificationCheckBox->setChecked(settings.value("disableNotificationPopups",false).toBool()); ui->muteAudioCheckBox->setChecked(settings.value("muteAudio",false).toBool()); @@ -422,3 +426,32 @@ void SettingsWidget::on_useNativeFileDialog_toggled(bool checked) { settings.setValue("useNativeFileDialog",checked); } + +void SettingsWidget::on_zoomPlus_clicked() +{ + double currentFactor = settings.value("zoomFactor",1.0).toDouble(); + double newFactor = currentFactor + 0.25; + ui->zoomFactorSpinBox->setValue(newFactor); + + settings.setValue("zoomFactor",ui->zoomFactorSpinBox->value()); + emit zoomChanged(); +} + +void SettingsWidget::on_zoomMinus_clicked() +{ + double currentFactor = settings.value("zoomFactor",1.0).toDouble(); + double newFactor = currentFactor - 0.25; + ui->zoomFactorSpinBox->setValue(newFactor); + + settings.setValue("zoomFactor",ui->zoomFactorSpinBox->value()); + emit zoomChanged(); +} + +void SettingsWidget::on_zoomReset_clicked() +{ + double newFactor = 1.0; + ui->zoomFactorSpinBox->setValue(newFactor); + + settings.setValue("zoomFactor",ui->zoomFactorSpinBox->value()); + emit zoomChanged(); +} diff --git a/src/settingswidget.h b/src/settingswidget.h index a49eda8..6f0fa4a 100644 --- a/src/settingswidget.h +++ b/src/settingswidget.h @@ -28,6 +28,7 @@ signals: void spellCheckChanged(bool checked); void notificationPopupTimeOutChanged(); void notify(QString message); + void zoomChanged(); public: explicit SettingsWidget(QWidget *parent = nullptr,QString engineCachePath = "", @@ -88,6 +89,11 @@ private slots: void themeSwitchTimerTimeout(); void on_useNativeFileDialog_toggled(bool checked); + void on_zoomPlus_clicked(); + void on_zoomMinus_clicked(); + + void on_zoomReset_clicked(); + private: Ui::SettingsWidget *ui; QString engineCachePath,enginePersistentStoragePath; diff --git a/src/settingswidget.ui b/src/settingswidget.ui index 3f7e2d4..55f55a1 100644 --- a/src/settingswidget.ui +++ b/src/settingswidget.ui @@ -109,42 +109,6 @@ background:transparent; General settings - - - - - - User Agent - - - - - - - - - - Set - - - - :/icons/categories/utilities.png:/icons/categories/utilities.png - - - - - - - Default - - - - :/icons/refresh-line.png:/icons/refresh-line.png - - - - - @@ -178,6 +142,101 @@ background:transparent; + + + + 0 + + + + + <html><head/><body><p>Enable application lock screen.</p></body></html> + + + Enable App Lock on Start + + + + + + + Current Password: + + + + + + + + + + + + 1 + 0 + + + + + 1 + 16777215 + + + + background-color: rgba(63, 129, 216, 48); + + + Qt::Vertical + + + + + + + Disable Notifications PopUp + + + + + + + Disable Auto Playback of Media + + + + + + + Mute Audio from Page + + + + + + + + + PopUp timeout + + + + + + + Secs + + + 2 + + + 20 + + + + + + + @@ -203,6 +262,17 @@ background:transparent; + + + + + + Use Native File Dialog + + + + + @@ -296,25 +366,112 @@ background:transparent; - - - - 0 + + + + + + Notification type + + + + + + + + Native notification + + + + :/icons/categories/featured.png:/icons/categories/featured.png + + + + + Customized notification + + + + :/icons/categories/devices-and-iot.png:/icons/categories/devices-and-iot.png + + + + + + + + + 0 + 0 + + + + Try + + + + :/icons/categories/science.png:/icons/categories/science.png + + + + + + + + + + 0 + 1 + + + + 16777215 + 1 + + + + background-color: rgba(63, 129, 216, 48); + + + QFrame::Raised + + + Qt::Horizontal + + + + + - - - <html><head/><body><p>Enable application lock screen.</p></body></html> + + + User Agent + + + + + + + - Enable App Lock on Start + Set + + + + :/icons/categories/utilities.png:/icons/categories/utilities.png - + - Current Password: + Default + + + + :/icons/refresh-line.png:/icons/refresh-line.png @@ -369,60 +526,79 @@ background:transparent; - - + + + + 0 + - + - Notification type + Zoom factor - - - - Native notification - - - - :/icons/categories/featured.png:/icons/categories/featured.png - - - - - Customized notification - - - - :/icons/categories/devices-and-iot.png:/icons/categories/devices-and-iot.png - - + + + + 0 + 0 + + + + Zoom Out + + + + + + + :/icons/minus.png:/icons/minus.png + - + + + + 0 + 0 + + + + Qt::AlignCenter + + + true + + + QAbstractSpinBox::NoButtons + + + + + 0 0 + + Zoom In + - Try + - :/icons/categories/science.png:/icons/categories/science.png + :/icons/plus.png:/icons/plus.png - - - - - - + + 1 @@ -438,89 +614,31 @@ background:transparent; background-color: rgba(63, 129, 216, 48); + + QFrame::Raised + Qt::Vertical - - - - Disable Notifications PopUp + + + + + 0 + 0 + - - - - - - Disable Auto Playback of Media + + reset - - - - - Mute Audio from Page + - - - - - - - - PopUp timeout - - - - - - - Secs - - - 2 - - - 20 - - - - - - - - - - - - 0 - 1 - - - - - 16777215 - 1 - - - - background-color: rgba(63, 129, 216, 48); - - - QFrame::Raised - - - Qt::Horizontal - - - - - - - - - Use Native File Dialog + + + :/icons/arrow-go-back-line.png:/icons/arrow-go-back-line.png -- cgit v1.2.3