From d4cae7a87fd30341b5a936aa848e1fdc019a379e Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 20 Oct 2026 12:13:00 +0200 Subject: 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 --- sb_builder/ui.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sb_builder/ui.py (limited to 'sb_builder/ui.py') 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. +# +# 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 -- cgit v1.2.3