diff --git a/CMakeLists.txt b/CMakeLists.txt index 22e3fbb9..c26af331 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ option(BUILD_DOCS "Build documentation" OFF) add_subdirectory(external) add_subdirectory(wxdata) +add_subdirectory(scwx-qt) add_subdirectory(test) if(BUILD_DOCS) diff --git a/scwx-qt/CMakeLists.txt b/scwx-qt/CMakeLists.txt new file mode 100644 index 00000000..80c6ae22 --- /dev/null +++ b/scwx-qt/CMakeLists.txt @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.11) +include(scwx-qt.cmake) diff --git a/scwx-qt/qt6-linguist.cmake b/scwx-qt/qt6-linguist.cmake new file mode 100644 index 00000000..8c348f74 --- /dev/null +++ b/scwx-qt/qt6-linguist.cmake @@ -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() \ No newline at end of file diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake new file mode 100644 index 00000000..4bcf048d --- /dev/null +++ b/scwx-qt/scwx-qt.cmake @@ -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) diff --git a/scwx-qt/source/scwx/qt/main.cpp b/scwx-qt/source/scwx/qt/main.cpp new file mode 100644 index 00000000..791842c6 --- /dev/null +++ b/scwx-qt/source/scwx/qt/main.cpp @@ -0,0 +1,11 @@ +#include "main_window.hpp" + +#include + +int main(int argc, char* argv[]) +{ + QApplication a(argc, argv); + scwx::qt::MainWindow w; + w.show(); + return a.exec(); +} diff --git a/scwx-qt/source/scwx/qt/main_window.cpp b/scwx-qt/source/scwx/qt/main_window.cpp new file mode 100644 index 00000000..8bc166c8 --- /dev/null +++ b/scwx-qt/source/scwx/qt/main_window.cpp @@ -0,0 +1,41 @@ +#include "main_window.hpp" +#include "./ui_main_window.h" + +namespace scwx +{ +namespace qt +{ + +template +class variant +{ +public: + template + inline variant(T&& value) + { + } +}; + +using ValueBase = variant; + +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 diff --git a/scwx-qt/source/scwx/qt/main_window.hpp b/scwx-qt/source/scwx/qt/main_window.hpp new file mode 100644 index 00000000..a89bdaaf --- /dev/null +++ b/scwx-qt/source/scwx/qt/main_window.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include + +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 diff --git a/scwx-qt/source/scwx/qt/main_window.ui b/scwx-qt/source/scwx/qt/main_window.ui new file mode 100644 index 00000000..f28d9ec4 --- /dev/null +++ b/scwx-qt/source/scwx/qt/main_window.ui @@ -0,0 +1,33 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + + 0 + 0 + 800 + 21 + + + + + + + + diff --git a/scwx-qt/ts/scwx_en_US.ts b/scwx-qt/ts/scwx_en_US.ts new file mode 100644 index 00000000..62989f17 --- /dev/null +++ b/scwx-qt/ts/scwx_en_US.ts @@ -0,0 +1,12 @@ + + + + + MainWindow + + + MainWindow + + + + diff --git a/setup-debug.bat b/setup-debug.bat index 31891eed..fb224d41 100644 --- a/setup-debug.bat +++ b/setup-debug.bat @@ -1,5 +1,5 @@ call tools\setup-common.bat mkdir 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 diff --git a/setup-release.bat b/setup-release.bat index 13bc4c34..1022ed11 100644 --- a/setup-release.bat +++ b/setup-release.bat @@ -1,5 +1,5 @@ call tools\setup-common.bat mkdir 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