summary refs log tree commit diff
path: root/src/ChatPage.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-10-07 20:09:34 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-10-07 20:51:35 +0300
commitbc4b47a5e30386df46f5d4d51a5be33b6a9d4c2f (patch)
tree42bd697afd1b4ce3d7b88bfefe11aa71dbdafae7 /src/ChatPage.cc
parentUpdate from Weblate. (#38) (diff)
downloadnheko-bc4b47a5e30386df46f5d4d51a5be33b6a9d4c2f.tar.xz
Use shared pointer for the modals
Diffstat (limited to 'src/ChatPage.cc')
-rw-r--r--src/ChatPage.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/ChatPage.cc b/src/ChatPage.cc

index 0800fe32..dbffc6d0 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc
@@ -572,21 +572,26 @@ ChatPage::keyPressEvent(QKeyEvent *event) void ChatPage::showQuickSwitcher() { - if (quickSwitcher_ == nullptr) { - quickSwitcher_ = new QuickSwitcher(this); + if (quickSwitcher_.isNull()) { + quickSwitcher_ = QSharedPointer<QuickSwitcher>( + new QuickSwitcher(this), + [=](QuickSwitcher *switcher) { switcher->deleteLater(); }); - connect(quickSwitcher_, + connect(quickSwitcher_.data(), &QuickSwitcher::roomSelected, room_list_, &RoomList::highlightSelectedRoom); - connect(quickSwitcher_, &QuickSwitcher::closing, this, [=]() { - if (this->quickSwitcherModal_ != nullptr) + + connect(quickSwitcher_.data(), &QuickSwitcher::closing, this, [=]() { + if (!this->quickSwitcherModal_.isNull()) this->quickSwitcherModal_->fadeOut(); }); } - if (quickSwitcherModal_ == nullptr) { - quickSwitcherModal_ = new OverlayModal(MainWindow::instance(), quickSwitcher_); + if (quickSwitcherModal_.isNull()) { + quickSwitcherModal_ = QSharedPointer<OverlayModal>( + new OverlayModal(MainWindow::instance(), quickSwitcher_.data()), + [=](OverlayModal *modal) { modal->deleteLater(); }); quickSwitcherModal_->setDuration(0); quickSwitcherModal_->setColor(QColor(30, 30, 30, 170)); }