mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 02:06:08 +08:00
refs #445, preparation for data GUI
* improved finding of main window * project -> version string * location of application icon
This commit is contained in:
committed by
Mathew Sutcliffe
parent
b308014bc2
commit
3e982b014f
@@ -69,7 +69,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
CEnableForFramelessWindow *CEnableForDockWidgetInfoArea::mainApplicationWindow() const
|
CEnableForFramelessWindow *CEnableForDockWidgetInfoArea::mainApplicationWindow() const
|
||||||
{
|
{
|
||||||
CEnableForFramelessWindow *mw = CGuiUtility::mainApplicationWindow();
|
CEnableForFramelessWindow *mw = CGuiUtility::mainFramelessEnabledApplicationWindow();
|
||||||
return mw;
|
return mw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,6 @@
|
|||||||
#include "../stylesheetutility.h"
|
#include "../stylesheetutility.h"
|
||||||
#include "../guiutility.h"
|
#include "../guiutility.h"
|
||||||
#include "blackmisc/icons.h"
|
#include "blackmisc/icons.h"
|
||||||
#include <QMenu>
|
|
||||||
#include <QListIterator>
|
|
||||||
#include <QSignalMapper>
|
|
||||||
#include <QCloseEvent>
|
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackGui;
|
using namespace BlackGui;
|
||||||
@@ -30,7 +26,8 @@ namespace BlackGui
|
|||||||
ui(new Ui::CMainInfoAreaComponent)
|
ui(new Ui::CMainInfoAreaComponent)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
initInfoArea();
|
initInfoArea(); // init base class
|
||||||
|
this->setWindowIcon(CIcons::swift24());
|
||||||
}
|
}
|
||||||
|
|
||||||
CMainInfoAreaComponent::~CMainInfoAreaComponent()
|
CMainInfoAreaComponent::~CMainInfoAreaComponent()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include "blackmisc/filelogger.h"
|
#include "blackmisc/filelogger.h"
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
#include "blackmisc/project.h"
|
#include "blackmisc/project.h"
|
||||||
#include <QWidget>
|
#include <QMainWindow>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@@ -22,27 +22,42 @@ using namespace BlackMisc;
|
|||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
CEnableForFramelessWindow *CGuiUtility::mainApplicationWindow()
|
CEnableForFramelessWindow *CGuiUtility::mainFramelessEnabledApplicationWindow()
|
||||||
{
|
{
|
||||||
QWidgetList tlw = topLevelApplicationWidgetsWithName();
|
QWidgetList tlw = topLevelApplicationWidgetsWithName();
|
||||||
foreach(QWidget * w, tlw)
|
for (QWidget *w : tlw)
|
||||||
{
|
{
|
||||||
|
// best coice is to check on frameless window
|
||||||
CEnableForFramelessWindow *mw = dynamic_cast<CEnableForFramelessWindow *>(w);
|
CEnableForFramelessWindow *mw = dynamic_cast<CEnableForFramelessWindow *>(w);
|
||||||
if (!mw) { continue; }
|
if (mw && mw->isMainApplicationWindow()) { return mw; }
|
||||||
if (mw->isMainApplicationWindow()) { return mw; }
|
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *CGuiUtility::mainApplicationWindowWidget()
|
QWidget *CGuiUtility::mainApplicationWindowWidget()
|
||||||
{
|
{
|
||||||
CEnableForFramelessWindow *mw = mainApplicationWindow();
|
CEnableForFramelessWindow *mw = mainFramelessEnabledApplicationWindow();
|
||||||
return mw ? mw->getWidget() : nullptr;
|
if (mw && mw->getWidget())
|
||||||
|
{
|
||||||
|
return mw->getWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
// second choice, try via QMainWindow
|
||||||
|
QWidgetList tlw = topLevelApplicationWidgetsWithName();
|
||||||
|
for (QWidget *w : tlw)
|
||||||
|
{
|
||||||
|
QMainWindow *qmw = qobject_cast<QMainWindow *>(w);
|
||||||
|
if (!qmw) { continue; }
|
||||||
|
if (!qmw->parentWidget()) { return qmw; }
|
||||||
|
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGuiUtility::isMainWindowFrameless()
|
bool CGuiUtility::isMainWindowFrameless()
|
||||||
{
|
{
|
||||||
CEnableForFramelessWindow *mw = mainApplicationWindow();
|
CEnableForFramelessWindow *mw = mainFramelessEnabledApplicationWindow();
|
||||||
Q_ASSERT(mw); // there should be a main window
|
Q_ASSERT(mw); // there should be a main window
|
||||||
return (mw && mw->isFrameless());
|
return (mw && mw->isFrameless());
|
||||||
}
|
}
|
||||||
@@ -90,7 +105,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
QPoint CGuiUtility::mainWindowPosition()
|
QPoint CGuiUtility::mainWindowPosition()
|
||||||
{
|
{
|
||||||
CEnableForFramelessWindow *mw = mainApplicationWindow();
|
CEnableForFramelessWindow *mw = mainFramelessEnabledApplicationWindow();
|
||||||
return (mw) ? mw->getWidget()->pos() : QPoint();
|
return (mw) ? mw->getWidget()->pos() : QPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Main application window
|
//! Main (frameless enabled) application window
|
||||||
static CEnableForFramelessWindow *mainApplicationWindow();
|
static CEnableForFramelessWindow *mainFramelessEnabledApplicationWindow();
|
||||||
|
|
||||||
//! Main application window widget
|
//! Main application window widget
|
||||||
static QWidget *mainApplicationWindowWidget();
|
static QWidget *mainApplicationWindowWidget();
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ using namespace BlackMisc;
|
|||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
CInfoArea::CInfoArea(QWidget *parent) :
|
CInfoArea::CInfoArea(QWidget *parent) :
|
||||||
QMainWindow(parent), CEnableForFramelessWindow(CEnableForFramelessWindow::WindowTool, false, "framelessInfoArea", this)
|
QMainWindow(parent),
|
||||||
|
CEnableForFramelessWindow(CEnableForFramelessWindow::WindowTool, false, "framelessInfoArea", this)
|
||||||
{
|
{
|
||||||
this->ps_setWholeInfoAreaFloating(this->m_infoAreaFloating);
|
this->ps_setWholeInfoAreaFloating(this->m_infoAreaFloating);
|
||||||
this->setWindowIcon(CIcons::swift24());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CInfoArea::~CInfoArea()
|
CInfoArea::~CInfoArea()
|
||||||
@@ -704,13 +704,12 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CInfoArea::setTabPixmaps()
|
void CInfoArea::setTabPixmaps()
|
||||||
{
|
{
|
||||||
if (!this->m_tabBar) return;
|
if (!this->m_tabBar) { return; }
|
||||||
for (int i = 0; i < this->m_tabBar->count(); i++)
|
for (int i = 0; i < this->m_tabBar->count(); i++)
|
||||||
{
|
{
|
||||||
const QString t(this->m_tabBar->tabText(i));
|
const QString t(this->m_tabBar->tabText(i));
|
||||||
int areaIndex = t.isEmpty() ? i : this->getAreaIndexByWindowTitle(t);
|
int areaIndex = t.isEmpty() ? i : this->getAreaIndexByWindowTitle(t);
|
||||||
const QPixmap p = indexToPixmap(areaIndex);
|
this->m_tabBar->setTabIcon(i, indexToPixmap(areaIndex));
|
||||||
this->m_tabBar->setTabIcon(i, p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
// filter
|
// filter
|
||||||
QWidget *mainWindow = this->mainApplicationWindowWidget();
|
QWidget *mainWindow = this->mainApplicationWindowWidget();
|
||||||
Q_ASSERT(mainWindow);
|
Q_ASSERT_X(mainWindow, Q_FUNC_INFO, "no main window found");
|
||||||
this->setFilterDialog(new CAircraftModelFilterForm(mainWindow));
|
this->setFilterDialog(new CAircraftModelFilterForm(mainWindow));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,15 +124,15 @@ namespace BlackMisc
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &CProject::systemNameAndVersion()
|
const QString &CProject::swiftVersionString()
|
||||||
{
|
{
|
||||||
static QString s = QString("swift %1").arg(version());
|
static QString s = QString("swift %1").arg(version());
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *CProject::systemNameAndVersionChar()
|
const char *CProject::swiftVersionChar()
|
||||||
{
|
{
|
||||||
static const QByteArray a(systemNameAndVersion().toUtf8());
|
static const QByteArray a(swiftVersionString().toUtf8());
|
||||||
return a.constData();
|
return a.constData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,10 +59,10 @@ namespace BlackMisc
|
|||||||
static const QString &version();
|
static const QString &version();
|
||||||
|
|
||||||
//! System's name and version
|
//! System's name and version
|
||||||
static const QString &systemNameAndVersion();
|
static const QString &swiftVersionString();
|
||||||
|
|
||||||
//! System's name and version
|
//! System's name and version
|
||||||
static const char *systemNameAndVersionChar();
|
static const char *swiftVersionChar();
|
||||||
|
|
||||||
//! Version major
|
//! Version major
|
||||||
static int versionMajor();
|
static int versionMajor();
|
||||||
|
|||||||
Reference in New Issue
Block a user