Skip to content

Commit cf9737e

Browse files
committed
Windows 8/8.1/10 toast notifications support added
1 parent 1b16064 commit cf9737e

File tree

14 files changed

+891
-102
lines changed

14 files changed

+891
-102
lines changed

Telegram/Resources/lang.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
185185
"lng_settings_desktop_notify" = "Desktop notifications";
186186
"lng_settings_show_name" = "Show sender's name";
187187
"lng_settings_show_preview" = "Show message preview";
188+
"lng_settings_use_windows" = "Use Windows notifications";
188189
"lng_settings_sound_notify" = "Play sound";
189190

190191
"lng_notification_preview" = "You have a new message";

Telegram/SourceFiles/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ enum {
321321
MemoryForImageCache = 64 * 1024 * 1024, // after 64mb of unpacked images we try to clear some memory
322322
NotifyWindowsCount = 3, // 3 desktop notifies at the same time
323323
NotifySettingSaveTimeout = 1000, // wait 1 second before saving notify setting to server
324+
NotifyDeletePhotoAfter = 60000, // delete notify photo after 1 minute
324325
UpdateChunk = 100 * 1024, // 100kb parts when downloading the update
325326
IdleMsecs = 60 * 1000, // after 60secs without user input we think we are idle
326327

Telegram/SourceFiles/gui/images.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ inline StorageKey storageKey(int32 dc, const uint64 &volume, int32 local) {
154154
inline StorageKey storageKey(const MTPDfileLocation &location) {
155155
return storageKey(location.vdc_id.v, location.vvolume_id.v, location.vlocal_id.v);
156156
}
157+
inline StorageKey storageKey(const StorageImageLocation &location) {
158+
return storageKey(location.dc, location.volume, location.local);
159+
}
160+
157161
enum StorageFileType {
158162
StorageFileUnknown = 0xaa963b05, // mtpc_storage_fileUnknown
159163
StorageFileJpeg = 0x7efe0e, // mtpc_storage_fileJpeg

Telegram/SourceFiles/localstorage.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
1919
#include "localstorage.h"
2020

2121
#include "mainwidget.h"
22+
#include "window.h"
2223
#include "lang.h"
2324

2425
namespace {
@@ -737,6 +738,15 @@ namespace {
737738
cSetDesktopNotify(v == 1);
738739
} break;
739740

741+
case dbiWindowsNotifications: {
742+
qint32 v;
743+
stream >> v;
744+
if (!_checkStreamStatus(stream)) return false;
745+
746+
cSetWindowsNotifications(v == 1);
747+
cSetCustomNotifies((App::wnd() ? App::wnd()->psHasNativeNotifications() : true) && !cWindowsNotifications());
748+
} break;
749+
740750
case dbiWorkMode: {
741751
qint32 v;
742752
stream >> v;
@@ -1269,7 +1279,7 @@ namespace {
12691279
_writeMap(WriteMapFast);
12701280
}
12711281

1272-
uint32 size = 12 * (sizeof(quint32) + sizeof(qint32));
1282+
uint32 size = 13 * (sizeof(quint32) + sizeof(qint32));
12731283
size += sizeof(quint32) + _stringSize(cAskDownloadPath() ? QString() : cDownloadPath());
12741284
size += sizeof(quint32) + sizeof(qint32) + (cRecentEmojisPreload().isEmpty() ? cGetRecentEmojis().size() : cRecentEmojisPreload().size()) * (sizeof(uint64) + sizeof(ushort));
12751285
size += sizeof(quint32) + sizeof(qint32) + cEmojiVariants().size() * (sizeof(uint32) + sizeof(uint64));
@@ -1285,6 +1295,7 @@ namespace {
12851295
data.stream << quint32(dbiSoundNotify) << qint32(cSoundNotify());
12861296
data.stream << quint32(dbiDesktopNotify) << qint32(cDesktopNotify());
12871297
data.stream << quint32(dbiNotifyView) << qint32(cNotifyView());
1298+
data.stream << quint32(dbiWindowsNotifications) << qint32(cWindowsNotifications());
12881299
data.stream << quint32(dbiAskDownloadPath) << qint32(cAskDownloadPath());
12891300
data.stream << quint32(dbiDownloadPath) << (cAskDownloadPath() ? QString() : cDownloadPath());
12901301
data.stream << quint32(dbiCompressPastedImage) << qint32(cCompressPastedImage());

Telegram/SourceFiles/pspecific_linux.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ class PsMainWindow : public QMainWindow {
6868

6969
void psUpdateCounter();
7070

71+
bool psHasNativeNotifications() {
72+
return false;
73+
}
74+
7175
virtual QImage iconWithCounter(int size, int count, style::color bg, bool smallIcon) = 0;
7276

7377
~PsMainWindow();

Telegram/SourceFiles/pspecific_mac.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ class PsMainWindow : public QMainWindow {
8383

8484
void psUpdateCounter();
8585

86+
bool psHasNativeNotifications() {
87+
return !(QSysInfo::macVersion() < QSysInfo::MV_10_8);
88+
}
89+
8690
virtual QImage iconWithCounter(int size, int count, style::color bg, bool smallIcon) = 0;
8791

8892
~PsMainWindow();

0 commit comments

Comments
 (0)