- add project custom compile parameters option dialog

- add project directories option dialog
 - add project precompiled header dialog
This commit is contained in:
royqh1979@gmail.com 2021-09-15 16:57:28 +08:00
parent 14c83ab829
commit c242225951
13 changed files with 318 additions and 9 deletions

View File

@ -45,8 +45,10 @@ SOURCES += \
settingsdialog/formattergeneralwidget.cpp \ settingsdialog/formattergeneralwidget.cpp \
settingsdialog/projectcompileparamaterswidget.cpp \ settingsdialog/projectcompileparamaterswidget.cpp \
settingsdialog/projectcompilerwidget.cpp \ settingsdialog/projectcompilerwidget.cpp \
settingsdialog/projectdirectorieswidget.cpp \
settingsdialog/projectfileswidget.cpp \ settingsdialog/projectfileswidget.cpp \
settingsdialog/projectgeneralwidget.cpp \ settingsdialog/projectgeneralwidget.cpp \
settingsdialog/projectprecompilewidget.cpp \
widgets/classbrowser.cpp \ widgets/classbrowser.cpp \
widgets/codecompletionlistview.cpp \ widgets/codecompletionlistview.cpp \
widgets/codecompletionpopup.cpp \ widgets/codecompletionpopup.cpp \
@ -131,8 +133,10 @@ HEADERS += \
settingsdialog/formattergeneralwidget.h \ settingsdialog/formattergeneralwidget.h \
settingsdialog/projectcompileparamaterswidget.h \ settingsdialog/projectcompileparamaterswidget.h \
settingsdialog/projectcompilerwidget.h \ settingsdialog/projectcompilerwidget.h \
settingsdialog/projectdirectorieswidget.h \
settingsdialog/projectfileswidget.h \ settingsdialog/projectfileswidget.h \
settingsdialog/projectgeneralwidget.h \ settingsdialog/projectgeneralwidget.h \
settingsdialog/projectprecompilewidget.h \
widgets/classbrowser.h \ widgets/classbrowser.h \
widgets/codecompletionlistview.h \ widgets/codecompletionlistview.h \
widgets/codecompletionpopup.h \ widgets/codecompletionpopup.h \
@ -193,8 +197,10 @@ FORMS += \
settingsdialog/formattergeneralwidget.ui \ settingsdialog/formattergeneralwidget.ui \
settingsdialog/projectcompileparamaterswidget.ui \ settingsdialog/projectcompileparamaterswidget.ui \
settingsdialog/projectcompilerwidget.ui \ settingsdialog/projectcompilerwidget.ui \
settingsdialog/projectdirectorieswidget.ui \
settingsdialog/projectfileswidget.ui \ settingsdialog/projectfileswidget.ui \
settingsdialog/projectgeneralwidget.ui \ settingsdialog/projectgeneralwidget.ui \
settingsdialog/projectprecompilewidget.ui \
widgets/cpudialog.ui \ widgets/cpudialog.ui \
mainwindow.ui \ mainwindow.ui \
settingsdialog/compilersetdirectorieswidget.ui \ settingsdialog/compilersetdirectorieswidget.ui \

View File

@ -95,7 +95,7 @@
<item> <item>
<widget class="QTabWidget" name="settingTabs"> <widget class="QTabWidget" name="settingTabs">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<property name="movable"> <property name="movable">
<bool>false</bool> <bool>false</bool>

View File

@ -101,7 +101,7 @@
</spacer> </spacer>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="lbCaretColor_4"> <widget class="QLabel" name="lbIndentLineColor">
<property name="text"> <property name="text">
<string>Indent Line Color</string> <string>Indent Line Color</string>
</property> </property>

View File

@ -1,8 +1,10 @@
#include "projectcompileparamaterswidget.h" #include "projectcompileparamaterswidget.h"
#include "ui_projectcompileparamaterswidget.h" #include "ui_projectcompileparamaterswidget.h"
#include "../mainwindow.h"
#include "../project.h"
ProjectCompileParamatersWidget::ProjectCompileParamatersWidget(QWidget *parent) : ProjectCompileParamatersWidget::ProjectCompileParamatersWidget(const QString &name, const QString &group, QWidget *parent) :
QWidget(parent), SettingsWidget(name,group,parent),
ui(new Ui::ProjectCompileParamatersWidget) ui(new Ui::ProjectCompileParamatersWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -12,3 +14,22 @@ ProjectCompileParamatersWidget::~ProjectCompileParamatersWidget()
{ {
delete ui; delete ui;
} }
void ProjectCompileParamatersWidget::doLoad()
{
ui->chkAddCharset->setChecked(pMainWindow->project()->options().addCharset);
ui->chkStaticLink->setChecked(pMainWindow->project()->options().staticLink);
ui->txtCCompiler->setPlainText(pMainWindow->project()->options().compilerCmd);
ui->txtCPPCompiler->setPlainText(pMainWindow->project()->options().cppCompilerCmd);
ui->txtLinker->setPlainText(pMainWindow->project()->options().linkerCmd);
}
void ProjectCompileParamatersWidget::doSave()
{
pMainWindow->project()->options().addCharset = ui->chkAddCharset->isChecked();
pMainWindow->project()->options().staticLink = ui->chkStaticLink->isChecked();
pMainWindow->project()->options().compilerCmd = ui->txtCCompiler->toPlainText();
pMainWindow->project()->options().cppCompilerCmd = ui->txtCPPCompiler->toPlainText();
pMainWindow->project()->options().linkerCmd = ui->txtLinker->toPlainText();
pMainWindow->project()->saveOptions();
}

View File

@ -2,21 +2,27 @@
#define PROJECTCOMPILEPARAMATERSWIDGET_H #define PROJECTCOMPILEPARAMATERSWIDGET_H
#include <QWidget> #include <QWidget>
#include "settingswidget.h"
namespace Ui { namespace Ui {
class ProjectCompileParamatersWidget; class ProjectCompileParamatersWidget;
} }
class ProjectCompileParamatersWidget : public QWidget class ProjectCompileParamatersWidget : public SettingsWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ProjectCompileParamatersWidget(QWidget *parent = nullptr); explicit ProjectCompileParamatersWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
~ProjectCompileParamatersWidget(); ~ProjectCompileParamatersWidget();
private: private:
Ui::ProjectCompileParamatersWidget *ui; Ui::ProjectCompileParamatersWidget *ui;
// SettingsWidget interface
protected:
void doLoad() override;
void doSave() override;
}; };
#endif // PROJECTCOMPILEPARAMATERSWIDGET_H #endif // PROJECTCOMPILEPARAMATERSWIDGET_H

View File

@ -36,9 +36,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTabWidget" name="txtLinker"> <widget class="QTabWidget" name="tabCommands">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@ -102,7 +102,7 @@
<number>5</number> <number>5</number>
</property> </property>
<item> <item>
<widget class="QPlainTextEdit" name="txtCCompiler_3"/> <widget class="QPlainTextEdit" name="txtLinker"/>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -0,0 +1,41 @@
#include "projectdirectorieswidget.h"
#include "ui_projectdirectorieswidget.h"
#include "compilersetdirectorieswidget.h"
#include "../project.h"
#include "../mainwindow.h"
ProjectDirectoriesWidget::ProjectDirectoriesWidget(const QString &name, const QString &group, QWidget *parent) :
SettingsWidget(name,group,parent),
ui(new Ui::ProjectDirectoriesWidget)
{
ui->setupUi(this);
mLibDirWidget = new CompilerSetDirectoriesWidget();
ui->tabDirs->addTab(mLibDirWidget,QObject::tr("Libraries"));
mIncludeDirWidget = new CompilerSetDirectoriesWidget();
ui->tabDirs->addTab(mIncludeDirWidget,QObject::tr("Includes"));
mResourceDirWidget = new CompilerSetDirectoriesWidget();
ui->tabDirs->addTab(mResourceDirWidget,QObject::tr("Resources"));
}
ProjectDirectoriesWidget::~ProjectDirectoriesWidget()
{
delete ui;
}
void ProjectDirectoriesWidget::doLoad()
{
mLibDirWidget->setDirList(pMainWindow->project()->options().libs);
mIncludeDirWidget->setDirList(pMainWindow->project()->options().includes);
mResourceDirWidget->setDirList(pMainWindow->project()->options().resourceIncludes);
}
void ProjectDirectoriesWidget::doSave()
{
pMainWindow->project()->options().libs = mLibDirWidget->dirList();
pMainWindow->project()->options().includes = mIncludeDirWidget->dirList();
pMainWindow->project()->options().resourceIncludes = mResourceDirWidget->dirList();
pMainWindow->project()->saveOptions();
}

View File

@ -0,0 +1,33 @@
#ifndef PROJECTDIRECTORIESWIDGET_H
#define PROJECTDIRECTORIESWIDGET_H
#include <QWidget>
#include "settingswidget.h"
#include "compilersetdirectorieswidget.h"
namespace Ui {
class ProjectDirectoriesWidget;
}
class CompilerSetDirectoriesWidget;
class ProjectDirectoriesWidget : public SettingsWidget
{
Q_OBJECT
public:
explicit ProjectDirectoriesWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
~ProjectDirectoriesWidget();
private:
Ui::ProjectDirectoriesWidget *ui;
CompilerSetDirectoriesWidget *mLibDirWidget;
CompilerSetDirectoriesWidget *mIncludeDirWidget;
CompilerSetDirectoriesWidget *mResourceDirWidget;
// SettingsWidget interface
protected:
void doLoad() override;
void doSave() override;
};
#endif // PROJECTDIRECTORIESWIDGET_H

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProjectDirectoriesWidget</class>
<widget class="QWidget" name="ProjectDirectoriesWidget">
<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="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTabWidget" name="tabDirs">
<property name="documentMode">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,44 @@
#include "projectprecompilewidget.h"
#include "ui_projectprecompilewidget.h"
#include "../mainwindow.h"
#include "../project.h"
#include <QFileDialog>
ProjectPreCompileWidget::ProjectPreCompileWidget(const QString &name, const QString &group, QWidget *parent) :
SettingsWidget(name,group,parent),
ui(new Ui::ProjectPreCompileWidget)
{
ui->setupUi(this);
}
ProjectPreCompileWidget::~ProjectPreCompileWidget()
{
delete ui;
}
void ProjectPreCompileWidget::doLoad()
{
ui->grpPrecompileHeader->setChecked(pMainWindow->project()->options().usePrecompiledHeader);
ui->txtPrecompileHeader->setText(pMainWindow->project()->options().precompiledHeader);
}
void ProjectPreCompileWidget::doSave()
{
pMainWindow->project()->options().usePrecompiledHeader = ui->grpPrecompileHeader->isChecked();
pMainWindow->project()->options().precompiledHeader = ui->txtPrecompileHeader->text();
pMainWindow->project()->saveOptions();
}
void ProjectPreCompileWidget::on_btnBrowse_triggered(QAction *arg1)
{
QString fileName = QFileDialog::getOpenFileName(
this,
tr("precompiled header"),
pMainWindow->project()->directory(),
tr("header files (*.h"));
if (!fileName.isEmpty() && QFileInfo(fileName).exists()) {
ui->txtPrecompileHeader->setText(fileName);
}
}

View File

@ -0,0 +1,30 @@
#ifndef PROJECTPRECOMPILEWIDGET_H
#define PROJECTPRECOMPILEWIDGET_H
#include <QWidget>
#include "settingswidget.h"
namespace Ui {
class ProjectPreCompileWidget;
}
class ProjectPreCompileWidget : public SettingsWidget
{
Q_OBJECT
public:
explicit ProjectPreCompileWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
~ProjectPreCompileWidget();
private:
Ui::ProjectPreCompileWidget *ui;
// SettingsWidget interface
protected:
void doLoad() override;
void doSave() override;
private slots:
void on_btnBrowse_triggered(QAction *arg1);
};
#endif // PROJECTPRECOMPILEWIDGET_H

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProjectPreCompileWidget</class>
<widget class="QWidget" name="ProjectPreCompileWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>741</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="grpPrecompileHeader">
<property name="title">
<string>Use precompiled header</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="txtPrecompileHeader"/>
</item>
<item>
<widget class="QToolButton" name="btnBrowse">
<property name="text">
<string>Browse</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/053-open.png</normalon>
</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;For more information about gcc precompiled header, see:&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -19,6 +19,9 @@
#include "projectgeneralwidget.h" #include "projectgeneralwidget.h"
#include "projectfileswidget.h" #include "projectfileswidget.h"
#include "projectcompilerwidget.h" #include "projectcompilerwidget.h"
#include "projectcompileparamaterswidget.h"
#include "projectdirectorieswidget.h"
#include "projectprecompilewidget.h"
#include <QDebug> #include <QDebug>
#include <QMessageBox> #include <QMessageBox>
#include <QModelIndex> #include <QModelIndex>
@ -163,6 +166,18 @@ PSettingsDialog SettingsDialog::projectOptionDialog()
widget->init(); widget->init();
dialog->addWidget(widget); dialog->addWidget(widget);
widget = new ProjectCompileParamatersWidget(tr("Custom Compile options"),tr("Project"));
widget->init();
dialog->addWidget(widget);
widget = new ProjectDirectoriesWidget(tr("Directories"),tr("Project"));
widget->init();
dialog->addWidget(widget);
widget = new ProjectPreCompileWidget(tr("Precompiled Header"),tr("Project"));
widget->init();
dialog->addWidget(widget);
dialog->selectFirstWidget(); dialog->selectFirstWidget();
return dialog; return dialog;