Esempio n. 1
0
    def __init__(self, parent, picture_parameter: dict):
        QFrame.__init__(self, parent, flags=Qt.FramelessWindowHint)
        self.buffer = parent.buffer
        self.picture_parameter = picture_parameter

        self.picture_label = QLabel()
        self.resize_multiple = 1

        scroll = QScrollArea(self)
        scroll.setWidget(self.picture_label)
        scroll.setObjectName('picture')

        self.name_combo = QComboBox(self)
        self.index_combo = QComboBox(self)
        self.palette_combo = QComboBox(self)
        self.resize_combo = QComboBox(self)

        self.name_combo.setFixedWidth(120)
        self.index_combo.setFixedWidth(120)
        self.palette_combo.setFixedWidth(120)
        self.resize_combo.setFixedWidth(120)

        self.name_combo.setItemDelegate(QStyledItemDelegate())
        self.index_combo.setItemDelegate(QStyledItemDelegate())
        self.palette_combo.setItemDelegate(QStyledItemDelegate())
        self.resize_combo.setItemDelegate(QStyledItemDelegate())

        self.resize_combo.addItems([f'          × {i + 1}' for i in range(4)])

        self.name_combo.currentTextChanged[str].connect(self.name_change)
        self.index_combo.currentIndexChanged.connect(self.refresh_data)
        self.palette_combo.currentIndexChanged.connect(self.refresh_data)
        self.resize_combo.currentIndexChanged.connect(self.refresh_data)

        self.name_combo.addItems(picture_parameter)

        output_button = QPushButton('導出圖片')
        input_button = QPushButton('導入圖片')
        output_button.clicked.connect(self.output_picture)
        input_button.clicked.connect(self.input_picture)

        control_layout = QVBoxLayout()
        control_layout.addWidget(QLabel('選擇圖片'), alignment=Qt.AlignLeft)
        control_layout.addWidget(self.name_combo, alignment=Qt.AlignRight)
        control_layout.addWidget(QLabel('選擇編號'), alignment=Qt.AlignLeft)
        control_layout.addWidget(self.index_combo, alignment=Qt.AlignRight)
        control_layout.addWidget(QLabel('選擇色板'), alignment=Qt.AlignLeft)
        control_layout.addWidget(self.palette_combo, alignment=Qt.AlignRight)
        control_layout.addWidget(QLabel('缩放比例'), alignment=Qt.AlignLeft)
        control_layout.addWidget(self.resize_combo, alignment=Qt.AlignRight)
        control_layout.addWidget(output_button, alignment=Qt.AlignRight)
        control_layout.addWidget(input_button, alignment=Qt.AlignRight)

        control_layout.addStretch()

        layout = QHBoxLayout()
        layout.addLayout(control_layout)
        layout.addWidget(scroll)

        self.setLayout(layout)
