mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +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 *mw = CGuiUtility::mainApplicationWindow();
|
||||
CEnableForFramelessWindow *mw = CGuiUtility::mainFramelessEnabledApplicationWindow();
|
||||
return mw;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
#include "../stylesheetutility.h"
|
||||
#include "../guiutility.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include <QMenu>
|
||||
#include <QListIterator>
|
||||
#include <QSignalMapper>
|
||||
#include <QCloseEvent>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui;
|
||||
@@ -30,7 +26,8 @@ namespace BlackGui
|
||||
ui(new Ui::CMainInfoAreaComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
initInfoArea();
|
||||
initInfoArea(); // init base class
|
||||
this->setWindowIcon(CIcons::swift24());
|
||||
}
|
||||
|
||||
CMainInfoAreaComponent::~CMainInfoAreaComponent()
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "blackmisc/filelogger.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/project.h"
|
||||
#include <QWidget>
|
||||
#include <QMainWindow>
|
||||
#include <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QMessageBox>
|
||||
@@ -22,27 +22,42 @@ using namespace BlackMisc;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
CEnableForFramelessWindow *CGuiUtility::mainApplicationWindow()
|
||||
CEnableForFramelessWindow *CGuiUtility::mainFramelessEnabledApplicationWindow()
|
||||
{
|
||||
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);
|
||||
if (!mw) { continue; }
|
||||
if (mw->isMainApplicationWindow()) { return mw; }
|
||||
if (mw && mw->isMainApplicationWindow()) { return mw; }
|
||||
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QWidget *CGuiUtility::mainApplicationWindowWidget()
|
||||
{
|
||||
CEnableForFramelessWindow *mw = mainApplicationWindow();
|
||||
return mw ? mw->getWidget() : nullptr;
|
||||
CEnableForFramelessWindow *mw = mainFramelessEnabledApplicationWindow();
|
||||
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()
|
||||
{
|
||||
CEnableForFramelessWindow *mw = mainApplicationWindow();
|
||||
CEnableForFramelessWindow *mw = mainFramelessEnabledApplicationWindow();
|
||||
Q_ASSERT(mw); // there should be a main window
|
||||
return (mw && mw->isFrameless());
|
||||
}
|
||||
@@ -90,7 +105,7 @@ namespace BlackGui
|
||||
|
||||
QPoint CGuiUtility::mainWindowPosition()
|
||||
{
|
||||
CEnableForFramelessWindow *mw = mainApplicationWindow();
|
||||
CEnableForFramelessWindow *mw = mainFramelessEnabledApplicationWindow();
|
||||
return (mw) ? mw->getWidget()->pos() : QPoint();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace BlackGui
|
||||
{
|
||||
|
||||
public:
|
||||
//! Main application window
|
||||
static CEnableForFramelessWindow *mainApplicationWindow();
|
||||
//! Main (frameless enabled) application window
|
||||
static CEnableForFramelessWindow *mainFramelessEnabledApplicationWindow();
|
||||
|
||||
//! Main application window widget
|
||||
static QWidget *mainApplicationWindowWidget();
|
||||
|
||||
@@ -27,10 +27,10 @@ using namespace BlackMisc;
|
||||
namespace BlackGui
|
||||
{
|
||||
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->setWindowIcon(CIcons::swift24());
|
||||
}
|
||||
|
||||
CInfoArea::~CInfoArea()
|
||||
@@ -704,13 +704,12 @@ namespace BlackGui
|
||||
|
||||
void CInfoArea::setTabPixmaps()
|
||||
{
|
||||
if (!this->m_tabBar) return;
|
||||
if (!this->m_tabBar) { return; }
|
||||
for (int i = 0; i < this->m_tabBar->count(); i++)
|
||||
{
|
||||
const QString t(this->m_tabBar->tabText(i));
|
||||
int areaIndex = t.isEmpty() ? i : this->getAreaIndexByWindowTitle(t);
|
||||
const QPixmap p = indexToPixmap(areaIndex);
|
||||
this->m_tabBar->setTabIcon(i, p);
|
||||
this->m_tabBar->setTabIcon(i, indexToPixmap(areaIndex));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace BlackGui
|
||||
|
||||
// filter
|
||||
QWidget *mainWindow = this->mainApplicationWindowWidget();
|
||||
Q_ASSERT(mainWindow);
|
||||
Q_ASSERT_X(mainWindow, Q_FUNC_INFO, "no main window found");
|
||||
this->setFilterDialog(new CAircraftModelFilterForm(mainWindow));
|
||||
}
|
||||
|
||||
|
||||
@@ -124,15 +124,15 @@ namespace BlackMisc
|
||||
return v;
|
||||
}
|
||||
|
||||
const QString &CProject::systemNameAndVersion()
|
||||
const QString &CProject::swiftVersionString()
|
||||
{
|
||||
static QString s = QString("swift %1").arg(version());
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -59,10 +59,10 @@ namespace BlackMisc
|
||||
static const QString &version();
|
||||
|
||||
//! System's name and version
|
||||
static const QString &systemNameAndVersion();
|
||||
static const QString &swiftVersionString();
|
||||
|
||||
//! System's name and version
|
||||
static const char *systemNameAndVersionChar();
|
||||
static const char *swiftVersionChar();
|
||||
|
||||
//! Version major
|
||||
static int versionMajor();
|
||||
|
||||
Reference in New Issue
Block a user