Skip to content

Commit fad84a8

Browse files
committed
add dock menu new window for macos
1 parent a6a3d87 commit fad84a8

File tree

7 files changed

+36
-7
lines changed

7 files changed

+36
-7
lines changed

COMTool/Main.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from PyQt5.QtCore import pyqtSignal, Qt, QRect, QMargins
2929
from PyQt5.QtWidgets import (QApplication, QWidget,QPushButton,QMessageBox,QDesktopWidget,QMainWindow,
3030
QVBoxLayout,QHBoxLayout,QGridLayout,QTextEdit,QLabel,QRadioButton,QCheckBox,
31-
QLineEdit,QGroupBox,QSplitter,QFileDialog, QScrollArea, QTabWidget)
31+
QLineEdit,QGroupBox,QSplitter,QFileDialog, QScrollArea, QTabWidget, QMenu)
3232
from PyQt5.QtGui import QIcon,QFont,QTextCursor,QPixmap,QColor
3333
import qtawesome as qta # https://github.com/spyder-ide/qtawesome
3434
import threading
@@ -289,11 +289,26 @@ def addTabPanel(tabWidget, name, plugin, connectionWidget = None):
289289

290290
if sys.platform == "win32":
291291
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("comtool")
292+
elif sys.platform == 'darwin':
293+
self.macOsAddDockMenu()
294+
292295
self.resize(800, 500)
293296
self.MoveToCenter()
294297
self.show()
295298
print("config file path:",parameters.configFilePath)
296299

300+
def macOsAddDockMenu(self):
301+
def dumplicateProcess():
302+
import multiprocessing
303+
p = multiprocessing.Process(target=main)
304+
p.start()
305+
306+
self.dockMenu = QMenu(self)
307+
self.dockMenu.addAction(_('New Window'),
308+
dumplicateProcess)
309+
self.dockMenu.setAsDockMenu()
310+
self.app.setAttribute(Qt.AA_DontShowIconsInMenus, True)
311+
297312
def initEvent(self):
298313
# menu
299314
self.settingsButton.clicked.connect(self.toggleSettings)

COMTool/assets/qss/style-dark.qss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ QTabWidget::pane { /* The tab widget frame */
385385

386386
QTabWidget::tab-bar {
387387
/* left: 5px; /* move to the right by 5px */
388+
alignment: left;
388389
}
389390

390391
/* Style the tab using the tab sub-control. Note that

COMTool/assets/qss/style.qss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ QTabWidget::pane { /* The tab widget frame */
387387

388388
QTabWidget::tab-bar {
389389
/* left: 5px; /* move to the right by 5px */
390+
alignment: left;
390391
}
391392

392393
/* Style the tab using the tab sub-control. Note that

COMTool/widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def __init__(self, parent, icon=None, title="", height=35,
5656
widgets_l, widgets_r = widgets
5757
if sys.platform.startswith("darwin"):
5858
layout.addWidget(self.close)
59-
layout.addWidget(self.max)
6059
layout.addWidget(self.min)
60+
layout.addWidget(self.max)
6161
for w in widgets_r:
6262
layout.addWidget(w)
6363
layout.addStretch(0)

README.MD

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ comtool
112112
* Download release at [release](https://github.com/Neutree/COMTool/releases) page or [sourceforge](https://sourceforge.net/projects/comtool/files/)
113113
* Install dmg package
114114

115-
If you want to open multiple comtool, now [you have to](https://github.com/Neutree/COMTool/issues/30) open terminal and type
115+
If you want to open multiple comtool, just right click dock icon, then click `New Window`.
116+
117+
or you can open terminal and type
116118
```
117119
open -n /Application/comtool.app
118120
```
@@ -122,6 +124,8 @@ cd /Applicatioin/comtool.app/Contents/MacOS
122124
./comtool
123125
```
124126

127+
> Because the program is not signed by the developer, it will warn when you open it for the first time. You need to go to `Settings -> Security and Privacy -> General` to see the prompt `comtool` and click `Open anyway`.
128+
125129
## Windows defender shows comtool binary is malware?
126130

127131
If your program is download from [here](https://github.com/Neutree/COMTool/releases), it's ok, the error caused by [pack issue](https://github.com/pyinstaller/pyinstaller/issues/4852), all the source code and pack script is here, even the pack progress is totally automated with github action, no one manually pack.

README_ZH.MD

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ comtool
109109
*[release](https://github.com/Neutree/COMTool/releases) 页面或 [sourceforge](https://sourceforge.net/projects/comtool/files/) 下载最新版本
110110
* 安装 dmg 包
111111

112-
如果你想同时打开多个`comtool`,目前[只能](https://github.com/Neutree/COMTool/issues/30)打开终端并输入
112+
如果你想同时打开多个`comtool`,只需要右键 dock 栏图标,选择`新建窗口`即可。
113+
114+
另外也可以打开终端并输入
113115
```
114116
open -n /Application/comtool.app
115117
```
@@ -119,6 +121,8 @@ cd /Applicatioin/comtool.app/Contents/MacOS
119121
./comtool
120122
```
121123

124+
> 因为程序没有开发者签名,所以第一次打开时会警告,需要到`设置 -> 安全和隐私 -> 通用` 看到提示`comtool` 点击 `仍要打开`即可
125+
122126

123127
## Windows Defender 显示 comtool 可执行程序是恶意软件?
124128

pack.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def BUNDLE(*args, **kw_args):
3535
kw_args["info_plist"] = items
3636
bundle_str_args = ""
3737
for arg in args:
38-
if type(arg) == str and arg != "exe":
38+
if type(arg) == str and arg != "exe" and arg != "coll":
3939
bundle_str_args += f'"{arg}", \n'
4040
else:
4141
bundle_str_args += f'{arg}, \n'
@@ -52,7 +52,8 @@ def BUNDLE(*args, **kw_args):
5252
code =f'app = BUNDLE({match[0]})'
5353
vars = {
5454
"BUNDLE": BUNDLE,
55-
"exe": "exe"
55+
"exe": "exe",
56+
"coll": "coll"
5657
}
5758
exec(code, vars)
5859
final_str = vars["app"]
@@ -80,7 +81,10 @@ def pack():
8081
# macos not case insensitive, so can not contain comtool file and COMTool dir, so we copy to binary root dir
8182
cmd = 'pyi-makespec --hidden-import babel.numbers -p "COMTool" --add-data="COMTool/assets:assets" --add-data="COMTool/locales:locales" --add-data="README_ZH.MD:./" --add-data="README.MD:./" -i="COMTool/assets/logo.icns" -w COMTool/Main.py -n comtool'
8283
os.system(cmd)
83-
upadte_spec_plist("comtool.spec", {"LSMultipleInstancesProhibited": False}) # enable multi instance support
84+
upadte_spec_plist("comtool.spec", {
85+
"LSMultipleInstancesProhibited": False,
86+
"CFBundleShortVersionString": version.__version__
87+
}) # enable multi instance support
8488
cmd = 'pyinstaller comtool.spec'
8589
else:
8690
cmd = 'pyinstaller --hidden-import babel.numbers -p "COMTool" --add-data="COMTool/assets:assets" --add-data="COMTool/locales:locales" --add-data="README.MD:./" --add-data="README_ZH.MD:./" -i="COMTool/assets/logo.ico" -w COMTool/Main.py -n comtool'

0 commit comments

Comments
 (0)