Skip to content

Commit 406d5ce

Browse files
committed
修改快捷键空格为回车、修复窗口超出屏幕
1 parent da88f42 commit 406d5ce

17 files changed

+1941
-1707
lines changed

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
+ 游戏模式方面,具有**全部6种无猜扫雷模式+标准+win7**,弱可猜、强可猜的模式都是绝无仅有的。
2121

22-
+ 外观上它只是一款普通的标准扫雷,但它能通过按住ctrl并滚动滚轮任意**调整大小**,能调整窗口的**透明度**。这是罕见的。
22+
+ 可以按住ctrl并滚动滚轮任意**调整大小**,能调整窗口的**透明度**。这是罕见的。
2323

2424
+ 按下“空格”计算局面中每一格是雷的概率。这是罕见的。
2525

@@ -137,16 +137,21 @@ Currently in the lengthy development phase, with updates approximately every 1 t
137137
[![Star History Chart](https://api.star-history.com/svg?repos=eee555/Metasweeper&type=Date)](https://star-history.com/?repos=eee555/Metasweeper#repos=eee555/Metasweeper&eee555/Metasweeper&Date)
138138

139139
## 赞助
140-
感谢您考虑支持我们的开源项目,赞助时请备注您的称呼(或Github主页)。您的赞助将有助于项目的持续发展和改进,使我们能够继续提高软件的质量(owner许诺向所有contributor按获得赞助时commit数量的比例分配赞助得到的收入)。
140+
感谢您考虑支持我们的开源项目,赞助时请备注5+您的昵称,例如“5张先生”。您的赞助将有助于项目的持续发展和改进,使我们能够继续提高软件的质量(owner许诺向所有contributor按获得赞助时commit数量的比例分配赞助得到的收入)。
141141

142142
### 一般赞助者
143-
- 一次性捐款¥10或以上
144-
- 您的名字将出现在项目的贡献者列表中
145-
146-
### 高级赞助者
147-
- 一次性捐款¥50或以上
148-
- 您的名字将出现在项目的贡献者列表中
149-
- 独家定期报告项目进展
143+
- 一次性捐款¥3及以上
144+
- 您的名字将永久出现在项目的贡献者列表中(按照您要求的形式)
145+
146+
### 重要赞助者
147+
- 一次性捐款¥50及以上
148+
- 一般赞助者的所有的权益
149+
- 独家定期报告项目进展
150+
151+
### 核心赞助者
152+
- 累计捐款¥1000及以上
153+
- 重要赞助者的所有的权益
154+
- 可行的前提下,按照您的要求来制定开发计划
150155

151156
![](readme_pic/微信收款码.png) ![](readme_pic/支付宝收款码.png)
152157

src/CheckUpdateGui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def downloadCancel(self):
391391
# app = QApplication(sys.argv)
392392
# data = {
393393
# "Github": "https://api.github.com/repos/",
394-
# "fff666": "https://fff666.top/",
394+
# "openms": "https://openms.top/",
395395
# }
396396
# w = CheckUpdateGui(GitHub(SourceManager(data), "eee555",
397397
# "Solvable-Minesweeper", "3.1.9", "(\d+\.\d+\.\d+)"))

src/gameSettings.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from ui.uiComponents import RoundQDialog
55
from country_name import country_name
66
from PyQt5.QtGui import QPixmap
7+
from PyQt5.QtCore import Qt
78

89
class ui_Form(Ui_Form):
910
def __init__(self, mainWindow):
@@ -37,19 +38,16 @@ def __init__(self, mainWindow):
3738

3839
self.Dialog = RoundQDialog(mainWindow.mainWindow)
3940
self.setupUi(self.Dialog)
40-
self.setParameter()
4141
self.Dialog.setWindowIcon(QtGui.QIcon (str(self.r_path.with_name('media').joinpath('cat.ico'))))
42+
4243
self.pushButton_yes.clicked.connect(self.processParameter)
4344
self.pushButton_no.clicked.connect(self.Dialog.close)
44-
self.comboBox_country.resize.connect(self.set_lineedit_country_geometry)
45-
self.lineEdit_country.textEdited.connect(lambda x: self.set_combobox_country(x))
46-
self.comboBox_country.activated['QString'].connect(lambda x: self.set_country_flag(x))
47-
self.lineEdit_country.textEdited.connect(lambda x: self.set_country_flag(x))
48-
45+
# self.comboBox_country.activated['QString'].connect(lambda x: self.onchange_combobox_country(x))
46+
self.comboBox_country.editTextChanged.connect(self.onchange_combobox_country)
47+
self.comboBox_country.lineEdit().setAlignment(Qt.AlignCenter)
4948
self.country_name = list(country_name.keys())
50-
self.set_combobox_country(self.lineEdit_country.text())
51-
self.set_country_flag(self.lineEdit_country.text())
52-
49+
self.setParameter()
50+
5351
def set_country_flag(self, flag_name):
5452
# 设置国旗图案
5553
if flag_name not in country_name:
@@ -61,22 +59,20 @@ def set_country_flag(self, flag_name):
6159
(fn + ".svg"))).scaled(51, 31)
6260
self.label_national_flag.setPixmap(pixmap)
6361
self.label_national_flag.update()
64-
65-
66-
def set_lineedit_country_geometry(self):
67-
# 把lineEdit_country重叠到comboBox_country上
68-
QRect1 = self.comboBox_country.geometry()
69-
QRect2 = self.horizontalWidget_country.geometry()
70-
self.lineEdit_country.setGeometry(QRect1.x() + QRect2.x(),
71-
QRect1.y() + QRect2.y(),
72-
QRect1.width() - 30, # 把箭头露出来
73-
QRect1.height())
74-
75-
def set_combobox_country(self, qtext):
76-
# 修改comboBox_country里的国家选项
62+
63+
64+
# 修改comboBox_country里的国家选项的回调
65+
def onchange_combobox_country(self, qtext):
66+
# 记录光标位置
67+
line_edit = self.comboBox_country.lineEdit()
68+
cursor_position = line_edit.cursorPosition()
69+
self.comboBox_country.editTextChanged.disconnect(self.onchange_combobox_country)
7770
self.comboBox_country.clear()
7871
self.comboBox_country.addItems(filter(lambda x: qtext in x, self.country_name))
79-
72+
self.comboBox_country.setCurrentText(qtext)
73+
line_edit.setCursorPosition(cursor_position)
74+
self.comboBox_country.editTextChanged.connect(self.onchange_combobox_country)
75+
self.set_country_flag(qtext)
8076

8177
def setParameter(self):
8278
self.spinBox_pixsize.setValue (self.pixSize)
@@ -90,7 +86,9 @@ def setParameter(self):
9086
self.lineEdit_label.setText(self.player_identifier)
9187
self.lineEdit_race_label.setText(self.race_identifier)
9288
self.lineEdit_unique_label.setText(self.unique_identifier)
93-
self.lineEdit_country.setText(self.country)
89+
# self.lineEdit_country.setText(self.country)
90+
# self.onchange_combobox_country(self.country)
91+
self.comboBox_country.setCurrentText(self.country)
9492
self.checkBox_end_then_flag.setChecked(self.end_then_flag)
9593
self.checkBox_cursor_limit.setChecked(self.cursor_limit)
9694
self.horizontalSlider_transparency.setValue (self.transparency)
@@ -122,7 +120,7 @@ def processParameter(self):
122120
self.player_identifier = self.lineEdit_label.text()
123121
self.race_identifier = self.lineEdit_race_label.text()
124122
self.unique_identifier = self.lineEdit_unique_label.text()
125-
self.country = self.lineEdit_country.text()
123+
self.country = self.comboBox_country.currentText()
126124
self.autosave_video = self.checkBox_autosave_video.isChecked()
127125
self.filter_forever = self.checkBox_filter_forever.isChecked()
128126
self.board_constraint = self.lineEdit_constraint.text()

src/main.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import time
33
from PyQt5 import QtWidgets
44
from PyQt5 import QtCore
5-
from PyQt5.QtWidgets import QApplication, QMessageBox
5+
from PyQt5.QtWidgets import QApplication
66
from PyQt5.QtNetwork import QLocalSocket, QLocalServer
77
import sys
88
import os
@@ -63,45 +63,45 @@ def find_window(class_name, window_name):
6363

6464
if __name__ == "__main__":
6565
# QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
66-
try:
67-
app = QtWidgets.QApplication(sys.argv)
68-
serverName = "MineSweeperServer"
69-
socket = QLocalSocket()
70-
socket.connectToServer(serverName)
71-
if socket.waitForConnected(500):
72-
if len(sys.argv) == 2:
73-
filePath = sys.argv[1]
74-
socket.write(filePath.encode())
75-
socket.flush()
76-
time.sleep(0.5)
77-
app.quit()
78-
else:
79-
localServer = QLocalServer()
80-
localServer.listen(serverName)
81-
localServer.newConnection.connect(
82-
lambda: on_new_connection(localServer=localServer))
83-
mainWindow = mainWindowGUI.MainWindow()
84-
ui = mineSweeperGUI.MineSweeperGUI(mainWindow, sys.argv)
85-
ui.mainWindow.show()
86-
# ui.mainWindow.game_setting = ui.game_setting
87-
88-
_translate = QtCore.QCoreApplication.translate
89-
hwnd = find_window(None, _translate("MainWindow", "元扫雷"))
90-
91-
SetWindowDisplayAffinity = ctypes.windll.user32.SetWindowDisplayAffinity
92-
ui.disable_screenshot = lambda: ... if SetWindowDisplayAffinity(
93-
hwnd, 0x00000011) else 1/0
94-
ui.enable_screenshot = lambda: ... if SetWindowDisplayAffinity(
95-
hwnd, 0x00000000) else 1/0
96-
ui.disable_screenshot = lambda: ... if SetWindowDisplayAffinity(
97-
hwnd, 0x00000011) else 1/0
98-
ui.enable_screenshot = lambda: ... if SetWindowDisplayAffinity(
99-
hwnd, 0x00000000) else 1/0
100-
101-
sys.exit(app.exec_())
102-
...
103-
except:
104-
pass
66+
# try:
67+
app = QtWidgets.QApplication(sys.argv)
68+
serverName = "MineSweeperServer"
69+
socket = QLocalSocket()
70+
socket.connectToServer(serverName)
71+
if socket.waitForConnected(500):
72+
if len(sys.argv) == 2:
73+
filePath = sys.argv[1]
74+
socket.write(filePath.encode())
75+
socket.flush()
76+
time.sleep(0.5)
77+
app.quit()
78+
else:
79+
localServer = QLocalServer()
80+
localServer.listen(serverName)
81+
localServer.newConnection.connect(
82+
lambda: on_new_connection(localServer=localServer))
83+
mainWindow = mainWindowGUI.MainWindow()
84+
ui = mineSweeperGUI.MineSweeperGUI(mainWindow, sys.argv)
85+
ui.mainWindow.show()
86+
# ui.mainWindow.game_setting = ui.game_setting
87+
88+
_translate = QtCore.QCoreApplication.translate
89+
hwnd = find_window(None, _translate("MainWindow", "元扫雷"))
90+
91+
SetWindowDisplayAffinity = ctypes.windll.user32.SetWindowDisplayAffinity
92+
ui.disable_screenshot = lambda: ... if SetWindowDisplayAffinity(
93+
hwnd, 0x00000011) else 1/0
94+
ui.enable_screenshot = lambda: ... if SetWindowDisplayAffinity(
95+
hwnd, 0x00000000) else 1/0
96+
ui.disable_screenshot = lambda: ... if SetWindowDisplayAffinity(
97+
hwnd, 0x00000011) else 1/0
98+
ui.enable_screenshot = lambda: ... if SetWindowDisplayAffinity(
99+
hwnd, 0x00000000) else 1/0
100+
101+
sys.exit(app.exec_())
102+
...
103+
# except:
104+
# pass
105105

106106
# 最高优先级
107107
# 计时器快捷键切换

src/mineSweeperGUI.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
import gameAbout
99
import gameSettings
1010
import gameSettingShortcuts
11-
import \
12-
captureScreen, mine_num_bar, videoControl, gameRecordPop
11+
import captureScreen, mine_num_bar, videoControl, gameRecordPop
1312
from CheckUpdateGui import CheckUpdateGui
1413
from githubApi import GitHub, SourceManager
1514
import minesweeper_master as mm
@@ -1604,9 +1603,9 @@ def closeEvent_(self):
16041603
self.unlimit_cursor()
16051604
# self.score_board_manager.close()
16061605
self.game_setting.set_value(
1607-
"DEFAULT/mainWinTop", str(self.mainWindow.x()))
1606+
"DEFAULT/mainWinTop", str(self.mainWindow.y()))
16081607
self.game_setting.set_value(
1609-
"DEFAULT/mainWinLeft", str(self.mainWindow.y()))
1608+
"DEFAULT/mainWinLeft", str(self.mainWindow.x()))
16101609
self.game_setting.set_value("DEFAULT/row", str(self.row))
16111610
self.game_setting.set_value("DEFAULT/column", str(self.column))
16121611
self.game_setting.set_value("DEFAULT/mineNum", str(self.mineNum))

