Skip to content

Commit

Permalink
Merge pull request #4 from kolod/windows
Browse files Browse the repository at this point in the history
Windows
  • Loading branch information
kolod authored Jun 6, 2024
2 parents dba9654 + 6fbd701 commit 457898a
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 71 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ jobs:
c_compiler: cl

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Qt
uses: jurplel/install-qt-action@v3
uses: jurplel/install-qt-action@v4
with:
version: '6.5.3'
version: '6.7.1'
target: 'desktop'
modules: 'qtcharts qtserialbus qtserialport'

Expand All @@ -69,7 +69,6 @@ jobs:
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}/gui
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/gui/i18n/*
/build-*-Release/
/build-*-Debug/
/gui/build/*
/installer/MSVC2017_*bit/*
76 changes: 53 additions & 23 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.22)

project(ppm-generator VERSION 1.1.0 LANGUAGES CXX)

Expand All @@ -7,14 +7,15 @@ set(PROJECT_DESCRIPTION "The GUI for the Arduino Nano sketch that allows you to
set(PROJECT_AUTHOR "Oleksandr Kolodkin")
set(PROJECT_URL "https://github.com/kolod/Arduino-PPM-Generator")

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
# set(CMAKE_INCLUDE_CURRENT_DIR ON)
# set(CMAKE_AUTOUIC ON)
# set(CMAKE_AUTOMOC ON)
# set(CMAKE_AUTORCC ON)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set(CMAKE_CXX_STANDARD 17)

find_package(Qt6 REQUIRED COMPONENTS Widgets Charts SerialBus SerialPort LinguistTools)
qt_standard_project_setup()

set(TS_FILES
translations/ppm_uk.ts
Expand Down Expand Up @@ -43,16 +44,15 @@ set(PROJECT_SOURCES
ppm.h
${TS_FILES}
${QRC_FILES}
# ${APP_WINDOWS_RESOURCE}
)

if(WIN32)
list(APPEND PROJECT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/resources.rc")
endif()

qt_add_executable(ppm-generator MANUAL_FINALIZATION ${PROJECT_SOURCES})
qt_add_lupdate(ppm-generator TS_FILES ${TS_FILES} OPTIONS -locations relative -no-obsolete)
qt_add_lrelease(ppm-generator TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES OPTIONS -compress -removeidentical)
qt6_add_executable(ppm-generator WIN32 MANUAL_FINALIZATION ${PROJECT_SOURCES})
qt6_add_lupdate(ppm-generator TS_FILES ${TS_FILES} OPTIONS -locations relative -no-obsolete)
qt6_add_lrelease(ppm-generator TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES OPTIONS -compress -removeidentical)

target_link_libraries(ppm-generator PRIVATE
Qt6::Widgets
Expand All @@ -67,15 +67,51 @@ set_target_properties(ppm-generator PROPERTIES
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)

if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(ppm-generator)
endif()
qt6_finalize_target(ppm-generator)

# Installation
set(CPACK_PACKAGE_CONTACT "oleksandr.koldkin@ukr.net")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/kolod/Arduino-PPM-Generator")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The GUI for Arduino Nano sketch that allows you to generate a PPM signal.")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../LICENSE")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/../README.md")
set(CPACK_PACKAGE_CHECKSUM SHA256)

if (WIN32)
install(TARGETS ppm-generator RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${VX_EXTRA_RESOURCE_FILES_RCC} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${QM_FILES} DESTINATION "${CMAKE_INSTALL_BINDIR}/translations" OPTIONAL)
qt_generate_deploy_app_script(TARGET ppm-generator OUTPUT_SCRIPT deploy_script NO_UNSUPPORTED_PLATFORM_ERROR)

message(${deploy_script})

install(SCRIPT ${deploy_script})
install(TARGETS ppm-generator BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${QM_FILES} DESTINATION ./translations)

set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ppm-generator")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "ppm-generator")
set(CPACK_PACKAGE_FILE_NAME "ppm-generator-win64")

set(CPACK_GENERATOR NSIS)
set(CPACK_NSIS_INSTALLED_ICON_NAME ppm-generator.exe)
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} (Win64)")
set(CPACK_NSIS_DISPLAY_NAME "PPM Generator")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
set(CMAKE_CL_64 TRUE) # This gets around a bug in the CPack installer name generation for MinGW 64-bit since 2.8

set(CPACK_NSIS_CREATE_ICONS_EXTRA
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\PPM Generator.lnk' '$INSTDIR\\\\bin\\\\ppm-generator.exe'"
)

set(CPACK_NSIS_DELETE_ICONS_EXTRA
"Delete '$SMPROGRAMS\\\\$START_MENU\\\\PPM Generator.lnk'"
)

message(${PROJECT_BINARY_DIR}/ppm-generator.exe)
message(${CMAKE_CURRENT_BINARY_DIR}/ppm-generator.exe)

include(CPack)

else()
include(GNUInstallDirs)
Expand All @@ -98,12 +134,6 @@ else()

list(JOIN DEBIAN_PACKAGE_DEPENDS ", " CPACK_DEBIAN_PACKAGE_DEPENDS)

set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/kolod/Arduino-PPM-Generator")

set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../LICENSE")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/../README.md")

set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Oleksandr Kolodkin <oleksandr.kolodkin@ukr.net>")
set(CPACK_DEBIAN_PACKAGE_SECTION "utils")
Expand Down
2 changes: 1 addition & 1 deletion gui/loader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Arduino PPM Generator
// Copyright (C) 2015-2021 Alexandr Kolodkin <alexandr.kolodkin@gmail.com>
// Copyright (C) 2015-... Oleksandr Kolodkin <oleksandr.kolodkin@ukr.net>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion gui/loader.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Arduino PPM Generator
// Copyright (C) 2015-2021 Alexandr Kolodkin <alexandr.kolodkin@gmail.com>
// Copyright (C) 2015-... Oleksandr Kolodkin <oleksandr.kolodkin@ukr.net>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
19 changes: 16 additions & 3 deletions gui/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Arduino PPM Generator
// Copyright (C) 2015-2020 Alexandr Kolodkin <alexandr.kolodkin@gmail.com>
// Copyright (C) 2015-... Oleksandr Kolodkin <oleksandr.kolodkin@ukr.net>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -23,6 +23,11 @@
#include <QLoggingCategory>
#include <QtGlobal>

#ifndef NDEBUG
#include <QLocale>
#include <QDirIterator>
#endif

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Expand All @@ -31,6 +36,13 @@ int main(int argc, char *argv[])
a.setApplicationVersion("1.1.0");
a.setStyle(QStyleFactory::create("Fusion"));

#ifndef NDEBUG
qDebug() << QLocale::system() << QLocale::system().bcp47Name();

QDirIterator it(":", QDirIterator::Subdirectories);
while (it.hasNext()) qDebug() << it.next();
#endif

// QLoggingCategory::setFilterRules(QStringLiteral("qt.modbus* = true"));

QTranslator qtTranslator;
Expand All @@ -46,13 +58,14 @@ int main(int argc, char *argv[])
qDebug() << "Qt translator not found.";
}

QStringList ApplicationTranslationPaths = {
const QStringList ApplicationTranslationPaths = {
qApp->applicationDirPath() + "/translations/",
qApp->applicationDirPath() + "/../translations/",
qApp->applicationDirPath() + "/../share/ppm-generator/translations/"
};

QTranslator myTranslator;
for (auto ApplicationTranslationPath : ApplicationTranslationPaths) {
for (const auto &ApplicationTranslationPath : ApplicationTranslationPaths) {
if (myTranslator.load(
QLocale(),
QLatin1String("ppm"),
Expand Down
54 changes: 30 additions & 24 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Arduino PPM Generator
// Copyright (C) 2015-2021 Alexandr Kolodkin <alexandr.kolodkin@gmail.com>
// Copyright (C) 2015-... Oleksandr Kolodkin <oleksandr.kolodkin@ukr.net>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -16,7 +16,6 @@

#include "mainwindow.h"
#include <QtMath>

#include <QDebug>

MainWindow::MainWindow(QWidget *parent)
Expand Down Expand Up @@ -389,21 +388,21 @@ void MainWindow::enumeratePorts()
int id = 0;
inputPort->clear();
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
QString tooltip =
QObject::tr(
"Port: %1\n"
"Location: %2\n"
"Description: %3\n"
"Manufacturer: %4\n"
"Vendor Identifier: %5\n"
"Product Identifier: %6"
)
.arg(info.portName())
.arg(info.systemLocation())
.arg(info.description())
.arg(info.manufacturer())
.arg(info.hasVendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : QString())
.arg(info.hasProductIdentifier() ? QString::number(info.productIdentifier(), 16) : QString());
auto tooltip = tr(
"Port: %1\n"
"Location: %2\n"
"Description: %3\n"
"Manufacturer: %4\n"
"Vendor Identifier: %5\n"
"Product Identifier: %6"
).arg(
info.portName(),
info.systemLocation(),
info.description(),
info.manufacturer(),
info.hasVendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : QString(),
info.hasProductIdentifier() ? QString::number(info.productIdentifier(), 16) : QString()
);

inputPort->addItem(info.portName());
inputPort->setItemData(id, QVariant(tooltip), Qt::ToolTipRole);
Expand Down Expand Up @@ -554,15 +553,22 @@ void MainWindow::check()
//
QPalette MainWindow::gradient(double value, double max)
{
QColor color(Qt::white);
QPalette newPalete(palette());
auto oldPalete = palette();
auto newPalete(oldPalete);

QColor foreColor = oldPalete.color(QPalette::Text);
QColor backColor = oldPalete.color(QPalette::Base);

if (value <= max * 1.0) color = QColor(255, 0, 0);
else if (value <= max * 1.2) color = QColor(255, 119, 0);
else if (value <= max * 1.5) color = QColor(255, 208, 0);
else if (value <= max * 2.0) color = QColor(255, 255, 0);
if (value <= max * 1.2) backColor = QColor("red");
else if (value <= max * 1.5) backColor = QColor("orange");
else if (value <= max * 2.0) backColor = QColor("yellow");

#if QT_VERSION >= QT_VERSION_CHECK(6,5,0)
if (backColor.lightnessF() >= 0.5) foreColor = QColor("black");
#endif

newPalete.setColor(QPalette::Base, color);
newPalete.setColor(QPalette::Text, foreColor);
newPalete.setColor(QPalette::Base, backColor);
return newPalete;
}

Expand Down
2 changes: 1 addition & 1 deletion gui/mainwindow.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Arduino PPM Generator
// Copyright (C) 2015-2020 Alexandr Kolodkin <alexandr.kolodkin@gmail.com>
// Copyright (C) 2015-... Oleksandr Kolodkin <oleksandr.kolodkin@ukr.net>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
3 changes: 1 addition & 2 deletions gui/ppm.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Arduino PPM Generator
// Copyright (C) 2015-2021 Alexandr Kolodkin <alexandr.kolodkin@gmail.com>
// Copyright (C) 2015-... Oleksandr Kolodkin <oleksandr.kolodkin@ukr.net>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#include <stdarg.h>
#include <math.h>
#include <QDebug>
#include "ppm.h"
Expand Down
2 changes: 1 addition & 1 deletion gui/ppm.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Arduino PPM Generator
// Copyright (C) 2015-2020 Alexandr Kolodkin <alexandr.kolodkin@gmail.com>
// Copyright (C) 2015-... Oleksandr Kolodkin <oleksandr.kolodkin@ukr.net>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 0 additions & 2 deletions gui/resources.qrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<RCC>
<qresource prefix="/">
<file>firmware.bin</file>
</qresource>
<qresource prefix="/">
<file>icons/connect.svg</file>
<file>icons/disconnect.svg</file>
<file>icons/update.svg</file>
Expand Down
2 changes: 1 addition & 1 deletion gui/resources.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Arduino PPM Generator
// Copyright (C) 2015-20209 Alexandr Kolodkin <alexandr.kolodkin@gmail.com>
// Copyright (C) 2015-... Oleksandr Kolodkin <oleksandr.kolodkin@ukr.net>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
7 changes: 0 additions & 7 deletions gui/translations.qrc

This file was deleted.

0 comments on commit 457898a

Please sign in to comment.