Exemplo n.º 1
0
class SelectFromListDialog(QDialog):
    def __init__(self, options, parent=None, title=''):
        super(SelectFromListDialog, self).__init__(parent)
        layout = QVBoxLayout(self)
        self.setWindowTitle(title)

        self.setStyleSheet("background-color: rgb(245,247,255);")

        # nice widget for editing the date
        self.selector = QListWidget(self)
        self.selector.addItems(list(options))
        layout.addWidget(self.selector)

        # OK and Cancel buttons
        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)
        layout.addWidget(self.buttons)

        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

    def selected(self):
        items = self.selector.selectedItems()
        q_text = items[0].text()
        return str(q_text)

    @staticmethod
    def get_selected(options, parent=None, title=''):
        dialog = SelectFromListDialog(options, parent, title)
        dialog.selector.setItemSelected(dialog.selector.item(0), True)
        result = dialog.exec_()
        focus = dialog.selected()
        return focus, result == QDialog.Accepted
Exemplo n.º 2
0
 def createCellWidget(self, qmlDict, attr, count):
     """
     Creates specific widgets for each attribute, which can be a QCombobox, a QLineEdit or a QListWidget.
     """
     if attr in qmlDict.keys():
         enableIgnoreOption = False
         #case the type is dict the cell widget must be a combobox
         if isinstance(qmlDict[attr],dict):
             comboItem = DsgCustomComboBox()
             comboItem.addItems(sorted(qmlDict[attr].keys()))
             self.attributeTableWidget.setCellWidget(count, 1, comboItem)
         #case the type is tuple the cell widget must be a listwidget
         if isinstance(qmlDict[attr],tuple):
             (table, filterKeys) = qmlDict[attr]
             #getting the value relation dictionary used to make the listwidget
             valueRelation = self.makeValueRelationDict(table, filterKeys)
             list = QListWidget()
             for key in valueRelation.keys():
                 listItem = QListWidgetItem(key)
                 listItem.setCheckState(Qt.Unchecked)
                 list.addItem(listItem)
             self.attributeTableWidget.setCellWidget(count, 1, list)
     #this is the normal case, a simple lineedit
     else:
         textItem = QLineEdit()
         self.attributeTableWidget.setCellWidget(count, 1, textItem)
         enableIgnoreOption = True
     #insert here aditional parameters
     self.createAditionalParameters(count, enableIgnoreOption)
Exemplo n.º 3
0
 def listKeyPressEvent(self, event):
     if event.matches(QKeySequence.Delete):
         self.__deleteList()
     elif event.key() == Qt.Key_Escape:
         self.playlistList.setCurrentRow(-1)
     else:
         QListWidget.keyPressEvent(self.playlistList, event)
Exemplo n.º 4
0
 def keyPressEvent(self, event):
     text, key = event.text(), event.key()
     if (key in (Qt.Key_Return, Qt.Key_Enter) and self.enter_select) \
        or key == Qt.Key_Tab:
         self.item_selected()
         event.accept()
     elif key in (Qt.Key_Return, Qt.Key_Enter,
                  Qt.Key_Period, Qt.Key_Left, Qt.Key_Right):
         self.hide()
         self.textedit.keyPressEvent(event)
     elif event.modifiers() & Qt.ShiftModifier:
         self.textedit.keyPressEvent(event)
         if len(text):
             self.update_current()
         event.accept()
     elif key in (Qt.Key_Up, Qt.Key_Down, Qt.Key_PageUp, Qt.Key_PageDown,
                  Qt.Key_Home, Qt.Key_End):
         QListWidget.keyPressEvent(self, event)
     elif len(text) or key == Qt.Key_Backspace:
         self.textedit.keyPressEvent(event)
         self.update_current()
         event.accept()
     else:
         self.hide()
         event.ignore()
Exemplo n.º 5
0
    def __initGui(self):
        self.setWindowTitle("ChatTracer")

        g = QGridLayout()
        w = QWidget()
        w.setLayout(g)
        self.setCentralWidget(w)

        self.logWindow = QTextEdit()
        self.logWindow.setReadOnly(True)
        self.logWindow.setFocusPolicy(Qt.NoFocus)
        self.logWindow.setMinimumWidth(300)
        g.addWidget(self.logWindow, 0, 0, 3, 1)

        l = QLabel("ChatParticipants")
        g.addWidget(l, 0, 1)

        self.participants = QListWidget()
        self.participants.setMaximumWidth(250)
        self.participants.setFocusPolicy(Qt.NoFocus)
        g.addWidget(self.participants, 1, 1)

        pb = QPushButton("Refresh Participants")
        pb.clicked.connect(self.onRefreshParticipants)
        g.addWidget(pb, 2, 1)

        g.setColumnStretch(0, 3)
        g.setColumnStretch(1, 2)

        self.show()
        pb.setFocus()
Exemplo n.º 6
0
    def __init__(self, parent=None):
        super(ShowPresets, self).__init__(parent)
        self.original_presets_file = '/usr/share/ffmulticonverter/presets.xml'
        self.config_folder = os.getenv('HOME') + '/.config/ffmulticonverter/'
        self.current_presets_file = self.config_folder + 'presets.xml'

        self.presListWidget = QListWidget()
        labelLabel = QLabel(self.tr('Preset label'))
        self.labelLineEdit = QLineEdit()
        self.labelLineEdit.setReadOnly(True)
        commandLabel = QLabel(self.tr('Preset command line parameters'))
        self.commandLineEdit = QLineEdit()
        self.commandLineEdit.setReadOnly(True)
        extLabel = QLabel(self.tr('Output file extension'))
        self.extLineEdit = QLineEdit()
        self.extLineEdit.setReadOnly(True)
        addButton = QPushButton(self.tr('Add'))
        self.deleteButton = QPushButton(self.tr('Delete'))
        self.delete_allButton = QPushButton(self.tr('Delete all'))
        self.editButton = QPushButton(self.tr('Edit'))
        searchLabel = QLabel(self.tr('Search'))
        self.searchLineEdit = QLineEdit()
        okButton = QPushButton(self.tr('OK'))
        okButton.setDefault(True)

        spc1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        spc2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        spc3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)

        grid = pyqttools.add_to_grid(
            QGridLayout(), [self.delete_allButton, addButton, spc1],
            [self.deleteButton, self.editButton, spc2])

        hlayout = pyqttools.add_to_layout(QHBoxLayout(), searchLabel,
                                          self.searchLineEdit, None, okButton)

        final_layout = pyqttools.add_to_layout(
            QVBoxLayout(), self.presListWidget, labelLabel, self.labelLineEdit,
            commandLabel, self.commandLineEdit, extLabel, self.extLineEdit,
            grid, spc3, hlayout)

        self.setLayout(final_layout)

        okButton.clicked.connect(self.accept)
        self.presListWidget.currentRowChanged.connect(self.show_preset)
        addButton.clicked.connect(self.add_preset)
        self.deleteButton.clicked.connect(self.delete_preset)
        self.delete_allButton.clicked.connect(self.delete_all_presets)
        self.editButton.clicked.connect(self.edit_preset)
        self.searchLineEdit.textEdited.connect(self.search)

        del_shortcut = QShortcut(self)
        del_shortcut.setKey(Qt.Key_Delete)
        del_shortcut.activated.connect(self.delete_preset)

        self.resize(430, 480)
        self.setWindowTitle(self.tr('Edit Presets'))

        QTimer.singleShot(0, self.load_xml)
        QTimer.singleShot(0, self.fill_presListWidget)
Exemplo n.º 7
0
    def __init__(self, parent):
        QListWidget.__init__(self, parent)

        self.update_categories()
        self.addAction(create_widget_action(self, "F2", self._rename_category))
        self.addAction(create_widget_action(self, "Del", self._del_category))
        self.addAction(create_widget_action(self, "CTRL+N", self._new_category))
Exemplo n.º 8
0
 def __init__(self, parent=None):
     super(MigrationWidget, self).__init__(parent, Qt.WindowStaysOnTopHint)
     self._migration, vbox, hbox = {}, QVBoxLayout(self), QHBoxLayout()
     lbl_title = QLabel(translations.TR_CURRENT_CODE)
     lbl_suggestion = QLabel(translations.TR_SUGGESTED_CHANGES)
     self.current_list, self.suggestion = QListWidget(), QPlainTextEdit()
     self.suggestion.setReadOnly(True)
     self.btn_apply = QPushButton(translations.TR_APPLY_CHANGES + " !")
     self.suggestion.setToolTip(translations.TR_SAVE_BEFORE_APPLY + " !")
     self.btn_apply.setToolTip(translations.TR_SAVE_BEFORE_APPLY + " !")
     # pack up all widgets
     hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding))
     hbox.addWidget(self.btn_apply)
     vbox.addWidget(lbl_title)
     vbox.addWidget(self.current_list)
     vbox.addWidget(lbl_suggestion)
     vbox.addWidget(self.suggestion)
     vbox.addLayout(hbox)
     # connections
     self.connect(self.current_list,
                  SIGNAL("itemClicked(QListWidgetItem*)"),
                  self.load_suggestion)
     self.connect(self.btn_apply, SIGNAL("clicked()"), self.apply_changes)
     # registers
     IDE.register_service('tab_migration', self)
     ExplorerContainer.register_tab(translations.TR_TAB_MIGRATION, self)
Exemplo n.º 9
0
    def __init__(self, parent=None):
        super(HDFWidget, self).__init__(parent=parent)
        self.parent = parent

        self.main_layout = QVBoxLayout()

        ### Select Dataset and properties ###
        self.layout = QHBoxLayout()
        self.list = QListWidget()
        self.textBox = QTextEdit()
        self.textBox.resize(200, 200)

        ### Add button ###
        self.button = QPushButton("Apply")

        self.main_layout.addLayout(self.layout)
        self.main_layout.addWidget(self.button)
        self.setLayout(self.main_layout)

        self.layout.addWidget(self.list)
        self.layout.addWidget(self.textBox)

        ### Variables ###
        self.settings = None

        self.list.itemClicked.connect(self.item_clicked)
        self.connect(self.button, QtCore.SIGNAL("clicked()"),
                     self.apply_settings)
Exemplo n.º 10
0
class SelectFromListDialog(QDialog):
    def __init__(self, options, parent=None, title=''):
        super(SelectFromListDialog, self).__init__(parent)
        layout = QVBoxLayout(self)
        self.setWindowTitle(title)

        self.setStyleSheet("background-color: rgb(245,247,255);")

        # nice widget for editing the date
        self.selector = QListWidget(self)
        self.selector.addItems(list(options))
        layout.addWidget(self.selector)

        # OK and Cancel buttons
        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
            Qt.Horizontal, self)
        layout.addWidget(self.buttons)

        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

    def selected(self):
        items = self.selector.selectedItems()
        q_text = items[0].text()
        return str(q_text)

    @staticmethod
    def get_selected(options, parent=None, title=''):
        dialog = SelectFromListDialog(options, parent, title)
        dialog.selector.setItemSelected(dialog.selector.item(0), True)
        result = dialog.exec_()
        focus = dialog.selected()
        return focus, result == QDialog.Accepted
Exemplo n.º 11
0
    def __init__(self):
        QWidget.__init__(self)

        addHelpToWidget(self, "init/case_list")

        layout = QVBoxLayout()

        self._list = QListWidget(self)
        self._list.setMinimumHeight(100)
        self._list.setMaximumHeight(250)
        self._default_selection_mode = self._list.selectionMode()
        self.setSelectable(False)

        layout.addWidget(QLabel("Available Cases:"))
        layout.addWidget(self._list)

        self._addRemoveWidget = AddRemoveWidget(self.addItem, self.removeItem, horizontal=True)
        self._addRemoveWidget.enableRemoveButton(False)
        layout.addWidget(self._addRemoveWidget)

        self._title = "New keyword"
        self._description = "Enter name of keyword:"

        self.setLayout(layout)

        ERT.ertChanged.connect(self.updateList)
        self.updateList()
Exemplo n.º 12
0
    def mouseReleaseEvent(self, event):
        """ 
        Обрабатываем нажатие на иконку 'Интересно/Скучно' как нажатие на обычный чекбокс
        
        Решение достаточно грубое, но в данной ситуации вполне себе работает. Перехватывать нужно 
        отпускание мыши, потому что в QAbstractItemView редактирование запускается именно по 
        отпусканию. 
        
        """

        if event.pos().x() < settings.entryIconWidth():
            item = self.itemAt(event.pos())
            item.setSelected(True)
            rect = self.visualItemRect(item)
            iconRect = QRect(rect.left(),
                             rect.top(),
                             settings.entryIconWidth(),
                             settings.entryIconHeight())
            if iconRect.contains(event.pos()):
                if item.checkState() == Qt.Checked:
                    item.setCheckState(Qt.Unchecked)
                else:
                    item.setCheckState(Qt.Checked)
        else:
            QListWidget.mousePressEvent(self, event)
Exemplo n.º 13
0
    def __init__(self, load_func, profiles, parent=None):
        QDialog.__init__(self, parent, Qt.Dialog)
        self.setMinimumWidth(400)
        self._profiles = profiles
        self.load_function = load_func
        vbox = QVBoxLayout(self)
        self.profileList = QListWidget()
        self.profileList.addItems([key for key in profiles])
        self.contentList = QListWidget()
        self.contentList.setSortingEnabled(True)
        self.btnDelete = QPushButton(self.tr("Delete Profile"))
        self.btnDelete.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.btnOpen = QPushButton(self.tr("Open Profile"))
        self.btnOpen.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.btnOpen.setDefault(True)
        hbox = QHBoxLayout()
        hbox.addWidget(self.btnDelete)
        hbox.addWidget(self.btnOpen)

        vbox.addWidget(self.profileList)
        vbox.addWidget(self.contentList)
        vbox.addLayout(hbox)

        self.connect(self.profileList, SIGNAL("itemSelectionChanged()"),
            self.load_profile_content)
        self.connect(self.btnOpen, SIGNAL("clicked()"), self.open_profile)
        self.connect(self.btnDelete, SIGNAL("clicked()"), self.delete_profile)
Exemplo n.º 14
0
class HyphenDialog(QDialog):
    def __init__(self, mainwindow):
        super(HyphenDialog, self).__init__(mainwindow)
        self.setWindowModality(Qt.WindowModal)
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.topLabel = QLabel()
        self.listWidget = QListWidget()
        
        layout.addWidget(self.topLabel)
        layout.addWidget(self.listWidget)
        layout.addWidget(widgets.Separator())
        
        self.buttons = b = QDialogButtonBox()
        layout.addWidget(b)
        b.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        help.addButton(b, lyrics_help)
        b.rejected.connect(self.reject)
        b.accepted.connect(self.accept)
        
        self.load()
        app.translateUI(self)
        qutil.saveDialogSize(self, "hyphenation/dialog/size")
        
    def translateUI(self):
        self.setWindowTitle(app.caption(_("Hyphenate Lyrics Text")))
        self.topLabel.setText(_("Please select a language:"))
        
    def load(self):
        self._langs = [(language_names.languageName(lang, po.setup.current()), lang, dic)
                       for lang, dic in findDicts().iteritems()]
        self._langs.sort()
        for name, lang, dic in self._langs:
            self.listWidget.addItem("{0}  ({1})".format(name, lang))
            
        def select():
            lastused = settings().value("lastused", "", type(""))
            if lastused:
                yield lastused
            lang = po.setup.preferred()[0]
            yield lang
            yield lang.split('_')[0]
        
        langs = [item[1] for item in self._langs]
        for preselect in select():
            try:
                self.listWidget.setCurrentRow(langs.index(preselect))
                break
            except ValueError:
                continue
   
    def hyphenator(self):
        if self.exec_() and self._langs:
            lang, dic = self._langs[self.listWidget.currentRow()][1:]
            result = hyphenator.Hyphenator(dic)
            settings().setValue("lastused", lang)
        else:
            result = None
        self.deleteLater()
        return result
Exemplo n.º 15
0
class OpenProjectType(QDialog, ProjectWizard):

    def __init__(self, main):
        QDialog.__init__(self)
        ProjectWizard.__init__(self)
        self._main = main
        self.setModal(True)
        vbox = QVBoxLayout(self)
        vbox.addWidget(QLabel('Select the Type of Project:'))
        self.listWidget = QListWidget()
        projectTypes = self.types.keys()
        projectTypes.sort()
        self.listWidget.addItems(projectTypes)
        vbox.addWidget(self.listWidget)
        btnNext = QPushButton('Next')
        vbox.addWidget(btnNext)
        if len(projectTypes) > 0:
            self.listWidget.setCurrentRow(0)
        else:
            btnNext.setEnabled(False)

        self.connect(btnNext, SIGNAL("clicked()"), self._open_project)

    def _open_project(self):
        type_ = str(self.listWidget.currentItem().text())
        extensions = self.types[type_].projectFiles()
        if extensions is None:
            self._main.open_project_folder()
        else:
            self._main.open_project_type(extensions)
Exemplo n.º 16
0
 def listKeyPressEvent(self, event):
     if event.matches(QKeySequence.Delete):
         self.__deleteList()
     elif event.key() == Qt.Key_Escape:
         self.playlistList.setCurrentRow(-1)
     else:
         QListWidget.keyPressEvent(self.playlistList, event)
Exemplo n.º 17
0
    def __init__(self, data, win_parent=None, group_active='main'):
        PyDialog.__init__(self, data, win_parent)
        self.set_font_size(data['font_size'])
        self._updated_groups = False

        #self.out_data = data

        #print(data)
        keys = []
        self.keys = [
            group.name for key, group in sorted(iteritems(data))
            if isinstance(key, int)
        ]
        self.active_key = self.keys.index(group_active)

        group_obj = data[self.active_key]
        name = group_obj.name

        self.imain = 0
        self.nrows = len(self.keys)

        self._default_name = group_obj.name
        self._default_elements = group_obj.element_str
        self.elements_pound = group_obj.elements_pound

        self.table = QListWidget(parent=None)
        self.table.clear()
        self.table.addItems(self.keys)

        self.setWindowTitle('Groups: Modify')
        self.create_widgets()
        self.create_layout()
        self.set_connections()

        self.on_set_as_main()
Exemplo n.º 18
0
 def keyPressEvent(self, event):
     text, key = event.text(), event.key()
     alt = event.modifiers() & Qt.AltModifier
     shift = event.modifiers() & Qt.ShiftModifier
     ctrl = event.modifiers() & Qt.ControlModifier
     modifier = shift or ctrl or alt
     if (key in (Qt.Key_Return, Qt.Key_Enter) and self.enter_select) \
        or key == Qt.Key_Tab:
         self.item_selected()
     elif key in (Qt.Key_Return, Qt.Key_Enter,
                  Qt.Key_Left, Qt.Key_Right) or text in ('.', ':'):
         self.hide()
         self.textedit.keyPressEvent(event)
     elif key in (Qt.Key_Up, Qt.Key_Down, Qt.Key_PageUp, Qt.Key_PageDown,
                  Qt.Key_Home, Qt.Key_End,
                  Qt.Key_CapsLock) and not modifier:
         QListWidget.keyPressEvent(self, event)
     elif len(text) or key == Qt.Key_Backspace:
         self.textedit.keyPressEvent(event)
         self.update_current()
     elif modifier:
         self.textedit.keyPressEvent(event)
     else:
         self.hide()
         QListWidget.keyPressEvent(self, event)
Exemplo n.º 19
0
 def __init__(self, parent=None):
     QListWidget.__init__(self, parent)
     self.iface = backend.pm.Iface()
     self.defaultIcon = KIcon(('applications-other', 'unknown'), KIconLoader.SizeSmallMedium)
     self.connect(self, SIGNAL("itemClicked(QListWidgetItem*)"),
                         self.groupChanged)
     self._list = {}
Exemplo n.º 20
0
    def fill(self):
        logging.debug(__name__ + ': fill')
        self.setLayout(QVBoxLayout())

        self._splitter = QSplitter()
        self.layout().addWidget(self._splitter)

        self._toolList = QListWidget(self._splitter)
        self.connect(self._toolList, SIGNAL("itemSelectionChanged()"),
                     self.toolSelected)
        self._properties = PropertyView(self._splitter)

        bottom = QHBoxLayout()
        self.layout().addLayout(bottom)
        changedir = QPushButton("&Change tools directory...")
        bottom.addWidget(changedir)
        self.connect(changedir, SIGNAL('clicked()'), self.changedir)
        help = QPushButton("&Help")
        bottom.addWidget(help)
        self.connect(help, SIGNAL('clicked()'), self.help)
        bottom.addStretch()
        cancel = QPushButton('&Cancel')
        bottom.addWidget(cancel)
        self.connect(cancel, SIGNAL('clicked()'), self.reject)
        self.ok = QPushButton("&Apply")
        bottom.addWidget(self.ok)
        self.ok.setDefault(True)
        self.connect(self.ok, SIGNAL('clicked()'), self.apply)
Exemplo n.º 21
0
 def mousePressEvent(self, e):
     index = self.indexAt(e.pos())
     if index.isValid():
         item = self.itemAt(e.pos())
         if e.button() == Qt.RightButton:
             self.menu.popup(QCursor.pos())
     QListWidget.mousePressEvent(self, e)
Exemplo n.º 22
0
    def event(self, event):

        # -------------------------------------------------------------------
        try:

            if event.type() == QEvent.KeyPress:

                _key = str(event.key());

                if _key == "16777235": # |16777235| == arrow_up
                    self.UPDATE_TIMER.singleShot( 10, self.DELAYED_METHOD_CALL );

                elif _key == "16777237": # |16777237| == arrow_down
                    self.UPDATE_TIMER.singleShot( 10, self.DELAYED_METHOD_CALL );

                elif _key == "16777220": # ENTER
                    self.clearFocus();
                    self.ON_ITEM_SELECTED();
                    return True;

            elif event.type() == QEvent.MouseButtonRelease:

                self.ON_ITEM_SELECTED();
                self.clearFocus();
                return True;

            return QListWidget.event(self, event)

        except Exception as _err:
            self.LOCAL_ERROR_LOG( str(_err) );
            return QListWidget.event(self, event)
Exemplo n.º 23
0
    def __init__(self, parent=None):
        super(FileSelector, self).__init__(parent,
                                           Qt.Dialog | Qt.FramelessWindowHint)
        self.setObjectName("file-selector")
        self._files = {}
        self.effect = QGraphicsOpacityEffect()
        self.setGraphicsEffect(self.effect)
        self.animation = QPropertyAnimation(self.effect, "opacity")
        self.animation.setDuration(1500)
        box = QVBoxLayout(self)
        box.setSpacing(30)
        self.list_of_files = QListWidget()
        self.list_of_files.setObjectName("list-selector")
        box.addWidget(self.list_of_files)
        self.label_path = QLabel()
        box.addWidget(self.label_path)
        self._load_files()

        self.connect(self.list_of_files,
                     SIGNAL("itemSelectionChanged()"),
                     self._update_label)
        self.connect(self.list_of_files,
                     SIGNAL("itemActivated(QListWidgetItem*)"),
                     self._open_file)
        self.connect(self.list_of_files,
                     SIGNAL("itemEntered(QListWidgetItem*)"),
                     self._open_file)
Exemplo n.º 24
0
 def __init__(self, main):
     QListWidget.__init__(self)
     self.setStyleSheet("""
     WebPluginList {
       color: black;
       background-color: white;
       selection-color: blue;
       border-radius: 10px;
       selection-background-color: #437DCD;
     }
     WebPluginList:Item {
         border-radius: 10px;
         border-style: solid;
         background-color: white;
     }
     WebPluginList:Item:hover {
         border-radius: 10px;
         border-style: solid;
         background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                              stop: 0 #FAFBFE, stop: 1 #6181E0);
     }""")
     self.connect(self, SIGNAL("itemSelectionChanged()"), self.openSelected)
     self._main = main
     settings = QSettings()
     i = 1
     for recent_project in settings.value('recentProjects',
                                          []).toStringList():
         if manage_files.folder_exists(str(recent_project)):
             item = QListWidgetItem(str(recent_project.split('/')[-1]))
             item.setToolTip(recent_project)
             item.setIcon(QIcon(resources.images['tree-app']))
             self.addItem(item)
         i = i + 1
         if i == 10:
             break
Exemplo n.º 25
0
    def initializePage(self):
        super(PanelPage, self).initializePage()

        rootLayout = QVBoxLayout()
        rootLayout.setContentsMargins(20, 30, 20, 30)

        row0 = QHBoxLayout()
        lable0 = QLabel('  依赖库:')
        lable0.setAlignment(Qt.AlignTop | Qt.AlignHCenter)
        self.lw_files = QListWidget()
        items0 = QStringList()
        for moudel in app.g_configurations.libs:
            items0.append(moudel['name'])
        self.lw_files.addItems(items0)
        row0.addWidget(lable0)
        row0.addWidget(self.lw_files)

        row1 = QHBoxLayout()
        lable1 = QLabel('工程文件:')
        lable1.setAlignment(Qt.AlignTop | Qt.AlignHCenter)
        self.lw_files = QListWidget()
        items1 = QStringList()
        for file in app.g_configurations.config['files']:
            items1.append(file['target'])
        self.lw_files.addItems(items1)
        row1.addWidget(lable1)
        row1.addWidget(self.lw_files)

        rootLayout.addLayout(row0)
        rootLayout.addLayout(row1)
        self.setLayout(rootLayout)
Exemplo n.º 26
0
    def initShape(self):
        self.hbox = QHBoxLayout()
        self.hbox.setContentsMargins(0, 0, 0, 0)

        self.listWidget = QListWidget()
        self.listWidget.setSortingEnabled(True)
        for codec in QTextCodec.availableCodecs():
            self.listWidget.addItem(str(codec))
        item = self.listWidget.findItems('UTF-8', Qt.MatchExactly)[0]
        self.listWidget.setCurrentItem(item)
        self.listWidget.scrollToItem(item)

        textAreaWidget = QWidget()
        self.hbox.addWidget(self.listWidget)
        self.connect(self.listWidget, SIGNAL("itemSelectionChanged()"),
                     self.codecChanged)

        self.scroll = Scroll(self)
        self.text = TextEdit(self)

        self.hbox.addWidget(self.text)
        self.hbox.addWidget(self.scroll)

        textAreaWidget.setLayout(self.hbox)

        self.addWidget(self.listWidget)
        self.addWidget(textAreaWidget)
        self.setStretchFactor(0, 0)
        self.setStretchFactor(1, 1)
Exemplo n.º 27
0
    def __init__(self, suggested, parent=None):
        super(PythonDetectDialog, self).__init__(parent, Qt.Dialog)
        self.setMaximumSize(QSize(0, 0))
        self.setWindowTitle("Configure Python Path")

        vbox = QVBoxLayout(self)
        msg_str = ("We have detected that you are using "
                   "Windows,\nplease choose the proper "
                   "Python application for you:")
        lblMessage = QLabel(self.tr(msg_str))
        vbox.addWidget(lblMessage)

        self.listPaths = QListWidget()
        self.listPaths.setSelectionMode(QListWidget.SingleSelection)
        vbox.addWidget(self.listPaths)

        hbox = QHBoxLayout()
        hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding))
        btnCancel = QPushButton(self.tr("Cancel"))
        btnAccept = QPushButton(self.tr("Accept"))
        hbox.addWidget(btnCancel)
        hbox.addWidget(btnAccept)
        vbox.addLayout(hbox)

        self.connect(btnAccept, SIGNAL("clicked()"), self._set_python_path)
        self.connect(btnCancel, SIGNAL("clicked()"), self.close)

        for path in suggested:
            self.listPaths.addItem(path)
        self.listPaths.setCurrentRow(0)
 def keyPressEvent(self, event):
     if event.matches(QKeySequence.Delete):
         self.__removeSelected()
     elif event.key() == Qt.Key_Escape:
         self.currentList.currentList.setCurrentRow(-1)
     else:
         QListWidget.keyPressEvent(self.currentList, event)
Exemplo n.º 29
0
    def __init__(self, parent=None):
        super(NewProjectManager, self).__init__(parent, Qt.Dialog)
        self.setWindowTitle(translations.TR_NEW_PROJECT)
        self.setMinimumHeight(500)
        vbox = QVBoxLayout(self)
        vbox.addWidget(QLabel(translations.TR_CHOOSE_TEMPLATE))
        vbox.addWidget(QLabel(translations.TR_TAB_PROJECTS))

        hbox = QHBoxLayout()
        self.list_projects = QListWidget()
        self.list_projects.setProperty("wizard", True)
        hbox.addWidget(self.list_projects)

        self.list_templates = QListWidget()
        self.list_templates.setProperty("wizard", True)
        hbox.addWidget(self.list_templates)

        self.text_info = QTextBrowser()
        self.text_info.setProperty("wizard", True)
        hbox.addWidget(self.text_info)

        vbox.addLayout(hbox)

        hbox2 = QHBoxLayout()
        self.cancel = QPushButton(translations.TR_CANCEL)
        self.choose = QPushButton(translations.TR_CHOOSE)
        hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding,
            QSizePolicy.Fixed))
        hbox2.addWidget(self.cancel)
        hbox2.addWidget(self.choose)
        vbox.addLayout(hbox2)
Exemplo n.º 30
0
    def __init__(self, projects, parent=None):
        super(AddToProject, self).__init__(parent)
        #pathProjects must be a list
        self._projects = projects
        self.setWindowTitle(translations.TR_ADD_FILE_TO_PROJECT)
        self.pathSelected = ''
        vbox = QVBoxLayout(self)

        hbox = QHBoxLayout()
        self._list = QListWidget()
        for project in self._projects:
            self._list.addItem(project.name)
        self._list.setCurrentRow(0)
        self._tree = QTreeView()
        #self._tree.header().setHidden(True)
        self._tree.setSelectionMode(QTreeView.SingleSelection)
        self._tree.setAnimated(True)
        self.load_tree(self._projects[0])
        hbox.addWidget(self._list)
        hbox.addWidget(self._tree)
        vbox.addLayout(hbox)

        hbox2 = QHBoxLayout()
        btnAdd = QPushButton(translations.TR_ADD_HERE)
        btnCancel = QPushButton(translations.TR_CANCEL)
        hbox2.addWidget(btnCancel)
        hbox2.addWidget(btnAdd)
        vbox.addLayout(hbox2)

        self.connect(btnCancel, SIGNAL("clicked()"), self.close)
        self.connect(btnAdd, SIGNAL("clicked()"), self._select_path)
        self.connect(
            self._list,
            SIGNAL("currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)"),
            self._project_changed)
Exemplo n.º 31
0
 def keyPressEvent(self, event):
     text, key = event.text(), event.key()
     alt = event.modifiers() & Qt.AltModifier
     shift = event.modifiers() & Qt.ShiftModifier
     ctrl = event.modifiers() & Qt.ControlModifier
     modifier = shift or ctrl or alt
     if (key in (Qt.Key_Return, Qt.Key_Enter) and self.enter_select) \
        or key == Qt.Key_Tab:
         self.item_selected()
     elif key in (Qt.Key_Return, Qt.Key_Enter, Qt.Key_Left,
                  Qt.Key_Right) or text in ('.', ':'):
         self.hide()
         self.textedit.keyPressEvent(event)
     elif key in (Qt.Key_Up, Qt.Key_Down, Qt.Key_PageUp, Qt.Key_PageDown,
                  Qt.Key_Home, Qt.Key_End,
                  Qt.Key_CapsLock) and not modifier:
         QListWidget.keyPressEvent(self, event)
     elif len(text) or key == Qt.Key_Backspace:
         self.textedit.keyPressEvent(event)
         self.update_current()
     elif modifier:
         self.textedit.keyPressEvent(event)
     else:
         self.hide()
         QListWidget.keyPressEvent(self, event)
Exemplo n.º 32
0
    def createExecutionWidget(self):
        self._executionDescriptionWidget = self.createDescriptionWidget(
            VispaWidget.ARROW_SHAPE_RIGHT, self.EXECUTING_DESCRIPTION)

        bodyWidget = QWidget(self._executionDescriptionWidget)
        bodyWidget.setLayout(QGridLayout())
        bodyWidget.layout().setContentsMargins(0, 0, 0, 0)

        label = QLabel("Open and run existing analysis:")
        bodyWidget.layout().addWidget(label, 0, 0)
        analysisDesignerButton = QToolButton()
        analysisDesignerButton.setText("Open analysis file")
        analysisDesignerButton.setIcon(self._fileopenIcon)
        self.connect(analysisDesignerButton, SIGNAL("clicked(bool)"),
                     self.parent().openAnalysisFileSlot)
        bodyWidget.layout().addWidget(analysisDesignerButton, 0, 1)
        self._analysisDesignerRecentFilesList = QListWidget()
        self._analysisDesignerRecentFilesList.setFixedSize(
            label.sizeHint().width() +
            analysisDesignerButton.sizeHint().width(), 150)
        self.connect(self._analysisDesignerRecentFilesList,
                     SIGNAL("doubleClicked(QModelIndex)"),
                     self.parent().openAnalysisFileSlot)
        bodyWidget.layout().addWidget(self._analysisDesignerRecentFilesList, 1,
                                      0, 1, 2)

        self._executionDescriptionWidget.setBodyWidget(bodyWidget)
Exemplo n.º 33
0
    def __init__(self):
        super(MigrationWidget, self).__init__()
        self._migration = {}
        vbox = QVBoxLayout(self)
        lbl_title = QLabel(self.tr("Current code:"))
        self.current_list = QListWidget()
        lbl_suggestion = QLabel(self.tr("Suggested changes:"))
        self.suggestion = QPlainTextEdit()
        self.suggestion.setReadOnly(True)

        self.btn_apply = QPushButton(self.tr("Apply change!"))
        hbox = QHBoxLayout()
        hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding))
        hbox.addWidget(self.btn_apply)

        vbox.addWidget(lbl_title)
        vbox.addWidget(self.current_list)
        vbox.addWidget(lbl_suggestion)
        vbox.addWidget(self.suggestion)
        vbox.addLayout(hbox)

        self.connect(self.current_list,
                     SIGNAL("itemClicked(QListWidgetItem*)"),
                     self.load_suggestion)
        self.connect(self.btn_apply, SIGNAL("clicked()"), self.apply_changes)
Exemplo n.º 34
0
 def keyPressEvent(self, event):
     text, key = event.text(), event.key()
     if (key in (Qt.Key_Return, Qt.Key_Enter) and self.enter_select) \
        or key == Qt.Key_Tab:
         self.item_selected()
         event.accept()
     elif key in (Qt.Key_Return, Qt.Key_Enter,
                  Qt.Key_Period, Qt.Key_Left, Qt.Key_Right):
         self.hide()
         self.textedit.keyPressEvent(event)
     elif event.modifiers() & Qt.ShiftModifier:
         self.textedit.keyPressEvent(event)
         if len(text):
             self.update_current()
         event.accept()
     elif key in (Qt.Key_Up, Qt.Key_Down, Qt.Key_PageUp, Qt.Key_PageDown,
                  Qt.Key_Home, Qt.Key_End):
         QListWidget.keyPressEvent(self, event)
     elif len(text) or key == Qt.Key_Backspace:
         self.textedit.keyPressEvent(event)
         self.update_current()
         event.accept()
     else:
         self.hide()
         event.ignore()
Exemplo n.º 35
0
class CardListWidged(QWidget):
    def __init__(self):
        super(CardListWidged, self).__init__()
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

        self.word_list = QListWidget(self)
        self.word_list.currentItemChanged.connect(self.on_item_changed)
        self.layout.addWidget(self.word_list)

        #making control panel
        self.control_panel = ControlPanel(self)
        self.layout.addWidget(self.control_panel)

        #create word edit widget
        self.card_edit_widget = CardEditWidget(self)
        self.layout.addWidget(self.card_edit_widget)
        self.cards = []
        self.cards = load_cards()
        self._update_word_list()


    def _update_word_list(self):
        self.word_list.clear()
        words = []
        for card in self.cards:
            words.append(card.word)
        self.word_list.addItems(words)

    def on_item_changed(self, curr, prev):
        word = curr.text()
        card = find_card_by_word(self.cards, word)
        self.card_edit_widget.show_card(card)
Exemplo n.º 36
0
 def __init__(self, parent=None):
     QListWidget.__init__(self, parent)
     self.iface = backend.pm.Iface()
     self.defaultIcon = KIcon(('applications-other', 'unknown'), KIconLoader.SizeSmallMedium)
     self.connect(self, SIGNAL("itemClicked(QListWidgetItem*)"),
                         self.groupChanged)
     self._list = {}
Exemplo n.º 37
0
    def __init__(self, name, stringlist=None, parent=None):
        super(StringListDlg, self).__init__(parent)

        self.name = name

        self.listWidget = QListWidget()
        if stringlist is not None:
            self.listWidget.addItems(stringlist)
            self.listWidget.setCurrentRow(0)
        buttonLayout = QVBoxLayout()
        for text, slot in (("&Add...", self.add), ("&Edit...", self.edit),
                           ("&Remove...", self.remove), ("&Up", self.up),
                           ("&Down", self.down), ("&Sort",
                                                  self.listWidget.sortItems),
                           ("Close", self.accept)):
            button = QPushButton(text)
            if not MAC:
                button.setFocusPolicy(Qt.NoFocus)
            if text == "Close":
                buttonLayout.addStretch()
            buttonLayout.addWidget(button)
            self.connect(button, SIGNAL("clicked()"), slot)
        layout = QHBoxLayout()
        layout.addWidget(self.listWidget)
        layout.addLayout(buttonLayout)
        self.setLayout(layout)
        self.setWindowTitle("Edit {0} List".format(self.name))
Exemplo n.º 38
0
    def __init__(self, parent=None):
        super(NotebookListDialog, self).__init__(parent)

        self.notebookList = QListWidget()
        self.moveUp = QPushButton('<<')
        self.moveDown = QPushButton('>>')
        self.add = QPushButton('Add')
        self.remove = QPushButton('Remove')
        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                          | QDialogButtonBox.Cancel)
        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
        layout = QGridLayout()
        layout.addWidget(self.notebookList, 0, 0, 4, 6)
        layout.addWidget(self.moveUp, 1, 6)
        layout.addWidget(self.moveDown, 2, 6)
        layout.addWidget(self.add, 4, 0)
        layout.addWidget(self.remove, 4, 1)
        layout.addWidget(self.buttonBox, 4, 5, 1, 2)
        self.setLayout(layout)

        self.notebookList.setItemDelegate(ListDelegate(self.notebookList))

        self.notebookList.currentRowChanged.connect(self.updateUi)
        self.add.clicked.connect(self.actionAdd)
        self.remove.clicked.connect(self.actionRemove)
        self.moveUp.clicked.connect(self.moveItemUp)
        self.moveDown.clicked.connect(self.moveItemDown)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        self.initList()
Exemplo n.º 39
0
    def __init__(self, opPixelClassification, parent):
        super( QDialog, self ).__init__(parent=parent)
        self._op = opPixelClassification
        classifier_listwidget = QListWidget(parent=self)
        classifier_listwidget.setSelectionMode( QListWidget.SingleSelection )

        classifier_factories = self._get_available_classifier_factories()
        for name, classifier_factory in classifier_factories.items():
            item = QListWidgetItem( name )
            item.setData( Qt.UserRole, QVariant(classifier_factory) )
            classifier_listwidget.addItem(item)

        buttonbox = QDialogButtonBox( Qt.Horizontal, parent=self )
        buttonbox.setStandardButtons( QDialogButtonBox.Ok | QDialogButtonBox.Cancel )
        buttonbox.accepted.connect( self.accept )
        buttonbox.rejected.connect( self.reject )
        
        layout = QVBoxLayout()
        layout.addWidget( classifier_listwidget )
        layout.addWidget( buttonbox )

        self.setLayout(layout)
        self.setWindowTitle( "Select Classifier Type" )
        
        # Save members
        self._classifier_listwidget = classifier_listwidget
Exemplo n.º 40
0
 def __init__(self, main):
     QListWidget.__init__(self)
     self.setStyleSheet("""
     WebPluginList {
       color: black;
       background-color: white;
       selection-color: blue;
       border-radius: 10px;
       selection-background-color: #437DCD;
     }
     WebPluginList:Item {
         border-radius: 10px;
         border-style: solid;
         background-color: white;
     }
     WebPluginList:Item:hover {
         border-radius: 10px;
         border-style: solid;
         background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                              stop: 0 #FAFBFE, stop: 1 #6181E0);
     }""")
     self.connect(self, SIGNAL("itemSelectionChanged()"), self.openSelected)
     self._main = main
     settings = QSettings()
     i = 1
     for recent_project in settings.value('recentProjects', []).toStringList():
         if manage_files.folder_exists(str(recent_project)):
             item = QListWidgetItem(str(recent_project.split('/')[-1]))
             item.setToolTip(recent_project)
             item.setIcon(QIcon(resources.images['tree-app']))
             self.addItem(item)
         i = i + 1
         if i == 10:
             break
Exemplo n.º 41
0
    def __init__(self, parent=None):
        super(MigrationWidget, self).__init__(parent, Qt.WindowStaysOnTopHint)
        self._migration = {}
        vbox = QVBoxLayout(self)
        lbl_title = QLabel(self.tr("Current code:"))
        self.current_list = QListWidget()
        lbl_suggestion = QLabel(self.tr("Suggested changes:"))
        self.suggestion = QPlainTextEdit()
        self.suggestion.setReadOnly(True)

        self.btn_apply = QPushButton(self.tr("Apply change!"))
        hbox = QHBoxLayout()
        hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding))
        hbox.addWidget(self.btn_apply)

        vbox.addWidget(lbl_title)
        vbox.addWidget(self.current_list)
        vbox.addWidget(lbl_suggestion)
        vbox.addWidget(self.suggestion)
        vbox.addLayout(hbox)

        self.connect(self.current_list,
                     SIGNAL("itemClicked(QListWidgetItem*)"),
                     self.load_suggestion)
        self.connect(self.btn_apply, SIGNAL("clicked()"), self.apply_changes)

        IDE.register_service('tab_migration', self)
        ExplorerContainer.register_tab(translations.TR_TAB_MIGRATION, self)
Exemplo n.º 42
0
    def __init__(self, parent, fields):
        QDialog.__init__(self, parent)

        layout = QVBoxLayout(self)

        self._list_elements = QListWidget(self)
        self._fields = dict(fields)
        for field, ftype in fields.items():
            self._list_elements.addItem(field + ' (' + ftype + ')')

        self._list_elements.setSelectionMode(
            QAbstractItemView.ExtendedSelection)

        layout.addWidget(self._list_elements)

        add_remove = AddRemoveButtonBar(self, 'Remove selected field(s)',
                                        self.remove, 'Add field', self.add)
        layout.addWidget(add_remove)

        buttons = QWidget(self)
        buttons_layout = QHBoxLayout()
        buttons.setLayout(buttons_layout)
        buttons_layout.addStretch()
        ok_button = QPushButton("Ok")
        cancel_button = QPushButton("Cancel")
        ok_button.clicked.connect(self.accept)
        cancel_button.clicked.connect(self.reject)
        buttons_layout.addWidget(ok_button)
        buttons_layout.addWidget(cancel_button)
        layout.addWidget(buttons)

        self.setLayout(layout)
Exemplo n.º 43
0
    def __init__(self, editor, project):
        QCompleter.__init__(self)

        self.icons = {
            'function': QIcon(resources.images['function']),
            'instance': QIcon(resources.images['attribute']),
            'module': QIcon(resources.images['module']),
            'class': QIcon(resources.images['class'])
        }

        self._editor = editor
        self._fromProject = False
        if project is not None:
            if type(project) is str:
                project = rope.base.project.Project(project, None,
                                                    '.ninjaproject')
            self._project = project
            self._fromProject = True
        else:
            self._project = rope.base.project.get_no_project()
        self.setWidget(self._editor)
        self.popupView = QListWidget()
        self.popupView.setAlternatingRowColors(True)
        self.popupView.setWordWrap(False)
        self.setPopup(self.popupView)
        self.setCompletionMode(QCompleter.PopupCompletion)
        self.setCaseSensitivity(Qt.CaseInsensitive)

        self.connect(self, SIGNAL("activated(QString)"),
                     self.insert_completion)
Exemplo n.º 44
0
    def createVerifyingWidget(self):
        self._verifyingDescriptionWidget = self.createDescriptionWidget(
            VispaWidget.ARROW_SHAPE_LEFT, self.VERIFYING_DESCRIPTION)

        bodyWidget = QWidget(self._verifyingDescriptionWidget)
        bodyWidget.setLayout(QGridLayout())
        bodyWidget.layout().setContentsMargins(0, 0, 0, 0)

        label = QLabel("Browse an existing PXL data file:")
        bodyWidget.layout().addWidget(label, 0, 0)
        analysisDesignerButton = QToolButton()
        analysisDesignerButton.setText("Open PXL file")
        analysisDesignerButton.setIcon(self._fileopenIcon)
        self.connect(analysisDesignerButton, SIGNAL("clicked(bool)"),
                     self.parent().openPxlFileSlot)
        bodyWidget.layout().addWidget(analysisDesignerButton, 0, 1)
        self._pxlEditorRecentFilesList = QListWidget()
        self._pxlEditorRecentFilesList.setFixedSize(
            label.sizeHint().width() +
            analysisDesignerButton.sizeHint().width(), 150)
        self.connect(self._pxlEditorRecentFilesList,
                     SIGNAL("doubleClicked(QModelIndex)"),
                     self.parent().openPxlFileSlot)
        bodyWidget.layout().addWidget(self._pxlEditorRecentFilesList, 1, 0, 1,
                                      2)

        self._verifyingDescriptionWidget.setBodyWidget(bodyWidget)
