diff --git a/core.cpp b/core.cpp index 3c6a3057e..658908066 100644 --- a/core.cpp +++ b/core.cpp @@ -811,7 +811,7 @@ void Core::checkConnection() void Core::loadConfiguration() { - QString path = Settings::getSettingsDirPath() + '/' + CONFIG_FILE_NAME; + QString path = QDir(Settings::getSettingsDirPath()).filePath(CONFIG_FILE_NAME); QFile configurationFile(path); @@ -862,7 +862,7 @@ void Core::saveConfiguration() return; } - path += '/' + CONFIG_FILE_NAME; + path = directory.filePath(CONFIG_FILE_NAME); QSaveFile configurationFile(path); if (!configurationFile.open(QIODevice::WriteOnly)) { qCritical() << "File " << path << " cannot be opened"; diff --git a/friend.cpp b/friend.cpp index b024d2dda..ec8dd3860 100644 --- a/friend.cpp +++ b/friend.cpp @@ -23,7 +23,7 @@ Friend::Friend(int FriendId, QString UserId) { widget = new FriendWidget(friendId, userId); chatForm = new ChatForm(this); - hasNewMessages = 0; + hasNewEvents = 0; friendStatus = Status::Offline; } diff --git a/friend.h b/friend.h index 8730ae435..8a3a2427a 100644 --- a/friend.h +++ b/friend.h @@ -36,7 +36,7 @@ public: int friendId; QString userId; ChatForm* chatForm; - int hasNewMessages; + int hasNewEvents; Status friendStatus; QPixmap avatar; }; diff --git a/settings.cpp b/settings.cpp index 1662e44b0..b2193e453 100644 --- a/settings.cpp +++ b/settings.cpp @@ -55,7 +55,7 @@ void Settings::load() if (portableSettings.exists()) makeToxPortable=true; - QString filePath = getSettingsDirPath() + '/' + FILENAME; + QString filePath = QDir(getSettingsDirPath()).filePath(FILENAME); //if no settings file exist -- use the default one QFile file(filePath); @@ -125,7 +125,7 @@ void Settings::load() void Settings::save() { - QString filePath = getSettingsDirPath() + '/' + FILENAME; + QString filePath = QDir(getSettingsDirPath()).filePath(FILENAME); save(filePath); } @@ -194,7 +194,7 @@ QString Settings::getSettingsDirPath() #ifdef Q_OS_WIN return QStandardPaths::writableLocation(QStandardPaths::ConfigLocation); #else - return QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + '/' + "tox" + '/'; + return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QDir::separator() + "tox"); #endif } diff --git a/smileypack.cpp b/smileypack.cpp index dba5ac0c5..cca56583c 100644 --- a/smileypack.cpp +++ b/smileypack.cpp @@ -163,7 +163,7 @@ QIcon SmileyPack::getAsIcon(const QString &key) void SmileyPack::cacheSmiley(const QString &name) { QSize size(16, 16); // TODO: adapt to text size - QString filename = path % '/' % name; + QString filename = QDir(path).filePath(name); QImage img(filename); if (!img.isNull()) diff --git a/widget/filetransfertwidget.cpp b/widget/filetransfertwidget.cpp index 773900b25..6c0a30ff7 100644 --- a/widget/filetransfertwidget.cpp +++ b/widget/filetransfertwidget.cpp @@ -278,7 +278,7 @@ void FileTransfertWidget::acceptRecvRequest() QString path; while (true) { - path = QFileDialog::getSaveFileName(this,tr("Save a file","Title of the file saving dialog"),QDir::currentPath()+'/'+filename->text()); + path = QFileDialog::getSaveFileName(this, tr("Save a file","Title of the file saving dialog"), QDir::current().filePath(filename->text())); if (path.isEmpty()) return; else diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index a95f0a076..5757e7444 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -376,6 +376,13 @@ void ChatForm::onFileRecvRequest(ToxFile file) connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransfertWidget::onFileTransferInfo); connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransfertWidget::onFileTransferCancelled); connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransfertWidget::onFileTransferFinished); + + if (!f->widget->isActive()) + { + f->hasNewEvents = 1; + // FIXME: add sound alert, as for incoming message + } + f->widget->updateStatusLight(); } void ChatForm::onAvInvite(int FriendId, int CallId, bool video) @@ -407,8 +414,8 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video) if (!w->isFriendWidgetCurActiveWidget(f)) { w->newMessageAlert(); - f->hasNewMessages=true; - w->updateFriendStatusLights(f->friendId); + f->hasNewEvents=true; + f->widget->updateStatusLight(); } } diff --git a/widget/friendwidget.cpp b/widget/friendwidget.cpp index 4840ed4a7..d41f3f52c 100644 --- a/widget/friendwidget.cpp +++ b/widget/friendwidget.cpp @@ -19,6 +19,8 @@ #include "grouplist.h" #include "groupwidget.h" #include "widget.h" +#include "friendlist.h" +#include "friend.h" #include #include @@ -203,3 +205,26 @@ int FriendWidget::isActive() { return isActiveWidget; } + +void FriendWidget::updateStatusLight() +{ + Friend* f = FriendList::findFriend(friendId); + Status status = f->friendStatus; + + if (status == Status::Online && f->hasNewEvents == 0) + statusPic.setPixmap(QPixmap(":img/status/dot_online.png")); + else if (status == Status::Online && f->hasNewEvents == 1) + statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png")); + else if (status == Status::Away && f->hasNewEvents == 0) + statusPic.setPixmap(QPixmap(":img/status/dot_idle.png")); + else if (status == Status::Away && f->hasNewEvents == 1) + statusPic.setPixmap(QPixmap(":img/status/dot_idle_notification.png")); + else if (status == Status::Busy && f->hasNewEvents == 0) + statusPic.setPixmap(QPixmap(":img/status/dot_busy.png")); + else if (status == Status::Busy && f->hasNewEvents == 1) + statusPic.setPixmap(QPixmap(":img/status/dot_busy_notification.png")); + else if (status == Status::Offline && f->hasNewEvents == 0) + statusPic.setPixmap(QPixmap(":img/status/dot_away.png")); + else if (status == Status::Offline && f->hasNewEvents == 1) + statusPic.setPixmap(QPixmap(":img/status/dot_away_notification.png")); +} diff --git a/widget/friendwidget.h b/widget/friendwidget.h index 71050d985..b174c2914 100644 --- a/widget/friendwidget.h +++ b/widget/friendwidget.h @@ -37,6 +37,7 @@ public: void setAsActiveChatroom(); void setAsInactiveChatroom(); int isActive(); + void updateStatusLight(); signals: void friendWidgetClicked(FriendWidget* widget); diff --git a/widget/widget.cpp b/widget/widget.cpp index cfba03b09..211a36bce 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -451,7 +451,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status) contactListWidget->moveWidget(f->widget, status); f->friendStatus = status; - updateFriendStatusLights(friendId); + f->widget->updateStatusLight(); // Workaround widget style after returning to list if (f->widget->isActive()) @@ -511,10 +511,10 @@ void Widget::onFriendWidgetClicked(FriendWidget *widget) isFriendWidgetActive = 1; isGroupWidgetActive = 0; - if (f->hasNewMessages != 0) - f->hasNewMessages = 0; + if (f->hasNewEvents != 0) + f->hasNewEvents = 0; - updateFriendStatusLights(f->friendId); + f->widget->updateStatusLight(); } void Widget::onFriendMessageReceived(int friendId, const QString& message) @@ -530,39 +530,17 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message) Friend* f2 = FriendList::findFriend(activeFriendWidget->friendId); if (((f->friendId != f2->friendId) || isFriendWidgetActive == 0) || isWindowMinimized || !isActiveWindow()) { - f->hasNewMessages = 1; + f->hasNewEvents = 1; newMessageAlert(); } } else { - f->hasNewMessages = 1; + f->hasNewEvents = 1; newMessageAlert(); } - updateFriendStatusLights(friendId); -} - -void Widget::updateFriendStatusLights(int friendId) -{ - Friend* f = FriendList::findFriend(friendId); - Status status = f->friendStatus; - if (status == Status::Online && f->hasNewMessages == 0) - f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online.png")); - else if (status == Status::Online && f->hasNewMessages == 1) - f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png")); - else if (status == Status::Away && f->hasNewMessages == 0) - f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_idle.png")); - else if (status == Status::Away && f->hasNewMessages == 1) - f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_idle_notification.png")); - else if (status == Status::Busy && f->hasNewMessages == 0) - f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_busy.png")); - else if (status == Status::Busy && f->hasNewMessages == 1) - f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_busy_notification.png")); - else if (status == Status::Offline && f->hasNewMessages == 0) - f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_away.png")); - else if (status == Status::Offline && f->hasNewMessages == 1) - f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_away_notification.png")); + f->widget->updateStatusLight(); } void Widget::newMessageAlert() @@ -790,8 +768,8 @@ bool Widget::event(QEvent * e) if (isFriendWidgetActive && activeFriendWidget != nullptr) { Friend* f = FriendList::findFriend(activeFriendWidget->friendId); - f->hasNewMessages = 0; - updateFriendStatusLights(f->friendId); + f->hasNewEvents = 0; + f->widget->updateStatusLight(); } else if (isGroupWidgetActive && activeGroupWidget != nullptr) { diff --git a/widget/widget.h b/widget/widget.h index 4b95fd800..e8f5599ea 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -58,7 +58,6 @@ public: void showTestCamview(); void newMessageAlert(); bool isFriendWidgetCurActiveWidget(Friend* f); - void updateFriendStatusLights(int friendId); ~Widget(); virtual void closeEvent(QCloseEvent *event);