1111
1212import sys
1313
14-
15-
1614from src .app .ui .TableView .UiTableViewForm import UiTableViewForm
15+ from src .app .ui .AboutForm .UiAboutForm import UiAboutForm
16+ import webbrowser
1717from PyQt5 import QtCore , QtGui , QtWidgets
18+ from PyQt5 .QtGui import QStandardItem , QColor
1819from PyQt5 .QtWidgets import QPushButton
19- from src .app .components .PatternGrid import PatternGrid
2020
2121
2222class UiMainWindow (object ):
@@ -31,10 +31,29 @@ def __init__(self, main_window):
3131 size_policy .setHeightForWidth (main_window .sizePolicy ().hasHeightForWidth ())
3232 main_window .setSizePolicy (size_policy )
3333 icon = QtGui .QIcon ()
34- icon .addPixmap (QtGui .QPixmap ("../../../assets/img/pattern_builder_icon.ico" ), QtGui .QIcon .Normal , QtGui .QIcon .Off )
34+ icon .addPixmap (QtGui .QPixmap ("../../../assets/img/pattern_builder_icon.ico" ), QtGui .QIcon .Normal ,
35+ QtGui .QIcon .Off )
3536 main_window .setWindowIcon (icon )
3637 self .main_window = main_window
3738
39+ self .help_pattern_builder_widget = QtWidgets .QWidget ()
40+ self .help_pattern_builder_form = UiAboutForm (self .help_pattern_builder_widget ,
41+ "Pattern builder help" ,
42+ "../../../assets/img/QuestionMark.png" ,
43+ "../../../assets/txt/help_pattern_builder.txt" )
44+
45+ self .about_pattern_builder_widget = QtWidgets .QWidget ()
46+ self .about_pattern_builder_form = UiAboutForm (self .about_pattern_builder_widget ,
47+ "About Pattern Builder" ,
48+ "../../../assets/img/pattern_builder_logo_c_800px.png" ,
49+ "../../../assets/txt/about_pattern_builder.txt" )
50+
51+ self .about_lyl_lynx_widget = QtWidgets .QWidget ()
52+ self .about_lyl_lynx_form = UiAboutForm (self .about_lyl_lynx_widget ,
53+ "About lyl-Lynx" ,
54+ "../../../assets/img/lyl8Lynx_logo.png" ,
55+ "../../../assets/txt/about_lyl_lynx.txt" )
56+
3857 self .colors_widget = QtWidgets .QWidget ()
3958 self .table_view_form = UiTableViewForm (self .colors_widget )
4059 self .table_view_form .close_button .clicked .connect (self .update_colors_select )
@@ -177,11 +196,15 @@ def __init__(self, main_window):
177196 self .verticalLayout .addWidget (self .toolBox_colors_title )
178197
179198 self .colors_comboBox = QtWidgets .QComboBox (self .toolBox_frame )
180- self .colors_comboBox .setMaxVisibleItems (64 )
199+ self .colors_comboBox .setMaxVisibleItems (16 )
200+ model = self .colors_comboBox .model ()
181201 self .colors_comboBox .setObjectName ("colors_comboBox" )
182202 initial_items = self .table_view_form .get_all ()
183203 for item in initial_items :
184- self .colors_comboBox .addItem (str (item ['id' ]))
204+ c_item = QStandardItem ()
205+ c_item .setText (str (item ['id' ]))
206+ c_item .setBackground (QColor (item ['Hex' ]))
207+ model .appendRow (c_item )
185208 self .selected_color_id = int (self .colors_comboBox .currentText ())
186209 self .verticalLayout .addWidget (self .colors_comboBox )
187210
@@ -222,26 +245,6 @@ def __init__(self, main_window):
222245
223246 self .verticalLayout .addLayout (self .reset_button_horizontal_layout )
224247
225- self .save_button_horizontal_layout = QtWidgets .QHBoxLayout ()
226- self .save_button_horizontal_layout .setObjectName ("save_button_horizontal_layout" )
227-
228- spacerItem7 = QtWidgets .QSpacerItem (20 , 20 , QtWidgets .QSizePolicy .Expanding , QtWidgets .QSizePolicy .Minimum )
229- self .save_button_horizontal_layout .addItem (spacerItem7 )
230-
231- self .save_button = QtWidgets .QPushButton (self .toolBox_frame )
232- size_policy = QtWidgets .QSizePolicy (QtWidgets .QSizePolicy .Minimum , QtWidgets .QSizePolicy .Fixed )
233- size_policy .setHorizontalStretch (0 )
234- size_policy .setVerticalStretch (0 )
235- size_policy .setHeightForWidth (self .save_button .sizePolicy ().hasHeightForWidth ())
236- self .save_button .setSizePolicy (size_policy )
237- self .save_button .setObjectName ("save_button" )
238- self .save_button_horizontal_layout .addWidget (self .save_button )
239-
240- spacerItem8 = QtWidgets .QSpacerItem (20 , 20 , QtWidgets .QSizePolicy .Expanding , QtWidgets .QSizePolicy .Minimum )
241- self .save_button_horizontal_layout .addItem (spacerItem8 )
242-
243- self .verticalLayout .addLayout (self .save_button_horizontal_layout )
244-
245248 self .export_button_horizontal_layout = QtWidgets .QHBoxLayout ()
246249 self .export_button_horizontal_layout .setObjectName ("export_button_horizontal_layout" )
247250
@@ -341,30 +344,6 @@ def __init__(self, main_window):
341344 self .statusbar .setObjectName ("statusbar" )
342345 main_window .setStatusBar (self .statusbar )
343346
344- self .action_new = QtWidgets .QAction (main_window )
345- icon4 = QtGui .QIcon ()
346- icon4 .addPixmap (QtGui .QPixmap ("../../../assets/img/NewFile.png" ), QtGui .QIcon .Normal , QtGui .QIcon .Off )
347- self .action_new .setIcon (icon4 )
348- self .action_new .setObjectName ("action_new" )
349-
350- self .action_open = QtWidgets .QAction (main_window )
351- icon5 = QtGui .QIcon ()
352- icon5 .addPixmap (QtGui .QPixmap ("../../../assets/img/OpenFile.png" ), QtGui .QIcon .Normal , QtGui .QIcon .Off )
353- self .action_open .setIcon (icon5 )
354- self .action_open .setObjectName ("action_open" )
355-
356- self .action_save = QtWidgets .QAction (main_window )
357- icon6 = QtGui .QIcon ()
358- icon6 .addPixmap (QtGui .QPixmap ("../../../assets/img/Save.png" ), QtGui .QIcon .Normal , QtGui .QIcon .Off )
359- self .action_save .setIcon (icon6 )
360- self .action_save .setObjectName ("action_save" )
361-
362- self .action_save_as = QtWidgets .QAction (main_window )
363- icon7 = QtGui .QIcon ()
364- icon7 .addPixmap (QtGui .QPixmap ("../../../assets/img/SaveAs.png" ), QtGui .QIcon .Normal , QtGui .QIcon .Off )
365- self .action_save_as .setIcon (icon7 )
366- self .action_save_as .setObjectName ("action_save_as" )
367-
368347 self .action_matrix_text_file_txt = QtWidgets .QAction (main_window )
369348 self .action_matrix_text_file_txt .setObjectName ("action_matrix_text_file_txt" )
370349
@@ -421,22 +400,26 @@ def __init__(self, main_window):
421400 icon8 .addPixmap (QtGui .QPixmap ("../../../assets/img/QuestionMark.png" ), QtGui .QIcon .Normal , QtGui .QIcon .Off )
422401 self .action_help .setIcon (icon8 )
423402 self .action_help .setObjectName ("action_help" )
403+ self .action_help .triggered .connect (self .help_pattern_builder_widget .show )
424404
425405 self .action_about_pb = QtWidgets .QAction (main_window )
426406 self .action_about_pb .setIcon (icon3 )
427407 self .action_about_pb .setObjectName ("action_about_pb" )
408+ self .action_about_pb .triggered .connect (self .about_pattern_builder_widget .show )
428409
429410 self .action_about_author = QtWidgets .QAction (main_window )
430411 icon9 = QtGui .QIcon ()
431412 icon9 .addPixmap (QtGui .QPixmap ("../../../assets/img/lyl8Lynx_logo.png" ), QtGui .QIcon .Normal , QtGui .QIcon .Off )
432413 self .action_about_author .setIcon (icon9 )
433414 self .action_about_author .setObjectName ("action_about_author" )
415+ self .action_about_author .triggered .connect (self .about_lyl_lynx_widget .show )
434416
435417 self .action_join_us = QtWidgets .QAction (main_window )
436418 icon10 = QtGui .QIcon ()
437419 icon10 .addPixmap (QtGui .QPixmap ("../../../assets/img/GitHub.png" ), QtGui .QIcon .Normal , QtGui .QIcon .Off )
438420 self .action_join_us .setIcon (icon10 )
439421 self .action_join_us .setObjectName ("action_join_us" )
422+ self .action_join_us .triggered .connect (self .redirect_to_github_repo )
440423
441424 self .menu_matrix .addAction (self .action_matrix_text_file_txt )
442425 self .menu_matrix .addAction (self .action_matrix_json )
@@ -461,11 +444,6 @@ def __init__(self, main_window):
461444 self .menu_pattern .addAction (self .action_pattern_pdf )
462445 self .menu_export_as .addAction (self .menu_pattern .menuAction ())
463446
464- self .menu_file .addAction (self .action_new )
465- self .menu_file .addAction (self .action_open )
466- self .menu_file .addSeparator ()
467- self .menu_file .addAction (self .action_save )
468- self .menu_file .addAction (self .action_save_as )
469447 self .menu_file .addAction (self .menu_export_as .menuAction ())
470448
471449 self .menu_help .addAction (self .action_help )
@@ -496,15 +474,19 @@ def colors_count(self):
496474 def update_colors_select (self ):
497475 items = self .table_view_form .get_all ().copy ()
498476 self .colors_comboBox .clear ()
477+ model = self .colors_comboBox .model ()
499478 for item in items :
500- self .colors_comboBox .addItem (str (item ['id' ]))
479+ c_item = QStandardItem ()
480+ c_item .setText (str (item ['id' ]))
481+ c_item .setBackground (QColor (item ['Hex' ]))
482+ model .appendRow (c_item )
501483
502484 def switch_button_color (self ):
503485 button = self .main_window .sender ()
504486 params = self .get_selected_color ()
505487 print (params )
506488 button .setText (str (params ['id' ]))
507- button .setStyleSheet ("background-color : " + params ['Hex' ])
489+ button .setStyleSheet ("background-color : " + params ['Hex' ])
508490
509491 def update_matrix_size (self ):
510492 for row in range (self .get_height ()):
@@ -532,6 +514,9 @@ def on_change_size(self):
532514 self .gridLayout .itemAt (i ).widget ().setParent (None )
533515 self .update_matrix_size ()
534516
517+ def redirect_to_github_repo (self ):
518+ webbrowser .open ('https://github.com/lyl-Lynx/Pattern-Builder' )
519+
535520 def retranslate_ui (self , main_window ):
536521 _translate = QtCore .QCoreApplication .translate
537522 main_window .setWindowTitle (_translate ("main_window" , "Pattern Builder by lyl-Lynx" ))
@@ -542,17 +527,12 @@ def retranslate_ui(self, main_window):
542527 self .toolBox_colors_title .setText (_translate ("main_window" , "Colors" ))
543528 self .colors_table_button .setText (_translate ("main_window" , "Open colors table" ))
544529 self .reset_button .setText (_translate ("main_window" , "Reset pattern" ))
545- self .save_button .setText (_translate ("main_window" , "Save" ))
546530 self .export_button .setText (_translate ("main_window" , "Export" ))
547531 self .menu_file .setTitle (_translate ("main_window" , "File" ))
548532 self .menu_export_as .setTitle (_translate ("main_window" , "Export as..." ))
549533 self .menu_matrix .setTitle (_translate ("main_window" , "Matrix" ))
550534 self .menu_pattern .setTitle (_translate ("main_window" , "Pattern" ))
551535 self .menu_help .setTitle (_translate ("main_window" , "Help" ))
552- self .action_new .setText (_translate ("main_window" , "New..." ))
553- self .action_open .setText (_translate ("main_window" , "Open..." ))
554- self .action_save .setText (_translate ("main_window" , "Save" ))
555- self .action_save_as .setText (_translate ("main_window" , "Save as..." ))
556536 self .action_matrix_text_file_txt .setText (_translate ("main_window" , "Text file (.txt)" ))
557537 self .action_matrix_json .setText (_translate ("main_window" , "JSON (.json)" ))
558538 self .action_matrix_tabler_csv .setText (_translate ("main_window" , "Tabler (.csv)" ))
@@ -575,6 +555,7 @@ def retranslate_ui(self, main_window):
575555 self .action_about_author .setText (_translate ("main_window" , "About lyl-Lynx" ))
576556 self .action_join_us .setText (_translate ("main_window" , "Join us on GitHub !" ))
577557
558+
578559if __name__ == "__main__" :
579560 app = QtWidgets .QApplication (sys .argv )
580561 window = QtWidgets .QMainWindow ()
0 commit comments