Compare commits

..

72 Commits

Author SHA1 Message Date
shouchih_chen
74c515f78a 1. Adjust name start posY -10 pixel in customlogo.cpp 2. fix two word name issue. 2024-10-05 06:31:20 +08:00
shouchih_chen
60ecafb424 1. Add QScrollArea to fit any screen size. 2024-09-28 10:57:49 +08:00
shouchih_chen
0e9e58a389 1. fix QNetworkRequest url is empty issue. 2. release version 2.9.0 2024-09-27 11:42:19 +08:00
shouchih_chen
7aa79287c8 1. 增加動態字形 2. fix color dialog issue in webassembly. 2024-09-27 10:17:26 +08:00
shouchih_chen
40d41b36e2 1. Add custom logo can export double name 2. add color selector for custom logo. 2024-09-26 15:20:20 +08:00
shouchih_chen
cbba28fcf5 Merge branch 'master-webassembly' into dev-webassembly
# Conflicts:
#	NameCreater/customlogo2.cpp
#	NameCreater/def.h
2024-09-26 13:53:40 +08:00
shouchih_chen
e8b68cf0c4 Improve compatibility between Qt5 and Qt6 2024-09-20 13:25:29 +08:00
shouchih_chen
1405d54f33 Merge branch 'master-webassembly' of https://gitlab.com/portfolio91/namecreater into master-webassembly
# Conflicts:
#	NameCreater/NameCreater.pro.user
#	NameCreater/customlogo2.cpp
2024-09-20 12:54:50 +08:00
16431955de Refactor code, Split QFileDialog in Webassembly and other desktop OS. 2024-09-20 12:47:26 +08:00
shouchih_chen
c13e225d29 update for testing vs 2022 2024-09-20 12:45:36 +08:00
shouchih_chen
4c92f00cb2 1. change app save path coding. 2024-09-14 16:55:57 +08:00
shouchih_chen
e8a4557906 1. update version 2.8.0. 2. change save path dir in customlogo2 in MAC setting. 2024-09-14 16:35:01 +08:00
shouchih_chen
bfab4f20da Add customlogo2 class 2024-09-14 16:20:26 +08:00
5bc600c0ec 1. Change chinese font. 2. adjust Five to Single zh_eng english x posistion. 2024-07-10 09:04:14 +08:00
shouchih_chen
17e98668b2 try show font name 2024-07-03 22:45:59 +08:00
8e9375c7ac try to fix font name not show issue. 2024-07-03 22:31:37 +08:00
shouchih_chen
de6c1a0a6b complete to load cht font from url. 2024-07-03 22:05:43 +08:00
faad6b25ef try to change cht font. 2024-07-03 20:47:58 +08:00
8277a65bdd 1. Update new five girl background. 2. Adjustment eng to eng position. 2024-06-27 17:11:19 +08:00
d3dd641a59 adjust five to signal Cht_eng arrangement method and position. 2024-06-02 17:36:42 +08:00
8bfd5da5f1 完成客制化背景產生器:
1. only finish one side name.
2. only finish chinese name and three word name.
2024-05-15 12:48:57 +08:00
599480df0f adjust BirthdayCreater eng position. 2024-05-14 15:10:25 +08:00
91ca0f21a9 adjust five to single word position. 2024-03-20 09:15:43 +08:00
2b51d7ddee modify BirthdayCreater eng position. 2024-03-14 15:03:27 +08:00
d1e80ad04c modify birthday eng to eng position. 2024-03-13 15:04:34 +08:00
5655d824d7 adjust five to signal zh_eng window and webassembly different position y issue. 2024-03-12 11:40:56 +08:00
47b543aaa7 add new resource for new five group. 2024-03-08 08:28:33 +08:00
0d14515dc3 1. add apple and pg image in birthday creator. 2. release v2.3.2 2023-10-02 08:59:52 +08:00
d9ebf66831 調整手帕夾 2023-10-02 08:44:32 +08:00
e64e06bf56 modify hk csv file 2023-08-02 22:35:36 +08:00
shouchih_chen
5bbafd6668 Modify HKHolder image resource. 2023-08-02 22:18:34 +08:00
shouchih_chen
bbc348d859 Modify for qt 6 build env 2023-08-02 05:49:54 +08:00
shouchih_chen
7a8106b539 Merge commit '052d36b520c27e916bc77e1625aa60143902b9c4' into dev-webassembly 2023-08-02 05:49:10 +08:00
shouchih_chen
052d36b520 Merge branch 'master-webassembly' of gitlab.com:portfolio91/namecreater into master-webassembly
# Conflicts:
#	NameCreater/NameCreater.pro.user
2023-07-30 20:17:33 +08:00
shouchih_chen
c5e8bba4ff add project build setting for QT 2023-07-30 20:15:55 +08:00
62e75e4ca0 modify HK label names 2023-07-30 20:13:18 +08:00
shouchih_chen 陳守志
46c669d78e use new font 2023-07-25 15:43:05 +08:00
shouchih_chen 陳守志
e14743ca15 完成中文排列對齊 2023-07-25 15:33:48 +08:00
shouchih_chen 陳守志
6ea71180c8 ongoing modify 2023-07-24 17:42:44 +08:00
shouchih_chen 陳守志
10a119e7ea ongoing implement HK holder creator function 2023-07-24 17:24:09 +08:00
shouchih_chen 陳守志
39402a800f 增加手帕夾產生器 Class 2023-07-24 15:09:50 +08:00
ShouChih Chen
3eb58b7830 Add: add birthday english 2023-05-24 21:00:34 +08:00
ShouChih Chen
c6fb017745 Modify: add QMAKE_LFLAGS for memory size in .pro file 2023-05-17 22:42:47 +08:00
Shouchih_Chen
f9cddcb565 modify: adjust english word position. 2023-05-17 16:53:41 +08:00
Shouchih_Chen
aaf3751879 Modify: change english font 2023-05-17 14:08:02 +08:00
0c5abc203c Modify: 重新下載英文對應字體,以及修改位置 2023-05-17 06:50:27 +08:00
8166fc30ae Add: 增加生日禮英文排列 2023-05-16 23:17:05 +08:00
b2602b5ef7 add name type for English name. 2023-05-13 07:37:05 +08:00
231f63295f 完成所有功能整合 2023-05-06 07:43:12 +08:00
3b6987bb8b add towel creater 2023-05-04 23:22:47 +08:00
shouchih_chen 陳守志
3da5037ca7 remove unused file 2023-05-04 11:20:14 +08:00
shouchih_chen 陳守志
2f330ac463 Porting birthday python code to c++ 2023-05-04 11:13:37 +08:00
d425173179 完成舊五入組整合 2023-05-04 06:28:54 +08:00
3b7756393e add old five code in. 2023-05-03 23:05:23 +08:00
425e9fead2 adjust FiveToSingle class 2023-05-03 22:10:09 +08:00
shouchih_chen 陳守志
1a254c4898 Merge branch 'webassembly_birthday' of https://gitlab.com/portfolio91/namecreater into webassembly_birthday
# Conflicts:
#	NameCreater/NameCreater.cpp
2023-05-03 17:38:20 +08:00
shouchih_chen 陳守志
f40a56c656 add interface files. 2023-05-03 17:37:18 +08:00
3942d7f147 build webassembly succeed. 2023-04-07 05:57:05 +08:00
shouchih_chen 陳守志
fc8bb70f56 1. save file succeed 2023-03-31 16:17:51 +08:00
shouchih_chen 陳守志
24639c50b0 web assemble testing 2023-03-31 14:40:23 +08:00
d9d110ce04 1. add new five picture 2. add x64 env 2022-12-28 22:16:02 +08:00
83fde65fae 調整位置 2022-03-26 10:16:17 +08:00
56ea07365d Merge branch 'birthday' of https://gitlab.com/portfolio91/namecreater into birthday
# Conflicts:
#	NameCreater/main.cpp
2022-03-26 07:10:19 +08:00
6009f56287 add number sample 2022-03-26 06:55:59 +08:00
shouchih_chen
dd69403ee6 修正一些錯誤 2022-03-25 22:53:47 +08:00
shouchih_chen
3ce254f16d Merge branch 'birthday' of https://gitlab.com/portfolio91/namecreater into birthday 2022-03-25 22:36:50 +08:00
shouchih_chen
1216358657 commit build setting 2022-03-25 22:36:28 +08:00
793446dcd2 1. add two word template
2. add new background
2022-03-25 22:30:29 +08:00
4fa3d9dc1c fix bg type string '/r/n' 2022-02-20 11:07:11 +08:00
shouchih_chen
27a4eb5c8b marco mac/windows handle /r/n string 2022-02-20 07:53:55 +08:00
6025cc2913 finish birthday namecreater 2022-02-20 07:27:25 +08:00
615fa0e283 finish layout adjustment. 2022-02-19 08:44:26 +08:00
26 changed files with 3025 additions and 4084 deletions

21
.gitignore vendored
View File

