web assemble testing

This commit is contained in:
shouchih_chen 陳守志 2023-03-31 14:40:23 +08:00
parent d9d110ce04
commit 24639c50b0
10 changed files with 480 additions and 421 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
/*.opendb /*.opendb
/*.db /*.db
/_bin /_bin
/web_build

View File

@ -1,12 +1,27 @@
#include "NameCreater.h" #include "NameCreater.h"
#include <QDebug> #include <QDebug>
#include <QFileDialog>
NameCreater::NameCreater(QWidget *parent) NameCreater::NameCreater(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
{ {
ui.setupUi(this); ui.setupUi(this);
connect(ui.openfile_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn);
qDebug() << ui.label->font().family(); qDebug() << ui.label->font().family();
} }
void NameCreater::OnClickedReadBtn() {
auto fileContentReady = [](const QString &fileName, const QByteArray &fileContent) {
if (fileName.isEmpty()) {
// No file was selected
}
else {
// Use fileName and fileContent
//processCSV(fileName, font, font_color);
}
};
QFileDialog::getOpenFileContent("CSV (*.csv)", fileContentReady);
}

View File

@ -12,4 +12,7 @@ public:
private: private:
Ui::NameCreaterClass ui; Ui::NameCreaterClass ui;
private Q_SLOTS:
void OnClickedReadBtn();
}; };

View File

@ -11,4 +11,4 @@ HEADERS += ./NameCreater.h
SOURCES += ./NameCreater.cpp \ SOURCES += ./NameCreater.cpp \
./main.cpp ./main.cpp
FORMS += ./NameCreater.ui FORMS += ./NameCreater.ui
RESOURCES += ./NameCreater.qrc RESOURCES += NameCreater.qrc

View File

@ -2,7 +2,7 @@ QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11 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.

View File

@ -1,5 +1,6 @@
<RCC> <RCC>
<qresource prefix="/NameCreater"> <qresource prefix="/NameCreater">
<file>_exp/DFYuanStd-W8.otf</file>
<file>resource/background_sample.jpg</file> <file>resource/background_sample.jpg</file>
<file>resource/background_b.jpg</file> <file>resource/background_b.jpg</file>
<file>resource/background_g.jpg</file> <file>resource/background_g.jpg</file>

View File

@ -16,12 +16,20 @@
<property name="windowTitle"> <property name="windowTitle">
<string>NameCreater</string> <string>NameCreater</string>
</property> </property>
<property name="styleSheet">
<string notr="true">color: rgb(0, 0, 0);</string>
</property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<property name="styleSheet">
<string notr="true">QWidget#centralWidget{
background-color: rgb(0, 0, 0);
}</string>
</property>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>240</x> <x>470</x>
<y>220</y> <y>40</y>
<width>441</width> <width>441</width>
<height>261</height> <height>261</height>
</rect> </rect>
@ -33,7 +41,20 @@
<string/> <string/>
</property> </property>
<property name="pixmap"> <property name="pixmap">
<pixmap resource="NameCreater.qrc">:/NameCreater/resource/background.jpg</pixmap> <pixmap>:/NameCreater/resource/background.jpg</pixmap>
</property>
</widget>
<widget class="QPushButton" name="openfile_btn">
<property name="geometry">
<rect>
<x>150</x>
<y>470</y>
<width>181</width>
<height>61</height>
</rect>
</property>
<property name="text">
<string>Open File</string>
</property> </property>
</widget> </widget>
</widget> </widget>
@ -43,9 +64,16 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>977</width> <width>977</width>
<height>22</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionOpen_File"/>
</widget>
<addaction name="menuFile"/>
</widget> </widget>
<widget class="QToolBar" name="mainToolBar"> <widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea"> <attribute name="toolBarArea">
@ -56,6 +84,11 @@
</attribute> </attribute>
</widget> </widget>
<widget class="QStatusBar" name="statusBar"/> <widget class="QStatusBar" name="statusBar"/>
<action name="actionOpen_File">
<property name="text">
<string>Open File</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<resources> <resources>

View File

@ -21,16 +21,16 @@
<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.19041.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'">10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">10.0.19041.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">10.0.19041.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'">10.0.19041.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'">10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)'=='Release|x64'">10.0.19041.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)'=='Release|x64'">10.0.19041.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>v142</PlatformToolset> <PlatformToolset>v140</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>
@ -38,7 +38,7 @@
</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>v142</PlatformToolset> <PlatformToolset>v140</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>
@ -49,7 +49,7 @@
<Import Project="$(QtMsBuild)\qt_defaults.props" /> <Import Project="$(QtMsBuild)\qt_defaults.props" />
</ImportGroup> </ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="QtSettings"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="QtSettings">
<QtInstall>$(DefaultQtVersion)</QtInstall> <QtInstall>5.8_msvc2015</QtInstall>
<QtModules>core;gui;widgets</QtModules> <QtModules>core;gui;widgets</QtModules>
<QtBuildConfig>debug</QtBuildConfig> <QtBuildConfig>debug</QtBuildConfig>
</PropertyGroup> </PropertyGroup>
@ -103,6 +103,9 @@
<PreBuildEvent> <PreBuildEvent>
<Command>xcopy /y "$(ProjectDir)_exp\*" "$(TargetDir)"</Command> <Command>xcopy /y "$(ProjectDir)_exp\*" "$(TargetDir)"</Command>
</PreBuildEvent> </PreBuildEvent>
<ClCompile>
<AdditionalOptions>/Zm1000</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PreBuildEvent> <PreBuildEvent>

View File

@ -17,7 +17,7 @@
<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>2022-02-09T21:34:52.5655210Z</QtLastBackgroundBuild> <QtLastBackgroundBuild>2023-02-07T09:42:35.8095077Z</QtLastBackgroundBuild>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="QtSettings"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="QtSettings">
<QtLastBackgroundBuild>2022-02-09T21:34:52.5655210Z</QtLastBackgroundBuild> <QtLastBackgroundBuild>2022-02-09T21:34:52.5655210Z</QtLastBackgroundBuild>

View File

@ -13,10 +13,12 @@
#include <QFontDatabase> #include <QFontDatabase>
//#define BG_SAMPLE_PATH ":/NameCreater/resource/background_sample.jpg" //#define BG_SAMPLE_PATH ":/NameCreater/resource/background_sample.jpg"
#define BG_SAMPLE_PATH ":/NameCreater/resource/background_number_smaple.jpg" #define BG_SAMPLE_PATH ":/NameCreater/resource/background_number_smaple.jpg"
#define BG_PATH_FORMAT ":/NameCreater/resource/background_%1.jpg" #define BG_PATH_FORMAT ":/NameCreater/resource/background_%1.jpg"
#define FONT_NAME "DFYuanStd-W8.otf" #define FONT_NAME "DFYuanStd-W8.otf"
#define FONT_PATH ":/NameCreater/_exp/DFYuanStd-W8.otf"
#define FONT_SIZE 120 #define FONT_SIZE 120
//#define FONT_SIZE 74 //#define FONT_SIZE 74
@ -112,7 +114,7 @@ QList<NameInfo_t> getNameByFile(const QString& filename) {
#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
@ -161,38 +163,10 @@ QList<NameInfo_t> getNameByFile(const QString& filename) {
return nameList; return nameList;
} }
int main(int argc, char* argv[])
{ void processCSV(const QString& filename, const QFont& font, const QColor& font_color) {
int export_times = 0; int export_times = 0;
QList<NameInfo_t> nameList = getNameByFile(filename);
QApplication a(argc, argv);
// NameCreater w;
// w.show();
#ifdef Q_OS_MAC
QString root_path = QCoreApplication::applicationDirPath() + "/../../../";
#else
QString root_path = QCoreApplication::applicationDirPath() + "/";
#endif
QString font_path = root_path.append(FONT_NAME);
QFile font_res(font_path);
if (!font_res.open(QIODevice::ReadOnly)) {
QMessageBox msgBox;
msgBox.setText("Can not load font file!" + font_path);
msgBox.exec();
font_res.close();
return 0;
}
int id = QFontDatabase::addApplicationFontFromData(font_res.readAll());
QStringList family_list = QFontDatabase::applicationFontFamilies(id);
QFont font = QFont(family_list.at(0));
font.setPixelSize(FONT_SIZE);
QColor font_color(0, 0, 0);
QList<NameInfo_t> nameList = getNameByFile("name.csv");
if (nameList.isEmpty()) { if (nameList.isEmpty()) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(("Name is empty !")); msgBox.setText(("Name is empty !"));
@ -241,7 +215,7 @@ int main(int argc, char* argv[])
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[pos_idx]; QPointF pos = name_info.is_number_bg ? NAME_POS_NUMBER[pos_idx] : NAME_POS[pos_idx];
int y_offset[2] = {0}; int y_offset[2] = { 0 };
if (name_len == 2) { if (name_len == 2) {
if (!rot) { if (!rot) {
pos.setY(pos.y() + 82 * xscale); pos.setY(pos.y() + 82 * xscale);
@ -306,7 +280,7 @@ int main(int argc, char* argv[])
} }
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 file_name = QString("%1_.jpg").arg(QString::number(export_times + 1)); QString file_name = QString("%1_.jpg").arg(QString::number(export_times + 1));
saveToImage(file_name, &scene); saveToImage(file_name, &scene);
export_times++; export_times++;
@ -320,9 +294,38 @@ int main(int argc, char* argv[])
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();
}
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
NameCreater w;
w.show();
#ifdef Q_OS_MAC
QString root_path = QCoreApplication::applicationDirPath() + "/../../../";
#else
//QString root_path = FONT_PATH;//QCoreApplication::applicationDirPath() + "/";
#endif
QString font_path = FONT_PATH; //root_path.append(FONT_NAME);
QFile font_res(font_path);
if (!font_res.open(QIODevice::ReadOnly)) {
QMessageBox msgBox;
msgBox.setText("Can not load font file!" + font_path);
msgBox.exec();
font_res.close(); font_res.close();
return 0; return 0;
}
int id = QFontDatabase::addApplicationFontFromData(font_res.readAll());
QStringList family_list = QFontDatabase::applicationFontFamilies(id);
QFont font = QFont(family_list.at(0));
font.setPixelSize(FONT_SIZE);
QColor font_color(0, 0, 0);
//font_res.close();
return a.exec();
} }