Skip to content

Commit 08b0857

Browse files
committed
0.3 release
1 parent 131fa6f commit 08b0857

18 files changed

+180
-795
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Compatible with all Xiaomi wearables made ~2021 and above (Devices manufactured
66

77
### Features:
88
- Intuitive and elegant user interface
9-
- Easy to build & unpack watch faces
9+
- Modern control methods
1010
- Powerful integrated text editor
1111
- Language support
1212

-8 Bytes
Binary file not shown.

src/dialog/compileDialog.ui

+7-10
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,6 @@
6262
</property>
6363
</widget>
6464
</item>
65-
<item row="6" column="0">
66-
<widget class="QLineEdit" name="thumbnailLocation">
67-
<property name="sizePolicy">
68-
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
69-
<horstretch>0</horstretch>
70-
<verstretch>0</verstretch>
71-
</sizepolicy>
72-
</property>
73-
</widget>
74-
</item>
7565
<item row="3" column="0">
7666
<widget class="QLabel" name="label_6">
7767
<property name="text">
@@ -115,6 +105,13 @@
115105
</property>
116106
</widget>
117107
</item>
108+
<item row="6" column="0">
109+
<widget class="QComboBox" name="thumbnailLocation">
110+
<property name="editable">
111+
<bool>true</bool>
112+
</property>
113+
</widget>
114+
</item>
118115
</layout>
119116
</widget>
120117
<widget class="QWidget" name="page">

src/dialog/compileDialog_ui.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
from translate import QCoreApplication
1313

14-
1514
from PyQt6 import QtCore, QtGui, QtWidgets
1615

17-
1816
class Ui_Dialog(object):
1917
def setupUi(self, Dialog):
2018
Dialog.setObjectName("Dialog")
@@ -41,14 +39,6 @@ def setupUi(self, Dialog):
4139
self.watchfaceName.setSizePolicy(sizePolicy)
4240
self.watchfaceName.setObjectName("watchfaceName")
4341
self.gridLayout.addWidget(self.watchfaceName, 2, 0, 1, 1)
44-
self.thumbnailLocation = QtWidgets.QLineEdit(parent=self.page_3)
45-
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed)
46-
sizePolicy.setHorizontalStretch(0)
47-
sizePolicy.setVerticalStretch(0)
48-
sizePolicy.setHeightForWidth(self.thumbnailLocation.sizePolicy().hasHeightForWidth())
49-
self.thumbnailLocation.setSizePolicy(sizePolicy)
50-
self.thumbnailLocation.setObjectName("thumbnailLocation")
51-
self.gridLayout.addWidget(self.thumbnailLocation, 6, 0, 1, 1)
5242
self.label_6 = QtWidgets.QLabel(parent=self.page_3)
5343
self.label_6.setObjectName("label_6")
5444
self.gridLayout.addWidget(self.label_6, 3, 0, 1, 1)
@@ -66,6 +56,10 @@ def setupUi(self, Dialog):
6656
self.label_5 = QtWidgets.QLabel(parent=self.page_3)
6757
self.label_5.setObjectName("label_5")
6858
self.gridLayout.addWidget(self.label_5, 1, 0, 1, 1)
59+
self.thumbnailLocation = QtWidgets.QComboBox(parent=self.page_3)
60+
self.thumbnailLocation.setEditable(True)
61+
self.thumbnailLocation.setObjectName("thumbnailLocation")
62+
self.gridLayout.addWidget(self.thumbnailLocation, 6, 0, 1, 1)
6963
self.stackedWidget.addWidget(self.page_3)
7064
self.page = QtWidgets.QWidget()
7165
self.page.setObjectName("page")
@@ -132,7 +126,6 @@ def setupUi(self, Dialog):
132126

133127
self.retranslateUi(Dialog)
134128
self.stackedWidget.setCurrentIndex(0)
135-
QtCore.QMetaObject.connectSlotsByName(Dialog)
136129

137130
def retranslateUi(self, Dialog):
138131
_translate = QCoreApplication.translate

src/dialog/newProject_ui.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
from translate import QCoreApplication
1313

14-
1514
from PyQt6 import QtCore, QtGui, QtWidgets
1615

1716

src/locales/ru/LC_MESSAGES/main.mo

80 Bytes
Binary file not shown.

src/locales/ru/LC_MESSAGES/main.po

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ msgstr "Невозможно найти"
4949
msgid "Select Folder..."
5050
msgstr "Выберите папку..."
5151

52+
msgid "Add Image..."
53+
msgstr "Добавить изображение..."
54+
5255
msgid "Are you sure you want to reset all dock widget positions?"
5356
msgstr "Вы уверены, что хотите сбросить все позиции виджетов доков?"
5457

src/locales/ru/LC_MESSAGES/window.mo

531 Bytes
Binary file not shown.

src/locales/ru/LC_MESSAGES/window.po

+29-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
msgid ""
55
msgstr ""
66
"Project-Id-Version: 1.0\n"
7-
"POT-Creation-Date: 2024-01-02 11:05+1100\n"
8-
"PO-Revision-Date: 2024-01-05 12:23+1100\n"
7+
"POT-Creation-Date: 2024-01-05 14:27+1100\n"
8+
"PO-Revision-Date: 2024-03-12 20:59+1100\n"
99
"Last-Translator: \n"
1010
"Language-Team: \n"
1111
"Language: ru\n"
@@ -19,7 +19,7 @@ msgid "Mi Create"
1919
msgstr ""
2020

2121
msgid "Save..."
22-
msgstr "Спасите..."
22+
msgstr "Сохранить..."
2323

2424
msgid "Save as..."
2525
msgstr "Сохранить как..."
@@ -48,6 +48,9 @@ msgstr "Выход"
4848
msgid "Edit"
4949
msgstr "Редактировать"
5050

51+
msgid "Search..."
52+
msgstr "Поиск..."
53+
5154
msgid "File"
5255
msgstr "Файл"
5356

@@ -82,13 +85,13 @@ msgid "Unpack..."
8285
msgstr "Распакуйте..."
8386

8487
msgid "Cut"
85-
msgstr "Разрез"
88+
msgstr "Вырезать"
8689

8790
msgid "Copy"
8891
msgstr "Копировать"
8992

9093
msgid "Paste"
91-
msgstr "Паста"
94+
msgstr "Вставить"
9295

9396
msgid "Project Source Code"
9497
msgstr "Исходный код проекта"
@@ -212,3 +215,24 @@ msgstr "..."
212215

213216
msgid "Search:"
214217
msgstr "Поиск:"
218+
219+
msgid "Resources"
220+
msgstr "Ресурсы"
221+
222+
msgid "Layers"
223+
msgstr "Слои"
224+
225+
msgid "Bring to Front"
226+
msgstr "На передний план"
227+
228+
msgid "Bring Forwards"
229+
msgstr "Принесите вперед"
230+
231+
msgid "Send to Back"
232+
msgstr "Отправить назад"
233+
234+
msgid "Send Backwards"
235+
msgstr "Отправьте его назад"
236+
237+
msgid "Delete"
238+
msgstr "Удалить"

src/locales/window.pot

+30
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ msgstr ""
4848
msgid "Edit"
4949
msgstr ""
5050

51+
msgid "Search..."
52+
msgstr ""
53+
5154
msgid "File"
5255
msgstr ""
5356

@@ -206,3 +209,30 @@ msgstr ""
206209

207210
msgid "Search:"
208211
msgstr ""
212+
213+
msgid "Resources"
214+
msgstr ""
215+
216+
msgid "Add Image..."
217+
msgstr ""
218+
219+
msgid "Layers"
220+
msgstr ""
221+
222+
msgid "Bring to Front"
223+
msgstr ""
224+
225+
msgid "Bring Forwards"
226+
msgstr ""
227+
228+
msgid "Send to Back"
229+
msgstr ""
230+
231+
msgid "Send Backwards"
232+
msgstr ""
233+
234+
msgid "Delete"
235+
msgstr ""
236+
237+
msgid "Layers"
238+
msgstr ""

