Skip to content
This repository was archived by the owner on Oct 5, 2025. It is now read-only.

Commit 7bc55f6

Browse files
authored
Merge (#181)
2 parents 8297a59 + fe16e86 commit 7bc55f6

File tree

20 files changed

+1009
-250
lines changed

20 files changed

+1009
-250
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "src/CodeKeeper/3rdParty/qmarkdowntextedit"]
22
path = src/CodeKeeper/3rdParty/qmarkdowntextedit
3-
url = https://github.com/pbek/qmarkdowntextedit
3+
url = https://github.com/pbek/qmarkdowntextedit

CodeKeeper

52.3 KB
Binary file not shown.

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ YELLOW="\e[1;33m"
66
RED="\e[1;31m"
77
RESET="\e[0m"
88

9-
bash clang_format.sh
9+
#bash clang_format.sh
1010

1111
# Change to the CodeKeeper source directory
1212
echo -e "${GREEN}Navigating to the CodeKeeper source directory...${RESET}"

src/CodeKeeper/CodeKeeper

52.3 KB
Binary file not shown.

src/CodeKeeper/CodeKeeper.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ HEADERS += \
3838
settingswindow.h \
3939
syncwindow.h \
4040
commandPalette.h \
41+
custom/clickableLabel/clickableLabel.h \
4142
custom/circleProgressbar/ProgressCircle.h \
4243
custom/circleChart/CircleChart.h \
4344
custom/ColorValueDisplay/ColorValueDisplay.h

src/CodeKeeper/accountFunc/functional.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void AccountWindow::setImageFromUrl(const QString &url, QLabel *label)
203203
void AccountWindow::get_image_url(const QString &username, QLabel *label)
204204
{
205205
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
206-
QUrl url("https://api.github.com/users/" + git_user);
206+
QUrl url("https://api.github.com/users/" + username);
207207

208208
QUrlQuery query;
209209
query.addQueryItem("login", username);
@@ -216,6 +216,13 @@ void AccountWindow::get_image_url(const QString &username, QLabel *label)
216216
request.setRawHeader("Accept", "application/vnd.github.v3+json");
217217

218218
QNetworkReply *reply = manager->get(request);
219+
220+
connect(reply, &QNetworkReply::errorOccurred, [=](QNetworkReply::NetworkError error) {
221+
qWarning() << "Network error occurred:" << error;
222+
qWarning() << "Error string:" << reply->errorString();
223+
reply->deleteLater();
224+
});
225+
219226
QObject::connect(reply, &QNetworkReply::finished, [=]() {
220227
if (reply->error())
221228
{
@@ -224,10 +231,17 @@ void AccountWindow::get_image_url(const QString &username, QLabel *label)
224231
return;
225232
}
226233

234+
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200)
235+
{
236+
qWarning() << "HTTP error:" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
237+
reply->deleteLater();
238+
return;
239+
}
240+
227241
QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
228242
QJsonObject obj = doc.object();
229243

230-
qDebug() << obj["avatar_url"].toString();
244+
qDebug() << "Avatar URL:" << obj["avatar_url"].toString();
231245

232246
setImageFromUrl(obj["avatar_url"].toString(), label);
233247

src/CodeKeeper/accountwindow.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <QHBoxLayout>
44
#include <QtWidgets>
5+
#include <qt/QtWidgets/qgridlayout.h>
56

67
#include "accountFunc/functional.cpp"
78
#include "custom/ColorValueDisplay/ColorValueDisplay.h"
@@ -19,7 +20,7 @@ AccountWindow::AccountWindow(QWidget *parent) : QMainWindow{parent}
1920
setCentralWidget(centralWidget);
2021

2122
mainLayout = new QGridLayout(centralWidget);
22-
setMinimumSize(800, 670);
23+
setFixedSize(800, 670);
2324

2425
globalSettings = new QSettings("CodeKeeper", "CodeKeeper");
2526

@@ -38,7 +39,8 @@ AccountWindow::AccountWindow(QWidget *parent) : QMainWindow{parent}
3839
langsTitle->setAlignment(Qt::AlignCenter);
3940

4041
profilePicture = new QLabel();
41-
profilePicture->setText(tr("Loading..."));
42+
profilePicture->setAlignment(Qt::AlignCenter);
43+
profilePicture->setPixmap(QPixmap(":/user.png").scaled(250, 250, Qt::KeepAspectRatio, Qt::SmoothTransformation));
4244
profilePicture->setFixedSize(300, 300);
4345
profilePicture->setStyleSheet("border-radius: 145px;");
4446

@@ -128,12 +130,12 @@ AccountWindow::AccountWindow(QWidget *parent) : QMainWindow{parent}
128130

129131
QVBoxLayout *statsLayout = new QVBoxLayout();
130132
statsLayout->setSpacing(20);
131-
statsLayout->addWidget(tasksTitle, Qt::AlignHCenter);
133+
statsLayout->addWidget(tasksTitle, Qt::AlignHCenter | Qt::AlignBottom);
132134
statsLayout->addLayout(tasksStatsLayout);
133-
statsLayout->addWidget(projectTitle, Qt::AlignHCenter);
135+
statsLayout->addWidget(projectTitle, Qt::AlignHCenter | Qt::AlignBottom);
134136
statsLayout->addLayout(projectsStatsLayout);
135-
statsLayout->addWidget(langsTitle, Qt::AlignHCenter);
136-
statsLayout->addWidget(langsCard, Qt::AlignCenter);
137+
// statsLayout->addWidget(langsTitle, Qt::AlignHCenter);
138+
// statsLayout->addWidget(langsCard, Qt::AlignCenter);
137139

138140
statsWidget = new QWidget();
139141
statsWidget->setFixedSize(350, 600);
@@ -144,6 +146,7 @@ AccountWindow::AccountWindow(QWidget *parent) : QMainWindow{parent}
144146
gitProfileLayout->addWidget(profilePicture, Qt::AlignCenter);
145147
gitProfileLayout->addWidget(profileInfo, Qt::AlignCenter);
146148

149+
/*
147150
QThread *GitLangsStatsThread = new QThread;
148151
QObject::connect(GitLangsStatsThread, &QThread::started, this, [this]() {
149152
auto gitLangsWidget = this->gitLangsWidget;
@@ -186,8 +189,11 @@ AccountWindow::AccountWindow(QWidget *parent) : QMainWindow{parent}
186189
langsTitle->hide();
187190
}
188191
});
192+
189193
GitLangsStatsThread->start();
190194
195+
*/
196+
191197
QThread *styleThread = new QThread;
192198
QObject::connect(styleThread, &QThread::started, this, [this]() {
193199
setFontStyle();

src/CodeKeeper/accountwindow.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include <QObject>
1010
#include <QtWidgets>
1111

12+
#include <QCache>
13+
#include <QSettings>
14+
#include <QDateTime>
15+
1216
class AccountWindow : public QMainWindow
1317
{
1418
Q_OBJECT
@@ -32,6 +36,8 @@ class AccountWindow : public QMainWindow
3236
bool isAutoSyncB;
3337
bool isCustomTheme;
3438

39+
QCache<QString, QPixmap> imageCache;
40+
3541
private:
3642
QHBoxLayout *langsStatsLayout;
3743
QHBoxLayout *GitLangsStatsLayout;
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#include <QLabel>
2+
#include <QMouseEvent>
3+
#include <QPainter>
4+
#include <QPixmap>
5+
6+
class ClickableLabel : public QLabel
7+
{
8+
Q_OBJECT
9+
public:
10+
explicit ClickableLabel(const QString &text, QWidget *parent = nullptr) : QLabel(parent), m_text(text)
11+
{
12+
setFixedHeight(25);
13+
setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
14+
m_pixmap.load(":/expand.png");
15+
m_pixmapSize = QSize(20, 20);
16+
m_textColor = Qt::black;
17+
}
18+
19+
void setCustomStyleSheet(const QString &styleSheet)
20+
{
21+
QLabel::setStyleSheet(styleSheet);
22+
updateFontSize();
23+
updateTextColor();
24+
}
25+
26+
void setPixmapSize(int size)
27+
{
28+
m_pixmapSize = QSize(size, size);
29+
m_pixmap = m_pixmap.scaled(m_pixmapSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
30+
update();
31+
}
32+
33+
signals:
34+
void clicked();
35+
36+
protected:
37+
void mousePressEvent(QMouseEvent *event) override
38+
{
39+
emit clicked();
40+
QLabel::mousePressEvent(event);
41+
}
42+
43+
void paintEvent(QPaintEvent *event) override
44+
{
45+
QLabel::paintEvent(event);
46+
47+
QPainter painter(this);
48+
int pixmapWidth = m_pixmap.width();
49+
int pixmapHeight = m_pixmap.height();
50+
painter.drawPixmap(5, (height() - pixmapHeight) / 2, m_pixmap);
51+
52+
painter.setPen(m_textColor);
53+
54+
int textX = pixmapWidth + 10;
55+
painter.drawText(textX, height() / 2 + painter.fontMetrics().height() / 4, m_text);
56+
}
57+
58+
private:
59+
QString m_text;
60+
QPixmap m_pixmap;
61+
QSize m_pixmapSize;
62+
QColor m_textColor;
63+
64+
void updateFontSize()
65+
{
66+
QStringList styleList = styleSheet().split(';');
67+
for (const QString &style : styleList)
68+
{
69+
if (style.contains("font-size:"))
70+
{
71+
QString fontSizeStr = style.split(':').last().trimmed();
72+
bool ok;
73+
int fontSize = fontSizeStr.split(' ').first().toInt(&ok);
74+
if (ok)
75+
{
76+
QFont font = this->font();
77+
font.setPointSize(fontSize);
78+
setFont(font);
79+
}
80+
break;
81+
}
82+
}
83+
}
84+
85+
void updateTextColor()
86+
{
87+
QStringList styleList = styleSheet().split(';');
88+
for (const QString &style : styleList)
89+
{
90+
if (style.contains("color:"))
91+
{
92+
QString colorStr = style.split(':').last().trimmed();
93+
QColor color(colorStr);
94+
if (color.isValid())
95+
{
96+
m_textColor = color;
97+
}
98+
break;
99+
}
100+
}
101+
}
102+
};

0 commit comments

Comments
 (0)