2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Add animations enable/disable setting.

Open chats / users on mouse press if animations are disabled.
This commit is contained in:
John Preston
2018-09-20 20:56:45 +03:00
parent 04dd4e30a8
commit fd0719db6d
12 changed files with 113 additions and 41 deletions

View File

@@ -924,15 +924,14 @@ AutoDownloadBox::AutoDownloadBox(QWidget *parent)
, _audioGroups(this, lang(lng_media_auto_groups), !(cAutoDownloadAudio() & dbiadNoGroups), st::defaultBoxCheckbox)
, _gifPrivate(this, lang(lng_media_auto_private_chats), !(cAutoDownloadGif() & dbiadNoPrivate), st::defaultBoxCheckbox)
, _gifGroups(this, lang(lng_media_auto_groups), !(cAutoDownloadGif() & dbiadNoGroups), st::defaultBoxCheckbox)
, _gifPlay(this, lang(lng_media_auto_play), cAutoPlayGif(), st::defaultBoxCheckbox)
, _sectionHeight(st::boxTitleHeight + 2 * (st::defaultCheck.diameter + st::setLittleSkip)) {
}
void AutoDownloadBox::prepare() {
addButton(langFactory(lng_connection_save), [this] { onSave(); });
addButton(langFactory(lng_cancel), [this] { closeBox(); });
addButton(langFactory(lng_connection_save), [=] { save(); });
addButton(langFactory(lng_cancel), [=] { closeBox(); });
setDimensions(st::boxWidth, 3 * _sectionHeight - st::autoDownloadTopDelta + st::setLittleSkip + _gifPlay->heightNoMargins() + st::setLittleSkip);
setDimensions(st::boxWidth, 3 * _sectionHeight - st::autoDownloadTopDelta + st::setLittleSkip);
}
void AutoDownloadBox::paintEvent(QPaintEvent *e) {
@@ -959,13 +958,11 @@ void AutoDownloadBox::resizeEvent(QResizeEvent *e) {
_gifPrivate->moveToLeft(st::boxTitlePosition.x(), 2 * _sectionHeight + top + st::setLittleSkip);
_gifGroups->moveToLeft(st::boxTitlePosition.x(), _gifPrivate->bottomNoMargins() + st::setLittleSkip);
_gifPlay->moveToLeft(st::boxTitlePosition.x(), _gifGroups->bottomNoMargins() + st::setLittleSkip);
}
void AutoDownloadBox::onSave() {
void AutoDownloadBox::save() {
auto photosChanged = false;
auto documentsChanged = false;
auto autoplayChanged = false;
auto photosEnabled = false;
auto voiceEnabled = false;
auto animationsEnabled = false;
@@ -1002,14 +999,7 @@ void AutoDownloadBox::onSave() {
documentsChanged = true;
cSetAutoDownloadGif(autoDownloadGif);
}
if (cAutoPlayGif() != _gifPlay->checked()) {
cSetAutoPlayGif(_gifPlay->checked());
if (!cAutoPlayGif()) {
Auth().data().stopAutoplayAnimations();
}
autoplayChanged = true;
}
if (photosChanged || documentsChanged || autoplayChanged) {
if (photosChanged || documentsChanged) {
Local::writeUserSettings();
}
if (photosEnabled) {

View File

@@ -23,8 +23,6 @@ class Radioenum;
} // namespace Ui
class AutoDownloadBox : public BoxContent {
Q_OBJECT
public:
AutoDownloadBox(QWidget *parent);
@@ -34,17 +32,15 @@ protected:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
private slots:
void onSave();
private:
void save();
object_ptr<Ui::Checkbox> _photoPrivate;
object_ptr<Ui::Checkbox> _photoGroups;
object_ptr<Ui::Checkbox> _audioPrivate;
object_ptr<Ui::Checkbox> _audioGroups;
object_ptr<Ui::Checkbox> _gifPrivate;
object_ptr<Ui::Checkbox> _gifGroups;
object_ptr<Ui::Checkbox> _gifPlay;
int _sectionHeight = 0;

View File

@@ -982,6 +982,9 @@ void PeerListContent::mousePressEvent(QMouseEvent *e) {
row->addRipple(_st.item, size, point, std::move(updateCallback));
}
}
if (anim::Disabled()) {
mousePressReleased(e->button());
}
}
void PeerListContent::mouseReleaseEvent(QMouseEvent *e) {