Skip to content

Commit

Permalink
Windows 8/8.1/10 toast notifications support added
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Aug 11, 2015
1 parent 1b16064 commit cf9737e
Show file tree
Hide file tree
Showing 14 changed files with 891 additions and 102 deletions.
1 change: 1 addition & 0 deletions Telegram/Resources/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_settings_desktop_notify" = "Desktop notifications";
"lng_settings_show_name" = "Show sender's name";
"lng_settings_show_preview" = "Show message preview";
"lng_settings_use_windows" = "Use Windows notifications";
"lng_settings_sound_notify" = "Play sound";

"lng_notification_preview" = "You have a new message";
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ enum {
MemoryForImageCache = 64 * 1024 * 1024, // after 64mb of unpacked images we try to clear some memory
NotifyWindowsCount = 3, // 3 desktop notifies at the same time
NotifySettingSaveTimeout = 1000, // wait 1 second before saving notify setting to server
NotifyDeletePhotoAfter = 60000, // delete notify photo after 1 minute
UpdateChunk = 100 * 1024, // 100kb parts when downloading the update
IdleMsecs = 60 * 1000, // after 60secs without user input we think we are idle

Expand Down
4 changes: 4 additions & 0 deletions Telegram/SourceFiles/gui/images.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ inline StorageKey storageKey(int32 dc, const uint64 &volume, int32 local) {
inline StorageKey storageKey(const MTPDfileLocation &location) {
return storageKey(location.vdc_id.v, location.vvolume_id.v, location.vlocal_id.v);
}
inline StorageKey storageKey(const StorageImageLocation &location) {
return storageKey(location.dc, location.volume, location.local);
}

enum StorageFileType {
StorageFileUnknown = 0xaa963b05, // mtpc_storage_fileUnknown
StorageFileJpeg = 0x7efe0e, // mtpc_storage_fileJpeg
Expand Down
13 changes: 12 additions & 1 deletion Telegram/SourceFiles/localstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
#include "localstorage.h"

#include "mainwidget.h"
#include "window.h"
#include "lang.h"

namespace {
Expand Down Expand Up @@ -737,6 +738,15 @@ namespace {
cSetDesktopNotify(v == 1);
} break;

case dbiWindowsNotifications: {
qint32 v;
stream >> v;
if (!_checkStreamStatus(stream)) return false;

cSetWindowsNotifications(v == 1);
cSetCustomNotifies((App::wnd() ? App::wnd()->psHasNativeNotifications() : true) && !cWindowsNotifications());
} break;

case dbiWorkMode: {
qint32 v;
stream >> v;
Expand Down Expand Up @@ -1269,7 +1279,7 @@ namespace {
_writeMap(WriteMapFast);
}

uint32 size = 12 * (sizeof(quint32) + sizeof(qint32));
uint32 size = 13 * (sizeof(quint32) + sizeof(qint32));
size += sizeof(quint32) + _stringSize(cAskDownloadPath() ? QString() : cDownloadPath());
size += sizeof(quint32) + sizeof(qint32) + (cRecentEmojisPreload().isEmpty() ? cGetRecentEmojis().size() : cRecentEmojisPreload().size()) * (sizeof(uint64) + sizeof(ushort));
size += sizeof(quint32) + sizeof(qint32) + cEmojiVariants().size() * (sizeof(uint32) + sizeof(uint64));
Expand All @@ -1285,6 +1295,7 @@ namespace {
data.stream << quint32(dbiSoundNotify) << qint32(cSoundNotify());
data.stream << quint32(dbiDesktopNotify) << qint32(cDesktopNotify());
data.stream << quint32(dbiNotifyView) << qint32(cNotifyView());
data.stream << quint32(dbiWindowsNotifications) << qint32(cWindowsNotifications());
data.stream << quint32(dbiAskDownloadPath) << qint32(cAskDownloadPath());
data.stream << quint32(dbiDownloadPath) << (cAskDownloadPath() ? QString() : cDownloadPath());
data.stream << quint32(dbiCompressPastedImage) << qint32(cCompressPastedImage());
Expand Down
4 changes: 4 additions & 0 deletions Telegram/SourceFiles/pspecific_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class PsMainWindow : public QMainWindow {

void psUpdateCounter();

bool psHasNativeNotifications() {
return false;
}

virtual QImage iconWithCounter(int size, int count, style::color bg, bool smallIcon) = 0;

~PsMainWindow();
Expand Down
4 changes: 4 additions & 0 deletions Telegram/SourceFiles/pspecific_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ class PsMainWindow : public QMainWindow {

void psUpdateCounter();

bool psHasNativeNotifications() {
return !(QSysInfo::macVersion() < QSysInfo::MV_10_8);
}

virtual QImage iconWithCounter(int size, int count, style::color bg, bool smallIcon) = 0;

~PsMainWindow();
Expand Down
Loading

0 comments on commit cf9737e

Please sign in to comment.