Skip to content

Commit e0d4015

Browse files
committed
applied auto version using git describe.
1 parent 8bc417b commit e0d4015

File tree

11 files changed

+108
-36
lines changed

11 files changed

+108
-36
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ui_*.h
1616
*.qmlc
1717
*.jsc
1818
Makefile*
19-
*build*
19+
/build/*
2020

2121
# Qt unit tests
2222
target_wrapper.*

CMakeLists.txt

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
cmake_minimum_required(VERSION 3.16)
22

3-
# Read version from file to set the project version
3+
#=============================================================================
4+
# Project Metadata and Versioning
5+
#=============================================================================
46
set(VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/resources/version.conf")
57
if(EXISTS "${VERSION_FILE}")
68
file(READ "${VERSION_FILE}" PROJECT_VERSION_STRING)
@@ -13,54 +15,85 @@ endif()
1315
project(bikram-calendar VERSION ${PROJECT_VERSION_STRING} LANGUAGES CXX)
1416
message(STATUS "Configuring bikram-calendar version: ${PROJECT_VERSION}")
1517

18+
#=============================================================================
19+
# C++ Standard and Qt Setup
20+
#=============================================================================
21+
set(CMAKE_CXX_STANDARD 17)
22+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1623
set(CMAKE_AUTOMOC ON)
1724
set(CMAKE_AUTORCC ON)
1825
set(CMAKE_AUTOUIC ON)
19-
set(CMAKE_CXX_STANDARD 17)
20-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2126

22-
find_package(Qt6 COMPONENTS
27+
find_package(Qt6 REQUIRED COMPONENTS
2328
Core
2429
Gui
25-
Qml
26-
Quick
2730
Widgets
28-
QuickControls2
31+
Quick
32+
Qml
2933
PrintSupport
30-
REQUIRED)
34+
)
3135

3236
qt_policy(SET QTP0001 NEW)
3337
qt_policy(SET QTP0004 NEW)
3438

35-
qt_add_executable(bikram-calendar
39+
#=============================================================================
40+
# Run Versioning Script Before Build
41+
#=============================================================================
42+
execute_process(
43+
COMMAND bash "${CMAKE_CURRENT_SOURCE_DIR}/update_version.sh"
44+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
45+
RESULT_VARIABLE VERSION_SCRIPT_RESULT
46+
)
47+
if(NOT VERSION_SCRIPT_RESULT EQUAL 0)
48+
message(WARNING "The version update script failed to run. Version info may be stale or incorrect.")
49+
endif()
50+
51+
#=============================================================================
52+
# Source Files
53+
#=============================================================================
54+
set(SOURCES
3655
main.cpp
3756
autostartmanager.cpp
3857
tooltipmanager.cpp
3958
helper.cpp
40-
resources.qrc
4159
)
4260

43-
target_sources(bikram-calendar PRIVATE
61+
set(HEADERS
4462
autostartmanager.h
4563
tooltipmanager.h
4664
helper.h
4765
)
4866

67+
set(RESOURCES
68+
resources.qrc
69+
)
70+
71+
qt_add_executable(bikram-calendar
72+
${SOURCES}
73+
${HEADERS}
74+
${RESOURCES}
75+
)
76+
4977
target_link_libraries(bikram-calendar PRIVATE
5078
Qt6::Core
5179
Qt6::Gui
52-
Qt6::Qml
53-
Qt6::Quick
5480
Qt6::Widgets
55-
Qt6::QuickControls2
81+
Qt6::Quick
82+
Qt6::Qml
5683
Qt6::PrintSupport
5784
)
5885

86+
#=============================================================================
87+
# QML Folder Installation (for development)
88+
#=============================================================================
89+
#install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/qml"
90+
# DESTINATION "${CMAKE_INSTALL_PREFIX}/qml"
91+
# FILES_MATCHING PATTERN "*.qml"
92+
#)
93+
5994
#=============================================================================
6095
# Installation Rules
6196
#=============================================================================
62-
# use: cmake -DCMAKE_INSTALL_PREFIX=/path/to/your/custom/directory for install in your choice directory
63-
# Include standard installation directories (e.g., bin, lib, include)
6497
include(GNUInstallDirs)
6598

6699
if(NOT CMAKE_INSTALL_PREFIX)
@@ -69,6 +102,7 @@ endif()
69102

70103
message(STATUS "Install prefix set to: ${CMAKE_INSTALL_PREFIX}")
71104
message(STATUS "Binary will be installed to: ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
105+
72106
install(TARGETS bikram-calendar
73107
DESTINATION ${CMAKE_INSTALL_BINDIR}
74108
)

bikram-calendar.pro

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ CONFIG += c++17
1212
#=============================================================================
1313
QT += core gui widgets quick qml printsupport
1414

15+
#=============================================================================
16+
# Run Versioning Script Before Build
17+
#=============================================================================
18+
!system(bash $$PWD/update_version.sh) {
19+
warning("The version update script failed to run. Version info may be stale or incorrect.")
20+
}
21+
1522
#=============================================================================
1623
# Project Files
1724
#=============================================================================

main.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,16 @@ void ensureDesktopFile(const QString &desktopFileName, const QString &startupWMC
6262
}
6363
}
6464

65-
// Read version.txt from project root or known relative path
66-
QString readVersionText() {
67-
QFile versionFile(":/resources/version.conf");
68-
if (!versionFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
69-
qWarning() << "Could not open version.conf";
70-
return "Unknown";
65+
QString readStringFromResource(const QString& resourcePath) {
66+
QFile file(resourcePath);
67+
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
68+
qDebug() << "Could not open resource file:" << resourcePath;
69+
return QString();
7170
}
72-
QTextStream in(&versionFile);
73-
QString version = in.readLine().trimmed();
74-
versionFile.close();
75-
return version;
71+
QTextStream in(&file);
72+
return in.readLine().trimmed();
7673
}
7774

78-
7975
int main(int argc, char *argv[]) {
8076
QCoreApplication::setOrganizationName("Nepdate");
8177
QCoreApplication::setOrganizationDomain("com.nepdate.calendar");
@@ -97,9 +93,11 @@ int main(int argc, char *argv[]) {
9793
QString platform = QGuiApplication::platformName();
9894
engine.rootContext()->setContextProperty("platformName", platform);
9995

100-
// App version pass to qml
101-
QString appVersion = readVersionText();
102-
engine.rootContext()->setContextProperty("appVersion", appVersion);
96+
// Pass Version and Build Info to QML
97+
QString baseVersion = readStringFromResource(":/resources/version.conf");
98+
QString buildInfo = readStringFromResource(":/resources/build_info.conf");
99+
engine.rootContext()->setContextProperty("appVersion", baseVersion);
100+
engine.rootContext()->setContextProperty("appBuildInfo", buildInfo);
103101

104102
// Register the Printer class as a QML singleton
105103
qmlRegisterSingletonType<Printer>("com.calendar.printer", 1, 0, "Printer", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
@@ -126,7 +124,7 @@ int main(int argc, char *argv[]) {
126124
" background-color: #ffffff;"
127125
"}"
128126
);
129-
QCoreApplication::setApplicationVersion(readVersionText());
127+
QCoreApplication::setApplicationVersion(baseVersion);
130128

131129
// Command-line parsing
132130
QCommandLineParser parser;

qml/InfoDialog.qml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ Dialog {
5353
anchors.horizontalCenter: parent.horizontalCenter
5454
color: theme ? theme.primaryText : "black"
5555
}
56+
57+
Text {
58+
text: appBuildInfo
59+
font.italic: true
60+
font.pixelSize: 11
61+
wrapMode: Text.WordWrap
62+
horizontalAlignment: Text.AlignHCenter
63+
anchors.horizontalCenter: parent.horizontalCenter
64+
color: theme ? theme.infoText : "transparent"
65+
}
5666
}
5767

5868
Text {

qml/Theme.qml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,15 @@ QtObject {
3535
readonly property color borderColor: isDark ? "#334155" : "#e2e8f0"
3636
readonly property color todayBorder: isDark ? "#0ea5e9" : "#0284c7"
3737
readonly property color saturdayBorder: isDark ? "#334155" : "#fda4af"
38-
readonly property color holidayBorder: isDark ? "#C58F69" : "#FF9101"
3938

4039
// === Highlighted Days ===
4140
readonly property color todayBg: isDark ? "#082f49" : "#f0f9ff"
4241
readonly property color saturdayBg: isDark ? "#6E3233" : "#FEDDDF"
43-
//readonly property color holidayBg: isDark ? "#6E3233" : "#FEDDDF"
4442
readonly property color adDayText: isDark ? "#BBCFFA" : "#6E9BFD"
4543

4644
// === Modal / Dialogs ===
4745
readonly property color modalHeaderText: headerPrimaryText
4846
readonly property color modalButtonBg: tertiaryBg
4947
readonly property color modalButtonText: headerPrimaryText
48+
readonly property color infoText: isDark ? "#FFBF00" : "#9B7606"
5049
}

qml/main.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import "qrc:/qml/"
1111
ApplicationWindow {
1212
id: window
1313
visible: true
14-
width: 800
14+
width: 550
1515
height: 720
1616
objectName: "printableRoot"
1717
minimumWidth: 540

resources.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
<file>qml/Theme.qml</file>
1818
<file>resources/EventData.js</file>
1919
<file>qml/EventDisplay.qml</file>
20+
<file>resources/build_info.conf</file>
2021
</qresource>
2122
</RCC>

resources/build_info.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Built from Git source at Wed Aug 20 08:22:30 AM +0545 2025

resources/version.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.0
1+
2.1.1-3-g8bc

0 commit comments

Comments
 (0)