Skip to content

Commit

Permalink
Merge pull request #129 from Nighty3098/InDev
Browse files Browse the repository at this point in the history
The project window has been changed. Added project description
  • Loading branch information
Nighty3098 authored Jul 21, 2024
2 parents 76a2a15 + 04b46c0 commit 9de7584
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/CodeKeeper/CMakeFiles/cmake.check_cache

This file was deleted.

8 changes: 4 additions & 4 deletions src/CodeKeeper/accountFunc/functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ int AccountWindow::getStarsCount(const QString& username, const QString& token)
return totalStars;
}

void AccountWindow::setUserData(const QString& username, QLabel *label)
void AccountWindow::setUserData(const QString& username, QLabel* label)
{
QNetworkAccessManager* manager = new QNetworkAccessManager(this);
QUrl url("https://api.github.com/users/" + git_user);
Expand Down Expand Up @@ -214,9 +214,9 @@ void AccountWindow::setUserData(const QString& username, QLabel *label)
qDebug() << "Company:" << obj["company"].toString();
qDebug() << "Login:" << obj["login"].toString();

label->setText("\n\n" + obj["bio"].toString() + "\nPublic repos: " + QString::number(obj["public_repos"].toInt()) + "\n\nFollowing: "
+ QString::number(obj["following"].toInt()) + "\n\nFollowers: " + QString::number(obj["followers"].toInt())
+ "\n\nStars: " + QString::number(getStarsCount(git_user, git_token)) + "\n");
label->setText("\n\n" + obj["bio"].toString() + "\nPublic repos: " + QString::number(obj["public_repos"].toInt())
+ "\n\nFollowing: " + QString::number(obj["following"].toInt()) + "\n\nFollowers: " + QString::number(obj["followers"].toInt())
+ "\n\nStars: " + QString::number(getStarsCount(git_user, git_token)) + "\n");

reply->deleteLater();
});
Expand Down
8 changes: 6 additions & 2 deletions src/CodeKeeper/keeperFunc/getProjectInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ void MainWindow::createGitBadges(QString git_url, QWebEngineView* page)
page->setHtml(html);
}

QString MainWindow::getRepositoryData(QString git_url, QTableWidget* table)
QString MainWindow::getRepositoryData(QString git_url, QTableWidget* table, QLabel* label)
{
QString prefix = "https://github.com/";
QString repo = git_url.replace(prefix, "");
QString repoData;

QString name, createdAt, openIssues, forks, lang, stars, repoSize, license, totalDownloads, release, releaseDate, lastCommitS;
QString name, description, createdAt, openIssues, forks, lang, stars, repoSize, license, totalDownloads, release, releaseDate, lastCommitS;

QNetworkAccessManager* manager = new QNetworkAccessManager(this);

Expand Down Expand Up @@ -130,6 +130,8 @@ QString MainWindow::getRepositoryData(QString git_url, QTableWidget* table)

name = obj["name"].toString();

description = obj["description"].toString();

createdAt = obj["created_at"].toString();
QDateTime createdDate = QDateTime::fromString(createdAt, Qt::ISODate);
createdAt = createdDate.toString("dd MMM yyyy hh:mm");
Expand Down Expand Up @@ -343,6 +345,8 @@ QString MainWindow::getRepositoryData(QString git_url, QTableWidget* table)
textList << "Release at";
}

label->setText(name + " - " + description);

