refs #400, GUI after Qt 5.4.1 migration

* ini file to complement style sheets (values changed in code)
* aircrafts -> aircraft
* some .h code to .cpp
This commit is contained in:
Klaus Basan
2015-04-01 14:47:42 +02:00
parent 313c5f5638
commit 96434928fe
17 changed files with 245 additions and 138 deletions

View File

@@ -45,7 +45,7 @@ win32 {
RESOURCES +=
DESTDIR = ../../lib
OTHER_FILES += ./qss/*.qss ./qss/*.css
OTHER_FILES += ./qss/*.qss ./qss/*.css ./qss/*.ini
win32:isEmpty(MINGW_IN_SHELL): COPY = xcopy /yi
else: COPY = cp -r

View File

@@ -94,16 +94,16 @@
</widget>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Views::CAirportView</class>
<extends>QTableView</extends>
<header>blackgui/views/airportview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Views::CSimulatedAircraftView</class>
<extends>QTableView</extends>
<header>blackgui/views/simulatedaircraftview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Views::CAirportView</class>
<extends>QTableView</extends>
<header>blackgui/views/airportview.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -14,10 +14,13 @@
<string>Audio</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="vl_AudioComponent">
<property name="spacing">
@@ -51,8 +54,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>396</width>
<height>296</height>
<width>398</width>
<height>298</height>
</rect>
</property>
<layout class="QVBoxLayout" name="vl_ScrollAreaInner">

View File

@@ -14,10 +14,13 @@
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="vl_AudioSetup">
<property name="leftMargin">

View File

@@ -20,10 +20,13 @@
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QGridLayout" name="gl_LogComponent">
<property name="leftMargin">
@@ -46,7 +49,7 @@
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pg_LogPage" native="true">
<widget class="QWidget" name="pg_LogPage">
<attribute name="title">
<string>Log</string>
</attribute>
@@ -81,7 +84,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="pg_LogConsole" native="true">
<widget class="QWidget" name="pg_LogConsole">
<attribute name="title">
<string>Console</string>
</attribute>

View File

@@ -92,7 +92,7 @@
<set>Qt::TopDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Aircrafts</string>
<string>Aircraft</string>
</property>
<attribute name="dockWidgetArea">
<number>4</number>

View File

@@ -11,32 +11,41 @@
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
<string>Text messages</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="vl_TextMessages">
<property name="spacing">
<number>2</number>
<number>1</number>
</property>
<property name="leftMargin">
<number>2</number>
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="tw_TextMessages">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
@@ -46,19 +55,19 @@
</attribute>
<layout class="QVBoxLayout" name="vl_TextMessagesAll">
<property name="spacing">
<number>2</number>
<number>0</number>
</property>
<property name="leftMargin">
<number>2</number>
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
<number>0</number>
</property>
<item>
<widget class="BlackGui::Views::CTextMessageView" name="tvp_TextMessagesAll">
@@ -111,19 +120,19 @@
</attribute>
<layout class="QVBoxLayout" name="vl_TextMessagesUnicom">
<property name="spacing">
<number>2</number>
<number>0</number>
</property>
<property name="leftMargin">
<number>2</number>
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
<number>0</number>
</property>
<item>
<widget class="BlackGui::CTextMessageTextEdit" name="tep_TextMessagesUnicom">
@@ -146,19 +155,19 @@
</attribute>
<layout class="QVBoxLayout" name="vl_TextMessagesCom1">
<property name="spacing">
<number>2</number>
<number>0</number>
</property>
<property name="leftMargin">
<number>2</number>
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
<number>0</number>
</property>
<item>
<widget class="BlackGui::CTextMessageTextEdit" name="tep_TextMessagesCOM1">
@@ -184,19 +193,19 @@
</attribute>
<layout class="QVBoxLayout" name="vl_TextMessagesCom2">
<property name="spacing">
<number>2</number>
<number>0</number>
</property>
<property name="leftMargin">
<number>2</number>
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
<number>0</number>
</property>
<item>
<widget class="BlackGui::CTextMessageTextEdit" name="tep_TextMessagesCOM2">

View File

@@ -47,7 +47,7 @@ namespace BlackGui
void CDockWidget::setEmptyTitleBar()
{
if (!this->m_titleBarWidgetOriginal) { this->initTitleBarWidgets(); }
if (this->titleBarWidget() == this->m_titleBarWidgetEmpty) return; // on purpose, as I do not know what happens when I call setTitleBar
if (this->titleBarWidget() == this->m_titleBarWidgetEmpty) { return; } // on purpose, as I do not know what happens when I call setTitleBar
this->setTitleBarWidget(this->m_titleBarWidgetEmpty);
}
@@ -56,6 +56,26 @@ namespace BlackGui
this->setTitleBarWidget(nullptr);
}
void CDockWidget::setMarginsWhenFloating(const QMargins &margins)
{
this->m_marginsWhenFloating = margins;
}
void CDockWidget::setMarginsWhenFloating(int left, int top, int right, int bottom)
{
this->m_marginsWhenFloating = QMargins(left, top, right, bottom);
}
void CDockWidget::setMarginsWhenDocked(const QMargins &margins)
{
this->m_marginsWhenDocked = margins;
}
void CDockWidget::setMarginsWhenDocked(int left, int top, int right, int bottom)
{
this->m_marginsWhenDocked = QMargins(left, top, right, bottom);
}
void CDockWidget::setWindowTitle(const QString &title)
{
this->m_windowTitleBackup = title;

View File

@@ -49,16 +49,16 @@ namespace BlackGui
void setNullTitleBar();
//! Margins when window is floating
void setMarginsWhenFloating(const QMargins &margins) { this->m_marginsWhenFloating = margins; }
void setMarginsWhenFloating(const QMargins &margins);
//! Margins when window is floating
void setMarginsWhenFloating(int left, int top, int right, int bottom) { this->m_marginsWhenFloating = QMargins(left, top, right, bottom); }
void setMarginsWhenFloating(int left, int top, int right, int bottom);
//! Margins when widget is floating
void setMarginsWhenDocked(const QMargins &margins) { this->m_marginsWhenDocked = margins; }
void setMarginsWhenDocked(const QMargins &margins);
//! Margins when widget is floating
void setMarginsWhenDocked(int left, int top, int right, int bottom) { this->m_marginsWhenDocked = QMargins(left, top, right, bottom); }
void setMarginsWhenDocked(int left, int top, int right, int bottom);
//! Window title backup
const QString &windowTitleBackup() const { return this->m_windowTitleBackup; }

View File

@@ -38,7 +38,7 @@ namespace BlackGui
bool CDockWidgetInfoArea::isSelectedDockWidget() const
{
const CInfoArea *ia = getParentInfoArea();
if (!ia) return false;
if (!ia) { return false; }
return ia->isSelectedDockWidgetInfoArea(this);
}
@@ -46,12 +46,12 @@ namespace BlackGui
{
// if the widget is invisible we are done
// but if it is visible, there is no guarantee it can be seen by the user
if (!this->isVisible()) return false;
if (!this->isVisible()) { return false; }
// further checks
if (this->isFloating())
{
if (this->isMinimized()) return false;
if (this->isMinimized()) { return false; }
return true;
}
else
@@ -125,7 +125,7 @@ namespace BlackGui
foreach(CDockWidgetInfoArea * ia, nestedInfoAreas)
{
QList<CEnableForDockWidgetInfoArea *> nestedInfoAreaComponents = ia->findEmbeddedDockWidgetInfoAreaComponents();
if (nestedInfoAreaComponents.isEmpty()) continue;
if (nestedInfoAreaComponents.isEmpty()) { continue; }
foreach(CEnableForDockWidgetInfoArea * iac, nestedInfoAreaComponents)
{
bool r = widgetsWithDockWidgetInfoAreaComponent.removeOne(iac);

View File

@@ -46,8 +46,7 @@ namespace BlackGui
}
this->ps_setDockArea(Qt::TopDockWidgetArea);
this->setMarginsWhenFloating(5, 5, 5, 5); // left, top, right bottom
this->setMarginsWhenDocked(1, 1, 1, 1); // top has no effect
this->iniFileBasedSettings();
this->connectAllWidgets();
this->setFeaturesForDockableWidgets(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable);
this->tabifyAllWidgets();
@@ -533,6 +532,30 @@ namespace BlackGui
return infoAreas;
}
void CInfoArea::iniFileBasedSettings()
{
const QSettings *settings = CStyleSheetUtility::instance().iniFile();
if (settings)
{
this->setMarginsWhenDocked(
settings->value("infoarea/margindocked.left").toInt(),
settings->value("infoarea/margindocked.top").toInt(),
settings->value("infoarea/margindocked.right").toInt(),
settings->value("infoarea/margindocked.bottom").toInt());
this->setMarginsWhenFloating(
settings->value("infoarea/marginfloating.left").toInt(),
settings->value("infoarea/marginfloating.top").toInt(),
settings->value("infoarea/marginfloating.right").toInt(),
settings->value("infoarea/marginfloating.bottom").toInt());
}
else
{
// some defaut if not available
this->setMarginsWhenFloating(10, 10, 20, 20); // left, top, right, bottom
this->setMarginsWhenDocked(1, 1, 1, 1); // top has no effect
}
}
void CInfoArea::ps_emitInfoAreaStatus()
{
int sia = this->getSelectedDockInfoAreaIndex();
@@ -664,6 +687,7 @@ namespace BlackGui
void CInfoArea::ps_onStyleSheetChanged()
{
this->iniFileBasedSettings();
if (this->m_tabBar)
{
QString qss = CStyleSheetUtility::instance().style(CStyleSheetUtility::fileNameDockWidgetTab());

View File

@@ -192,6 +192,9 @@ namespace BlackGui
//! \remarks result stored in m_dockableWidgets
QList<CDockWidgetInfoArea *> findOwnDockWidgetInfoAreas() const;
//! Settings based on ini file
void iniFileBasedSettings();
private slots:
//! Tab bar has been double clicked
void ps_tabBarDoubleClicked(int tabBarIndex);

View File

@@ -1,12 +0,0 @@
Useful blocks, currently not used but saved for future
/** required when dock widget is floating **/
/** background-image not working on QDockWidget, so I use direct children **/
#sw_MainMiddle QDockWidget {
background-color: black;
}
#sw_MainMiddle QDockWidget > QWidget {
background-color: black;
background-image: url(:/textures/icons/textures/texture-inner.jpg);
}

