2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
#include "data/data_types.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-10-23 09:44:42 +00:00
|
|
|
enum class ImageRoundRadius;
|
2016-04-12 21:31:28 +00:00
|
|
|
class MainWindow;
|
2014-05-30 08:53:19 +00:00
|
|
|
class MainWidget;
|
2018-01-11 19:33:26 +00:00
|
|
|
class HistoryItem;
|
2018-01-13 12:45:11 +00:00
|
|
|
class History;
|
2018-01-11 13:07:29 +00:00
|
|
|
namespace HistoryView {
|
2018-01-13 12:45:11 +00:00
|
|
|
class Element;
|
2018-01-11 13:07:29 +00:00
|
|
|
} // namespace HistoryView
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
using HistoryItemsMap = base::flat_set<not_null<HistoryItem*>>;
|
2016-09-27 13:37:18 +00:00
|
|
|
using GifItems = QHash<Media::Clip::Reader*, HistoryItem*>;
|
2015-12-27 21:37:48 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
enum RoundCorners {
|
|
|
|
SmallMaskCorners = 0x00, // for images
|
|
|
|
LargeMaskCorners,
|
|
|
|
|
|
|
|
BoxCorners,
|
|
|
|
MenuCorners,
|
|
|
|
BotKbOverCorners,
|
|
|
|
StickerCorners,
|
|
|
|
StickerSelectedCorners,
|
|
|
|
SelectedOverlaySmallCorners,
|
|
|
|
SelectedOverlayLargeCorners,
|
|
|
|
DateCorners,
|
|
|
|
DateSelectedCorners,
|
2019-03-14 20:00:24 +00:00
|
|
|
OverviewVideoCorners,
|
|
|
|
OverviewVideoSelectedCorners,
|
2018-01-11 19:33:26 +00:00
|
|
|
ForwardCorners,
|
|
|
|
MediaviewSaveCorners,
|
|
|
|
EmojiHoverCorners,
|
|
|
|
StickerHoverCorners,
|
|
|
|
BotKeyboardCorners,
|
|
|
|
PhotoSelectOverlayCorners,
|
|
|
|
|
|
|
|
Doc1Corners,
|
|
|
|
Doc2Corners,
|
|
|
|
Doc3Corners,
|
|
|
|
Doc4Corners,
|
|
|
|
|
|
|
|
InShadowCorners, // for photos without bg
|
|
|
|
InSelectedShadowCorners,
|
|
|
|
|
|
|
|
MessageInCorners, // with shadow
|
|
|
|
MessageInSelectedCorners,
|
|
|
|
MessageOutCorners,
|
|
|
|
MessageOutSelectedCorners,
|
|
|
|
|
|
|
|
RoundCornersCount
|
|
|
|
};
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
namespace App {
|
2016-04-12 21:31:28 +00:00
|
|
|
MainWindow *wnd();
|
2014-05-30 08:53:19 +00:00
|
|
|
MainWidget *main();
|
|
|
|
|
|
|
|
QString formatPhone(QString phone);
|
|
|
|
|
2015-12-27 21:37:48 +00:00
|
|
|
void addSavedGif(DocumentData *doc);
|
|
|
|
void checkSavedGif(HistoryItem *item);
|
2019-01-03 12:36:01 +00:00
|
|
|
[[nodiscard]] QString peerName(const PeerData *peer, bool forDialogs = false);
|
2019-04-25 12:45:15 +00:00
|
|
|
void feedUserLink(MTPint userId, const MTPContactLink &myLink, const MTPContactLink &foreignLink);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
void hoveredItem(HistoryView::Element *item);
|
|
|
|
HistoryView::Element *hoveredItem();
|
|
|
|
void pressedItem(HistoryView::Element *item);
|
|
|
|
HistoryView::Element *pressedItem();
|
|
|
|
void hoveredLinkItem(HistoryView::Element *item);
|
|
|
|
HistoryView::Element *hoveredLinkItem();
|
|
|
|
void pressedLinkItem(HistoryView::Element *item);
|
|
|
|
HistoryView::Element *pressedLinkItem();
|
|
|
|
void mousedItem(HistoryView::Element *item);
|
|
|
|
HistoryView::Element *mousedItem();
|
2016-06-14 16:26:41 +00:00
|
|
|
void clearMousedItems();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-23 16:06:56 +00:00
|
|
|
const style::font &monofont();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void initMedia();
|
2015-12-27 21:37:48 +00:00
|
|
|
void deinitMedia();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-03-02 18:34:42 +00:00
|
|
|
enum LaunchState {
|
|
|
|
Launched = 0,
|
|
|
|
QuitRequested = 1,
|
|
|
|
QuitProcessed = 2,
|
|
|
|
};
|
2014-05-30 08:53:19 +00:00
|
|
|
void quit();
|
2016-03-02 18:34:42 +00:00
|
|
|
bool quitting();
|
|
|
|
LaunchState launchState();
|
|
|
|
void setLaunchState(LaunchState state);
|
2016-10-28 12:44:28 +00:00
|
|
|
void restart();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-11-28 15:45:07 +00:00
|
|
|
constexpr auto kFileSizeLimit = 1500 * 1024 * 1024; // Load files up to 1500mb
|
|
|
|
constexpr auto kImageSizeLimit = 64 * 1024 * 1024; // Open images up to 64mb jpg/png/gif
|
|
|
|
QImage readImage(QByteArray data, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr);
|
|
|
|
QImage readImage(const QString &file, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr, QByteArray *content = 0);
|
2016-05-27 10:57:11 +00:00
|
|
|
QPixmap pixmapFromImageInPlace(QImage &&image);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-12-18 17:50:25 +00:00
|
|
|
void complexOverlayRect(Painter &p, QRect rect, ImageRoundRadius radius, RectParts corners);
|
|
|
|
void complexLocationRect(Painter &p, QRect rect, ImageRoundRadius radius, RectParts corners);
|
2016-11-21 20:26:54 +00:00
|
|
|
|
2017-07-13 14:42:46 +00:00
|
|
|
QImage *cornersMask(ImageRoundRadius radius);
|
2016-12-23 13:21:01 +00:00
|
|
|
void roundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color bg, RoundCorners index, const style::color *shadow = nullptr, RectParts parts = RectPart::Full);
|
|
|
|
inline void roundRect(Painter &p, const QRect &rect, style::color bg, RoundCorners index, const style::color *shadow = nullptr, RectParts parts = RectPart::Full) {
|
2016-11-12 15:02:19 +00:00
|
|
|
return roundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg, index, shadow, parts);
|
2015-05-20 19:28:24 +00:00
|
|
|
}
|
2016-12-23 13:21:01 +00:00
|
|
|
void roundShadow(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color shadow, RoundCorners index, RectParts parts = RectPart::Full);
|
|
|
|
inline void roundShadow(Painter &p, const QRect &rect, style::color shadow, RoundCorners index, RectParts parts = RectPart::Full) {
|
2016-11-12 15:02:19 +00:00
|
|
|
return roundShadow(p, rect.x(), rect.y(), rect.width(), rect.height(), shadow, index, parts);
|
2015-05-22 11:14:52 +00:00
|
|
|
}
|
2016-12-23 13:21:01 +00:00
|
|
|
void roundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color bg, ImageRoundRadius radius, RectParts parts = RectPart::Full);
|
|
|
|
inline void roundRect(Painter &p, const QRect &rect, style::color bg, ImageRoundRadius radius, RectParts parts = RectPart::Full) {
|
2016-11-12 15:02:19 +00:00
|
|
|
return roundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg, radius, parts);
|
2015-10-03 10:09:09 +00:00
|
|
|
}
|
2015-05-20 19:28:24 +00:00
|
|
|
|
2015-11-20 13:34:37 +00:00
|
|
|
};
|