From d00248b832f931a6b8e7712e4cf839369f0dd3e1 Mon Sep 17 00:00:00 2001
From: Nighty3098 <154594695+Nighty3098@users.noreply.github.com>
Date: Sat, 8 Jun 2024 21:29:46 +0700
Subject: [PATCH 1/2] Added tabs
---
src/CodeKeeper/keeperFunc/getProjectInfo.cpp | 4 +--
src/CodeKeeper/keeperFunc/projectsFunc.cpp | 26 +++++++++++++++++---
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/src/CodeKeeper/keeperFunc/getProjectInfo.cpp b/src/CodeKeeper/keeperFunc/getProjectInfo.cpp
index 7ffa8e95..75da2f1a 100644
--- a/src/CodeKeeper/keeperFunc/getProjectInfo.cpp
+++ b/src/CodeKeeper/keeperFunc/getProjectInfo.cpp
@@ -267,8 +267,8 @@ QString MainWindow::getRepositoryData(QString git_url, QTableWidget *table)
table->setColumnCount(2);
table->setShowGrid(false);
- table->setColumnWidth(0, 190);
- table->setColumnWidth(1, 190);
+ table->setColumnWidth(0, 195);
+ table->setColumnWidth(1, 195);
table->setRowHeight(0, 25);
table->setRowHeight(1, 25);
diff --git a/src/CodeKeeper/keeperFunc/projectsFunc.cpp b/src/CodeKeeper/keeperFunc/projectsFunc.cpp
index b6d4185a..7a5a5752 100644
--- a/src/CodeKeeper/keeperFunc/projectsFunc.cpp
+++ b/src/CodeKeeper/keeperFunc/projectsFunc.cpp
@@ -122,10 +122,19 @@ void MainWindow::openProject(QListWidget *listWidget, QListWidgetItem *item)
{
if (item) {
QDialog dialog(this);
- dialog.setFixedSize(400, 550);
+ dialog.setFixedSize(420, 550);
dialog.setWindowTitle(tr("Edit project"));
dialog.setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
+ QVBoxLayout *centralLayout = new QVBoxLayout(&dialog);
+
+ QTabWidget *tabs = new QTabWidget();
+ tabs->setMovable(true);
+ tabs->setTabPosition(QTabWidget::South);
+
+ QWidget *projectTab = new QWidget();
+ QGridLayout mainLayout(projectTab);
+
QString data = item->text();
QStringList splitData = data.split("\n");
@@ -138,8 +147,6 @@ void MainWindow::openProject(QListWidget *listWidget, QListWidgetItem *item)
qDebug() << "Open project: " << projectData[0] << " " << projectData[1] << " "
<< projectData[2] << " " << projectData[3] << " " << projectData[4];
- QGridLayout mainLayout(&dialog);
-
QLineEdit *title = new QLineEdit();
title->setAlignment(Qt::AlignCenter);
title->setPlaceholderText(" Project name: ");
@@ -155,7 +162,7 @@ void MainWindow::openProject(QListWidget *listWidget, QListWidgetItem *item)
linkToGit->setFont(selectedFont);
QComboBox *documentation = new QComboBox();
- documentation->setFixedSize(190, 20);
+ documentation->setFixedSize(200, 20);
documentation->setFont(selectedFont);
QLabel *lastMod = new QLabel();
@@ -264,6 +271,17 @@ void MainWindow::openProject(QListWidget *listWidget, QListWidgetItem *item)
thread->start();
});
+
+
+
+ QWidget *issuesTab = new QWidget();
+ QGridLayout issuesLayout(issuesTab);
+
+ tabs->addTab(projectTab, "Project");
+ tabs->addTab(issuesTab, "Issues");
+
+ centralLayout->addWidget(tabs);
+
dialog.exec();
} else {
qWarning() << "Error";
From 839699fff019eab70a39aad8bc4ee27892f03bc6 Mon Sep 17 00:00:00 2001
From: Nighty3098 <154594695+Nighty3098@users.noreply.github.com>
Date: Mon, 10 Jun 2024 01:03:34 +0700
Subject: [PATCH 2/2] Added Issues tab
---
src/CodeKeeper/keeperFunc/getProjectInfo.cpp | 70 ++++++++++++++++----
src/CodeKeeper/keeperFunc/projectsFunc.cpp | 48 +++++++++-----
src/CodeKeeper/mainwindow.h | 1 +
3 files changed, 87 insertions(+), 32 deletions(-)
diff --git a/src/CodeKeeper/keeperFunc/getProjectInfo.cpp b/src/CodeKeeper/keeperFunc/getProjectInfo.cpp
index 75da2f1a..458d6f5e 100644
--- a/src/CodeKeeper/keeperFunc/getProjectInfo.cpp
+++ b/src/CodeKeeper/keeperFunc/getProjectInfo.cpp
@@ -135,29 +135,27 @@ QString MainWindow::getRepositoryData(QString git_url, QTableWidget *table)
createdAt = obj["created_at"].toString();
QDateTime createdDate = QDateTime::fromString(createdAt, Qt::ISODate);
createdAt = createdDate.toString("dd MMM yyyy hh:mm");
-
+
openIssues = QString::number(obj["open_issues"].toInt());
// repoData += " \n Watchers: " + QString::number(obj["watchers"].toInt()) + " ";
forks = QString::number(obj["forks"].toInt());
lang = obj["language"].toString();
-
-
+
stars = QString::number(obj["stargazers_count"].toInt());
-
+
qint64 size = obj["size"].toDouble();
repoSize = formatFileSize(size);
-
if (obj.contains("license")) {
QJsonObject licenseObj = obj["license"].toObject();
if (licenseObj.contains("name")) {
- license = licenseObj["name"].toString() + " ";
+ license = licenseObj["name"].toString() + " ";
} else {
- qDebug() << "License not found";
+ qDebug() << "License not found";
}
} else {
- qDebug() << "License not found";
+ qDebug() << "License not found";
}
QUrl commitUrl("https://api.github.com/repos/" + repo + "/commits");
@@ -227,7 +225,6 @@ QString MainWindow::getRepositoryData(QString git_url, QTableWidget *table)
totalDownloads = QString::number(iTotalDownloads);
-
// Release info
QUrl releasesUrl("https://api.github.com/repos/" + repo + "/releases/latest");
releasesUrl.setQuery(query);
@@ -252,7 +249,6 @@ QString MainWindow::getRepositoryData(QString git_url, QTableWidget *table)
QJsonObject releasesObj = releasesDoc.object();
qDebug() << releasesDoc;
-
release = releasesObj["name"].toString();
dateStr = releasesObj["published_at"].toString();
@@ -267,8 +263,8 @@ QString MainWindow::getRepositoryData(QString git_url, QTableWidget *table)
table->setColumnCount(2);
table->setShowGrid(false);
- table->setColumnWidth(0, 195);
- table->setColumnWidth(1, 195);
+ table->setColumnWidth(0, 190);
+ table->setColumnWidth(1, 190);
table->setRowHeight(0, 25);
table->setRowHeight(1, 25);
@@ -355,8 +351,6 @@ QString MainWindow::getRepositoryData(QString git_url, QTableWidget *table)
table->item(i, 0)->setTextAlignment(Qt::AlignCenter);
}
-
-
for (int row = 0; row < table->rowCount(); ++row) {
for (int col = 0; col < table->columnCount(); ++col) {
QTableWidgetItem *item = table->item(row, col);
@@ -368,3 +362,51 @@ QString MainWindow::getRepositoryData(QString git_url, QTableWidget *table)
return repoData;
}
+
+QString MainWindow::getProjectIssues(QString git_url)
+{
+ int maxLength = 120;
+ QString prefix = "https://github.com/";
+ QString repo = git_url.replace(prefix, "");
+ QString issuesData;
+
+ QUrl url("https://api.github.com/repos/" + repo + "/issues");
+ QNetworkRequest request(url);
+
+ QNetworkAccessManager manager;
+ QNetworkReply *reply = manager.get(request);
+
+ request.setHeader(QNetworkRequest::UserAgentHeader, "CodeKeeper");
+ request.setRawHeader("Authorization", ("Bearer " + git_token).toUtf8());
+ request.setRawHeader("X-GitHub-Api-Version", "2022-11-28");
+ request.setRawHeader("Accept", "application/vnd.github.v3+json");
+
+ QEventLoop loop;
+ QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
+
+ loop.exec();
+
+ if (reply->error() == QNetworkReply::NoError) {
+ QByteArray data = reply->readAll();
+ QJsonDocument json = QJsonDocument::fromJson(data);
+ QJsonArray issues = json.array();
+
+ qDebug() << json;
+
+ foreach (const QJsonValue &issue, issues) {
+ QJsonObject issueObject = issue.toObject();
+ QString title = issueObject["title"].toString();
+ QString body = issueObject["body"].toString();
+ QString shortBody = body.left(maxLength);
+ QString link = issueObject["html_url"].toString();
+
+ issuesData += "