Example #1
0
    def __init__(self, iter: int, parent=None) -> None:
        super().__init__(parent)

        self._iter = iter
        self._delegateWidth = 70
        self._delegateHeight = 70

        self._real_view = QListView(self)
        self._real_view.setViewMode(QListView.IconMode)
        self._real_view.setGridSize(
            QSize(self._delegateWidth, self._delegateHeight))
        self._real_view.setItemDelegate(
            RealizationDelegate(self._delegateWidth, self._delegateHeight,
                                self))
        self._real_view.setSelectionMode(QAbstractItemView.SingleSelection)
        self._real_view.setFlow(QListView.LeftToRight)
        self._real_view.setWrapping(True)
        self._real_view.setResizeMode(QListView.Adjust)
        self._real_view.setUniformItemSizes(True)

        self._real_view.currentChanged = lambda current, _: self.currentChanged.emit(
            current)

        layout = QVBoxLayout()
        layout.addWidget(self._real_view)

        self.setLayout(layout)
Example #2
0
    def __init__(self):
        super(ConfigDialog, self).__init__()

        self.needs_reload = True

        # Set size and position
        self.setGeometry(0, 0, 900, 550)
        frameGm = self.frameGeometry()
        screen = QApplication.desktop().screenNumber(
            QApplication.desktop().cursor().pos())
        centerPoint = QApplication.desktop().screenGeometry(screen).center()
        frameGm.moveCenter(centerPoint)
        self.move(frameGm.topLeft())

        self.contentsWidget = QListView()
        self.contentsWidget.setViewMode(QListView.IconMode)
        # self.contentsWidget.setIconSize(QSize(96, 84))
        self.contentsWidget.setMovement(QListView.Static)
        self.contentsWidget.setMaximumWidth(174)
        self.contentsWidget.setSpacing(12)
        self.contentsWidget.setSelectionMode(QAbstractItemView.SingleSelection)

        self.contentsModel = QStandardItemModel()
        self.contentsWidget.setModel(self.contentsModel)
        self.contentsWidget.selectionModel().currentChanged.connect(
            self.changePage)

        self.buttonboxWidget = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel
            | QDialogButtonBox.Apply  # | QDialogButtonBox.Help
        )
        self.buttonboxWidget.button(QDialogButtonBox.Ok).clicked.connect(
            self.ok)
        self.buttonboxWidget.button(QDialogButtonBox.Apply).clicked.connect(
            self.apply)
        self.buttonboxWidget.button(QDialogButtonBox.Cancel).clicked.connect(
            self.close)

        self.pagesWidget = QStackedWidget()

        horizontalLayout = QHBoxLayout()
        horizontalLayout.addWidget(self.contentsWidget)
        horizontalLayout.addWidget(self.pagesWidget, 1)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(horizontalLayout)
        # mainLayout.addStretch(1)
        mainLayout.addSpacing(12)
        mainLayout.addWidget(self.buttonboxWidget)

        self.setLayout(mainLayout)
        self.setWindowTitle("Config Dialog")

        # Set modality
        self.setModal(True)

        self.lastwidget = None

        # Restore Settings
        pluginmanager.attach(self.request_reload, Filters.COMPLETE)
Example #3
0
 def commentaryListView(self):
     # https://doc.qt.io/archives/qtforpython-5.12/PySide2/QtCore/QStringListModel.html
     # https://gist.github.com/minoue/9f384cd36339429eb0bf
     # https://www.pythoncentral.io/pyside-pyqt-tutorial-qlistview-and-qstandarditemmodel/
     list = QListView()
     list.setEditTriggers(QAbstractItemView.NoEditTriggers)
     model = QStandardItemModel(list)
     for index, commentary in enumerate(self.parent.commentaryFullNameList):
         item = QStandardItem(commentary)
         item.setToolTip(self.parent.commentaryList[index])
         #item.setCheckable(True)
         #item.setCheckState(Qt.CheckState.Checked)
         #item.setCheckState(Qt.CheckState.Unchecked)
         #print(item.checkState() is Qt.CheckState.Checked)
         model.appendRow(item)
     #model = QStringListModel(self.parent.commentaryList)
     #model = QStringListModel(self.parent.commentaryFullNameList)
     list.setModel(model)
     if config.commentaryText in self.parent.commentaryList:
         list.setCurrentIndex(
             model.index(
                 self.parent.commentaryList.index(config.commentaryText),
                 0))
     list.selectionModel().selectionChanged.connect(self.commentarySelected)
     return list
Example #4
0
    def __init__(self, parent):
        super(InfoFrame, self).__init__(parent)

        self.widget_layout = QVBoxLayout(self)
        self.setLayout(self.widget_layout)

        self.section_label = QLabel(self)
        self.section_label.setText("Informations")
        self.widget_layout.addWidget(self.section_label)

        self.label = QLabel(self)
        self.label.setText("Select information to collect after successfull connection. Keep in mind that the more "
                           "data you collect the more suspicious you are for antivirus software. You can "
                           "change these settings later.")
        self.label.setWordWrap(True)
        self.widget_layout.addWidget(self.label)

        self.list = QListView(self)
        self.model = QStandardItemModel(self.list)
        self.widget_layout.addWidget(self.list)
        self.list.setModel(self.model)

        self.item_string = {}
        infos = ConfigManager.get_infos()

        for info in infos:
            self.item_string[info] = {"name": " ".join(info.capitalize().split("_"))}

        for string in self.item_string:
            item = QStandardItem(self.item_string.get(string).get("name"))
            item.setFlags(Qt.ItemIsEnabled)
            item.setData(QVariant(Qt.Checked), Qt.CheckStateRole)
            self.model.appendRow(item)
Example #5
0
 def commentaryListView(self):
     # https://doc.qt.io/archives/qtforpython-5.12/PySide2/QtCore/QStringListModel.html
     # https://gist.github.com/minoue/9f384cd36339429eb0bf
     # https://www.pythoncentral.io/pyside-pyqt-tutorial-qlistview-and-qstandarditemmodel/
     self.commentaryListView = QListView()
     self.commentaryListView.setEditTriggers(QAbstractItemView.NoEditTriggers)
     self.reloadCommentariesListModel()
     return self.commentaryListView
Example #6
0
 def chapterListView(self):
     self.chapterlist = QListView()
     self.chapterlist.setEditTriggers(QAbstractItemView.NoEditTriggers)
     topicList = self.getBookTopicList()
     self.chapterModel = QStringListModel(topicList)
     self.chapterlist.setModel(self.chapterModel)
     self.scrollChapterList(topicList)
     self.chapterlist.selectionModel().selectionChanged.connect(self.chapterSelected)
     return self.chapterlist
Example #7
0
 def videoListView(self):
     list = QListView()
     list.setEditTriggers(QAbstractItemView.NoEditTriggers)
     model = QStandardItemModel(list)
     for file in self.videoList:
         item = QStandardItem(file)
         model.appendRow(item)
     list.setModel(model)
     list.selectionModel().selectionChanged.connect(self.playSelectedVideo)
     return list
Example #8
0
    def __init__(self,
                 parent,
                 help_text=None,
                 item_styles=ITEM_STYLES,
                 item_separator_styles=ITEM_SEPARATOR_STYLES):
        """Multi purpose switcher."""
        super(Switcher, self).__init__(parent)
        self._visible_rows = 0
        self._modes = {}
        self._mode_on = ''
        self._item_styles = item_styles
        self._item_separator_styles = item_separator_styles

        # Widgets
        self.edit = QLineEdit(self)
        self.list = QListView(self)
        self.model = QStandardItemModel(self.list)
        self.proxy = SwitcherProxyModel(self.list)
        self.filter = KeyPressFilter()

        # Widgets setup
        self.setWindowFlags(Qt.Popup | Qt.FramelessWindowHint)
        self.setWindowOpacity(0.95)
        #        self.setMinimumHeight(self._MIN_HEIGHT)
        self.setMaximumHeight(self._MAX_HEIGHT)
        self.edit.installEventFilter(self.filter)
        self.edit.setPlaceholderText(help_text if help_text else '')
        self.list.setMinimumWidth(self._MIN_WIDTH)
        self.list.setSpacing(-2)
        self.list.setItemDelegate(HTMLDelegate(self))
        self.list.setFocusPolicy(Qt.NoFocus)
        self.list.setSelectionBehavior(self.list.SelectItems)
        self.list.setSelectionMode(self.list.SingleSelection)
        self.list.setVerticalScrollMode(QAbstractItemView.ScrollPerItem)
        self.proxy.setSourceModel(self.model)
        self.list.setModel(self.proxy)

        # Layout
        layout = QVBoxLayout()
        layout.addWidget(self.edit)
        layout.addWidget(self.list)
        self.setLayout(layout)

        # Signals
        self.filter.sig_up_key_pressed.connect(self.previous_row)
        self.filter.sig_down_key_pressed.connect(self.next_row)
        self.filter.sig_enter_key_pressed.connect(self.enter)
        self.edit.textChanged.connect(self.setup)
        self.edit.textChanged.connect(self.sig_text_changed)
        self.edit.returnPressed.connect(self.enter)
        self.list.clicked.connect(self.enter)
        self.list.clicked.connect(self.edit.setFocus)
        self.list.selectionModel().currentChanged.connect(
            self.current_item_changed)
        self.edit.setFocus()
