diff --git a/src/misc/settings.cpp b/src/misc/settings.cpp
index 750520f9c..7de1946ee 100644
--- a/src/misc/settings.cpp
+++ b/src/misc/settings.cpp
@@ -216,6 +216,7 @@ void Settings::load()
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
).toString();
compactLayout = s.value("compactLayout", false).toBool();
+ groupchatPosition = s.value("groupchatPosition", true).toBool();
s.endGroup();
s.beginGroup("Advanced");
@@ -383,6 +384,7 @@ void Settings::saveGlobal(QString path)
s.setValue("groupAlwaysNotify", groupAlwaysNotify);
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
s.setValue("compactLayout", compactLayout);
+ s.setValue("groupchatPosition", groupchatPosition);
s.setValue("autoSaveEnabled", autoSaveEnabled);
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
s.endGroup();
@@ -1162,6 +1164,17 @@ void Settings::setCompactLayout(bool value)
emit compactLayoutChanged();
}
+bool Settings::getGroupchatPosition() const
+{
+ return groupchatPosition;
+}
+
+void Settings::setGroupchatPosition(bool value)
+{
+ groupchatPosition = value;
+ emit groupchatPositionChanged();
+}
+
int Settings::getThemeColor() const
{
return themeColor;
diff --git a/src/misc/settings.h b/src/misc/settings.h
index 921745565..a2632ccc4 100644
--- a/src/misc/settings.h
+++ b/src/misc/settings.h
@@ -242,6 +242,9 @@ public:
bool getCompactLayout() const;
void setCompactLayout(bool compact);
+ bool getGroupchatPosition() const;
+ void setGroupchatPosition(bool value);
+
public:
void save(bool writePersonal = true);
void save(QString path, bool writePersonal = true);
@@ -269,6 +272,7 @@ private:
bool fauxOfflineMessaging;
bool compactLayout;
+ bool groupchatPosition;
bool enableIPv6;
QString translation;
static bool makeToxPortable;
@@ -353,6 +357,7 @@ signals:
void emojiFontChanged();
void timestampFormatChanged();
void compactLayoutChanged();
+ void groupchatPositionChanged();
};
#endif // SETTINGS_HPP
diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp
index 73dd64c4f..391f8af6b 100644
--- a/src/widget/form/settings/generalform.cpp
+++ b/src/widget/form/settings/generalform.cpp
@@ -75,6 +75,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->groupAlwaysNotify->setChecked(Settings::getInstance().getGroupAlwaysNotify());
bodyUI->cbFauxOfflineMessaging->setChecked(Settings::getInstance().getFauxOfflineMessaging());
bodyUI->cbCompactLayout->setChecked(Settings::getInstance().getCompactLayout());
+ bodyUI->cbGroupchatPosition->setChecked(Settings::getInstance().getGroupchatPosition());
for (auto entry : SmileyPack::listSmileyPacks())
{
@@ -152,6 +153,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
connect(bodyUI->reconnectButton, &QPushButton::clicked, this, &GeneralForm::onReconnectClicked);
connect(bodyUI->cbFauxOfflineMessaging, &QCheckBox::stateChanged, this, &GeneralForm::onFauxOfflineMessaging);
connect(bodyUI->cbCompactLayout, &QCheckBox::stateChanged, this, &GeneralForm::onCompactLayout);
+ connect(bodyUI->cbGroupchatPosition, &QCheckBox::stateChanged, this, &GeneralForm::onGroupchatPositionChanged);
#ifndef QTOX_PLATFORM_EXT
bodyUI->autoAwayLabel->setEnabled(false); // these don't seem to change the appearance of the widgets,
@@ -364,6 +366,12 @@ void GeneralForm::onCompactLayout()
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)
{
int index = bodyUI->themeColorCBox->currentIndex();
diff --git a/src/widget/form/settings/generalform.h b/src/widget/form/settings/generalform.h
index b383cbcfb..d9ac24b62 100644
--- a/src/widget/form/settings/generalform.h
+++ b/src/widget/form/settings/generalform.h
@@ -59,6 +59,7 @@ private slots:
void onSetGroupAlwaysNotify();
void onFauxOfflineMessaging();
void onCompactLayout();
+ void onGroupchatPositionChanged();
void onThemeColorChanged(int);
private:
diff --git a/src/widget/form/settings/generalsettings.ui b/src/widget/form/settings/generalsettings.ui
index ad4dad396..a805dc231 100644
--- a/src/widget/form/settings/generalsettings.ui
+++ b/src/widget/form/settings/generalsettings.ui
@@ -381,6 +381,16 @@ will be sent to them when they will appear online to you.
+ -
+
+
+ If checked, groupchats will be placed at the top of the friends list, otherwise, they'll be placed at the bottom.
+
+
+ Place groupchats at top of friend list
+
+
+
diff --git a/src/widget/form/settingswidget.h b/src/widget/form/settingswidget.h
index 1cdafabbe..32364a1af 100644
--- a/src/widget/form/settingswidget.h
+++ b/src/widget/form/settingswidget.h
@@ -44,6 +44,7 @@ public:
signals:
void setShowSystemTray(bool newValue);
void compactToggled(bool compact);
+ void groupchatPositionToggled(bool groupchatPosition);
private slots:
void onTabChanged(int);
diff --git a/src/widget/friendlistwidget.cpp b/src/widget/friendlistwidget.cpp
index 8185458ad..128bc2fcc 100644
--- a/src/widget/friendlistwidget.cpp
+++ b/src/widget/friendlistwidget.cpp
@@ -20,7 +20,7 @@
#include "src/friendlist.h"
#include "src/widget/friendwidget.h"
-FriendListWidget::FriendListWidget(QWidget *parent) :
+FriendListWidget::FriendListWidget(QWidget *parent, bool groupchatPosition) :
QWidget(parent)
{
mainLayout = new QGridLayout();
@@ -42,11 +42,16 @@ FriendListWidget::FriendListWidget(QWidget *parent) :
layouts[static_cast(s)] = l;
}
- mainLayout->addLayout(layouts[static_cast(Status::Online)], 0, 0);
- mainLayout->addLayout(groupLayout, 1, 0);
- mainLayout->addLayout(layouts[static_cast(Status::Away)], 2, 0);
- mainLayout->addLayout(layouts[static_cast(Status::Busy)], 3, 0);
- mainLayout->addLayout(layouts[static_cast(Status::Offline)], 4, 0);
+ if(groupchatPosition){
+ mainLayout->addLayout(groupLayout, 0, 0);
+ mainLayout->addLayout(layouts[static_cast(Status::Online)], 1, 0);
+ mainLayout->addLayout(layouts[static_cast(Status::Offline)], 2, 0);
+ }
+ else{
+ mainLayout->addLayout(layouts[static_cast(Status::Online)], 0, 0);
+ mainLayout->addLayout(groupLayout, 1, 0);
+ mainLayout->addLayout(layouts[static_cast(Status::Offline)], 2, 0);
+ }
}
QVBoxLayout* FriendListWidget::getGroupLayout()
@@ -64,6 +69,20 @@ QVBoxLayout* FriendListWidget::getFriendLayout(Status s)
return layouts[static_cast(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(Status::Online)], 1, 0);
+ }
+ else{
+ mainLayout->addLayout(layouts[static_cast(Status::Online)], 0, 0);
+ mainLayout->addLayout(groupLayout, 1, 0);
+ }
+}
+
void FriendListWidget::moveWidget(QWidget *w, Status s, int hasNewEvents)
{
getFriendLayout(s)->removeWidget(w);
diff --git a/src/widget/friendlistwidget.h b/src/widget/friendlistwidget.h
index c291f6777..70101b885 100644
--- a/src/widget/friendlistwidget.h
+++ b/src/widget/friendlistwidget.h
@@ -29,14 +29,14 @@ class FriendListWidget : public QWidget
{
Q_OBJECT
public:
- explicit FriendListWidget(QWidget *parent = 0);
-
+ explicit FriendListWidget(QWidget *parent = 0, bool groupchatPosition = true);
QVBoxLayout* getGroupLayout();
QVBoxLayout* getFriendLayout(Status s);
signals:
public slots:
+ void onGroupchatPositionChanged(bool top);
void moveWidget(QWidget *w, Status s, int hasNewEvents);
private:
diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp
index 55bfa9ceb..8d00e2660 100644
--- a/src/widget/widget.cpp
+++ b/src/widget/widget.cpp
@@ -147,7 +147,7 @@ void Widget::init()
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->setLayoutDirection(Qt::RightToLeft);
@@ -200,6 +200,7 @@ void Widget::init()
addFriendForm->show(*ui);
+ connect(settingsWidget, &SettingsWidget::groupchatPositionToggled, contactListWidget, &FriendListWidget::onGroupchatPositionChanged);
#if (AUTOUPDATE_ENABLED)
if (Settings::getInstance().getCheckUpdates())
AutoUpdater::checkUpdatesAsyncInteractive();