def __init__(self,parent=None): QTabWidget.__init__(self,parent) self.setTabBar(TabBarSupport(self)) self.setMovable(False) self.setTabsClosable(True) self.setDocumentMode(False) self.navigationButton = QPushButton(QIcon(getPath('iconDir','navigation.png')),"",self) self.navigationButton.setFlat(True) self.closeButton = QPushButton(QIcon(getPath('iconDir','navclose.png')),"",self) self.closeButton.setFlat(True) self.rightCornerWidget = QWidget(self) self.rightCornerWidgetLayout = QHBoxLayout(self.rightCornerWidget) self.rightCornerWidgetLayout.setMargin(0) self.rightCornerWidgetLayout.setSpacing(0) self.rightCornerWidgetLayout.addWidget(self.navigationButton) self.rightCornerWidgetLayout.addWidget(self.closeButton) self.setCornerWidget(self.rightCornerWidget, Qt.TopRightCorner) QObject.connect(self.navigationButton, SIGNAL("pressed()"),self.__evt_navigation) QObject.connect(self.closeButton, SIGNAL("clicked(bool)"),lambda:self.emit(SIGNAL("tabCloseRequested (int)"),self.currentIndex())) QObject.connect(self, SIGNAL("tabCloseRequested (int)"),self.__evt_close_tab_click) QObject.connect(self.tabBar(), SIGNAL('customContextMenuRequested(const QPoint &)'),self.__evt_showContextMenu)
def __init__(self, parent=None): QTabWidget.__init__(self, parent) self.setTabBar(TabBarSupport(self)) self.setMovable(False) self.setTabsClosable(True) self.setDocumentMode(False) self.navigationButton = QPushButton( QIcon(getPath('iconDir', 'navigation.png')), "", self) self.navigationButton.setFlat(True) self.closeButton = QPushButton( QIcon(getPath('iconDir', 'navclose.png')), "", self) self.closeButton.setFlat(True) self.rightCornerWidget = QWidget(self) self.rightCornerWidgetLayout = QHBoxLayout(self.rightCornerWidget) self.rightCornerWidgetLayout.setMargin(0) self.rightCornerWidgetLayout.setSpacing(0) self.rightCornerWidgetLayout.addWidget(self.navigationButton) self.rightCornerWidgetLayout.addWidget(self.closeButton) self.setCornerWidget(self.rightCornerWidget, Qt.TopRightCorner) QObject.connect(self.navigationButton, SIGNAL("pressed()"), self.__evt_navigation) QObject.connect( self.closeButton, SIGNAL("clicked(bool)"), lambda: self.emit( SIGNAL("tabCloseRequested (int)"), self.currentIndex())) QObject.connect(self, SIGNAL("tabCloseRequested (int)"), self.__evt_close_tab_click) QObject.connect(self.tabBar(), SIGNAL('customContextMenuRequested(const QPoint &)'), self.__evt_showContextMenu)
class PluginErrorDialog(QDialog): """ Dialog with tabs each tab is a python traceback """ def __init__(self): QDialog.__init__(self) self.setWindowTitle(translations.TR_PLUGIN_ERROR_REPORT) self.resize(600, 400) vbox = QVBoxLayout(self) label = QLabel(translations.TR_SOME_PLUGINS_REMOVED) vbox.addWidget(label) self._tabs = QTabWidget() vbox.addWidget(self._tabs) hbox = QHBoxLayout() btnAccept = QPushButton(translations.TR_ACCEPT) btnAccept.setMaximumWidth(100) hbox.addWidget(btnAccept) vbox.addLayout(hbox) #signals self.connect(btnAccept, SIGNAL("clicked()"), self.close) def add_traceback(self, plugin_name, traceback_msg): """Add a Traceback to the widget on a new tab""" traceback_widget = TracebackWidget(traceback_msg) self._tabs.addTab(traceback_widget, plugin_name)
def __init__(self, parent): super(SchemesManagerWidget, self).__init__(parent, Qt.Dialog) self.setWindowTitle(translations.TR_EDITOR_SCHEMES) self.resize(700, 500) vbox = QVBoxLayout(self) self._tabs = QTabWidget() vbox.addWidget(self._tabs) # Footer hbox = QHBoxLayout() btn_close = QPushButton(self.tr('Close')) btnReload = QPushButton(self.tr("Reload")) hbox.addWidget(btn_close) hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) hbox.addWidget(btnReload) vbox.addLayout(hbox) self.overlay = ui_tools.Overlay(self) self.overlay.show() self._schemes = [] self._loading = True self.downloadItems = [] #Load Themes with Thread self.connect(btnReload, SIGNAL("clicked()"), self._reload_themes) self._thread = ui_tools.ThreadExecution(self.execute_thread) self.connect(self._thread, SIGNAL("finished()"), self.load_skins_data) self.connect(btn_close, SIGNAL('clicked()'), self.close) self._reload_themes()
def __init__(self): QWidget.__init__(self) self.plugin_manager = plugin_manager.PluginManager() vbox = QVBoxLayout(self) self._tabs = QTabWidget() vbox.addWidget(self._tabs) #load widgets self._load_widgets()
def __init__(self): QDialog.__init__(self) self.setWindowTitle(translations.TR_PLUGIN_ERROR_REPORT) self.resize(600, 400) vbox = QVBoxLayout(self) label = QLabel(translations.TR_SOME_PLUGINS_REMOVED) vbox.addWidget(label) self._tabs = QTabWidget() vbox.addWidget(self._tabs) hbox = QHBoxLayout() btnAccept = QPushButton(translations.TR_ACCEPT) btnAccept.setMaximumWidth(100) hbox.addWidget(btnAccept) vbox.addLayout(hbox) #signals self.connect(btnAccept, SIGNAL("clicked()"), self.close)
def __init__(self, parent): QDialog.__init__(self, parent, Qt.Dialog) self.setWindowTitle(translations.TR_PLUGIN_MANAGER) self.resize(700, 600) vbox = QVBoxLayout(self) self._tabs = QTabWidget() vbox.addWidget(self._tabs) self._txt_data = QTextBrowser() self._txt_data.setOpenLinks(False) vbox.addWidget(QLabel(translations.TR_PROJECT_DESCRIPTION)) vbox.addWidget(self._txt_data) # Footer hbox = QHBoxLayout() btn_close = QPushButton(translations.TR_CLOSE) btnReload = QPushButton(translations.TR_RELOAD) hbox.addWidget(btn_close) hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) hbox.addWidget(btnReload) vbox.addLayout(hbox) self.overlay = ui_tools.Overlay(self) self.overlay.hide() self._oficial_available = [] self._community_available = [] self._locals = [] self._updates = [] self._loading = True self._requirements = {} self.connect(btnReload, SIGNAL("clicked()"), self._reload_plugins) self.thread = ThreadLoadPlugins(self) self.connect(self.thread, SIGNAL("finished()"), self._load_plugins_data) self.connect(self.thread, SIGNAL("plugin_downloaded(PyQt_PyObject)"), self._after_download_plugin) self.connect(self.thread, SIGNAL("plugin_manually_installed(PyQt_PyObject)"), self._after_manual_install_plugin) self.connect(self.thread, SIGNAL("plugin_uninstalled(PyQt_PyObject)"), self._after_uninstall_plugin) self.connect(self._txt_data, SIGNAL("anchorClicked(const QUrl&)"), self._open_link) self.connect(btn_close, SIGNAL('clicked()'), self.close) self.overlay.show() self._reload_plugins()
def __init__(self,parent=None): QTabWidget.__init__(self,parent) #some default value is needed self.setTabPosition(QTabWidget.South) self.setTabShape(QTabWidget.Triangular) self.setDocumentMode(True) self.__toolBar = QToolBar(self) self.__toolBar.setIconSize(QSize(16,16)) self.__htmlEditorArea = HtmlEditView(self) #self.__htmlEditorArea.setBaseUrl(baseURL) self.__sourceView = SouceView(self) self.__searchBarForEditor = SearchWidget(self.__htmlEditorArea,self) self.__searchBarForEditor.setVisible(False) self.__inspector = None self.__inspectorSplitter = QSplitter(self) self.__inspectorSplitter.setOrientation(Qt.Vertical) self.__inspectorSplitter.addWidget(self.__htmlEditorArea) #tab1 layout=QVBoxLayout(self) layout.setSpacing(0) layout.setMargin(0) layout.addWidget(self.__toolBar) layout.addWidget(self.__searchBarForEditor) layout.addWidget(self.__inspectorSplitter) the_editor_tab=QWidget(self) the_editor_tab.setLayout(layout) the_editor_tab.setAutoFillBackground(True) self.addTab(the_editor_tab, "Edit") #tab2 self.addTab(self.__sourceView, "Source") QObject.connect(self, SIGNAL("currentChanged (int)"),self.__evt_currentTabChange) #actions self.__setupToolBarAction()
class PluginPreferences(QWidget): """ Plugins section widget in NINJA-IDE Preferences """ def __init__(self): QWidget.__init__(self) self.plugin_manager = plugin_manager.PluginManager() vbox = QVBoxLayout(self) self._tabs = QTabWidget() vbox.addWidget(self._tabs) #load widgets self._load_widgets() def _load_widgets(self): logger.info("Loading plugins preferences widgets") #Collect the preferences widget for each active plugin for plugin in self.plugin_manager.get_active_plugins(): plugin_name = plugin.metadata.get('name') try: preferences_widget = plugin.get_preferences_widget() if preferences_widget: self._tabs.addTab(preferences_widget, plugin_name) except Exception as reason: logger.error("Unable to add the preferences widget (%s): %s", plugin_name, reason) continue def save(self): logger.info("Saving plugins preferences") for i in range(self._tabs.count()): try: self._tabs.widget(i).save() except Exception as reason: logger.error("Unable to save preferences (%s): %s", self._tabs.tabText(i), reason) continue
class PluginsManagerWidget(QDialog): """Plugin Manager widget""" def __init__(self, parent): QDialog.__init__(self, parent, Qt.Dialog) self.setWindowTitle(translations.TR_PLUGIN_MANAGER) self.resize(700, 600) vbox = QVBoxLayout(self) self._tabs = QTabWidget() vbox.addWidget(self._tabs) self._txt_data = QTextBrowser() self._txt_data.setOpenLinks(False) vbox.addWidget(QLabel(translations.TR_PROJECT_DESCRIPTION)) vbox.addWidget(self._txt_data) # Footer hbox = QHBoxLayout() btn_close = QPushButton(translations.TR_CLOSE) btnReload = QPushButton(translations.TR_RELOAD) hbox.addWidget(btn_close) hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) hbox.addWidget(btnReload) vbox.addLayout(hbox) self.overlay = ui_tools.Overlay(self) self.overlay.hide() self._oficial_available = [] self._community_available = [] self._locals = [] self._updates = [] self._loading = True self._requirements = {} self.connect(btnReload, SIGNAL("clicked()"), self._reload_plugins) self.thread = ThreadLoadPlugins(self) self.connect(self.thread, SIGNAL("finished()"), self._load_plugins_data) self.connect(self.thread, SIGNAL("plugin_downloaded(PyQt_PyObject)"), self._after_download_plugin) self.connect(self.thread, SIGNAL("plugin_manually_installed(PyQt_PyObject)"), self._after_manual_install_plugin) self.connect(self.thread, SIGNAL("plugin_uninstalled(PyQt_PyObject)"), self._after_uninstall_plugin) self.connect(self._txt_data, SIGNAL("anchorClicked(const QUrl&)"), self._open_link) self.connect(btn_close, SIGNAL('clicked()'), self.close) self.overlay.show() self._reload_plugins() def show_plugin_info(self, data): """Takes data argument, format for HTML and display it""" plugin_description = data[2].replace('\n', '<br>') html = HTML_STYLE.format(name=data[0], version=data[1], description=plugin_description, author=data[3], link=data[4]) self._txt_data.setHtml(html) def _open_link(self, url): """Takes an url argument and open the link on web browser""" link = url.toString() if link.startswith('/plugins/'): link = 'http://ninja-ide.org' + link webbrowser.open(link) def _reload_plugins(self): """Reload all plugins""" self.overlay.show() self._loading = True self.thread.runnable = self.thread.collect_data_thread self.thread.start() def _after_manual_install_plugin(self, plugin): """After installing, take plugin and add it to installedWidget items""" data = {} data['name'] = plugin[0] data['version'] = plugin[1] data['description'] = '' data['authors'] = '' data['home'] = '' self._installedWidget.add_table_items([data]) def _after_download_plugin(self, plugin): """After installing, take plugin and add it to installedWidget items""" oficial_plugin = _get_plugin(plugin[0], self._oficial_available) community_plugin = _get_plugin(plugin[0], self._community_available) if oficial_plugin: self._installedWidget.add_table_items([oficial_plugin]) self._availableOficialWidget.remove_item(plugin[0]) elif community_plugin: self._installedWidget.add_table_items([community_plugin]) self._availableCommunityWidget.remove_item(plugin[0]) def _after_uninstall_plugin(self, plugin): """After uninstall plugin,make available plugin corresponding to type""" oficial_plugin = _get_plugin(plugin[0], self._oficial_available) community_plugin = _get_plugin(plugin[0], self._community_available) if oficial_plugin: self._availableOficialWidget.add_table_items([oficial_plugin]) self._installedWidget.remove_item(plugin[0]) elif community_plugin: self._availableCommunityWidget.add_table_items([community_plugin]) self._installedWidget.remove_item(plugin[0]) def _load_plugins_data(self): """Load all the plugins data""" if self._loading: self._tabs.clear() self._updatesWidget = UpdatesWidget(self, copy(self._updates)) self._availableOficialWidget = AvailableWidget( self, copy(self._oficial_available)) self._availableCommunityWidget = AvailableWidget( self, copy(self._community_available)) self._installedWidget = InstalledWidget(self, copy(self._locals)) self._tabs.addTab(self._availableOficialWidget, translations.TR_OFFICIAL_AVAILABLE) self._tabs.addTab(self._availableCommunityWidget, translations.TR_COMMUNITY_AVAILABLE) self._tabs.addTab(self._updatesWidget, translations.TR_UPDATE) self._tabs.addTab(self._installedWidget, translations.TR_INSTALLED) self._manualWidget = ManualInstallWidget(self) self._tabs.addTab(self._manualWidget, translations.TR_MANUAL_INSTALL) self._loading = False self.overlay.hide() self.thread.wait() def download_plugins(self, plugs): """ Install """ self.overlay.show() self.thread.plug = plugs #set the function to run in the thread self.thread.runnable = self.thread.download_plugins_thread self.thread.start() def install_plugins_manually(self, plug): """Install plugin from local zip.""" self.overlay.show() self.thread.plug = plug #set the function to run in the thread self.thread.runnable = self.thread.manual_install_plugins_thread self.thread.start() def mark_as_available(self, plugs): """ Uninstall """ self.overlay.show() self.thread.plug = plugs #set the function to run in the thread self.thread.runnable = self.thread.uninstall_plugins_thread self.thread.start() def update_plugin(self, plugs): """ Update """ self.overlay.show() self.thread.plug = plugs #set the function to run in the thread self.thread.runnable = self.thread.update_plugin_thread self.thread.start() def reset_installed_plugins(self): """Reset all the installed plugins""" local_plugins = plugin_manager.local_plugins() plugins = _format_for_table(local_plugins) self._installedWidget.reset_table(plugins) def resizeEvent(self, event): """Handle Resize events""" self.overlay.resize(event.size()) event.accept()
class SchemesManagerWidget(QDialog): def __init__(self, parent): super(SchemesManagerWidget, self).__init__(parent, Qt.Dialog) self.setWindowTitle(translations.TR_EDITOR_SCHEMES) self.resize(700, 500) vbox = QVBoxLayout(self) self._tabs = QTabWidget() vbox.addWidget(self._tabs) # Footer hbox = QHBoxLayout() btn_close = QPushButton(self.tr('Close')) btnReload = QPushButton(self.tr("Reload")) hbox.addWidget(btn_close) hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) hbox.addWidget(btnReload) vbox.addLayout(hbox) self.overlay = ui_tools.Overlay(self) self.overlay.show() self._schemes = [] self._loading = True self.downloadItems = [] #Load Themes with Thread self.connect(btnReload, SIGNAL("clicked()"), self._reload_themes) self._thread = ui_tools.ThreadExecution(self.execute_thread) self.connect(self._thread, SIGNAL("finished()"), self.load_skins_data) self.connect(btn_close, SIGNAL('clicked()'), self.close) self._reload_themes() def _reload_themes(self): self.overlay.show() self._loading = True self._thread.execute = self.execute_thread self._thread.start() def load_skins_data(self): if self._loading: self._tabs.clear() self._schemeWidget = SchemeWidget(self, self._schemes) self._tabs.addTab(self._schemeWidget, self.tr("Editor Schemes")) self._loading = False self.overlay.hide() self._thread.wait() def download_scheme(self, scheme): self.overlay.show() self.downloadItems = scheme self._thread.execute = self._download_scheme_thread self._thread.start() def resizeEvent(self, event): self.overlay.resize(event.size()) event.accept() def execute_thread(self): try: descriptor_schemes = urlopen(resources.SCHEMES_URL) schemes = json_manager.parse(descriptor_schemes) schemes = [(d['name'], d['download']) for d in schemes] local_schemes = self.get_local_schemes() schemes = [ schemes[i] for i in range(len(schemes)) if os.path.basename(schemes[i][1]) not in local_schemes ] self._schemes = schemes except URLError: self._schemes = [] def get_local_schemes(self): if not file_manager.folder_exists(resources.EDITOR_SKINS): file_manager.create_tree_folders(resources.EDITOR_SKINS) schemes = os.listdir(resources.EDITOR_SKINS) schemes = [s for s in schemes if s.lower().endswith('.color')] return schemes def _download_scheme_thread(self): for d in self.downloadItems: self.download(d[1], resources.EDITOR_SKINS) def download(self, url, folder): fileName = os.path.join(folder, os.path.basename(url)) try: content = urlopen(url) with open(fileName, 'w') as f: f.write(content.read()) except URLError: return