From 31e3e7379911e4c50710aefeee63cd45f5848152 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sat, 2 Mar 2013 14:18:52 +0100 Subject: [PATCH 1/9] OP-857 OP-858 Added space between name and unit in Scope gadget legend --- ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp index 65fc167ac..e1775ace0 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp @@ -432,9 +432,9 @@ void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField QString curveNameScaled; if(scaleOrderFactor == 0) - curveNameScaled = curveName + "(" + units + ")"; + curveNameScaled = curveName + " (" + units + ")"; else - curveNameScaled = curveName + "(x10^" + QString::number(scaleOrderFactor) + " " + units + ")"; + curveNameScaled = curveName + " (x10^" + QString::number(scaleOrderFactor) + " " + units + ")"; QwtPlotCurve* plotCurve = new QwtPlotCurve(curveNameScaled); plotCurve->setPen(pen); From 96a1e1d8c9d75cebbf1c6b182abf1b6df6b800cc Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sat, 2 Mar 2013 18:20:34 +0100 Subject: [PATCH 2/9] OP-857 OP-859 fixed various glitches in Commmunity panel: Show three lines of news instead of one; Fixed improper eliding of news text; Moved News scroll bar to the right so it won't overlap the news text; Removed clipping in Sites panel that caused the Os to be clipped. --- ground/openpilotgcs/src/plugins/welcome/qml/NewsPanel.qml | 6 ++++-- ground/openpilotgcs/src/plugins/welcome/qml/SitesPanel.qml | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/welcome/qml/NewsPanel.qml b/ground/openpilotgcs/src/plugins/welcome/qml/NewsPanel.qml index 4d08f2d80..6d794b210 100644 --- a/ground/openpilotgcs/src/plugins/welcome/qml/NewsPanel.qml +++ b/ground/openpilotgcs/src/plugins/welcome/qml/NewsPanel.qml @@ -53,7 +53,7 @@ Item { spacing: 4 Text { text: title - width: view.width + width: view.width - 4 textFormat: text.indexOf("&") > 0 ? Text.StyledText : Text.PlainText elide: Text.ElideRight font.bold: true @@ -62,8 +62,10 @@ Item { Text { text: description - width: view.width + width: view.width - 4 textFormat: text.indexOf("&") > 0 ? Text.StyledText : Text.PlainText + maximumLineCount: 3 + wrapMode: Text.WordWrap elide: Text.ElideRight color: mouseArea.containsMouse ? "#224d81" : "black" } diff --git a/ground/openpilotgcs/src/plugins/welcome/qml/SitesPanel.qml b/ground/openpilotgcs/src/plugins/welcome/qml/SitesPanel.qml index be6ddd9a4..e4c11bd86 100644 --- a/ground/openpilotgcs/src/plugins/welcome/qml/SitesPanel.qml +++ b/ground/openpilotgcs/src/plugins/welcome/qml/SitesPanel.qml @@ -32,10 +32,9 @@ Item { ListView { id: view width: parent.width - anchors { top: header.bottom; topMargin: 14; bottom: parent.bottom } + anchors { top: header.bottom; topMargin: 14; leftMargin: 32; bottom: parent.bottom } model: sitesModel spacing: 8 - clip: true delegate: Text { text: title From 9b495b4d5ee9ff74d8fea32aaa8b13e7224406b2 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Tue, 12 Mar 2013 22:04:03 +0100 Subject: [PATCH 3/9] OP-857 OP-869 fixed style sheet issues: - removed wide style sheets - added style sheet common to all platforms - fixed broken styles for QTabWidget and QGroupBox on Windows - fixed broken style for QTabWidget on Linux --- .../OpenPilotGCS_wide.xml | 2 +- .../openpilotgcs/stylesheets/default.qss | 84 ++++++++++++ .../stylesheets/default_linux.qss | 118 +++-------------- .../stylesheets/default_macos.qss | 120 +++--------------- .../stylesheets/default_windows.qss | 118 +++-------------- .../openpilotgcs/stylesheets/wide_linux.qss | 105 --------------- .../openpilotgcs/stylesheets/wide_macos.qss | 104 --------------- .../openpilotgcs/stylesheets/wide_windows.qss | 104 --------------- .../src/plugins/coreplugin/mainwindow.cpp | 85 ++++++++----- .../src/plugins/coreplugin/mainwindow.h | 2 +- 10 files changed, 189 insertions(+), 653 deletions(-) create mode 100644 ground/openpilotgcs/share/openpilotgcs/stylesheets/default.qss delete mode 100644 ground/openpilotgcs/share/openpilotgcs/stylesheets/wide_linux.qss delete mode 100644 ground/openpilotgcs/share/openpilotgcs/stylesheets/wide_macos.qss delete mode 100644 ground/openpilotgcs/share/openpilotgcs/stylesheets/wide_windows.qss diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml index e5ebe0b44..e8234e1e8 100644 --- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml +++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml @@ -11,7 +11,7 @@ false Wide configuration
Default configuration built for wide screens (17"up)
- wide + default 0 diff --git a/ground/openpilotgcs/share/openpilotgcs/stylesheets/default.qss b/ground/openpilotgcs/share/openpilotgcs/stylesheets/default.qss new file mode 100644 index 000000000..0f100f1cc --- /dev/null +++ b/ground/openpilotgcs/share/openpilotgcs/stylesheets/default.qss @@ -0,0 +1,84 @@ +/* Default styles */ + +MyListWidget { + font-size: 11px; +} + +Utils--StyledBar { + background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(200, 200, 200, 255)); +} + +QSlider::groove:horizontal { + border: 1px solid rgb(196, 196, 196); + background: white; + height: 6px; + border-radius: 2px; + margin 10px 10px; +} + +QSlider::add-page:horizontal { + background: #fff; + border: 1px solid #777; + height: 1px; + border-radius: 4px; +} + +QSlider::sub-page:horizontal { + background: rgb(249, 117, 76); + border: 1px solid #777; + height: 1px; + border-radius: 4px; +} + +QSlider::handle:horizontal { + background: rgb(196, 196, 196); + width: 18px; + height: 28px; + margin: -2px 0; + border-radius: 3px; + border: 1px solid #777; +} + +QSlider::groove:vertical { + border: 1px solid rgb(196, 196, 196); + background: white; + width: 6px; + border-radius: 2px; + margin 0px -10px; + margin-top: 5px; + margin-bottom: 5px; +} + +QSlider::sub-page:vertical { + background: #fff; + border: 1px solid #777; + width: 1px; + border-radius: 4px; +} + +QSlider::add-page:vertical { + background: rgb(249, 117, 76); + border: 1px solid #777; + width: 1px; + border-radius: 4px; +} + +QSlider::handle:vertical { + background: rgb(196, 196, 196); + width: 18px; + margin: -6 -6; + border-radius: 3px; + border: 1px solid #777; +} + +QSlider::handle:vertical:hover { + background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); + border: 1px solid #444; + border-radius: 4px; +} + +QSlider::handle:horizontal:hover { + background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); + border: 1px solid #444; + border-radius: 4px; +} diff --git a/ground/openpilotgcs/share/openpilotgcs/stylesheets/default_linux.qss b/ground/openpilotgcs/share/openpilotgcs/stylesheets/default_linux.qss index 97844c95a..64ac641ab 100644 --- a/ground/openpilotgcs/share/openpilotgcs/stylesheets/default_linux.qss +++ b/ground/openpilotgcs/share/openpilotgcs/stylesheets/default_linux.qss @@ -1,105 +1,19 @@ -MyListWidget {font-size: 11px;} -MixerCurveWidget {font-size: 12px;} -Utils--StyledBar { background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(200, 200, 200, 255));} - +/* Linux styles */ +QGroupBox { + border: 1px solid gray; + border-radius: 5px; + margin-top: 1ex; + font-size: 11px; + font-weight: bold; +} +QGroupBox::title { + subcontrol-origin: margin; + subcontrol-position: top left; + padding: 0 3px; +} - - - QGroupBox { - border: 1px solid gray; - border-radius: 5px; - margin-top: 1ex; /* leave space at the top for the title */ - font-size: 11px; - font-weight: bold; - } - - QGroupBox::title { - subcontrol-origin: margin; - subcontrol-position: top left; /* position at the top center */ - padding: 0 3px; - - } - - QTabWidget::pane { /* The tab widget frame */ - margin: 1px,1px,1px,1px; - border: 2px solid rgb(196,196,196); - border-radius: 5px; - padding: 0px; - } - - QSlider::groove:horizontal { - border: 1px solid rgb(196,196,196); - background: white; - height: 6px; - border-radius: 2px; - margin 10px 10px; - } - QSlider::add-page:horizontal { - background: #fff; - border: 1px solid #777; - height: 1px; - border-radius: 4px; - } - - QSlider::sub-page:horizontal { - background: rgb(249,117,76); - border: 1px solid #777; - height: 1px; - border-radius: 4px; - } - - - QSlider::handle:horizontal { - background: rgb(196,196,196); - width: 18px; - height: 28px; - margin: -2px 0; - border-radius: 3px; - border: 1px solid #777; - } - - QSlider::groove:vertical { - border: 1px solid rgb(196,196,196); - background: white; - width: 6px; - border-radius: 2px; - margin 0px -10px; - margin-top: 5px; - margin-bottom: 5px; - } - QSlider::sub-page:vertical { - background: #fff; - border: 1px solid #777; - width: 1px; - border-radius: 4px; - } - - QSlider::add-page:vertical { - background: rgb(249,117,76); - border: 1px solid #777; - width: 1px; - border-radius: 4px; - } - - - QSlider::handle:vertical { - background: rgb(196,196,196); - width: 18px; - margin: -6 -6; - border-radius: 3px; - border: 1px solid #777; - } - - QSlider::handle:vertical:hover { - background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); - border: 1px solid #444; - border-radius: 4px; - } - - QSlider::handle:horizontal:hover { - background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); - border: 1px solid #444; - border-radius: 4px; - } +MixerCurveWidget { + font-size: 12px; +} diff --git a/ground/openpilotgcs/share/openpilotgcs/stylesheets/default_macos.qss b/ground/openpilotgcs/share/openpilotgcs/stylesheets/default_macos.qss index 430d04d67..55fa1b6c1 100644 --- a/ground/openpilotgcs/share/openpilotgcs/stylesheets/default_macos.qss +++ b/ground/openpilotgcs/share/openpilotgcs/stylesheets/default_macos.qss @@ -1,104 +1,22 @@ -MyListWidget {font-size: 11px;} -Utils--StyledBar { background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(200, 200, 200, 255));} - +/* MacOS styles */ +QGroupBox { + border: 1px solid gray; + border-radius: 5px; + margin-top: 1ex; + font-size: 11px; + font-weight: bold; +} +QGroupBox::title { + subcontrol-origin: margin; + subcontrol-position: top left; + padding: 0 3px; +} - - - QGroupBox { - border: 1px solid gray; - border-radius: 5px; - margin-top: 1ex; /* leave space at the top for the title */ - font-size: 11px; - font-weight: bold; - } - - QGroupBox::title { - subcontrol-origin: margin; - subcontrol-position: top left; /* position at the top center */ - padding: 0 3px; - - } - - QTabWidget::pane { /* The tab widget frame */ - margin: 1px,1px,1px,1px; - border: 2px solid rgb(196,196,196); - border-radius: 5px; - padding: 0px; - } - - QSlider::groove:horizontal { - border: 1px solid rgb(196,196,196); - background: white; - height: 6px; - border-radius: 2px; - margin 10px 10px; - } - QSlider::add-page:horizontal { - background: #fff; - border: 1px solid #777; - height: 1px; - border-radius: 4px; - } - - QSlider::sub-page:horizontal { - background: rgb(249,117,76); - border: 1px solid #777; - height: 1px; - border-radius: 4px; - } - - - QSlider::handle:horizontal { - background: rgb(196,196,196); - width: 18px; - height: 28px; - margin: -2px 0; - border-radius: 3px; - border: 1px solid #777; - } - - QSlider::groove:vertical { - border: 1px solid rgb(196,196,196); - background: white; - width: 6px; - border-radius: 2px; - margin 0px -10px; - margin-top: 5px; - margin-bottom: 5px; - } - QSlider::sub-page:vertical { - background: #fff; - border: 1px solid #777; - width: 1px; - border-radius: 4px; - } - - QSlider::add-page:vertical { - background: rgb(249,117,76); - border: 1px solid #777; - width: 1px; - border-radius: 4px; - } - - - QSlider::handle:vertical { - background: rgb(196,196,196); - width: 18px; - margin: -6 -6; - border-radius: 3px; - border: 1px solid #777; - } - - QSlider::handle:vertical:hover { - background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); - border: 1px solid #444; - border-radius: 4px; - } - - QSlider::handle:horizontal:hover { - background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); - border: 1px solid #444; - border-radius: 4px; - } +QTabWidget::pane { + margin: 1px, 1px, 1px, 1px; + border: 2px solid rgb(196, 196, 196); + border-radius: 5px; + padding: 0px; +} diff --git a/ground/openpilotgcs/share/openpilotgcs/stylesheets/default_windows.qss b/ground/openpilotgcs/share/openpilotgcs/stylesheets/default_windows.qss index 430d04d67..e378375c0 100644 --- a/ground/openpilotgcs/share/openpilotgcs/stylesheets/default_windows.qss +++ b/ground/openpilotgcs/share/openpilotgcs/stylesheets/default_windows.qss @@ -1,104 +1,18 @@ -MyListWidget {font-size: 11px;} -Utils--StyledBar { background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(200, 200, 200, 255));} - +/* Windows styles */ +QGroupBox { + border: 1px solid gray; + border-radius: 3px; + margin-top: 1ex; + padding: 1ex 0px 0px 0px; + font-size: 11px; + font-weight: bold; +} - - - - QGroupBox { - border: 1px solid gray; - border-radius: 5px; - margin-top: 1ex; /* leave space at the top for the title */ - font-size: 11px; - font-weight: bold; - } - - QGroupBox::title { - subcontrol-origin: margin; - subcontrol-position: top left; /* position at the top center */ - padding: 0 3px; - - } - - QTabWidget::pane { /* The tab widget frame */ - margin: 1px,1px,1px,1px; - border: 2px solid rgb(196,196,196); - border-radius: 5px; - padding: 0px; - } - - QSlider::groove:horizontal { - border: 1px solid rgb(196,196,196); - background: white; - height: 6px; - border-radius: 2px; - margin 10px 10px; - } - QSlider::add-page:horizontal { - background: #fff; - border: 1px solid #777; - height: 1px; - border-radius: 4px; - } - - QSlider::sub-page:horizontal { - background: rgb(249,117,76); - border: 1px solid #777; - height: 1px; - border-radius: 4px; - } - - - QSlider::handle:horizontal { - background: rgb(196,196,196); - width: 18px; - height: 28px; - margin: -2px 0; - border-radius: 3px; - border: 1px solid #777; - } - - QSlider::groove:vertical { - border: 1px solid rgb(196,196,196); - background: white; - width: 6px; - border-radius: 2px; - margin 0px -10px; - margin-top: 5px; - margin-bottom: 5px; - } - QSlider::sub-page:vertical { - background: #fff; - border: 1px solid #777; - width: 1px; - border-radius: 4px; - } - - QSlider::add-page:vertical { - background: rgb(249,117,76); - border: 1px solid #777; - width: 1px; - border-radius: 4px; - } - - - QSlider::handle:vertical { - background: rgb(196,196,196); - width: 18px; - margin: -6 -6; - border-radius: 3px; - border: 1px solid #777; - } - - QSlider::handle:vertical:hover { - background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); - border: 1px solid #444; - border-radius: 4px; - } - - QSlider::handle:horizontal:hover { - background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); - border: 1px solid #444; - border-radius: 4px; - } +QGroupBox::title { + subcontrol-origin: margin; + subcontrol-position: top left; + left: 7px; + top: -1ex; + padding: 0px 3px; +} diff --git a/ground/openpilotgcs/share/openpilotgcs/stylesheets/wide_linux.qss b/ground/openpilotgcs/share/openpilotgcs/stylesheets/wide_linux.qss deleted file mode 100644 index 97844c95a..000000000 --- a/ground/openpilotgcs/share/openpilotgcs/stylesheets/wide_linux.qss +++ /dev/null @@ -1,105 +0,0 @@ -MyListWidget {font-size: 11px;} -MixerCurveWidget {font-size: 12px;} -Utils--StyledBar { background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(200, 200, 200, 255));} - - - - - - - QGroupBox { - border: 1px solid gray; - border-radius: 5px; - margin-top: 1ex; /* leave space at the top for the title */ - font-size: 11px; - font-weight: bold; - } - - QGroupBox::title { - subcontrol-origin: margin; - subcontrol-position: top left; /* position at the top center */ - padding: 0 3px; - - } - - QTabWidget::pane { /* The tab widget frame */ - margin: 1px,1px,1px,1px; - border: 2px solid rgb(196,196,196); - border-radius: 5px; - padding: 0px; - } - - QSlider::groove:horizontal { - border: 1px solid rgb(196,196,196); - background: white; - height: 6px; - border-radius: 2px; - margin 10px 10px; - } - QSlider::add-page:horizontal { - background: #fff; - border: 1px solid #777; - height: 1px; - border-radius: 4px; - } - - QSlider::sub-page:horizontal { - background: rgb(249,117,76); - border: 1px solid #777; - height: 1px; - border-radius: 4px; - } - - - QSlider::handle:horizontal { - background: rgb(196,196,196); - width: 18px; - height: 28px; - margin: -2px 0; - border-radius: 3px; - border: 1px solid #777; - } - - QSlider::groove:vertical { - border: 1px solid rgb(196,196,196); - background: white; - width: 6px; - border-radius: 2px; - margin 0px -10px; - margin-top: 5px; - margin-bottom: 5px; - } - QSlider::sub-page:vertical { - background: #fff; - border: 1px solid #777; - width: 1px; - border-radius: 4px; - } - - QSlider::add-page:vertical { - background: rgb(249,117,76); - border: 1px solid #777; - width: 1px; - border-radius: 4px; - } - - - QSlider::handle:vertical { - background: rgb(196,196,196); - width: 18px; - margin: -6 -6; - border-radius: 3px; - border: 1px solid #777; - } - - QSlider::handle:vertical:hover { - background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); - border: 1px solid #444; - border-radius: 4px; - } - - QSlider::handle:horizontal:hover { - background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); - border: 1px solid #444; - border-radius: 4px; - } diff --git a/ground/openpilotgcs/share/openpilotgcs/stylesheets/wide_macos.qss b/ground/openpilotgcs/share/openpilotgcs/stylesheets/wide_macos.qss deleted file mode 100644 index 430d04d67..000000000 --- a/ground/openpilotgcs/share/openpilotgcs/stylesheets/wide_macos.qss +++ /dev/null @@ -1,104 +0,0 @@ -MyListWidget {font-size: 11px;} -Utils--StyledBar { background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(200, 200, 200, 255));} - - - - - - - QGroupBox { - border: 1px solid gray; - border-radius: 5px; - margin-top: 1ex; /* leave space at the top for the title */ - font-size: 11px; - font-weight: bold; - } - - QGroupBox::title { - subcontrol-origin: margin; - subcontrol-position: top left; /* position at the top center */ - padding: 0 3px; - - } - - QTabWidget::pane { /* The tab widget frame */ - margin: 1px,1px,1px,1px; - border: 2px solid rgb(196,196,196); - border-radius: 5px; - padding: 0px; - } - - QSlider::groove:horizontal { - border: 1px solid rgb(196,196,196); - background: white; - height: 6px; - border-radius: 2px; - margin 10px 10px; - } - QSlider::add-page:horizontal { - background: #fff; - border: 1px solid #777; - height: 1px; - border-radius: 4px; - } - - QSlider::sub-page:horizontal { - background: rgb(249,117,76); - border: 1px solid #777; - height: 1px; - border-radius: 4px; - } - - - QSlider::handle:horizontal { - background: rgb(196,196,196); - width: 18px; - height: 28px; - margin: -2px 0; - border-radius: 3px; - border: 1px solid #777; - } - - QSlider::groove:vertical { - border: 1px solid rgb(196,196,196); - background: white; - width: 6px; - border-radius: 2px; - margin 0px -10px; - margin-top: 5px; - margin-bottom: 5px; - } - QSlider::sub-page:vertical { - background: #fff; - border: 1px solid #777; - width: 1px; - border-radius: 4px; - } - - QSlider::add-page:vertical { - background: rgb(249,117,76); - border: 1px solid #777; - width: 1px; - border-radius: 4px; - } - - - QSlider::handle:vertical { - background: rgb(196,196,196); - width: 18px; - margin: -6 -6; - border-radius: 3px; - border: 1px solid #777; - } - - QSlider::handle:vertical:hover { - background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); - border: 1px solid #444; - border-radius: 4px; - } - - QSlider::handle:horizontal:hover { - background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); - border: 1px solid #444; - border-radius: 4px; - } diff --git a/ground/openpilotgcs/share/openpilotgcs/stylesheets/wide_windows.qss b/ground/openpilotgcs/share/openpilotgcs/stylesheets/wide_windows.qss deleted file mode 100644 index 430d04d67..000000000 --- a/ground/openpilotgcs/share/openpilotgcs/stylesheets/wide_windows.qss +++ /dev/null @@ -1,104 +0,0 @@ -MyListWidget {font-size: 11px;} -Utils--StyledBar { background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(200, 200, 200, 255));} - - - - - - - QGroupBox { - border: 1px solid gray; - border-radius: 5px; - margin-top: 1ex; /* leave space at the top for the title */ - font-size: 11px; - font-weight: bold; - } - - QGroupBox::title { - subcontrol-origin: margin; - subcontrol-position: top left; /* position at the top center */ - padding: 0 3px; - - } - - QTabWidget::pane { /* The tab widget frame */ - margin: 1px,1px,1px,1px; - border: 2px solid rgb(196,196,196); - border-radius: 5px; - padding: 0px; - } - - QSlider::groove:horizontal { - border: 1px solid rgb(196,196,196); - background: white; - height: 6px; - border-radius: 2px; - margin 10px 10px; - } - QSlider::add-page:horizontal { - background: #fff; - border: 1px solid #777; - height: 1px; - border-radius: 4px; - } - - QSlider::sub-page:horizontal { - background: rgb(249,117,76); - border: 1px solid #777; - height: 1px; - border-radius: 4px; - } - - - QSlider::handle:horizontal { - background: rgb(196,196,196); - width: 18px; - height: 28px; - margin: -2px 0; - border-radius: 3px; - border: 1px solid #777; - } - - QSlider::groove:vertical { - border: 1px solid rgb(196,196,196); - background: white; - width: 6px; - border-radius: 2px; - margin 0px -10px; - margin-top: 5px; - margin-bottom: 5px; - } - QSlider::sub-page:vertical { - background: #fff; - border: 1px solid #777; - width: 1px; - border-radius: 4px; - } - - QSlider::add-page:vertical { - background: rgb(249,117,76); - border: 1px solid #777; - width: 1px; - border-radius: 4px; - } - - - QSlider::handle:vertical { - background: rgb(196,196,196); - width: 18px; - margin: -6 -6; - border-radius: 3px; - border: 1px solid #777; - } - - QSlider::handle:vertical:hover { - background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); - border: 1px solid #444; - border-radius: 4px; - } - - QSlider::handle:horizontal:hover { - background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); - border: 1px solid #444; - border-radius: 4px; - } diff --git a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp index 000156d70..3cbcb9ac7 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp @@ -310,11 +310,37 @@ void MainWindow::extensionsInitialized() qs = settings; qDebug() << "Load default config from resource " << filename; } + qs->beginGroup("General"); - m_config_description=qs->value("Description", "none").toString(); - m_config_details=qs->value("Details", "none").toString(); - m_config_stylesheet=qs->value("StyleSheet", "none").toString(); - loadStyleSheet(m_config_stylesheet); + m_config_description = qs->value("Description", "none").toString(); + m_config_details = qs->value("Details", "none").toString(); + m_config_stylesheet = qs->value("StyleSheet", "none").toString(); + + qDebug() << "Configured style sheet:" << m_config_stylesheet; + if (m_config_stylesheet == "wide") { + // OP-869 just in case some user configuration still references the now obsolete "wide" style sheet + m_config_stylesheet = "default"; + } + + // Load common style sheet + QString style = loadStyleSheet(m_config_stylesheet + ".qss"); + + // Load and concatenate platform specific style sheet + QString fileName = m_config_stylesheet; +#ifdef Q_OS_MAC + fileName += "_macos.qss"; +#elif defined(Q_OS_LINUX) + fileName += "_linux.qss"; +#else + fileName += "_windows.qss"; +#endif + style += loadStyleSheet(fileName); + + // We'll use qApp macro to get the QApplication pointer + // and set the style sheet application wide. + qDebug() << "Setting application style sheet to:" << style; + qApp->setStyleSheet(style); + qs->endGroup(); m_uavGadgetInstanceManager = new UAVGadgetInstanceManager(this); m_uavGadgetInstanceManager->readSettings(qs); @@ -329,40 +355,33 @@ void MainWindow::extensionsInitialized() emit m_coreImpl->coreOpened(); } -void MainWindow::loadStyleSheet(QString name) { - /* Let's use QFile and point to a resource... */ - QDir directory(QCoreApplication::applicationDirPath()); +QString MainWindow::loadStyleSheet(QString fileName) { + // Let's use QFile and point to a resource... + QDir dir(QCoreApplication::applicationDirPath()); #ifdef Q_OS_MAC - directory.cdUp(); - directory.cd("Resources"); + dir.cdUp(); + dir.cd("Resources"); #else - directory.cdUp(); - directory.cd("share"); - directory.cd("openpilotgcs"); -#endif - directory.cd("stylesheets"); -#ifdef Q_OS_MAC - QFile data(directory.absolutePath()+QDir::separator()+name+"_macos.qss"); -#elif defined(Q_OS_LINUX) - QFile data(directory.absolutePath()+QDir::separator()+name+"_linux.qss"); -#else - QFile data(directory.absolutePath()+QDir::separator()+name+"_windows.qss"); + dir.cdUp(); + dir.cd("share"); + dir.cd("openpilotgcs"); #endif + dir.cd("stylesheets"); QString style; - /* ...to open the file */ - if(data.open(QFile::ReadOnly)) { - /* QTextStream... */ - QTextStream styleIn(&data); - /* ...read file to a string. */ - style = styleIn.readAll(); - data.close(); - /* We'll use qApp macro to get the QApplication pointer - * and set the style sheet application wide. */ - qApp->setStyleSheet(style); - qDebug()<<"Loaded stylesheet:"< Date: Tue, 12 Mar 2013 22:36:35 +0100 Subject: [PATCH 4/9] OP-857 OP-860 minor improvments to the connection widget - made it wider so it can at least display the string "USB: CopterControl" - added a tooltip to the connection combo box that will display the currently selected connection - other minor code cleanups --- .../plugins/coreplugin/connectionmanager.cpp | 93 +++++++++++-------- .../plugins/coreplugin/connectionmanager.h | 1 + 2 files changed, 56 insertions(+), 38 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp index 8d1e7ff1c..2580c2dab 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp @@ -41,7 +41,6 @@ namespace Core { - ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, QTabWidget *modeStack) : QWidget(mainWindow), m_availableDevList(0), @@ -50,36 +49,41 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, QTabWidge polling(true), m_mainWindow(mainWindow) { - QHBoxLayout *layout = new QHBoxLayout; - layout->setSpacing(5); - layout->setContentsMargins(5,2,5,2); - + // monitor widget m_monitorWidget = new TelemetryMonitorWidget(this); - layout->addWidget(m_monitorWidget, Qt::AlignHCenter); - - layout->addWidget(new QLabel(tr("Connections:"))); + // device list m_availableDevList = new QComboBox; - m_availableDevList->setMinimumWidth(100); - m_availableDevList->setMaximumWidth(150); + m_availableDevList->setMinimumWidth(120); + m_availableDevList->setMaximumWidth(180); m_availableDevList->setContextMenuPolicy(Qt::CustomContextMenu); - layout->addWidget(m_availableDevList); + // connect button m_connectBtn = new QPushButton(tr("Connect")); m_connectBtn->setEnabled(false); - layout->addWidget(m_connectBtn); + + // put everything together + QHBoxLayout *layout = new QHBoxLayout; + layout->setSpacing(5); + layout->setContentsMargins(5, 2, 5, 2); + + layout->addWidget(m_monitorWidget, 0, Qt::AlignVCenter); + layout->addWidget(new QLabel(tr("Connections:")), 0, Qt::AlignVCenter); + layout->addWidget(m_availableDevList, 0, Qt::AlignVCenter); + layout->addWidget(m_connectBtn, 0, Qt::AlignVCenter); setLayout(layout); modeStack->setCornerWidget(this, Qt::TopRightCorner); QObject::connect(m_connectBtn, SIGNAL(clicked()), this, SLOT(onConnectClicked())); + QObject::connect(m_availableDevList, SIGNAL(currentIndexChanged(int)), this, SLOT(onDeviceSelectionChanged(int))); // setup our reconnect timers reconnect = new QTimer(this); reconnectCheck = new QTimer(this); - connect(reconnect,SIGNAL(timeout()),this,SLOT(reconnectSlot())); - connect(reconnectCheck,SIGNAL(timeout()),this,SLOT(reconnectCheckSlot())); + connect(reconnect, SIGNAL(timeout()), this, SLOT(reconnectSlot())); + connect(reconnectCheck, SIGNAL(timeout()), this, SLOT(reconnectCheckSlot())); } ConnectionManager::~ConnectionManager() @@ -103,7 +107,8 @@ void ConnectionManager::init() */ bool ConnectionManager::connectDevice(DevListItem device) { - DevListItem connection_device = findDevice(m_availableDevList->itemData(m_availableDevList->currentIndex(),Qt::ToolTipRole).toString()); + QString deviceName = m_availableDevList->itemData(m_availableDevList->currentIndex(), Qt::ToolTipRole).toString(); + DevListItem connection_device = findDevice(deviceName); if (!connection_device.connection) return false; @@ -224,21 +229,33 @@ void ConnectionManager::onConnectionDestroyed(QObject *obj) disconnectDevice(); } +/** +* Slot called when the user selects a device from the combo box +*/ +void ConnectionManager::onDeviceSelectionChanged(int index) +{ + if (index >= 0) { + QString deviceName = m_availableDevList->itemData(index, Qt::ToolTipRole).toString(); + m_availableDevList->setToolTip(deviceName); + } +} + /** * Slot called when the user clicks the connect/disconnect button */ void ConnectionManager::onConnectClicked() { // Check if we have a ioDev already created: - if (!m_ioDev) - { + if (!m_ioDev) { // connecting to currently selected device - DevListItem device = findDevice(m_availableDevList->itemData(m_availableDevList->currentIndex(), Qt::ToolTipRole).toString()); - if (device.connection) + QString deviceName = m_availableDevList->itemData(m_availableDevList->currentIndex(), Qt::ToolTipRole).toString(); + DevListItem device = findDevice(deviceName); + if (device.connection) { connectDevice(device); + } } - else - { // disconnecting + else { + // disconnecting disconnectDevice(); } } @@ -444,32 +461,32 @@ void ConnectionManager::devChanged(IConnection *connection) void ConnectionManager::updateConnectionDropdown() { - //add all the list again to the combobox - foreach (DevListItem d, m_devList) - { + // add all the list again to the combobox + foreach (DevListItem d, m_devList) { m_availableDevList->addItem(d.getConName()); - m_availableDevList->setItemData(m_availableDevList->count()-1, d.getConName(), Qt::ToolTipRole); - if(!m_ioDev && d.getConName().startsWith("USB")) - { - if(m_mainWindow->generalSettings()->autoConnect() || m_mainWindow->generalSettings()->autoSelect()) + m_availableDevList->setItemData(m_availableDevList->count() - 1, d.getConName(), Qt::ToolTipRole); + if (!m_ioDev && d.getConName().startsWith("USB")) { + if (m_mainWindow->generalSettings()->autoConnect() || m_mainWindow->generalSettings()->autoSelect()) { m_availableDevList->setCurrentIndex(m_availableDevList->count() - 1); - - if(m_mainWindow->generalSettings()->autoConnect() && polling) - { + } + if (m_mainWindow->generalSettings()->autoConnect() && polling) { qDebug() << "Automatically opening device"; connectDevice(d); - qDebug()<<"ConnectionManager::devChanged autoconnected USB device"; + qDebug() << "ConnectionManager::updateConnectionDropdown autoconnected USB device"; } } } - if(m_ioDev)//if a device is connected make it the one selected on the dropbox - { - for(int x=0;xcount();++x) - { - if(m_connectionDevice.getConName()==m_availableDevList->itemData(x,Qt::ToolTipRole).toString()) - m_availableDevList->setCurrentIndex(x); + if (m_ioDev) { + // if a device is connected make it the one selected on the dropbox + for (int i = 0; i < m_availableDevList->count(); i++) { + QString deviceName = m_availableDevList->itemData(i, Qt::ToolTipRole).toString(); + if (m_connectionDevice.getConName() == deviceName) { + m_availableDevList->setCurrentIndex(i); + } } } + // update combo box tooltip + onDeviceSelectionChanged(m_availableDevList->currentIndex()); } void Core::ConnectionManager::connectionsCallBack() diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h index 2f131d4a3..8a8f49eff 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h @@ -125,6 +125,7 @@ private slots: void aboutToRemoveObject(QObject *obj); void onConnectClicked(); + void onDeviceSelectionChanged(int index); void devChanged(IConnection *connection); void onConnectionDestroyed(QObject *obj); From 23077d33262d20b42c27f3f6c1b7886fe8d13811 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Tue, 19 Mar 2013 22:08:40 +0100 Subject: [PATCH 5/9] OP-857 OP-876 fixed issue that prevented default size of Options dialog to be taken into account on 1st launch of GCS (with no user settings) --- .../src/plugins/coreplugin/mainwindow.cpp | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp index 5da11fe7a..299d75bbb 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp @@ -269,9 +269,10 @@ void MainWindow::extensionsInitialized() { QSettings *qs = m_settings; QString commandLine; - if ( ! qs->allKeys().count() ) { + if (!qs->allKeys().count()) { + // no user settings, so try to load some default ones foreach(QString str, qApp->arguments()) { - if(str.contains("configfile")) { + if (str.contains("configfile")) { qDebug() << "ass"; commandLine = str.split("=").at(1); qDebug() << commandLine; @@ -279,28 +280,30 @@ void MainWindow::extensionsInitialized() } QDir directory(QCoreApplication::applicationDirPath()); #ifdef Q_OS_MAC - directory.cdUp(); - directory.cd("Resources"); + directory.cdUp(); + directory.cd("Resources"); #else - directory.cdUp(); - directory.cd("share"); - directory.cd("openpilotgcs"); + directory.cdUp(); + directory.cd("share"); + directory.cd("openpilotgcs"); #endif directory.cd("default_configurations"); qDebug() << "Looking for configuration files in:" << directory.absolutePath(); QString filename; - if(!commandLine.isEmpty() && QFile::exists(directory.absolutePath() + QDir::separator() + commandLine)) { + if (!commandLine.isEmpty() && QFile::exists(directory.absolutePath() + QDir::separator() + commandLine)) { + // use file name specified on command line filename = directory.absolutePath() + QDir::separator() + commandLine; qDebug() << "Configuration file" << filename << "specified on command line will be loaded."; - } - else if(QFile::exists(directory.absolutePath() + QDir::separator() + DEFAULT_CONFIG_FILENAME)) { + } else if (QFile::exists(directory.absolutePath() + QDir::separator() + DEFAULT_CONFIG_FILENAME)) { + // use default file name filename = directory.absolutePath() + QDir::separator() + DEFAULT_CONFIG_FILENAME; qDebug() << "Default configuration file" << filename << "will be loaded."; - } - else { - qDebug() << "Default configuration file " << directory.absolutePath() << QDir::separator() << DEFAULT_CONFIG_FILENAME << "was not found."; + } else { + // prompt user for default file name + qDebug() << "Default configuration file" << directory.absolutePath() << QDir::separator() + << DEFAULT_CONFIG_FILENAME << "was not found."; importSettings *dialog = new importSettings(this); dialog->loadFiles(directory.absolutePath()); dialog->exec(); @@ -309,7 +312,13 @@ void MainWindow::extensionsInitialized() qDebug() << "Configuration file" << filename << "was selected and will be loaded."; } + // create settings from file qs = new QSettings(filename, XmlConfig::XmlSettingsFormat); + + // replace empty settings with new ones + delete m_settings; + m_settings = qs; + qDebug() << "Configuration file" << filename << "was loaded."; } @@ -900,13 +909,12 @@ void MainWindow::setFocusToEditor() } -bool MainWindow::showOptionsDialog(const QString &category, - const QString &page, - QWidget *parent) +bool MainWindow::showOptionsDialog(const QString &category, const QString &page, QWidget *parent) { emit m_coreImpl->optionsDialogRequested(); - if (!parent) + if (!parent) { parent = this; + } SettingsDialog dlg(parent, category, page); return dlg.execDialog(); } From e39f70536b52e8fe458f47d633c350d8f4a53222 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Tue, 19 Mar 2013 22:10:47 +0100 Subject: [PATCH 6/9] OP-857 OP-876 fixed issue that prevented default size of Options dialog to be taken into account on 1st launch of GCS (with no user settings) --- .../coreplugin/dialogs/settingsdialog.cpp | 35 +++++++++++-------- .../coreplugin/dialogs/settingsdialog.h | 13 ++----- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/ground/openpilotgcs/src/plugins/coreplugin/dialogs/settingsdialog.cpp index d14f35e02..bdcbac380 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/dialogs/settingsdialog.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/dialogs/settingsdialog.cpp @@ -77,12 +77,8 @@ static inline QList sortedOptionsPages() return rc; } -SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId, - const QString &pageId) - : QDialog(parent), - m_applied(false), - m_windowWidth(0), - m_windowHeight(0) +SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId, const QString &pageId) + : QDialog(parent), m_applied(false) { setupUi(this); #ifdef Q_OS_MAC @@ -90,19 +86,28 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId, #else setWindowTitle(tr("Options")); #endif + + QSettings *settings = ICore::instance()->settings(); + settings->beginGroup("General"); + + // restore last displayed category and page + // this is done only if no category or page was provided through the constructor QString initialCategory = categoryId; QString initialPage = pageId; - qDebug() << "SettingsDialog constructor initial category: " << initialCategory << ", initial page: " << initialPage; + qDebug() << "SettingsDialog constructor initial category:" << initialCategory << ", initial page:" << initialPage; if (initialCategory.isEmpty() && initialPage.isEmpty()) { - QSettings *settings = ICore::instance()->settings(); - initialCategory = settings->value("General/LastPreferenceCategory", QVariant(QString())).toString(); - initialPage = settings->value("General/LastPreferencePage", QVariant(QString())).toString(); - qDebug() << "SettingsDialog settings initial category: " << initialCategory << ", initial page: " << initialPage; - m_windowWidth = settings->value("General/SettingsWindowWidth", 0).toInt(); - m_windowHeight = settings->value("General/SettingsWindowHeight", 0).toInt(); + initialCategory = settings->value("LastPreferenceCategory", QVariant(QString())).toString(); + initialPage = settings->value("LastPreferencePage", QVariant(QString())).toString(); + qDebug() << "SettingsDialog settings initial category:" << initialCategory << ", initial page: " << initialPage; } - if (m_windowWidth > 0 && m_windowHeight > 0) - resize(m_windowWidth, m_windowHeight); + // restore window size + int windowWidth = settings->value("SettingsWindowWidth", 0).toInt(); + int windowHeight = settings->value("SettingsWindowHeight", 0).toInt(); + qDebug() << "SettingsDialog window width :" << windowWidth << ", height:" << windowHeight; + if (windowWidth > 0 && windowHeight > 0) { + resize(windowWidth, windowHeight); + } + settings->endGroup(); buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); diff --git a/ground/openpilotgcs/src/plugins/coreplugin/dialogs/settingsdialog.h b/ground/openpilotgcs/src/plugins/coreplugin/dialogs/settingsdialog.h index 3000084a2..ebf108c2f 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/dialogs/settingsdialog.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/dialogs/settingsdialog.h @@ -46,15 +46,12 @@ class SettingsDialog : public QDialog, public ::Ui::SettingsDialog Q_OBJECT public: - SettingsDialog(QWidget *parent, - const QString &initialCategory = QString(), - const QString &initialPage = QString()); + SettingsDialog(QWidget *parent, const QString &initialCategory = QString(), const QString &initialPage = QString()); ~SettingsDialog(); - // Run the dialog and return true if 'Ok' was choosen or 'Apply' was invoked - // at least once + // Run the dialog and return true if 'Ok' was choosen or 'Apply' was invoked at least once bool execDialog(); - void insertPage(IOptionsPage* page); + void insertPage(IOptionsPage *page); void deletePage(); void updateText(QString text); void disableApplyOk(bool disable); @@ -74,17 +71,13 @@ private slots: void apply(); void categoryItemSelectedShowChildInstead(); - private: - QList m_pages; QMap *> m_categoryItemsMap; UAVGadgetInstanceManager *m_instanceManager; bool m_applied; QString m_currentCategory; QString m_currentPage; - int m_windowWidth; - int m_windowHeight; }; } // namespace Internal From cdb3730edbc77b9b017d8ce850a85f233a0cabce Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Wed, 20 Mar 2013 22:40:02 +0200 Subject: [PATCH 7/9] OP-857 OP-876 made default Options dialog size bigger to avoid some scroll bars showing up --- .../default_configurations/OpenPilotGCS.xml | 7 ++++--- .../default_configurations/OpenPilotGCS_wide.xml | 16 ++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml index b7883d423..e944992e1 100644 --- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml +++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml @@ -2,13 +2,14 @@ true true - false Default configuration
Default configuration built to work on all screen sizes
false + + true - 700 - 800 + 554 + 776 default false
diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml index e8234e1e8..e4aaa0109 100644 --- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml +++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml @@ -2,16 +2,16 @@ true true - false - Notify Plugin - settings - true - 700 - 800 - false Wide configuration -
Default configuration built for wide screens (17"up)
+
Default configuration built for wide screens (17" and up)
+ false + + + true + 554 + 776 default + false
0 From eef25f4e9db7e83dbb424cb2ce402fee841faebe Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sun, 24 Mar 2013 16:50:17 +0100 Subject: [PATCH 8/9] OP-857 OP-876 fixed regression introduced while fixing this issue (settings were not handled well anymore) - added timing debug messages - minor cleanups --- ground/openpilotgcs/src/app/main.cpp | 13 +++- .../src/plugins/coreplugin/mainwindow.cpp | 78 +++++++++++-------- .../serialpluginconfiguration.cpp | 29 ++++--- .../serialpluginconfiguration.h | 13 ++-- 4 files changed, 85 insertions(+), 48 deletions(-) diff --git a/ground/openpilotgcs/src/app/main.cpp b/ground/openpilotgcs/src/app/main.cpp index b641b4aac..98b93ff9a 100644 --- a/ground/openpilotgcs/src/app/main.cpp +++ b/ground/openpilotgcs/src/app/main.cpp @@ -50,6 +50,8 @@ #include #include +#include + enum { OptionIndent = 4, DescriptionIndent = 24 }; static const char *appNameC = "OpenPilot GCS"; @@ -234,6 +236,9 @@ static void overrideSettings(QSettings &settings, int argc, char **argv){ int main(int argc, char **argv) { + QElapsedTimer timer; + timer.start(); + #ifdef Q_OS_MAC // increase the number of file that can be opened in OpenPilot GCS struct rlimit rl; @@ -391,5 +396,11 @@ int main(int argc, char **argv) splash.showProgressMessage(QObject::tr("Application started.")); QTimer::singleShot(1500, &splash, SLOT(close())); - return app.exec(); + qDebug() << "main() took" << timer.elapsed() << "ms"; + + int ret = app.exec(); + + qDebug() << "GCS ran for" << timer.elapsed() << "ms"; + + return ret; } diff --git a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp index 299d75bbb..7dc19c262 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp @@ -84,6 +84,7 @@ #include #include #include +#include #include "dialogs/importsettings.h" #include @@ -268,16 +269,8 @@ void MainWindow::modeChanged(Core::IMode */*mode*/) void MainWindow::extensionsInitialized() { QSettings *qs = m_settings; - QString commandLine; if (!qs->allKeys().count()) { // no user settings, so try to load some default ones - foreach(QString str, qApp->arguments()) { - if (str.contains("configfile")) { - qDebug() << "ass"; - commandLine = str.split("=").at(1); - qDebug() << commandLine; - } - } QDir directory(QCoreApplication::applicationDirPath()); #ifdef Q_OS_MAC directory.cdUp(); @@ -292,6 +285,13 @@ void MainWindow::extensionsInitialized() qDebug() << "Looking for configuration files in:" << directory.absolutePath(); QString filename; + // check if command line contains a config file name + QString commandLine; + foreach(QString str, qApp->arguments()) { + if (str.contains("configfile")) { + commandLine = str.split("=").at(1); + } + } if (!commandLine.isEmpty() && QFile::exists(directory.absolutePath() + QDir::separator() + commandLine)) { // use file name specified on command line filename = directory.absolutePath() + QDir::separator() + commandLine; @@ -315,9 +315,15 @@ void MainWindow::extensionsInitialized() // create settings from file qs = new QSettings(filename, XmlConfig::XmlSettingsFormat); - // replace empty settings with new ones - delete m_settings; - m_settings = qs; + // transfer loaded settings to application settings + QStringList keys = qs->allKeys(); + foreach(QString key, keys) { + m_settings->setValue(key, qs->value(key)); + } + + // and delete loaded settings + delete qs; + qs = m_settings; qDebug() << "Configuration file" << filename << "was loaded."; } @@ -353,6 +359,7 @@ void MainWindow::extensionsInitialized() qApp->setStyleSheet(style); qs->endGroup(); + m_uavGadgetInstanceManager = new UAVGadgetInstanceManager(this); m_uavGadgetInstanceManager->readSettings(qs); @@ -397,15 +404,14 @@ QString MainWindow::loadStyleSheet(QString fileName) { void MainWindow::closeEvent(QCloseEvent *event) { - if ( !m_generalSettings->saveSettingsOnExit() ){ + if (!m_generalSettings->saveSettingsOnExit()) { m_dontSaveSettings = true; } - if ( !m_dontSaveSettings ){ + if (!m_dontSaveSettings) { emit m_coreImpl->saveSettingsRequested(); } - const QList listeners = - ExtensionSystem::PluginManager::instance()->getObjects(); + const QList listeners = ExtensionSystem::PluginManager::instance()->getObjects(); foreach (ICoreListener *listener, listeners) { if (!listener->coreAboutToClose()) { event->ignore(); @@ -415,7 +421,7 @@ void MainWindow::closeEvent(QCloseEvent *event) emit m_coreImpl->coreAboutToClose(); - if ( !m_dontSaveSettings ){ + if (!m_dontSaveSettings) { saveSettings(m_settings); m_uavGadgetInstanceManager->saveSettings(m_settings); } @@ -423,7 +429,6 @@ void MainWindow::closeEvent(QCloseEvent *event) } // Check for desktop file manager file drop events - static bool isDesktopFileManagerDrop(const QMimeData *d, QStringList *files = 0) { if (files) @@ -545,9 +550,7 @@ void MainWindow::registerDefaultContainers() ac->appendGroup(Constants::G_HELP_ABOUT); } -static Command *createSeparator(ActionManager *am, QObject *parent, - const QString &name, - const QList &context) +static Command *createSeparator(ActionManager *am, QObject *parent, const QString &name, const QList &context) { QAction *tmpaction = new QAction(parent); tmpaction->setSeparator(true); @@ -1183,13 +1186,18 @@ void MainWindow::createWorkspaces(QSettings* qs, bool diffOnly) { } else { m_uavGadgetManagers.clear(); } - for (int i = start; i < newWorkspacesNo; ++i) { - const QString name = m_workspaceSettings->name(i); + QElapsedTimer totalTimer; + totalTimer.start(); + for (int i = start; i < newWorkspacesNo; ++i) { + QElapsedTimer timer; + timer.start(); + + const QString name = m_workspaceSettings->name(i); const QString iconName = m_workspaceSettings->iconName(i); const QString modeName = m_workspaceSettings->modeName(i); - uavGadgetManager = new Core::UAVGadgetManager(CoreImpl::instance(), name, - QIcon(iconName), 90-i+1, modeName, this); + uavGadgetManager = new Core::UAVGadgetManager(CoreImpl::instance(), name, QIcon(iconName), 90 - i + 1, modeName, + this); connect(uavGadgetManager, SIGNAL(showUavGadgetMenus(bool, bool)), this, SLOT(showUavGadgetMenus(bool, bool))); @@ -1203,7 +1211,9 @@ void MainWindow::createWorkspaces(QSettings* qs, bool diffOnly) { pm->addObject(uavGadgetManager); m_uavGadgetManagers.append(uavGadgetManager); uavGadgetManager->readSettings(qs); + qDebug() << "MainWindow::createWorkspaces - creating workspace" << name << "took" << timer.elapsed() << "ms"; } + qDebug() << "MainWindow::createWorkspaces - creating workspaces took" << totalTimer.elapsed() << "ms"; } static const char *settingsGroup = "MainWindow"; @@ -1215,7 +1225,7 @@ static const char *modePriorities = "ModePriorities"; void MainWindow::readSettings(QSettings* qs, bool workspaceDiffOnly) { - if ( !qs ){ + if (!qs) { qs = m_settings; } @@ -1237,8 +1247,9 @@ void MainWindow::readSettings(QSettings* qs, bool workspaceDiffOnly) } else { resize(750, 400); } - if (qs->value(QLatin1String(maxKey), false).toBool()) + if (qs->value(QLatin1String(maxKey), false).toBool()) { setWindowState(Qt::WindowMaximized); + } setFullScreen(qs->value(QLatin1String(fullScreenKey), false).toBool()); qs->endGroup(); @@ -1263,9 +1274,11 @@ void MainWindow::readSettings(QSettings* qs, bool workspaceDiffOnly) void MainWindow::saveSettings(QSettings* qs) { - if ( m_dontSaveSettings ) return; + if (m_dontSaveSettings) { + return; + } - if ( !qs ){ + if (!qs) { qs = m_settings; } @@ -1309,7 +1322,7 @@ void MainWindow::saveSettings(QSettings* qs) void MainWindow::readSettings(IConfigurablePlugin* plugin, QSettings* qs) { - if ( !qs ){ + if (!qs) { qs = m_settings; } @@ -1332,8 +1345,11 @@ void MainWindow::readSettings(IConfigurablePlugin* plugin, QSettings* qs) void MainWindow::saveSettings(IConfigurablePlugin* plugin, QSettings* qs) { - if ( m_dontSaveSettings ) return; - if ( !qs ){ + if (m_dontSaveSettings) { + return; + } + + if (!qs) { qs = m_settings; } diff --git a/ground/openpilotgcs/src/plugins/serialconnection/serialpluginconfiguration.cpp b/ground/openpilotgcs/src/plugins/serialconnection/serialpluginconfiguration.cpp index 75510f52c..8d8c9bbe6 100644 --- a/ground/openpilotgcs/src/plugins/serialconnection/serialpluginconfiguration.cpp +++ b/ground/openpilotgcs/src/plugins/serialconnection/serialpluginconfiguration.cpp @@ -30,11 +30,13 @@ #include "utils/pathutils.h" #include +#include + /** * Loads a saved configuration or defaults if non exist. * */ -SerialPluginConfiguration::SerialPluginConfiguration(QString classId, QSettings* qSettings, QObject *parent) : +SerialPluginConfiguration::SerialPluginConfiguration(QString classId, QSettings *qSettings, QObject *parent) : IUAVGadgetConfiguration(classId, parent), m_speed("57600") { @@ -43,6 +45,10 @@ SerialPluginConfiguration::SerialPluginConfiguration(QString classId, QSettings* settings = Core::ICore::instance()->settings(); } +SerialPluginConfiguration::~SerialPluginConfiguration() +{ +} + /** * Clones a configuration. * @@ -50,7 +56,7 @@ SerialPluginConfiguration::SerialPluginConfiguration(QString classId, QSettings* IUAVGadgetConfiguration *SerialPluginConfiguration::clone() { SerialPluginConfiguration *m = new SerialPluginConfiguration(this->classId()); - m->m_speed=m_speed; + m->m_speed = m_speed; return m; } @@ -61,23 +67,24 @@ IUAVGadgetConfiguration *SerialPluginConfiguration::clone() void SerialPluginConfiguration::saveConfig(QSettings* settings) const { settings->setValue("speed", m_speed); } + void SerialPluginConfiguration::restoresettings() { settings->beginGroup(QLatin1String("SerialConnection")); - QString str=(settings->value(QLatin1String("speed"), tr("")).toString()); - if(str.isEmpty()) - m_speed="57600"; - else - m_speed=str; + QString str = (settings->value(QLatin1String("speed"), tr("")).toString()); + qDebug() << "SerialPluginConfiguration::restoresettings - speed" << str; + if (str.isEmpty()) { + m_speed = "57600"; + } + else { + m_speed = str; + } settings->endGroup(); - } + void SerialPluginConfiguration::savesettings() const { settings->beginGroup(QLatin1String("SerialConnection")); settings->setValue(QLatin1String("speed"), m_speed); settings->endGroup(); } -SerialPluginConfiguration::~SerialPluginConfiguration() -{ -} diff --git a/ground/openpilotgcs/src/plugins/serialconnection/serialpluginconfiguration.h b/ground/openpilotgcs/src/plugins/serialconnection/serialpluginconfiguration.h index 793ad102b..41a1e2c5a 100644 --- a/ground/openpilotgcs/src/plugins/serialconnection/serialpluginconfiguration.h +++ b/ground/openpilotgcs/src/plugins/serialconnection/serialpluginconfiguration.h @@ -40,16 +40,19 @@ class SerialPluginConfiguration : public IUAVGadgetConfiguration { Q_OBJECT public: - explicit SerialPluginConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0); - QString speed() {return m_speed;} - void saveConfig(QSettings* settings) const; + explicit SerialPluginConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0); + virtual ~SerialPluginConfiguration(); + + QString speed() { return m_speed; } + void saveConfig(QSettings *settings) const; IUAVGadgetConfiguration *clone(); void savesettings() const; void restoresettings(); - virtual ~SerialPluginConfiguration(); + private: QString m_speed; - QSettings* settings; + QSettings *settings; + public slots: void setSpeed(QString speed) { m_speed = speed; } From caa9964fe5ab4709fea839efeb23b431dbbef39f Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Tue, 26 Mar 2013 00:37:39 +0100 Subject: [PATCH 9/9] OP-857 OP-876 made default Options dialog size even bigger --- .../openpilotgcs/default_configurations/OpenPilotGCS.xml | 4 ++-- .../openpilotgcs/default_configurations/OpenPilotGCS_wide.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml index e944992e1..2aa17dba1 100644 --- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml +++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml @@ -8,8 +8,8 @@ true - 554 - 776 + 600 + 800 default false diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml index e4aaa0109..1199ff928 100644 --- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml +++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml @@ -8,8 +8,8 @@ true - 554 - 776 + 600 + 800 default false