add options to set terminal

This commit is contained in:
Roy Qu 2021-12-25 23:38:53 +08:00
parent 4f61797a50
commit edc9fe6ed0
12 changed files with 683 additions and 427 deletions

View File

@ -318,6 +318,15 @@ win32: SOURCES += \
settingsdialog/environmentfileassociationwidget.cpp \
settingsdialog/projectversioninfowidget.cpp
linux: HEADERS += \
settingsdialog/environmentprogramswidget.h
linux: SOURCES += \
settingsdialog/environmentprogramswidget.cpp
linux: FORMS += \
settingsdialog/environmentprogramswidget.ui
TRANSLATIONS += \
RedPandaIDE_zh_CN.ts

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -228,7 +228,7 @@ void CompilerManager::run(const QString &filename, const QString &arguments, con
#else
QString newArguments = QString(" -e \"%1\" %2")
.arg(localizePath(filename)).arg(arguments);
execRunner = new ExecutableRunner("/usr/bin/x-terminal-emulator",newArguments,workDir);
execRunner = new ExecutableRunner(pSettings->environment().terminalPath(),newArguments,workDir);
#endif
execRunner->setStartConsole(true);
} else {

View File

@ -2253,8 +2253,13 @@ void DebugTarget::run()
cmd= mGDBServer;
arguments = QString(" localhost:%1 \"%2\"").arg(mPort).arg(mInferior);
#else
cmd= "/usr/bin/x-terminal-emulator";
if (programHasConsole(mInferior)) {
cmd= pSettings->environment().terminalPath();
arguments = QString(" -e \"%1\" localhost:%2 \"%3\"").arg(mGDBServer).arg(mPort).arg(mInferior);
} else {
cmd= mGDBServer;
arguments = QString(" localhost:%1 \"%2\"").arg(mPort).arg(mInferior);
}
#endif
QString workingDir = QFileInfo(mInferior).path();

View File

@ -2798,6 +2798,10 @@ void Settings::Environment::doLoad()
if (!fileExists(mDefaultOpenFolder)) {
mDefaultOpenFolder = QDir::currentPath();
}
#ifdef Q_OS_LINUX
mTerminalPath = stringValue("terminal_path","/usr/bin/x-terminal-emulator");
#endif
}
int Settings::Environment::interfaceFontSize() const
@ -2850,6 +2854,16 @@ void Settings::Environment::setIconSet(const QString &newIconSet)
mIconSet = newIconSet;
}
QString Settings::Environment::terminalPath() const
{
return mTerminalPath;
}
void Settings::Environment::setTerminalPath(const QString &terminalPath)
{
mTerminalPath = terminalPath;
}
void Settings::Environment::doSave()
{
//Appearence
@ -2861,6 +2875,9 @@ void Settings::Environment::doSave()
saveValue("current_folder",mCurrentFolder);
saveValue("default_open_folder",mDefaultOpenFolder);
#ifndef Q_OS_WIN
saveValue("terminal_path",mTerminalPath);
#endif
}
QString Settings::Environment::interfaceFont() const

View File

@ -487,6 +487,9 @@ public:
const QString &iconSet() const;
void setIconSet(const QString &newIconSet);
QString terminalPath() const;
void setTerminalPath(const QString &terminalPath);
private:
//Appearence
@ -498,6 +501,7 @@ public:
QString mIconSet;
QString mDefaultOpenFolder;
QString mTerminalPath;
// _Base interface
protected:
void doSave() override;

View File

@ -0,0 +1,46 @@
#include "environmentprogramswidget.h"
#include "ui_environmentprogramswidget.h"
#include "../settings.h"
#include "../iconsmanager.h"
#include <QFileDialog>
EnvironmentProgramsWidget::EnvironmentProgramsWidget(const QString& name, const QString& group, QWidget *parent) :
SettingsWidget(name,group,parent),
ui(new Ui::EnvironmentProgramsWidget)
{
ui->setupUi(this);
}
EnvironmentProgramsWidget::~EnvironmentProgramsWidget()
{
delete ui;
}
void EnvironmentProgramsWidget::doLoad()
{
ui->txtTerminal->setText(pSettings->environment().terminalPath());
}
void EnvironmentProgramsWidget::doSave()
{
pSettings->environment().setTerminalPath(ui->txtTerminal->text());
pSettings->environment().save();
}
void EnvironmentProgramsWidget::updateIcons(const QSize &)
{
pIconsManager->setIcon(ui->btnChooseTerminal,IconsManager::ACTION_FILE_OPEN_FOLDER);
}
void EnvironmentProgramsWidget::on_btnChooseTerminal_clicked()
{
QString filename = QFileDialog::getOpenFileName(
this,
tr("Choose Terminal Program"),
QString(),
tr("All files (*.*)"));
if (!filename.isEmpty() && fileExists(filename) ) {
ui->txtTerminal->setText(filename);
}
}

View File

@ -0,0 +1,30 @@
#ifndef ENVIRONMENTPROGRAMSWIDGET_H
#define ENVIRONMENTPROGRAMSWIDGET_H
#include "settingswidget.h"
namespace Ui {
class EnvironmentProgramsWidget;
}
class EnvironmentProgramsWidget : public SettingsWidget
{
Q_OBJECT
public:
explicit EnvironmentProgramsWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
~EnvironmentProgramsWidget();
private:
Ui::EnvironmentProgramsWidget *ui;
// SettingsWidget interface
protected:
void doLoad();
void doSave();
void updateIcons(const QSize &size);
private slots:
void on_btnChooseTerminal_clicked();
};
#endif // ENVIRONMENTPROGRAMSWIDGET_H

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EnvironmentProgramsWidget</class>
<widget class="QWidget" name="EnvironmentProgramsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="txtTerminal"/>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="btnChooseTerminal">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/images/newlook24/053-open.png</normaloff>:/icons/images/newlook24/053-open.png</iconset>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Terminal</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -36,6 +36,9 @@
#include "environmentfileassociationwidget.h"
#include "projectversioninfowidget.h"
#endif
#ifdef Q_OS_LINUX
#include "environmentprogramswidget.h"
#endif
#include <QDebug>
#include <QMessageBox>
#include <QModelIndex>
@ -129,6 +132,12 @@ PSettingsDialog SettingsDialog::optionDialog()
widget->init();
dialog->addWidget(widget);
#ifdef Q_OS_LINUX
widget = new EnvironmentProgramsWidget(tr("Terminal"),tr("Environment"));
widget->init();
dialog->addWidget(widget);
#endif
widget = new EnvironmentPerformanceWidget(tr("Performance"),tr("Environment"));
widget->init();
dialog->addWidget(widget);

View File

@ -21,7 +21,11 @@ void ToolsManager::load()
mTools.clear();
PToolItem item = std::make_shared<ToolItem>();
item->title = tr("Remove Compiled");
#ifdef Q_OS_WIN
item->program = "del";
#else
item->program = "rm";
#endif
item->workingDirectory = "<SOURCEPATH>";
item->parameters = "<EXENAME>";
item->pauseAfterExit = false;