refs #445, preparation for data GUI

* improved finding of main window
* project -> version string
* location of application icon
This commit is contained in:
Klaus Basan
2015-07-10 01:22:37 +02:00
committed by Mathew Sutcliffe
parent b308014bc2
commit 3e982b014f
8 changed files with 39 additions and 28 deletions

View File

@@ -69,7 +69,7 @@ namespace BlackGui
CEnableForFramelessWindow *CEnableForDockWidgetInfoArea::mainApplicationWindow() const
{
CEnableForFramelessWindow *mw = CGuiUtility::mainApplicationWindow();
CEnableForFramelessWindow *mw = CGuiUtility::mainFramelessEnabledApplicationWindow();
return mw;
}

View File

@@ -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()

View File

@@ -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();
}

View File

@@ -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();

View File

@@ -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));
}
}

View File

@@ -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));
}

View File

@@ -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();
}

View File

@@ -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();