Skip to content

Commit 24ca0d2

Browse files
author
j33433
committed
Darwin fix for about menu
1 parent 9ef017a commit 24ca0d2

File tree

6 files changed

+346
-12
lines changed

6 files changed

+346
-12
lines changed

source/Makefile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
all: ui/mainwindow.py ui/about.py ui/images_rc.py
1+
OS=$(shell uname -s)
2+
3+
ifeq ($(OS),Darwin)
4+
UIC=pyside-uic-2.7
5+
PLATFORM=_Darwin
6+
else
7+
UIC=pyside-uic
8+
PLATFROM=
9+
endif
10+
11+
all: ui/mainwindow$(PLATFROM).py ui/about$(PLATFORM).py ui/images_rc.py
212

313
ui/images_rc.py: ui/images.qrc
414
pyside-rcc -o ui/images_rc.py ui/images.qrc
515

6-
ui/mainwindow.py: ui/mainwindow.ui Makefile
7-
( cat .disclaimer; pyside-uic ui/mainwindow.ui ) > ui/mainwindow.py
16+
ui/mainwindow$(PLATFORM).py: ui/mainwindow.ui Makefile
17+
( cat .disclaimer; $(UIC) ui/mainwindow.ui ) > ui/mainwindow.py.tmp
18+
mv ui/mainwindow.py.tmp ui/mainwindow$(PLATFORM).py
819

9-
ui/about.py: ui/about.ui Makefile
10-
( cat .disclaimer; pyside-uic ui/about.ui ) > ui/about.py
20+
ui/about$(PLATFORM).py: ui/about.ui Makefile
21+
( cat .disclaimer; $(UIC) ui/about.ui ) > ui/about.py.tmp
22+
mv ui/about.py.tmp ui/about$(PLATFORM).py
1123

source/mpowertcx.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,16 @@
3434

3535
from PySide.QtGui import *
3636
from PySide.QtCore import *
37-
from ui.about import Ui_Dialog
38-
from ui.mainwindow import Ui_MainWindow
37+
38+
if platform.system() == 'Darwin':
39+
# The UIC generates things differently for the OS X context menu
40+
from ui.about_Darwin import Ui_Dialog
41+
from ui.mainwindow_Darwin import Ui_MainWindow
42+
else:
43+
from ui.about import Ui_Dialog
44+
from ui.mainwindow import Ui_MainWindow
45+
46+
3947
from mpower import MPower
4048
from dateutil import tz
4149
from widgetsettings import WidgetSettings
@@ -63,6 +71,8 @@ def __init__(self):
6371
self.version = "v2.0.1"
6472
self.trues = [True, 'True', 'true'] # workaround for pyside
6573
self.setupUi(self)
74+
# self.menuHelp.menuAction().setMenuRole(QAction.AboutRole)
75+
# self.menuBar().setMenuRole(QAction.AboutRole)
6676
self.unstash()
6777
self.assignWidgets()
6878
self.configure()

source/ui/about.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
# Form implementation generated from reading ui file 'ui/about.ui'
2323
#
24-
# Created: Sat Dec 9 13:42:52 2017
25-
# by: pyside-uic 0.2.15 running on PySide 1.2.1
24+
# Created: Sat Dec 9 16:15:56 2017
25+
# by: pyside-uic 0.2.15 running on PySide 1.2.4
2626
#
2727
# WARNING! All changes made in this file will be lost!
2828

source/ui/about_Darwin.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#
2+
# MPowerTCX: Share Schwinn A.C. indoor cycle data with Strava, GoldenCheetah
3+
# and other apps.
4+
#
5+
# Copyright (C) 2016-2017 James Roth
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
#
20+
# -*- coding: utf-8 -*-
21+
22+
# Form implementation generated from reading ui file 'ui/about.ui'
23+
#
24+
# Created: Sat Dec 9 16:29:15 2017
25+
# by: pyside-uic 0.2.15 running on PySide 1.2.4
26+
#
27+
# WARNING! All changes made in this file will be lost!
28+
29+
from PySide import QtCore, QtGui
30+
31+
class Ui_Dialog(object):
32+
def setupUi(self, Dialog):
33+
Dialog.setObjectName("Dialog")
34+
Dialog.resize(680, 403)
35+
self.gridLayout = QtGui.QGridLayout(Dialog)
36+
self.gridLayout.setObjectName("gridLayout")
37+
self.labelVersion = QtGui.QLabel(Dialog)
38+
self.labelVersion.setObjectName("labelVersion")
39+
self.gridLayout.addWidget(self.labelVersion, 0, 0, 1, 1)
40+
self.labelSupport = QtGui.QLabel(Dialog)
41+
self.labelSupport.setObjectName("labelSupport")
42+
self.gridLayout.addWidget(self.labelSupport, 1, 0, 1, 1)
43+
self.labelLicense = QtGui.QLabel(Dialog)
44+
self.labelLicense.setObjectName("labelLicense")
45+
self.gridLayout.addWidget(self.labelLicense, 2, 0, 1, 1)
46+
self.pushButton = QtGui.QPushButton(Dialog)
47+
self.pushButton.setText("")
48+
icon = QtGui.QIcon()
49+
icon.addPixmap(QtGui.QPixmap(":/icon/mpowertcx icon flat.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
50+
self.pushButton.setIcon(icon)
51+
self.pushButton.setIconSize(QtCore.QSize(256, 256))
52+
self.pushButton.setFlat(True)
53+
self.pushButton.setObjectName("pushButton")
54+
self.gridLayout.addWidget(self.pushButton, 3, 1, 1, 1)
55+
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
56+
self.gridLayout.addItem(spacerItem, 4, 1, 1, 1)
57+
self.licenseEdit = QtGui.QPlainTextEdit(Dialog)
58+
self.licenseEdit.setFrameShape(QtGui.QFrame.Box)
59+
self.licenseEdit.setReadOnly(True)
60+
self.licenseEdit.setObjectName("licenseEdit")
61+
self.gridLayout.addWidget(self.licenseEdit, 3, 0, 2, 1)
62+
self.buttonBox = QtGui.QDialogButtonBox(Dialog)
63+
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
64+
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
65+
self.buttonBox.setCenterButtons(True)
66+
self.buttonBox.setObjectName("buttonBox")
67+
self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 2)
68+
69+
self.retranslateUi(Dialog)
70+
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept)
71+
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject)
72+
QtCore.QMetaObject.connectSlotsByName(Dialog)
73+
74+
def retranslateUi(self, Dialog):
75+
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "MPowerTCX: About", None, QtGui.QApplication.UnicodeUTF8))
76+
self.labelVersion.setText(QtGui.QApplication.translate("Dialog", "Version:", None, QtGui.QApplication.UnicodeUTF8))
77+
self.labelSupport.setText(QtGui.QApplication.translate("Dialog", "Support: j33433@gmail.com", None, QtGui.QApplication.UnicodeUTF8))
78+
self.labelLicense.setText(QtGui.QApplication.translate("Dialog", "License:", None, QtGui.QApplication.UnicodeUTF8))
79+
80+
import images_rc

source/ui/mainwindow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
# Form implementation generated from reading ui file 'ui/mainwindow.ui'
2323
#
24-
# Created: Sat Dec 9 13:35:30 2017
25-
# by: pyside-uic 0.2.15 running on PySide 1.2.1
24+
# Created: Sat Dec 9 16:15:56 2017
25+
# by: pyside-uic 0.2.15 running on PySide 1.2.4
2626
#
2727
# WARNING! All changes made in this file will be lost!
2828

@@ -186,7 +186,7 @@ def setupUi(self, MainWindow):
186186
self.gridLayout_6.addItem(spacerItem4, 1, 0, 1, 1)
187187
self.gridLayout_3.addWidget(self.groupBoxCompatibility, 1, 1, 1, 1)
188188
MainWindow.setCentralWidget(self.centralwidget)
189-
self.menubar = QtGui.QMenuBar(MainWindow)
189+
self.menubar = QtGui.QMenuBar()
190190
self.menubar.setGeometry(QtCore.QRect(0, 0, 680, 20))
191191
self.menubar.setObjectName("menubar")
192192
self.menuHelp = QtGui.QMenu(self.menubar)

0 commit comments

Comments
 (0)