-
Notifications
You must be signed in to change notification settings - Fork 0
/
calendarwindow.h
102 lines (81 loc) · 3 KB
/
calendarwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef CALENDARWINDOW_H
#define CALENDARWINDOW_H
#include <QMainWindow>
#include "bikram.h"
#include <QMessageBox>
#include <QMenu>
#include <QDesktopServices>
#include <QUrl>
namespace Ui {
class CalendarWindow;
}
class CalendarWindow : public QMainWindow
{
Q_OBJECT
public:
int gYear, gMonth, gDay;
explicit CalendarWindow(QWidget *parent = nullptr);
~CalendarWindow();
QString getBikramMonthName(int month) {
QStringList bikramMonths = {"बैशाख", "जेठ", "असार", "श्रावण", "भाद्र",
"अश्विन", "कार्तिक", "मंसिर", "पौष", "माघ",
"फाल्गुन", "चैत"};
if (month >= 1 && month <= 12) {
return bikramMonths[month - 1];
} else {
return QString("Invalid Month");
}
}
QString getEnglishMonthName(int month) {
QStringList englishMonths = {"जनवरी", "फेब्रुअरी", "मार्च", "अप्रिल", "मे", "जुन",
"जुलाई", "अगस्ट", "सेप्टेम्बर", "अक्टोबर", "नोभेम्बर", "डिसेम्बर"};
// Adjust month to use as an index (0-based in QStringList)
int index = month - 1;
if (index >= 0 && index < englishMonths.size()) {
return englishMonths.at(index);
}
return ""; // Return empty string if index is out of range
}
// Function to convert number to Nepali numeral string
QString convertToNepaliNumerals(int number) {
QString nepaliNumbers[] = {"०", "१", "२", "३", "४", "५", "६", "७", "८", "९"};
QString result;
QString numStr = QString::number(number);
for (QChar ch : numStr) {
if (ch.isDigit()) {
int digit = ch.digitValue();
result += nepaliNumbers[digit];
} else {
result += ch;
}
}
return result;
}
private slots:
void onAdYearChanged(int index);
void onAdMonthChanged(int index);
void onAdDayChanged(int index);
void onBsYearChanged(int index);
void onBsMonthChanged(int index);
void onBsDayChanged(int index);
void ontodayButtonclicked();
void showMenu();
void showAbout();
void openSourceCode();
protected:
void resizeEvent(QResizeEvent* event) override;
bool eventFilter(QObject *object, QEvent *event) override;
private:
Ui::CalendarWindow *ui;
bikram converter;
bool blockSignals;
void centerOnScreen();
void updateBsDateFromAd(int year, int month, int day);
void updateAdDateFromBs(int year, int month, int day);
void updateCalendar(int year, int month);
void adjustCellSizes();
void centerWidgets();
void adjustCalendarTableSize();
void populateBsDays(int year, int month);
};
#endif // CALENDARWINDOW_H