2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
an unofficial desktop messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
|
|
|
Copyright (c) 2014 John Preston, https://tdesktop.com
|
|
|
|
*/
|
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
|
|
|
#include "title.h"
|
|
|
|
#include "pspecific.h"
|
|
|
|
#include "gui/boxshadow.h"
|
|
|
|
|
2014-08-06 14:40:21 +00:00
|
|
|
class MediaView;
|
2014-05-30 08:53:19 +00:00
|
|
|
class TitleWidget;
|
|
|
|
class IntroWidget;
|
|
|
|
class MainWidget;
|
2014-08-01 11:09:46 +00:00
|
|
|
class SettingsWidget;
|
2014-05-30 08:53:19 +00:00
|
|
|
class BackgroundWidget;
|
|
|
|
class LayeredWidget;
|
|
|
|
|
|
|
|
class ConnectingWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ConnectingWidget(QWidget *parent, const QString &text, const QString &reconnect);
|
|
|
|
void set(const QString &text, const QString &reconnect);
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void onReconnect();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
BoxShadow _shadow;
|
|
|
|
QString _text;
|
|
|
|
int32 _textWidth;
|
|
|
|
LinkButton _reconnect;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class TempDirDeleter : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
TempDirDeleter(QThread *thread);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void onStart();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void succeed();
|
|
|
|
void failed();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-07-06 03:32:21 +00:00
|
|
|
|
|
|
|
class NotifyWindow : public QWidget, public Animated {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
NotifyWindow(HistoryItem *item, int32 x, int32 y);
|
|
|
|
|
|
|
|
void enterEvent(QEvent *e);
|
|
|
|
void leaveEvent(QEvent *e);
|
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
|
|
|
|
bool animStep(float64 ms);
|
|
|
|
void animHide(float64 duration, anim::transition func);
|
|
|
|
void startHiding();
|
|
|
|
void stopHiding();
|
|
|
|
void moveTo(int32 x, int32 y, int32 index = -1);
|
|
|
|
|
2014-07-18 10:37:34 +00:00
|
|
|
void updateNotifyDisplay();
|
2014-07-06 03:32:21 +00:00
|
|
|
void updatePeerPhoto();
|
|
|
|
|
2014-07-18 10:37:34 +00:00
|
|
|
void itemRemoved(HistoryItem *del);
|
|
|
|
|
2014-07-06 03:32:21 +00:00
|
|
|
int32 index() const {
|
|
|
|
return history ? _index : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
~NotifyWindow();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void hideByTimer();
|
|
|
|
void checkLastInput();
|
|
|
|
|
|
|
|
void unlinkHistory(History *hist = 0);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
DWORD started;
|
|
|
|
#endif
|
|
|
|
History *history;
|
2014-07-18 10:37:34 +00:00
|
|
|
HistoryItem *item;
|
2014-07-06 03:32:21 +00:00
|
|
|
IconedButton close;
|
|
|
|
QPixmap pm;
|
|
|
|
float64 alphaDuration, posDuration;
|
|
|
|
QTimer hideTimer, inputTimer;
|
|
|
|
bool hiding;
|
|
|
|
int32 _index;
|
|
|
|
anim::fvalue aOpacity;
|
|
|
|
anim::transition aOpacityFunc;
|
|
|
|
anim::ivalue aY;
|
|
|
|
ImagePtr peerPhoto;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef QList<NotifyWindow*> NotifyWindows;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
class Window : public PsMainWindow {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
Window(QWidget *parent = 0);
|
|
|
|
~Window();
|
|
|
|
|
|
|
|
void init();
|
2014-09-29 02:47:30 +00:00
|
|
|
void firstShow();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-08-11 09:03:45 +00:00
|
|
|
QWidget *filedialogParent();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
bool eventFilter(QObject *obj, QEvent *evt);
|
|
|
|
|
|
|
|
void inactivePress(bool inactive);
|
|
|
|
bool inactivePress() const;
|
|
|
|
|
|
|
|
void wStartDrag(QMouseEvent *e);
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
|
|
|
void closeEvent(QCloseEvent *e);
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
|
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
|
|
|
|
void setupIntro(bool anim);
|
|
|
|
void setupMain(bool anim);
|
|
|
|
void startMain(const MTPUser &user);
|
|
|
|
void getNotifySetting(const MTPInputNotifyPeer &peer, uint32 msWait = 0);
|
|
|
|
|
|
|
|
void mtpStateChanged(int32 dc, int32 state);
|
|
|
|
|
|
|
|
TitleWidget *getTitle();
|
|
|
|
|
|
|
|
HitTestType hitTest(const QPoint &p) const;
|
|
|
|
QRect iconRect() const;
|
|
|
|
|
|
|
|
QRect clientRect() const;
|
|
|
|
QRect photoRect() const;
|
|
|
|
|
|
|
|
IntroWidget *introWidget();
|
|
|
|
MainWidget *mainWidget();
|
2014-08-01 11:09:46 +00:00
|
|
|
SettingsWidget *settingsWidget();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void showConnecting(const QString &text, const QString &reconnect = QString());
|
|
|
|
void hideConnecting();
|
|
|
|
|
|
|
|
void hideSettings(bool fast = false);
|
|
|
|
void showPhoto(const PhotoLink *lnk, HistoryItem *item = 0);
|
2014-08-11 09:03:45 +00:00
|
|
|
void showPhoto(PhotoData *photo, HistoryItem *item);
|
|
|
|
void showPhoto(PhotoData *photo, PeerData *item);
|
2014-05-30 08:53:19 +00:00
|
|
|
void showLayer(LayeredWidget *w);
|
|
|
|
void replaceLayer(LayeredWidget *w);
|
|
|
|
void hideLayer();
|
|
|
|
|
|
|
|
bool layerShown();
|
|
|
|
|
2014-06-14 19:32:11 +00:00
|
|
|
bool historyIsActive(int state = -1) const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void activate();
|
|
|
|
|
|
|
|
void noIntro(IntroWidget *was);
|
2014-08-01 11:09:46 +00:00
|
|
|
void noSettings(SettingsWidget *was);
|
2014-05-30 08:53:19 +00:00
|
|
|
void noMain(MainWidget *was);
|
|
|
|
void noBox(BackgroundWidget *was);
|
|
|
|
|
|
|
|
void topWidget(QWidget *w);
|
|
|
|
void noTopWidget(QWidget *w);
|
|
|
|
|
|
|
|
void fixOrder();
|
|
|
|
|
|
|
|
enum TempDirState {
|
|
|
|
TempDirRemoving,
|
|
|
|
TempDirExists,
|
|
|
|
TempDirEmpty,
|
|
|
|
};
|
|
|
|
TempDirState tempDirState();
|
|
|
|
void tempDirDelete();
|
|
|
|
|
2014-08-06 14:40:21 +00:00
|
|
|
void quit();
|
|
|
|
|
2014-07-06 03:32:21 +00:00
|
|
|
void notifySettingGot();
|
|
|
|
void notifySchedule(History *history, MsgId msgId);
|
|
|
|
void notifyClear(History *history = 0);
|
|
|
|
void notifyClearFast();
|
|
|
|
void notifyShowNext(NotifyWindow *remove = 0);
|
2014-07-18 10:37:34 +00:00
|
|
|
void notifyItemRemoved(HistoryItem *item);
|
2014-07-06 03:32:21 +00:00
|
|
|
void notifyStopHiding();
|
|
|
|
void notifyStartHiding();
|
2014-07-18 10:37:34 +00:00
|
|
|
void notifyUpdateAllPhotos();
|
2014-07-06 03:32:21 +00:00
|
|
|
void notifyUpdateAll();
|
|
|
|
void notifyActivateAll();
|
|
|
|
|
2014-07-18 10:37:34 +00:00
|
|
|
QImage iconLarge() const;
|
|
|
|
|
|
|
|
void sendPaths();
|
|
|
|
|
2014-08-11 09:03:45 +00:00
|
|
|
void mediaOverviewUpdated(PeerData *peer);
|
|
|
|
void changingMsgId(HistoryItem *row, MsgId newId);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
public slots:
|
|
|
|
|
2014-06-14 19:32:11 +00:00
|
|
|
void checkHistoryActivation(int state = -1);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void showSettings();
|
|
|
|
void layerHidden();
|
|
|
|
void updateTitleStatus();
|
2014-09-26 23:48:19 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void quitFromTray();
|
|
|
|
void showFromTray(QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Unknown);
|
2014-09-26 23:48:19 +00:00
|
|
|
bool minimizeToTray();
|
2014-05-30 08:53:19 +00:00
|
|
|
void toggleTray(QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Unknown);
|
|
|
|
|
|
|
|
void onInactiveTimer();
|
|
|
|
|
|
|
|
void onTempDirCleared();
|
|
|
|
void onTempDirClearFailed();
|
2014-07-06 03:32:21 +00:00
|
|
|
|
|
|
|
void notifyFire();
|
2014-09-29 02:47:30 +00:00
|
|
|
void updateTrayMenu(bool force = false);
|
2014-09-26 23:48:19 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void resized(const QSize &size);
|
|
|
|
void tempDirCleared();
|
|
|
|
void tempDirClearFailed();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
void setupTrayIcon();
|
|
|
|
|
|
|
|
private:
|
2014-09-20 21:31:03 +00:00
|
|
|
|
2014-09-26 23:48:19 +00:00
|
|
|
void placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, style::color color);
|
2014-09-20 21:31:03 +00:00
|
|
|
QImage iconWithCounter(int size, int count, style::color bg, bool smallIcon);
|
|
|
|
QImage icon16, icon32, icon64;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
QWidget *centralwidget;
|
|
|
|
|
|
|
|
TitleWidget *title;
|
|
|
|
IntroWidget *intro;
|
|
|
|
MainWidget *main;
|
2014-08-01 11:09:46 +00:00
|
|
|
SettingsWidget *settings;
|
2014-05-30 08:53:19 +00:00
|
|
|
BackgroundWidget *layerBG;
|
|
|
|
|
|
|
|
QWidget *_topWidget; // temp hack for CountrySelect
|
|
|
|
ConnectingWidget *_connecting;
|
|
|
|
|
|
|
|
TempDirDeleter *_tempDeleter;
|
|
|
|
QThread *_tempDeleterThread;
|
|
|
|
|
|
|
|
void clearWidgets();
|
|
|
|
|
|
|
|
QIcon myIcon;
|
|
|
|
|
|
|
|
bool dragging;
|
|
|
|
QPoint dragStart;
|
|
|
|
|
|
|
|
bool _inactivePress;
|
|
|
|
QTimer _inactiveTimer;
|
|
|
|
|
2014-07-06 03:32:21 +00:00
|
|
|
typedef QMap<MsgId, uint64> NotifyWhenMap;
|
|
|
|
typedef QMap<History*, NotifyWhenMap> NotifyWhenMaps;
|
|
|
|
NotifyWhenMaps notifyWhenMaps;
|
|
|
|
struct NotifyWaiter {
|
|
|
|
NotifyWaiter(MsgId msg, uint64 when) : msg(msg), when(when) {
|
|
|
|
}
|
|
|
|
MsgId msg;
|
|
|
|
uint64 when;
|
|
|
|
};
|
|
|
|
typedef QMap<History*, NotifyWaiter> NotifyWaiters;
|
|
|
|
NotifyWaiters notifyWaiters;
|
|
|
|
NotifyWaiters notifySettingWaiters;
|
|
|
|
QTimer notifyWaitTimer;
|
|
|
|
|
2014-08-15 11:19:32 +00:00
|
|
|
typedef QMap<uint64, NullType> NotifyWhenAlert;
|
2014-07-06 03:32:21 +00:00
|
|
|
typedef QMap<History*, NotifyWhenAlert> NotifyWhenAlerts;
|
|
|
|
NotifyWhenAlerts notifyWhenAlerts;
|
|
|
|
|
|
|
|
NotifyWindows notifyWindows;
|
|
|
|
|
2014-08-06 14:40:21 +00:00
|
|
|
MediaView *_mediaView;
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|