* update chinese translations

* make clean for project done
This commit is contained in:
royqh1979@gmail.com 2021-09-17 21:33:19 +08:00
parent fc4beb9fda
commit 7f14720666
10 changed files with 1499 additions and 414 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -88,6 +88,34 @@ void CompilerManager::compileProject(std::shared_ptr<Project> project, bool rebu
}
}
void CompilerManager::cleanProject(std::shared_ptr<Project> project)
{
if (!pSettings->compilerSets().defaultSet()) {
QMessageBox::critical(pMainWindow,
tr("No compiler set"),
tr("No compiler set is configured.")+tr("Can't start debugging."));
return;
}
{
QMutexLocker locker(&mCompileMutex);
if (mCompiler!=nullptr) {
return;
}
mCompileErrorCount = 0;
ProjectCompiler* compiler = new ProjectCompiler(project,false,false);
compiler->setOnlyClean(true);
mCompiler->setRebuild(false);
mCompiler = compiler;
connect(mCompiler, &Compiler::compileFinished, this ,&CompilerManager::onCompileFinished);
connect(mCompiler, &Compiler::compileIssue, this, &CompilerManager::onCompileIssue);
connect(mCompiler, &Compiler::compileFinished, pMainWindow, &MainWindow::onCompileFinished);
connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::onCompileLog);
connect(mCompiler, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue);
connect(mCompiler, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured);
mCompiler->start();
}
}
void CompilerManager::buildProjectMakefile(std::shared_ptr<Project> project)
{
if (!pSettings->compilerSets().defaultSet()) {

View File

@ -21,6 +21,7 @@ public:
void compile(const QString& filename, const QByteArray& encoding, bool rebuild, bool silent=false,bool onlyCheckSyntax=false);
void compileProject(std::shared_ptr<Project> project, bool rebuild, bool silent=false,bool onlyCheckSyntax=false);
void cleanProject(std::shared_ptr<Project> project);
void buildProjectMakefile(std::shared_ptr<Project> project);
void checkSyntax(const QString&filename, const QString& content, bool isAscii, std::shared_ptr<Project> project);
void run(const QString& filename, const QString& arguments, const QString& workDir);

View File

@ -421,6 +421,16 @@ void ProjectCompiler::writeln(QFile &file, const QString &s)
file.write("\n");
}
bool ProjectCompiler::onlyClean() const
{
return mOnlyClean;
}
void ProjectCompiler::setOnlyClean(bool newOnlyClean)
{
mOnlyClean = newOnlyClean;
}
QString ProjectCompiler::pipedText()
{
return QString();
@ -446,7 +456,11 @@ bool ProjectCompiler::prepareForCompile()
buildMakeFile();
mCompiler = compilerSet()->make();
if (mRebuild) {
if (mOnlyClean) {
mArguments = QString("-f \"%1\" clean").arg(extractRelativePath(
mProject->directory(),
mProject->makeFileName()));
} if (mRebuild) {
mArguments = QString("-f \"%1\" clean all").arg(extractRelativePath(
mProject->directory(),
mProject->makeFileName()));

View File

@ -12,6 +12,9 @@ public:
ProjectCompiler(std::shared_ptr<Project> project, bool silent,bool onlyCheckSyntax);
void buildMakeFile();
bool onlyClean() const;
void setOnlyClean(bool newOnlyClean);
private:
void createStandardMakeFile();
void createStaticMakeFile();
@ -25,6 +28,8 @@ private:
void writeMakeObjFilesRules(QFile& file);
void writeln(QFile& file, const QString& s="");
// Compiler interface
private:
bool mOnlyClean;
protected:
bool prepareForCompile() override;
QString pipedText() override;

View File

@ -108,6 +108,10 @@ MainWindow::MainWindow(QWidget *parent)
ui->actionEncode_in_ANSI->setCheckable(true);
ui->actionEncode_in_UTF_8->setCheckable(true);
mMenuRecentProjects = new QMenu();
mMenuRecentProjects->setTitle(tr("Recent Projects"));
ui->menuFile->insertMenu(ui->actionExit, mMenuRecentProjects);
mMenuRecentFiles = new QMenu();
mMenuRecentFiles->setTitle(tr("Recent Files"));
ui->menuFile->insertMenu(ui->actionExit, mMenuRecentFiles);
@ -155,6 +159,9 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->menuFile, &QMenu::aboutToShow,
this,&MainWindow::rebuildOpenedFileHisotryMenu);
connect(ui->menuProject, &QMenu::aboutToShow,
this, &MainWindow::updateProjectActions);
buildContextMenus();
}
@ -262,7 +269,8 @@ void MainWindow::updateProjectActions()
ui->actionView_Makefile->setEnabled(hasProject);
ui->actionProject_New_File->setEnabled(hasProject);
ui->actionAdd_to_project->setEnabled(hasProject);
ui->actionRemove_from_project->setEnabled(hasProject && ui->projectView->selectionModel()->hasSelection());
ui->actionRemove_from_project->setEnabled(hasProject && ui->projectView->selectionModel()->selectedIndexes().count()>0);
ui->actionMakeClean->setEnabled(hasProject);
ui->actionProject_options->setEnabled(hasProject);
ui->actionClose_Project->setEnabled(hasProject);
updateCompileActions();
@ -500,11 +508,20 @@ void MainWindow::updateDebugEval(const QString &value)
void MainWindow::rebuildOpenedFileHisotryMenu()
{
mMenuRecentFiles->clear();
mMenuRecentProjects->clear();
foreach (QAction* action,mRecentFileActions) {
action->setParent(nullptr);
action->deleteLater();
}
mRecentFileActions.clear();
foreach (QAction* action,mRecentProjectActions) {
action->setParent(nullptr);
action->deleteLater();
}
mRecentProjectActions.clear();
if (pSettings->history().openedFiles().size()==0) {
mMenuRecentFiles->setEnabled(false);
} else {
@ -519,6 +536,22 @@ void MainWindow::rebuildOpenedFileHisotryMenu()
}
mMenuRecentFiles->addActions(mRecentFileActions);
}
if (pSettings->history().openedProjects().size()==0) {
mMenuRecentProjects->setEnabled(false);
} else {
mMenuRecentProjects->setEnabled(true);
for (const QString& filename: pSettings->history().openedProjects()) {
QAction* action = new QAction();
action->setText(filename);
connect(action, &QAction::triggered, [&filename,this](bool){
this->openProject(filename);
});
mRecentProjectActions.append(action);
}
mMenuRecentProjects->addActions(mRecentProjectActions);
}
}
void MainWindow::updateClassBrowserForEditor(Editor *editor)
@ -1610,6 +1643,21 @@ void MainWindow::onEditorTabContextMenu(const QPoint &pos)
menu.exec(tabBar->mapToGlobal(pos));
}
void MainWindow::prepareProjectForCompile()
{
if (!mProject)
return;
if (!mProject->saveUnits())
return;
// Check if saves have been succesful
for (int i=0; i<mEditorList->pageCount();i++) {
Editor * e= (*(mEditorList))[i];
if (e->inProject() && e->modified())
return;
}
mProject->buildPrivateResource();
}
void MainWindow::closeProject(bool refreshEditor)
{
// Stop executing program
@ -3085,18 +3133,17 @@ void MainWindow::on_actionView_Makefile_triggered()
{
if (!mProject)
return;
if (!mProject->saveUnits())
return;
// Check if saves have been succesful
for (int i=0; i<mEditorList->pageCount();i++) {
Editor * e= (*(mEditorList))[i];
if (e->inProject() && e->modified())
return;
}
mProject->buildPrivateResource();
prepareProjectForCompile();
mCompilerManager->buildProjectMakefile(mProject);
openFile(mProject->makeFileName());
}
void MainWindow::on_actionMakeClean_triggered()
{
if (!mProject)
return;
prepareProjectForCompile();
mCompilerManager->cleanProject(mProject);
}

View File

@ -125,6 +125,7 @@ public slots:
void onEditorTabContextMenu(const QPoint& pos);
private:
void prepareProjectForCompile();
void closeProject(bool refreshEditor);
void updateProjectView();
void openFiles(const QStringList& files);
@ -322,6 +323,8 @@ private slots:
void on_actionView_Makefile_triggered();
void on_actionMakeClean_triggered();
private:
Ui::MainWindow *ui;
EditorList *mEditorList;
@ -331,6 +334,7 @@ private:
QMenu *mMenuEncoding;
QMenu *mMenuEncodingList;
QMenu *mMenuRecentFiles;
QMenu *mMenuRecentProjects;
QMenu *mMenuNew;
QComboBox *mCompilerSet;
CompilerManager *mCompilerManager;
@ -338,6 +342,7 @@ private:
CPUDialog *mCPUDialog;
SearchDialog *mSearchDialog;
QList<QAction *> mRecentFileActions;
QList<QAction *> mRecentProjectActions;
bool mQuitting;
QElapsedTimer mParserTimer;
QFileSystemWatcher mFileSystemWatcher;

View File

@ -11,11 +11,11 @@ ProjectDirectoriesWidget::ProjectDirectoriesWidget(const QString &name, const QS
ui->setupUi(this);
mLibDirWidget = new CompilerSetDirectoriesWidget();
ui->tabDirs->addTab(mLibDirWidget,QObject::tr("Libraries"));
ui->tabDirs->addTab(mLibDirWidget,tr("Libraries"));
mIncludeDirWidget = new CompilerSetDirectoriesWidget();
ui->tabDirs->addTab(mIncludeDirWidget,QObject::tr("Includes"));
ui->tabDirs->addTab(mIncludeDirWidget,tr("Includes"));
mResourceDirWidget = new CompilerSetDirectoriesWidget();
ui->tabDirs->addTab(mResourceDirWidget,QObject::tr("Resources"));
ui->tabDirs->addTab(mResourceDirWidget,tr("Resources"));
}

View File

@ -36,7 +36,7 @@ void ProjectPreCompileWidget::on_btnBrowse_triggered(QAction *arg1)
this,
tr("Precompiled header"),
pMainWindow->project()->directory(),
tr("header files (*.h"));
tr("header files (*.h)"));
if (!fileName.isEmpty() && QFileInfo(fileName).exists()) {
ui->txtPrecompileHeader->setText(fileName);
}