-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
55 lines (50 loc) · 1.33 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "GitChatConfig.h"
#include "GitChat.h"
#include "Git.h"
#include <QApplication>
#include <QMessageBox>
#include <QTextStream>
#include <QFile>
#include <optional>
#include <QUuid>
#include <QProcess>
int main(int argc, char *argv[])
try {
QApplication a(argc, argv);
QFile f("qdarkstyle/style.qss");
if (!f.exists())
{
QMessageBox msgBox;
msgBox.setText("Unable to set stylesheet, file not found");
msgBox.exec();
}
else
{
f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll());
}
GitChatConfig chatConfig;
std::optional<GitChat> chat;
std::optional<Git> git;
chatConfig.connect(&chatConfig, &GitChatConfig::gitLogin, [&]
(QString gitUrl, QString login, QString password){
try {
git.emplace(gitUrl, login, password);
chat.emplace(git.value());
chatConfig.close();
chat->show();
} catch (const std::exception& err) {
QMessageBox msgBox;
msgBox.setFixedSize(500,200);
msgBox.critical(nullptr, "Error: ", QString{"Error: "} + err.what());
}
});
chatConfig.show();
return a.exec();
}
catch(const std::exception& err)
{
QMessageBox msgBox;
msgBox.critical(nullptr, "Error", err.what());
}