mirror of https://github.com/procxx/kepka.git
Move MediaView from MainWindow to Messenger.
This commit is contained in:
parent
fa818407e6
commit
b08732cf28
|
@ -160,7 +160,7 @@ namespace App {
|
||||||
|
|
||||||
MainWindow *wnd() {
|
MainWindow *wnd() {
|
||||||
if (auto instance = Messenger::InstancePointer()) {
|
if (auto instance = Messenger::InstancePointer()) {
|
||||||
return instance->mainWindow();
|
return instance->getActiveWindow();
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,9 @@ public:
|
||||||
void checkAutoLock();
|
void checkAutoLock();
|
||||||
void checkAutoLockIn(TimeMs time);
|
void checkAutoLockIn(TimeMs time);
|
||||||
|
|
||||||
|
base::Observable<DocumentData*> documentUpdated;
|
||||||
|
base::Observable<std::pair<HistoryItem*, MsgId>> messageIdChanging;
|
||||||
|
|
||||||
~AuthSession();
|
~AuthSession();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -24,6 +24,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "platform/platform_file_utilities.h"
|
#include "platform/platform_file_utilities.h"
|
||||||
#include "base/task_queue.h"
|
#include "base/task_queue.h"
|
||||||
|
#include "messenger.h"
|
||||||
|
|
||||||
bool filedialogGetSaveFile(QString &file, const QString &caption, const QString &filter, const QString &initialPath) {
|
bool filedialogGetSaveFile(QString &file, const QString &caption, const QString &filter, const QString &initialPath) {
|
||||||
QStringList files;
|
QStringList files;
|
||||||
|
@ -220,7 +221,7 @@ bool GetDefault(QStringList &files, QByteArray &remoteContent, const QString &ca
|
||||||
}
|
}
|
||||||
QString file;
|
QString file;
|
||||||
if (type == Type::ReadFiles) {
|
if (type == Type::ReadFiles) {
|
||||||
files = QFileDialog::getOpenFileNames(App::wnd() ? App::wnd()->filedialogParent() : 0, caption, startFile, filter);
|
files = QFileDialog::getOpenFileNames(Messenger::Instance().getFileDialogParent(), caption, startFile, filter);
|
||||||
QString path = files.isEmpty() ? QString() : QFileInfo(files.back()).absoluteDir().absolutePath();
|
QString path = files.isEmpty() ? QString() : QFileInfo(files.back()).absoluteDir().absolutePath();
|
||||||
if (!path.isEmpty() && path != cDialogLastPath()) {
|
if (!path.isEmpty() && path != cDialogLastPath()) {
|
||||||
cSetDialogLastPath(path);
|
cSetDialogLastPath(path);
|
||||||
|
@ -228,11 +229,11 @@ bool GetDefault(QStringList &files, QByteArray &remoteContent, const QString &ca
|
||||||
}
|
}
|
||||||
return !files.isEmpty();
|
return !files.isEmpty();
|
||||||
} else if (type == Type::ReadFolder) {
|
} else if (type == Type::ReadFolder) {
|
||||||
file = QFileDialog::getExistingDirectory(App::wnd() ? App::wnd()->filedialogParent() : 0, caption, startFile);
|
file = QFileDialog::getExistingDirectory(Messenger::Instance().getFileDialogParent(), caption, startFile);
|
||||||
} else if (type == Type::WriteFile) {
|
} else if (type == Type::WriteFile) {
|
||||||
file = QFileDialog::getSaveFileName(App::wnd() ? App::wnd()->filedialogParent() : 0, caption, startFile, filter);
|
file = QFileDialog::getSaveFileName(Messenger::Instance().getFileDialogParent(), caption, startFile, filter);
|
||||||
} else {
|
} else {
|
||||||
file = QFileDialog::getOpenFileName(App::wnd() ? App::wnd()->filedialogParent() : 0, caption, startFile, filter);
|
file = QFileDialog::getOpenFileName(Messenger::Instance().getFileDialogParent(), caption, startFile, filter);
|
||||||
}
|
}
|
||||||
if (file.isEmpty()) {
|
if (file.isEmpty()) {
|
||||||
files = QStringList();
|
files = QStringList();
|
||||||
|
|
|
@ -241,11 +241,6 @@ bool isLayerShown() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isMediaViewShown() {
|
|
||||||
if (auto w = App::wnd()) return w->ui_isMediaViewShown();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void repaintHistoryItem(gsl::not_null<const HistoryItem*> item) {
|
void repaintHistoryItem(gsl::not_null<const HistoryItem*> item) {
|
||||||
if (auto main = App::main()) {
|
if (auto main = App::main()) {
|
||||||
main->ui_repaintHistoryItem(item);
|
main->ui_repaintHistoryItem(item);
|
||||||
|
@ -282,10 +277,7 @@ void showPeerHistoryAsync(const PeerId &peer, MsgId msgId, ShowWay way) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerData *getPeerForMouseAction() {
|
PeerData *getPeerForMouseAction() {
|
||||||
if (auto w = App::wnd()) {
|
return Messenger::Instance().ui_getPeerForMouseAction();
|
||||||
return w->ui_getPeerForMouseAction();
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hideWindowNoQuit() {
|
bool hideWindowNoQuit() {
|
||||||
|
|
|
@ -103,7 +103,6 @@ QPointer<BoxType> show(object_ptr<BoxType> content, ShowLayerOptions options = C
|
||||||
void hideLayer(bool fast = false);
|
void hideLayer(bool fast = false);
|
||||||
void hideSettingsAndLayer(bool fast = false);
|
void hideSettingsAndLayer(bool fast = false);
|
||||||
bool isLayerShown();
|
bool isLayerShown();
|
||||||
bool isMediaViewShown();
|
|
||||||
|
|
||||||
void repaintHistoryItem(gsl::not_null<const HistoryItem*> item);
|
void repaintHistoryItem(gsl::not_null<const HistoryItem*> item);
|
||||||
void autoplayMediaInlineAsync(const FullMsgId &msgId);
|
void autoplayMediaInlineAsync(const FullMsgId &msgId);
|
||||||
|
|
|
@ -29,6 +29,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "chat_helpers/message_field.h"
|
#include "chat_helpers/message_field.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
#include "messenger.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "auth_session.h"
|
#include "auth_session.h"
|
||||||
|
@ -986,7 +987,7 @@ void InnerWidget::openContextGif() {
|
||||||
if (auto item = App::contextItem()) {
|
if (auto item = App::contextItem()) {
|
||||||
if (auto media = item->getMedia()) {
|
if (auto media = item->getMedia()) {
|
||||||
if (auto document = media->getDocument()) {
|
if (auto document = media->getDocument()) {
|
||||||
_controller->window()->showDocument(document, item);
|
Messenger::Instance().showDocument(document, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "auth_session.h"
|
#include "auth_session.h"
|
||||||
|
#include "messenger.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
|
||||||
|
@ -1463,7 +1464,7 @@ void HistoryInner::openContextGif() {
|
||||||
if (auto item = App::contextItem()) {
|
if (auto item = App::contextItem()) {
|
||||||
if (auto media = item->getMedia()) {
|
if (auto media = item->getMedia()) {
|
||||||
if (auto document = media->getDocument()) {
|
if (auto document = media->getDocument()) {
|
||||||
_controller->window()->showDocument(document, item);
|
Messenger::Instance().showDocument(document, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -828,7 +828,7 @@ void MainWidget::notify_historyMuteUpdated(History *history) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::cmd_search() {
|
bool MainWidget::cmd_search() {
|
||||||
if (Ui::isLayerShown() || Ui::isMediaViewShown()) return false;
|
if (Ui::isLayerShown() || !isActiveWindow()) return false;
|
||||||
if (_wideSection) {
|
if (_wideSection) {
|
||||||
return _wideSection->cmd_search();
|
return _wideSection->cmd_search();
|
||||||
}
|
}
|
||||||
|
@ -836,12 +836,12 @@ bool MainWidget::cmd_search() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::cmd_next_chat() {
|
bool MainWidget::cmd_next_chat() {
|
||||||
if (Ui::isLayerShown() || Ui::isMediaViewShown()) return false;
|
if (Ui::isLayerShown() || !isActiveWindow()) return false;
|
||||||
return _history->cmd_next_chat();
|
return _history->cmd_next_chat();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::cmd_previous_chat() {
|
bool MainWidget::cmd_previous_chat() {
|
||||||
if (Ui::isLayerShown() || Ui::isMediaViewShown()) return false;
|
if (Ui::isLayerShown() || !isActiveWindow()) return false;
|
||||||
return _history->cmd_previous_chat();
|
return _history->cmd_previous_chat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1557,7 +1557,7 @@ bool MainWidget::insertBotCommand(const QString &cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::searchMessages(const QString &query, PeerData *inPeer) {
|
void MainWidget::searchMessages(const QString &query, PeerData *inPeer) {
|
||||||
App::wnd()->hideMediaview();
|
Messenger::Instance().hideMediaView();
|
||||||
_dialogs->searchMessages(query, inPeer);
|
_dialogs->searchMessages(query, inPeer);
|
||||||
if (Adaptive::OneColumn()) {
|
if (Adaptive::OneColumn()) {
|
||||||
Ui::showChatsList();
|
Ui::showChatsList();
|
||||||
|
@ -1606,10 +1606,6 @@ void MainWidget::mediaOverviewUpdated(const Notify::PeerUpdate &update) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::changingMsgId(HistoryItem *row, MsgId newId) {
|
|
||||||
if (_overview) _overview->changingMsgId(row, newId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWidget::itemEdited(HistoryItem *item) {
|
void MainWidget::itemEdited(HistoryItem *item) {
|
||||||
if (_history->peer() == item->history()->peer || (_history->peer() && _history->peer() == item->history()->peer->migrateTo())) {
|
if (_history->peer() == item->history()->peer || (_history->peer() && _history->peer() == item->history()->peer->migrateTo())) {
|
||||||
_history->itemEdited(item);
|
_history->itemEdited(item);
|
||||||
|
@ -1926,7 +1922,7 @@ void MainWidget::documentLoadProgress(DocumentData *document) {
|
||||||
Ui::repaintHistoryItem(item);
|
Ui::repaintHistoryItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
App::wnd()->documentUpdated(document);
|
Auth().documentUpdated.notify(document, true);
|
||||||
|
|
||||||
if (!document->loaded() && document->song()) {
|
if (!document->loaded() && document->song()) {
|
||||||
Media::Player::instance()->documentLoadProgress(document);
|
Media::Player::instance()->documentLoadProgress(document);
|
||||||
|
@ -3941,7 +3937,7 @@ bool MainWidget::started() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::openPeerByName(const QString &username, MsgId msgId, const QString &startToken) {
|
void MainWidget::openPeerByName(const QString &username, MsgId msgId, const QString &startToken) {
|
||||||
App::wnd()->hideMediaview();
|
Messenger::Instance().hideMediaView();
|
||||||
|
|
||||||
PeerData *peer = App::peerByName(username);
|
PeerData *peer = App::peerByName(username);
|
||||||
if (peer) {
|
if (peer) {
|
||||||
|
@ -3981,12 +3977,12 @@ void MainWidget::openPeerByName(const QString &username, MsgId msgId, const QStr
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::joinGroupByHash(const QString &hash) {
|
void MainWidget::joinGroupByHash(const QString &hash) {
|
||||||
App::wnd()->hideMediaview();
|
Messenger::Instance().hideMediaView();
|
||||||
MTP::send(MTPmessages_CheckChatInvite(MTP_string(hash)), rpcDone(&MainWidget::inviteCheckDone, hash), rpcFail(&MainWidget::inviteCheckFail));
|
MTP::send(MTPmessages_CheckChatInvite(MTP_string(hash)), rpcDone(&MainWidget::inviteCheckDone, hash), rpcFail(&MainWidget::inviteCheckFail));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::stickersBox(const MTPInputStickerSet &set) {
|
void MainWidget::stickersBox(const MTPInputStickerSet &set) {
|
||||||
App::wnd()->hideMediaview();
|
Messenger::Instance().hideMediaView();
|
||||||
auto box = Ui::show(Box<StickerSetBox>(set));
|
auto box = Ui::show(Box<StickerSetBox>(set));
|
||||||
connect(box, SIGNAL(installed(uint64)), this, SLOT(onStickersInstalled(uint64)));
|
connect(box, SIGNAL(installed(uint64)), this, SLOT(onStickersInstalled(uint64)));
|
||||||
}
|
}
|
||||||
|
@ -4768,7 +4764,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
_history->peerMessagesUpdated();
|
_history->peerMessagesUpdated();
|
||||||
} else {
|
} else {
|
||||||
App::historyUnregItem(msgRow);
|
App::historyUnregItem(msgRow);
|
||||||
if (App::wnd()) App::wnd()->changingMsgId(msgRow, d.vid.v);
|
Auth().messageIdChanging.notify({ msgRow, d.vid.v }, true);
|
||||||
msgRow->setId(d.vid.v);
|
msgRow->setId(d.vid.v);
|
||||||
if (msgRow->history()->peer->isSelf()) {
|
if (msgRow->history()->peer->isSelf()) {
|
||||||
msgRow->history()->unregSendAction(App::self());
|
msgRow->history()->unregSendAction(App::self());
|
||||||
|
|
|
@ -318,7 +318,6 @@ public:
|
||||||
void jumpToDate(gsl::not_null<PeerData*> peer, const QDate &date);
|
void jumpToDate(gsl::not_null<PeerData*> peer, const QDate &date);
|
||||||
void searchMessages(const QString &query, PeerData *inPeer);
|
void searchMessages(const QString &query, PeerData *inPeer);
|
||||||
bool preloadOverview(PeerData *peer, MediaOverviewType type);
|
bool preloadOverview(PeerData *peer, MediaOverviewType type);
|
||||||
void changingMsgId(HistoryItem *row, MsgId newId);
|
|
||||||
void itemEdited(HistoryItem *item);
|
void itemEdited(HistoryItem *item);
|
||||||
|
|
||||||
void loadMediaBack(PeerData *peer, MediaOverviewType type, bool many = false);
|
void loadMediaBack(PeerData *peer, MediaOverviewType type, bool many = false);
|
||||||
|
|
|
@ -181,8 +181,6 @@ void MainWindow::firstShow() {
|
||||||
|
|
||||||
psFirstShow();
|
psFirstShow();
|
||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
|
|
||||||
createMediaView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::clearWidgetsHook() {
|
void MainWindow::clearWidgetsHook() {
|
||||||
|
@ -229,7 +227,7 @@ void MainWindow::setupPasscode() {
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
|
|
||||||
if (_main) _main->hide();
|
if (_main) _main->hide();
|
||||||
hideMediaview();
|
Messenger::Instance().hideMediaView();
|
||||||
Ui::hideSettingsAndLayer(true);
|
Ui::hideSettingsAndLayer(true);
|
||||||
if (_intro) _intro->hide();
|
if (_intro) _intro->hide();
|
||||||
if (animated) {
|
if (animated) {
|
||||||
|
@ -421,7 +419,7 @@ void MainWindow::ui_showBox(object_ptr<BoxContent> box, ShowLayerOptions options
|
||||||
destroyLayerDelayed();
|
destroyLayerDelayed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hideMediaview();
|
Messenger::Instance().hideMediaView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,15 +458,6 @@ void MainWindow::ui_hideMediaPreview() {
|
||||||
_mediaPreview->hidePreview();
|
_mediaPreview->hidePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerData *MainWindow::ui_getPeerForMouseAction() {
|
|
||||||
if (Ui::isMediaViewShown()) {
|
|
||||||
return Platform::MainWindow::ui_getPeerForMouseAction();
|
|
||||||
} else if (_main) {
|
|
||||||
return _main->ui_getPeerForMouseAction();
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::showConnecting(const QString &text, const QString &reconnect) {
|
void MainWindow::showConnecting(const QString &text, const QString &reconnect) {
|
||||||
if (_connecting) {
|
if (_connecting) {
|
||||||
_connecting->set(text, reconnect);
|
_connecting->set(text, reconnect);
|
||||||
|
@ -555,74 +544,47 @@ void MainWindow::setInnerFocus() {
|
||||||
|
|
||||||
bool MainWindow::eventFilter(QObject *object, QEvent *e) {
|
bool MainWindow::eventFilter(QObject *object, QEvent *e) {
|
||||||
switch (e->type()) {
|
switch (e->type()) {
|
||||||
case QEvent::KeyPress:
|
case QEvent::KeyPress: {
|
||||||
if (cDebug() && e->type() == QEvent::KeyPress && object == windowHandle()) {
|
if (cDebug() && e->type() == QEvent::KeyPress && object == windowHandle()) {
|
||||||
auto key = static_cast<QKeyEvent*>(e)->key();
|
auto key = static_cast<QKeyEvent*>(e)->key();
|
||||||
FeedLangTestingKey(key);
|
FeedLangTestingKey(key);
|
||||||
}
|
}
|
||||||
// [[fallthrough]];
|
} break;
|
||||||
case QEvent::MouseButtonPress:
|
|
||||||
case QEvent::TouchBegin:
|
|
||||||
case QEvent::Wheel:
|
|
||||||
psUserActionDone();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case QEvent::MouseMove:
|
case QEvent::MouseMove: {
|
||||||
if (_main && _main->isIdle()) {
|
if (_main && _main->isIdle()) {
|
||||||
psUserActionDone();
|
psUserActionDone();
|
||||||
_main->checkIdleFinish();
|
_main->checkIdleFinish();
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
|
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease: {
|
||||||
Ui::hideMediaPreview();
|
Ui::hideMediaPreview();
|
||||||
break;
|
} break;
|
||||||
|
|
||||||
case QEvent::ShortcutOverride: // handle shortcuts ourselves
|
case QEvent::ApplicationActivate: {
|
||||||
return true;
|
|
||||||
|
|
||||||
case QEvent::Shortcut:
|
|
||||||
DEBUG_LOG(("Shortcut event caught: %1").arg(static_cast<QShortcutEvent*>(e)->key().toString()));
|
|
||||||
if (Shortcuts::launch(static_cast<QShortcutEvent*>(e)->shortcutId())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case QEvent::ApplicationActivate:
|
|
||||||
if (object == QCoreApplication::instance()) {
|
if (object == QCoreApplication::instance()) {
|
||||||
psUserActionDone();
|
InvokeQueued(this, [this] {
|
||||||
App::CallDelayed(1, this, [this] {
|
|
||||||
handleActiveChanged();
|
handleActiveChanged();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
|
|
||||||
case QEvent::FileOpen:
|
case QEvent::WindowStateChange: {
|
||||||
if (object == QCoreApplication::instance()) {
|
|
||||||
QString url = static_cast<QFileOpenEvent*>(e)->url().toEncoded().trimmed();
|
|
||||||
if (url.startsWith(qstr("tg://"), Qt::CaseInsensitive)) {
|
|
||||||
cSetStartUrl(url.mid(0, 8192));
|
|
||||||
Messenger::Instance().checkStartUrl();
|
|
||||||
}
|
|
||||||
activate();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case QEvent::WindowStateChange:
|
|
||||||
if (object == this) {
|
if (object == this) {
|
||||||
auto state = (windowState() & Qt::WindowMinimized) ? Qt::WindowMinimized :
|
auto state = (windowState() & Qt::WindowMinimized) ? Qt::WindowMinimized :
|
||||||
((windowState() & Qt::WindowMaximized) ? Qt::WindowMaximized :
|
((windowState() & Qt::WindowMaximized) ? Qt::WindowMaximized :
|
||||||
((windowState() & Qt::WindowFullScreen) ? Qt::WindowFullScreen : Qt::WindowNoState));
|
((windowState() & Qt::WindowFullScreen) ? Qt::WindowFullScreen : Qt::WindowNoState));
|
||||||
handleStateChanged(state);
|
handleStateChanged(state);
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
|
|
||||||
case QEvent::Move:
|
case QEvent::Move:
|
||||||
case QEvent::Resize:
|
case QEvent::Resize: {
|
||||||
if (object == this) {
|
if (object == this) {
|
||||||
positionUpdated();
|
positionUpdated();
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Platform::MainWindow::eventFilter(object, e);
|
return Platform::MainWindow::eventFilter(object, e);
|
||||||
|
@ -990,18 +952,13 @@ QImage MainWindow::iconWithCounter(int size, int count, style::color bg, style::
|
||||||
|
|
||||||
void MainWindow::sendPaths() {
|
void MainWindow::sendPaths() {
|
||||||
if (App::passcoded()) return;
|
if (App::passcoded()) return;
|
||||||
hideMediaview();
|
Messenger::Instance().hideMediaView();
|
||||||
Ui::hideSettingsAndLayer(true);
|
Ui::hideSettingsAndLayer(true);
|
||||||
if (_main) {
|
if (_main) {
|
||||||
_main->activate();
|
_main->activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::changingMsgId(HistoryItem *row, MsgId newId) {
|
|
||||||
if (_main) _main->changingMsgId(row, newId);
|
|
||||||
Platform::MainWindow::changingMsgId(row, newId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::updateIsActiveHook() {
|
void MainWindow::updateIsActiveHook() {
|
||||||
if (_main) _main->updateOnline();
|
if (_main) _main->updateOnline();
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,6 @@ public:
|
||||||
|
|
||||||
void sendPaths();
|
void sendPaths();
|
||||||
|
|
||||||
void changingMsgId(HistoryItem *row, MsgId newId) override;
|
|
||||||
|
|
||||||
QImage iconWithCounter(int size, int count, style::color bg, style::color fg, bool smallIcon) override;
|
QImage iconWithCounter(int size, int count, style::color bg, style::color fg, bool smallIcon) override;
|
||||||
|
|
||||||
bool contentOverlapped(const QRect &globalRect);
|
bool contentOverlapped(const QRect &globalRect);
|
||||||
|
@ -138,7 +136,6 @@ public:
|
||||||
void ui_showMediaPreview(DocumentData *document);
|
void ui_showMediaPreview(DocumentData *document);
|
||||||
void ui_showMediaPreview(PhotoData *photo);
|
void ui_showMediaPreview(PhotoData *photo);
|
||||||
void ui_hideMediaPreview();
|
void ui_hideMediaPreview();
|
||||||
PeerData *ui_getPeerForMouseAction() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *o, QEvent *e) override;
|
bool eventFilter(QObject *o, QEvent *e) override;
|
||||||
|
|
|
@ -72,7 +72,7 @@ bool typeHasMediaOverview(MediaOverviewType type) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
MediaView::MediaView(QWidget*) : TWidget(nullptr)
|
MediaView::MediaView() : TWidget(nullptr)
|
||||||
, _transparentBrush(style::transparentPlaceholderBrush())
|
, _transparentBrush(style::transparentPlaceholderBrush())
|
||||||
, _animStarted(getms())
|
, _animStarted(getms())
|
||||||
, _docDownload(this, lang(lng_media_download), st::mediaviewFileLink)
|
, _docDownload(this, lang(lng_media_download), st::mediaviewFileLink)
|
||||||
|
@ -106,6 +106,14 @@ MediaView::MediaView(QWidget*) : TWidget(nullptr)
|
||||||
onVideoPauseResume();
|
onVideoPauseResume();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
subscribe(Auth().documentUpdated, [this](DocumentData *document) {
|
||||||
|
if (!isHidden()) {
|
||||||
|
documentUpdated(document);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
subscribe(Auth().messageIdChanging, [this](std::pair<HistoryItem*, MsgId> update) {
|
||||||
|
changingMsgId(update.first, update.second);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
subscribe(Messenger::Instance().authSessionChanged(), [handleAuthSessionChange] {
|
subscribe(Messenger::Instance().authSessionChanged(), [handleAuthSessionChange] {
|
||||||
|
@ -133,8 +141,6 @@ MediaView::MediaView(QWidget*) : TWidget(nullptr)
|
||||||
_saveMsgUpdater.setSingleShot(true);
|
_saveMsgUpdater.setSingleShot(true);
|
||||||
connect(&_saveMsgUpdater, SIGNAL(timeout()), this, SLOT(updateImage()));
|
connect(&_saveMsgUpdater, SIGNAL(timeout()), this, SLOT(updateImage()));
|
||||||
|
|
||||||
connect(App::wnd()->windowHandle(), SIGNAL(activeChanged()), this, SLOT(onCheckActive()));
|
|
||||||
|
|
||||||
setAttribute(Qt::WA_AcceptTouchEvents);
|
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||||
_touchTimer.setSingleShot(true);
|
_touchTimer.setSingleShot(true);
|
||||||
connect(&_touchTimer, SIGNAL(timeout()), this, SLOT(onTouchTimer()));
|
connect(&_touchTimer, SIGNAL(timeout()), this, SLOT(onTouchTimer()));
|
||||||
|
@ -156,17 +162,24 @@ void MediaView::refreshLang() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaView::moveToScreen() {
|
void MediaView::moveToScreen() {
|
||||||
if (App::wnd() && windowHandle() && App::wnd()->windowHandle() && windowHandle()->screen() != App::wnd()->windowHandle()->screen()) {
|
auto widgetScreen = [this](auto &&widget) -> QScreen* {
|
||||||
windowHandle()->setScreen(App::wnd()->windowHandle()->screen());
|
if (auto handle = widget ? widget->windowHandle() : nullptr) {
|
||||||
|
return handle->screen();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
auto activeWindow = Messenger::Instance().getActiveWindow();
|
||||||
|
auto activeWindowScreen = widgetScreen(activeWindow);
|
||||||
|
auto myScreen = widgetScreen(this);
|
||||||
|
if (activeWindowScreen && myScreen && myScreen != activeWindowScreen) {
|
||||||
|
windowHandle()->setScreen(activeWindowScreen);
|
||||||
|
}
|
||||||
|
auto available = activeWindow ? Sandbox::screenGeometry(activeWindow->geometry().center()) : QApplication::desktop()->screenGeometry();
|
||||||
|
if (geometry() != available) {
|
||||||
|
setGeometry(available);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto wndCenter = App::wnd()->geometry().center();
|
auto navSkip = 2 * st::mediaviewControlMargin + st::mediaviewControlSize;
|
||||||
QRect avail = Sandbox::screenGeometry(wndCenter);
|
|
||||||
if (avail != geometry()) {
|
|
||||||
setGeometry(avail);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 navSkip = 2 * st::mediaviewControlMargin + st::mediaviewControlSize;
|
|
||||||
_closeNav = myrtlrect(width() - st::mediaviewControlMargin - st::mediaviewControlSize, st::mediaviewControlMargin, st::mediaviewControlSize, st::mediaviewControlSize);
|
_closeNav = myrtlrect(width() - st::mediaviewControlMargin - st::mediaviewControlSize, st::mediaviewControlMargin, st::mediaviewControlSize, st::mediaviewControlSize);
|
||||||
_closeNavIcon = centerrect(_closeNav, st::mediaviewClose);
|
_closeNavIcon = centerrect(_closeNav, st::mediaviewClose);
|
||||||
_leftNav = myrtlrect(st::mediaviewControlMargin, navSkip, st::mediaviewControlSize, height() - 2 * navSkip);
|
_leftNav = myrtlrect(st::mediaviewControlMargin, navSkip, st::mediaviewControlSize, height() - 2 * navSkip);
|
||||||
|
@ -275,10 +288,12 @@ void MediaView::changingMsgId(HistoryItem *row, MsgId newId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a fake update.
|
// Send a fake update.
|
||||||
Notify::PeerUpdate update(row->history()->peer);
|
if (!isHidden()) {
|
||||||
update.flags |= Notify::PeerUpdate::Flag::SharedMediaChanged;
|
Notify::PeerUpdate update(row->history()->peer);
|
||||||
update.mediaTypesMask |= (1 << _overview);
|
update.flags |= Notify::PeerUpdate::Flag::SharedMediaChanged;
|
||||||
mediaOverviewUpdated(update);
|
update.mediaTypesMask |= (1 << _overview);
|
||||||
|
mediaOverviewUpdated(update);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaView::updateDocSize() {
|
void MediaView::updateDocSize() {
|
||||||
|
@ -670,9 +685,7 @@ void MediaView::updateMixerVideoVolume() const {
|
||||||
|
|
||||||
void MediaView::close() {
|
void MediaView::close() {
|
||||||
if (_menu) _menu->hideMenu(true);
|
if (_menu) _menu->hideMenu(true);
|
||||||
if (App::wnd()) {
|
Messenger::Instance().hideMediaView();
|
||||||
Ui::hideLayer(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaView::activateControls() {
|
void MediaView::activateControls() {
|
||||||
|
@ -750,10 +763,8 @@ void MediaView::onScreenResized(int screen) {
|
||||||
|
|
||||||
void MediaView::onToMessage() {
|
void MediaView::onToMessage() {
|
||||||
if (auto item = _msgid ? App::histItemById(_msgmigrated ? 0 : _channel, _msgid) : 0) {
|
if (auto item = _msgid ? App::histItemById(_msgmigrated ? 0 : _channel, _msgid) : 0) {
|
||||||
if (App::wnd()) {
|
close();
|
||||||
close();
|
Ui::showPeerHistoryAtItem(item);
|
||||||
Ui::showPeerHistoryAtItem(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,13 +968,11 @@ void MediaView::onForward() {
|
||||||
auto item = App::histItemById(_msgmigrated ? 0 : _channel, _msgid);
|
auto item = App::histItemById(_msgmigrated ? 0 : _channel, _msgid);
|
||||||
if (!_msgid || !item || item->id < 0 || item->serviceMsg()) return;
|
if (!_msgid || !item || item->id < 0 || item->serviceMsg()) return;
|
||||||
|
|
||||||
if (App::wnd()) {
|
close();
|
||||||
close();
|
if (auto main = App::main()) {
|
||||||
if (auto main = App::main()) {
|
auto items = SelectedItemSet();
|
||||||
auto items = SelectedItemSet();
|
items.insert(item->id, item);
|
||||||
items.insert(item->id, item);
|
main->showForwardLayer(items);
|
||||||
main->showForwardLayer(items);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2528,7 +2537,7 @@ void MediaView::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_over == OverName && _down == OverName) {
|
if (_over == OverName && _down == OverName) {
|
||||||
if (App::wnd() && _from) {
|
if (_from) {
|
||||||
close();
|
close();
|
||||||
Ui::showPeerProfile(_from);
|
Ui::showPeerProfile(_from);
|
||||||
}
|
}
|
||||||
|
@ -2608,15 +2617,15 @@ void MediaView::touchEvent(QTouchEvent *e) {
|
||||||
|
|
||||||
case QEvent::TouchEnd:
|
case QEvent::TouchEnd:
|
||||||
if (!_touchPress) return;
|
if (!_touchPress) return;
|
||||||
if (!_touchMove && App::wnd()) {
|
if (!_touchMove) {
|
||||||
Qt::MouseButton btn(_touchRightButton ? Qt::RightButton : Qt::LeftButton);
|
Qt::MouseButton btn(_touchRightButton ? Qt::RightButton : Qt::LeftButton);
|
||||||
QPoint mapped(mapFromGlobal(_touchStart)), winMapped(App::wnd()->mapFromGlobal(_touchStart));
|
auto mapped = mapFromGlobal(_touchStart);
|
||||||
|
|
||||||
QMouseEvent pressEvent(QEvent::MouseButtonPress, mapped, winMapped, _touchStart, btn, Qt::MouseButtons(btn), Qt::KeyboardModifiers());
|
QMouseEvent pressEvent(QEvent::MouseButtonPress, mapped, mapped, _touchStart, btn, Qt::MouseButtons(btn), Qt::KeyboardModifiers());
|
||||||
pressEvent.accept();
|
pressEvent.accept();
|
||||||
mousePressEvent(&pressEvent);
|
mousePressEvent(&pressEvent);
|
||||||
|
|
||||||
QMouseEvent releaseEvent(QEvent::MouseButtonRelease, mapped, winMapped, _touchStart, btn, Qt::MouseButtons(btn), Qt::KeyboardModifiers());
|
QMouseEvent releaseEvent(QEvent::MouseButtonRelease, mapped, mapped, _touchStart, btn, Qt::MouseButtons(btn), Qt::KeyboardModifiers());
|
||||||
mouseReleaseEvent(&releaseEvent);
|
mouseReleaseEvent(&releaseEvent);
|
||||||
|
|
||||||
if (_touchRightButton) {
|
if (_touchRightButton) {
|
||||||
|
@ -2733,16 +2742,6 @@ void MediaView::onDropdown() {
|
||||||
_dropdown->setFocus();
|
_dropdown->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaView::onCheckActive() {
|
|
||||||
if (App::wnd() && isVisible()) {
|
|
||||||
if (App::wnd()->isActiveWindow() && App::wnd()->hasFocus()) {
|
|
||||||
activateWindow();
|
|
||||||
Sandbox::setActiveWindow(this);
|
|
||||||
setFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MediaView::onTouchTimer() {
|
void MediaView::onTouchTimer() {
|
||||||
_touchRightButton = true;
|
_touchRightButton = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ class MediaView : public TWidget, private base::Subscriber, public RPCSender, pu
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MediaView(QWidget*);
|
MediaView();
|
||||||
|
|
||||||
void setVisible(bool visible) override;
|
void setVisible(bool visible) override;
|
||||||
|
|
||||||
|
@ -73,8 +73,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void mediaOverviewUpdated(const Notify::PeerUpdate &update);
|
void mediaOverviewUpdated(const Notify::PeerUpdate &update);
|
||||||
void documentUpdated(DocumentData *doc);
|
|
||||||
void changingMsgId(HistoryItem *row, MsgId newId);
|
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
@ -126,7 +124,6 @@ private slots:
|
||||||
|
|
||||||
void onDropdown();
|
void onDropdown();
|
||||||
|
|
||||||
void onCheckActive();
|
|
||||||
void onTouchTimer();
|
void onTouchTimer();
|
||||||
|
|
||||||
void updateImage();
|
void updateImage();
|
||||||
|
@ -186,6 +183,9 @@ private:
|
||||||
void destroyThemePreview();
|
void destroyThemePreview();
|
||||||
void updateThemePreviewGeometry();
|
void updateThemePreviewGeometry();
|
||||||
|
|
||||||
|
void documentUpdated(DocumentData *doc);
|
||||||
|
void changingMsgId(HistoryItem *row, MsgId newId);
|
||||||
|
|
||||||
// Radial animation interface.
|
// Radial animation interface.
|
||||||
float64 radialProgress() const;
|
float64 radialProgress() const;
|
||||||
bool radialLoading() const;
|
bool radialLoading() const;
|
||||||
|
|
|
@ -35,6 +35,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "observer_peer.h"
|
#include "observer_peer.h"
|
||||||
#include "storage/file_upload.h"
|
#include "storage/file_upload.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
#include "mediaview.h"
|
||||||
#include "mtproto/dc_options.h"
|
#include "mtproto/dc_options.h"
|
||||||
#include "mtproto/mtp_instance.h"
|
#include "mtproto/mtp_instance.h"
|
||||||
#include "media/player/media_player_instance.h"
|
#include "media/player/media_player_instance.h"
|
||||||
|
@ -129,6 +130,9 @@ Messenger::Messenger() : QObject()
|
||||||
_window->createWinId();
|
_window->createWinId();
|
||||||
_window->init();
|
_window->init();
|
||||||
|
|
||||||
|
_mediaView = std::make_unique<MediaView>();
|
||||||
|
|
||||||
|
QCoreApplication::instance()->installEventFilter(this);
|
||||||
Sandbox::connect(SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(onAppStateChanged(Qt::ApplicationState)));
|
Sandbox::connect(SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(onAppStateChanged(Qt::ApplicationState)));
|
||||||
|
|
||||||
DEBUG_LOG(("Application Info: window created..."));
|
DEBUG_LOG(("Application Info: window created..."));
|
||||||
|
@ -180,6 +184,97 @@ Messenger::Messenger() : QObject()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Messenger::hideMediaView() {
|
||||||
|
if (_mediaView && !_mediaView->isHidden()) {
|
||||||
|
_mediaView->hide();
|
||||||
|
_window->reActivateWindow();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Messenger::showPhoto(gsl::not_null<const PhotoOpenClickHandler*> link, HistoryItem *item) {
|
||||||
|
return (!item && link->peer())
|
||||||
|
? showPhoto(link->photo(), link->peer())
|
||||||
|
: showPhoto(link->photo(), item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Messenger::showPhoto(gsl::not_null<PhotoData*> photo, HistoryItem *item) {
|
||||||
|
if (_mediaView->isHidden()) Ui::hideLayer(true);
|
||||||
|
_mediaView->showPhoto(photo, item);
|
||||||
|
_mediaView->activateWindow();
|
||||||
|
_mediaView->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Messenger::showPhoto(gsl::not_null<PhotoData*> photo, PeerData *peer) {
|
||||||
|
if (_mediaView->isHidden()) Ui::hideLayer(true);
|
||||||
|
_mediaView->showPhoto(photo, peer);
|
||||||
|
_mediaView->activateWindow();
|
||||||
|
_mediaView->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Messenger::showDocument(gsl::not_null<DocumentData*> document, HistoryItem *item) {
|
||||||
|
if (cUseExternalVideoPlayer() && document->isVideo()) {
|
||||||
|
QDesktopServices::openUrl(QUrl("file:///" + document->location(false).fname));
|
||||||
|
} else {
|
||||||
|
if (_mediaView->isHidden()) Ui::hideLayer(true);
|
||||||
|
_mediaView->showDocument(document, item);
|
||||||
|
_mediaView->activateWindow();
|
||||||
|
_mediaView->setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PeerData *Messenger::ui_getPeerForMouseAction() {
|
||||||
|
if (_mediaView && !_mediaView->isHidden()) {
|
||||||
|
return _mediaView->ui_getPeerForMouseAction();
|
||||||
|
} else if (auto main = App::main()) {
|
||||||
|
return main->ui_getPeerForMouseAction();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Messenger::eventFilter(QObject *object, QEvent *e) {
|
||||||
|
switch (e->type()) {
|
||||||
|
case QEvent::KeyPress:
|
||||||
|
case QEvent::MouseButtonPress:
|
||||||
|
case QEvent::TouchBegin:
|
||||||
|
case QEvent::Wheel: {
|
||||||
|
psUserActionDone();
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case QEvent::ShortcutOverride: {
|
||||||
|
// handle shortcuts ourselves
|
||||||
|
return true;
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case QEvent::Shortcut: {
|
||||||
|
DEBUG_LOG(("Shortcut event caught: %1").arg(static_cast<QShortcutEvent*>(e)->key().toString()));
|
||||||
|
if (Shortcuts::launch(static_cast<QShortcutEvent*>(e)->shortcutId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case QEvent::ApplicationActivate: {
|
||||||
|
if (object == QCoreApplication::instance()) {
|
||||||
|
psUserActionDone();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case QEvent::FileOpen: {
|
||||||
|
if (object == QCoreApplication::instance()) {
|
||||||
|
auto url = QString::fromUtf8(static_cast<QFileOpenEvent*>(e)->url().toEncoded().trimmed());
|
||||||
|
if (url.startsWith(qstr("tg://"), Qt::CaseInsensitive)) {
|
||||||
|
cSetStartUrl(url.mid(0, 8192));
|
||||||
|
checkStartUrl();
|
||||||
|
}
|
||||||
|
_window->activate();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QObject::eventFilter(object, e);
|
||||||
|
}
|
||||||
|
|
||||||
void Messenger::setMtpMainDcId(MTP::DcId mainDcId) {
|
void Messenger::setMtpMainDcId(MTP::DcId mainDcId) {
|
||||||
Expects(!_mtproto);
|
Expects(!_mtproto);
|
||||||
_private->mtpConfig.mainDcId = mainDcId;
|
_private->mtpConfig.mainDcId = mainDcId;
|
||||||
|
@ -616,6 +711,8 @@ void Messenger::authSessionDestroy() {
|
||||||
_private->storedAuthSession.reset();
|
_private->storedAuthSession.reset();
|
||||||
_private->authSessionUserId = 0;
|
_private->authSessionUserId = 0;
|
||||||
authSessionChanged().notify(true);
|
authSessionChanged().notify(true);
|
||||||
|
|
||||||
|
loggedOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Messenger::setInternalLinkDomain(const QString &domain) const {
|
void Messenger::setInternalLinkDomain(const QString &domain) const {
|
||||||
|
@ -800,6 +897,7 @@ Messenger::~Messenger() {
|
||||||
Expects(SingleInstance == this);
|
Expects(SingleInstance == this);
|
||||||
|
|
||||||
_window.reset();
|
_window.reset();
|
||||||
|
_mediaView.reset();
|
||||||
|
|
||||||
// Some MTP requests can be cancelled from data clearing.
|
// Some MTP requests can be cancelled from data clearing.
|
||||||
App::clearHistories();
|
App::clearHistories();
|
||||||
|
@ -832,10 +930,30 @@ Messenger::~Messenger() {
|
||||||
SingleInstance = nullptr;
|
SingleInstance = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow *Messenger::mainWindow() {
|
MainWindow *Messenger::getActiveWindow() {
|
||||||
return _window.get();
|
return _window.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget *Messenger::getFileDialogParent() {
|
||||||
|
return (_mediaView && _mediaView->isVisible()) ? (QWidget*)_mediaView.get() : (QWidget*)getActiveWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Messenger::checkMediaViewActivation() {
|
||||||
|
if (_mediaView && !_mediaView->isHidden()) {
|
||||||
|
_mediaView->activateWindow();
|
||||||
|
Sandbox::setActiveWindow(_mediaView.get());
|
||||||
|
_mediaView->setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Messenger::loggedOut() {
|
||||||
|
if (_mediaView) {
|
||||||
|
hideMediaView();
|
||||||
|
_mediaView->rpcClear();
|
||||||
|
_mediaView->clearData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QPoint Messenger::getPointForCallPanelCenter() const {
|
QPoint Messenger::getPointForCallPanelCenter() const {
|
||||||
Expects(_window != nullptr);
|
Expects(_window != nullptr);
|
||||||
Expects(_window->windowHandle() != nullptr);
|
Expects(_window->windowHandle() != nullptr);
|
||||||
|
|
|
@ -41,6 +41,7 @@ class AuthSessionData;
|
||||||
class MainWidget;
|
class MainWidget;
|
||||||
class FileUploader;
|
class FileUploader;
|
||||||
class Translator;
|
class Translator;
|
||||||
|
class MediaView;
|
||||||
|
|
||||||
namespace Local {
|
namespace Local {
|
||||||
struct StoredAuthSession;
|
struct StoredAuthSession;
|
||||||
|
@ -69,7 +70,22 @@ public:
|
||||||
|
|
||||||
~Messenger();
|
~Messenger();
|
||||||
|
|
||||||
MainWindow *mainWindow();
|
// Windows interface.
|
||||||
|
MainWindow *getActiveWindow();
|
||||||
|
QWidget *getFileDialogParent();
|
||||||
|
QWidget *getGlobalShortcutParent() {
|
||||||
|
return &_globalShortcutParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MediaView interface.
|
||||||
|
void checkMediaViewActivation();
|
||||||
|
bool hideMediaView();
|
||||||
|
void showPhoto(gsl::not_null<const PhotoOpenClickHandler*> link, HistoryItem *item = nullptr);
|
||||||
|
void showPhoto(gsl::not_null<PhotoData*> photo, HistoryItem *item);
|
||||||
|
void showPhoto(gsl::not_null<PhotoData*> photo, PeerData *item);
|
||||||
|
void showDocument(gsl::not_null<DocumentData*> document, HistoryItem *item);
|
||||||
|
PeerData *ui_getPeerForMouseAction();
|
||||||
|
|
||||||
QPoint getPointForCallPanelCenter() const;
|
QPoint getPointForCallPanelCenter() const;
|
||||||
QImage logo() const {
|
QImage logo() const {
|
||||||
return _logo;
|
return _logo;
|
||||||
|
@ -174,6 +190,9 @@ public:
|
||||||
_callDelayedTimer.call(duration, std::move(lambda));
|
_callDelayedTimer.call(duration, std::move(lambda));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject *object, QEvent *event) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void peerPhotoDone(PeerId peer);
|
void peerPhotoDone(PeerId peer);
|
||||||
void peerPhotoFail(PeerId peer);
|
void peerPhotoFail(PeerId peer);
|
||||||
|
@ -198,6 +217,8 @@ private:
|
||||||
static void QuitAttempt();
|
static void QuitAttempt();
|
||||||
void quitDelayed();
|
void quitDelayed();
|
||||||
|
|
||||||
|
void loggedOut();
|
||||||
|
|
||||||
QMap<FullMsgId, PeerId> photoUpdates;
|
QMap<FullMsgId, PeerId> photoUpdates;
|
||||||
|
|
||||||
QMap<MTP::DcId, TimeMs> killDownloadSessionTimes;
|
QMap<MTP::DcId, TimeMs> killDownloadSessionTimes;
|
||||||
|
@ -207,7 +228,10 @@ private:
|
||||||
struct Private;
|
struct Private;
|
||||||
const std::unique_ptr<Private> _private;
|
const std::unique_ptr<Private> _private;
|
||||||
|
|
||||||
|
QWidget _globalShortcutParent;
|
||||||
|
|
||||||
std::unique_ptr<MainWindow> _window;
|
std::unique_ptr<MainWindow> _window;
|
||||||
|
std::unique_ptr<MediaView> _mediaView;
|
||||||
std::unique_ptr<Lang::Instance> _langpack;
|
std::unique_ptr<Lang::Instance> _langpack;
|
||||||
std::unique_ptr<Lang::CloudManager> _langCloudManager;
|
std::unique_ptr<Lang::CloudManager> _langCloudManager;
|
||||||
std::unique_ptr<Lang::Translator> _translator;
|
std::unique_ptr<Lang::Translator> _translator;
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace Layout {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
TextParseOptions _documentNameOptions = {
|
TextParseOptions _documentNameOptions = {
|
||||||
TextParseMultiline | TextParseRichText | TextParseLinks | TextParseHashtags | TextParseMentions | TextParseBotCommands | TextParseMarkdown, // flags
|
TextParseMultiline | TextParseRichText | TextParseLinks | TextParseMarkdown, // flags
|
||||||
0, // maxw
|
0, // maxw
|
||||||
0, // maxh
|
0, // maxh
|
||||||
Qt::LayoutDirectionAuto, // dir
|
Qt::LayoutDirectionAuto, // dir
|
||||||
|
|
|
@ -96,6 +96,9 @@ OverviewInner::OverviewInner(OverviewWidget *overview, Ui::ScrollArea *scroll, P
|
||||||
subscribe(App::wnd()->dragFinished(), [this] {
|
subscribe(App::wnd()->dragFinished(), [this] {
|
||||||
dragActionUpdate(QCursor::pos());
|
dragActionUpdate(QCursor::pos());
|
||||||
});
|
});
|
||||||
|
subscribe(Auth().messageIdChanging, [this](std::pair<HistoryItem*, MsgId> update) {
|
||||||
|
changingMsgId(update.first, update.second);
|
||||||
|
});
|
||||||
|
|
||||||
if (_type == OverviewLinks || _type == OverviewFiles) {
|
if (_type == OverviewLinks || _type == OverviewFiles) {
|
||||||
_search->show();
|
_search->show();
|
||||||
|
@ -1725,6 +1728,10 @@ void OverviewInner::mediaOverviewUpdated() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverviewInner::changingMsgId(HistoryItem *row, MsgId newId) {
|
void OverviewInner::changingMsgId(HistoryItem *row, MsgId newId) {
|
||||||
|
if (peer() != row->history()->peer && migratePeer() != row->history()->peer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MsgId oldId = complexMsgId(row);
|
MsgId oldId = complexMsgId(row);
|
||||||
if (row->history() == _migrated) newId = -newId;
|
if (row->history() == _migrated) newId = -newId;
|
||||||
|
|
||||||
|
@ -2245,12 +2252,6 @@ void OverviewWidget::mediaOverviewUpdated(const Notify::PeerUpdate &update) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverviewWidget::changingMsgId(HistoryItem *row, MsgId newId) {
|
|
||||||
if (peer() == row->history()->peer || migratePeer() == row->history()->peer) {
|
|
||||||
_inner->changingMsgId(row, newId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OverviewWidget::grapWithoutTopBarShadow() {
|
void OverviewWidget::grapWithoutTopBarShadow() {
|
||||||
grabStart();
|
grabStart();
|
||||||
_topShadow->hide();
|
_topShadow->hide();
|
||||||
|
|
|
@ -88,7 +88,6 @@ public:
|
||||||
void setSelectMode(bool enabled);
|
void setSelectMode(bool enabled);
|
||||||
|
|
||||||
void mediaOverviewUpdated();
|
void mediaOverviewUpdated();
|
||||||
void changingMsgId(HistoryItem *row, MsgId newId);
|
|
||||||
void repaintItem(const HistoryItem *msg);
|
void repaintItem(const HistoryItem *msg);
|
||||||
|
|
||||||
Window::TopBarWidget::SelectedState getSelectionState() const;
|
Window::TopBarWidget::SelectedState getSelectionState() const;
|
||||||
|
@ -144,6 +143,7 @@ private:
|
||||||
|
|
||||||
void itemRemoved(HistoryItem *item);
|
void itemRemoved(HistoryItem *item);
|
||||||
MsgId complexMsgId(const HistoryItem *item) const;
|
MsgId complexMsgId(const HistoryItem *item) const;
|
||||||
|
void changingMsgId(HistoryItem *row, MsgId newId);
|
||||||
|
|
||||||
bool itemMigrated(MsgId msgId) const;
|
bool itemMigrated(MsgId msgId) const;
|
||||||
ChannelId itemChannel(MsgId msgId) const;
|
ChannelId itemChannel(MsgId msgId) const;
|
||||||
|
@ -320,7 +320,6 @@ public:
|
||||||
void doneShow();
|
void doneShow();
|
||||||
|
|
||||||
void mediaOverviewUpdated(const Notify::PeerUpdate &update);
|
void mediaOverviewUpdated(const Notify::PeerUpdate &update);
|
||||||
void changingMsgId(HistoryItem *row, MsgId newId);
|
|
||||||
void itemRemoved(HistoryItem *item);
|
void itemRemoved(HistoryItem *item);
|
||||||
|
|
||||||
QPoint clampMousePosition(QPoint point);
|
QPoint clampMousePosition(QPoint point);
|
||||||
|
|
|
@ -23,6 +23,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include <private/qguiapplication_p.h>
|
#include <private/qguiapplication_p.h>
|
||||||
#include "platform/linux/linux_libs.h"
|
#include "platform/linux/linux_libs.h"
|
||||||
#include "platform/linux/linux_gdk_helper.h"
|
#include "platform/linux/linux_gdk_helper.h"
|
||||||
|
#include "messenger.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
|
|
||||||
|
@ -149,7 +150,7 @@ bool PreviewSupported() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetNative(QStringList &files, QByteArray &remoteContent, const QString &caption, const QString &filter, Type type, QString startFile) {
|
bool GetNative(QStringList &files, QByteArray &remoteContent, const QString &caption, const QString &filter, Type type, QString startFile) {
|
||||||
auto parent = App::wnd() ? App::wnd()->filedialogParent() : nullptr;
|
auto parent = Messenger::Instance().getFileDialogParent();
|
||||||
internal::GtkFileDialog dialog(parent, caption, QString(), filter);
|
internal::GtkFileDialog dialog(parent, caption, QString(), filter);
|
||||||
|
|
||||||
dialog.setModal(true);
|
dialog.setModal(true);
|
||||||
|
|
|
@ -24,6 +24,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "platform/win/windows_dlls.h"
|
#include "platform/win/windows_dlls.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "messenger.h"
|
||||||
|
|
||||||
#include <Shlwapi.h>
|
#include <Shlwapi.h>
|
||||||
#include <Windowsx.h>
|
#include <Windowsx.h>
|
||||||
|
@ -356,7 +357,8 @@ bool Get(QStringList &files, QByteArray &remoteContent, const QString &caption,
|
||||||
// that forced file icon and maybe other properties being resolved and this was
|
// that forced file icon and maybe other properties being resolved and this was
|
||||||
// a blocking operation.
|
// a blocking operation.
|
||||||
auto helperPath = cDialogHelperPathFinal();
|
auto helperPath = cDialogHelperPathFinal();
|
||||||
QFileDialog dialog(App::wnd() ? App::wnd()->filedialogParent() : 0, caption, helperPath, filter);
|
auto parent = Messenger::Instance().getFileDialogParent();
|
||||||
|
QFileDialog dialog(parent, caption, helperPath, filter);
|
||||||
|
|
||||||
dialog.setModal(true);
|
dialog.setModal(true);
|
||||||
if (type == Type::ReadFile || type == Type::ReadFiles) {
|
if (type == Type::ReadFile || type == Type::ReadFiles) {
|
||||||
|
|
|
@ -106,7 +106,7 @@ PhotoData *CoverWidget::validatePhoto() const {
|
||||||
|
|
||||||
void CoverWidget::onPhotoShow() {
|
void CoverWidget::onPhotoShow() {
|
||||||
if (auto photo = validatePhoto()) {
|
if (auto photo = validatePhoto()) {
|
||||||
App::wnd()->showPhoto(photo, _peer);
|
Messenger::Instance().showPhoto(photo, _peer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ PhotoData *CoverWidget::validatePhoto() const {
|
||||||
|
|
||||||
void CoverWidget::onPhotoShow() {
|
void CoverWidget::onPhotoShow() {
|
||||||
if (auto photo = validatePhoto()) {
|
if (auto photo = validatePhoto()) {
|
||||||
App::wnd()->showPhoto(photo, _self);
|
Messenger::Instance().showPhoto(photo, _self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,11 @@ bool minimize_telegram() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool close_telegram() {
|
bool close_telegram() {
|
||||||
if (!Ui::hideWindowNoQuit()) {
|
if (!Messenger::Instance().hideMediaView()) {
|
||||||
if (auto w = App::wnd()) {
|
if (!Ui::hideWindowNoQuit()) {
|
||||||
w->close();
|
if (auto w = App::wnd()) {
|
||||||
|
w->close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -251,7 +253,7 @@ QKeySequence setShortcut(const QString &keys, const QString &command) {
|
||||||
if (it == DataPtr->commands.cend()) {
|
if (it == DataPtr->commands.cend()) {
|
||||||
LOG(("Warning: could not find shortcut command handler '%1'").arg(command));
|
LOG(("Warning: could not find shortcut command handler '%1'").arg(command));
|
||||||
} else {
|
} else {
|
||||||
auto shortcut = std::make_unique<QShortcut>(seq, App::wnd(), nullptr, nullptr, Qt::ApplicationShortcut);
|
auto shortcut = std::make_unique<QShortcut>(seq, Messenger::Instance().getGlobalShortcutParent(), nullptr, nullptr, Qt::ApplicationShortcut);
|
||||||
if (!DataPtr->autoRepeatCommands.contains(command)) {
|
if (!DataPtr->autoRepeatCommands.contains(command)) {
|
||||||
shortcut->setAutoRepeat(false);
|
shortcut->setAutoRepeat(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1234,7 +1234,7 @@ ImagePtr PhotoData::makeReplyPreview() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhotoOpenClickHandler::onClickImpl() const {
|
void PhotoOpenClickHandler::onClickImpl() const {
|
||||||
App::wnd()->showPhoto(this, App::hoveredLinkItem() ? App::hoveredLinkItem() : App::contextItem());
|
Messenger::Instance().showPhoto(this, App::hoveredLinkItem() ? App::hoveredLinkItem() : App::contextItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhotoSaveClickHandler::onClickImpl() const {
|
void PhotoSaveClickHandler::onClickImpl() const {
|
||||||
|
@ -1440,7 +1440,7 @@ void DocumentOpenClickHandler::doOpen(DocumentData *data, HistoryItem *context,
|
||||||
auto &location = data->location(true);
|
auto &location = data->location(true);
|
||||||
if (auto applyTheme = data->isTheme()) {
|
if (auto applyTheme = data->isTheme()) {
|
||||||
if (!location.isEmpty() && location.accessEnable()) {
|
if (!location.isEmpty() && location.accessEnable()) {
|
||||||
App::wnd()->showDocument(data, context);
|
Messenger::Instance().showDocument(data, context);
|
||||||
location.accessDisable();
|
location.accessDisable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1478,9 +1478,9 @@ void DocumentOpenClickHandler::doOpen(DocumentData *data, HistoryItem *context,
|
||||||
}
|
}
|
||||||
} else if (playVideo) {
|
} else if (playVideo) {
|
||||||
if (!data->data().isEmpty()) {
|
if (!data->data().isEmpty()) {
|
||||||
App::wnd()->showDocument(data, context);
|
Messenger::Instance().showDocument(data, context);
|
||||||
} else if (location.accessEnable()) {
|
} else if (location.accessEnable()) {
|
||||||
App::wnd()->showDocument(data, context);
|
Messenger::Instance().showDocument(data, context);
|
||||||
location.accessDisable();
|
location.accessDisable();
|
||||||
} else {
|
} else {
|
||||||
auto filepath = location.name();
|
auto filepath = location.name();
|
||||||
|
@ -1500,14 +1500,14 @@ void DocumentOpenClickHandler::doOpen(DocumentData *data, HistoryItem *context,
|
||||||
if (action == ActionOnLoadPlayInline && context && context->getMedia()) {
|
if (action == ActionOnLoadPlayInline && context && context->getMedia()) {
|
||||||
context->getMedia()->playInline();
|
context->getMedia()->playInline();
|
||||||
} else {
|
} else {
|
||||||
App::wnd()->showDocument(data, context);
|
Messenger::Instance().showDocument(data, context);
|
||||||
}
|
}
|
||||||
} else if (location.accessEnable()) {
|
} else if (location.accessEnable()) {
|
||||||
if (data->isAnimation() || QImageReader(location.name()).canRead()) {
|
if (data->isAnimation() || QImageReader(location.name()).canRead()) {
|
||||||
if (action == ActionOnLoadPlayInline && context && context->getMedia()) {
|
if (action == ActionOnLoadPlayInline && context && context->getMedia()) {
|
||||||
context->getMedia()->playInline();
|
context->getMedia()->playInline();
|
||||||
} else {
|
} else {
|
||||||
App::wnd()->showDocument(data, context);
|
Messenger::Instance().showDocument(data, context);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
File::Launch(location.name());
|
File::Launch(location.name());
|
||||||
|
@ -1748,7 +1748,7 @@ void DocumentData::performActionOnLoad() {
|
||||||
auto playAnimation = isAnimation() && (_actionOnLoad == ActionOnLoadPlayInline || _actionOnLoad == ActionOnLoadOpen) && showImage && item && item->getMedia();
|
auto playAnimation = isAnimation() && (_actionOnLoad == ActionOnLoadPlayInline || _actionOnLoad == ActionOnLoadOpen) && showImage && item && item->getMedia();
|
||||||
if (auto applyTheme = isTheme()) {
|
if (auto applyTheme = isTheme()) {
|
||||||
if (!loc.isEmpty() && loc.accessEnable()) {
|
if (!loc.isEmpty() && loc.accessEnable()) {
|
||||||
App::wnd()->showDocument(this, item);
|
Messenger::Instance().showDocument(this, item);
|
||||||
loc.accessDisable();
|
loc.accessDisable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1788,7 +1788,7 @@ void DocumentData::performActionOnLoad() {
|
||||||
if (_actionOnLoad == ActionOnLoadPlayInline && item->getMedia()) {
|
if (_actionOnLoad == ActionOnLoadPlayInline && item->getMedia()) {
|
||||||
item->getMedia()->playInline();
|
item->getMedia()->playInline();
|
||||||
} else {
|
} else {
|
||||||
App::wnd()->showDocument(this, item);
|
Messenger::Instance().showDocument(this, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1807,7 +1807,7 @@ void DocumentData::performActionOnLoad() {
|
||||||
if (_actionOnLoad == ActionOnLoadPlayInline && item && item->getMedia()) {
|
if (_actionOnLoad == ActionOnLoadPlayInline && item && item->getMedia()) {
|
||||||
item->getMedia()->playInline();
|
item->getMedia()->playInline();
|
||||||
} else {
|
} else {
|
||||||
App::wnd()->showDocument(this, item);
|
Messenger::Instance().showDocument(this, item);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
File::Launch(already);
|
File::Launch(already);
|
||||||
|
|
|
@ -478,11 +478,9 @@ PopupMenu::~PopupMenu() {
|
||||||
for (auto submenu : base::take(_submenus)) {
|
for (auto submenu : base::take(_submenus)) {
|
||||||
delete submenu;
|
delete submenu;
|
||||||
}
|
}
|
||||||
#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64
|
|
||||||
if (auto w = App::wnd()) {
|
if (auto w = App::wnd()) {
|
||||||
w->reActivateWindow();
|
w->reActivateWindow();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (_destroyedCallback) {
|
if (_destroyedCallback) {
|
||||||
_destroyedCallback();
|
_destroyedCallback();
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,10 +80,6 @@ MainWindow::MainWindow() : QWidget()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::hideNoQuit() {
|
bool MainWindow::hideNoQuit() {
|
||||||
if (_mediaView && !_mediaView->isHidden()) {
|
|
||||||
hideMediaview();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (Global::WorkMode().value() == dbiwmTrayOnly || Global::WorkMode().value() == dbiwmWindowAndTray) {
|
if (Global::WorkMode().value() == dbiwmTrayOnly || Global::WorkMode().value() == dbiwmWindowAndTray) {
|
||||||
if (minimizeToTray()) {
|
if (minimizeToTray()) {
|
||||||
Ui::showChatsList();
|
Ui::showChatsList();
|
||||||
|
@ -101,48 +97,10 @@ bool MainWindow::hideNoQuit() {
|
||||||
|
|
||||||
void MainWindow::clearWidgets() {
|
void MainWindow::clearWidgets() {
|
||||||
Ui::hideLayer(true);
|
Ui::hideLayer(true);
|
||||||
if (_mediaView) {
|
|
||||||
hideMediaview();
|
|
||||||
_mediaView->rpcClear();
|
|
||||||
_mediaView->clearData();
|
|
||||||
}
|
|
||||||
clearWidgetsHook();
|
clearWidgetsHook();
|
||||||
updateGlobalMenu();
|
updateGlobalMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showPhoto(const PhotoOpenClickHandler *lnk, HistoryItem *item) {
|
|
||||||
return (!item && lnk->peer()) ? showPhoto(lnk->photo(), lnk->peer()) : showPhoto(lnk->photo(), item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::showPhoto(PhotoData *photo, HistoryItem *item) {
|
|
||||||
if (_mediaView->isHidden()) Ui::hideLayer(true);
|
|
||||||
_mediaView->showPhoto(photo, item);
|
|
||||||
_mediaView->activateWindow();
|
|
||||||
_mediaView->setFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::showPhoto(PhotoData *photo, PeerData *peer) {
|
|
||||||
if (_mediaView->isHidden()) Ui::hideLayer(true);
|
|
||||||
_mediaView->showPhoto(photo, peer);
|
|
||||||
_mediaView->activateWindow();
|
|
||||||
_mediaView->setFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::showDocument(DocumentData *doc, HistoryItem *item) {
|
|
||||||
if (cUseExternalVideoPlayer() && doc->isVideo()) {
|
|
||||||
QDesktopServices::openUrl(QUrl("file:///" + doc->location(false).fname));
|
|
||||||
} else {
|
|
||||||
if (_mediaView->isHidden()) Ui::hideLayer(true);
|
|
||||||
_mediaView->showDocument(doc, item);
|
|
||||||
_mediaView->activateWindow();
|
|
||||||
_mediaView->setFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MainWindow::ui_isMediaViewShown() {
|
|
||||||
return _mediaView && !_mediaView->isHidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::updateIsActive(int timeout) {
|
void MainWindow::updateIsActive(int timeout) {
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
return _isActiveTimer.callOnce(timeout);
|
return _isActiveTimer.callOnce(timeout);
|
||||||
|
@ -155,15 +113,6 @@ bool MainWindow::computeIsActive() const {
|
||||||
return isActiveWindow() && isVisible() && !(windowState() & Qt::WindowMinimized);
|
return isActiveWindow() && isVisible() && !(windowState() & Qt::WindowMinimized);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::hideMediaview() {
|
|
||||||
if (_mediaView && !_mediaView->isHidden()) {
|
|
||||||
_mediaView->hide();
|
|
||||||
#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64
|
|
||||||
reActivateWindow();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onReActivate() {
|
void MainWindow::onReActivate() {
|
||||||
if (auto w = App::wnd()) {
|
if (auto w = App::wnd()) {
|
||||||
if (auto f = QApplication::focusWidget()) {
|
if (auto f = QApplication::focusWidget()) {
|
||||||
|
@ -178,14 +127,6 @@ void MainWindow::onReActivate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *MainWindow::filedialogParent() {
|
|
||||||
return (_mediaView && _mediaView->isVisible()) ? (QWidget*)_mediaView : (QWidget*)this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::createMediaView() {
|
|
||||||
_mediaView.create(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::updateWindowIcon() {
|
void MainWindow::updateWindowIcon() {
|
||||||
setWindowIcon(_icon);
|
setWindowIcon(_icon);
|
||||||
}
|
}
|
||||||
|
@ -221,9 +162,8 @@ void MainWindow::handleStateChanged(Qt::WindowState state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::handleActiveChanged() {
|
void MainWindow::handleActiveChanged() {
|
||||||
if (isActiveWindow() && _mediaView && !_mediaView->isHidden()) {
|
if (isActiveWindow()) {
|
||||||
_mediaView->activateWindow();
|
Messenger::Instance().checkMediaViewActivation();
|
||||||
_mediaView->setFocus();
|
|
||||||
}
|
}
|
||||||
App::CallDelayed(1, this, [this] {
|
App::CallDelayed(1, this, [this] {
|
||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
|
@ -438,23 +378,6 @@ void MainWindow::tryToExtendWidthBy(int addToWidth) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::documentUpdated(DocumentData *doc) {
|
|
||||||
if (!_mediaView || _mediaView->isHidden()) return;
|
|
||||||
_mediaView->documentUpdated(doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::changingMsgId(HistoryItem *row, MsgId newId) {
|
|
||||||
if (!_mediaView || _mediaView->isHidden()) return;
|
|
||||||
_mediaView->changingMsgId(row, newId);
|
|
||||||
}
|
|
||||||
|
|
||||||
PeerData *MainWindow::ui_getPeerForMouseAction() {
|
|
||||||
if (_mediaView && !_mediaView->isHidden()) {
|
|
||||||
return _mediaView->ui_getPeerForMouseAction();
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::launchDrag(std::unique_ptr<QMimeData> data) {
|
void MainWindow::launchDrag(std::unique_ptr<QMimeData> data) {
|
||||||
auto weak = QPointer<MainWindow>(this);
|
auto weak = QPointer<MainWindow>(this);
|
||||||
auto drag = std::make_unique<QDrag>(App::wnd());
|
auto drag = std::make_unique<QDrag>(App::wnd());
|
||||||
|
|
|
@ -49,7 +49,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hideNoQuit();
|
bool hideNoQuit();
|
||||||
void hideMediaview();
|
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
HitTestResult hitTest(const QPoint &p) const;
|
HitTestResult hitTest(const QPoint &p) const;
|
||||||
|
@ -70,18 +69,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void reActivateWindow() {
|
void reActivateWindow() {
|
||||||
|
#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64
|
||||||
onReActivate();
|
onReActivate();
|
||||||
QTimer::singleShot(200, this, SLOT(onReActivate()));
|
QTimer::singleShot(200, this, SLOT(onReActivate()));
|
||||||
|
#endif // Q_OS_LINUX32 || Q_OS_LINUX64
|
||||||
}
|
}
|
||||||
|
|
||||||
void showPhoto(const PhotoOpenClickHandler *lnk, HistoryItem *item = 0);
|
|
||||||
void showPhoto(PhotoData *photo, HistoryItem *item);
|
|
||||||
void showPhoto(PhotoData *photo, PeerData *item);
|
|
||||||
void showDocument(DocumentData *doc, HistoryItem *item);
|
|
||||||
bool ui_isMediaViewShown();
|
|
||||||
|
|
||||||
QWidget *filedialogParent();
|
|
||||||
|
|
||||||
void showRightColumn(object_ptr<TWidget> widget);
|
void showRightColumn(object_ptr<TWidget> widget);
|
||||||
bool canExtendWidthBy(int addToWidth);
|
bool canExtendWidthBy(int addToWidth);
|
||||||
void tryToExtendWidthBy(int addToWidth);
|
void tryToExtendWidthBy(int addToWidth);
|
||||||
|
@ -89,16 +82,11 @@ public:
|
||||||
virtual void updateTrayMenu(bool force = false) {
|
virtual void updateTrayMenu(bool force = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: rewrite using base::Observable
|
|
||||||
void documentUpdated(DocumentData *doc);
|
|
||||||
virtual void changingMsgId(HistoryItem *row, MsgId newId);
|
|
||||||
|
|
||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
|
|
||||||
TWidget *bodyWidget() {
|
TWidget *bodyWidget() {
|
||||||
return _body.data();
|
return _body.data();
|
||||||
}
|
}
|
||||||
virtual PeerData *ui_getPeerForMouseAction();
|
|
||||||
|
|
||||||
void launchDrag(std::unique_ptr<QMimeData> data);
|
void launchDrag(std::unique_ptr<QMimeData> data);
|
||||||
base::Observable<void> &dragFinished() {
|
base::Observable<void> &dragFinished() {
|
||||||
|
@ -165,8 +153,6 @@ protected:
|
||||||
|
|
||||||
void setPositionInited();
|
void setPositionInited();
|
||||||
|
|
||||||
void createMediaView();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void savePositionByTimer() {
|
void savePositionByTimer() {
|
||||||
savePosition();
|
savePosition();
|
||||||
|
@ -197,8 +183,6 @@ private:
|
||||||
bool _wasInactivePress = false;
|
bool _wasInactivePress = false;
|
||||||
base::Timer _inactivePressTimer;
|
base::Timer _inactivePressTimer;
|
||||||
|
|
||||||
object_ptr<MediaView> _mediaView = { nullptr };
|
|
||||||
|
|
||||||
base::Observable<void> _dragFinished;
|
base::Observable<void> _dragFinished;
|
||||||
base::Observable<void> _widgetGrabbed;
|
base::Observable<void> _widgetGrabbed;
|
||||||
|
|
||||||
|
|
|
@ -384,9 +384,7 @@ void Manager::notificationActivated(PeerId peerId, MsgId msgId) {
|
||||||
if (auto window = App::wnd()) {
|
if (auto window = App::wnd()) {
|
||||||
auto history = App::history(peerId);
|
auto history = App::history(peerId);
|
||||||
window->showFromTray();
|
window->showFromTray();
|
||||||
#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64
|
|
||||||
window->reActivateWindow();
|
window->reActivateWindow();
|
||||||
#endif
|
|
||||||
if (App::passcoded()) {
|
if (App::passcoded()) {
|
||||||
window->setInnerFocus();
|
window->setInnerFocus();
|
||||||
system()->clearAll();
|
system()->clearAll();
|
||||||
|
|
Loading…
Reference in New Issue