Skip to content

Commit

Permalink
Merge pull request #118 from DXS-GROUP/InDev
Browse files Browse the repository at this point in the history
Added style selection functionality: standard (system) or custom (from custom_stylesheet.qss). Added a progress bar in the account window, changed some of the displayed data.
  • Loading branch information
Nighty3098 committed Jul 17, 2024
2 parents 718de7a + 9b15a73 commit af3a5e5
Show file tree
Hide file tree
Showing 14 changed files with 816 additions and 631 deletions.
3 changes: 2 additions & 1 deletion src/CodeKeeper/CodeKeeper.pro
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ HEADERS += \
RESOURCES += \
../resources/resources.qrc \
../stylesheet/stylesheet.qss \
../stylesheet/stylesheet_setting_window.qss
../stylesheet/stylesheet_setting_window.qss \
../stylesheet/custom_stylesheet.qss

include(3rdParty/qmarkdowntextedit/qmarkdowntextedit.pri)

Expand Down
25 changes: 23 additions & 2 deletions src/CodeKeeper/accountFunc/functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <QPixmap>
#include <QLabel>

#include "mainwindow.h"

void AccountWindow::setImageFromUrl(const QString &url, QLabel *label)
{
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
Expand Down Expand Up @@ -173,11 +175,11 @@ void AccountWindow::setUserData(const QString &username, QLabel *label)

qDebug() << "" << doc;

profileInfo->setText(obj["bio"].toString() + "\nPublic repos: "
profileInfo->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)) + "\n____________________");
+ QString::number(getStarsCount(git_user)) + "\n");

setImageFromUrl(obj["avatar_url"].toString(), profilePicture);
reply->deleteLater();
Expand All @@ -188,3 +190,22 @@ void AccountWindow::onOpenRepoClicked()
{
QDesktopServices::openUrl(QUrl("https://github.com/" + git_user + "/"));
}

void AccountWindow::setTasksProgress() {
MainWindow *mainWindow = qobject_cast<MainWindow *>(this->parent());
QString stats = mainWindow->getKeeperStats();

int incompleteTasksCount = mainWindow->incompleteTasks->count();
int completeTasksCount = mainWindow->completeTasks->count();
int inprocessTasksCount = mainWindow->inprocessTasks->count();

int totalTasks = incompleteTasksCount + completeTasksCount + inprocessTasksCount;

double percentage = static_cast<double>(completeTasksCount) / static_cast<double>(totalTasks) * 100.0;

qDebug() << completeTasksCount << "/" << totalTasks;

tasksStatsProgress->setMaximum(100);
tasksStatsProgress->setValue(percentage);
tasksStatsProgress->setFormat("Completed tasks: " + QString::number(completeTasksCount) + "/" + QString::number(totalTasks));
}
17 changes: 12 additions & 5 deletions src/CodeKeeper/accountwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ AccountWindow::AccountWindow(QWidget *parent) : QMainWindow{ parent }
{
QFile file(":/stylesheet/stylesheet_setting_window.qss");
file.open(QFile::ReadOnly);
this->setStyleSheet(file.readAll());
// this->setStyleSheet(file.readAll());
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);

centralWidget = new QWidget(this);
setCentralWidget(centralWidget);

mainLayout = new QGridLayout(centralWidget);
setFixedSize(400, 700);
setFixedSize(400, 750);

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

Expand All @@ -36,6 +36,10 @@ AccountWindow::AccountWindow(QWidget *parent) : QMainWindow{ parent }
codeKeeperStats->setText(stats);
codeKeeperStats->setAlignment(Qt::AlignHCenter);

tasksStatsProgress = new QProgressBar();
tasksStatsProgress->setFixedHeight(25);
tasksStatsProgress->setAlignment(Qt::AlignCenter);

userName = new QLabel();
userName->setText(git_user);
userName->setAlignment(Qt::AlignHCenter);
Expand All @@ -58,20 +62,23 @@ AccountWindow::AccountWindow(QWidget *parent) : QMainWindow{ parent }
QThread *setUserDataThread = new QThread;
QObject::connect(setUserDataThread, &QThread::started, this, [this]() {
setUserData(git_user, profilePicture);
setTasksProgress();

qDebug() << "setUserDataThread started";
});
setUserDataThread->start();


mainLayout->addWidget(closeWindow, 0, 0, 1, 3, Qt::AlignLeft);
mainLayout->addWidget(profilePicture, 1, 0, 3, 3, Qt::AlignCenter);
mainLayout->addWidget(userName, 5, 0, 1, 3, Qt::AlignCenter);
mainLayout->addWidget(profileInfo, 6, 0, 1, 3, Qt::AlignCenter);
mainLayout->addWidget(codeKeeperStats, 7, 0, 1, 3, Qt::AlignCenter);
mainLayout->addWidget(openRepo, 8, 0, 1, 3, Qt::AlignCenter);
mainLayout->addWidget(tasksStatsProgress, 9, 0, 1, 3, Qt::AlignCenter);
mainLayout->addWidget(codeKeeperStats, 10, 0, 1, 3, Qt::AlignCenter);
mainLayout->addWidget(openRepo, 13, 0, 1, 3, Qt::AlignCenter);

connect(closeWindow, SIGNAL(clicked()), this, SLOT(closeWindowSlot()));
connect(openRepo, SIGNAL(clicked()), this, SLOT(onOpenRepoClicked()));
}

AccountWindow::~AccountWindow(){};
AccountWindow::~AccountWindow() {};
4 changes: 4 additions & 0 deletions src/CodeKeeper/accountwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,21 @@ class AccountWindow : public QMainWindow
QLabel *userName;
QLabel *profileInfo;
QLabel *codeKeeperStats;
QLabel *tasksStats;

QPushButton *closeWindow;
QPushButton *openRepo;

QProgressBar *tasksStatsProgress;

private slots:
void setUserData(const QString &username, QLabel *label);
void closeWindowSlot();
void getSettingsData();
void setImageFromUrl(const QString &url, QLabel *label);
void onOpenRepoClicked();
int getStarsCount(const QString &username);
void setTasksProgress();
};

#endif // ACCOUNTWINDOW_H
32 changes: 16 additions & 16 deletions src/CodeKeeper/keeperFunc/functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ QString MainWindow::getKeeperStats()

int tasks_count = incompleteTasksCount + completeTasksCount + inprocessTasksCount;

QString tasksStats = "Complete tasks: " + QString::number(completeTasksCount) + "/"
+ QString::number(tasks_count);
QString projectsStats = "Not started projects: " + QString::number(notStartedProjects->count())
+ "\n\n" + "Started projects: " + QString::number(startedProjects->count()) + "\n\n"
+ "Projects on review: " + QString::number(finishlineProjects->count()) + "\n\n"
+ "Finished projects: " + QString::number(finishedProjects->count());

QString stats = tasksStats + "\n\n" + projectsStats;
QString stats = "\n" + projectsStats;

qDebug() << stats;
return stats;
Expand Down Expand Up @@ -62,6 +60,7 @@ void MainWindow::getSettingsData()
font_size = globalSettings->value("fontSize").value<QString>();
theme = globalSettings->value("theme").value<QString>();
isCustomTitlebar = globalSettings->value("isCustomTitlebar").value<bool>();
isCustomTheme = globalSettings->value("isCustomTheme").value<bool>();
sortNotesRole = globalSettings->value("sortRole", Qt::DisplayRole).value<int>();
isAutoSyncing = globalSettings->value("isAutoSync").value<bool>();
isVisibleNotesList = globalSettings->value("isVisibleNotesList", true).toBool();
Expand Down Expand Up @@ -89,7 +88,7 @@ void MainWindow::getSettingsData()

qDebug() << " " << dir << selectedFont << font_size << theme << isCustomTitlebar
<< sortNotesRole << isAutoSyncing << isVisibleNotesList << isVisibleFolders
<< isVisiblePreview << isViewMode << git_repo << git_user << git_token << isAutoSyncB;
<< isVisiblePreview << isViewMode << git_repo << git_user << git_token << isAutoSyncB << isCustomTheme;
}

void MainWindow::setConnectionStatus()
Expand Down Expand Up @@ -333,17 +332,16 @@ void MainWindow::setFontPr1(QFont *selectedFont, int *font_size_int)

openSettingsBtn->setFont(*selectedFont);
openSettingsBtn->setStyleSheet(
"QPushButton {background-color: transparent; color: #ffffff; font-size: " + font_size
+ "pt;} "
"QPushButton:hover{text-decoration: none; background-color: transparent; color: "
"#37d442; font-size: "
+ font_size + "pt;}");
"QPushButton {border: none; background-color: transparent; font-size: " + font_size
+ "pt;} ");

syncDataBtn->setFont(*selectedFont);
syncDataBtn->setStyleSheet(
"QPushButton {background-color: transparent; color: #ffffff; font-size: " + font_size
"QPushButton {background-color: transparent; border: none; color: #ffffff; font-size: "
+ font_size
+ "pt;} "
"QPushButton:hover{text-decoration: none; background-color: transparent; color: "
"QPushButton:hover{text-decoration: none; border: none; background-color: "
"transparent; color: "
"#37d442; font-size: "
+ font_size + "pt;}");

Expand Down Expand Up @@ -549,9 +547,11 @@ void MainWindow::setFontPr1(QFont *selectedFont, int *font_size_int)

openAccountWindow->setFont(*selectedFont);
openAccountWindow->setStyleSheet(
"QPushButton {background-color: transparent; color: #ffffff; font-size: " + font_size
+ "pt;} "
"QPushButton:hover{text-decoration: none; background-color: transparent; color: "
"#37d442; font-size: "
+ font_size + "pt;}");
"QPushButton {border: none; background-color: transparent; font-size: " + font_size
+ "pt;} ");

mainTabButton->setStyleSheet("background-color: transparent; border: none;");
tasksTabButton->setStyleSheet("background-color: transparent; border: none;");
notesTabButton->setStyleSheet("background-color: transparent; border: none;");
projectsTabButton->setStyleSheet("background-color: transparent; border: none;");
}
6 changes: 3 additions & 3 deletions src/CodeKeeper/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ bool loadApp(QSplashScreen *psplash)

int main(int argc, char *argv[])
{
QFile file(":/stylesheet/stylesheet.qss");
file.open(QFile::ReadOnly);
// QFile file(":/stylesheet/custom_stylesheet.qss");
// file.open(QFile::ReadOnly);

QApplication a(argc, argv);

// QSplashScreen splash(QPixmap(":/icon.png"));
// splash.show();

MainWindow keeper;
a.setStyleSheet(file.readAll());
// a.setStyleSheet(file.readAll());

keeper.setWindowIcon(QIcon(":/icon.png"));

Expand Down
Loading

0 comments on commit af3a5e5

Please sign in to comment.