Exemplo n.º 45
0
    def initMainUi(self):
        role_names = self.parentApplet.dataSelectionApplet.topLevelOperator.DatasetRoles.value
        self.list_widgets = []
        
        # Create a tab for each role
        for role_index, role_name in enumerate(role_names):
            select_button = QPushButton("Select " + role_name + " Files...", 
                                        clicked=partial(self.select_files, role_index) )
            clear_button = QPushButton("Clear " + role_name + " Files",
                                       clicked=partial(self.clear_files, role_index) )
            button_layout = QHBoxLayout()
            button_layout.addWidget(select_button)
            button_layout.addSpacerItem( QSpacerItem(0,0,hPolicy=QSizePolicy.Expanding) )
            button_layout.addWidget(clear_button)
            button_layout.setContentsMargins(0, 0, 0, 0)
            
            button_layout_widget = QWidget()
            button_layout_widget.setLayout(button_layout)
            button_layout_widget.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum) )

            list_widget = QListWidget(parent=self)
            list_widget.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) )
            self.list_widgets.append( list_widget )

            tab_layout = QVBoxLayout()
            tab_layout.setContentsMargins(0, 0, 0, 0)
            tab_layout.addWidget( button_layout_widget )
            tab_layout.addWidget( list_widget )
            
            layout_widget = QWidget(parent=self)
            layout_widget.setLayout(tab_layout)
            self.addTab(layout_widget, role_name)
Exemplo n.º 46
0
 def keyPressEvent(self, event):
     if event.matches(QKeySequence.Delete):
         self.__removeSelected()
     elif event.key() == Qt.Key_Escape:
         self.currentList.currentList.setCurrentRow(-1)
     else:
         QListWidget.keyPressEvent(self.currentList, event)
Exemplo n.º 47
0
class OpenProjectType(QDialog, ProjectWizard):
    def __init__(self, main):
        QDialog.__init__(self)
        ProjectWizard.__init__(self)
        self._main = main
        self.setModal(True)
        vbox = QVBoxLayout(self)
        vbox.addWidget(QLabel('Select the Type of Project:'))
        self.listWidget = QListWidget()
        projectTypes = self.types.keys()
        projectTypes.sort()
        self.listWidget.addItems(projectTypes)
        vbox.addWidget(self.listWidget)
        btnNext = QPushButton('Next')
        vbox.addWidget(btnNext)
        if len(projectTypes) > 0:
            self.listWidget.setCurrentRow(0)
        else:
            btnNext.setEnabled(False)

        self.connect(btnNext, SIGNAL("clicked()"), self._open_project)

    def _open_project(self):
        type_ = str(self.listWidget.currentItem().text())
        extensions = self.types[type_].projectFiles()
        if extensions is None:
            self._main.open_project_folder()
        else:
            self._main.open_project_type(extensions)
Exemplo n.º 48
0
    def initializePage(self):
        super(PanelPage, self).initializePage()

        rootLayout = QVBoxLayout()
        rootLayout.setContentsMargins(20, 30, 20, 30)

        row0 = QHBoxLayout()
        lable0 = QLabel('  依赖库:')
        lable0.setAlignment(Qt.AlignTop | Qt.AlignHCenter)
        self.lw_files = QListWidget()
        items0 = QStringList()
        for moudel in app.g_configurations.libs:
            items0.append(moudel['name'])
        self.lw_files.addItems(items0)
        row0.addWidget(lable0)
        row0.addWidget(self.lw_files)

        row1 = QHBoxLayout()
        lable1 = QLabel('工程文件:')
        lable1.setAlignment(Qt.AlignTop | Qt.AlignHCenter)
        self.lw_files = QListWidget()
        items1 = QStringList()
        for file in app.g_configurations.config['files']:
            items1.append(file['target'])
        self.lw_files.addItems(items1)
        row1.addWidget(lable1)
        row1.addWidget(self.lw_files)

        rootLayout.addLayout(row0)
        rootLayout.addLayout(row1)
        self.setLayout(rootLayout)
Exemplo n.º 49
0
class ErrorsWidget(QWidget):

    def __init__(self):
        QWidget.__init__(self)
        self.pep8 = None
        self._outRefresh = True

        vbox = QVBoxLayout(self)
        self.listErrors = QListWidget()
        self.listPep8 = QListWidget()
        self.errorsLabel = QLabel(self.tr(ERRORS_TEXT).arg(0))
        vbox.addWidget(self.errorsLabel)
        vbox.addWidget(self.listErrors)
        self.pep8Label = QLabel(self.tr(PEP8_TEXT).arg(0))
        vbox.addWidget(self.pep8Label)
        vbox.addWidget(self.listPep8)

        self.connect(self.listErrors, SIGNAL("itemSelectionChanged()"),
            self.errors_selected)
        self.connect(self.listPep8, SIGNAL("itemSelectionChanged()"),
            self.pep8_selected)

    def errors_selected(self):
        editorWidget = main_container.MainContainer().get_actual_editor()
        if editorWidget and self._outRefresh:
            lineno = self.listErrors.currentItem().data(Qt.UserRole).toInt()[0]
            editorWidget.jump_to_line(lineno)
            editorWidget.setFocus()

    def pep8_selected(self):
        editorWidget = main_container.MainContainer().get_actual_editor()
        if editorWidget and self._outRefresh:
            lineno = self.listPep8.currentItem().data(Qt.UserRole).toInt()[0]
            editorWidget.jump_to_line(lineno)
            editorWidget.setFocus()

    def refresh_lists(self, errors, pep8):
        self._outRefresh = False
        self.listErrors.clear()
        self.listPep8.clear()
        for lineno in errors.errorsSummary:
            linenostr = 'L%s\t' % str(lineno + 1)
            for data in errors.errorsSummary[lineno]:
                item = QListWidgetItem(linenostr + data)
                item.setToolTip(linenostr + data)
                item.setData(Qt.UserRole, lineno)
                self.listErrors.addItem(item)
        self.errorsLabel.setText(self.tr(ERRORS_TEXT).arg(
            len(errors.errorsSummary)))
        for lineno in pep8.pep8checks:
            linenostr = 'L%s\t' % str(lineno + 1)
            for data in pep8.pep8checks[lineno]:
                item = QListWidgetItem(linenostr + data.split('\n')[0])
                item.setToolTip(linenostr + data.split('\n')[0])
                item.setData(Qt.UserRole, lineno)
                self.listPep8.addItem(item)
        self.pep8Label.setText(self.tr(PEP8_TEXT).arg(
            len(pep8.pep8checks)))
        self._outRefresh = True
