def createListOption(self): def addItem(label, icon_pixmap, width, height): item = QListWidgetItem(list_option) item.setText(label) item.setTextAlignment(Qt.AlignHCenter) item.setIcon(QIcon(icon_pixmap)) item.setSizeHint(QSize(width, height)) list_option = QListWidget() list_option.setAutoFillBackground(True) list_option.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) list_option.setTextElideMode(Qt.ElideNone) list_option.setMovement(QListView.Static) list_option.setFlow(QListView.TopToBottom) list_option.setProperty("isWrapping", QVariant(False)) list_option.setSpacing(3) list_option.setViewMode(QListView.IconMode) items = [] items.append((QApplication.translate("option", "Connections"), "connections.png")) items.append((QApplication.translate("option", "Accounts"), "accounts.png")) items.append((QApplication.translate("option", "Aliases"), "aliases.png")) items.append((QApplication.translate("option", "Macros"), "macros.png")) items.append((QApplication.translate("option", "Keypad"), "keypad.png")) items.append((QApplication.translate("option", "Triggers"), "triggers.png")) items.append((QApplication.translate("option", "Preferences"), "preferences.png")) max_width = 0 for label, icon_name in items: w = list_option.fontMetrics().boundingRect(label).width() if w > max_width: max_width = w # An empiric method to align element in the center of the QListWidget max_width += 15 total_height = 0 for label, icon_name in items: icon_pixmap = QPixmap(":/images/" + icon_name) height = icon_pixmap.height() + list_option.fontMetrics().height() + 3 total_height += height + 5 addItem(label, icon_pixmap, max_width, height) list_option.setUniformItemSizes(True) list_option.setFixedWidth(max_width + 10) list_option.setMinimumHeight(total_height) return list_option
class PreferencesDialog(QDialog): def __init__(self, mainwindow): super(PreferencesDialog, self).__init__(mainwindow) self.setWindowModality(Qt.WindowModal) self.addAction(mainwindow.actionCollection.help_whatsthis) layout = QVBoxLayout() layout.setSpacing(10) self.setLayout(layout) # listview to the left, stacked widget to the right top = QHBoxLayout() layout.addLayout(top) self.pagelist = QListWidget(self) self.stack = QStackedWidget(self) top.addWidget(self.pagelist, 0) top.addWidget(self.stack, 2) layout.addWidget(widgets.Separator(self)) b = self.buttons = QDialogButtonBox(self) b.setStandardButtons( QDialogButtonBox.Ok | QDialogButtonBox.Cancel | QDialogButtonBox.Apply | QDialogButtonBox.Reset | QDialogButtonBox.Help) layout.addWidget(b) b.accepted.connect(self.accept) b.rejected.connect(self.reject) b.button(QDialogButtonBox.Apply).clicked.connect(self.saveSettings) b.button(QDialogButtonBox.Reset).clicked.connect(self.loadSettings) b.button(QDialogButtonBox.Help).clicked.connect(self.showHelp) b.button(QDialogButtonBox.Help).setShortcut(QKeySequence.HelpContents) b.button(QDialogButtonBox.Apply).setEnabled(False) # fill the pagelist self.pagelist.setIconSize(QSize(32, 32)) self.pagelist.setSpacing(2) for item in pageorder(): self.pagelist.addItem(item()) self.pagelist.currentItemChanged.connect(self.slotCurrentItemChanged) app.translateUI(self, 100) # read our size and selected page qutil.saveDialogSize(self, "preferences/dialog/size", QSize(500, 300)) self.pagelist.setCurrentRow(_prefsindex) def translateUI(self): self.pagelist.setFixedWidth(self.pagelist.sizeHintForColumn(0) + 12) self.setWindowTitle(app.caption(_("Preferences"))) def done(self, result): if result and self.buttons.button(QDialogButtonBox.Apply).isEnabled(): self.saveSettings() # save our size and selected page global _prefsindex _prefsindex = self.pagelist.currentRow() super(PreferencesDialog, self).done(result) def pages(self): """Yields the settings pages that are already instantiated.""" for n in range(self.stack.count()): yield self.stack.widget(n) def showHelp(self): userguide.show(self.pagelist.currentItem().help) def loadSettings(self): """Loads the settings on reset.""" for page in self.pages(): page.loadSettings() page.hasChanges = False self.buttons.button(QDialogButtonBox.Apply).setEnabled(False) def saveSettings(self): """Saves the settings and applies them.""" for page in self.pages(): if page.hasChanges: page.saveSettings() page.hasChanges = False self.buttons.button(QDialogButtonBox.Apply).setEnabled(False) # emit the signal app.settingsChanged() def slotCurrentItemChanged(self, item): item.activate() def changed(self): """Call this to enable the Apply button.""" self.buttons.button(QDialogButtonBox.Apply).setEnabled(True)
class PreferencesDialog(QDialog): def __init__(self, mainwindow): super(PreferencesDialog, self).__init__(mainwindow) self.setWindowModality(Qt.WindowModal) if mainwindow: self.addAction(mainwindow.actionCollection.help_whatsthis) layout = QVBoxLayout() layout.setSpacing(10) self.setLayout(layout) # listview to the left, stacked widget to the right top = QHBoxLayout() layout.addLayout(top) self.pagelist = QListWidget(self) self.stack = QStackedWidget(self) top.addWidget(self.pagelist, 0) top.addWidget(self.stack, 2) layout.addWidget(widgets.Separator(self)) b = self.buttons = QDialogButtonBox(self) b.setStandardButtons( QDialogButtonBox.Ok | QDialogButtonBox.Cancel | QDialogButtonBox.Apply | QDialogButtonBox.Reset | QDialogButtonBox.Help) layout.addWidget(b) b.accepted.connect(self.accept) b.rejected.connect(self.reject) b.button(QDialogButtonBox.Apply).clicked.connect(self.saveSettings) b.button(QDialogButtonBox.Reset).clicked.connect(self.loadSettings) b.button(QDialogButtonBox.Help).clicked.connect(self.showHelp) b.button(QDialogButtonBox.Help).setShortcut(QKeySequence.HelpContents) b.button(QDialogButtonBox.Apply).setEnabled(False) # fill the pagelist self.pagelist.setIconSize(QSize(32, 32)) self.pagelist.setSpacing(2) for item in pageorder(): self.pagelist.addItem(item()) self.pagelist.currentItemChanged.connect(self.slotCurrentItemChanged) app.translateUI(self, 100) # read our size and selected page qutil.saveDialogSize(self, "preferences/dialog/size", QSize(500, 300)) self.pagelist.setCurrentRow(_prefsindex) def translateUI(self): self.pagelist.setFixedWidth(self.pagelist.sizeHintForColumn(0) + 12) self.setWindowTitle(app.caption(_("Preferences"))) def done(self, result): if result and self.buttons.button(QDialogButtonBox.Apply).isEnabled(): self.saveSettings() # save our size and selected page global _prefsindex _prefsindex = self.pagelist.currentRow() super(PreferencesDialog, self).done(result) def pages(self): """Yields the settings pages that are already instantiated.""" for n in range(self.stack.count()): yield self.stack.widget(n) def showHelp(self): userguide.show(self.pagelist.currentItem().help) def loadSettings(self): """Loads the settings on reset.""" for page in self.pages(): page.loadSettings() page.hasChanges = False self.buttons.button(QDialogButtonBox.Apply).setEnabled(False) def saveSettings(self): """Saves the settings and applies them.""" for page in self.pages(): if page.hasChanges: page.saveSettings() page.hasChanges = False self.buttons.button(QDialogButtonBox.Apply).setEnabled(False) # emit the signal app.settingsChanged() def slotCurrentItemChanged(self, item): item.activate() def changed(self): """Call this to enable the Apply button.""" self.buttons.button(QDialogButtonBox.Apply).setEnabled(True)
class ConfigDialog(QDialog): def __init__(self, parent=None): QDialog.__init__(self, parent) self.contents_widget = QListWidget() self.contents_widget.setMovement(QListView.Static) self.contents_widget.setMinimumWidth(120) self.contents_widget.setMaximumWidth(120) self.contents_widget.setSpacing(1) bbox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Apply |QDialogButtonBox.Cancel) self.apply_btn = bbox.button(QDialogButtonBox.Apply) self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()")) self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()")) self.connect(bbox, SIGNAL("clicked(QAbstractButton*)"), self.button_clicked) self.pages_widget = QStackedWidget() self.connect(self.pages_widget, SIGNAL("currentChanged(int)"), self.current_page_changed) self.connect(self.contents_widget, SIGNAL("currentRowChanged(int)"), self.pages_widget.setCurrentIndex) self.contents_widget.setCurrentRow(0) hlayout = QHBoxLayout() hlayout.addWidget(self.contents_widget) hlayout.addWidget(self.pages_widget) hlayout.setStretch(1,1) btnlayout = QHBoxLayout() btnlayout.addStretch(1) btnlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addLayout(hlayout) vlayout.addLayout(btnlayout) self.setLayout(vlayout) self.setWindowTitle("Preferences") self.setWindowIcon(get_icon("configure.png")) def get_current_index(self): """Return current page index""" return self.contents_widget.currentRow() def set_current_index(self, index): """Set current page index""" self.contents_widget.setCurrentRow(index) def accept(self): """Reimplement Qt method""" for index in range(self.pages_widget.count()): configpage = self.pages_widget.widget(index) if not configpage.is_valid(): return configpage.apply_changes() QDialog.accept(self) def button_clicked(self, button): if button is self.apply_btn: # Apply button was clicked configpage = self.pages_widget.currentWidget() if not configpage.is_valid(): return configpage.apply_changes() def current_page_changed(self, index): widget = self.pages_widget.widget(index) self.apply_btn.setVisible(widget.apply_callback is not None) self.apply_btn.setEnabled(widget.is_modified) def add_page(self, widget): self.connect(self, SIGNAL('check_settings()'), widget.check_settings) self.connect(widget, SIGNAL('show_this_page()'), lambda row=self.contents_widget.count(): self.contents_widget.setCurrentRow(row)) self.connect(widget, SIGNAL("apply_button_enabled(bool)"), self.apply_btn.setEnabled) self.pages_widget.addWidget(widget) item = QListWidgetItem(self.contents_widget) item.setIcon(widget.get_icon()) item.setText(widget.get_name()) item.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled) item.setSizeHint(QSize(0, 25)) def check_all_settings(self): """This method is called to check all configuration page settings after configuration dialog has been shown""" self.emit(SIGNAL('check_settings()'))
class RunLilyPondDialog(KDialog): """ A dialog where a DocumentJob can be configured before it's started. """ def __init__(self, mainwin): self.mainwin = mainwin KDialog.__init__(self, mainwin) self.setCaption(i18n("Run LilyPond")) self.setButtons(KDialog.ButtonCode( KDialog.Help | KDialog.Ok | KDialog.Cancel )) self.setButtonText(KDialog.Ok, i18n("Run LilyPond")) self.setButtonIcon(KDialog.Ok, KIcon("run-lilypond")) self.setHelp("running") layout = QVBoxLayout(self.mainWidget()) layout.addWidget(QLabel(i18n( "Select which LilyPond version you want to run:"))) self.lilypond = QListWidget() self.lilypond.setIconSize(QSize(22, 22)) self.lilypond.setSpacing(4) layout.addWidget(self.lilypond) self.preview = QCheckBox(i18n( "Run LilyPond in preview mode (with Point and Click)")) layout.addWidget(self.preview) self.verbose = QCheckBox(i18n("Run LilyPond with verbose output")) layout.addWidget(self.verbose) def configureJob(self, job, doc=None): """Configure a job, belonging to document. If the document is not given, it is expected to live in the document attribute of the job. If there is already a job running, we just display, but disable the Run button, until the old job finishes. """ doc = doc or job.document # populate the dialog based on remembered settings for this document self.lilypond.clear() # find the configured lilypond versions conf = config("lilypond") paths = conf.readEntry("paths", ["lilypond"]) or ["lilypond"] default = conf.readEntry("default", "lilypond") import ly.version # get all versions ver = dict((path, lilyPondVersion(path)) for path in paths) # default if default not in paths: default = paths[0] # Sort on version paths.sort(key=ver.get) versions = [format(ver.get(p)) for p in paths] # Determine automatic version (lowest possible) autopath = None docVersion = doc.lilyPondVersion() if docVersion: autopath = automaticLilyPondCommand(docVersion) def addItem(version, path, icon, title, tooltip): item = QListWidgetItem(self.lilypond) item.setIcon(KIcon(icon)) item.setText("{0}\n{1}: {2}".format(title, i18n("Command"), path)) item.setToolTip(tooltip) version or item.setFlags(Qt.NoItemFlags) # Add all available LilyPond versions: for path in paths: if ver[path]: title = i18n("LilyPond %1", format(ver[path])) tooltip = i18n("Use LilyPond version %1", format(ver[path])) addenda, tips = [], [] if path == default: addenda.append(i18n("default")) tips.append(i18n("Default LilyPond Version.")) if path == autopath: addenda.append(i18n("automatic")) tips.append(i18n("Automatic LilyPond Version (determined from document).")) if addenda: title += " [{0}]".format(", ".join(addenda)) tooltip += "\n{0}".format("\n".join(tips)) addItem(format(ver[path]), path, "run-lilypond", title, tooltip + "\n" + i18n("Path: %1", ly.version.LilyPondInstance(path).command() or path)) else: addItem("", path, "dialog-error", i18n("LilyPond (version unknown)"), i18n("Use LilyPond (version unknown)\nPath: %1", ly.version.LilyPondInstance(path).command() or path)) # Copy the settings from the document: self.preview.setChecked(doc.metainfo["custom preview"]) self.verbose.setChecked(doc.metainfo["custom verbose"]) try: self.lilypond.setCurrentRow(versions.index( doc.metainfo["custom lilypond version"])) except ValueError: cmd = autopath if autopath and conf.readEntry("automatic version", False) else default self.lilypond.setCurrentRow(paths.index(cmd)) # Focus our listbox: self.lilypond.setFocus() # Disable the Run button if a job is running for this document oldjob = self.mainwin.jobManager().job(doc) self.enableButtonOk(not oldjob) if oldjob: enable = lambda: self.enableButtonOk(True) oldjob.done.connect(enable) # Wait for user interaction: result = self.exec_() # If a job was running, don't listen to it anymore if oldjob: oldjob.done.disconnect(enable) if not result: return False # cancelled # Save the settings in the document's metainfo and configure job: doc.metainfo["custom preview"] = job.preview = self.preview.isChecked() doc.metainfo["custom verbose"] = job.verbose = self.verbose.isChecked() index = self.lilypond.currentRow() doc.metainfo["custom lilypond version"] = versions[index] job.command = paths[index] return True
class ConfigDialog(QDialog): def __init__(self, parent=None): QDialog.__init__(self, parent) self.contents_widget = QListWidget() self.contents_widget.setMovement(QListView.Static) self.contents_widget.setMinimumWidth(120) self.contents_widget.setMaximumWidth(120) self.contents_widget.setSpacing(1) bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply | QDialogButtonBox.Cancel) self.apply_btn = bbox.button(QDialogButtonBox.Apply) self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()")) self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()")) self.connect(bbox, SIGNAL("clicked(QAbstractButton*)"), self.button_clicked) self.pages_widget = QStackedWidget() self.connect(self.pages_widget, SIGNAL("currentChanged(int)"), self.current_page_changed) self.connect(self.contents_widget, SIGNAL("currentRowChanged(int)"), self.pages_widget.setCurrentIndex) self.contents_widget.setCurrentRow(0) hlayout = QHBoxLayout() hlayout.addWidget(self.contents_widget) hlayout.addWidget(self.pages_widget) hlayout.setStretch(1, 1) btnlayout = QHBoxLayout() btnlayout.addStretch(1) btnlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addLayout(hlayout) vlayout.addLayout(btnlayout) self.setLayout(vlayout) self.setWindowTitle("Preferences") self.setWindowIcon(get_icon("configure.png")) def get_current_index(self): """Return current page index""" return self.contents_widget.currentRow() def set_current_index(self, index): """Set current page index""" self.contents_widget.setCurrentRow(index) def accept(self): """Reimplement Qt method""" for index in range(self.pages_widget.count()): configpage = self.pages_widget.widget(index) if not configpage.is_valid(): return configpage.apply_changes() QDialog.accept(self) def button_clicked(self, button): if button is self.apply_btn: # Apply button was clicked configpage = self.pages_widget.currentWidget() if not configpage.is_valid(): return configpage.apply_changes() def current_page_changed(self, index): widget = self.pages_widget.widget(index) self.apply_btn.setVisible(widget.apply_callback is not None) self.apply_btn.setEnabled(widget.is_modified) def add_page(self, widget): self.connect(self, SIGNAL('check_settings()'), widget.check_settings) self.connect(widget, SIGNAL('show_this_page()'), lambda row=self.contents_widget.count(): self. contents_widget.setCurrentRow(row)) self.connect(widget, SIGNAL("apply_button_enabled(bool)"), self.apply_btn.setEnabled) self.pages_widget.addWidget(widget) item = QListWidgetItem(self.contents_widget) item.setIcon(widget.get_icon()) item.setText(widget.get_name()) item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) item.setSizeHint(QSize(0, 25)) def check_all_settings(self): """This method is called to check all configuration page settings after configuration dialog has been shown""" self.emit(SIGNAL('check_settings()'))
class ConfigDialog(QDialog): """Spyder configuration ('Preferences') dialog box""" def __init__(self, parent=None): QDialog.__init__(self, parent) # Destroying the C++ object right after closing the dialog box, # otherwise it may be garbage-collected in another QThread # (e.g. the editor's analysis thread in Spyder), thus leading to # a segmentation fault on UNIX or an application crash on Windows self.setAttribute(Qt.WA_DeleteOnClose) self.contents_widget = QListWidget() self.contents_widget.setMovement(QListView.Static) self.contents_widget.setSpacing(1) bbox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Apply |QDialogButtonBox.Cancel) self.apply_btn = bbox.button(QDialogButtonBox.Apply) self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()")) self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()")) self.connect(bbox, SIGNAL("clicked(QAbstractButton*)"), self.button_clicked) self.pages_widget = QStackedWidget() self.connect(self.pages_widget, SIGNAL("currentChanged(int)"), self.current_page_changed) self.connect(self.contents_widget, SIGNAL("currentRowChanged(int)"), self.pages_widget.setCurrentIndex) self.contents_widget.setCurrentRow(0) hsplitter = QSplitter() hsplitter.addWidget(self.contents_widget) hsplitter.addWidget(self.pages_widget) btnlayout = QHBoxLayout() btnlayout.addStretch(1) btnlayout.addWidget(bbox) vlayout = QVBoxLayout() vlayout.addWidget(hsplitter) vlayout.addLayout(btnlayout) self.setLayout(vlayout) self.setWindowTitle(_("Preferences")) self.setWindowIcon(get_icon("configure.png")) def get_current_index(self): """Return current page index""" return self.contents_widget.currentRow() def set_current_index(self, index): """Set current page index""" self.contents_widget.setCurrentRow(index) def get_page(self, index=None): """Return page widget""" if index is None: widget = self.pages_widget.currentWidget() else: widget = self.pages_widget.widget(index) return widget.widget() def accept(self): """Reimplement Qt method""" for index in range(self.pages_widget.count()): configpage = self.get_page(index) if not configpage.is_valid(): return configpage.apply_changes() QDialog.accept(self) def button_clicked(self, button): if button is self.apply_btn: # Apply button was clicked configpage = self.get_page() if not configpage.is_valid(): return configpage.apply_changes() def current_page_changed(self, index): widget = self.get_page(index) self.apply_btn.setVisible(widget.apply_callback is not None) self.apply_btn.setEnabled(widget.is_modified) def add_page(self, widget): self.connect(self, SIGNAL('check_settings()'), widget.check_settings) self.connect(widget, SIGNAL('show_this_page()'), lambda row=self.contents_widget.count(): self.contents_widget.setCurrentRow(row)) self.connect(widget, SIGNAL("apply_button_enabled(bool)"), self.apply_btn.setEnabled) scrollarea = QScrollArea(self) scrollarea.setWidgetResizable(True) scrollarea.setWidget(widget) self.pages_widget.addWidget(scrollarea) item = QListWidgetItem(self.contents_widget) item.setIcon(widget.get_icon()) item.setText(widget.get_name()) item.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled) item.setSizeHint(QSize(0, 25)) def check_all_settings(self): """This method is called to check all configuration page settings after configuration dialog has been shown""" self.emit(SIGNAL('check_settings()')) def resizeEvent(self, event): """ Reimplement Qt method to be able to save the widget's size from the main application """ QDialog.resizeEvent(self, event) self.emit(SIGNAL("size_change(QSize)"), self.size())
class LayerImportBrowser(QDialog): class VectorPage(QWidget): def __init__(self, parent=None, filters="", encodings=[]): QWidget.__init__(self, parent) self.filters = filters self.layerLineEdit = QLineEdit() self.browseToolButton = QToolButton() self.browseToolButton.setAutoRaise(True) self.browseToolButton.setIcon(QIcon(":document-open")) layerLabel = QLabel("&Dataset:") layerLabel.setBuddy(self.layerLineEdit) self.encodingComboBox = QComboBox() self.encodingComboBox.addItems(encodings) encodingLabel = QLabel("&Encoding:") encodingLabel.setBuddy(self.encodingComboBox) hbox = QHBoxLayout() hbox.addWidget(layerLabel) hbox.addWidget(self.layerLineEdit) hbox.addWidget(self.browseToolButton) vbox = QVBoxLayout() vbox.addLayout(hbox) hbox = QHBoxLayout() hbox.addWidget(encodingLabel) hbox.addWidget(self.encodingComboBox) vbox.addLayout(hbox) self.setLayout(vbox) self.encodingComboBox.setCurrentIndex(self.encodingComboBox.findText("System")) self.connect(self.browseToolButton, SIGNAL("clicked()"), self.browseToFile) self.connect(self.encodingComboBox, SIGNAL("currentIndexChanged(QString)"), self.changeEncoding) def browseToFile(self): dialog = QFileDialog(self, "manageR - Open Vector File", unicode(robjects.r.getwd()[0]), self.filters) if not dialog.exec_() == QDialog.Accepted: return files = dialog.selectedFiles() file = files.first().trimmed() self.layerLineEdit.setText(file) self.emit(SIGNAL("filePathChanged(QString)"), file) def changeEncoding(self, text): self.emit(SIGNAL("encodingChanged(QString)"), text) class RasterPage(QWidget): def __init__(self, parent=None, filters=""): QWidget.__init__(self, parent) self.parent = parent self.filters = filters self.layerLineEdit = QLineEdit() self.browseToolButton = QToolButton() self.browseToolButton.setAutoRaise(True) self.browseToolButton.setIcon(QIcon(":document-open")) layerLabel = QLabel("&Dataset:") layerLabel.setBuddy(self.layerLineEdit) hbox = QHBoxLayout() hbox.addWidget(layerLabel) hbox.addWidget(self.layerLineEdit) hbox.addWidget(self.browseToolButton) vbox = QVBoxLayout() vbox.addLayout(hbox) self.setLayout(vbox) self.connect(self.browseToolButton, SIGNAL("clicked()"), self.browseToFile) def browseToFile(self): dialog = QFileDialog(self, "manageR - Open Raster File", unicode(robjects.r.getwd()[0]), self.filters) if not dialog.exec_() == QDialog.Accepted: return files = dialog.selectedFiles() file = files.first().trimmed() self.layerLineEdit.setText(file) self.emit(SIGNAL("filePathChanged(QString)"), file) def __init__(self, parent=None, vectors="", rasters="", encodings=[]): QDialog.__init__(self, parent) self.contentsWidget = QListWidget() self.setWindowIcon(QIcon(":icon")) self.contentsWidget.setViewMode(QListView.IconMode) self.contentsWidget.setIconSize(QSize(76, 66)) self.contentsWidget.setMovement(QListView.Static) self.contentsWidget.setMaximumWidth(106) self.contentsWidget.setMinimumWidth(106) self.contentsWidget.setMinimumHeight(220) self.contentsWidget.setSpacing(12) self.__filePath = "" self.__encoding = "System" self.__type = 0 self.pagesWidget = QStackedWidget() vectorPage = self.VectorPage(self, vectors, encodings) self.pagesWidget.addWidget(vectorPage) rasterPage = self.RasterPage(self, rasters) self.pagesWidget.addWidget(rasterPage) buttons = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel, Qt.Horizontal, self) self.connect(buttons, SIGNAL("accepted()"), self.accept) self.connect(buttons, SIGNAL("rejected()"), self.reject) self.connect(vectorPage, SIGNAL("filePathChanged(QString)"), self.setFilePath) self.connect(vectorPage, SIGNAL("encodingChanged(QString)"), self.setEncoding) self.connect(rasterPage, SIGNAL("filePathChanged(QString)"), self.setFilePath) self.createIcons() self.contentsWidget.setCurrentRow(0) horizontalLayout = QHBoxLayout() horizontalLayout.addWidget(self.contentsWidget) horizontalLayout.addWidget(self.pagesWidget, 1) mainLayout = QVBoxLayout() mainLayout.addLayout(horizontalLayout) mainLayout.addStretch(1) mainLayout.addSpacing(12) mainLayout.addWidget(buttons) self.setLayout(mainLayout) self.setWindowTitle("manageR - Import Layer") def createIcons(self): vectorButton = QListWidgetItem(self.contentsWidget) vectorButton.setIcon(QIcon(":custom-vector.svg")) vectorButton.setText("Vector Layer") vectorButton.setTextAlignment(Qt.AlignHCenter) vectorButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) rasterButton = QListWidgetItem(self.contentsWidget) rasterButton.setIcon(QIcon(":custom-raster.svg")) rasterButton.setText("Raster Layer") rasterButton.setTextAlignment(Qt.AlignHCenter) rasterButton.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) self.connect(self.contentsWidget, SIGNAL("currentItemChanged(QListWidgetItem*, QListWidgetItem*)"), self.changePage) def changePage(self, current, previous): if not current: current = previous self.pagesWidget.setCurrentIndex(self.contentsWidget.row(current)) def filePath(self): return self.__filePath def setFilePath(self, filePath): self.__filePath = filePath def encoding(self): return self.__encoding def setEncoding(self, encoding): self.__encoding = encoding def layerType(self): return self.__type def setLayerType(self, type): self.__type = type def accept(self): self.__type = self.pagesWidget.currentIndex() QDialog.accept(self)