Esempio n. 2
0
 def __init__(self, options, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.options = options
     self.addItems(options.values())
     self.activated.connect(self.on_activated)
     self.setItemDelegate(QStyledItemDelegate())
     self.view().parentWidget().setStyleSheet('border: 0')
Esempio n. 3
0
    def edit_completer(self):
        if self.edit_completer_update_enabled == False:
            return

        address_list = []
        with data_session_scope() as session:
            for address, alias in Alias.get_aliases(session).items():
                address_list.append("{} ({})".format(alias, address))
            for address in session.query(Address).all():
                address_list.append(address.address)
        completer = QCompleter(address_list, self.edit_resale_to)
        completer_delegate = QStyledItemDelegate(completer)
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        completer.popup().setItemDelegate(completer_delegate)
        completer.popup().setStyleSheet("""
            QAbstractItemView {
                font: 10pt "Roboto Light";
                border: 1px solid #41ADFF;
                border-top: 0px;
                background-color: #FFF79A;
                border-radius: 2px;
            }
            QAbstractItemView::item  {
                margin-top: 3px;
            }
            """)
        self.edit_resale_to.setCompleter(completer)
Esempio n. 4
0
    def createAllView(self):
        styledItemDelegate = QStyledItemDelegate()
        styledItemDelegate.setItemEditorFactory(ItemEditorFactory())
        self.setItemDelegate(styledItemDelegate)

        # create the view
        self.setSelectionMode(QAbstractItemView.SingleSelection)
        #self.setSelectionBehavior(QAbstractItemView.SelectRows)

        # set the table model
        self.tablemodel = MyTableModel(self)
        self.setModel(self.tablemodel)
        self.clicked.connect(self.showSelection)
        #self.dataChanged.connect(self.selection_changed)

        # set the minimum size
        self.setMinimumSize(100, 100)

        # set horizontal header properties
        hh = self.horizontalHeader()
        hh.setMinimumSectionSize(75)
        hh.setStretchLastSection(True)
        hh.setSortIndicator(1, Qt.AscendingOrder)

        vh = self.verticalHeader()
        vh.setVisible(False)

        # set column width to fit contents
        self.resizeColumnsToContents()

        # set row height
        self.resizeRowsToContents()

        # enable sorting
        self.setSortingEnabled(True)
Esempio n. 5
0
    def createGUI(self):
        colorEditorFactory = QItemEditorFactory()
        colorListItemEditorCreator = ColorListItemEditorCreator()
        colorListItemEditorCreator.setActivatedSlot(self.comboBoxActivated)
        colorEditorFactory.registerEditor(QVariant.Color,
                                          colorListItemEditorCreator)
        colorEditorDelegate = QStyledItemDelegate(self)
        colorEditorDelegate.setItemEditorFactory(colorEditorFactory)

        figureEditorFactory = QItemEditorFactory()
        figureListItemEditorCreator = FigureListItemEditorCreator()
        figureListItemEditorCreator.setActivatedSlot(self.comboBoxActivated)
        figureEditorFactory.registerEditor(QVariant.String,
                                           figureListItemEditorCreator)
        figureEditorDelegate = QStyledItemDelegate(self)
        figureEditorDelegate.setItemEditorFactory(figureEditorFactory)

        self.regionTableWidget.cellChanged.connect(
            self.regionTableWidgetCellChanged)
        self.regionTableWidget.setColumnCount(3)
        self.regionTableWidget.setItemDelegateForColumn(1, colorEditorDelegate)
        self.regionTableWidget.setItemDelegateForColumn(
            2, figureEditorDelegate)

        self.regionTableWidget.setHorizontalHeaderLabels(
            ["Name", "Color", "Type"])
        self.regionTableWidget.verticalHeader().setVisible(False)
        self.regionTableWidget.resize(150, 50)

        qApp = QtWidgets.qApp
        self.upRegionButton.setIcon(qApp.style().standardIcon(
            QStyle.SP_ArrowUp))
        self.downRegionButton.setIcon(qApp.style().standardIcon(
            QStyle.SP_ArrowDown))

        self.addRegionButton.clicked.connect(self.addRegionButtonClicked)
        self.removeRegionButton.clicked.connect(self.removeRegionButtonClicked)
        self.upRegionButton.clicked.connect(self.upRegionButtonClicked)
        self.downRegionButton.clicked.connect(self.downRegionButtonClicked)

        self.radiusSpinBox.valueChanged.connect(self.radiusSpinBoxValueChanged)

        self.actionCoordinates.triggered.connect(self.setCoordinatesVisible)
        self.actionPoints.triggered.connect(self.setPointsVisible)
        self.actionLines.triggered.connect(self.setLinesVisible)
        self.actionRegions.triggered.connect(self.setRegionsVisible)
Esempio n. 6
0
 def get_data_set_combo():
     select_data_set_list = QComboBox()
     item_delegate = QStyledItemDelegate()
     select_data_set_list.setItemDelegate(item_delegate)
     for name in dict_site:
         select_data_set_list.addItem(
             DataSetsManager.get_data_set(name).icon, name)
     return select_data_set_list
Esempio n. 7
0
 def changeRowBorder(self, row):
     # toggle column border thicnkess
     if self.borderThickness[row]:
         self.borderThickness.pop(row)
         self.setItemDelegateForRow(row, QStyledItemDelegate(self))
     else:
         self.borderThickness[row] = True
         self.setItemDelegateForRow(row, drawBorderDelegate(self))
     self.verticalHeader().repaint()
Esempio n. 8
0
 def __init__(self, parent, data_name):
     QComboBox.__init__(self, parent)
     self.control_widgets = []
     self.control_targets = []
     self.addItems(Character(parent, **DATA_PARAMETER.get(data_name)).sequence())
     self.setCurrentIndex(0)
     # noinspection PyUnresolvedReferences
     self.currentIndexChanged[int].connect(self.control_index)
     self.setItemDelegate(QStyledItemDelegate())
Esempio n. 9
0
    def __init__(self):
        super(Dropdown, self).__init__()

        self.setItemDelegate(QStyledItemDelegate())
        self.setPlaceholderText("None")
        self.setView(QListView())

        self.deselected = None
        self.currentIndexChanged.connect(self.changed_signal)
Esempio n. 10
0
 def __init__(self, parent, data_name, mapping_name, attach=None):
     QComboBox.__init__(self, parent)
     self.data_name = data_name
     self.mapping_name = mapping_name
     self.attach = attach
     self.data_type: Numerical = self.parser(self.parser_type, data_name)
     self.mapping_type: Character = self.parser(Character, mapping_name)
     self.addItems(self.mapping.values())
     self.setMaxVisibleItems(15)
     self.setItemDelegate(QStyledItemDelegate())
Esempio n. 11
0
 def __init__(self, parent, data_name, mapping_name, attach=None):
     QComboBox.__init__(self, parent)
     self.data_name = data_name
     self.mapping_name = mapping_name
     self.attach = attach
     self.data_type: Numerical = self.parser(self.parser_type, data_name)
     self.mapping_type: Picture = self.parser(Picture, mapping_name)
     [self.addItem(QIcon(pic.toqpixmap()), '') for code, pic in self.mapping.items()]
     self.setIconSize(QSize(*list(self.mapping.values())[0].size))
     self.setMaxVisibleItems(10)
     self.setItemDelegate(QStyledItemDelegate())
Esempio n. 12
0
    def __init__(self, *args, mode=Mode.FadeOut, **kwargs):
        super().__init__(*args, **kwargs)
        self.setItemDelegate(QStyledItemDelegate())

        if mode == self.Mode.FadeIn:
            items = self.FadeInIcons
        else:
            items = self.FadeOutIcons

        for key in sorted(items.keys()):
            self.addItem(items[key], translate('Fade', key), key)
Esempio n. 13
0
class AddressLineCompleter(QCompleter):
    mCompleterItemDelegate = QStyledItemDelegate()

    def pathFromIndex(self, index: QModelIndex) -> str:
        return getTreeItemPath(index, role=self.completionRole())

    def splitPath(self, path: str) -> List[str]:
        return path.split("/")

    def setModel(self, c: QAbstractItemModel) -> None:
        super(AddressLineCompleter, self).setModel(c)
        self.popup().setItemDelegate(self.mCompleterItemDelegate)
Esempio n. 14
0
    def __init__(self, parent=None):
        super(ProjectTreeColumn, self).__init__(parent)
        vbox = QVBoxLayout(self)
        # vbox.setSizeConstraint(QVBoxLayout.SetDefaultConstraint)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        self._buttons = []
        frame = QFrame()
        frame.setObjectName("actionbar")
        box = QVBoxLayout(frame)
        box.setContentsMargins(0, 0, 0, 0)
        box.setSpacing(0)

        self._combo_project = QComboBox()
        self._combo_project.setItemDelegate(QStyledItemDelegate())
        self._combo_project.setObjectName("combo_projects")
        box.addWidget(self._combo_project)
        vbox.addWidget(frame)
        self._combo_project.setContextMenuPolicy(Qt.CustomContextMenu)
        self._projects_area = QStackedLayout()
        logger.debug("This is the projects area")
        vbox.addLayout(self._projects_area)

        # Empty widget
        self._empty_proj = QLabel(translations.TR_NO_PROJECTS)
        self._empty_proj.setAlignment(Qt.AlignCenter)
        self._empty_proj.setAutoFillBackground(True)
        self._empty_proj.setBackgroundRole(QPalette.Base)
        self._projects_area.addWidget(self._empty_proj)
        self._projects_area.setCurrentWidget(self._empty_proj)

        self.projects = []

        self._combo_project.currentIndexChanged.connect(
            self._change_current_project)
        self._combo_project.customContextMenuRequested[
            'const QPoint&'].connect(self.context_menu_for_root)

        connections = (
            {
                "target": "main_container",
                "signal_name": "addToProject",
                "slot": self._add_file_to_project
            },
            {
                "target": "main_container",
                "signal_name": "showFileInExplorer",
                "slot": self._show_file_in_explorer
            },
        )
        IDE.register_service('projects_explorer', self)
        IDE.register_signals('projects_explorer', connections)
        ExplorerContainer.register_tab(translations.TR_TAB_PROJECTS, self)
Esempio n. 15
0
 def initData(self, cdict):
     self.options = cdict
     num = len(cdict)
     self.topFiller.setMinimumSize(400, 40 * num + 50)
     maxh = 40 * num + 50 > 500 and 500 or 40 * num + 50
     self.setFixedHeight(maxh)
     oWidget = QWidget(self.topFiller)
     mm = QVBoxLayout()
     oWidget.setLayout(mm)
     index = 0
     self.opcombox = []
     for op in self.options:
         if self.getDictValue(op, 'default') != "":
             m = QHBoxLayout()
             a = QLabel()
             a.setFixedWidth(200)
             a.setText(op['label'])
             if self.getDictValue(op, "hover"):
                 a.setToolTip(op['hover'])
             m.addWidget(a)
             if self.getDictValue(op, 'options'):
                 b = QComboBox()
                 b.select = True
                 b.index = index
                 b.name = op['name']
                 self.opcombox.append(b)
                 b.setFixedWidth(150)
                 b.setStyleSheet(
                     "QComboBox QAbstractItemView::item { min-height: 25px; min-width: 100px; }"
                 )
                 b.setItemDelegate(QStyledItemDelegate())
                 b.currentIndexChanged.connect(self.selectChange)
                 bd = []
                 for o in op['options']:
                     b.addItem(str(o['description']))
                     bd.append(o['data'])
                 b.data = bd
                 if self.getDictValue(op['options'][b.currentIndex()],
                                      'hover'):
                     b.setToolTip(op['options'][b.currentIndex()]['hover'])
             else:
                 b = QLabel()
                 self.opcombox.append(b)
                 b.select = False
                 b.name = op['name']
                 b.data = op['default']
                 b.setText("请直接修改modinfo.lua")
             m.addWidget(b)
             mm.addLayout(m)
         index += 1
     self.loadExistValue()
Esempio n. 16
0
 def on_btnSettings_clicked(self, checked):
     """
     Launches the results table settings dialog
     """
     idx = self.results_model.scenario_desc_col_index()
     dialog = ResultsTableSettings(self)
     dialog.exec_()
     self.results_model.reset_data(self.parent.scenario_stats_df)
     if idx is not None:
         self.tblResView.setItemDelegateForColumn(idx, QStyledItemDelegate())
     if self.results_model.scenario_desc_col_index() is not None:
         self.tblResView.setItemDelegateForColumn(self.results_model.scenario_desc_col_index(), HtmlDelegate())
     self.tblResView.resizeColumnsToContents()
     self.tblResView.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
Esempio n. 17
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.setRowCount(1)
        self.setColumnCount(2)

        self.verticalHeader().hide()
        self.horizontalHeader().hide()
        self.horizontalHeader().setSectionResizeMode(
            QHeaderView.ResizeToContents)

        self.tdelegate = QStyledItemDelegate()
        self.tdelegate.setItemEditorFactory(TypeFactory(self))
        self.setItemDelegateForColumn(0, self.tdelegate)

        self.edelegate = QStyledItemDelegate()
        self.edelegate.setItemEditorFactory(EditorFactory(self))
        self.setItemDelegateForColumn(1, self.edelegate)

        self.itemChanged.connect(self._updateColumnCount)

        self.setItem(0, 0, QTableWidgetItem('To'))

        self.msg = None
Esempio n. 18
0
    def __init__(self, source, parent=None):
        super().__init__(parent)

        self.setHeaderHidden(True)

        # Enable Drag and Drop
        self.setDefaultDropAction(Qt.MoveAction)
        self.setDragDropMode(QAbstractItemView.DragDrop)

        # Load StyleSheet
        path = os.getcwd()
        print(path)
        stylesheet_file = QFile(path + "/desktop_mode/stylesheet.qss")
        if stylesheet_file.open(QFile.ReadOnly):
            self.setStyleSheet(str(stylesheet_file.readAll(),
                                   encoding='utf-8'))
            stylesheet_file.close()
            print('Use stylesheet successfully')

        # Set Item Clicked Slot
        self.itemClicked.connect(self.item_clicked)

        # Set Item Right Clicked Slot
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.item_right_clicked)

        # Set All Data in Tree
        for item in source:
            tree_item = QTreeWidgetItem([item.name])
            tree_item.setFlags(tree_item.flags() | Qt.ItemIsEditable)
            for note in item.note:
                sub_tree_item = QTreeWidgetItem(tree_item)
                sub_tree_item.setText(0, note.title)
                sub_tree_item.setFlags(sub_tree_item.flags()
                                       | Qt.ItemIsEditable)
            self.addTopLevelItem(tree_item)

        # Set Edit Finished Slot
        item_delegate = QStyledItemDelegate(self)
        self.setItemDelegate(item_delegate)
        item_delegate.closeEditor.connect(self.rename_finished)

        # Set Item Double Clicked Slot
        self.itemDoubleClicked.connect(self.rename_item)

        # Record name to rename
        self.old_name = ''
        self.new_name = ''
Esempio n. 19
0
    def __init__(self, parent=None):
        super(ProjectTreeColumn, self).__init__(parent)
        vbox = QVBoxLayout(self)
        # vbox.setSizeConstraint(QVBoxLayout.SetDefaultConstraint)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        self._buttons = []
        frame = QFrame()
        frame.setObjectName("actionbar")
        box = QVBoxLayout(frame)
        box.setContentsMargins(0, 0, 0, 0)
        box.setSpacing(0)

        self._combo_project = QComboBox()
        self._combo_project.setItemDelegate(QStyledItemDelegate())
        self._combo_project.setObjectName("combo_projects")
        box.addWidget(self._combo_project)
        vbox.addWidget(frame)
        self._combo_project.setContextMenuPolicy(Qt.CustomContextMenu)
        self._projects_area = QStackedLayout()
        logger.debug("This is the projects area")
        vbox.addLayout(self._projects_area)

        self.projects = []

        self._combo_project.customContextMenuRequested[
            'const QPoint&'].connect(self.context_menu_for_root)

        connections = (
            {
                'target': 'main_container',
                'signal_name': 'addToProject',
                'slot': self._add_file_to_project
            },
            {
                'target': 'main_container',
                'signal_name': 'showFileInExplorer',
                'slot': self._show_file_in_explorer
            },
        )
        IDE.register_service('projects_explorer', self)
        IDE.register_signals('projects_explorer', connections)
        ExplorerContainer.register_tab(translations.TR_TAB_PROJECTS, self)
Esempio n. 20
0
    def __init__(self, parent):
        super().__init__(parent)
        self.setupUi(self)

        self.edit_amount.textChanged.connect(self.on_amount_edit)

        self.edit_address.setValidator(AddressValidator())
        self.edit_address.textChanged.connect(self.on_address_edit)
        self.edit_address.textChanged.connect(self.check_state)

        self.edit_description.setStyleSheet('QLineEdit:focus {background-color: #fff79a}')

        self.btn_send_cancel.clicked.connect(self.on_cancel_clicked)
        self.btn_send_send.setDisabled(True)
        self.amount_valid = False
        self.address_valid = False
        self.btn_send_send.clicked.connect(self.on_send_clicked)

        address_list =[]
        for address in Address.select().order_by(Address.address.desc()):
            if address.alias is not None:
                address_list.append("{} ({})".format(address.alias, address.address))
            address_list.append(address.address)
        completer = QCompleter(address_list, self.edit_address)
        completer_delegate = QStyledItemDelegate(completer)
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        completer.popup().setItemDelegate(completer_delegate)
        completer.popup().setStyleSheet(
            """
            QAbstractItemView {
                font: 10pt "Roboto Light";
                border: 1px solid #41ADFF;
                border-top: 0px;
                background-color: #FFF79A;
                border-radius: 2px;
            }
            QAbstractItemView::item  {
                margin-top: 3px;
            }           
            """
        )
        self.edit_address.setCompleter(completer)
Esempio n. 21
0
 def get_status_layout(self):
     status_hbox = QHBoxLayout()
     label_status = QLabel("Statut :")
     label_status.setFixedWidth(150*c.ech)
     label_status.setStyleSheet(label_subtitle_stylesheet)
     status_hbox.addWidget(label_status)
     self.dropdown_status.setFixedHeight(30*c.ech)
     self.dropdown_status.setItemDelegate(QStyledItemDelegate())
     self.dropdown_status.setStyleSheet(dropdown_stylesheet)
     self.dropdown_status.addItem("En cours")
     self.dropdown_status.addItem("En vente")
     self.dropdown_status.addItem("Vendu")
     if not self.player.on_sell:
         self.dropdown_status.setCurrentText("En cours")
     if self.player.on_sell and not self.player.solding_price:
         self.dropdown_status.setCurrentText("En vente")
     if self.player.solding_price:
         self.dropdown_status.setCurrentText("Vendu")
     self.dropdown_status.activated.connect(self.on_status_changed)
     status_hbox.addWidget(self.dropdown_status)
     return status_hbox
Esempio n. 22
0
    def __init__(self, app, bot, stream):
        # app
        super(GUI, self).__init__()
        QDir.setCurrent(bundle_dir)
        self.app = app

        # window info
        self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
        window_icon = QIcon('./assets/favicon.ico')
        self.setWindowTitle('Discord Audio Pipe')
        self.app.setWindowIcon(window_icon)
        self.position = None

        # discord
        self.bot = bot
        self.voice = None
        self.stream = stream

        # layout
        central = QWidget()
        layout = QGridLayout()
        central.setLayout(layout)

        # loading
        self.info = QLabel('Connecting...')
        self.loading = QSvgWidget('./assets/loading.svg')

        # devices
        self.devices = QComboBox(self)
        self.devices.setItemDelegate(QStyledItemDelegate())
        self.devices.setPlaceholderText('None')
        device_lb = QLabel('Devices')
        device_lb.setObjectName('label')

        for device, idx in sound.query_devices().items():
            self.devices.addItem(device + '   ', idx)

        # servers
        self.servers = QComboBox(self)
        self.servers.setItemDelegate(QStyledItemDelegate())
        self.servers.setPlaceholderText('None')
        server_lb = QLabel('Servers     ')
        server_lb.setObjectName('label')

        # channels
        self.channels = QComboBox(self)
        self.channels.setItemDelegate(QStyledItemDelegate())
        self.channels.setPlaceholderText('None')
        channel_lb = QLabel('Channels  ')
        channel_lb.setObjectName('label')

        # mute
        self.mute = QPushButton('Mute', self)
        self.mute.setObjectName('mute')

        # add widgets
        layout.addWidget(self.info, 0, 0, 1, 3)
        layout.addWidget(self.loading, 0, 3, alignment=Qt.AlignHCenter)
        layout.addWidget(device_lb, 1, 0)
        layout.addWidget(self.devices, 2, 0)
        layout.addWidget(server_lb, 1, 1)
        layout.addWidget(self.servers, 2, 1)
        layout.addWidget(channel_lb, 1, 2)
        layout.addWidget(self.channels, 2, 2)
        layout.addWidget(self.mute, 2, 3)

        # events
        self.devices.currentTextChanged.connect(self.change_device)
        self.servers.currentTextChanged.connect(
            lambda: asyncio.ensure_future(self.change_server()))
        self.channels.currentTextChanged.connect(
            lambda: asyncio.ensure_future(self.change_channel()))
        self.mute.clicked.connect(self.toggle_mute)

        # build window
        titlebar = TitleBar(self)
        self.setMenuWidget(titlebar)
        self.setCentralWidget(central)
        self.disable_ui()

        # load styles
        QFontDatabase.addApplicationFont('./assets/Roboto-Black.ttf')
        with open('./assets/style.qss', 'r') as qss:
            self.app.setStyleSheet(qss.read())

        # show window
        self.show()
Esempio n. 23
0
 def on_decoration_mode_action(self):
     self.slide_list_widget.list_view.setItemDelegate(QStyledItemDelegate())
     list_model = self.slide_list_widget.list_model
     list_model.beginResetModel()
     self.slide_list_widget.list_model.decoration_mode(self.item_to_str, self.item_to_pixmap)
     list_model.endResetModel()
