diff --git a/QTCREATOR.md b/QTCREATOR.md index 8f608204d..dbdf70585 100644 --- a/QTCREATOR.md +++ b/QTCREATOR.md @@ -110,7 +110,7 @@ Install some packages for Qt (see **/home/user/TBuild/Libraries/QtStatic/qtbase/ In Terminal go to **/home/user/TBuild/Libraries/QtStatic** and there run - ./configure -release -opensource -confirm-license -qt-xcb -no-opengl -static -nomake examples -nomake tests + ./configure -release -opensource -confirm-license -qt-zlib -qt-libpng -qt-libjpeg -qt-freetype -qt-harfbuzz -qt-pcre -qt-xcb -qt-xkbcommon-x11 -no-opengl -static -nomake examples -nomake tests make -j4 sudo make -j4 install diff --git a/Telegram/FixMake.sh b/Telegram/FixMake.sh index da1e041c0..77a933e1a 100755 --- a/Telegram/FixMake.sh +++ b/Telegram/FixMake.sh @@ -21,7 +21,6 @@ Replace '\-lSM' '\/usr\/lib\/x86_64\-linux\-gnu\/libSM\.a' Replace '\-lICE' '\/usr\/lib\/x86_64\-linux\-gnu\/libICE\.a' Replace '\-lfontconfig' '\/usr\/lib\/x86_64\-linux\-gnu\/libfontconfig\.a \/usr\/lib\/x86_64\-linux\-gnu\/libexpat\.a' Replace '\-lfreetype' '\/usr\/lib\/x86_64\-linux\-gnu\/libfreetype\.a' -Replace '\-lpng' '\/usr\/lib\/x86_64\-linux\-gnu\/libpng\.a' Replace '\-lXext' '\/usr\/lib\/x86_64\-linux\-gnu\/libXext\.a' Replace '\-lopus' '\/usr\/local\/lib\/libopus\.a' Replace '\-lopenal' '\/usr\/local\/lib\/libopenal\.a' diff --git a/Telegram/FixMake32.sh b/Telegram/FixMake32.sh index 98043c0b8..4b7591ab5 100755 --- a/Telegram/FixMake32.sh +++ b/Telegram/FixMake32.sh @@ -21,7 +21,6 @@ Replace '\-lSM' '\/usr\/lib\/i386\-linux\-gnu\/libSM\.a' Replace '\-lICE' '\/usr\/lib\/i386\-linux\-gnu\/libICE\.a' Replace '\-lfontconfig' '\/usr\/lib\/i386\-linux\-gnu\/libfontconfig\.a \/usr\/lib\/i386\-linux\-gnu\/libexpat\.a' Replace '\-lfreetype' '\/usr\/lib\/i386\-linux\-gnu\/libfreetype\.a' -Replace '\-lpng' '\/usr\/lib\/i386\-linux\-gnu\/libpng\.a' Replace '\-lXext' '\/usr\/lib\/i386\-linux\-gnu\/libXext\.a' Replace '\-lopus' '\/usr\/local\/lib\/libopus\.a' Replace '\-lopenal' '\/usr\/local\/lib\/libopenal\.a' diff --git a/Telegram/Resources/style.txt b/Telegram/Resources/style.txt index adc2c028f..a7211a669 100644 --- a/Telegram/Resources/style.txt +++ b/Telegram/Resources/style.txt @@ -62,6 +62,8 @@ wndShadowShift: 1px; layerAlpha: 0.5; layerBg: black; +overBg: #edf2f5; + boxBg: white; boxVerticalMargin: 10px; boxWidth: 320px; @@ -238,6 +240,25 @@ solidScroll: flatScroll { duration: 150; hiding: 0; } +defaultPopupMenu: PopupMenu { + skip: 5px; + + shadow: sprite(241px, 46px, 6px, 6px); + shadowShift: 1px; + + itemBg: white; + itemBgOver: overBg; + itemFg: black; + itemFgOver: black; + itemPadding: margins(20px, 8px, 20px, 7px); + itemFont: normalFont; + + duration: 120; + + widthMin: 150px; + widthMax: 300px; +} +almostTransparent: #ffffff0d; boxScroll: flatScroll(solidScroll) { width: 18px; deltax: 6px; @@ -684,7 +705,7 @@ countryRowHeight: 36px; countryRowNameFont: semiboldFont; countryRowPadding: margins(22px, 9px, 8px, 0px); countryRowCodeFont: font(fsize); -countryRowBgOver: #f5f8fa; +countryRowBgOver: overBg; countryRowCodeFg: #808080; countryRowCodeFgOver: #7c99b2; countriesSkip: 12px; @@ -1166,8 +1187,8 @@ mediaSaveButton: flatButton(btnDefFlat) { downColor: #507da2; bgColor: white; - overBgColor: #f5f8fa; - downBgColor: #f5f8fa; + overBgColor: overBg; + downBgColor: overBg; width: -28px; height: 34px; @@ -1381,7 +1402,7 @@ contactsStatusFont: font(fsize); contactsStatusFg: #999999; contactsStatusFgOver: #7c99b2; contactsStatusFgOnline: #3b8dcc; -contactsBgOver: #f5f8fa; +contactsBgOver: overBg; contactsBgActive: #6f9cbd; contactsCheckPosition: point(8px, 16px); contactsCheckIcon: sprite(187px, 61px, 18px, 14px); diff --git a/Telegram/Resources/style_classes.txt b/Telegram/Resources/style_classes.txt index 37ddce8f9..6dc16056a 100644 --- a/Telegram/Resources/style_classes.txt +++ b/Telegram/Resources/style_classes.txt @@ -243,6 +243,25 @@ dropdown { width: number; } +PopupMenu { + skip: number; + + shadow: sprite; + shadowShift: number; + + itemBg: color; + itemBgOver: color; + itemFg: color; + itemFgOver: color; + itemPadding: margins; + itemFont: font; + + duration: number; + + widthMin: number; + widthMax: number; +} + botKeyboardButton { margin: number; padding: number; diff --git a/Telegram/SourceFiles/gui/boxshadow.cpp b/Telegram/SourceFiles/gui/boxshadow.cpp index 7752ae93c..415978d7b 100644 --- a/Telegram/SourceFiles/gui/boxshadow.cpp +++ b/Telegram/SourceFiles/gui/boxshadow.cpp @@ -107,3 +107,8 @@ void BoxShadow::paint(QPainter &p, const QRect &box, int32 shifty, int32 flags) } } } + +style::margins BoxShadow::getDimensions(int32 shifty) const { + int32 d = _colors.size() / cIntRetinaFactor(); + return style::margins(d - shifty, d - 2 * shifty, d - shifty, d); +} diff --git a/Telegram/SourceFiles/gui/boxshadow.h b/Telegram/SourceFiles/gui/boxshadow.h index 1ff90ef68..2d2b903ae 100644 --- a/Telegram/SourceFiles/gui/boxshadow.h +++ b/Telegram/SourceFiles/gui/boxshadow.h @@ -33,6 +33,7 @@ public: BoxShadow(const style::sprite &topLeft); void paint(QPainter &p, const QRect &box, int32 shifty, int32 flags = Left | Top | Right | Bottom); + style::margins getDimensions(int32 shifty) const; private: diff --git a/Telegram/SourceFiles/gui/contextmenu.cpp b/Telegram/SourceFiles/gui/contextmenu.cpp index 10b4a6f86..4d12013bf 100644 --- a/Telegram/SourceFiles/gui/contextmenu.cpp +++ b/Telegram/SourceFiles/gui/contextmenu.cpp @@ -275,3 +275,291 @@ ContextMenu::~ContextMenu() { } #endif } + +PopupMenu::PopupMenu(const style::PopupMenu &st) : TWidget(0) +, _st(st) +, _itemHeight(_st.itemPadding.top() + _st.itemFont->height + _st.itemPadding.bottom()) +, _mouseSelection(false) +, _shadow(_st.shadow) +, _selected(-1) +, a_opacity(1) +, _a_hide(animFunc(this, &PopupMenu::animStep_hide)) +, _deleteOnHide(false) { + _padding = _shadow.getDimensions(_st.shadowShift); + + resetActions(); + + setWindowFlags(Qt::FramelessWindowHint | Qt::BypassWindowManagerHint | Qt::Tool | Qt::NoDropShadowWindowHint | Qt::WindowStaysOnTopHint); + setMouseTracking(true); + + hide(); + + setAttribute(Qt::WA_NoSystemBackground, true); + setAttribute(Qt::WA_TranslucentBackground, true); +} + +QAction *PopupMenu::addAction(const QString &text, const QObject *receiver, const char* member) { + QAction *a = 0; + _actions.push_back(a = new QAction(text, this)); + connect(a, SIGNAL(triggered(bool)), receiver, member); + connect(a, SIGNAL(triggered(bool)), this, SLOT(hideStart())); + connect(a, SIGNAL(changed()), this, SLOT(actionChanged())); + + int32 w = _st.widthMin, mw = _st.widthMax; + for (int32 i = 0, l = _actions.size(); i < l; ++i) { + int32 goodw = _padding.left() + _st.itemPadding.left() + _st.itemFont->width(_actions[i]->text()) + _st.itemPadding.right() + _padding.right(); + w = snap(goodw, w, mw); + } + resize(w, height() + _itemHeight); + update(); + + return a; +} + +PopupMenu::Actions &PopupMenu::actions() { + return _actions; +} + +void PopupMenu::actionChanged() { + int32 w = _st.widthMin, mw = _st.widthMax; + for (int32 i = 0, l = _actions.size(); i < l; ++i) { + int32 goodw = _padding.left() + _st.itemPadding.left() + _st.itemFont->width(_actions[i]->text()) + _st.itemPadding.right() + _padding.right(); + w = snap(goodw, w, mw); + } + if (w != width()) { + resize(w, height()); + } + update(); +} + +void PopupMenu::activeWindowChanged() { + if (!windowHandle()->isActive()) { + hideStart(); + } +} + +void PopupMenu::resetActions() { + clearActions(); + resize(_st.widthMin, _padding.top() + (_st.skip * 2) + _padding.bottom()); +} + +void PopupMenu::clearActions() { + for (int32 i = 0, l = _actions.size(); i < l; ++i) { + delete _actions[i]; + } + _actions.clear(); + + _selected = -1; +} + +void PopupMenu::resizeEvent(QResizeEvent *e) { + _inner = QRect(_padding.left(), _padding.top(), width() - _padding.left() - _padding.right(), height() - _padding.top() - _padding.bottom()); +} + +void PopupMenu::paintEvent(QPaintEvent *e) { + Painter p(this); + + p.setClipRect(e->rect()); + QPainter::CompositionMode m = p.compositionMode(); + p.setCompositionMode(QPainter::CompositionMode_Source); + if (_a_hide.animating()) { + p.drawPixmap(0, 0, _cache); + return; + } + + p.fillRect(e->rect(), st::almostTransparent->b); + p.setCompositionMode(m); + + _shadow.paint(p, _inner, _st.shadowShift); + + QRect topskip(_padding.left(), _padding.top(), _inner.width(), _st.skip); + QRect bottomskip(_padding.left(), height() - _padding.bottom() - _st.skip, _inner.width(), _st.skip); + if (e->rect().intersects(topskip)) p.fillRect(e->rect().intersected(topskip), _st.itemBg->b); + if (e->rect().intersects(bottomskip)) p.fillRect(e->rect().intersected(bottomskip), _st.itemBg->b); + + int32 from = floorclamp(e->rect().top() - _padding.top() - _st.skip, _itemHeight, 0, _actions.size()); + int32 to = ceilclamp(e->rect().top() + e->rect().height() - _padding.top() - _st.skip, _itemHeight, 0, _actions.size()); + + p.translate(_padding.left(), _padding.top() + _st.skip + (from * _itemHeight)); + p.setFont(_st.itemFont); + for (int32 i = from; i < to; ++i) { + p.fillRect(0, 0, _inner.width(), _itemHeight, (i == _selected ? _st.itemBgOver : _st.itemBg)->b); + p.setPen(i == _selected ? _st.itemFgOver : _st.itemFg); + p.drawTextLeft(_st.itemPadding.left(), _st.itemPadding.top(), width() - _padding.left() - _padding.right(), _actions.at(i)->text()); + p.translate(0, _itemHeight); + } +} + +void PopupMenu::updateSelected() { + if (!_mouseSelection) return; + + QPoint p(mapFromGlobal(_mouse) - QPoint(_padding.left(), _padding.top() + _st.skip)); + setSelected(p.y() >= 0 ? (p.y() / _itemHeight) : -1); +} + +void PopupMenu::itemPressed() { + if (_selected >= 0 && _selected < _actions.size()) { + emit _actions[_selected]->trigger(); + return; + } +} + +void PopupMenu::keyPressEvent(QKeyEvent *e) { + if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) { + itemPressed(); + } else if (e->key() == Qt::Key_Escape) { + hideStart(); + return; + } + if ((e->key() != Qt::Key_Up && e->key() != Qt::Key_Down) || _actions.size() < 1) return; + + int32 newSelected = _selected + (e->key() == Qt::Key_Down ? 1 : -1); + if (_selected < 0 || _selected >= _actions.size()) { + newSelected = (e->key() == Qt::Key_Down) ? 0 : (_actions.size() - 1); + } else { + if (newSelected < 0) { + newSelected = _actions.size() - 1; + } else if (newSelected >= _actions.size()) { + newSelected = 0; + } + } + _mouseSelection = false; + setSelected(newSelected); +} + +void PopupMenu::enterEvent(QEvent *e) { + QPoint mouse = QCursor::pos(); + if (_inner.contains(mapFromGlobal(mouse))) { + _mouseSelection = true; + _mouse = mouse; + updateSelected(); + } else { + _mouseSelection = false; + setSelected(-1); + } +} + +void PopupMenu::leaveEvent(QEvent *e) { + if (_mouseSelection) { + _mouseSelection = false; + setSelected(-1); + } +} + +void PopupMenu::setSelected(int32 newSelected) { + if (newSelected >= _actions.size()) { + newSelected = -1; + } + if (newSelected != _selected) { + updateSelectedItem(); + _selected = newSelected; + updateSelectedItem(); + } +} + +void PopupMenu::updateSelectedItem() { + if (_selected >= 0) { + update(_padding.left(), _padding.top() + _st.skip + (_selected * _itemHeight), width() - _padding.left() - _padding.right(), _itemHeight); + } +} + +void PopupMenu::mouseMoveEvent(QMouseEvent *e) { + if (_inner.contains(e->pos())) { + _mouseSelection = true; + _mouse = e->globalPos(); + updateSelected(); + } else { + _mouseSelection = false; + setSelected(-1); + } +} + +void PopupMenu::mousePressEvent(QMouseEvent *e) { + mouseMoveEvent(e); + itemPressed(); +} + +void PopupMenu::focusOutEvent(QFocusEvent *e) { + if (!_a_hide.animating()) hideStart(); +} + +void PopupMenu::fastHide() { + if (_a_hide.animating()) { + _a_hide.stop(); + } + a_opacity = anim::fvalue(0, 0); + hideFinish(); +} + +void PopupMenu::hideStart() { + if (isHidden()) return; + + if (cPlatform() == dbipMac) { + fastHide(); // animated itself + } else { + _cache = myGrab(this); + a_opacity.start(0); + _a_hide.start(); + } +} + +void PopupMenu::hideFinish() { + hide(); + if (_deleteOnHide) { + deleteLater(); + } +} + +bool PopupMenu::animStep_hide(float64 ms) { + float64 dt = ms / _st.duration; + bool res = true; + if (dt >= 1) { + a_opacity.finish(); + hideFinish(); + res = false; + } else { + a_opacity.update(dt, anim::linear); + } + update(); + return res; +} + +void PopupMenu::deleteOnHide() { + _deleteOnHide = true; +} + +void PopupMenu::popup(const QPoint &p) { + QPoint w = p - QPoint(0, _padding.top()); + QRect r = App::app() ? App::app()->desktop()->screenGeometry(p) : QDesktopWidget().screenGeometry(p); + if (rtl()) { + if (w.x() - width() < r.x() - _padding.left()) { + w.setX(r.x() - _padding.left()); + } else { + w.setX(w.x() - width()); + } + } else if (w.x() + width() - _padding.right() > r.x() + r.width()) { + w.setX(r.x() + r.width() - width() + _padding.right()); + } + if (w.y() + height() - _padding.bottom() > r.y() + r.height()) { + w.setY(p.y() - height() + _padding.bottom()); + } + if (w.y() < r.y()) { + w.setY(r.y()); + } + move(w); + psUpdateOverlayed(this); + show(); + psShowOverAll(this); + windowHandle()->requestActivate(); + activateWindow(); + setFocus(); +} + +PopupMenu::~PopupMenu() { + clearActions(); +#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64 + if (App::wnd()) { + App::wnd()->activateWindow(); + } +#endif +} diff --git a/Telegram/SourceFiles/gui/contextmenu.h b/Telegram/SourceFiles/gui/contextmenu.h index 0bd427c9c..7eed9c8ce 100644 --- a/Telegram/SourceFiles/gui/contextmenu.h +++ b/Telegram/SourceFiles/gui/contextmenu.h @@ -82,4 +82,74 @@ private: bool _deleteOnHide; -}; \ No newline at end of file +}; + +class PopupMenu : public TWidget { + Q_OBJECT + +public: + + PopupMenu(const style::PopupMenu &st = st::defaultPopupMenu); + QAction *addAction(const QString &text, const QObject *receiver, const char* member); + void resetActions(); + + typedef QVector Actions; + Actions &actions(); + + void resizeEvent(QResizeEvent *e); + void paintEvent(QPaintEvent *e); + void keyPressEvent(QKeyEvent *e); + void mouseMoveEvent(QMouseEvent *e); + void mousePressEvent(QMouseEvent *e); + void leaveEvent(QEvent *e); + void enterEvent(QEvent *e); + + void focusOutEvent(QFocusEvent *e); + + void fastHide(); + + bool animStep_hide(float64 ms); + + void updateSelected(); + + void deleteOnHide(); + void popup(const QPoint &p); + + ~PopupMenu(); + +public slots: + + void hideStart(); + void hideFinish(); + + void actionChanged(); + void activeWindowChanged(); + +private: + + void clearActions(); + void setSelected(int32 selected); + void updateSelectedItem(); + void itemPressed(); + + const style::PopupMenu &_st; + + Actions _actions; + + int32 _itemHeight; + QRect _inner; + style::margins _padding; + + QPoint _mouse; + bool _mouseSelection; + + BoxShadow _shadow; + int32 _selected; + + QPixmap _cache; + anim::fvalue a_opacity; + Animation _a_hide; + + bool _deleteOnHide; + +}; diff --git a/Telegram/SourceFiles/gui/text.cpp b/Telegram/SourceFiles/gui/text.cpp index d64b43a76..814d37cf5 100644 --- a/Telegram/SourceFiles/gui/text.cpp +++ b/Telegram/SourceFiles/gui/text.cpp @@ -2543,6 +2543,15 @@ void Text::setMarkedText(style::font font, const QString &text, const EntitiesIn _font = font; clean(); { +// QByteArray ba = text.toUtf8(); +// const char *ch = ba.constData(); +// LOG(("STR: %1").arg(text)); +// LOG(("BYTES: %1").arg(mb(ba.constData(), ba.size()).str())); +// for (int32 i = 0; i < text.size(); ++i) { +// LOG(("LETTER %1: '%2' - %3").arg(i).arg(text.at(i)).arg(text.at(i).unicode())); +// } +// int32 w = _font->width(text); + TextParser parser(this, text, entities, options); } recountNaturalSize(true, options.dir); diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 393ffdeb5..5020b9c80 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -803,7 +803,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { AudioLink *lnkAudio = dynamic_cast(_contextMenuLnk.data()); DocumentLink *lnkDocument = dynamic_cast(_contextMenuLnk.data()); if (lnkPhoto || lnkVideo || lnkAudio || lnkDocument) { - _menu = new ContextMenu(historyWidget); + _menu = new PopupMenu(); if (isUponSelected > 0) { _menu->addAction(lang(lng_context_copy_selected), this, SLOT(copySelectedText()))->setEnabled(true); } @@ -853,59 +853,59 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { HistoryServiceMsg *srv = dynamic_cast(item); if (isUponSelected > 0) { - if (!_menu) _menu = new ContextMenu(this); + if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_copy_selected), this, SLOT(copySelectedText()))->setEnabled(true); if (item && item->id > 0 && isUponSelected != 2 && canSendMessages) { _menu->addAction(lang(lng_context_reply_msg), historyWidget, SLOT(onReplyToMessage())); } } else { if (item && item->id > 0 && isUponSelected != -2 && canSendMessages) { - if (!_menu) _menu = new ContextMenu(this); + if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_reply_msg), historyWidget, SLOT(onReplyToMessage())); } if (item && !isUponSelected && !_contextMenuLnk) { if (HistorySticker *sticker = dynamic_cast(msg ? msg->getMedia() : 0)) { DocumentData *doc = sticker->document(); if (doc && doc->sticker() && doc->sticker()->set.type() != mtpc_inputStickerSetEmpty) { - if (!_menu) _menu = new ContextMenu(this); + if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(doc->sticker()->setInstalled() ? lng_context_pack_info : lng_context_pack_add), historyWidget, SLOT(onStickerPackInfo())); } } QString contextMenuText = item->selectedText(FullItemSel); if (!contextMenuText.isEmpty() && (!msg || !msg->getMedia() || msg->getMedia()->type() != MediaTypeSticker)) { - if (!_menu) _menu = new ContextMenu(this); + if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_copy_text), this, SLOT(copyContextText()))->setEnabled(true); } } } if (_contextMenuLnk && dynamic_cast(_contextMenuLnk.data())) { - if (!_menu) _menu = new ContextMenu(historyWidget); + if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_open_link), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_link), this, SLOT(copyContextUrl()))->setEnabled(true); } else if (_contextMenuLnk && dynamic_cast(_contextMenuLnk.data())) { - if (!_menu) _menu = new ContextMenu(historyWidget); + if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_open_email), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_email), this, SLOT(copyContextUrl()))->setEnabled(true); } else if (_contextMenuLnk && dynamic_cast(_contextMenuLnk.data())) { - if (!_menu) _menu = new ContextMenu(historyWidget); + if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_open_mention), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_mention), this, SLOT(copyContextUrl()))->setEnabled(true); } else if (_contextMenuLnk && dynamic_cast(_contextMenuLnk.data())) { - if (!_menu) _menu = new ContextMenu(historyWidget); + if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_open_hashtag), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_hashtag), this, SLOT(copyContextUrl()))->setEnabled(true); } else { } if (isUponSelected > 1) { - if (!_menu) _menu = new ContextMenu(this); + if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_forward_selected), historyWidget, SLOT(onForwardSelected())); if (selectedForDelete == selectedForForward) { _menu->addAction(lang(lng_context_delete_selected), historyWidget, SLOT(onDeleteSelected())); } _menu->addAction(lang(lng_context_clear_selection), historyWidget, SLOT(onClearSelected())); } else if (item && ((isUponSelected != -2 && (canForward || canDelete)) || item->id > 0)) { - if (!_menu) _menu = new ContextMenu(this); + if (!_menu) _menu = new PopupMenu(); if (isUponSelected != -2) { if (canForward) { _menu->addAction(lang(lng_context_forward_msg), historyWidget, SLOT(forwardMessage()))->setEnabled(true); @@ -920,7 +920,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } } else { if (App::mousedItem() && !App::mousedItem()->serviceMsg() && App::mousedItem()->id > 0) { - if (!_menu) _menu = new ContextMenu(this); + if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_select_msg), historyWidget, SLOT(selectMessage()))->setEnabled(true); item = App::mousedItem(); } diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index 40f72586c..835046c1b 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -180,7 +180,7 @@ private: uint64 _touchSpeedTime, _touchAccelerationTime, _touchTime; QTimer _touchScrollTimer; - ContextMenu *_menu; + PopupMenu *_menu; }; diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index 2b8ba330b..959c8ced5 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -1777,7 +1777,7 @@ void OverviewInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { AudioLink *lnkAudio = dynamic_cast(_contextMenuLnk.data()); DocumentLink *lnkDocument = dynamic_cast(_contextMenuLnk.data()); if (lnkPhoto || lnkVideo || lnkAudio || lnkDocument) { - _menu = new ContextMenu(_overview); + _menu = new PopupMenu(); if (App::hoveredLinkItem()) { _menu->addAction(lang(lng_context_to_msg), this, SLOT(goToMessage()))->setEnabled(true); } @@ -1818,7 +1818,7 @@ void OverviewInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { if (_selectedMsgId > 0) updateMsg(App::histItemById(_channel, _selectedMsgId)); } else if (!ignoreMousedItem && App::mousedItem() && App::mousedItem()->id == _mousedItem) { _contextMenuUrl = _lnkOverIndex ? urlByIndex(_mousedItem, _mousedItemIndex, _lnkOverIndex) : QString(); - _menu = new ContextMenu(_overview); + _menu = new PopupMenu(); if ((_contextMenuLnk && dynamic_cast(_contextMenuLnk.data())) || (!_contextMenuUrl.isEmpty() && !urlIsEmail(_contextMenuUrl))) { _menu->addAction(lang(lng_context_open_link), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_link), this, SLOT(copyContextUrl()))->setEnabled(true); diff --git a/Telegram/SourceFiles/overviewwidget.h b/Telegram/SourceFiles/overviewwidget.h index 449b3ea88..954dd6780 100644 --- a/Telegram/SourceFiles/overviewwidget.h +++ b/Telegram/SourceFiles/overviewwidget.h @@ -260,7 +260,7 @@ private: uint64 _touchSpeedTime, _touchAccelerationTime, _touchTime; QTimer _touchScrollTimer; - ContextMenu *_menu; + PopupMenu *_menu; }; class OverviewWidget : public TWidget, public RPCSender { diff --git a/Telegram/SourceFiles/profilewidget.cpp b/Telegram/SourceFiles/profilewidget.cpp index 9dee6744a..53346fb6a 100644 --- a/Telegram/SourceFiles/profilewidget.cpp +++ b/Telegram/SourceFiles/profilewidget.cpp @@ -1218,7 +1218,7 @@ void ProfileInner::contextMenuEvent(QContextMenuEvent *e) { if (!_phoneText.isEmpty() || (_peerUser && !_peerUser->username.isEmpty())) { QRect info(_left + st::profilePhotoSize + st::profilePhoneLeft, st::profilePadding.top(), _width - st::profilePhotoSize - st::profilePhoneLeft, st::profilePhotoSize); if (info.contains(mapFromGlobal(e->globalPos()))) { - _menu = new ContextMenu(this); + _menu = new PopupMenu(); if (!_phoneText.isEmpty()) { _menu->addAction(lang(lng_profile_copy_phone), this, SLOT(onCopyPhone()))->setEnabled(true); } diff --git a/Telegram/SourceFiles/profilewidget.h b/Telegram/SourceFiles/profilewidget.h index d98c17250..786ca6069 100644 --- a/Telegram/SourceFiles/profilewidget.h +++ b/Telegram/SourceFiles/profilewidget.h @@ -194,7 +194,7 @@ private: QPoint _lastPos; QString _onlineText; - ContextMenu *_menu; + PopupMenu *_menu; void blockDone(bool blocked, const MTPBool &result); bool blockFail(const RPCError &error); diff --git a/Telegram/SourceFiles/pspecific_wnd.h b/Telegram/SourceFiles/pspecific_wnd.h index 0f323f3a0..be9bb8b6f 100644 --- a/Telegram/SourceFiles/pspecific_wnd.h +++ b/Telegram/SourceFiles/pspecific_wnd.h @@ -93,7 +93,7 @@ protected: bool posInited; QSystemTrayIcon *trayIcon; - ContextMenu *trayIconMenu; + PopupMenu *trayIconMenu; QImage icon256, iconbig256; QIcon wndIcon; diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index f2f720f70..2d2d2245e 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -444,7 +444,7 @@ void Window::init() { void Window::firstShow() { #ifdef Q_OS_WIN - trayIconMenu = new ContextMenu(this); + trayIconMenu = new PopupMenu(); #else trayIconMenu = new QMenu(this); trayIconMenu->setFont(QFont("Tahoma"));