mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
parent
05547086fb
commit
cebd8cbc19
3 changed files with 32 additions and 6 deletions
|
@ -569,7 +569,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
|||
hasNotifications = true;
|
||||
}
|
||||
|
||||
if (hasNotifications)
|
||||
if (hasNotifications && userSettings_->hasDesktopNotifications())
|
||||
http::client()->notifications(
|
||||
5,
|
||||
[this](const mtx::responses::Notifications &res,
|
||||
|
|
|
@ -38,6 +38,7 @@ UserSettings::load()
|
|||
{
|
||||
QSettings settings;
|
||||
isTrayEnabled_ = settings.value("user/window/tray", true).toBool();
|
||||
hasDesktopNotifications_ = settings.value("user/desktop_notifications", true).toBool();
|
||||
isStartInTrayEnabled_ = settings.value("user/window/start_in_tray", false).toBool();
|
||||
isOrderingEnabled_ = settings.value("user/room_ordering", true).toBool();
|
||||
isGroupViewEnabled_ = settings.value("user/group_view", true).toBool();
|
||||
|
@ -94,6 +95,7 @@ UserSettings::save()
|
|||
settings.setValue("typing_notifications", isTypingNotificationsEnabled_);
|
||||
settings.setValue("read_receipts", isReadReceiptsEnabled_);
|
||||
settings.setValue("group_view", isGroupViewEnabled_);
|
||||
settings.setValue("desktop_notifications", hasDesktopNotifications_);
|
||||
settings.setValue("theme", theme());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
@ -188,6 +190,15 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
|||
receiptsLayout->addWidget(receiptsLabel);
|
||||
receiptsLayout->addWidget(readReceipts_, 0, Qt::AlignBottom | Qt::AlignRight);
|
||||
|
||||
auto desktopLayout = new QHBoxLayout;
|
||||
desktopLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin);
|
||||
auto desktopLabel = new QLabel(tr("Desktop notifications"), this);
|
||||
desktopLabel->setFont(font);
|
||||
desktopNotifications_ = new Toggle(this);
|
||||
|
||||
desktopLayout->addWidget(desktopLabel);
|
||||
desktopLayout->addWidget(desktopNotifications_, 0, Qt::AlignBottom | Qt::AlignRight);
|
||||
|
||||
auto scaleFactorOptionLayout = new QHBoxLayout;
|
||||
scaleFactorOptionLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin);
|
||||
auto scaleFactorLabel = new QLabel(tr("Scale factor (requires restart)"), this);
|
||||
|
@ -239,6 +250,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
|||
mainLayout_->addWidget(new HorizontalLine(this));
|
||||
mainLayout_->addLayout(typingLayout);
|
||||
mainLayout_->addLayout(receiptsLayout);
|
||||
mainLayout_->addLayout(desktopLayout);
|
||||
mainLayout_->addWidget(new HorizontalLine(this));
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
|
@ -307,6 +319,10 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
|
|||
settings_->setReadReceipts(!isDisabled);
|
||||
});
|
||||
|
||||
connect(desktopNotifications_, &Toggle::toggled, this, [this](bool isDisabled) {
|
||||
settings_->setDesktopNotifications(!isDisabled);
|
||||
});
|
||||
|
||||
connect(backBtn_, &QPushButton::clicked, this, [this]() {
|
||||
settings_->save();
|
||||
emit moveBack();
|
||||
|
@ -326,6 +342,7 @@ UserSettingsPage::showEvent(QShowEvent *)
|
|||
groupViewToggle_->setState(!settings_->isGroupViewEnabled());
|
||||
typingNotifications_->setState(!settings_->isTypingNotificationsEnabled());
|
||||
readReceipts_->setState(!settings_->isReadReceiptsEnabled());
|
||||
desktopNotifications_->setState(!settings_->hasDesktopNotifications());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -44,19 +44,19 @@ public:
|
|||
{
|
||||
isTrayEnabled_ = state;
|
||||
save();
|
||||
};
|
||||
}
|
||||
|
||||
void setStartInTray(bool state)
|
||||
{
|
||||
isStartInTrayEnabled_ = state;
|
||||
save();
|
||||
};
|
||||
}
|
||||
|
||||
void setRoomOrdering(bool state)
|
||||
{
|
||||
isOrderingEnabled_ = state;
|
||||
save();
|
||||
};
|
||||
}
|
||||
|
||||
void setGroupView(bool state)
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
|
||||
isGroupViewEnabled_ = state;
|
||||
save();
|
||||
};
|
||||
}
|
||||
|
||||
void setReadReceipts(bool state)
|
||||
{
|
||||
|
@ -77,7 +77,13 @@ public:
|
|||
{
|
||||
isTypingNotificationsEnabled_ = state;
|
||||
save();
|
||||
};
|
||||
}
|
||||
|
||||
void setDesktopNotifications(bool state)
|
||||
{
|
||||
hasDesktopNotifications_ = state;
|
||||
save();
|
||||
}
|
||||
|
||||
QString theme() const { return !theme_.isEmpty() ? theme_ : "light"; }
|
||||
bool isTrayEnabled() const { return isTrayEnabled_; }
|
||||
|
@ -86,6 +92,7 @@ public:
|
|||
bool isGroupViewEnabled() const { return isGroupViewEnabled_; }
|
||||
bool isTypingNotificationsEnabled() const { return isTypingNotificationsEnabled_; }
|
||||
bool isReadReceiptsEnabled() const { return isReadReceiptsEnabled_; }
|
||||
bool hasDesktopNotifications() const { return hasDesktopNotifications_; }
|
||||
|
||||
signals:
|
||||
void groupViewStateChanged(bool state);
|
||||
|
@ -98,6 +105,7 @@ private:
|
|||
bool isGroupViewEnabled_;
|
||||
bool isTypingNotificationsEnabled_;
|
||||
bool isReadReceiptsEnabled_;
|
||||
bool hasDesktopNotifications_;
|
||||
};
|
||||
|
||||
class HorizontalLine : public QFrame
|
||||
|
@ -142,6 +150,7 @@ private:
|
|||
Toggle *groupViewToggle_;
|
||||
Toggle *typingNotifications_;
|
||||
Toggle *readReceipts_;
|
||||
Toggle *desktopNotifications_;
|
||||
|
||||
QComboBox *themeCombo_;
|
||||
QComboBox *scaleFactorCombo_;
|
||||
|
|
Loading…
Reference in a new issue