mainwindow.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "mainwindow.h"
  8. #include "data/data_document.h"
  9. #include "data/data_session.h"
  10. #include "data/data_document_media.h"
  11. #include "dialogs/ui/dialogs_layout.h"
  12. #include "history/history.h"
  13. #include "ui/widgets/popup_menu.h"
  14. #include "ui/widgets/buttons.h"
  15. #include "ui/widgets/shadow.h"
  16. #include "ui/widgets/tooltip.h"
  17. #include "ui/emoji_config.h"
  18. #include "ui/ui_utility.h"
  19. #include "lang/lang_cloud_manager.h"
  20. #include "lang/lang_instance.h"
  21. #include "core/sandbox.h"
  22. #include "core/application.h"
  23. #include "export/export_manager.h"
  24. #include "inline_bots/bot_attach_web_view.h" // AttachWebView::cancel.
  25. #include "intro/intro_widget.h"
  26. #include "main/main_session.h"
  27. #include "main/main_account.h" // Account::sessionValue.
  28. #include "main/main_domain.h"
  29. #include "mainwidget.h"
  30. #include "ui/boxes/confirm_box.h"
  31. #include "boxes/connection_box.h"
  32. #include "storage/storage_account.h"
  33. #include "storage/localstorage.h"
  34. #include "apiwrap.h"
  35. #include "api/api_updates.h"
  36. #include "settings/settings_intro.h"
  37. #include "base/options.h"
  38. #include "window/notifications_manager.h"
  39. #include "window/themes/window_theme.h"
  40. #include "window/themes/window_theme_warning.h"
  41. #include "window/window_main_menu.h"
  42. #include "window/window_controller.h" // App::wnd.
  43. #include "window/window_session_controller.h"
  44. #include "window/window_media_preview.h"
  45. #include "styles/style_dialogs.h"
  46. #include "styles/style_layers.h"
  47. #include "styles/style_window.h"
  48. #include <QtGui/QWindow>
  49. namespace {
  50. // Code for testing languages is F7-F6-F7-F8
  51. void FeedLangTestingKey(int key) {
  52. static auto codeState = 0;
  53. if ((codeState == 0 && key == Qt::Key_F7)
  54. || (codeState == 1 && key == Qt::Key_F6)
  55. || (codeState == 2 && key == Qt::Key_F7)
  56. || (codeState == 3 && key == Qt::Key_F8)) {
  57. ++codeState;
  58. } else {
  59. codeState = 0;
  60. }
  61. if (codeState == 4) {
  62. codeState = 0;
  63. Lang::CurrentCloudManager().switchToTestLanguage();
  64. }
  65. }
  66. base::options::toggle AutoScrollInactiveChat({
  67. .id = kOptionAutoScrollInactiveChat,
  68. .name = "Mark as read of inactive chat",
  69. .description = "Mark new messages as read and scroll the chat "
  70. "even when the window is not in focus.",
  71. });
  72. } // namespace
  73. const char kOptionAutoScrollInactiveChat[]
  74. = "auto-scroll-inactive-chat";
  75. MainWindow::MainWindow(not_null<Window::Controller*> controller)
  76. : Platform::MainWindow(controller) {
  77. resize(st::windowDefaultWidth, st::windowDefaultHeight);
  78. setLocale(QLocale(QLocale::English, QLocale::UnitedStates));
  79. using Window::Theme::BackgroundUpdate;
  80. Window::Theme::Background()->updates(
  81. ) | rpl::start_with_next([=](const BackgroundUpdate &data) {
  82. themeUpdated(data);
  83. }, lifetime());
  84. Core::App().passcodeLockChanges(
  85. ) | rpl::start_with_next([=] {
  86. updateGlobalMenu();
  87. }, lifetime());
  88. Ui::Emoji::Updated(
  89. ) | rpl::start_with_next([=] {
  90. Ui::ForceFullRepaint(this);
  91. }, lifetime());
  92. setAttribute(Qt::WA_OpaquePaintEvent);
  93. }
  94. void MainWindow::initHook() {
  95. Platform::MainWindow::initHook();
  96. QCoreApplication::instance()->installEventFilter(this);
  97. }
  98. void MainWindow::applyInitialWorkMode() {
  99. const auto workMode = Core::App().settings().workMode();
  100. workmodeUpdated(workMode);
  101. if (controller().isPrimary()) {
  102. if (Core::App().settings().windowPosition().maximized) {
  103. DEBUG_LOG(("Window Pos: First show, setting maximized."));
  104. setWindowState(Qt::WindowMaximized);
  105. }
  106. if (cStartInTray()
  107. || (cLaunchMode() == LaunchModeAutoStart
  108. && cStartMinimized()
  109. && !Core::App().passcodeLocked())) {
  110. DEBUG_LOG(("Window Pos: First show, setting minimized after."));
  111. if (workMode == Core::Settings::WorkMode::TrayOnly
  112. || workMode == Core::Settings::WorkMode::WindowAndTray) {
  113. hide();
  114. } else {
  115. setWindowState(windowState() | Qt::WindowMinimized);
  116. }
  117. }
  118. }
  119. setPositionInited();
  120. }
  121. void MainWindow::finishFirstShow() {
  122. applyInitialWorkMode();
  123. createGlobalMenu();
  124. windowActiveValue(
  125. ) | rpl::skip(1) | rpl::filter(
  126. !rpl::mappers::_1
  127. ) | rpl::start_with_next([=] {
  128. Ui::Tooltip::Hide();
  129. }, lifetime());
  130. setAttribute(Qt::WA_NoSystemBackground);
  131. if (!_passcodeLock && _main) {
  132. _main->activate();
  133. }
  134. }
  135. void MainWindow::clearWidgetsHook() {
  136. _mediaPreview.destroy();
  137. _main.destroy();
  138. _intro.destroy();
  139. if (!Core::App().passcodeLocked()) {
  140. _passcodeLock.destroy();
  141. }
  142. }
  143. QPixmap MainWindow::grabForSlideAnimation() {
  144. return Ui::GrabWidget(bodyWidget());
  145. }
  146. void MainWindow::preventOrInvoke(Fn<void()> callback) {
  147. if (_main && _main->preventsCloseSection(callback)) {
  148. return;
  149. }
  150. callback();
  151. }
  152. void MainWindow::setupPasscodeLock() {
  153. auto animated = (_main || _intro);
  154. auto oldContentCache = animated ? grabForSlideAnimation() : QPixmap();
  155. _passcodeLock.create(bodyWidget(), &controller());
  156. updateControlsGeometry();
  157. ui_hideSettingsAndLayer(anim::type::instant);
  158. if (_main) {
  159. _main->hide();
  160. }
  161. if (_intro) {
  162. _intro->hide();
  163. }
  164. if (animated) {
  165. _passcodeLock->showAnimated(std::move(oldContentCache));
  166. } else {
  167. _passcodeLock->showFinished();
  168. setInnerFocus();
  169. }
  170. if (const auto sessionController = controller().sessionController()) {
  171. sessionController->session().attachWebView().closeAll();
  172. }
  173. }
  174. void MainWindow::clearPasscodeLock() {
  175. Expects(_intro || _main);
  176. if (!_passcodeLock) {
  177. return;
  178. }
  179. auto oldContentCache = grabForSlideAnimation();
  180. _passcodeLock.destroy();
  181. if (_intro) {
  182. _intro->show();
  183. updateControlsGeometry();
  184. _intro->showAnimated(std::move(oldContentCache), true);
  185. } else if (_main) {
  186. _main->show();
  187. updateControlsGeometry();
  188. _main->showAnimated(std::move(oldContentCache), true);
  189. Core::App().checkStartUrl();
  190. }
  191. }
  192. void MainWindow::setupIntro(
  193. Intro::EnterPoint point,
  194. QPixmap oldContentCache) {
  195. auto animated = (_main || _passcodeLock);
  196. destroyLayer();
  197. auto created = object_ptr<Intro::Widget>(
  198. bodyWidget(),
  199. &controller(),
  200. &account(),
  201. point);
  202. created->showSettingsRequested(
  203. ) | rpl::start_with_next([=] {
  204. showSettings();
  205. }, created->lifetime());
  206. clearWidgets();
  207. _intro = std::move(created);
  208. if (_passcodeLock) {
  209. _intro->hide();
  210. } else {
  211. _intro->show();
  212. updateControlsGeometry();
  213. if (animated) {
  214. _intro->showAnimated(std::move(oldContentCache));
  215. } else {
  216. setInnerFocus();
  217. }
  218. }
  219. fixOrder();
  220. }
  221. void MainWindow::setupMain(
  222. MsgId singlePeerShowAtMsgId,
  223. QPixmap oldContentCache) {
  224. Expects(account().sessionExists());
  225. const auto animated = _intro
  226. || (_passcodeLock && !Core::App().passcodeLocked());
  227. const auto weakAnimatedLayer = (_main && _layer && !_passcodeLock)
  228. ? Ui::MakeWeak(_layer.get())
  229. : nullptr;
  230. if (weakAnimatedLayer) {
  231. Assert(!animated);
  232. _layer->hideAllAnimatedPrepare();
  233. } else {
  234. destroyLayer();
  235. }
  236. auto created = object_ptr<MainWidget>(bodyWidget(), sessionController());
  237. clearWidgets();
  238. _main = std::move(created);
  239. updateControlsGeometry();
  240. Ui::SendPendingMoveResizeEvents(_main);
  241. _main->controller()->showByInitialId(
  242. Window::SectionShow::Way::ClearStack,
  243. singlePeerShowAtMsgId);
  244. if (_passcodeLock) {
  245. _main->hide();
  246. } else {
  247. _main->show();
  248. updateControlsGeometry();
  249. if (animated) {
  250. _main->showAnimated(std::move(oldContentCache));
  251. } else {
  252. _main->activate();
  253. }
  254. Core::App().checkStartUrl();
  255. }
  256. fixOrder();
  257. if (const auto strong = weakAnimatedLayer.data()) {
  258. strong->hideAllAnimatedRun();
  259. }
  260. }
  261. void MainWindow::showSettings() {
  262. if (_passcodeLock) {
  263. return;
  264. }
  265. if (const auto session = sessionController()) {
  266. session->showSettings();
  267. } else {
  268. showSpecialLayer(
  269. Box<Settings::LayerWidget>(&controller()),
  270. anim::type::normal);
  271. }
  272. }
  273. void MainWindow::showSpecialLayer(
  274. object_ptr<Ui::LayerWidget> layer,
  275. anim::type animated) {
  276. if (_passcodeLock) {
  277. return;
  278. }
  279. if (layer) {
  280. ensureLayerCreated();
  281. _layer->showSpecialLayer(std::move(layer), animated);
  282. } else if (_layer) {
  283. _layer->hideSpecialLayer(animated);
  284. }
  285. }
  286. bool MainWindow::showSectionInExistingLayer(
  287. not_null<Window::SectionMemento*> memento,
  288. const Window::SectionShow &params) {
  289. if (_layer) {
  290. return _layer->showSectionInternal(memento, params);
  291. }
  292. return false;
  293. }
  294. void MainWindow::showMainMenu() {
  295. if (_passcodeLock) return;
  296. if (isHidden()) showFromTray();
  297. ensureLayerCreated();
  298. _layer->showMainMenu(
  299. object_ptr<Window::MainMenu>(body(), sessionController()),
  300. anim::type::normal);
  301. }
  302. void MainWindow::ensureLayerCreated() {
  303. if (_layer) {
  304. return;
  305. }
  306. _layer = base::make_unique_q<Ui::LayerStackWidget>(
  307. bodyWidget(),
  308. crl::guard(this, [=] { return controller().uiShow(); }));
  309. _layer->hideFinishEvents(
  310. ) | rpl::filter([=] {
  311. return _layer != nullptr; // Last hide finish is sent from destructor.
  312. }) | rpl::start_with_next([=] {
  313. destroyLayer();
  314. }, _layer->lifetime());
  315. if (const auto controller = sessionController()) {
  316. controller->enableGifPauseReason(Window::GifPauseReason::Layer);
  317. }
  318. }
  319. void MainWindow::destroyLayer() {
  320. if (!_layer) {
  321. return;
  322. }
  323. auto layer = base::take(_layer);
  324. const auto resetFocus = Ui::InFocusChain(layer);
  325. if (resetFocus) {
  326. setFocus();
  327. }
  328. layer = nullptr;
  329. if (const auto controller = sessionController()) {
  330. controller->disableGifPauseReason(Window::GifPauseReason::Layer);
  331. }
  332. if (resetFocus) {
  333. setInnerFocus();
  334. }
  335. InvokeQueued(this, [=] {
  336. checkActivation();
  337. });
  338. }
  339. void MainWindow::ui_hideSettingsAndLayer(anim::type animated) {
  340. if (animated == anim::type::instant) {
  341. destroyLayer();
  342. } else if (_layer) {
  343. _layer->hideAll(animated);
  344. }
  345. }
  346. void MainWindow::ui_removeLayerBlackout() {
  347. if (_layer) {
  348. _layer->removeBodyCache();
  349. }
  350. }
  351. MainWidget *MainWindow::sessionContent() const {
  352. return _main.data();
  353. }
  354. void MainWindow::showOrHideBoxOrLayer(
  355. std::variant<
  356. v::null_t,
  357. object_ptr<Ui::BoxContent>,
  358. std::unique_ptr<Ui::LayerWidget>> &&layer,
  359. Ui::LayerOptions options,
  360. anim::type animated) {
  361. using UniqueLayer = std::unique_ptr<Ui::LayerWidget>;
  362. using ObjectBox = object_ptr<Ui::BoxContent>;
  363. if (auto layerWidget = std::get_if<UniqueLayer>(&layer)) {
  364. ensureLayerCreated();
  365. _layer->showLayer(std::move(*layerWidget), options, animated);
  366. } else if (auto box = std::get_if<ObjectBox>(&layer)) {
  367. ensureLayerCreated();
  368. _layer->showBox(std::move(*box), options, animated);
  369. } else {
  370. if (_layer) {
  371. _layer->hideTopLayer(animated);
  372. if ((animated == anim::type::instant)
  373. && _layer
  374. && !_layer->layerShown()) {
  375. destroyLayer();
  376. }
  377. }
  378. Core::App().hideMediaView();
  379. }
  380. }
  381. bool MainWindow::ui_isLayerShown() const {
  382. return _layer != nullptr;
  383. }
  384. bool MainWindow::showMediaPreview(
  385. Data::FileOrigin origin,
  386. not_null<DocumentData*> document) {
  387. const auto media = document->activeMediaView();
  388. const auto preview = Data::VideoPreviewState(media.get());
  389. if (!document->sticker()
  390. && (!document->isAnimation() || !preview.loaded())) {
  391. return false;
  392. }
  393. if (!_mediaPreview) {
  394. _mediaPreview.create(bodyWidget(), sessionController());
  395. updateControlsGeometry();
  396. }
  397. if (_mediaPreview->isHidden()) {
  398. fixOrder();
  399. }
  400. _mediaPreview->showPreview(origin, document);
  401. return true;
  402. }
  403. bool MainWindow::showMediaPreview(
  404. Data::FileOrigin origin,
  405. not_null<PhotoData*> photo) {
  406. if (!_mediaPreview) {
  407. _mediaPreview.create(bodyWidget(), sessionController());
  408. updateControlsGeometry();
  409. }
  410. if (_mediaPreview->isHidden()) {
  411. fixOrder();
  412. }
  413. _mediaPreview->showPreview(origin, photo);
  414. return true;
  415. }
  416. void MainWindow::hideMediaPreview() {
  417. if (!_mediaPreview) {
  418. return;
  419. }
  420. _mediaPreview->hidePreview();
  421. }
  422. void MainWindow::themeUpdated(const Window::Theme::BackgroundUpdate &data) {
  423. using Type = Window::Theme::BackgroundUpdate::Type;
  424. // We delay animating theme warning because we want all other
  425. // subscribers to receive palette changed notification before any
  426. // animations (that include pixmap caches with old palette values).
  427. if (data.type == Type::TestingTheme) {
  428. if (!_testingThemeWarning) {
  429. _testingThemeWarning.create(bodyWidget());
  430. _testingThemeWarning->hide();
  431. _testingThemeWarning->setGeometry(rect());
  432. _testingThemeWarning->setHiddenCallback([this] { _testingThemeWarning.destroyDelayed(); });
  433. }
  434. crl::on_main(this, [=] {
  435. if (_testingThemeWarning) {
  436. _testingThemeWarning->showAnimated();
  437. }
  438. });
  439. } else if (data.type == Type::RevertingTheme || data.type == Type::ApplyingTheme) {
  440. if (_testingThemeWarning) {
  441. if (_testingThemeWarning->isHidden()) {
  442. _testingThemeWarning.destroy();
  443. } else {
  444. crl::on_main(this, [=] {
  445. if (_testingThemeWarning) {
  446. _testingThemeWarning->hideAnimated();
  447. _testingThemeWarning = nullptr;
  448. }
  449. setInnerFocus();
  450. });
  451. }
  452. }
  453. }
  454. }
  455. bool MainWindow::markingAsRead() const {
  456. return _main
  457. && !_main->isHidden()
  458. && !_main->animatingShow()
  459. && !_layer
  460. && !isHidden()
  461. && !isMinimized()
  462. && windowHandle()->isExposed()
  463. && (AutoScrollInactiveChat.value()
  464. || (isActive() && !_main->session().updates().isIdle()));
  465. }
  466. void MainWindow::checkActivation() {
  467. updateIsActive();
  468. if (_main) {
  469. _main->checkActivation();
  470. }
  471. }
  472. bool MainWindow::contentOverlapped(const QRect &globalRect) {
  473. return (_main && _main->contentOverlapped(globalRect))
  474. || (_layer && _layer->contentOverlapped(globalRect));
  475. }
  476. void MainWindow::setInnerFocus() {
  477. if (_testingThemeWarning) {
  478. _testingThemeWarning->setFocus();
  479. } else if (_layer && _layer->canSetFocus()) {
  480. _layer->setInnerFocus();
  481. } else if (_passcodeLock) {
  482. _passcodeLock->setInnerFocus();
  483. } else if (_main) {
  484. _main->setInnerFocus();
  485. } else if (_intro) {
  486. _intro->setInnerFocus();
  487. }
  488. }
  489. bool MainWindow::eventFilter(QObject *object, QEvent *e) {
  490. switch (e->type()) {
  491. case QEvent::KeyPress: {
  492. if (Logs::DebugEnabled()
  493. && object == windowHandle()) {
  494. const auto key = static_cast<QKeyEvent*>(e)->key();
  495. FeedLangTestingKey(key);
  496. }
  497. #ifdef _DEBUG
  498. if (static_cast<QKeyEvent*>(e)->modifiers().testFlag(
  499. Qt::ControlModifier)) {
  500. switch (static_cast<QKeyEvent*>(e)->key()) {
  501. case Qt::Key_F11:
  502. anim::SetSlowMultiplier((anim::SlowMultiplier() == 10)
  503. ? 1
  504. : 10);
  505. return true;
  506. case Qt::Key_F12:
  507. anim::SetSlowMultiplier((anim::SlowMultiplier() == 50)
  508. ? 1
  509. : 50);
  510. return true;
  511. }
  512. }
  513. #endif
  514. } break;
  515. case QEvent::MouseMove: {
  516. const auto position = static_cast<QMouseEvent*>(e)->globalPos();
  517. if (_lastMousePosition != position) {
  518. if (const auto controller = sessionController()) {
  519. if (controller->session().updates().isIdle()) {
  520. Core::App().updateNonIdle();
  521. }
  522. }
  523. }
  524. _lastMousePosition = position;
  525. } break;
  526. case QEvent::MouseButtonRelease: {
  527. hideMediaPreview();
  528. } break;
  529. case QEvent::ApplicationActivate: {
  530. if (object == QCoreApplication::instance()) {
  531. InvokeQueued(this, [=] {
  532. handleActiveChanged(isActiveWindow());
  533. });
  534. }
  535. } break;
  536. case QEvent::WindowStateChange: {
  537. if (object == this) {
  538. auto state = (windowState() & Qt::WindowMinimized) ? Qt::WindowMinimized :
  539. ((windowState() & Qt::WindowMaximized) ? Qt::WindowMaximized :
  540. ((windowState() & Qt::WindowFullScreen) ? Qt::WindowFullScreen : Qt::WindowNoState));
  541. handleStateChanged(state);
  542. }
  543. } break;
  544. case QEvent::Move:
  545. case QEvent::Resize: {
  546. if (object == this) {
  547. positionUpdated();
  548. }
  549. } break;
  550. }
  551. return Platform::MainWindow::eventFilter(object, e);
  552. }
  553. bool MainWindow::takeThirdSectionFromLayer() {
  554. return _layer ? _layer->takeToThirdSection() : false;
  555. }
  556. void MainWindow::fixOrder() {
  557. if (_passcodeLock) _passcodeLock->raise();
  558. if (_layer) _layer->raise();
  559. if (_mediaPreview) _mediaPreview->raise();
  560. if (_testingThemeWarning) _testingThemeWarning->raise();
  561. }
  562. void MainWindow::closeEvent(QCloseEvent *e) {
  563. if (Core::Sandbox::Instance().isSavingSession() || Core::Quitting()) {
  564. e->accept();
  565. Core::Quit();
  566. return;
  567. } else if (Core::App().closeNonLastAsync(&controller())) {
  568. e->accept();
  569. return;
  570. }
  571. e->ignore();
  572. const auto hasAuth = [&] {
  573. if (!Core::App().domain().started()) {
  574. return false;
  575. }
  576. for (const auto &[_, account] : Core::App().domain().accounts()) {
  577. if (account->sessionExists()) {
  578. return true;
  579. }
  580. }
  581. return false;
  582. }();
  583. if (!hasAuth || !hideNoQuit()) {
  584. Core::Quit();
  585. }
  586. }
  587. void MainWindow::updateControlsGeometry() {
  588. Platform::MainWindow::updateControlsGeometry();
  589. auto body = bodyWidget()->rect();
  590. if (_passcodeLock) _passcodeLock->setGeometry(body);
  591. auto mainLeft = 0;
  592. auto mainWidth = body.width();
  593. if (const auto session = sessionController()) {
  594. if (const auto skip = session->filtersWidth()) {
  595. mainLeft += skip;
  596. mainWidth -= skip;
  597. }
  598. }
  599. if (_main) {
  600. _main->setGeometry({
  601. body.x() + mainLeft,
  602. body.y(),
  603. mainWidth,
  604. body.height() });
  605. }
  606. if (_intro) _intro->setGeometry(body);
  607. if (_layer) _layer->setGeometry(body);
  608. if (_mediaPreview) _mediaPreview->setGeometry(body);
  609. if (_testingThemeWarning) _testingThemeWarning->setGeometry(body);
  610. if (_main) _main->checkMainSectionToLayer();
  611. }
  612. void MainWindow::sendPaths() {
  613. if (controller().locked()) {
  614. return;
  615. }
  616. Core::App().hideMediaView();
  617. ui_hideSettingsAndLayer(anim::type::instant);
  618. if (_main) {
  619. _main->activate();
  620. }
  621. }
  622. MainWindow::~MainWindow() = default;