mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
added a compact layout for the friends list
This commit is contained in:
parent
5cb1b6fe8e
commit
c73b07db72
|
@ -142,6 +142,7 @@ void Settings::load()
|
|||
globalAutoAcceptDir = s.value("globalAutoAcceptDir",
|
||||
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
|
||||
).toString();
|
||||
compactLayout = s.value("compactLayout", false).toBool();
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup("Advanced");
|
||||
|
@ -289,6 +290,7 @@ void Settings::save(QString path, bool writeFriends)
|
|||
s.setValue("checkUpdates", checkUpdates);
|
||||
s.setValue("showInFront", showInFront);
|
||||
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
|
||||
s.setValue("compactLayout", compactLayout);
|
||||
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
||||
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
||||
s.endGroup();
|
||||
|
@ -958,6 +960,15 @@ void Settings::setFauxOfflineMessaging(bool value)
|
|||
fauxOfflineMessaging = value;
|
||||
}
|
||||
|
||||
bool Settings::getCompactLayout() const {
|
||||
return compactLayout;
|
||||
}
|
||||
|
||||
void Settings::setCompactLayout(bool value) {
|
||||
compactLayout = value;
|
||||
emit compactLayoutChanged();
|
||||
}
|
||||
|
||||
int Settings::getThemeColor() const
|
||||
{
|
||||
return themeColor;
|
||||
|
|
|
@ -215,6 +215,9 @@ public:
|
|||
bool getFauxOfflineMessaging() const;
|
||||
void setFauxOfflineMessaging(bool value);
|
||||
|
||||
bool getCompactLayout() const;
|
||||
void setCompactLayout(bool compact);
|
||||
|
||||
public:
|
||||
void save(bool writeFriends = true);
|
||||
void save(QString path, bool writeFriends = true);
|
||||
|
@ -238,6 +241,7 @@ private:
|
|||
bool dontShowDhtDialog;
|
||||
|
||||
bool fauxOfflineMessaging;
|
||||
bool compactLayout;
|
||||
bool enableIPv6;
|
||||
QString translation;
|
||||
static bool makeToxPortable;
|
||||
|
@ -313,6 +317,7 @@ signals:
|
|||
void smileyPackChanged();
|
||||
void emojiFontChanged();
|
||||
void timestampFormatChanged();
|
||||
void compactLayoutChanged();
|
||||
};
|
||||
|
||||
#endif // SETTINGS_HPP
|
||||
|
|
|
@ -68,6 +68,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
|||
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getGlobalAutoAcceptDir());
|
||||
bodyUI->showInFront->setChecked(Settings::getInstance().getShowInFront());
|
||||
bodyUI->cbFauxOfflineMessaging->setChecked(Settings::getInstance().getFauxOfflineMessaging());
|
||||
bodyUI->cbCompactLayout->setChecked(Settings::getInstance().getCompactLayout());
|
||||
|
||||
for (auto entry : SmileyPack::listSmileyPacks())
|
||||
{
|
||||
|
@ -141,6 +142,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
|||
connect(bodyUI->proxyPort, SIGNAL(valueChanged(int)), this, SLOT(onProxyPortEdited(int)));
|
||||
connect(bodyUI->reconnectButton, &QPushButton::clicked, this, &GeneralForm::onReconnectClicked);
|
||||
connect(bodyUI->cbFauxOfflineMessaging, &QCheckBox::stateChanged, this, &GeneralForm::onFauxOfflineMessaging);
|
||||
connect(bodyUI->cbCompactLayout, &QCheckBox::stateChanged, this, &GeneralForm::onCompactLayout);
|
||||
|
||||
#ifndef QTOX_PLATFORM_EXT
|
||||
bodyUI->autoAwayLabel->setEnabled(false); // these don't seem to change the appearance of the widgets,
|
||||
|
@ -331,6 +333,11 @@ void GeneralForm::onFauxOfflineMessaging()
|
|||
Settings::getInstance().setFauxOfflineMessaging(bodyUI->cbFauxOfflineMessaging->isChecked());
|
||||
}
|
||||
|
||||
void GeneralForm::onCompactLayout()
|
||||
{
|
||||
Settings::getInstance().setCompactLayout(bodyUI->cbCompactLayout->isChecked());
|
||||
}
|
||||
|
||||
void GeneralForm::onThemeColorChanged(int)
|
||||
{
|
||||
int index = bodyUI->themeColorCBox->currentIndex();
|
||||
|
|
|
@ -55,6 +55,7 @@ private slots:
|
|||
void onCheckUpdateChanged();
|
||||
void onSetShowInFront();
|
||||
void onFauxOfflineMessaging();
|
||||
void onCompactLayout();
|
||||
void onThemeColorChanged(int);
|
||||
|
||||
private:
|
||||
|
|
|
@ -183,6 +183,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbCompactLayout">
|
||||
<property name="text">
|
||||
<string>Compact layout</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item alignment="Qt::AlignLeft">
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "genericchatroomwidget.h"
|
||||
#include "src/misc/style.h"
|
||||
#include "src/misc/settings.h"
|
||||
#include "maskablepixmapwidget.h"
|
||||
#include "croppinglabel.h"
|
||||
#include <QMouseEvent>
|
||||
|
@ -24,7 +25,16 @@
|
|||
GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
{
|
||||
setProperty("compact", Settings::getInstance().getCompactLayout());
|
||||
|
||||
if(property("compact").toBool())
|
||||
{
|
||||
setFixedHeight(25);
|
||||
}
|
||||
else
|
||||
{
|
||||
setFixedHeight(55);
|
||||
}
|
||||
|
||||
setLayout(&layout);
|
||||
layout.setSpacing(0);
|
||||
|
@ -34,7 +44,14 @@ GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
|
|||
setLayoutDirection(Qt::LeftToRight); // parent might have set Qt::RightToLeft
|
||||
|
||||
// avatar
|
||||
if(property("compact").toBool())
|
||||
{
|
||||
avatar = new MaskablePixmapWidget(this, QSize(20,20), ":/img/avatar_mask.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
||||
}
|
||||
|
||||
// status text
|
||||
statusMessageLabel = new CroppingLabel(this);
|
||||
|
@ -44,6 +61,20 @@ GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
|
|||
nameLabel = new CroppingLabel(this);
|
||||
nameLabel->setObjectName("name");
|
||||
|
||||
if(property("compact").toBool())
|
||||
{
|
||||
layout.addSpacing(18);
|
||||
layout.addWidget(avatar);
|
||||
layout.addSpacing(5);
|
||||
layout.addWidget(nameLabel);
|
||||
layout.addWidget(statusMessageLabel);
|
||||
layout.addSpacing(5);
|
||||
layout.addWidget(&statusPic);
|
||||
layout.addSpacing(5);
|
||||
layout.activate();
|
||||
}
|
||||
else
|
||||
{
|
||||
textLayout.addStretch();
|
||||
textLayout.addWidget(nameLabel);
|
||||
textLayout.addWidget(statusMessageLabel);
|
||||
|
@ -57,6 +88,7 @@ GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
|
|||
layout.addWidget(&statusPic);
|
||||
layout.addSpacing(10);
|
||||
layout.activate();
|
||||
}
|
||||
|
||||
setProperty("active", false);
|
||||
setStyleSheet(Style::getStylesheet(":/ui/chatroomWidgets/genericChatroomWidget.css"));
|
||||
|
@ -102,3 +134,13 @@ void GenericChatroomWidget::reloadTheme()
|
|||
{
|
||||
setStyleSheet(Style::getStylesheet(":/ui/chatroomWidgets/genericChatroomWidget.css"));
|
||||
}
|
||||
|
||||
bool GenericChatroomWidget::isCompact() const
|
||||
{
|
||||
return compact;
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::setCompact(bool compact) {
|
||||
this->compact = compact;
|
||||
Style::repolish(this);
|
||||
}
|
||||
|
|
|
@ -53,6 +53,11 @@ public:
|
|||
|
||||
void reloadTheme();
|
||||
|
||||
bool isCompact() const;
|
||||
void setCompact(bool compact);
|
||||
|
||||
Q_PROPERTY(bool compact READ isCompact WRITE setCompact)
|
||||
|
||||
signals:
|
||||
void chatroomWidgetClicked(GenericChatroomWidget* widget);
|
||||
|
||||
|
@ -65,6 +70,7 @@ protected:
|
|||
MaskablePixmapWidget* avatar;
|
||||
QLabel statusPic;
|
||||
CroppingLabel *nameLabel, *statusMessageLabel;
|
||||
bool compact;
|
||||
|
||||
friend class Style; ///< To update our stylesheets
|
||||
};
|
||||
|
|
|
@ -13,25 +13,49 @@ GenericChatroomWidget[active="false"]:hover
|
|||
background-color: @themeLight;
|
||||
}
|
||||
|
||||
GenericChatroomWidget[active="true"] > QLabel#status
|
||||
GenericChatroomWidget[active="true"][compact="true"] > QLabel#status
|
||||
{
|
||||
font: @small;
|
||||
color: @mediumGrey;
|
||||
}
|
||||
|
||||
GenericChatroomWidget[active="false"][compact="true"] > QLabel#status
|
||||
{
|
||||
font: @small;
|
||||
color: @lightGrey;
|
||||
}
|
||||
|
||||
GenericChatroomWidget[active="true"][compact="true"] > QLabel#name
|
||||
{
|
||||
font: @medium;
|
||||
color: @darkGrey;
|
||||
}
|
||||
|
||||
GenericChatroomWidget[active="false"][compact="true"] > QLabel#name
|
||||
{
|
||||
font: @medium;
|
||||
color: @white;
|
||||
}
|
||||
|
||||
GenericChatroomWidget[active="true"][compact="false"] > QLabel#status
|
||||
{
|
||||
font: @medium;
|
||||
color: @mediumGrey;
|
||||
}
|
||||
|
||||
GenericChatroomWidget[active="false"] > QLabel#status
|
||||
GenericChatroomWidget[active="false"][compact="false"] > QLabel#status
|
||||
{
|
||||
font: @medium;
|
||||
color: @lightGrey;
|
||||
}
|
||||
|
||||
GenericChatroomWidget[active="true"] > QLabel#name
|
||||
GenericChatroomWidget[active="true"][compact="false"] > QLabel#name
|
||||
{
|
||||
font: @big;
|
||||
color: @darkGrey;
|
||||
}
|
||||
|
||||
GenericChatroomWidget[active="false"] > QLabel#name
|
||||
GenericChatroomWidget[active="false"][compact="false"] > QLabel#name
|
||||
{
|
||||
font: @big;
|
||||
color: @white;
|
||||
|
|
Loading…
Reference in New Issue
Block a user