commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 05/06: qtgui: adds ability to set qss style


From: git
Subject: [Commit-gnuradio] [gnuradio] 05/06: qtgui: adds ability to set qss style sheet as a preference.
Date: Sat, 8 Mar 2014 16:32:45 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch master
in repository gnuradio.

commit e0b8cd475644807b28aaaa15e21b6a0d169e1634
Author: Tom Rondeau <address@hidden>
Date:   Sat Mar 8 11:23:35 2014 -0500

    qtgui: adds ability to set qss style sheet as a preference.
---
 gr-qtgui/doc/qtgui.dox                  |  6 ++++++
 gr-qtgui/examples/dark.qss              |  4 ++--
 gr-qtgui/gr-qtgui.conf                  |  4 ++++
 gr-qtgui/include/gnuradio/qtgui/utils.h |  9 +++++++++
 gr-qtgui/lib/const_sink_c_impl.cc       |  7 +++++++
 gr-qtgui/lib/freq_sink_c_impl.cc        |  7 +++++++
 gr-qtgui/lib/freq_sink_f_impl.cc        |  7 +++++++
 gr-qtgui/lib/histogram_sink_f_impl.cc   |  7 +++++++
 gr-qtgui/lib/qtgui_util.cc              | 19 ++++++++++++++++++-
 gr-qtgui/lib/sink_c_impl.cc             |  7 +++++++
 gr-qtgui/lib/sink_f_impl.cc             |  7 +++++++
 gr-qtgui/lib/time_raster_sink_b_impl.cc |  7 +++++++
 gr-qtgui/lib/time_raster_sink_f_impl.cc |  7 +++++++
 gr-qtgui/lib/time_sink_c_impl.cc        |  7 +++++++
 gr-qtgui/lib/time_sink_f_impl.cc        |  7 +++++++
 gr-qtgui/lib/waterfall_sink_c_impl.cc   |  7 +++++++
 gr-qtgui/lib/waterfall_sink_f_impl.cc   |  7 +++++++
 17 files changed, 123 insertions(+), 3 deletions(-)

diff --git a/gr-qtgui/doc/qtgui.dox b/gr-qtgui/doc/qtgui.dox
index cbe5b83..63530d4 100644
--- a/gr-qtgui/doc/qtgui.dox
+++ b/gr-qtgui/doc/qtgui.dox
@@ -203,4 +203,10 @@ usability. When using QTGUI sinks through an X-forwarding 
session over
 SSH, switch to using 'native' for a significant speed boost on the
 remote end.
 
+We can also set a QT Style Sheet (QSS) file to adjust the look of our
+plotting tools. Set the 'qss' option of the 'qtgui' section in our
+configuration file to a QSS file. An example QSS file is distributed
+with the QTGUI examples found in
+share/gnuradio/examples/qt-gui/dark.qss.
+
 */
diff --git a/gr-qtgui/examples/dark.qss b/gr-qtgui/examples/dark.qss
index 77a3756..9bbe00b 100644
--- a/gr-qtgui/examples/dark.qss
+++ b/gr-qtgui/examples/dark.qss
@@ -66,7 +66,7 @@ QLineEdit,
 QPlainTextEdit,
 QComboBox,
 QMenu {
-    selection-color: black; 
+    selection-color: black;
     selection-background-color: lightgrey;
     background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 black, stop: 1 
rgb(128, 128, 128));
     border: 1px solid gray;
