- change: "save" action will be enabled no matter contents in the current editor is modified or not

This commit is contained in:
royqh1979@gmail.com 2021-11-01 23:14:17 +08:00
parent 0a7855281e
commit 1b9fdd3020
8 changed files with 41 additions and 32 deletions

View File

@ -1,3 +1,6 @@
Version 0.7.7
- change: "save" action will be enabled no matter contents in the current editor is modified or not
Version 0.7.6
- change: don't auto insert a new line when input an enter between '(' and ')' or between '[' and ']' (indent instead)
- enhancement: the line containing '}' will use the indents of the matching '{' line, instead of just unindent one level

View File

@ -83,7 +83,6 @@ SOURCES += \
iconsmanager.cpp \
main.cpp \
mainwindow.cpp \
problems/problemcasevalidator.cpp \
qsynedit/CodeFolding.cpp \
qsynedit/Constants.cpp \
qsynedit/KeyStrokes.cpp \
@ -158,7 +157,6 @@ HEADERS += \
platform.h \
problems/ojproblemset.h \
problems/problemcasevalidator.h \
problems/problemcasevalidator.h \
project.h \
projectoptions.h \
projecttemplate.h \

View File

@ -247,6 +247,7 @@ void CompilerManager::runProblem(const QString &filename, const QString &argumen
connect(mRunner, &Runner::finished, pMainWindow ,&MainWindow::onRunProblemFinished);
connect(mRunner, &Runner::runErrorOccurred, pMainWindow ,&MainWindow::onRunErrorOccured);
connect(execRunner, &OJProblemCasesRunner::caseStarted, pMainWindow, &MainWindow::onOJProblemCaseStarted);
connect(execRunner, &OJProblemCasesRunner::caseFinished, pMainWindow, &MainWindow::onOJProblemCaseFinished);
mRunner->start();
}
@ -262,6 +263,7 @@ void CompilerManager::runProblem(const QString &filename, const QString &argumen
connect(mRunner, &Runner::finished, pMainWindow ,&MainWindow::onRunProblemFinished);
connect(mRunner, &Runner::runErrorOccurred, pMainWindow ,&MainWindow::onRunErrorOccured);
connect(execRunner, &OJProblemCasesRunner::caseStarted, pMainWindow, &MainWindow::onOJProblemCaseStarted);
connect(execRunner, &OJProblemCasesRunner::caseFinished, pMainWindow, &MainWindow::onOJProblemCaseFinished);
mRunner->start();
}

View File

@ -62,6 +62,7 @@ void OJProblemCasesRunner::runCase(int index,POJProblemCase problemCase)
QByteArray readed;
while (true) {
process.waitForFinished(1000);
readed += process.readAll();
if (process.state()!=QProcess::Running) {
break;
}
@ -73,7 +74,6 @@ void OJProblemCasesRunner::runCase(int index,POJProblemCase problemCase)
process.kill();
break;
}
readed += process.readAll();
if (errorOccurred)
break;
}

View File

@ -216,7 +216,6 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->lstProblemCases->selectionModel(),
&QItemSelectionModel::currentRowChanged,
this, &MainWindow::onProblemCaseIndexChanged);
ui->tabProblem->setVisible(false);
//files view
ui->treeFiles->setModel(&mFileSystemModel);
@ -354,7 +353,7 @@ void MainWindow::updateEditorActions()
ui->actionPaste->setEnabled(!e->readOnly() && !QGuiApplication::clipboard()->text().isEmpty());
ui->actionRedo->setEnabled(e->canRedo());
ui->actionUndo->setEnabled(e->canUndo());
ui->actionSave->setEnabled(e->modified());
ui->actionSave->setEnabled(!e->readOnly());
ui->actionSaveAs->setEnabled(true);
ui->actionExport_As_HTML->setEnabled(true);
ui->actionExport_As_RTF->setEnabled(true);
@ -1096,7 +1095,7 @@ void MainWindow::runExecutable(const QString &exeName,const QString &filename,Ru
tr("Source file is not compiled.")
+"<br /><br />"+tr("Compile now?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
ui->actionCompile_Run->trigger();
doCompileRun(runType);
}
return;
} else {
@ -1111,7 +1110,7 @@ void MainWindow::runExecutable(const QString &exeName,const QString &filename,Ru
tr("Source file is more recent than executable.")
+"<br /><br />"+tr("Recompile now?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
ui->actionCompile_Run->trigger();
doCompileRun(runType);
return;
}
} else {
@ -1120,21 +1119,6 @@ void MainWindow::runExecutable(const QString &exeName,const QString &filename,Ru
}
}
}
// Pause programs if they contain a console
// if devData.ConsolePause and ProgramHasConsole(FileToRun) then begin
// if fUseRunParams then
// Parameters := '"' + FileToRun + '" ' + fRunParams
// else
// Parameters := '"' + FileToRun + '"';
// FileToRun := devDirs.Exec + 'ConsolePauser.exe';
// end else begin
// if fUseRunParams then
// Parameters := fRunParams
// else
// Parameters := '';
// FileToRun := FileToRun;
// end;
updateCompileActions();
QString params;
@ -2545,13 +2529,11 @@ void MainWindow::onProblemSetIndexChanged(const QModelIndex &current, const QMod
// }
if (!idx.isValid()) {
ui->btnRemoveProblem->setEnabled(false);
ui->tabProblem->setVisible(false);
} else {
ui->btnRemoveProblem->setEnabled(true);
POJProblem problem = mOJProblemSetModel.problem(idx.row());
mOJProblemModel.setProblem(problem);
ui->lblProblem->setText(problem->name);
ui->tabProblem->setVisible(true);
openCloseBottomPanel(true);
ui->tabMessages->setCurrentWidget(ui->tabProblem);
}
@ -2564,7 +2546,6 @@ void MainWindow::onProblemCaseIndexChanged(const QModelIndex &current, const QMo
POJProblemCase problemCase = mOJProblemModel.getCase(previous.row());
problemCase->input = ui->txtProblemCaseInput->toPlainText();
problemCase->expected = ui->txtProblemCaseExpected->toPlainText();
problemCase->output = ui->txtProblemCaseOutput->toPlainText();
}
if (idx.isValid()) {
POJProblemCase problemCase = mOJProblemModel.getCase(idx.row());
@ -3279,9 +3260,15 @@ void MainWindow::onCompileFinished(bool isCheckSyntax)
//run succession task if there aren't any errors
if (mCompileSuccessionTask && mCompilerManager->compileErrorCount()==0) {
switch (mCompileSuccessionTask->type) {
case MainWindow::CompileSuccessionTaskType::Run:
case MainWindow::CompileSuccessionTaskType::RunNormal:
runExecutable(mCompileSuccessionTask->filename);
break;
case MainWindow::CompileSuccessionTaskType::RunProblemCases:
runExecutable(mCompileSuccessionTask->filename,QString(),RunType::ProblemCases);
break;
case MainWindow::CompileSuccessionTaskType::RunCurrentProblemCase:
runExecutable(mCompileSuccessionTask->filename,QString(),RunType::CurrentProblemCase);
break;
case MainWindow::CompileSuccessionTaskType::Debug:
debug();
break;
@ -3598,9 +3585,7 @@ void MainWindow::on_tabMessages_tabBarDoubleClicked(int )
void MainWindow::on_actionCompile_Run_triggered()
{
mCompileSuccessionTask = std::make_shared<CompileSuccessionTask>();
mCompileSuccessionTask->type = CompileSuccessionTaskType::Run;
compile();
doCompileRun(RunType::Normal);
}
void MainWindow::on_actionRebuild_triggered()
@ -4688,6 +4673,22 @@ void MainWindow::clearIssues()
ui->tableIssues->clearIssues();
}
void MainWindow::doCompileRun(RunType runType)
{
mCompileSuccessionTask = std::make_shared<CompileSuccessionTask>();
switch (runType) {
case RunType::CurrentProblemCase:
mCompileSuccessionTask->type = CompileSuccessionTaskType::RunCurrentProblemCase;
break;
case RunType::ProblemCases:
mCompileSuccessionTask->type = CompileSuccessionTaskType::RunProblemCases;
break;
default:
mCompileSuccessionTask->type = CompileSuccessionTaskType::RunNormal;
}
compile();
}
Ui::MainWindow *MainWindow::mainWidget() const
{
return ui;

View File

@ -53,7 +53,9 @@ class MainWindow : public QMainWindow
enum class CompileSuccessionTaskType {
None,
Run,
RunNormal,
RunProblemCases,
RunCurrentProblemCase,
Debug,
Profile
};
@ -206,6 +208,7 @@ private:
void showSearchReplacePanel(bool show);
void setFilesViewRoot(const QString& path);
void clearIssues();
void doCompileRun(RunType runType);
private slots:
void onAutoSaveTimeout();

View File

@ -2385,7 +2385,9 @@ void Settings::CompilerSets::loadSets()
.arg(pCurrentSet->name())
+"<br /><br />"
+msg
+"Would you like Red Panda C++ to remove them for you and add the default paths to the valid paths?<br /><br />Leaving those directories will lead to problems during compilation.<br /><br />Unless you know exactly what you're doing, it is recommended that you click Yes.",
+QObject::tr("Would you like Red Panda C++ to remove them for you and add the default paths to the valid paths?")
+"<br /><br />"
+QObject::tr("Leaving those directories will lead to problems during compilation.<br /><br />Unless you know exactly what you're doing, it is recommended that you click Yes."),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
return;
}

View File

@ -289,7 +289,7 @@ QVariant OJProblemModel::data(const QModelIndex &index, int role) const
case ProblemCaseTestState::Failed:
return QIcon(":/icons/images/newlook24/008-close.png");
case ProblemCaseTestState::Passed:
return QIcon(":/icons/images/newlook24/007-bughelp.png");
return QIcon(":/icons/images/newlook24/007-bughlp.png");
case ProblemCaseTestState::Testing:
return QIcon(":/icons/images/newlook24/052-next.png");
default: