"Fossies" - the Fresh Open Source Software Archive

Member "tdesktop-2.6.1/Telegram/SourceFiles/boxes/auto_lock_box.cpp" (24 Feb 2021, 1931 Bytes) of package /linux/misc/tdesktop-2.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "auto_lock_box.cpp" see the Fossies "Dox" file reference documentation.

    1 /*
    2 This file is part of Telegram Desktop,
    3 the official desktop application for the Telegram messaging service.
    4 
    5 For license and copyright information please follow this link:
    6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
    7 */
    8 #include "boxes/auto_lock_box.h"
    9 
   10 #include "lang/lang_keys.h"
   11 #include "storage/localstorage.h"
   12 #include "core/application.h"
   13 #include "mainwindow.h"
   14 #include "ui/widgets/checkbox.h"
   15 #include "facades.h"
   16 #include "styles/style_layers.h"
   17 #include "styles/style_boxes.h"
   18 
   19 AutoLockBox::AutoLockBox(QWidget*, not_null<Main::Session*> session)
   20 : _session(session) {
   21 }
   22 
   23 void AutoLockBox::prepare() {
   24     setTitle(tr::lng_passcode_autolock());
   25 
   26     addButton(tr::lng_box_ok(), [this] { closeBox(); });
   27 
   28     auto options = { 60, 300, 3600, 18000 };
   29 
   30     auto group = std::make_shared<Ui::RadiobuttonGroup>(
   31         Core::App().settings().autoLock());
   32     auto y = st::boxOptionListPadding.top() + st::autolockButton.margin.top();
   33     auto count = int(options.size());
   34     _options.reserve(count);
   35     for (auto seconds : options) {
   36         _options.emplace_back(this, group, seconds, (seconds % 3600) ? tr::lng_passcode_autolock_minutes(tr::now, lt_count, seconds / 60) : tr::lng_passcode_autolock_hours(tr::now, lt_count, seconds / 3600), st::autolockButton);
   37         _options.back()->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), y);
   38         y += _options.back()->heightNoMargins() + st::boxOptionListSkip;
   39     }
   40     group->setChangedCallback([this](int value) { durationChanged(value); });
   41 
   42     setDimensions(st::autolockWidth, st::boxOptionListPadding.top() + count * _options.back()->heightNoMargins() + (count - 1) * st::boxOptionListSkip + st::boxOptionListPadding.bottom() + st::boxPadding.bottom());
   43 }
   44 
   45 void AutoLockBox::durationChanged(int seconds) {
   46     Core::App().settings().setAutoLock(seconds);
   47     Core::App().saveSettingsDelayed();
   48     Global::RefLocalPasscodeChanged().notify();
   49 
   50     Core::App().checkAutoLock();
   51     closeBox();
   52 }