@@ -76,7 +76,7 @@ QMenu {
 
 QPushButton,
 QToolButton {
-    selection-color: black; 
+    selection-color: black;
     selection-background-color: white;
     background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 black, stop: 1 
rgb(128, 128, 128));
     border: 1px solid gray;
diff --git a/gr-qtgui/gr-qtgui.conf b/gr-qtgui/gr-qtgui.conf
index 66354cf..b1d3414 100644
--- a/gr-qtgui/gr-qtgui.conf
+++ b/gr-qtgui/gr-qtgui.conf
@@ -8,3 +8,7 @@
 # - 'raster' is fast and stable; terrible X forwarding performance
 # - 'native' most compute intensive; very good over X
 style = raster
+
+# Use a QSS style sheet to set the look and styles of the plots
+# See gnuradio/examples/qt-gui/dark.qss
+# qss =
\ No newline at end of file
diff --git a/gr-qtgui/include/gnuradio/qtgui/utils.h 
b/gr-qtgui/include/gnuradio/qtgui/utils.h
index 7794feb..4b2623d 100644
--- a/gr-qtgui/include/gnuradio/qtgui/utils.h
+++ b/gr-qtgui/include/gnuradio/qtgui/utils.h
@@ -27,6 +27,15 @@
 #include <gnuradio/qtgui/api.h>
 #include <qwt_plot_picker.h>
 #include <qwt_picker_machine.h>
+#include <QString>
+
+/*!
+ * From QSS file name, extracts the file contents and returns a
+ * QString that contains the QSS information. Designed to be passed to
+ * the qApplication. The QSS file is typically retrieved using the
+ * [qtgui] qss=<filename> section of the preferences files.
+ */
+QTGUI_API QString get_qt_style_sheet(QString filename);
 
 class QTGUI_API QwtDblClickPlotPicker: public QwtPlotPicker
 {
diff --git a/gr-qtgui/lib/const_sink_c_impl.cc 
b/gr-qtgui/lib/const_sink_c_impl.cc
index 8b1a804..bc4b411 100644
--- a/gr-qtgui/lib/const_sink_c_impl.cc
+++ b/gr-qtgui/lib/const_sink_c_impl.cc
@@ -115,6 +115,13 @@ namespace gr {
        d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
+      // If a style sheet is set in the prefs file, enable it here.
+      std::string qssfile = prefs::singleton()->get_string("qtgui","qss","");
+      if(qssfile.size() > 0) {
+        QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+        d_qApplication->setStyleSheet(sstext);
+      }
+
       d_main_gui = new ConstellationDisplayForm(d_nconnections, d_parent);
       d_main_gui->setNPoints(d_size);
       // initialize update time to 10 times a second
diff --git a/gr-qtgui/lib/freq_sink_c_impl.cc b/gr-qtgui/lib/freq_sink_c_impl.cc
index ff37597..0f37fe8 100644
--- a/gr-qtgui/lib/freq_sink_c_impl.cc
+++ b/gr-qtgui/lib/freq_sink_c_impl.cc
@@ -138,6 +138,13 @@ namespace gr {
         d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
+      // If a style sheet is set in the prefs file, enable it here.
+      std::string qssfile = prefs::singleton()->get_string("qtgui","qss","");
+      if(qssfile.size() > 0) {
+        QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+        d_qApplication->setStyleSheet(sstext);
+      }
+
       d_main_gui = new FreqDisplayForm(d_nconnections, d_parent);
       set_fft_window(d_wintype);
       set_fft_size(d_fftsize);
diff --git a/gr-qtgui/lib/freq_sink_f_impl.cc b/gr-qtgui/lib/freq_sink_f_impl.cc
index f2dfb4f..b77e523 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.cc
+++ b/gr-qtgui/lib/freq_sink_f_impl.cc
@@ -138,6 +138,13 @@ namespace gr {
        d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
+      // If a style sheet is set in the prefs file, enable it here.
+      std::string qssfile = prefs::singleton()->get_string("qtgui","qss","");
+      if(qssfile.size() > 0) {
+        QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+        d_qApplication->setStyleSheet(sstext);
+      }
+
       d_main_gui = new FreqDisplayForm(d_nconnections, d_parent);
       set_fft_window(d_wintype);
       set_fft_size(d_fftsize);
diff --git a/gr-qtgui/lib/histogram_sink_f_impl.cc 
b/gr-qtgui/lib/histogram_sink_f_impl.cc
index 07620a1..4b3aa29 100644
--- a/gr-qtgui/lib/histogram_sink_f_impl.cc
+++ b/gr-qtgui/lib/histogram_sink_f_impl.cc
@@ -114,6 +114,13 @@ namespace gr {
        d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
+      // If a style sheet is set in the prefs file, enable it here.
+      std::string qssfile = prefs::singleton()->get_string("qtgui","qss","");
+      if(qssfile.size() > 0) {
+        QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+        d_qApplication->setStyleSheet(sstext);
+      }
+
       d_main_gui = new HistogramDisplayForm(d_nconnections, d_parent);
       d_main_gui->setNumBins(d_bins);
       d_main_gui->setNPoints(d_size);
diff --git a/gr-qtgui/lib/qtgui_util.cc b/gr-qtgui/lib/qtgui_util.cc
index bb06f58..9ca19cb 100644
--- a/gr-qtgui/lib/qtgui_util.cc
+++ b/gr-qtgui/lib/qtgui_util.cc
@@ -23,6 +23,24 @@
 #include <gnuradio/qtgui/utils.h>
 #include <QDebug>
 
+QString
+get_qt_style_sheet(QString filename)
+{
+  QString sstext;
+  QFile ss(filename);
+  if(!ss.open(QIODevice::ReadOnly | QIODevice::Text)) {
+    return sstext;
+  }
+
+  QTextStream sstream(&ss);
+  while(!sstream.atEnd()) {
+    sstext += sstream.readLine();
+  }
+  ss.close();
+
+  return sstext;
+}
+
 QwtPickerDblClickPointMachine::QwtPickerDblClickPointMachine()
 #if QWT_VERSION < 0x060000
     : QwtPickerMachine ()
@@ -82,4 +100,3 @@ QwtDblClickPlotPicker::stateMachine(int n) const
 {
   return new QwtPickerDblClickPointMachine;
 }
-
diff --git a/gr-qtgui/lib/sink_c_impl.cc b/gr-qtgui/lib/sink_c_impl.cc
index b810a45..12720bd 100644
--- a/gr-qtgui/lib/sink_c_impl.cc
+++ b/gr-qtgui/lib/sink_c_impl.cc
@@ -128,6 +128,13 @@ namespace gr {
        d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
+      // If a style sheet is set in the prefs file, enable it here.
+      std::string qssfile = prefs::singleton()->get_string("qtgui","qss","");
+      if(qssfile.size() > 0) {
+        QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+        d_qApplication->setStyleSheet(sstext);
+      }
+
       if(d_center_freq < 0) {
        throw std::runtime_error("sink_c_impl: Received bad center 
frequency.\n");
       }
diff --git a/gr-qtgui/lib/sink_f_impl.cc b/gr-qtgui/lib/sink_f_impl.cc
index ef194f9..a3567ae 100644
--- a/gr-qtgui/lib/sink_f_impl.cc
+++ b/gr-qtgui/lib/sink_f_impl.cc
@@ -128,6 +128,13 @@ namespace gr {
        d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
+      // If a style sheet is set in the prefs file, enable it here.
+      std::string qssfile = prefs::singleton()->get_string("qtgui","qss","");
+      if(qssfile.size() > 0) {
+        QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+        d_qApplication->setStyleSheet(sstext);
+      }
+
       uint64_t maxBufferSize = 32768;
       d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize,
                                        d_center_freq,
diff --git a/gr-qtgui/lib/time_raster_sink_b_impl.cc 
b/gr-qtgui/lib/time_raster_sink_b_impl.cc
index 84f702b..5e5a9f5 100644
--- a/gr-qtgui/lib/time_raster_sink_b_impl.cc
+++ b/gr-qtgui/lib/time_raster_sink_b_impl.cc
@@ -129,6 +129,13 @@ namespace gr {
        d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
+      // If a style sheet is set in the prefs file, enable it here.
+      std::string qssfile = prefs::singleton()->get_string("qtgui","qss","");
+      if(qssfile.size() > 0) {
+        QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+        d_qApplication->setStyleSheet(sstext);
+      }
+
       // Create time raster plot; as a bit input, we expect to see 1's
       // and 0's from each stream, so we set the maximum intensity
       // (zmax) to the number of connections so after adding the
diff --git a/gr-qtgui/lib/time_raster_sink_f_impl.cc 
b/gr-qtgui/lib/time_raster_sink_f_impl.cc
index beb2937..a68a503 100644
--- a/gr-qtgui/lib/time_raster_sink_f_impl.cc
+++ b/gr-qtgui/lib/time_raster_sink_f_impl.cc
@@ -127,6 +127,13 @@ namespace gr {
        d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
+      // If a style sheet is set in the prefs file, enable it here.
+      std::string qssfile = prefs::singleton()->get_string("qtgui","qss","");
+      if(qssfile.size() > 0) {
+        QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+        d_qApplication->setStyleSheet(sstext);
+      }
+
       // Create time raster plot; as a bit input, we expect to see 1's
       // and 0's from each stream, so we set the maximum intensity
       // (zmax) to the number of connections so after adding the
diff --git a/gr-qtgui/lib/time_sink_c_impl.cc b/gr-qtgui/lib/time_sink_c_impl.cc
index 6cd3146..0f723f8 100644
--- a/gr-qtgui/lib/time_sink_c_impl.cc
+++ b/gr-qtgui/lib/time_sink_c_impl.cc
@@ -118,6 +118,13 @@ namespace gr {
        d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
+      // If a style sheet is set in the prefs file, enable it here.
+      std::string qssfile = prefs::singleton()->get_string("qtgui","qss","");
+      if(qssfile.size() > 0) {
+        QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+        d_qApplication->setStyleSheet(sstext);
+      }
+
       d_main_gui = new TimeDisplayForm(d_nconnections, d_parent);
       d_main_gui->setNPoints(d_size);
       d_main_gui->setSampleRate(d_samp_rate);
diff --git a/gr-qtgui/lib/time_sink_f_impl.cc b/gr-qtgui/lib/time_sink_f_impl.cc
index 7bbda19..f547185 100644
--- a/gr-qtgui/lib/time_sink_f_impl.cc
+++ b/gr-qtgui/lib/time_sink_f_impl.cc
@@ -120,6 +120,13 @@ namespace gr {
        d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
+      // If a style sheet is set in the prefs file, enable it here.
+      std::string qssfile = prefs::singleton()->get_string("qtgui","qss","");
+      if(qssfile.size() > 0) {
+        QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+        d_qApplication->setStyleSheet(sstext);
+      }
+
       d_main_gui = new TimeDisplayForm(d_nconnections, d_parent);
       d_main_gui->setNPoints(d_size);
       d_main_gui->setSampleRate(d_samp_rate);
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.cc 
b/gr-qtgui/lib/waterfall_sink_c_impl.cc
index 54e4c95..ded93d1 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.cc
@@ -137,6 +137,13 @@ namespace gr {
        d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
+      // If a style sheet is set in the prefs file, enable it here.
+      std::string qssfile = prefs::singleton()->get_string("qtgui","qss","");
+      if(qssfile.size() > 0) {
+        QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+        d_qApplication->setStyleSheet(sstext);
+      }
+
       d_main_gui = new WaterfallDisplayForm(d_nconnections, d_parent);
       set_fft_window(d_wintype);
       set_fft_size(d_fftsize);
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.cc 
b/gr-qtgui/lib/waterfall_sink_f_impl.cc
index 9f7bb37..bb6c3e0 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.cc
@@ -136,6 +136,13 @@ namespace gr {
        d_qApplication = new QApplication(d_argc, &d_argv);
       }
 
+      // If a style sheet is set in the prefs file, enable it here.
+      std::string qssfile = prefs::singleton()->get_string("qtgui","qss","");
+      if(qssfile.size() > 0) {
+        QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+        d_qApplication->setStyleSheet(sstext);
+      }
+
       d_main_gui = new WaterfallDisplayForm(d_nconnections, d_parent);
       set_fft_window(d_wintype);
       set_fft_size(d_fftsize);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]