summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnathan Corgan <johnathan@corganlabs.com>2016-10-17 07:29:10 -0700
committerJohnathan Corgan <johnathan@corganlabs.com>2016-10-17 07:29:10 -0700
commit49d97afaa150682c3b5d285f7333581400ed04ad (patch)
tree5dacd9e4b41eedcb5aec9b77549b84d5fec660d8
parent15a8a39c9acb1eca7ed2fb29868eaaa1e1e3d5a9 (diff)
parent5fc448bd285777af3309d300d96be35c2e910c89 (diff)
Merge remote-tracking branch 'osh/qtgui_qss_fix'
-rw-r--r--gr-qtgui/include/gnuradio/qtgui/utils.h3
-rw-r--r--gr-qtgui/lib/const_sink_c_impl.cc6
-rw-r--r--gr-qtgui/lib/edit_box_msg_impl.cc6
-rw-r--r--gr-qtgui/lib/freq_sink_c_impl.cc6
-rw-r--r--gr-qtgui/lib/freq_sink_f_impl.cc6
-rw-r--r--gr-qtgui/lib/histogram_sink_f_impl.cc6
-rw-r--r--gr-qtgui/lib/qtgui_util.cc12
-rw-r--r--gr-qtgui/lib/sink_c_impl.cc6
-rw-r--r--gr-qtgui/lib/sink_f_impl.cc6
-rw-r--r--gr-qtgui/lib/time_raster_sink_b_impl.cc6
-rw-r--r--gr-qtgui/lib/time_raster_sink_f_impl.cc6
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.cc6
-rw-r--r--gr-qtgui/lib/time_sink_f_impl.cc6
-rw-r--r--gr-qtgui/lib/vector_sink_f_impl.cc6
-rw-r--r--gr-qtgui/lib/waterfall_sink_c_impl.cc6
-rw-r--r--gr-qtgui/lib/waterfall_sink_f_impl.cc6
-rw-r--r--gr-qtgui/python/qtgui/CMakeLists.txt1
-rw-r--r--gr-qtgui/python/qtgui/__init__.py1
-rwxr-xr-xgr-qtgui/python/qtgui/range.py3
-rw-r--r--gr-qtgui/python/qtgui/util.py35
-rw-r--r--grc/core/generator/flow_graph.tmpl2
21 files changed, 70 insertions, 71 deletions
diff --git a/gr-qtgui/include/gnuradio/qtgui/utils.h b/gr-qtgui/include/gnuradio/qtgui/utils.h
index 2c51b24820..438c965ed5 100644
--- a/gr-qtgui/include/gnuradio/qtgui/utils.h
+++ b/gr-qtgui/include/gnuradio/qtgui/utils.h
@@ -28,6 +28,7 @@
#include <qwt_plot_picker.h>
#include <qwt_picker_machine.h>
#include <QString>
+#include <QCoreApplication>
/*!
* From QSS file name, extracts the file contents and returns a
@@ -66,4 +67,6 @@ public:
const QEvent *e);
};
+void check_set_qss(QApplication *app);
+
#endif /* INCLUDED_QTGUI_UTILS_H */
diff --git a/gr-qtgui/lib/const_sink_c_impl.cc b/gr-qtgui/lib/const_sink_c_impl.cc
index eaaf5f570a..63777d7827 100644
--- a/gr-qtgui/lib/const_sink_c_impl.cc
+++ b/gr-qtgui/lib/const_sink_c_impl.cc
@@ -136,11 +136,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
int numplots = (d_nconnections > 0) ? d_nconnections : 1;
d_main_gui = new ConstellationDisplayForm(numplots, d_parent);
diff --git a/gr-qtgui/lib/edit_box_msg_impl.cc b/gr-qtgui/lib/edit_box_msg_impl.cc
index e0c5f64b3d..084e2d4f34 100644
--- a/gr-qtgui/lib/edit_box_msg_impl.cc
+++ b/gr-qtgui/lib/edit_box_msg_impl.cc
@@ -73,11 +73,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
d_is_pair = is_pair;
d_is_static = is_static;
diff --git a/gr-qtgui/lib/freq_sink_c_impl.cc b/gr-qtgui/lib/freq_sink_c_impl.cc
index 517786d58d..ffa4e3017c 100644
--- a/gr-qtgui/lib/freq_sink_c_impl.cc
+++ b/gr-qtgui/lib/freq_sink_c_impl.cc
@@ -162,11 +162,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
int numplots = (d_nconnections > 0) ? d_nconnections : 1;
d_main_gui = new FreqDisplayForm(numplots, d_parent);
diff --git a/gr-qtgui/lib/freq_sink_f_impl.cc b/gr-qtgui/lib/freq_sink_f_impl.cc
index 90624e78eb..3fe2572eb0 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.cc
+++ b/gr-qtgui/lib/freq_sink_f_impl.cc
@@ -161,11 +161,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
int numplots = (d_nconnections > 0) ? d_nconnections : 1;
d_main_gui = new FreqDisplayForm(numplots, d_parent);
diff --git a/gr-qtgui/lib/histogram_sink_f_impl.cc b/gr-qtgui/lib/histogram_sink_f_impl.cc
index 4a1267c129..cd48de8666 100644
--- a/gr-qtgui/lib/histogram_sink_f_impl.cc
+++ b/gr-qtgui/lib/histogram_sink_f_impl.cc
@@ -123,11 +123,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
int numplots = (d_nconnections > 0) ? d_nconnections : 1;
d_main_gui = new HistogramDisplayForm(numplots, d_parent);
diff --git a/gr-qtgui/lib/qtgui_util.cc b/gr-qtgui/lib/qtgui_util.cc
index 07cf3cc9a3..0a0c826bbe 100644
--- a/gr-qtgui/lib/qtgui_util.cc
+++ b/gr-qtgui/lib/qtgui_util.cc
@@ -21,8 +21,11 @@
*/
#include <gnuradio/qtgui/utils.h>
+#include <gnuradio/prefs.h>
#include <QDebug>
#include <QFile>
+#include <QCoreApplication>
+#include <qapplication.h>
QString
get_qt_style_sheet(QString filename)
@@ -101,3 +104,12 @@ QwtDblClickPlotPicker::stateMachine(int n) const
{
return new QwtPickerDblClickPointMachine;
}
+
+void check_set_qss(QApplication *app){
+ std::string qssfile = gr::prefs::singleton()->get_string("qtgui","qss","");
+ if(qssfile.size() > 0) {
+ QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
+ app->setStyleSheet(sstext);
+ }
+}
+
diff --git a/gr-qtgui/lib/sink_c_impl.cc b/gr-qtgui/lib/sink_c_impl.cc
index c1ee694213..ba34eaaa32 100644
--- a/gr-qtgui/lib/sink_c_impl.cc
+++ b/gr-qtgui/lib/sink_c_impl.cc
@@ -138,11 +138,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
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 d9bc526dbf..17a4f78db4 100644
--- a/gr-qtgui/lib/sink_f_impl.cc
+++ b/gr-qtgui/lib/sink_f_impl.cc
@@ -138,11 +138,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
uint64_t maxBufferSize = 32768;
d_main_gui = new SpectrumGUIClass(maxBufferSize, d_fftsize,
diff --git a/gr-qtgui/lib/time_raster_sink_b_impl.cc b/gr-qtgui/lib/time_raster_sink_b_impl.cc
index c0990a9890..cc13faf49a 100644
--- a/gr-qtgui/lib/time_raster_sink_b_impl.cc
+++ b/gr-qtgui/lib/time_raster_sink_b_impl.cc
@@ -138,11 +138,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
// 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
diff --git a/gr-qtgui/lib/time_raster_sink_f_impl.cc b/gr-qtgui/lib/time_raster_sink_f_impl.cc
index 2fb3e7db68..873bd68555 100644
--- a/gr-qtgui/lib/time_raster_sink_f_impl.cc
+++ b/gr-qtgui/lib/time_raster_sink_f_impl.cc
@@ -136,11 +136,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
// 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
diff --git a/gr-qtgui/lib/time_sink_c_impl.cc b/gr-qtgui/lib/time_sink_c_impl.cc
index 209f03340f..d7514aebaa 100644
--- a/gr-qtgui/lib/time_sink_c_impl.cc
+++ b/gr-qtgui/lib/time_sink_c_impl.cc
@@ -137,11 +137,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
int numplots = (d_nconnections > 0) ? d_nconnections : 2;
d_main_gui = new TimeDisplayForm(numplots, d_parent);
diff --git a/gr-qtgui/lib/time_sink_f_impl.cc b/gr-qtgui/lib/time_sink_f_impl.cc
index 50a86d7dff..b3b1c5909d 100644
--- a/gr-qtgui/lib/time_sink_f_impl.cc
+++ b/gr-qtgui/lib/time_sink_f_impl.cc
@@ -134,11 +134,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
int numplots = (d_nconnections > 0) ? d_nconnections : 1;
d_main_gui = new TimeDisplayForm(numplots, d_parent);
diff --git a/gr-qtgui/lib/vector_sink_f_impl.cc b/gr-qtgui/lib/vector_sink_f_impl.cc
index ba139b97f4..6197da4949 100644
--- a/gr-qtgui/lib/vector_sink_f_impl.cc
+++ b/gr-qtgui/lib/vector_sink_f_impl.cc
@@ -147,11 +147,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
d_main_gui = new VectorDisplayForm(d_nconnections, d_parent);
d_main_gui->setVecSize(d_vlen);
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.cc b/gr-qtgui/lib/waterfall_sink_c_impl.cc
index 7395aaf2a9..fbc655afba 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.cc
@@ -162,11 +162,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
int numplots = (d_nconnections > 0) ? d_nconnections : 1;
d_main_gui = new WaterfallDisplayForm(numplots, d_parent);
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.cc b/gr-qtgui/lib/waterfall_sink_f_impl.cc
index b6f50de31d..fdb8fde686 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.cc
@@ -162,11 +162,7 @@ namespace gr {
}
// 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);
- }
+ check_set_qss(d_qApplication);
int numplots = (d_nconnections > 0) ? d_nconnections : 1;
d_main_gui = new WaterfallDisplayForm(numplots, d_parent);
diff --git a/gr-qtgui/python/qtgui/CMakeLists.txt b/gr-qtgui/python/qtgui/CMakeLists.txt
index 4fa4d0f484..1c20033db2 100644
--- a/gr-qtgui/python/qtgui/CMakeLists.txt
+++ b/gr-qtgui/python/qtgui/CMakeLists.txt
@@ -23,6 +23,7 @@ include(GrPython)
GR_PYTHON_INSTALL(
FILES __init__.py
range.py
+ util.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio/qtgui
COMPONENT "qtgui_python"
)
diff --git a/gr-qtgui/python/qtgui/__init__.py b/gr-qtgui/python/qtgui/__init__.py
index 224bde071e..8b60dc6dbe 100644
--- a/gr-qtgui/python/qtgui/__init__.py
+++ b/gr-qtgui/python/qtgui/__init__.py
@@ -35,3 +35,4 @@ except ImportError:
from qtgui_swig import *
from range import Range, RangeWidget
+import util
diff --git a/gr-qtgui/python/qtgui/range.py b/gr-qtgui/python/qtgui/range.py
index 3eafc9002e..ca42bf71f7 100755
--- a/gr-qtgui/python/qtgui/range.py
+++ b/gr-qtgui/python/qtgui/range.py
@@ -22,7 +22,7 @@
#
from PyQt4 import Qt, QtCore, QtGui
-
+import util
class Range(object):
def __init__(self, minv, maxv, step, default, min_length):
@@ -33,6 +33,7 @@ class Range(object):
self.min_length = min_length
self.find_precision()
self.find_nsteps()
+ util.check_set_qss()
def find_precision(self):
# Get the decimal part of the step
diff --git a/gr-qtgui/python/qtgui/util.py b/gr-qtgui/python/qtgui/util.py
new file mode 100644
index 0000000000..d2e9495ac6
--- /dev/null
+++ b/gr-qtgui/python/qtgui/util.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright 2016 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from PyQt4 import Qt, QtCore, QtGui
+from gnuradio import gr
+
+def check_set_qss():
+ app = QtGui.qApp
+ qssfile = gr.prefs().get_string("qtgui","qss","")
+ if(len(qssfile)>0):
+ try:
+ app.setStyleSheet(open(qssfile).read())
+ except:
+ print "WARNING: bad QSS file, %s"%(qssfile)
+
diff --git a/grc/core/generator/flow_graph.tmpl b/grc/core/generator/flow_graph.tmpl
index 07c4169525..1ef251c46b 100644
--- a/grc/core/generator/flow_graph.tmpl
+++ b/grc/core/generator/flow_graph.tmpl
@@ -91,6 +91,7 @@ class $(class_name)(grc_wxgui.top_block_gui):
self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
#end if
#elif $generate_options == 'qt_gui'
+from gnuradio import qtgui
class $(class_name)(gr.top_block, Qt.QWidget):
@@ -99,6 +100,7 @@ class $(class_name)(gr.top_block, Qt.QWidget):
gr.top_block.__init__(self, "$title")
Qt.QWidget.__init__(self)
self.setWindowTitle("$title")
+ qtgui.util.check_set_qss()
try:
self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
except: