def fillStyleList(self): """Fill list of styles.""" for stns in self.stylesheet.getSettingsList(): item = qt4.QListWidgetItem(utils.getIcon(stns.pixmap), stns.usertext) item.VZsettings = stns self.stylesListWidget.addItem(item)
def __init__(self, document, pagenumber): qt4.QScrollArea.__init__(self) self.setFrameShape(qt4.QFrame.NoFrame) self.setWidgetResizable(True) # window which shows plot self.document = document pw = self.plotwin = PlotWindow(document, None) pw.isfullscreen = True pw.pagenumber = pagenumber self.setWidget(pw) pw.setFocus() self.showFullScreen() self.toolbar = qt4.QToolBar(_("Full screen toolbar"), self) self.toolbar.addAction(utils.getIcon("kde-window-close"), _("Close"), self.close) for a in ( "view.zoom11", "view.zoomin", "view.zoomout", "view.zoomwidth", "view.zoomheight", "view.zoompage", "view.prevpage", "view.nextpage", ): self.toolbar.addAction(pw.vzactions[a]) self.toolbar.show()
def __init__(self, *args): """Initialise the line edit.""" qt4.QLineEdit.__init__(self, *args) # the clear button itself, with no padding self.clearbutton = cb = qt4.QToolButton(self) cb.setIcon( utils.getIcon('kde-edit-delete') ) cb.setCursor(qt4.Qt.ArrowCursor) cb.setStyleSheet('QToolButton { border: none; padding: 0px; }') cb.setToolTip("Clear text") cb.hide() # make clicking on the button clear the text self.connect(cb, qt4.SIGNAL('clicked()'), self, qt4.SLOT("clear()")) # button should appear if there is text self.connect(self, qt4.SIGNAL('textChanged(const QString&)'), self.updateCloseButton) # positioning of the button fw = self.style().pixelMetric(qt4.QStyle.PM_DefaultFrameWidth) self.setStyleSheet("QLineEdit { padding-right: %ipx; } " % (cb.sizeHint().width() + fw + 1)) msz = self.minimumSizeHint() mx = cb.sizeHint().height()+ fw*2 + 2 self.setMinimumSize( max(msz.width(), mx), max(msz.height(), mx) )
def __init__(self, *args): """Initialise the line edit.""" qt4.QLineEdit.__init__(self, *args) # the clear button itself, with no padding self.clearbutton = cb = qt4.QToolButton(self) cb.setIcon(utils.getIcon('kde-edit-delete')) cb.setCursor(qt4.Qt.ArrowCursor) cb.setStyleSheet('QToolButton { border: none; padding: 0px; }') cb.setToolTip("Clear text") cb.hide() # make clicking on the button clear the text self.connect(cb, qt4.SIGNAL('clicked()'), self, qt4.SLOT("clear()")) # button should appear if there is text self.connect(self, qt4.SIGNAL('textChanged(const QString&)'), self.updateCloseButton) # positioning of the button fw = self.style().pixelMetric(qt4.QStyle.PM_DefaultFrameWidth) self.setStyleSheet("QLineEdit { padding-right: %ipx; } " % (cb.sizeHint().width() + fw + 1)) msz = self.minimumSizeHint() mx = cb.sizeHint().height() + fw * 2 + 2 self.setMinimumSize(max(msz.width(), mx), max(msz.height(), mx))
def data(self, index, role): """Return data for the index given.""" # why do we get passed invalid indicies? :-) if not index.isValid(): return qt4.QVariant() column = index.column() obj = index.internalPointer() if role == qt4.Qt.DisplayRole: # return text for columns if column == 0: return qt4.QVariant(obj.name) elif column == 1: return qt4.QVariant(obj.typename) elif role == qt4.Qt.DecorationRole: # return icon for first column if column == 0: filename = 'button_%s' % obj.typename return qt4.QVariant(utils.getIcon(filename)) elif role == qt4.Qt.ToolTipRole: # provide tool tip showing description if obj.userdescription: return qt4.QVariant(obj.userdescription) elif role == qt4.Qt.TextColorRole: # show disabled looking text if object or any parent is hidden hidden = False p = obj while p is not None: if 'hide' in p.settings and p.settings.hide: hidden = True break p = p.parent # return brush for hidden widget text, based on disabled text if hidden: return qt4.QVariant(qt4.QPalette().brush(qt4.QPalette.Disabled, qt4.QPalette.Text)) # return nothing return qt4.QVariant()
def data(self, index, role): """Return data for the index given.""" # why do we get passed invalid indicies? :-) if not index.isValid(): return qt4.QVariant() column = index.column() obj = index.internalPointer() if role == qt4.Qt.DisplayRole: # return text for columns if column == 0: return qt4.QVariant(obj.name) elif column == 1: return qt4.QVariant(obj.typename) elif role == qt4.Qt.DecorationRole: # return icon for first column if column == 0: filename = 'button_%s' % obj.typename return qt4.QVariant(utils.getIcon(filename)) elif role == qt4.Qt.ToolTipRole: # provide tool tip showing description if obj.userdescription: return qt4.QVariant(obj.userdescription) elif role == qt4.Qt.TextColorRole: # show disabled looking text if object or any parent is hidden hidden = False p = obj while p is not None: if 'hide' in p.settings and p.settings.hide: hidden = True break p = p.parent # return brush for hidden widget text, based on disabled text if hidden: return qt4.QVariant(qt4.QPalette().brush( qt4.QPalette.Disabled, qt4.QPalette.Text)) # return nothing return qt4.QVariant()
def __init__(self, document, pagenumber): qt4.QScrollArea.__init__(self) self.setFrameShape(qt4.QFrame.NoFrame) self.setWidgetResizable(True) # window which shows plot self.document = document pw = self.plotwin = PlotWindow(document, None) pw.isfullscreen = True pw.pagenumber = pagenumber self.setWidget(pw) pw.setFocus() self.showFullScreen() self.toolbar = qt4.QToolBar(_("Full screen toolbar"), self) self.toolbar.addAction(utils.getIcon("kde-window-close"), _("Close"), self.close) for a in ('view.zoom11', 'view.zoomin', 'view.zoomout', 'view.zoomwidth', 'view.zoomheight', 'view.zoompage', 'view.prevpage', 'view.nextpage'): self.toolbar.addAction(pw.vzactions[a]) self.toolbar.show()
def __init__(self, parent, document): VeuszDialog.__init__(self, parent, 'import.ui') self.document = document # whether file import looks likely to work self.filepreviewokay = False # tabs loaded currently in dialog self.tabs = {} for tabname, tabclass in ( (_('&Standard'), ImportTabStandard), (_('CS&V'), ImportTabCSV), (_('FI&TS'), ImportTabFITS), (_('&2D'), ImportTab2D), (_('Plugins'), ImportTabPlugins), ): w = tabclass(self) self.methodtab.addTab(w, tabname) # add promoted plugins for p in plugins.importpluginregistry: if p.promote_tab is not None: w = ImportTabPlugins(self, promote=p.name) self.methodtab.addTab(w, p.promote_tab) self.connect( self.methodtab, qt4.SIGNAL('currentChanged(int)'), self.slotUpdatePreview ) self.connect(self.browsebutton, qt4.SIGNAL('clicked()'), self.slotBrowseClicked) self.connect( self.filenameedit, qt4.SIGNAL('editTextChanged(const QString&)'), self.slotUpdatePreview ) self.importbutton = self.buttonBox.addButton(_("&Import"), qt4.QDialogButtonBox.ApplyRole) self.connect( self.importbutton, qt4.SIGNAL('clicked()'), self.slotImport) self.connect( self.buttonBox.button(qt4.QDialogButtonBox.Reset), qt4.SIGNAL('clicked()'), self.slotReset ) self.connect( self.encodingcombo, qt4.SIGNAL('currentIndexChanged(int)'), self.slotUpdatePreview ) # change to tab last used self.methodtab.setCurrentIndex( setting.settingdb.get('import_lasttab', 0)) # add completion for filename if there is support in version of qt # (requires qt >= 4.3) if hasattr(qt4, 'QDirModel'): c = self.filenamecompleter = qt4.QCompleter(self) model = qt4.QDirModel(c) c.setModel(model) self.filenameedit.setCompleter(c) # defaults for prefix and suffix self.prefixcombo.default = self.suffixcombo.default = ['', '$FILENAME'] # default state for check boxes self.linkcheckbox.default = True # further defaults self.encodingcombo.defaultlist = utils.encodings self.encodingcombo.defaultval = 'utf_8' # load icon for clipboard self.clipbutton.setIcon( utils.getIcon('kde-clipboard') ) self.connect(qt4.QApplication.clipboard(), qt4.SIGNAL('dataChanged()'), self.updateClipPreview) self.connect( self.clipbutton, qt4.SIGNAL("clicked()"), self.slotClipButtonClicked) self.updateClipPreview()
def __init__(self, document, setnsproxy, shownames=False): qt4.QTabWidget.__init__(self) self.document = document if setnsproxy is None: return # get list of settings self.setnsproxy = setnsproxy setnslist = setnsproxy.settingsProxyList() # add formatting settings if necessary numformat = len( [setn for setn in setnsproxy.settingList() if setn.formatting] ) if numformat > 0: # add on a formatting tab setnslist.insert(0, setnsproxy) self.connect( self, qt4.SIGNAL('currentChanged(int)'), self.slotCurrentChanged ) # subsettings for tabs self.tabsubsetns = [] # collected titles and tooltips for tabs self.tabtitles = [] self.tabtooltips = [] # tabs which have been initialized self.tabinit = set() # add tab for each subsettings for subset in setnslist: if subset.name() == 'StyleSheet': continue self.tabsubsetns.append(subset) # details of tab mainsettings = (subset is setnsproxy) if mainsettings: # main tab formatting, so this is special pixmap = 'settings_main' tabname = title = 'Main' tooltip = 'Main formatting' else: # others if hasattr(subset, 'pixmap'): pixmap = subset.pixmap() else: pixmap = None tabname = subset.name() tooltip = title = subset.usertext() # hide name in tab if not shownames: tabname = '' self.tabtitles.append(title) self.tabtooltips.append(tooltip) # create tab indx = self.addTab(qt4.QWidget(), utils.getIcon(pixmap), tabname) self.setTabToolTip(indx, tooltip)
def __init__(self, document, setnsproxy, shownames=False): qt4.QTabWidget.__init__(self) self.document = document if setnsproxy is None: return # get list of settings self.setnsproxy = setnsproxy setnslist = setnsproxy.settingsProxyList() # add formatting settings if necessary numformat = len( [setn for setn in setnsproxy.settingList() if setn.formatting] ) if numformat > 0: # add on a formatting tab setnslist.insert(0, setnsproxy) self.connect( self, qt4.SIGNAL('currentChanged(int)'), self.slotCurrentChanged ) # subsettings for tabs self.tabsubsetns = [] # collected titles and tooltips for tabs self.tabtitles = [] self.tabtooltips = [] # tabs which have been initialized self.tabinit = set() # add tab for each subsettings for subset in setnslist: if subset.setnsmode() not in ('formatting', 'widgetsettings'): continue self.tabsubsetns.append(subset) # details of tab if subset is setnsproxy: # main tab formatting, so this is special pixmap = 'settings_main' tabname = title = _('Main') tooltip = _('Main formatting') else: # others if hasattr(subset, 'pixmap'): pixmap = subset.pixmap() else: pixmap = None tabname = subset.name() tooltip = title = subset.usertext() # hide name in tab if not shownames: tabname = '' self.tabtitles.append(title) self.tabtooltips.append(tooltip) # create tab indx = self.addTab(qt4.QWidget(), utils.getIcon(pixmap), tabname) self.setTabToolTip(indx, tooltip)
def __init__(self, *args): qt4.QMainWindow.__init__(self, *args) self.setAcceptDrops(True) # icon and different size variations d = utils.imagedir self.setWindowIcon( utils.getIcon('veusz') ) # master documenent self.document = document.Document() # filename for document and update titlebar self.filename = '' self.updateTitlebar() # keep a list of references to dialogs self.dialogs = [] # construct menus and toolbars self._defineMenus() # make plot window self.plot = plotwindow.PlotWindow(self.document, self, menu = self.menus['view']) self.setCentralWidget(self.plot) self.plot.showToolbar() # likewise with the tree-editing window self.treeedit = treeeditwindow.TreeEditDock(self.document, self) self.addDockWidget(qt4.Qt.LeftDockWidgetArea, self.treeedit) self.propdock = treeeditwindow.PropertiesDock(self.document, self.treeedit, self) self.addDockWidget(qt4.Qt.LeftDockWidgetArea, self.propdock) self.formatdock = treeeditwindow.FormatDock(self.document, self.treeedit, self) self.addDockWidget(qt4.Qt.LeftDockWidgetArea, self.formatdock) self.datadock = DataNavigatorWindow(self.document, self, self) self.addDockWidget(qt4.Qt.RightDockWidgetArea, self.datadock) # make the console window a dock self.console = consolewindow.ConsoleWindow(self.document, self) self.console.hide() self.interpreter = self.console.interpreter self.addDockWidget(qt4.Qt.BottomDockWidgetArea, self.console) # assemble the statusbar statusbar = self.statusbar = qt4.QStatusBar(self) self.setStatusBar(statusbar) self.updateStatusbar('Ready') # a label for the picker readout self.pickerlabel = qt4.QLabel(statusbar) self._setPickerFont(self.pickerlabel) statusbar.addPermanentWidget(self.pickerlabel) self.pickerlabel.hide() # plot queue - how many plots are currently being drawn self.plotqueuecount = 0 self.connect( self.plot, qt4.SIGNAL("queuechange"), self.plotQueueChanged ) self.plotqueuelabel = qt4.QLabel() self.plotqueuelabel.setToolTip("Number of rendering jobs remaining") statusbar.addWidget(self.plotqueuelabel) self.plotqueuelabel.show() # a label for the cursor position readout self.axisvalueslabel = qt4.QLabel(statusbar) statusbar.addPermanentWidget(self.axisvalueslabel) self.axisvalueslabel.show() self.slotUpdateAxisValues(None) # a label for the page number readout self.pagelabel = qt4.QLabel(statusbar) statusbar.addPermanentWidget(self.pagelabel) self.pagelabel.show() # working directory - use previous one self.dirname = setdb.get('dirname', qt4.QDir.homePath()) self.dirname_export = setdb.get('dirname_export', self.dirname) if setdb['dirname_usecwd']: self.dirname = self.dirname_export = os.getcwd() # connect plot signals to main window self.connect( self.plot, qt4.SIGNAL("sigUpdatePage"), self.slotUpdatePage ) self.connect( self.plot, qt4.SIGNAL("sigAxisValuesFromMouse"), self.slotUpdateAxisValues ) self.connect( self.plot, qt4.SIGNAL("sigPickerEnabled"), self.slotPickerEnabled ) self.connect( self.plot, qt4.SIGNAL("sigPointPicked"), self.slotUpdatePickerLabel ) # disable save if already saved self.connect( self.document, qt4.SIGNAL("sigModified"), self.slotModifiedDoc ) # if the treeeditwindow changes the page, change the plot window self.connect( self.treeedit, qt4.SIGNAL("sigPageChanged"), self.plot.setPageNumber ) # if a widget in the plot window is clicked by the user self.connect( self.plot, qt4.SIGNAL("sigWidgetClicked"), self.treeedit.selectWidget ) self.connect( self.treeedit, qt4.SIGNAL("widgetsSelected"), self.plot.selectedWidgets ) # enable/disable undo/redo self.connect(self.menus['edit'], qt4.SIGNAL('aboutToShow()'), self.slotAboutToShowEdit) #Get the list of recently opened files self.populateRecentFiles() self.setupWindowGeometry() self.defineViewWindowMenu() # if document requests it, ask whether an allowed import self.connect(self.document, qt4.SIGNAL('check_allowed_imports'), self.slotAllowedImportsDoc)
def __init__(self, parent, document): VeuszDialog.__init__(self, parent, 'import.ui') self.document = document # whether file import looks likely to work self.filepreviewokay = False # tabs loaded currently in dialog self.tabs = {} for tabname, tabclass in ( (_('&Standard'), ImportTabStandard), (_('CS&V'), ImportTabCSV), (_('FI&TS'), ImportTabFITS), (_('&2D'), ImportTab2D), (_('Plugins'), ImportTabPlugins), ): w = tabclass(self) self.methodtab.addTab(w, tabname) # add promoted plugins for p in plugins.importpluginregistry: if p.promote_tab is not None: w = ImportTabPlugins(self, promote=p.name) self.methodtab.addTab(w, p.promote_tab) self.connect(self.methodtab, qt4.SIGNAL('currentChanged(int)'), self.slotUpdatePreview) self.connect(self.browsebutton, qt4.SIGNAL('clicked()'), self.slotBrowseClicked) self.connect(self.filenameedit, qt4.SIGNAL('editTextChanged(const QString&)'), self.slotUpdatePreview) self.importbutton = self.buttonBox.addButton( _("&Import"), qt4.QDialogButtonBox.ApplyRole) self.connect(self.importbutton, qt4.SIGNAL('clicked()'), self.slotImport) self.connect(self.buttonBox.button(qt4.QDialogButtonBox.Reset), qt4.SIGNAL('clicked()'), self.slotReset) self.connect(self.encodingcombo, qt4.SIGNAL('currentIndexChanged(int)'), self.slotUpdatePreview) # change to tab last used self.methodtab.setCurrentIndex( setting.settingdb.get('import_lasttab', 0)) # add completion for filename if there is support in version of qt # (requires qt >= 4.3) if hasattr(qt4, 'QDirModel'): c = self.filenamecompleter = qt4.QCompleter(self) model = qt4.QDirModel(c) c.setModel(model) self.filenameedit.setCompleter(c) # defaults for prefix and suffix self.prefixcombo.default = self.suffixcombo.default = ['', '$FILENAME'] # default state for check boxes self.linkcheckbox.default = True # further defaults self.encodingcombo.defaultlist = utils.encodings self.encodingcombo.defaultval = 'utf_8' # load icon for clipboard self.clipbutton.setIcon(utils.getIcon('kde-clipboard')) self.connect(qt4.QApplication.clipboard(), qt4.SIGNAL('dataChanged()'), self.updateClipPreview) self.connect(self.clipbutton, qt4.SIGNAL("clicked()"), self.slotClipButtonClicked) self.updateClipPreview()