diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 1e973856..d2a8fc16 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -45,11 +45,13 @@ SOURCES += \ settingsdialog/editorsymbolcompletionwidget.cpp \ settingsdialog/editorsyntaxcheckwidget.cpp \ settingsdialog/environmentappearencewidget.cpp \ + settingsdialog/executorgeneralwidget.cpp \ settingsdialog/settingsdialog.cpp \ settingsdialog/settingswidget.cpp \ systemconsts.cpp \ utils.cpp \ widgets/coloredit.cpp \ + widgets/consolewidget.cpp \ widgets/issuestable.cpp \ widgets/qpatchedcombobox.cpp @@ -90,12 +92,14 @@ HEADERS += \ settingsdialog/editorsymbolcompletionwidget.h \ settingsdialog/editorsyntaxcheckwidget.h \ settingsdialog/environmentappearencewidget.h \ + settingsdialog/executorgeneralwidget.h \ settingsdialog/settingsdialog.h \ settingsdialog/settingswidget.h \ systemconsts.h \ utils.h \ common.h \ widgets/coloredit.h \ + widgets/consolewidget.h \ widgets/issuestable.h \ widgets/qpatchedcombobox.h @@ -110,6 +114,7 @@ FORMS += \ settingsdialog/editorsymbolcompletionwidget.ui \ settingsdialog/editorsyntaxcheckwidget.ui \ settingsdialog/environmentappearencewidget.ui \ + settingsdialog/executorgeneralwidget.ui \ settingsdialog/settingsdialog.ui TRANSLATIONS += \ diff --git a/RedPandaIDE/compiler/compilermanager.cpp b/RedPandaIDE/compiler/compilermanager.cpp index 4b92bc72..6cc6a918 100644 --- a/RedPandaIDE/compiler/compilermanager.cpp +++ b/RedPandaIDE/compiler/compilermanager.cpp @@ -5,6 +5,7 @@ #include "../mainwindow.h" #include "executablerunner.h" #include "utils.h" +#include "../settings.h" CompilerManager::CompilerManager(QObject *parent) : QObject(parent) { @@ -74,7 +75,7 @@ void CompilerManager::run(const QString &filename, const QString &arguments, con if (mRunner!=nullptr) { return; } - if (programHasConsole(filename)) { + if (pSettings->executor().pauseConsole() && programHasConsole(filename)) { QString newArguments = QString(" 0 \"%1\" %2").arg(toLocalPath(filename)).arg(arguments); mRunner = new ExecutableRunner(includeTrailingPathDelimiter(pSettings->dirs().app())+"ConsolePauser.exe",newArguments,workDir); } else { diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index fd4e7e67..00bb004f 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -279,7 +279,7 @@ void Editor::wheelEvent(QWheelEvent *event) { pMainWindow->updateEditorSettings(); event->accept(); return; - } else { + } else if (event->angleDelta().y()<0) { size = std::max(2,size-1); pSettings->editor().setFontSize(size); pMainWindow->updateEditorSettings(); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 5379c3e0..858f2319 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -122,14 +122,12 @@ void MainWindow::updateEditorActions() ui->actionEncode_in_UTF_8->setEnabled(false); ui->actionConvert_to_ANSI->setEnabled(false); ui->actionConvert_to_UTF_8->setEnabled(false); - ui->actionCompile->setEnabled(false); ui->actionCopy->setEnabled(false); ui->actionCut->setEnabled(false); ui->actionFoldAll->setEnabled(false); ui->actionIndent->setEnabled(false); ui->actionPaste->setEnabled(false); ui->actionRedo->setEnabled(false); - ui->actionRun->setEnabled(false); ui->actionSave->setEnabled(false); ui->actionSaveAs->setEnabled(false); ui->actionSaveAll->setEnabled(false); @@ -138,15 +136,19 @@ void MainWindow::updateEditorActions() ui->actionUnIndent->setEnabled(false); ui->actionUndo->setEnabled(false); ui->actionUnfoldAll->setEnabled(false); + + ui->actionCompile->setEnabled(false); + ui->actionCompile_Run->setEnabled(false); + ui->actionRun->setEnabled(false); + ui->actionRebuild->setEnabled(false); + ui->actionStop_Execution->setEnabled(false); } else { ui->actionAuto_Detect->setEnabled(true); ui->actionEncode_in_ANSI->setEnabled(true); ui->actionEncode_in_UTF_8->setEnabled(true); ui->actionConvert_to_ANSI->setEnabled(e->encodingOption()!=ENCODING_SYSTEM_DEFAULT && e->fileEncoding()!=ENCODING_SYSTEM_DEFAULT); ui->actionConvert_to_UTF_8->setEnabled(e->encodingOption()!=ENCODING_UTF8 && e->fileEncoding()!=ENCODING_UTF8); - //if (e->compilable()) - ui->actionCompile->setEnabled(true); - ui->actionRun->setEnabled(true); + ui->actionCopy->setEnabled(e->selAvail()); ui->actionCut->setEnabled(e->selAvail()); ui->actionFoldAll->setEnabled(e->lines()->count()>0); @@ -162,10 +164,28 @@ void MainWindow::updateEditorActions() ui->actionToggleComment->setEnabled(!e->readOnly() && e->lines()->count()>0); ui->actionUnIndent->setEnabled(!e->readOnly() && e->lines()->count()>0); ui->actionUnfoldAll->setEnabled(e->lines()->count()>0); + + updateCompileActions(); } } +void MainWindow::updateCompileActions() +{ + if (mCompilerManager->compiling()|| mCompilerManager->running()) { + ui->actionCompile->setEnabled(false); + ui->actionCompile_Run->setEnabled(false); + ui->actionRun->setEnabled(false); + ui->actionRebuild->setEnabled(false); + } else { + ui->actionCompile->setEnabled(true); + ui->actionCompile_Run->setEnabled(true); + ui->actionRun->setEnabled(true); + ui->actionRebuild->setEnabled(true); + } + ui->actionStop_Execution->setEnabled(mCompilerManager->running()); +} + void MainWindow::updateEditorColorSchemes() { mEditorList->applyColorSchemes(pSettings->editor().colorScheme()); @@ -310,7 +330,8 @@ bool MainWindow::compile(bool rebuild) if (mCompileSuccessionTask) { mCompileSuccessionTask->filename = getCompiledExecutableName(editor->filename()); } - mCompilerManager->compile(editor->filename(),editor->fileEncoding(),rebuild); + mCompilerManager->compile(editor->filename(),editor->fileEncoding(),rebuild); + updateCompileActions(); openCloseMessageSheet(true); ui->tabMessages->setCurrentWidget(ui->tabCompilerOutput); return true; @@ -371,6 +392,10 @@ void MainWindow::runExecutable(const QString &exeName,const QString &filename) // MainForm.UpdateAppTitle; // end; mCompilerManager->run(exeName,"",QFileInfo(exeName).absolutePath()); + updateCompileActions(); + if (pSettings->executor().minimizeOnRun()) { + showMinimized(); + } } void MainWindow::runExecutable() @@ -616,6 +641,7 @@ void MainWindow::onCompileFinished() } } mCheckSyntaxInBack=false; + updateCompileActions(); } void MainWindow::onCompileErrorOccured(const QString &reason) @@ -630,7 +656,10 @@ void MainWindow::onRunErrorOccured(const QString &reason) void MainWindow::onRunFinished() { - qDebug()<<"run finished"; + updateCompileActions(); + if (pSettings->executor().minimizeOnRun()) { + showNormal(); + } } void MainWindow::on_actionCompile_triggered() diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 86111a4f..f8e7b80d 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -41,6 +41,7 @@ public: void updateForStatusbarModeInfo(); void updateEditorSettings(); void updateEditorActions(); + void updateCompileActions(); void updateEditorColorSchemes(); void updateCompilerSet(); void checkSyntaxInBack(Editor* e); diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index b910c5ed..99a7add9 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -5173,8 +5173,9 @@ void SynEdit::wheelEvent(QWheelEvent *event) { if (event->angleDelta().y()>0) { verticalScrollBar()->setValue(verticalScrollBar()->value()-1); + event->accept(); return; - } else { + } else if (event->angleDelta().y()<0) { verticalScrollBar()->setValue(verticalScrollBar()->value()+1); event->accept(); return; diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 17f66d68..be4da8af 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -20,7 +20,8 @@ Settings::Settings(const QString &filename): mDirs(this), mEditor(this), mEnvironment(this), - mCompilerSets(this) + mCompilerSets(this), + mExecutor(this) { } @@ -2199,3 +2200,43 @@ void Settings::Environment::setTheme(const QString &theme) { mTheme = theme; } + +Settings::Executor::Executor(Settings *settings):_Base(settings, SETTING_EXECUTOR) +{ + +} + +bool Settings::Executor::minimizeOnRun() const +{ + return mMinimizeOnRun; +} + +void Settings::Executor::setMinimizeOnRun(bool minimizeOnRun) +{ + mMinimizeOnRun = minimizeOnRun; +} + +void Settings::Executor::doSave() +{ + //Appearence + saveValue("pause_console", mPauseConsole); + saveValue("minimize_on_run", mMinimizeOnRun); +} + +bool Settings::Executor::pauseConsole() const +{ + return mPauseConsole; +} + +void Settings::Executor::setPauseConsole(bool pauseConsole) +{ + mPauseConsole = pauseConsole; +} + +void Settings::Executor::doLoad() +{ + //Appearence + mPauseConsole = boolValue("pause_console",true); + mMinimizeOnRun = boolValue("minimize_on_run",false); +} + diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index d9c9a53b..9cf1790b 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -15,6 +15,7 @@ #define SETTING_DIRS "Dirs" #define SETTING_EDITOR "Editor" #define SETTING_ENVIRONMENT "Environment" +#define SETTING_EXECUTOR "Executor" #define SETTING_COMPILTER_SETS "CompilerSets" #define SETTING_COMPILTER_SETS_DEFAULT_INDEX "defaultIndex" #define SETTING_COMPILTER_SETS_COUNT "count" @@ -367,6 +368,27 @@ public: void doLoad() override; }; + class Executor: public _Base { + public: + explicit Executor(Settings * settings); + + bool pauseConsole() const; + void setPauseConsole(bool pauseConsole); + + bool minimizeOnRun() const; + void setMinimizeOnRun(bool minimizeOnRun); + + private: + // general + bool mPauseConsole; + bool mMinimizeOnRun; + + protected: + void doSave() override; + void doLoad() override; + }; + + class CompilerSet { public: explicit CompilerSet(const QString& compilerFolder = QString()); @@ -540,6 +562,7 @@ public: Editor& editor(); CompilerSets& compilerSets(); Environment& environment(); + Executor& executor(); QString filename() const; private: @@ -549,6 +572,7 @@ private: Editor mEditor; Environment mEnvironment; CompilerSets mCompilerSets; + Executor mExecutor; }; diff --git a/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp b/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp new file mode 100644 index 00000000..07d671c2 --- /dev/null +++ b/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp @@ -0,0 +1,29 @@ +#include "executorgeneralwidget.h" +#include "ui_executorgeneralwidget.h" +#include "../settings.h" + +ExecutorGeneralWidget::ExecutorGeneralWidget(const QString& name, const QString& group, QWidget *parent): + SettingsWidget(name,group,parent), + ui(new Ui::ExecutorGeneralWidget) +{ + ui->setupUi(this); +} + +ExecutorGeneralWidget::~ExecutorGeneralWidget() +{ + delete ui; +} + +void ExecutorGeneralWidget::doLoad() +{ + ui->chkPauseConsole->setChecked(pSettings->executor().pauseConsole()); + ui->chkMinimizeOnRun->setChecked(pSettings->executor().minimizeOnRun()); +} + +void ExecutorGeneralWidget::doSave() +{ + pSettings->executor().setPauseConsole(ui->chkPauseConsole->isChecked()); + pSettings->executor().setMinimizeOnRun(ui->chkMinimizeOnRun->isChecked()); + + pSettings->executor().save(); +} diff --git a/RedPandaIDE/settingsdialog/executorgeneralwidget.h b/RedPandaIDE/settingsdialog/executorgeneralwidget.h new file mode 100644 index 00000000..bedc9cb6 --- /dev/null +++ b/RedPandaIDE/settingsdialog/executorgeneralwidget.h @@ -0,0 +1,28 @@ +#ifndef EXECUTORGENERALWIDGET_H +#define EXECUTORGENERALWIDGET_H + +#include +#include "settingswidget.h" + +namespace Ui { +class ExecutorGeneralWidget; +} + +class ExecutorGeneralWidget : public SettingsWidget +{ + Q_OBJECT + +public: + explicit ExecutorGeneralWidget(const QString& name, const QString& group, QWidget *parent = nullptr); + ~ExecutorGeneralWidget(); + +private: + Ui::ExecutorGeneralWidget *ui; + + // SettingsWidget interface +protected: + void doLoad() override; + void doSave() override; +}; + +#endif // EXECUTORGENERALWIDGET_H diff --git a/RedPandaIDE/settingsdialog/executorgeneralwidget.ui b/RedPandaIDE/settingsdialog/executorgeneralwidget.ui new file mode 100644 index 00000000..1db4fb82 --- /dev/null +++ b/RedPandaIDE/settingsdialog/executorgeneralwidget.ui @@ -0,0 +1,67 @@ + + + ExecutorGeneralWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + + Pause console programs after return + + + + + + + Minimize IDE when running programs + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/RedPandaIDE/settingsdialog/settingsdialog.cpp b/RedPandaIDE/settingsdialog/settingsdialog.cpp index c08b0020..7cffe955 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.cpp +++ b/RedPandaIDE/settingsdialog/settingsdialog.cpp @@ -9,6 +9,7 @@ #include "editorsyntaxcheckwidget.h" #include "editorsymbolcompletionwidget.h" #include "environmentappearencewidget.h" +#include "executorgeneralwidget.h" #include #include #include @@ -58,6 +59,10 @@ SettingsDialog::SettingsDialog(QWidget *parent) : addWidget(pEditorSyntaxCheckWidget); + pExecutorGeneralWidget = new ExecutorGeneralWidget(tr("General"),tr("Program Runner")); + pExecutorGeneralWidget->init(); + addWidget(pExecutorGeneralWidget); + ui->widgetsView->expandAll(); //select the first widget of the first group auto groupIndex = ui->widgetsView->model()->index(0,0); diff --git a/RedPandaIDE/settingsdialog/settingsdialog.h b/RedPandaIDE/settingsdialog/settingsdialog.h index 0bbbe55e..ec6a0668 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.h +++ b/RedPandaIDE/settingsdialog/settingsdialog.h @@ -19,6 +19,7 @@ class EditorSymbolCompletionWidget; class EditorColorSchemeWidget; class EditorSyntaxCheckWidget; class EnvironmentAppearenceWidget; +class ExecutorGeneralWidget; class SettingsWidget; class SettingsDialog : public QDialog { @@ -56,6 +57,7 @@ private: EnvironmentAppearenceWidget* pEnvironmentAppearenceWidget; EditorSymbolCompletionWidget* pEditorSymbolCompletionWidget; EditorSyntaxCheckWidget* pEditorSyntaxCheckWidget; + ExecutorGeneralWidget * pExecutorGeneralWidget; }; #endif // SETTINGSDIALOG_H diff --git a/RedPandaIDE/widgets/consolewidget.cpp b/RedPandaIDE/widgets/consolewidget.cpp new file mode 100644 index 00000000..cd497745 --- /dev/null +++ b/RedPandaIDE/widgets/consolewidget.cpp @@ -0,0 +1,6 @@ +#include "consolewidget.h" + +ConsoleWidget::ConsoleWidget(QWidget *parent):QTextEdit(parent) +{ + +} diff --git a/RedPandaIDE/widgets/consolewidget.h b/RedPandaIDE/widgets/consolewidget.h new file mode 100644 index 00000000..e7f9cfb5 --- /dev/null +++ b/RedPandaIDE/widgets/consolewidget.h @@ -0,0 +1,19 @@ +#ifndef CONSOLEWIDGET_H +#define CONSOLEWIDGET_H + +#include + +class ConsoleWidget : public QTextEdit +{ + Q_OBJECT +public: + explicit ConsoleWidget(QWidget* parent = nullptr); +private: + QString mCurrentCommand; + QStringList mCommandHistory; + int mHistoryIndex; + int mHistorySize; + QString mPrompt; +}; + +#endif // CONSOLEWIDGET_H