11
src/blackgui/qss/gui.ini Normal file
View File

@@ -0,0 +1,11 @@
[infoarea]
; margins as used in infoarea.cpp
margindocked.left = 1
margindocked.right = 1
margindocked.top = 1
margindocked.bottom = 1
marginfloating.left = 5
marginfloating.right = 20
marginfloating.top = 5
marginfloating.bottom = 20

View File

@@ -4,8 +4,8 @@ http://qt-project.org/doc/qt-5.3/stylesheet-examples.html
http://web.forret.com/tools/color.asp?RGB=2F4F4F&name=Dark+slate+gray
Remarks:
there is no opacity with background image, so we need semitransparent images
use -- instead of :: for namespaces
1) there is no opacity with background image, so we need semitransparent images
2) use -- instead of :: for namespaces
Used dynamic properties
frameless (infobar.qss , here)
@@ -21,20 +21,27 @@ QMainWindow {
/** background-image not working on QDockWidget, so I use direct children **/
#sw_MainMiddle BlackGui--CDockWidgetInfoArea {
background-color: black;
background-image: url(:/textures/icons/textures/texture-inner.jpg);
}
/** this is the first widget in the dock area **/
/** all dock widgets shall have this QWidget as container **/
#sw_MainMiddle BlackGui--CDockWidgetInfoArea > QWidget {
background-color: black;
background-image: url(:/textures/icons/textures/texture-inner.jpg);
}
/** the following QFrame, likely the component itself
#sw_MainMiddle BlackGui--CDockWidgetInfoArea > QWidget > QFrame {
border: 0px;
padding: 0px;
}
/** fix the menu, which is overridden by the above QWidget **/
#sw_MainMiddle BlackGui--CDockWidgetInfoArea > QMenu {
border: 2px solid darkslategray; /* reserve space for selection border */
border: 1px solid darkslategray; /* reserve space for selection border */
background: lightgray;
color: black;
padding: 2px;
padding: 0px;
}
/** required when info area is not floating **/
@@ -46,14 +53,8 @@ BlackGui--CInfoArea {
/** fix scroll areas **/
/** in flight plan **/
QAbstractScrollArea #qw_FlightPlanTabMain {
background-color: black;
background-image: url(:/textures/icons/textures/texture-inner.jpg);
}
QAbstractScrollArea #qw_RemarksGenerator {
background-color: transparent;
background-image: url(:/textures/icons/textures/texture-inner.jpg);
}
QAbstractScrollArea #qw_FlightPlanTabMain { background-color: black; background-image: url(:/textures/icons/textures/texture-inner.jpg); }
QAbstractScrollArea #qw_RemarksGenerator { background-color: transparent; background-image: url(:/textures/icons/textures/texture-inner.jpg); }
/** in log component **/
QAbstractScrollArea #pg_StatusPageMessages { background-color: black; }