Esempio n. 24
0
    def __init__(self):
        QMainWindow.__init__(self)

        self.navigation_stack = []
        self.feedback_dialog_is_open = False
        self.tribler_started = False
        self.tribler_settings = None
        self.debug_window = None
        self.core_manager = CoreManager()
        self.pending_requests = {}
        self.pending_uri_requests = []
        self.download_uri = None
        self.dialog = None
        self.start_download_dialog_active = False
        self.request_mgr = None
        self.search_request_mgr = None
        self.search_suggestion_mgr = None
        self.selected_torrent_files = []
        self.vlc_available = True
        self.has_search_results = False
        self.start_time = time.time()

        sys.excepthook = self.on_exception

        uic.loadUi(get_ui_file_path('mainwindow.ui'), self)
        TriblerRequestManager.window = self
        self.tribler_status_bar.hide()

        self.magnet_handler = MagnetHandler(self.window)
        QDesktopServices.setUrlHandler("magnet", self.magnet_handler,
                                       "on_open_magnet_link")

        QCoreApplication.setOrganizationDomain("nl")
        QCoreApplication.setOrganizationName("TUDelft")
        QCoreApplication.setApplicationName("Tribler")
        QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)

        self.read_settings()

        # Remove the focus rect on OS X
        for widget in self.findChildren(QLineEdit) + self.findChildren(
                QListWidget) + self.findChildren(QTreeWidget):
            widget.setAttribute(Qt.WA_MacShowFocusRect, 0)

        self.menu_buttons = [
            self.left_menu_button_home, self.left_menu_button_search,
            self.left_menu_button_my_channel,
            self.left_menu_button_subscriptions,
            self.left_menu_button_video_player,
            self.left_menu_button_downloads, self.left_menu_button_discovered
        ]

        self.video_player_page.initialize_player()
        self.search_results_page.initialize_search_results_page()
        self.settings_page.initialize_settings_page()
        self.subscribed_channels_page.initialize()
        self.edit_channel_page.initialize_edit_channel_page()
        self.downloads_page.initialize_downloads_page()
        self.home_page.initialize_home_page()
        self.loading_page.initialize_loading_page()
        self.discovering_page.initialize_discovering_page()
        self.discovered_page.initialize_discovered_page()
        self.trust_page.initialize_trust_page()

        self.stackedWidget.setCurrentIndex(PAGE_LOADING)

        # Create the system tray icon
        if QSystemTrayIcon.isSystemTrayAvailable():
            self.tray_icon = QSystemTrayIcon()
            use_monochrome_icon = get_gui_setting(self.gui_settings,
                                                  "use_monochrome_icon",
                                                  False,
                                                  is_bool=True)
            self.update_tray_icon(use_monochrome_icon)

        self.hide_left_menu_playlist()
        self.left_menu_button_debug.setHidden(True)
        self.top_menu_button.setHidden(True)
        self.left_menu.setHidden(True)
        self.trust_button.setHidden(True)
        self.settings_button.setHidden(True)
        self.add_torrent_button.setHidden(True)
        self.top_search_bar.setHidden(True)

        # Set various icons
        self.top_menu_button.setIcon(QIcon(get_image_path('menu.png')))

        self.search_completion_model = QStringListModel()
        completer = QCompleter()
        completer.setModel(self.search_completion_model)
        completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
        self.item_delegate = QStyledItemDelegate()
        completer.popup().setItemDelegate(self.item_delegate)
        completer.popup().setStyleSheet("""
        QListView {
            background-color: #404040;
        }

        QListView::item {
            color: #D0D0D0;
            padding-top: 5px;
            padding-bottom: 5px;
        }

        QListView::item:hover {
            background-color: #707070;
        }
        """)
        self.top_search_bar.setCompleter(completer)

        # Toggle debug if developer mode is enabled
        self.window().left_menu_button_debug.setHidden(not get_gui_setting(
            self.gui_settings, "debug", False, is_bool=True))

        self.core_manager.start()

        self.core_manager.events_manager.received_search_result_channel.connect(
            self.search_results_page.received_search_result_channel)
        self.core_manager.events_manager.received_search_result_torrent.connect(
            self.search_results_page.received_search_result_torrent)
        self.core_manager.events_manager.torrent_finished.connect(
            self.on_torrent_finished)
        self.core_manager.events_manager.new_version_available.connect(
            self.on_new_version_available)
        self.core_manager.events_manager.tribler_started.connect(
            self.on_tribler_started)

        # Install signal handler for ctrl+c events
        def sigint_handler(*_):
            self.close_tribler()

        signal.signal(signal.SIGINT, sigint_handler)

        self.installEventFilter(self.video_player_page)

        self.show()
Esempio n. 25
0
    def __init__(self, core_args=None, core_env=None, api_port=None):
        QMainWindow.__init__(self)

        QCoreApplication.setOrganizationDomain("nl")
        QCoreApplication.setOrganizationName("TUDelft")
        QCoreApplication.setApplicationName("Tribler")
        QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)

        self.gui_settings = QSettings()
        api_port = api_port or int(get_gui_setting(self.gui_settings, "api_port", DEFAULT_API_PORT))
        dispatcher.update_worker_settings(port=api_port)

        self.navigation_stack = []
        self.tribler_started = False
        self.tribler_settings = None
        self.debug_window = None
        self.core_manager = CoreManager(api_port)
        self.pending_requests = {}
        self.pending_uri_requests = []
        self.download_uri = None
        self.dialog = None
        self.new_version_dialog = None
        self.start_download_dialog_active = False
        self.request_mgr = None
        self.search_request_mgr = None
        self.search_suggestion_mgr = None
        self.selected_torrent_files = []
        self.vlc_available = True
        self.has_search_results = False
        self.last_search_query = None
        self.last_search_time = None
        self.start_time = time.time()
        self.exception_handler_called = False
        self.token_refresh_timer = None

        sys.excepthook = self.on_exception

        uic.loadUi(get_ui_file_path('mainwindow.ui'), self)
        TriblerRequestManager.window = self
        self.tribler_status_bar.hide()

        # Load dynamic widgets
        uic.loadUi(get_ui_file_path('torrent_channel_list_container.ui'), self.channel_page_container)
        self.channel_torrents_list = self.channel_page_container.items_list
        self.channel_torrents_detail_widget = self.channel_page_container.details_tab_widget
        self.channel_torrents_detail_widget.initialize_details_widget()
        self.channel_torrents_list.itemSelectionChanged.connect(self.channel_page.clicked_item)

        uic.loadUi(get_ui_file_path('torrent_channel_list_container.ui'), self.search_page_container)
        self.search_results_list = self.search_page_container.items_list
        self.search_torrents_detail_widget = self.search_page_container.details_tab_widget
        self.search_torrents_detail_widget.initialize_details_widget()
        self.search_results_list.itemClicked.connect(self.on_channel_item_click)
        self.search_results_list.itemSelectionChanged.connect(self.search_results_page.clicked_item)
        self.token_balance_widget.mouseReleaseEvent = self.on_token_balance_click

        def on_state_update(new_state):
            self.loading_text_label.setText(new_state)

        self.core_manager.core_state_update.connect(on_state_update)

        self.magnet_handler = MagnetHandler(self.window)
        QDesktopServices.setUrlHandler("magnet", self.magnet_handler, "on_open_magnet_link")

        self.debug_pane_shortcut = QShortcut(QKeySequence("Ctrl+d"), self)
        self.debug_pane_shortcut.activated.connect(self.clicked_menu_button_debug)

        # Remove the focus rect on OS X
        for widget in self.findChildren(QLineEdit) + self.findChildren(QListWidget) + self.findChildren(QTreeWidget):
            widget.setAttribute(Qt.WA_MacShowFocusRect, 0)

        self.menu_buttons = [self.left_menu_button_home, self.left_menu_button_search, self.left_menu_button_my_channel,
                             self.left_menu_button_subscriptions, self.left_menu_button_video_player,
                             self.left_menu_button_downloads, self.left_menu_button_discovered]

        self.video_player_page.initialize_player()
        self.search_results_page.initialize_search_results_page()
        self.settings_page.initialize_settings_page()
        self.subscribed_channels_page.initialize()
        self.edit_channel_page.initialize_edit_channel_page()
        self.downloads_page.initialize_downloads_page()
        self.home_page.initialize_home_page()
        self.loading_page.initialize_loading_page()
        self.discovering_page.initialize_discovering_page()
        self.discovered_page.initialize_discovered_page()
        self.trust_page.initialize_trust_page()

        self.stackedWidget.setCurrentIndex(PAGE_LOADING)

        # Create the system tray icon
        if QSystemTrayIcon.isSystemTrayAvailable():
            self.tray_icon = QSystemTrayIcon()
            use_monochrome_icon = get_gui_setting(self.gui_settings, "use_monochrome_icon", False, is_bool=True)
            self.update_tray_icon(use_monochrome_icon)

            # Create the tray icon menu
            menu = self.create_add_torrent_menu()
            show_downloads_action = QAction('Show downloads', self)
            show_downloads_action.triggered.connect(self.clicked_menu_button_downloads)
            token_balance_action = QAction('Show token balance', self)
            token_balance_action.triggered.connect(lambda: self.on_token_balance_click(None))
            quit_action = QAction('Quit Tribler', self)
            quit_action.triggered.connect(self.close_tribler)
            menu.addSeparator()
            menu.addAction(show_downloads_action)
            menu.addAction(token_balance_action)
            menu.addSeparator()
            menu.addAction(quit_action)
            self.tray_icon.setContextMenu(menu)
        else:
            self.tray_icon = None

        self.hide_left_menu_playlist()
        self.left_menu_button_debug.setHidden(True)
        self.top_menu_button.setHidden(True)
        self.left_menu.setHidden(True)
        self.token_balance_widget.setHidden(True)
        self.settings_button.setHidden(True)
        self.add_torrent_button.setHidden(True)
        self.top_search_bar.setHidden(True)

        # Set various icons
        self.top_menu_button.setIcon(QIcon(get_image_path('menu.png')))

        self.search_completion_model = QStringListModel()
        completer = QCompleter()
        completer.setModel(self.search_completion_model)
        completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
        self.item_delegate = QStyledItemDelegate()
        completer.popup().setItemDelegate(self.item_delegate)
        completer.popup().setStyleSheet("""
        QListView {
            background-color: #404040;
        }

        QListView::item {
            color: #D0D0D0;
            padding-top: 5px;
            padding-bottom: 5px;
        }

        QListView::item:hover {
            background-color: #707070;
        }
        """)
        self.top_search_bar.setCompleter(completer)

        # Toggle debug if developer mode is enabled
        self.window().left_menu_button_debug.setHidden(
            not get_gui_setting(self.gui_settings, "debug", False, is_bool=True))

        # Start Tribler
        self.core_manager.start(core_args=core_args, core_env=core_env)

        self.core_manager.events_manager.received_search_result_channel.connect(
            self.search_results_page.received_search_result_channel)
        self.core_manager.events_manager.received_search_result_torrent.connect(
            self.search_results_page.received_search_result_torrent)
        self.core_manager.events_manager.torrent_finished.connect(self.on_torrent_finished)
        self.core_manager.events_manager.new_version_available.connect(self.on_new_version_available)
        self.core_manager.events_manager.tribler_started.connect(self.on_tribler_started)
        self.core_manager.events_manager.events_started.connect(self.on_events_started)
        self.core_manager.events_manager.low_storage_signal.connect(self.on_low_storage)

        # Install signal handler for ctrl+c events
        def sigint_handler(*_):
            self.close_tribler()

        signal.signal(signal.SIGINT, sigint_handler)

        self.installEventFilter(self.video_player_page)

        # Resize the window according to the settings
        center = QApplication.desktop().availableGeometry(self).center()
        pos = self.gui_settings.value("pos", QPoint(center.x() - self.width() * 0.5, center.y() - self.height() * 0.5))
        size = self.gui_settings.value("size", self.size())

        self.move(pos)
        self.resize(size)

        self.show()
Esempio n. 26
0
    def __init__(self, main_combo=False):
        super(ActionBar, self).__init__()
        self.setAutoFillBackground(True)
        self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.setObjectName("actionbar")
        hbox = QHBoxLayout(self)
        hbox.setContentsMargins(0, 0, 0, 0)
        hbox.setSpacing(1)

        # self.lbl_checks = QLabel('')
        # self.lbl_checks.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        # self.lbl_checks.setFixedWidth(48)
        # self.lbl_checks.setVisible(False)
        # hbox.addWidget(self.lbl_checks)

        self.combo_files = ComboFiles(self)
        self.combo_files.setObjectName("combotab")
        # self.combo_files.setSizePolicy(
        #     QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.combo_files.setSizeAdjustPolicy(
            QComboBox.AdjustToMinimumContentsLengthWithIcon)
        self.combo_files.setMaximumWidth(400)
        self.combo_files.currentIndexChanged[int].connect(self.current_changed)
        self.combo_files.setToolTip(translations.TR_COMBO_FILE_TOOLTIP)
        self.combo_files.setContextMenuPolicy(Qt.CustomContextMenu)
        self.combo_files.customContextMenuRequested.connect(
            self._context_menu_requested)
        hbox.addWidget(self.combo_files)
        self.symbols_combo = QComboBox()
        self.symbols_combo.setObjectName("combo_symbols")
        # For correctly style sheet
        self.symbols_combo.setItemDelegate(QStyledItemDelegate())
        self.symbols_combo.setModel(Model([]))
        self.symbols_combo.setSizeAdjustPolicy(
            QComboBox.AdjustToMinimumContentsLengthWithIcon)
        self.symbols_combo.activated[int].connect(self.current_symbol_changed)
        hbox.addWidget(self.symbols_combo)

        # Code Navigator actions
        self.code_navigator = CodeNavigator()
        hbox.addWidget(self.code_navigator)
        # Image Viewer actions
        self.image_viewer_controls = ImageViewerControls()
        self.image_viewer_controls.setSizePolicy(QSizePolicy.Expanding,
                                                 QSizePolicy.Fixed)
        self.image_viewer_controls.setVisible(False)
        hbox.addWidget(self.image_viewer_controls)

        self._pos_text = "Line: %d, Col: %d"
        self.lbl_position = QLabel()
        self.lbl_position.setObjectName("position")
        self.lbl_position.setText(self._pos_text % (0, 0))
        margin = self.style().pixelMetric(
            QStyle.PM_LayoutHorizontalSpacing) / 2
        self.lbl_position.setContentsMargins(margin, 0, margin, 0)
        self.lbl_position.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        hbox.addWidget(self.lbl_position)
        self.btn_close = QPushButton()
        self.btn_close.setIcon(self.style().standardIcon(
            QStyle.SP_DialogCloseButton))

        if main_combo:
            self.btn_close.setObjectName('close_button_combo')
            self.btn_close.setToolTip(translations.TR_CLOSE_FILE)
            self.btn_close.clicked.connect(self.about_to_close_file)
        else:
            self.btn_close.setObjectName('close_split')
            self.btn_close.setToolTip(translations.TR_CLOSE_SPLIT)
            self.btn_close.clicked.connect(lambda: self.closeSplit.emit())
        self.btn_close.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum)
        hbox.addWidget(self.btn_close)
