File: boolean.py

package info (click to toggle)
setools 4.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,600 kB
  • sloc: python: 24,485; makefile: 14
file content (35 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# SPDX-License-Identifier: LGPL-2.1-only

from PyQt6 import QtGui, QtWidgets
import setools

from . import util

__all__ = ('boolean_detail', 'boolean_detail_action', 'boolean_tooltip')


def boolean_detail(boolean: setools.Boolean, parent: QtWidgets.QWidget | None = None) -> None:
    """Display a dialog with Boolean details."""

    util.display_object_details(
        f"{boolean} Details",
        f"""
        <h1>Boolean Name</h1>
        <p>{boolean}<p>

        <p><b>Default state: {boolean.state}</b></p>
        """,
        parent)


def boolean_detail_action(boolean: setools.Boolean,
                          parent: QtWidgets.QWidget | None = None) -> QtGui.QAction:
    """Return a QAction that, when triggered, opens a Boolean detail popup."""
    a = QtGui.QAction(f"Properties of {boolean}")
    a.triggered.connect(lambda x: boolean_detail(boolean, parent))
    return a


def boolean_tooltip(boolean: setools.Boolean) -> str:
    """Return tooltip text for this Boolean."""
    return f"{boolean} is a Boolean with {boolean.state} default state."