View File

@@ -94,7 +94,13 @@ namespace BlackGui
bool CStyleSheetUtility::read()
{
QDir directory(qssDirectory());
if (!directory.exists()) return false;
if (!directory.exists()) { return false; }
// ini file
QString iniFile = directory.absolutePath().append("/").append(fileNameIniFile());
m_iniFile.reset(new QSettings(iniFile, QSettings::IniFormat));
// qss/css files
directory.setNameFilters({"*.qss", "*.css"});
directory.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
@@ -130,7 +136,7 @@ namespace BlackGui
QString style;
foreach(QString fileName, fileNames)
{
if (!this->containsStyle(fileName)) continue;
if (!this->containsStyle(fileName)) { continue; }
QString s = this->m_styleSheets[fileName.toLower()].trimmed();
if (s.isEmpty()) continue;
if (!style.isEmpty()) style.append("\n\n");
@@ -214,6 +220,78 @@ namespace BlackGui
return n;
}
CStyleSheetUtility &CStyleSheetUtility::instance()
{
static CStyleSheetUtility r;
return r;
}
const QString &CStyleSheetUtility::fileNameFonts()
{
static const QString f("fonts.qss");
return f;
}
const QString &CStyleSheetUtility::fileNameMainWindow()
{
static const QString f("mainwindow.qss");
return f;
}
const QString &CStyleSheetUtility::fileNameInfoBar()
{
static const QString f("infobar.qss");
return f;
}
const QString &CStyleSheetUtility::fileNameDockWidgetTab()
{
static const QString f("dockwidgettab.qss");
return f;
}
const QString &CStyleSheetUtility::fileNameInfoWindow()
{
static const QString f("stylesheetinfo.qss");
return f;
}
const QString &CStyleSheetUtility::fileNameTextMessage()
{
static const QString f("textmessage.css");
return f;
}
const QString &CStyleSheetUtility::fileNameFilterDialog()
{
static const QString f("filterdialog.qss");
return f;
}
const QString &CStyleSheetUtility::fileNameIniFile()
{
static const QString f("gui.ini");
return f;
}
const QStringList &CStyleSheetUtility::fontWeights()
{
static const QStringList w( {"bold", "semibold", "light", "black", "normal"});
return w;
}
const QStringList &CStyleSheetUtility::fontStyles()
{
static const QStringList s( {"italic", "oblique", "normal"});
return s;
}
const QString &CStyleSheetUtility::transparentBackgroundColor()
{
static const QString t = "background-color: transparent;";
return t;
}
QString CStyleSheetUtility::qssDirectory()
{
QString dirPath = QCoreApplication::applicationDirPath();

View File

@@ -17,6 +17,8 @@
#include <QFont>
#include <QStringList>
#include <QStyle>
#include <QScopedPointer>
#include <QSettings>
namespace BlackGui
{
@@ -48,6 +50,9 @@ namespace BlackGui
//! Current font color from style sheet
QString fontColor();
//! GUI ini file data
const QSettings *iniFile() const { return m_iniFile.data(); }
//! Get the font style
static QString fontStyle(const QString &combinedStyleAndWeight);
@@ -55,82 +60,40 @@ namespace BlackGui
static QString fontWeight(const QString &combinedStyleAndWeight);
//! Central reader
static CStyleSheetUtility &instance()
{
static CStyleSheetUtility r;
return r;
}
static CStyleSheetUtility &instance();
//! File name fonts.qss
static const QString &fileNameFonts()
{
static const QString f("fonts.qss");
return f;
}
static const QString &fileNameFonts();
//! File name mainwindow.qss
static const QString &fileNameMainWindow()
{
static const QString f("mainwindow.qss");
return f;
}
static const QString &fileNameMainWindow();
//! File name infobar.qss
static const QString &fileNameInfoBar()
{
static const QString f("infobar.qss");
return f;
}
static const QString &fileNameInfoBar();
//! File name dockwidgettab.qss
static const QString &fileNameDockWidgetTab()
{
static const QString f("dockwidgettab.qss");
return f;
}
static const QString &fileNameDockWidgetTab();
//! File name maininfoarea.qss
static const QString &fileNameInfoWindow()
{
static const QString f("stylesheetinfo.qss");
return f;
}
static const QString &fileNameInfoWindow();
//! File name textmessage.qss
static const QString &fileNameTextMessage()
{
static const QString f("textmessage.css");
return f;
}
static const QString &fileNameTextMessage();
//! File name maininfoarea.qss
static const QString &fileNameFilterDialog()
{
static const QString f("filterdialog.qss");
return f;
}
static const QString &fileNameFilterDialog();
//! File name ini file
static const QString &fileNameIniFile();
//! Font weights
static const QStringList &fontWeights()
{
static const QStringList w( {"bold", "semibold", "light", "black", "normal"});
return w;
}
static const QStringList &fontWeights();
//! Font styles
static const QStringList &fontStyles()
{
static const QStringList s( {"italic", "oblique", "normal"});
return s;
}
static const QStringList &fontStyles();
//! Transparent background color
static const QString &transparentBackgroundColor()
{
static const QString t = "background-color: transparent;";
return t;
}
static const QString &transparentBackgroundColor();
//! qss directory
static QString qssDirectory();
@@ -157,6 +120,7 @@ namespace BlackGui
private:
QMap<QString, QString> m_styleSheets; //!< filename, stylesheet
QScopedPointer<QSettings> m_iniFile;
//! Constructor
explicit CStyleSheetUtility(QObject *parent = nullptr);