work save: project general option dialog

This commit is contained in:
royqh1979@gmail.com 2021-09-14 14:05:43 +08:00
parent 1a00443f89
commit 4e1cb482f9
5 changed files with 406 additions and 1 deletions

View File

@ -43,6 +43,7 @@ SOURCES += \
settingsdialog/editorcodecompletionwidget.cpp \
settingsdialog/editormiscwidget.cpp \
settingsdialog/formattergeneralwidget.cpp \
settingsdialog/projectgeneralwidget.cpp \
widgets/classbrowser.cpp \
widgets/codecompletionlistview.cpp \
widgets/codecompletionpopup.cpp \
@ -125,6 +126,7 @@ HEADERS += \
settingsdialog/editorcodecompletionwidget.h \
settingsdialog/editormiscwidget.h \
settingsdialog/formattergeneralwidget.h \
settingsdialog/projectgeneralwidget.h \
widgets/classbrowser.h \
widgets/codecompletionlistview.h \
widgets/codecompletionpopup.h \
@ -183,6 +185,7 @@ FORMS += \
settingsdialog/editorcodecompletionwidget.ui \
settingsdialog/editormiscwidget.ui \
settingsdialog/formattergeneralwidget.ui \
settingsdialog/projectgeneralwidget.ui \
widgets/cpudialog.ui \
mainwindow.ui \
settingsdialog/compilersetdirectorieswidget.ui \

View File

@ -326,10 +326,13 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
if (unit->encoding() == ENCODING_AUTO_DETECT) {
if (unit->editor() && unit->editor()->fileEncoding()!=ENCODING_ASCII)
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(unit->editor()->fileEncoding(),getDefaultSystemEncoding());
.arg(unit->editor()->fileEncoding(),getDefaultSystemEncoding());
} else if (unit->encoding()!=ENCODING_ASCII) {
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(unit->encoding(),getDefaultSystemEncoding());
} else if (unit->encoding()!=ENCODING_SYSTEM_DEFAULT) {
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(getDefaultSystemEncoding(),getDefaultSystemEncoding());
}
}

View File

@ -0,0 +1,74 @@
#include "projectgeneralwidget.h"
#include "ui_projectgeneralwidget.h"
#include "../project.h"
#include "../mainwindow.h"
#include <QIcon>
#include <QTextCodec>
ProjectGeneralWidget::ProjectGeneralWidget(const QString &name, const QString &group, QWidget *parent) :
SettingsWidget(name,group,parent),
ui(new Ui::ProjectGeneralWidget)
{
ui->setupUi(this);
}
ProjectGeneralWidget::~ProjectGeneralWidget()
{
delete ui;
}
void ProjectGeneralWidget::doLoad()
{
std::shared_ptr<Project> project = pMainWindow->project();
if (!project)
return;
ui->txtName->setText(project->name());
ui->txtFileName->setText(project->filename());
ui->txtOutputFile->setText(project->executable());
int srcCount=0,headerCount=0,resCount=0,otherCount=0, totalCount=0;
foreach (const PProjectUnit& unit, project->units()) {
switch(getFileType(unit->fileName())) {
case FileType::CSource:
case FileType::CppSource:
srcCount++;
break;
case FileType::CppHeader:
case FileType::CHeader:
headerCount++;
break;
case FileType::WindowsResourceSource:
resCount++;
break;
default:
otherCount++;
}
totalCount++;
}
ui->lblFiles->setText(tr("%1 files [ %2 sources, %3 headers, %4 resources, %5 other files ]")
.arg(totalCount).arg(srcCount).arg(headerCount)
.arg(resCount).arg(otherCount));
ui->cbDefaultEncoding->addItem(ENCODING_AUTO_DETECT);
ui->cbDefaultEncoding->addItem(ENCODING_SYSTEM_DEFAULT);
ui->cbDefaultEncoding->addItem(ENCODING_UTF8);
foreach (const QByteArray& name, QTextCodec::availableCodecs()){
if (name == "system")
continue;
if (name == "utf-8")
continue;
ui->cbDefaultEncoding->addItem(name);
}
ui->cbDefaultEncoding->setCurrentText(project->options().encoding);
ui->lstType->setCurrentRow( static_cast<int>(project->options().type));
ui->cbDefaultCpp->setChecked(project->options().useGPP);
ui->cbSupportXPTheme->setChecked(project->options().supportXPThemes);
mIconPath = project->options().icon;
if (!mIconPath.isEmpty()) {
QPixmap icon(project->options().icon);
ui->lblICon->setPixmap(icon);
}
}

View File

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

View File

@ -0,0 +1,296 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProjectGeneralWidget</class>
<widget class="QWidget" name="ProjectGeneralWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>674</width>
<height>639</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QLineEdit" name="txtFileName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>File Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="txtName"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="txtOutputFile">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Files:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="cbDefaultEncoding"/>
</item>
<item row="3" column="1">
<widget class="QLabel" name="lblFiles">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Default encoding:</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Icon</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="1">
<widget class="QPushButton" name="btnRemove">
<property name="text">
<string>Remove</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/images/newlook24/011-clrhist.png</normaloff>:/icons/images/newlook24/011-clrhist.png</iconset>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="btnLibrary">
<property name="text">
<string>Library</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/005-arricon.png</normalon>
</iconset>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="3">
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblICon">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" 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="QGroupBox" name="groupBox">
<property name="title">
<string>Type</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="lstType">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="resizeMode">
<enum>QListView::Fixed</enum>
</property>
<property name="layoutMode">
<enum>QListView::SinglePass</enum>
</property>
<property name="viewMode">
<enum>QListView::ListMode</enum>
</property>
<item>
<property name="text">
<string>Win32 GUI</string>
</property>
</item>
<item>
<property name="text">
<string>Win32 Console</string>
</property>
</item>
<item>
<property name="text">
<string>Win32 Static Library</string>
</property>
</item>
<item>
<property name="text">
<string>Win32 DLL</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbDefaultCpp">
<property name="text">
<string>Default to C++ when creating new files</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbSupportXPTheme">
<property name="text">
<string>Support Windows XP Themes</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Output File:</string>
</property>
</widget>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>