diff --git a/NameCreater/BirthdayCreater.cpp b/NameCreater/BirthdayCreater.cpp index a2b3cf6..5b9323d 100644 --- a/NameCreater/BirthdayCreater.cpp +++ b/NameCreater/BirthdayCreater.cpp @@ -59,7 +59,7 @@ QList BirthdayCreater::getNameByFileContent(Name_Type_e type, const case Name_zh: name = csvList.at(0); bg_type = csvList.at(1); - ; + break; case Name_zh_eng: name = csvList.at(0); @@ -67,6 +67,9 @@ QList BirthdayCreater::getNameByFileContent(Name_Type_e type, const bg_type = csvList.at(2); break; + case Name_eng: + eng_name = csvList.at(0); + bg_type = csvList.at(1); default: break; @@ -74,7 +77,7 @@ QList BirthdayCreater::getNameByFileContent(Name_Type_e type, const qDebug() << "row :" << row << " " << name <<", eng: "<< eng_name << ", bg_type: " << bg_type; - if (name.compare("name") == 0) { + if (name.compare("name") == 0 || eng_name.compare("eng_name")==0) { //pass first line continue; } @@ -164,7 +167,65 @@ void BirthdayCreater::generaImageFromCSV(Name_Type_e type, const QString& filena } } break; - case Name_eng: + case Name_eng: + for (int idx = 0; idx < nameList.length(); idx++) { + + if ((idx % MAX_LABEL_IN_PAPER) == 0) { + + QGraphicsRectItem* bg_item = new QGraphicsRectItem(0, 0, BG_WIDTH, BG_HEIGHT); + bg_item->setBrush(QBrush(QColor(255, 255, 255))); + //QGraphicsPixmapItem* bg_item = QGraphicsPixmapItem(QPixmap(BG_SMAPLE_PATH)); + scene.addItem(bg_item); + + } + NameInfo_t name_info = nameList.at(idx); + int col_index = idx % MAX_LABEL_IN_PAPER; + QString label_rel_path = label_bg_map[name_info.name2]; + 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->setOpacity(1); + scene.addItem(label_item); + + int chrismas_y_offset = 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) { + chrismas_y_offset = 30; + } + + + QFont _new_font = QFont(EnglisthFont()); + _new_font.setWeight(QFont::ExtraLight); + int _new_size = getFontSizebyStr(_new_font, 120, 480, name_info.name_eng); + _new_font.setPixelSize(_new_size); + + for(int i = 0; i < 2; i++){ + qreal dir = (i == 0) ? -1.0:1.0; + qreal x_offset = (i == 0) ? 290.0 : 170.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; + //add English world + QGraphicsTextItem* eng_word_item = new QGraphicsTextItem(name_info.name_eng); + eng_word_item->setFont(_new_font); + QRectF rect = eng_word_item->boundingRect(); + eng_word_item->setDefaultTextColor(font_color); + + 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)); + scene.addItem(eng_word_item); + } + + + + if ((idx % MAX_LABEL_IN_PAPER) == (MAX_LABEL_IN_PAPER - 1) || idx == nameList.count() - 1) { + QString date_str = QDateTime::currentDateTime().toString("MMddhhmm"); + QString file_name = QString("Birthday_%2_%1.jpg").arg(QString::number(export_times + 1), date_str); + saveToImage(file_name, &scene); + export_times++; + scene.clear(); + } + } + + break; case Name_zh_eng: for (int idx = 0; idx < nameList.length(); idx++) { diff --git a/NameCreater/NameCreater.cpp b/NameCreater/NameCreater.cpp index 54b7e52..368f64e 100644 --- a/NameCreater/NameCreater.cpp +++ b/NameCreater/NameCreater.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "FiveToSingle.h" #include "BirthdayCreater.h" @@ -21,7 +22,7 @@ #define ENGLISH_FONT_PATH ":/NameCreater/_exp/FontsFree-Net-Acumin-Pro-Semibold.ttf" #define FONT_SIZE 120 -#define VERSION "v2.1.0" +#define VERSION "v2.1.1" NameCreater::NameCreater(QWidget *parent) @@ -34,6 +35,7 @@ NameCreater::NameCreater(QWidget *parent) connect(ui.towel_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); connect(ui.fivenew_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); connect(ui.birthday_zh_eng_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); + connect(ui.birthday_eng_eng_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn); QString font_path = FONT_PATH; QFile font_res(font_path); @@ -91,7 +93,7 @@ NameCreater::NameCreater(QWidget *parent) ui.version_label->setFont(version_font); ui.version_label->setText(VERSION); - QList titals = findChildren(QRegExp("tital_label")); + QList titals = findChildren(QRegularExpression("tital_label")); foreach(auto tital, titals) { tital->setFont(tital_font); } @@ -121,6 +123,11 @@ void NameCreater::OnClickedReadBtn() { 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; + b.setEnglishFont(font_english); + b.generaImageFromCSV(Name_Type_e::Name_eng, fileName,fileContent,this->font, this->font_color); + } } diff --git a/NameCreater/NameCreater.pro b/NameCreater/NameCreater.pro index d4daa1e..ac9f334 100644 --- a/NameCreater/NameCreater.pro +++ b/NameCreater/NameCreater.pro @@ -17,6 +17,6 @@ qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -QMAKE_LFLAGS+= -s TOTAL_MEMORY=67108864 +#QMAKE_LFLAGS+= -s TOTAL_MEMORY=67108864 diff --git a/NameCreater/NameCreater.pro.user b/NameCreater/NameCreater.pro.user index 267fece..fc67cae 100644 --- a/NameCreater/NameCreater.pro.user +++ b/NameCreater/NameCreater.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -81,10 +81,164 @@ true + + true + ProjectExplorer.Project.Target.0 + + WebAssemblyDeviceType + Qt 5.15.2 WebAssembly + Qt 5.15.2 WebAssembly + qt.qt5.5152.wasm_32_kit + 0 + -1 + 0 + + 0 + /home/shouchih/qt_ws/namecreater/build-NameCreater-Qt_5_15_2_WebAssembly-Debug + /home/shouchih/qt_ws/namecreater/build-NameCreater-Qt_5_15_2_WebAssembly-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /home/shouchih/qt_ws/namecreater/build-NameCreater-Qt_5_15_2_WebAssembly-Release + /home/shouchih/qt_ws/namecreater/build-NameCreater-Qt_5_15_2_WebAssembly-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + /home/shouchih/qt_ws/namecreater/build-NameCreater-Qt_5_15_2_WebAssembly-Profile + /home/shouchih/qt_ws/namecreater/build-NameCreater-Qt_5_15_2_WebAssembly-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + 0 + + true + true + true + + NameCreater + WebAssembly.RunConfiguration.Emrun/home/shouchih/qt_ws/namecreater/NameCreater/NameCreater.pro + /home/shouchih/qt_ws/namecreater/NameCreater/NameCreater.pro + false + true + false + true + firefox + + 1 + + + + ProjectExplorer.Project.Target.1 Desktop Desktop Qt 5.15.2 GCC 64bit @@ -248,157 +402,6 @@ 1 - - ProjectExplorer.Project.Target.1 - - WebAssemblyDeviceType - Qt 5.15.2 WebAssembly - Qt 5.15.2 WebAssembly - qt.qt5.5152.wasm_32_kit - 0 - -1 - 0 - - 0 - /home/shouchih/qt_ws/namecreater/build-NameCreater-Qt_5_15_2_WebAssembly-Debug - /home/shouchih/qt_ws/namecreater/build-NameCreater-Qt_5_15_2_WebAssembly-Debug - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - /home/shouchih/qt_ws/namecreater/build-NameCreater-Qt_5_15_2_WebAssembly-Release - /home/shouchih/qt_ws/namecreater/build-NameCreater-Qt_5_15_2_WebAssembly-Release - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - 0 - - - 0 - /home/shouchih/qt_ws/namecreater/build-NameCreater-Qt_5_15_2_WebAssembly-Profile - /home/shouchih/qt_ws/namecreater/build-NameCreater-Qt_5_15_2_WebAssembly-Profile - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - 0 - 0 - - 3 - 0 - - true - true - true - - NameCreater - WebAssembly.RunConfiguration.Emrun/home/shouchih/qt_ws/namecreater/NameCreater/NameCreater.pro - /home/shouchih/qt_ws/namecreater/NameCreater/NameCreater.pro - false - true - false - true - firefox - - 1 - - ProjectExplorer.Project.TargetCount 2 diff --git a/NameCreater/NameCreater.ui b/NameCreater/NameCreater.ui index bc7ff94..53073cf 100644 --- a/NameCreater/NameCreater.ui +++ b/NameCreater/NameCreater.ui @@ -38,7 +38,6 @@ Yu Gothic UI 10 - 50 false false @@ -60,7 +59,7 @@ 10 40 851 - 521 + 581 @@ -77,6 +76,51 @@ border-color: rgb(255, 255, 255); QFrame::Raised + + + + + Yu Gothic UI + 20 + false + false + + + + color: rgb(255, 255, 255); + + + + 五入組拆成單入產生器 + + + Qt::AlignCenter + + + + + + + + Yu Gothic UI + 20 + false + false + + + + +color: rgb(255, 255, 255); + + + + 生日禮產生器(英/英) + + + Qt::AlignCenter + + + @@ -90,99 +134,12 @@ border-color: rgb(255, 255, 255); - - - - - 0 - 76 - - - - Open File - - - - - - - - 0 - 76 - - - - Open File - - - - - - - - Yu Gothic UI - 20 - 50 - false - false - - - - -color: rgb(255, 255, 255); - - - - 生日禮產生器(中/英) - - - Qt::AlignCenter - - - - - - - - 0 - 76 - - - - Open File - - - - - - - - Yu Gothic UI - 20 - 50 - false - false - - - - color: rgb(255, 255, 255); - - - - 五入組產生器 - - - Qt::AlignCenter - - - Yu Gothic UI 20 - 50 false false @@ -200,36 +157,12 @@ color: rgb(255, 255, 255); - - - - - Yu Gothic UI - 20 - 50 - false - false - - - - color: rgb(255, 255, 255); - - - - 五入組拆成單入產生器 - - - Qt::AlignCenter - - - Yu Gothic UI 20 - 50 false false @@ -259,6 +192,103 @@ color: rgb(255, 255, 255); + + + + + 0 + 76 + + + + Open File + + + + + + + + 0 + 76 + + + + Open File + + + + + + + + 0 + 76 + + + + Open File + + + + + + + + Yu Gothic UI + 20 + false + false + + + + color: rgb(255, 255, 255); + + + + 五入組產生器 + + + Qt::AlignCenter + + + + + + + + Yu Gothic UI + 20 + false + false + + + + +color: rgb(255, 255, 255); + + + + 生日禮產生器(中/英) + + + Qt::AlignCenter + + + + + + + + 0 + 76 + + + + Open File + + + @@ -268,7 +298,7 @@ color: rgb(255, 255, 255); 0 0 946 - 21 + 22 @@ -288,8 +318,6 @@ color: rgb(255, 255, 255); - - - + diff --git a/NameCreater/_exp/生日禮範例_英英.csv b/NameCreater/_exp/生日禮範例_英英.csv new file mode 100644 index 0000000..457a049 --- /dev/null +++ b/NameCreater/_exp/生日禮範例_英英.csv @@ -0,0 +1,21 @@ +eng_name,bg_type +Alice,r +Alice,r +Alice,r +Alice,r +Alice,r +George,sn +George,co +George,ol +George,m +George,y +George,b +Jolin,g +Chirs,m +xxxxxxxdgde,p +gfdgadgdd,r +Jolin,co +Jolin,ol +Jessica,sn +Arial,st +Arial,b