for (int i = 0; i < dataList.count(); i++) {
table->setItem(i, 0, new QTableWidgetItem(textList[i]));
table->setItem(i, 1, new QTableWidgetItem(dataList[i]));
Expand Down
28 changes: 20 additions & 8 deletions src/CodeKeeper/keeperFunc/projectsFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void MainWindow::openProject(QListWidget* listWidget, QListWidgetItem* item)
dialog.setMinimumHeight(500);
dialog.setWindowTitle(tr("Project"));
dialog.setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
dialog.setStyleSheet("QWidget { background-color: #222126; } QPushButton {background-color: #0a070d; } QLineEdit {background-color: #0a070d;}");

QPushButton* saveDataBtn = new QPushButton();
saveDataBtn->setText("Save");
Expand Down Expand Up @@ -158,6 +159,7 @@ void MainWindow::openProject(QListWidget* listWidget, QListWidgetItem* item)
QTabWidget* tabs = new QTabWidget();
tabs->setMovable(true);
tabs->setTabPosition(QTabWidget::South);
tabs->setStyleSheet(" QTabBar::tab { height: 15px; width: 100px; background: #222126; } QTabBar::tab:selected { height: 15px; width: 100px; color: #fff; background: #0a070d; }");

QWidget* projectTab = new QWidget();
QGridLayout mainLayout(projectTab);
Expand Down Expand Up @@ -208,6 +210,14 @@ void MainWindow::openProject(QListWidget* listWidget, QListWidgetItem* item)
git_stats->setContentsMargins(0, 0, 0, 0);
git_stats->setAlternatingRowColors(true);

git_stats->setStyleSheet("QTableWidget { background-color: transparent; alternate-background-color: #0a070d; } QTableWidget::item {border-radius: 5px;}");

QLabel* descriptionL = new QLabel();
descriptionL->setFixedHeight(30);
descriptionL->setAlignment(Qt::AlignCenter);
descriptionL->setFont(selectedFont);
descriptionL->setStyleSheet("font-size: " + font_size + "pt;");

QHBoxLayout* statsLayout = new QHBoxLayout();

QSpacerItem* leftSpacer = new QSpacerItem(0, 10, QSizePolicy::Expanding, QSizePolicy::Minimum);
Expand All @@ -233,10 +243,11 @@ void MainWindow::openProject(QListWidget* listWidget, QListWidgetItem* item)
loadDocumentations(dir, *documentation);
documentation->setCurrentText(projectData[2]);

mainLayout.addWidget(title, 2, 0, 1, 2);
mainLayout.addWidget(linkToGit, 3, 0, 1, 2);
mainLayout.addWidget(documentation, 4, 0);
mainLayout.addWidget(openButton, 4, 1);
mainLayout.addWidget(title, 0, 0, 1, 2);
mainLayout.addWidget(linkToGit, 1, 0, 1, 2);
// mainLayout.addWidget(documentation, 2, 0);
// mainLayout.addWidget(openButton, 2, 1);
// mainLayout.addWidget(descriptionL, 3, 0, 1, 2);
mainLayout.addLayout(statsLayout, 5, 0, 5, 2);
mainLayout.addWidget(lastMod, 10, 0, 1, 2, Qt::AlignCenter);

Expand All @@ -255,11 +266,12 @@ void MainWindow::openProject(QListWidget* listWidget, QListWidgetItem* item)
tabs->addTab(projectTab, "Project");
tabs->addTab(issuesTab, "Issues");

centralLayout->addWidget(descriptionL);
centralLayout->addWidget(tabs);

QThread* thread = new QThread;
QObject::connect(thread, &QThread::started, this, [this, projectData, git_stats, issuesLabel]() {
getRepositoryData(projectData[1], git_stats);
QObject::connect(thread, &QThread::started, this, [this, projectData, git_stats, issuesLabel, descriptionL]() {
getRepositoryData(projectData[1], git_stats, descriptionL);
issuesLabel->setHtml(getProjectIssues(projectData[1]));
});
thread->start();
Expand Down Expand Up @@ -291,8 +303,8 @@ void MainWindow::openProject(QListWidget* listWidget, QListWidgetItem* item)
QString repo = projectLink.replace(prefix, "");

QThread* thread = new QThread;
QObject::connect(thread, &QThread::started, this, [this, projectData, repo, git_stats, issuesLabel]() {
getRepositoryData(repo, git_stats);
QObject::connect(thread, &QThread::started, this, [this, projectData, repo, git_stats, issuesLabel, descriptionL]() {
getRepositoryData(repo, git_stats, descriptionL);
issuesLabel->setHtml(getProjectIssues(repo));
});
thread->start();
Expand Down
2 changes: 1 addition & 1 deletion src/CodeKeeper/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class MainWindow : public QMainWindow
bool isRepoSize;

private slots:
QString getRepositoryData(QString git_url, QTableWidget *table);
QString getRepositoryData(QString git_url, QTableWidget *table, QLabel *label);
QString getProjectIssues(QString git_url);

void openSettingsWindow();
Expand Down
3 changes: 2 additions & 1 deletion src/CodeKeeper/syncwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ SyncWindow::SyncWindow(QWidget* parent) : QMainWindow(parent)
centralWidget = new QWidget(this);
setCentralWidget(centralWidget);

this->setStyleSheet(" QWidget { background-color: #222126; } QPushButton {background-color: #0a070d; } QProgressBar {background-color: #0a070d; }");
this->setStyleSheet(
" QWidget { background-color: #222126; } QPushButton {background-color: #0a070d; } QProgressBar {background-color: #0a070d; }");
this->setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
this->setFixedSize(300, 500);

Expand Down

0 comments on commit 9de7584

Please sign in to comment.