From 5b5aa40d4727f5a1a8ef02f48db4179d9040c8c1 Mon Sep 17 00:00:00 2001 From: Jens Kallup Date: Mon, 8 Jul 2024 23:25:29 +0200 Subject: [PATCH] update --- src/_internal/img/open-folder-blue.png | Bin 0 -> 890 bytes src/_internal/img/open-folder-green.png | Bin 0 -> 894 bytes src/_internal/img/open-folder-yellow.png | Bin 0 -> 908 bytes src/favorites.ini | 3 + src/locales/en_us/LC_MESSAGES/observer.po | 12 + src/observer.py | 541 +++++++++++++++++++--- 6 files changed, 492 insertions(+), 64 deletions(-) create mode 100644 src/_internal/img/open-folder-blue.png create mode 100644 src/_internal/img/open-folder-green.png create mode 100644 src/_internal/img/open-folder-yellow.png diff --git a/src/_internal/img/open-folder-blue.png b/src/_internal/img/open-folder-blue.png new file mode 100644 index 0000000000000000000000000000000000000000..0a7501f40bbe28737d9a2a2d67f047dc754ac626 GIT binary patch literal 890 zcmV-=1BLvFP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf5dZ)S5dnW>Uy%R+0}n|=K~z{r?UqkS z6j2<DvG1Ra9t5@h#0Vb+C+9s=Q$UavQZ#uB8gyi(4txR!0- zQHv@*)KFlt=c;Bd&%7R$1}~wu1b+f9mRsEb;dhrOW>I8DQ#lLI^{h0D+I#_dYCEkx~F=gdos$LDfTJN%ak(ipZF7%jf&{5LJwn z0&JAAO)5$r`k2(@FmioX&d5lIgL)#iaJlUQvGZR#zAd`)wN z>8DXe$;hDd$pv5(7CxK-Q=Du6cq4uZWmVEg$t$Z!;)O&!KRQ|@z2Ul@Cq zR1YX4FCk}d4P+LS^M=Z`d}xzjKwli=jj26ZH-Hfs0DZm}oJTIAu}-k(Ilp-38~%2Z z)(sH$HGzHSQ4ovvp|OTGGX%@y-FzI>2a!5q0IK*w=N+6^otAYcO0cI9NT$Q%^$vDL z>VyHpeC%!cWnkZR42?BRc@jcHos8-7Jyh`nP%QxJL>s^R%Y3>dw^dk=pyw3`wk*FS z4RxT3A7FXR9qm|$s|JlVs3yZwe=DPUICA%N#l{K1sKy(`4bH>$K!i-R)>!)N25K6z zs>;o%qO2J}^|u2v6>uJ?Lt_zYz*1i`15Y4SBEw zjPR^!v$3bBVh9XuGShzVFSY6SV1`B^_fS0=i!jEgUK1mXH4YCC&!UaN*Mj{m#8G@U zx9Yygw>o^gbqBJFDGZTw5>Fhh+zdI%1*8a6@S!vl=qsTicBq_V)iMQCBvI2EZ^ zboyX6F-Q!xo=?4YRI7+xu(b5xR#6NWV3`(l-DVaRI(~XQ9v#&t{~G|m0G~xv^M_aY Qo&W#<07*qoM6N<$g0!xQtN;K2 literal 0 HcmV?d00001 diff --git a/src/_internal/img/open-folder-green.png b/src/_internal/img/open-folder-green.png new file mode 100644 index 0000000000000000000000000000000000000000..3d780d207ae8ca3e8dc5448dc362a3b3736416d3 GIT binary patch literal 894 zcmV-^1A+XBP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf5dZ)S5dnW>Uy%R+0~1L^K~z{r?Ur9i zQ&Akpf9K9!b!#n@28AHyoI@y|gd}^YhkDQ;sE48=45^p$r59i7p_j0F49Y(ViAugy ztgwgZ58+>OXofiFrea!BQ`GLg+x>S=XL=Y(ZqDuY=fMx$jo;^9cE0DHbAAlA_}8H5 zhuiJW)pgyzViJHcuLgr7pIK=LsIai;8X@QoA**3Fg6F`i675JJ5Ljj^El{DeNVs}9 z%X)kt&s2OQg+O)d4<#g$w()WQMW)jN6%@Eh<2ef)a+;Y+Oy8siRV^aH7*|Y8_+K)e zGMf$%<+>+~pMH#d*L0{s2oa_ez|j>O9c0BCQVJl_r8wIp%F_#KQu{{II36LW4Fr63 zOvOkkz-GDkPKKs#d1}Nrx`(M49Q*#GIBW=XjI&s|hQAUZ5lJt>f`sAgViNmp9bWk~ zXzr5c70exDY6X)CFC-NJ({U^A3o!XjXT}&zCRj=;z?(4@u5?IH)9C=)P7|}KLulJ= zI29tHX{|n~J>`HOqZ%B%WMd|M-q#Dj^Tjrp6U%jXSl%6)`=wbR>{f`6^iQwBaGc#ePSNJUeZBo!ok4fnn3uJFM zX7)oK36|$IJtKoWU@8V@LReV(CDU8K3ezDS$}VhUCOx7P>S+`R06*{v8TFRwVqmW|sL z3`e8&sx}Tj6P6X3oTo?6!_*pL1Lo(K?BIDRhn0q)su_B2uH}o@>s6WB;(r6+C(8R( U^{;?S0RR9107*qoM6N<$g8P$@K>z>% literal 0 HcmV?d00001 diff --git a/src/_internal/img/open-folder-yellow.png b/src/_internal/img/open-folder-yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..2989d510986202a8fd60deb00c6106cb0c878dac GIT binary patch literal 908 zcmV;719SX|P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf5dZ)S5dnW>Uy%R+10hL7K~z{r?U!pv zQ(+j#|K~W}nnyRgE3y>^*~PXAL3A^-APkYPLV`-PMuMNRjBXS}IqFLvg2-D15nZq( zj50GT=tJ1e{LqCybRn_}y6sFop3QSQ&4-4l+uRxLOTWWmJii^z{x9#@`<{o96%a#M z`ivPd58$5yr_%|Z=Shu^MiYgp3@)e*-f8jfz*p~ajm4Y*_`=xLn7!aSG3Sw|NZ zEy}{IS!TLT{NZr?#BKtus1%GEQ2=(sZ#_gY%X1o$WGK+1Fmf*?>elGraq z;ZA|ON5ao4KTYY$RLx}A5!$IH=uFGVsAI^}jlTCSD7Wt<6C?odl+o7cQ%1i_ zSuH|uIN{)aei3QuX~@l8MJ7mqyO%{US_AZ%`DD}~i5?8Rx#k}|%LaaS%m7|dM)M^J zdP^x7HaeRW-+2X-bO|UdEFd$?m;u_Gyvml#A}MP#8I?#r40K&YS;;o&bUKp5j0*6l zOK574pr6bqT_|n`mvhjr8<% z`X&I=+v}9~R_(#V_9sf%=yz#`$wr*4K90P+)nrEUw>NaVdAM9ozl;_v8;2P)rYjAN ihRkUGH>WWU0Q?5KUKMhX%||c*0000 in the widget list. + # if it present, then return True; else False... + # ----------------------------------------------- + def isItemInList(self, text): + for index in range(self.list_widget.count()): + if self.list_widget.item(index).text() == text: + return True + return False + + # ----------------------------------------------- + # dialog, to open a new project file ... + # ----------------------------------------------- + def pro_open_clicked(self): + options = QFileDialog.Options() + options |= QFileDialog.DontUseNativeDialog + file_path, file_pattern = QFileDialog.getOpenFileName(self, + "Open File", "", + "All Files (*);;Project Files (*.pro)", + options=options) + self.hlay_edit.setText(file_path) + + # ----------------------------------------------- + # close the current opened project file ... + # ----------------------------------------------- + def pro_close_clicked(self): + self.list_widget.clear() + self.hlay_edit.setText("") + return + def pro_new_clicked(self): + return + + # ----------------------------------------------- + # add project file name to favorite list ... + # ----------------------------------------------- + def fav_add_clicked(self): + txt = self.hlay_edit.text() + if len(txt.strip()) > 0: + if not self.isItemInList(txt): + if txt.endswith(".pro"): + if os.path.exists(txt): + item = QListWidgetItem(self.icon, txt) + self.list_widget.addItem(item) + else: + msg = QMessageBox() + msg.setWindowTitle("Information") + msg.setFont(self.font) + msg.setText( + "File can not add to Favorite list.\n" + "Either, you have no access permission's. Or it was deleted.\n" + "Command aborted.") + msg.setIcon(QMessageBox.Information) + + btn_ok = msg.addButton(QMessageBox.Ok) + btn_ok.setFont(self.font) + + msg.setStyleSheet(_("msgbox_css")) + result = msg.exec_() + else: + msg = QMessageBox() + msg.setWindowTitle("Information") + msg.setFont(self.font) + msg.setText( + "Project files must be end with .pro extension.\n" + "Command aborted.") + msg.setIcon(QMessageBox.Information) + + btn_ok = msg.addButton(QMessageBox.Ok) + btn_ok.setFont(self.font) + + msg.setStyleSheet(_("msgbox_css")) + result = msg.exec_() + else: + msg = QMessageBox() + msg.setWindowTitle("Information") + msg.setFont(self.font) + msg.setText( + "No item is already in the Favorite list.\n" + "Command aborted.") + msg.setIcon(QMessageBox.Information) + + btn_ok = msg.addButton(QMessageBox.Ok) + btn_ok.setFont(self.font) + + msg.setStyleSheet(_("msgbox_css")) + result = msg.exec_() + else: + msg = QMessageBox() + msg.setWindowTitle("Information") + msg.setFont(self.font) + msg.setText( + "No text available for adding into the Favorite list.\n" + "Command aborted.") + msg.setIcon(QMessageBox.Information) + + btn_ok = msg.addButton(QMessageBox.Ok) + btn_ok.setFont(self.font) + + msg.setStyleSheet(_("msgbox_css")) + result = msg.exec_() + return + + # ----------------------------------------------- + # delete selected favorite from the given list... + # ----------------------------------------------- + def fav_del_clicked(self): + selected_items = self.list_widget.selectedItems() + if selected_items: + selected_item = selected_items[0] + self.list_widget.takeItem(self.list_widget.row(selected_item)) + else: + msg = QMessageBox() + msg.setWindowTitle("Information") + msg.setFont(self.font) + msg.setText( + "No item is selected in the Favorite list.\n" + "Command aborted.") + msg.setIcon(QMessageBox.Information) + + btn_ok = msg.addButton(QMessageBox.Ok) + btn_ok.setFont(self.font) + + msg.setStyleSheet(_("msgbox_css")) + result = msg.exec_() + return + + def path_push_clicked(self): + if len(self.hlay_edit.text().split()) < 1: + msg = QMessageBox() + msg.setWindowTitle("Information") + msg.setFont(self.font) + msg.setText( + "You must open a Project before you can add Element's\n" + "Command aborted.") + msg.setIcon(QMessageBox.Information) + + btn_ok = msg.addButton(QMessageBox.Ok) + btn_ok.setFont(self.font) + + msg.setStyleSheet(_("msgbox_css")) + result = msg.exec_() + return + old_text = self.path_edit.text() + if self.selected_item == None: + msg = QMessageBox() + msg.setWindowTitle("Information") + msg.setFont(self.font) + msg.setText( + "No project file section selected.\n" + "Command aborted.") + msg.setIcon(QMessageBox.Information) + + btn_ok = msg.addButton(QMessageBox.Ok) + btn_ok.setFont(self.font) + + msg.setStyleSheet(_("msgbox_css")) + result = msg.exec_() + self.path_edit.setText(old_text) + return + new_text = QFileDialog.getExistingDirectory(self, "Select Folder:") + if len(new_text.strip()) > 0: + if not os.path.isdir(new_text): + self.path_edit.setText(new_text) + msg = QMessageBox() + msg.setWindowTitle("Information") + msg.setFont(self.font) + msg.setText( + f"Path for Component: {new_text} could not be set.\n" + "Not a directory.\n" + "aborted.") + msg.setIcon(QMessageBox.Information) + + btn_ok = msg.addButton(QMessageBox.Ok) + btn_ok.setFont(self.font) + + msg.setStyleSheet(_("msgbox_css")) + result = msg.exec_() + return + try: + path_name = "@" + if self.selected_item: + print("ok") + if self.selected_item == "Form": + path_name = genv.v__app__config.get("dBaseProject", "Form") + elif self.selected_item == "Report": + path_name = genv.v__app__config.get("dBaseProject", "Report") + elif self.selected_item == "Program": + path_name = genv.v__app__config.get("dBaseProject", "Program") + elif self.selected_item == "Desktop Tables": + path_name = genv.v__app__config.get("dBaseProject", "DeskTable") + elif self.selected_item == "SQL": + path_name = genv.v__app__config.get("dBaseProject", "SQL") + elif self.selected_item == "Image": + path_name = genv.v__app__config.get("dBaseProject", "Image") + elif self.selected_item == "Other": + path_name = genv.v__app__config.get("dBaseProject", "Other") + # + print(path_name) + self.path_edit.setText(path_name) + except Exception as e: + print(f"text error: {e}") + pass + self.path_edit.setText(new_text) + else: + msg = QMessageBox() + msg.setWindowTitle("Information") + msg.setFont(self.font) + msg.setText( + "Something went wrong during selecting folder.\n" + "set old value...\n" + "Command aborted.") + msg.setIcon(QMessageBox.Information) + + btn_ok = msg.addButton(QMessageBox.Ok) + btn_ok.setFont(self.font) + + msg.setStyleSheet(_("msgbox_css")) + result = msg.exec_() + self.path_edit.setText(old_text) + return + + # ----------------------------------------------- + # setup project file items list ... + # ----------------------------------------------- def populate_tree(self): - model = QStandardItemModel() - root_node = model.invisibleRootItem() + root_node = self.model.invisibleRootItem() font1 = QFont(genv.v__app__font, 12) font1.setBold(True) @@ -6604,29 +6943,40 @@ def populate_tree(self): font2.setBold(True) font2.setItalic(True) + icon1 = QIcon(os.path.join(genv.v__app__img__int__, "open-folder-blue.png")) + icon2 = QIcon(os.path.join(genv.v__app__img__int__, "open-folder-yellow.png")) + parent_item = QStandardItem("Project Files") parent_item.setFont(font1) + parent_item.setIcon(icon1) child_item_1 = QStandardItem("Form") child_item_1.setFont(font2) + child_item_1.setIcon(icon2) child_item_2 = QStandardItem("Report") child_item_2.setFont(font2) + child_item_2.setIcon(icon2) child_item_3 = QStandardItem("Program") child_item_3.setFont(font2) + child_item_3.setIcon(icon2) child_item_4 = QStandardItem("Desktop Tables") child_item_4.setFont(font2) + child_item_4.setIcon(icon2) child_item_5 = QStandardItem("SQL") child_item_5.setFont(font2) + child_item_5.setIcon(icon2) child_item_6 = QStandardItem("Image") child_item_6.setFont(font2) + child_item_6.setIcon(icon2) child_item_7 = QStandardItem("Other") child_item_7.setFont(font2) + child_item_7.setIcon(icon2) # parent_item.appendRow(child_item_1) parent_item.appendRow(child_item_2) @@ -6637,10 +6987,73 @@ def populate_tree(self): parent_item.appendRow(child_item_7) root_node.appendRow(parent_item) - self.tree_view.setModel(model) - - self.expand_all_items(self.tree_view, model.indexFromItem(model.invisibleRootItem())) + self.tree_view.setModel(self.model) + + self.expand_all_items( + self.tree_view, + self.model.indexFromItem( + self.model.invisibleRootItem())) + + # ----------------------------------------------- + # get the item selected from the file item list. + # ----------------------------------------------- + def on_item_clicked(self, index): + item = self.model.itemFromIndex(index) + self.selected_item = item + if not item == None: + parent_item = item.parent() + if not parent_item == None: + if parent_item.text() == "Project Files": + if item.text() == "Form": + print("form direct") + return + elif item.text() == "Report": + print("report direct") + return + elif item.text() == "Program": + print("program direct") + return + elif item.text() == "Desktop Tables": + print("desktop tables direct") + return + elif item.text() == "SQL": + print("sql direct") + return + elif item.text() == "Image": + print("image direct") + return + elif item.text() == "Other": + print("other direct") + return + elif parent_item.text() == "Form": + print("form direct 1") + return + elif parent_item.text() == "Report": + print("report direct 1") + return + elif parent_item.text() == "Program": + print("program direct 1") + return + elif parent_item.text() == "Desktop Tables": + print("deskt tables direct 1") + return + elif parent_item.text() == "SQL": + print("sql direct") + return + elif parent_item.text() == "Image": + print("image direct 1") + return + elif item.text() == "Other": + print("other direct 1") + return + else: + if item.text() == "Project Files": + print("project files 11") + return + # ----------------------------------------------- + # expand all items in the tree view ... + # ----------------------------------------------- def expand_all_items(self, tree_view, index): tree_view.expand(index) model = tree_view.model()