-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes: #3153 Signed-off-by: Nicholas Guriev <[email protected]> (github: mymedia2)
- Loading branch information
Showing
7 changed files
with
124 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* This file is part of Telegram Desktop, the official desktop version of | ||
* Telegram messaging app, see https://desktop.telegram.org | ||
* | ||
* This code is in Public Domain, see license terms in .github/CONTRIBUTING.md | ||
* Copyright (C) 2017, Nicholas Guriev <[email protected]> | ||
*/ | ||
|
||
#include "boxes/mute_settings_box.h" | ||
|
||
#include "lang/lang_keys.h" | ||
#include "mainwidget.h" | ||
#include "styles/style_boxes.h" | ||
#include "ui/special_buttons.h" | ||
#include "ui/widgets/checkbox.h" | ||
#include "ui/widgets/labels.h" | ||
|
||
void MuteSettingsBox::prepare() { | ||
setTitle(langFactory(lng_disable_notifications_from_tray)); | ||
int y = 0; | ||
|
||
object_ptr<Ui::FlatLabel> info(this, st::boxLabel); | ||
info->setText(lang(lng_mute_box_tip)); | ||
info->moveToLeft(st::boxPadding.left(), y); | ||
y += info->height() + st::boxLittleSkip; | ||
|
||
object_ptr<Ui::PeerAvatarButton> icon(this, _peer, st::mutePhotoButton); | ||
icon->setPointerCursor(false); | ||
icon->moveToLeft(st::boxPadding.left(), y); | ||
|
||
object_ptr<Ui::FlatLabel> title(this, st::muteChatTitle); | ||
title->setText(App::peerName(_peer, true)); | ||
title->moveToLeft(st::boxPadding.left(), | ||
y + icon->height() / 2 - title->height() / 2); | ||
// the icon is always higher than this chat title | ||
y += icon->height() + st::boxMediumSkip; | ||
|
||
const int FOREVER = 8760; // in fact, this is mute only for 1 year | ||
auto group = std::make_shared<Ui::RadiobuttonGroup>(FOREVER); | ||
y += st::boxOptionListPadding.top(); | ||
for (int value : { 1, 4, 18, 72, FOREVER }) { // periods in hours | ||
QString text; | ||
if (value < 24) { | ||
text = lng_mute_duration_hours(lt_count, value); | ||
} else if (value < FOREVER) { | ||
text = lng_rights_chat_banned_day(lt_count, value / 24); | ||
} else { | ||
text = lang(lng_rights_chat_banned_forever); | ||
} | ||
object_ptr<Ui::Radiobutton> option(this, group, value, text); | ||
option->moveToLeft(st::boxPadding.left(), y); | ||
y += option->heightNoMargins() + st::boxOptionListSkip; | ||
} | ||
y += st::boxOptionListPadding.bottom() - st::boxOptionListSkip; | ||
|
||
addButton(langFactory(lng_box_ok), [this, group] { | ||
App::main()->updateNotifySetting(_peer, NotifySettingSetMuted, | ||
SilentNotifiesDontChange, group->value() * 3600); | ||
closeBox(); | ||
}); | ||
addButton(langFactory(lng_cancel), [this] { closeBox(); }); | ||
|
||
setDimensions(st::boxWidth, y); | ||
} | ||
// vi: ts=4 tw=80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* This file is part of Telegram Desktop, the official desktop version of | ||
* Telegram messaging app, see https://desktop.telegram.org | ||
* | ||
* This code is in Public Domain, see license terms in .github/CONTRIBUTING.md | ||
* Copyright (C) 2017, Nicholas Guriev <[email protected]> | ||
*/ | ||
#pragma once | ||
|
||
#include "boxes/abstract_box.h" | ||
|
||
/* This class implements a dialog-box with radio-buttons for pick duration of | ||
* turning off notifications from a chat. The widget is opened by a context menu | ||
* in the left list of dialogues. */ | ||
class MuteSettingsBox : public BoxContent { | ||
Q_OBJECT | ||
|
||
public: | ||
MuteSettingsBox(QWidget *parent, gsl::not_null<PeerData*> peer) | ||
: _peer(peer) { | ||
} | ||
|
||
protected: | ||
void prepare() override; | ||
|
||
private: | ||
gsl::not_null<PeerData*> _peer; | ||
}; | ||
// vi: ts=4 tw=80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters