work save:
- fix: left panel size not correctly saved - fix: cant run programs not statically linked - project files option widget
This commit is contained in:
parent
bf71340233
commit
6fc5f5995f
|
@ -4,6 +4,8 @@
|
|||
#include <windows.h>
|
||||
#include <QDebug>
|
||||
#include "compilermanager.h"
|
||||
#include "../settings.h"
|
||||
#include "../systemconsts.h"
|
||||
|
||||
ExecutableRunner::ExecutableRunner(const QString &filename, const QString &arguments, const QString &workDir):
|
||||
QThread(),
|
||||
|
@ -30,6 +32,22 @@ void ExecutableRunner::run()
|
|||
process.setProgram(mFilename);
|
||||
process.setArguments(QProcess::splitCommand(mArguments));
|
||||
process.setWorkingDirectory(mWorkDir);
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
QString path = env.value("PATH");
|
||||
QStringList pathAdded;
|
||||
if (pSettings->compilerSets().defaultSet()) {
|
||||
foreach(const QString& dir, pSettings->compilerSets().defaultSet()->binDirs()) {
|
||||
pathAdded.append(dir);
|
||||
}
|
||||
}
|
||||
pathAdded.append(pSettings->dirs().app());
|
||||
if (!path.isEmpty()) {
|
||||
path+= PATH_SEPARATOR + pathAdded.join(PATH_SEPARATOR);
|
||||
} else {
|
||||
path = pathAdded.join(PATH_SEPARATOR);
|
||||
}
|
||||
env.insert("PATH",path);
|
||||
process.setProcessEnvironment(env);
|
||||
process.setCreateProcessArgumentsModifier([](QProcess::CreateProcessArguments * args){
|
||||
args->flags |= CREATE_NEW_CONSOLE;
|
||||
args->startupInfo -> dwFlags &= ~STARTF_USESTDHANDLES;
|
||||
|
@ -60,6 +78,7 @@ void ExecutableRunner::run()
|
|||
break;
|
||||
}
|
||||
if (errorOccurred) {
|
||||
qDebug()<<"process error:"<<process.error();
|
||||
switch (process.error()) {
|
||||
case QProcess::FailedToStart:
|
||||
emit runErrorOccurred(tr("The runner process '%1' failed to start.").arg(mFilename));
|
||||
|
|
|
@ -2655,7 +2655,7 @@ void MainWindow::on_tabInfos_tabBarClicked(int index)
|
|||
|
||||
void MainWindow::on_splitterInfos_splitterMoved(int, int)
|
||||
{
|
||||
QList<int> sizes = ui->splitterMessages->sizes();
|
||||
QList<int> sizes = ui->splitterInfos->sizes();
|
||||
mLeftPanelWidth = sizes[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ QT_BEGIN_NAMESPACE
|
|||
namespace Ui { class MainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
enum class CompileTarget {
|
||||
Invalid, None, File, Project, SyntaxCheck
|
||||
};
|
||||
|
|
|
@ -68,13 +68,13 @@ void CppParser::addHardDefineByLine(const QString &line)
|
|||
void CppParser::addIncludePath(const QString &value)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
mPreprocessor.includePaths().insert(value);
|
||||
mPreprocessor.includePaths().insert(includeTrailingPathDelimiter(value));
|
||||
}
|
||||
|
||||
void CppParser::addProjectIncludePath(const QString &value)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
mPreprocessor.projectIncludePaths().insert(value);
|
||||
mPreprocessor.projectIncludePaths().insert(includeTrailingPathDelimiter(value));
|
||||
}
|
||||
|
||||
void CppParser::clearIncludePaths()
|
||||
|
|
|
@ -369,7 +369,7 @@ bool isSystemHeaderFile(const QString &fileName, const QSet<QString> &includePat
|
|||
QFileInfo info(fileName);
|
||||
if (info.exists()) { // full file name
|
||||
QDir dir = info.dir();
|
||||
QString absPath = excludeTrailingPathDelimiter(dir.absolutePath());
|
||||
QString absPath = includeTrailingPathDelimiter(dir.absolutePath());
|
||||
foreach (const QString& incPath, includePaths) {
|
||||
if (absPath.startsWith(incPath))
|
||||
return true;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include "projectfileswidget.h"
|
||||
#include "ui_projectfileswidget.h"
|
||||
#include "../mainwindow.h"
|
||||
#include "../systemconsts.h"
|
||||
|
||||
ProjectFilesWidget::ProjectFilesWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ProjectFilesWidget::ProjectFilesWidget(const QString &name, const QString &group, QWidget *parent) :
|
||||
SettingsWidget(name,group,parent),
|
||||
ui(new Ui::ProjectFilesWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -12,3 +14,161 @@ ProjectFilesWidget::~ProjectFilesWidget()
|
|||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ProjectFilesWidget::doLoad()
|
||||
{
|
||||
std::shared_ptr<Project> project = pMainWindow->project();
|
||||
if (!project)
|
||||
return;
|
||||
mUnits.clear();
|
||||
foreach (const PProjectUnit& unit, project->units()) {
|
||||
PProjectUnit unitCopy = std::make_shared<ProjectUnit>(project.get());
|
||||
unitCopy->setPriority(unit->priority());
|
||||
unitCopy->setCompile(unit->compile());
|
||||
unitCopy->setLink(unit->link());
|
||||
unitCopy->setCompileCpp(unit->compileCpp());
|
||||
unitCopy->setOverrideBuildCmd(unit->overrideBuildCmd());
|
||||
unitCopy->setBuildCmd(unit->buildCmd());
|
||||
unitCopy->setEncoding(unit->encoding());
|
||||
mUnits.append(unitCopy);
|
||||
}
|
||||
ui->treeProject->setModel(project->model());
|
||||
ui->treeProject->expandAll();
|
||||
ui->grpFileOptions->setEnabled(false);
|
||||
ui->spinPriority->setMinimum(0);
|
||||
ui->spinPriority->setMaximum(9999);
|
||||
ui->cbEncoding->addItems(pSystemConsts->codecNames());
|
||||
}
|
||||
|
||||
void ProjectFilesWidget::doSave()
|
||||
{
|
||||
for (int i=0;i<mUnits.count();i++) {
|
||||
PProjectUnit unitCopy = mUnits[i];
|
||||
PProjectUnit unit = pMainWindow->project()->units()[i];
|
||||
unit->setPriority(unitCopy->priority());
|
||||
unit->setCompile(unitCopy->compile());
|
||||
unit->setLink(unitCopy->link());
|
||||
unit->setCompileCpp(unitCopy->compileCpp());
|
||||
unit->setOverrideBuildCmd(unitCopy->overrideBuildCmd());
|
||||
unit->setBuildCmd(unitCopy->buildCmd());
|
||||
unit->setEncoding(unitCopy->encoding());
|
||||
}
|
||||
pMainWindow->project()->sortUnitsByPriority();
|
||||
pMainWindow->project()->saveUnits();
|
||||
}
|
||||
|
||||
PProjectUnit ProjectFilesWidget::currentUnit()
|
||||
{
|
||||
QModelIndex index = ui->treeProject->currentIndex();
|
||||
if (!index.isValid())
|
||||
return PProjectUnit();
|
||||
FolderNode* node = static_cast<FolderNode*>(index.internalPointer());
|
||||
if (!node)
|
||||
return PProjectUnit();
|
||||
int i = node->unitIndex;
|
||||
if (i>=0) {
|
||||
return mUnits[i];
|
||||
} else
|
||||
return PProjectUnit();
|
||||
}
|
||||
|
||||
void ProjectFilesWidget::on_treeProject_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return ;
|
||||
FolderNode* node = static_cast<FolderNode*>(index.internalPointer());
|
||||
if (!node)
|
||||
return;
|
||||
int i = node->unitIndex;
|
||||
if (i>=0) {
|
||||
PProjectUnit unit = mUnits[i];
|
||||
ui->grpFileOptions->setEnabled(true);
|
||||
ui->spinPriority->setValue(unit->priority());
|
||||
ui->chkCompile->setChecked(unit->compile());
|
||||
ui->chkLink->setChecked(unit->link());
|
||||
ui->chkCompileAsCPP->setChecked(unit->compileCpp());
|
||||
ui->chkOverrideBuildCommand->setChecked(unit->overrideBuildCmd());
|
||||
ui->txtBuildCommand->setPlainText(unit->buildCmd());
|
||||
ui->txtBuildCommand->setEnabled(ui->chkOverrideBuildCommand->isChecked());
|
||||
ui->cbEncoding->setCurrentText(unit->encoding());
|
||||
} else {
|
||||
ui->grpFileOptions->setEnabled(false);
|
||||
ui->spinPriority->setValue(0);
|
||||
ui->chkCompile->setChecked(false);
|
||||
ui->chkLink->setChecked(false);
|
||||
ui->chkCompileAsCPP->setChecked(false);
|
||||
ui->chkOverrideBuildCommand->setChecked(false);
|
||||
ui->txtBuildCommand->setPlainText("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesWidget::on_spinPriority_valueChanged(int)
|
||||
{
|
||||
PProjectUnit unit = currentUnit();
|
||||
if(!unit)
|
||||
return;
|
||||
unit->setPriority(ui->spinPriority->value());
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesWidget::on_chkCompile_stateChanged(int)
|
||||
{
|
||||
PProjectUnit unit = currentUnit();
|
||||
if(!unit)
|
||||
return;
|
||||
unit->setCompile(ui->chkCompile->isChecked());
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesWidget::on_chkLink_stateChanged(int)
|
||||
{
|
||||
PProjectUnit unit = currentUnit();
|
||||
if(!unit)
|
||||
return;
|
||||
unit->setLink(ui->chkLink->isChecked());
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesWidget::on_chkCompileAsCPP_stateChanged(int )
|
||||
{
|
||||
PProjectUnit unit = currentUnit();
|
||||
if(!unit)
|
||||
return;
|
||||
unit->setCompileCpp(ui->chkCompileAsCPP->isChecked());
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesWidget::on_chkOverrideBuildCommand_stateChanged(int )
|
||||
{
|
||||
PProjectUnit unit = currentUnit();
|
||||
if(!unit)
|
||||
return;
|
||||
unit->setOverrideBuildCmd(ui->chkOverrideBuildCommand->isChecked());
|
||||
ui->txtBuildCommand->setEnabled(ui->chkOverrideBuildCommand->isChecked());
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesWidget::on_txtBuildCommand_textChanged()
|
||||
{
|
||||
PProjectUnit unit = currentUnit();
|
||||
if(!unit)
|
||||
return;
|
||||
unit->setBuildCmd(ui->txtBuildCommand->toPlainText());
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesWidget::on_cbEncoding_currentTextChanged(const QString &)
|
||||
{
|
||||
PProjectUnit unit = currentUnit();
|
||||
if(!unit)
|
||||
return;
|
||||
unit->setEncoding(ui->cbEncoding->currentText().toLocal8Bit());
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesWidget::on_treeProject_clicked(const QModelIndex &index)
|
||||
{
|
||||
on_treeProject_doubleClicked(index);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,22 +2,42 @@
|
|||
#define PROJECTFILESWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "settings.h"
|
||||
#include "../project.h"
|
||||
#include "settingswidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class ProjectFilesWidget;
|
||||
}
|
||||
|
||||
class ProjectFilesWidget : public Settings
|
||||
class ProjectFilesWidget : public SettingsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ProjectFilesWidget(QWidget *parent = nullptr);
|
||||
explicit ProjectFilesWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
||||
~ProjectFilesWidget();
|
||||
|
||||
private:
|
||||
Ui::ProjectFilesWidget *ui;
|
||||
QList<PProjectUnit> mUnits;
|
||||
|
||||
|
||||
// SettingsWidget interface
|
||||
protected:
|
||||
void doLoad() override;
|
||||
void doSave() override;
|
||||
private:
|
||||
PProjectUnit currentUnit();
|
||||
private slots:
|
||||
void on_treeProject_doubleClicked(const QModelIndex &index);
|
||||
void on_spinPriority_valueChanged(int arg1);
|
||||
void on_chkCompile_stateChanged(int arg1);
|
||||
void on_chkLink_stateChanged(int arg1);
|
||||
void on_chkCompileAsCPP_stateChanged(int arg1);
|
||||
void on_chkOverrideBuildCommand_stateChanged(int arg1);
|
||||
void on_txtBuildCommand_textChanged();
|
||||
void on_cbEncoding_currentTextChanged(const QString &arg1);
|
||||
void on_treeProject_clicked(const QModelIndex &index);
|
||||
};
|
||||
|
||||
#endif // PROJECTFILESWIDGET_H
|
||||
|
|
|
@ -26,8 +26,11 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<widget class="QGroupBox" name="grpFileOptions">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
#include "ui_projectgeneralwidget.h"
|
||||
#include "../project.h"
|
||||
#include "../mainwindow.h"
|
||||
#include "settings.h"
|
||||
#include "../systemconsts.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QIcon>
|
||||
#include <QTextCodec>
|
||||
|
||||
|
@ -50,32 +53,7 @@ void ProjectGeneralWidget::doLoad()
|
|||
.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);
|
||||
QList<QByteArray> codecNames;
|
||||
QSet<QByteArray> codecAlias;
|
||||
codecAlias.insert("system");
|
||||
codecAlias.insert("utf-8");
|
||||
|
||||
foreach (const QByteArray& name, QTextCodec::availableCodecs()){
|
||||
QByteArray lname = name.toLower();
|
||||
if (lname.startsWith("cp"))
|
||||
continue;
|
||||
if (codecAlias.contains(lname))
|
||||
continue;
|
||||
codecNames.append(lname);
|
||||
QTextCodec* codec = QTextCodec::codecForName(name);
|
||||
if (codec) {
|
||||
foreach (const QByteArray& alias, codec->aliases()) {
|
||||
codecAlias.insert(alias.toLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
std::sort(codecNames.begin(),codecNames.end());
|
||||
foreach (const QByteArray& name,codecNames) {
|
||||
ui->cbDefaultEncoding->addItem(name);
|
||||
}
|
||||
ui->cbDefaultEncoding->addItems(pSystemConsts->codecNames());
|
||||
ui->cbDefaultEncoding->setCurrentText(project->options().encoding);
|
||||
|
||||
ui->lstType->setCurrentRow( static_cast<int>(project->options().type));
|
||||
|
@ -84,9 +62,10 @@ void ProjectGeneralWidget::doLoad()
|
|||
ui->cbSupportXPTheme->setChecked(project->options().supportXPThemes);
|
||||
mIconPath = project->options().icon;
|
||||
if (!mIconPath.isEmpty()) {
|
||||
QPixmap icon(project->options().icon);
|
||||
QPixmap icon(mIconPath);
|
||||
ui->lblICon->setPixmap(icon);
|
||||
}
|
||||
ui->btnRemove->setEnabled(!mIconPath.isEmpty());
|
||||
}
|
||||
|
||||
void ProjectGeneralWidget::doSave()
|
||||
|
@ -106,3 +85,27 @@ void ProjectGeneralWidget::doSave()
|
|||
project->options().icon = mIconPath;
|
||||
project->saveOptions();
|
||||
}
|
||||
|
||||
void ProjectGeneralWidget::on_btnBrowse_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Select icon file"),
|
||||
pSettings->dirs().app(),
|
||||
tr("Icon Files (*.ico)"));
|
||||
if (!fileName.isEmpty()) {
|
||||
mIconPath = fileName;
|
||||
QPixmap icon(mIconPath);
|
||||
ui->lblICon->setPixmap(icon);
|
||||
setSettingsChanged();
|
||||
}
|
||||
ui->btnRemove->setEnabled(!mIconPath.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
void ProjectGeneralWidget::on_btnRemove_clicked()
|
||||
{
|
||||
mIconPath = "";
|
||||
ui->lblICon->setPixmap(QPixmap());
|
||||
ui->btnRemove->setEnabled(!mIconPath.isEmpty());
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ private:
|
|||
protected:
|
||||
void doLoad() override;
|
||||
void doSave() override;
|
||||
private slots:
|
||||
void on_btnBrowse_clicked();
|
||||
void on_btnRemove_clicked();
|
||||
};
|
||||
|
||||
#endif // PROJECTGENERALWIDGET_H
|
||||
|
|
|
@ -97,30 +97,7 @@
|
|||
<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">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
|
@ -140,16 +117,19 @@
|
|||
<widget class="QLabel" name="lblICon">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
<width>128</width>
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -169,6 +149,17 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" 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="btnBrowse">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
|
@ -180,6 +171,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<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>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "debuggeneralwidget.h"
|
||||
#include "formattergeneralwidget.h"
|
||||
#include "projectgeneralwidget.h"
|
||||
#include "projectfileswidget.h"
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QModelIndex>
|
||||
|
@ -153,6 +154,10 @@ PSettingsDialog SettingsDialog::projectOptionDialog()
|
|||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new ProjectFilesWidget(tr("Files"),tr("Project"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
dialog->selectFirstWidget();
|
||||
|
||||
return dialog;
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#include "systemconsts.h"
|
||||
#include "utils.h"
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QTextCodec>
|
||||
|
||||
SystemConsts* pSystemConsts;
|
||||
|
||||
|
@ -12,6 +15,34 @@ SystemConsts::SystemConsts(): mDefaultFileFilters()
|
|||
addDefaultFileFilter(QObject::tr("C files"),"*.c");
|
||||
addDefaultFileFilter(QObject::tr("C++ files"),"*.cpp *.cc *.cxx");
|
||||
addDefaultFileFilter(QObject::tr("Header files"),"*.h *.hh");
|
||||
|
||||
addFileFilter(mIconFileFilters, QObject::tr("Icon files"), "*.ico");
|
||||
|
||||
mCodecNames.append(ENCODING_AUTO_DETECT);
|
||||
mCodecNames.append(ENCODING_SYSTEM_DEFAULT);
|
||||
mCodecNames.append(ENCODING_UTF8);
|
||||
QStringList codecNames;
|
||||
QSet<QByteArray> codecAlias;
|
||||
codecAlias.insert("system");
|
||||
codecAlias.insert("utf-8");
|
||||
|
||||
foreach (const QByteArray& name, QTextCodec::availableCodecs()){
|
||||
QByteArray lname = name.toLower();
|
||||
if (lname.startsWith("cp"))
|
||||
continue;
|
||||
if (codecAlias.contains(lname))
|
||||
continue;
|
||||
codecNames.append(lname);
|
||||
codecAlias.insert(lname);
|
||||
QTextCodec* codec = QTextCodec::codecForName(name);
|
||||
if (codec) {
|
||||
foreach (const QByteArray& alias, codec->aliases()) {
|
||||
codecAlias.insert(alias.toLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
std::sort(codecNames.begin(),codecNames.end());
|
||||
mCodecNames.append(codecNames);
|
||||
}
|
||||
|
||||
const QStringList &SystemConsts::defaultFileFilters() const noexcept
|
||||
|
@ -36,5 +67,30 @@ const QString &SystemConsts::defaultAllFileFilter() const noexcept
|
|||
|
||||
void SystemConsts::addDefaultFileFilter(const QString &name, const QString &fileExtensions)
|
||||
{
|
||||
mDefaultFileFilters.append(name+ " (" + fileExtensions+")");
|
||||
addFileFilter(mDefaultFileFilters,name,fileExtensions);
|
||||
}
|
||||
|
||||
void SystemConsts::addFileFilter(QStringList filters, const QString &name, const QString &fileExtensions)
|
||||
{
|
||||
filters.append(name+ " (" + fileExtensions+")");
|
||||
}
|
||||
|
||||
const QStringList &SystemConsts::codecNames() const
|
||||
{
|
||||
return mCodecNames;
|
||||
}
|
||||
|
||||
const QStringList &SystemConsts::iconFileFilters() const
|
||||
{
|
||||
return mIconFileFilters;
|
||||
}
|
||||
|
||||
const QString &SystemConsts::iconFileFilter() const
|
||||
{
|
||||
return mIconFileFilters[0];
|
||||
}
|
||||
|
||||
void SystemConsts::setIconFileFilters(const QStringList &newIconFileFilters)
|
||||
{
|
||||
mIconFileFilters = newIconFileFilters;
|
||||
}
|
||||
|
|
|
@ -59,8 +59,17 @@ public:
|
|||
const QString& defaultCPPFileFilter() const noexcept;
|
||||
const QString& defaultAllFileFilter() const noexcept;
|
||||
void addDefaultFileFilter(const QString& name, const QString& fileExtensions);
|
||||
const QStringList &iconFileFilters() const;
|
||||
const QString& iconFileFilter() const;
|
||||
void setIconFileFilters(const QStringList &newIconFileFilters);
|
||||
|
||||
const QStringList &codecNames() const;
|
||||
|
||||
private:
|
||||
void addFileFilter(QStringList filters, const QString& name, const QString& fileExtensions);
|
||||
QStringList mDefaultFileFilters;
|
||||
QStringList mIconFileFilters;
|
||||
QStringList mCodecNames;
|
||||
};
|
||||
|
||||
extern SystemConsts* pSystemConsts;
|
||||
|
|
Loading…
Reference in New Issue