2017-11-02 01:41:13 +03:00
|
|
|
/*
|
|
|
|
* nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-11-25 23:47:06 +03:00
|
|
|
#include <QApplication>
|
2017-11-02 01:41:13 +03:00
|
|
|
#include <QComboBox>
|
2020-10-27 22:29:53 +03:00
|
|
|
#include <QCoreApplication>
|
2018-09-15 23:52:14 +03:00
|
|
|
#include <QFileDialog>
|
2020-10-20 03:38:18 +03:00
|
|
|
#include <QFontComboBox>
|
2020-02-18 18:08:19 +03:00
|
|
|
#include <QFormLayout>
|
2018-09-15 23:52:14 +03:00
|
|
|
#include <QInputDialog>
|
2017-11-02 01:41:13 +03:00
|
|
|
#include <QLabel>
|
2018-09-15 23:52:14 +03:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QMessageBox>
|
2020-01-31 08:12:02 +03:00
|
|
|
#include <QPainter>
|
2019-08-10 20:14:37 +03:00
|
|
|
#include <QProcessEnvironment>
|
2017-11-02 01:41:13 +03:00
|
|
|
#include <QPushButton>
|
2020-02-15 05:37:54 +03:00
|
|
|
#include <QResizeEvent>
|
2018-01-14 16:57:58 +03:00
|
|
|
#include <QScrollArea>
|
2020-02-15 05:47:58 +03:00
|
|
|
#include <QScroller>
|
2017-11-02 01:41:13 +03:00
|
|
|
#include <QSettings>
|
2020-05-26 23:27:05 +03:00
|
|
|
#include <QSpinBox>
|
2020-02-15 04:35:26 +03:00
|
|
|
#include <QStandardPaths>
|
2019-08-10 20:14:37 +03:00
|
|
|
#include <QString>
|
2019-03-28 02:13:38 +03:00
|
|
|
#include <QTextStream>
|
2020-06-08 21:26:37 +03:00
|
|
|
#include <QtQml>
|
2017-11-02 01:41:13 +03:00
|
|
|
|
2019-12-15 05:34:17 +03:00
|
|
|
#include "Cache.h"
|
2017-11-02 01:41:13 +03:00
|
|
|
#include "Config.h"
|
2018-08-21 09:22:51 +03:00
|
|
|
#include "MatrixClient.h"
|
|
|
|
#include "Olm.h"
|
2017-11-02 01:41:13 +03:00
|
|
|
#include "UserSettingsPage.h"
|
2018-07-22 19:48:58 +03:00
|
|
|
#include "Utils.h"
|
2020-10-27 20:14:06 +03:00
|
|
|
#include "WebRTCSession.h"
|
2018-07-17 16:37:25 +03:00
|
|
|
#include "ui/FlatButton.h"
|
|
|
|
#include "ui/ToggleButton.h"
|
2017-11-02 01:41:13 +03:00
|
|
|
|
2018-09-30 14:33:54 +03:00
|
|
|
#include "config/nheko.h"
|
2018-03-22 17:20:22 +03:00
|
|
|
|
2020-06-12 05:22:16 +03:00
|
|
|
UserSettings::UserSettings() { load(); }
|
2017-11-02 01:41:13 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::load()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
2020-05-26 23:53:21 +03:00
|
|
|
tray_ = settings.value("user/window/tray", false).toBool();
|
|
|
|
hasDesktopNotifications_ = settings.value("user/desktop_notifications", true).toBool();
|
2020-06-10 12:27:21 +03:00
|
|
|
hasAlertOnNotification_ = settings.value("user/alert_on_notification", false).toBool();
|
2020-05-26 23:53:21 +03:00
|
|
|
startInTray_ = settings.value("user/window/start_in_tray", false).toBool();
|
|
|
|
groupView_ = settings.value("user/group_view", true).toBool();
|
|
|
|
buttonsInTimeline_ = settings.value("user/timeline/buttons", true).toBool();
|
|
|
|
timelineMaxWidth_ = settings.value("user/timeline/max_width", 0).toInt();
|
|
|
|
messageHoverHighlight_ =
|
2020-05-16 00:27:41 +03:00
|
|
|
settings.value("user/timeline/message_hover_highlight", false).toBool();
|
2020-05-26 23:53:21 +03:00
|
|
|
enlargeEmojiOnlyMessages_ =
|
2020-05-19 22:04:38 +03:00
|
|
|
settings.value("user/timeline/enlarge_emoji_only_msg", false).toBool();
|
2020-05-26 23:53:21 +03:00
|
|
|
markdown_ = settings.value("user/markdown_enabled", true).toBool();
|
|
|
|
typingNotifications_ = settings.value("user/typing_notifications", true).toBool();
|
|
|
|
sortByImportance_ = settings.value("user/sort_by_unread", true).toBool();
|
|
|
|
readReceipts_ = settings.value("user/read_receipts", true).toBool();
|
|
|
|
theme_ = settings.value("user/theme", defaultTheme_).toString();
|
|
|
|
font_ = settings.value("user/font_family", "default").toString();
|
|
|
|
avatarCircles_ = settings.value("user/avatar_circles", true).toBool();
|
|
|
|
decryptSidebar_ = settings.value("user/decrypt_sidebar", true).toBool();
|
2020-10-18 01:52:35 +03:00
|
|
|
shareKeysWithTrustedUsers_ =
|
|
|
|
settings.value("user/share_keys_with_trusted_users", true).toBool();
|
2020-10-24 17:21:00 +03:00
|
|
|
mobileMode_ = settings.value("user/mobile_mode", false).toBool();
|
2020-10-18 01:52:35 +03:00
|
|
|
emojiFont_ = settings.value("user/emoji_font_family", "default").toString();
|
|
|
|
baseFontSize_ = settings.value("user/font_size", QFont().pointSizeF()).toDouble();
|
2020-06-08 21:26:37 +03:00
|
|
|
presence_ =
|
|
|
|
settings.value("user/presence", QVariant::fromValue(Presence::AutomaticPresence))
|
|
|
|
.value<Presence>();
|
2020-11-13 03:55:35 +03:00
|
|
|
ringtone_ = settings.value("user/ringtone", "Default").toString();
|
2020-10-27 20:14:06 +03:00
|
|
|
microphone_ = settings.value("user/microphone", QString()).toString();
|
|
|
|
camera_ = settings.value("user/camera", QString()).toString();
|
|
|
|
cameraResolution_ = settings.value("user/camera_resolution", QString()).toString();
|
|
|
|
cameraFrameRate_ = settings.value("user/camera_frame_rate", QString()).toString();
|
|
|
|
useStunServer_ = settings.value("user/use_stun_server", false).toBool();
|
2018-10-01 17:56:46 +03:00
|
|
|
|
2017-11-25 23:47:06 +03:00
|
|
|
applyTheme();
|
|
|
|
}
|
2020-05-26 23:27:05 +03:00
|
|
|
void
|
|
|
|
UserSettings::setMessageHoverHighlight(bool state)
|
|
|
|
{
|
2020-05-26 23:53:21 +03:00
|
|
|
if (state == messageHoverHighlight_)
|
2020-05-26 23:27:05 +03:00
|
|
|
return;
|
2020-05-26 23:53:21 +03:00
|
|
|
messageHoverHighlight_ = state;
|
2020-05-26 23:27:05 +03:00
|
|
|
emit messageHoverHighlightChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
void
|
|
|
|
UserSettings::setEnlargeEmojiOnlyMessages(bool state)
|
|
|
|
{
|
2020-05-26 23:53:21 +03:00
|
|
|
if (state == enlargeEmojiOnlyMessages_)
|
2020-05-26 23:27:05 +03:00
|
|
|
return;
|
2020-05-26 23:53:21 +03:00
|
|
|
enlargeEmojiOnlyMessages_ = state;
|
2020-05-26 23:27:05 +03:00
|
|
|
emit enlargeEmojiOnlyMessagesChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
void
|
|
|
|
UserSettings::setTray(bool state)
|
|
|
|
{
|
2020-05-26 23:53:21 +03:00
|
|
|
if (state == tray_)
|
2020-05-26 23:27:05 +03:00
|
|
|
return;
|
2020-05-26 23:53:21 +03:00
|
|
|
tray_ = state;
|
2020-05-26 23:27:05 +03:00
|
|
|
emit trayChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setStartInTray(bool state)
|
|
|
|
{
|
2020-05-26 23:53:21 +03:00
|
|
|
if (state == startInTray_)
|
2020-05-26 23:27:05 +03:00
|
|
|
return;
|
2020-05-26 23:53:21 +03:00
|
|
|
startInTray_ = state;
|
2020-05-26 23:27:05 +03:00
|
|
|
emit startInTrayChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2020-10-24 17:21:00 +03:00
|
|
|
void
|
|
|
|
UserSettings::setMobileMode(bool state)
|
|
|
|
{
|
|
|
|
if (state == mobileMode_)
|
|
|
|
return;
|
|
|
|
mobileMode_ = state;
|
|
|
|
emit mobileModeChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2020-05-26 23:27:05 +03:00
|
|
|
void
|
|
|
|
UserSettings::setGroupView(bool state)
|
|
|
|
{
|
2020-05-26 23:53:21 +03:00
|
|
|
if (groupView_ != state)
|
2020-05-26 23:27:05 +03:00
|
|
|
emit groupViewStateChanged(state);
|
|
|
|
|
2020-05-26 23:53:21 +03:00
|
|
|
groupView_ = state;
|
2020-05-26 23:27:05 +03:00
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-05-26 23:53:21 +03:00
|
|
|
UserSettings::setMarkdown(bool state)
|
2020-05-26 23:27:05 +03:00
|
|
|
{
|
2020-05-26 23:53:21 +03:00
|
|
|
if (state == markdown_)
|
2020-05-26 23:27:05 +03:00
|
|
|
return;
|
2020-05-26 23:53:21 +03:00
|
|
|
markdown_ = state;
|
2020-05-26 23:27:05 +03:00
|
|
|
emit markdownChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setReadReceipts(bool state)
|
|
|
|
{
|
2020-05-26 23:53:21 +03:00
|
|
|
if (state == readReceipts_)
|
2020-05-26 23:27:05 +03:00
|
|
|
return;
|
2020-05-26 23:53:21 +03:00
|
|
|
readReceipts_ = state;
|
2020-05-26 23:27:05 +03:00
|
|
|
emit readReceiptsChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setTypingNotifications(bool state)
|
|
|
|
{
|
2020-05-26 23:53:21 +03:00
|
|
|
if (state == typingNotifications_)
|
2020-05-26 23:27:05 +03:00
|
|
|
return;
|
2020-05-26 23:53:21 +03:00
|
|
|
typingNotifications_ = state;
|
2020-05-26 23:27:05 +03:00
|
|
|
emit typingNotificationsChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setSortByImportance(bool state)
|
|
|
|
{
|
|
|
|
if (state == sortByImportance_)
|
|
|
|
return;
|
|
|
|
sortByImportance_ = state;
|
|
|
|
emit roomSortingChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setButtonsInTimeline(bool state)
|
|
|
|
{
|
2020-05-26 23:53:21 +03:00
|
|
|
if (state == buttonsInTimeline_)
|
2020-05-26 23:27:05 +03:00
|
|
|
return;
|
2020-05-26 23:53:21 +03:00
|
|
|
buttonsInTimeline_ = state;
|
2020-05-26 23:27:05 +03:00
|
|
|
emit buttonInTimelineChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setTimelineMaxWidth(int state)
|
|
|
|
{
|
|
|
|
if (state == timelineMaxWidth_)
|
|
|
|
return;
|
|
|
|
timelineMaxWidth_ = state;
|
|
|
|
emit timelineMaxWidthChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setDesktopNotifications(bool state)
|
|
|
|
{
|
|
|
|
if (state == hasDesktopNotifications_)
|
|
|
|
return;
|
|
|
|
hasDesktopNotifications_ = state;
|
|
|
|
emit desktopNotificationsChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2020-06-10 12:27:21 +03:00
|
|
|
void
|
|
|
|
UserSettings::setAlertOnNotification(bool state)
|
|
|
|
{
|
|
|
|
if (state == hasAlertOnNotification_)
|
|
|
|
return;
|
|
|
|
hasAlertOnNotification_ = state;
|
|
|
|
emit alertOnNotificationChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2020-05-26 23:27:05 +03:00
|
|
|
void
|
|
|
|
UserSettings::setAvatarCircles(bool state)
|
|
|
|
{
|
|
|
|
if (state == avatarCircles_)
|
|
|
|
return;
|
|
|
|
avatarCircles_ = state;
|
|
|
|
emit avatarCirclesChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setDecryptSidebar(bool state)
|
|
|
|
{
|
|
|
|
if (state == decryptSidebar_)
|
|
|
|
return;
|
|
|
|
decryptSidebar_ = state;
|
|
|
|
emit decryptSidebarChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
2017-11-25 23:47:06 +03:00
|
|
|
|
2018-10-06 17:21:03 +03:00
|
|
|
void
|
|
|
|
UserSettings::setFontSize(double size)
|
|
|
|
{
|
2020-05-26 23:27:05 +03:00
|
|
|
if (size == baseFontSize_)
|
|
|
|
return;
|
2018-10-06 17:21:03 +03:00
|
|
|
baseFontSize_ = size;
|
2020-05-26 23:27:05 +03:00
|
|
|
emit fontSizeChanged(size);
|
2018-10-06 17:21:03 +03:00
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2019-01-19 19:20:41 +03:00
|
|
|
void
|
|
|
|
UserSettings::setFontFamily(QString family)
|
|
|
|
{
|
2020-05-26 23:27:05 +03:00
|
|
|
if (family == font_)
|
|
|
|
return;
|
2019-01-19 19:20:41 +03:00
|
|
|
font_ = family;
|
2020-05-26 23:27:05 +03:00
|
|
|
emit fontChanged(family);
|
2019-01-19 19:20:41 +03:00
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2019-07-27 00:31:59 +03:00
|
|
|
void
|
|
|
|
UserSettings::setEmojiFontFamily(QString family)
|
|
|
|
{
|
2020-05-26 23:27:05 +03:00
|
|
|
if (family == emojiFont_)
|
|
|
|
return;
|
2019-07-27 00:31:59 +03:00
|
|
|
emojiFont_ = family;
|
2020-05-26 23:27:05 +03:00
|
|
|
emit emojiFontChanged(family);
|
2019-07-27 00:31:59 +03:00
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2020-06-08 21:26:37 +03:00
|
|
|
void
|
|
|
|
UserSettings::setPresence(Presence state)
|
|
|
|
{
|
|
|
|
if (state == presence_)
|
|
|
|
return;
|
|
|
|
presence_ = state;
|
|
|
|
emit presenceChanged(state);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2017-11-25 23:47:06 +03:00
|
|
|
void
|
|
|
|
UserSettings::setTheme(QString theme)
|
|
|
|
{
|
2020-06-14 11:26:15 +03:00
|
|
|
if (theme == theme_)
|
2020-05-26 23:27:05 +03:00
|
|
|
return;
|
2017-11-25 23:47:06 +03:00
|
|
|
theme_ = theme;
|
|
|
|
save();
|
|
|
|
applyTheme();
|
2020-05-26 23:27:05 +03:00
|
|
|
emit themeChanged(theme);
|
2017-11-25 23:47:06 +03:00
|
|
|
}
|
|
|
|
|
2020-07-11 02:19:48 +03:00
|
|
|
void
|
|
|
|
UserSettings::setUseStunServer(bool useStunServer)
|
|
|
|
{
|
|
|
|
if (useStunServer == useStunServer_)
|
|
|
|
return;
|
|
|
|
useStunServer_ = useStunServer;
|
|
|
|
emit useStunServerChanged(useStunServer);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2020-10-18 01:52:35 +03:00
|
|
|
void
|
|
|
|
UserSettings::setShareKeysWithTrustedUsers(bool shareKeys)
|
|
|
|
{
|
|
|
|
if (shareKeys == shareKeysWithTrustedUsers_)
|
|
|
|
return;
|
2020-10-23 17:59:18 +03:00
|
|
|
|
2020-10-18 01:52:35 +03:00
|
|
|
shareKeysWithTrustedUsers_ = shareKeys;
|
|
|
|
emit shareKeysWithTrustedUsersChanged(shareKeys);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2020-11-13 03:55:35 +03:00
|
|
|
void
|
|
|
|
UserSettings::setRingtone(QString ringtone)
|
|
|
|
{
|
|
|
|
if (ringtone == ringtone_)
|
|
|
|
return;
|
|
|
|
ringtone_ = ringtone;
|
|
|
|
emit ringtoneChanged(ringtone);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2020-08-06 00:56:44 +03:00
|
|
|
void
|
2020-10-27 20:14:06 +03:00
|
|
|
UserSettings::setMicrophone(QString microphone)
|
2020-08-06 00:56:44 +03:00
|
|
|
{
|
2020-10-27 20:14:06 +03:00
|
|
|
if (microphone == microphone_)
|
2020-08-06 00:56:44 +03:00
|
|
|
return;
|
2020-10-27 20:14:06 +03:00
|
|
|
microphone_ = microphone;
|
|
|
|
emit microphoneChanged(microphone);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setCamera(QString camera)
|
|
|
|
{
|
|
|
|
if (camera == camera_)
|
|
|
|
return;
|
|
|
|
camera_ = camera;
|
|
|
|
emit cameraChanged(camera);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setCameraResolution(QString resolution)
|
|
|
|
{
|
|
|
|
if (resolution == cameraResolution_)
|
|
|
|
return;
|
|
|
|
cameraResolution_ = resolution;
|
|
|
|
emit cameraResolutionChanged(resolution);
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::setCameraFrameRate(QString frameRate)
|
|
|
|
{
|
|
|
|
if (frameRate == cameraFrameRate_)
|
|
|
|
return;
|
|
|
|
cameraFrameRate_ = frameRate;
|
|
|
|
emit cameraFrameRateChanged(frameRate);
|
2020-08-06 00:56:44 +03:00
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
2017-11-25 23:47:06 +03:00
|
|
|
void
|
|
|
|
UserSettings::applyTheme()
|
|
|
|
{
|
|
|
|
QFile stylefile;
|
|
|
|
|
2020-03-30 22:48:28 +03:00
|
|
|
static QPalette original;
|
|
|
|
if (this->theme() == "light") {
|
2017-11-25 23:47:06 +03:00
|
|
|
stylefile.setFileName(":/styles/styles/nheko.qss");
|
2020-04-09 00:08:43 +03:00
|
|
|
QPalette lightActive(
|
|
|
|
/*windowText*/ QColor("#333"),
|
|
|
|
/*button*/ QColor("#333"),
|
|
|
|
/*light*/ QColor(0xef, 0xef, 0xef),
|
2020-10-26 15:50:44 +03:00
|
|
|
/*dark*/ QColor(110, 110, 110),
|
|
|
|
/*mid*/ QColor(220, 220, 220),
|
2020-04-09 00:08:43 +03:00
|
|
|
/*text*/ QColor("#333"),
|
|
|
|
/*bright_text*/ QColor("#333"),
|
2020-10-26 15:50:44 +03:00
|
|
|
/*base*/ QColor("#fff"),
|
2020-04-09 00:08:43 +03:00
|
|
|
/*window*/ QColor("white"));
|
2020-10-26 15:50:44 +03:00
|
|
|
lightActive.setColor(QPalette::AlternateBase, QColor("#eee"));
|
2020-04-09 00:08:43 +03:00
|
|
|
lightActive.setColor(QPalette::Highlight, QColor("#38a3d8"));
|
2020-03-30 22:48:28 +03:00
|
|
|
lightActive.setColor(QPalette::ToolTipBase, lightActive.base().color());
|
|
|
|
lightActive.setColor(QPalette::ToolTipText, lightActive.text().color());
|
|
|
|
lightActive.setColor(QPalette::Link, QColor("#0077b5"));
|
2020-10-26 15:50:44 +03:00
|
|
|
lightActive.setColor(QPalette::ButtonText, QColor("#495057"));
|
2020-03-30 22:48:28 +03:00
|
|
|
QApplication::setPalette(lightActive);
|
|
|
|
} else if (this->theme() == "dark") {
|
2017-11-25 23:47:06 +03:00
|
|
|
stylefile.setFileName(":/styles/styles/nheko-dark.qss");
|
2020-04-09 00:08:43 +03:00
|
|
|
QPalette darkActive(
|
|
|
|
/*windowText*/ QColor("#caccd1"),
|
|
|
|
/*button*/ QColor(0xff, 0xff, 0xff),
|
|
|
|
/*light*/ QColor("#caccd1"),
|
2020-10-26 15:50:44 +03:00
|
|
|
/*dark*/ QColor(110, 110, 110),
|
|
|
|
/*mid*/ QColor("#202228"),
|
2020-04-09 00:08:43 +03:00
|
|
|
/*text*/ QColor("#caccd1"),
|
|
|
|
/*bright_text*/ QColor(0xff, 0xff, 0xff),
|
2020-10-26 15:50:44 +03:00
|
|
|
/*base*/ QColor("#202228"),
|
|
|
|
/*window*/ QColor("#2d3139"));
|
|
|
|
darkActive.setColor(QPalette::AlternateBase, QColor("#2d3139"));
|
2020-03-30 22:48:28 +03:00
|
|
|
darkActive.setColor(QPalette::Highlight, QColor("#38a3d8"));
|
|
|
|
darkActive.setColor(QPalette::ToolTipBase, darkActive.base().color());
|
|
|
|
darkActive.setColor(QPalette::ToolTipText, darkActive.text().color());
|
|
|
|
darkActive.setColor(QPalette::Link, QColor("#38a3d8"));
|
2020-10-26 15:50:44 +03:00
|
|
|
darkActive.setColor(QPalette::ButtonText, "#727274");
|
2020-03-30 22:48:28 +03:00
|
|
|
QApplication::setPalette(darkActive);
|
2017-11-25 23:47:06 +03:00
|
|
|
} else {
|
|
|
|
stylefile.setFileName(":/styles/styles/system.qss");
|
2020-03-30 22:48:28 +03:00
|
|
|
QApplication::setPalette(original);
|
2017-11-25 23:47:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
stylefile.open(QFile::ReadOnly);
|
|
|
|
QString stylesheet = QString(stylefile.readAll());
|
|
|
|
|
|
|
|
qobject_cast<QApplication *>(QApplication::instance())->setStyleSheet(stylesheet);
|
2017-11-02 01:41:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettings::save()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("user");
|
2017-11-02 23:00:43 +03:00
|
|
|
|
|
|
|
settings.beginGroup("window");
|
2020-05-26 23:53:21 +03:00
|
|
|
settings.setValue("tray", tray_);
|
|
|
|
settings.setValue("start_in_tray", startInTray_);
|
2017-11-02 23:00:43 +03:00
|
|
|
settings.endGroup();
|
|
|
|
|
2020-03-10 02:30:45 +03:00
|
|
|
settings.beginGroup("timeline");
|
2020-05-26 23:53:21 +03:00
|
|
|
settings.setValue("buttons", buttonsInTimeline_);
|
|
|
|
settings.setValue("message_hover_highlight", messageHoverHighlight_);
|
|
|
|
settings.setValue("enlarge_emoji_only_msg", enlargeEmojiOnlyMessages_);
|
2020-05-26 23:27:05 +03:00
|
|
|
settings.setValue("max_width", timelineMaxWidth_);
|
2020-03-10 02:30:45 +03:00
|
|
|
settings.endGroup();
|
|
|
|
|
2019-09-07 23:22:07 +03:00
|
|
|
settings.setValue("avatar_circles", avatarCircles_);
|
2020-04-22 04:42:17 +03:00
|
|
|
settings.setValue("decrypt_sidebar", decryptSidebar_);
|
2020-10-18 01:52:35 +03:00
|
|
|
settings.setValue("share_keys_with_trusted_users", shareKeysWithTrustedUsers_);
|
2020-10-24 17:21:00 +03:00
|
|
|
settings.setValue("mobile_mode", mobileMode_);
|
2018-10-01 17:56:46 +03:00
|
|
|
settings.setValue("font_size", baseFontSize_);
|
2020-05-26 23:53:21 +03:00
|
|
|
settings.setValue("typing_notifications", typingNotifications_);
|
2020-03-15 21:56:39 +03:00
|
|
|
settings.setValue("minor_events", sortByImportance_);
|
2020-05-26 23:53:21 +03:00
|
|
|
settings.setValue("read_receipts", readReceipts_);
|
|
|
|
settings.setValue("group_view", groupView_);
|
|
|
|
settings.setValue("markdown_enabled", markdown_);
|
2018-08-11 18:26:17 +03:00
|
|
|
settings.setValue("desktop_notifications", hasDesktopNotifications_);
|
2020-06-10 12:27:21 +03:00
|
|
|
settings.setValue("alert_on_notification", hasAlertOnNotification_);
|
2017-11-02 01:41:13 +03:00
|
|
|
settings.setValue("theme", theme());
|
2019-01-19 19:20:41 +03:00
|
|
|
settings.setValue("font_family", font_);
|
2019-07-27 00:31:59 +03:00
|
|
|
settings.setValue("emoji_font_family", emojiFont_);
|
2020-06-08 21:26:37 +03:00
|
|
|
settings.setValue("presence", QVariant::fromValue(presence_));
|
2020-11-13 03:55:35 +03:00
|
|
|
settings.setValue("ringtone", ringtone_);
|
2020-10-27 20:14:06 +03:00
|
|
|
settings.setValue("microphone", microphone_);
|
|
|
|
settings.setValue("camera", camera_);
|
|
|
|
settings.setValue("camera_resolution", cameraResolution_);
|
|
|
|
settings.setValue("camera_frame_rate", cameraFrameRate_);
|
2020-07-11 02:19:48 +03:00
|
|
|
settings.setValue("use_stun_server", useStunServer_);
|
2019-07-27 00:31:59 +03:00
|
|
|
|
2017-11-02 01:41:13 +03:00
|
|
|
settings.endGroup();
|
2020-05-26 23:27:05 +03:00
|
|
|
|
|
|
|
settings.sync();
|
2017-11-02 01:41:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
HorizontalLine::HorizontalLine(QWidget *parent)
|
2017-11-06 00:04:55 +03:00
|
|
|
: QFrame{parent}
|
2017-11-02 01:41:13 +03:00
|
|
|
{
|
|
|
|
setFrameShape(QFrame::HLine);
|
|
|
|
setFrameShadow(QFrame::Sunken);
|
|
|
|
}
|
|
|
|
|
|
|
|
UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidget *parent)
|
2017-11-06 00:04:55 +03:00
|
|
|
: QWidget{parent}
|
|
|
|
, settings_{settings}
|
2017-11-02 01:41:13 +03:00
|
|
|
{
|
2020-02-19 00:16:07 +03:00
|
|
|
topLayout_ = new QVBoxLayout{this};
|
2017-11-02 01:41:13 +03:00
|
|
|
|
|
|
|
QIcon icon;
|
|
|
|
icon.addFile(":/icons/icons/ui/angle-pointing-to-left.png");
|
|
|
|
|
2020-02-19 00:16:07 +03:00
|
|
|
auto backBtn_ = new FlatButton{this};
|
2017-11-02 01:41:13 +03:00
|
|
|
backBtn_->setMinimumSize(QSize(24, 24));
|
|
|
|
backBtn_->setIcon(icon);
|
|
|
|
backBtn_->setIconSize(QSize(24, 24));
|
|
|
|
|
2018-07-22 18:03:12 +03:00
|
|
|
QFont font;
|
|
|
|
font.setPointSizeF(font.pointSizeF() * 1.1);
|
2017-11-02 01:41:13 +03:00
|
|
|
|
2018-06-23 01:46:18 +03:00
|
|
|
auto versionInfo = new QLabel(QString("%1 | %2").arg(nheko::version).arg(nheko::build_os));
|
2020-10-22 02:20:02 +03:00
|
|
|
if (QCoreApplication::applicationName() != "nheko")
|
2020-10-27 22:29:53 +03:00
|
|
|
versionInfo->setText(versionInfo->text() + " | " +
|
|
|
|
tr("profile: %1").arg(QCoreApplication::applicationName()));
|
2018-06-23 01:46:18 +03:00
|
|
|
versionInfo->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
2018-03-22 17:20:22 +03:00
|
|
|
|
2017-11-02 01:41:13 +03:00
|
|
|
topBarLayout_ = new QHBoxLayout;
|
|
|
|
topBarLayout_->setSpacing(0);
|
|
|
|
topBarLayout_->setMargin(0);
|
|
|
|
topBarLayout_->addWidget(backBtn_, 1, Qt::AlignLeft | Qt::AlignVCenter);
|
|
|
|
topBarLayout_->addStretch(1);
|
|
|
|
|
2020-02-18 18:08:19 +03:00
|
|
|
formLayout_ = new QFormLayout;
|
2017-11-02 01:41:13 +03:00
|
|
|
|
2020-02-18 18:08:19 +03:00
|
|
|
formLayout_->setLabelAlignment(Qt::AlignLeft);
|
|
|
|
formLayout_->setFormAlignment(Qt::AlignRight);
|
|
|
|
formLayout_->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
|
|
|
formLayout_->setRowWrapPolicy(QFormLayout::WrapLongRows);
|
|
|
|
formLayout_->setHorizontalSpacing(0);
|
2018-05-08 23:53:40 +03:00
|
|
|
|
2020-02-19 00:16:07 +03:00
|
|
|
auto general_ = new QLabel{tr("GENERAL"), this};
|
2020-02-18 18:08:19 +03:00
|
|
|
general_->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
|
|
|
general_->setFont(font);
|
2018-01-09 22:57:41 +03:00
|
|
|
|
2020-10-18 01:52:35 +03:00
|
|
|
trayToggle_ = new Toggle{this};
|
|
|
|
startInTrayToggle_ = new Toggle{this};
|
|
|
|
avatarCircles_ = new Toggle{this};
|
|
|
|
decryptSidebar_ = new Toggle(this);
|
|
|
|
shareKeysWithTrustedUsers_ = new Toggle(this);
|
|
|
|
groupViewToggle_ = new Toggle{this};
|
|
|
|
timelineButtonsToggle_ = new Toggle{this};
|
|
|
|
typingNotifications_ = new Toggle{this};
|
|
|
|
messageHoverHighlight_ = new Toggle{this};
|
|
|
|
enlargeEmojiOnlyMessages_ = new Toggle{this};
|
|
|
|
sortByImportance_ = new Toggle{this};
|
|
|
|
readReceipts_ = new Toggle{this};
|
|
|
|
markdown_ = new Toggle{this};
|
|
|
|
desktopNotifications_ = new Toggle{this};
|
|
|
|
alertOnNotification_ = new Toggle{this};
|
|
|
|
useStunServer_ = new Toggle{this};
|
2020-10-24 17:21:00 +03:00
|
|
|
mobileMode_ = new Toggle{this};
|
2020-10-18 01:52:35 +03:00
|
|
|
scaleFactorCombo_ = new QComboBox{this};
|
|
|
|
fontSizeCombo_ = new QComboBox{this};
|
2020-10-20 03:38:18 +03:00
|
|
|
fontSelectionCombo_ = new QFontComboBox{this};
|
2020-10-18 01:52:35 +03:00
|
|
|
emojiFontSelectionCombo_ = new QComboBox{this};
|
2020-11-13 03:55:35 +03:00
|
|
|
ringtoneCombo_ = new QComboBox{this};
|
2020-10-27 22:29:53 +03:00
|
|
|
microphoneCombo_ = new QComboBox{this};
|
|
|
|
cameraCombo_ = new QComboBox{this};
|
|
|
|
cameraResolutionCombo_ = new QComboBox{this};
|
|
|
|
cameraFrameRateCombo_ = new QComboBox{this};
|
2020-10-18 01:52:35 +03:00
|
|
|
timelineMaxWidthSpin_ = new QSpinBox{this};
|
2018-01-09 22:57:41 +03:00
|
|
|
|
2020-11-25 22:05:10 +03:00
|
|
|
trayToggle_->setChecked(settings_->tray());
|
|
|
|
startInTrayToggle_->setChecked(settings_->startInTray());
|
|
|
|
avatarCircles_->setChecked(settings_->avatarCircles());
|
|
|
|
decryptSidebar_->setChecked(settings_->decryptSidebar());
|
|
|
|
shareKeysWithTrustedUsers_->setChecked(settings_->shareKeysWithTrustedUsers());
|
|
|
|
groupViewToggle_->setChecked(settings_->groupView());
|
|
|
|
timelineButtonsToggle_->setChecked(settings_->buttonsInTimeline());
|
|
|
|
typingNotifications_->setChecked(settings_->typingNotifications());
|
|
|
|
messageHoverHighlight_->setChecked(settings_->messageHoverHighlight());
|
|
|
|
enlargeEmojiOnlyMessages_->setChecked(settings_->enlargeEmojiOnlyMessages());
|
|
|
|
sortByImportance_->setChecked(settings_->sortByImportance());
|
|
|
|
readReceipts_->setChecked(settings_->readReceipts());
|
|
|
|
markdown_->setChecked(settings_->markdown());
|
|
|
|
desktopNotifications_->setChecked(settings_->hasDesktopNotifications());
|
|
|
|
alertOnNotification_->setChecked(settings_->hasAlertOnNotification());
|
|
|
|
useStunServer_->setChecked(settings_->useStunServer());
|
|
|
|
mobileMode_->setChecked(settings_->mobileMode());
|
|
|
|
|
2020-11-25 19:31:03 +03:00
|
|
|
if (!settings_->tray()) {
|
|
|
|
startInTrayToggle_->setState(false);
|
2020-01-27 17:59:25 +03:00
|
|
|
startInTrayToggle_->setDisabled(true);
|
2020-11-25 19:31:03 +03:00
|
|
|
}
|
2019-08-29 07:36:28 +03:00
|
|
|
|
2020-02-19 00:16:07 +03:00
|
|
|
avatarCircles_->setFixedSize(64, 48);
|
|
|
|
|
|
|
|
auto uiLabel_ = new QLabel{tr("INTERFACE"), this};
|
2020-02-19 22:23:57 +03:00
|
|
|
uiLabel_->setFixedHeight(uiLabel_->minimumHeight() + LayoutTopMargin);
|
|
|
|
uiLabel_->setAlignment(Qt::AlignBottom);
|
2020-02-19 00:16:07 +03:00
|
|
|
uiLabel_->setFont(font);
|
|
|
|
|
2018-10-07 12:58:38 +03:00
|
|
|
for (double option = 1; option <= 3; option += 0.25)
|
|
|
|
scaleFactorCombo_->addItem(QString::number(option));
|
2018-10-01 17:56:46 +03:00
|
|
|
for (double option = 10; option < 17; option += 0.5)
|
|
|
|
fontSizeCombo_->addItem(QString("%1 ").arg(QString::number(option)));
|
|
|
|
|
2019-01-19 19:20:41 +03:00
|
|
|
QFontDatabase fontDb;
|
|
|
|
|
2020-02-19 00:16:07 +03:00
|
|
|
// TODO: Is there a way to limit to just emojis, rather than
|
|
|
|
// all emoji fonts?
|
|
|
|
auto emojiFamilies = fontDb.families(QFontDatabase::Symbol);
|
2019-07-27 00:31:59 +03:00
|
|
|
for (const auto &family : emojiFamilies) {
|
|
|
|
emojiFontSelectionCombo_->addItem(family);
|
|
|
|
}
|
|
|
|
|
2020-02-19 00:16:07 +03:00
|
|
|
fontSelectionCombo_->setCurrentIndex(fontSelectionCombo_->findText(settings_->font()));
|
2019-01-19 20:31:17 +03:00
|
|
|
|
2020-02-19 00:16:07 +03:00
|
|
|
emojiFontSelectionCombo_->setCurrentIndex(
|
|
|
|
emojiFontSelectionCombo_->findText(settings_->emojiFont()));
|
2019-07-27 00:31:59 +03:00
|
|
|
|
2020-02-19 00:16:07 +03:00
|
|
|
themeCombo_ = new QComboBox{this};
|
2017-11-25 19:19:58 +03:00
|
|
|
themeCombo_->addItem("Light");
|
|
|
|
themeCombo_->addItem("Dark");
|
2017-11-02 01:41:13 +03:00
|
|
|
themeCombo_->addItem("System");
|
|
|
|
|
2019-01-19 20:31:17 +03:00
|
|
|
QString themeStr = settings_->theme();
|
|
|
|
themeStr.replace(0, 1, themeStr[0].toUpper());
|
|
|
|
int themeIndex = themeCombo_->findText(themeStr);
|
|
|
|
themeCombo_->setCurrentIndex(themeIndex);
|
|
|
|
|
2020-05-26 23:27:05 +03:00
|
|
|
timelineMaxWidthSpin_->setMinimum(0);
|
|
|
|
timelineMaxWidthSpin_->setMaximum(100'000'000);
|
|
|
|
timelineMaxWidthSpin_->setSingleStep(10);
|
|
|
|
|
2020-07-11 02:19:48 +03:00
|
|
|
auto callsLabel = new QLabel{tr("CALLS"), this};
|
|
|
|
callsLabel->setFixedHeight(callsLabel->minimumHeight() + LayoutTopMargin);
|
|
|
|
callsLabel->setAlignment(Qt::AlignBottom);
|
|
|
|
callsLabel->setFont(font);
|
|
|
|
|
2020-02-19 00:16:07 +03:00
|
|
|
auto encryptionLabel_ = new QLabel{tr("ENCRYPTION"), this};
|
2020-02-19 22:23:57 +03:00
|
|
|
encryptionLabel_->setFixedHeight(encryptionLabel_->minimumHeight() + LayoutTopMargin);
|
|
|
|
encryptionLabel_->setAlignment(Qt::AlignBottom);
|
2020-02-18 18:08:19 +03:00
|
|
|
encryptionLabel_->setFont(font);
|
2018-08-21 09:22:51 +03:00
|
|
|
|
2018-09-19 22:42:26 +03:00
|
|
|
QFont monospaceFont;
|
|
|
|
monospaceFont.setFamily("Monospace");
|
|
|
|
monospaceFont.setStyleHint(QFont::Monospace);
|
2018-08-21 09:22:51 +03:00
|
|
|
monospaceFont.setPointSizeF(monospaceFont.pointSizeF() * 0.9);
|
|
|
|
|
2018-09-15 23:52:14 +03:00
|
|
|
deviceIdValue_ = new QLabel{this};
|
2018-08-21 09:22:51 +03:00
|
|
|
deviceIdValue_->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
|
|
|
deviceIdValue_->setFont(monospaceFont);
|
|
|
|
|
2018-09-15 23:52:14 +03:00
|
|
|
deviceFingerprintValue_ = new QLabel{this};
|
2018-08-21 09:22:51 +03:00
|
|
|
deviceFingerprintValue_->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
|
|
|
deviceFingerprintValue_->setFont(monospaceFont);
|
2018-09-15 23:52:14 +03:00
|
|
|
|
2020-02-19 22:00:49 +03:00
|
|
|
deviceFingerprintValue_->setText(utils::humanReadableFingerprint(QString(44, 'X')));
|
2020-02-19 00:16:07 +03:00
|
|
|
|
|
|
|
auto sessionKeysLabel = new QLabel{tr("Session Keys"), this};
|
2018-09-15 23:52:14 +03:00
|
|
|
sessionKeysLabel->setFont(font);
|
2020-02-18 18:08:19 +03:00
|
|
|
sessionKeysLabel->setMargin(OptionMargin);
|
2018-09-15 23:52:14 +03:00
|
|
|
|
2018-09-19 22:42:26 +03:00
|
|
|
auto sessionKeysImportBtn = new QPushButton{tr("IMPORT"), this};
|
|
|
|
auto sessionKeysExportBtn = new QPushButton{tr("EXPORT"), this};
|
2020-02-18 18:08:19 +03:00
|
|
|
|
2020-02-19 00:16:07 +03:00
|
|
|
auto sessionKeysLayout = new QHBoxLayout;
|
|
|
|
sessionKeysLayout->addWidget(new QLabel{"", this}, 1, Qt::AlignRight);
|
2018-09-19 22:42:26 +03:00
|
|
|
sessionKeysLayout->addWidget(sessionKeysExportBtn, 0, Qt::AlignRight);
|
|
|
|
sessionKeysLayout->addWidget(sessionKeysImportBtn, 0, Qt::AlignRight);
|
2018-09-15 23:52:14 +03:00
|
|
|
|
2020-05-23 16:15:46 +03:00
|
|
|
auto boxWrap = [this, &font](QString labelText, QWidget *field, QString tooltipText = "") {
|
2020-02-19 00:16:07 +03:00
|
|
|
auto label = new QLabel{labelText, this};
|
2020-02-18 18:08:19 +03:00
|
|
|
label->setFont(font);
|
|
|
|
label->setMargin(OptionMargin);
|
2018-08-21 09:22:51 +03:00
|
|
|
|
2020-05-23 16:15:46 +03:00
|
|
|
if (!tooltipText.isEmpty()) {
|
|
|
|
label->setToolTip(tooltipText);
|
|
|
|
}
|
|
|
|
|
2020-02-19 00:16:07 +03:00
|
|
|
auto layout = new QHBoxLayout;
|
2020-02-18 18:08:19 +03:00
|
|
|
layout->addWidget(field, 0, Qt::AlignRight);
|
2018-08-21 09:22:51 +03:00
|
|
|
|
2020-02-18 18:08:19 +03:00
|
|
|
formLayout_->addRow(label, layout);
|
|
|
|
};
|
2018-08-21 09:22:51 +03:00
|
|
|
|
2020-02-18 18:08:19 +03:00
|
|
|
formLayout_->addRow(general_);
|
2020-02-19 00:16:07 +03:00
|
|
|
formLayout_->addRow(new HorizontalLine{this});
|
2020-05-23 16:15:46 +03:00
|
|
|
boxWrap(
|
|
|
|
tr("Minimize to tray"),
|
|
|
|
trayToggle_,
|
|
|
|
tr("Keep the application running in the background after closing the client window."));
|
|
|
|
boxWrap(tr("Start in tray"),
|
|
|
|
startInTrayToggle_,
|
|
|
|
tr("Start the application in the background without showing the client window."));
|
2020-02-18 18:08:19 +03:00
|
|
|
formLayout_->addRow(new HorizontalLine{this});
|
2020-05-23 16:15:46 +03:00
|
|
|
boxWrap(tr("Circular Avatars"),
|
|
|
|
avatarCircles_,
|
|
|
|
tr("Change the appearance of user avatars in chats.\nOFF - square, ON - Circle."));
|
|
|
|
boxWrap(tr("Group's sidebar"),
|
|
|
|
groupViewToggle_,
|
|
|
|
tr("Show a column containing groups and tags next to the room list."));
|
|
|
|
boxWrap(tr("Decrypt messages in sidebar"),
|
|
|
|
decryptSidebar_,
|
|
|
|
tr("Decrypt the messages shown in the sidebar.\nOnly affects messages in "
|
|
|
|
"encrypted chats."));
|
|
|
|
boxWrap(tr("Show buttons in timeline"),
|
|
|
|
timelineButtonsToggle_,
|
|
|
|
tr("Show buttons to quickly reply, react or access additional options next to each "
|
|
|
|
"message."));
|
2020-05-26 23:27:05 +03:00
|
|
|
boxWrap(tr("Limit width of timeline"),
|
|
|
|
timelineMaxWidthSpin_,
|
|
|
|
tr("Set the max width of messages in the timeline (in pixels). This can help "
|
|
|
|
"readability on wide screen, when Nheko is maximised"));
|
2020-05-23 16:15:46 +03:00
|
|
|
boxWrap(tr("Typing notifications"),
|
|
|
|
typingNotifications_,
|
|
|
|
tr("Show who is typing in a room.\nThis will also enable or disable sending typing "
|
|
|
|
"notifications to others."));
|
|
|
|
boxWrap(
|
|
|
|
tr("Sort rooms by unreads"),
|
|
|
|
sortByImportance_,
|
|
|
|
tr(
|
|
|
|
"Display rooms with new messages first.\nIf this is off, the list of rooms will only "
|
|
|
|
"be sorted by the timestamp of the last message in a room.\nIf this is on, rooms which "
|
|
|
|
"have active notifications (the small circle with a number in it) will be sorted on "
|
|
|
|
"top. Rooms, that you have muted, will still be sorted by timestamp, since you don't "
|
|
|
|
"seem to consider them as important as the other rooms."));
|
2020-02-18 18:08:19 +03:00
|
|
|
formLayout_->addRow(new HorizontalLine{this});
|
2020-05-23 16:15:46 +03:00
|
|
|
boxWrap(tr("Read receipts"),
|
|
|
|
readReceipts_,
|
|
|
|
tr("Show if your message was read.\nStatus is displayed next to timestamps."));
|
|
|
|
boxWrap(
|
|
|
|
tr("Send messages as Markdown"),
|
2020-05-26 23:53:21 +03:00
|
|
|
markdown_,
|
2020-05-23 16:15:46 +03:00
|
|
|
tr("Allow using markdown in messages.\nWhen disabled, all messages are sent as a plain "
|
|
|
|
"text."));
|
|
|
|
boxWrap(tr("Desktop notifications"),
|
|
|
|
desktopNotifications_,
|
|
|
|
tr("Notify about received message when the client is not currently focused."));
|
2020-06-10 12:27:21 +03:00
|
|
|
boxWrap(tr("Alert on notification"),
|
|
|
|
alertOnNotification_,
|
|
|
|
tr("Show an alert when a message is received.\nThis usually causes the application "
|
|
|
|
"icon in the task bar to animate in some fashion."));
|
2020-05-23 16:15:46 +03:00
|
|
|
boxWrap(tr("Highlight message on hover"),
|
|
|
|
messageHoverHighlight_,
|
|
|
|
tr("Change the background color of messages when you hover over them."));
|
|
|
|
boxWrap(tr("Large Emoji in timeline"),
|
|
|
|
enlargeEmojiOnlyMessages_,
|
|
|
|
tr("Make font size larger if messages with only a few emojis are displayed."));
|
2020-02-19 00:16:07 +03:00
|
|
|
formLayout_->addRow(uiLabel_);
|
2020-02-18 18:08:19 +03:00
|
|
|
formLayout_->addRow(new HorizontalLine{this});
|
2020-02-19 00:16:07 +03:00
|
|
|
|
2020-10-28 02:58:20 +03:00
|
|
|
boxWrap(tr("Touchscreen mode"),
|
2020-10-24 17:21:00 +03:00
|
|
|
mobileMode_,
|
2020-10-28 02:58:20 +03:00
|
|
|
tr("Will prevent text selection in the timeline to make touch scrolling easier."));
|
2020-02-19 00:16:07 +03:00
|
|
|
#if !defined(Q_OS_MAC)
|
2020-05-23 16:15:46 +03:00
|
|
|
boxWrap(tr("Scale factor"),
|
|
|
|
scaleFactorCombo_,
|
|
|
|
tr("Change the scale factor of the whole user interface."));
|
2020-02-19 00:16:07 +03:00
|
|
|
#else
|
|
|
|
scaleFactorCombo_->hide();
|
|
|
|
#endif
|
2020-02-18 18:08:19 +03:00
|
|
|
boxWrap(tr("Font size"), fontSizeCombo_);
|
|
|
|
boxWrap(tr("Font Family"), fontSelectionCombo_);
|
2020-02-19 00:16:07 +03:00
|
|
|
|
|
|
|
#if !defined(Q_OS_MAC)
|
2020-02-18 18:08:19 +03:00
|
|
|
boxWrap(tr("Emoji Font Family"), emojiFontSelectionCombo_);
|
2020-02-19 00:16:07 +03:00
|
|
|
#else
|
|
|
|
emojiFontSelectionCombo_->hide();
|
|
|
|
#endif
|
|
|
|
|
2020-02-18 18:08:19 +03:00
|
|
|
boxWrap(tr("Theme"), themeCombo_);
|
2020-07-11 02:19:48 +03:00
|
|
|
|
|
|
|
formLayout_->addRow(callsLabel);
|
|
|
|
formLayout_->addRow(new HorizontalLine{this});
|
2020-11-13 03:55:35 +03:00
|
|
|
boxWrap(tr("Ringtone"),
|
|
|
|
ringtoneCombo_,
|
|
|
|
tr("Set the notification sound to play when a call invite arrives"));
|
2020-10-27 20:14:06 +03:00
|
|
|
boxWrap(tr("Microphone"), microphoneCombo_);
|
|
|
|
boxWrap(tr("Camera"), cameraCombo_);
|
|
|
|
boxWrap(tr("Camera resolution"), cameraResolutionCombo_);
|
|
|
|
boxWrap(tr("Camera frame rate"), cameraFrameRateCombo_);
|
2020-11-13 03:55:35 +03:00
|
|
|
|
|
|
|
ringtoneCombo_->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
|
|
ringtoneCombo_->addItem("Mute");
|
|
|
|
ringtoneCombo_->addItem("Default");
|
|
|
|
ringtoneCombo_->addItem("Other...");
|
|
|
|
const QString &ringtone = settings_->ringtone();
|
|
|
|
if (!ringtone.isEmpty() && ringtone != "Mute" && ringtone != "Default")
|
|
|
|
ringtoneCombo_->addItem(ringtone);
|
2020-10-27 20:14:06 +03:00
|
|
|
microphoneCombo_->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
|
|
cameraCombo_->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
|
|
cameraResolutionCombo_->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
|
|
cameraFrameRateCombo_->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
2020-11-13 03:55:35 +03:00
|
|
|
|
2020-08-06 00:56:44 +03:00
|
|
|
boxWrap(tr("Allow fallback call assist server"),
|
2020-07-11 02:19:48 +03:00
|
|
|
useStunServer_,
|
|
|
|
tr("Will use turn.matrix.org as assist when your home server does not offer one."));
|
|
|
|
|
2020-02-18 18:08:19 +03:00
|
|
|
formLayout_->addRow(encryptionLabel_);
|
2020-02-19 00:16:07 +03:00
|
|
|
formLayout_->addRow(new HorizontalLine{this});
|
2020-02-18 18:08:19 +03:00
|
|
|
boxWrap(tr("Device ID"), deviceIdValue_);
|
|
|
|
boxWrap(tr("Device Fingerprint"), deviceFingerprintValue_);
|
2020-10-18 01:52:35 +03:00
|
|
|
boxWrap(
|
2020-10-28 02:55:18 +03:00
|
|
|
tr("Share keys with verified users and devices"),
|
2020-10-18 01:52:35 +03:00
|
|
|
shareKeysWithTrustedUsers_,
|
|
|
|
tr("Automatically replies to key requests from other users, if they are verified."));
|
2020-02-19 00:16:07 +03:00
|
|
|
formLayout_->addRow(new HorizontalLine{this});
|
2020-02-18 18:08:19 +03:00
|
|
|
formLayout_->addRow(sessionKeysLabel, sessionKeysLayout);
|
2017-11-02 01:41:13 +03:00
|
|
|
|
2020-02-19 00:16:07 +03:00
|
|
|
auto scrollArea_ = new QScrollArea{this};
|
2018-05-09 01:00:10 +03:00
|
|
|
scrollArea_->setFrameShape(QFrame::NoFrame);
|
|
|
|
scrollArea_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
scrollArea_->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
|
|
|
|
scrollArea_->setWidgetResizable(true);
|
|
|
|
scrollArea_->setAlignment(Qt::AlignTop | Qt::AlignVCenter);
|
|
|
|
|
2020-02-15 05:47:58 +03:00
|
|
|
QScroller::grabGesture(scrollArea_, QScroller::TouchGesture);
|
|
|
|
|
2020-02-20 20:11:30 +03:00
|
|
|
auto spacingAroundForm = new QHBoxLayout;
|
|
|
|
spacingAroundForm->addStretch(1);
|
|
|
|
spacingAroundForm->addLayout(formLayout_, 0);
|
|
|
|
spacingAroundForm->addStretch(1);
|
|
|
|
|
2020-02-19 00:16:07 +03:00
|
|
|
auto scrollAreaContents_ = new QWidget{this};
|
2018-05-09 01:00:10 +03:00
|
|
|
scrollAreaContents_->setObjectName("UserSettingScrollWidget");
|
2020-02-20 20:11:30 +03:00
|
|
|
scrollAreaContents_->setLayout(spacingAroundForm);
|
2018-05-09 01:00:10 +03:00
|
|
|
|
|
|
|
scrollArea_->setWidget(scrollAreaContents_);
|
2017-11-02 01:41:13 +03:00
|
|
|
topLayout_->addLayout(topBarLayout_);
|
2018-08-01 21:26:34 +03:00
|
|
|
topLayout_->addWidget(scrollArea_, Qt::AlignTop);
|
|
|
|
topLayout_->addStretch(1);
|
2018-03-22 17:20:22 +03:00
|
|
|
topLayout_->addWidget(versionInfo);
|
2017-11-02 01:41:13 +03:00
|
|
|
|
|
|
|
connect(themeCombo_,
|
2020-06-06 00:34:00 +03:00
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
2019-01-20 07:43:48 +03:00
|
|
|
[this](const QString &text) {
|
|
|
|
settings_->setTheme(text.toLower());
|
|
|
|
emit themeChanged();
|
|
|
|
});
|
2018-07-22 19:48:58 +03:00
|
|
|
connect(scaleFactorCombo_,
|
2020-06-06 00:34:00 +03:00
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
2018-07-22 20:26:50 +03:00
|
|
|
[](const QString &factor) { utils::setScaleFactor(factor.toFloat()); });
|
2018-10-01 17:56:46 +03:00
|
|
|
connect(fontSizeCombo_,
|
2020-06-06 00:34:00 +03:00
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
2018-10-01 17:56:46 +03:00
|
|
|
[this](const QString &size) { settings_->setFontSize(size.trimmed().toDouble()); });
|
2019-01-19 19:20:41 +03:00
|
|
|
connect(fontSelectionCombo_,
|
2020-06-06 00:34:00 +03:00
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
2019-01-19 19:20:41 +03:00
|
|
|
[this](const QString &family) { settings_->setFontFamily(family.trimmed()); });
|
2019-07-27 00:31:59 +03:00
|
|
|
connect(emojiFontSelectionCombo_,
|
2020-06-06 00:34:00 +03:00
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
2019-07-27 00:31:59 +03:00
|
|
|
[this](const QString &family) { settings_->setEmojiFontFamily(family.trimmed()); });
|
2020-10-27 20:14:06 +03:00
|
|
|
|
2020-11-13 03:55:35 +03:00
|
|
|
connect(ringtoneCombo_,
|
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
|
|
|
[this](const QString &ringtone) {
|
|
|
|
if (ringtone == "Other...") {
|
|
|
|
QString homeFolder =
|
|
|
|
QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
|
|
|
auto filepath = QFileDialog::getOpenFileName(
|
|
|
|
this, tr("Select a file"), homeFolder, tr("All Files (*)"));
|
|
|
|
if (!filepath.isEmpty()) {
|
|
|
|
const auto &oldSetting = settings_->ringtone();
|
|
|
|
if (oldSetting != "Mute" && oldSetting != "Default")
|
|
|
|
ringtoneCombo_->removeItem(
|
|
|
|
ringtoneCombo_->findText(oldSetting));
|
|
|
|
settings_->setRingtone(filepath);
|
|
|
|
ringtoneCombo_->addItem(filepath);
|
|
|
|
ringtoneCombo_->setCurrentText(filepath);
|
|
|
|
} else {
|
|
|
|
ringtoneCombo_->setCurrentText(settings_->ringtone());
|
|
|
|
}
|
|
|
|
} else if (ringtone == "Mute" || ringtone == "Default") {
|
|
|
|
const auto &oldSetting = settings_->ringtone();
|
|
|
|
if (oldSetting != "Mute" && oldSetting != "Default")
|
|
|
|
ringtoneCombo_->removeItem(
|
|
|
|
ringtoneCombo_->findText(oldSetting));
|
|
|
|
settings_->setRingtone(ringtone);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-10-27 20:14:06 +03:00
|
|
|
connect(microphoneCombo_,
|
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
|
|
|
[this](const QString µphone) { settings_->setMicrophone(microphone); });
|
|
|
|
|
|
|
|
connect(cameraCombo_,
|
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
|
|
|
[this](const QString &camera) {
|
|
|
|
settings_->setCamera(camera);
|
|
|
|
std::vector<std::string> resolutions =
|
|
|
|
WebRTCSession::instance().getResolutions(camera.toStdString());
|
|
|
|
cameraResolutionCombo_->clear();
|
|
|
|
for (const auto &resolution : resolutions)
|
|
|
|
cameraResolutionCombo_->addItem(QString::fromStdString(resolution));
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(cameraResolutionCombo_,
|
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
|
|
|
[this](const QString &resolution) {
|
|
|
|
settings_->setCameraResolution(resolution);
|
|
|
|
std::vector<std::string> frameRates =
|
|
|
|
WebRTCSession::instance().getFrameRates(settings_->camera().toStdString(),
|
|
|
|
resolution.toStdString());
|
|
|
|
cameraFrameRateCombo_->clear();
|
|
|
|
for (const auto &frameRate : frameRates)
|
|
|
|
cameraFrameRateCombo_->addItem(QString::fromStdString(frameRate));
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(cameraFrameRateCombo_,
|
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
|
|
|
[this](const QString &frameRate) { settings_->setCameraFrameRate(frameRate); });
|
|
|
|
|
2020-11-25 18:57:54 +03:00
|
|
|
connect(trayToggle_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setTray(enabled);
|
|
|
|
if (enabled) {
|
2020-11-25 22:05:10 +03:00
|
|
|
startInTrayToggle_->setChecked(false);
|
2018-05-08 23:53:40 +03:00
|
|
|
startInTrayToggle_->setEnabled(true);
|
2020-11-25 22:05:10 +03:00
|
|
|
startInTrayToggle_->setState(false);
|
|
|
|
settings_->setStartInTray(false);
|
2020-11-25 18:57:54 +03:00
|
|
|
} else {
|
2020-11-25 22:05:10 +03:00
|
|
|
startInTrayToggle_->setChecked(false);
|
2020-11-25 19:31:03 +03:00
|
|
|
startInTrayToggle_->setState(false);
|
2020-11-25 18:57:54 +03:00
|
|
|
startInTrayToggle_->setDisabled(true);
|
2020-11-25 22:05:10 +03:00
|
|
|
settings_->setStartInTray(false);
|
2018-05-08 23:53:40 +03:00
|
|
|
}
|
2020-11-25 18:57:54 +03:00
|
|
|
emit trayOptionChanged(enabled);
|
2017-11-02 01:41:13 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 18:57:54 +03:00
|
|
|
connect(startInTrayToggle_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setStartInTray(enabled);
|
2018-05-08 23:53:40 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(mobileMode_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setMobileMode(enabled);
|
2020-10-24 17:21:00 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(groupViewToggle_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setGroupView(enabled);
|
2018-01-09 22:57:41 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(decryptSidebar_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setDecryptSidebar(enabled);
|
2020-04-23 02:52:30 +03:00
|
|
|
emit decryptSidebarChanged();
|
2020-04-22 04:42:17 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(shareKeysWithTrustedUsers_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setShareKeysWithTrustedUsers(enabled);
|
2020-10-23 17:59:18 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(avatarCircles_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setAvatarCircles(enabled);
|
2019-08-29 07:36:28 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(markdown_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setMarkdown(enabled);
|
2020-01-27 17:59:25 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(typingNotifications_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setTypingNotifications(enabled);
|
2018-01-14 16:57:58 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(sortByImportance_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setSortByImportance(enabled);
|
2020-03-15 18:19:22 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(timelineButtonsToggle_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setButtonsInTimeline(enabled);
|
2020-03-10 02:30:45 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(readReceipts_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setReadReceipts(enabled);
|
2018-03-11 18:56:40 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(desktopNotifications_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setDesktopNotifications(enabled);
|
2018-08-11 18:26:17 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(alertOnNotification_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setAlertOnNotification(enabled);
|
2020-06-10 12:27:21 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(messageHoverHighlight_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setMessageHoverHighlight(enabled);
|
2020-05-16 00:27:41 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(enlargeEmojiOnlyMessages_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setEnlargeEmojiOnlyMessages(enabled);
|
2020-05-19 22:04:38 +03:00
|
|
|
});
|
|
|
|
|
2020-11-25 19:05:31 +03:00
|
|
|
connect(useStunServer_, &Toggle::toggled, this, [this](bool enabled) {
|
|
|
|
settings_->setUseStunServer(enabled);
|
2020-07-11 02:19:48 +03:00
|
|
|
});
|
|
|
|
|
2020-05-26 23:27:05 +03:00
|
|
|
connect(timelineMaxWidthSpin_,
|
|
|
|
qOverload<int>(&QSpinBox::valueChanged),
|
|
|
|
this,
|
|
|
|
[this](int newValue) { settings_->setTimelineMaxWidth(newValue); });
|
|
|
|
|
2020-02-18 18:08:19 +03:00
|
|
|
connect(
|
|
|
|
sessionKeysImportBtn, &QPushButton::clicked, this, &UserSettingsPage::importSessionKeys);
|
|
|
|
|
|
|
|
connect(
|
|
|
|
sessionKeysExportBtn, &QPushButton::clicked, this, &UserSettingsPage::exportSessionKeys);
|
|
|
|
|
2018-02-20 18:09:11 +03:00
|
|
|
connect(backBtn_, &QPushButton::clicked, this, [this]() {
|
2017-11-02 01:41:13 +03:00
|
|
|
settings_->save();
|
|
|
|
emit moveBack();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettingsPage::showEvent(QShowEvent *)
|
|
|
|
{
|
2018-10-01 17:56:46 +03:00
|
|
|
// FIXME macOS doesn't show the full option unless a space is added.
|
|
|
|
utils::restoreCombobox(fontSizeCombo_, QString::number(settings_->fontSize()) + " ");
|
|
|
|
utils::restoreCombobox(scaleFactorCombo_, QString::number(utils::scaleFactor()));
|
|
|
|
utils::restoreCombobox(themeCombo_, settings_->theme());
|
2020-11-13 03:55:35 +03:00
|
|
|
utils::restoreCombobox(ringtoneCombo_, settings_->ringtone());
|
2018-01-09 22:57:41 +03:00
|
|
|
|
2020-11-25 18:57:54 +03:00
|
|
|
trayToggle_->setState(settings_->tray());
|
|
|
|
startInTrayToggle_->setState(settings_->startInTray());
|
|
|
|
groupViewToggle_->setState(settings_->groupView());
|
|
|
|
decryptSidebar_->setState(settings_->decryptSidebar());
|
|
|
|
shareKeysWithTrustedUsers_->setState(settings_->shareKeysWithTrustedUsers());
|
|
|
|
avatarCircles_->setState(settings_->avatarCircles());
|
|
|
|
typingNotifications_->setState(settings_->typingNotifications());
|
|
|
|
sortByImportance_->setState(settings_->sortByImportance());
|
|
|
|
timelineButtonsToggle_->setState(settings_->buttonsInTimeline());
|
|
|
|
mobileMode_->setState(settings_->mobileMode());
|
|
|
|
readReceipts_->setState(settings_->readReceipts());
|
|
|
|
markdown_->setState(settings_->markdown());
|
|
|
|
desktopNotifications_->setState(settings_->hasDesktopNotifications());
|
|
|
|
alertOnNotification_->setState(settings_->hasAlertOnNotification());
|
|
|
|
messageHoverHighlight_->setState(settings_->messageHoverHighlight());
|
|
|
|
enlargeEmojiOnlyMessages_->setState(settings_->enlargeEmojiOnlyMessages());
|
2018-08-21 09:22:51 +03:00
|
|
|
deviceIdValue_->setText(QString::fromStdString(http::client()->device_id()));
|
2020-05-26 23:27:05 +03:00
|
|
|
timelineMaxWidthSpin_->setValue(settings_->timelineMaxWidth());
|
2020-10-27 20:14:06 +03:00
|
|
|
|
|
|
|
WebRTCSession::instance().refreshDevices();
|
|
|
|
auto mics =
|
|
|
|
WebRTCSession::instance().getDeviceNames(false, settings_->microphone().toStdString());
|
|
|
|
microphoneCombo_->clear();
|
|
|
|
for (const auto &m : mics)
|
|
|
|
microphoneCombo_->addItem(QString::fromStdString(m));
|
|
|
|
|
|
|
|
auto cameraResolution = settings_->cameraResolution();
|
|
|
|
auto cameraFrameRate = settings_->cameraFrameRate();
|
|
|
|
|
|
|
|
auto cameras =
|
|
|
|
WebRTCSession::instance().getDeviceNames(true, settings_->camera().toStdString());
|
|
|
|
cameraCombo_->clear();
|
|
|
|
for (const auto &c : cameras)
|
|
|
|
cameraCombo_->addItem(QString::fromStdString(c));
|
|
|
|
|
|
|
|
utils::restoreCombobox(cameraResolutionCombo_, cameraResolution);
|
|
|
|
utils::restoreCombobox(cameraFrameRateCombo_, cameraFrameRate);
|
|
|
|
|
2020-11-25 18:57:54 +03:00
|
|
|
useStunServer_->setState(settings_->useStunServer());
|
2018-08-21 09:22:51 +03:00
|
|
|
|
|
|
|
deviceFingerprintValue_->setText(
|
|
|
|
utils::humanReadableFingerprint(olm::client()->identity_keys().ed25519));
|
2017-11-02 01:41:13 +03:00
|
|
|
}
|
2017-11-09 23:04:40 +03:00
|
|
|
|
|
|
|
void
|
2017-11-22 20:52:38 +03:00
|
|
|
UserSettingsPage::paintEvent(QPaintEvent *)
|
|
|
|
{
|
|
|
|
QStyleOption opt;
|
|
|
|
opt.init(this);
|
|
|
|
QPainter p(this);
|
|
|
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
|
|
|
}
|
2017-11-25 19:19:58 +03:00
|
|
|
|
2018-09-15 23:52:14 +03:00
|
|
|
void
|
|
|
|
UserSettingsPage::importSessionKeys()
|
|
|
|
{
|
2020-02-15 04:35:26 +03:00
|
|
|
const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
|
|
|
const QString fileName =
|
|
|
|
QFileDialog::getOpenFileName(this, tr("Open Sessions File"), homeFolder, "");
|
2018-09-15 23:52:14 +03:00
|
|
|
|
|
|
|
QFile file(fileName);
|
|
|
|
if (!file.open(QIODevice::ReadOnly)) {
|
|
|
|
QMessageBox::warning(this, tr("Error"), file.errorString());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto bin = file.peek(file.size());
|
|
|
|
auto payload = std::string(bin.data(), bin.size());
|
|
|
|
|
|
|
|
bool ok;
|
|
|
|
auto password = QInputDialog::getText(this,
|
|
|
|
tr("File Password"),
|
|
|
|
tr("Enter the passphrase to decrypt the file:"),
|
|
|
|
QLineEdit::Password,
|
|
|
|
"",
|
|
|
|
&ok);
|
2018-09-19 22:42:26 +03:00
|
|
|
if (!ok)
|
|
|
|
return;
|
2018-09-15 23:52:14 +03:00
|
|
|
|
2018-09-19 22:42:26 +03:00
|
|
|
if (password.isEmpty()) {
|
2018-09-15 23:52:14 +03:00
|
|
|
QMessageBox::warning(this, tr("Error"), tr("The password cannot be empty"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2019-04-05 01:24:21 +03:00
|
|
|
auto sessions =
|
|
|
|
mtx::crypto::decrypt_exported_sessions(payload, password.toStdString());
|
2019-12-15 04:56:04 +03:00
|
|
|
cache::importSessionKeys(std::move(sessions));
|
2020-10-27 19:45:28 +03:00
|
|
|
} catch (const std::exception &e) {
|
2018-09-15 23:52:14 +03:00
|
|
|
QMessageBox::warning(this, tr("Error"), e.what());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UserSettingsPage::exportSessionKeys()
|
|
|
|
{
|
|
|
|
// Open password dialog.
|
|
|
|
bool ok;
|
|
|
|
auto password = QInputDialog::getText(this,
|
|
|
|
tr("File Password"),
|
|
|
|
tr("Enter passphrase to encrypt your session keys:"),
|
|
|
|
QLineEdit::Password,
|
|
|
|
"",
|
|
|
|
&ok);
|
2018-09-19 22:42:26 +03:00
|
|
|
if (!ok)
|
|
|
|
return;
|
2018-09-15 23:52:14 +03:00
|
|
|
|
2018-09-19 22:42:26 +03:00
|
|
|
if (password.isEmpty()) {
|
2018-09-15 23:52:14 +03:00
|
|
|
QMessageBox::warning(this, tr("Error"), tr("The password cannot be empty"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open file dialog to save the file.
|
2020-02-15 04:35:26 +03:00
|
|
|
const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
|
|
|
const QString fileName =
|
2018-09-15 23:52:14 +03:00
|
|
|
QFileDialog::getSaveFileName(this, tr("File to save the exported session keys"), "", "");
|
|
|
|
|
|
|
|
QFile file(fileName);
|
2019-03-28 02:13:38 +03:00
|
|
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
2018-09-15 23:52:14 +03:00
|
|
|
QMessageBox::warning(this, tr("Error"), file.errorString());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Export sessions & save to file.
|
|
|
|
try {
|
|
|
|
auto encrypted_blob = mtx::crypto::encrypt_exported_sessions(
|
2019-12-15 04:56:04 +03:00
|
|
|
cache::exportSessionKeys(), password.toStdString());
|
2018-09-15 23:52:14 +03:00
|
|
|
|
2019-04-05 01:24:21 +03:00
|
|
|
QString b64 = QString::fromStdString(mtx::crypto::bin2base64(encrypted_blob));
|
2018-09-15 23:52:14 +03:00
|
|
|
|
2019-03-28 02:13:38 +03:00
|
|
|
QString prefix("-----BEGIN MEGOLM SESSION DATA-----");
|
|
|
|
QString suffix("-----END MEGOLM SESSION DATA-----");
|
|
|
|
QString newline("\n");
|
|
|
|
QTextStream out(&file);
|
|
|
|
out << prefix << newline << b64 << newline << suffix;
|
|
|
|
file.close();
|
2020-10-27 19:45:28 +03:00
|
|
|
} catch (const std::exception &e) {
|
2018-09-15 23:52:14 +03:00
|
|
|
QMessageBox::warning(this, tr("Error"), e.what());
|
|
|
|
}
|
|
|
|
}
|