@ -1,11 +1,10 @@
*Debug/ *Debug/
*Release/ *Release/
/.vs/ /.vs/
/*.opendb /*.opendb
/*.db /*.db
/_bin /_bin
/web_build /web_build
/buildwed /buildwed
/NameCreater/*.aps /NameCreater/*.aps
/buildweb/ /buildweb/
/NameCreater/build/*

View File

@ -1,308 +1,308 @@
#include "BirthdayCreater.h" #include "BirthdayCreater.h"
#include <QTextCodec> #include <QTextCodec>
#include <QTextStream> #include <QTextStream>
#include <QDebug> #include <QDebug>
#include <QMessageBox> #include <QMessageBox>
#include <QDateTime> #include <QDateTime>
#define LABEL_HIGHT_LIMIT 350.0 #define LABEL_HIGHT_LIMIT 350.0
#define LABEL_POS_X_OFFSET 323.0 #define LABEL_POS_X_OFFSET 323.0
#define NAME_TWO_WORD_OFFSET 170.0 #define NAME_TWO_WORD_OFFSET 170.0
#define NAME_THREE_WORD_OFFSET 145.0 #define NAME_THREE_WORD_OFFSET 145.0
#define MAX_LABEL_IN_PAPER 10 #define MAX_LABEL_IN_PAPER 10
#define FONT_PIXEL_SIZE 120 #define FONT_PIXEL_SIZE 120
static QPoint LABEL_POS_START = QPoint(163, 70); static QPoint LABEL_POS_START = QPoint(163, 115);
static QPoint NAME_OFFSET_START = QPoint(82, 712); static QPoint NAME_OFFSET_START = QPoint(82, 712);
static QPoint NAME_OFFSET_REVERSE_START = QPoint(214, 1745); static QPoint NAME_OFFSET_REVERSE_START = QPoint(214, 1745);
BirthdayCreater::BirthdayCreater() :INameCreater() BirthdayCreater::BirthdayCreater() :INameCreater()
{ {
label_bg_map["b"] = ":/NameCreater/resource/b.jpg"; label_bg_map["b"] = ":/NameCreater/resource/b.jpg";
label_bg_map["g"] = ":/NameCreater/resource/g.jpg"; label_bg_map["g"] = ":/NameCreater/resource/g.jpg";
label_bg_map["m"] = ":/NameCreater/resource/m.jpg"; label_bg_map["m"] = ":/NameCreater/resource/m.jpg";
label_bg_map["p"] = ":/NameCreater/resource/p.jpg"; label_bg_map["p"] = ":/NameCreater/resource/p.jpg";
label_bg_map["r"] = ":/NameCreater/resource/r.jpg"; label_bg_map["r"] = ":/NameCreater/resource/r.jpg";
label_bg_map["w"] = ":/NameCreater/resource/w.jpg"; label_bg_map["w"] = ":/NameCreater/resource/w.jpg";
label_bg_map["y"] = ":/NameCreater/resource/y.jpg"; label_bg_map["y"] = ":/NameCreater/resource/y.jpg";
label_bg_map["co"] = ":/NameCreater/resource/co.jpg"; label_bg_map["co"] = ":/NameCreater/resource/co.jpg";
label_bg_map["ol"] = ":/NameCreater/resource/ol.jpg"; label_bg_map["ol"] = ":/NameCreater/resource/ol.jpg";
label_bg_map["sn"] = ":/NameCreater/resource/sn.jpg"; label_bg_map["sn"] = ":/NameCreater/resource/sn.jpg";
label_bg_map["st"] = ":/NameCreater/resource/st.jpg"; label_bg_map["st"] = ":/NameCreater/resource/st.jpg";
label_bg_map["a"] = ":/NameCreater/resource/a.jpg"; label_bg_map["a"] = ":/NameCreater/resource/a.jpg";
label_bg_map["pg"] = ":/NameCreater/resource/pg.jpg"; label_bg_map["pg"] = ":/NameCreater/resource/pg.jpg";
} }
BirthdayCreater::~BirthdayCreater() BirthdayCreater::~BirthdayCreater()
{ {
} }
QList<NameInfo_t> BirthdayCreater::getNameByFileContent(Name_Type_e type, const QByteArray& conetent) QList<NameInfo_t> BirthdayCreater::getNameByFileContent(Name_Type_e type, const QByteArray& conetent)
{ {
QList<NameInfo_t> nameList; QList<NameInfo_t> nameList;
QTextCodec* tc = QTextCodec::codecForName("Big5"); QTextCodec* tc = QTextCodec::codecForName("Big5");
QString codec = tc->toUnicode(conetent.data()); QString codec = tc->toUnicode(conetent.data());
QTextStream stream(&codec); QTextStream stream(&codec);
int row = 0; int row = 0;
while (!stream.atEnd()) while (!stream.atEnd())
{ {
NameInfo_t info; NameInfo_t info;
QString line = stream.readLine(); QString line = stream.readLine();
QString name_tc = line; QString name_tc = line;
QStringList csvList = name_tc.split(','); QStringList csvList = name_tc.split(',');
QString name, eng_name, bg_type; QString name, eng_name, bg_type;
switch (type) { switch (type) {
case Name_zh: case Name_zh:
name = csvList.at(0); name = csvList.at(0);
bg_type = csvList.at(1); bg_type = csvList.at(1);
break; break;
case Name_zh_eng: case Name_zh_eng:
name = csvList.at(0); name = csvList.at(0);
eng_name = csvList.at(1); eng_name = csvList.at(1);
bg_type = csvList.at(2); bg_type = csvList.at(2);
break; break;
case Name_eng: case Name_eng:
eng_name = csvList.at(0); eng_name = csvList.at(0);
bg_type = csvList.at(1); bg_type = csvList.at(1);
default: default:
break; break;
} }
qDebug() << "row :" << row << " " << name <<", eng: "<< eng_name << ", bg_type: " << bg_type; qDebug() << "row :" << row << " " << name <<", eng: "<< eng_name << ", bg_type: " << bg_type;
if (name.compare("name") == 0 || eng_name.compare("eng_name")==0) { if (name.compare("name") == 0 || eng_name.compare("eng_name")==0) {
//pass first line //pass first line
continue; continue;
} }
info.name1 = name; info.name1 = name;
info.name_eng = eng_name; info.name_eng = eng_name;
info.name2 = bg_type; info.name2 = bg_type;
nameList.append(info); nameList.append(info);
row++; row++;
} }
return nameList; return nameList;
} }
void BirthdayCreater::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color) void BirthdayCreater::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
{ {
int export_times = 0; int export_times = 0;
QList<NameInfo_t> nameList = getNameByFileContent(type, filecontent); QList<NameInfo_t> nameList = getNameByFileContent(type, filecontent);
if (nameList.isEmpty()) { if (nameList.isEmpty()) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(QString("Name is empty ! ").append(filename)); msgBox.setText(QString("Name is empty ! ").append(filename));
msgBox.exec(); msgBox.exec();
} }
QGraphicsScene scene; QGraphicsScene scene;
scene.setBackgroundBrush(QBrush(QColor(255, 255, 255))); scene.setBackgroundBrush(QBrush(QColor(255, 255, 255)));
QGraphicsView view(&scene); QGraphicsView view(&scene);
switch (type) switch (type)
{ {
case Name_zh: case Name_zh:
for (int idx = 0; idx < nameList.length(); idx++) { for (int idx = 0; idx < nameList.length(); idx++) {
if ((idx % MAX_LABEL_IN_PAPER) == 0) { if ((idx % MAX_LABEL_IN_PAPER) == 0) {
QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT); QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT);
bg_item->setBrush(QBrush(QColor(255, 255, 255))); bg_item->setBrush(QBrush(QColor(255, 255, 255)));
//QGraphicsPixmapItem* bg_item = QGraphicsPixmapItem(QPixmap(BG_SMAPLE_PATH)); //QGraphicsPixmapItem* bg_item = QGraphicsPixmapItem(QPixmap(BG_SMAPLE_PATH));
scene.addItem(bg_item); scene.addItem(bg_item);
} }
NameInfo_t name_info = nameList.at(idx); NameInfo_t name_info = nameList.at(idx);
int col_index = idx % MAX_LABEL_IN_PAPER; int col_index = idx % MAX_LABEL_IN_PAPER;
QString label_rel_path = label_bg_map[name_info.name2]; QString label_rel_path = label_bg_map[name_info.name2];
QGraphicsPixmapItem* label_item = new QGraphicsPixmapItem(QPixmap(label_rel_path)); QGraphicsPixmapItem* label_item = new QGraphicsPixmapItem(QPixmap(label_rel_path));
label_item->setPos(int(LABEL_POS_START.x() + LABEL_POS_X_OFFSET * col_index), int(LABEL_POS_START.y())); label_item->setPos(int(LABEL_POS_START.x() + LABEL_POS_X_OFFSET * col_index), int(LABEL_POS_START.y()));
label_item->setOpacity(1); label_item->setOpacity(1);
scene.addItem(label_item); scene.addItem(label_item);
int chrismas_y_offset = 0; int chrismas_y_offset = 0;
if (name_info.name2.compare("co") == 0 || name_info.name2.compare("ol") == 0 || if (name_info.name2.compare("co") == 0 || name_info.name2.compare("ol") == 0 ||
/*name_info.name2.compare("st") == 0 ||*/ name_info.name2.compare("sn") == 0) { name_info.name2.compare("st") == 0 || name_info.name2.compare("sn") == 0) {
chrismas_y_offset = 30; chrismas_y_offset = 30;
} }
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
int name_word_len = name_info.name1.length(); int name_word_len = name_info.name1.length();
qreal two_word_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET / 2 : 0; qreal two_word_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET / 2 : 0;
qreal offset_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET : NAME_THREE_WORD_OFFSET; qreal offset_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET : NAME_THREE_WORD_OFFSET;
for (int w = 0; w < name_word_len; w++) { for (int w = 0; w < name_word_len; w++) {
QGraphicsTextItem* word_item = new QGraphicsTextItem(name_info.name1.at(w)); QGraphicsTextItem* word_item = new QGraphicsTextItem(name_info.name1.at(w));
word_item->setFont(font); word_item->setFont(font);
word_item->setDefaultTextColor(font_color); word_item->setDefaultTextColor(font_color);
if (i == 0) { if (i == 0) {
word_item->setPos(label_item->x() + NAME_OFFSET_START.x(), label_item->y() + NAME_OFFSET_START.y() + two_word_y + chrismas_y_offset + offset_y * w); word_item->setPos(label_item->x() + NAME_OFFSET_START.x(), label_item->y() + NAME_OFFSET_START.y() + two_word_y + chrismas_y_offset + offset_y * w);
} }
else { else {
word_item->setTransform(QTransform().fromScale(-1, -1)); word_item->setTransform(QTransform().fromScale(-1, -1));
word_item->setPos(label_item->x() + NAME_OFFSET_REVERSE_START.x(), label_item->y() + NAME_OFFSET_REVERSE_START.y() - two_word_y - chrismas_y_offset - offset_y * w); word_item->setPos(label_item->x() + NAME_OFFSET_REVERSE_START.x(), label_item->y() + NAME_OFFSET_REVERSE_START.y() - two_word_y - chrismas_y_offset - offset_y * w);
} }
scene.addItem(word_item); scene.addItem(word_item);
} }
} }
if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) { if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) {
QString date_str = QDateTime::currentDateTime().toString("MMddhhmm"); QString date_str = QDateTime::currentDateTime().toString("MMddhhmm");
QString file_name = QString("Birthday_%2_%1.jpg").arg(QString::number(export_times + 1), date_str); QString file_name = QString("Birthday_%2_%1.jpg").arg(QString::number(export_times + 1), date_str);
saveToImage(file_name, &scene); saveToImage(file_name, &scene);
export_times++; export_times++;
scene.clear(); scene.clear();
} }
} }
break; break;
case Name_eng: case Name_eng:
for (int idx = 0; idx < nameList.length(); idx++) { for (int idx = 0; idx < nameList.length(); idx++) {
if ((idx % MAX_LABEL_IN_PAPER) == 0) { if ((idx % MAX_LABEL_IN_PAPER) == 0) {
QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT); QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT);
bg_item->setBrush(QBrush(QColor(255, 255, 255))); bg_item->setBrush(QBrush(QColor(255, 255, 255)));
//QGraphicsPixmapItem* bg_item = QGraphicsPixmapItem(QPixmap(BG_SMAPLE_PATH)); //QGraphicsPixmapItem* bg_item = QGraphicsPixmapItem(QPixmap(BG_SMAPLE_PATH));
scene.addItem(bg_item); scene.addItem(bg_item);
} }
NameInfo_t name_info = nameList.at(idx); NameInfo_t name_info = nameList.at(idx);
int col_index = idx % MAX_LABEL_IN_PAPER; int col_index = idx % MAX_LABEL_IN_PAPER;
QString label_rel_path = label_bg_map[name_info.name2]; QString label_rel_path = label_bg_map[name_info.name2];
QGraphicsPixmapItem* label_item = new QGraphicsPixmapItem(QPixmap(label_rel_path)); QGraphicsPixmapItem* label_item = new QGraphicsPixmapItem(QPixmap(label_rel_path));
label_item->setPos(int(LABEL_POS_START.x() + LABEL_POS_X_OFFSET * col_index), int(LABEL_POS_START.y())); label_item->setPos(int(LABEL_POS_START.x() + LABEL_POS_X_OFFSET * col_index), int(LABEL_POS_START.y()));
label_item->setOpacity(1); label_item->setOpacity(1);
scene.addItem(label_item); scene.addItem(label_item);
int chrismas_y_offset = 0; int chrismas_y_offset = 0;
if (name_info.name2.compare("co") == 0 || name_info.name2.compare("ol") == 0 || if (name_info.name2.compare("co") == 0 || name_info.name2.compare("ol") == 0 ||
/*name_info.name2.compare("st") == 0 ||*/ name_info.name2.compare("sn") == 0) { name_info.name2.compare("st") == 0 || name_info.name2.compare("sn") == 0) {
chrismas_y_offset = 30; chrismas_y_offset = 30;
} }
QFont _new_font = QFont(EnglisthFont()); QFont _new_font = QFont(EnglisthFont());
_new_font.setWeight(QFont::ExtraLight); _new_font.setWeight(QFont::ExtraLight);
int _new_size = getFontSizebyStr(_new_font, 120, 480, name_info.name_eng); int _new_size = getFontSizebyStr(_new_font, 120, 480, name_info.name_eng);
_new_font.setPixelSize(_new_size); _new_font.setPixelSize(_new_size);
for(int i = 0; i < 2; i++){ for(int i = 0; i < 2; i++){
qreal dir = (i == 0) ? -1.0:1.0; qreal dir = (i == 0) ? -1.0:1.0;
qreal x_offset = (i == 0) ? 280.0 : 170.0; qreal x_offset = (i == 0) ? 290.0 : 170.0;
qreal y_offset = (i == 0) ? 890.0 : 1550.0; qreal y_offset = (i == 0) ? 890.0 : 1550.0;
int sp_y_offset = (i == 0)? 1.0*chrismas_y_offset:-1.0*chrismas_y_offset; int sp_y_offset = (i == 0)? 1.0*chrismas_y_offset:-1.0*chrismas_y_offset;
//add English world //add English world
QGraphicsTextItem* eng_word_item = new QGraphicsTextItem(name_info.name_eng,label_item); QGraphicsTextItem* eng_word_item = new QGraphicsTextItem(name_info.name_eng);
eng_word_item->setFont(_new_font); eng_word_item->setFont(_new_font);
QRectF rect = eng_word_item->boundingRect(); QRectF rect = eng_word_item->boundingRect();
eng_word_item->setDefaultTextColor(font_color); eng_word_item->setDefaultTextColor(font_color);
eng_word_item->setRotation(i == 0 ? 90 : -90); eng_word_item->setRotation(i == 0 ? 90 : -90);
eng_word_item->setPos(x_offset - rect.height()/2.0, y_offset + sp_y_offset + (rect.width()/2*dir)); eng_word_item->setPos(label_item->x() + x_offset - rect.height()/2.0, label_item->y() + y_offset + sp_y_offset + (rect.width()/2*dir));
//scene.addItem(eng_word_item); scene.addItem(eng_word_item);
} }
if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) { if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) {
QString date_str = QDateTime::currentDateTime().toString("MMddhhmm"); QString date_str = QDateTime::currentDateTime().toString("MMddhhmm");
QString file_name = QString("Birthday_%2_%1.jpg").arg(QString::number(export_times + 1), date_str); QString file_name = QString("Birthday_%2_%1.jpg").arg(QString::number(export_times + 1), date_str);
saveToImage(file_name, &scene); saveToImage(file_name, &scene);
export_times++; export_times++;
scene.clear(); scene.clear();
} }
} }
break; break;
case Name_zh_eng: case Name_zh_eng:
for (int idx = 0; idx < nameList.length(); idx++) { for (int idx = 0; idx < nameList.length(); idx++) {
if ((idx % MAX_LABEL_IN_PAPER) == 0) { if ((idx % MAX_LABEL_IN_PAPER) == 0) {
QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT); QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT);
bg_item->setBrush(QBrush(QColor(255, 255, 255))); bg_item->setBrush(QBrush(QColor(255, 255, 255)));
//QGraphicsPixmapItem* bg_item = QGraphicsPixmapItem(QPixmap(BG_SMAPLE_PATH)); //QGraphicsPixmapItem* bg_item = QGraphicsPixmapItem(QPixmap(BG_SMAPLE_PATH));
scene.addItem(bg_item); scene.addItem(bg_item);
} }
NameInfo_t name_info = nameList.at(idx); NameInfo_t name_info = nameList.at(idx);
int col_index = idx % MAX_LABEL_IN_PAPER; int col_index = idx % MAX_LABEL_IN_PAPER;
QString label_rel_path = label_bg_map[name_info.name2]; QString label_rel_path = label_bg_map[name_info.name2];
QGraphicsPixmapItem* label_item = new QGraphicsPixmapItem(QPixmap(label_rel_path)); QGraphicsPixmapItem* label_item = new QGraphicsPixmapItem(QPixmap(label_rel_path));
label_item->setPos(int(LABEL_POS_START.x() + LABEL_POS_X_OFFSET * col_index), int(LABEL_POS_START.y())); label_item->setPos(int(LABEL_POS_START.x() + LABEL_POS_X_OFFSET * col_index), int(LABEL_POS_START.y()));
label_item->setOpacity(1); label_item->setOpacity(1);
scene.addItem(label_item); scene.addItem(label_item);
int chrismas_y_offset = 0; int chrismas_y_offset = 0;
if (name_info.name2.compare("co") == 0 || name_info.name2.compare("ol") == 0 || if (name_info.name2.compare("co") == 0 || name_info.name2.compare("ol") == 0 ||
/*name_info.name2.compare("st") == 0 ||*/ name_info.name2.compare("sn") == 0) { name_info.name2.compare("st") == 0 || name_info.name2.compare("sn") == 0) {
chrismas_y_offset = 30; chrismas_y_offset = 30;
} }
// add ZH word // add ZH word
int name_word_len = name_info.name1.length(); int name_word_len = name_info.name1.length();
qreal two_word_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET / 2 : 0; qreal two_word_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET / 2 : 0;
qreal offset_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET : NAME_THREE_WORD_OFFSET; qreal offset_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET : NAME_THREE_WORD_OFFSET;
for (int w = 0; w < name_word_len; w++) { for (int w = 0; w < name_word_len; w++) {
QGraphicsTextItem* word_item = new QGraphicsTextItem(name_info.name1.at(w)); QGraphicsTextItem* word_item = new QGraphicsTextItem(name_info.name1.at(w));
word_item->setFont(font); word_item->setFont(font);
word_item->setDefaultTextColor(font_color); word_item->setDefaultTextColor(font_color);
word_item->setPos(label_item->x() + NAME_OFFSET_START.x(), label_item->y() + NAME_OFFSET_START.y() + two_word_y + chrismas_y_offset + offset_y * w); word_item->setPos(label_item->x() + NAME_OFFSET_START.x(), label_item->y() + NAME_OFFSET_START.y() + two_word_y + chrismas_y_offset + offset_y * w);
scene.addItem(word_item); scene.addItem(word_item);
} }
//TODO: add English world //TODO: add English world
QGraphicsTextItem* eng_word_item = new QGraphicsTextItem(name_info.name_eng); QGraphicsTextItem* eng_word_item = new QGraphicsTextItem(name_info.name_eng);
QFont _new_font = QFont(EnglisthFont()); QFont _new_font = QFont(EnglisthFont());
_new_font.setWeight(QFont::ExtraLight); _new_font.setWeight(QFont::ExtraLight);
int _new_size = getFontSizebyStr(_new_font, 120, 480, name_info.name_eng); int _new_size = getFontSizebyStr(_new_font, 120, 480, name_info.name_eng);
_new_font.setPixelSize(_new_size); _new_font.setPixelSize(_new_size);
eng_word_item->setFont(_new_font); eng_word_item->setFont(_new_font);
QRectF rect = eng_word_item->boundingRect(); QRectF rect = eng_word_item->boundingRect();
eng_word_item->setDefaultTextColor(font_color); eng_word_item->setDefaultTextColor(font_color);
eng_word_item->setRotation(-90); eng_word_item->setRotation(-90);
eng_word_item->setPos(label_item->x() + 170.0 - rect.height()/2.0, label_item->y() + 1580 - chrismas_y_offset + rect.width()/2); eng_word_item->setPos(label_item->x() + 170.0 - rect.height()/2.0, label_item->y() + 1580 - chrismas_y_offset + rect.width()/2);
scene.addItem(eng_word_item); scene.addItem(eng_word_item);
if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) { if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) {
QString date_str = QDateTime::currentDateTime().toString("MMddhhmm"); QString date_str = QDateTime::currentDateTime().toString("MMddhhmm");
QString file_name = QString("Birthday_%2_%1.jpg").arg(QString::number(export_times + 1), date_str); QString file_name = QString("Birthday_%2_%1.jpg").arg(QString::number(export_times + 1), date_str);
saveToImage(file_name, &scene); saveToImage(file_name, &scene);
export_times++; export_times++;
scene.clear(); scene.clear();
} }
} }
break; break;
default: default:
break; break;
} }
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(QString().asprintf("Export Finshed. Count:%d", export_times)); msgBox.setText(QString().asprintf("Export Finshed. Count:%d", export_times));
msgBox.exec(); msgBox.exec();
} }

View File

@ -1,19 +1,19 @@
#pragma once #pragma once
#include "INameCreater.h" #include "INameCreater.h"
#include <QMap> #include <QMap>
class BirthdayCreater : public INameCreater class BirthdayCreater : public INameCreater
{ {
public: public:
BirthdayCreater(); BirthdayCreater();
~BirthdayCreater(); ~BirthdayCreater();
protected: protected:
QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent); QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent);
public: public:
virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color); virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
private: private:
QMap<QString, QString> label_bg_map; QMap<QString, QString> label_bg_map;
}; };

View File

