diff --git a/samples/blackgui/mainwindow.cpp b/samples/blackgui/mainwindow.cpp
index 176e2e1a0..adcd0d8ac 100644
--- a/samples/blackgui/mainwindow.cpp
+++ b/samples/blackgui/mainwindow.cpp
@@ -9,8 +9,7 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
-#include "blackmisc/iconsstandard.h"
-#include "blackmisc/iconsnetwork.h"
+#include "blackmisc/icon.h"
#include "blackgui/stylesheetutility.h"
#include "blackgui/models/atcstationlistmodel.h"
#include "blackcore/dbus_server.h"
@@ -47,7 +46,7 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
m_timerContextWatchdog(nullptr),
m_timerStatusBar(nullptr), m_timerSimulator(nullptr),
// context menus
- m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr),
+ m_contextMenuStatusMessageList(nullptr),
// cockpit
m_inputFocusedWidget(nullptr),
// status bar
@@ -160,10 +159,10 @@ void MainWindow::ps_setMainPage(bool start)
}
QObject *sender = QObject::sender();
- if (sender == this->ui->pb_MainConnect || sender == this->ui->pb_MainStatus)
- this->ui->sw_MainMiddle->setCurrentIndex(MainPageStatus);
- else if (sender == this->ui->pb_MainCockpit)
+ if (sender == this->ui->pb_MainCockpit)
+ {
this->ui->sw_MainMiddle->setCurrentIndex(MainPageCockpit);
+ }
else
{
this->ui->sw_MainMiddle->setCurrentIndex(MainPageFoo);
@@ -200,6 +199,10 @@ void MainWindow::ps_setMainPage(bool start)
{
this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaWeather);
}
+ else if (sender == this->ui->pb_MainLog)
+ {
+ this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaLog);
+ }
else if (sender == this->ui->pb_MainMappings)
{
this->ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaMappings);
@@ -230,8 +233,6 @@ void MainWindow::ps_toggleNetworkConnection()
{
CStatusMessageList msgs;
if (!this->isContextNetworkAvailableCheck()) return;
-
- this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(CIconsNetworkAndAviation::statusTransition());
if (!this->getIContextNetwork()->isConnected())
{
// validation of data here is not required, network context does this
@@ -299,11 +300,11 @@ void MainWindow::ps_displayStatusMessageInGui(const CStatusMessage &statusMessag
if (!this->m_init) return;
this->ui->sb_MainStatusBar->show();
this->m_timerStatusBar->start(3000);
- this->m_statusBarIcon->setPixmap(statusMessage.toIcon());
+ this->m_statusBarIcon->setPixmap(statusMessage.toPixmap());
this->m_statusBarLabel->setText(statusMessage.getMessage());
// list
- this->ui->tvp_StatusMessages->insert(statusMessage);
+ this->ui->comp_MainInfoArea->getLogComponent()->appendStatusMessageToList(statusMessage);
// display overlay for errors, but not for validation
if (statusMessage.getSeverity() == CStatusMessage::SeverityError && statusMessage.getType() != CStatusMessage::TypeValidation)
@@ -326,7 +327,7 @@ void MainWindow::displayRedirectedOutput(const CStatusMessage &statusMessage, qi
{
if (!this->getIContextApplication()) return;
if (this->getIContextApplication()->getUniqueId() == contextId) return; //self triggered
- this->ui->te_StatusPageConsole->appendHtml(statusMessage.toHtml());
+ this->ui->comp_MainInfoArea->getLogComponent()->appendStatusMessageToConsole(statusMessage);
}
void MainWindow::ps_onChangedSetttings(uint typeValue)
@@ -410,41 +411,23 @@ void MainWindow::updateGuiStatusInformation()
{
bool dbus = !this->getIContextNetwork()->usingLocalObjects();
network = dbus ? now : "local";
- this->ui->cb_StatusWithDBus->setChecked(dbus);
- }
-
- // handle voice, mute
- QString voice("unavailable");
- if (this->m_contextAudioAvailable)
- {
- voice = this->getIContextAudio()->usingLocalObjects() ? "local" : now;
- this->ui->pb_SoundMute->setEnabled(true);
- }
- else
- {
- // voice not available
- this->ui->pb_SoundMute->setEnabled(false);
+ this->ui->comp_InfoBarStatus->setDBusStatus(dbus);
}
// update status fields
- this->ui->le_StatusNetworkContext->setText(network);
- this->ui->le_StatusAudioContext->setText(voice);
+ QString s = QString("network: %1").arg(network);
+ this->ui->comp_InfoBarStatus->setDBusTooltip(s);
// Connected button
if (this->m_contextNetworkAvailable && this->getIContextNetwork()->isConnected())
{
- if (this->ui->lbl_StatusNetworkConnectedIcon->toolTip().startsWith("dis", Qt::CaseInsensitive))
- this->ui->lbl_StatusNetworkConnectedIcon->setToolTip(now);
this->ui->pb_MainConnect->setText("Disconnect");
this->ui->pb_MainConnect->setStyleSheet("background-color: green");
- this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(CIconsNetworkAndAviation::statusConnected());
}
else
{
- this->ui->lbl_StatusNetworkConnectedIcon->setToolTip("disconnected");
this->ui->pb_MainConnect->setText("Connect");
this->ui->pb_MainConnect->setStyleSheet("background-color: ");
- this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(CIconsNetworkAndAviation::statusDisconnected());
}
}
@@ -471,25 +454,39 @@ void MainWindow::ps_changeWindowOpacity(int opacity)
void MainWindow::updateSimulatorData()
{
- if (this->getIContextSimulator()->isConnected())
- ui->le_SimulatorStatus->setText("Connected");
- else
- ui->le_SimulatorStatus->setText("Not connected");
+ CSimulatorComponent *simComp = this->ui->comp_MainInfoArea->getSimulatorComponent();
+ Q_ASSERT(simComp);
+ if (!this->getIContextSimulator()->isConnected())
+ {
+ simComp->clear();
+ simComp->addOrUpdateByName("info", "sim not connected", CIcons::StandardIconWarning16);
+ return;
+ }
+
+ // clear old warnings / information
+ if (simComp->rowCount() < 5)
+ {
+ simComp->clear();
+ }
CAircraft ownAircraft = this->getIContextOwnAircraft()->getOwnAircraft();
- ui->le_SimulatorLatitude->setText(ownAircraft.getSituation().latitude().toFormattedQString());
- ui->le_SimulatorLongitude->setText(ownAircraft.getSituation().longitude().toFormattedQString());
- ui->le_SimulatorAltitude->setText(ownAircraft.getSituation().getAltitude().toFormattedQString());
- ui->le_SimulatorPitch->setText(ownAircraft.getSituation().getPitch().toFormattedQString());
- ui->le_SimulatorBank->setText(ownAircraft.getSituation().getBank().toFormattedQString());
- ui->le_SimulatorHeading->setText(ownAircraft.getSituation().getHeading().toFormattedQString());
- ui->le_SimulatorGroundSpeed->setText(ownAircraft.getSituation().getGroundSpeed().toFormattedQString());
+ CAircraftSituation s = ownAircraft.getSituation();
+ CComSystem c1 = ownAircraft.getCom1System();
+ CComSystem c2 = ownAircraft.getCom2System();
- ui->le_SimulatorCom1Active->setText(ownAircraft.getCom1System().getFrequencyActive().toFormattedQString());
- ui->le_SimulatorCom1Standby->setText(ownAircraft.getCom1System().getFrequencyStandby().toFormattedQString());
- ui->le_SimulatorCom2Active->setText(ownAircraft.getCom2System().getFrequencyActive().toFormattedQString());
- ui->le_SimulatorCom2Standby->setText(ownAircraft.getCom2System().getFrequencyStandby().toFormattedQString());
- ui->le_SimulatorTransponder->setText(ownAircraft.getTransponderCodeFormatted());
+ simComp->addOrUpdateByName("latitude", s.latitude().toFormattedQString(), s.latitude().toIcon());
+ simComp->addOrUpdateByName("longitude", s.longitude().toFormattedQString(), s.longitude().toIcon());
+ simComp->addOrUpdateByName("altitude", s.getAltitude().toFormattedQString(), s.getAltitude().toIcon());
+ simComp->addOrUpdateByName("pitch", s.getPitch().toFormattedQString(), CIcons::AviationAttitudeIndicator);
+ simComp->addOrUpdateByName("bank", s.getBank().toFormattedQString(), CIcons::AviationAttitudeIndicator);
+ simComp->addOrUpdateByName("heading", s.getHeading().toFormattedQString(), s.getHeading().toIcon());
+ simComp->addOrUpdateByName("ground speed", s.getGroundSpeed().toFormattedQString(), s.getGroundSpeed().toIcon());
+
+ simComp->addOrUpdateByName("COM1 active", c1.getFrequencyActive().toFormattedQString(), c1.getFrequencyActive().toIcon());
+ simComp->addOrUpdateByName("COM2 active", c2.getFrequencyActive().toFormattedQString(), c2.getFrequencyActive().toIcon());
+ simComp->addOrUpdateByName("COM1 standby", c1.getFrequencyStandby().toFormattedQString(), c1.getFrequencyStandby().toIcon());
+ simComp->addOrUpdateByName("COM2 standby", c2.getFrequencyStandby().toFormattedQString(), c2.getFrequencyStandby().toIcon());
+ simComp->addOrUpdateByName("Transponder", ownAircraft.getTransponderCodeFormatted(), ownAircraft.getTransponder().toIcon());
}
void MainWindow::ps_onSimulatorConnectionChanged(bool isAvailable)
diff --git a/samples/blackgui/mainwindow.h b/samples/blackgui/mainwindow.h
index 6e24d5239..24c2cb93e 100644
--- a/samples/blackgui/mainwindow.h
+++ b/samples/blackgui/mainwindow.h
@@ -74,9 +74,8 @@ protected:
//! \remarks keep the values in sync with the real tab indexes
enum MainPageIndex
{
- MainPageStatus = 0,
- MainPageCockpit = 4,
- MainPageFoo = 9
+ MainPageCockpit = 0,
+ MainPageFoo = 1
};
private:
@@ -99,7 +98,6 @@ private:
QPoint m_dragPosition; /*!< position, if moving is handled with frameless window */
// context menus
- QMenu *m_contextMenuAudio; /*!< audio context menu */
QMenu *m_contextMenuStatusMessageList; /*!< context menu for status message list */
// cockpit
@@ -119,9 +117,6 @@ private:
//! Init GUI signals
void initGuiSignals();
- //! Init the context menus
- void initContextMenus();
-
//! Context network availability check, otherwise status message
bool isContextNetworkAvailableCheck();
@@ -242,9 +237,6 @@ private slots:
*/
void ps_changeWindowOpacity(int opacity = -1);
- //! Context menu for audio
- void ps_displayAudioIconContextMenu(const QPoint &position);
-
//! Toogle Windows stay on top
void ps_toogleWindowStayOnTop();
diff --git a/samples/blackgui/mainwindow.ui b/samples/blackgui/mainwindow.ui
index f41a69fdd..8cc39e418 100644
--- a/samples/blackgui/mainwindow.ui
+++ b/samples/blackgui/mainwindow.ui
@@ -7,7 +7,7 @@
0
0
350
- 550
+ 574
@@ -35,6 +35,9 @@
Qt::ToolButtonIconOnly
+
+ true
+
QTabWidget::Rounded
@@ -124,82 +127,6 @@
2
- -
-
-
-
- 0
- 0
-
-
-
-
- 16777215
- 22
-
-
-
- Cockpit
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 16777215
- 22
-
-
-
- Mappings
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 16777215
- 22
-
-
-
- Weather
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 16777215
- 22
-
-
-
- Status
-
-
-
-
@@ -213,28 +140,6 @@
- -
-
-
-
- 0
- 0
-
-
-
-
- 16777215
- 22
-
-
-
- Qt::LeftToRight
-
-
- Settings
-
-
-
-
@@ -333,8 +238,8 @@
- -
-
+
-
+
0
@@ -348,58 +253,11 @@
- Text/Chat
+ Aircrafts
- -
-
-
-
- 0
- 0
-
-
-
-
- 16777215
- 22
-
-
-
- Flightplan
-
-
-
- -
-
-
- Users
-
-
-
- -
-
-
- Ident
-
-
-
- -
-
-
- Simulator
-
-
-
- -
-
-
- Foo
-
-
-
- -
+
-
@@ -418,8 +276,15 @@
- -
-
+
-
+
+
+ Users
+
+
+
+ -
+
0
@@ -433,7 +298,145 @@
- Aircrafts
+ Cockpit
+
+
+
+ -
+
+
+ Ident
+
+
+
+ -
+
+
+ Foo
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 22
+
+
+
+ Text/Chat
+
+
+
+ -
+
+
+ Simulator
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 22
+
+
+
+ Weather
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 22
+
+
+
+ Flightplan
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 22
+
+
+
+ Mappings
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 22
+
+
+
+ Qt::LeftToRight
+
+
+ Settings
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 22
+
+
+
+ Log
@@ -462,277 +465,8 @@
QFrame::NoFrame
- 7
+ 1
-
-
-
- 0
- 0
-
-
-
-
- 4
-
-
- 2
-
-
- 2
-
-
- 2
-
-
- 2
-
- -
-
-
-
-
-
- DBus
-
-
- true
-
-
- false
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- Network connected
-
-
-
- -
-
-
- Network context
-
-
-
- -
-
-
- Voice context
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
-
-
-
- :/blackgui/icons/loginred.png
-
-
-
- -
-
-
-
-
-
- :/blackgui/icons/audiovolumelow.png
-
-
-
-
-
- -
-
-
- 0
-
-
- 3
-
-
-
-
- 0
- 0
- 79
- 71
-
-
-
- Messages
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- QAbstractItemView::SingleSelection
-
-
- QAbstractItemView::SelectRows
-
-
- false
-
-
-
-
-
-
-
-
- 0
- 0
- 83
- 71
-
-
-
- Console
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 75
- false
- true
-
-
-
- QPlainTextEdit::NoWrap
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
@@ -755,247 +489,6 @@
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- -
-
-
- Longitude
-
-
-
- -
-
-
- Status
-
-
-
- -
-
-
- Bank
-
-
-
- -
-
-
- Latitude
-
-
-
- -
-
-
- Ground Speed
-
-
-
- -
-
-
- Heading
-
-
-
- -
-
-
- On ground
-
-
-
- -
-
-
- Altitude
-
-
-
- -
-
-
- Pitch
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- COM1 Standby
-
-
-
- -
-
-
- COM1 Active
-
-
-
- -
-
-
- COM2 Active
-
-
-
- -
-
-
- COM2 Standby
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- false
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- false
-
-
-
- -
-
-
- -
-
-
- Transponder
-
-
-
-
-
@@ -1114,6 +607,18 @@
false
+
+
+ QDockWidget::AllDockWidgetFeatures
+
+
+ Qt::BottomDockWidgetArea|Qt::TopDockWidgetArea
+
+
+ 4
+
+
+
Position EDDF (Frankfurt, GER)
@@ -1167,11 +672,6 @@
-
- BlackGui::Views::CStatusMessageView
- QTableView
- blackgui/views/statusmessageview.h
-
BlackGui::Components::CCockpitV1Component
QWidget
@@ -1184,28 +684,26 @@
blackgui/components/maininfoareacomponent.h
1
+
+ BlackGui::Components::CInfoBarStatus
+ QWidget
+ blackgui/components/infobarstatus.h
+ 1
+
+
+ BlackGui::CDockWidgetInfoBar
+ QDockWidget
+ blackgui/dockwidgetinfobar.h
+ 1
+
- cb_StatusWithDBus
- le_StatusNetworkContext
- le_StatusAudioContext
- tvp_StatusMessages
le_CommandLineInput
pb_MainConnect
- pb_MainStatus
- pb_MainWeather
- pb_MainFlightplan
- pb_MainUsers
- pb_CockpitIdent
- pb_MainCockpit
- pb_MainTextMessages
- pb_MainMappings
- pb_MainSettings
pb_MainKeypadOpacity100
pb_MainKeypadOpacity050
pb_SoundMute
pb_SoundMaxVolume
- te_StatusPageConsole
diff --git a/samples/blackgui/mainwindow_init.cpp b/samples/blackgui/mainwindow_init.cpp
index 5a226352c..56f8ebf38 100644
--- a/samples/blackgui/mainwindow_init.cpp
+++ b/samples/blackgui/mainwindow_init.cpp
@@ -17,7 +17,7 @@
#include "blackgui/components/textmessagecomponent.h"
#include "blackgui/models/atcstationlistmodel.h"
#include "blackgui/models/keyboardkeylistmodel.h"
-#include "blackmisc/iconsstandard.h"
+#include "blackmisc/icons.h"
#include "blackmisc/avselcal.h"
#include "blackmisc/project.h"
#include
@@ -129,9 +129,6 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
// start screen
this->ps_setMainPage(true);
- // init context menus
- this->initContextMenus();
-
// starting
this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStarts);
@@ -139,8 +136,8 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
ps_onSimulatorConnectionChanged(this->getIContextSimulator()->isConnected());
// info
- this->ui->te_StatusPageConsole->appendPlainText(CProject::systemNameAndVersion());
- this->ui->te_StatusPageConsole->appendPlainText(CProject::compiledInfo());
+ this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(CProject::systemNameAndVersion());
+ this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(CProject::compiledInfo());
// hotkeys
this->ps_registerHotkeys();
@@ -180,8 +177,6 @@ void MainWindow::initGuiSignals()
Q_ASSERT(connected);
connected = this->connect(this->ui->pb_MainSimulator, SIGNAL(released()), this, SLOT(ps_setMainPage()));
Q_ASSERT(connected);
- connected = this->connect(this->ui->pb_MainStatus, SIGNAL(released()), this, SLOT(ps_setMainPage()));
- Q_ASSERT(connected);
connected = this->connect(this->ui->pb_MainUsers, SIGNAL(released()), this, SLOT(ps_setMainPage()));
Q_ASSERT(connected);
connected = this->connect(this->ui->pb_MainTextMessages, SIGNAL(released()), this, SLOT(ps_setMainPage()));
@@ -190,6 +185,8 @@ void MainWindow::initGuiSignals()
Q_ASSERT(connected);
connected = this->connect(this->ui->pb_MainMappings, SIGNAL(released()), this, SLOT(ps_setMainPage()));
Q_ASSERT(connected);
+ connected = this->connect(this->ui->pb_MainLog, SIGNAL(released()), this, SLOT(ps_setMainPage()));
+ Q_ASSERT(connected);
connected = this->connect(this->ui->pb_MainKeypadOpacity050, SIGNAL(clicked()), this, SLOT(ps_changeWindowOpacity()));
Q_ASSERT(connected);
connected = this->connect(this->ui->pb_MainKeypadOpacity100, SIGNAL(clicked()), this, SLOT(ps_changeWindowOpacity()));
diff --git a/samples/blackgui/mainwindow_menus.cpp b/samples/blackgui/mainwindow_menus.cpp
index cf3d54dea..f4f56ae02 100644
--- a/samples/blackgui/mainwindow_menus.cpp
+++ b/samples/blackgui/mainwindow_menus.cpp
@@ -80,50 +80,3 @@ void MainWindow::ps_onMenuClicked()
}
if (!msgs.isEmpty()) this->ps_displayStatusMessagesInGui(msgs);
}
-
-/*
- * Reload settings
- */
-void MainWindow::initContextMenus()
-{
- this->ui->lbl_StatusVoiceStatus->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(this->ui->lbl_StatusVoiceStatus, &QLabel::customContextMenuRequested, this, &MainWindow::ps_displayAudioIconContextMenu);
-}
-
-/*
- * Audio context menu
- */
-void MainWindow::ps_displayAudioIconContextMenu(const QPoint &position)
-{
- // position for most widgets
- QWidget *sender = qobject_cast(QWidget::sender());
- Q_ASSERT(sender);
- QPoint globalPosition = sender->mapToGlobal(position);
-
- if (!this->m_contextMenuAudio)
- {
- this->m_contextMenuAudio = new QMenu(this);
- this->m_contextMenuAudio->addAction("Toogle mute");
-
-#if defined(Q_OS_WIN)
- // QSysInfo::WindowsVersion only available on Win platforms
- if (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)
- {
- this->m_contextMenuAudio->addAction("Mixer");
- }
-#endif
- }
-
- QAction *selectedItem = this->m_contextMenuAudio->exec(globalPosition);
- if (selectedItem)
- {
- // http://forum.technical-assistance.co.uk/sndvol32exe-command-line-parameters-vt1348.html
- const QList actions = this->m_contextMenuAudio->actions();
- if (selectedItem == actions.at(0)) this->ui->pb_SoundMute->click();
- else if (actions.size() > 1 && selectedItem == actions.at(1))
- {
- QStringList parameterlist;
- QProcess::startDetached("SndVol.exe", parameterlist);
- }
- }
-}
diff --git a/src/blackgui/guiutility.cpp b/src/blackgui/guiutility.cpp
new file mode 100644
index 000000000..d7660bf2b
--- /dev/null
+++ b/src/blackgui/guiutility.cpp
@@ -0,0 +1,64 @@
+/* Copyright (C) 2014
+ * swift Project Community / Contributors
+ *
+ * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
+ * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project,
+ * including this file, may be copied, modified, propagated, or distributed except according to the terms
+ * contained in the LICENSE file.
+ */
+
+#include "guiutility.h"
+#include
+#include
+
+namespace BlackGui
+{
+
+ QMainWindow *CGuiUtility::mainWindow()
+ {
+ QWidgetList tlw = topLevelApplicationWidgetsWithName();
+ foreach(QWidget * w, tlw)
+ {
+ QMainWindow *mw = qobject_cast(w);
+ if (!mw) { continue; }
+ QString n = mw->objectName().toLower();
+ if (n.contains("main") && n.contains("window")) return mw;
+ }
+ return nullptr;
+ }
+
+ QWidgetList CGuiUtility::topLevelApplicationWidgetsWithName()
+ {
+ QWidgetList tlw = QApplication::topLevelWidgets();
+ QWidgetList rl;
+ foreach(QWidget * w, tlw)
+ {
+ if (w->objectName().isEmpty()) continue;
+ rl.append(w);
+ }
+ return rl;
+ }
+
+ QPoint CGuiUtility::mainWindowPosition()
+ {
+ QMainWindow *mw = mainWindow();
+ return (mw) ? mw->pos() : QPoint();
+ }
+
+ QPoint CGuiUtility::introWindowPosition()
+ {
+ QWidgetList tlw = topLevelApplicationWidgetsWithName();
+ foreach(QWidget * w, tlw)
+ {
+ QString n = w->objectName().toLower();
+ if (n.contains("intro")) return w->pos();
+ }
+ return QPoint(0, 0);
+ }
+
+ QPoint CGuiUtility::assumedMainWindowPosition()
+ {
+ QPoint p = mainWindowPosition();
+ return (p.isNull()) ? introWindowPosition() : p;
+ }
+}
diff --git a/src/blackgui/guiutility.h b/src/blackgui/guiutility.h
new file mode 100644
index 000000000..5bacc4d6c
--- /dev/null
+++ b/src/blackgui/guiutility.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 2014
+ * swift Project Community / Contributors
+ *
+ * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
+ * directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project,
+ * including this file, may be copied, modified, propagated, or distributed except according to the terms
+ * contained in the LICENSE file.
+ */
+
+//! \file
+
+#ifndef BLACKGUI_GUIUTILITY_H
+#define BLACKGUI_GUIUTILITY_H
+
+#include
+#include
+
+namespace BlackGui
+{
+ //! GUI utilities
+ class CGuiUtility
+ {
+
+ public:
+
+ //! Main application window
+ static QMainWindow *mainWindow();
+
+ //! Top level widgets with names
+ static QWidgetList topLevelApplicationWidgetsWithName();
+
+ //! Position of main window
+ static QPoint mainWindowPosition();
+
+ //! Position of intro window
+ static QPoint introWindowPosition();
+
+ //! During initialization, when main window position might not be set set
+ static QPoint assumedMainWindowPosition();
+
+ private:
+ //! Constructor, use static methods only
+ CGuiUtility() {}
+ };
+
+}
+
+#endif // guard
diff --git a/src/blackgui/qss/mainwindow.qss b/src/blackgui/qss/mainwindow.qss
index 7b9899e78..a68928b11 100644
--- a/src/blackgui/qss/mainwindow.qss
+++ b/src/blackgui/qss/mainwindow.qss
@@ -1,5 +1,9 @@
/** http://qt-project.org/doc/qt-5.3/stylesheet-examples.html **/
+#MainWindow {
+ background-color: darkslategray;
+}
+
QWidget {
background-color: black;
}