Example #9
0
 def __init__(self, parent, batch_manager):
     super().__init__(parent)
     self.task_count = 0
     self.calculation_manager = batch_manager
     self.whole_progress = QProgressBar(self)
     self.whole_progress.setMinimum(0)
     self.whole_progress.setMaximum(1)
     self.whole_progress.setFormat("%v of %m")
     self.whole_progress.setTextVisible(True)
     self.part_progress = QProgressBar(self)
     self.part_progress.setMinimum(0)
     self.part_progress.setMaximum(1)
     self.part_progress.setFormat("%v of %m")
     self.whole_label = QLabel("All batch progress:", self)
     self.part_label = QLabel("Single batch progress:", self)
     self.cancel_remove_btn = QPushButton("Remove task")
     self.cancel_remove_btn.setDisabled(True)
     self.logs = ExceptionList(self)
     self.logs.setToolTip("Logs")
     self.task_view = QListView()
     self.task_que = QStandardItemModel(self)
     self.task_view.setModel(self.task_que)
     self.process_num_timer = QTimer()
     self.process_num_timer.setInterval(1000)
     self.process_num_timer.setSingleShot(True)
     self.process_num_timer.timeout.connect(self.change_number_of_workers)
     self.number_of_process = QSpinBox(self)
     self.number_of_process.setRange(1, multiprocessing.cpu_count())
     self.number_of_process.setValue(1)
     self.number_of_process.setToolTip(
         "Number of process used in batch calculation")
     self.number_of_process.valueChanged.connect(
         self.process_num_timer_start)
     self.progress_item_dict = {}
     layout = QGridLayout()
     layout.addWidget(self.whole_label, 0, 0, Qt.AlignRight)
     layout.addWidget(self.whole_progress, 0, 1, 1, 2)
     layout.addWidget(self.part_label, 1, 0, Qt.AlignRight)
     layout.addWidget(self.part_progress, 1, 1, 1, 2)
     lab = QLabel("Number of process:")
     lab.setToolTip("Number of process used in batch calculation")
     layout.addWidget(lab, 2, 0)
     layout.addWidget(self.number_of_process, 2, 1)
     layout.addWidget(self.logs, 3, 0, 2, 3)
     layout.addWidget(self.task_view, 0, 4, 4, 1)
     layout.addWidget(self.cancel_remove_btn, 4, 4, 1, 1)
     layout.setColumnMinimumWidth(2, 10)
     layout.setColumnStretch(2, 1)
     self.setLayout(layout)
     self.preview_timer = QTimer()
     self.preview_timer.setInterval(1000)
     self.preview_timer.timeout.connect(self.update_info)
     self.task_view.selectionModel().currentChanged.connect(
         self.task_selection_change)
     self.cancel_remove_btn.clicked.connect(self.task_cancel_remove)
Example #10
0
    def setupUI(self):
        from qtpy.QtGui import QStandardItemModel
        from qtpy.QtWidgets import (QPushButton, QLabel, QListView,
                                    QAbstractItemView, QHBoxLayout,
                                    QVBoxLayout, QLineEdit)

        mainLayout = QVBoxLayout()

        readingListLayout = QVBoxLayout()

        readingListLayout.addWidget(QLabel(self.translation[0]))
        readingListLayout.addWidget(
            QLabel("{0}{1}".format(self.translation[1], self.today)))

        filterLayout = QHBoxLayout()
        filterLayout.addWidget(QLabel(self.translation[2]))
        self.filterEntry = QLineEdit()
        self.filterEntry.textChanged.connect(self.resetItems)
        filterLayout.addWidget(self.filterEntry)
        readingListLayout.addLayout(filterLayout)

        self.readingList = QListView()
        self.readingList.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.readingListModel = QStandardItemModel(self.readingList)
        self.readingList.setModel(self.readingListModel)
        self.resetItems()
        self.readingListModel.itemChanged.connect(self.itemChanged)
        #print(self.readingList.currentIndex().row())
        #self.readingList.selectionModel().selectionChanged.connect(self.function)
        readingListLayout.addWidget(self.readingList)

        buttonsLayout = QHBoxLayout()

        button = QPushButton(self.translation[3])
        button.clicked.connect(self.openInTabs)
        buttonsLayout.addWidget(button)

        self.hideShowButton = QPushButton(self.translation[4])
        self.hideShowButton.clicked.connect(self.hideShowCheckedItems)
        buttonsLayout.addWidget(self.hideShowButton)

        button = QPushButton(self.translation[6])
        button.clicked.connect(self.resetAllItems)
        buttonsLayout.addWidget(button)

        button = QPushButton(self.translation[7])
        button.clicked.connect(self.saveProgress)
        buttonsLayout.addWidget(button)

        mainLayout.addLayout(readingListLayout)
        mainLayout.addLayout(buttonsLayout)

        self.setLayout(mainLayout)
Example #11
0
    def _make_plot_list(self):
        """
        Make a list showing the names of the plots
        :return: A QListView object which will contain plot names
        """
        list_view = QListView(self)
        list_view.setSelectionMode(QAbstractItemView.ExtendedSelection)
        plot_list = QStandardItemModel(list_view)
        list_view.setModel(plot_list)

        list_view.installEventFilter(self)
        return list_view
Example #12
0
 def bookListView(self):
     self.bookList = QListView()
     self.bookList.setEditTriggers(QAbstractItemView.NoEditTriggers)
     self.bookModel = QStringListModel(self.parent.referenceBookList)
     self.bookList.setModel(self.bookModel)
     if config.book in self.parent.referenceBookList:
         self.bookList.setCurrentIndex(
             self.bookModel.index(
                 self.parent.referenceBookList.index(config.book), 0))
     self.bookList.selectionModel().selectionChanged.connect(
         self.bookSelected)
     return self.bookList
Example #13
0
    def __init__(self, folder, parent=None):
        """Init."""
        super().__init__(parent)
        font = get_font()

        self.folder = folder
        self.path_selected = ""
        self.path_list = []
        self.results_old = {}
        self.setWindowTitle("Path Finder")
        self.setWindowFlags(Qt.Popup | Qt.FramelessWindowHint)
        self.setWindowOpacity(0.95)
        self.setFixedHeight(self._MAX_HEIGHT)
        self.setFont(font)

        # Set List widget
        self.list_viewer = QListView(self)
        self.list_viewer.setAttribute(Qt.WA_TransparentForMouseEvents)
        self.list_viewer.setFocusPolicy(Qt.NoFocus)
        self.list_viewer.setFixedWidth(self._MIN_WIDTH)
        self.list_viewer.setUniformItemSizes(True)
        self.list_model = QStringListModel()
        self.list_viewer.setModel(self.list_model)
        self.list_viewer.setFont(font)

        # Set edit
        self.edit = PathFinderEdit(self, textChanged=self.update_list)
        self.edit.setFont(font)
        self.edit.sig_esc_key_pressed.connect(self.close)
        self.edit.sig_enter_key_pressed.connect(self.enter)

        self.edit.sig_up_key_pressed.connect(lambda: self.prev_row(1))
        self.edit.sig_pg_up_key_pressed.connect(self.pg_up)
        self.edit.sig_pg_half_up_key_pressed.connect(self.pg_half_up)

        self.edit.sig_down_key_pressed.connect(lambda: self.next_row(1))
        self.edit.sig_pg_down_key_pressed.connect(self.pg_down)
        self.edit.sig_pg_half_down_key_pressed.connect(self.pg_half_down)

        layout = QVBoxLayout()
        layout.addWidget(self.edit)
        layout.addWidget(self.list_viewer)

        self.setLayout(layout)

        self.get_path_list()
        self.update_list()

        self.edit.setFocus()
Example #14
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.resize(200, 300)

        self.progress_log_list_view = QListView(self)
        self.progress_log_item_model = BufferedItemModel(
            self.progress_log_list_view)

        self.progress_log_list_view.setUniformItemSizes(True)
        self.progress_log_list_view.setModel(self.progress_log_item_model)

        self.setLayout(QVBoxLayout(self))
        self.layout().addWidget(self.progress_log_list_view)

        self.__bind_auto_scroll_handlers()