Skip to content

Commit de11bc4

Browse files
author
Lee Miller
committed
Make Windows the default window style on windows, not GTK+
1 parent c3c4190 commit de11bc4

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

src/bitmessageqt/__init__.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
get_plugins = False
6363

6464

65+
is_windows = sys.platform.startswith('win')
66+
67+
6568
# TODO: rewrite
6669
def powQueueSize():
6770
"""Returns the size of queues.workerQueue including current unfinished work"""
@@ -80,7 +83,7 @@ def openKeysFile():
8083
keysfile = os.path.join(state.appdata, 'keys.dat')
8184
if 'linux' in sys.platform:
8285
subprocess.call(["xdg-open", keysfile])
83-
elif sys.platform.startswith('win'):
86+
elif is_windows:
8487
os.startfile(keysfile) # pylint: disable=no-member
8588

8689

@@ -868,7 +871,7 @@ def updateStartOnLogon(self):
868871
"""
869872
startonlogon = config.safeGetBoolean(
870873
'bitmessagesettings', 'startonlogon')
871-
if sys.platform.startswith('win'): # Auto-startup for Windows
874+
if is_windows: # Auto-startup for Windows
872875
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
873876
settings = QtCore.QSettings(
874877
RUN_PATH, QtCore.QSettings.NativeFormat)
@@ -4233,6 +4236,14 @@ class BitmessageQtApplication(QtGui.QApplication):
42334236
# Unique identifier for this application
42344237
uuid = '6ec0149b-96e1-4be1-93ab-1465fb3ebf7c'
42354238

4239+
@staticmethod
4240+
def get_windowstyle():
4241+
"""Get window style set in config or default"""
4242+
return config.safeGet(
4243+
'bitmessagesettings', 'windowstyle',
4244+
'Windows' if is_windows else 'GTK+'
4245+
)
4246+
42364247
def __init__(self, *argv):
42374248
super(BitmessageQtApplication, self).__init__(*argv)
42384249
id = BitmessageQtApplication.uuid
@@ -4241,8 +4252,7 @@ def __init__(self, *argv):
42414252
QtCore.QCoreApplication.setOrganizationDomain("bitmessage.org")
42424253
QtCore.QCoreApplication.setApplicationName("pybitmessageqt")
42434254

4244-
self.setStyle(
4245-
config.safeGet('bitmessagesettings', 'windowstyle', 'GTK+'))
4255+
self.setStyle(self.get_windowstyle())
42464256

42474257
font = config.safeGet('bitmessagesettings', 'font')
42484258
if font:

src/bitmessageqt/settings.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def __init__(self, parent=None, firstrun=False):
4545
super(SettingsDialog, self).__init__(parent)
4646
widgets.load('settings.ui', self)
4747

48+
self.app = QtGui.QApplication.instance()
4849
self.parent = parent
4950
self.firstrun = firstrun
5051
self.config = config_obj
@@ -87,14 +88,13 @@ def adjust_from_config(self, config):
8788
"""Adjust all widgets state according to config settings"""
8889
# pylint: disable=too-many-branches,too-many-statements
8990

90-
current_style = config.safeGet(
91-
'bitmessagesettings', 'windowstyle', 'GTK+')
91+
current_style = self.app.get_windowstyle()
9292
for i, sk in enumerate(QtGui.QStyleFactory.keys()):
9393
self.comboBoxStyle.addItem(sk)
9494
if sk == current_style:
9595
self.comboBoxStyle.setCurrentIndex(i)
9696

97-
self.save_font_setting(QtGui.QApplication.instance().font())
97+
self.save_font_setting(self.app.font())
9898

9999
if not self.parent.tray.isSystemTrayAvailable():
100100
self.groupBoxTray.setEnabled(False)
@@ -148,7 +148,7 @@ def adjust_from_config(self, config):
148148
"MainWindow",
149149
"Tray notifications not yet supported on your OS."))
150150

151-
if 'win' not in sys.platform and not self.parent.desktop:
151+
if not sys.platform.startswith('win') and not self.parent.desktop:
152152
self.checkBoxStartOnLogon.setDisabled(True)
153153
self.checkBoxStartOnLogon.setText(_translate(
154154
"MainWindow", "Start-on-login not yet supported on your OS."))
@@ -372,9 +372,7 @@ def accept(self):
372372
self.checkBoxReplyBelow.isChecked()))
373373

374374
window_style = str(self.comboBoxStyle.currentText())
375-
if self.config.safeGet(
376-
'bitmessagesettings', 'windowstyle', 'GTK+'
377-
) != window_style or self.config.safeGet(
375+
if self.app.get_windowstyle() != window_style or self.config.safeGet(
378376
'bitmessagesettings', 'font'
379377
) != self.font_setting:
380378
self.config.set('bitmessagesettings', 'windowstyle', window_style)

src/bitmessageqt/tests/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def test_styling(self):
4343
self.assertIs(style_setting, None)
4444
self.assertIs(font_setting, None)
4545
style_control = self.dialog.comboBoxStyle
46-
self.assertEqual(style_control.currentText(), 'GTK+')
46+
self.assertEqual(
47+
style_control.currentText(), self.app.get_windowstyle())
4748

4849
def call_font_dialog():
4950
"""A function to get the open font dialog and accept it"""

0 commit comments

Comments
 (0)