Browse Source

Improved and bugfixed window persistence

QGC4.4
lm 14 years ago
parent
commit
55cdf5dbdc
  1. 14
      src/uas/UASManager.cc
  2. 48
      src/ui/DebugConsole.cc
  3. 4
      src/ui/HDDisplay.cc
  4. 12
      src/ui/HUD.cc
  5. 1412
      src/ui/MainWindow.cc
  6. 14
      src/ui/MainWindow.h

14
src/uas/UASManager.cc

@ -71,6 +71,18 @@ void UASManager::run() @@ -71,6 +71,18 @@ void UASManager::run()
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
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 (activeUAS == NULL)
if (firstUAS)
{
setActiveUAS(uas);
}

48
src/ui/DebugConsole.cc

@ -205,30 +205,30 @@ void DebugConsole::paintEvent(QPaintEvent *event) @@ -205,30 +205,30 @@ void DebugConsole::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
// Update bandwidth
if (holdOn)
{
//qDebug() << "Data rate:" << dataRate/1000.0f << "kB/s";
QString rate("data rate: %1");
rate.arg(dataRate);
QPainter painter(this);
painter.setRenderHint(QPainter::HighQualityAntialiasing);
painter.translate(width()/5.0f, height()/5.0f);
//QFont font("Bitstream Vera Sans");
QFont font = painter.font();
font.setPixelSize((int)(60.0f));
QFontMetrics metrics = QFontMetrics(font);
int border = qMax(4, metrics.leading());
QRect rect = metrics.boundingRect(0, 0, width() - 2*border, int(height()*0.125),
Qt::AlignLeft | Qt::TextWordWrap, rate);
painter.setPen(QColor(255, 50, 50));
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);
//Qt::AlignRight | Qt::TextWordWrap
}
// if (holdOn)
// {
// //qDebug() << "Data rate:" << dataRate/1000.0f << "kB/s";
// QString rate("data rate: %1");
// rate.arg(dataRate);
// QPainter painter(this);
// painter.setRenderHint(QPainter::HighQualityAntialiasing);
// painter.translate(width()/5.0f, height()/5.0f);
// //QFont font("Bitstream Vera Sans");
// QFont font = painter.font();
// font.setPixelSize((int)(60.0f));
// QFontMetrics metrics = QFontMetrics(font);
// int border = qMax(4, metrics.leading());
// QRect rect = metrics.boundingRect(0, 0, width() - 2*border, int(height()*0.125),
// Qt::AlignLeft | Qt::TextWordWrap, rate);
// painter.setPen(QColor(255, 50, 50));
// 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);
// //Qt::AlignRight | Qt::TextWordWrap
// }
}
void DebugConsole::receiveBytes(LinkInterface* link, QByteArray bytes)

4
src/ui/HDDisplay.cc

@ -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!";
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;
// Connect with UAS
@ -151,7 +151,7 @@ HDDisplay::~HDDisplay() @@ -151,7 +151,7 @@ HDDisplay::~HDDisplay()
void HDDisplay::enableGLRendering(bool enable)
{
Q_UNUSED(enable)
}
void HDDisplay::triggerUpdate()

12
src/ui/HUD.cc

@ -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!";
fontDatabase.addApplicationFont(fontFileName);
font = fontDatabase.font(fontFamilyName, "Roman", (int)(10*scalingFactor*1.2f+0.5f));
if (font.family() != fontFamilyName) qDebug() << "ERROR! Font not loaded: " << fontFamilyName;
font = fontDatabase.font(fontFamilyName, "Roman", qMax(5,(int)(10.0f*scalingFactor*1.2f+0.5f)));
QFont* fontPtr = &font;
if (!fontPtr)
{
qDebug() << "ERROR! FONT NOT LOADED!";
}
else
{
if (font.family() != fontFamilyName) qDebug() << "ERROR! WRONG FONT LOADED: " << fontFamilyName;
}
// Connect with UAS
UASManager* manager = UASManager::instance();

1412
src/ui/MainWindow.cc

File diff suppressed because it is too large Load Diff

14
src/ui/MainWindow.h

@ -138,17 +138,14 @@ public slots: @@ -138,17 +138,14 @@ public slots:
/** @brief Reload the CSS style sheet */
void reloadStylesheet();
void closeEvent(QCloseEvent* event);
/*
==========================================================
Potentially Deprecated
==========================================================
*/
void loadPixhawkEngineerView();
/** @brief Load view with all widgets */
void loadAllView();
void loadWidgets();
/** @brief Load data view, allowing to plot flight data */
@ -228,13 +225,15 @@ protected: @@ -228,13 +225,15 @@ protected:
}TOOLS_WIDGET_NAMES;
typedef enum _SETTINGS_SECTIONS {
typedef enum _SETTINGS_SECTIONS
{
SECTION_MENU,
SUB_SECTION_CHECKED,
SUB_SECTION_LOCATION,
} SETTINGS_SECTIONS;
typedef enum _VIEW_SECTIONS {
typedef enum _VIEW_SECTIONS
{
VIEW_ENGINEER,
VIEW_OPERATOR,
VIEW_PILOT,
@ -301,6 +300,7 @@ protected: @@ -301,6 +300,7 @@ protected:
/** @brief Keeps track of the current view */
VIEW_SECTIONS currentView;
bool aboutToCloseFlag;
QStatusBar* statusBar;
QStatusBar* createStatusBar();

Loading…
Cancel
Save