LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
fancytrayicon.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "fancytrayicon.h"
10#include <QMenu>
11#include <QtDebug>
13
14#ifdef IS_FREEDESKTOP_PLATFORM
16#endif
17
18namespace LC::Util
19{
20 FancyTrayIcon::FancyTrayIcon (IconInfo info, QObject *parent)
21 : QObject { parent }
22 , Info_ { std::move (info) }
23 {
24 ReinitImpl ();
25 }
26
28
30 {
31 return Info_;
32 }
33
34 void FancyTrayIcon::SetVisible (bool visible)
35 {
36 if (visible == Visible_)
37 return;
38
39 Visible_ = visible;
40 if (!visible)
41 Impl_.reset ();
42 else
43 ReinitImpl ();
44 }
45
47 {
48 Status_ = status;
49 if (Impl_)
50 Impl_->UpdateStatus ();
51 }
52
54 {
55 return Status_;
56 }
57
58 void FancyTrayIcon::SetIcon (const Icon& icon)
59 {
60 Icon_ = icon;
61 if (Impl_)
62 Impl_->UpdateIcon ();
63 }
64
66 {
67 return Icon_;
68 }
69
71 {
72 Tooltip_ = std::move (tooltip);
73 if (Impl_)
74 Impl_->UpdateTooltip ();
75 }
76
78 {
79 return Tooltip_;
80 }
81
83 {
84 Menu_ = menu;
85 if (Impl_)
86 Impl_->UpdateMenu ();
87 }
88
90 {
91 return Menu_;
92 }
93
94 void FancyTrayIcon::ReinitImpl ()
95 {
96 try
97 {
98#ifdef IS_FREEDESKTOP_PLATFORM
99 Impl_ = std::make_unique<FancyTrayIconFreedesktop> (*this);
100#endif
101 }
102 catch (const std::exception& e)
103 {
104 qCritical () << Q_FUNC_INFO
105 << "unable to create icon implementation:"
106 << e.what ();
107 }
108
109 if (!Impl_)
110 Impl_ = std::make_unique<FancyTrayIconFallback> (*this);
111 }
112}
void SetStatus(Status status)
const IconInfo & GetInfo() const
std::variant< QString, QIcon > Icon
void SetIcon(const Icon &icon)
void SetVisible(bool visible)
const Tooltip & GetTooltip() const
const Icon & GetIcon() const
FancyTrayIcon(IconInfo info, QObject *parent=nullptr)
void SetContextMenu(QMenu *menu)
void SetToolTip(Tooltip tooltip)
QMenu * GetContextMenu() const
STL namespace.