From 0711c4a5c1bdb7dff8386c1bc3a03ff52d94177a Mon Sep 17 00:00:00 2001 From: Nikhil Tanwar <2002nikhiltanwar@gmail.com> Date: Thu, 9 Sep 2021 11:39:33 +0530 Subject: [PATCH] Added white background to mainview Followed design as specified in #640 --- resources/css/_settingsManager.css | 93 +++++------------------------- src/settingsmanager.cpp | 20 +++---- src/settingsmanager.h | 2 +- src/settingsview.cpp | 8 ++- ui/mainwindow.ui | 6 +- ui/settings.ui | 86 ++++++++++++++++++--------- 6 files changed, 92 insertions(+), 123 deletions(-) diff --git a/resources/css/_settingsManager.css b/resources/css/_settingsManager.css index 1321b52..1efff15 100644 --- a/resources/css/_settingsManager.css +++ b/resources/css/_settingsManager.css @@ -1,88 +1,23 @@ -html, body { - padding: 0; - margin: auto; - height: 100%; - position: relative; - width: 80%; - overflow: hidden; +QLabel, +QPushButton { + font: 12pt "Cantarell"; } -#settings { - height: 100%; - position: relative; +QLabel#settingsLabel { + font: bold 32pt "Cantarell"; } - -#header { - display: flex; - flex-direction: row; - flex-wrap: nowrap; - justify-content: space-between; +QSpinBox, QLabel#downloadDirPath{ + font: bold 12pt "Cantarell"; } - -.row { - display: flex; - flex-direction: row; - flex-wrap: nowrap; - justify-content: space-between; - align-items: center; - border-top: 1px solid grey; - height: 40px; -} - - -input { - margin: 5px; -} - -#download_dir { - flex: 1; - margin: 5px; - overflow: hidden; - direction: rtl; -} - -#download_dir > span { - display: block; - float: right; - direction: ltr; - min-width: 100%; - font-size: 0.9em; -} - -input[type=number] { - width: 80px; -} - -input[type=button] { +QPushButton { + background-color: white; color: blue; - font-weight: bold; - font-size: 14px; - border: 0; - background: transparent; - border-radius: 2px; + padding: 5px; + font:bold; + border-radius: 3px; } -input[type=button]:hover { +QPushButton:hover { + background-color: RoyalBlue; color: white; - background: blue; -} - -input[type=number]::-webkit-inner-spin-button, -input[type=number]::-webkit-outer-spin-button { - opacity: 1; -} - -div.percentage-symbol { - position: relative; -} - -div.percentage-symbol:before { - position: absolute; - content: "%"; - top: 0.4em; - right: 1.5em; -} - -div.percentage-symbol input { - text-align: left; } diff --git a/src/settingsmanager.cpp b/src/settingsmanager.cpp index 481c728..c5256a6 100644 --- a/src/settingsmanager.cpp +++ b/src/settingsmanager.cpp @@ -4,7 +4,6 @@ #include #include #include - SettingsManager::SettingsManager(QObject *parent) : QObject(parent), m_settings("Kiwix", "Kiwix-desktop"), @@ -15,17 +14,11 @@ SettingsManager::SettingsManager(QObject *parent) SettingsView* SettingsManager::getView() { - static SettingsView *view = nullptr; - - if (!view || !m_settingsViewDisplayed) - view = new SettingsView(); - + auto view = new SettingsView(); view->init(m_kiwixServerPort, m_zoomFactor * 100, m_downloadDir); - connect(view, &QObject::destroyed, this, [=]() { m_settingsViewDisplayed = false;}); connect(view, &SettingsView::serverPortChanged, this, &SettingsManager::setKiwixServerPort); connect(view, &SettingsView::downloadDirChanged, this, &SettingsManager::setDownloadDir); - connect(view, &SettingsView::zoomFactorChanged, this, &SettingsManager::setZoomFactor); - m_settingsViewDisplayed = true; + connect(view, &SettingsView::zoomFactorChanged, this, &SettingsManager::setZoom); return view; } @@ -66,11 +59,14 @@ void SettingsManager::setKiwixServerPort(int port) emit(portChanged(port)); } +void SettingsManager::setZoom(int factor) +{ + qreal zoomFactor = (double)factor/100; + setZoomFactor(zoomFactor); +} + void SettingsManager::setZoomFactor(qreal zoomFactor) { - if (zoomFactor > 1) - zoomFactor /= 100; - m_zoomFactor = zoomFactor; m_settings.setValue("view/zoomFactor", zoomFactor); } diff --git a/src/settingsmanager.h b/src/settingsmanager.h index ec635b4..5e95c47 100644 --- a/src/settingsmanager.h +++ b/src/settingsmanager.h @@ -34,7 +34,7 @@ public slots: QString getDownloadDir() { return m_downloadDir; } void resetDownloadDir(); void browseDownloadDir(); - + void setZoom(int factor); private: void initSettings(); bool confirmDialogDownloadDir(const QString& dir); diff --git a/src/settingsview.cpp b/src/settingsview.cpp index a2079ac..81f60dc 100644 --- a/src/settingsview.cpp +++ b/src/settingsview.cpp @@ -1,7 +1,7 @@ #include "settingsview.h" #include "ui_settings.h" #include "kiwixapp.h" - +#include #include #include SettingsView::SettingsView(QWidget *parent) @@ -9,6 +9,10 @@ SettingsView::SettingsView(QWidget *parent) , ui(new Ui::Settings) { ui->setupUi(this); + QFile file("./resources/css/_settingsManager.css"); + file.open(QFile::ReadOnly); + QString styleSheet = QString(file.readAll()); + ui->widget->setStyleSheet(styleSheet); connect(ui->serverPortSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &SettingsView::serverPortChanged); connect(ui->zoomLevelSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &SettingsView::zoomFactorChanged); connect(ui->resetButton, &QPushButton::clicked, this, &SettingsView::resetDownloadDir); @@ -44,7 +48,7 @@ bool SettingsView::confirmDialogDownloadDir(const QString& dir) void SettingsView::resetDownloadDir() { - auto dir = QString::fromStdString(getDataDirectory()); + auto dir = QString::fromStdString(kiwix::getDataDirectory()); const auto &downloadDir = KiwixApp::instance()->getSettingsManager()->getDownloadDir(); if (dir == downloadDir) { return; diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index 3e89d7f..6505e0c 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -79,7 +79,11 @@ - + + + background-color: rgb(255, 255, 255); + + diff --git a/ui/settings.ui b/ui/settings.ui index dcbd772..2ea6838 100644 --- a/ui/settings.ui +++ b/ui/settings.ui @@ -34,7 +34,7 @@ 16777215 - + @@ -45,13 +45,6 @@ 0 - - - 16 - 75 - true - - Settings @@ -68,13 +61,6 @@ - - - 10 - 75 - true - - Port for local kiwix server: @@ -95,6 +81,9 @@ + + false + @@ -122,12 +111,6 @@ - - - 75 - true - - Zoom level: @@ -148,10 +131,22 @@ + + false + % + + 30 + + 500 + + + 10 + + 100 @@ -169,19 +164,13 @@ - - - 75 - true - - Download directory: - + Qt::Horizontal @@ -200,18 +189,59 @@ + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + true + + + true + + + + Reset + + true + + + true + + + true + + + + Browse + + true +