Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devlopment #25

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
54 changes: 42 additions & 12 deletions calendarwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -290,17 +295,17 @@ void CalendarWindow::showAbout() {
}

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

QMessageBox msgBox(QMessageBox::Information, "About", aboutText, QMessageBox::Ok, this);
msgBox.setTextFormat(Qt::RichText);
msgBox.exec();
}

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

// Populate BS day combo box based on current month and year
populateBsDays(bsYear, bsMonth);

//QDate currentDate = QDate::currentDate();
int bsDaysInMonth = converter.daysInMonth(bsYear, bsMonth);
ui->output->setText(QString("विक्रम सम्वत मा परिवर्तन गरियो: %1 %2 %3 गते %5 \n%2 %1 मा जम्मा दिन सङ्ख्या: %4")
.arg(convertToNepaliNumerals(bsYear)).arg(bsMonthName).arg(convertToNepaliNumerals(bsDay)).arg(convertToNepaliNumerals(bsDaysInMonth)).arg(tithipaksha));
QDate bsDate(bsYear, bsMonth, bsDay);
// Get the current AD (Gregorian) system date
QDate systemDate = QDate::currentDate();

// Retrieve the selected AD date from combo boxes
int selectedAdYear = ui->yearselectAD->currentText().toInt();
int selectedAdMonth = ui->monthselectAD->currentIndex() + 1; // Adjust index
int selectedAdDay = ui->dayselectAD->currentText().toInt();
QDate selectedAdDate(selectedAdYear, selectedAdMonth, selectedAdDay);

// Check if the selected AD date matches the current system date
if (selectedAdDate == systemDate) {
ui->output->setText(QString("आज: बिक्रम सम्वत: %1 %2 %3 गते %5\n %2 %1 मा जम्मा दिन सङ्ख्या: %4")
.arg(convertToNepaliNumerals(bsYear))
.arg(bsMonthName)
.arg(convertToNepaliNumerals(bsDay))
.arg(convertToNepaliNumerals(bsDaysInMonth))
.arg(tithipaksha));
} else {
ui->output->setText(QString("विक्रम सम्वत मा परिवर्तन गरियो: %1 %2 %3 गते %5\n %2 %1 मा जम्मा दिन सङ्ख्या: %4")
.arg(convertToNepaliNumerals(bsYear))
.arg(bsMonthName)
.arg(convertToNepaliNumerals(bsDay))
.arg(convertToNepaliNumerals(bsDaysInMonth))
.arg(tithipaksha));
}




Expand Down
Loading
Loading