mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:30:06 +00:00
Add Qt project
This commit is contained in:
parent
9daee7b8c6
commit
760e8a52a1
11 changed files with 296 additions and 2 deletions
|
|
@ -42,6 +42,7 @@ option(BUILD_DOCS "Build documentation" OFF)
|
||||||
|
|
||||||
add_subdirectory(external)
|
add_subdirectory(external)
|
||||||
add_subdirectory(wxdata)
|
add_subdirectory(wxdata)
|
||||||
|
add_subdirectory(scwx-qt)
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|
||||||
if(BUILD_DOCS)
|
if(BUILD_DOCS)
|
||||||
|
|
|
||||||
2
scwx-qt/CMakeLists.txt
Normal file
2
scwx-qt/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
cmake_minimum_required(VERSION 3.11)
|
||||||
|
include(scwx-qt.cmake)
|
||||||
102
scwx-qt/qt6-linguist.cmake
Normal file
102
scwx-qt/qt6-linguist.cmake
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright (C) 2020 The Qt Company Ltd.
|
||||||
|
# Copyright 2005-2011 Kitware, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# * Neither the name of Kitware, Inc. nor the names of its
|
||||||
|
# contributors may be used to endorse or promote products derived
|
||||||
|
# from this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#=============================================================================
|
||||||
|
|
||||||
|
# Modified to remove include directories from translation
|
||||||
|
|
||||||
|
function(qt6_create_translation_scwx _qm_files)
|
||||||
|
set(options)
|
||||||
|
set(oneValueArgs)
|
||||||
|
set(multiValueArgs OPTIONS)
|
||||||
|
|
||||||
|
cmake_parse_arguments(_LUPDATE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
set(_lupdate_files ${_LUPDATE_UNPARSED_ARGUMENTS})
|
||||||
|
set(_lupdate_options ${_LUPDATE_OPTIONS})
|
||||||
|
|
||||||
|
list(FIND _lupdate_options "-extensions" _extensions_index)
|
||||||
|
if(_extensions_index GREATER -1)
|
||||||
|
math(EXPR _extensions_index "${_extensions_index} + 1")
|
||||||
|
list(GET _lupdate_options ${_extensions_index} _extensions_list)
|
||||||
|
string(REPLACE "," ";" _extensions_list "${_extensions_list}")
|
||||||
|
list(TRANSFORM _extensions_list STRIP)
|
||||||
|
list(TRANSFORM _extensions_list REPLACE "^\." "")
|
||||||
|
list(TRANSFORM _extensions_list PREPEND "*.")
|
||||||
|
else()
|
||||||
|
set(_extensions_list "*.java;*.jui;*.ui;*.c;*.c++;*.cc;*.cpp;*.cxx;*.ch;*.h;*.h++;*.hh;*.hpp;*.hxx;*.js;*.qs;*.qml;*.qrc")
|
||||||
|
endif()
|
||||||
|
set(_my_sources)
|
||||||
|
set(_my_tsfiles)
|
||||||
|
foreach(_file ${_lupdate_files})
|
||||||
|
get_filename_component(_ext ${_file} EXT)
|
||||||
|
get_filename_component(_abs_FILE ${_file} ABSOLUTE)
|
||||||
|
if(_ext MATCHES "ts")
|
||||||
|
list(APPEND _my_tsfiles ${_abs_FILE})
|
||||||
|
else()
|
||||||
|
list(APPEND _my_sources ${_abs_FILE})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
foreach(_ts_file ${_my_tsfiles})
|
||||||
|
if(_my_sources)
|
||||||
|
# make a list file to call lupdate on, so we don't make our commands too
|
||||||
|
# long for some systems
|
||||||
|
get_filename_component(_ts_name ${_ts_file} NAME)
|
||||||
|
set(_ts_lst_file "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lst_file")
|
||||||
|
set(_lst_file_srcs)
|
||||||
|
set(_dependencies)
|
||||||
|
foreach(_lst_file_src ${_my_sources})
|
||||||
|
set(_lst_file_srcs "${_lst_file_src}\n${_lst_file_srcs}")
|
||||||
|
if(IS_DIRECTORY ${_lst_file_src})
|
||||||
|
list(TRANSFORM _extensions_list PREPEND "${_lst_file_src}/" OUTPUT_VARIABLE _directory_glob)
|
||||||
|
file(GLOB_RECURSE _directory_contents CONFIGURE_DEPENDS ${_directory_glob})
|
||||||
|
list(APPEND _dependencies ${_directory_contents})
|
||||||
|
else()
|
||||||
|
list(APPEND _dependencies "${_lst_file_src}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
|
||||||
|
# foreach(_pro_include ${_inc_DIRS})
|
||||||
|
# get_filename_component(_abs_include "${_pro_include}" ABSOLUTE)
|
||||||
|
# set(_lst_file_srcs "-I${_pro_include}\n${_lst_file_srcs}")
|
||||||
|
# endforeach()
|
||||||
|
|
||||||
|
file(WRITE ${_ts_lst_file} "${_lst_file_srcs}")
|
||||||
|
endif()
|
||||||
|
add_custom_command(OUTPUT ${_ts_file}
|
||||||
|
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::lupdate
|
||||||
|
ARGS ${_lupdate_options} "@${_ts_lst_file}" -ts ${_ts_file}
|
||||||
|
DEPENDS ${_dependencies}
|
||||||
|
VERBATIM)
|
||||||
|
endforeach()
|
||||||
|
qt6_add_translation(${_qm_files} ${_my_tsfiles})
|
||||||
|
set(${_qm_files} ${${_qm_files}} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
62
scwx-qt/scwx-qt.cmake
Normal file
62
scwx-qt/scwx-qt.cmake
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
cmake_minimum_required(VERSION 3.11)
|
||||||
|
|
||||||
|
project(scwx-qt LANGUAGES CXX)
|
||||||
|
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTORCC ON)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
|
||||||
|
# Check https://doc.qt.io/qt/deployment-android.html for more information.
|
||||||
|
# They need to be set before the find_package( ...) calls below.
|
||||||
|
|
||||||
|
#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(QT NAMES Qt6
|
||||||
|
COMPONENTS Gui
|
||||||
|
LinguistTools
|
||||||
|
Network
|
||||||
|
OpenGL
|
||||||
|
OpenGLWidgets
|
||||||
|
Widgets REQUIRED)
|
||||||
|
|
||||||
|
find_package(Qt${QT_VERSION_MAJOR}
|
||||||
|
COMPONENTS Gui
|
||||||
|
LinguistTools
|
||||||
|
Network
|
||||||
|
OpenGL
|
||||||
|
OpenGLWidgets
|
||||||
|
Widgets
|
||||||
|
REQUIRED)
|
||||||
|
|
||||||
|
include(qt6-linguist.cmake)
|
||||||
|
|
||||||
|
set(TS_FILES ts/scwx_en_US.ts)
|
||||||
|
|
||||||
|
set(PROJECT_SOURCES
|
||||||
|
source/scwx/qt/main.cpp
|
||||||
|
source/scwx/qt/main_window.cpp
|
||||||
|
source/scwx/qt/main_window.hpp
|
||||||
|
source/scwx/qt/main_window.ui
|
||||||
|
${TS_FILES}
|
||||||
|
)
|
||||||
|
|
||||||
|
qt_add_executable(scwx-qt
|
||||||
|
${PROJECT_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
qt6_create_translation_scwx(QM_FILES ${PROJECT_SOURCE_DIR} ${TS_FILES})
|
||||||
|
|
||||||
|
target_link_libraries(scwx-qt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||||
11
scwx-qt/source/scwx/qt/main.cpp
Normal file
11
scwx-qt/source/scwx/qt/main.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "main_window.hpp"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
scwx::qt::MainWindow w;
|
||||||
|
w.show();
|
||||||
|
return a.exec();
|
||||||
|
}
|
||||||
41
scwx-qt/source/scwx/qt/main_window.cpp
Normal file
41
scwx-qt/source/scwx/qt/main_window.cpp
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
#include "main_window.hpp"
|
||||||
|
#include "./ui_main_window.h"
|
||||||
|
|
||||||
|
namespace scwx
|
||||||
|
{
|
||||||
|
namespace qt
|
||||||
|
{
|
||||||
|
|
||||||
|
template<typename... Types>
|
||||||
|
class variant
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
template<typename T>
|
||||||
|
inline variant(T&& value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
using ValueBase = variant<float, double>;
|
||||||
|
|
||||||
|
struct Value : ValueBase
|
||||||
|
{
|
||||||
|
using ValueBase::ValueBase;
|
||||||
|
};
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QWidget* parent) :
|
||||||
|
QMainWindow(parent), ui(new Ui::MainWindow)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
Value(0.0f);
|
||||||
|
Value(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace scwx
|
||||||
30
scwx-qt/source/scwx/qt/main_window.hpp
Normal file
30
scwx-qt/source/scwx/qt/main_window.hpp
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class MainWindow;
|
||||||
|
}
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace scwx
|
||||||
|
{
|
||||||
|
namespace qt
|
||||||
|
{
|
||||||
|
|
||||||
|
class MainWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MainWindow(QWidget* parent = nullptr);
|
||||||
|
~MainWindow();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::MainWindow* ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
} // namespace scwx
|
||||||
33
scwx-qt/source/scwx/qt/main_window.ui
Normal file
33
scwx-qt/source/scwx/qt/main_window.ui
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?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">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>800</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
12
scwx-qt/ts/scwx_en_US.ts
Normal file
12
scwx-qt/ts/scwx_en_US.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="scwx-qt_en_US">
|
||||||
|
<context>
|
||||||
|
<name>MainWindow</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../source/scwx/qt/main_window.ui" line="14"/>
|
||||||
|
<source>MainWindow</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
call tools\setup-common.bat
|
call tools\setup-common.bat
|
||||||
mkdir build-debug
|
mkdir build-debug
|
||||||
cd build-debug
|
cd build-debug
|
||||||
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CONFIGURATION_TYPES=Debug -DCMAKE_PREFIX_PATH=C:\Qt\6.1.0\msvc2019_64 ..
|
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CONFIGURATION_TYPES=Debug -DCMAKE_PREFIX_PATH=C:\Qt\6.1.1\msvc2019_64 ..
|
||||||
pause
|
pause
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
call tools\setup-common.bat
|
call tools\setup-common.bat
|
||||||
mkdir build-release
|
mkdir build-release
|
||||||
cd build-release
|
cd build-release
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES=Release -DCMAKE_PREFIX_PATH=C:\Qt\6.1.0\msvc2019_64 ..
|
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES=Release -DCMAKE_PREFIX_PATH=C:\Qt\6.1.1\msvc2019_64 ..
|
||||||
pause
|
pause
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue