aboutsummaryrefslogtreecommitdiffstats
path: root/sb_builder/ui.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-20 12:13:00 +0200
committerDanilo M. <danix@danix.xyz>2026-10-20 12:13:00 +0200
commitd4cae7a87fd30341b5a936aa848e1fdc019a379e (patch)
tree4a8a21966595468046f1b39b345a49a03c76f25e /sb_builder/ui.py
parentc8306d6c87a40bb800241cccd90831e3893550b5 (diff)
downloadsb-builder-d4cae7a87fd30341b5a936aa848e1fdc019a379e.tar.gz
sb-builder-d4cae7a87fd30341b5a936aa848e1fdc019a379e.zip
One frame for every tab: ribbons of actions, next steps as dialogs
Tabs are permanent and load on first show. The ribbon shows the current tab's actions in workflow order, a small ribbon under it the view controls; inapplicable actions are disabled with the reason as tooltip. Starting a job stays on the tab; the Jobs tab reads (running), then shows the end status. When a preview this session started ends, its log opens with Run it (publish box) or Apply shadowing; Not now loses nothing, Run it in Jobs reopens it. New hint moves to the Packages ribbon and acts on the ticked packages without a hint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'sb_builder/ui.py')
-rw-r--r--sb_builder/ui.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/sb_builder/ui.py b/sb_builder/ui.py
new file mode 100644
index 0000000..087d1a7
--- /dev/null
+++ b/sb_builder/ui.py
@@ -0,0 +1,46 @@
+# sb-builder - ribbon actions
+# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+"""Ribbon actions shared by the tabs (UI guidelines in AGENTS.md).
+
+Each tab owns two lists of QActions: `actions` for the main ribbon (what it
+does, in workflow order) and `view_actions` for the small one (selection and
+view controls). The main window shows the current tab's lists.
+"""
+
+from PyQt6.QtGui import QAction, QIcon
+from PyQt6.QtWidgets import QStyle
+
+
+def action(parent, text, icon, fallback, slot=None, checkable=False, shortcut=None):
+ """A ribbon action: freedesktop icon with a QStyle fallback."""
+ a = QAction(QIcon.fromTheme(icon, parent.style().standardIcon(fallback)), text, parent,
+ checkable=checkable)
+ if slot:
+ a.triggered.connect(lambda _checked=False: slot())
+ a.setData(shortcut) # shown in the tooltip; the tab's QShortcut does the work
+ enable(a, None)
+ return a
+
+
+def enable(a, reason):
+ """Enable a, or disable it with reason as its tooltip: disabled, never hidden."""
+ a.setEnabled(not reason)
+ tip = a.text() + (f" ({a.data()})" if a.data() else "")
+ a.setToolTip(f"{tip}: {reason}" if reason else tip)
+
+
+SP = QStyle.StandardPixmap