web assemble testing
This commit is contained in:
parent
d9d110ce04
commit
24639c50b0
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
||||
/*.opendb
|
||||
/*.db
|
||||
/_bin
|
||||
/web_build
|
||||
|
||||
@ -1,12 +1,27 @@
|
||||
#include "NameCreater.h"
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
|
||||
|
||||
NameCreater::NameCreater(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(ui.openfile_btn, &QPushButton::released, this, &NameCreater::OnClickedReadBtn);
|
||||
|
||||
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);
|
||||
}
|
||||
@ -12,4 +12,7 @@ public:
|
||||
|
||||
private:
|
||||
Ui::NameCreaterClass ui;
|
||||
|
||||
private Q_SLOTS:
|
||||
void OnClickedReadBtn();
|
||||
};
|
||||
|
||||
@ -11,4 +11,4 @@ HEADERS += ./NameCreater.h
|
||||
SOURCES += ./NameCreater.cpp \
|
||||
./main.cpp
|
||||
FORMS += ./NameCreater.ui
|
||||
RESOURCES += ./NameCreater.qrc
|
||||
RESOURCES += NameCreater.qrc
|
||||
|
||||
@ -2,7 +2,7 @@ QT += core gui
|
||||
|
||||
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.
|
||||
# In order to do so, uncomment the following line.
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/NameCreater">
|
||||
<file>_exp/DFYuanStd-W8.otf</file>
|
||||
<file>resource/background_sample.jpg</file>
|
||||
<file>resource/background_b.jpg</file>
|
||||
<file>resource/background_g.jpg</file>
|
||||
|
||||
@ -16,12 +16,20 @@
|
||||
<property name="windowTitle">
|
||||
<string>NameCreater</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(0, 0, 0);</string>
|
||||
</property>
|
||||
<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">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>220</y>
|
||||
<x>470</x>
|
||||
<y>40</y>
|
||||
<width>441</width>
|
||||
<height>261</height>
|
||||
</rect>
|
||||
@ -33,7 +41,20 @@
|
||||
<string/>
|
||||
</property>
|
||||
<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>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -43,9 +64,16 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>977</width>
|
||||
<height>22</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionOpen_File"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
@ -56,6 +84,11 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionOpen_File">
|
||||
<property name="text">
|
||||
<string>Open File</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
||||
@ -21,16 +21,16 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B66B108B-6DA8-408D-936D-988FF8B6B722}</ProjectGuid>
|
||||
<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)' == '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>
|
||||
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
@ -38,7 +38,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
@ -49,7 +49,7 @@
|
||||
<Import Project="$(QtMsBuild)\qt_defaults.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="QtSettings">
|
||||
<QtInstall>$(DefaultQtVersion)</QtInstall>
|
||||
<QtInstall>5.8_msvc2015</QtInstall>
|
||||
<QtModules>core;gui;widgets</QtModules>
|
||||
<QtBuildConfig>debug</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
@ -103,6 +103,9 @@
|
||||
<PreBuildEvent>
|
||||
<Command>xcopy /y "$(ProjectDir)_exp\*" "$(TargetDir)"</Command>
|
||||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<AdditionalOptions>/Zm1000</AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<PreBuildEvent>
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<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 Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="QtSettings">
|
||||
<QtLastBackgroundBuild>2022-02-09T21:34:52.5655210Z</QtLastBackgroundBuild>
|
||||
|
||||
@ -13,10 +13,12 @@
|
||||
#include <QFontDatabase>
|
||||
|
||||
|
||||
|
||||
//#define BG_SAMPLE_PATH ":/NameCreater/resource/background_sample.jpg"
|
||||
#define BG_SAMPLE_PATH ":/NameCreater/resource/background_number_smaple.jpg"
|
||||
#define BG_PATH_FORMAT ":/NameCreater/resource/background_%1.jpg"
|
||||
#define FONT_NAME "DFYuanStd-W8.otf"
|
||||
#define FONT_PATH ":/NameCreater/_exp/DFYuanStd-W8.otf"
|
||||
#define FONT_SIZE 120
|
||||
//#define FONT_SIZE 74
|
||||
|
||||
@ -112,7 +114,7 @@ QList<NameInfo_t> getNameByFile(const QString& filename) {
|
||||
#ifdef Q_OS_MAC
|
||||
QString root_path = QCoreApplication::applicationDirPath() + "/../../../";
|
||||
#else
|
||||
QString root_path = QCoreApplication::applicationDirPath() + "/";
|
||||
QString root_path = "";//QCoreApplication::applicationDirPath() + "/";
|
||||
#endif
|
||||
|
||||
|
||||
@ -161,38 +163,10 @@ QList<NameInfo_t> getNameByFile(const QString& filename) {
|
||||
return nameList;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
void processCSV(const QString& filename, const QFont& font, const QColor& font_color) {
|
||||
int export_times = 0;
|
||||
|
||||
|
||||
|
||||
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");
|
||||
QList<NameInfo_t> nameList = getNameByFile(filename);
|
||||
if (nameList.isEmpty()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(("Name is empty !"));
|
||||
@ -241,7 +215,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
xscale = yscale = (j == 1) ? -1 : 1;
|
||||
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 (!rot) {
|
||||
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);
|
||||
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));
|
||||
saveToImage(file_name, &scene);
|
||||
export_times++;
|
||||
@ -320,9 +294,38 @@ int main(int argc, char* argv[])
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString().asprintf("Export Finshed. Count:%d", export_times));
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user