コード例 #1
0
ファイル: iepwizard.py プロジェクト: guanzd88/iep
    def __init__(self, parent, i):
        BaseIEPWizardPage.__init__(self, parent, i)

        # Create label and checkbox
        t1 = translate('wizard',
                       "This wizard can be opened using 'Help > IEP wizard'")
        t2 = translate('wizard', "Show this wizard on startup")
        self._label_info = QtGui.QLabel(t1, self)
        self._check_show = QtGui.QCheckBox(t2, self)
        self._check_show.stateChanged.connect(self._setNewUser)

        # Create language switcher
        self._langLabel = QtGui.QLabel(translate('wizard', "Select language"),
                                       self)
        #
        self._langBox = QtGui.QComboBox(self)
        self._langBox.setEditable(False)
        # Fill
        index, theIndex = -1, -1
        cur = iep.config.settings.language
        for lang in sorted(LANGUAGES):
            index += 1
            self._langBox.addItem(lang)
            if lang == LANGUAGE_SYNONYMS.get(cur, cur):
                theIndex = index
        # Set current index
        if theIndex >= 0:
            self._langBox.setCurrentIndex(theIndex)
        # Bind signal
        self._langBox.activated.connect(self.onLanguageChange)

        # Init check state
        if iep.config.state.newUser:
            self._check_show.setCheckState(QtCore.Qt.Checked)

        # Create sublayout
        layout = QtGui.QHBoxLayout()
        layout.addWidget(self._langLabel, 0)
        layout.addWidget(self._langBox, 0)
        layout.addStretch(2)
        self.layout().addLayout(layout)

        # Add to layout
        self.layout().addSpacing(10)
        self.layout().addWidget(self._label_info)
        self.layout().addWidget(self._check_show)
コード例 #2
0
ファイル: iepProjectManager.py プロジェクト: guanzd88/iep
    def __init__(self, parent):
        QtGui.QWidget.__init__(self, parent)

        # Init config
        toolId = self.__class__.__name__.lower()
        self.config = iep.config.tools[toolId]
        if not hasattr(self.config, 'projects'):
            self.config.projects = []
        if not hasattr(self.config, 'activeproject'):
            self.config.activeproject = -1
        if not hasattr(self.config, 'filter'):
            self.config.filter = '!*.pyc'
        if not hasattr(self.config, 'listdisclosed'):
            self.config.listdisclosed = True

        # Create example?
        if not self.config.projects:
            exampleProject = Project('Example', os.path.expanduser('~'))
            self.config.projects.append(exampleProject)
            self.config.activeproject = 0

        #Init projects model
        self.projectsModel = ProjectsModel(self.config)

        #Init dir model and filtered dir model
        self.dirModel = QtGui.QFileSystemModel()
        #TODO: using the default IconProvider bugs on mac, restoring window state fails

        self.dirModel.setIconProvider(IconProviderWindows())

        #TODO: self.dirModel.setSorting(QtCore.QDir.DirsFirst)
        # todo: huh? QFileSystemModel.setSorting Does not exist
        self.filteredDirModel = DirSortAndFilter()
        self.filteredDirModel.setSourceModel(self.dirModel)

        #Init widgets and layout
        self.buttonLayout = QtGui.QVBoxLayout()
        self.configButton = QtGui.QPushButton(self)
        self.configButton.setIcon(iep.icons.wrench)
        self.configButton.setIconSize(QtCore.QSize(16, 16))

        self.buttonLayout.addWidget(self.configButton, 0)
        self.buttonLayout.addStretch(1)

        self.projectsCombo = QtGui.QComboBox()
        self.projectsCombo.setModel(self.projectsModel)

        self.hLayout = QtGui.QHBoxLayout()
        self.hLayout.addWidget(self.projectsCombo, 1)
        self.hLayout.addLayout(self.buttonLayout, 0)

        self.dirList = QtGui.QTreeView()
        self.dirList.setHeaderHidden(True)

        # The lessThan function in DirSortAndFilter ensures dirs are before files
        self.dirList.sortByColumn(0, QtCore.Qt.AscendingOrder)
        self.filterCombo = QtGui.QComboBox()

        self.layout = QtGui.QVBoxLayout()
        self.layout.addWidget(DeprLabel(self))
        self.layout.addLayout(self.hLayout)
        self.layout.addWidget(self.dirList, 10)
        self.layout.addWidget(self.filterCombo)

        self.setLayout(self.layout)

        #Load projects in the list
        self.projectsCombo.show()

        #Load default filters
        self.filterCombo.setEditable(True)
        self.filterCombo.setCompleter(None)
        self.filterCombo.setInsertPolicy(self.filterCombo.NoInsert)
        for pattern in [
                '*', '!*.pyc', '*.py *.pyw *.pyx *.pxd', '*.h *.c *.cpp'
        ]:
            self.filterCombo.addItem(pattern)
        self.filterCombo.editTextChanged.connect(self.filterChanged)

        # Set file pattern line edit (in combobox)
        self.filterPattern = self.filterCombo.lineEdit()
        self.filterPattern.setText(self.config.filter)
        self.filterPattern.setToolTip('File filter pattern')

        #Connect signals
        self.projectsCombo.currentIndexChanged.connect(self.comboChangedEvent)
        self.dirList.doubleClicked.connect(self.itemDoubleClicked)
        self.configButton.clicked.connect(self.showConfigDialog)

        #Apply previous selected project
        self.activeProject = None
        self.projectChanged(self.config.activeproject)

        #Attach the context menu
        self.dirList.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.dirList.customContextMenuRequested.connect(
            self.contextMenuTriggered)
