|
|
|
@ -54,7 +54,7 @@ Widget::Widget(QWidget *parent)
@@ -54,7 +54,7 @@ Widget::Widget(QWidget *parent)
|
|
|
|
|
: QMainWindow(parent), |
|
|
|
|
ui(new Ui::MainWindow), |
|
|
|
|
activeChatroomWidget{nullptr} |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
translator = new QTranslator; |
|
|
|
|
setTranslation(); |
|
|
|
|
} |
|
|
|
@ -74,10 +74,10 @@ void Widget::init()
@@ -74,10 +74,10 @@ void Widget::init()
|
|
|
|
|
layout()->setContentsMargins(0, 0, 0, 0); |
|
|
|
|
ui->friendList->setStyleSheet(Style::getStylesheet(":ui/friendList/friendList.css")); |
|
|
|
|
|
|
|
|
|
profilePicture = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png"); |
|
|
|
|
profilePicture = new MaskablePixmapWidget(this, QSize(40, 40), ":/img/avatar_mask.png"); |
|
|
|
|
profilePicture->setPixmap(QPixmap(":/img/contact_dark.png")); |
|
|
|
|
profilePicture->setClickable(true); |
|
|
|
|
ui->horizontalLayout_3->insertWidget(0,profilePicture); |
|
|
|
|
ui->horizontalLayout_3->insertWidget(0, profilePicture); |
|
|
|
|
ui->horizontalLayout_3->insertSpacing(1, 7); |
|
|
|
|
|
|
|
|
|
ui->mainContent->setLayout(new QVBoxLayout()); |
|
|
|
@ -144,6 +144,11 @@ void Widget::init()
@@ -144,6 +144,11 @@ void Widget::init()
|
|
|
|
|
core = new Core(Camera::getInstance(), coreThread, profilePath); |
|
|
|
|
core->moveToThread(coreThread); |
|
|
|
|
connect(coreThread, &QThread::started, core, &Core::start); |
|
|
|
|
|
|
|
|
|
filesForm = new FilesForm(); |
|
|
|
|
addFriendForm = new AddFriendForm; |
|
|
|
|
settingsWidget = new SettingsWidget(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(core, &Core::connected, this, &Widget::onConnected); |
|
|
|
|
connect(core, &Core::disconnected, this, &Widget::onDisconnected); |
|
|
|
@ -153,8 +158,8 @@ void Widget::init()
@@ -153,8 +158,8 @@ void Widget::init()
|
|
|
|
|
connect(core, &Core::usernameSet, this, &Widget::setUsername); |
|
|
|
|
connect(core, &Core::statusMessageSet, this, &Widget::setStatusMessage); |
|
|
|
|
connect(core, &Core::selfAvatarChanged, this, &Widget::onSelfAvatarLoaded); |
|
|
|
|
connect(core, SIGNAL(fileDownloadFinished(const QString&)), &filesForm, SLOT(onFileDownloadComplete(const QString&))); |
|
|
|
|
connect(core, SIGNAL(fileUploadFinished(const QString&)), &filesForm, SLOT(onFileUploadComplete(const QString&))); |
|
|
|
|
connect(core, SIGNAL(fileDownloadFinished(const QString&)), filesForm, SLOT(onFileDownloadComplete(const QString&))); |
|
|
|
|
connect(core, SIGNAL(fileUploadFinished(const QString&)), filesForm, SLOT(onFileUploadComplete(const QString&))); |
|
|
|
|
connect(core, &Core::friendAdded, this, &Widget::addFriend); |
|
|
|
|
connect(core, &Core::failedToAddFriend, this, &Widget::addFriendFailed); |
|
|
|
|
connect(core, &Core::friendUsernameChanged, this, &Widget::onFriendUsernameChanged); |
|
|
|
@ -181,19 +186,33 @@ void Widget::init()
@@ -181,19 +186,33 @@ void Widget::init()
|
|
|
|
|
connect(ui->groupButton, SIGNAL(clicked()), this, SLOT(onGroupClicked())); |
|
|
|
|
connect(ui->transferButton, SIGNAL(clicked()), this, SLOT(onTransferClicked())); |
|
|
|
|
connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked())); |
|
|
|
|
connect(ui->nameLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onUsernameChanged(QString,QString))); |
|
|
|
|
connect(ui->statusLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onStatusMessageChanged(QString,QString))); |
|
|
|
|
connect(ui->nameLabel, SIGNAL(textChanged(QString, QString)), this, SLOT(onUsernameChanged(QString, QString))); |
|
|
|
|
connect(ui->statusLabel, SIGNAL(textChanged(QString, QString)), this, SLOT(onStatusMessageChanged(QString, QString))); |
|
|
|
|
connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked())); |
|
|
|
|
connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline())); |
|
|
|
|
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway())); |
|
|
|
|
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy())); |
|
|
|
|
connect(&friendForm, SIGNAL(friendRequested(QString,QString)), this, SIGNAL(friendRequested(QString,QString))); |
|
|
|
|
connect(addFriendForm, SIGNAL(friendRequested(QString, QString)), this, SIGNAL(friendRequested(QString, QString))); |
|
|
|
|
connect(idleTimer, &QTimer::timeout, this, &Widget::onUserAway); |
|
|
|
|
|
|
|
|
|
coreThread->start(); |
|
|
|
|
|
|
|
|
|
settingsWidget = new SettingsWidget(); |
|
|
|
|
friendForm.show(*ui); |
|
|
|
|
addFriendForm->show(*ui); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Widget::setTranslation() |
|
|
|
|
{ |
|
|
|
|
// Load translations
|
|
|
|
|
QCoreApplication::removeTranslator(translator); |
|
|
|
|
QString locale; |
|
|
|
|
if ((locale = Settings::getInstance().getTranslation()).isEmpty()) |
|
|
|
|
locale = QLocale::system().name().section('_', 0, 0); |
|
|
|
|
|
|
|
|
|
if (translator->load(locale, ":translations/")) |
|
|
|
|
qDebug() << "Loaded translation" << locale; |
|
|
|
|
else |
|
|
|
|
qDebug() << "Error loading translation" << locale; |
|
|
|
|
QCoreApplication::installTranslator(translator); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget::~Widget() |
|
|
|
@ -205,6 +224,8 @@ Widget::~Widget()
@@ -205,6 +224,8 @@ Widget::~Widget()
|
|
|
|
|
coreThread->terminate(); |
|
|
|
|
delete core; |
|
|
|
|
delete settingsWidget; |
|
|
|
|
delete addFriendForm; |
|
|
|
|
delete filesForm; |
|
|
|
|
|
|
|
|
|
for (Friend* f : FriendList::friendList) |
|
|
|
|
delete f; |
|
|
|
@ -418,7 +439,7 @@ void Widget::onStatusSet(Status status)
@@ -418,7 +439,7 @@ void Widget::onStatusSet(Status status)
|
|
|
|
|
void Widget::onAddClicked() |
|
|
|
|
{ |
|
|
|
|
hideMainForms(); |
|
|
|
|
friendForm.show(*ui); |
|
|
|
|
addFriendForm->show(*ui); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Widget::onGroupClicked() |
|
|
|
@ -429,7 +450,7 @@ void Widget::onGroupClicked()
@@ -429,7 +450,7 @@ void Widget::onGroupClicked()
|
|
|
|
|
void Widget::onTransferClicked() |
|
|
|
|
{ |
|
|
|
|
hideMainForms(); |
|
|
|
|
filesForm.show(*ui); |
|
|
|
|
filesForm->show(*ui); |
|
|
|
|
activeChatroomWidget = nullptr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -907,17 +928,3 @@ void Widget::onGroupSendResult(int groupId, const QString& message, int result)
@@ -907,17 +928,3 @@ void Widget::onGroupSendResult(int groupId, const QString& message, int result)
|
|
|
|
|
if (result == -1) |
|
|
|
|
g->chatForm->addSystemInfoMessage("Message failed to send", "red"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Widget::setTranslation() |
|
|
|
|
{ |
|
|
|
|
// Load translations
|
|
|
|
|
QCoreApplication::removeTranslator(translator); |
|
|
|
|
QString locale; |
|
|
|
|
if ((locale = Settings::getInstance().getTranslation()) == "") |
|
|
|
|
locale = QLocale::system().name().section('_', 0, 0); |
|
|
|
|
if (translator->load(locale,":translations/")) |
|
|
|
|
qDebug() << "Loaded translation" << locale; |
|
|
|
|
else |
|
|
|
|
qDebug() << "Error loading translation" << locale; |
|
|
|
|
QCoreApplication::installTranslator(translator); |
|
|
|
|
} |
|
|
|
|