mirror of https://github.com/procxx/kepka.git
Activate mediaview instead of main window.
If the mediaview is currently shown and we receive an activation event for the main window we should activate and focus mediaview.
This commit is contained in:
parent
5915f3f928
commit
1e6d4d6b41
|
@ -148,33 +148,11 @@ void MainWindow::onInactiveTimer() {
|
||||||
inactivePress(false);
|
inactivePress(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onStateChanged(Qt::WindowState state) {
|
|
||||||
stateChangedHook(state);
|
|
||||||
|
|
||||||
psUserActionDone();
|
|
||||||
|
|
||||||
updateIsActive((state == Qt::WindowMinimized) ? Global::OfflineBlurTimeout() : Global::OnlineFocusTimeout());
|
|
||||||
|
|
||||||
psUpdateSysMenu(state);
|
|
||||||
if (state == Qt::WindowMinimized && Global::WorkMode().value() == dbiwmTrayOnly) {
|
|
||||||
App::wnd()->minimizeToTray();
|
|
||||||
}
|
|
||||||
savePosition(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::initHook() {
|
void MainWindow::initHook() {
|
||||||
Platform::MainWindow::initHook();
|
Platform::MainWindow::initHook();
|
||||||
|
|
||||||
QCoreApplication::instance()->installEventFilter(this);
|
QCoreApplication::instance()->installEventFilter(this);
|
||||||
connect(windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(onStateChanged(Qt::WindowState)));
|
connect(windowHandle(), &QWindow::activeChanged, this, [this] { checkHistoryActivation(); }, Qt::QueuedConnection);
|
||||||
connect(windowHandle(), SIGNAL(activeChanged()), this, SLOT(onWindowActiveChanged()), Qt::QueuedConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::onWindowActiveChanged() {
|
|
||||||
checkHistoryActivation();
|
|
||||||
QTimer::singleShot(1, base::lambda_slot_once(this, [this] {
|
|
||||||
updateTrayMenu();
|
|
||||||
}), SLOT(action()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::firstShow() {
|
void MainWindow::firstShow() {
|
||||||
|
@ -333,7 +311,6 @@ void MainWindow::setupMain(const MTPUser *self) {
|
||||||
|
|
||||||
t_assert(AuthSession::Exists());
|
t_assert(AuthSession::Exists());
|
||||||
|
|
||||||
|
|
||||||
_main.create(bodyWidget(), controller());
|
_main.create(bodyWidget(), controller());
|
||||||
_main->show();
|
_main->show();
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
|
@ -589,7 +566,7 @@ void MainWindow::setInnerFocus() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::eventFilter(QObject *obj, QEvent *e) {
|
bool MainWindow::eventFilter(QObject *object, QEvent *e) {
|
||||||
switch (e->type()) {
|
switch (e->type()) {
|
||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
case QEvent::KeyPress:
|
case QEvent::KeyPress:
|
||||||
|
@ -620,14 +597,16 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *e) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEvent::ApplicationActivate:
|
case QEvent::ApplicationActivate:
|
||||||
if (obj == QCoreApplication::instance()) {
|
if (object == QCoreApplication::instance()) {
|
||||||
psUserActionDone();
|
psUserActionDone();
|
||||||
QTimer::singleShot(1, this, SLOT(onWindowActiveChanged()));
|
App::CallDelayed(1, this, [this] {
|
||||||
|
handleActiveChanged();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEvent::FileOpen:
|
case QEvent::FileOpen:
|
||||||
if (obj == QCoreApplication::instance()) {
|
if (object == QCoreApplication::instance()) {
|
||||||
QString url = static_cast<QFileOpenEvent*>(e)->url().toEncoded().trimmed();
|
QString url = static_cast<QFileOpenEvent*>(e)->url().toEncoded().trimmed();
|
||||||
if (url.startsWith(qstr("tg://"), Qt::CaseInsensitive)) {
|
if (url.startsWith(qstr("tg://"), Qt::CaseInsensitive)) {
|
||||||
cSetStartUrl(url.mid(0, 8192));
|
cSetStartUrl(url.mid(0, 8192));
|
||||||
|
@ -640,21 +619,23 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *e) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEvent::WindowStateChange:
|
case QEvent::WindowStateChange:
|
||||||
if (obj == this) {
|
if (object == this) {
|
||||||
Qt::WindowState state = (windowState() & Qt::WindowMinimized) ? Qt::WindowMinimized : ((windowState() & Qt::WindowMaximized) ? Qt::WindowMaximized : ((windowState() & Qt::WindowFullScreen) ? Qt::WindowFullScreen : Qt::WindowNoState));
|
auto state = (windowState() & Qt::WindowMinimized) ? Qt::WindowMinimized :
|
||||||
onStateChanged(state);
|
((windowState() & Qt::WindowMaximized) ? Qt::WindowMaximized :
|
||||||
|
((windowState() & Qt::WindowFullScreen) ? Qt::WindowFullScreen : Qt::WindowNoState));
|
||||||
|
handleStateChanged(state);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEvent::Move:
|
case QEvent::Move:
|
||||||
case QEvent::Resize:
|
case QEvent::Resize:
|
||||||
if (obj == this) {
|
if (object == this) {
|
||||||
positionUpdated();
|
positionUpdated();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Platform::MainWindow::eventFilter(obj, e);
|
return Platform::MainWindow::eventFilter(object, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateTrayMenu(bool force) {
|
void MainWindow::updateTrayMenu(bool force) {
|
||||||
|
@ -774,10 +755,10 @@ void MainWindow::fixOrder() {
|
||||||
|
|
||||||
void MainWindow::showFromTray(QSystemTrayIcon::ActivationReason reason) {
|
void MainWindow::showFromTray(QSystemTrayIcon::ActivationReason reason) {
|
||||||
if (reason != QSystemTrayIcon::Context) {
|
if (reason != QSystemTrayIcon::Context) {
|
||||||
QTimer::singleShot(1, base::lambda_slot_once(this, [this] {
|
App::CallDelayed(1, this, [this] {
|
||||||
updateTrayMenu();
|
updateTrayMenu();
|
||||||
updateGlobalMenu();
|
updateGlobalMenu();
|
||||||
}), SLOT(action()));
|
});
|
||||||
activate();
|
activate();
|
||||||
Notify::unreadCounterUpdated();
|
Notify::unreadCounterUpdated();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "platform/platform_main_window.h"
|
#include "platform/platform_main_window.h"
|
||||||
#include "core/single_timer.h"
|
#include "core/single_timer.h"
|
||||||
|
|
||||||
class MediaView;
|
|
||||||
class PasscodeWidget;
|
class PasscodeWidget;
|
||||||
class MainWidget;
|
class MainWidget;
|
||||||
class LayerStackWidget;
|
class LayerStackWidget;
|
||||||
|
@ -188,11 +187,6 @@ signals:
|
||||||
void tempDirClearFailed(int task);
|
void tempDirClearFailed(int task);
|
||||||
void checkNewAuthorization();
|
void checkNewAuthorization();
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onStateChanged(Qt::WindowState state);
|
|
||||||
|
|
||||||
void onWindowActiveChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkAuthSession();
|
void checkAuthSession();
|
||||||
void showConnecting(const QString &text, const QString &reconnect = QString());
|
void showConnecting(const QString &text, const QString &reconnect = QString());
|
||||||
|
|
|
@ -567,9 +567,6 @@ void MainWindow::psFirstShow() {
|
||||||
void MainWindow::psInitSysMenu() {
|
void MainWindow::psInitSysMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::psUpdateSysMenu(Qt::WindowState state) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::psUpdateMargins() {
|
void MainWindow::psUpdateMargins() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ public:
|
||||||
|
|
||||||
void psFirstShow();
|
void psFirstShow();
|
||||||
void psInitSysMenu();
|
void psInitSysMenu();
|
||||||
void psUpdateSysMenu(Qt::WindowState state);
|
|
||||||
void psUpdateMargins();
|
void psUpdateMargins();
|
||||||
|
|
||||||
void psRefreshTaskbarIcon() {
|
void psRefreshTaskbarIcon() {
|
||||||
|
|
|
@ -34,7 +34,6 @@ public:
|
||||||
|
|
||||||
void psFirstShow();
|
void psFirstShow();
|
||||||
void psInitSysMenu();
|
void psInitSysMenu();
|
||||||
void psUpdateSysMenu(Qt::WindowState state);
|
|
||||||
void psUpdateMargins();
|
void psUpdateMargins();
|
||||||
|
|
||||||
void psRefreshTaskbarIcon() {
|
void psRefreshTaskbarIcon() {
|
||||||
|
|
|
@ -496,9 +496,6 @@ void MainWindow::psMacSelectAll() {
|
||||||
void MainWindow::psInitSysMenu() {
|
void MainWindow::psInitSysMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::psUpdateSysMenu(Qt::WindowState state) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::psUpdateMargins() {
|
void MainWindow::psUpdateMargins() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -829,13 +829,17 @@ void MainWindow::psFirstShow() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::stateChangedHook(Qt::WindowState state) {
|
||||||
|
updateSystemMenu(state);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::psInitSysMenu() {
|
void MainWindow::psInitSysMenu() {
|
||||||
Qt::WindowStates states = windowState();
|
Qt::WindowStates states = windowState();
|
||||||
ps_menu = GetSystemMenu(ps_hWnd, FALSE);
|
ps_menu = GetSystemMenu(ps_hWnd, FALSE);
|
||||||
psUpdateSysMenu(windowHandle()->windowState());
|
updateSystemMenu(windowHandle()->windowState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::psUpdateSysMenu(Qt::WindowState state) {
|
void MainWindow::updateSystemMenu(Qt::WindowState state) {
|
||||||
if (!ps_menu) return;
|
if (!ps_menu) return;
|
||||||
|
|
||||||
int menuToDisable = SC_RESTORE;
|
int menuToDisable = SC_RESTORE;
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
|
|
||||||
void psFirstShow();
|
void psFirstShow();
|
||||||
void psInitSysMenu();
|
void psInitSysMenu();
|
||||||
void psUpdateSysMenu(Qt::WindowState state);
|
void updateSystemMenu(Qt::WindowState state);
|
||||||
void psUpdateMargins();
|
void psUpdateMargins();
|
||||||
|
|
||||||
void psRefreshTaskbarIcon();
|
void psRefreshTaskbarIcon();
|
||||||
|
@ -86,6 +86,8 @@ protected:
|
||||||
int32 screenNameChecksum(const QString &name) const override;
|
int32 screenNameChecksum(const QString &name) const override;
|
||||||
void unreadCounterChangedHook() override;
|
void unreadCounterChangedHook() override;
|
||||||
|
|
||||||
|
void stateChangedHook(Qt::WindowState state) override;
|
||||||
|
|
||||||
bool hasTrayIcon() const override {
|
bool hasTrayIcon() const override {
|
||||||
return trayIcon;
|
return trayIcon;
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ bool EventFilter::mainWindowEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
|
||||||
case WM_SYSCOMMAND: {
|
case WM_SYSCOMMAND: {
|
||||||
if (wParam == SC_MOUSEMENU) {
|
if (wParam == SC_MOUSEMENU) {
|
||||||
POINTS p = MAKEPOINTS(lParam);
|
POINTS p = MAKEPOINTS(lParam);
|
||||||
App::wnd()->psUpdateSysMenu(App::wnd()->windowHandle()->windowState());
|
App::wnd()->updateSystemMenu(App::wnd()->windowHandle()->windowState());
|
||||||
TrackPopupMenu(App::wnd()->psMenu(), TPM_LEFTALIGN | TPM_TOPALIGN | TPM_LEFTBUTTON, p.x, p.y, 0, hWnd, 0);
|
TrackPopupMenu(App::wnd()->psMenu(), TPM_LEFTALIGN | TPM_TOPALIGN | TPM_LEFTBUTTON, p.x, p.y, 0, hWnd, 0);
|
||||||
}
|
}
|
||||||
} return false;
|
} return false;
|
||||||
|
|
|
@ -190,6 +190,9 @@ void MainWindow::init() {
|
||||||
initHook();
|
initHook();
|
||||||
updateWindowIcon();
|
updateWindowIcon();
|
||||||
|
|
||||||
|
connect(windowHandle(), &QWindow::activeChanged, this, [this] { handleActiveChanged(); }, Qt::QueuedConnection);
|
||||||
|
connect(windowHandle(), &QWindow::windowStateChanged, this, [this](Qt::WindowState state) { handleStateChanged(state); });
|
||||||
|
|
||||||
_positionUpdatedTimer->setSingleShot(true);
|
_positionUpdatedTimer->setSingleShot(true);
|
||||||
connect(_positionUpdatedTimer, SIGNAL(timeout()), this, SLOT(savePositionByTimer()));
|
connect(_positionUpdatedTimer, SIGNAL(timeout()), this, SLOT(savePositionByTimer()));
|
||||||
|
|
||||||
|
@ -203,6 +206,26 @@ void MainWindow::init() {
|
||||||
updateUnreadCounter();
|
updateUnreadCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::handleStateChanged(Qt::WindowState state) {
|
||||||
|
stateChangedHook(state);
|
||||||
|
updateIsActive((state == Qt::WindowMinimized) ? Global::OfflineBlurTimeout() : Global::OnlineFocusTimeout());
|
||||||
|
psUserActionDone();
|
||||||
|
if (state == Qt::WindowMinimized && Global::WorkMode().value() == dbiwmTrayOnly) {
|
||||||
|
minimizeToTray();
|
||||||
|
}
|
||||||
|
savePosition(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::handleActiveChanged() {
|
||||||
|
if (isActiveWindow() && _mediaView && !_mediaView->isHidden()) {
|
||||||
|
_mediaView->activateWindow();
|
||||||
|
_mediaView->setFocus();
|
||||||
|
}
|
||||||
|
App::CallDelayed(1, this, [this] {
|
||||||
|
updateTrayMenu();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::updatePalette() {
|
void MainWindow::updatePalette() {
|
||||||
auto p = palette();
|
auto p = palette();
|
||||||
p.setColor(QPalette::Window, st::windowBg->c);
|
p.setColor(QPalette::Window, st::windowBg->c);
|
||||||
|
|
|
@ -100,6 +100,8 @@ protected:
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
void savePosition(Qt::WindowState state = Qt::WindowActive);
|
void savePosition(Qt::WindowState state = Qt::WindowActive);
|
||||||
|
void handleStateChanged(Qt::WindowState state);
|
||||||
|
void handleActiveChanged();
|
||||||
|
|
||||||
virtual void initHook() {
|
virtual void initHook() {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue