commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 10/16: grc: simple dialog for selecting QSS


From: git
Subject: [Commit-gnuradio] [gnuradio] 10/16: grc: simple dialog for selecting QSS theme for QT GUI apps
Date: Sat, 3 Oct 2015 19:14:11 +0000 (UTC)

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

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 5b3a80d03a890492e1e219ec91d5275e6b5dafd1
Author: Glenn Richardson <address@hidden>
Date:   Fri Aug 28 13:27:53 2015 -0400

    grc: simple dialog for selecting QSS theme for QT GUI apps
---
 grc/gui/ActionHandler.py | 15 +++++++++++++--
 grc/gui/Actions.py       |  5 +++++
 grc/gui/Bars.py          |  1 +
 grc/gui/Constants.py     |  2 +-
 grc/gui/FileDialogs.py   | 15 ++++++++++++++-
 5 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index faa59b6..ee01595 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -34,8 +34,9 @@ from .ParserErrorsDialog import ParserErrorsDialog
 from .MainWindow import MainWindow
 from .PropsDialog import PropsDialog
 from .FileDialogs import (OpenFlowGraphFileDialog, SaveFlowGraphFileDialog,
-                          SaveReportsFileDialog, SaveImageFileDialog)
-from .Constants import DEFAULT_CANVAS_SIZE, IMAGE_FILE_EXTENSION
+                          SaveReportsFileDialog, SaveImageFileDialog,
+                          OpenQSSFileDialog)
+from .Constants import DEFAULT_CANVAS_SIZE, IMAGE_FILE_EXTENSION, GR_PREFIX
 
 gobject.threads_init()
 
@@ -143,6 +144,7 @@ class ActionHandler:
                 Actions.TOGGLE_SHOW_BLOCK_COMMENTS,
                 Actions.TOGGLE_SHOW_CODE_PREVIEW_TAB,
                 Actions.TOGGLE_SHOW_FLOWGRAPH_COMPLEXITY,
+                Actions.FLOW_GRAPH_OPEN_QSS_THEME,
             ):
                 action.set_sensitive(True)
                 if hasattr(action, 'load_from_preferences'):
@@ -474,6 +476,15 @@ class ActionHandler:
             if file_paths: #open a new page for each file, show only the first
                 for i,file_path in enumerate(file_paths):
                     self.main_window.new_page(file_path, show=(i==0))
+        elif action == Actions.FLOW_GRAPH_OPEN_QSS_THEME:
+            file_paths = OpenQSSFileDialog(GR_PREFIX + 
'/share/gnuradio/themes/').run()
+            if file_paths:
+                try:
+                    from gnuradio import gr
+                    gr.prefs().set_string("qtgui", "qss", file_paths[0])
+                    gr.prefs().save()
+                except Exception as e:
+                    Messages.send("Failed to save QSS preference: " + str(e))
         elif action == Actions.FLOW_GRAPH_CLOSE:
             self.main_window.close_page()
         elif action == Actions.FLOW_GRAPH_SAVE:
diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py
index 7a050d7..2092934 100644
--- a/grc/gui/Actions.py
+++ b/grc/gui/Actions.py
@@ -439,6 +439,11 @@ XML_PARSER_ERRORS_DISPLAY = Action(
     tooltip='View errors that occured while parsing XML files',
     stock_id=gtk.STOCK_DIALOG_ERROR,
 )
+FLOW_GRAPH_OPEN_QSS_THEME = Action(
+    label='Set Default QT GUI _Theme',
+    tooltip='Set a default QT Style Sheet file to use for QT GUI',
+    stock_id=gtk.STOCK_OPEN,
+)
 TOOLS_RUN_FDESIGN = Action(
     label='Filter Design Tool',
     tooltip='Execute gr_filter_design',
diff --git a/grc/gui/Bars.py b/grc/gui/Bars.py
index 4b5fd2e..2ab5b2a 100644
--- a/grc/gui/Bars.py
+++ b/grc/gui/Bars.py
@@ -116,6 +116,7 @@ MENU_BAR_LIST = (
     ]),
     (gtk.Action('Tools', '_Tools', None, None), [
         Actions.TOOLS_RUN_FDESIGN,
+        Actions.FLOW_GRAPH_OPEN_QSS_THEME,
         None,
         Actions.TOGGLE_SHOW_FLOWGRAPH_COMPLEXITY,
         None,
diff --git a/grc/gui/Constants.py b/grc/gui/Constants.py
index 32d6960..980396f 100644
--- a/grc/gui/Constants.py
+++ b/grc/gui/Constants.py
@@ -26,7 +26,7 @@ import sys
 from gnuradio import gr
 
 _gr_prefs = gr.prefs()
-
+GR_PREFIX = gr.prefix()
 
 # default path for the open/save dialogs
 DEFAULT_FILE_PATH = os.getcwd()
diff --git a/grc/gui/FileDialogs.py b/grc/gui/FileDialogs.py
index 96cbd94..730ac6f 100644
--- a/grc/gui/FileDialogs.py
+++ b/grc/gui/FileDialogs.py
@@ -35,6 +35,7 @@ OPEN_FLOW_GRAPH = 'open flow graph'
 SAVE_FLOW_GRAPH = 'save flow graph'
 SAVE_REPORTS = 'save reports'
 SAVE_IMAGE = 'save image'
+OPEN_QSS_THEME = 'open qss theme'
 
 FILE_OVERWRITE_MARKUP_TMPL="""\
 File <b>$encode($filename)</b> Exists!\nWould you like to overwrite the 
existing file?"""
@@ -72,6 +73,13 @@ def get_all_files_filter():
     filter.add_pattern('*')
     return filter
 
+##the filter for qss files
+def get_qss_themes_filter():
+    filter = gtk.FileFilter()
+    filter.set_name('QSS Themes')
+    filter.add_pattern('*.qss')
+    return filter
+
 ##################################################
 # File Dialogs
 ##################################################
@@ -126,6 +134,10 @@ class FileDialog(FileDialogHelper):
             self.add_and_set_filter(get_image_files_filter())
             current_file_path = current_file_path + IMAGE_FILE_EXTENSION
             self.set_current_name(path.basename(current_file_path)) #show the 
current filename
+        elif self.type == OPEN_QSS_THEME:
+            FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_OPEN, 
'Open a QSS theme...')
+            self.add_and_set_filter(get_qss_themes_filter())
+            self.set_select_multiple(False)
         self.set_current_folder(path.dirname(current_file_path)) #current 
directory
 
     def add_and_set_filter(self, filter):
@@ -171,7 +183,7 @@ class FileDialog(FileDialogHelper):
         #############################################
         # Handle Open Dialogs
         #############################################
-        elif self.type in (OPEN_FLOW_GRAPH,):
+        elif self.type in (OPEN_FLOW_GRAPH, OPEN_QSS_THEME):
             filenames = self.get_filenames()
             for filename in filenames:
                 if not path.exists(filename): #show a warning and re-run
@@ -195,5 +207,6 @@ class FileDialog(FileDialogHelper):
 
 class OpenFlowGraphFileDialog(FileDialog): type = OPEN_FLOW_GRAPH
 class SaveFlowGraphFileDialog(FileDialog): type = SAVE_FLOW_GRAPH
+class OpenQSSFileDialog(FileDialog): type = OPEN_QSS_THEME
 class SaveReportsFileDialog(FileDialog): type = SAVE_REPORTS
 class SaveImageFileDialog(FileDialog): type = SAVE_IMAGE



reply via email to

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