Allow user to set a base Qt window style and the font (family and size only)
This commit is contained in:
parent
21bef1058d
commit
ec1b05ee90
|
@ -4241,6 +4241,15 @@ class BitmessageQtApplication(QtGui.QApplication):
|
||||||
QtCore.QCoreApplication.setOrganizationDomain("bitmessage.org")
|
QtCore.QCoreApplication.setOrganizationDomain("bitmessage.org")
|
||||||
QtCore.QCoreApplication.setApplicationName("pybitmessageqt")
|
QtCore.QCoreApplication.setApplicationName("pybitmessageqt")
|
||||||
|
|
||||||
|
self.setStyle(
|
||||||
|
config.safeGet('bitmessagesettings', 'windowstyle', 'GTK+'))
|
||||||
|
|
||||||
|
font = config.safeGet('bitmessagesettings', 'font')
|
||||||
|
if font:
|
||||||
|
# family, size, weight = font.split(',')
|
||||||
|
family, size = font.split(',')
|
||||||
|
self.setFont(QtGui.QFont(family, int(size)))
|
||||||
|
|
||||||
self.server = None
|
self.server = None
|
||||||
self.is_running = False
|
self.is_running = False
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
self.firstrun = firstrun
|
self.firstrun = firstrun
|
||||||
self.config = config_obj
|
self.config = config_obj
|
||||||
self.net_restart_needed = False
|
self.net_restart_needed = False
|
||||||
|
self.font_setting = None
|
||||||
self.timer = QtCore.QTimer()
|
self.timer = QtCore.QTimer()
|
||||||
|
|
||||||
if self.config.safeGetBoolean('bitmessagesettings', 'dontconnect'):
|
if self.config.safeGetBoolean('bitmessagesettings', 'dontconnect'):
|
||||||
|
@ -85,6 +86,16 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
def adjust_from_config(self, config):
|
def adjust_from_config(self, config):
|
||||||
"""Adjust all widgets state according to config settings"""
|
"""Adjust all widgets state according to config settings"""
|
||||||
# pylint: disable=too-many-branches,too-many-statements
|
# pylint: disable=too-many-branches,too-many-statements
|
||||||
|
|
||||||
|
current_style = config.safeGet(
|
||||||
|
'bitmessagesettings', 'windowstyle', 'GTK+')
|
||||||
|
for i, sk in enumerate(QtGui.QStyleFactory.keys()):
|
||||||
|
self.comboBoxStyle.addItem(sk)
|
||||||
|
if sk == current_style:
|
||||||
|
self.comboBoxStyle.setCurrentIndex(i)
|
||||||
|
|
||||||
|
self.save_font_setting(QtGui.QApplication.instance().font())
|
||||||
|
|
||||||
if not self.parent.tray.isSystemTrayAvailable():
|
if not self.parent.tray.isSystemTrayAvailable():
|
||||||
self.groupBoxTray.setEnabled(False)
|
self.groupBoxTray.setEnabled(False)
|
||||||
self.groupBoxTray.setTitle(_translate(
|
self.groupBoxTray.setTitle(_translate(
|
||||||
|
@ -322,6 +333,18 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
if status == 'success':
|
if status == 'success':
|
||||||
self.parent.namecoin = nc
|
self.parent.namecoin = nc
|
||||||
|
|
||||||
|
def save_font_setting(self, font):
|
||||||
|
"""Save user font setting and set the buttonFont text"""
|
||||||
|
font_setting = (font.family(), font.pointSize())
|
||||||
|
self.buttonFont.setText('{} {}'.format(*font_setting))
|
||||||
|
self.font_setting = '{},{}'.format(*font_setting)
|
||||||
|
|
||||||
|
def choose_font(self):
|
||||||
|
"""Show the font selection dialog"""
|
||||||
|
font, valid = QtGui.QFontDialog.getFont()
|
||||||
|
if valid:
|
||||||
|
self.save_font_setting(font)
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
"""A callback for accepted event of buttonBox (OK button pressed)"""
|
"""A callback for accepted event of buttonBox (OK button pressed)"""
|
||||||
# pylint: disable=too-many-branches,too-many-statements
|
# pylint: disable=too-many-branches,too-many-statements
|
||||||
|
@ -348,6 +371,22 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
self.config.set('bitmessagesettings', 'replybelow', str(
|
self.config.set('bitmessagesettings', 'replybelow', str(
|
||||||
self.checkBoxReplyBelow.isChecked()))
|
self.checkBoxReplyBelow.isChecked()))
|
||||||
|
|
||||||
|
window_style = str(self.comboBoxStyle.currentText())
|
||||||
|
if self.config.safeGet(
|
||||||
|
'bitmessagesettings', 'windowstyle', 'GTK+'
|
||||||
|
) != window_style or self.config.safeGet(
|
||||||
|
'bitmessagesettings', 'font'
|
||||||
|
) != self.font_setting:
|
||||||
|
self.config.set('bitmessagesettings', 'windowstyle', window_style)
|
||||||
|
self.config.set('bitmessagesettings', 'font', self.font_setting)
|
||||||
|
queues.UISignalQueue.put((
|
||||||
|
'updateStatusBar', (
|
||||||
|
_translate(
|
||||||
|
"MainWindow",
|
||||||
|
"You need to restart the application to apply"
|
||||||
|
" the window style or default font."), 1)
|
||||||
|
))
|
||||||
|
|
||||||
lang = str(self.languageComboBox.itemData(
|
lang = str(self.languageComboBox.itemData(
|
||||||
self.languageComboBox.currentIndex()).toString())
|
self.languageComboBox.currentIndex()).toString())
|
||||||
self.config.set('bitmessagesettings', 'userlocale', lang)
|
self.config.set('bitmessagesettings', 'userlocale', lang)
|
||||||
|
|
|
@ -147,6 +147,32 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBoxStyle">
|
||||||
|
<property name="title">
|
||||||
|
<string>Custom Style</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBoxStyle">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="buttonFont">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="9" column="1">
|
<item row="9" column="1">
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -1202,5 +1228,11 @@
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonFont</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>settingsDialog</receiver>
|
||||||
|
<slot>choose_font</slot>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Reference in New Issue
Block a user