void TrayIcon::showMessage(const Data::DlgState& state) { #if defined (_WIN32) if (toastSupported()) { ToastManager_->DisplayToastMessage(state.AimId_, state.GetText()); return; } #elif defined (__APPLE__) if (ncSupported()) { NotificationCenterManager_->DisplayNotification(state.AimId_, state.GetText()); return; } #endif //_WIN32 MessageAlert_->addAlert(state); TrayPosition pos = getTrayPosition(); QRect availableGeometry = QDesktopWidget().availableGeometry(); int screenMargin = Utils::scale_value(20) - Ui::get_gui_settings()->get_shadow_width(); switch (pos) { case Ui::TOP_RIGHT: MessageAlert_->move(availableGeometry.topRight().x() - MessageAlert_->width() - screenMargin, availableGeometry.topRight().y() + screenMargin); break; case Ui::BOTTOM_LEFT: MessageAlert_->move(availableGeometry.bottomLeft().x() + screenMargin, availableGeometry.bottomLeft().y() - MessageAlert_->height() - screenMargin); break; case Ui::BOTOOM_RIGHT: MessageAlert_->move(availableGeometry.bottomRight().x() - MessageAlert_->width() - screenMargin, availableGeometry.bottomRight().y() - MessageAlert_->height() - screenMargin); break; case Ui::TOP_LEFT: default: MessageAlert_->move(availableGeometry.topLeft().x() + screenMargin, availableGeometry.topLeft().y() + screenMargin); break; } MessageAlert_->show(); }
void UnknownItemDelegate::paint(QPainter* _painter, const QStyleOptionViewItem& _option, const Data::DlgState& _dlg, bool _fromAlert, bool _dragOverlay) const { if (_dlg.AimId_ == ql1s("~delete_all~")) { _painter->save(); _painter->setRenderHint(QPainter::Antialiasing); _painter->setRenderHint(QPainter::TextAntialiasing); _painter->setRenderHint(QPainter::SmoothPixmapTransform); _painter->translate(_option.rect.topLeft()); const bool hasMouseOver = (platform::is_apple() ? Logic::getUnknownsModel()->customFlagIsSet(Logic::CustomAbstractListModelFlags::HasMouseOver) : true); const bool isSelected_ = (_option.state & QStyle::State_Selected) && !stateBlocked_; const bool isHovered_ = (_option.state & QStyle::State_MouseOver) && !stateBlocked_ && !isSelected_ && hasMouseOver; ContactList::RenderDeleteAllItem(* _painter, QT_TRANSLATE_NOOP("contact_list", "Close All"), isHovered_, viewParams_); _painter->restore(); return; } const auto isMultichat = Logic::getContactListModel()->isChat(_dlg.AimId_); const auto state = isMultichat ? QString() : Logic::getContactListModel()->getState(_dlg.AimId_); bool isDefault = false; const auto avatar = *GetAvatarStorage()->GetRounded( _dlg.AimId_, QString(), Utils::scale_bitmap(ContactList::GetRecentsParams(viewParams_.regim_).getAvatarSize()), state, isDefault, false, ContactList::GetRecentsParams(viewParams_.regim_).isCL() ); const bool hasMouseOver = (platform::is_apple() ? Logic::getUnknownsModel()->customFlagIsSet(Logic::CustomAbstractListModelFlags::HasMouseOver) : true); const bool isSelected_ = (_option.state & QStyle::State_Selected) && !stateBlocked_; const bool isHovered_ = (_option.state & QStyle::State_MouseOver) && !stateBlocked_ && !isSelected_ && hasMouseOver; const auto displayName = Logic::getContactListModel()->getDisplayName(_dlg.AimId_); auto message = _dlg.GetText(); bool isOfficial = _dlg.Official_ || Logic::getContactListModel()->isOfficial(_dlg.AimId_); bool isDrawLastRead = false; QPixmap lastReadAvatar; bool isOutgoing = _dlg.Outgoing_; bool isLastRead = (_dlg.LastMsgId_ >= 0 && _dlg.TheirsLastRead_ > 0 && _dlg.LastMsgId_ <= _dlg.TheirsLastRead_); if (!isMultichat && isOutgoing && isLastRead && !Logic::GetMessagesModel()->hasPending(_dlg.AimId_)) { lastReadAvatar = *GetAvatarStorage()->GetRounded( _dlg.AimId_, QString(), Utils::scale_bitmap(ContactList::GetRecentsParams(viewParams_.regim_).getLastReadAvatarSize()), QString(), isDefault, false, ContactList::GetRecentsParams(viewParams_.regim_).isCL()); isDrawLastRead = true; } ContactList::RecentItemVisualData visData( _dlg.AimId_, avatar, state, message, isHovered_, isSelected_, displayName.isEmpty() ? _dlg.AimId_ : displayName, true /* hasLastSeen */, QDateTime::fromTime_t(_dlg.Time_), (int)_dlg.UnreadCount_, Logic::getContactListModel()->isMuted(_dlg.AimId_), _dlg.senderNick_, isOfficial, isDrawLastRead, lastReadAvatar, false /* isTyping */); _painter->save(); _painter->setRenderHint(QPainter::Antialiasing); _painter->setRenderHint(QPainter::TextAntialiasing); _painter->setRenderHint(QPainter::SmoothPixmapTransform); _painter->translate(_option.rect.topLeft()); ContactList::RenderRecentsItem(*_painter, visData, viewParams_, _option.rect); if (_dragOverlay) ContactList::RenderRecentsDragOverlay(*_painter, viewParams_); _painter->restore(); }