src/main.py

+30-11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# TODO
55
# Put documentation on code, its a wasteland out there
66
# Remove multi-project support in favor of in-line AOD editing (through a toggle)
7+
# Serialize fprj widgets to improve speed when querying
78
# Fix themes
89
# Bundle SVG icons
910

@@ -73,6 +74,7 @@ def __init__(self):
7374
self.fileChanged = False
7475
self.clipboard = []
7576
self.stagedChanges = []
77+
self.resourceImages = []
7678
self.selectionDebounce = False
7779

7880
# Setup Settings
@@ -171,7 +173,7 @@ def accepted():
171173
if self.currentCompileState == 0:
172174
currentProject = self.getCurrentProject()
173175
currentProject["data"]["FaceProject"]["Screen"]["@Title"] = self.compileUi.watchfaceName.text()
174-
currentProject["data"]["FaceProject"]["Screen"]["@Bitmap"] = self.compileUi.thumbnailLocation.text()
176+
currentProject["data"]["FaceProject"]["Screen"]["@Bitmap"] = self.compileUi.thumbnailLocation.currentText()
175177

176178
reply = QMessageBox.question(self, 'Mi Create', _("Save project before building?"), QMessageBox.StandardButton.Yes, QMessageBox.StandardButton.No)
177179
if reply == QMessageBox.StandardButton.Yes:
@@ -410,14 +412,16 @@ def reloadImages(self, imageFolder):
410412
self.ui.resourceList.clear()
411413
else:
412414
self.ui.resourceList.clear()
415+
self.resourceImages.clear()
413416
for filename in os.listdir(imageFolder):
414417
file = os.path.join(imageFolder, filename)
415418
if os.path.isfile(file):
416419
logging.debug("Creating file entry for "+os.path.basename(file))
417420
item = QListWidgetItem(QIcon(file), os.path.basename(file))
418421
item.setData(0, os.path.basename(file))
419422
item.setSizeHint(QSize(64, 64))
420-
423+
424+
self.resourceImages.append(os.path.basename(file))
421425
self.ui.resourceList.addItem(item)
422426

423427
def setupWorkspace(self):
@@ -507,7 +511,7 @@ def addResource():
507511
if currentProject == None or not currentProject.get("imageFolder"):
508512
return
509513

510-
files = QFileDialog.getOpenFileNames(self, 'Add Image...', "%userprofile%\\", "Image File (*.png *.jpeg *.jpg)")
514+
files = QFileDialog.getOpenFileNames(self, _("Add Image..."), "%userprofile%\\", "Image File (*.png *.jpeg *.jpg)")
511515

512516
if not files[0]:
513517
return
@@ -531,7 +535,8 @@ def openResourceFolder():
531535
return
532536

