-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
625 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
project(ucwqt VERSION "1.0.0" LANGUAGES CXX) | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
|
||
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) | ||
include(QtCommon) | ||
|
||
fix_project_version() | ||
set(RES_FILES) | ||
add_project_meta(RES_FILES) | ||
# QtCreator supports the following variables for Android, which are identical to qmake Android variables. | ||
# Check http://doc.qt.io/qt-5/deployment-android.html for more information. | ||
# They need to be set before the find_package(Qt5 ...) call. | ||
|
||
#if(ANDROID) | ||
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") | ||
# if (ANDROID_ABI STREQUAL "armeabi-v7a") | ||
# set(ANDROID_EXTRA_LIBS | ||
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so | ||
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so) | ||
# endif() | ||
#endif() | ||
|
||
find_package(Qt5 COMPONENTS Widgets LinguistTools REQUIRED) | ||
|
||
set(TS_FILES ucwqt_zh_CN.ts) | ||
|
||
if(ANDROID) | ||
add_library(ucwqt SHARED | ||
main.cpp | ||
MainWindow.cpp | ||
MainWindow.h | ||
MainWindow.ui | ||
${TS_FILES} | ||
${RES_FILES} | ||
) | ||
else() | ||
add_executable(ucwqt | ||
main.cpp | ||
MainWindow.cpp | ||
MainWindow.h | ||
MainWindow.ui | ||
${TS_FILES} | ||
${RES_FILES} | ||
) | ||
endif() | ||
|
||
target_link_libraries(ucwqt PRIVATE Qt5::Widgets) | ||
|
||
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "MainWindow.h" | ||
#include "./ui_MainWindow.h" | ||
|
||
MainWindow::MainWindow(QWidget *parent) | ||
: QMainWindow(parent) | ||
, ui(new Ui::MainWindow) | ||
{ | ||
ui->setupUi(this); | ||
} | ||
|
||
MainWindow::~MainWindow() | ||
{ | ||
delete ui; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef MAINWINDOW_H | ||
#define MAINWINDOW_H | ||
|
||
#include <QMainWindow> | ||
|
||
QT_BEGIN_NAMESPACE | ||
namespace Ui { class MainWindow; } | ||
QT_END_NAMESPACE | ||
|
||
class MainWindow : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
MainWindow(QWidget *parent = nullptr); | ||
~MainWindow(); | ||
|
||
private: | ||
Ui::MainWindow *ui; | ||
}; | ||
#endif // MAINWINDOW_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>MainWindow</class> | ||
<widget class="QMainWindow" name="MainWindow"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>800</width> | ||
<height>600</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>MainWindow</string> | ||
</property> | ||
<widget class="QWidget" name="centralwidget"/> | ||
<widget class="QMenuBar" name="menubar"/> | ||
<widget class="QStatusBar" name="statusbar"/> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "MyClass.h" | ||
|
||
MyClass::MyClass(QObject *parent) : QObject(parent) | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef MYCLASS_H | ||
#define MYCLASS_H | ||
|
||
#include <QObject> | ||
|
||
class MyClass : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit MyClass(QObject *parent = nullptr); | ||
|
||
signals: | ||
|
||
}; | ||
|
||
#endif // MYCLASS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
macro(fix_project_version) | ||
if (NOT PROJECT_VERSION_PATCH) | ||
set(PROJECT_VERSION_PATCH 0) | ||
endif() | ||
|
||
if (NOT PROJECT_VERSION_TWEAK) | ||
set(PROJECT_VERSION_TWEAK 0) | ||
endif() | ||
endmacro() | ||
|
||
macro(get_git_tag) | ||
execute_process(COMMAND git rev-parse --short HEAD | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
OUTPUT_VARIABLE PACKAGE_GIT_VERSION | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
endmacro(get_git_tag) | ||
|
||
macro(add_project_meta FILES_TO_INCLUDE) | ||
if (NOT RESOURCE_FOLDER) | ||
set(RESOURCE_FOLDER res) | ||
endif() | ||
|
||
if (NOT ICON_NAME) | ||
set(ICON_NAME AppIcon) | ||
endif() | ||
|
||
if (APPLE) | ||
set(ICON_FILE ${RESOURCE_FOLDER}/${ICON_NAME}.icns) | ||
elseif (WIN32) | ||
set(ICON_FILE ${RESOURCE_FOLDER}/${ICON_NAME}.ico) | ||
endif() | ||
|
||
if (WIN32) | ||
configure_file("${PROJECT_SOURCE_DIR}/cmake/windows_metafile.rc.in" | ||
"windows_metafile.rc" | ||
) | ||
set(RES_FILES "windows_metafile.rc") | ||
set(CMAKE_RC_COMPILER_INIT windres) | ||
ENABLE_LANGUAGE(RC) | ||
# SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>") | ||
endif() | ||
|
||
if (APPLE) | ||
set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) | ||
|
||
# Identify MacOS bundle | ||
set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME}) | ||
set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}) | ||
set(MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION}) | ||
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") | ||
set(MACOSX_BUNDLE_COPYRIGHT ${COPYRIGHT}) | ||
set(MACOSX_BUNDLE_GUI_IDENTIFIER ${IDENTIFIER}) | ||
set(MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}) | ||
endif() | ||
|
||
if (APPLE) | ||
set(${FILES_TO_INCLUDE} ${ICON_FILE}) | ||
elseif (WIN32) | ||
set(${FILES_TO_INCLUDE} ${RES_FILES}) | ||
endif() | ||
endmacro(add_project_meta) | ||
|
||
macro(init_os_bundle) | ||
if (APPLE) | ||
set(OS_BUNDLE MACOSX_BUNDLE) | ||
elseif (WIN32) | ||
set(OS_BUNDLE WIN32) | ||
endif() | ||
endmacro(init_os_bundle) | ||
|
||
macro(fix_win_compiler) | ||
if (MSVC) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES | ||
WIN32_EXECUTABLE YES | ||
LINK_FLAGS "/ENTRY:mainCRTStartup" | ||
) | ||
endif() | ||
endmacro() | ||
|
||
macro(init_qt) | ||
# Let's do the CMake job for us | ||
set(CMAKE_AUTOMOC ON) # For meta object compiler | ||
set(CMAKE_AUTORCC ON) # Resource files | ||
set(CMAKE_AUTOUIC ON) # UI files | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
endmacro() | ||
|
||
init_os_bundle() | ||
init_qt() | ||
#fix_win_compiler() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "winver.h" | ||
|
||
IDI_ICON1 ICON DISCARDABLE "@ICON_FILE@" | ||
|
||
VS_VERSION_INFO VERSIONINFO | ||
FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,@PROJECT_VERSION_TWEAK@ | ||
PRODUCTVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,@PROJECT_VERSION_TWEAK@ | ||
FILEFLAGS 0x0L | ||
FILEFLAGSMASK 0x3fL | ||
FILEOS 0x00040004L | ||
FILETYPE 0x1L | ||
FILESUBTYPE 0x0L | ||
BEGIN | ||
BLOCK "StringFileInfo" | ||
BEGIN | ||
BLOCK "000004b0" | ||
BEGIN | ||
VALUE "CompanyName", "@COMPANY@" | ||
VALUE "FileDescription", "@PROJECT_NAME@" | ||
VALUE "FileVersion", "@PROJECT_VERSION@" | ||
VALUE "LegalCopyright", "@COPYRIGHT@" | ||
VALUE "InternalName", "@PROJECT_NAME@" | ||
VALUE "OriginalFilename", "@[email protected]" | ||
VALUE "ProductName", "@PROJECT_NAME@" | ||
VALUE "ProductVersion", "@PROJECT_VERSION@" | ||
END | ||
END | ||
END | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "MainWindow.h" | ||
|
||
#include <QApplication> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QApplication a(argc, argv); | ||
MainWindow w; | ||
w.show(); | ||
return a.exec(); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!DOCTYPE TS> | ||
<TS version="2.1" language="ucwqt_zh_CN"> | ||
<context> | ||
<name>MainWindow</name> | ||
<message> | ||
<location filename="MainWindow.ui" line="14"/> | ||
<source>MainWindow</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
</context> | ||
</TS> |