summaryrefslogtreecommitdiffstats
path: root/ui/main_window.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-05-03 10:42:30 +0200
committerDanilo M. <danix@danix.xyz>2026-05-03 10:42:30 +0200
commit8263e7374d2c81ed0a64481a978d6e7157016b08 (patch)
tree977c3f46ae4b0f25a2f449b86faa12889e38ba63 /ui/main_window.py
parent1786c672753a74b876f415dd5f32742c0e24f8c9 (diff)
downloadpublisher-8263e7374d2c81ed0a64481a978d6e7157016b08.tar.gz
publisher-8263e7374d2c81ed0a64481a978d6e7157016b08.zip
feat: git view with status, pull/push, and deleted article restore
Diffstat (limited to 'ui/main_window.py')
-rw-r--r--ui/main_window.py34
1 files changed, 31 insertions, 3 deletions
diff --git a/ui/main_window.py b/ui/main_window.py
index 4073591..ad7134f 100644
--- a/ui/main_window.py
+++ b/ui/main_window.py
@@ -91,8 +91,15 @@ class MainWindow(QMainWindow):
self._stack.addWidget(self._translation_view)
self._page_translations = self._stack.count() - 1
+ from ui.git_view import GitView
+
+ self._git_view = GitView(Path(self.config.blog_repo), parent=self)
+ self._git_view.refresh_needed.connect(self._refresh_articles)
+ self._stack.addWidget(self._git_view)
+ self._page_git = self._stack.count() - 1
+
# Remaining placeholders
- for name in ["taxonomy", "media", "git", "hugo"]:
+ for name in ["taxonomy", "media", "hugo"]:
w = QLabel(f"[{name}]")
w.setAlignment(Qt.AlignmentFlag.AlignCenter)
self._stack.addWidget(w)
@@ -205,10 +212,31 @@ class MainWindow(QMainWindow):
self._stack.setCurrentIndex(self._page_translations)
def _do_git_push(self, branch: str):
- pass # implemented in Task 16
+ from workers.git_worker import GitWorker
+ repo = Path(self.config.blog_repo)
+ if branch == "master":
+ worker = GitWorker.push_master(repo, self)
+ else:
+ worker = GitWorker.push_production(repo, self)
+ worker.error.connect(lambda e: self.statusBar().showMessage(f"Git error: {e}", 5000))
+ worker.finished.connect(lambda ok: self.statusBar().showMessage("Push completato." if ok else "Push fallito.", 4000))
+ worker.start()
def _do_delete_article(self, article: Article):
- pass # implemented in Task 16
+ from PyQt6.QtWidgets import QMessageBox
+ from workers.git_worker import GitWorker
+ reply = QMessageBox.question(
+ self, "Elimina articolo",
+ f"Eliminare '{article.slug}' ({article.lang})? L'operazione sarà tracciata in git.",
+ )
+ if reply == QMessageBox.StandardButton.Yes:
+ rel = str(article.path.parent.relative_to(Path(self.config.blog_repo)))
+ worker = GitWorker.remove_article(
+ Path(self.config.blog_repo), rel, article.slug, article.lang, self
+ )
+ worker.error.connect(lambda e: self.statusBar().showMessage(f"Errore: {e}", 5000))
+ worker.finished.connect(lambda ok: self._refresh_articles() if ok else None)
+ worker.start()
def _setup_watcher(self):
if not self.config.blog_repo: