Merge pull request #1001 from duarm/master

options to open images/videos with external program by default
This commit is contained in:
DeepBlueV7.X 2022-03-20 04:30:54 +01:00 committed by GitHub
commit dda1bcd3c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 92 additions and 6 deletions

View file

@ -2908,6 +2908,16 @@ Reason: %4</translation>
<source>Use identicons</source>
<translation>Use identicons</translation>
</message>
<message>
<location line="+2"/>
<source>Open images with external program</source>
<translation>Open images with external program</translation>
</message>
<message>
<location line="+2"/>
<source>Open videos with external program</source>
<translation>Open videos with external program</translation>
</message>
<message>
<location line="+2"/>
<source>Decrypt messages in sidebar</source>

View file

@ -68,7 +68,7 @@ Item {
TapHandler {
//enabled: type == MtxEvent.ImageMessage && (img.status == Image.Ready || mxcimage.loaded)
onSingleTapped: {
TimelineManager.openImageOverlay(room, url, eventId);
Settings.openImageExternal ? room.openMedia(eventId) : TimelineManager.openImageOverlay(room, url, eventId);
eventPoint.accepted = true;
}
gesturePolicy: TapHandler.ReleaseWithinBounds

View file

@ -52,7 +52,7 @@ Item {
height: parent.height - fileInfoLabel.height
TapHandler {
onTapped: mediaControls.showControls()
onTapped: Settings.openVideoExternal ? room.openMedia(eventId) : mediaControls.showControls()
}
Image {

View file

@ -84,6 +84,8 @@ UserSettings::load(std::optional<QString> profile)
avatarCircles_ = settings.value(QStringLiteral("user/avatar_circles"), true).toBool();
useIdenticon_ = settings.value(QStringLiteral("user/use_identicon"), true).toBool();
openImageExternal_ = settings.value(QStringLiteral("user/open_image_external"), false).toBool();
openVideoExternal_ = settings.value(QStringLiteral("user/open_video_external"), false).toBool();
decryptSidebar_ = settings.value(QStringLiteral("user/decrypt_sidebar"), true).toBool();
privacyScreen_ = settings.value(QStringLiteral("user/privacy_screen"), false).toBool();
privacyScreenTimeout_ =
@ -687,6 +689,26 @@ UserSettings::setUseIdenticon(bool state)
save();
}
void
UserSettings::setOpenImageExternal(bool state)
{
if (state == openImageExternal_)
return;
openImageExternal_ = state;
emit openImageExternalChanged(openImageExternal_);
save();
}
void
UserSettings::setOpenVideoExternal(bool state)
{
if (state == openVideoExternal_)
return;
openVideoExternal_ = state;
emit openVideoExternalChanged(openVideoExternal_);
save();
}
void
UserSettings::applyTheme()
{
@ -764,6 +786,8 @@ UserSettings::save()
settings.setValue(QStringLiteral("use_stun_server"), useStunServer_);
settings.setValue(QStringLiteral("currentProfile"), profile_);
settings.setValue(QStringLiteral("use_identicon"), useIdenticon_);
settings.setValue(QStringLiteral("open_image_external"), openImageExternal_);
settings.setValue(QStringLiteral("open_video_external"), openVideoExternal_);
settings.endGroup(); // user
@ -868,6 +892,10 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
return tr("Circular Avatars");
case UseIdenticon:
return tr("Use identicons");
case OpenImageExternal:
return tr("Open images with external program");
case OpenVideoExternal:
return tr("Open videos with external program");
case DecryptSidebar:
return tr("Decrypt messages in sidebar");
case PrivacyScreen:
@ -992,6 +1020,10 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
return i->avatarCircles();
case UseIdenticon:
return i->useIdenticon();
case OpenImageExternal:
return i->openImageExternal();
case OpenVideoExternal:
return i->openVideoExternal();
case DecryptSidebar:
return i->decryptSidebar();
case PrivacyScreen:
@ -1134,6 +1166,14 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
"Change the appearance of user avatars in chats.\nOFF - square, ON - circle.");
case UseIdenticon:
return tr("Display an identicon instead of a letter when no avatar is set.");
case OpenImageExternal:
return tr("Toggles the behavior of \"Right-Click>Open with external program\" "
"when tapping the image.\nNote that when this option is ON, opened "
"files are left unencrypted on disk and must be manually deleted.");
case OpenVideoExternal:
return tr("Toggles the behavior of \"Right-Click>Open with external program\" "
"when tapping the video.\nNote that when this option is ON, opened "
"files are left unencrypted on disk and must be manually deleted.");
case DecryptSidebar:
return tr("Decrypt the messages shown in the sidebar.\nOnly affects messages in "
"encrypted chats.");
@ -1230,6 +1270,8 @@ UserSettingsModel::data(const QModelIndex &index, int role) const
case AlertOnNotification:
case AvatarCircles:
case UseIdenticon:
case OpenImageExternal:
case OpenVideoExternal:
case DecryptSidebar:
case PrivacyScreen:
case MobileMode:
@ -1522,6 +1564,20 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
} else
return false;
}
case OpenImageExternal: {
if (value.userType() == QMetaType::Bool) {
i->setOpenImageExternal(value.toBool());
return true;
} else
return false;
}
case OpenVideoExternal: {
if (value.userType() == QMetaType::Bool) {
i->setOpenVideoExternal(value.toBool());
return true;
} else
return false;
}
case DecryptSidebar: {
if (value.userType() == QMetaType::Bool) {
i->setDecryptSidebar(value.toBool());
@ -1782,6 +1838,12 @@ UserSettingsModel::UserSettingsModel(QObject *p)
connect(s.get(), &UserSettings::useIdenticonChanged, this, [this]() {
emit dataChanged(index(UseIdenticon), index(UseIdenticon), {Value});
});
connect(s.get(), &UserSettings::openImageExternalChanged, this, [this]() {
emit dataChanged(index(OpenImageExternal), index(OpenImageExternal), {Value});
});
connect(s.get(), &UserSettings::openVideoExternalChanged, this, [this]() {
emit dataChanged(index(OpenVideoExternal), index(OpenVideoExternal), {Value});
});
connect(s.get(), &UserSettings::privacyScreenChanged, this, [this]() {
emit dataChanged(index(PrivacyScreen), index(PrivacyScreen), {Value});
emit dataChanged(index(PrivacyScreenTimeout), index(PrivacyScreenTimeout), {Enabled});

View file

@ -105,6 +105,10 @@ class UserSettings : public QObject
Q_PROPERTY(bool disableCertificateValidation READ disableCertificateValidation WRITE
setDisableCertificateValidation NOTIFY disableCertificateValidationChanged)
Q_PROPERTY(bool useIdenticon READ useIdenticon WRITE setUseIdenticon NOTIFY useIdenticonChanged)
Q_PROPERTY(bool openImageExternal READ openImageExternal WRITE setOpenImageExternal NOTIFY
openImageExternalChanged)
Q_PROPERTY(bool openVideoExternal READ openVideoExternal WRITE setOpenVideoExternal NOTIFY
openVideoExternalChanged)
Q_PROPERTY(QStringList hiddenPins READ hiddenPins WRITE setHiddenPins NOTIFY hiddenPinsChanged)
Q_PROPERTY(QStringList recentReactions READ recentReactions WRITE setRecentReactions NOTIFY
@ -184,6 +188,8 @@ public:
void setHiddenWidgets(QStringList hiddenTags);
void setRecentReactions(QStringList recent);
void setUseIdenticon(bool state);
void setOpenImageExternal(bool state);
void setOpenVideoExternal(bool state);
void setCollapsedSpaces(QList<QStringList> spaces);
QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; }
@ -246,6 +252,8 @@ public:
QStringList hiddenWidgets() const { return hiddenWidgets_; }
QStringList recentReactions() const { return recentReactions_; }
bool useIdenticon() const { return useIdenticon_ && JdenticonProvider::isAvailable(); }
bool openImageExternal() const { return openImageExternal_; }
bool openVideoExternal() const { return openVideoExternal_; }
QList<QStringList> collapsedSpaces() const { return collapsedSpaces_; }
signals:
@ -297,6 +305,8 @@ signals:
void homeserverChanged(QString homeserver);
void disableCertificateValidationChanged(bool disabled);
void useIdenticonChanged(bool state);
void openImageExternalChanged(bool state);
void openVideoExternalChanged(bool state);
void hiddenPinsChanged();
void hiddenWidgetsChanged();
void recentReactionsChanged();
@ -361,6 +371,8 @@ private:
QStringList recentReactions_;
QList<QStringList> collapsedSpaces_;
bool useIdenticon_;
bool openImageExternal_;
bool openVideoExternal_;
QSettings settings;
@ -384,6 +396,8 @@ class UserSettingsModel : public QAbstractListModel
EmojiFont,
AvatarCircles,
UseIdenticon,
OpenImageExternal,
OpenVideoExternal,
PrivacyScreen,
PrivacyScreenTimeout,