mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
commit
f531d5672d
4
core.cpp
4
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";
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
2
friend.h
2
friend.h
|
@ -36,7 +36,7 @@ public:
|
|||
int friendId;
|
||||
QString userId;
|
||||
ChatForm* chatForm;
|
||||
int hasNewMessages;
|
||||
int hasNewEvents;
|
||||
Status friendStatus;
|
||||
QPixmap avatar;
|
||||
};
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include "grouplist.h"
|
||||
#include "groupwidget.h"
|
||||
#include "widget.h"
|
||||
#include "friendlist.h"
|
||||
#include "friend.h"
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
|
||||
|
@ -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"));
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
void setAsActiveChatroom();
|
||||
void setAsInactiveChatroom();
|
||||
int isActive();
|
||||
void updateStatusLight();
|
||||
|
||||
signals:
|
||||
void friendWidgetClicked(FriendWidget* widget);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -58,7 +58,6 @@ public:
|
|||
void showTestCamview();
|
||||
void newMessageAlert();
|
||||
bool isFriendWidgetCurActiveWidget(Friend* f);
|
||||
void updateFriendStatusLights(int friendId);
|
||||
~Widget();
|
||||
|
||||
virtual void closeEvent(QCloseEvent *event);
|
||||
|
|
Loading…
Reference in New Issue
Block a user