Exemplo n.º 50
0
    def initUI(self, engine):
        splitter = QSplitter(Qt.Horizontal)      
        
        # make the right panel
        right_panel = QSplitter(Qt.Vertical)        
        player = Player()
        track_queue = QListWidget()
        
        ## set play on double click
        def play_track():
            player.set_track(track_queue.currentItem().get_track())
            player.play()
        track_queue.doubleClicked.connect(play_track)

        ## advance list on track finish
        def track_finish_task():		
            print 'track finished'
            if track_queue.currentRow() == track_queue.count() - 1:
                track_queue.setCurrentRow(0)
            else:
                track_queue.setCurrentRow(track_queue.currentRow() + 1)
            play_track()
        player.track_finished.connect(track_finish_task)

        ## put some entry controls on menu
        track_queue.setContextMenuPolicy(Qt.CustomContextMenu)
        def onContext(point):
            ## make action
            qaction = QAction('Delete item', track_queue)
            def remove_entry():
                track_queue.takeItem(track_queue.currentRow())
            qaction.triggered.connect(remove_entry)	  
            # Create a menu
            menu = QMenu("Menu", track_queue)
            menu.addAction(qaction)
            # Show the context menu.
            menu.exec_(track_queue.mapToGlobal(point))      
        track_queue.connect(track_queue, QtCore.SIGNAL("customContextMenuRequested(QPoint)"),
                        onContext)
        utils.add_widgets_to_component(right_panel, [player, track_queue])     
        
        ## make the left panel
        left_panel = QWidget()
        vbox = QVBoxLayout()
        utils.add_widgets_to_component(vbox, 
                    [PlaylistsPanel(engine, [player], [track_queue]),
	                   SearchPanel(engine, [player], [track_queue])])
        left_panel.setLayout(vbox)  
        
        utils.add_widgets_to_component(splitter, [left_panel, right_panel])
        splitter.setSizes([1, 10])
        
        bottomBar = self.make_bottom_bar()        

        # Application UI layout
        vBox = QVBoxLayout(self)        
        vBox.addWidget(splitter)
        vBox.addWidget(bottomBar)        
        self.setLayout(vBox)
Exemplo n.º 51
0
    def __init__(self, parent):
        QListWidget.__init__(self, parent)

        self.category_id = None
        self.update_articles()
        self.addAction(create_widget_action(self, "F2", self._rename_article))
        self.addAction(create_widget_action(self, "Del", self._del_article))
        self.addAction(create_widget_action(self, "CTRL+N", self._new_article))
Exemplo n.º 52
0
    def __init__(self, parent):
        QListWidget.__init__(self, parent)

        self.article_id = None
        self.update_words()

        self.itemDoubleClicked.connect(self._select_item)
        self.addAction(create_widget_action(self, "Return", self._select_item))
        self.addAction(create_widget_action(self, "Delete", self._delete_item))
Exemplo n.º 53
0
class InterfacePage(QWizardPage):

    def __init__(self):
        super(InterfacePage,self).__init__()
        self.completed = False
        self.setTitle('接口设置')
        self.setSubTitle('设置需要实现的接口')
        rootLayout = QVBoxLayout()
        rootLayout.setContentsMargins(20, 30, 20, 30)

        self.lw_interface = QListWidget()
        rootLayout.addWidget(self.lw_interface)
        self.setLayout(rootLayout)

    def initializePage(self):
        super(InterfacePage, self).initializePage()
        exsits = []
        for key in app.g_configurations.interfaces:
            if app.g_configurations.interfaces[key]:
                exsits.append(key)

        for interface in app.g_configurations.config['interfaces']:
            litem = QListWidgetItem(interface['name'])
            litem.setToolTip(interface['description'])
            litem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
            if app.g_configurations.initialized:
                if interface['name'] in exsits:
                    litem.setCheckState(Qt.Checked)
                else:
                    litem.setCheckState(Qt.Unchecked)
            else:
                isdefault = False
                if app.g_configurations.component_type == "window":
                    if interface['default'] & 2:
                        isdefault = True
                else:
                    if interface['default'] & 1:
                        isdefault = True
                if isdefault:
                    litem.setCheckState(Qt.Checked)
                else:
                    litem.setCheckState(Qt.Unchecked)
            self.lw_interface.addItem(litem)

    def validatePage(self):
        interfaces = {}
        for i in range(self.lw_interface.count()):
            litem = self.lw_interface.item(i)
            key = app.QString2str(litem.text())
            if litem.checkState() == 2:
                interfaces[key] = True;
            else:
                interfaces[key] = False;

        app.g_configurations.interfaces = interfaces
        return True
Exemplo n.º 54
0
class DetailWindow(myWindow):
  
    listToParaAndRdnr = {}
  
    def __init__(self, parent = None):
        super(DetailWindow, self).__init__(parent, layoutCls = QHBoxLayout, fixed = False)
        self._listWidget = QListWidget(self)
        self._paraAndRdnr = QTableView(self)
        self.layout().addWidget(self._listWidget)
        self.layout().addWidget(self._paraAndRdnr)
        self._listWidget.clicked.connect(self.showParaAndRdnr)
  
    def showParaAndRdnr(self, listItem):
        paraAndRdnr = self.listToParaAndRdnr.get(listItem.row())
        model = QStandardItemModel(self)
        c = 0
        for para, rdnrs in paraAndRdnr.iteritems():
            l = self._createListItem(para, rdnrs)
            model.insertRow(c, l)
            c += 1
        model.setHeaderData(0, Qt.Horizontal, "Paragraph")
        model.setHeaderData(1, Qt.Horizontal, "Randnummern")
        self._paraAndRdnr.setModel(model)
    
    def _createListItem(self, para, rdnrs):
        rdnrsAsStr = toStr(collect([item for sublist in rdnrs for item in sublist]))
        item1 = QStandardItem(para.decode("utf-8"))
        item1.setToolTip(para.decode("utf-8"))
        item2 = QStandardItem(rdnrsAsStr)
        item2.setToolTip(rdnrsAsStr)
        return [item1, item2]
  
    def showDetails(self, content, windowTitle = None):
        if windowTitle: self.setWindowTitle(windowTitle)
        details = self._map_details(content)
        self._listWidget.clear()
        i = 0
        for fileName, paraAndRdnrs in details.iteritems():
            self._listWidget.addItem(fileName)
            self.listToParaAndRdnr[i] = paraAndRdnrs
            i += 1
    
    def _map_details(self, data):
        def nestedMap(data):
            res = {}
            idx = len(data[0])-1
            for d in data:
                old = res.get(d[idx], [])
                old.append(d[:idx])
                res[d[idx]] = old
            return res
        
        res = nestedMap(data)
        for k, v in res.iteritems():
            res[k] = nestedMap(v)
        return res
Exemplo n.º 55
0
 def createEditor(self, parent, option, index):
     # special combobox for field type
     if index.column() == self.column:
         list = QListWidget(parent)
         for item in self.itemsDict:
             listItem = QListWidgetItem(item)
             listItem.setCheckState(Qt.Unchecked)
             list.addItem(listItem)
         return list
     return QItemDelegate.createEditor(self, parent, option, index)
Exemplo n.º 56
0
class TrackListView(QDockWidget):
    def __init__(self, parent=None):
        QDockWidget.__init__(self, parent)

        self.trackList = QListWidget()
        self.trackList.addItem("juhu")

        # layout = QVBoxLayout()
        # layout.addWidget(trackList)
        self.setWidget(self.trackList)
Exemplo n.º 57
0
 def __init__(self, parent, ancestor):
     QListWidget.__init__(self, ancestor)
     self.setWindowFlags(Qt.SubWindow | Qt.FramelessWindowHint)
     self.textedit = parent
     self.completion_list = None
     self.case_sensitive = False
     self.show_single = None
     self.enter_select = None
     self.hide()
     self.connect(self, SIGNAL("itemActivated(QListWidgetItem*)"),
                  self.item_selected)
Exemplo n.º 58
0
	def __init__(self, qnotero):

		"""
		Constructor

		Arguments:
		qnotero -- a Qnotero instance
		"""

		QListWidget.__init__(self, qnotero)
		self.setMouseTracking(True)
Exemplo n.º 59
0
    def __init__(self, parent):
        QListWidget.__init__(self, parent)
        self.setStyleSheet(
            "QListWidget { background: #1a1d1f }")
        self._parent = parent
        self.setContextMenuPolicy(Qt.CustomContextMenu)

        # Conexión
        self.connect(self, SIGNAL("itemClicked(QListWidgetItem*)"),
                     self._go_to_line)
        self.connect(self, SIGNAL("customContextMenuRequested(const QPoint)"),
                     self._load_context_menu)