From c80bebe1f0579b5750a467daafe7e913d2c24e5a Mon Sep 17 00:00:00 2001 From: Valentin Korenjak Date: Fri, 27 Mar 2026 21:37:34 +0100 Subject: [PATCH] =?UTF-8?q?=C5=A0e=20malo=20=C5=A1minke=20(=C5=A1t.=20pesm?= =?UTF-8?q?i)=20in=209900=20za=20prikaz=20istega=20preko=20tipkovnice.=20#?= =?UTF-8?q?9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projector.py | 46 ++++++++++++++++++++++++++++++++++++++++++++ web/server.py | 7 +++++++ web/static/script.js | 5 +++++ 3 files changed, 58 insertions(+) diff --git a/projector.py b/projector.py index 333076c..b5a27f1 100755 --- a/projector.py +++ b/projector.py @@ -343,6 +343,9 @@ class SongProjector: elif self.song_number == "9901": self.update_songs_database() return + elif self.song_number == "9900": + self.show_app_info_tkinter() + return try: song_id = int(self.song_number) self.cursor.execute("SELECT lyrics FROM songs WHERE id=?", (song_id,)) @@ -717,6 +720,49 @@ class SongProjector: except Exception as e: print(f"Napaka pri pošiljanju ntfy obvestila: {e}") + # ------------------------------------------------------ + # Prikaži informacije o aplikaciji v Tkinter oknu + # ------------------------------------------------------ + def show_app_info_tkinter(self): + """Prikaže informacije o aplikaciji v glavnem oknu (ukaz 9900).""" + try: + with open('appinfo.json', 'r', encoding='utf-8') as f: + info = json.load(f) + + self.cursor.execute("SELECT COUNT(*) FROM songs") + count = self.cursor.fetchone()[0] + + authors = ", ".join(info.get("authors", [])) + + display_text = ( + f"{info.get('name', 'Projekcija')}\n" + f"Verzija: {info.get('version', 'neznana')}\n\n" + f"{info.get('description', '')}\n\n" + f"Avtorji: {authors}\n\n" + f"Število pesmi v bazi: {count}" + ) + + # Ponastavitev izgleda barvnega območja za prikaz informacij + self.color_frame.config(bg=self.settings["bg_color"], width=self.color_width, height=self.screen_height) + self.color_frame.place(relx=0.5, rely=0.5, anchor="center") + self.display_text.config(bg=self.settings["bg_color"], fg=self.settings["fg_color"], text=display_text) + self.display_text.pack(expand=True) + + # self.song_number_last = "9900" + self.song_info_label.config(text="Informacije o programu") + self.song_info_label.lift() + + self.pages = [] + self.current_page_index = 0 + self.waiting_for_song = True + + notify_clients() + + except Exception as e: + self.display_text.config(text=f"Napaka pri branju informacij: {e}") + finally: + self.song_number = "" + # ---------------------------------------------------------- # Zagon aplikacije # ---------------------------------------------------------- diff --git a/web/server.py b/web/server.py index 9ba3294..6441271 100644 --- a/web/server.py +++ b/web/server.py @@ -207,6 +207,13 @@ def get_app_info(): # appinfo.json je v korenskem imeniku projekta with open('appinfo.json', 'r', encoding='utf-8') as f: info = json.load(f) + + # Dodaj število pesmi v bazi + if _projector_app is not None: + _projector_app.cursor.execute("SELECT COUNT(*) FROM songs") + count = _projector_app.cursor.fetchone()[0] + info['song_count'] = count + return jsonify(info) except Exception as e: return jsonify({'error': str(e)}), 500 diff --git a/web/static/script.js b/web/static/script.js index a864c37..a5261cd 100644 --- a/web/static/script.js +++ b/web/static/script.js @@ -362,6 +362,11 @@ async function openAbout() { document.getElementById('about-name').textContent = data.name; document.getElementById('about-version').textContent = 'Verzija ' + data.version; document.getElementById('about-description').textContent = data.description; + + // Dodaj število pesmi + if (data.song_count !== undefined) { + document.getElementById('about-description').innerHTML += `

Število pesmi v bazi: ${data.song_count}`; + } const authorsList = document.getElementById('about-authors'); authorsList.innerHTML = '';