Skip to content

Commit

Permalink
v 0.4 is here baby
Browse files Browse the repository at this point in the history
  • Loading branch information
ZyMa-1 committed Jan 18, 2024
1 parent fb70149 commit 8154e57
Show file tree
Hide file tree
Showing 21 changed files with 536 additions and 510 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Goal of the project was to learn how to build scalable and manageble application

Screenshots of the 'MainWindow' and QtDesigner interface, showcasing the loaded plugin, contains in [/readme_images](/readme_images) directory.

![Image 4](/readme_images/4_new.png)

# Blog

I have written a detailed blog covering all aspects of the application. You can find it [right here](https://zyma-1.github.io/technical/2023/06/26/Conways-game-of-life-as-a-PySide6-widget.html).
Expand Down
6 changes: 3 additions & 3 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- Zoom in/Zoom out (idk)
- Statistics (alive cells, dead cells, cells died, cells born)
- Make class for Pattern or naah
- Full Language Translate
- Pattern Saving from the state
- Statistics!
- Border annoys
- Border annoys
- Fix unittest tempfiles not creating at all
- Add notice about focusing
47 changes: 33 additions & 14 deletions designer/AboutDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>320</width>
<height>196</height>
<height>210</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -44,8 +44,27 @@
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>8</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
Expand Down Expand Up @@ -81,19 +100,6 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="text_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>{text}</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
Expand All @@ -114,6 +120,19 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="text_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>{text}</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down
10 changes: 5 additions & 5 deletions designer/InstructionsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>263</width>
<width>284</width>
<height>206</height>
</rect>
</property>
Expand Down Expand Up @@ -65,9 +65,9 @@ QPushButton:pressed {
</font>
</property>
<property name="text">
<string>• To change cell state to the opposite,
<string>• To change the cell state to the opposite,
press 'Enter' key or click the cell with
left mouse button.</string>
the left mouse button.</string>
</property>
<property name="margin">
<number>0</number>
Expand All @@ -82,8 +82,8 @@ left mouse button.</string>
</font>
</property>
<property name="text">
<string>• Use arrow keys to change
current active cell position</string>
<string>• Use arrow keys on the keyboard
to change the current active cell position</string>
</property>
<property name="margin">
<number>0</number>
Expand Down
10 changes: 5 additions & 5 deletions designer/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>720</width>
<height>530</height>
<width>621</width>
<height>439</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -151,8 +151,8 @@
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<width>240</width>
<height>240</height>
</size>
</property>
<property name="maximumSize">
Expand Down Expand Up @@ -300,7 +300,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>720</width>
<width>621</width>
<height>22</height>
</rect>
</property>
Expand Down
37 changes: 24 additions & 13 deletions localization/translations/main_gui_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../designer/AboutDialog.ui" line="93"/>
<location filename="../../designer/AboutDialog.ui" line="132"/>
<source>{text}</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../designer/AboutDialog.ui" line="110"/>
<location filename="../../designer/AboutDialog.ui" line="116"/>
<source>{author_name}</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../designer/AboutDialog.ui" line="63"/>
<location filename="../../designer/AboutDialog.ui" line="82"/>
<source>Author:</source>
<translation>Автор:</translation>
</message>
<message>
<location filename="../../designer/AboutDialog.ui" line="80"/>
<location filename="../../designer/AboutDialog.ui" line="99"/>
<source>{app_version}</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../designer/AboutDialog.ui" line="73"/>
<location filename="../../designer/AboutDialog.ui" line="92"/>
<source>App version:</source>
<translation>Версия:</translation>
</message>
Expand All @@ -61,20 +61,31 @@
</message>
<message>
<location filename="../../designer/InstructionsDialog.ui" line="68"/>
<source>• To change the cell state to the opposite,
press &apos;Enter&apos; key or click the cell with
the left mouse button.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../designer/InstructionsDialog.ui" line="85"/>
<source>• Use arrow keys on the keyboard
to change the current active cell position</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>• To change cell state to the opposite,
press &apos;Enter&apos; key or click the cell with
left mouse button.</source>
<translation>• Чтобы поменять состояние клетки
<translation type="vanished">• Чтобы поменять состояние клетки
на противоположное
нажмите клавишу &apos;Enter&apos;
или нажмите на клетку
левой кнопкой мыши.</translation>
</message>
<message>
<location filename="../../designer/InstructionsDialog.ui" line="85"/>
<source>• Use arrow keys to change
current active cell position</source>
<translation>• Используйте стрелки
<translation type="obsolete">• Используйте стрелки на клавиатуре
чтобы поменять позицию
активной клетки</translation>
</message>
Expand Down Expand Up @@ -295,17 +306,17 @@ current active cell position</source>
<message>
<location filename="../../designer/MainWindow.ui" line="285"/>
<source>Set perfect size button</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../../designer/MainWindow.ui" line="288"/>
<source>Set perfect size</source>
<translation type="unfinished"></translation>
<translation>Применить идеальный размер</translation>
</message>
<message>
<location filename="../../designer/MainWindow.ui" line="558"/>
<source>Apply button</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../../designer/MainWindow.ui" line="577"/>
Expand All @@ -325,12 +336,12 @@ current active cell position</source>
<message>
<location filename="../../designer/MainWindow.ui" line="686"/>
<source>Sync button</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../../designer/MainWindow.ui" line="689"/>
<source>Sync</source>
<translation type="unfinished"></translation>
<translation>Синхронизировать</translation>
</message>
<message>
<location filename="../../designer/MainWindow.ui" line="700"/>
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def init_language_settings():

app.setOrganizationName("ZyMa-1")
app.setApplicationName("Conway's Game Of Life Widget")
app.setApplicationVersion("0.3")
app.setApplicationVersion("0.4")

# Retrieving language value from settings
init_language_settings()
Expand Down
Binary file added readme_images/4_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 22 additions & 18 deletions scripts/full_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,25 @@ def convert_ts(input_path: pathlib.Path, output_path: pathlib.Path):


if __name__ == "__main__":
src = PROJECT_ROOT / "src"
designer = PROJECT_ROOT / "designer"
ui = PROJECT_ROOT / "src" / "ui"
resources = PROJECT_ROOT / "src" / "resources"
translations = PROJECT_ROOT / "localization" / "translations"
r_translations = PROJECT_ROOT / "src" / "resources" / "translations"
################## UI ######################################

input_path_1 = PROJECT_ROOT / "designer" / "ConwaysGameOfLifeDialog.ui"
output_path_1 = PROJECT_ROOT / "src" / "ui" / "Ui_ConwaysGameOfLifeDialog.py"
input_path_1 = designer / "ConwaysGameOfLifeDialog.ui"
output_path_1 = ui / "Ui_ConwaysGameOfLifeDialog.py"

input_path_2 = PROJECT_ROOT / "designer" / "MainWindow.ui"
output_path_2 = PROJECT_ROOT / "src" / "ui" / "Ui_MainWindow.py"
input_path_2 = designer / "MainWindow.ui"
output_path_2 = ui / "Ui_MainWindow.py"

input_path_3 = PROJECT_ROOT / "designer" / "AboutDialog.ui"
output_path_3 = PROJECT_ROOT / "src" / "ui" / "Ui_AboutDialog.py"
input_path_3 = designer / "AboutDialog.ui"
output_path_3 = ui / "Ui_AboutDialog.py"

input_path_4 = PROJECT_ROOT / "designer" / "InstructionsDialog.ui"
output_path_4 = PROJECT_ROOT / "src" / "ui" / "Ui_InstructionsDialog.py"
input_path_4 = designer / "InstructionsDialog.ui"
output_path_4 = ui / "Ui_InstructionsDialog.py"

convert_ui(input_path_1, output_path_1)
convert_ui(input_path_2, output_path_2)
Expand All @@ -68,25 +74,23 @@ def convert_ts(input_path: pathlib.Path, output_path: pathlib.Path):

################## LOCALIZATION UPDATE ######################################

src_path = PROJECT_ROOT / "src"
designer_path = PROJECT_ROOT / "designer"
main_py_path = PROJECT_ROOT / "main.py"
py_paths_1 = [main_py_path, designer_path, src_path]
main_py = PROJECT_ROOT / "main.py"
py_paths_1 = [main_py, designer, src]

output_path_1 = PROJECT_ROOT / "localization" / "translations" / "main_gui_ru.ts"
output_path_1 = translations / "main_gui_ru.ts"

update_ts(py_paths_1, output_path_1)

################## LOCALIZATION CONVERT #####################################

input_path_1 = PROJECT_ROOT / "localization" / "translations" / "main_gui_ru.ts"
output_path_1 = PROJECT_ROOT / "src" / "resources" / "translations" / "main_gui_ru.qm"
input_path_1 = translations / "main_gui_ru.ts"
output_path_1 = r_translations / "main_gui_ru.qm"

convert_ts(input_path_1, output_path_1)

################## RESOURCES ######################################

input_path_1 = PROJECT_ROOT / "src" / "resources" / "resources.qrc"
output_path_1 = PROJECT_ROOT / "src" / "resources" / "rc_resources.py"
input_path_1 = resources / "resources.qrc"
output_path_1 = resources / "rc_resources.py"

convert_rcc(input_path_1, output_path_1)
convert_rcc(input_path_1, output_path_1)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from src.backend.PathManager import PathManager
from src.conways_game_of_life.ConwaysGameOfLife import ConwaysGameOfLife
from .QtPropertyJsonConverter import to_json_type, to_property_type
from .QtPropertyJsonConverter import serialize_property, deserialize_property


class ConwaysGameOfLifeConfigManager(QObject):
Expand Down Expand Up @@ -69,10 +69,10 @@ def _save_properties(self):
self._property_dict.clear()
for name in self.conways_game_of_life_widget.savable_properties_names():
value = self.conways_game_of_life_widget.property(name)
value = to_json_type(value)
value = serialize_property(value)
self._property_dict[name] = value

def _load_properties(self):
for name, value in self._property_dict.items():
value = to_property_type(value)
value = deserialize_property(value)
self.conways_game_of_life_widget.setProperty(name, value)
22 changes: 12 additions & 10 deletions src/conways_game_of_life/ConfigManager/QtPropertyJsonConverter.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from PySide6.QtGui import QColor


def to_property_type(value):
if (isinstance(value, list) or isinstance(value, tuple)) and len(value) == 3:
value = QColor(value[0], value[1], value[2])
def deserialize_property(obj):
if isinstance(obj, dict) and '__qcolor__' in obj:
rgba = obj['rgba']
return QColor(*rgba)
return obj

return value


def to_json_type(value):
if isinstance(value, QColor):
value = (value.red(), value.green(), value.blue())

return value
def serialize_property(obj):
if isinstance(obj, QColor):
return {
'__qcolor__': True,
'rgba': (obj.red(), obj.green(), obj.blue(), obj.alpha())
}
return obj
Loading

0 comments on commit 8154e57

Please sign in to comment.