Skip to content

Commit 20dc30d

Browse files
authored
Devlopment (#25)
* fix Cmake and version increment * v2.0.2 started * functions improvement
1 parent 1cc0cd4 commit 20dc30d

File tree

10 files changed

+244
-202
lines changed

10 files changed

+244
-202
lines changed

CMakeLists.txt

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
cmake_minimum_required(VERSION 3.16)
2-
project(nepdate VERSION 2.0.2 LANGUAGES CXX)
2+
3+
# Read version from VERSION.txt
4+
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/resources/VERSION.txt" VERSION_CONTENTS)
5+
string(STRIP "${VERSION_CONTENTS}" APP_VERSION)
6+
7+
# Project definition
8+
project(nepdate VERSION ${APP_VERSION} LANGUAGES CXX)
9+
310

411
set(CMAKE_CXX_STANDARD 17)
512
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -11,7 +18,7 @@ elseif (UNIX AND NOT APPLE)
1118
message(STATUS "Configuring for Linux")
1219
endif()
1320

14-
# Try to find the highest available version of Qt (Qt7, Qt6, or Qt5)
21+
# Find Qt version
1522
find_package(Qt6 QUIET COMPONENTS Widgets Gui Core)
1623
if (NOT Qt6_FOUND)
1724
find_package(Qt5 QUIET COMPONENTS Widgets Gui Core)
@@ -41,16 +48,15 @@ function(add_nepdate_executable target_name sources headers forms resources)
4148
endif()
4249
endfunction()
4350

44-
### nepdate-widget executable ###
4551

46-
# Collect nepdate-widget sources
52+
# Define nepdate-widget executable
53+
4754
set(NEPDATE_WIDGET_SOURCES
4855
main.cpp
4956
mainwindow.cpp
5057
calendarwindow.cpp
5158
)
5259

53-
# Collect nepdate-widget headers
5460
set(NEPDATE_WIDGET_HEADERS
5561
mainwindow.h
5662
bikram.h
@@ -59,30 +65,29 @@ set(NEPDATE_WIDGET_HEADERS
5965
calendarwindow.h
6066
)
6167

62-
# Collect nepdate-widget forms
6368
set(NEPDATE_WIDGET_FORMS
6469
mainwindow.ui
6570
calendarwindow.ui
6671
)
6772

68-
# Collect nepdate-widget resources
6973
set(NEPDATE_WIDGET_RESOURCES
7074
resources.qrc
7175
)
7276

73-
# Create nepdate-widget executable
74-
add_nepdate_executable(nepdate-widget "${NEPDATE_WIDGET_SOURCES}" "${NEPDATE_WIDGET_HEADERS}" "${NEPDATE_WIDGET_FORMS}" "${NEPDATE_WIDGET_RESOURCES}")
7577

76-
### nepdate-calendar executable ###
78+
add_nepdate_executable(nepdate_widget "${NEPDATE_WIDGET_SOURCES}" "${NEPDATE_WIDGET_HEADERS}" "${NEPDATE_WIDGET_FORMS}" "${NEPDATE_WIDGET_RESOURCES}")
7779

78-
# Collect nepdate-calendar sources
80+
81+
# Set the output name to nepdate-widget
82+
set_target_properties(nepdate_widget PROPERTIES OUTPUT_NAME nepdate-widget)
83+
84+
# Define nepdate-calendar executable
7985
set(NEPDATE_CALENDAR_SOURCES
8086
main_calendar.cpp
8187
calendarwindow.cpp
8288
mainwindow.cpp
8389
)
8490

85-
# Collect nepdate-calendar headers
8691
set(NEPDATE_CALENDAR_HEADERS
8792
calendarwindow.h
8893
DayTithiWidget.h
@@ -91,16 +96,16 @@ set(NEPDATE_CALENDAR_HEADERS
9196
mainwindow.h
9297
)
9398

94-
# Collect nepdate-calendar forms
9599
set(NEPDATE_CALENDAR_FORMS
96100
calendarwindow.ui
97101
mainwindow.ui
98102
)
99103

100-
# Collect nepdate-calendar resources
101104
set(NEPDATE_CALENDAR_RESOURCES
102105
resources.qrc
103106
)
104107

105-
# Create nepdate-calendar executable
106-
add_nepdate_executable(nepdate-calendar "${NEPDATE_CALENDAR_SOURCES}" "${NEPDATE_CALENDAR_HEADERS}" "${NEPDATE_CALENDAR_FORMS}" "${NEPDATE_CALENDAR_RESOURCES}")
108+
add_nepdate_executable(nepdate_calendar "${NEPDATE_CALENDAR_SOURCES}" "${NEPDATE_CALENDAR_HEADERS}" "${NEPDATE_CALENDAR_FORMS}" "${NEPDATE_CALENDAR_RESOURCES}")
109+
110+
# Set the output name to nepdate-calendar
111+
set_target_properties(nepdate_calendar PROPERTIES OUTPUT_NAME nepdate_calendar)

calendarwindow.cpp

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ CalendarWindow::CalendarWindow(QWidget *parent) :
3232
qApp->setStyleSheet(styleSheet);
3333
file.close();
3434
}
35+
36+
int fontId = QFontDatabase::addApplicationFont(":/resources/Laila-Medium.ttf");
37+
QString fontFamily = QFontDatabase::applicationFontFamilies(fontId).at(0);
38+
QFont appFont(fontFamily);
39+
CalendarWindow::setFont(appFont);
40+
3541
// Initialize current date to today's date
3642
QDate currentDate = QDate::currentDate();
3743
// Populate AD combo boxes
@@ -75,8 +81,7 @@ CalendarWindow::CalendarWindow(QWidget *parent) :
7581
QString bsMonthName = getBikramMonthName(bsMonth);
7682
QString tithiName = QString::fromStdString(tithi[(int)panchang.tithi_index]);
7783
QString paksha = QString::fromStdString(panchang.paksha);
78-
QString tithipaksha = QString("%1 %2").arg(paksha).arg(tithiName);
79-
84+
QString tithipaksha = QString("%1 %2").arg(paksha).arg(tithiName);
8085

8186
// Set current date in BS combo boxes
8287
ui->yearselectBS->setCurrentText(QString::number(bsYear));
@@ -290,17 +295,17 @@ void CalendarWindow::showAbout() {
290295
}
291296

292297
QString aboutText = QString(R"(
293-
<center>
294-
<h2 class='about.h2'>About</h2>
295-
<p class='about.p'>Nepali Calendar</p>
296-
<p><b>Author:</b> <span class='about'>khumnath</span></p>
297-
<p><b>Version:</b> %1</p>
298-
<p>This application is written in C++ and Qt framework. For more information, visit my
299-
<a href="https://github.com/khumnath/nepdate" class="about">GitHub page</a>.
298+
<center style="background-color: white; padding: 20px;">
299+
<h2 style="font-size: 24px; font-weight: bold; color: black;">Nepali Calendar</h2>
300+
<p style="color: black;"><b>Author:</b> <span style="font-weight: normal;">khumnath</span></p>
301+
<p style="color: black;"><b>Version:</b> <span style="color: green; font-weight: bold;">%1</span></p>
302+
<p style="color: black;">This application is written in C++ and the Qt framework. For more information, visit my
303+
<a href="https://github.com/khumnath/nepdate" style="color: blue; text-decoration: underline;">GitHub page</a>.
300304
</p>
301305
</center>)").arg(version);
302306

303307
QMessageBox msgBox(QMessageBox::Information, "About", aboutText, QMessageBox::Ok, this);
308+
msgBox.setTextFormat(Qt::RichText);
304309
msgBox.exec();
305310
}
306311

@@ -443,10 +448,35 @@ void CalendarWindow::updateBsDateFromAd(int year, int month, int day) {
443448

444449
// Populate BS day combo box based on current month and year
445450
populateBsDays(bsYear, bsMonth);
446-
451+
//QDate currentDate = QDate::currentDate();
447452
int bsDaysInMonth = converter.daysInMonth(bsYear, bsMonth);
448-
ui->output->setText(QString("विक्रम सम्वत मा परिवर्तन गरियो: %1 %2 %3 गते %5 \n%2 %1 मा जम्मा दिन सङ्ख्या: %4")
449-
.arg(convertToNepaliNumerals(bsYear)).arg(bsMonthName).arg(convertToNepaliNumerals(bsDay)).arg(convertToNepaliNumerals(bsDaysInMonth)).arg(tithipaksha));
453+
QDate bsDate(bsYear, bsMonth, bsDay);
454+
// Get the current AD (Gregorian) system date
455+
QDate systemDate = QDate::currentDate();
456+
457+
// Retrieve the selected AD date from combo boxes
458+
int selectedAdYear = ui->yearselectAD->currentText().toInt();
459+
int selectedAdMonth = ui->monthselectAD->currentIndex() + 1; // Adjust index
460+
int selectedAdDay = ui->dayselectAD->currentText().toInt();
461+
QDate selectedAdDate(selectedAdYear, selectedAdMonth, selectedAdDay);
462+
463+
// Check if the selected AD date matches the current system date
464+
if (selectedAdDate == systemDate) {
465+
ui->output->setText(QString("आज: बिक्रम सम्वत: %1 %2 %3 गते %5\n %2 %1 मा जम्मा दिन सङ्ख्या: %4")
466+
.arg(convertToNepaliNumerals(bsYear))
467+
.arg(bsMonthName)
468+
.arg(convertToNepaliNumerals(bsDay))
469+
.arg(convertToNepaliNumerals(bsDaysInMonth))
470+
.arg(tithipaksha));
471+
} else {
472+
ui->output->setText(QString("विक्रम सम्वत मा परिवर्तन गरियो: %1 %2 %3 गते %5\n %2 %1 मा जम्मा दिन सङ्ख्या: %4")
473+
.arg(convertToNepaliNumerals(bsYear))
474+
.arg(bsMonthName)
475+
.arg(convertToNepaliNumerals(bsDay))
476+
.arg(convertToNepaliNumerals(bsDaysInMonth))
477+
.arg(tithipaksha));
478+
}
479+
450480

451481

452482

0 commit comments

Comments
 (0)