Skip to content

Commit 7270dfd

Browse files
committed
functions improvement
1 parent 29fe6a1 commit 7270dfd

File tree

10 files changed

+240
-203
lines changed

10 files changed

+240
-203
lines changed

CMakeLists.txt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
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)
39

410
set(CMAKE_CXX_STANDARD 17)
511
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -11,7 +17,7 @@ elseif (UNIX AND NOT APPLE)
1117
message(STATUS "Configuring for Linux")
1218
endif()
1319

14-
# Try to find the highest available version of Qt (Qt7, Qt6, or Qt5)
20+
# Find Qt version
1521
find_package(Qt6 QUIET COMPONENTS Widgets Gui Core)
1622
if (NOT Qt6_FOUND)
1723
find_package(Qt5 QUIET COMPONENTS Widgets Gui Core)
@@ -41,16 +47,13 @@ function(add_nepdate_executable target_name sources headers forms resources)
4147
endif()
4248
endfunction()
4349

44-
### nepdate-widget executable ###
45-
46-
# Collect nepdate-widget sources
50+
# Define nepdate-widget executable
4751
set(NEPDATE_WIDGET_SOURCES
4852
main.cpp
4953
mainwindow.cpp
5054
calendarwindow.cpp
5155
)
5256

53-
# Collect nepdate-widget headers
5457
set(NEPDATE_WIDGET_HEADERS
5558
mainwindow.h
5659
bikram.h
@@ -59,30 +62,27 @@ set(NEPDATE_WIDGET_HEADERS
5962
calendarwindow.h
6063
)
6164

62-
# Collect nepdate-widget forms
6365
set(NEPDATE_WIDGET_FORMS
6466
mainwindow.ui
6567
calendarwindow.ui
6668
)
6769

68-
# Collect nepdate-widget resources
6970
set(NEPDATE_WIDGET_RESOURCES
7071
resources.qrc
7172
)
7273

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

76-
### nepdate-calendar executable ###
76+
# Set the output name to nepdate-widget
77+
set_target_properties(nepdate_widget PROPERTIES OUTPUT_NAME nepdate-widget)
7778

78-
# Collect nepdate-calendar sources
79+
# Define nepdate-calendar executable
7980
set(NEPDATE_CALENDAR_SOURCES
8081
main_calendar.cpp
8182
calendarwindow.cpp
8283
mainwindow.cpp
8384
)
8485

85-
# Collect nepdate-calendar headers
8686
set(NEPDATE_CALENDAR_HEADERS
8787
calendarwindow.h
8888
DayTithiWidget.h
@@ -91,16 +91,16 @@ set(NEPDATE_CALENDAR_HEADERS
9191
mainwindow.h
9292
)
9393

94-
# Collect nepdate-calendar forms
9594
set(NEPDATE_CALENDAR_FORMS
9695
calendarwindow.ui
9796
mainwindow.ui
9897
)
9998

100-
# Collect nepdate-calendar resources
10199
set(NEPDATE_CALENDAR_RESOURCES
102100
resources.qrc
103101
)
104102

105-
# Create nepdate-calendar executable
106-
add_nepdate_executable(nepdate-calendar "${NEPDATE_CALENDAR_SOURCES}" "${NEPDATE_CALENDAR_HEADERS}" "${NEPDATE_CALENDAR_FORMS}" "${NEPDATE_CALENDAR_RESOURCES}")
103+
add_nepdate_executable(nepdate_calendar "${NEPDATE_CALENDAR_SOURCES}" "${NEPDATE_CALENDAR_HEADERS}" "${NEPDATE_CALENDAR_FORMS}" "${NEPDATE_CALENDAR_RESOURCES}")
104+
105+
# Set the output name to nepdate-calendar
106+
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)