def __init__(self): QWidget.__init__(self) IDEGeneric.__init__(self) self.setWindowTitle('NINJA-IDE {Ninja Is Not Just Another IDE}') self.setWindowIcon(QIcon(resources.images['icon'])) self.setWindowState(Qt.WindowMaximized) self.setMinimumSize(700, 500) #Opactity self.opacity = 1 #ToolBar self._toolbar = QToolBar() self._toolbar.setToolTip('Press and Drag to Move') styles.set_style(self._toolbar, 'toolbar-default') self.addToolBar(Qt.LeftToolBarArea, self._toolbar) self._toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly) #StatusBar self._status = StatusBar() self._status.hide() self.setStatusBar(self._status) #Main Widgets self.main = MainWindow(self) self.setCentralWidget(self.main) #Menu menubar = self.menuBar() file_ = menubar.addMenu('&File') edit = menubar.addMenu('&Edit') view = menubar.addMenu('&View') source = menubar.addMenu('&Source') project = menubar.addMenu('&Project') self.pluginsMenu = menubar.addMenu('P&lugins') about = menubar.addMenu('&About') #The order of the icons in the toolbar is defined by this calls self._menuFile = MenuFile(file_, self._toolbar, self.main) self._menuView = MenuView(view, self, self.main) self._menuEdit = MenuEdit(edit, self._toolbar, self.main, self._status) self._menuSource = MenuSource(source, self.main) self._menuProject = MenuProject(project, self._toolbar, self.main) self._menuPlugins = MenuPlugins(self.pluginsMenu, self) self._menuAbout = MenuAbout(about, self.main) self.main.container.load_toolbar(self._toolbar) self.main._central.actual_tab().obtain_editor().setFocus() #Tray Icon self.trayIcon = updates.TrayIconUpdates(self) self.trayIcon.show() self.connect(self.main, SIGNAL("fileSaved(QString)"), self.show_status_message)
class IDE(QMainWindow, IDEGeneric): max_opacity = 1 min_opacity = 0.3 def __init__(self): QWidget.__init__(self) IDEGeneric.__init__(self) self.setWindowTitle('NINJA-IDE {Ninja Is Not Just Another IDE}') self.setWindowIcon(QIcon(resources.images['icon'])) self.setWindowState(Qt.WindowMaximized) self.setMinimumSize(700, 500) #Opactity self.opacity = 1 #ToolBar self._toolbar = QToolBar() self._toolbar.setToolTip('Press and Drag to Move') styles.set_style(self._toolbar, 'toolbar-default') self.addToolBar(Qt.LeftToolBarArea, self._toolbar) self._toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly) #StatusBar self._status = StatusBar() self._status.hide() self.setStatusBar(self._status) #Main Widgets self.main = MainWindow(self) self.setCentralWidget(self.main) #Menu menubar = self.menuBar() file_ = menubar.addMenu('&File') edit = menubar.addMenu('&Edit') view = menubar.addMenu('&View') source = menubar.addMenu('&Source') project = menubar.addMenu('&Project') self.pluginsMenu = menubar.addMenu('P&lugins') about = menubar.addMenu('&About') #The order of the icons in the toolbar is defined by this calls self._menuFile = MenuFile(file_, self._toolbar, self.main) self._menuView = MenuView(view, self, self.main) self._menuEdit = MenuEdit(edit, self._toolbar, self.main, self._status) self._menuSource = MenuSource(source, self.main) self._menuProject = MenuProject(project, self._toolbar, self.main) self._menuPlugins = MenuPlugins(self.pluginsMenu, self) self._menuAbout = MenuAbout(about, self.main) self.main.container.load_toolbar(self._toolbar) self.main._central.actual_tab().obtain_editor().setFocus() #Tray Icon self.trayIcon = updates.TrayIconUpdates(self) self.trayIcon.show() self.connect(self.main, SIGNAL("fileSaved(QString)"), self.show_status_message) def show_status_message(self, message): self._status.showMessage(message, 2000) def add_toolbar_item(self, plugin, name, icon): self._toolbar.addSeparator() action = self._toolbar.addAction(QIcon(icon), name) self.connect(action, SIGNAL("triggered()"), lambda: plugin.toolbarAction()) def closeEvent(self, event): settings = QSettings() if settings.value('preferences/general/loadFiles', Qt.Checked).toInt()[0] == Qt.Checked: settings.setValue('openFiles/projects', self.main.get_open_projects()) settings.setValue('openFiles/tab1', self.main._central._tabs.get_open_files()) settings.setValue('openFiles/tab2', self.main._central._tabs2.get_open_files()) else: settings.setValue('openFiles/projects', []) confirm = settings.value('preferences/general/confirmExit', Qt.Checked).toInt()[0] if (confirm == Qt.Checked) and self.main._central.check_for_unsaved(): val = QMessageBox.question(self, 'Some changes were not saved', 'Do you want to exit anyway?', QMessageBox.Yes, QMessageBox.No) if val == QMessageBox.No: event.ignore() else: self.main._properties._treeProjects.close_open_projects() else: self.main._properties._treeProjects.close_open_projects() def wheelEvent(self, event): if event.modifiers() == Qt.AltModifier: if event.delta() == 120 and self.opacity < self.max_opacity: self.opacity += 0.1 elif event.delta() == -120 and self.opacity > self.min_opacity: self.opacity -= 0.1 self.setWindowOpacity(self.opacity) event.ignore() else: super(IDE, self).wheelEvent(event)