diff options
author | wi <william.os4y@gmail.com> | 2015-04-26 23:02:11 +0200 |
---|---|---|
committer | wi <william.os4y@gmail.com> | 2015-04-26 23:02:11 +0200 |
commit | 666e3b70b6b1936c2b1dd67c48b521b43077b149 (patch) | |
tree | 03953122d6dd28a44aa4a3ff3da3c21a4ac6f188 /lumina-fm | |
parent | Add support for system-defined default non-mime applications in the luminaDes... (diff) | |
download | lumina-666e3b70b6b1936c2b1dd67c48b521b43077b149.tar.gz lumina-666e3b70b6b1936c2b1dd67c48b521b43077b149.tar.bz2 lumina-666e3b70b6b1936c2b1dd67c48b521b43077b149.zip |
Add a contextMenu allowing the user to open a terminal in the selected folder
Diffstat (limited to 'lumina-fm')
-rw-r--r-- | lumina-fm/MainUI.cpp | 19 | ||||
-rw-r--r-- | lumina-fm/MainUI.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp index 7f1e5fcc..ce3c4bd2 100644 --- a/lumina-fm/MainUI.cpp +++ b/lumina-fm/MainUI.cpp @@ -971,6 +971,11 @@ void MainUI::OpenContextMenu(const QPoint &pt){ contextMenu->addSeparator(); contextMenu->addAction(LXDG::findIcon("system-search",""), tr("File Properties"), this, SLOT(ViewPropertiesItem()) )->setEnabled(hasSelection && info.fileName().endsWith(".desktop")); } + if (info.isDir() || CItem.isEmpty()) { + //in case the user click on a directory or click on the background + contextMenu->addSeparator(); + contextMenu->addAction(LXDG::findIcon("system-search",""), tr("Open Terminal here"), this, SLOT(openTerminal())); + } //Now show the menu if(radio_view_details->isChecked()){ contextMenu->popup(ui->tree_dir_view->mapToGlobal(pt)); @@ -1425,6 +1430,20 @@ void MainUI::ViewPropertiesItem(){ } } +void MainUI::openTerminal(){ + QFileInfoList sel = getSelectedItems(); + QString shell; + if (getenv("SHELL")) shell = QString(getenv("SHELL")); + else shell = QString("/bin/sh"); + if(sel.isEmpty()){ + //TODO: replace xterm by the user's choice + QProcess::startDetached("xterm -e \"cd " + getCurrentDir() + " && " + shell + " \" "); + } else { + QProcess::startDetached("xterm -e \"cd " + sel[0].absoluteFilePath() + " && " + shell + " \" "); + } +} + + void MainUI::CutItems(){ //Only let this run if viewing the browser page if(ui->stackedWidget->currentWidget()!=ui->page_browser){ return; } diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h index b18d25a5..0e3d7eb5 100644 --- a/lumina-fm/MainUI.h +++ b/lumina-fm/MainUI.h @@ -216,6 +216,7 @@ private slots: void FavoriteItem(); // - full selection actions void ViewPropertiesItem(); + void openTerminal(); void CutItems(); void CopyItems(); void PasteItems(); |