Esempio n. 27
0
    def __init__(self, core_args=None, core_env=None, api_port=None, api_key=None):
        QMainWindow.__init__(self)
        self._logger = logging.getLogger(self.__class__.__name__)

        QCoreApplication.setOrganizationDomain("nl")
        QCoreApplication.setOrganizationName("TUDelft")
        QCoreApplication.setApplicationName("Tribler")

        self.setWindowIcon(QIcon(QPixmap(get_image_path('tribler.png'))))

        self.gui_settings = QSettings('nl.tudelft.tribler')
        api_port = api_port or int(get_gui_setting(self.gui_settings, "api_port", DEFAULT_API_PORT))
        api_key = api_key or get_gui_setting(self.gui_settings, "api_key", hexlify(os.urandom(16)).encode('utf-8'))
        self.gui_settings.setValue("api_key", api_key)

        api_port = get_first_free_port(start=api_port, limit=100)
        request_manager.port, request_manager.key = api_port, api_key

        self.tribler_started = False
        self.tribler_settings = None
        # TODO: move version_id to tribler_common and get core version in the core crash message
        self.tribler_version = version_id
        self.debug_window = None

        self.error_handler = ErrorHandler(self)
        self.core_manager = CoreManager(api_port, api_key, self.error_handler)
        self.pending_requests = {}
        self.pending_uri_requests = []
        self.download_uri = None
        self.dialog = None
        self.create_dialog = None
        self.chosen_dir = None
        self.new_version_dialog = None
        self.start_download_dialog_active = False
        self.selected_torrent_files = []
        self.has_search_results = False
        self.last_search_query = None
        self.last_search_time = None
        self.start_time = time.time()
        self.token_refresh_timer = None
        self.shutdown_timer = None
        self.add_torrent_url_dialog_active = False

        sys.excepthook = self.error_handler.gui_error

        uic.loadUi(get_ui_file_path('mainwindow.ui'), self)
        TriblerRequestManager.window = self
        self.tribler_status_bar.hide()

        self.token_balance_widget.mouseReleaseEvent = self.on_token_balance_click

        def on_state_update(new_state):
            self.loading_text_label.setText(new_state)

        connect(self.core_manager.core_state_update, on_state_update)

        self.magnet_handler = MagnetHandler(self.window)
        QDesktopServices.setUrlHandler("magnet", self.magnet_handler, "on_open_magnet_link")

        self.debug_pane_shortcut = QShortcut(QKeySequence("Ctrl+d"), self)
        connect(self.debug_pane_shortcut.activated, self.clicked_menu_button_debug)
        self.import_torrent_shortcut = QShortcut(QKeySequence("Ctrl+o"), self)
        connect(self.import_torrent_shortcut.activated, self.on_add_torrent_browse_file)
        self.add_torrent_url_shortcut = QShortcut(QKeySequence("Ctrl+i"), self)
        connect(self.add_torrent_url_shortcut.activated, self.on_add_torrent_from_url)

        connect(self.top_search_bar.clicked, self.clicked_search_bar)

        # Remove the focus rect on OS X
        for widget in self.findChildren(QLineEdit) + self.findChildren(QListWidget) + self.findChildren(QTreeWidget):
            widget.setAttribute(Qt.WA_MacShowFocusRect, 0)

        self.menu_buttons = [
            self.left_menu_button_downloads,
            self.left_menu_button_discovered,
            self.left_menu_button_trust_graph,
            self.left_menu_button_popular,
        ]
        hide_xxx = get_gui_setting(self.gui_settings, "family_filter", True, is_bool=True)
        self.search_results_page.initialize_content_page(hide_xxx=hide_xxx)
        self.search_results_page.channel_torrents_filter_input.setHidden(True)

        self.settings_page.initialize_settings_page()
        self.downloads_page.initialize_downloads_page()
        self.loading_page.initialize_loading_page()
        self.discovering_page.initialize_discovering_page()

        self.discovered_page.initialize_content_page(hide_xxx=hide_xxx)

        self.popular_page.initialize_content_page(hide_xxx=hide_xxx)

        self.trust_page.initialize_trust_page()
        self.trust_graph_page.initialize_trust_graph()

        self.stackedWidget.setCurrentIndex(PAGE_LOADING)

        # Create the system tray icon
        if QSystemTrayIcon.isSystemTrayAvailable():
            self.tray_icon = QSystemTrayIcon()
            use_monochrome_icon = get_gui_setting(self.gui_settings, "use_monochrome_icon", False, is_bool=True)
            self.update_tray_icon(use_monochrome_icon)

            # Create the tray icon menu
            menu = self.create_add_torrent_menu()
            show_downloads_action = QAction('Show downloads', self)
            connect(show_downloads_action.triggered, self.clicked_menu_button_downloads)
            token_balance_action = QAction('Show token balance', self)
            connect(token_balance_action.triggered, lambda _: self.on_token_balance_click(None))
            quit_action = QAction('Quit Tribler', self)
            connect(quit_action.triggered, self.close_tribler)
            menu.addSeparator()
            menu.addAction(show_downloads_action)
            menu.addAction(token_balance_action)
            menu.addSeparator()
            menu.addAction(quit_action)
            self.tray_icon.setContextMenu(menu)
        else:
            self.tray_icon = None

        self.left_menu_button_debug.setHidden(True)
        self.top_menu_button.setHidden(True)
        self.left_menu.setHidden(True)
        self.token_balance_widget.setHidden(True)
        self.settings_button.setHidden(True)
        self.add_torrent_button.setHidden(True)
        self.top_search_bar.setHidden(True)

        # Set various icons
        self.top_menu_button.setIcon(QIcon(get_image_path('menu.png')))

        self.search_completion_model = QStringListModel()
        completer = QCompleter()
        completer.setModel(self.search_completion_model)
        completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
        self.item_delegate = QStyledItemDelegate()
        completer.popup().setItemDelegate(self.item_delegate)
        completer.popup().setStyleSheet(
            """
        QListView {
            background-color: #404040;
        }

        QListView::item {
            color: #D0D0D0;
            padding-top: 5px;
            padding-bottom: 5px;
        }

        QListView::item:hover {
            background-color: #707070;
        }
        """
        )
        self.top_search_bar.setCompleter(completer)

        # Toggle debug if developer mode is enabled
        self.window().left_menu_button_debug.setHidden(
            not get_gui_setting(self.gui_settings, "debug", False, is_bool=True)
        )

        # Start Tribler
        self.core_manager.start(core_args=core_args, core_env=core_env)

        connect(self.core_manager.events_manager.torrent_finished, self.on_torrent_finished)
        connect(self.core_manager.events_manager.new_version_available, self.on_new_version_available)
        connect(self.core_manager.events_manager.tribler_started, self.on_tribler_started)
        connect(self.core_manager.events_manager.low_storage_signal, self.on_low_storage)
        connect(self.core_manager.events_manager.tribler_shutdown_signal, self.on_tribler_shutdown_state_update)
        connect(self.core_manager.events_manager.config_error_signal, self.on_config_error_signal)

        # Install signal handler for ctrl+c events
        def sigint_handler(*_):
            self.close_tribler()

        signal.signal(signal.SIGINT, sigint_handler)

        # Resize the window according to the settings
        center = QApplication.desktop().availableGeometry(self).center()
        pos = self.gui_settings.value("pos", QPoint(center.x() - self.width() * 0.5, center.y() - self.height() * 0.5))
        size = self.gui_settings.value("size", self.size())

        self.move(pos)
        self.resize(size)

        self.show()

        self.add_to_channel_dialog = AddToChannelDialog(self.window())

        self.add_torrent_menu = self.create_add_torrent_menu()
        self.add_torrent_button.setMenu(self.add_torrent_menu)

        self.channels_menu_list = self.findChild(ChannelsMenuListWidget, "channels_menu_list")

        connect(self.channels_menu_list.itemClicked, self.open_channel_contents_page)

        # The channels content page is only used to show subscribed channels, so we always show xxx
        # contents in it.
        connect(
            self.core_manager.events_manager.node_info_updated,
            lambda data: self.channels_menu_list.reload_if_necessary([data]),
        )
        connect(self.left_menu_button_new_channel.clicked, self.create_new_channel)
