- enhancement: suppoort localization info in project templates
- change: template / project files use utf-8 encoding instead of ANSI
This commit is contained in:
parent
2d9472d179
commit
6bc943ba9c
5
NEWS.md
5
NEWS.md
|
@ -1,3 +1,8 @@
|
||||||
|
Red Panda C++ Version 0.13.1
|
||||||
|
- enhancement: suppoort localization info in project templates
|
||||||
|
- change: template / project files use utf-8 encoding instead of ANSI
|
||||||
|
|
||||||
|
|
||||||
Red Panda C++ Version 0.12.7
|
Red Panda C++ Version 0.12.7
|
||||||
- change: make current build system follow FHS specifications
|
- change: make current build system follow FHS specifications
|
||||||
- fix: crash when close settings dialog in Ubuntu 20.04 (but we'll leak memory now...)
|
- fix: crash when close settings dialog in Ubuntu 20.04 (but we'll leak memory now...)
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
ProjectTemplate::ProjectTemplate(QObject *parent) : QObject(parent)
|
ProjectTemplate::ProjectTemplate(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
@ -105,11 +106,20 @@ void ProjectTemplate::readTemplateFile(const QString &fileName)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString lang = pSettings->environment().language();
|
||||||
// template info
|
// template info
|
||||||
mDescription = fromByteArray(mIni->GetValue("Template", "Description", ""));
|
|
||||||
mIcon = fromByteArray(mIni->GetValue("Template", "Icon", ""));
|
mIcon = fromByteArray(mIni->GetValue("Template", "Icon", ""));
|
||||||
mCategory = fromByteArray(mIni->GetValue("Template", "Category", ""));
|
if (!lang.isEmpty()) {
|
||||||
mName = fromByteArray(mIni->GetValue("Template", "Name", ""));
|
mCategory = fromByteArray(mIni->GetValue("Template", QString("Category[%1]").arg(lang).toUtf8(), ""));
|
||||||
|
mName = fromByteArray(mIni->GetValue("Template", QString("Name[%1]").arg(lang).toUtf8(), ""));
|
||||||
|
mDescription = fromByteArray(mIni->GetValue("Template", QString("Description[%1]").arg(lang).toUtf8(), ""));
|
||||||
|
}
|
||||||
|
if (mCategory.isEmpty())
|
||||||
|
mCategory = fromByteArray(mIni->GetValue("Template", "Category", ""));
|
||||||
|
if (mName.isEmpty())
|
||||||
|
mName = fromByteArray(mIni->GetValue("Template", "Name", ""));
|
||||||
|
if (mDescription.isEmpty())
|
||||||
|
mDescription = fromByteArray(mIni->GetValue("Template", "Description", ""));
|
||||||
|
|
||||||
mOptions.icon = mIni->GetValue("Project", "Icon", "");
|
mOptions.icon = mIni->GetValue("Project", "Icon", "");
|
||||||
mOptions.type = static_cast<ProjectType>(mIni->GetLongValue("Project", "Type", 0)); // default = gui
|
mOptions.type = static_cast<ProjectType>(mIni->GetLongValue("Project", "Type", 0)); // default = gui
|
||||||
|
|
|
@ -776,12 +776,20 @@ QString extractFileDir(const QString &fileName)
|
||||||
|
|
||||||
QByteArray toByteArray(const QString &s)
|
QByteArray toByteArray(const QString &s)
|
||||||
{
|
{
|
||||||
return s.toLocal8Bit();
|
//return s.toLocal8Bit();
|
||||||
|
return s.toUtf8();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fromByteArray(const QByteArray &s)
|
QString fromByteArray(const QByteArray &s)
|
||||||
{
|
{
|
||||||
return QString::fromLocal8Bit(s);
|
QTextCodec* codec = QTextCodec::codecForName(ENCODING_UTF8);
|
||||||
|
QTextCodec::ConverterState state;
|
||||||
|
if (!codec)
|
||||||
|
return QString(s);
|
||||||
|
QString tmp = codec->toUnicode(s,s.length(),&state);
|
||||||
|
if (state.invalidChars>0)
|
||||||
|
tmp = QString::fromLocal8Bit(s);
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString linesToText(const QStringList &lines)
|
QString linesToText(const QStringList &lines)
|
||||||
|
|
|
@ -173,6 +173,7 @@ void NewProjectDialog::updateView()
|
||||||
icon,
|
icon,
|
||||||
t->name());
|
t->name());
|
||||||
}
|
}
|
||||||
|
item->setData(Qt::ToolTipRole,t->name());
|
||||||
item->setData(Qt::UserRole,i);
|
item->setData(Qt::UserRole,i);
|
||||||
ui->lstTemplates->addItem(item);
|
ui->lstTemplates->addItem(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,12 @@
|
||||||
<property name="viewMode">
|
<property name="viewMode">
|
||||||
<enum>QListView::IconMode</enum>
|
<enum>QListView::IconMode</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="uniformItemSizes">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="itemAlignment">
|
<property name="itemAlignment">
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
[Template]
|
[Template]
|
||||||
ver=1
|
ver=1
|
||||||
Name=Windows Application
|
Name=Windows Application
|
||||||
|
Name[zh_CN]=Windows应用程序
|
||||||
Icon=Windows.ico
|
Icon=Windows.ico
|
||||||
Description=A standard Windows application
|
Description=A standard Windows application
|
||||||
|
Description[zh_CN]=基于Windows API开发的图形界面应用程序
|
||||||
Category=Basic
|
Category=Basic
|
||||||
|
Category[zh_CN]=基础
|
||||||
|
|
||||||
[Unit0]
|
[Unit0]
|
||||||
CName=main.c
|
CName=main.c
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
[Template]
|
[Template]
|
||||||
ver=1
|
ver=1
|
||||||
Name=Console Application
|
Name=Console Application
|
||||||
|
Name[zh_CN]=控制台程序
|
||||||
Icon=ConsoleToo.ico
|
Icon=ConsoleToo.ico
|
||||||
Description=A console application (MS-DOS window)
|
Description=A console application (MS-DOS window)
|
||||||
|
Description[zh_CN]=控制台应用程序
|
||||||
Category=Basic
|
Category=Basic
|
||||||
|
Category[zh_CN]=基础
|
||||||
|
|
||||||
[Unit0]
|
[Unit0]
|
||||||
CName=main.c
|
CName=main.c
|
||||||
|
|
Loading…
Reference in New Issue