def contextMenuEvent(self, _event): try: currentItem = self.currentItem() if currentItem is not None: self.mContextMenu.setGeometry(_event.globalX(), _event.globalY(), 1, 1) selectedItem = self.mContextMenu.exec_() if selectedItem is not None: selectedKey = selectedItem.objectName() if ((selectedKey in [ self.mContextMenuActionNames[0], self.mContextMenuActionNames[2], self.mContextMenuActionNames[3] ]) and self.checkReadOnlyColumn(currentItem.columnKey) is False): return False if selectedKey == self.mContextMenuActionNames[0]: self.createHistoryPoint() MApplication.clipboard().setText(currentItem.text()) currentItem.setText("") elif selectedKey == self.mContextMenuActionNames[1]: MApplication.clipboard().setText(currentItem.text()) elif selectedKey == self.mContextMenuActionNames[2]: self.createHistoryPoint() currentItem.setText(MApplication.clipboard().text()) elif selectedKey == self.mContextMenuActionNames[3]: self.editItem(currentItem) elif selectedKey == self.mContextMenuActionNames[4]: self.createHistoryPoint() for rowNo in self.getSelectedRows(): self.hideRow(rowNo) elif selectedKey == "Open Details": self.showDetails() elif selectedKey == self.mContextMenuOpenWithNames[0]: from Core import Execute Execute.openWith([ fu.getRealDirName( self.values[currentItem.row()]["path"]) ]) elif selectedKey == self.mContextMenuOpenWithNames[1]: from Core import Execute Execute.openWith( [self.values[currentItem.row()]["path"]]) elif uni.isWindows is False and selectedKey == self.mContextMenuOpenWithNames[ 2]: from Core import Execute Execute.execute([ "konsole", "--workdir", fu.getRealDirName( self.values[currentItem.row()]["path"]) ]) except: ReportBug.ReportBug()
def stopReadOnlyEmbeddedDB(_isNoAlertIfSuccessfully=True): global isReadOnlyStarted if isReadOnlyStarted is False: return True isReadOnlyStarted = False mysqldPID = getReadOnlyPID() if mysqldPID is not None: Execute.execute(["kill", "-TERM", str(mysqldPID)]) Dialogs.sleep(translate("EmbeddedDBCore", "Stopping Embedded Server..."), 3) if _isNoAlertIfSuccessfully is False: Dialogs.show(translate("EmbeddedDBCore", "Stopped Embedded Server"), translate("EmbeddedDBCore", "Embedded Amarok database server stopped.")) return True
def stopReadOnlyEmbeddedDB(_isNoAlertIfSuccessfully=True): global isReadOnlyStarted if isReadOnlyStarted is False: return True isReadOnlyStarted = False mysqldPID = getReadOnlyPID() if mysqldPID is not None: Execute.execute(["kill", "-TERM", str(mysqldPID)]) Dialogs.sleep( translate("EmbeddedDBCore", "Stopping Embedded Server..."), 3) if _isNoAlertIfSuccessfully is False: Dialogs.show( translate("EmbeddedDBCore", "Stopped Embedded Server"), translate("EmbeddedDBCore", "Embedded Amarok database server stopped.")) return True
def play(self, _filePath): from Core import Execute if self.popen is not False: self.runCommand("quit") command = [uni.MySettings["mplayerPath"]] command += uni.MySettings["mplayerArgs"].split(" ") command += [uni.MySettings["mplayerAudioDevicePointer"], uni.MySettings["mplayerAudioDevice"], str(_filePath)] self.popen = Execute.execute(command) return True
def clickedAnAction(_action): try: actionName = _action.objectName() if actionName == "Open State": f = Dialogs.getOpenFileName(translate("MenuBar", "Open State Of Hamsi Manager"), fu.userDirectoryPath, translate("MenuBar", "Application Runner") + " (*.desktop)") if f is not None: Settings.openStateOfSettings(f) elif actionName == "Save State": f = Dialogs.getSaveFileName(translate("MenuBar", "Save State Of Hamsi Manager"), fu.joinPath(fu.userDirectoryPath, "HamsiManager.desktop"), translate("MenuBar", "Application Runner") + " (*.desktop)") if f is not None: Settings.saveStateOfSettings(f) Dialogs.show(translate("MenuBar", "Current State Saved"), translate("MenuBar", "Current state saved with preferences.<br>You can continue where you left off.")) elif actionName == "With This Profile (My Settings)": if Execute.executeAsRootWithThread(["--sDirectoryPath", fu.pathOfSettingsDirectory], "HamsiManager"): getMainWindow().close() else: Dialogs.showError(translate("MenuBar", "Can Not Run As Root"), translate("MenuBar", "Hamsi Manager can not run as root.")) elif actionName == "With Root Profile (Own Settings)": if Execute.executeAsRootWithThread([], "HamsiManager"): getMainWindow().close() else: Dialogs.showError(translate("MenuBar", "Can Not Run As Root"), translate("MenuBar", "Hamsi Manager can not run as root.")) elif actionName == "Quit": getMainWindow().close() elif actionName == "HTML Format": if _action.parent().objectName() == "Export To File": getMainTable().exportValues("file", "html", "title") elif _action.parent().objectName() == "Show In New Window": getMainTable().exportValues("dialog", "html", "title") elif _action.parent().objectName() == "Copy To Clipboard": getMainTable().exportValues("clipboard", "html", "title") elif actionName == "Text Format": if _action.parent().objectName() == "Export To File": getMainTable().exportValues("file", "plainText", "title") elif _action.parent().objectName() == "Show In New Window": getMainTable().exportValues("dialog", "plainText", "title") elif _action.parent().objectName() == "Copy To Clipboard": getMainTable().exportValues("clipboard", "plainText", "title") elif actionName == "HTML Format (File Tree)": if _action.parent().objectName() == "Export To File": fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "file", "html", "fileTree", "title") elif _action.parent().objectName() == "Show In New Window": fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "dialog", "html", "fileTree", "title") elif _action.parent().objectName() == "Copy To Clipboard": fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "clipboard", "html", "fileTree", "title") elif actionName == "Text Format (File Tree)": if _action.parent().objectName() == "Export To File": fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "file", "plainText", "fileTree", "title") elif _action.parent().objectName() == "Show In New Window": fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "dialog", "plainText", "fileTree", "title") elif _action.parent().objectName() == "Copy To Clipboard": fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "clipboard", "plainText", "fileTree", "title") elif actionName == "About QT": if isActivePyKDE4: QMessageBox.aboutQt(getMainWindow(), translate("MenuBar", "About QT")) else: MMessageBox.aboutQt(getMainWindow(), translate("MenuBar", "About QT")) elif actionName == "Options": from Options import OptionsForm OptionsForm.OptionsForm(getMainWindow()) elif actionName == "My Plugins": import MyPlugins MyPlugins.MyPlugins() elif actionName == "Reconfigure": from Tools import Configurator Configurator.Configurator("configurePage") elif actionName == "My Plugins (System)": Execute.execute(["--qm", "--plugins", "--runAsRoot"], "HamsiManager") elif actionName == "Reconfigure (System)": Execute.execute(["--qm", "--configurator", "--runAsRoot"], "HamsiManager") elif actionName == "Update": from Core import UpdateControl UpdateControl.UpdateControl(getMainWindow()) elif actionName == "Report Bug": ReportBug.ReportBug(True) elif actionName == "Suggest Idea": from Core import SuggestIdea SuggestIdea.SuggestIdea() elif actionName == "About Hamsi Manager": if isActivePyKDE4 is False: MMessageBox.about(getMainWindow(), translate("MenuBar", "About Hamsi Manager"), uni.aboutOfHamsiManager) elif actionName == translate("ToolsBar", "Check Icon"): getMainWindow().setEnabled(False) fu.checkIcon(getMainWindow().FileManager.getCurrentDirectoryPath()) Dialogs.show(translate("ToolsBar", "Directory Icon Checked"), translate("ToolsBar", "Current directory icon checked.<br>The default action based on the data is executed.")) getMainWindow().setEnabled(True) elif actionName == "Clear Empty Directories": if getMainTable().checkUnSavedValues() is False: _action.setChecked(False) return False answer = Dialogs.ask(translate("ToolsBar", "Empty Directories Will Be Removed"), str(translate("ToolsBar", "Are you sure you want to remove empty directories based on the criteria you set in \"%s\"?")) % Organizer.getLink( getMainWindow().FileManager.getCurrentDirectoryPath())) if answer == Dialogs.Yes: getMainWindow().setEnabled(False) currentDirPath = getMainWindow().FileManager.getCurrentDirectoryPath() if fu.isWritableFileOrDir(currentDirPath): fu.checkEmptyDirectories(currentDirPath, True, True, True, True) Dialogs.show(translate("ToolsBar", "Directory Cleaned"), translate("ToolsBar", "The current directory is cleaned based on the criteria you set.")) getMainWindow().setEnabled(True) getMainWindow().FileManager.makeRefresh() elif actionName == "Pack": from Tools import Packager Packager.Packager(getMainWindow().FileManager.getCurrentDirectoryPath()) elif actionName == "Hash": from Tools import Hasher Hasher.Hasher(getMainWindow().FileManager.getCurrentDirectoryPath()) elif actionName == "Clear": from Tools import Cleaner Cleaner.Cleaner(getMainWindow().FileManager.getCurrentDirectoryPath()) elif actionName == "Text Corrector": from Tools import TextCorrector TextCorrector.TextCorrector(getMainWindow().FileManager.getCurrentDirectoryPath()) elif actionName == "File Tree": from Tools import FileTreeBuilder FileTreeBuilder.FileTreeBuilder(getMainWindow().FileManager.getCurrentDirectoryPath()) elif actionName == "Search": from Tools import Searcher Searcher.Searcher([getMainWindow().FileManager.getCurrentDirectoryPath()]) elif actionName == "Script Manager": from Tools import ScriptManager if ScriptManager.ScriptManager.checkScriptManager(): ScriptManager.ScriptManager(getMainWindow()) elif actionName == "Show Last Actions": from Core import RecordsForm RecordsForm.RecordsForm(getMainWindow()) elif actionName == "Remove Sub Files": answer = Dialogs.ask(translate("ToolsBar", "All Files Will Be Removed"), str(translate("ToolsBar", "Are you sure you want to remove only all files in \"%s\"?<br>Note:Do not will remove directory and subfolders.")) % Organizer.getLink( getMainWindow().FileManager.getCurrentDirectoryPath())) if answer == Dialogs.Yes: getMainWindow().setEnabled(False) fu.removeOnlySubFiles(getMainWindow().FileManager.getCurrentDirectoryPath()) getMainWindow().setEnabled(True) Dialogs.show(translate("ToolsBar", "Removed Only All Files"), str(translate("ToolsBar", "Removed only all files in \"%s\".<br>Note:Do not removed directory and subfolders.")) % Organizer.getLink( getMainWindow().FileManager.getCurrentDirectoryPath())) elif actionName == "Amarok Embedded Database Configurator": import Amarok if Amarok.checkAmarok(): Amarok.openEmbeddedDBConfigurator() elif _action.parent().objectName() == "Table Types": changeTableType(_action) elif _action.parent().objectName() == "File Renamer Types": changeReNamerType(_action) elif _action.parent().objectName() == "Scripts": from Core import Scripts Scripts.runScriptFile(fu.joinPath(Scripts.pathOfScripsDirectory, actionName)) Records.saveAllRecords() except: ReportBug.ReportBug()
def clickedAnAction(_action): try: actionName = _action.objectName() if actionName == "Open State": f = Dialogs.getOpenFileName( translate("MenuBar", "Open State Of Hamsi Manager"), fu.userDirectoryPath, translate("MenuBar", "Application Runner") + " (*.desktop)") if f is not None: Settings.openStateOfSettings(f) elif actionName == "Save State": f = Dialogs.getSaveFileName( translate("MenuBar", "Save State Of Hamsi Manager"), fu.joinPath(fu.userDirectoryPath, "HamsiManager.desktop"), translate("MenuBar", "Application Runner") + " (*.desktop)") if f is not None: Settings.saveStateOfSettings(f) Dialogs.show( translate("MenuBar", "Current State Saved"), translate( "MenuBar", "Current state saved with preferences.<br>You can continue where you left off." )) elif actionName == "With This Profile (My Settings)": if Execute.executeAsRootWithThread( ["--sDirectoryPath", fu.pathOfSettingsDirectory], "HamsiManager"): getMainWindow().close() else: Dialogs.showError( translate("MenuBar", "Can Not Run As Root"), translate("MenuBar", "Hamsi Manager can not run as root.")) elif actionName == "With Root Profile (Own Settings)": if Execute.executeAsRootWithThread([], "HamsiManager"): getMainWindow().close() else: Dialogs.showError( translate("MenuBar", "Can Not Run As Root"), translate("MenuBar", "Hamsi Manager can not run as root.")) elif actionName == "Quit": getMainWindow().close() elif actionName == "HTML Format": if _action.parent().objectName() == "Export To File": getMainTable().exportValues("file", "html", "title") elif _action.parent().objectName() == "Show In New Window": getMainTable().exportValues("dialog", "html", "title") elif _action.parent().objectName() == "Copy To Clipboard": getMainTable().exportValues("clipboard", "html", "title") elif actionName == "Text Format": if _action.parent().objectName() == "Export To File": getMainTable().exportValues("file", "plainText", "title") elif _action.parent().objectName() == "Show In New Window": getMainTable().exportValues("dialog", "plainText", "title") elif _action.parent().objectName() == "Copy To Clipboard": getMainTable().exportValues("clipboard", "plainText", "title") elif actionName == "HTML Format (File Tree)": if _action.parent().objectName() == "Export To File": fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "file", "html", "fileTree", "title") elif _action.parent().objectName() == "Show In New Window": fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "dialog", "html", "fileTree", "title") elif _action.parent().objectName() == "Copy To Clipboard": fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "clipboard", "html", "fileTree", "title") elif actionName == "Text Format (File Tree)": if _action.parent().objectName() == "Export To File": fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "file", "plainText", "fileTree", "title") elif _action.parent().objectName() == "Show In New Window": fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "dialog", "plainText", "fileTree", "title") elif _action.parent().objectName() == "Copy To Clipboard": fu.getFileTree((getMainWindow().FileManager.currentDirectory), 0, "clipboard", "plainText", "fileTree", "title") elif actionName == "About QT": if isActivePyKDE4: QMessageBox.aboutQt(getMainWindow(), translate("MenuBar", "About QT")) else: MMessageBox.aboutQt(getMainWindow(), translate("MenuBar", "About QT")) elif actionName == "Options": from Options import OptionsForm OptionsForm.OptionsForm(getMainWindow()) elif actionName == "My Plugins": import MyPlugins MyPlugins.MyPlugins() elif actionName == "Reconfigure": from Tools import Configurator Configurator.Configurator("configurePage") elif actionName == "My Plugins (System)": Execute.execute(["--qm", "--plugins", "--runAsRoot"], "HamsiManager") elif actionName == "Reconfigure (System)": Execute.execute(["--qm", "--configurator", "--runAsRoot"], "HamsiManager") elif actionName == "Update": from Core import UpdateControl UpdateControl.UpdateControl(getMainWindow()) elif actionName == "Report Bug": ReportBug.ReportBug(True) elif actionName == "Suggest Idea": from Core import SuggestIdea SuggestIdea.SuggestIdea() elif actionName == "About Hamsi Manager": if isActivePyKDE4 is False: MMessageBox.about(getMainWindow(), translate("MenuBar", "About Hamsi Manager"), uni.aboutOfHamsiManager) elif actionName == translate("ToolsBar", "Check Icon"): getMainWindow().setEnabled(False) fu.checkIcon(getMainWindow().FileManager.getCurrentDirectoryPath()) Dialogs.show( translate("ToolsBar", "Directory Icon Checked"), translate( "ToolsBar", "Current directory icon checked.<br>The default action based on the data is executed." )) getMainWindow().setEnabled(True) elif actionName == "Clear Empty Directories": if getMainTable().checkUnSavedValues() is False: _action.setChecked(False) return False answer = Dialogs.ask( translate("ToolsBar", "Empty Directories Will Be Removed"), str( translate( "ToolsBar", "Are you sure you want to remove empty directories based on the criteria you set in \"%s\"?" )) % Organizer.getLink( getMainWindow().FileManager.getCurrentDirectoryPath())) if answer == Dialogs.Yes: getMainWindow().setEnabled(False) currentDirPath = getMainWindow( ).FileManager.getCurrentDirectoryPath() if fu.isWritableFileOrDir(currentDirPath): fu.checkEmptyDirectories(currentDirPath, True, True, True, True) Dialogs.show( translate("ToolsBar", "Directory Cleaned"), translate( "ToolsBar", "The current directory is cleaned based on the criteria you set." )) getMainWindow().setEnabled(True) getMainWindow().FileManager.makeRefresh() elif actionName == "Pack": from Tools import Packager Packager.Packager( getMainWindow().FileManager.getCurrentDirectoryPath()) elif actionName == "Hash": from Tools import Hasher Hasher.Hasher( getMainWindow().FileManager.getCurrentDirectoryPath()) elif actionName == "Clear": from Tools import Cleaner Cleaner.Cleaner( getMainWindow().FileManager.getCurrentDirectoryPath()) elif actionName == "Text Corrector": from Tools import TextCorrector TextCorrector.TextCorrector( getMainWindow().FileManager.getCurrentDirectoryPath()) elif actionName == "File Tree": from Tools import FileTreeBuilder FileTreeBuilder.FileTreeBuilder( getMainWindow().FileManager.getCurrentDirectoryPath()) elif actionName == "Search": from Tools import Searcher Searcher.Searcher( [getMainWindow().FileManager.getCurrentDirectoryPath()]) elif actionName == "Script Manager": from Tools import ScriptManager if ScriptManager.ScriptManager.checkScriptManager(): ScriptManager.ScriptManager(getMainWindow()) elif actionName == "Show Last Actions": from Core import RecordsForm RecordsForm.RecordsForm(getMainWindow()) elif actionName == "Remove Sub Files": answer = Dialogs.ask( translate("ToolsBar", "All Files Will Be Removed"), str( translate( "ToolsBar", "Are you sure you want to remove only all files in \"%s\"?<br>Note:Do not will remove directory and subfolders." )) % Organizer.getLink( getMainWindow().FileManager.getCurrentDirectoryPath())) if answer == Dialogs.Yes: getMainWindow().setEnabled(False) fu.removeOnlySubFiles( getMainWindow().FileManager.getCurrentDirectoryPath()) getMainWindow().setEnabled(True) Dialogs.show( translate("ToolsBar", "Removed Only All Files"), str( translate( "ToolsBar", "Removed only all files in \"%s\".<br>Note:Do not removed directory and subfolders." )) % Organizer.getLink( getMainWindow().FileManager.getCurrentDirectoryPath())) elif actionName == "Amarok Embedded Database Configurator": import Amarok if Amarok.checkAmarok(): Amarok.openEmbeddedDBConfigurator() elif _action.parent().objectName() == "Table Types": changeTableType(_action) elif _action.parent().objectName() == "File Renamer Types": changeReNamerType(_action) elif _action.parent().objectName() == "Scripts": from Core import Scripts Scripts.runScriptFile( fu.joinPath(Scripts.pathOfScripsDirectory, actionName)) Records.saveAllRecords() except: ReportBug.ReportBug()