Skip to content

Commit

Permalink
Allow overriding terminal to run (#685)
Browse files Browse the repository at this point in the history
TerminalName and TerminalCommand
  • Loading branch information
dail8859 authored Dec 23, 2024
1 parent 5c68724 commit 17d0a02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions src/NotepadNext/dialogs/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,14 +761,19 @@ MainWindow::MainWindow(NotepadNextApplication *app) :

#ifdef Q_OS_WIN
connect(ui->actionShowInExplorer, &QAction::triggered, this, [=]() {
QStringList arguments;
arguments << "/select," << QDir::toNativeSeparators(currentEditor()->getFileInfo().canonicalFilePath());
QString filePath = QDir::toNativeSeparators(currentEditor()->getFileInfo().canonicalFilePath());
QStringList arguments = {"/select,", filePath};
QProcess::startDetached("explorer", arguments);
});
connect(ui->actionOpenCommandPromptHere, &QAction::triggered, this, [=]() {
QStringList arguments;
arguments << "/c" << "start" << "/d" << QDir::toNativeSeparators(currentEditor()->getFileInfo().dir().canonicalPath()) << "cmd";
QProcess::startDetached(QStringLiteral("cmd"), arguments);

QString terminalName = app->getSettings()->value("App/TerminalName", "Command Prompt").toString();
ui->actionOpenTerminalHere->setText(ui->actionOpenTerminalHere->text().arg(terminalName));

connect(ui->actionOpenTerminalHere, &QAction::triggered, this, [=]() {
QString command = app->getSettings()->value("App/TerminalCommand", "cmd").toString();
QString filePath = QDir::toNativeSeparators(currentEditor()->getFileInfo().dir().canonicalPath());
QStringList arguments = {"/c", "start", "/d", filePath, command};
QProcess::startDetached("cmd", arguments);
});
#endif

Expand Down Expand Up @@ -1522,7 +1527,7 @@ void MainWindow::updateFileStatusBasedUi(ScintillaNext *editor)
ui->actionCopyFullPath->setEnabled(isFile);
ui->actionCopyFileDirectory->setEnabled(isFile);
ui->actionShowInExplorer->setEnabled(isFile);
ui->actionOpenCommandPromptHere->setEnabled(isFile);
ui->actionOpenTerminalHere->setEnabled(isFile);
}

bool MainWindow::isAnyUnsaved() const
Expand Down Expand Up @@ -2095,7 +2100,7 @@ void MainWindow::tabBarRightClicked(ScintillaNext *editor)
"",
#ifdef Q_OS_WIN
"ShowInExplorer",
"OpenCommandPromptHere",
"OpenTerminalHere",
"",
#endif
"CopyFullPath",
Expand Down
4 changes: 2 additions & 2 deletions src/NotepadNext/dialogs/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1137,13 +1137,13 @@
<string>Show in Explorer</string>
</property>
</action>
<action name="actionOpenCommandPromptHere">
<action name="actionOpenTerminalHere">
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/icons/application_osx_terminal.png</normaloff>:/icons/application_osx_terminal.png</iconset>
</property>
<property name="text">
<string>Open Command Prompt Here</string>
<string>Open %1 Here</string>
</property>
</action>
<action name="actionToggleBookmark">
Expand Down

0 comments on commit 17d0a02

Please sign in to comment.