Skip to content

Commit 2536f0b

Browse files
committed
addressed widget repaint issue and widget size changed. #36 #37
1 parent 604f1d1 commit 2536f0b

File tree

3 files changed

+17
-32
lines changed

3 files changed

+17
-32
lines changed

DayTithiWidget.h

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class DayTithiWidget : public QWidget {
8888
QIcon storedIcon;
8989
qreal storedIconOpacity = 1.0;
9090
void adjustIconSize() {
91-
int minSize = qMin(width(), height()) / 2;
91+
int minSize = qMin(width(), height()) / 4;
9292
iconSize = QSize(minSize + 18, minSize + 18);
9393
iconLabel->setFixedSize(iconSize);
9494
iconLabel->setScaledContents(true);
@@ -119,53 +119,33 @@ class DayTithiWidget : public QWidget {
119119
protected:
120120
void resizeEvent(QResizeEvent *event) override {
121121
QWidget::resizeEvent(event);
122-
123122
int w = width();
124123
int h = height();
125-
126124
int minDim = qMin(w, h);
127-
128-
// Font sizes
129125
int dayFontSize = std::max(12, static_cast<int>(minDim * 0.14));
130126
int tithiFontSize = std::max(8, static_cast<int>(minDim * 0.05));
131127
int englishDayFontSize = std::max(8, static_cast<int>(minDim * 0.05));
132-
133-
// --- Update Fonts ---
134128
int fontId = QFontDatabase::addApplicationFont(":/resources/Martel-Bold.ttf");
135129
QString fontFamily = QFontDatabase::applicationFontFamilies(fontId).at(0);
136130
QFont dayFont = dayLabel->font();
137131
dayFont.setPointSize(dayFontSize);
138132
dayFont.setFamily(fontFamily);
139133
dayFont.setBold(true);
140134
dayLabel->setFont(dayFont);
141-
dayLabel->repaint();
142-
143135
QFont tithiFont = tithiLabel->font();
144136
tithiFont.setPointSize(tithiFontSize);
145137
tithiFont.setItalic(true);
146138
tithiLabel->setFont(tithiFont);
147-
148-
149-
dayLabel->adjustSize();
139+
QFont englishDayFont = englishDayLabel->font();
140+
englishDayFont.setPointSize(englishDayFontSize);
141+
englishDayLabel->setFont(englishDayFont);
142+
// Position labels without adjustSize/repaint
150143
int dayX = 20;
151-
int dayY = (h / 3) - (dayLabel->height() / 2); // Move up
144+
int dayY = (h / 3) - (dayLabel->height() / 2);
152145
dayLabel->move(dayX, dayY);
153-
154-
// --- Reposition English Day Label (top-right) ---
155-
englishDayLabel->adjustSize();
156146
englishDayLabel->move(width() - englishDayLabel->width() - 6, 6);
157-
158-
159-
// --- Reposition Tithi Label (bottom-left) ---
160-
tithiLabel->adjustSize();
161147
tithiLabel->move(6, h - tithiLabel->height() - 6);
162-
163-
164-
QFont englishDayFont = englishDayLabel->font();
165-
englishDayFont.setPointSize(englishDayFontSize);
166-
englishDayLabel->setFont(englishDayFont);
167-
englishDayLabel->adjustSize();
168-
adjustIconSize(); // Should reposition icon manually too
148+
adjustIconSize();
169149
}
170150

171151
};

calendarwindow.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <QtWidgets>
1616
#include <QSettings>
1717
#include <QCloseEvent>
18+
#include <QTimer>
1819

1920
CalendarWindow::CalendarWindow(QWidget *parent) :
2021
QMainWindow(parent),
@@ -125,7 +126,6 @@ CalendarWindow::CalendarWindow(QWidget *parent) :
125126
adjustCalendarTableSize();
126127
}
127128

128-
#include <QTimer>
129129

130130
void CalendarWindow::setWindowPosition() {
131131
QSettings settings("Nepdate", "Nepdatecalendar");
@@ -669,7 +669,6 @@ void CalendarWindow::updateCalendar(int year, int month) {
669669

670670
if (isToday && isSaturday) {
671671
// If today is both Saturday and the current date, apply the "today" style
672-
item->setBackground(QColor(153, 255, 204)); // light green
673672
customWidget->setTodayStyle(); // defined in DayTithiWidget.h
674673
} else if (isToday) {
675674
// If it's just today, apply the "today" style

mainwindow.ui

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>450</width>
9+
<width>414</width>
1010
<height>91</height>
1111
</rect>
1212
</property>
13+
<property name="sizePolicy">
14+
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
15+
<horstretch>0</horstretch>
16+
<verstretch>0</verstretch>
17+
</sizepolicy>
18+
</property>
1319
<property name="font">
1420
<font>
15-
<family>Laila</family>
21+
<family>Sans Serif</family>
1622
<pointsize>11</pointsize>
1723
</font>
1824
</property>
@@ -63,7 +69,7 @@ QPushButton:pressed {
6369
</property>
6470
<property name="font">
6571
<font>
66-
<family>Laila</family>
72+
<family>Sans Serif</family>
6773
<pointsize>11</pointsize>
6874
</font>
6975
</property>

0 commit comments

Comments
 (0)