Commit 55cdf5db authored by lm's avatar lm

Improved and bugfixed window persistence

parent e53a9d6f
...@@ -71,6 +71,18 @@ void UASManager::run() ...@@ -71,6 +71,18 @@ void UASManager::run()
void UASManager::addUAS(UASInterface* uas) void UASManager::addUAS(UASInterface* uas)
{ {
// WARNING: The active uas is set here
// and then announced below. This is necessary
// to make sure the getActiveUAS() function
// returns the UAS once the UASCreated() signal
// is emitted. The code is thus NOT redundant.
bool firstUAS = false;
if (activeUAS == NULL)
{
firstUAS = true;
activeUAS = uas;
}
// Only execute if there is no UAS at this index // Only execute if there is no UAS at this index
if (!systems.contains(uas->getUASID())) if (!systems.contains(uas->getUASID()))
{ {
...@@ -79,7 +91,7 @@ void UASManager::addUAS(UASInterface* uas) ...@@ -79,7 +91,7 @@ void UASManager::addUAS(UASInterface* uas)
} }
// If there is no active UAS yet, set the first one as the active UAS // If there is no active UAS yet, set the first one as the active UAS
if (activeUAS == NULL) if (firstUAS)
{ {
setActiveUAS(uas); setActiveUAS(uas);
} }
......
...@@ -205,30 +205,30 @@ void DebugConsole::paintEvent(QPaintEvent *event) ...@@ -205,30 +205,30 @@ void DebugConsole::paintEvent(QPaintEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
// Update bandwidth // Update bandwidth
if (holdOn) // if (holdOn)
{ // {
//qDebug() << "Data rate:" << dataRate/1000.0f << "kB/s"; // //qDebug() << "Data rate:" << dataRate/1000.0f << "kB/s";
QString rate("data rate: %1"); // QString rate("data rate: %1");
rate.arg(dataRate); // rate.arg(dataRate);
QPainter painter(this); // QPainter painter(this);
painter.setRenderHint(QPainter::HighQualityAntialiasing); // painter.setRenderHint(QPainter::HighQualityAntialiasing);
painter.translate(width()/5.0f, height()/5.0f); // painter.translate(width()/5.0f, height()/5.0f);
//QFont font("Bitstream Vera Sans"); // //QFont font("Bitstream Vera Sans");
QFont font = painter.font(); // QFont font = painter.font();
font.setPixelSize((int)(60.0f)); // font.setPixelSize((int)(60.0f));
QFontMetrics metrics = QFontMetrics(font); // QFontMetrics metrics = QFontMetrics(font);
int border = qMax(4, metrics.leading()); // int border = qMax(4, metrics.leading());
QRect rect = metrics.boundingRect(0, 0, width() - 2*border, int(height()*0.125), // QRect rect = metrics.boundingRect(0, 0, width() - 2*border, int(height()*0.125),
Qt::AlignLeft | Qt::TextWordWrap, rate); // Qt::AlignLeft | Qt::TextWordWrap, rate);
painter.setPen(QColor(255, 50, 50)); // painter.setPen(QColor(255, 50, 50));
painter.setRenderHint(QPainter::TextAntialiasing); // painter.setRenderHint(QPainter::TextAntialiasing);
painter.drawText(QRect(QPoint(static_cast<int>(width()/5.0f), static_cast<int>(height()/5.0f)), QPoint(static_cast<int>(width() - width()/5.0f), static_cast<int>(height() - height()/5.0f))), rate); // painter.drawText(QRect(QPoint(static_cast<int>(width()/5.0f), static_cast<int>(height()/5.0f)), QPoint(static_cast<int>(width() - width()/5.0f), static_cast<int>(height() - height()/5.0f))), rate);
//Qt::AlignRight | Qt::TextWordWrap // //Qt::AlignRight | Qt::TextWordWrap
} // }
} }
void DebugConsole::receiveBytes(LinkInterface* link, QByteArray bytes) void DebugConsole::receiveBytes(LinkInterface* link, QByteArray bytes)
......
...@@ -134,7 +134,7 @@ HDDisplay::HDDisplay(QStringList* plotList, QWidget *parent) : ...@@ -134,7 +134,7 @@ HDDisplay::HDDisplay(QStringList* plotList, QWidget *parent) :
if(!QFile::exists(fontFileName)) qDebug() << "ERROR! font file: " << fontFileName << " DOES NOT EXIST!"; if(!QFile::exists(fontFileName)) qDebug() << "ERROR! font file: " << fontFileName << " DOES NOT EXIST!";
fontDatabase.addApplicationFont(fontFileName); fontDatabase.addApplicationFont(fontFileName);
font = fontDatabase.font(fontFamilyName, "Roman", (int)(10*scalingFactor*1.2f+0.5f)); font = fontDatabase.font(fontFamilyName, "Roman", qMax(5, (int)(10*scalingFactor*1.2f+0.5f)));
if (font.family() != fontFamilyName) qDebug() << "ERROR! Font not loaded: " << fontFamilyName; if (font.family() != fontFamilyName) qDebug() << "ERROR! Font not loaded: " << fontFamilyName;
// Connect with UAS // Connect with UAS
...@@ -151,7 +151,7 @@ HDDisplay::~HDDisplay() ...@@ -151,7 +151,7 @@ HDDisplay::~HDDisplay()
void HDDisplay::enableGLRendering(bool enable) void HDDisplay::enableGLRendering(bool enable)
{ {
Q_UNUSED(enable)
} }
void HDDisplay::triggerUpdate() void HDDisplay::triggerUpdate()
......
...@@ -150,8 +150,16 @@ HUD::HUD(int width, int height, QWidget* parent) ...@@ -150,8 +150,16 @@ HUD::HUD(int width, int height, QWidget* parent)
if(!QFile::exists(fontFileName)) qDebug() << "ERROR! font file: " << fontFileName << " DOES NOT EXIST!"; if(!QFile::exists(fontFileName)) qDebug() << "ERROR! font file: " << fontFileName << " DOES NOT EXIST!";
fontDatabase.addApplicationFont(fontFileName); fontDatabase.addApplicationFont(fontFileName);
font = fontDatabase.font(fontFamilyName, "Roman", (int)(10*scalingFactor*1.2f+0.5f)); font = fontDatabase.font(fontFamilyName, "Roman", qMax(5,(int)(10.0f*scalingFactor*1.2f+0.5f)));
if (font.family() != fontFamilyName) qDebug() << "ERROR! Font not loaded: " << fontFamilyName; QFont* fontPtr = &font;
if (!fontPtr)
{
qDebug() << "ERROR! FONT NOT LOADED!";
}
else
{
if (font.family() != fontFamilyName) qDebug() << "ERROR! WRONG FONT LOADED: " << fontFamilyName;
}
// Connect with UAS // Connect with UAS
UASManager* manager = UASManager::instance(); UASManager* manager = UASManager::instance();
......
This diff is collapsed.
...@@ -138,17 +138,14 @@ public slots: ...@@ -138,17 +138,14 @@ public slots:
/** @brief Reload the CSS style sheet */ /** @brief Reload the CSS style sheet */
void reloadStylesheet(); void reloadStylesheet();
void closeEvent(QCloseEvent* event);
/* /*
========================================================== ==========================================================
Potentially Deprecated Potentially Deprecated
========================================================== ==========================================================
*/ */
void loadPixhawkEngineerView();
/** @brief Load view with all widgets */
void loadAllView();
void loadWidgets(); void loadWidgets();
/** @brief Load data view, allowing to plot flight data */ /** @brief Load data view, allowing to plot flight data */
...@@ -228,13 +225,15 @@ protected: ...@@ -228,13 +225,15 @@ protected:
}TOOLS_WIDGET_NAMES; }TOOLS_WIDGET_NAMES;
typedef enum _SETTINGS_SECTIONS { typedef enum _SETTINGS_SECTIONS
{
SECTION_MENU, SECTION_MENU,
SUB_SECTION_CHECKED, SUB_SECTION_CHECKED,
SUB_SECTION_LOCATION, SUB_SECTION_LOCATION,
} SETTINGS_SECTIONS; } SETTINGS_SECTIONS;
typedef enum _VIEW_SECTIONS { typedef enum _VIEW_SECTIONS
{
VIEW_ENGINEER, VIEW_ENGINEER,
VIEW_OPERATOR, VIEW_OPERATOR,
VIEW_PILOT, VIEW_PILOT,
...@@ -301,6 +300,7 @@ protected: ...@@ -301,6 +300,7 @@ protected:
/** @brief Keeps track of the current view */ /** @brief Keeps track of the current view */
VIEW_SECTIONS currentView; VIEW_SECTIONS currentView;
bool aboutToCloseFlag;
QStatusBar* statusBar; QStatusBar* statusBar;
QStatusBar* createStatusBar(); QStatusBar* createStatusBar();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment