Example #1
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     l = QVBoxLayout(parent)
     l.addWidget(self)
     l.setContentsMargins(0, 0, 0, 0)
     l = QFormLayout(self)
     l.setContentsMargins(0, 0, 0, 0)
     l.setFieldGrowthPolicy(l.AllNonFixedFieldsGrow)
     self.choices = c = QComboBox()
     c.setMinimumContentsLength(30)
     for text, data in [
             (_('Search for the author on Goodreads'), 'search-goodreads'),
             (_('Search for the author on Amazon'), 'search-amzn'),
             (_('Search for the author in your calibre library'), 'search-calibre'),
             (_('Search for the author on Wikipedia'), 'search-wikipedia'),
             (_('Search for the author on Google Books'), 'search-google'),
             (_('Search for the book on Goodreads'), 'search-goodreads-book'),
             (_('Search for the book on Amazon'), 'search-amzn-book'),
             (_('Search for the book on Google Books'), 'search-google-book'),
             (_('Use a custom search URL'), 'url'),
     ]:
         c.addItem(text, data)
     l.addRow(_('Clicking on &author names should:'), c)
     self.custom_url = u = QLineEdit(self)
     u.textChanged.connect(self.changed_signal)
     u.setPlaceholderText(_('Enter the URL'))
     c.currentIndexChanged.connect(self.current_changed)
     l.addRow(u)
     self.current_changed()
     c.currentIndexChanged.connect(self.changed_signal)
    def initialize(self, spy_widget):
        """
        Initialize QWidget and set SpyQWidget

        :param spy_widget: instance of SpyQWidget to manage spy events
        :type spy_widget: alignak_app.qobjects.events.spy.SpyQWidget
        """

        problem_layout = QVBoxLayout()
        problem_layout.setContentsMargins(5, 20, 5, 5)
        self.setLayout(problem_layout)

        self.spy_widget = spy_widget

        self.problems_title.setObjectName('title')
        problem_layout.addWidget(self.problems_title)

        problem_layout.addWidget(self.get_search_widget())

        problem_layout.addWidget(self.get_btn_widget())

        problem_layout.addWidget(self.problems_table)

        self.update_problems_data()

        update_problems = int(settings.get_config('Alignak-app', 'update_problems')) * 1000
        self.refresh_timer.setInterval(update_problems)
        self.refresh_timer.start()
        self.refresh_timer.timeout.connect(self.update_problems_data)
Example #3
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     l = QVBoxLayout(parent)
     l.addWidget(self)
     l.setContentsMargins(0, 0, 0, 0)
     l = QFormLayout(self)
     l.setContentsMargins(0, 0, 0, 0)
     l.setFieldGrowthPolicy(l.AllNonFixedFieldsGrow)
     self.choices = c = QComboBox()
     c.setMinimumContentsLength(30)
     for text, data in [
         (_('Search for the author on Goodreads'), 'search-goodreads'),
         (_('Search for the author on Amazon'), 'search-amzn'),
         (_('Search for the author in your calibre library'),
          'search-calibre'),
         (_('Search for the author on Wikipedia'), 'search-wikipedia'),
         (_('Search for the author on Google Books'), 'search-google'),
         (_('Search for the book on Goodreads'), 'search-goodreads-book'),
         (_('Search for the book on Amazon'), 'search-amzn-book'),
         (_('Search for the book on Google Books'), 'search-google-book'),
         (_('Use a custom search URL'), 'url'),
     ]:
         c.addItem(text, data)
     l.addRow(_('Clicking on &author names should:'), c)
     self.custom_url = u = QLineEdit(self)
     u.textChanged.connect(self.changed_signal)
     u.setPlaceholderText(_('Enter the URL'))
     c.currentIndexChanged.connect(self.current_changed)
     l.addRow(u)
     self.current_changed()
     c.currentIndexChanged.connect(self.changed_signal)
Example #4
0
    def __init__(self,
                 parent: TWidget,
                 file_path=None,
                 text_format="HTML",
                 highlighter="",
                 func_after_save=None,
                 spell=None):
        super(TabEdit, self).__init__()

        self._editor = TextEditor(parent,
                                  parent.cfg,
                                  show_status_bar=True,
                                  show_tool_bar=True,
                                  format=text_format,
                                  load=self._load,
                                  save=self._save,
                                  spell=spell)
        self._editor.enabled_save_signal.connect(self.set_enabled_save)
        self._func_after_save = func_after_save
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)
        layout.addWidget(self._editor, alignment=Qt.Alignment())

        self._parent = parent
        self._file_path = file_path
        self._text_format = text_format.upper()
        name = "HTML" if text_format.upper() == "HTML" else "TEXT"
        self._prev_text_format = name
        self._highlighter = highlighter
        self._is_modified = False
        self._editor.set_option(highlighter=highlighter)
        self._editor.load()
Example #5
0
    def initialize(self):
        """
        Initialize History QWidget

        """

        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)

        # Title Window
        main_layout.addWidget(get_logo_widget(self, _('History')))

        # History QWidget
        history_widget = QWidget()
        history_layout = QVBoxLayout(history_widget)

        # History QTableWidget
        self.history_table.setObjectName('history')
        self.history_table.verticalHeader().hide()
        self.history_table.verticalHeader().setDefaultSectionSize(100)
        self.history_table.setColumnCount(len(self.table_headers))
        self.history_table.setColumnWidth(0, 600)
        self.history_table.setSortingEnabled(True)
        self.history_table.setHorizontalScrollMode(QAbstractItemView.ScrollPerItem)
        self.history_table.setHorizontalHeaderLabels(self.table_headers)
        self.history_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.history_table.horizontalHeader().setStretchLastSection(True)
        self.history_table.horizontalHeader().setMinimumHeight(30)
        history_layout.addWidget(self.history_table)

        main_layout.addWidget(history_widget)

        center_widget(self)
Example #6
0
        def run(self, *args, **kwargs):
            """Create & show dialog

            Args:
                onClose(accepted): Function to run on close. Defaults to None.
            """
            dlg = QDialog()
            dlg.setWindowFlags(dlg.windowFlags()
                               & ~Qt.WindowContextHelpButtonHint)
            dlg.setWindowTitle(title)

            layout = QVBoxLayout()
            layout.setContentsMargins(10, 10, 10, 10)
            self.layout = layout
            dlg.setLayout(layout)

            pushQDlgStack(self)
            self.constructor(dlg, *args, **kwargs)
            popQDlgStack(self)

            dlg.setWindowModality(Qt.WindowModal)
            if size:
                dlg.resize(size[0], size[1])
            dlg.show()
            return dlg.exec_() == QDialog.Accepted
Example #7
0
class IntroWidget(QWidget):
    def __init__(self, gui):
        QWidget.__init__(self, gui)

        self.l = QVBoxLayout()
        self.l.setContentsMargins(0, 0, 0, 0)
        self.l.addWidget(
            QLabel('''
            <h2 style="text-align: center">
                Your Own eBooks in the Cloud and on Your Devices<br>
                Anytime, Anywhere &amp; on Any Device
            </h2>
            <p>
                BookFusion is an eBook platform that allows you to manage, upload, read,<br>
                share, organization bookmarks, and sync all your books.
            </p>
            <ul>
                <li>Organize your eBook library</li>
                <li>Sync reading progress, bookmarks, highlights and notes<br>across all devices</li>
                <li>Read both offline and online</li>
                <li>Supports popular eBook formats</li>
                <li>Web and Native Android &amp; iOS apps</li>
                <li>Many more features</li>
            </ul>
            <p></p>
        '''))
        self.setLayout(self.l)
    def initialize(self):
        """
        Initialize User QWidget

        """

        main_layout = QVBoxLayout(self)
        self.setLayout(main_layout)
        main_layout.setContentsMargins(0, 0, 0, 0)

        main_layout.addWidget(get_logo_widget(self, _('User View')))

        user_widget = QWidget(self)
        user_layout = QGridLayout(user_widget)

        user_title = QLabel(_('User informations:'))
        user_title.setObjectName('itemtitle')
        user_layout.addWidget(user_title, 0, 0, 1, 2)
        user_layout.setAlignment(user_title, Qt.AlignCenter)

        # User QWidgets
        user_layout.addWidget(self.get_informations_widget(), 1, 0, 1, 1)
        user_layout.addWidget(self.get_notes_mail_widget(), 1, 1, 1, 1)
        user_layout.addWidget(self.get_notifications_widget(), 2, 0, 1, 2)

        main_layout.addWidget(user_widget)
        center_widget(self)
Example #9
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     l = QVBoxLayout(parent)
     l.addWidget(self)
     l.setContentsMargins(0, 0, 0, 0)
     l = QFormLayout(self)
     l.setContentsMargins(0, 0, 0, 0)
     l.setFieldGrowthPolicy(l.AllNonFixedFieldsGrow)
     self.choices = c = QComboBox()
     c.setMinimumContentsLength(30)
     for text, data in [
             (_('Search for the author on Goodreads'), 'search-goodreads'),
             (_('Search for the author on Amazon'), 'search-amzn'),
             (_('Search for the author in your calibre library'), 'search-calibre'),
             (_('Search for the author on Wikipedia'), 'search-wikipedia'),
             (_('Search for the author on Google Books'), 'search-google'),
             (_('Search for the book on Goodreads'), 'search-goodreads-book'),
             (_('Search for the book on Amazon'), 'search-amzn-book'),
             (_('Search for the book on Google Books'), 'search-google-book'),
             (_('Use a custom search URL'), 'url'),
     ]:
         c.addItem(text, data)
     l.addRow(_('Clicking on &author names should:'), c)
     self.custom_url = u = QLineEdit(self)
     u.setToolTip(_(
         'Enter the URL to search. It should contain the string {0}'
         '\nwhich will be replaced by the author name. For example,'
         '\n{1}').format('{author}', 'https://en.wikipedia.org/w/index.php?search={author}'))
     u.textChanged.connect(self.changed_signal)
     u.setPlaceholderText(_('Enter the URL'))
     c.currentIndexChanged.connect(self.current_changed)
     l.addRow(u)
     self.current_changed()
     c.currentIndexChanged.connect(self.changed_signal)
Example #10
0
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags(), caption="Select Tags", ok_button="Select"):
     QDialog.__init__(self, parent, flags)
     self.setModal(modal)
     self.setWindowTitle(caption)
     lo = QVBoxLayout(self)
     lo.setContentsMargins(10, 10, 10, 10)
     lo.setSpacing(5)
     # tag selector
     self.wtagsel = QListWidget(self)
     lo.addWidget(self.wtagsel)
     #    self.wtagsel.setColumnMode(QListBox.FitToWidth)
     self.wtagsel.setSelectionMode(QListWidget.MultiSelection)
     self.wtagsel.itemSelectionChanged.connect(self._check_tag)
     # buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setContentsMargins(5, 5, 5, 5)
     self.wokbtn = QPushButton(ok_button, self)
     self.wokbtn.setMinimumWidth(128)
     self.wokbtn.clicked.connect(self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     cancelbtn.clicked.connect(self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     self._tagnames = []
Example #11
0
 def beginVertical(self, **options):
     widget = QWidget()
     v = QVBoxLayout()
     v.setContentsMargins(*options.get("contentMargin", (0, 0, 0, 0)))
     widget.setLayout(v)
     self.layoutStack[-1].addWidget(widget)
     self.layoutStack.append(v)
    def initialize(self):
        """
        Intialize QWidget

        """

        self.timer.setInterval(30000)
        self.timer.start()
        self.timer.timeout.connect(self.send_datamanager_events)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        self.events_list.setDragDropMode(QAbstractItemView.DragOnly)
        self.events_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.events_list.setDropIndicatorShown(True)
        self.events_list.doubleClicked.connect(self.remove_event)
        self.events_list.setWordWrap(True)
        self.events_list.setIconSize(QSize(16, 16))

        self.add_event(
            'OK',
            _('Welcome %s, you are connected to Alignak Backend') %
            data_manager.database['user'].name,
            timer=True
        )

        layout.addWidget(self.events_list)
def createCalibrationControls():
    gb = QGroupBox("Calibration")

    #------------------------------------------
    layout = QGridLayout()

    arduino = createArduinoCalibrationControls()
    pc = createPcCalibrationControls()
    gui = createGuiCalibration()

    layout.addWidget(arduino, 0, 0, 1, 1)
    layout.addWidget(pc, 1, 0, 1, 1)
    layout.addWidget(gui, 0, 1, 2, 1)

    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(5)

    upper = QWidget()
    upper.setLayout(layout)

    #------------------------------------------

    vbox = QVBoxLayout()

    vbox.addWidget(upper)
    vbox.addStretch(1)

    vbox.setContentsMargins(0, 0, 0, 0)
    vbox.setSpacing(0)

    gb.setLayout(vbox)
    return gb
    def initialize(self, title, text):
        """
        Initialize QDialog for UserNotesQDialog

        :param title: title of the QDialog
        :type title: str
        :param text: text to edit
        :type text: str
        """

        self.old_text = text
        center_widget(self)

        # Main status_layout
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        main_layout.addWidget(get_logo_widget(self, title))

        text_title = QLabel(_("Edit your text:"))
        text_title.setObjectName('subtitle')
        main_layout.addWidget(text_title)
        main_layout.setAlignment(text_title, Qt.AlignCenter)

        main_layout.addWidget(self.get_text_widget())
Example #15
0
    def __init__(self, parent):
        orientation = Qt.Vertical
        if config['gui_layout'] == 'narrow':
            orientation = Qt.Horizontal if is_widescreen() else Qt.Vertical
        idx = 0 if orientation == Qt.Vertical else 1
        size = 300 if orientation == Qt.Vertical else 550
        Splitter.__init__(self, 'cover_browser_splitter', _('Cover browser'),
                I('cover_flow.png'),
                orientation=orientation, parent=parent,
                connect_button=not config['separate_cover_flow'],
                side_index=idx, initial_side_size=size, initial_show=False,
                shortcut='Shift+Alt+B')

        quickview_widget = QWidget()
        parent.quickview_splitter = QuickviewSplitter(
                parent=self, orientation=Qt.Vertical, qv_widget=quickview_widget)
        parent.library_view = BooksView(parent)
        parent.library_view.setObjectName('library_view')
        stack = QStackedWidget(self)
        av = parent.library_view.alternate_views
        parent.pin_container = av.set_stack(stack)
        parent.grid_view = GridView(parent)
        parent.grid_view.setObjectName('grid_view')
        av.add_view('grid', parent.grid_view)
        parent.quickview_splitter.addWidget(stack)

        l = QVBoxLayout()
        l.setContentsMargins(4, 0, 0, 0)
        quickview_widget.setLayout(l)
        parent.quickview_splitter.addWidget(quickview_widget)
        parent.quickview_splitter.hide_quickview_widget()

        self.addWidget(parent.quickview_splitter)
def createSpeedControls():
    speed_gb = QGroupBox("Speed")
    speed_gb.setMaximumWidth(50)

    layout = QVBoxLayout()
    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(0)

    speed1_btn = QPushButton("1")
    speed2_btn = QPushButton("2")
    speed3_btn = QPushButton("3")
    speed4_btn = QPushButton("4")
    speed5_btn = QPushButton("5")
    speed6_btn = QPushButton("6")

    speed1_btn.clicked.connect(lambda: send_cmd(["1"]))
    speed2_btn.clicked.connect(lambda: send_cmd(["2"]))
    speed3_btn.clicked.connect(lambda: send_cmd(["3"]))
    speed4_btn.clicked.connect(lambda: send_cmd(["4"]))
    speed5_btn.clicked.connect(lambda: send_cmd(["5"]))
    speed6_btn.clicked.connect(lambda: send_cmd(["6"]))

    layout.addWidget(speed1_btn)
    layout.addWidget(speed2_btn)
    layout.addWidget(speed3_btn)
    layout.addWidget(speed4_btn)
    layout.addWidget(speed5_btn)
    layout.addWidget(speed6_btn)
    layout.addStretch(1)

    speed_gb.setLayout(layout)

    return speed_gb
    def initialize(self):
        """
        Intialize QWidget

        """

        self.timer.setInterval(30000)
        self.timer.start()
        self.timer.timeout.connect(self.send_datamanager_events)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        self.events_list.setDragDropMode(QAbstractItemView.DragOnly)
        self.events_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.events_list.setDropIndicatorShown(True)
        self.events_list.doubleClicked.connect(self.remove_event)
        self.events_list.setWordWrap(True)
        self.events_list.setIconSize(QSize(16, 16))

        self.add_event('OK',
                       _('Welcome %s, you are connected to Alignak Backend') %
                       data_manager.database['user'].name,
                       timer=True)

        layout.addWidget(self.events_list)
Example #18
0
    def __init__(self, parent):
        orientation = Qt.Vertical
        if config['gui_layout'] == 'narrow':
            orientation = Qt.Horizontal if is_widescreen() else Qt.Vertical
        idx = 0 if orientation == Qt.Vertical else 1
        size = 300 if orientation == Qt.Vertical else 550
        Splitter.__init__(self, 'cover_browser_splitter', _('Cover browser'),
                I('cover_flow.png'),
                orientation=orientation, parent=parent,
                connect_button=not config['separate_cover_flow'],
                side_index=idx, initial_side_size=size, initial_show=False,
                shortcut='Shift+Alt+B')

        quickview_widget = QWidget()
        parent.quickview_splitter = QuickviewSplitter(
                parent=self, orientation=Qt.Vertical, qv_widget=quickview_widget)
        parent.library_view = BooksView(parent)
        parent.library_view.setObjectName('library_view')
        stack = QStackedWidget(self)
        av = parent.library_view.alternate_views
        av.set_stack(stack)
        parent.grid_view = GridView(parent)
        parent.grid_view.setObjectName('grid_view')
        av.add_view('grid', parent.grid_view)
        parent.quickview_splitter.addWidget(stack)

        l = QVBoxLayout()
        l.setContentsMargins(4, 0, 0, 0)
        quickview_widget.setLayout(l)
        parent.quickview_splitter.addWidget(quickview_widget)
        parent.quickview_splitter.hide_quickview_widget()

        self.addWidget(parent.quickview_splitter)
    def initialize(self, spy_widget):
        """
        Initialize QWidget and set SpyQWidget

        :param spy_widget: instance of SpyQWidget to manage spy events
        :type spy_widget: alignak_app.qobjects.events.spy.SpyQWidget
        """

        problem_layout = QVBoxLayout()
        problem_layout.setContentsMargins(5, 20, 5, 5)
        self.setLayout(problem_layout)

        self.spy_widget = spy_widget

        self.problems_title.setObjectName('title')
        problem_layout.addWidget(self.problems_title)

        problem_layout.addWidget(self.get_search_widget())

        problem_layout.addWidget(self.get_btn_widget())

        problem_layout.addWidget(self.problems_table)

        self.update_problems_data()

        update_problems = int(
            settings.get_config('Alignak-app', 'update_problems')) * 1000
        self.refresh_timer.setInterval(update_problems)
        self.refresh_timer.start()
        self.refresh_timer.timeout.connect(self.update_problems_data)
    def initialize(self, title, text):
        """
        Initialize QDialog for UserNotesQDialog

        :param title: title of the QDialog
        :type title: str
        :param text: text to edit
        :type text: str
        """

        self.old_text = text
        center_widget(self)

        # Main status_layout
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        main_layout.addWidget(get_logo_widget(self, title))

        text_title = QLabel(_("Edit your text:"))
        text_title.setObjectName('subtitle')
        main_layout.addWidget(text_title)
        main_layout.setAlignment(text_title, Qt.AlignCenter)

        main_layout.addWidget(self.get_text_widget())
    def initialize(self, item_type, options):
        """
        Initialize QDialog with App widget logo and options QWidget

        :param item_type: define item type for options: host or service
        :type item_type: str
        :param options: list of notification options
        :type options: list
        """

        center_widget(self)

        # Main status_layout
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        # QDialog title
        titles = {
            'host': _('Host Notifications'),
            'service': _('Service Notifications')
        }
        main_layout.addWidget(get_logo_widget(self, titles[item_type]))

        # Notification QWidget
        main_layout.addWidget(self.get_notifications_widget(
            item_type, options))
Example #22
0
    def build_query_text_edit(self):
        # Add layouts
        query_edit_layout = QVBoxLayout(self)
        query_edit_layout.setContentsMargins(0, 0, 0, 0)
        query_control_layout = QHBoxLayout(self)
        query_control_layout.setContentsMargins(0, 0, 0, 0)

        # Execute query button
        self.query_execute_button = QPushButton(
            UI.QUERY_CONTROL_EXECUTE_BUTTON_TEXT, self)
        self.query_execute_button.clicked.connect(self.on_execute_click)
        query_control_layout.addWidget(self.query_execute_button)

        # Fetch data button
        self.query_fetch_button = QPushButton(
            UI.QUERY_CONTROL_FETCH_BUTTON_TEXT, self)
        self.query_fetch_button.clicked.connect(self.on_fetch_click)
        self.model.fetch_changed.connect(self.on_fetch_changed)
        query_control_layout.addWidget(self.query_fetch_button)

        # Commit button
        self.query_commit_button = QPushButton(
            UI.QUERY_CONTROL_COMMIT_BUTTON_TEXT, self)
        self.query_commit_button.clicked.connect(self.on_connect_click)
        query_control_layout.addWidget(self.query_commit_button)

        # Rollback button
        self.query_rollback_button = QPushButton(
            UI.QUERY_CONTROL_ROLLBACK_BUTTON_TEXT, self)
        self.query_rollback_button.clicked.connect(self.on_rollback_click)
        query_control_layout.addWidget(self.query_rollback_button)

        # Build control strip widget
        query_control = QWidget(self)
        query_control.setLayout(query_control_layout)
        query_edit_layout.addWidget(query_control)

        # Initialize query edit document for text editor
        # and use SQL Highlighter CSS styles for it.
        self.query_text_edit_document = QTextDocument(self)
        self.query_text_edit_document.setDefaultStyleSheet(
            SQLHighlighter.style())

        # Initialize query text editor using previously built
        # text edutir document.
        self.query_text_edit = QTextEdit(self)
        self.query_text_edit.setDocument(self.query_text_edit_document)
        self.query_text_edit.textChanged.connect(self.on_query_changed)
        self.query_text_edit.setText(UI.QUERY_EDITOR_DEFAULT_TEXT)
        query_edit_layout.addWidget(self.query_text_edit)

        # Connect model's connected/disconnected signals
        self.model.connected.connect(self.on_connected)
        self.model.disconnected.connect(self.on_disconnected)

        query_edit = QWidget(self)
        query_edit.setLayout(query_edit_layout)
        query_edit.sizePolicy().setVerticalPolicy(QSizePolicy.Minimum)
        return query_edit
Example #23
0
 def init_ui(self):
     layout = QVBoxLayout(self)
     layout.setContentsMargins(0, 0, 0, 0)
     control_bar = self.init_control_bar()
     layout.addWidget(control_bar)
     workspace = self.init_workspace()
     layout.addWidget(workspace)
     self.setLayout(layout)
def createNavigationControls():
    gb = QGroupBox("Navigation Controls")

    #-------------------------------------------

    layout = QGridLayout()

    pause_both_btn = QPushButton("Pause vector && time")
    pause_btn = QPushButton("Pause vector")
    pause_time_btn = QPushButton("Pause time")
    continue_btn = QPushButton("Continue")
    release_btn = QPushButton("Release")
    cwHalfStep_btn = QPushButton("=> half step")
    ccwHalfStep_btn = QPushButton("<= half step")
    ccwDir_btn = QPushButton("CCW direction")
    cwDir_btn = QPushButton("CW direction")

    continue_btn.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)

    pause_both_btn.clicked.connect(pause_vector_and_time)
    pause_btn.clicked.connect(lambda: send_cmd(["p"]))
    pause_time_btn.clicked.connect(tracker.pause_time)
    continue_btn.clicked.connect(continue_)
    release_btn.clicked.connect(lambda: send_cmd(["r"]))
    cwHalfStep_btn.clicked.connect(lambda: send_cmd([">", "h", "<"]))
    ccwHalfStep_btn.clicked.connect(lambda: send_cmd(["<", "h"]))
    ccwDir_btn.clicked.connect(lambda: send_cmd(["<"]))
    cwDir_btn.clicked.connect(lambda: send_cmd([">"]))

    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(0)
    layout.setVerticalSpacing(0)

    layout.addWidget(pause_both_btn, 0, 0)
    layout.addWidget(pause_btn, 1, 0)
    layout.addWidget(pause_time_btn, 2, 0)
    layout.addWidget(continue_btn, 0, 1, 3, 1)
    layout.addWidget(ccwHalfStep_btn, 3, 0)
    layout.addWidget(cwHalfStep_btn, 3, 1)
    layout.addWidget(ccwDir_btn, 4, 0)
    layout.addWidget(cwDir_btn, 4, 1)
    layout.addWidget(createGotoControls(), 5, 0, 1, 2)
    layout.addWidget(release_btn, 6, 0, 1, 2)

    upper = QWidget()
    upper.setLayout(layout)

    #-------------------------------------------
    vbox = QVBoxLayout()

    vbox.addWidget(upper)
    vbox.addStretch(1)

    vbox.setContentsMargins(0, 0, 0, 0)
    vbox.setSpacing(0)

    gb.setLayout(vbox)
    return gb
Example #25
0
    def __init__(self, parent=None):
        """
        Create menu object.

        `UndoMenu` class shows list of child items in the plain list,
        suitable for undo / redo operations.

        Items are inserted to menu with `setItems()` method.

        Methods `setMaxWidth()` and `setLength()` allow to limit the
        width (in pixels) and height (as a number of shown items) of
        menu.

        To customize summary label (shown in the bottom area of menu),
        use `setComment()` method.

        Top-most item can be obtained with `lastItem()` method.

        Arguments:
            parent (Optional[QWidget]): Parent widget. Defaults to None.
        """
        QMenu.__init__(self, parent)
        v_layout = QVBoxLayout(self)
        v_layout.setContentsMargins(0, 0, 0, 0)

        frame = QFrame(self)
        frame.setFrameStyle(QFrame.Panel | QFrame.Plain)
        v_layout.addWidget(frame)

        v_layout = QVBoxLayout(frame)
        v_layout.setContentsMargins(0, 0, 0, 0)
        v_layout.setSpacing(1)

        self._list = QListWidget(frame)
        self._list.setFrameStyle(QListWidget.NoFrame)
        self._list.setSelectionMode(QListWidget.MultiSelection)
        self._list.setVerticalScrollMode(QListWidget.ScrollPerItem)
        self._list.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self._list.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._list.setResizeMode(QListWidget.Adjust)
        self._list.setFocusPolicy(Qt.NoFocus)
        self._list.viewport().installEventFilter(self)
        self._list.installEventFilter(self)
        self._list.viewport().setMouseTracking(True)

        self._label = QLabel(frame)
        self._label.setAlignment(Qt.AlignCenter)

        v_layout.addWidget(self._list)
        v_layout.addWidget(HLine(frame))
        v_layout.addWidget(self._label)

        self._comment = "%d"
        self._length = 10
        self._max_width = 0

        self._updateComment()
Example #26
0
 def __init__(self, parent, flags=Qt.WindowFlags()):
     QDialog.__init__(self, parent, flags)
     self.setModal(False)
     self.setWindowTitle("Select sources by...")
     lo = QVBoxLayout(self)
     lo.setContentsMargins(10, 10, 10, 10)
     lo.setSpacing(5)
     # select by
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     #    lab = QLabel("Select:")
     #   lo1.addWidget(lab)
     self.wselby = QComboBox(self)
     lo1.addWidget(self.wselby, 0)
     self.wselby.activated[str].connect(self._setup_selection_by)
     # under/over
     self.wgele = QComboBox(self)
     lo1.addWidget(self.wgele, 0)
     self.wgele.addItems([">", ">=", "<=", "<", "sum<=", "sum>", "=="])
     self.wgele.activated[str].connect(self._select_threshold)
     # threshold value
     self.wthreshold = QLineEdit(self)
     self.wthreshold.editingFinished.connect(self._select_threshold)
     lo1.addWidget(self.wthreshold, 1)
     # min and max label
     self.wminmax = QLabel(self)
     lo.addWidget(self.wminmax)
     # selection slider
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     self.wpercent = QSlider(self)
     self.wpercent.setTracking(False)
     self.wpercent.valueChanged[int].connect(self._select_percentile)
     self.wpercent.sliderMoved[int].connect(
         self._select_percentile_threshold)
     self.wpercent.setRange(0, 100)
     self.wpercent.setOrientation(Qt.Horizontal)
     lo1.addWidget(self.wpercent)
     self.wpercent_lbl = QLabel("0%", self)
     self.wpercent_lbl.setMinimumWidth(64)
     lo1.addWidget(self.wpercent_lbl)
     #    # hide button
     #    lo.addSpacing(10)
     #    lo2 = QHBoxLayout()
     #    lo.addLayout(lo2)
     #    lo2.setContentsMargins(0,0,0,0)
     #    hidebtn = QPushButton("Close",self)
     #    hidebtn.setMinimumWidth(128)
     #    QObject.connect(hidebtn,pyqtSignal("clicked()"),self.hide)
     #    lo2.addStretch(1)
     #    lo2.addWidget(hidebtn)
     #    lo2.addStretch(1)
     #    self.setMinimumWidth(384)
     self._in_select_threshold = False
     self._sort_index = None
     self.qerrmsg = QErrorMessage(self)
Example #27
0
class Td(QDlgContainer):
    def __init__(self, colspan=1):
        self.colspan = colspan
        self.layout = QVBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        qDlgStackTop().addChild(self)

    def addChild(self, child):
        addLayoutOrWidget(self.layout, child)
def createArduinoCalibrationControls():
    gb = QGroupBox("Arduino Calibration")
    vbox = QVBoxLayout()

    #-------------------------------------------
    layout = QHBoxLayout()

    label = QLabel("Set current position as:")
    lineEdit = QLineEdit()
    degreesLabel = QLabel("deg")
    set_btn = QPushButton("Set")

    lineEdit.setMaximumWidth(30)
    set_btn.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

    set_btn.clicked.connect(lambda: send_cmd(["=" + lineEdit.displayText()]))

    layout.setContentsMargins(0, 0, 0, 0)

    layout.addWidget(label)
    layout.addWidget(lineEdit)
    layout.addWidget(degreesLabel)
    layout.addWidget(set_btn)

    upper = QWidget()
    upper.setLayout(layout)

    #-------------------------------------------

    layout = QHBoxLayout()

    btn0 = QPushButton("Set as 0")
    btn180 = QPushButton("Set as 180")

    btn0.clicked.connect(lambda: send_cmd(["=0"]))
    btn180.clicked.connect(lambda: send_cmd(["=180"]))

    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(0)

    layout.addWidget(btn0)
    layout.addWidget(btn180)
    layout.addStretch(1)

    lower = QWidget()
    lower.setLayout(layout)

    #-------------------------------------------

    vbox.setContentsMargins(0, 0, 0, 0)
    vbox.setSpacing(0)

    vbox.addWidget(upper)
    vbox.addWidget(lower)
    gb.setLayout(vbox)
    return gb
Example #29
0
File: align.py Project: ligm74/LiGM
    def __init__(self, color_caption):
        TestableWidget.__init__(self)
        self.setWindowFlags(Qt.Popup)
        self._text = self.tr("Alignment text")

        main_layout = QVBoxLayout()
        main_layout.setContentsMargins(0, 0, 0, 0)

        b = "border: 1px solid #9b9b9b;"
        self._styles = {
            "border": b,
            "border_blue": "border: 0px solid blue;",
            "frame": 'QFrame[frameShape="4"]{color: #9b9b9b;}'
        }

        self.setStyleSheet(self._styles["frame"])

        # -- CAPTION ----------------------------------
        caption = QFrame(self, flags=Qt.WindowFlags())
        caption_layout = QHBoxLayout()
        self._lbl_caption = QLabel(self._text)
        self._lbl_caption.setStyleSheet(self._styles["border_blue"])
        caption_layout.addWidget(self._lbl_caption, alignment=Qt.Alignment())
        caption.setLayout(caption_layout)
        caption_layout.setContentsMargins(9, 5, 9, 5)
        caption.setStyleSheet(
            f"background-color: {color_caption}; {self._styles['border']}")

        # -- CELLS GRID -------------------------------
        cellsbox = QFrame(self, flags=Qt.WindowFlags())
        cells = QGridLayout()
        cellsbox.setLayout(cells)
        cells.setContentsMargins(9, 0, 9, 9)
        self._clrbtn = []
        for i in range(1, 4):
            for j in range(1, 5):
                self._clrbtn.append(QToolButton())
                self._clrbtn[-1].clicked.connect(
                    lambda z, y=i, x=j: self.select_align_(x, y))
                self._clrbtn[-1].setAutoRaise(True)

                sz = 48
                self._clrbtn[-1].setFixedSize(sz, sz)
                self._clrbtn[-1].setIconSize(QSize(sz, sz))

                self._clrbtn[-1].setIcon(QIcon(img(f"editor/a{i}{j}.png")))
                # noinspection PyArgumentList
                cells.addWidget(self._clrbtn[-1], i - 1, j - 1)

        # ---------------------------------------------
        main_layout.addWidget(caption, alignment=Qt.Alignment())
        main_layout.addWidget(cellsbox, alignment=Qt.Alignment())

        self.setLayout(main_layout)
Example #30
0
    def _setup_ui(self):
        self.setFixedWidth(300)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setAlignment(Qt.AlignTop)

        layout.addWidget(ImageInfo())
        layout.addWidget(ProcessList())

        self.setLayout(layout)
    def __init__(self, *args, **kwargs):
        super(PanelDataPlotting, self).__init__(*args, **kwargs)

        # create the layout for the panel
        layout_pane = QVBoxLayout()
        self.setLayout(layout_pane)
        self.setContentsMargins(0, 0, 0, 0)
        layout_pane.setContentsMargins(0, 20, 5, 1)

        # create an empty scene and and a view port
        self.gview = GViewPlotting(self)
        layout_pane.addWidget(self.gview)
Example #32
0
 def init_ui(self):
     # Declare main vertical layout
     layout = QVBoxLayout(self)
     layout.setContentsMargins(0, 0, 0, 0)
     # Initialize control toolbar
     control_bar = self.init_control_bar()
     layout.addWidget(control_bar)
     # Initialize workspace
     workspace = self.init_workspace()
     layout.addWidget(workspace)
     # Apply configured UI layout to the widget
     self.setLayout(layout)
    def initialize_synthesis(self):
        """
        Initialize Synthesis QWidget

        """

        synthesis_layout = QVBoxLayout()
        synthesis_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(synthesis_layout)

        # Search widget
        search_widget = self.get_search_widget()
        synthesis_layout.addWidget(search_widget)

        # Host widget
        self.host_widget.initialize()
        self.host_widget.setMaximumHeight(self.width() * 0.5)
        synthesis_layout.addWidget(self.host_widget)

        # Hint Widget
        hint_text = _(
            '<h4>Dahsboard</h4>'
            '<ul><li>At the top of App, '
            'you have a dashboard that summarizes the number of items per state.</li></ul>'
            '<h4>Tabs</h4>'
            '<ul><li><h4>Host Synthesis</h4></li>'
            'Tap in the search bar to view a host and its services.'
            '<li><h4>Problems</h4></li>'
            'The "Problems" tab will show you all problems detected in your backend.'
            '<li><h4>Spy Hosts</h4></li>'
            'A "Spy Host" will keep you regularly informed of his condition. '
            'You will also see problems detected for this host, in the "Spy Hosts" panel.</ul>'
            '<h4>Alignak</h4>'
            '<ul><li>You can see your backend status and daemons if available, '
            'as well as your profile.</li></ul>'
            '<h4>Livestate</h4>'
            '<ul><li>In the livestate, you can see global state of your monitored items.</li></ul>'
            '<h4>Events</h4>'
            '<ul><li>Events will show you informative messages your actions inside App.</li></ul>'
        )
        hint_layout = QVBoxLayout(self.hint_widget)
        hint_label = QLabel(hint_text)
        hint_label.setObjectName('subtitle')
        hint_layout.addWidget(hint_label)
        synthesis_layout.addWidget(self.hint_widget)

        # Services widget
        self.services_widget.initialize()
        synthesis_layout.addWidget(self.services_widget)

        # Align all widgets to Top
        synthesis_layout.setAlignment(Qt.AlignTop)
    def initialize_synthesis(self):
        """
        Initialize Synthesis QWidget

        """

        synthesis_layout = QVBoxLayout()
        synthesis_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(synthesis_layout)

        # Search widget
        search_widget = self.get_search_widget()
        synthesis_layout.addWidget(search_widget)

        # Host widget
        self.host_widget.initialize()
        self.host_widget.setMaximumHeight(self.width() * 0.5)
        synthesis_layout.addWidget(self.host_widget)

        # Hint Widget
        hint_text = _(
            '<h4>Dahsboard</h4>'
            '<ul><li>At the top of App, '
            'you have a dashboard that summarizes the number of items per state.</li></ul>'
            '<h4>Tabs</h4>'
            '<ul><li><h4>Host Synthesis</h4></li>'
            'Tap in the search bar to view a host and its services.'
            '<li><h4>Problems</h4></li>'
            'The "Problems" tab will show you all problems detected in your backend.'
            '<li><h4>Spy Hosts</h4></li>'
            'A "Spy Host" will keep you regularly informed of his condition. '
            'You will also see problems detected for this host, in the "Spy Hosts" panel.</ul>'
            '<h4>Alignak</h4>'
            '<ul><li>You can see your backend status and daemons if available, '
            'as well as your profile.</li></ul>'
            '<h4>Livestate</h4>'
            '<ul><li>In the livestate, you can see global state of your monitored items.</li></ul>'
            '<h4>Events</h4>'
            '<ul><li>Events will show you informative messages your actions inside App.</li></ul>'
        )
        hint_layout = QVBoxLayout(self.hint_widget)
        hint_label = QLabel(hint_text)
        hint_label.setObjectName('subtitle')
        hint_layout.addWidget(hint_label)
        synthesis_layout.addWidget(self.hint_widget)

        # Services widget
        self.services_widget.initialize()
        synthesis_layout.addWidget(self.services_widget)

        # Align all widgets to Top
        synthesis_layout.setAlignment(Qt.AlignTop)
Example #35
0
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags()):
     QDialog.__init__(self, parent, flags)
     self.model = None
     self._model_dir = None
     self.setModal(modal)
     self.setWindowTitle("Add FITS brick")
     lo = QVBoxLayout(self)
     lo.setContentsMargins(10, 10, 10, 10)
     lo.setSpacing(5)
     # file selector
     self.wfile = FileSelector(self,
                               label="FITS filename:",
                               dialog_label="FITS file",
                               default_suffix="fits",
                               file_types="FITS files (*.fits *.FITS)",
                               file_mode=QFileDialog.ExistingFile)
     lo.addWidget(self.wfile)
     # overwrite or add mode
     lo1 = QGridLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     lo1.addWidget(QLabel("Padding factor:", self), 0, 0)
     self.wpad = QLineEdit("2", self)
     self.wpad.setValidator(QDoubleValidator(self))
     lo1.addWidget(self.wpad, 0, 1)
     lo1.addWidget(QLabel("Assign source name:", self), 1, 0)
     self.wname = QLineEdit(self)
     lo1.addWidget(self.wname, 1, 1)
     # OK/cancel buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setContentsMargins(5, 5, 5, 5)
     self.wokbtn = QPushButton("OK", self)
     self.wokbtn.setMinimumWidth(128)
     self.wokbtn.clicked.connect(self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     cancelbtn.clicked.connect(self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     # signals
     self.wfile.filenameSelected.connect(self._fileSelected)
     # internal state
     self.qerrmsg = QErrorMessage(self)
Example #36
0
    def initialize_dialog(self):
        """
        Initialize Server QDialog

        """

        main_layout = QVBoxLayout()
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        main_layout.addWidget(get_logo_widget(self, _('Alignak Settings')))

        main_layout.addWidget(self.get_settings_widget())

        center_widget(self)
    def initialize_dialog(self):
        """
        Initialize Server QDialog

        """

        main_layout = QVBoxLayout()
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        main_layout.addWidget(get_logo_widget(self, _('Alignak Settings')))

        main_layout.addWidget(self.get_settings_widget())

        center_widget(self)
    def initialize_dialog(self):
        """
        Initialize Proxy QDialog

        """

        main_layout = QVBoxLayout()
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        main_layout.addWidget(get_logo_widget(self, _('Proxy Settings')))

        main_layout.addWidget(self.get_proxy_widget())

        center_widget(self)
    def initialize(self):
        """
        Initialize QDialog for PasswordDialog

        """

        center_widget(self)

        # Main status_layout
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        main_layout.addWidget(get_logo_widget(self, _('Edit Password')))

        pass_title = QLabel(_("Please type a new PASSWORD:"******"Your password must contain at least 5 characters."))
        self.help_label.setWordWrap(True)
        pass_layout.addWidget(self.help_label)

        # Accept button
        accept_btn = QPushButton('Confirm', self)
        accept_btn.clicked.connect(self.handle_confirm)
        accept_btn.setObjectName('valid')
        accept_btn.setMinimumHeight(30)
        pass_layout.addWidget(accept_btn)

        main_layout.addWidget(pass_widget)
    def addVignette (self,warrior,i):
        widget_vignette = QWidget(self.vignettes)        
        layout_one_vignette = QVBoxLayout(widget_vignette)
        layout_one_vignette.setSpacing(0)
        layout_one_vignette.setContentsMargins(0, 0, 0, 0)
        warrior_button = QPushButton(widget_vignette)
        # on met plus car dans le cas du signal clicked on enverra True ou False (0 ou 1)
        warrior_button.setObjectName(str(i+2))
        warrior_button.clicked.connect(self.parent().goWarriorPage)
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        warrior_button.setFixedSize(QtCore.QSize(100,120))
        warrior_button.setSizePolicy(sizePolicy)
        layout_one_vignette.addWidget(warrior_button)
        
        # label
        warrior_label = HerosLabel(warrior,widget_vignette)
        layout_one_vignette.addWidget(warrior_label)
        
        max_col  = 3
        groupe_name = warrior.groupe().name
        if warrior.masterGroupe() != None : 
            groupe_name = warrior.masterGroupe().name+"/"+groupe_name
        

        #path = os.path.join(Config().instance.path_to_pic(),faction_name,empire_name,kingdom_name,"Picture",groupe_name,warrior_name
        icon = QIcon(warrior.thumb)

        #print (basepath+"/"+faction_name+"/"+empire_name+"/"+kingdom_name+"/Picture/"+groupe_name+"/"+warrior.name+"/portrait_thumbnail.jpg")
        warrior_button.setIcon(icon)
        warrior_button.setIconSize(QtCore.QSize(100,120))

        if self.nb_col == 0:
            self.nb_row = self.nb_row + 1


        self.gridLayout.addWidget(widget_vignette,self.nb_row,self.nb_col)
        self.vignettes_liste.append(widget_vignette)
        self.nb_col = (self.nb_col +1)%max_col
    def initialize(self):
        """
        Initialize QDialog

        """

        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)

        main_layout.addWidget(get_logo_widget(self, _('User View')))

        # Daemons QWidget
        daemons_widget = QWidget(self)
        daemons_widget.setLayout(self.daemons_layout)

        daemons = data_manager.database['alignakdaemon']

        # Init QLabels
        self.init_daemons_labels(daemons)

        # Add daemons label
        line = 0
        self.add_daemon_titles_labels(line)

        for daemon_item in daemons:
            line += 1
            self.add_daemon_labels(daemon_item, line)

        line += 1

        # Ok QPushButton
        ok_btn = QPushButton(_('OK'))
        ok_btn.setObjectName('ok')
        ok_btn.setFixedSize(120, 30)
        ok_btn.clicked.connect(self.accept)
        self.daemons_layout.addWidget(ok_btn, line, 0, 1, 7)
        self.daemons_layout.setAlignment(ok_btn, Qt.AlignCenter)

        main_layout.addWidget(daemons_widget)
        center_widget(self)
    def initialize(self, item_type, options):
        """
        Initialize QDialog with App widget logo and options QWidget

        :param item_type: define item type for options: host or service
        :type item_type: str
        :param options: list of notification options
        :type options: list
        """

        center_widget(self)

        # Main status_layout
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        # QDialog title
        titles = {'host': _('Host Notifications'), 'service': _('Service Notifications')}
        main_layout.addWidget(get_logo_widget(self, titles[item_type]))

        # Notification QWidget
        main_layout.addWidget(self.get_notifications_widget(item_type, options))
    def initialize(self, widgettitle, dialog, title, text):
        """
        Initialize QDialog for PasswordDialog

        :param widgettitle: title of the QDialog
        :type widgettitle: str
        :param dialog: type of dialog ('text' or 'error')
        :type dialog: str
        :param title: title of text to display
        :type title: str
        :param text: text to display
        :type text: str
        """

        center_widget(self)

        # Main status_layout
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        main_layout.addWidget(get_logo_widget(self, widgettitle))
        main_layout.addWidget(self.get_message_widget(dialog, title, text))
Example #44
0
class Dialog(QDialog):
    def __init__(self, title, widget=None, closeButton=True, keySequence=None, isDialog=False, icon=None):
        QDialog.__init__(self, ctx.mainScreen)
        self.setObjectName("dialog")

        self.isDialog = isDialog
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)
        self.wlayout= QHBoxLayout()

        if icon:
            self.setStyleSheet("""QDialog QLabel{ margin-left:16px;margin-right:10px}
                                  QDialog#dialog {background-image:url(':/images/%s.png');
                                                  background-repeat:no-repeat;
                                                  background-position: top left; padding-left:500px;} """ % icon)

        self.windowTitle = windowTitle(self, closeButton)
        self.setTitle(title)
        #self.layout.setMargin(0)
        self.layout.addWidget(self.windowTitle)

        if widget:
            self.addWidget(widget)
            try:
                widget.finished[int].connect(self.reject)
            except:
                pass
            finally:
                try:
                    widget.resizeDialog[int,int].connect(self.resize)
                except:
                    pass
            

        if closeButton:
            self.windowTitle.pushButton.clicked.connect(self.reject)

        if keySequence:
            shortCut = QShortcut(keySequence, self)
            shortCut.activated.connect(self.reject)

        QMetaObject.connectSlotsByName(self)
        self.resize(10,10)

    def setTitle(self, title):
        self.windowTitle.label.setText(title)

    def addWidget(self, widget):
        self.content = widget
        self.wlayout.addWidget(self.content)
        if self.isDialog:
            widget.setStyleSheet("QMessageBox { background:none }")
            self.layout.addItem(QSpacerItem(10, 10, QSizePolicy.Fixed, QSizePolicy.MinimumExpanding))
            self.layout.setContentsMargins(0, 0, 0, 8)
        self.layout.addLayout(self.wlayout)

    def setCentered(self):
        self.move(ctx.mainScreen.width()/2 - self.width()/2,
                  ctx.mainScreen.height()/2 - self.height()/2)

    def exec_(self):
        QTimer.singleShot(0, self.setCentered)
        return QDialog.exec_(self)
Example #45
0
    def __init__(self, parent = None):
        super(MainWidget, self).__init__(parent)

        # member variables
        self._lTheorySpd = 0
        self._rTheorySpd = 0
        self._serialSend = SerialSend()

        # mainWindow properties
        self.setObjectName('MainWidget')
        self.setWindowIcon(QIcon(':/image/default/app.icon'))
        self.setWindowTitle('%s V%s' % (
                            qApp.applicationDisplayName(),
                            qApp.applicationVersion()))
        self.resize(800, 480)

        # mainWindow layout

        # top

        self.groupBoxTop = QGroupBox(self)
        self.groupBoxTop.setObjectName('groupBoxTop')

        # command dashboard
        buttonLeftPower = JSwitchButton(parent = self.groupBoxTop)
        buttonRightPower = JSwitchButton(parent = self.groupBoxTop)
        buttonSettings = QPushButton(self.groupBoxTop)
        buttonHistory = QPushButton(self.groupBoxTop)
        buttonQuit = QPushButton(self.groupBoxTop)

        buttonLeftPower.setObjectName('buttonLeftPower')
        buttonRightPower.setObjectName('buttonRightPower')
        buttonSettings.setObjectName('buttonSettings')
        buttonHistory.setObjectName('buttonHistory')
        buttonQuit.setObjectName('buttonQuit')

        areaPortState = QWidget(self)
        areaPortState.setObjectName('areaPortState')
        areaPortState.setStyleSheet('QWidget#areaPortState{border-radius:3px;'
                                    'border:1px solid #505050;'
                                    'background-color:rgba(64,64,64,50);}')
        vertLayoutPortState = QVBoxLayout(areaPortState)
        vertLayoutPortState.setContentsMargins(50, 2, 50, 2)
        vertLayoutPortState.setSpacing(3)

        buttonPortState = JSwitchButton(pixmap = QPixmap(':/carmonitor/image/button-port-state.png'), parent = areaPortState)
        buttonPortState.setObjectName('buttonPortState')
        vertLayoutPortState.addWidget(QLabel('串口', areaPortState), 0, Qt.AlignHCenter)
        vertLayoutPortState.addWidget(buttonPortState)

        #
        horiLayoutTop = QHBoxLayout(self.groupBoxTop)
        horiLayoutTop.setContentsMargins(0, 0, 0, 0)
        horiLayoutTop.addSpacing(25)
        horiLayoutTop.addWidget(buttonSettings, 0, Qt.AlignLeft)
        horiLayoutTop.addSpacing(20)
        horiLayoutTop.addWidget(buttonHistory, 0, Qt.AlignLeft)
        horiLayoutTop.addSpacing(65)
        horiLayoutTop.addWidget(buttonLeftPower)
        horiLayoutTop.addWidget(QLabel('左电源开关', self.groupBoxTop))
        horiLayoutTop.addStretch()
        horiLayoutTop.addWidget(areaPortState, 0, Qt.AlignTop)
        horiLayoutTop.addStretch()
        horiLayoutTop.addWidget(QLabel('右电源开关', self.groupBoxTop))
        horiLayoutTop.addWidget(buttonRightPower)
        horiLayoutTop.addSpacing(150)
        horiLayoutTop.addWidget(buttonQuit, 0, Qt.AlignRight)
        horiLayoutTop.addSpacing(25)

        # middle

        # curves
        self.curveLBP = CurveWidget(title = '左刹车压力(MPa)', parent = self)
        self.curveLRP = CurveWidget(title = '左转速(r/min)', parent = self)
        self.curveRBP = CurveWidget(title = '右刹车压力(MPa)', parent = self)
        self.curveRRP = CurveWidget(title = '右转速(r/min)', parent = self)

        self.curveLBP.setObjectName('curveLBP')
        self.curveLRP.setObjectName('curveLRP')
        self.curveRBP.setObjectName('curveRBP')
        self.curveRRP.setObjectName('curveRRP')

        # self.curveLBP.setAxisScale(QwtPlot.yLeft, 0, 30, 5)

        # areaMiddle
        self.areaMiddle = QWidget(self)
        self.areaMiddle.setObjectName('areaMiddle')
        self.areaMiddle.setFixedWidth(280)

        #
        groupBoxStatus = QGroupBox(self)
        groupBoxStatus.setObjectName('groupBoxStatus')

        # status-view
        gridLayoutStatus = QGridLayout(groupBoxStatus)
        gridLayoutStatus.setContentsMargins(5, 5, 5, 5)
        gridLayoutStatus.setHorizontalSpacing(8)
        gridLayoutStatus.setVerticalSpacing(3)

        # Brake-Command
        editLeftBrakeCmd = QLineEdit(groupBoxStatus)
        editRightBrakeCmd = QLineEdit(groupBoxStatus)
        editLeftBrakeCmd.setObjectName('editLeftBrakeCmd')
        editRightBrakeCmd.setObjectName('editRightBrakeCmd')
        editLeftBrakeCmd.setReadOnly(True)
        editRightBrakeCmd.setReadOnly(True)
        gridLayoutStatus.addWidget(QLabel('刹车指令:', groupBoxStatus),
                                   0, 0, 1, 2, Qt.AlignCenter)
        gridLayoutStatus.addWidget(editLeftBrakeCmd, 1, 0, 1, 1)
        gridLayoutStatus.addWidget(editRightBrakeCmd, 1, 1, 1, 1)

        # Major Brake Pressure
        self.editMLeftBrakeP = QLineEdit(groupBoxStatus)
        self.editMRightBrakeP = QLineEdit(groupBoxStatus)
        self.editMLeftBrakeP.setObjectName('editMLeftBrakeP')
        self.editMRightBrakeP.setObjectName('editMRightBrakeP')
        self.editMLeftBrakeP.setReadOnly(True)
        self.editMRightBrakeP.setReadOnly(True)
        gridLayoutStatus.addWidget(QLabel('主刹车压力:', groupBoxStatus),
                                   2, 0, 1, 2, Qt.AlignCenter)
        gridLayoutStatus.addWidget(self.editMLeftBrakeP, 3, 0, 1, 1)
        gridLayoutStatus.addWidget(self.editMRightBrakeP, 3, 1, 1, 1)

        # Assistant Brake Pressure
        self.editALeftBrakeP = QLineEdit(groupBoxStatus)
        self.editARightBrakeP = QLineEdit(groupBoxStatus)
        self.editALeftBrakeP.setObjectName('editALeftBrakeP')
        self.editARightBrakeP.setObjectName('editARightBrakeP')
        self.editALeftBrakeP.setReadOnly(True)
        self.editARightBrakeP.setReadOnly(True)
        gridLayoutStatus.addWidget(QLabel('副刹车压力:', groupBoxStatus),
                                   4, 0, 1, 2, Qt.AlignCenter)
        gridLayoutStatus.addWidget(self.editALeftBrakeP, 5, 0, 1, 1)
        gridLayoutStatus.addWidget(self.editARightBrakeP, 5, 1, 1, 1)

        # Rotation Rate
        self.editLeftRotateRate = QLineEdit(groupBoxStatus)
        self.editRightRotateRate = QLineEdit(groupBoxStatus)
        self.editLeftRotateRate.setObjectName('editLeftRotateRate')
        self.editRightRotateRate.setObjectName('editRightRotateRate')
        gridLayoutStatus.addWidget(QLabel('实际转速:', groupBoxStatus),
                                   6, 0, 1, 2, Qt.AlignCenter)
        gridLayoutStatus.addWidget(self.editLeftRotateRate, 7, 0, 1, 1)
        gridLayoutStatus.addWidget(self.editRightRotateRate, 7, 1, 1, 1)

        # Theory Rotation Rate
        self.editTheoryLeftRotateRate = QLineEdit(groupBoxStatus)
        self.editTheoryRightRotateRate = QLineEdit(groupBoxStatus)
        self.editTheoryLeftRotateRate.setObjectName('editTheoryLeftRotateRate')
        self.editTheoryRightRotateRate.setObjectName('editTheoryRightRotateRate')
        gridLayoutStatus.addWidget(QLabel('理论转速:', groupBoxStatus),
                                   8, 0, 1, 2, Qt.AlignCenter)
        gridLayoutStatus.addWidget(self.editTheoryLeftRotateRate, 9, 0, 1, 1)
        gridLayoutStatus.addWidget(self.editTheoryRightRotateRate, 9, 1, 1, 1)

        #
        groupBoxCtrl = QGroupBox(self)
        groupBoxCtrl.setObjectName('groupBoxCtrl')

        # status-view
        gridLayoutCtrl = QGridLayout(groupBoxCtrl)
        gridLayoutCtrl.setContentsMargins(5, 5, 5, 5)
        gridLayoutCtrl.setSpacing(20)

        # left-button
        buttonLeftDashboard = JDashButton('左指令旋钮', groupBoxCtrl)
        buttonLeftSpeedGain = JDashButton('左转速增益', groupBoxCtrl)
        buttonLeftSpeedKnob = JDashButton('左转速增益', groupBoxCtrl)
        buttonLeftTracksip = JTracksipButton(parent = groupBoxCtrl)
        buttonLeftDashboard.setObjectName('buttonLeftDashboard')
        buttonLeftSpeedGain.setObjectName('buttonLeftSpeedGain')
        buttonLeftSpeedKnob.setObjectName('buttonLeftSpeedKnob')
        buttonLeftTracksip.setObjectName('buttonLeftTracksip')
        buttonLeftTracksip.setFixedSize(110, 45)

        # right-button
        buttonRightDashboard = JDashButton('右指令旋钮', groupBoxCtrl)
        buttonRightSpeedGain = JDashButton('右转速增益', groupBoxCtrl)
        buttonRightSpeedKnob = JDashButton('右转速增益', groupBoxCtrl)
        buttonRightTracksip = JTracksipButton(parent = groupBoxCtrl)
        buttonRightDashboard.setObjectName('buttonRightDashboard')
        buttonRightSpeedGain.setObjectName('buttonRightSpeedGain')
        buttonRightSpeedKnob.setObjectName('buttonRightSpeedKnob')
        buttonRightTracksip.setObjectName('buttonRightTracksip')
        buttonRightTracksip.setFixedSize(110, 45)

        horiLayoutTracksip = QHBoxLayout()
        horiLayoutTracksip.setContentsMargins(0, 0, 0, 0)
        horiLayoutTracksip.setSpacing(5)
        horiLayoutTracksip.addWidget(buttonLeftTracksip)
        horiLayoutTracksip.addWidget(QLabel('打滑', self), 0, Qt.AlignHCenter)
        horiLayoutTracksip.addWidget(buttonRightTracksip)
        gridLayoutCtrl.addLayout(horiLayoutTracksip, 0, 0, 1, 2)

        horiLayoutDashboard = QHBoxLayout()
        horiLayoutDashboard.setContentsMargins(0, 0, 0, 0)
        horiLayoutDashboard.setSpacing(5)
        horiLayoutDashboard.addWidget(buttonLeftDashboard)
        horiLayoutDashboard.addWidget(QLabel('    ', self), 0, Qt.AlignHCenter)
        horiLayoutDashboard.addWidget(buttonRightDashboard)
        gridLayoutCtrl.addLayout(horiLayoutDashboard, 1, 0, 1, 2)

        horiLayoutSpeedGain = QHBoxLayout()
        horiLayoutSpeedGain.setContentsMargins(0, 0, 0, 0)
        horiLayoutSpeedGain.setSpacing(5)
        horiLayoutSpeedGain.addWidget(buttonLeftSpeedGain)
        horiLayoutSpeedGain.addWidget(QLabel('(粗调)', self), 0, Qt.AlignHCenter)
        horiLayoutSpeedGain.addWidget(buttonRightSpeedGain)
        gridLayoutCtrl.addLayout(horiLayoutSpeedGain, 2, 0, 1, 2)


        horiLayoutSpeedKnob = QHBoxLayout()
        horiLayoutSpeedKnob.setContentsMargins(0, 0, 0, 0)
        horiLayoutSpeedKnob.setSpacing(5)
        horiLayoutSpeedKnob.addWidget(buttonLeftSpeedKnob)
        horiLayoutSpeedKnob.addWidget(QLabel('(细调)', self), 0, Qt.AlignHCenter)
        horiLayoutSpeedKnob.addWidget(buttonRightSpeedKnob)
        gridLayoutCtrl.addLayout(horiLayoutSpeedKnob, 3, 0, 1, 2)

        #
        vertLayoutMid = QVBoxLayout(self.areaMiddle)
        vertLayoutMid.setContentsMargins(0, 0, 0, 0)
        vertLayoutMid.setSpacing(0)
        vertLayoutMid.addWidget(groupBoxStatus)
        vertLayoutMid.addWidget(groupBoxCtrl)
        vertLayoutMid.addSpacing(20)

        #
        gridLayoutBottom = QGridLayout()
        gridLayoutBottom.setContentsMargins(0, 0, 0, 0)
        gridLayoutBottom.setSpacing(1)
        gridLayoutBottom.addWidget(self.curveLBP, 0, 0, 1, 1)
        gridLayoutBottom.addWidget(self.curveLRP, 1, 0, 1, 1)
        gridLayoutBottom.addWidget(self.areaMiddle, 0, 1, 2, 1)
        gridLayoutBottom.addWidget(self.curveRBP, 0, 2, 1, 1)
        gridLayoutBottom.addWidget(self.curveRRP, 1, 2, 1, 1)

        # main-layout
        vertLayoutMain = QVBoxLayout(self)
        vertLayoutMain.setContentsMargins(5, 5, 5, 5)
        vertLayoutMain.addWidget(self.groupBoxTop)
        vertLayoutMain.addLayout(gridLayoutBottom)

        # global properties
        qApp.setProperty('MainWidget', self)
        self._serialProxy = SerialPortProxy(self)
        self._serialProxy._serialSimulate = SerialSimulate(self._serialProxy)  #
        qApp.setProperty('SerialProxy', self._serialProxy)

        #
        buttonSettings.clicked.connect(self.onButtonSettingsClicked)
        buttonHistory.clicked.connect(self.onButtonHistoryClicked)
        buttonPortState.clicked.connect(self.onButtonPortStateClicked)
        buttonQuit.clicked.connect(self.onButtonQuitClicked)

        # curves
        self.curveLBP.doubleClicked.connect(self.onCurveDoubleClicked)
        self.curveLRP.doubleClicked.connect(self.onCurveDoubleClicked)
        self.curveRBP.doubleClicked.connect(self.onCurveDoubleClicked)
        self.curveRRP.doubleClicked.connect(self.onCurveDoubleClicked)

        # switch-power
        buttonLeftPower.stateChanged.connect(self.onButtonLeftPowerStateChanged)
        buttonRightPower.stateChanged.connect(self.onButtonRightPowerStateChanged)

        # switch-tracksip
        buttonLeftTracksip.stateChanged.connect(self.onButtonLeftTracksipStateChanged)
        buttonRightTracksip.stateChanged.connect(self.onButtonRightTracksipStateChanged)

        self._serialProxy.stateChanged.connect(self.onSerialStateChanged)
        self._serialProxy.serialPortError.connect(self.onSerialPortError)
        self._serialProxy.displayRespond.connect(self.onSerialDisplayRespond)

        #
        buttonLeftSpeedGain.clicked.connect(self.execSliderWidget)
        buttonLeftSpeedKnob.clicked.connect(self.execSliderWidget)
        buttonRightSpeedGain.clicked.connect(self.execSliderWidget)
        buttonRightSpeedKnob.clicked.connect(self.execSliderWidget)

        # final initialization

        self.editMLeftBrakeP.setText('0 MPa')
        self.editMRightBrakeP.setText('0 MPa')
        self.editALeftBrakeP.setText('0 MPa')
        self.editARightBrakeP.setText('0 MPa')

        self.editLeftRotateRate.setText('0 r/min')
        self.editRightRotateRate.setText('0 r/min')
        self.editTheoryLeftRotateRate.setText('0 r/min')
        self.editTheoryRightRotateRate.setText('0 r/min')

        #
        c_memset(self._serialSend, 0, ctypes.sizeof(self._serialSend))

        # SQL
        sqlName = applicationDirPath() \
            + '/../data/cm-' \
            + QDateTime.currentDateTime().toLocalTime().toString('yyyy-MM-dd-HH-mm-ss') \
            + '.db'
        if not DatabaseMgr().create(sqlName):
            assert(False)

        # start serialport
        self._serialProxy.start()

        #
        buttonLeftTracksip.setState(self._serialSend.ctrlWord.lTracksip)
        buttonRightTracksip.setState(self._serialSend.ctrlWord.lTracksip)
    def initialize(self, item_type, item_name, comment):  # pylint: disable=too-many-locals
        """
        Initialize Downtime QDialog

        :param item_type: type of item to acknowledge : host | service
        :type item_type: str
        :param item_name: name of the item to acknowledge
        :type item_name: str
        :param comment: the default comment of action
        :type comment: str
        """

        logger.debug("Create Downtime QDialog...")

        # Main status_layout
        center_widget(self)
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)

        main_layout.addWidget(get_logo_widget(self, _('Request Downtime')))

        downtime_widget = QWidget()
        downtime_widget.setObjectName('dialog')
        downtime_layout = QGridLayout(downtime_widget)

        downtime_title = QLabel(_('Request a downtime'))
        downtime_title.setObjectName('itemtitle')
        downtime_layout.addWidget(downtime_title, 0, 0, 1, 3)

        host_label = QLabel('<b>%s:</b> %s' % (item_type.capitalize(), item_name))
        downtime_layout.addWidget(host_label, 1, 0, 1, 1)

        options_label = QLabel(_('Downtime options:'))
        options_label.setObjectName('subtitle')
        downtime_layout.addWidget(options_label, 2, 0, 1, 1)

        self.fixed_toggle_btn.initialize()
        self.fixed_toggle_btn.update_btn_state(self.fixed)
        downtime_layout.addWidget(self.fixed_toggle_btn, 2, 1, 1, 1)

        fixed_label = QLabel(_('Fixed'))
        downtime_layout.addWidget(fixed_label, 2, 2, 1, 1)

        fixed_info = QLabel(
            _(
                'If checked, downtime will start and end at the times specified'
                ' by the “start time” and “end time” fields.'
            )
        )
        fixed_info.setWordWrap(True)
        downtime_layout.addWidget(fixed_info, 3, 0, 1, 3)

        duration_label = QLabel(_('Duration'))
        duration_label.setObjectName('subtitle')
        downtime_layout.addWidget(duration_label, 4, 0, 1, 1)

        duration_clock = QLabel()
        duration_clock.setPixmap(QPixmap(settings.get_image('time')))
        downtime_layout.addWidget(duration_clock, 4, 1, 1, 1)
        duration_clock.setFixedSize(16, 16)
        duration_clock.setScaledContents(True)

        self.duration.setTime(QTime(4, 00))
        self.duration.setDisplayFormat("HH'h'mm")
        downtime_layout.addWidget(self.duration, 4, 2, 1, 1)

        duration_info = QLabel(
            _('Sets the duration if it is a non-fixed downtime.')
        )
        downtime_layout.addWidget(duration_info, 5, 0, 1, 3)

        date_range_label = QLabel(_('Downtime date range'))
        date_range_label.setObjectName('subtitle')
        downtime_layout.addWidget(date_range_label, 6, 0, 1, 1)

        calendar_label = QLabel()
        calendar_label.setPixmap(QPixmap(settings.get_image('calendar')))
        calendar_label.setFixedSize(16, 16)
        calendar_label.setScaledContents(True)
        downtime_layout.addWidget(calendar_label, 6, 1, 1, 1)

        start_time_label = QLabel(_('Start time:'))
        downtime_layout.addWidget(start_time_label, 7, 0, 1, 1)

        self.start_time.setCalendarPopup(True)
        self.start_time.setDateTime(datetime.datetime.now())
        self.start_time.setDisplayFormat("dd/MM/yyyy HH'h'mm")
        downtime_layout.addWidget(self.start_time, 7, 1, 1, 2)

        end_time_label = QLabel(_('End time:'))
        downtime_layout.addWidget(end_time_label, 8, 0, 1, 1)

        self.end_time.setCalendarPopup(True)
        self.end_time.setDateTime(datetime.datetime.now() + datetime.timedelta(hours=2))
        self.end_time.setDisplayFormat("dd/MM/yyyy HH'h'mm")
        downtime_layout.addWidget(self.end_time, 8, 1, 1, 2)

        self.comment_edit.setText(comment)
        self.comment_edit.setMaximumHeight(60)
        downtime_layout.addWidget(self.comment_edit, 9, 0, 1, 3)

        request_btn = QPushButton(_('REQUEST DOWNTIME'), self)
        request_btn.clicked.connect(self.handle_accept)
        request_btn.setObjectName('valid')
        request_btn.setMinimumHeight(30)
        request_btn.setDefault(True)
        downtime_layout.addWidget(request_btn, 10, 0, 1, 3)

        main_layout.addWidget(downtime_widget)
    def initialize(self, item_type, item_name, comment):  # pylint: disable=too-many-locals
        """
        Initialize Acknowledge QDialog

        :param item_type: type of item to acknowledge : host | service
        :type item_type: str
        :param item_name: name of the item to acknowledge
        :type item_name: str
        :param comment: the default comment of action
        :type comment: str
        """

        logger.debug("Create Acknowledge QDialog...")

        # Main status_layout
        center_widget(self)
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)

        main_layout.addWidget(get_logo_widget(self, _('Request Acknowledge')))

        ack_widget = QWidget()
        ack_widget.setObjectName('dialog')
        ack_layout = QGridLayout(ack_widget)

        ack_title = QLabel(_('Request an acknowledge'))
        ack_title.setObjectName('itemtitle')
        ack_layout.addWidget(ack_title, 0, 0, 1, 2)

        host_label = QLabel('<b>%s:</b> %s' % (item_type.capitalize(), item_name))
        ack_layout.addWidget(host_label, 1, 0, 1, 1)

        sticky_label = QLabel(_('Acknowledge is sticky:'))
        sticky_label.setObjectName('subtitle')
        ack_layout.addWidget(sticky_label, 2, 0, 1, 1)

        self.sticky_toggle_btn.initialize()
        self.sticky_toggle_btn.update_btn_state(self.sticky)
        ack_layout.addWidget(self.sticky_toggle_btn, 2, 1, 1, 1)

        sticky_info = QLabel(
            _(
                'If checked, '
                'the acknowledge will remain until the element returns to an "OK" state.'
            )
        )
        sticky_info.setWordWrap(True)
        ack_layout.addWidget(sticky_info, 3, 0, 1, 2)

        notify_label = QLabel(_('Acknowledge notifies:'))
        notify_label.setObjectName('subtitle')
        ack_layout.addWidget(notify_label, 4, 0, 1, 1)

        self.notify_toggle_btn.initialize()
        self.notify_toggle_btn.update_btn_state(self.notify)
        ack_layout.addWidget(self.notify_toggle_btn, 4, 1, 1, 1)

        notify_info = QLabel(
            _('If checked, a notification will be sent out to the concerned contacts.')
        )
        notify_info.setWordWrap(True)
        ack_layout.addWidget(notify_info, 5, 0, 1, 2)

        ack_comment = QLabel(_('Acknowledge comment:'))
        ack_comment.setObjectName('subtitle')
        ack_layout.addWidget(ack_comment, 6, 0, 1, 1)

        self.ack_comment_edit = QTextEdit()
        self.ack_comment_edit.setText(comment)
        self.ack_comment_edit.setMaximumHeight(60)
        ack_layout.addWidget(self.ack_comment_edit, 7, 0, 1, 2)

        request_btn = QPushButton(_('REQUEST ACKNOWLEDGE'), self)
        request_btn.clicked.connect(self.accept)
        request_btn.setObjectName('valid')
        request_btn.setMinimumHeight(30)
        request_btn.setDefault(True)
        ack_layout.addWidget(request_btn, 8, 0, 1, 2)

        main_layout.addWidget(ack_widget)
Example #48
0
class TagBrowserWidget(QWidget):  # {{{

    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self.parent = parent
        self._layout = QVBoxLayout()
        self.setLayout(self._layout)
        self._layout.setContentsMargins(0,0,0,0)

        # Set up the find box & button
        search_layout = QHBoxLayout()
        self._layout.addLayout(search_layout)
        self.item_search = HistoryLineEdit(parent)
        self.item_search.setMinimumContentsLength(5)
        self.item_search.setSizeAdjustPolicy(self.item_search.AdjustToMinimumContentsLengthWithIcon)
        try:
            self.item_search.lineEdit().setPlaceholderText(
                                                _('Find item in tag browser'))
        except:
            pass             # Using Qt < 4.7
        self.item_search.setToolTip(_(
        'Search for items. This is a "contains" search; items containing the\n'
        'text anywhere in the name will be found. You can limit the search\n'
        'to particular categories using syntax similar to search. For example,\n'
        'tags:foo will find foo in any tag, but not in authors etc. Entering\n'
        '*foo will filter all categories at once, showing only those items\n'
        'containing the text "foo"'))
        search_layout.addWidget(self.item_search)
        ac = QAction(parent)
        parent.addAction(ac)
        parent.keyboard.register_shortcut('tag browser find box',
                _('Find item'), default_keys=(),
                action=ac, group=_('Tag Browser'))
        ac.triggered.connect(self.set_focus_to_find_box)

        self.search_button = QToolButton()
        self.search_button.setText(_('Find'))
        self.search_button.setToolTip(_('Find the first/next matching item'))
        search_layout.addWidget(self.search_button)
        ac = QAction(parent)
        parent.addAction(ac)
        parent.keyboard.register_shortcut('tag browser find button',
                _('Find button'), default_keys=(),
                action=ac, group=_('Tag Browser'))
        ac.triggered.connect(self.search_button.click)

        self.expand_button = QToolButton()
        self.expand_button.setText('-')
        self.expand_button.setToolTip(_('Collapse all categories'))
        search_layout.addWidget(self.expand_button)
        search_layout.setStretch(0, 10)
        search_layout.setStretch(1, 1)
        search_layout.setStretch(2, 1)
        ac = QAction(parent)
        parent.addAction(ac)
        parent.keyboard.register_shortcut('tag browser collapse all',
                _('Collapse all'), default_keys=(),
                action=ac, group=_('Tag Browser'))
        ac.triggered.connect(self.expand_button.clicked)

        self.current_find_position = None
        self.search_button.clicked.connect(self.find)
        self.item_search.initialize('tag_browser_search')
        self.item_search.lineEdit().returnPressed.connect(self.do_find)
        self.item_search.lineEdit().textEdited.connect(self.find_text_changed)
        self.item_search.activated[str].connect(self.do_find)
        self.item_search.completer().setCaseSensitivity(Qt.CaseSensitive)

        parent.tags_view = TagsView(parent)
        self.tags_view = parent.tags_view
        self.expand_button.clicked.connect(self.tags_view.collapseAll)
        self._layout.addWidget(parent.tags_view)

        # Now the floating 'not found' box
        l = QLabel(self.tags_view)
        self.not_found_label = l
        l.setFrameStyle(QFrame.StyledPanel)
        l.setAutoFillBackground(True)
        l.setText('<p><b>'+_('No More Matches.</b><p> Click Find again to go to first match'))
        l.setAlignment(Qt.AlignVCenter)
        l.setWordWrap(True)
        l.resize(l.sizeHint())
        l.move(10,20)
        l.setVisible(False)
        self.not_found_label_timer = QTimer()
        self.not_found_label_timer.setSingleShot(True)
        self.not_found_label_timer.timeout.connect(self.not_found_label_timer_event,
                                                   type=Qt.QueuedConnection)

        parent.alter_tb = l = QPushButton(parent)
        l.setText(_('Alter Tag Browser'))
        l.setIcon(QIcon(I('tags.png')))
        l.m = QMenu()
        l.setMenu(l.m)
        self._layout.addWidget(l)
        ac = QAction(parent)
        parent.addAction(ac)
        parent.keyboard.register_shortcut('tag browser alter',
                _('Alter tag browser'), default_keys=(),
                action=ac, group=_('Tag Browser'))
        ac.triggered.connect(l.showMenu)

        sb = l.m.addAction(_('Sort by'))
        sb.m = l.sort_menu = QMenu(l.m)
        sb.setMenu(sb.m)
        sb.bg = QActionGroup(sb)

        # Must be in the same order as db2.CATEGORY_SORTS
        for i, x in enumerate((_('Sort by name'), _('Sort by number of books'),
                  _('Sort by average rating'))):
            a = sb.m.addAction(x)
            sb.bg.addAction(a)
            a.setCheckable(True)
            if i == 0:
                a.setChecked(True)
        sb.setToolTip(
                _('Set the sort order for entries in the Tag Browser'))
        sb.setStatusTip(sb.toolTip())

        ma = l.m.addAction(_('Search type when selecting multiple items'))
        ma.m = l.match_menu = QMenu(l.m)
        ma.setMenu(ma.m)
        ma.ag = QActionGroup(ma)

        # Must be in the same order as db2.MATCH_TYPE
        for i, x in enumerate((_('Match any of the items'), _('Match all of the items'))):
            a = ma.m.addAction(x)
            ma.ag.addAction(a)
            a.setCheckable(True)
            if i == 0:
                a.setChecked(True)
        ma.setToolTip(
                _('When selecting multiple entries in the Tag Browser '
                    'match any or all of them'))
        ma.setStatusTip(ma.toolTip())

        mt = l.m.addAction(_('Manage authors, tags, etc.'))
        mt.setToolTip(_('All of these category_managers are available by right-clicking '
                       'on items in the tag browser above'))
        mt.m = l.manage_menu = QMenu(l.m)
        mt.setMenu(mt.m)

        ac = QAction(parent)
        parent.addAction(ac)
        parent.keyboard.register_shortcut('tag browser toggle item',
                _("'Click' found item"), default_keys=(),
                action=ac, group=_('Tag Browser'))
        ac.triggered.connect(self.toggle_item)

        # self.leak_test_timer = QTimer(self)
        # self.leak_test_timer.timeout.connect(self.test_for_leak)
        # self.leak_test_timer.start(5000)

    def toggle_item(self):
        self.tags_view.toggle_current_index()

    def set_pane_is_visible(self, to_what):
        self.tags_view.set_pane_is_visible(to_what)

    def find_text_changed(self, str):
        self.current_find_position = None

    def set_focus_to_find_box(self):
        self.item_search.setFocus()
        self.item_search.lineEdit().selectAll()

    def do_find(self, str=None):
        self.current_find_position = None
        self.find()

    def find(self):
        model = self.tags_view.model()
        model.clear_boxed()
        txt = unicode(self.item_search.currentText()).strip()

        if txt.startswith('*'):
            model.set_categories_filter(txt[1:])
            self.tags_view.recount()
            self.current_find_position = None
            return
        if model.get_categories_filter():
            model.set_categories_filter(None)
            self.tags_view.recount()
            self.current_find_position = None

        if not txt:
            return

        self.item_search.lineEdit().blockSignals(True)
        self.search_button.setFocus(True)
        self.item_search.lineEdit().blockSignals(False)

        key = None
        colon = txt.rfind(':') if len(txt) > 2 else 0
        if colon > 0:
            key = self.parent.library_view.model().db.\
                        field_metadata.search_term_to_field_key(txt[:colon])
            txt = txt[colon+1:]

        self.current_find_position = \
            model.find_item_node(key, txt, self.current_find_position)

        if self.current_find_position:
            self.tags_view.show_item_at_path(self.current_find_position, box=True)
        elif self.item_search.text():
            self.not_found_label.setVisible(True)
            if self.tags_view.verticalScrollBar().isVisible():
                sbw = self.tags_view.verticalScrollBar().width()
            else:
                sbw = 0
            width = self.width() - 8 - sbw
            height = self.not_found_label.heightForWidth(width) + 20
            self.not_found_label.resize(width, height)
            self.not_found_label.move(4, 10)
            self.not_found_label_timer.start(2000)

    def not_found_label_timer_event(self):
        self.not_found_label.setVisible(False)
Example #49
0
class TagBrowserWidget(QFrame):  # {{{

    def __init__(self, parent):
        QFrame.__init__(self, parent)
        self.setFrameStyle(QFrame.NoFrame if gprefs['tag_browser_old_look'] else QFrame.StyledPanel)
        self._parent = parent
        self._layout = QVBoxLayout(self)
        self._layout.setContentsMargins(0,0,0,0)

        # Set up the find box & button
        self.tb_bar = tbb = TagBrowserBar(self)
        self.alter_tb, self.item_search, self.search_button = tbb.alter_tb, tbb.item_search, tbb.search_button
        self.toggle_search_button = tbb.toggle_search_button
        self._layout.addWidget(tbb)

        self.current_find_position = None
        self.search_button.clicked.connect(self.find)
        self.item_search.lineEdit().textEdited.connect(self.find_text_changed)
        self.item_search.activated[str].connect(self.do_find)

        # The tags view
        parent.tags_view = TagsView(parent)
        self.tags_view = parent.tags_view
        self._layout.insertWidget(0, parent.tags_view)

        # Now the floating 'not found' box
        l = QLabel(self.tags_view)
        self.not_found_label = l
        l.setFrameStyle(QFrame.StyledPanel)
        l.setAutoFillBackground(True)
        l.setText('<p><b>'+_('No More Matches.</b><p> Click Find again to go to first match'))
        l.setAlignment(Qt.AlignVCenter)
        l.setWordWrap(True)
        l.resize(l.sizeHint())
        l.move(10,20)
        l.setVisible(False)
        self.not_found_label_timer = QTimer()
        self.not_found_label_timer.setSingleShot(True)
        self.not_found_label_timer.timeout.connect(self.not_found_label_timer_event,
                                                   type=Qt.QueuedConnection)
        # The Alter Tag Browser button
        l = self.alter_tb
        self.collapse_all_action = ac = QAction(parent)
        parent.addAction(ac)
        parent.keyboard.register_shortcut('tag browser collapse all',
                _('Collapse all'), default_keys=(),
                action=ac, group=_('Tag browser'))
        connect_lambda(ac.triggered, self, lambda self: self.tags_view.collapseAll())

        ac = QAction(parent)
        parent.addAction(ac)
        parent.keyboard.register_shortcut('tag browser alter',
                _('Configure Tag browser'), default_keys=(),
                action=ac, group=_('Tag browser'))
        ac.triggered.connect(l.showMenu)

        sb = l.m.addAction(_('Sort by'))
        sb.m = l.sort_menu = QMenu(l.m)
        sb.setMenu(sb.m)
        sb.bg = QActionGroup(sb)

        # Must be in the same order as db2.CATEGORY_SORTS
        for i, x in enumerate((_('Name'), _('Number of books'),
                  _('Average rating'))):
            a = sb.m.addAction(x)
            sb.bg.addAction(a)
            a.setCheckable(True)
            if i == 0:
                a.setChecked(True)
        sb.setToolTip(
                _('Set the sort order for entries in the Tag browser'))
        sb.setStatusTip(sb.toolTip())

        ma = l.m.addAction(_('Search type when selecting multiple items'))
        ma.m = l.match_menu = QMenu(l.m)
        ma.setMenu(ma.m)
        ma.ag = QActionGroup(ma)

        # Must be in the same order as db2.MATCH_TYPE
        for i, x in enumerate((_('Match any of the items'), _('Match all of the items'))):
            a = ma.m.addAction(x)
            ma.ag.addAction(a)
            a.setCheckable(True)
            if i == 0:
                a.setChecked(True)
        ma.setToolTip(
                _('When selecting multiple entries in the Tag browser '
                    'match any or all of them'))
        ma.setStatusTip(ma.toolTip())

        mt = l.m.addAction(_('Manage authors, tags, etc.'))
        mt.setToolTip(_('All of these category_managers are available by right-clicking '
                       'on items in the tag browser above'))
        mt.m = l.manage_menu = QMenu(l.m)
        mt.setMenu(mt.m)

        ac = QAction(parent)
        parent.addAction(ac)
        parent.keyboard.register_shortcut('tag browser toggle item',
                _("'Click' found item"), default_keys=(),
                action=ac, group=_('Tag browser'))
        ac.triggered.connect(self.toggle_item)

        # self.leak_test_timer = QTimer(self)
        # self.leak_test_timer.timeout.connect(self.test_for_leak)
        # self.leak_test_timer.start(5000)

    def save_state(self):
        gprefs.set('tag browser search box visible', self.toggle_search_button.isChecked())

    def toggle_item(self):
        self.tags_view.toggle_current_index()

    def set_pane_is_visible(self, to_what):
        self.tags_view.set_pane_is_visible(to_what)

    def find_text_changed(self, str):
        self.current_find_position = None

    def set_focus_to_find_box(self):
        self.tb_bar.set_focus_to_find_box()

    def do_find(self, str=None):
        self.current_find_position = None
        self.find()

    @property
    def find_text(self):
        return unicode_type(self.item_search.currentText()).strip()

    def find(self):
        model = self.tags_view.model()
        model.clear_boxed()
        txt = self.find_text

        if txt.startswith('*'):
            model.set_categories_filter(txt[1:])
            self.tags_view.recount()
            self.current_find_position = None
            return
        if model.get_categories_filter():
            model.set_categories_filter(None)
            self.tags_view.recount()
            self.current_find_position = None

        if not txt:
            return

        self.item_search.lineEdit().blockSignals(True)
        self.search_button.setFocus(True)
        self.item_search.lineEdit().blockSignals(False)

        key = None
        colon = txt.rfind(':') if len(txt) > 2 else 0
        if colon > 0:
            key = self._parent.library_view.model().db.\
                        field_metadata.search_term_to_field_key(txt[:colon])
            txt = txt[colon+1:]

        self.current_find_position = \
            model.find_item_node(key, txt, self.current_find_position)

        if self.current_find_position:
            self.tags_view.show_item_at_path(self.current_find_position, box=True)
        elif self.item_search.text():
            self.not_found_label.setVisible(True)
            if self.tags_view.verticalScrollBar().isVisible():
                sbw = self.tags_view.verticalScrollBar().width()
            else:
                sbw = 0
            width = self.width() - 8 - sbw
            height = self.not_found_label.heightForWidth(width) + 20
            self.not_found_label.resize(width, height)
            self.not_found_label.move(4, 10)
            self.not_found_label_timer.start(2000)

    def not_found_label_timer_event(self):
        self.not_found_label.setVisible(False)

    def keyPressEvent(self, ev):
        if ev.key() in (Qt.Key_Enter, Qt.Key_Return) and self.find_text:
            self.find()
            ev.accept()
            return
        return QFrame.keyPressEvent(self, ev)
Example #50
0
    def addVignette (self, warrior):
        label_name = "label_vignette_left"
        if self.current_page == 0 : 
            widget_vignette = QWidget(self.vignettes_gauche)
        else:
            label_name = "label_vignette_right"
            widget_vignette = QWidget(self.vignettes_droite)        
        # widget_vignette.setObjectName("toto")
        # widget_vignette.setStyleSheet("#toto { background-color: rgb(170, 255, 0,0);}")
        layout_one_vignette = QVBoxLayout(widget_vignette)
        layout_one_vignette.setSpacing(0)
        layout_one_vignette.setContentsMargins(0, 0, 0, 0)
        if type(warrior)== Temple:
            warrior_button = TempleButton(self.model, warrior, widget_vignette)
        else:
            warrior_button = HerosButton(self.model, warrior, widget_vignette)
        warrior_button.connect()
        layout_one_vignette.setAlignment(QtCore.Qt.AlignCenter)
#         warrior_button.setStyleSheet("QPushButton { background-color: rgb(170, 255, 0);border-style: outset; border-width: 2px; border-color: beige;}")
        # warrior_button.setAttribute(QtCore.Qt.WA_TranslucentBackground,True)
        layout_one_vignette.addWidget(warrior_button)
        
        # label
        if (type(warrior)==Temple):
            warrior_label = TempleLabel(warrior, widget_vignette)
        else:
            warrior_label = HerosLabel(warrior, widget_vignette)
        warrior_label.connect()
        warrior_label.setObjectName(label_name)
        layout_one_vignette.addWidget(warrior_label)
        

#         warrior_button.setFixedSize(QSize(100,120))
        max_col = 3

#         groupe_name = warrior.groupe().name
#         if warrior.masterGroupe() != None : 
#             groupe_name = warrior.masterGroupe().name + "/" + groupe_name
        
 
        
        size_pic_height = warrior_button.size().height()
        size_pic_width = warrior_button.size().width()
        ratio_h = warrior.thumb.height() / size_pic_height
        ratio_v = warrior.thumb.width() / size_pic_width
        picture = warrior.thumb
        if ratio_h < ratio_v :
            if not warrior.thumb.isNull():
                picture = warrior.thumb.scaledToHeight(size_pic_height)
                diff = picture.width() - size_pic_width
                picture = picture.copy(diff / 2.0, 0, size_pic_width, size_pic_height)
        else:
            if not warrior.thumb.isNull():
                picture = warrior.thumb.scaledToWidth(size_pic_width)
                diff = picture.height() - size_pic_height
                picture = picture.copy(0, diff / 2.0, size_pic_width, size_pic_height)

        icon = QIcon(picture)
        warrior_button.setIcon(icon)
        warrior_button.setIconSize(QSize(picture.width() - 3, picture.height() - 3))

            

        if self.nb_col == 0:
            self.nb_row = self.nb_row + 1

        if self.current_page == 0 : 
            self.gridLayout.addWidget(widget_vignette, self.nb_row, self.nb_col)
        else:
            self.gridLayout_2.addWidget(widget_vignette, self.nb_row, self.nb_col)
        self.nb_col = (self.nb_col + 1) % max_col
    def initialize(self):
        """
        Initialize QDialog

        """

        main_layout = QVBoxLayout()
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        about_widget = QWidget()
        about_widget.setObjectName('about')
        about_layout = QVBoxLayout(about_widget)

        # QDialog Title
        about_title = QLabel(_('About'))
        about_title.setFixedHeight(40)
        about_title.setObjectName('aboutheader')
        main_layout.addWidget(about_title)

        # Main About
        about_text = "%s\nVersion %s\nCopyright: %s" % \
            (__application__, __version__, __copyright__)
        main_about = QLabel(about_text)
        main_about.setObjectName('aboutmain')
        main_about.setToolTip(__application__)
        about_layout.addWidget(main_about)
        about_layout.setAlignment(main_about, Qt.AlignCenter)

        # Release notes
        release_data = QLabel(__releasenotes__)
        release_data.setObjectName('about')
        release_data.setToolTip(_('Release notes'))
        release_data.setWordWrap(True)
        about_layout.addWidget(release_data)

        # Homepage
        home_title = QLabel(_('Home page:'))
        home_title.setObjectName('abouttitle')
        home_title.setToolTip(_('Home page'))
        about_layout.addWidget(home_title)
        about_layout.addWidget(self.get_external_link_label(__project_url__))

        # User Doc
        doc_title = QLabel(_('User documentation'))
        doc_title.setObjectName('abouttitle')
        doc_title.setToolTip(_('User documentation'))
        about_layout.addWidget(doc_title)
        about_layout.addWidget(self.get_external_link_label(__doc_url__))

        # Alignak
        alignak_title = QLabel(_('About Alignak solution:'))
        alignak_title.setObjectName('abouttitle')
        alignak_title.setToolTip(_('About Alignak solution'))
        about_layout.addWidget(alignak_title)
        about_layout.addWidget(self.get_external_link_label(__alignak_url__))

        # Powered
        powered_title = QLabel(_('Powered by:'))
        powered_title.setObjectName('abouttitle')
        powered_title.setToolTip(_('PyQt5'))
        about_layout.addWidget(powered_title)
        powered_data = self.get_external_link_label('https://www.riverbankcomputing.com/', 'PyQt5')
        about_layout.addWidget(powered_data)

        main_layout.addWidget(about_widget)