src/superGUI.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,25 @@ def read_or_create_game_setting(self):
457457
self.mainWindow.setWindowOpacity(transparency / 100)
458458
mainWinTop = self.game_setting.get_or_set_value("DEFAULT/mainwintop", 100, int)
459459
mainWinLeft = self.game_setting.get_or_set_value("DEFAULT/mainwinleft", 200, int)
460-
self.mainWindow.move(mainWinTop, mainWinLeft)
460+
461+
window_width = self.mainWindow.width()
462+
window_height = self.mainWindow.height()
463+
screen = QtGui.QGuiApplication.primaryScreen()
464+
screen_geometry = screen.geometry()
465+
screen_width = screen_geometry.width()
466+
screen_height = screen_geometry.height()
467+
if mainWinLeft < 0:
468+
mainWinLeft = 0
469+
elif mainWinLeft + window_width > screen_width:
470+
mainWinLeft = screen_width - window_width
471+
if mainWinTop < 0:
472+
mainWinTop = 0
473+
elif mainWinTop + window_height > screen_height:
474+
mainWinTop = screen_height - window_height
475+
# 考虑设置导致窗口移出屏幕外(例如使用拓展屏)。然而执行此初始化方法时,屏幕尚未
476+
# 画局面,因此尺寸较完全初始化后偏小,仍有可能有半个窗口在屏幕外,当然这不影响使用。
477+
self.mainWindow.move(mainWinLeft, mainWinTop)
478+
461479
self.row = self.game_setting.get_or_set_value("DEFAULT/row", 16, int)
462480
self.column = self.game_setting.get_or_set_value("DEFAULT/column", 30, int)
463481
self.mineNum = self.game_setting.get_or_set_value("DEFAULT/mineNum", 99, int)

src/ui/uiComponents.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from PyQt5.QtGui import QPixmap
1515
import configparser
1616
from PyQt5.QtCore import pyqtSignal
17+
from PyQt5.QtCore import QEvent
1718
# ui相关的小组件,非窗口
1819

1920
class RoundQDialog(QDialog):
@@ -238,25 +239,22 @@ def mouseReleaseEvent(self, e):
238239
class ScoreTable(QtWidgets.QTableWidget):
239240
...
240241

241-
# 能响应点击的QComboBox
242+
# 可编辑、阻止输入框部分点击事件冒泡
242243
class BetterQCombox(QComboBox):
243-
# clicked = pyqtSignal()
244-
# show_popup = pyqtSignal()
245244
resize = pyqtSignal()
246245
def __init__(self, parent=None):
247246
super(BetterQCombox, self).__init__(parent)
247+
248+
def mousePressEvent(self, event):
249+
# 拦截鼠标按下事件,阻止事件冒泡
250+
super().mousePressEvent(event)
251+
event.accept()
248252

249-
# def mousePressEvent(self, QMouseEvent):
250-
# self.clicked.emit()
251-
# QComboBox.mousePressEvent(self, QMouseEvent)
252-
253-
# def showPopup(self):
254-
# self.show_popup.emit()
255-
# QComboBox.showPopup(self)
253+
def mouseReleaseEvent(self, event):
254+
# 拦截鼠标释放事件,阻止事件冒泡
255+
super().mouseReleaseEvent(event)
256+
event.accept()
256257

257-
# def hidePopup(self):
258-
# QComboBox.hidePopup(self)
259-
260258
def resizeEvent(self, e):
261259
self.resize.emit()
262260

