2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Styles improved. Members dropdown is shown with a delay.

Overview of chat photos fixed. Tray icon tries read a file on Linux.
This commit is contained in:
John Preston
2016-06-21 17:19:24 +03:00
parent d001ec346d
commit c73b5a6da4
12 changed files with 117 additions and 40 deletions

View File

@@ -105,6 +105,8 @@ f_gdk_init_check gdk_init_check = nullptr;
f_gdk_pixbuf_new_from_data gdk_pixbuf_new_from_data = nullptr;
f_gtk_status_icon_new_from_pixbuf gtk_status_icon_new_from_pixbuf = nullptr;
f_gtk_status_icon_set_from_pixbuf gtk_status_icon_set_from_pixbuf = nullptr;
f_gtk_status_icon_new_from_file gtk_status_icon_new_from_file = nullptr;
f_gtk_status_icon_set_from_file gtk_status_icon_set_from_file = nullptr;
f_gtk_status_icon_set_title gtk_status_icon_set_title = nullptr;
f_gtk_status_icon_set_tooltip_text gtk_status_icon_set_tooltip_text = nullptr;
f_gtk_status_icon_set_visible gtk_status_icon_set_visible = nullptr;
@@ -157,6 +159,8 @@ void start() {
load(lib_gtk, "gdk_pixbuf_new_from_data", gdk_pixbuf_new_from_data);
load(lib_gtk, "gtk_status_icon_new_from_pixbuf", gtk_status_icon_new_from_pixbuf);
load(lib_gtk, "gtk_status_icon_set_from_pixbuf", gtk_status_icon_set_from_pixbuf);
load(lib_gtk, "gtk_status_icon_new_from_file", gtk_status_icon_new_from_file);
load(lib_gtk, "gtk_status_icon_set_from_file", gtk_status_icon_set_from_file);
load(lib_gtk, "gtk_status_icon_set_title", gtk_status_icon_set_title);
load(lib_gtk, "gtk_status_icon_set_tooltip_text", gtk_status_icon_set_tooltip_text);
load(lib_gtk, "gtk_status_icon_set_visible", gtk_status_icon_set_visible);

View File

@@ -128,6 +128,12 @@ extern f_gtk_status_icon_new_from_pixbuf gtk_status_icon_new_from_pixbuf;
typedef void (*f_gtk_status_icon_set_from_pixbuf)(GtkStatusIcon *status_icon, GdkPixbuf *pixbuf);
extern f_gtk_status_icon_set_from_pixbuf gtk_status_icon_set_from_pixbuf;
typedef GtkStatusIcon* (*f_gtk_status_icon_new_from_file)(const gchar *filename);
extern f_gtk_status_icon_new_from_file gtk_status_icon_new_from_file;
typedef void (*f_gtk_status_icon_set_from_file)(GtkStatusIcon *status_icon, const gchar *filename);
extern f_gtk_status_icon_set_from_file gtk_status_icon_set_from_file;
typedef void (*f_gtk_status_icon_set_title)(GtkStatusIcon *status_icon, const gchar *title);
extern f_gtk_status_icon_set_title gtk_status_icon_set_title;

View File

@@ -248,9 +248,16 @@ void MainWindow::psSetupTrayIcon() {
if (!trayIcon) {
trayIcon = new QSystemTrayIcon(this);
QIcon icon(QPixmap::fromImage(App::wnd()->iconLarge(), Qt::ColorOnly));
QIcon icon;
QFileInfo f(_trayIconImageFile());
if (f.exists()) {
QByteArray path = QFile::encodeName(f.absoluteFilePath());
icon = QIcon(path.constData());
} else {
icon = QIcon(QPixmap::fromImage(App::wnd()->iconLarge(), Qt::ColorOnly));
}
trayIcon->setIcon(icon);
trayIcon->setToolTip(str_const_toString(AppName));
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection);
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
@@ -329,18 +336,30 @@ void MainWindow::psUpdateCounter() {
_psUpdateIndicatorTimer.start(100);
}
} else if (useStatusIcon && trayIconChecked) {
loadPixbuf(_trayIconImageGen());
Libs::gtk_status_icon_set_from_pixbuf(_trayIcon, _trayPixbuf);
QFileInfo iconFile(_trayIconImageFile());
if (iconFile.exists()) {
QByteArray path = QFile::encodeName(f.absoluteFilePath());
Libs::gtk_status_icon_set_from_file(_trayIcon, path.constData());
} else {
loadPixbuf(_trayIconImageGen());
Libs::gtk_status_icon_set_from_pixbuf(_trayIcon, _trayPixbuf);
}
}
} else if (trayIcon) {
int32 counter = App::histories().unreadBadge();
bool muted = App::histories().unreadOnlyMuted();
QIcon icon;
QFileInfo f(_trayIconImageFile());
if (f.exists()) {
QByteArray path = QFile::encodeName(f.absoluteFilePath());
icon = QIcon(path.constData());
} else {
int32 counter = App::histories().unreadBadge();
bool muted = App::histories().unreadOnlyMuted();
style::color bg = muted ? st::counterMuteBG : st::counterBG;
QIcon iconSmall;
iconSmall.addPixmap(QPixmap::fromImage(iconWithCounter(16, counter, bg, true), Qt::ColorOnly));
iconSmall.addPixmap(QPixmap::fromImage(iconWithCounter(32, counter, bg, true), Qt::ColorOnly));
trayIcon->setIcon(iconSmall);
style::color bg = muted ? st::counterMuteBG : st::counterBG;
icon.addPixmap(QPixmap::fromImage(iconWithCounter(16, counter, bg, true), Qt::ColorOnly));
icon.addPixmap(QPixmap::fromImage(iconWithCounter(32, counter, bg, true), Qt::ColorOnly));
}
trayIcon->setIcon(icon);
}
}
@@ -382,6 +401,8 @@ void MainWindow::LibsLoaded() {
&& (Libs::gdk_pixbuf_new_from_data != nullptr)
&& (Libs::gtk_status_icon_new_from_pixbuf != nullptr)
&& (Libs::gtk_status_icon_set_from_pixbuf != nullptr)
&& (Libs::gtk_status_icon_new_from_file != nullptr)
&& (Libs::gtk_status_icon_set_from_file != nullptr)
&& (Libs::gtk_status_icon_set_title != nullptr)
&& (Libs::gtk_status_icon_set_tooltip_text != nullptr)
&& (Libs::gtk_status_icon_set_visible != nullptr)
@@ -532,8 +553,14 @@ void MainWindow::psCreateTrayIcon() {
if (Libs::gdk_init_check(0, 0)) {
if (!_trayMenu) _trayMenu = Libs::gtk_menu_new();
if (_trayMenu) {
loadPixbuf(_trayIconImageGen());
_trayIcon = Libs::gtk_status_icon_new_from_pixbuf(_trayPixbuf);
QFileInfo iconFile(_trayIconImageFile());
if (iconFile.exists()) {
QByteArray path = QFile::encodeName(iconFile.absoluteFilePath());
_trayIcon = Libs::gtk_status_icon_new_from_file(path.constData());
} else {
loadPixbuf(_trayIconImageGen());
_trayIcon = Libs::gtk_status_icon_new_from_pixbuf(_trayPixbuf);
}
if (_trayIcon) {
Libs::g_signal_connect_helper(_trayIcon, "popup-menu", GCallback(_trayIconPopup), _trayMenu);
Libs::g_signal_connect_helper(_trayIcon, "activate", GCallback(_trayIconActivate), _trayMenu);