Skip to content

Commit

Permalink
Add a contextMenu allowing the user to open a terminal in the selecte…
Browse files Browse the repository at this point in the history
…d folder
  • Loading branch information
william-os4y committed Apr 26, 2015
1 parent 63d9a81 commit 666e3b7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lumina-fm/MainUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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; }
Expand Down
1 change: 1 addition & 0 deletions lumina-fm/MainUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ private slots:
void FavoriteItem();
// - full selection actions
void ViewPropertiesItem();
void openTerminal();
void CutItems();
void CopyItems();
void PasteItems();
Expand Down

0 comments on commit 666e3b7

Please sign in to comment.