Create tray icon without a parent.
This commit is contained in:
parent
3e332ad8e7
commit
e4c16ccba4
3 changed files with 4 additions and 26 deletions
|
@ -23,16 +23,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
[[nodiscard]] QWidget *Parent() {
|
|
||||||
Expects(Core::App().activePrimaryWindow() != nullptr);
|
|
||||||
|
|
||||||
return Core::App().activePrimaryWindow()->widget();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
class IconGraphic final {
|
class IconGraphic final {
|
||||||
public:
|
public:
|
||||||
explicit IconGraphic();
|
explicit IconGraphic();
|
||||||
|
@ -335,7 +325,7 @@ void Tray::createIcon() {
|
||||||
const auto counter = Core::App().unreadBadge();
|
const auto counter = Core::App().unreadBadge();
|
||||||
const auto muted = Core::App().unreadBadgeMuted();
|
const auto muted = Core::App().unreadBadgeMuted();
|
||||||
|
|
||||||
_icon = base::make_unique_q<QSystemTrayIcon>(Parent());
|
_icon = base::make_unique_q<QSystemTrayIcon>(nullptr);
|
||||||
_icon->setIcon(_iconGraphic->trayIcon(
|
_icon->setIcon(_iconGraphic->trayIcon(
|
||||||
_iconGraphic->systemIcon(
|
_iconGraphic->systemIcon(
|
||||||
iconThemeName,
|
iconThemeName,
|
||||||
|
@ -405,7 +395,7 @@ void Tray::updateIcon() {
|
||||||
|
|
||||||
void Tray::createMenu() {
|
void Tray::createMenu() {
|
||||||
if (!_menu) {
|
if (!_menu) {
|
||||||
_menu = base::make_unique_q<QMenu>(Parent());
|
_menu = base::make_unique_q<QMenu>(nullptr);
|
||||||
}
|
}
|
||||||
if (!_menuXEmbed) {
|
if (!_menuXEmbed) {
|
||||||
_menuXEmbed = base::make_unique_q<Ui::PopupMenu>(nullptr);
|
_menuXEmbed = base::make_unique_q<Ui::PopupMenu>(nullptr);
|
||||||
|
|
|
@ -222,12 +222,6 @@ void UpdateIcon(const NSStatusItem *status) {
|
||||||
status.button.imageScaling = NSImageScaleProportionallyDown;
|
status.button.imageScaling = NSImageScaleProportionallyDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] QWidget *Parent() {
|
|
||||||
Expects(Core::App().activePrimaryWindow() != nullptr);
|
|
||||||
|
|
||||||
return Core::App().activePrimaryWindow()->widget();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class NativeIcon final {
|
class NativeIcon final {
|
||||||
|
@ -366,7 +360,7 @@ void Tray::updateIcon() {
|
||||||
|
|
||||||
void Tray::createMenu() {
|
void Tray::createMenu() {
|
||||||
if (!_menu) {
|
if (!_menu) {
|
||||||
_menu = base::make_unique_q<QMenu>(Parent());
|
_menu = base::make_unique_q<QMenu>(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,12 +89,6 @@ constexpr auto kTooltipDelay = crl::time(10000);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] QWidget *Parent() {
|
|
||||||
Expects(Core::App().activePrimaryWindow() != nullptr);
|
|
||||||
|
|
||||||
return Core::App().activePrimaryWindow()->widget();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Tray::Tray() {
|
Tray::Tray() {
|
||||||
|
@ -102,7 +96,7 @@ Tray::Tray() {
|
||||||
|
|
||||||
void Tray::createIcon() {
|
void Tray::createIcon() {
|
||||||
if (!_icon) {
|
if (!_icon) {
|
||||||
_icon = base::make_unique_q<QSystemTrayIcon>(Parent());
|
_icon = base::make_unique_q<QSystemTrayIcon>(nullptr);
|
||||||
updateIcon();
|
updateIcon();
|
||||||
_icon->setToolTip(AppName.utf16());
|
_icon->setToolTip(AppName.utf16());
|
||||||
using Reason = QSystemTrayIcon::ActivationReason;
|
using Reason = QSystemTrayIcon::ActivationReason;
|
||||||
|
|
Loading…
Reference in a new issue