Esempio n. 28
0
    def __init__(self, parent=None):
        super(ExtendedComboBox, self).__init__(parent)
        self.setFocusPolicy(Qt.StrongFocus)
        self.setInsertPolicy(QComboBox.NoInsert)
        self.setEditable(True)

        # add a filter model to filter matching items
        self.pFilterModel = QSortFilterProxyModel(self)
        self.pFilterModel.setFilterCaseSensitivity(Qt.CaseInsensitive)
        self.pFilterModel.setSourceModel(self.model())

        # add a completer, which uses the filter model
        self.completer = CustomQCompleter(self.pFilterModel, self)
        self.completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.mCompleterItemDelegate = QStyledItemDelegate(self)

        self.completer.popup().setItemDelegate(self.mCompleterItemDelegate)

        self.comboStyleSheet = ("""
            QLineEdit {
                border: 2px solid gray;
                border-radius: 15px;
                padding: 6px;
                selection-background-color: darkgray;
                min-width: 10em;
                font: 20px;
                outline: 0px;
            }            
            """ + "QAbstractItemView {"
                                "    min-width: 200px;"
                                "}\n"
                                "QAbstractItemView::item {"
                                "    min-height: 30px;"
                                "}\n"
                                "QScrollBar:vertical {\n"
                                "  width: 5px;\n"
                                "  background: #f1f1f1;\n"
                                "}\n"
                                "\n"
                                "QScrollBar::handle:vertical {\n"
                                "  background: #888;\n"
                                "  border-radius: 2px;\n"
                                "}\n"
                                "QScrollBar::add-line:vertical {\n"
                                "  border: 2px solid gray;\n"
                                "  background: #f1f1f1;\n"
                                "}\n"
                                "\n"
                                "QScrollBar::handle:hover:vertical {\n"
                                "  background: #555;\n"
                                "}\n")

        self.setDropDownStylesheet()

        # always show all (filtered) completions
        self.completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
        self.setCompleter(self.completer)

        # connect signals
        self.lineEdit().textEdited.connect(
            self.pFilterModel.setFilterFixedString)
        self.lineEdit().returnPressed.connect(self.returnPress)
        self.completer.activated.connect(self.on_completer_activated)
Esempio n. 29
0
 def on_text_mode_action(self):
     self.slide_list_widget.list_view.setItemDelegate(QStyledItemDelegate())
     list_model = self.slide_list_widget.list_model
     list_model.beginResetModel()
     self.slide_list_widget.list_model.text_mode(self.item_to_str)
     list_model.endResetModel()
Esempio n. 30
0
    def __init__(self, parent=None):
        super(NewShardDialog, self).__init__(parent)
        self.setFixedSize(250, 150)

        frame = QFrame(self)
        frame_layout = QVBoxLayout()

        name_layout = QHBoxLayout()
        name_label = QLabel()
        name_label.setText("世界别名:")
        name_label.setFixedWidth(70)
        self.name_lineEdit = QLineEdit()
        name_layout.addWidget(name_label)
        name_layout.addWidget(self.name_lineEdit)

        ip_layout = QHBoxLayout()
        ip_label = QLabel()
        ip_label.setText("服务器:")
        ip_label.setFixedWidth(70)
        self.server = QComboBox()
        self.server.setStyleSheet(
            "QComboBox QAbstractItemView::item { min-height: 25px; min-width: 100px; }"
        )
        self.server.setItemDelegate(QStyledItemDelegate())
        ip_layout.addWidget(ip_label)
        ip_layout.addWidget(self.server)

        serverlaber1layout = QHBoxLayout()
        serverlaber1 = QLabel()
        serverlaber1.setText("世界属性:")
        serverlaber1.setFixedWidth(70)
        ismasterGroup = QButtonGroup()
        self.ismasterR = QRadioButton()
        self.notmasterR = QRadioButton()
        self.ismasterR.setText("主世界")
        self.ismasterR.setFixedWidth(80)
        self.notmasterR.setText("附从世界")
        self.notmasterR.setChecked(True)
        ismasterGroup.addButton(self.ismasterR)
        ismasterGroup.addButton(self.notmasterR)
        serverlaber1layout.addWidget(serverlaber1)
        serverlaber1layout.addWidget(self.ismasterR)
        serverlaber1layout.addWidget(self.notmasterR)

        type_layout = QHBoxLayout()
        type_label = QLabel()
        type_label.setText("世界类型:")
        type_label.setFixedWidth(70)
        self.type = QComboBox()
        self.type.setStyleSheet(
            "QComboBox QAbstractItemView::item { min-height: 25px; min-width: 100px; }"
        )
        self.type.setItemDelegate(QStyledItemDelegate())
        self.type.addItems(["地面", "洞穴", "挂机", "熔炉", "暴食"])
        type_layout.addWidget(type_label)
        type_layout.addWidget(self.type)

        btn_layout = QHBoxLayout()
        self.cancel_btn = QPushButton()
        self.cancel_btn.setText("取消")
        self.save_btn = QPushButton()
        self.save_btn.setText("确定")
        btn_layout.addWidget(self.cancel_btn)
        btn_layout.addWidget(self.save_btn)

        frame_layout.addLayout(name_layout)
        frame_layout.addLayout(ip_layout)
        frame_layout.addLayout(serverlaber1layout)
        frame_layout.addLayout(type_layout)
        frame_layout.addLayout(btn_layout)
        frame.setLayout(frame_layout)

        self.cancel_btn.clicked.connect(self.hide)
        self.save_btn.clicked.connect(self.save)