533537
if platform.system() == "Windows":
534-
os.startfile(currentProject["imageFolder"])
538+
path = str.replace(currentProject["imageFolder"], "/", "\\")
539+
os.startfile(path)
535540
elif platform.system() == "Darwin":
536541
subprocess.Popen(["open", currentProject["imageFolder"]])
537542
else:
@@ -597,6 +602,9 @@ def updateProperty(widgetName, property, value):
597602
else:
598603
self.showDialogue("warning", "Invalid source name!")
599604
return
605+
elif property == "@Alignment":
606+
alignmentList = ["Left", "Center", "Right"]
607+
currentItem[property] = str(alignmentList.index(value))
600608
elif property == "@Name":
601609
if value == widgetName:
602610
return
@@ -629,6 +637,8 @@ def updateProperty(widgetName, property, value):
629637
self.ignoreHistoryInvoke = False
630638
updateProperty(currentSelected.data(0,101), args[0], args[1])
631639
else:
640+
if not currentItem.get(args[0]):
641+
currentItem[args[0]] = ""
632642
command = CommandModifyProperty(currentItem["@Name"], args[0], currentItem[args[0]], args[1], updateProperty, f"Change property {args[0]} to {args[1]}")
633643
self.historySystem.undoStack.push(command)
634644
self.ignoreHistoryInvoke = False
@@ -647,7 +657,7 @@ def updateProperties(self, item, itemType=None):
647657
currentProject = self.getCurrentProject()
648658
for index, object in enumerate(currentProject["data"]["FaceProject"]["Screen"]["Widget"]):
649659
if object["@Name"] == item:
650-
self.propertiesWidget.loadProperties(self.propertyJson[itemType], currentProject["data"]["FaceProject"]["Screen"]["Widget"][index], currentProject["data"]["FaceProject"]["@DeviceType"])
660+
self.propertiesWidget.loadProperties(self.propertyJson[itemType], currentProject["data"]["FaceProject"]["Screen"]["Widget"][index], self.resourceImages, currentProject["data"]["FaceProject"]["@DeviceType"])
651661
break
652662
else:
653663
return
@@ -791,7 +801,6 @@ def deleteSelectedWatchfaceWidgets(self):
791801
self.ignoreHistoryInvoke = False
792802
else:
793803
def commandFunc(data):
794-
projectWidgets = currentProject["data"]["FaceProject"]["Screen"]["Widget"]
795804
currentProject["data"]["FaceProject"]["Screen"]["Widget"] = data
796805
currentProject["canvas"].loadObjects(currentProject["data"], currentProject["imageFolder"], self.settings["Canvas"]["Antialiasing"]["value"])
797806
self.Explorer.updateExplorer(currentProject["data"])
@@ -825,6 +834,9 @@ def pasteWatchfaceWidgets(self):
825834

826835
for item in self.clipboard:
827836
print(item)
837+
prevData = currentProject["data"]["FaceProject"]["Screen"]["Widget"]
838+
newData = prevData.copy()
839+
828840
sameNameWidgets = list(filter(lambda widget: widget["@Name"] == item["@Name"], currentProject["data"]["FaceProject"]["Screen"]["Widget"]))
829841
count = len(sameNameWidgets)
830842

@@ -839,10 +851,16 @@ def pasteWatchfaceWidgets(self):
839851

840852
modifiedItem["@Name"] = f"{item['@Name']}{name_suffix * index}"
841853

842-
currentProject["data"]["FaceProject"]["Screen"]["Widget"].append(modifiedItem)
843-
currentProject["canvas"].loadObjects(currentProject["data"], currentProject["imageFolder"], self.settings["Canvas"]["Antialiasing"]["value"])
844-
self.Explorer.updateExplorer(currentProject["data"])
845-
currentProject["canvas"].selectObject(modifiedItem["@Name"])
854+
newData.append(modifiedItem)
855+
856+
def commandFunc(data):
857+
currentProject["data"]["FaceProject"]["Screen"]["Widget"] = data
858+
currentProject["canvas"].loadObjects(currentProject["data"], currentProject["imageFolder"], self.settings["Canvas"]["Antialiasing"]["value"])
859+
self.Explorer.updateExplorer(currentProject["data"])
860+
currentProject["canvas"].selectObject(modifiedItem["@Name"])
861+
862+
command = CommandModifyProjectData(prevData, newData, commandFunc, f"Paste objects through ModifyProjectData command")
863+
self.historySystem.undoStack.push(command)
846864

847865
def zoomCanvas(self, zoom):
848866
currentProject = self.getCurrentProject()
@@ -1233,7 +1251,8 @@ def compileProject(self):
12331251
self.compileUi.buttonBox.addButton("Cancel", QDialogButtonBox.ButtonRole.RejectRole)
12341252

12351253
self.compileUi.watchfaceName.setText(currentProject["data"]["FaceProject"]["Screen"]["@Title"])
1236-
self.compileUi.thumbnailLocation.setText(currentProject["data"]["FaceProject"]["Screen"]["@Bitmap"])
1254+
self.compileUi.thumbnailLocation.addItems(self.resourceImages)
1255+
self.compileUi.thumbnailLocation.setCurrentText(currentProject["data"]["FaceProject"]["Screen"]["@Bitmap"])
12371256

12381257
self.compileDialog.setModal(True)
12391258
self.compileDialog.show()
-816 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)