Commit 74d21a64 authored by pixhawk's avatar pixhawk

Added proper support for loading / updating different stylesheets

parent 39aa9ccc
......@@ -49,7 +49,7 @@ border: 1px solid #111111;
}
QCheckBox::indicator:checked {
background-color: #222222;
background-color: #333333;
}
QCheckBox::indicator:checked:hover {
......@@ -92,12 +92,14 @@ border: 1px solid #111111;
/* titlebar-close-icon: url(close.png);
titlebar-normal-icon: url(undock.png);*/
}
QDockWidget::title {
text-align: left; /* align the text to the left */
background: lightgray;
padding-left: 5px;
}
text-align: left;
background: #EEEEEE;
color: #111111;
padding-left: 5px;
height: 10px;
border-bottom: 1px solid #222222;
}
QDockWidget::close-button, QDockWidget::float-button {
border: 1px solid transparent;
......@@ -120,15 +122,6 @@ QDockWidget::close-button, QDockWidget::float-button {
color: #EEEEEE;
}
QDockWidget::title {
text-align: left;
background: #121214;
color: #4A4A4F;
padding-left: 5px;
height: 10px;
border-bottom: 1px solid #222222;
}
QSeparator {
color: #EEEEEE;
}
......@@ -184,7 +177,7 @@ QPushButton {
border-radius: 5px;
padding-left: 10px;
padding-right: 10px;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #232228, stop: 1 #020208);
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #C3C2C8, stop: 1 #828288);
}
QPushButton:checked {
......@@ -202,7 +195,7 @@ QToolButton {
max-height: 18px;
border: 2px solid #4A4A4F;
border-radius: 5px;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #232228, stop: 1 #020208);
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #C3C2C8, stop: 1 #828288);
}
QToolButton:checked {
......
......@@ -66,7 +66,8 @@ MainWindow::MainWindow(QWidget *parent):
toolsMenuActions(),
currentView(VIEW_UNCONNECTED),
aboutToCloseFlag(false),
changingViewsFlag(false)
changingViewsFlag(false),
styleFileName(QCoreApplication::applicationDirPath() + "/style-indoor.css")
{
if (!settings.contains("CURRENT_VIEW"))
{
......@@ -1163,20 +1164,12 @@ void MainWindow::saveScreen()
}
}
/**
* Reload the style sheet from disk. The function tries to load "qgroundcontrol.css" from the application
* directory (which by default does not exist). If it fails, it will load the bundled default CSS
* from memory.
* To customize the application, just create a qgroundcontrol.css file in the application directory
*/
void MainWindow::reloadStylesheet()
void MainWindow::selectStylesheet()
{
QString fileName = QCoreApplication::applicationDirPath() + "/style-indoor.css";
// Let user select style sheet
fileName = QFileDialog::getOpenFileName(this, tr("Specify stylesheet"), fileName, tr("CSS Stylesheet (*.css);;"));
styleFileName = QFileDialog::getOpenFileName(this, tr("Specify stylesheet"), styleFileName, tr("CSS Stylesheet (*.css);;"));
if (!fileName.endsWith(".css"))
if (!styleFileName.endsWith(".css"))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
......@@ -1189,7 +1182,13 @@ void MainWindow::reloadStylesheet()
}
// Load style sheet
QFile* styleSheet = new QFile(fileName);
reloadStylesheet();
}
void MainWindow::reloadStylesheet()
{
// Load style sheet
QFile* styleSheet = new QFile(styleFileName);
if (!styleSheet->exists())
{
styleSheet = new QFile(":/images/style-mission.css");
......@@ -1205,7 +1204,7 @@ void MainWindow::reloadStylesheet()
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("QGroundControl did lot load a new style"));
msgBox.setInformativeText(tr("Stylesheet file %1 was not readable").arg(fileName));
msgBox.setInformativeText(tr("Stylesheet file %1 was not readable").arg(styleFileName));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
......@@ -1315,7 +1314,8 @@ void MainWindow::connectCommonActions()
connect(ui.actionUnconnectedView, SIGNAL(triggered()), this, SLOT(loadUnconnectedView()));
connect(ui.actionMavlinkView, SIGNAL(triggered()), this, SLOT(loadMAVLinkView()));
connect(ui.actionReloadStyle, SIGNAL(triggered()), this, SLOT(reloadStylesheet()));
connect(ui.actionReloadStylesheet, SIGNAL(triggered()), this, SLOT(reloadStylesheet()));
connect(ui.actionSelectStylesheet, SIGNAL(triggered()), this, SLOT(selectStylesheet()));
// Help Actions
connect(ui.actionOnline_Documentation, SIGNAL(triggered()), this, SLOT(showHelp()));
......
......@@ -137,6 +137,8 @@ public slots:
/** @brief Reload the CSS style sheet */
void reloadStylesheet();
/** @brief Let the user select the CSS style sheet */
void selectStylesheet();
/** @brief Add a custom tool widget */
void createCustomWidget();
......@@ -411,6 +413,7 @@ protected:
LogCompressor* comp;
QString screenFileName;
QTimer* videoTimer;
QString styleFileName;
private:
Ui::MainWindow ui;
......
......@@ -58,13 +58,19 @@
<property name="title">
<string>File</string>
</property>
<widget class="QMenu" name="menuPreferences">
<property name="title">
<string>Preferences</string>
</property>
<addaction name="actionSelectStylesheet"/>
<addaction name="actionReloadStylesheet"/>
</widget>
<addaction name="actionJoystick_Settings"/>
<addaction name="actionSimulate"/>
<addaction name="separator"/>
<addaction name="actionMuteAudioOutput"/>
<addaction name="actionJoystickSettings"/>
<addaction name="actionPreferences"/>
<addaction name="actionReloadStyle"/>
<addaction name="menuPreferences"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
......@@ -338,13 +344,13 @@
<string>Meta+M</string>
</property>
</action>
<action name="actionReloadStyle">
<action name="actionSelectStylesheet">
<property name="icon">
<iconset resource="../../mavground.qrc">
<normaloff>:/images/categories/applications-internet.svg</normaloff>:/images/categories/applications-internet.svg</iconset>
</property>
<property name="text">
<string>Load Stylesheet</string>
<string>Select Stylesheet</string>
</property>
</action>
<action name="actionPilotsView">
......@@ -387,18 +393,6 @@
<string>Mute Audio Output</string>
</property>
</action>
<action name="actionPreferences">
<property name="icon">
<iconset resource="../../mavground.qrc">
<normaloff>:/images/categories/preferences-system.svg</normaloff>:/images/categories/preferences-system.svg</iconset>
</property>
<property name="text">
<string>Preferences</string>
</property>
<property name="toolTip">
<string>QGroundControl global settings</string>
</property>
</action>
<action name="actionUnconnectedView">
<property name="checkable">
<bool>true</bool>
......@@ -429,6 +423,14 @@
<string>Shutdown the onboard computer - works not during flight</string>
</property>
</action>
<action name="actionReloadStylesheet">
<property name="text">
<string>Reload Stylesheet</string>
</property>
<property name="shortcut">
<string>Meta+R</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment