From 20dc30d92cd3f20f47f65fa5252bf3f8ecbe3d2b Mon Sep 17 00:00:00 2001 From: khumnath <50103558+khumnath@users.noreply.github.com> Date: Tue, 5 Nov 2024 22:59:01 +0900 Subject: [PATCH 1/2] Devlopment (#25) * fix Cmake and version increment * v2.0.2 started * functions improvement --- CMakeLists.txt | 37 +++++---- calendarwindow.cpp | 54 ++++++++++--- mainwindow.cpp | 155 ++++++++++++++++++------------------- mainwindow.h | 8 +- mainwindow.ui | 63 +++++++++------ resources.qrc | 2 + resources/Laila-Medium.ttf | Bin 0 -> 333980 bytes resources/VERSION.txt | 2 +- resources/flag.png | Bin 0 -> 19415 bytes resources/style.qss | 125 ++++++++++++++---------------- 10 files changed, 244 insertions(+), 202 deletions(-) create mode 100644 resources/Laila-Medium.ttf create mode 100644 resources/flag.png diff --git a/CMakeLists.txt b/CMakeLists.txt index 57cae1a..a52e66d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,12 @@ cmake_minimum_required(VERSION 3.16) -project(nepdate VERSION 2.0.2 LANGUAGES CXX) + +# Read version from VERSION.txt +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/resources/VERSION.txt" VERSION_CONTENTS) +string(STRIP "${VERSION_CONTENTS}" APP_VERSION) + +# Project definition +project(nepdate VERSION ${APP_VERSION} LANGUAGES CXX) + set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -11,7 +18,7 @@ elseif (UNIX AND NOT APPLE) message(STATUS "Configuring for Linux") endif() -# Try to find the highest available version of Qt (Qt7, Qt6, or Qt5) +# Find Qt version find_package(Qt6 QUIET COMPONENTS Widgets Gui Core) if (NOT Qt6_FOUND) find_package(Qt5 QUIET COMPONENTS Widgets Gui Core) @@ -41,16 +48,15 @@ function(add_nepdate_executable target_name sources headers forms resources) endif() endfunction() -### nepdate-widget executable ### -# Collect nepdate-widget sources +# Define nepdate-widget executable + set(NEPDATE_WIDGET_SOURCES main.cpp mainwindow.cpp calendarwindow.cpp ) -# Collect nepdate-widget headers set(NEPDATE_WIDGET_HEADERS mainwindow.h bikram.h @@ -59,30 +65,29 @@ set(NEPDATE_WIDGET_HEADERS calendarwindow.h ) -# Collect nepdate-widget forms set(NEPDATE_WIDGET_FORMS mainwindow.ui calendarwindow.ui ) -# Collect nepdate-widget resources set(NEPDATE_WIDGET_RESOURCES resources.qrc ) -# Create nepdate-widget executable -add_nepdate_executable(nepdate-widget "${NEPDATE_WIDGET_SOURCES}" "${NEPDATE_WIDGET_HEADERS}" "${NEPDATE_WIDGET_FORMS}" "${NEPDATE_WIDGET_RESOURCES}") -### nepdate-calendar executable ### +add_nepdate_executable(nepdate_widget "${NEPDATE_WIDGET_SOURCES}" "${NEPDATE_WIDGET_HEADERS}" "${NEPDATE_WIDGET_FORMS}" "${NEPDATE_WIDGET_RESOURCES}") -# Collect nepdate-calendar sources + +# Set the output name to nepdate-widget +set_target_properties(nepdate_widget PROPERTIES OUTPUT_NAME nepdate-widget) + +# Define nepdate-calendar executable set(NEPDATE_CALENDAR_SOURCES main_calendar.cpp calendarwindow.cpp mainwindow.cpp ) -# Collect nepdate-calendar headers set(NEPDATE_CALENDAR_HEADERS calendarwindow.h DayTithiWidget.h @@ -91,16 +96,16 @@ set(NEPDATE_CALENDAR_HEADERS mainwindow.h ) -# Collect nepdate-calendar forms set(NEPDATE_CALENDAR_FORMS calendarwindow.ui mainwindow.ui ) -# Collect nepdate-calendar resources set(NEPDATE_CALENDAR_RESOURCES resources.qrc ) -# Create nepdate-calendar executable -add_nepdate_executable(nepdate-calendar "${NEPDATE_CALENDAR_SOURCES}" "${NEPDATE_CALENDAR_HEADERS}" "${NEPDATE_CALENDAR_FORMS}" "${NEPDATE_CALENDAR_RESOURCES}") +add_nepdate_executable(nepdate_calendar "${NEPDATE_CALENDAR_SOURCES}" "${NEPDATE_CALENDAR_HEADERS}" "${NEPDATE_CALENDAR_FORMS}" "${NEPDATE_CALENDAR_RESOURCES}") + +# Set the output name to nepdate-calendar +set_target_properties(nepdate_calendar PROPERTIES OUTPUT_NAME nepdate_calendar) diff --git a/calendarwindow.cpp b/calendarwindow.cpp index 0b43d44..7147f55 100755 --- a/calendarwindow.cpp +++ b/calendarwindow.cpp @@ -32,6 +32,12 @@ CalendarWindow::CalendarWindow(QWidget *parent) : qApp->setStyleSheet(styleSheet); file.close(); } + + int fontId = QFontDatabase::addApplicationFont(":/resources/Laila-Medium.ttf"); + QString fontFamily = QFontDatabase::applicationFontFamilies(fontId).at(0); + QFont appFont(fontFamily); + CalendarWindow::setFont(appFont); + // Initialize current date to today's date QDate currentDate = QDate::currentDate(); // Populate AD combo boxes @@ -75,8 +81,7 @@ CalendarWindow::CalendarWindow(QWidget *parent) : QString bsMonthName = getBikramMonthName(bsMonth); QString tithiName = QString::fromStdString(tithi[(int)panchang.tithi_index]); QString paksha = QString::fromStdString(panchang.paksha); - QString tithipaksha = QString("%1 %2").arg(paksha).arg(tithiName); - + QString tithipaksha = QString("%1 %2").arg(paksha).arg(tithiName); // Set current date in BS combo boxes ui->yearselectBS->setCurrentText(QString::number(bsYear)); @@ -290,17 +295,17 @@ void CalendarWindow::showAbout() { } QString aboutText = QString(R"( -
Nepali Calendar
-Author: khumnath
-Version: %1
-This application is written in C++ and Qt framework. For more information, visit my - GitHub page. +
Author: khumnath
+Version: %1
+This application is written in C++ and the Qt framework. For more information, visit my + GitHub page.
XFrU^L#zu9?Qru~zPHt{exBWgS=XznvbuNWFm!$l|rNnr`
z)@PLGsH&iH~+Tv3O(iXQR_p!=7xBuW`RV4So1rI*|$tqco
za 9ez=u}AA4n3fQ+!Nq@()@NDl<1twHUWdn_9QFnD!WBw$h+|+q^M5(xjhbf9q{E
zTO!tsr}DQQ*`_vDt~}eG%XY9`ZQA@y<(=%(rbMEtay^Df$y~q35R-%<$0I?v)ufy+
z%;PedaaiS5P=zx55PM59;8g^wWV0Oqq0$seb*4cA{UNjrW;j6r8usD#+|C`z4o^}Q
z@?Umo)T>JP+OiA#