Changeset 2700

Show
Ignore:
Timestamp:
06/03/17 04:58:55 (3 years ago)
Author:
jwoithe
Message:

ffado_mixer: add a "Themes" submenu to the "View" menu.

Xavier Forestier's November 2016 patchset included code to add themes under
the "Help" menu which could be selected by the user. The code to do this is
relatively simple so there seems little reason to hold it back. The only
change compared to the submitted patch is to move the themes to a submenu of
the "View" menu since conceptually this is a better place than the top of
the "Help" menu.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/support/mixer-qt4/ffado/ffadowindow.py

    r2694 r2700  
    8484 
    8585        self.editmenu = self.menuBar().addMenu("&View") 
     86 
     87        self.thememenu = self.editmenu.addMenu("Theme") 
     88        themes = QStyleFactory.keys() 
     89        self.menuTheme = {} 
     90        for theme in themes: 
     91            self.menuTheme[theme] = QAction(QIcon.fromTheme("preferences-desktop-theme"), theme, self ) 
     92            self.menuTheme[theme].setCheckable(True) 
     93 
     94            if (ffado_python3 and (self.style().objectName().lower() == theme.lower()) or 
     95                    not(ffado_python3) and (self.style().objectName().toLower() == theme.toLower())): 
     96                self.menuTheme[theme].setDisabled(True) 
     97                self.menuTheme[theme].setChecked(True) 
     98            self.menuTheme[theme].triggered.connect(self.switchTheme ) 
     99            self.thememenu.addAction( self.menuTheme[theme] ) 
     100 
    86101        self.updateaction = QAction(QIcon.fromTheme("view-refresh"),"&Update Mixer Panels", self) 
    87102        self.updateaction.setEnabled(False) 
     
    108123        del self.manager 
    109124        log.info("__del__ finished") 
     125 
     126    def switchTheme(self, checked) : 
     127        for theme in self.menuTheme : 
     128            if not self.menuTheme[theme].isEnabled() : 
     129                self.menuTheme[theme].setChecked(False) 
     130                self.menuTheme[theme].setDisabled(False) 
     131        for theme in self.menuTheme : 
     132            if self.menuTheme[theme].isChecked() : 
     133                self.menuTheme[theme].setDisabled(True) 
     134                QApplication.setStyle(QStyleFactory.create(theme)) 
    110135 
    111136    def closeEvent(self, event):