src/ui/ui_about.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def setupUi(self, Form):
5353
self.label_2.setWhatsThis("")
5454
self.label_2.setAccessibleName("")
5555
self.label_2.setAccessibleDescription("")
56-
self.label_2.setText("<html><head/><body><p><a href=\"https://github.com/eee555/Solvable-Minesweeper\"><span style=\" font-size:12pt; font-weight:600; text-decoration: underline; color:#0000ff;\">https://github.com/eee555/Solvable-Minesweeper</span></a></p></body></html>")
56+
self.label_2.setText("<html><head/><body><p><a href=\"https://github.com/eee555/Metasweeper\"><span style=\" text-decoration: underline; color:#0000ff;\">https://github.com/eee555/Metasweeper</span></a></p></body></html>")
5757
self.label_2.setTextFormat(QtCore.Qt.RichText)
5858
self.label_2.setWordWrap(True)
5959
self.label_2.setOpenExternalLinks(True)
@@ -93,7 +93,7 @@ def setupUi(self, Form):
9393
self.label_4.setAccessibleName("")
9494
self.label_4.setAccessibleDescription("")
9595
self.label_4.setLayoutDirection(QtCore.Qt.LeftToRight)
96-
self.label_4.setText("<html><head/><body><p><a href=\"https://openms.top/#/guide/[80.%E6%95%99%E7%A8%8B.%E8%BD%AF%E4%BB%B6]%E5%85%83%E6%89%AB%E9%9B%B7%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B\"><span style=\" text-decoration: underline; color:#0000ff;\">https://openms.top/#/guide/[80.%E6%95%99%E7%A8%8B.%E8%BD%AF%E4%BB%B6]%E5%85%83%E6%89%AB%E9%9B%B7%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B</span></a></p></body></html>")
96+
self.label_4.setText("<html><head/><body><p><a href=\"https://openms.top/#/guide/[80.教程.软件]元扫雷使用教程\"><span style=\" text-decoration: underline; color:#0000ff;\">https://openms.top/#/guide/[80.教程.软件]元扫雷使用教程</span></a></p></body></html>")
9797
self.label_4.setTextFormat(QtCore.Qt.RichText)
9898
self.label_4.setWordWrap(True)
9999
self.label_4.setOpenExternalLinks(True)
@@ -140,7 +140,6 @@ def setupUi(self, Form):
140140
self.pushButton.setStyleSheet("border-image: url(media/button.png);\n"
141141
"font: 16pt \"黑体\";\n"
142142
"color:white;font: bold;")
143-
self.pushButton.setShortcut("Space")
144143
self.pushButton.setAutoDefault(False)
145144
self.pushButton.setFlat(False)
146145
self.pushButton.setObjectName("pushButton")
@@ -160,3 +159,4 @@ def retranslateUi(self, Form):
160159
self.label_race_label_3.setText(_translate("Form", "①本软件可以不受任何限制地复制、储存、传播。\n"
161160
"②任何人可以在任何一个项目中使用本项目源代码的任何一个部分,同时欢迎在本项目主页提出宝贵的意见。"))
162161
self.pushButton.setText(_translate("Form", "确定"))
162+
self.pushButton.setShortcut(_translate("Form", "Return"))

src/ui/ui_defined_parameter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def setupUi(self, Form):
4343
self.pushButton_3.setStyleSheet("border-image: url(media/button.png);\n"
4444
"font: 16pt \"黑体\";\n"
4545
"color:white;font: bold;")
46-
self.pushButton_3.setShortcut("Return")
4746
self.pushButton_3.setAutoDefault(False)
4847
self.pushButton_3.setFlat(False)
4948
self.pushButton_3.setObjectName("pushButton_3")
@@ -150,6 +149,7 @@ def retranslateUi(self, Form):
150149
Form.setWindowTitle(_translate("Form", "自定义设置"))
151150
self.pushButton_2.setText(_translate("Form", "取消"))
152151
self.pushButton_3.setText(_translate("Form", "确定"))
152+
self.pushButton_3.setShortcut(_translate("Form", "Return"))
153153
self.label.setText(_translate("Form", "行数(row)"))
154154
self.label_2.setText(_translate("Form", "列数(column)"))
155155
self.label_3.setText(_translate("Form", "雷数(number)"))

src/ui/ui_gameSettingShortcuts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def setupUi(self, Form):
6060
self.pushButton.setStyleSheet("border-image: url(media/button.png);\n"
6161
"font: 16pt \"黑体\";\n"
6262
"color:white;font: bold;")
63-
self.pushButton.setShortcut("Return")
6463
self.pushButton.setAutoDefault(False)
6564
self.pushButton.setFlat(False)
6665
self.pushButton.setObjectName("pushButton")
@@ -747,6 +746,7 @@ def retranslateUi(self, Form):
747746
_translate = QtCore.QCoreApplication.translate
748747
self.pushButton_2.setText(_translate("Form", "取消"))
749748
self.pushButton.setText(_translate("Form", "确定"))
749+
self.pushButton.setShortcut(_translate("Form", "Return"))
750750
self.comboBox_gamemode4.setItemText(0, _translate("Form", "标准"))
751751
self.comboBox_gamemode4.setItemText(1, _translate("Form", "Win7"))
752752
self.comboBox_gamemode4.setItemText(2, _translate("Form", "强无猜"))

0 commit comments

Comments
 (0)