mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr1371'
This commit is contained in:
commit
2a730d5e22
|
@ -58,6 +58,8 @@ void Friend::setName(QString name)
|
||||||
|
|
||||||
if (widget->isActive())
|
if (widget->isActive())
|
||||||
GUI::setWindowTitle(name);
|
GUI::setWindowTitle(name);
|
||||||
|
|
||||||
|
emit displayedNameChanged(getFriendWidget(), getStatus(), hasNewEvents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +73,8 @@ void Friend::setAlias(QString name)
|
||||||
|
|
||||||
if (widget->isActive())
|
if (widget->isActive())
|
||||||
GUI::setWindowTitle(dispName);
|
GUI::setWindowTitle(dispName);
|
||||||
|
|
||||||
|
emit displayedNameChanged(getFriendWidget(), getStatus(), hasNewEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Friend::setStatusMessage(QString message)
|
void Friend::setStatusMessage(QString message)
|
||||||
|
|
|
@ -17,14 +17,16 @@
|
||||||
#ifndef FRIEND_H
|
#ifndef FRIEND_H
|
||||||
#define FRIEND_H
|
#define FRIEND_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "corestructs.h"
|
#include "corestructs.h"
|
||||||
|
|
||||||
struct FriendWidget;
|
struct FriendWidget;
|
||||||
class ChatForm;
|
class ChatForm;
|
||||||
|
|
||||||
struct Friend
|
struct Friend : QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Friend(int FriendId, const ToxID &UserId);
|
Friend(int FriendId, const ToxID &UserId);
|
||||||
Friend(const Friend& other)=delete;
|
Friend(const Friend& other)=delete;
|
||||||
|
@ -49,6 +51,9 @@ public:
|
||||||
ChatForm *getChatForm();
|
ChatForm *getChatForm();
|
||||||
FriendWidget *getFriendWidget();
|
FriendWidget *getFriendWidget();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void displayedNameChanged(FriendWidget* widget, Status s, int hasNewEvents);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString userAlias, userName;
|
QString userAlias, userName;
|
||||||
ToxID userID;
|
ToxID userID;
|
||||||
|
|
|
@ -217,6 +217,7 @@ void Settings::load()
|
||||||
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
|
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
|
||||||
).toString();
|
).toString();
|
||||||
compactLayout = s.value("compactLayout", false).toBool();
|
compactLayout = s.value("compactLayout", false).toBool();
|
||||||
|
groupchatPosition = s.value("groupchatPosition", true).toBool();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("Advanced");
|
s.beginGroup("Advanced");
|
||||||
|
@ -385,6 +386,7 @@ void Settings::saveGlobal(QString path)
|
||||||
s.setValue("groupAlwaysNotify", groupAlwaysNotify);
|
s.setValue("groupAlwaysNotify", groupAlwaysNotify);
|
||||||
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
|
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
|
||||||
s.setValue("compactLayout", compactLayout);
|
s.setValue("compactLayout", compactLayout);
|
||||||
|
s.setValue("groupchatPosition", groupchatPosition);
|
||||||
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
||||||
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
@ -1174,6 +1176,16 @@ void Settings::setCompactLayout(bool value)
|
||||||
emit compactLayoutChanged();
|
emit compactLayoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::getGroupchatPosition() const
|
||||||
|
{
|
||||||
|
return groupchatPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setGroupchatPosition(bool value)
|
||||||
|
{
|
||||||
|
groupchatPosition = value;
|
||||||
|
}
|
||||||
|
|
||||||
int Settings::getThemeColor() const
|
int Settings::getThemeColor() const
|
||||||
{
|
{
|
||||||
return themeColor;
|
return themeColor;
|
||||||
|
|
|
@ -245,6 +245,9 @@ public:
|
||||||
bool getCompactLayout() const;
|
bool getCompactLayout() const;
|
||||||
void setCompactLayout(bool compact);
|
void setCompactLayout(bool compact);
|
||||||
|
|
||||||
|
bool getGroupchatPosition() const;
|
||||||
|
void setGroupchatPosition(bool value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void save(bool writePersonal = true);
|
void save(bool writePersonal = true);
|
||||||
void save(QString path, bool writePersonal = true);
|
void save(QString path, bool writePersonal = true);
|
||||||
|
@ -272,6 +275,7 @@ private:
|
||||||
|
|
||||||
bool fauxOfflineMessaging;
|
bool fauxOfflineMessaging;
|
||||||
bool compactLayout;
|
bool compactLayout;
|
||||||
|
bool groupchatPosition;
|
||||||
bool enableIPv6;
|
bool enableIPv6;
|
||||||
QString translation;
|
QString translation;
|
||||||
static bool makeToxPortable;
|
static bool makeToxPortable;
|
||||||
|
|
|
@ -77,6 +77,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
||||||
bodyUI->groupAlwaysNotify->setChecked(Settings::getInstance().getGroupAlwaysNotify());
|
bodyUI->groupAlwaysNotify->setChecked(Settings::getInstance().getGroupAlwaysNotify());
|
||||||
bodyUI->cbFauxOfflineMessaging->setChecked(Settings::getInstance().getFauxOfflineMessaging());
|
bodyUI->cbFauxOfflineMessaging->setChecked(Settings::getInstance().getFauxOfflineMessaging());
|
||||||
bodyUI->cbCompactLayout->setChecked(Settings::getInstance().getCompactLayout());
|
bodyUI->cbCompactLayout->setChecked(Settings::getInstance().getCompactLayout());
|
||||||
|
bodyUI->cbGroupchatPosition->setChecked(Settings::getInstance().getGroupchatPosition());
|
||||||
|
|
||||||
for (auto entry : SmileyPack::listSmileyPacks())
|
for (auto entry : SmileyPack::listSmileyPacks())
|
||||||
{
|
{
|
||||||
|
@ -154,6 +155,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
||||||
connect(bodyUI->reconnectButton, &QPushButton::clicked, this, &GeneralForm::onReconnectClicked);
|
connect(bodyUI->reconnectButton, &QPushButton::clicked, this, &GeneralForm::onReconnectClicked);
|
||||||
connect(bodyUI->cbFauxOfflineMessaging, &QCheckBox::stateChanged, this, &GeneralForm::onFauxOfflineMessaging);
|
connect(bodyUI->cbFauxOfflineMessaging, &QCheckBox::stateChanged, this, &GeneralForm::onFauxOfflineMessaging);
|
||||||
connect(bodyUI->cbCompactLayout, &QCheckBox::stateChanged, this, &GeneralForm::onCompactLayout);
|
connect(bodyUI->cbCompactLayout, &QCheckBox::stateChanged, this, &GeneralForm::onCompactLayout);
|
||||||
|
connect(bodyUI->cbGroupchatPosition, &QCheckBox::stateChanged, this, &GeneralForm::onGroupchatPositionChanged);
|
||||||
|
|
||||||
// prevent stealing mouse whell scroll
|
// prevent stealing mouse whell scroll
|
||||||
// scrolling event won't be transmitted to comboboxes or qspinboxes when scrolling
|
// scrolling event won't be transmitted to comboboxes or qspinboxes when scrolling
|
||||||
|
@ -394,6 +396,12 @@ void GeneralForm::onCompactLayout()
|
||||||
emit parent->compactToggled(bodyUI->cbCompactLayout->isChecked());
|
emit parent->compactToggled(bodyUI->cbCompactLayout->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeneralForm::onGroupchatPositionChanged()
|
||||||
|
{
|
||||||
|
Settings::getInstance().setGroupchatPosition(bodyUI->cbGroupchatPosition->isChecked());
|
||||||
|
emit parent->groupchatPositionToggled(bodyUI->cbGroupchatPosition->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralForm::onThemeColorChanged(int)
|
void GeneralForm::onThemeColorChanged(int)
|
||||||
{
|
{
|
||||||
int index = bodyUI->themeColorCBox->currentIndex();
|
int index = bodyUI->themeColorCBox->currentIndex();
|
||||||
|
|
|
@ -60,6 +60,7 @@ private slots:
|
||||||
void onSetGroupAlwaysNotify();
|
void onSetGroupAlwaysNotify();
|
||||||
void onFauxOfflineMessaging();
|
void onFauxOfflineMessaging();
|
||||||
void onCompactLayout();
|
void onCompactLayout();
|
||||||
|
void onGroupchatPositionChanged();
|
||||||
void onThemeColorChanged(int);
|
void onThemeColorChanged(int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -374,7 +374,7 @@ instead of system taskbar.</string>
|
||||||
<widget class="QCheckBox" name="cbFauxOfflineMessaging">
|
<widget class="QCheckBox" name="cbFauxOfflineMessaging">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string comment="toolTip for Faux offline messaging setting">Messages you are trying to send to your friends when they are not online
|
<string comment="toolTip for Faux offline messaging setting">Messages you are trying to send to your friends when they are not online
|
||||||
will be sent to them when they will appear online to you.</string>
|
will be sent to them when they appear online to you.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Faux offline messaging</string>
|
<string>Faux offline messaging</string>
|
||||||
|
@ -391,6 +391,16 @@ will be sent to them when they will appear online to you.</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QCheckBox" name="cbGroupchatPosition">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string comment="toolTip for groupchat positioning">If checked, groupchats will be placed at the top of the friends list, otherwise, they'll be placed below online friends.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Place groupchats at top of friend list</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void setShowSystemTray(bool newValue);
|
void setShowSystemTray(bool newValue);
|
||||||
void compactToggled(bool compact);
|
void compactToggled(bool compact);
|
||||||
|
void groupchatPositionToggled(bool groupchatPosition);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTabChanged(int);
|
void onTabChanged(int);
|
||||||
|
|
|
@ -16,8 +16,11 @@
|
||||||
#include "friendlistwidget.h"
|
#include "friendlistwidget.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
#include "src/friend.h"
|
||||||
|
#include "src/friendlist.h"
|
||||||
|
#include "src/widget/friendwidget.h"
|
||||||
|
|
||||||
FriendListWidget::FriendListWidget(QWidget *parent) :
|
FriendListWidget::FriendListWidget(QWidget *parent, bool groupchatPosition) :
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
{
|
{
|
||||||
mainLayout = new QGridLayout();
|
mainLayout = new QGridLayout();
|
||||||
|
@ -30,7 +33,7 @@ FriendListWidget::FriendListWidget(QWidget *parent) :
|
||||||
groupLayout->setSpacing(0);
|
groupLayout->setSpacing(0);
|
||||||
groupLayout->setMargin(0);
|
groupLayout->setMargin(0);
|
||||||
|
|
||||||
for (Status s : {Status::Online, Status::Away, Status::Busy, Status::Offline})
|
for (Status s : {Status::Online, Status::Offline})
|
||||||
{
|
{
|
||||||
QVBoxLayout *l = new QVBoxLayout();
|
QVBoxLayout *l = new QVBoxLayout();
|
||||||
l->setSpacing(0);
|
l->setSpacing(0);
|
||||||
|
@ -39,11 +42,18 @@ FriendListWidget::FriendListWidget(QWidget *parent) :
|
||||||
layouts[static_cast<int>(s)] = l;
|
layouts[static_cast<int>(s)] = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(groupchatPosition)
|
||||||
|
{
|
||||||
|
mainLayout->addLayout(groupLayout, 0, 0);
|
||||||
|
mainLayout->addLayout(layouts[static_cast<int>(Status::Online)], 1, 0);
|
||||||
|
mainLayout->addLayout(layouts[static_cast<int>(Status::Offline)], 2, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
mainLayout->addLayout(layouts[static_cast<int>(Status::Online)], 0, 0);
|
mainLayout->addLayout(layouts[static_cast<int>(Status::Online)], 0, 0);
|
||||||
mainLayout->addLayout(groupLayout, 1, 0);
|
mainLayout->addLayout(groupLayout, 1, 0);
|
||||||
mainLayout->addLayout(layouts[static_cast<int>(Status::Away)], 2, 0);
|
mainLayout->addLayout(layouts[static_cast<int>(Status::Offline)], 2, 0);
|
||||||
mainLayout->addLayout(layouts[static_cast<int>(Status::Busy)], 3, 0);
|
}
|
||||||
mainLayout->addLayout(layouts[static_cast<int>(Status::Offline)], 4, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVBoxLayout* FriendListWidget::getGroupLayout()
|
QVBoxLayout* FriendListWidget::getGroupLayout()
|
||||||
|
@ -57,15 +67,43 @@ QVBoxLayout* FriendListWidget::getFriendLayout(Status s)
|
||||||
if (res != layouts.end())
|
if (res != layouts.end())
|
||||||
return res.value();
|
return res.value();
|
||||||
|
|
||||||
qDebug() << "Friend Status: " << static_cast<int>(s) << " not found!";
|
//qDebug() << "Friend Status: " << static_cast<int>(s) << " not found!";
|
||||||
return layouts[static_cast<int>(Status::Online)];
|
return layouts[static_cast<int>(Status::Online)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FriendListWidget::onGroupchatPositionChanged(bool top)
|
||||||
|
{
|
||||||
|
mainLayout->removeItem(groupLayout);
|
||||||
|
mainLayout->removeItem(getFriendLayout(Status::Online));
|
||||||
|
if(top)
|
||||||
|
{
|
||||||
|
mainLayout->addLayout(groupLayout, 0, 0);
|
||||||
|
mainLayout->addLayout(layouts[static_cast<int>(Status::Online)], 1, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mainLayout->addLayout(layouts[static_cast<int>(Status::Online)], 0, 0);
|
||||||
|
mainLayout->addLayout(groupLayout, 1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FriendListWidget::moveWidget(QWidget *w, Status s, int hasNewEvents)
|
void FriendListWidget::moveWidget(QWidget *w, Status s, int hasNewEvents)
|
||||||
{
|
{
|
||||||
mainLayout->removeWidget(w);
|
QVBoxLayout* l = getFriendLayout(s);
|
||||||
if (hasNewEvents == 0)
|
l->removeWidget(w);
|
||||||
getFriendLayout(s)->addWidget(w);
|
Friend* g = FriendList::findFriend(dynamic_cast<FriendWidget*>(w)->friendId);
|
||||||
else
|
for(int i = 0; i < l->count(); i++)
|
||||||
getFriendLayout(s)->insertWidget(0, w);
|
{
|
||||||
|
FriendWidget* w1 = dynamic_cast<FriendWidget*>(l->itemAt(i)->widget());
|
||||||
|
if(w1 != NULL)
|
||||||
|
{
|
||||||
|
Friend* f = FriendList::findFriend(w1->friendId);
|
||||||
|
if(f->getDisplayedName().localeAwareCompare(g->getDisplayedName()) > 0)
|
||||||
|
{
|
||||||
|
l->insertWidget(i,w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l->addWidget(w);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,15 +29,15 @@ class FriendListWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit FriendListWidget(QWidget *parent = 0);
|
explicit FriendListWidget(QWidget *parent = 0, bool groupchatPosition = true);
|
||||||
|
|
||||||
QVBoxLayout* getGroupLayout();
|
QVBoxLayout* getGroupLayout();
|
||||||
QVBoxLayout* getFriendLayout(Status s);
|
QVBoxLayout* getFriendLayout(Status s);
|
||||||
void moveWidget(QWidget *w, Status s, int hasNewEvents);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void onGroupchatPositionChanged(bool top);
|
||||||
|
void moveWidget(QWidget *w, Status s, int hasNewEvents);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<int, QVBoxLayout*> layouts;
|
QHash<int, QVBoxLayout*> layouts;
|
||||||
|
|
|
@ -144,7 +144,7 @@ void Widget::init()
|
||||||
|
|
||||||
ui->statusHead->setStyleSheet(Style::getStylesheet(":/ui/window/statusPanel.css"));
|
ui->statusHead->setStyleSheet(Style::getStylesheet(":/ui/window/statusPanel.css"));
|
||||||
|
|
||||||
contactListWidget = new FriendListWidget();
|
contactListWidget = new FriendListWidget(0, Settings::getInstance().getGroupchatPosition());
|
||||||
ui->friendList->setWidget(contactListWidget);
|
ui->friendList->setWidget(contactListWidget);
|
||||||
ui->friendList->setLayoutDirection(Qt::RightToLeft);
|
ui->friendList->setLayoutDirection(Qt::RightToLeft);
|
||||||
|
|
||||||
|
@ -197,6 +197,7 @@ void Widget::init()
|
||||||
|
|
||||||
addFriendForm->show(*ui);
|
addFriendForm->show(*ui);
|
||||||
|
|
||||||
|
connect(settingsWidget, &SettingsWidget::groupchatPositionToggled, contactListWidget, &FriendListWidget::onGroupchatPositionChanged);
|
||||||
#if (AUTOUPDATE_ENABLED)
|
#if (AUTOUPDATE_ENABLED)
|
||||||
if (Settings::getInstance().getCheckUpdates())
|
if (Settings::getInstance().getCheckUpdates())
|
||||||
AutoUpdater::checkUpdatesAsyncInteractive();
|
AutoUpdater::checkUpdatesAsyncInteractive();
|
||||||
|
@ -561,10 +562,10 @@ void Widget::addFriend(int friendId, const QString &userId)
|
||||||
//qDebug() << "Widget: Adding friend with id" << userId;
|
//qDebug() << "Widget: Adding friend with id" << userId;
|
||||||
ToxID userToxId = ToxID::fromString(userId);
|
ToxID userToxId = ToxID::fromString(userId);
|
||||||
Friend* newfriend = FriendList::addFriend(friendId, userToxId);
|
Friend* newfriend = FriendList::addFriend(friendId, userToxId);
|
||||||
QLayout* layout = contactListWidget->getFriendLayout(Status::Offline);
|
contactListWidget->moveWidget(newfriend->getFriendWidget(),Status::Offline,0);
|
||||||
layout->addWidget(newfriend->getFriendWidget());
|
|
||||||
|
|
||||||
Core* core = Nexus::getCore();
|
Core* core = Nexus::getCore();
|
||||||
|
connect(newfriend, &Friend::displayedNameChanged, contactListWidget, &FriendListWidget::moveWidget);
|
||||||
connect(settingsWidget, &SettingsWidget::compactToggled, newfriend->getFriendWidget(), &GenericChatroomWidget::onCompactChanged);
|
connect(settingsWidget, &SettingsWidget::compactToggled, newfriend->getFriendWidget(), &GenericChatroomWidget::onCompactChanged);
|
||||||
connect(newfriend->getFriendWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
|
connect(newfriend->getFriendWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
|
||||||
connect(newfriend->getFriendWidget(), SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
|
connect(newfriend->getFriendWidget(), SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
|
||||||
|
@ -626,10 +627,20 @@ void Widget::onFriendStatusChanged(int friendId, Status status)
|
||||||
if (!f)
|
if (!f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
contactListWidget->moveWidget(f->getFriendWidget(), status, f->getEventFlag());
|
|
||||||
|
|
||||||
bool isActualChange = f->getStatus() != status;
|
bool isActualChange = f->getStatus() != status;
|
||||||
|
|
||||||
|
if(isActualChange)
|
||||||
|
{
|
||||||
|
if(f->getStatus() == Status::Offline)
|
||||||
|
{
|
||||||
|
contactListWidget->moveWidget(f->getFriendWidget(), Status::Online, f->getEventFlag());
|
||||||
|
}
|
||||||
|
else if(status == Status::Offline)
|
||||||
|
{
|
||||||
|
contactListWidget->moveWidget(f->getFriendWidget(), Status::Offline, f->getEventFlag());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
f->setStatus(status);
|
f->setStatus(status);
|
||||||
f->getFriendWidget()->updateStatusLight();
|
f->getFriendWidget()->updateStatusLight();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user