コード例 #3
0
ファイル: iepWebBrowser.py プロジェクト: guanzd88/iep
    def __init__(self, parent):
        QtGui.QFrame.__init__(self, parent)

        # Init config
        toolId = self.__class__.__name__.lower()
        self._config = iep.config.tools[toolId]
        if not hasattr(self._config, 'zoomFactor'):
            self._config.zoomFactor = 1.0
        if not hasattr(self._config, 'bookMarks'):
            self._config.bookMarks = default_bookmarks

        # Get style object (for icons)
        style = QtGui.QApplication.style()

        # Create some buttons
        self._back = QtGui.QToolButton(self)
        self._back.setIcon(style.standardIcon(style.SP_ArrowBack))
        self._back.setIconSize(QtCore.QSize(16, 16))
        #
        self._forward = QtGui.QToolButton(self)
        self._forward.setIcon(style.standardIcon(style.SP_ArrowForward))
        self._forward.setIconSize(QtCore.QSize(16, 16))

        # Create address bar
        #self._address = QtGui.QLineEdit(self)
        self._address = QtGui.QComboBox(self)
        self._address.setEditable(True)
        self._address.setInsertPolicy(self._address.NoInsert)
        #
        for a in self._config.bookMarks:
            self._address.addItem(a)
        self._address.setEditText('')

        # Create web view
        self._view = WebView(self)
        #
        #         self._view.setZoomFactor(self._config.zoomFactor)
        #         settings = self._view.settings()
        #         settings.setAttribute(settings.JavascriptEnabled, True)
        #         settings.setAttribute(settings.PluginsEnabled, True)

        # Layout
        self._sizer1 = QtGui.QVBoxLayout(self)
        self._sizer2 = QtGui.QHBoxLayout()
        #
        self._sizer2.addWidget(self._back, 0)
        self._sizer2.addWidget(self._forward, 0)
        self._sizer2.addWidget(self._address, 1)
        #
        self._sizer1.addLayout(self._sizer2, 0)
        self._sizer1.addWidget(self._view, 1)
        #
        self._sizer1.setSpacing(2)
        self.setLayout(self._sizer1)

        # Bind signals
        self._back.clicked.connect(self.onBack)
        self._forward.clicked.connect(self.onForward)
        self._address.lineEdit().returnPressed.connect(self.go)
        self._address.activated.connect(self.go)
        self._view.loadFinished.connect(self.onLoadEnd)
        self._view.loadStarted.connect(self.onLoadStart)

        # Start
        self._view.show()
        self.go('http://docs.python.org')