* options dialog
This commit is contained in:
parent
c85130ea76
commit
fb2ed9b84e
|
@ -13,8 +13,11 @@ SOURCES += \
|
|||
editorlist.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
settingsdialog/compilersetdirectorieswidget.cpp \
|
||||
settingsdialog/compilersetoptionwidget.cpp \
|
||||
settings.cpp \
|
||||
settingsdialog.cpp \
|
||||
settingsdialog/settingsdialog.cpp \
|
||||
settingsdialog/settingswidget.cpp \
|
||||
systemconsts.cpp \
|
||||
utils.cpp
|
||||
|
||||
|
@ -22,14 +25,19 @@ HEADERS += \
|
|||
editor.h \
|
||||
editorlist.h \
|
||||
mainwindow.h \
|
||||
settingsdialog/compilersetdirectorieswidget.h \
|
||||
settingsdialog/compilersetoptionwidget.h \
|
||||
settings.h \
|
||||
settingsdialog.h \
|
||||
settingsdialog/settingsdialog.h \
|
||||
settingsdialog/settingswidget.h \
|
||||
systemconsts.h \
|
||||
utils.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
settingsdialog.ui
|
||||
settingsdialog/compilersetdirectorieswidget.ui \
|
||||
settingsdialog/compilersetoptionwidget.ui \
|
||||
settingsdialog/settingsdialog.ui
|
||||
|
||||
TRANSLATIONS += \
|
||||
RedPandaIDE_zh_CN.ts
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <QFileDialog>
|
||||
#include <QLabel>
|
||||
|
||||
#include <settingsdialog/settingsdialog.h>
|
||||
|
||||
MainWindow* pMainWindow;
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
|
@ -131,3 +133,9 @@ void MainWindow::on_actionSaveAs_triggered()
|
|||
editor->saveAs();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionOptions_triggered()
|
||||
{
|
||||
SettingsDialog settingsDialog;
|
||||
settingsDialog.exec();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ private slots:
|
|||
|
||||
void on_actionSaveAs_triggered();
|
||||
|
||||
void on_actionOptions_triggered();
|
||||
|
||||
private:
|
||||
void setupActions();
|
||||
|
||||
|
|
|
@ -193,9 +193,16 @@
|
|||
<addaction name="separator"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSaveAs"/>
|
||||
<addaction name="actionSave_All"/>
|
||||
<addaction name="actionSaveAll"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTools">
|
||||
<property name="title">
|
||||
<string>Tools</string>
|
||||
</property>
|
||||
<addaction name="actionOptions"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuTools"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
|
@ -211,7 +218,7 @@
|
|||
<addaction name="actionNew"/>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSave_All"/>
|
||||
<addaction name="actionSaveAll"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar_2">
|
||||
<property name="windowTitle">
|
||||
|
@ -276,7 +283,7 @@
|
|||
<string>Save As</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_All">
|
||||
<action name="actionSaveAll">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/images/newlook24/071-saveall.png</normalon>
|
||||
|
@ -289,6 +296,11 @@
|
|||
<string>Ctrl+Shift+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOptions">
|
||||
<property name="text">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -223,6 +223,11 @@ void Settings::CompilerSet::setOption(PCompilerOption &option, char valueChar)
|
|||
option->value = charToValue(valueChar);
|
||||
}
|
||||
|
||||
bool Settings::CompilerSet::dirsValid(QString &msg)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const QString &Settings::CompilerSet::CCompilerName() const
|
||||
{
|
||||
return mCCompilerName;
|
||||
|
@ -987,6 +992,28 @@ void Settings::CompilerSets::loadSets()
|
|||
PCompilerSet pSet=loadSet(i);
|
||||
mList.push_back(pSet);
|
||||
}
|
||||
|
||||
PCompilerSet pCurrentSet = defaultSet();
|
||||
if (pCurrentSet) {
|
||||
QString msg;
|
||||
if (!pCurrentSet->dirsValid(msg)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::CompilerSets::deleteSet(int index)
|
||||
{
|
||||
// Erase all sections at and above from disk
|
||||
for (int i=index;i<mList.size();i++) {
|
||||
mSettings->mSettings.beginGroup(QString(SETTING_COMPILTER_SET).arg(i));
|
||||
mSettings->mSettings.remove("");
|
||||
mSettings->mSettings.endGroup();
|
||||
}
|
||||
mList.erase(std::begin(mList)+index);
|
||||
for (int i=index;i<mList.size();i++) {
|
||||
saveSet(i);
|
||||
}
|
||||
}
|
||||
|
||||
Settings::CompilerSetList &Settings::CompilerSets::list()
|
||||
|
@ -1009,6 +1036,14 @@ void Settings::CompilerSets::setDefaultIndex(int value)
|
|||
mDefaultIndex = value;
|
||||
}
|
||||
|
||||
Settings::PCompilerSet Settings::CompilerSets::defaultSet()
|
||||
{
|
||||
if (mDefaultIndex>=0 && mDefaultIndex<mList.size()) {
|
||||
return mList[mDefaultIndex];
|
||||
}
|
||||
return PCompilerSet();
|
||||
}
|
||||
|
||||
void Settings::CompilerSets::saveSet(int index)
|
||||
{
|
||||
PCompilerSet pSet = mList[index];
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
CompilerSet& operator= (const CompilerSet& ) = delete;
|
||||
CompilerSet& operator= (const CompilerSet&& ) = delete;
|
||||
|
||||
//properties
|
||||
|
||||
void addOption(const QString& name, const QString section, bool isC,
|
||||
bool isCpp, bool isLinker,
|
||||
int value, const QString& setting,
|
||||
|
@ -88,6 +88,8 @@ public:
|
|||
void setOption(const QString& setting, char valueChar);
|
||||
void setOption(PCompilerOption& option, char valueChar);
|
||||
|
||||
bool dirsValid(QString& msg);
|
||||
//properties
|
||||
const QString& CCompilerName() const;
|
||||
void setCCompilerName(const QString& name);
|
||||
const QString& cppCompilerName() const;
|
||||
|
@ -202,11 +204,13 @@ public:
|
|||
void findSets();
|
||||
void saveSets();
|
||||
void loadSets();
|
||||
void deleteSet(int index);
|
||||
//properties
|
||||
CompilerSetList& list();
|
||||
int size() const;
|
||||
int defaultIndex() const;
|
||||
void setDefaultIndex(int value);
|
||||
PCompilerSet defaultSet();
|
||||
private:
|
||||
void saveSet(int index);
|
||||
PCompilerSet loadSet(int index);
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
#include "settingsdialog.h"
|
||||
#include "ui_settingsdialog.h"
|
||||
|
||||
SettingsDialog::SettingsDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::SettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
SettingsDialog::~SettingsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef SETTINGSDIALOG_H
|
||||
#define SETTINGSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class SettingsDialog;
|
||||
}
|
||||
|
||||
class SettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsDialog(QWidget *parent = nullptr);
|
||||
~SettingsDialog();
|
||||
|
||||
private:
|
||||
Ui::SettingsDialog *ui;
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
|
@ -1,150 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SettingsDialog</class>
|
||||
<widget class="QDialog" name="SettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>977</width>
|
||||
<height>622</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListView" name="listView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame_3">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>192</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="text">
|
||||
<string>Cancle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -0,0 +1,64 @@
|
|||
#include "settingswidget.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QLineEdit>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
SettingsWidget::SettingsWidget(const QString &name, const QString &group, QWidget *parent):
|
||||
QWidget(parent),
|
||||
mName(name),
|
||||
mGroup(group)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SettingsWidget::init()
|
||||
{
|
||||
load();
|
||||
for (QLineEdit* p:findChildren<QLineEdit*>()) {
|
||||
connect(p, &QLineEdit::textChanged, this, &SettingsWidget::setSettingsChanged);
|
||||
}
|
||||
for (QCheckBox* p:findChildren<QCheckBox*>()) {
|
||||
connect(p, &QCheckBox::stateChanged, this, &SettingsWidget::setSettingsChanged);
|
||||
}
|
||||
for (QPlainTextEdit* p:findChildren<QPlainTextEdit*>()) {
|
||||
connect(p, &QPlainTextEdit::textChanged, this, &SettingsWidget::setSettingsChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsWidget::load()
|
||||
{
|
||||
doLoad();
|
||||
mSettingsChanged = false;
|
||||
}
|
||||
|
||||
void SettingsWidget::save()
|
||||
{
|
||||
doSave();
|
||||
mSettingsChanged = false;
|
||||
}
|
||||
|
||||
const QString &SettingsWidget::group()
|
||||
{
|
||||
return mGroup;
|
||||
}
|
||||
|
||||
const QString &SettingsWidget::name()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
bool SettingsWidget::settingsChanged()
|
||||
{
|
||||
return mSettingsChanged;
|
||||
}
|
||||
|
||||
void SettingsWidget::setSettingsChanged()
|
||||
{
|
||||
mSettingsChanged = true;
|
||||
}
|
||||
|
||||
void SettingsWidget::clearSettingsChanged()
|
||||
{
|
||||
mSettingsChanged = false;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef SETTINGSWIDGET_H
|
||||
#define SETTINGSWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class SettingsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SettingsWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
||||
|
||||
virtual void init();
|
||||
|
||||
void load();
|
||||
void save();
|
||||
signals:
|
||||
|
||||
protected:
|
||||
virtual void doLoad() = 0;
|
||||
virtual void doSave() = 0;
|
||||
public:
|
||||
const QString& group();
|
||||
const QString& name();
|
||||
bool settingsChanged();
|
||||
public slots:
|
||||
void setSettingsChanged();
|
||||
void clearSettingsChanged();
|
||||
private:
|
||||
bool mSettingsChanged;
|
||||
QString mGroup;
|
||||
QString mName;
|
||||
};
|
||||
|
||||
#endif // SETTINGSWIDGET_H
|
Loading…
Reference in New Issue