mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Handle channel event log mouse events.
This commit is contained in:
@@ -24,12 +24,15 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
#include "styles/style_window.h"
|
||||
#include "platform/platform_window_title.h"
|
||||
#include "window/themes/window_theme.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "mediaview.h"
|
||||
#include "messenger.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
namespace Window {
|
||||
|
||||
constexpr auto kInactivePressTimeout = 200;
|
||||
|
||||
QImage LoadLogo() {
|
||||
return QImage(qsl(":/gui/art/logo_256.png"));
|
||||
}
|
||||
@@ -58,8 +61,7 @@ MainWindow::MainWindow() : QWidget()
|
||||
, _positionUpdatedTimer(this)
|
||||
, _body(this)
|
||||
, _icon(CreateIcon())
|
||||
, _titleText(qsl("Telegram"))
|
||||
, _isActiveTimer(this) {
|
||||
, _titleText(qsl("Telegram")) {
|
||||
subscribe(Theme::Background(), [this](const Theme::BackgroundUpdate &data) {
|
||||
if (data.paletteChanged()) {
|
||||
if (_title) {
|
||||
@@ -70,9 +72,11 @@ MainWindow::MainWindow() : QWidget()
|
||||
});
|
||||
subscribe(Global::RefUnreadCounterUpdate(), [this] { updateUnreadCounter(); });
|
||||
subscribe(Global::RefWorkMode(), [this](DBIWorkMode mode) { workmodeUpdated(mode); });
|
||||
subscribe(Messenger::Instance().authSessionChanged(), [this] { checkAuthSession(); });
|
||||
checkAuthSession();
|
||||
|
||||
_isActiveTimer->setSingleShot(true);
|
||||
connect(_isActiveTimer, SIGNAL(timeout()), this, SLOT(updateIsActiveByTimer()));
|
||||
_isActiveTimer.setCallback([this] { updateIsActive(0); });
|
||||
_inactivePressTimer.setCallback([this] { setInactivePress(false); });
|
||||
}
|
||||
|
||||
bool MainWindow::hideNoQuit() {
|
||||
@@ -140,8 +144,8 @@ bool MainWindow::ui_isMediaViewShown() {
|
||||
}
|
||||
|
||||
void MainWindow::updateIsActive(int timeout) {
|
||||
if (timeout) {
|
||||
return _isActiveTimer->start(timeout);
|
||||
if (timeout > 0) {
|
||||
return _isActiveTimer.callOnce(timeout);
|
||||
}
|
||||
_isActive = computeIsActive();
|
||||
updateIsActiveHook();
|
||||
@@ -433,6 +437,36 @@ PeerData *MainWindow::ui_getPeerForMouseAction() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MainWindow::launchDrag(std::unique_ptr<QMimeData> data) {
|
||||
auto weak = QPointer<MainWindow>(this);
|
||||
auto drag = std::make_unique<QDrag>(App::wnd());
|
||||
drag->setMimeData(data.release());
|
||||
drag->exec(Qt::CopyAction);
|
||||
|
||||
// We don't receive mouseReleaseEvent when drag is finished.
|
||||
ClickHandler::unpressed();
|
||||
if (weak) {
|
||||
weak->dragFinished().notify();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::checkAuthSession() {
|
||||
if (AuthSession::Exists()) {
|
||||
_controller = std::make_unique<Window::Controller>(this);
|
||||
} else {
|
||||
_controller = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setInactivePress(bool inactive) {
|
||||
_wasInactivePress = inactive;
|
||||
if (_wasInactivePress) {
|
||||
_inactivePressTimer.callOnce(kInactivePressTimeout);
|
||||
} else {
|
||||
_inactivePressTimer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() = default;
|
||||
|
||||
} // namespace Window
|
||||
|
@@ -21,11 +21,13 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
#pragma once
|
||||
|
||||
#include "window/window_title.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
class MediaView;
|
||||
|
||||
namespace Window {
|
||||
|
||||
class Controller;
|
||||
class TitleWidget;
|
||||
|
||||
QImage LoadLogo();
|
||||
@@ -38,6 +40,14 @@ class MainWindow : public QWidget, protected base::Subscriber {
|
||||
public:
|
||||
MainWindow();
|
||||
|
||||
Window::Controller *controller() const {
|
||||
return _controller.get();
|
||||
}
|
||||
void setInactivePress(bool inactive);
|
||||
bool wasInactivePress() const {
|
||||
return _wasInactivePress;
|
||||
}
|
||||
|
||||
bool hideNoQuit();
|
||||
void hideMediaview();
|
||||
|
||||
@@ -90,6 +100,14 @@ public:
|
||||
}
|
||||
virtual PeerData *ui_getPeerForMouseAction();
|
||||
|
||||
void launchDrag(std::unique_ptr<QMimeData> data);
|
||||
base::Observable<void> &dragFinished() {
|
||||
return _dragFinished;
|
||||
}
|
||||
base::Observable<void> &widgetGrabbed() {
|
||||
return _widgetGrabbed;
|
||||
}
|
||||
|
||||
public slots:
|
||||
bool minimizeToTray();
|
||||
void updateGlobalMenu() {
|
||||
@@ -154,11 +172,9 @@ private slots:
|
||||
savePosition();
|
||||
}
|
||||
void onReActivate();
|
||||
void updateIsActiveByTimer() {
|
||||
updateIsActive(0);
|
||||
}
|
||||
|
||||
private:
|
||||
void checkAuthSession();
|
||||
void updatePalette();
|
||||
void updateUnreadCounter();
|
||||
void initSize();
|
||||
@@ -168,6 +184,7 @@ private:
|
||||
object_ptr<QTimer> _positionUpdatedTimer;
|
||||
bool _positionInited = false;
|
||||
|
||||
std::unique_ptr<Window::Controller> _controller;
|
||||
object_ptr<TitleWidget> _title = { nullptr };
|
||||
object_ptr<TWidget> _body;
|
||||
object_ptr<TWidget> _rightColumn = { nullptr };
|
||||
@@ -175,11 +192,16 @@ private:
|
||||
QIcon _icon;
|
||||
QString _titleText;
|
||||
|
||||
object_ptr<QTimer> _isActiveTimer;
|
||||
bool _isActive = false;
|
||||
base::Timer _isActiveTimer;
|
||||
bool _wasInactivePress = false;
|
||||
base::Timer _inactivePressTimer;
|
||||
|
||||
object_ptr<MediaView> _mediaView = { nullptr };
|
||||
|
||||
base::Observable<void> _dragFinished;
|
||||
base::Observable<void> _widgetGrabbed;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Window
|
||||
|
@@ -68,9 +68,6 @@ public:
|
||||
base::Observable<void> &floatPlayerAreaUpdated() {
|
||||
return _floatPlayerAreaUpdated;
|
||||
}
|
||||
base::Observable<void> &widgetGrabbed() {
|
||||
return _widgetGrabbed;
|
||||
}
|
||||
|
||||
struct ColumnLayout {
|
||||
int bodyWidth;
|
||||
@@ -111,7 +108,6 @@ private:
|
||||
GifPauseReasons _gifPauseReasons = { 0 };
|
||||
base::Observable<void> _gifPauseLevelChanged;
|
||||
base::Observable<void> _floatPlayerAreaUpdated;
|
||||
base::Observable<void> _widgetGrabbed;
|
||||
|
||||
base::Variable<float64> _dialogsWidthRatio = { kDefaultDialogsWidthRatio };
|
||||
base::Variable<bool> _dialogsListFocused = { false };
|
||||
|
Reference in New Issue
Block a user