From 7bd7c585fc1552653467791fe258c958a61f9e43 Mon Sep 17 00:00:00 2001 From: Han Young Date: Wed, 5 May 2021 17:00:37 +0800 Subject: [PATCH 1/5] Improve Kiwix Serve dialog look and feel #421 --- resources/css/localServer.css | 8 +-- src/localkiwixserver.cpp | 6 +- ui/localkiwixserver.ui | 121 ++++++++++++++++++++-------------- 3 files changed, 81 insertions(+), 54 deletions(-) diff --git a/resources/css/localServer.css b/resources/css/localServer.css index 154af8d..ac55b04 100644 --- a/resources/css/localServer.css +++ b/resources/css/localServer.css @@ -3,13 +3,13 @@ QWidget { } QPushButton { + opacity: 1; border: none; padding: 3px; - color:blue; + color: RoyalBlue; outline: 0; } QPushButton:hover { - background-color: blue; - color: white; -} \ No newline at end of file + color: DeepSkyBlue; +} diff --git a/src/localkiwixserver.cpp b/src/localkiwixserver.cpp index be50790..a510ba5 100644 --- a/src/localkiwixserver.cpp +++ b/src/localkiwixserver.cpp @@ -32,8 +32,12 @@ LocalKiwixServer::LocalKiwixServer(QWidget *parent) : break; } } + ui->KiwixServerButton->setStyleSheet("QPushButton {background-color: RoyalBlue;" + "color: white;" + "padding: 5px;" + "border-radius: 3px;}" + "QPushButton:hover {background-color: DodgerBlue;}"); ui->label->setText(gt("local-kiwix-server")); - ui->label->setStyleSheet("font-weight: bold;"); ui->KiwixServerText->setText(gt("kiwix-server-description")); ui->OpenInBrowserButton->setText(gt("open-in-browser")); ui->KiwixServerButton->setText(gt("start-kiwix-server")); diff --git a/ui/localkiwixserver.ui b/ui/localkiwixserver.ui index 780b602..9c192f6 100644 --- a/ui/localkiwixserver.ui +++ b/ui/localkiwixserver.ui @@ -7,55 +7,87 @@ 0 0 400 - 342 + 140 + + + 0 + 0 + + Local Kiwix Server Settings - Kiwix - - - - QFrame::NoFrame + + + + - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + + false + + + true - - + + + + true + + + + 11 + + PointingHandCursor - Start Kiwix Server - - - false + Open in browser true - - - - Qt::Vertical + + + + + 0 + 0 + - - - 20 - 40 - + + + 11 + - + + TextLabel + + + true + + + + + + + + 12 + 75 + true + + + + Local Kiwix Server + + @@ -70,39 +102,30 @@ p, li { white-space: pre-wrap; } - - - - false - - - true - - - - - - - true + + + + + 11 + PointingHandCursor + + false + - Open in browser + Start Kiwix Server + + + false true - - - - Local Kiwix Server - - - From 89945e3fa1015c7a9e27e4aa074305db780c4942 Mon Sep 17 00:00:00 2001 From: Han Young Date: Wed, 5 May 2021 21:06:07 +0800 Subject: [PATCH 2/5] modal dialog and http:// for ip addr --- src/localkiwixserver.cpp | 3 ++- src/mainwindow.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/localkiwixserver.cpp b/src/localkiwixserver.cpp index a510ba5..bf8d7d8 100644 --- a/src/localkiwixserver.cpp +++ b/src/localkiwixserver.cpp @@ -9,6 +9,7 @@ LocalKiwixServer::LocalKiwixServer(QWidget *parent) : QDialog(parent), ui(new Ui::LocalKiwixServer) { + setWindowModality(Qt::WindowModal); ui->setupUi(this); QFile styleFile(":/css/localServer.css"); @@ -63,7 +64,7 @@ void LocalKiwixServer::runOrStopServer() { if (!m_active) { mp_server->setPort(m_port); - ui->IpAddress->setText(m_ipAddress + ":" + QString::number(m_port)); + ui->IpAddress->setText("http://" + m_ipAddress + ":" + QString::number(m_port)); if (!mp_server->start()) { QMessageBox messageBox; messageBox.critical(0,"Error","An error has occured !"); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index edecb2e..325033e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -93,4 +93,4 @@ QStackedWidget *MainWindow::getSideDockWidget() ContentManagerSide *MainWindow::getSideContentManager() { return mp_ui->contentmanagerside; -} \ No newline at end of file +} From 5bceb0ac8378fdb2e7c04a02d95304e6ec39dcf3 Mon Sep 17 00:00:00 2001 From: Han Young Date: Thu, 6 May 2021 16:47:32 +0800 Subject: [PATCH 3/5] apply suggestions --- resources/css/localServer.css | 7 +- resources/i18n/en.json | 3 + src/localkiwixserver.cpp | 6 +- src/mainwindow.cpp | 7 +- src/mainwindow.h | 3 +- ui/localkiwixserver.ui | 117 ++++++++++++++++++++++------------ 6 files changed, 96 insertions(+), 47 deletions(-) diff --git a/resources/css/localServer.css b/resources/css/localServer.css index ac55b04..680b876 100644 --- a/resources/css/localServer.css +++ b/resources/css/localServer.css @@ -11,5 +11,10 @@ QPushButton { } QPushButton:hover { - color: DeepSkyBlue; + color: rgba(65, 105, 225, 0.9); +} + +QLineEdit { + border: 2px solid gray; + border-radius: 3px; } diff --git a/resources/i18n/en.json b/resources/i18n/en.json index 5a2bba4..e3f1315 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -4,8 +4,10 @@ ] }, "name":"English", + "error-title":"Error", "error-downloader-window-title":"Cannot create downloader", "error-downloader-launch-message":"Impossible to launch downloader, Kiwix-desktop will start but all download functions will not working !", + "error-launch-server-message":"An error has occured !", "open-zim":"Open Zim", "local-kiwix-server":"Local Kiwix Server", "random-article":"Random Article", @@ -14,6 +16,7 @@ "print":"Print", "new-tab":"New tab", "close-tab":"Close tab", + "close-dialog":"Close", "reopen-closed-tab":"Reopen closed tab", "browse-library":"Browse library", "open-file":"Open file", diff --git a/src/localkiwixserver.cpp b/src/localkiwixserver.cpp index bf8d7d8..93cb06e 100644 --- a/src/localkiwixserver.cpp +++ b/src/localkiwixserver.cpp @@ -9,7 +9,7 @@ LocalKiwixServer::LocalKiwixServer(QWidget *parent) : QDialog(parent), ui(new Ui::LocalKiwixServer) { - setWindowModality(Qt::WindowModal); + setWindowFlag(Qt::FramelessWindowHint, true); ui->setupUi(this); QFile styleFile(":/css/localServer.css"); @@ -26,6 +26,7 @@ LocalKiwixServer::LocalKiwixServer(QWidget *parent) : connect(ui->OpenInBrowserButton, SIGNAL(clicked()), this, SLOT(openInBrowser())); connect(KiwixApp::instance()->getSettingsManager(), &SettingsManager::portChanged, this, [=](int port) { m_port = port; }); + connect(ui->closeButton, &QPushButton::clicked, this, &LocalKiwixServer::close); const QHostAddress &localhost = QHostAddress(QHostAddress::LocalHost); for (const QHostAddress &address: QNetworkInterface::allAddresses()) { if (address.protocol() == QAbstractSocket::IPv4Protocol && address != localhost) { @@ -42,6 +43,7 @@ LocalKiwixServer::LocalKiwixServer(QWidget *parent) : ui->KiwixServerText->setText(gt("kiwix-server-description")); ui->OpenInBrowserButton->setText(gt("open-in-browser")); ui->KiwixServerButton->setText(gt("start-kiwix-server")); + ui->closeButton->setText(gt("close-dialog")); ui->OpenInBrowserButton->setVisible(false); ui->IpAddress->setVisible(false); } @@ -67,7 +69,7 @@ void LocalKiwixServer::runOrStopServer() ui->IpAddress->setText("http://" + m_ipAddress + ":" + QString::number(m_port)); if (!mp_server->start()) { QMessageBox messageBox; - messageBox.critical(0,"Error","An error has occured !"); + messageBox.critical(0,gt("error-title"),gt("error-launch-server-message")); return; } m_active = true; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 325033e..4bb2ead 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -74,7 +74,12 @@ void MainWindow::keyPressEvent(QKeyEvent *event) } return QWidget::keyPressEvent(event); } - +void MainWindow::moveEvent(QMoveEvent *event) +{ + Q_UNUSED(event); + const auto global = mapToGlobal(rect().center()); + mp_localKiwixServer->move(global.x() - mp_localKiwixServer->width() / 2, global.y() - mp_localKiwixServer->height() / 2); +} TabBar* MainWindow::getTabBar() { return mp_ui->tabBar; diff --git a/src/mainwindow.h b/src/mainwindow.h index 9321c7c..0627551 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -30,7 +30,8 @@ public: protected slots: void toggleFullScreen(); void keyPressEvent(QKeyEvent *event); - +protected: + void moveEvent(QMoveEvent *event) override; private: Ui::MainWindow *mp_ui; About *mp_about; diff --git a/ui/localkiwixserver.ui b/ui/localkiwixserver.ui index 9c192f6..a65aa33 100644 --- a/ui/localkiwixserver.ui +++ b/ui/localkiwixserver.ui @@ -7,7 +7,7 @@ 0 0 400 - 140 + 151 @@ -19,42 +19,43 @@ Local Kiwix Server Settings - Kiwix + + false + + + true + - - - - - - - false - - - true - - - - - - - true - + + QLayout::SetFixedSize + + + 11 + 75 + true PointingHandCursor + + false + - Open in browser + Start Kiwix Server + + + false true - + @@ -75,6 +76,42 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + true + + + + 11 + 75 + true + + + + PointingHandCursor + + + Open in browser + + + true + + + @@ -89,43 +126,39 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + 11 + 75 + true PointingHandCursor - - false - - Start Kiwix Server - - - false + Close true + + + + + + + false + + + true + + + From eab11c635c7b68230225b54d4b80c430344f091f Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Sat, 31 Jul 2021 19:38:43 +0200 Subject: [PATCH 4/5] Rename label from close-dialog to close --- resources/i18n/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/i18n/en.json b/resources/i18n/en.json index e3f1315..021a6ab 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -16,7 +16,7 @@ "print":"Print", "new-tab":"New tab", "close-tab":"Close tab", - "close-dialog":"Close", + "close":"Close", "reopen-closed-tab":"Reopen closed tab", "browse-library":"Browse library", "open-file":"Open file", From 1eb440b579c4ceb19ff33c5516ff2a54653aed33 Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Sat, 31 Jul 2021 19:40:11 +0200 Subject: [PATCH 5/5] Don't center Kiwix Serve dialog per default --- src/mainwindow.cpp | 6 ------ src/mainwindow.h | 2 -- 2 files changed, 8 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4bb2ead..445c10c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -74,12 +74,6 @@ void MainWindow::keyPressEvent(QKeyEvent *event) } return QWidget::keyPressEvent(event); } -void MainWindow::moveEvent(QMoveEvent *event) -{ - Q_UNUSED(event); - const auto global = mapToGlobal(rect().center()); - mp_localKiwixServer->move(global.x() - mp_localKiwixServer->width() / 2, global.y() - mp_localKiwixServer->height() / 2); -} TabBar* MainWindow::getTabBar() { return mp_ui->tabBar; diff --git a/src/mainwindow.h b/src/mainwindow.h index 0627551..1296806 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -30,8 +30,6 @@ public: protected slots: void toggleFullScreen(); void keyPressEvent(QKeyEvent *event); -protected: - void moveEvent(QMoveEvent *event) override; private: Ui::MainWindow *mp_ui; About *mp_about;