Merge pull request #638 from kiwix/work/serverdialog

Improve Kiwix Serve dialog look and feel
This commit is contained in:
Kelson 2021-07-31 19:51:13 +02:00 committed by GitHub
commit e6e17cff58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 116 additions and 47 deletions

View File

@ -3,13 +3,18 @@ QWidget {
}
QPushButton {
opacity: 1;
border: none;
padding: 3px;
color:blue;
color: RoyalBlue;
outline: 0;
}
QPushButton:hover {
background-color: blue;
color: white;
}
color: rgba(65, 105, 225, 0.9);
}
QLineEdit {
border: 2px solid gray;
border-radius: 3px;
}

View File

@ -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":"Close",
"reopen-closed-tab":"Reopen closed tab",
"browse-library":"Browse library",
"open-file":"Open file",

View File

@ -9,6 +9,7 @@ LocalKiwixServer::LocalKiwixServer(QWidget *parent) :
QDialog(parent),
ui(new Ui::LocalKiwixServer)
{
setWindowFlag(Qt::FramelessWindowHint, true);
ui->setupUi(this);
QFile styleFile(":/css/localServer.css");
@ -25,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) {
@ -32,11 +34,16 @@ 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"));
ui->closeButton->setText(gt("close-dialog"));
ui->OpenInBrowserButton->setVisible(false);
ui->IpAddress->setVisible(false);
}
@ -59,10 +66,10 @@ 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 !");
messageBox.critical(0,gt("error-title"),gt("error-launch-server-message"));
return;
}
m_active = true;

View File

@ -74,7 +74,6 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
}
return QWidget::keyPressEvent(event);
}
TabBar* MainWindow::getTabBar()
{
return mp_ui->tabBar;
@ -93,4 +92,4 @@ QStackedWidget *MainWindow::getSideDockWidget()
ContentManagerSide *MainWindow::getSideContentManager()
{
return mp_ui->contentmanagerside;
}
}

View File

@ -30,7 +30,6 @@ public:
protected slots:
void toggleFullScreen();
void keyPressEvent(QKeyEvent *event);
private:
Ui::MainWindow *mp_ui;
About *mp_about;

View File

@ -7,32 +7,43 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>342</height>
<height>151</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Local Kiwix Server Settings - Kiwix</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0" colspan="2">
<widget class="QTextBrowser" name="KiwixServerText">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="5" column="1">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item row="5" column="2">
<widget class="QPushButton" name="KiwixServerButton">
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>Start Kiwix Server</string>
</property>
@ -44,18 +55,26 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="2" column="0" colspan="3">
<widget class="QLabel" name="KiwixServerText">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</spacer>
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="horizontalSpacer">
@ -70,21 +89,18 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLineEdit" name="IpAddress">
<property name="frame">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="3" column="2">
<widget class="QPushButton" name="OpenInBrowserButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
@ -98,11 +114,51 @@ p, li { white-space: pre-wrap; }
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Local Kiwix Server</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="closeButton">
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Close</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLineEdit" name="IpAddress">
<property name="inputMask">
<string/>
</property>
<property name="frame">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>