@ -1,369 +1,369 @@
#include "FiveToSingle.h" #include "FiveToSingle.h"
#include <QMessageBox> #include <QMessageBox>
#include <QDateTime> #include <QDateTime>
#include <QTextCodec> #include <QTextCodec>
#include <QTextStream> #include <QTextStream>
#include <QDebug> #include <QDebug>
#define BG_PATH_FORMAT ":/NameCreater/resource/background_%1.jpg" #define BG_PATH_FORMAT ":/NameCreater/resource/background_%1.jpg"
static QPointF BG_POS[] = { static QPointF BG_POS[] = {
QPointF(159, 61), QPointF(482, 61), QPointF(802, 61), QPointF(159, 61), QPointF(482, 61), QPointF(802, 61),
QPointF(1122, 61), QPointF(1449, 61), QPointF(1772, 61), QPointF(1122, 61), QPointF(1449, 61), QPointF(1772, 61),
QPointF(2095, 61), QPointF(2414, 61), QPointF(2738, 61), QPointF(2095, 61), QPointF(2414, 61), QPointF(2738, 61),
QPointF(3060, 61), QPointF(900, 2094), QPointF(900, 2420), QPointF(3060, 61), QPointF(900, 2094), QPointF(900, 2420),
}; };
static int BG_POS_COUNT = sizeof(BG_POS) / sizeof(BG_POS[0]); static int BG_POS_COUNT = sizeof(BG_POS) / sizeof(BG_POS[0]);
static QPointF NAME_POS[] = { static QPointF NAME_POS[] = {
QPointF(240, 430), QPointF(372, 1402), QPointF(240, 430), QPointF(372, 1402),
QPointF(564, 430), QPointF(694, 1402), QPointF(564, 430), QPointF(694, 1402),
QPointF(883, 430), QPointF(1014, 1402), QPointF(883, 430), QPointF(1014, 1402),
QPointF(1205, 430), QPointF(1337, 1402), QPointF(1205, 430), QPointF(1337, 1402),
QPointF(1532, 430), QPointF(1663, 1402), QPointF(1532, 430), QPointF(1663, 1402),
QPointF(1854, 430), QPointF(1987, 1402), QPointF(1854, 430), QPointF(1987, 1402),
QPointF(2176, 430), QPointF(2309, 1402), QPointF(2176, 430), QPointF(2309, 1402),
QPointF(2498, 430), QPointF(2629, 1402), QPointF(2498, 430), QPointF(2629, 1402),
QPointF(2821, 430), QPointF(2952, 1402), QPointF(2821, 430), QPointF(2952, 1402),
QPointF(3145, 430), QPointF(3276, 1402), QPointF(3145, 430), QPointF(3276, 1402),
QPointF(1268, 2012), QPointF(2240, 1880), QPointF(1268, 2012), QPointF(2240, 1880),
QPointF(1268, 2334), QPointF(2240, 2202), QPointF(1268, 2334), QPointF(2240, 2202),
}; };
static QPointF NAME_POS_NUMBER[] = { static QPointF NAME_POS_NUMBER[] = {
QPointF(240, 370), QPointF(372, 1442), QPointF(240, 370), QPointF(372, 1442),
QPointF(564, 370), QPointF(694, 1442), QPointF(564, 370), QPointF(694, 1442),
QPointF(883, 370), QPointF(1014, 1442), QPointF(883, 370), QPointF(1014, 1442),
QPointF(1205, 370), QPointF(1337, 1442), QPointF(1205, 370), QPointF(1337, 1442),
QPointF(1532, 370), QPointF(1663, 1442), QPointF(1532, 370), QPointF(1663, 1442),
QPointF(1854, 370), QPointF(1987, 1442), QPointF(1854, 370), QPointF(1987, 1442),
QPointF(2176, 370), QPointF(2309, 1442), QPointF(2176, 370), QPointF(2309, 1442),
QPointF(2498, 370), QPointF(2629, 1442), QPointF(2498, 370), QPointF(2629, 1442),
QPointF(2821, 370), QPointF(2952, 1442), QPointF(2821, 370), QPointF(2952, 1442),
QPointF(3145, 370), QPointF(3276, 1442), QPointF(3145, 370), QPointF(3276, 1442),
QPointF(1228, 2012), QPointF(2280, 1880), QPointF(1228, 2012), QPointF(2280, 1880),
QPointF(1228, 2334), QPointF(2280, 2202), QPointF(1228, 2334), QPointF(2280, 2202),
}; };
static QPointF NEW_POS = QPoint(81, 320); static QPointF NEW_POS = QPoint(81, 320);
//static int NAME_POS_COUNT = sizeof(NAME_POS) / sizeof(NAME_POS[0]); //static int NAME_POS_COUNT = sizeof(NAME_POS) / sizeof(NAME_POS[0]);
FiveToSingle::FiveToSingle() :INameCreater() FiveToSingle::FiveToSingle() :INameCreater()
{ {
} }
FiveToSingle::~FiveToSingle() FiveToSingle::~FiveToSingle()
{ {
} }
QList<NameInfo_t> FiveToSingle::getNameByFileContent(Name_Type_e type, const QByteArray& conetent) QList<NameInfo_t> FiveToSingle::getNameByFileContent(Name_Type_e type, const QByteArray& conetent)
{ {
QList<NameInfo_t> nameList; QList<NameInfo_t> nameList;
QTextCodec* tc = QTextCodec::codecForName("Big5"); QTextCodec* tc = QTextCodec::codecForName("Big5");
QString codec = tc->toUnicode(conetent.data()); QString codec = tc->toUnicode(conetent.data());
QTextStream stream(&codec); QTextStream stream(&codec);
int row = 0; int row = 0;
while (!stream.atEnd()) while (!stream.atEnd())
{ {
NameInfo_t info; NameInfo_t info;
QString line = stream.readLine(); QString line = stream.readLine();
QString name_tc = line; QString name_tc = line;
QStringList csvList = name_tc.split(','); QStringList csvList = name_tc.split(',');
QString name, eng_name, bg_type; QString name, eng_name, bg_type;
switch (type) { switch (type) {
case Name_zh: case Name_zh:
name = csvList.at(0); name = csvList.at(0);
bg_type = csvList.at(1); bg_type = csvList.at(1);
break; break;
case Name_zh_eng: case Name_zh_eng:
name = csvList.at(0); name = csvList.at(0);
eng_name = csvList.at(1); eng_name = csvList.at(1);
bg_type = csvList.at(2); bg_type = csvList.at(2);
break; break;
case Name_eng: case Name_eng:
eng_name = csvList.at(0); eng_name = csvList.at(0);
bg_type = csvList.at(1); bg_type = csvList.at(1);
default: default:
break; break;
} }
qDebug() << "row :" << row << " " << name << ", eng: " << eng_name << ", bg_type: " << bg_type; qDebug() << "row :" << row << " " << name << ", eng: " << eng_name << ", bg_type: " << bg_type;
if (name.compare("name_1") == 0 || eng_name.compare("eng_name") == 0) { if (name.compare("name_1") == 0 || eng_name.compare("eng_name") == 0) {
//pass first line //pass first line
continue; continue;
} }
info.name1 = name; info.name1 = name;
info.name_eng = eng_name; info.name_eng = eng_name;
info.name2 = QString(BG_PATH_FORMAT).arg(bg_type); info.name2 = QString(BG_PATH_FORMAT).arg(bg_type);
nameList.append(info); nameList.append(info);
row++; row++;
} }
return nameList; return nameList;
} }
void FiveToSingle::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color) void FiveToSingle::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
{ {
int export_times = 0; int export_times = 0;
QList<NameInfo_t> nameList = getNameByFileContent(type, filecontent); QList<NameInfo_t> nameList = getNameByFileContent(type, filecontent);
if (nameList.isEmpty()) { if (nameList.isEmpty()) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(QString("Name is empty ! ").append(filename)); msgBox.setText(QString("Name is empty ! ").append(filename));
msgBox.exec(); msgBox.exec();
} }
QGraphicsScene scene; QGraphicsScene scene;
scene.setBackgroundBrush(QBrush(QColor(255, 255, 255))); scene.setBackgroundBrush(QBrush(QColor(255, 255, 255)));
QGraphicsView view(&scene); QGraphicsView view(&scene);
/*QImage image(BG_SAMPLE_PATH); /*QImage image(BG_SAMPLE_PATH);
QGraphicsPixmapItem* bgItem = new QGraphicsPixmapItem(QPixmap::fromImage(image)); QGraphicsPixmapItem* bgItem = new QGraphicsPixmapItem(QPixmap::fromImage(image));
scene.addItem(bgItem);*/ scene.addItem(bgItem);*/
switch (type) { switch (type) {
case Name_zh: case Name_zh:
{ {
for (int n = 0; n < nameList.length(); n++) { for (int n = 0; n < nameList.length(); n++) {
int idx = n % BG_POS_COUNT; int idx = n % BG_POS_COUNT;
NameInfo_t name_info = nameList.at(n); NameInfo_t name_info = nameList.at(n);
QImage name_image(name_info.name2); QImage name_image(name_info.name2);
if (idx == 0) { if (idx == 0) {
QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT); QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT);
bg_item->setBrush(QBrush(QColor(255, 255, 255))); bg_item->setBrush(QBrush(QColor(255, 255, 255)));
scene.addItem(bg_item); scene.addItem(bg_item);
} }
QGraphicsPixmapItem* name_bgItem = new QGraphicsPixmapItem(QPixmap::fromImage(name_image)); QGraphicsPixmapItem* name_bgItem = new QGraphicsPixmapItem(QPixmap::fromImage(name_image));
bool rot = (idx == 10 || idx == 11); bool rot = (idx == 10 || idx == 11);
name_bgItem->setRotation(rot ? -90 : 0); name_bgItem->setRotation(rot ? -90 : 0);
name_bgItem->setPos(BG_POS[idx]); name_bgItem->setPos(BG_POS[idx]);
scene.addItem(name_bgItem); scene.addItem(name_bgItem);
if (name_info.name1.isEmpty()) { if (name_info.name1.isEmpty()) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(QString().asprintf("Name is Empty at %d", export_times + 1)); msgBox.setText(QString().asprintf("Name is Empty at %d", export_times + 1));
msgBox.exec(); msgBox.exec();
} }
QString name = name_info.name1; QString name = name_info.name1;
int name_len = name.length(); int name_len = name.length();
for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) {
int pos_idx = idx * 2 + j; int pos_idx = idx * 2 + j;
qreal xscale, yscale; qreal xscale, yscale;
xscale = yscale = (j == 1) ? -1 : 1; xscale = yscale = (j == 1) ? -1 : 1;
QPointF pos = name_info.is_number_bg ? NAME_POS_NUMBER[pos_idx] : NAME_POS_NUMBER[pos_idx]; QPointF pos = name_info.is_number_bg ? NAME_POS_NUMBER[pos_idx] : NAME_POS_NUMBER[pos_idx];
qreal y_offset[2] = { 0 }; qreal y_offset[2] = { 0 };
if (name_len == 2) { if (name_len == 2) {
if (!rot) { if (!rot) {
pos.setY(pos.y() + 82.0 * xscale); pos.setY(pos.y() + 82.0 * xscale);
} }
else { else {
pos.setX(pos.x() + 82.0 * xscale); pos.setX(pos.x() + 82.0 * xscale);
} }
y_offset[0] = 25; y_offset[0] = 25;
} }
QGraphicsTextItem* textItem1 = new QGraphicsTextItem(name.mid(0, 1)); QGraphicsTextItem* textItem1 = new QGraphicsTextItem(name.mid(0, 1));
textItem1->setFont(font); textItem1->setFont(font);
textItem1->setDefaultTextColor(font_color); textItem1->setDefaultTextColor(font_color);
if (!rot) { if (!rot) {
textItem1->setPos(pos); textItem1->setPos(pos);
textItem1->setTransform(QTransform::fromScale(xscale, yscale)); textItem1->setTransform(QTransform::fromScale(xscale, yscale));
} }
else { else {
textItem1->setPos(pos); textItem1->setPos(pos);
textItem1->setRotation(-90); textItem1->setRotation(-90);
textItem1->setTransform(QTransform::fromScale(xscale, yscale)); textItem1->setTransform(QTransform::fromScale(xscale, yscale));
} }
scene.addItem(textItem1); scene.addItem(textItem1);
QGraphicsTextItem* textItem2 = new QGraphicsTextItem(name.mid(1, 1)); QGraphicsTextItem* textItem2 = new QGraphicsTextItem(name.mid(1, 1));
textItem2->setFont(font); textItem2->setFont(font);
textItem2->setDefaultTextColor(font_color); textItem2->setDefaultTextColor(font_color);
if (!rot) { if (!rot) {
textItem2->setPos(pos.x(), pos.y() + (145 + y_offset[0]) * xscale); textItem2->setPos(pos.x(), pos.y() + (145 + y_offset[0]) * xscale);
textItem2->setTransform(QTransform::fromScale(xscale, yscale)); textItem2->setTransform(QTransform::fromScale(xscale, yscale));
} }
else { else {
textItem2->setPos(pos.x() + (145 + y_offset[0]) * xscale, pos.y()); textItem2->setPos(pos.x() + (145 + y_offset[0]) * xscale, pos.y());
textItem2->setRotation(-90); textItem2->setRotation(-90);
textItem2->setTransform(QTransform::fromScale(xscale, yscale)); textItem2->setTransform(QTransform::fromScale(xscale, yscale));
} }
scene.addItem(textItem2); scene.addItem(textItem2);
if (name_len > 2) { if (name_len > 2) {
QGraphicsTextItem* textItem3 = new QGraphicsTextItem(name.mid(2, 1)); QGraphicsTextItem* textItem3 = new QGraphicsTextItem(name.mid(2, 1));
textItem3->setFont(font); textItem3->setFont(font);
textItem3->setDefaultTextColor(font_color); textItem3->setDefaultTextColor(font_color);
if (!rot) { if (!rot) {
textItem3->setPos(pos.x(), pos.y() + 290 * xscale); textItem3->setPos(pos.x(), pos.y() + 290 * xscale);
textItem3->setTransform(QTransform::fromScale(xscale, yscale)); textItem3->setTransform(QTransform::fromScale(xscale, yscale));
} }
else { else {
textItem3->setPos(pos.x() + 290 * xscale, pos.y()); textItem3->setPos(pos.x() + 290 * xscale, pos.y());
textItem3->setRotation(-90); textItem3->setRotation(-90);
textItem3->setTransform(QTransform::fromScale(xscale, yscale)); textItem3->setTransform(QTransform::fromScale(xscale, yscale));
} }
scene.addItem(textItem3); scene.addItem(textItem3);
} }
} }
bool is_export_page = ((idx + 1) % BG_POS_COUNT == 0); bool is_export_page = ((idx + 1) % BG_POS_COUNT == 0);
if (is_export_page || n == nameList.count() - 1) { if (is_export_page || n == nameList.count() - 1) {
QString date_str = QDateTime::currentDateTime().toString("MMddhhmm"); QString date_str = QDateTime::currentDateTime().toString("MMddhhmm");
QString file_name = QString("Signal_%2_%1.jpg").arg(QString::number(export_times + 1), date_str); QString file_name = QString("Signal_%2_%1.jpg").arg(QString::number(export_times + 1), date_str);
saveToImage(file_name, &scene); saveToImage(file_name, &scene);
export_times++; export_times++;
scene.clear(); scene.clear();
} }
} }
} }
break; break;
case Name_zh_eng: case Name_zh_eng:
{ {
QFont _new_font = QFont(this->EnglisthFont()); QFont _new_font = QFont(this->EnglisthFont());
_new_font.setWeight(QFont::ExtraLight); _new_font.setWeight(QFont::ExtraLight);
for (int n = 0; n < nameList.length(); n++) { for (int n = 0; n < nameList.length(); n++) {
int idx = n % BG_POS_COUNT; int idx = n % BG_POS_COUNT;
NameInfo_t name_info = nameList.at(n); NameInfo_t name_info = nameList.at(n);
QImage name_image(name_info.name2); QImage name_image(name_info.name2);
if (idx == 0) { if (idx == 0) {
QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT); QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT);
bg_item->setBrush(QBrush(QColor(255, 255, 255))); bg_item->setBrush(QBrush(QColor(255, 255, 255)));
scene.addItem(bg_item); scene.addItem(bg_item);
} }
QGraphicsPixmapItem* name_bgItem = new QGraphicsPixmapItem(QPixmap::fromImage(name_image)); QGraphicsPixmapItem* name_bgItem = new QGraphicsPixmapItem(QPixmap::fromImage(name_image));
bool rot = (idx == 10 || idx == 11); bool rot = (idx == 10 || idx == 11);
name_bgItem->setRotation(rot ? -90 : 0); name_bgItem->setRotation(rot ? -90 : 0);
name_bgItem->setPos(BG_POS[idx]); name_bgItem->setPos(BG_POS[idx]);
scene.addItem(name_bgItem); scene.addItem(name_bgItem);
if (name_info.name1.isEmpty()) { if (name_info.name1.isEmpty()) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(QString().asprintf("Name is Empty at %d", export_times + 1)); msgBox.setText(QString().asprintf("Name is Empty at %d", export_times + 1));
msgBox.exec(); msgBox.exec();
} }
QString name = name_info.name1; QString name = name_info.name1;
int name_len = name.length(); int name_len = name.length();
for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) {
int pos_idx = idx * 2 + j; int pos_idx = idx * 2 + j;
QPointF pos = NEW_POS; QPointF pos = NEW_POS;
if (j == 0) { if (j == 0) {
qreal xscale, yscale; qreal xscale, yscale;
xscale = yscale = 1; xscale = yscale = 1;
qreal y_offset[2] = { 0 }; qreal y_offset[2] = { 0 };
if (name_len == 2) { if (name_len == 2) {
pos.setY(pos.y() + 82.0 * xscale); pos.setY(pos.y() + 82.0 * xscale);
y_offset[0] = 25; y_offset[0] = 25;
} }
QGraphicsTextItem* textItem1 = new QGraphicsTextItem(name.mid(0, 1), name_bgItem); QGraphicsTextItem* textItem1 = new QGraphicsTextItem(name.mid(0, 1), name_bgItem);
textItem1->setFont(font); textItem1->setFont(font);
textItem1->setDefaultTextColor(font_color); textItem1->setDefaultTextColor(font_color);
textItem1->setPos(pos); textItem1->setPos(pos);
textItem1->setTransform(QTransform::fromScale(xscale, yscale)); textItem1->setTransform(QTransform::fromScale(xscale, yscale));
//scene.addItem(textItem1); //scene.addItem(textItem1);
QGraphicsTextItem* textItem2 = new QGraphicsTextItem(name.mid(1, 1), name_bgItem); QGraphicsTextItem* textItem2 = new QGraphicsTextItem(name.mid(1, 1), name_bgItem);
textItem2->setFont(font); textItem2->setFont(font);
textItem2->setDefaultTextColor(font_color); textItem2->setDefaultTextColor(font_color);
textItem2->setPos(pos.x(), pos.y() + (145 + y_offset[0]) * xscale); textItem2->setPos(pos.x(), pos.y() + (145 + y_offset[0]) * xscale);
textItem2->setTransform(QTransform::fromScale(xscale, yscale)); textItem2->setTransform(QTransform::fromScale(xscale, yscale));
if (name_len > 2) { if (name_len > 2) {
QGraphicsTextItem* textItem3 = new QGraphicsTextItem(name.mid(2, 1), name_bgItem); QGraphicsTextItem* textItem3 = new QGraphicsTextItem(name.mid(2, 1), name_bgItem);
textItem3->setFont(font); textItem3->setFont(font);
textItem3->setDefaultTextColor(font_color); textItem3->setDefaultTextColor(font_color);
textItem3->setPos(pos.x(), pos.y() + 290 * xscale); textItem3->setPos(pos.x(), pos.y() + 290 * xscale);
textItem3->setTransform(QTransform::fromScale(xscale, yscale)); textItem3->setTransform(QTransform::fromScale(xscale, yscale));
} }
} }
else if (j == 1) { else if (j == 1) {
//TODO: add English world //TODO: add English world
QGraphicsTextItem* eng_word_item = new QGraphicsTextItem(name_info.name_eng, name_bgItem); QGraphicsTextItem* eng_word_item = new QGraphicsTextItem(name_info.name_eng, name_bgItem);
int _new_size = getFontSizebyStr(_new_font, 120, 480, name_info.name_eng); int _new_size = getFontSizebyStr(_new_font, 120, 480, name_info.name_eng);
_new_font.setPixelSize(_new_size); _new_font.setPixelSize(_new_size);
eng_word_item->setFont(_new_font); eng_word_item->setFont(_new_font);
eng_word_item->adjustSize(); eng_word_item->adjustSize();
QRectF rect = eng_word_item->boundingRect(); QRectF rect = eng_word_item->boundingRect();
eng_word_item->setDefaultTextColor(font_color); eng_word_item->setDefaultTextColor(font_color);
eng_word_item->setRotation(-90); eng_word_item->setRotation(-90);
// the position export from web is different. // the position export from web is different.
eng_word_item->setPos((name_bgItem->boundingRect().width()/2 - rect.height()/2)+20, 1230 + rect.width() / 2); eng_word_item->setPos((name_bgItem->boundingRect().width()/2 - rect.height()/2)+20, 1230 + rect.width() / 2);
} }
} }
bool is_export_page = ((idx + 1) % BG_POS_COUNT == 0); bool is_export_page = ((idx + 1) % BG_POS_COUNT == 0);
if (is_export_page || n == nameList.count() - 1) { if (is_export_page || n == nameList.count() - 1) {
QString date_str = QDateTime::currentDateTime().toString("MMddhhmm"); QString date_str = QDateTime::currentDateTime().toString("MMddhhmm");
QString file_name = QString("Signal_%2_%1.jpg").arg(QString::number(export_times + 1), date_str); QString file_name = QString("Signal_%2_%1.jpg").arg(QString::number(export_times + 1), date_str);
saveToImage(file_name, &scene); saveToImage(file_name, &scene);
export_times++; export_times++;
scene.clear(); scene.clear();
} }
} }
} }
break; break;
default: default:
break; break;
} }
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(QString().asprintf("Export Finshed. Count:%d", export_times)); msgBox.setText(QString().asprintf("Export Finshed. Count:%d", export_times));
msgBox.exec(); msgBox.exec();
} }

View File

@ -1,15 +1,15 @@
#pragma once #pragma once
#include "INameCreater.h" #include "INameCreater.h"
class FiveToSingle : public INameCreater class FiveToSingle : public INameCreater
{ {
public: public:
FiveToSingle(); FiveToSingle();
~FiveToSingle(); ~FiveToSingle();
protected: protected:
QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent); QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent);
public: public:
virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color); virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
}; };

View File

@ -1,313 +1,313 @@
#include "HKHolderCreater.h" #include "HKHolderCreater.h"
#include <QTextCodec> #include <QTextCodec>
#include <QTextStream> #include <QTextStream>
#include <QDebug> #include <QDebug>
#include <QMessageBox> #include <QMessageBox>
#include <QDateTime> #include <QDateTime>
#include <QGraphicsPixmapItem> #include <QGraphicsPixmapItem>
#define HK_BG_WIDTH 2482 #define HK_BG_WIDTH 2482
#define HK_BG_HEIGH 3509 #define HK_BG_HEIGH 3509
#define MAX_COL_IN_ROW 7 #define MAX_COL_IN_ROW 7
#define MAX_LABEL_IN_PAPER 14 #define MAX_LABEL_IN_PAPER 14
#define NAME_TWO_WORD_OFFSET 90.0 #define NAME_TWO_WORD_OFFSET 90.0
#define NAME_THREE_WORD_OFFSET 82.0 #define NAME_THREE_WORD_OFFSET 82.0
#define NAME_TWO_EXT_Y 20.0 #define NAME_TWO_EXT_Y 20.0
#define NAME_TWO_EXT_REV_Y 23.0 #define NAME_TWO_EXT_REV_Y 23.0
static qreal row_x_offset = 132; static qreal row_x_offset = 132;
static qreal row_x_gap = 320; static qreal row_x_gap = 320;
static qreal row_y_offset[] = { 105 , 1615 }; static qreal row_y_offset[] = { 105 , 1615 };
static QPoint NAME_OFFSET_START = QPoint(92, 413); static QPoint NAME_OFFSET_START = QPoint(92, 413);
static QPoint NAME_OFFSET_REVERSE_START = QPoint(179, 1030); static QPoint NAME_OFFSET_REVERSE_START = QPoint(179, 1030);
HKHolderCreater::HKHolderCreater() : INameCreater() HKHolderCreater::HKHolderCreater() : INameCreater()
{ {
label_bg_map["a"] = ":/NameCreater/resource/hk_holder/a.jpg"; label_bg_map["a"] = ":/NameCreater/resource/hk_holder/a.jpg";
label_bg_map["b"] = ":/NameCreater/resource/hk_holder/b.jpg"; label_bg_map["b"] = ":/NameCreater/resource/hk_holder/b.jpg";
label_bg_map["m"] = ":/NameCreater/resource/hk_holder/m.jpg"; label_bg_map["m"] = ":/NameCreater/resource/hk_holder/m.jpg";
label_bg_map["g"] = ":/NameCreater/resource/hk_holder/g.jpg"; label_bg_map["g"] = ":/NameCreater/resource/hk_holder/g.jpg";
label_bg_map["st"] = ":/NameCreater/resource/hk_holder/st.jpg"; label_bg_map["st"] = ":/NameCreater/resource/hk_holder/st.jpg";
label_bg_map["w"] = ":/NameCreater/resource/hk_holder/w.jpg"; label_bg_map["w"] = ":/NameCreater/resource/hk_holder/w.jpg";
label_bg_map["p"] = ":/NameCreater/resource/hk_holder/p.jpg"; label_bg_map["p"] = ":/NameCreater/resource/hk_holder/p.jpg";
label_bg_map["pg"] = ":/NameCreater/resource/hk_holder/pg.jpg"; label_bg_map["pg"] = ":/NameCreater/resource/hk_holder/pg.jpg";
label_bg_map["r"] = ":/NameCreater/resource/hk_holder/r.jpg"; label_bg_map["r"] = ":/NameCreater/resource/hk_holder/r.jpg";
label_bg_map["y"] = ":/NameCreater/resource/hk_holder/y.jpg"; label_bg_map["y"] = ":/NameCreater/resource/hk_holder/y.jpg";
} }
HKHolderCreater::~HKHolderCreater() HKHolderCreater::~HKHolderCreater()
{ {
} }
QList<NameInfo_t> HKHolderCreater::getNameByFileContent(Name_Type_e type, const QByteArray& conetent) QList<NameInfo_t> HKHolderCreater::getNameByFileContent(Name_Type_e type, const QByteArray& conetent)
{ {
QList<NameInfo_t> nameList; QList<NameInfo_t> nameList;
QTextCodec* tc = QTextCodec::codecForName("Big5"); QTextCodec* tc = QTextCodec::codecForName("Big5");
QString codec = tc->toUnicode(conetent.data()); QString codec = tc->toUnicode(conetent.data());
QTextStream stream(&codec); QTextStream stream(&codec);
int row = 0; int row = 0;
while (!stream.atEnd()) while (!stream.atEnd())
{ {
NameInfo_t info; NameInfo_t info;
QString line = stream.readLine(); QString line = stream.readLine();
QString name_tc = line; QString name_tc = line;
QStringList csvList = name_tc.split(','); QStringList csvList = name_tc.split(',');
QString name, eng_name, bg_type; QString name, eng_name, bg_type;
switch (type) { switch (type) {
case Name_zh: case Name_zh:
name = csvList.at(0); name = csvList.at(0);
bg_type = csvList.at(1); bg_type = csvList.at(1);
break; break;
case Name_zh_eng: case Name_zh_eng:
/*name = csvList.at(0); /*name = csvList.at(0);
eng_name = csvList.at(1); eng_name = csvList.at(1);
bg_type = csvList.at(2);*/ bg_type = csvList.at(2);*/
break; break;
case Name_eng: case Name_eng:
//eng_name = csvList.at(0); //eng_name = csvList.at(0);
//bg_type = csvList.at(1); //bg_type = csvList.at(1);
default: default:
break; break;
} }
qDebug() << "row :" << row << " " << name << ", eng: " << eng_name << ", bg_type: " << bg_type; qDebug() << "row :" << row << " " << name << ", eng: " << eng_name << ", bg_type: " << bg_type;
if (name.compare("name") == 0 || eng_name.compare("eng_name") == 0) { if (name.compare("name") == 0 || eng_name.compare("eng_name") == 0) {
//pass first line //pass first line
continue; continue;
} }
info.name1 = name; info.name1 = name;
info.name_eng = eng_name; info.name_eng = eng_name;
info.name2 = bg_type; info.name2 = bg_type;
nameList.append(info); nameList.append(info);
row++; row++;
} }
return nameList; return nameList;
} }
void HKHolderCreater::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color) void HKHolderCreater::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
{ {
int export_times = 0; int export_times = 0;
QList<NameInfo_t> nameList = getNameByFileContent(type, filecontent); QList<NameInfo_t> nameList = getNameByFileContent(type, filecontent);
if (nameList.isEmpty()) { if (nameList.isEmpty()) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(QString("Name is empty ! ").append(filename)); msgBox.setText(QString("Name is empty ! ").append(filename));
msgBox.exec(); msgBox.exec();
} }
QGraphicsScene scene; QGraphicsScene scene;
scene.setBackgroundBrush(QBrush(QColor(255, 255, 255))); scene.setBackgroundBrush(QBrush(QColor(255, 255, 255)));
QGraphicsView view(&scene); QGraphicsView view(&scene);
switch (type) switch (type)
{ {
case Name_zh: case Name_zh:
for (int idx = 0; idx < nameList.length(); idx++) { for (int idx = 0; idx < nameList.length(); idx++) {
if ((idx % MAX_LABEL_IN_PAPER) == 0) { if ((idx % MAX_LABEL_IN_PAPER) == 0) {
QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, HK_BG_WIDTH, HK_BG_HEIGH); QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, HK_BG_WIDTH, HK_BG_HEIGH);
bg_item->setBrush(QBrush(QColor(255, 255, 255))); bg_item->setBrush(QBrush(QColor(255, 255, 255)));
//QGraphicsPixmapItem* bg_item = new QGraphicsPixmapItem(QPixmap(":/NameCreater/resource/hk_holder/sample.jpg")); //QGraphicsPixmapItem* bg_item = new QGraphicsPixmapItem(QPixmap(":/NameCreater/resource/hk_holder/sample.jpg"));
scene.addItem(bg_item); scene.addItem(bg_item);
} }
int re_idx, row_idx, col_idx; int re_idx, row_idx, col_idx;
re_idx = idx % MAX_LABEL_IN_PAPER; re_idx = idx % MAX_LABEL_IN_PAPER;
row_idx = re_idx / MAX_COL_IN_ROW; row_idx = re_idx / MAX_COL_IN_ROW;
col_idx = re_idx % MAX_COL_IN_ROW; col_idx = re_idx % MAX_COL_IN_ROW;
NameInfo_t name_info = nameList.at(idx); NameInfo_t name_info = nameList.at(idx);
QString label_rel_path = label_bg_map[name_info.name2]; QString label_rel_path = label_bg_map[name_info.name2];
QGraphicsPixmapItem* label_item = new QGraphicsPixmapItem(QPixmap(label_rel_path)); QGraphicsPixmapItem* label_item = new QGraphicsPixmapItem(QPixmap(label_rel_path));
label_item->setPos(qreal(row_x_offset + col_idx* row_x_gap), row_y_offset[row_idx]); label_item->setPos(qreal(row_x_offset + col_idx* row_x_gap), row_y_offset[row_idx]);
//label_item->setOpacity(0.5); //label_item->setOpacity(0.5);
scene.addItem(label_item); scene.addItem(label_item);
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
int name_word_len = name_info.name1.length(); int name_word_len = name_info.name1.length();
qreal two_word_y = (name_word_len == 2) ? NAME_TWO_EXT_Y : 0; qreal two_word_y = (name_word_len == 2) ? NAME_TWO_EXT_Y : 0;
qreal two_word_rev_y = (name_word_len == 2) ? NAME_TWO_EXT_REV_Y : 0; qreal two_word_rev_y = (name_word_len == 2) ? NAME_TWO_EXT_REV_Y : 0;
qreal offset_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET : NAME_THREE_WORD_OFFSET; qreal offset_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET : NAME_THREE_WORD_OFFSET;
for (int w = 0; w < name_word_len; w++) { for (int w = 0; w < name_word_len; w++) {
QGraphicsTextItem* word_item = new QGraphicsTextItem(name_info.name1.at(w)); QGraphicsTextItem* word_item = new QGraphicsTextItem(name_info.name1.at(w));
word_item->setFont(font); word_item->setFont(font);
word_item->setDefaultTextColor(font_color); word_item->setDefaultTextColor(font_color);
if (i == 0) { if (i == 0) {
word_item->setPos(label_item->x() + NAME_OFFSET_START.x(), label_item->y() + NAME_OFFSET_START.y() + two_word_y + offset_y * w); word_item->setPos(label_item->x() + NAME_OFFSET_START.x(), label_item->y() + NAME_OFFSET_START.y() + two_word_y + offset_y * w);
} }
else { else {
word_item->setTransform(QTransform().fromScale(-1, -1)); word_item->setTransform(QTransform().fromScale(-1, -1));
word_item->setPos(label_item->x() + NAME_OFFSET_REVERSE_START.x(), label_item->y() + NAME_OFFSET_REVERSE_START.y() - two_word_rev_y - offset_y * w); word_item->setPos(label_item->x() + NAME_OFFSET_REVERSE_START.x(), label_item->y() + NAME_OFFSET_REVERSE_START.y() - two_word_rev_y - offset_y * w);
} }
scene.addItem(word_item); scene.addItem(word_item);
} }
} }
if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) { if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) {
QString date_str = QDateTime::currentDateTime().toString("MMddhhmm"); QString date_str = QDateTime::currentDateTime().toString("MMddhhmm");
QString file_name = QString("HK_%2_%1.jpg").arg(QString::number(export_times + 1), date_str); QString file_name = QString("HK_%2_%1.jpg").arg(QString::number(export_times + 1), date_str);
saveToImage(file_name, &scene); saveToImage(file_name, &scene);
export_times++; export_times++;
scene.clear(); scene.clear();
} }
} }
break; break;
/* /*
case Name_eng: case Name_eng:
for (int idx = 0; idx < nameList.length(); idx++) { for (int idx = 0; idx < nameList.length(); idx++) {
if ((idx % MAX_LABEL_IN_PAPER) == 0) { if ((idx % MAX_LABEL_IN_PAPER) == 0) {
QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT); QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT);
bg_item->setBrush(QBrush(QColor(255, 255, 255))); bg_item->setBrush(QBrush(QColor(255, 255, 255)));
//QGraphicsPixmapItem* bg_item = QGraphicsPixmapItem(QPixmap(BG_SMAPLE_PATH)); //QGraphicsPixmapItem* bg_item = QGraphicsPixmapItem(QPixmap(BG_SMAPLE_PATH));
scene.addItem(bg_item); scene.addItem(bg_item);
} }
NameInfo_t name_info = nameList.at(idx); NameInfo_t name_info = nameList.at(idx);
int col_index = idx % MAX_LABEL_IN_PAPER; int col_index = idx % MAX_LABEL_IN_PAPER;
QString label_rel_path = label_bg_map[name_info.name2]; QString label_rel_path = label_bg_map[name_info.name2];
QGraphicsPixmapItem* label_item = new QGraphicsPixmapItem(QPixmap(label_rel_path)); QGraphicsPixmapItem* label_item = new QGraphicsPixmapItem(QPixmap(label_rel_path));
label_item->setPos(int(LABEL_POS_START.x() + LABEL_POS_X_OFFSET * col_index), int(LABEL_POS_START.y())); label_item->setPos(int(LABEL_POS_START.x() + LABEL_POS_X_OFFSET * col_index), int(LABEL_POS_START.y()));
label_item->setOpacity(1); label_item->setOpacity(1);
scene.addItem(label_item); scene.addItem(label_item);
int chrismas_y_offset = 0; int chrismas_y_offset = 0;
if (name_info.name2.compare("co") == 0 || name_info.name2.compare("ol") == 0 || if (name_info.name2.compare("co") == 0 || name_info.name2.compare("ol") == 0 ||
name_info.name2.compare("st") == 0 || name_info.name2.compare("sn") == 0) { name_info.name2.compare("st") == 0 || name_info.name2.compare("sn") == 0) {
chrismas_y_offset = 30; chrismas_y_offset = 30;
} }
QFont _new_font = QFont(EnglisthFont()); QFont _new_font = QFont(EnglisthFont());
_new_font.setWeight(QFont::ExtraLight); _new_font.setWeight(QFont::ExtraLight);
int _new_size = getFontSizebyStr(_new_font, 120, 480, name_info.name_eng); int _new_size = getFontSizebyStr(_new_font, 120, 480, name_info.name_eng);
_new_font.setPixelSize(_new_size); _new_font.setPixelSize(_new_size);
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
qreal dir = (i == 0) ? -1.0 : 1.0; qreal dir = (i == 0) ? -1.0 : 1.0;
qreal x_offset = (i == 0) ? 290.0 : 170.0; qreal x_offset = (i == 0) ? 290.0 : 170.0;
qreal y_offset = (i == 0) ? 780.0 : 1580.0; qreal y_offset = (i == 0) ? 780.0 : 1580.0;
chrismas_y_offset = (i == 0) ? 1.0 * chrismas_y_offset : -1.0 * chrismas_y_offset; chrismas_y_offset = (i == 0) ? 1.0 * chrismas_y_offset : -1.0 * chrismas_y_offset;
//add English world //add English world
QGraphicsTextItem* eng_word_item = new QGraphicsTextItem(name_info.name_eng); QGraphicsTextItem* eng_word_item = new QGraphicsTextItem(name_info.name_eng);
eng_word_item->setFont(_new_font); eng_word_item->setFont(_new_font);
QRectF rect = eng_word_item->boundingRect(); QRectF rect = eng_word_item->boundingRect();
eng_word_item->setDefaultTextColor(font_color); eng_word_item->setDefaultTextColor(font_color);
eng_word_item->setRotation(i == 0 ? 90 : -90); eng_word_item->setRotation(i == 0 ? 90 : -90);
eng_word_item->setPos(label_item->x() + x_offset - rect.height() / 2.0, label_item->y() + y_offset + chrismas_y_offset + (rect.width() / 2 * dir)); eng_word_item->setPos(label_item->x() + x_offset - rect.height() / 2.0, label_item->y() + y_offset + chrismas_y_offset + (rect.width() / 2 * dir));
scene.addItem(eng_word_item); scene.addItem(eng_word_item);
} }
if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) { if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) {
QString date_str = QDateTime::currentDateTime().toString("MMddhhmm"); QString date_str = QDateTime::currentDateTime().toString("MMddhhmm");
QString file_name = QString("Birthday_%2_%1.jpg").arg(QString::number(export_times + 1), date_str); QString file_name = QString("Birthday_%2_%1.jpg").arg(QString::number(export_times + 1), date_str);
saveToImage(file_name, &scene); saveToImage(file_name, &scene);
export_times++; export_times++;
scene.clear(); scene.clear();
} }
} }
break; break;
case Name_zh_eng: case Name_zh_eng:
for (int idx = 0; idx < nameList.length(); idx++) { for (int idx = 0; idx < nameList.length(); idx++) {
if ((idx % MAX_LABEL_IN_PAPER) == 0) { if ((idx % MAX_LABEL_IN_PAPER) == 0) {
QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT); QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT);
bg_item->setBrush(QBrush(QColor(255, 255, 255))); bg_item->setBrush(QBrush(QColor(255, 255, 255)));
//QGraphicsPixmapItem* bg_item = QGraphicsPixmapItem(QPixmap(BG_SMAPLE_PATH)); //QGraphicsPixmapItem* bg_item = QGraphicsPixmapItem(QPixmap(BG_SMAPLE_PATH));
scene.addItem(bg_item); scene.addItem(bg_item);
} }
NameInfo_t name_info = nameList.at(idx); NameInfo_t name_info = nameList.at(idx);
int col_index = idx % MAX_LABEL_IN_PAPER; int col_index = idx % MAX_LABEL_IN_PAPER;
QString label_rel_path = label_bg_map[name_info.name2]; QString label_rel_path = label_bg_map[name_info.name2];
QGraphicsPixmapItem* label_item = new QGraphicsPixmapItem(QPixmap(label_rel_path)); QGraphicsPixmapItem* label_item = new QGraphicsPixmapItem(QPixmap(label_rel_path));
label_item->setPos(int(LABEL_POS_START.x() + LABEL_POS_X_OFFSET * col_index), int(LABEL_POS_START.y())); label_item->setPos(int(LABEL_POS_START.x() + LABEL_POS_X_OFFSET * col_index), int(LABEL_POS_START.y()));
label_item->setOpacity(1); label_item->setOpacity(1);
scene.addItem(label_item); scene.addItem(label_item);
int chrismas_y_offset = 0; int chrismas_y_offset = 0;
if (name_info.name2.compare("co") == 0 || name_info.name2.compare("ol") == 0 || if (name_info.name2.compare("co") == 0 || name_info.name2.compare("ol") == 0 ||
name_info.name2.compare("st") == 0 || name_info.name2.compare("sn") == 0) { name_info.name2.compare("st") == 0 || name_info.name2.compare("sn") == 0) {
chrismas_y_offset = 30; chrismas_y_offset = 30;
} }
// add ZH word // add ZH word
int name_word_len = name_info.name1.length(); int name_word_len = name_info.name1.length();
qreal two_word_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET / 2 : 0; qreal two_word_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET / 2 : 0;
qreal offset_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET : NAME_THREE_WORD_OFFSET; qreal offset_y = (name_word_len == 2) ? NAME_TWO_WORD_OFFSET : NAME_THREE_WORD_OFFSET;
for (int w = 0; w < name_word_len; w++) { for (int w = 0; w < name_word_len; w++) {
QGraphicsTextItem* word_item = new QGraphicsTextItem(name_info.name1.at(w)); QGraphicsTextItem* word_item = new QGraphicsTextItem(name_info.name1.at(w));
word_item->setFont(font); word_item->setFont(font);
word_item->setDefaultTextColor(font_color); word_item->setDefaultTextColor(font_color);
word_item->setPos(label_item->x() + NAME_OFFSET_START.x(), label_item->y() + NAME_OFFSET_START.y() + two_word_y + chrismas_y_offset + offset_y * w); word_item->setPos(label_item->x() + NAME_OFFSET_START.x(), label_item->y() + NAME_OFFSET_START.y() + two_word_y + chrismas_y_offset + offset_y * w);
scene.addItem(word_item); scene.addItem(word_item);
} }
//TODO: add English world //TODO: add English world
QGraphicsTextItem* eng_word_item = new QGraphicsTextItem(name_info.name_eng); QGraphicsTextItem* eng_word_item = new QGraphicsTextItem(name_info.name_eng);
QFont _new_font = QFont(EnglisthFont()); QFont _new_font = QFont(EnglisthFont());
_new_font.setWeight(QFont::ExtraLight); _new_font.setWeight(QFont::ExtraLight);
int _new_size = getFontSizebyStr(_new_font, 120, 480, name_info.name_eng); int _new_size = getFontSizebyStr(_new_font, 120, 480, name_info.name_eng);
_new_font.setPixelSize(_new_size); _new_font.setPixelSize(_new_size);
eng_word_item->setFont(_new_font); eng_word_item->setFont(_new_font);
QRectF rect = eng_word_item->boundingRect(); QRectF rect = eng_word_item->boundingRect();
eng_word_item->setDefaultTextColor(font_color); eng_word_item->setDefaultTextColor(font_color);
eng_word_item->setRotation(-90); eng_word_item->setRotation(-90);
eng_word_item->setPos(label_item->x() + 170.0 - rect.height() / 2.0, label_item->y() + 1580 - chrismas_y_offset + rect.width() / 2); eng_word_item->setPos(label_item->x() + 170.0 - rect.height() / 2.0, label_item->y() + 1580 - chrismas_y_offset + rect.width() / 2);
scene.addItem(eng_word_item); scene.addItem(eng_word_item);
if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) { if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) {
QString date_str = QDateTime::currentDateTime().toString("MMddhhmm"); QString date_str = QDateTime::currentDateTime().toString("MMddhhmm");
QString file_name = QString("Birthday_%2_%1.jpg").arg(QString::number(export_times + 1), date_str); QString file_name = QString("Birthday_%2_%1.jpg").arg(QString::number(export_times + 1), date_str);
saveToImage(file_name, &scene); saveToImage(file_name, &scene);
export_times++; export_times++;
scene.clear(); scene.clear();
} }
} }
break; break;
*/ */
default: default:
break; break;
} }
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(QString().asprintf("Export Finshed. Count:%d", export_times)); msgBox.setText(QString().asprintf("Export Finshed. Count:%d", export_times));
msgBox.exec(); msgBox.exec();
} }

View File

@ -1,20 +1,20 @@
#pragma once #pragma once
#include "INameCreater.h" #include "INameCreater.h"
#include <QMap> #include <QMap>
class HKHolderCreater : class HKHolderCreater :
public INameCreater public INameCreater
{ {
public: public:
HKHolderCreater(); HKHolderCreater();
~HKHolderCreater(); ~HKHolderCreater();
protected: protected:
QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent); QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent);
public: public:
virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color); virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
private: private:
QMap<QString, QString> label_bg_map; QMap<QString, QString> label_bg_map;
}; };

View File

@ -1,181 +1,179 @@
#include "INameCreater.h" #include "INameCreater.h"
#include <QDebug> #include <QDebug>
#include <QApplication> #include <QApplication>
#include <QPainter> #include <QPainter>
#include <QDateTime> #include <QDateTime>
#include <QBuffer> #include <QBuffer>
#include <QFileDialog> #include <QFileDialog>
#include <QTextCodec> #include <QTextCodec>
#include <QTextStream> #include <QTextStream>
#include <QMessageBox> #include <QMessageBox>
#include <QRegularExpression> #include <QRegularExpression>
#define BG_PATH_FORMAT ":/NameCreater/resource/background_%1.jpg" #define BG_PATH_FORMAT ":/NameCreater/resource/background_%1.jpg"
INameCreater::INameCreater() INameCreater::INameCreater()
{ {
} }
INameCreater::~INameCreater() INameCreater::~INameCreater()
{ {
} }
void INameCreater::saveToImage(const QString& filename, QGraphicsScene* scene) void INameCreater::saveToImage(const QString& filename, QGraphicsScene* scene)
{ {
scene->clearSelection(); // Selections would also render to the file scene->clearSelection(); // Selections would also render to the file
scene->setSceneRect(scene->itemsBoundingRect()); // Re-shrink the scene to it's bounding contents scene->setSceneRect(scene->itemsBoundingRect()); // Re-shrink the scene to it's bounding contents
QImage image(scene->sceneRect().size().toSize(), QImage::Format_ARGB32); // Create the image with the exact size of the shrunk scene QImage image(scene->sceneRect().size().toSize(), QImage::Format_ARGB32); // Create the image with the exact size of the shrunk scene
image.fill(Qt::transparent); // Start all pixels transparent image.fill(Qt::transparent); // Start all pixels transparent
int dpm = 300 / 0.0254; // ~300 DPI int dpm = 300 / 0.0254; // ~300 DPI
image.setDotsPerMeterX(dpm); image.setDotsPerMeterX(dpm);
image.setDotsPerMeterY(dpm); image.setDotsPerMeterY(dpm);
QPainter painter(&image); QPainter painter(&image);
scene->render(&painter); scene->render(&painter);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
QString folder_name = QCoreApplication::applicationDirPath() + "/../../../export_" + QDateTime::currentDateTime().toString("yyyyMMdd"); QString folder_name = QCoreApplication::applicationDirPath() + "/../../../export_" + QDateTime::currentDateTime().toString("yyyyMMdd");
qDebug() << "app director path" <<QCoreApplication::applicationDirPath(); qDebug() << "app director path" <<QCoreApplication::applicationDirPath();
#else #else
QString folder_name = "./";//QCoreApplication::applicationDirPath() + "/export_" + QDateTime::currentDateTime().toString("yyyyMMdd"); QString folder_name = "./";//QCoreApplication::applicationDirPath() + "/export_" + QDateTime::currentDateTime().toString("yyyyMMdd");
#endif #endif
QString savePath = folder_name.append(filename); QString savePath = folder_name.append(filename);
#ifdef Q_OS_WASM #ifdef Q_OS_WASM
QByteArray imageData; QByteArray imageData;
QBuffer buffer(&imageData); QBuffer buffer(&imageData);
buffer.open(QIODevice::WriteOnly); buffer.open(QIODevice::WriteOnly);
QPixmap pixmap = QPixmap::fromImage(image); QPixmap pixmap = QPixmap::fromImage(image);
pixmap.save(&buffer, "JPEG", 100); // You can also use other formats like "JPEG" or "BMP" pixmap.save(&buffer, "JPEG", 100); // You can also use other formats like "JPEG" or "BMP"
QFileDialog::saveFileContent(imageData, savePath); QFileDialog::saveFileContent(imageData, savePath);
#else #else
qDebug()<<"image save path:" << savePath; qDebug()<<"image save path:" << savePath;
image.save(savePath, "JPEG"); image.save(savePath, "JPEG");
#endif #endif
} }
QList<NameInfo_t> INameCreater::getNameByFile(Name_Type_e type, const QString& filename) QList<NameInfo_t> INameCreater::getNameByFile(Name_Type_e type, const QString& filename)
{ {
QList<NameInfo_t> nameList; QList<NameInfo_t> nameList;
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
QString root_path = QCoreApplication::applicationDirPath() + "/../../../"; QString root_path = QCoreApplication::applicationDirPath() + "/../../../";
#else #else
QString root_path = "";//QCoreApplication::applicationDirPath() + "/"; QString root_path = "";//QCoreApplication::applicationDirPath() + "/";
#endif #endif
QFile file(filename); QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) { if (!file.open(QIODevice::ReadOnly)) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(QString("Load file failed!").append(filename)); msgBox.setText(QString("Load file failed!").append(filename));
msgBox.exec(); msgBox.exec();
file.close(); file.close();
return nameList; return nameList;
} }
int row = 0; int row = 0;
QTextCodec* tc = QTextCodec::codecForName("Big5"); QTextCodec* tc = QTextCodec::codecForName("Big5");
while (!file.atEnd()) while (!file.atEnd())
{ {
NameInfo_t info; NameInfo_t info;
QByteArray line = file.readLine(); QByteArray line = file.readLine();
QString name_tc = tc->toUnicode(line); QString name_tc = tc->toUnicode(line);
QStringList csvList = name_tc.split(','); QStringList csvList = name_tc.split(',');
QString name1 = csvList.at(0); QString name1 = csvList.at(0);
QString type_str = csvList.last();//QString::fromLocal8Bit(csvList.last()); QString type_str = csvList.last();//QString::fromLocal8Bit(csvList.last());
qDebug() << "row :" << row << " " << name1; qDebug() << "row :" << row << " " << name1;
type_str = type_str.remove(QRegularExpression("\r")); type_str = type_str.remove(QRegularExpression("\r"));
type_str = type_str.remove(QRegularExpression("\n")); type_str = type_str.remove(QRegularExpression("\n"));
if (name1.compare("name_1") == 0) { if (name1.compare("name_1") == 0) {
continue; continue;
} }
info.name1 = name1; info.name1 = name1;
info.bg_path = QString(BG_PATH_FORMAT).arg(type_str); info.bg_path = QString(BG_PATH_FORMAT).arg(type_str);
info.is_number_bg = type_str[0].isDigit(); info.is_number_bg = type_str[0].isDigit();
nameList.append(info); nameList.append(info);
row++; row++;
} }
file.close(); file.close();
return nameList; return nameList;
} }
QList<NameInfo_t> INameCreater::getNameByFileContent(Name_Type_e type, const QByteArray& conetent) QList<NameInfo_t> INameCreater::getNameByFileContent(Name_Type_e type, const QByteArray& conetent)
{ {
(void)type; (void)type;
QList<NameInfo_t> nameList; QList<NameInfo_t> nameList;
QTextCodec* tc = QTextCodec::codecForName("Big5"); QTextCodec* tc = QTextCodec::codecForName("Big5");
QString codec = tc->toUnicode(conetent.data()); QString codec = tc->toUnicode(conetent.data());
QTextStream stream(&codec); QTextStream stream(&codec);
int row = 0; int row = 0;
while (!stream.atEnd()) while (!stream.atEnd())
{ {
NameInfo_t info; NameInfo_t info;
QString line = stream.readLine(); QString line = stream.readLine();
QString name_tc = line; QString name_tc = line;
QStringList csvList = name_tc.split(','); QStringList csvList = name_tc.split(',');
QString name1 = csvList.at(0); QString name1 = csvList.at(0);
QString type_str = csvList.last();//QString::fromLocal8Bit(csvList.last()); QString type_str = csvList.last();//QString::fromLocal8Bit(csvList.last());
qDebug() << "row :" << row << " " << name1; qDebug() << "row :" << row << " " << name1;
type_str = type_str.remove(QRegularExpression("\r")); type_str = type_str.remove(QRegularExpression("\r"));
type_str = type_str.remove(QRegularExpression("\n")); type_str = type_str.remove(QRegularExpression("\n"));
if (name1.compare("name_1") == 0) { if (name1.compare("name_1") == 0) {
continue; continue;
} }
info.name1 = name1; info.name1 = name1;
info.bg_path = QString(BG_PATH_FORMAT).arg(type_str); info.bg_path = QString(BG_PATH_FORMAT).arg(type_str);
info.is_number_bg = type_str[0].isDigit(); info.is_number_bg = type_str[0].isDigit();
nameList.append(info); nameList.append(info);
row++; row++;
} }
return nameList; return nameList;
} }
void INameCreater::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color) void INameCreater::generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color)
{ {
} }
int INameCreater::getFontSizebyStr(const QFont& font, int max_font_size,int max_label_width, const QString& str) int INameCreater::getFontSizebyStr(const QFont& font, int max_font_size,int max_label_width, const QString& str)
{ {
QFont _font(font); QFont _font(font);
int font_size = max_font_size; int font_size = max_font_size;
while (font_size > 10) { while (font_size > 10) {
_font.setPixelSize(font_size); _font.setPixelSize(font_size);
QFontMetrics fm(_font); QFontMetrics fm(_font);
if (fm.horizontalAdvance(str) <= max_label_width) return font_size; if (fm.horizontalAdvance(str) <= max_label_width) return font_size;
font_size--; font_size--;
} }
return font_size; return font_size;
} }

View File

@ -1,52 +1,52 @@
#pragma once #pragma once
#include <QObject> #include <QObject>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QGraphicsView> #include <QGraphicsView>
#include <QGraphicsRectItem> #include <QGraphicsRectItem>
#include <QCoreApplication> #include <QCoreApplication>
#define BG_WIDTH 3508 #define BG_WIDTH 3508
#define BG_HEIGHT 2481 #define BG_HEIGHT 2481
struct NameInfo_t { struct NameInfo_t {
QString name1; QString name1;
QString name2; QString name2;
QString name_eng; QString name_eng;
QString bg_path; QString bg_path;
bool is_number_bg; bool is_number_bg;
int bg_type; int bg_type;
}; };
enum Name_Type_e { enum Name_Type_e {
Name_zh = 0, Name_zh = 0,
Name_eng, Name_eng,
Name_zh_eng Name_zh_eng
}; };
class INameCreater : public QObject { class INameCreater : public QObject {
public: public:
INameCreater(); INameCreater();
~INameCreater(); ~INameCreater();
void setEnglishFont(const QFont& font) { void setEnglishFont(const QFont& font) {
eng_Font = QFont(font); eng_Font = QFont(font);
} }
QFont EnglisthFont() const { QFont EnglisthFont() const {
return eng_Font; return eng_Font;
} }
void saveToImage(const QString& filename, QGraphicsScene* scene); void saveToImage(const QString& filename, QGraphicsScene* scene);
protected: protected:
QList<NameInfo_t> getNameByFile(Name_Type_e type, const QString& filename); QList<NameInfo_t> getNameByFile(Name_Type_e type, const QString& filename);
QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent); QList<NameInfo_t> getNameByFileContent(Name_Type_e type, const QByteArray& conetent);
virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color); virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
int getFontSizebyStr(const QFont& font, int max_font_size, int max_label_width, const QString& str); int getFontSizebyStr(const QFont& font, int max_font_size, int max_label_width, const QString& str);
private: private:
QFont eng_Font; QFont eng_Font;
}; };

View File

@ -1,322 +1,318 @@
#include "def.h" #include "def.h"
#include "NameCreater.h" #include "NameCreater.h"
#include <QDebug> #include <QDebug>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QFontDatabase> #include <QFontDatabase>
#include <QTextCodec> #include <QTextCodec>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QGraphicsView> #include <QGraphicsView>
#include <QGraphicsPixmapItem> #include <QGraphicsPixmapItem>
#include <QDateTime> #include <QDateTime>
#include <QBuffer> #include <QBuffer>
#include <QRegularExpression> #include <QRegularExpression>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonArray> #include <QJsonArray>
#include <QComboBox> #include <QComboBox>
#include "FiveToSingle.h" #include "FiveToSingle.h"
#include "BirthdayCreater.h" #include "BirthdayCreater.h"
#include "TowelCreater.h" #include "TowelCreater.h"
#include "NewFiveCreater.h" #include "NewFiveCreater.h"
#include "HKHolderCreater.h" #include "HKHolderCreater.h"
#include "customlogo.h" #include "customlogo.h"
#include "customlogo2.h" #include "customlogo2.h"
#define TOWEL_FONT_PATH ":/NameCreater/_exp/W1.ttc" #define TOWEL_FONT_PATH ":/NameCreater/_exp/W1.ttc"
#define ENGLISH_FONT_PATH ":/NameCreater/_exp/FontsFree-Net-Acumin-Pro-Semibold.ttf" #define ENGLISH_FONT_PATH ":/NameCreater/_exp/FontsFree-Net-Acumin-Pro-Semibold.ttf"
#define FONT_SIZE 120 #define FONT_SIZE 120
//#define FONT_CHT_URL "https://bazaar1688.ddns.net/font/TaiwanPearl-SemiBold.ttf" //#define FONT_CHT_URL "https://bazaar1688.ddns.net/font/TaiwanPearl-SemiBold.ttf"
#define FONT_JSON_URL "https://namecreater.bazaar1688.duckdns.org/font/fonts.json" #define FONT_JSON_URL "https://bazaar1688.ddns.net/font/fonts.json"
//#define FONT_CHT_URL "http://45.32.51.135/font/TaiwanPearl-SemiBold.ttf" //#define FONT_CHT_URL "http://45.32.51.135/font/TaiwanPearl-SemiBold.ttf"
static CustomLogo* s_custom_logo_widget = nullptr; NameCreater::NameCreater(QWidget* parent)
: QMainWindow(parent)
NameCreater::NameCreater(QWidget* parent) {
: QMainWindow(parent) ui.setupUi(this);
{
ui.setupUi(this);
ui.scrollAreaWidgetContents->setMinimumSize(ui.frame->size());
ui.scrollAreaWidgetContents->setMinimumSize(ui.frame->size()); connect(ui.fivesingle_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn);
//connect(ui.fiveold_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn);
connect(ui.fivesingle_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); connect(ui.birthday_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn);
//connect(ui.fiveold_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); connect(ui.towel_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn);
connect(ui.birthday_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); connect(ui.fivenew_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn);
connect(ui.towel_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); connect(ui.birthday_zh_eng_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn);
connect(ui.fivenew_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); connect(ui.birthday_eng_eng_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn);
connect(ui.birthday_zh_eng_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); connect(ui.handkerchief_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn);
connect(ui.birthday_eng_eng_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); connect(ui.fivesingle_zh_eng_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn);
connect(ui.handkerchief_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); connect(ui.customlogo_btn, &QPushButton::released, this, &NameCreater::OnClickedCustomLogoBtn);
connect(ui.fivesingle_zh_eng_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); connect(ui.customlogo2_btn, &QPushButton::released, this, &NameCreater::OnClickedCustomLogo2Btn);
connect(ui.customlogo_btn, &QPushButton::released, this, &NameCreater::OnClickedCustomLogoBtn);
connect(ui.customlogo2_btn, &QPushButton::released, this, &NameCreater::OnClickedCustomLogo2Btn); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
connect(ui.font_comboBox, &QComboBox::currentTextChanged, this, &NameCreater::OnFontComboBoxTextChanged);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #else
connect(ui.font_comboBox, &QComboBox::currentTextChanged, this, &NameCreater::OnFontComboBoxTextChanged); connect(ui.font_comboBox, &QComboBox::currentIndexChanged, this, &NameCreater::OnFontComboBoxIndexChanged);
#else #endif
connect(ui.font_comboBox, &QComboBox::currentIndexChanged, this, &NameCreater::OnFontComboBoxIndexChanged); //qDebug()<<"QSslSocket="<<QSslSocket::sslLibraryBuildVersionString();
#endif
//qDebug()<<"QSslSocket="<<QSslSocket::sslLibraryBuildVersionString(); connect(&network_mgr, &QNetworkAccessManager::finished, this, &NameCreater::onFontDownloadFinished);
connect(&network_mgr, &QNetworkAccessManager::finished, this, &NameCreater::onFontDownloadFinished); query_type = 10;
query(QUrl(FONT_JSON_URL), 10);
query_type = 10;
query(QUrl(FONT_JSON_URL), 10); }
} NameCreater::~NameCreater()
{
NameCreater::~NameCreater()
{ }
} void NameCreater::parseFontJson(const QByteArray& data)
{
void NameCreater::parseFontJson(const QByteArray& data) QJsonDocument jsonDoc = QJsonDocument::fromJson(data);
{
QJsonDocument jsonDoc = QJsonDocument::fromJson(data); if (jsonDoc.isNull()) {
qDebug() << "Failed to create JSON doc.";
if (jsonDoc.isNull()) { return;
qDebug() << "Failed to create JSON doc."; }
return;
} if (jsonDoc.isObject()) {
QJsonObject jsonObj = jsonDoc.object();
if (jsonDoc.isObject()) { // Process the JSON object
QJsonObject jsonObj = jsonDoc.object(); qDebug() << "JSON Object:" << jsonObj;
// Process the JSON object }
qDebug() << "JSON Object:" << jsonObj; else if (jsonDoc.isArray()) {
} ui.font_comboBox->clear();
else if (jsonDoc.isArray()) { QJsonArray jsonArray = jsonDoc.array();
ui.font_comboBox->clear();
QJsonArray jsonArray = jsonDoc.array(); foreach(auto val, jsonArray) {
auto obj = val.toObject();
foreach(auto val, jsonArray) { QString n = obj["font_name"].toString();
auto obj = val.toObject(); QString u = obj["font_url"].toString();
QString n = obj["font_name"].toString(); ui.font_comboBox->addItem(n, u);
QString u = obj["font_url"].toString(); }
ui.font_comboBox->addItem(n, u);
} // Process the JSON array
qDebug() << "JSON Array:" << jsonArray;
// Process the JSON array
qDebug() << "JSON Array:" << jsonArray;
}
}
}
} void NameCreater::query(const QUrl& url, int type)
{
void NameCreater::query(const QUrl& url, int type) QNetworkRequest req(url);
{ req.setAttribute(QNetworkRequest::User, QVariant(type));
QNetworkRequest req(url); network_mgr.get(req);
req.setAttribute(QNetworkRequest::User, QVariant(type));
network_mgr.get(req);
}
} void NameCreater::loadFont(const QByteArray& fontdata) {
void NameCreater::loadFont(const QByteArray& fontdata) { int id = QFontDatabase::addApplicationFontFromData(fontdata);
QStringList family_list = QFontDatabase::applicationFontFamilies(id);
int id = QFontDatabase::addApplicationFontFromData(fontdata); qDebug() << "font family list:" << family_list;
QStringList family_list = QFontDatabase::applicationFontFamilies(id); QString cht_fontname = family_list.at(0);
qDebug() << "font family list:" << family_list;
QString cht_fontname = family_list.at(0); font = QFont(cht_fontname);
font.setPixelSize(FONT_SIZE);
font = QFont(cht_fontname);
font.setPixelSize(FONT_SIZE); QString font_path = QString(TOWEL_FONT_PATH);
QFile font_res_towel(font_path);
QString font_path = QString(TOWEL_FONT_PATH); if (!font_res_towel.open(QIODevice::ReadOnly)) {
QFile font_res_towel(font_path); QMessageBox msgBox;
if (!font_res_towel.open(QIODevice::ReadOnly)) { msgBox.setText("Can not load font file!" + font_path);
QMessageBox msgBox; msgBox.exec();
msgBox.setText("Can not load font file!" + font_path); font_res_towel.close();
msgBox.exec(); }
font_res_towel.close();
} id = QFontDatabase::addApplicationFontFromData(font_res_towel.readAll());
font_towel = QFont(QFontDatabase::applicationFontFamilies(id).at(0));
id = QFontDatabase::addApplicationFontFromData(font_res_towel.readAll()); font_towel.setPixelSize(240);
font_towel = QFont(QFontDatabase::applicationFontFamilies(id).at(0)); font_towel.setLetterSpacing(QFont::PercentageSpacing, 42);
font_towel.setPixelSize(240);
font_towel.setLetterSpacing(QFont::PercentageSpacing, 42);
font_path = QString(ENGLISH_FONT_PATH);
QFile font_res_eng(font_path);
font_path = QString(ENGLISH_FONT_PATH); if (!font_res_eng.open(QIODevice::ReadOnly)) {
QFile font_res_eng(font_path); QMessageBox msgBox;
if (!font_res_eng.open(QIODevice::ReadOnly)) { msgBox.setText("Can not load font file!" + font_path);
QMessageBox msgBox; msgBox.exec();
msgBox.setText("Can not load font file!" + font_path); font_res_eng.close();
msgBox.exec(); }
font_res_eng.close();
} id = QFontDatabase::addApplicationFontFromData(font_res_eng.readAll());
font_english = QFont(QFontDatabase::applicationFontFamilies(id).at(0));
id = QFontDatabase::addApplicationFontFromData(font_res_eng.readAll());
font_english = QFont(QFontDatabase::applicationFontFamilies(id).at(0));
font_color = QColor(0, 0, 0);
font_color = QColor(0, 0, 0); QFont tital_font = QFont(font);
tital_font.setPixelSize(20);
QFont tital_font = QFont(font);
tital_font.setPixelSize(20); QFont version_font = QFont(font);
version_font.setPixelSize(12);
QFont version_font = QFont(font);
version_font.setPixelSize(12); //ui.tital_label->setFont(tital_font);
//ui.tital_label->setFont(tital_font); char c_font_name[64] = { 0 };
sprintf(c_font_name, "%s", cht_fontname.toStdString().c_str());
char c_font_name[64] = { 0 }; ui.font_name_label->setFont(version_font);
sprintf(c_font_name, "%s", cht_fontname.toStdString().c_str()); ui.font_name_label->setText(QString::fromLocal8Bit(c_font_name));
ui.font_name_label->setFont(version_font);
ui.font_name_label->setText(QString::fromLocal8Bit(c_font_name)); ui.version_label->setFont(version_font);
ui.version_label->setText(VERSION);
ui.version_label->setFont(version_font); ui.font_comboBox->setFont(version_font);
ui.version_label->setText(VERSION);
ui.font_comboBox->setFont(version_font); QList<QLabel*> titals = findChildren<QLabel*>(QRegularExpression("tital_label"));
foreach(auto tital, titals) {
QList<QLabel*> titals = findChildren<QLabel*>(QRegularExpression("tital_label")); tital->setFont(tital_font);
foreach(auto tital, titals) { }
tital->setFont(tital_font);
} qDebug() << "Load Font Succeed!";
qDebug() << "Load Font Succeed!"; }
}
void NameCreater::OnClickedReadBtn() {
auto sender = (QPushButton*)QObject::sender();
void NameCreater::OnClickedReadBtn() {
auto sender = (QPushButton*)QObject::sender(); #ifdef Q_OS_WASM
#ifdef Q_OS_WASM auto fileContentReady = [this, sender](const QString& fileName, const QByteArray& fileContent) {
if (!fileName.isEmpty()) {
auto fileContentReady = [this, sender](const QString& fileName, const QByteArray& fileContent) { this->execCreater(sender, fileName, fileContent);
if (!fileName.isEmpty()) { }
this->execCreater(sender, fileName, fileContent);
} };
QFileDialog::getOpenFileContent("CSV (*.csv)", fileContentReady);
};
QFileDialog::getOpenFileContent("CSV (*.csv)", fileContentReady); #else
QString filename = QFileDialog::getOpenFileName(nullptr, "Open Name File", QDir::currentPath(), "CSV file(*.csv)");
#else if (!filename.isEmpty()) {
QString filename = QFileDialog::getOpenFileName(nullptr, "Open Name File", QDir::currentPath(), "CSV file(*.csv)"); QFile _f(filename);
if (!filename.isEmpty()) { if (_f.open(QIODevice::ReadOnly)) {
QFile _f(filename); execCreater(sender, filename, _f.readAll());
if (_f.open(QIODevice::ReadOnly)) { }
execCreater(sender, filename, _f.readAll()); }
} #endif
} }
#endif
} void NameCreater::execCreater(QObject* sender, const QString& fileName, const QByteArray& fileContent) {
void NameCreater::execCreater(QObject* sender, const QString& fileName, const QByteArray& fileContent) {
// Use fileName and fileContent
if (sender == ui.fivesingle_btn) FiveToSingle().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, this->font, this->font_color);
// Use fileName and fileContent
if (sender == ui.fivesingle_btn) FiveToSingle().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, this->font, this->font_color); if (sender == ui.birthday_btn) BirthdayCreater().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, this->font, this->font_color);
if (sender == ui.fivenew_btn) NewFiveCreater().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, this->font, this->font_color);
if (sender == ui.birthday_btn) BirthdayCreater().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, this->font, this->font_color); if (sender == ui.towel_btn) TowelCreater().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, this->font_towel, this->font_color);
if (sender == ui.fivenew_btn) NewFiveCreater().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, this->font, this->font_color); if (sender == ui.birthday_zh_eng_btn) {
if (sender == ui.towel_btn) TowelCreater().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, this->font_towel, this->font_color); BirthdayCreater creater;
if (sender == ui.birthday_zh_eng_btn) { creater.setEnglishFont(font_english);
BirthdayCreater creater; creater.generaImageFromCSV(Name_Type_e::Name_zh_eng, fileName, fileContent, this->font, this->font_color);
creater.setEnglishFont(font_english); }
creater.generaImageFromCSV(Name_Type_e::Name_zh_eng, fileName, fileContent, this->font, this->font_color); if (sender == ui.birthday_eng_eng_btn) {
} BirthdayCreater b;
if (sender == ui.birthday_eng_eng_btn) { b.setEnglishFont(font_english);
BirthdayCreater b; b.generaImageFromCSV(Name_Type_e::Name_eng, fileName, fileContent, this->font, this->font_color);
b.setEnglishFont(font_english); }
b.generaImageFromCSV(Name_Type_e::Name_eng, fileName, fileContent, this->font, this->font_color); if (sender == ui.handkerchief_btn) {
} QFont newFont(font);
if (sender == ui.handkerchief_btn) { newFont.setPixelSize(78);
QFont newFont(font); QColor newColor(0, 0, 0);
newFont.setPixelSize(78); HKHolderCreater().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, newFont, newColor);
QColor newColor(0, 0, 0); }
HKHolderCreater().generaImageFromCSV(Name_Type_e::Name_zh, fileName, fileContent, newFont, newColor); if (sender == ui.fivesingle_zh_eng_btn) {
} FiveToSingle f;
if (sender == ui.fivesingle_zh_eng_btn) { f.setEnglishFont(this->font_english);
FiveToSingle f; f.generaImageFromCSV(Name_Type_e::Name_zh_eng, fileName, fileContent, this->font, this->font_color);
f.setEnglishFont(this->font_english); return;
f.generaImageFromCSV(Name_Type_e::Name_zh_eng, fileName, fileContent, this->font, this->font_color); }
return;
} }
}
void NameCreater::OnClickedCustomLogoBtn() {
QEventLoop loop;
void NameCreater::OnClickedCustomLogoBtn() { CustomLogo widget(&this->font);
//QEventLoop loop; widget.show();
if (s_custom_logo_widget == nullptr) { connect(&widget, &CustomLogo::finished, &loop, &QEventLoop::quit);
s_custom_logo_widget = new CustomLogo(&this->font); loop.exec();
} qDebug() << "exit event loop";
s_custom_logo_widget->show();
}
//connect(&widget, &CustomLogo::finished, &loop, &QEventLoop::quit);
//loop.exec(); void NameCreater::OnClickedCustomLogo2Btn() {
QEventLoop loop;
} customlogo2 widget(&this->font);
connect(&widget, &CustomLogo::finished, &loop, &QEventLoop::quit);
void NameCreater::OnClickedCustomLogo2Btn() { widget.show();
QEventLoop loop; loop.exec();
customlogo2 widget(&this->font); }
connect(&widget, &CustomLogo::finished, &loop, &QEventLoop::quit);
widget.show(); void NameCreater::onFontDownloadFinished(QNetworkReply* reply) {
loop.exec();
} if (reply->error() == QNetworkReply::NoError) {
QString url = reply->request().url().toString();
void NameCreater::onFontDownloadFinished(QNetworkReply* reply) { int attri = reply->request().attribute(QNetworkRequest::User).toInt();
if (reply->error() == QNetworkReply::NoError) { qDebug() << "req url:" << url << "attribi:" << QString::number(attri);
QString url = reply->request().url().toString();
int attri = reply->request().attribute(QNetworkRequest::User).toInt(); if (url.contains("fonts.json") || attri == 10 || query_type == 10) {
qDebug() << "query fonts json succeed";
qDebug() << "req url:" << url << "attribi:" << QString::number(attri); parseFontJson(reply->readAll());
if (url.contains("fonts.json") || attri == 10 || query_type == 10) { }else if (url.contains(".ttf") || url.contains(".otf") || attri == 20 || query_type == 20) {
qDebug() << "query fonts json succeed"; qDebug() << "query font family succeed";
parseFontJson(reply->readAll()); loadFont(reply->readAll());
}
}else if (url.contains(".ttf") || url.contains(".otf") || attri == 20 || query_type == 20) {
qDebug() << "query font family succeed"; }
loadFont(reply->readAll()); else {
}
QMessageBox msgBox;
} msgBox.setText("Can not load font file!" + reply->errorString());
else { msgBox.exec();
reply->deleteLater();
QMessageBox msgBox;
msgBox.setText("Can not load font file!" + reply->errorString());
msgBox.exec(); return;
reply->deleteLater(); }
}
return;
} void NameCreater::OnFontComboBoxTextChanged(const QString& str)
{
} QComboBox* sender = (QComboBox*)QObject::sender();
QString u = sender->currentData().toString();
void NameCreater::OnFontComboBoxTextChanged(const QString& str) query_type = 20;
{ query(QUrl(u),20);
QComboBox* sender = (QComboBox*)QObject::sender(); }
QString u = sender->currentData().toString();
query_type = 20; void NameCreater::OnFontComboBoxIndexChanged(int idx)
query(QUrl(u),20); {
} QComboBox* sender = (QComboBox*)QObject::sender();
QString u = sender->currentData().toString();
void NameCreater::OnFontComboBoxIndexChanged(int idx) query_type = 20;
{ query(QUrl(u),20);
QComboBox* sender = (QComboBox*)QObject::sender(); }
QString u = sender->currentData().toString();
query_type = 20;
query(QUrl(u),20);
}

View File

@ -1,49 +1,48 @@
#pragma once #pragma once
#include <QtWidgets/QMainWindow> #include <QtWidgets/QMainWindow>
#include "ui_NameCreater.h" #include "ui_NameCreater.h"
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QNetworkReply> #include <QNetworkReply>
class NameCreater : public QMainWindow class NameCreater : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
NameCreater(QWidget *parent = Q_NULLPTR); NameCreater(QWidget *parent = Q_NULLPTR);
~NameCreater(); ~NameCreater();
private: private:
Ui::NameCreaterClass ui; Ui::NameCreaterClass ui;
QFont font, font_towel, font_english; QFont font, font_towel, font_english;
QColor font_color;
QColor font_color;
QNetworkAccessManager network_mgr;
QNetworkAccessManager network_mgr; int query_type;
int query_type;
void query(const QUrl& url, int type = -1);
void query(const QUrl& url, int type = -1);
void loadFont(const QByteArray& fontdata);
void loadFont(const QByteArray& fontdata); void execCreater(QObject*sender, const QString&fileName, const QByteArray &fileContent);
void execCreater(QObject*sender, const QString&fileName, const QByteArray &fileContent); void parseFontJson(const QByteArray& data);
void parseFontJson(const QByteArray& data);
private Q_SLOTS:
private Q_SLOTS: void OnClickedReadBtn();
void OnClickedReadBtn(); void OnClickedCustomLogoBtn();
void OnClickedCustomLogoBtn(); void OnClickedCustomLogo2Btn();
void OnClickedCustomLogo2Btn(); void onFontDownloadFinished(QNetworkReply *reply);
void onFontDownloadFinished(QNetworkReply *reply);
void OnFontComboBoxTextChanged(const QString& str);
void OnFontComboBoxTextChanged(const QString& str); void OnFontComboBoxIndexChanged(int idx);
void OnFontComboBoxIndexChanged(int idx);
};
};

View File

@ -1,37 +1,37 @@
# ---------------------------------------------------- # ----------------------------------------------------
# This file is generated by the Qt Visual Studio Tools. # This file is generated by the Qt Visual Studio Tools.
# ------------------------------------------------------ # ------------------------------------------------------
# This is a reminder that you are using a generated .pro file. # This is a reminder that you are using a generated .pro file.
# Remove it when you are finished editing this file. # Remove it when you are finished editing this file.
message("You are running qmake on a generated .pro file. This may not work!") message("You are running qmake on a generated .pro file. This may not work!")
HEADERS += ./resource.h \ HEADERS += ./resource.h \
$$PWD/def.h \ $$PWD/def.h \
./NameCreater.h \ ./NameCreater.h \
./BirthdayCreater.h \ ./BirthdayCreater.h \
./FiveToSingle.h \ ./FiveToSingle.h \
./INameCreater.h \ ./INameCreater.h \
./OldFiveCreater.h \ ./OldFiveCreater.h \
./TowelCreater.h \ ./TowelCreater.h \
./NewFiveCreater.h \ ./NewFiveCreater.h \
./HKHolderCreater.h \ ./HKHolderCreater.h \
./customlogo.h \ ./customlogo.h \
./customlogo2.h ./customlogo2.h
SOURCES += ./NameCreater.cpp \ SOURCES += ./NameCreater.cpp \
./main.cpp \ ./main.cpp \
./BirthdayCreater.cpp \ ./BirthdayCreater.cpp \
./OldFiveCreater.cpp \ ./OldFiveCreater.cpp \
./FiveToSingle.cpp \ ./FiveToSingle.cpp \
./INameCreater.cpp \ ./INameCreater.cpp \
./TowelCreater.cpp \ ./TowelCreater.cpp \
./NewFiveCreater.cpp \ ./NewFiveCreater.cpp \
./HKHolderCreater.cpp \ ./HKHolderCreater.cpp \
./customlogo.cpp \ ./customlogo.cpp \
./customlogo2.cpp ./customlogo2.cpp
FORMS += ./NameCreater.ui \ FORMS += ./NameCreater.ui \
./customlogo.ui \ ./customlogo.ui \
./customlogo2.ui ./customlogo2.ui
RESOURCES += NameCreater.qrc RESOURCES += NameCreater.qrc

View File

@ -1,27 +1,27 @@
QT += core gui QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets network greaterThan(QT_MAJOR_VERSION, 4): QT += widgets network
greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat
CONFIG += c++11 resources_big CONFIG += c++11 resources_big
# You can make your code fail to compile if it uses deprecated APIs. # You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line. # In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
include(NameCreater.pri) include(NameCreater.pri)
# Default rules for deployment. # Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target !isEmpty(target.path): INSTALLS += target
wasm-emscripten{ wasm-emscripten{
QMAKE_LFLAGS+= -s TOTAL_MEMORY=67108864 QMAKE_LFLAGS+= -s TOTAL_MEMORY=67108864
QMAKE_LFLAGS += -s ALLOW_MEMORY_GROWTH=1 QMAKE_LFLAGS += -s ALLOW_MEMORY_GROWTH=1
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,60 +1,60 @@
// Microsoft Visual C++ generated resource script. // Microsoft Visual C++ generated resource script.
// //
#include "resource.h" #include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS #define APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Generated from the TEXTINCLUDE 2 resource. // Generated from the TEXTINCLUDE 2 resource.
// //
#include "winres.h" #include "winres.h"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS #undef APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ­^¤å (¬ü°ê) resources // ­^¤å (¬ü°ê) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 4, 1 LANGUAGE 4, 1
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// TEXTINCLUDE // TEXTINCLUDE
// //
1 TEXTINCLUDE 1 TEXTINCLUDE
BEGIN BEGIN
"resource.h\0" "resource.h\0"
END END
2 TEXTINCLUDE 2 TEXTINCLUDE
BEGIN BEGIN
"#include ""winres.h""\r\n" "#include ""winres.h""\r\n"
"\0" "\0"
END END
3 TEXTINCLUDE 3 TEXTINCLUDE
BEGIN BEGIN
"\r\n" "\r\n"
"\0" "\0"
END END
#endif // APSTUDIO_INVOKED #endif // APSTUDIO_INVOKED
#endif // ­^¤å (¬ü°ê) resources #endif // ­^¤å (¬ü°ê) resources
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED #ifndef APSTUDIO_INVOKED
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Generated from the TEXTINCLUDE 3 resource. // Generated from the TEXTINCLUDE 3 resource.
// //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED #endif // not APSTUDIO_INVOKED

File diff suppressed because it is too large Load Diff

View File

@ -1,228 +1,226 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64"> <ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32"> <ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release|x64"> <ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>x64</Platform> <Platform>x64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{B66B108B-6DA8-408D-936D-988FF8B6B722}</ProjectGuid> <ProjectGuid>{B66B108B-6DA8-408D-936D-988FF8B6B722}</ProjectGuid>
<Keyword>QtVS_v304</Keyword> <Keyword>QtVS_v304</Keyword>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'">10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'">10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'">10.0.16299.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'">10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)'=='Release|x64'">10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)'=='Release|x64'">10.0</WindowsTargetPlatformVersion>
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild> <QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>NotSet</CharacterSet> </PropertyGroup>
</PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType>
<ConfigurationType>Application</ConfigurationType> <PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v143</PlatformToolset> </PropertyGroup>
</PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType>
<ConfigurationType>Application</ConfigurationType> <PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v143</PlatformToolset> </PropertyGroup>
<CharacterSet>NotSet</CharacterSet> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
</PropertyGroup> <ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(QtMsBuild)\qt_defaults.props" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')"> </ImportGroup>
<Import Project="$(QtMsBuild)\qt_defaults.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="QtSettings">
</ImportGroup> <QtInstall>5.15.2_msvc2019_64</QtInstall>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="QtSettings"> <QtModules>core;gui;widgets;network</QtModules>
<QtInstall>5.15.2_msvc2019_64</QtInstall> <QtBuildConfig>debug</QtBuildConfig>
<QtModules>core;gui;widgets;network</QtModules> </PropertyGroup>
<QtBuildConfig>debug</QtBuildConfig> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="QtSettings">
</PropertyGroup> <QtInstall>$(DefaultQtVersion)</QtInstall>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="QtSettings"> <QtModules>core;gui;widgets;network;core5compat</QtModules>
<QtInstall>$(DefaultQtVersion)</QtInstall> <QtBuildConfig>debug</QtBuildConfig>
<QtModules>core;gui;widgets;network</QtModules> </PropertyGroup>
<QtBuildConfig>debug</QtBuildConfig> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'" Label="QtSettings">
</PropertyGroup> <QtInstall>$(DefaultQtVersion)</QtInstall>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'" Label="QtSettings"> <QtModules>core;gui;widgets</QtModules>
<QtInstall>$(DefaultQtVersion)</QtInstall> <QtBuildConfig>release</QtBuildConfig>
<QtModules>core;gui;widgets</QtModules> </PropertyGroup>
<QtBuildConfig>release</QtBuildConfig> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="QtSettings">
</PropertyGroup> <QtInstall>$(DefaultQtVersion)</QtInstall>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="QtSettings"> <QtModules>core;gui;widgets;network;core5compat</QtModules>
<QtInstall>$(DefaultQtVersion)</QtInstall> <QtBuildConfig>release</QtBuildConfig>
<QtModules>core;gui;widgets;network;core5compat</QtModules> </PropertyGroup>
<QtBuildConfig>release</QtBuildConfig> <Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
</PropertyGroup> <Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')"> </Target>
<Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." /> <ImportGroup Label="ExtensionSettings" />
</Target> <ImportGroup Label="Shared" />
<ImportGroup Label="ExtensionSettings" /> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'">
<ImportGroup Label="Shared" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'"> <Import Project="$(QtMsBuild)\Qt.props" />
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup>
<Import Project="$(QtMsBuild)\Qt.props" /> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
</ImportGroup> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> <Import Project="$(QtMsBuild)\Qt.props" />
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup>
<Import Project="$(QtMsBuild)\Qt.props" /> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'">
</ImportGroup> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'"> <Import Project="$(QtMsBuild)\Qt.props" />
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup>
<Import Project="$(QtMsBuild)\Qt.props" /> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
</ImportGroup> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(QtMsBuild)\Qt.props" />
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup>
<Import Project="$(QtMsBuild)\Qt.props" /> <PropertyGroup Label="UserMacros" />
</ImportGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'">
<PropertyGroup Label="UserMacros" /> <OutDir>$(SolutionDir)_bin\</OutDir>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'"> <IntDir>$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)_bin\</OutDir> </PropertyGroup>
<IntDir>$(Configuration)\</IntDir> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
</PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" /> <OutDir>$(SolutionDir)_bin\</OutDir>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'"> <IntDir>$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)_bin\</OutDir> </PropertyGroup>
<IntDir>$(Configuration)\</IntDir> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PropertyGroup> <PreBuildEvent>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Command>xcopy /y "$(ProjectDir)_exp\*" "$(TargetDir)"</Command>
<PreBuildEvent> </PreBuildEvent>
<Command>xcopy /y "$(ProjectDir)_exp\*" "$(TargetDir)"</Command> <ClCompile>
</PreBuildEvent> <AdditionalOptions>/Zm1000</AdditionalOptions>
<ClCompile> </ClCompile>
<AdditionalOptions>/Zm1000</AdditionalOptions> </ItemDefinitionGroup>
</ClCompile> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</ItemDefinitionGroup> <PreBuildEvent>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Command>xcopy /y "$(ProjectDir)_exp\*" "$(TargetDir)"</Command>
<PreBuildEvent> </PreBuildEvent>
<Command>xcopy /y "$(ProjectDir)_exp\*" "$(TargetDir)"</Command> <ClCompile>
</PreBuildEvent> <AdditionalOptions>/Zm1000</AdditionalOptions>
<ClCompile> </ClCompile>
<AdditionalOptions>/Zm1000</AdditionalOptions> <Link>
</ClCompile> <HeapCommitSize>
<Link> </HeapCommitSize>
<HeapCommitSize> <HeapReserveSize>
</HeapCommitSize> </HeapReserveSize>
<HeapReserveSize> </Link>
</HeapReserveSize> </ItemDefinitionGroup>
</Link> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</ItemDefinitionGroup> <PreBuildEvent>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Command>xcopy /y "$(ProjectDir)_exp\*" "$(TargetDir)"</Command>
<PreBuildEvent> </PreBuildEvent>
<Command>xcopy /y "$(ProjectDir)_exp\*" "$(TargetDir)"</Command> </ItemDefinitionGroup>
</PreBuildEvent> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</ItemDefinitionGroup> <PreBuildEvent>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Command>xcopy /y "$(ProjectDir)_exp\*" "$(TargetDir)"</Command>
<PreBuildEvent> </PreBuildEvent>
<Command>xcopy /y "$(ProjectDir)_exp\*" "$(TargetDir)"</Command> </ItemDefinitionGroup>
</PreBuildEvent> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="Configuration">
</ItemDefinitionGroup> <ClCompile>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="Configuration"> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ClCompile> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <Optimization>Disabled</Optimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<Optimization>Disabled</Optimization> </ClCompile>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> <Link>
</ClCompile> <SubSystem>Windows</SubSystem>
<Link> <GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem> </Link>
<GenerateDebugInformation>true</GenerateDebugInformation> </ItemDefinitionGroup>
</Link> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
</ItemDefinitionGroup> <ClCompile>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ClCompile> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <Optimization>Disabled</Optimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<Optimization>Disabled</Optimization> </ClCompile>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> <Link>
</ClCompile> <SubSystem>Windows</SubSystem>
<Link> <GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem> </Link>
<GenerateDebugInformation>true</GenerateDebugInformation> </ItemDefinitionGroup>
</Link> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'" Label="Configuration">
</ItemDefinitionGroup> <ClCompile>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'" Label="Configuration"> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ClCompile> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <DebugInformationFormat>None</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <Optimization>MaxSpeed</Optimization>
<DebugInformationFormat>None</DebugInformationFormat> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<Optimization>MaxSpeed</Optimization> </ClCompile>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <Link>
</ClCompile> <SubSystem>Windows</SubSystem>
<Link> <GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem> </Link>
<GenerateDebugInformation>false</GenerateDebugInformation> </ItemDefinitionGroup>
</Link> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
</ItemDefinitionGroup> <ClCompile>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ClCompile> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <DebugInformationFormat>None</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <Optimization>MaxSpeed</Optimization>
<DebugInformationFormat>None</DebugInformationFormat> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<Optimization>MaxSpeed</Optimization> </ClCompile>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <Link>
</ClCompile> <SubSystem>Windows</SubSystem>
<Link> <GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem> </Link>
<GenerateDebugInformation>false</GenerateDebugInformation> </ItemDefinitionGroup>
</Link> <ItemGroup>
</ItemDefinitionGroup> <ClCompile Include="BirthdayCreater.cpp" />
<ItemGroup> <ClCompile Include="customlogo.cpp" />
<ClCompile Include="BirthdayCreater.cpp" /> <ClCompile Include="customlogo2.cpp" />
<ClCompile Include="customlogo.cpp" /> <ClCompile Include="HKHolderCreater.cpp" />
<ClCompile Include="customlogo2.cpp" /> <ClCompile Include="NewFiveCreater.cpp" />
<ClCompile Include="HKHolderCreater.cpp" /> <ClCompile Include="OldFiveCreater.cpp" />
<ClCompile Include="NewFiveCreater.cpp" /> <ClCompile Include="TowelCreater.cpp" />
<ClCompile Include="OldFiveCreater.cpp" /> <QtRcc Include="NameCreater.qrc" />
<ClCompile Include="TowelCreater.cpp" /> <QtUic Include="customlogo.ui" />
<QtRcc Include="NameCreater.qrc" /> <QtUic Include="customlogo2.ui" />
<QtUic Include="customlogo.ui" /> <QtUic Include="NameCreater.ui" />
<QtUic Include="customlogo2.ui" /> <QtMoc Include="NameCreater.h" />
<QtUic Include="NameCreater.ui" /> <ClCompile Include="FiveToSingle.cpp" />
<QtMoc Include="NameCreater.h" /> <ClCompile Include="INameCreater.cpp" />
<ClCompile Include="FiveToSingle.cpp" /> <ClCompile Include="NameCreater.cpp" />
<ClCompile Include="INameCreater.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="NameCreater.cpp" /> </ItemGroup>
<ClCompile Include="main.cpp" /> <ItemGroup>
</ItemGroup> <ClInclude Include="BirthdayCreater.h" />
<ItemGroup> <QtMoc Include="customlogo.h" />
<ClInclude Include="BirthdayCreater.h" /> <QtMoc Include="customlogo2.h" />
<QtMoc Include="customlogo.h" /> <ClInclude Include="def.h" />
<QtMoc Include="customlogo2.h" /> <ClInclude Include="FiveToSingle.h" />
<ClInclude Include="def.h" /> <ClInclude Include="HKHolderCreater.h" />
<ClInclude Include="FiveToSingle.h" /> <ClInclude Include="INameCreater.h" />
<ClInclude Include="HKHolderCreater.h" /> <ClInclude Include="NewFiveCreater.h" />
<ClInclude Include="INameCreater.h" /> <ClInclude Include="OldFiveCreater.h" />
<ClInclude Include="NewFiveCreater.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="OldFiveCreater.h" /> <ClInclude Include="TowelCreater.h" />
<ClInclude Include="resource.h" /> </ItemGroup>
<ClInclude Include="TowelCreater.h" /> <ItemGroup>
</ItemGroup> <ResourceCompile Include="NameCreater.rc" />
<ItemGroup> </ItemGroup>
<ResourceCompile Include="NameCreater.rc" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</ItemGroup> <ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(QtMsBuild)\qt.targets" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')"> </ImportGroup>
<Import Project="$(QtMsBuild)\qt.targets" /> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> </Project>

View File

@ -1,124 +1,124 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<Filter Include="Source Files"> <Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter> </Filter>
<Filter Include="Header Files"> <Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter> </Filter>
<Filter Include="Resource Files"> <Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> <Extensions>qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter> </Filter>
<Filter Include="Form Files"> <Filter Include="Form Files">
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier> <UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
<Extensions>ui</Extensions> <Extensions>ui</Extensions>
</Filter> </Filter>
<Filter Include="Translation Files"> <Filter Include="Translation Files">
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier> <UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
<Extensions>ts</Extensions> <Extensions>ts</Extensions>
</Filter> </Filter>
<Filter Include="Creaters"> <Filter Include="Creaters">
<UniqueIdentifier>{c0b8778b-3058-44d2-9adc-b902360289e6}</UniqueIdentifier> <UniqueIdentifier>{c0b8778b-3058-44d2-9adc-b902360289e6}</UniqueIdentifier>
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtRcc Include="NameCreater.qrc"> <QtRcc Include="NameCreater.qrc">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</QtRcc> </QtRcc>
<QtUic Include="NameCreater.ui"> <QtUic Include="NameCreater.ui">
<Filter>Form Files</Filter> <Filter>Form Files</Filter>
</QtUic> </QtUic>
<QtMoc Include="NameCreater.h"> <QtMoc Include="NameCreater.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</QtMoc> </QtMoc>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="main.cpp"> <ClCompile Include="main.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="FiveToSingle.cpp"> <ClCompile Include="FiveToSingle.cpp">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="INameCreater.cpp"> <ClCompile Include="INameCreater.cpp">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="OldFiveCreater.cpp"> <ClCompile Include="OldFiveCreater.cpp">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="NameCreater.cpp"> <ClCompile Include="NameCreater.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="BirthdayCreater.cpp"> <ClCompile Include="BirthdayCreater.cpp">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="TowelCreater.cpp"> <ClCompile Include="TowelCreater.cpp">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="NewFiveCreater.cpp"> <ClCompile Include="NewFiveCreater.cpp">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="HKHolderCreater.cpp"> <ClCompile Include="HKHolderCreater.cpp">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="customlogo.cpp"> <ClCompile Include="customlogo.cpp">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="customlogo2.cpp"> <ClCompile Include="customlogo2.cpp">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="resource.h"> <ClInclude Include="resource.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="FiveToSingle.h"> <ClInclude Include="FiveToSingle.h">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="INameCreater.h"> <ClInclude Include="INameCreater.h">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="OldFiveCreater.h"> <ClInclude Include="OldFiveCreater.h">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="BirthdayCreater.h"> <ClInclude Include="BirthdayCreater.h">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="TowelCreater.h"> <ClInclude Include="TowelCreater.h">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="NewFiveCreater.h"> <ClInclude Include="NewFiveCreater.h">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="HKHolderCreater.h"> <ClInclude Include="HKHolderCreater.h">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="def.h"> <ClInclude Include="def.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="NameCreater.rc"> <ResourceCompile Include="NameCreater.rc">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtUic Include="customlogo.ui"> <QtUic Include="customlogo.ui">
<Filter>Form Files</Filter> <Filter>Form Files</Filter>
</QtUic> </QtUic>
<QtUic Include="customlogo2.ui"> <QtUic Include="customlogo2.ui">
<Filter>Form Files</Filter> <Filter>Form Files</Filter>
</QtUic> </QtUic>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtMoc Include="customlogo.h"> <QtMoc Include="customlogo.h">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</QtMoc> </QtMoc>
<QtMoc Include="customlogo2.h"> <QtMoc Include="customlogo2.h">
<Filter>Creaters</Filter> <Filter>Creaters</Filter>
</QtMoc> </QtMoc>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,39 +1,39 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<QtLastBackgroundBuild>2024-05-14T07:08:49.3700216Z</QtLastBackgroundBuild> <QtLastBackgroundBuild>2024-05-14T07:08:49.3700216Z</QtLastBackgroundBuild>
<QtTouchProperty> <QtTouchProperty>
</QtTouchProperty> </QtTouchProperty>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="QtSettings"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="QtSettings">
<QtLastBackgroundBuild>2024-05-14T07:08:49.6936159Z</QtLastBackgroundBuild> <QtLastBackgroundBuild>2024-05-14T07:08:49.6936159Z</QtLastBackgroundBuild>
<QtTouchProperty> <QtTouchProperty>
</QtTouchProperty> </QtTouchProperty>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<QtLastBackgroundBuild>2024-05-14T07:08:49.8356144Z</QtLastBackgroundBuild> <QtLastBackgroundBuild>2024-05-14T07:08:49.8356144Z</QtLastBackgroundBuild>
<QtTouchProperty> <QtTouchProperty>
</QtTouchProperty> </QtTouchProperty>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="QtSettings"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="QtSettings">
<QtLastBackgroundBuild>2024-05-14T07:08:49.9726151Z</QtLastBackgroundBuild> <QtLastBackgroundBuild>2024-05-14T07:08:49.9726151Z</QtLastBackgroundBuild>
<QtTouchProperty> <QtTouchProperty>
</QtTouchProperty> </QtTouchProperty>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -12,5 +12,8 @@ protected:
public: public:
virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color); virtual void generaImageFromCSV(Name_Type_e type, const QString& filename, const QByteArray& filecontent, const QFont& font, const QColor& font_color);
}; };

View File

@ -1,21 +1,21 @@
name,bg_type name,bg_type
§d¦t°a,a §d¦t°a,a
Á¤_¹ä,m Á¤_¹ä,m
Á¤_¹ä,g Á¤_¹ä,g
Á¤_¹ä,b Á¤_¹ä,b
Á¤_¹ä,w Á¤_¹ä,w
²ÀÇ,r ²ÀÇ,r
¸â¨°ºÓ,pg ¸â¨°ºÓ,pg
¸â¨°ºÓ,y ¸â¨°ºÓ,y
¸â¨°ºÓ,b ¸â¨°ºÓ,b
¸â¨°ºÓ,p ¸â¨°ºÓ,p
¸â¨°ºÓ,g ¸â¨°ºÓ,g
³¯§Ó,st ³¯§Ó,st
³¯¦u§Ó,r ³¯¦u§Ó,r
³¯¦u§Ó,p ³¯¦u§Ó,p
³¯§Ó,r ³¯§Ó,r
§d¨Î¹a,y §d¨Î¹a,y
§d¨Î¹a,y §d¨Î¹a,y
§d¹a,y §d¹a,y
§d¹a,p §d¹a,p
§d¹a,st §d¹a,st

1 name bg_type
2 §d¦t°a a
3 Á¤_¹ä m
4 Á¤_¹ä g
5 Á¤_¹ä b
6 Á¤_¹ä w
7 ²ÀÇ r
8 ¸â¨°ºÓ pg
9 ¸â¨°ºÓ y
10 ¸â¨°ºÓ b
11 ¸â¨°ºÓ p
12 ¸â¨°ºÓ g
13 ³¯§Ó st
14 ³¯¦u§Ó r
15 ³¯¦u§Ó p
16 ³¯§Ó r
17 §d¨Î¹a y
18 §d¨Î¹a y
19 §d¹a y
20 §d¹a p
21 §d¹a st

View File

@ -12,14 +12,6 @@
#include <QColorDialog> #include <QColorDialog>
#define DEMO_BG_PATH ":/NameCreater/resource/custom_logo/bg_1.jpg"
#define KEY_DEMO_BG_ITEM 10
#define KEY_WORD_ITEM 100
#define KEY_WORD_ITEM_X_POS 101
#define KEY_WORD_ITEM_Y_POS 102
#define DEMO_WORD_UNICODE "\u92ea\u96dc\u5152"
static QPointF BG_POS_START = QPointF(159, 61); static QPointF BG_POS_START = QPointF(159, 61);
static QPointF BG_POS_ROT_START = QPointF(900, 2094); static QPointF BG_POS_ROT_START = QPointF(900, 2094);
static qreal BG_WIDTH_OFFSET = 320; static qreal BG_WIDTH_OFFSET = 320;
@ -33,7 +25,6 @@ static QColor FONT_COLOR = QColor(0, 0, 0);
static QColorDialog* s_colorDialog = nullptr; static QColorDialog* s_colorDialog = nullptr;
class QGraphicsCloneTextItem : public QGraphicsTextItem { class QGraphicsCloneTextItem : public QGraphicsTextItem {
public: public:
QGraphicsCloneTextItem(const QString& text, QGraphicsItem* parent = nullptr) : QGraphicsCloneTextItem(const QString& text, QGraphicsItem* parent = nullptr) :
@ -61,17 +52,11 @@ CustomLogo::CustomLogo(QFont* font, QDialog* parent) :
fontColor(QColor(0, 0, 0)) fontColor(QColor(0, 0, 0))
{ {
ui->setupUi(this); ui->setupUi(this);
x_adjust_offset = y_adjust_offset = 0;
onSliderValueChanged(0);
connect(ui->load_bg_btn, &QPushButton::released, this, &CustomLogo::onClickedBtn); connect(ui->load_bg_btn, &QPushButton::released, this, &CustomLogo::onClickedBtn);
connect(ui->load_list_btn, &QPushButton::released, this, &CustomLogo::onClickedBtn); connect(ui->load_list_btn, &QPushButton::released, this, &CustomLogo::onClickedBtn);
connect(ui->color_btn, &QPushButton::released, this, &CustomLogo::onClickedBtn); connect(ui->color_btn, &QPushButton::released, this, &CustomLogo::onClickedBtn);
connect(ui->reset_adjust_btn, &QPushButton::released, this, &CustomLogo::onClickedBtn);
connect(ui->double_checkbox, &QCheckBox::clicked, this, &CustomLogo::onCheckboxClicked);
connect(ui->x_adjust_slider, &QSlider::valueChanged, this, &CustomLogo::onSliderValueChanged);
connect(ui->y_adjust_slider, &QSlider::valueChanged, this, &CustomLogo::onSliderValueChanged);
QFont _f(*font); QFont _f(*font);
@ -84,17 +69,6 @@ CustomLogo::CustomLogo(QFont* font, QDialog* parent) :
ui->color_label->setFont(_f); ui->color_label->setFont(_f);
ui->color_btn->setFont(_f); ui->color_btn->setFont(_f);
ui->double_checkbox->setFont(_f); ui->double_checkbox->setFont(_f);
ui->hor_label->setFont(_f);
ui->vel_label->setFont(_f);
demo_scene.setBackgroundBrush(QBrush(QColor(255, 255, 255)));
ui->demo_graphicsView->setScene(&demo_scene);
QPixmap def_demo_bg(DEMO_BG_PATH);
createDemoGraphicItemBG(def_demo_bg);
} }
@ -112,8 +86,7 @@ void CustomLogo::loadBGFromFile()
else { else {
QPixmap pix; QPixmap pix;
if (pix.loadFromData(fileContent, "JPG")) { if (pix.loadFromData(fileContent, "JPG")) {
//ui->display_label->setPixmap(pix); ui->display_label->setPixmap(pix);
createDemoGraphicItemBG(pix);
} }
else { else {
qDebug() << "Data content not image format"; qDebug() << "Data content not image format";
@ -124,76 +97,6 @@ void CustomLogo::loadBGFromFile()
QFileDialog::getOpenFileContent("Image (*.jpg)", fileContentReady); QFileDialog::getOpenFileContent("Image (*.jpg)", fileContentReady);
} }
void CustomLogo::createDemoGraphicItemBG(const QPixmap& img)
{
demo_scene.clear();
bool isReverse = ui->double_checkbox->isChecked();
QGraphicsPixmapItem* name_bgItem = new QGraphicsPixmapItem(img);
name_bgItem->setData(KEY_DEMO_BG_ITEM, KEY_DEMO_BG_ITEM);
name_bgItem->setPos(10, 10);
demo_scene.addItem(name_bgItem);
QGraphicsRectItem* name_rectItem = NULL, * name_reverse_rectItem = NULL;
name_rectItem = new QGraphicsRectItem(QRectF(0, 0, name_bgItem->boundingRect().width(), name_bgItem->boundingRect().height() / 2), name_bgItem);
name_rectItem->setPen(QPen(QColor(0, 0, 0, 255)));
if (isReverse) {
name_reverse_rectItem = new QGraphicsRectItem(name_rectItem->rect(), name_bgItem);
name_reverse_rectItem->setPen(QPen(QColor(0, 0, 0, 0)));
name_reverse_rectItem->setPos(name_bgItem->boundingRect().width(), name_bgItem->boundingRect().height());
name_reverse_rectItem->setRotation(180);
}
QString name = QString(DEMO_WORD_UNICODE);
int name_len = name.length();
QPointF pos = NAME_OFFSET_START;
qreal y_offset = 0;
if (name_len == 2) {
pos.setY(pos.y() + 65.0);
y_offset = 55;
}
for (int k = 0; k < name_len; k++) {
QGraphicsCloneTextItem* textItem = new QGraphicsCloneTextItem(name.mid(k, 1), name_rectItem);
textItem->setFont(*customFont);
textItem->setDefaultTextColor(fontColor);
qreal _posX = (name_rectItem->boundingRect().width() / 2 - textItem->boundingRect().width() / 2);
qreal _posY = (pos.y()) + k * (EACH_WORD_OFFSET + y_offset);
qDebug() << "Name num:" << QString::number(k) << "PosY:" << QString::number(_posY);
textItem->setData(KEY_WORD_ITEM, QVariant(KEY_WORD_ITEM));
textItem->setData(KEY_WORD_ITEM_X_POS, QVariant(_posX));
textItem->setData(KEY_WORD_ITEM_Y_POS, QVariant(_posY));
textItem->setPos(_posX+x_adjust_offset, _posY+y_adjust_offset);
if (name_reverse_rectItem) {
QGraphicsCloneTextItem* _ti = ((QGraphicsCloneTextItem*)textItem)->clone(name_reverse_rectItem);
_ti->setData(KEY_WORD_ITEM, QVariant(KEY_WORD_ITEM));
_ti->setData(KEY_WORD_ITEM_X_POS, QVariant(_posX));
_ti->setData(KEY_WORD_ITEM_Y_POS, QVariant(_posY));
}
}
}
void CustomLogo::updateDemoGraphicItemBG() {
foreach(QGraphicsItem * item, demo_scene.items()) {
QVariant v = item->data(KEY_WORD_ITEM);
if (v.toInt() == KEY_WORD_ITEM) {
((QGraphicsTextItem*)item)->setDefaultTextColor(fontColor);
qreal _ori_x = item->data(KEY_WORD_ITEM_X_POS).toReal();
qreal _ori_y = item->data(KEY_WORD_ITEM_Y_POS).toReal();
item->setPos(_ori_x + x_adjust_offset, _ori_y + y_adjust_offset);
}
}
}
void CustomLogo::loadListFromFile() void CustomLogo::loadListFromFile()
{ {
auto fileContentReady = [this](const QString& fileName, const QByteArray& fileContent) { auto fileContentReady = [this](const QString& fileName, const QByteArray& fileContent) {
@ -238,17 +141,12 @@ void CustomLogo::gerneraImageFromList(const QList<NameInfo_t>& nameList, Name_Ty
scene.addItem(bg_item); scene.addItem(bg_item);
} }
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QPixmap _bg = ui->display_label->pixmap()->copy();
#else
QPixmap _bg = ui->display_label->pixmap().copy();
#endif //
QPixmap _bg;
foreach(QGraphicsItem * item, demo_scene.items()) {
QVariant v = item->data(KEY_DEMO_BG_ITEM);
if (v.toInt() == KEY_DEMO_BG_ITEM) {
_bg = ((QGraphicsPixmapItem*)item)->pixmap().copy();
break;
}
}
QGraphicsPixmapItem* name_bgItem = new QGraphicsPixmapItem(_bg); QGraphicsPixmapItem* name_bgItem = new QGraphicsPixmapItem(_bg);
@ -284,7 +182,7 @@ void CustomLogo::gerneraImageFromList(const QList<NameInfo_t>& nameList, Name_Ty
qreal _posX = name_rectItem->boundingRect().width() / 2 - textItem->boundingRect().width() / 2; qreal _posX = name_rectItem->boundingRect().width() / 2 - textItem->boundingRect().width() / 2;
qreal _posY = pos.y() + k * (EACH_WORD_OFFSET + y_offset); qreal _posY = pos.y() + k * (EACH_WORD_OFFSET + y_offset);
qDebug() << "Name num:" << QString::number(k) << "PosY:" << QString::number(_posY); qDebug() << "Name num:" << QString::number(k) << "PosY:" << QString::number(_posY);
textItem->setPos(_posX+x_adjust_offset, _posY+y_adjust_offset); textItem->setPos(_posX, _posY);
} }
@ -329,9 +227,7 @@ QList<NameInfo_t> CustomLogo::getNameByFileContent(Name_Type_e type, const QByte
{ {
QList<NameInfo_t> nameList; QList<NameInfo_t> nameList;
QString codec_text = ui->codec_comboBox->currentText(); QTextCodec* tc = QTextCodec::codecForName("Big5");
QTextCodec* tc = QTextCodec::codecForName(codec_text.toStdString().c_str()); // can also using "Utf8" or "Big5" codec
QString codec = tc->toUnicode(conetent.data()); QString codec = tc->toUnicode(conetent.data());
QTextStream stream(&codec); QTextStream stream(&codec);
@ -379,40 +275,6 @@ void CustomLogo::onColorSelected(const QColor& color)
QPalette palette = ui->color_label->palette(); QPalette palette = ui->color_label->palette();
palette.setColor(QPalette::WindowText, fontColor); palette.setColor(QPalette::WindowText, fontColor);
ui->color_label->setPalette(palette); ui->color_label->setPalette(palette);
updateDemoGraphicItemBG();
}
void CustomLogo::onSliderValueChanged(int value)
{
auto slider = QObject::sender();
if (slider == ui->x_adjust_slider) {
x_adjust_offset = value;
}
else if (slider == ui->y_adjust_slider) {
y_adjust_offset = value;
}
ui->x_adjust_label->setText(QString("X: %1").arg(QString::number(x_adjust_offset)));
ui->y_adjust_label->setText(QString("Y: %1").arg(QString::number(y_adjust_offset)));
updateDemoGraphicItemBG();
}
void CustomLogo::onCheckboxClicked(bool click)
{
(void)click;
foreach(QGraphicsItem * item, demo_scene.items()) {
QVariant v = item->data(KEY_DEMO_BG_ITEM);
if (v.toInt() == KEY_DEMO_BG_ITEM) {
QPixmap _bg = ((QGraphicsPixmapItem*)item)->pixmap().copy();
createDemoGraphicItemBG(_bg);
break;
}
}
} }
@ -434,10 +296,6 @@ void CustomLogo::onClickedBtn() {
s_colorDialog->open(); s_colorDialog->open();
} }
else if (sender == ui->reset_adjust_btn) {
ui->x_adjust_slider->setValue(0);
ui->y_adjust_slider->setValue(0);
}
} }

View File

@ -21,13 +21,8 @@ private:
Ui::CustomLogo *ui; Ui::CustomLogo *ui;
QFont* customFont; QFont* customFont;
QColor fontColor; QColor fontColor;
QGraphicsScene demo_scene;
qreal x_adjust_offset, y_adjust_offset;
void loadBGFromFile(); void loadBGFromFile();
void createDemoGraphicItemBG(const QPixmap& img);
void updateDemoGraphicItemBG();
void loadListFromFile(); void loadListFromFile();
void gerneraImageFromList(const QList<NameInfo_t>& nameList, Name_Type_e type); void gerneraImageFromList(const QList<NameInfo_t>& nameList, Name_Type_e type);
@ -37,8 +32,6 @@ protected:
private Q_SLOTS: private Q_SLOTS:
void onClickedBtn(); void onClickedBtn();
void onColorSelected(const QColor& color); void onColorSelected(const QColor& color);
void onSliderValueChanged(int value);
void onCheckboxClicked(bool click);

View File

@ -7,12 +7,31 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>545</width> <width>545</width>
<height>653</height> <height>1741</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<widget class="QLabel" name="display_label">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>293</width>
<height>1715</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="NameCreater.qrc">:/NameCreater/resource/custom_logo/bg_1.jpg</pixmap>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
<widget class="QPushButton" name="load_bg_btn"> <widget class="QPushButton" name="load_bg_btn">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -93,146 +112,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QGraphicsView" name="demo_graphicsView">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>311</width>
<height>561</height>
</rect>
</property>
</widget>
<widget class="QFrame" name="frame">
<property name="geometry">
<rect>
<x>330</x>
<y>410</y>
<width>201</width>
<height>141</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="1" column="0">
<widget class="QLabel" name="hor_label">
<property name="text">
<string>水平</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="x_adjust_slider">
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSlider" name="y_adjust_slider">
<property name="minimum">
<number>-120</number>
</property>
<property name="maximum">
<number>120</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="vel_label">
<property name="text">
<string>垂直</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="x_adjust_label">
<property name="text">
<string>X</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="y_adjust_label">
<property name="text">
<string>Y</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="reset_adjust_btn">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>311</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Codec:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="codec_comboBox">
<item>
<property name="text">
<string>Big5</string>
</property>
</item>
<item>
<property name="text">
<string>Utf8</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
<resources> <resources>
<include location="NameCreater.qrc"/> <include location="NameCreater.qrc"/>

View File

@ -1,7 +1,7 @@
#ifndef DEF_H #ifndef DEF_H
#define DEF_H #define DEF_H
#define VERSION "v2.10.3" #define VERSION "v2.9.2"
#endif // DEF_H #endif // DEF_H

View File

@ -1,14 +1,14 @@
//{{NO_DEPENDENCIES}} //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file. // Microsoft Visual C++ generated include file.
// Used by NameCreater.rc // Used by NameCreater.rc
// Next default values for new objects // Next default values for new objects
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101 #define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif
#endif #endif