Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QSystemTrayIconPrivate Class Reference

#include <qsystemtrayicon_p.h>

Inheritance diagram for QSystemTrayIconPrivate:
QObjectPrivate QObjectData

Public Functions

QRect geometry_sys () const
 
void install_sys ()
 
 QSystemTrayIconPrivate ()
 
void remove_sys ()
 
void showMessage_sys (const QString &msg, const QString &title, QSystemTrayIcon::MessageIcon icon, int secs)
 
void updateIcon_sys ()
 
void updateMenu_sys ()
 
void updateToolTip_sys ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static bool isSystemTrayAvailable_sys ()
 
static bool supportsMessages_sys ()
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

QIcon icon
 
QPointer< QMenumenu
 
QSystemTrayIconSyssys
 
QString toolTip
 
bool visible
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Detailed Description

Definition at line 72 of file qsystemtrayicon_p.h.

Constructors and Destructors

◆ QSystemTrayIconPrivate()

QSystemTrayIconPrivate::QSystemTrayIconPrivate ( )
inline

Definition at line 77 of file qsystemtrayicon_p.h.

77 : sys(0), visible(false) { }
QSystemTrayIconSys * sys

Functions

◆ geometry_sys()

QRect QSystemTrayIconPrivate::geometry_sys ( ) const

Definition at line 171 of file qsystemtrayicon_mac.mm.

Referenced by QSystemTrayIconSys::findIconGeometry(), QSystemTrayIconSys::findTrayGeometry(), QSystemTrayIconPrivate(), and QSystemTrayIconSys::x11Event().

172 {
173  if(sys) {
174  const QRectF geom = [sys->item geometry];
175  if(!geom.isNull())
176  return geom.toRect();
177  }
178  return QRect();
179 }
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QSystemTrayIconSys * sys
QRect toRect() const
Returns a QRect based on the values of this rectangle.
Definition: qrect.h:845
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:655

◆ install_sys()

void QSystemTrayIconPrivate::install_sys ( )

Definition at line 160 of file qsystemtrayicon_mac.mm.

Referenced by QSystemTrayIconSys::findTrayGeometry(), QSystemTrayIconPrivate(), QSystemTrayIconSys::winEvent(), and QSystemTrayIconSys::x11Event().

161 {
163  if (!sys) {
164  sys = new QSystemTrayIconSys(q, this);
165  updateIcon_sys();
166  updateMenu_sys();
168  }
169 }
#define Q_Q(Class)
Definition: qglobal.h:2483
QSystemTrayIconSys * sys
The QSystemTrayIcon class provides an icon for an application in the system tray. ...

◆ isSystemTrayAvailable_sys()

bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys ( )
static

◆ remove_sys()

void QSystemTrayIconPrivate::remove_sys ( )

◆ showMessage_sys()

void QSystemTrayIconPrivate::showMessage_sys ( const QString msg,
const QString title,
QSystemTrayIcon::MessageIcon  icon,
int  secs 
)

Definition at line 234 of file qsystemtrayicon_mac.mm.

Referenced by QSystemTrayIconSys::findIconGeometry(), QSystemTrayIconSys::findTrayGeometry(), QSystemTrayIconPrivate(), and QSystemTrayIconSys::x11Event().

235 {
236 
237  if(sys) {
238 #ifdef QT_MAC_SYSTEMTRAY_USE_GROWL
239  // Make sure that we have Growl installed on the machine we are running on.
240  QCFType<CFURLRef> cfurl;
241  OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator,
242  CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
243  if (status == kLSApplicationNotFoundErr)
244  return;
245  QCFType<CFBundleRef> bundle = CFBundleCreate(0, cfurl);
246 
247  if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"),
248  kCFCompareCaseInsensitive | kCFCompareBackwards) != kCFCompareEqualTo)
249  return;
250  QPixmap notificationIconPixmap;
253  else if(icon == QSystemTrayIcon::Warning)
255  else if(icon == QSystemTrayIcon::Critical)
257  QTemporaryFile notificationIconFile;
258  QString notificationType(QLatin1String("Notification")), notificationIcon, notificationApp(QApplication::applicationName());
259  if(notificationApp.isEmpty())
260  notificationApp = QLatin1String("Application");
261  if(!notificationIconPixmap.isNull() && notificationIconFile.open()) {
262  QImageWriter writer(&notificationIconFile, "PNG");
263  if(writer.write(notificationIconPixmap.toImage()))
264  notificationIcon = QLatin1String("image from location \"file://") + notificationIconFile.fileName() + QLatin1String("\"");
265  }
267  "tell application \"GrowlHelperApp\"\n"
268  "-- Make a list of all the notification types (all)\n"
269  "set the allNotificationsList to {\"") + notificationType + QLatin1String("\"}\n"
270 
271  "-- Make a list of the notifications (enabled)\n"
272  "set the enabledNotificationsList to {\"") + notificationType + QLatin1String("\"}\n"
273 
274  "-- Register our script with growl.\n"
275  "register as application \"") + notificationApp + QLatin1String("\" all notifications allNotificationsList default notifications enabledNotificationsList\n"
276 
277  "-- Send a Notification...\n") +
278  QLatin1String("notify with name \"") + notificationType +
279  QLatin1String("\" title \"") + title +
280  QLatin1String("\" description \"") + message +
281  QLatin1String("\" application name \"") + notificationApp +
282  QLatin1String("\" ") + notificationIcon +
283  QLatin1String("\nend tell"));
285 #elif 0
287  NSView *v = [[sys->item item] view];
288  NSWindow *w = [v window];
289  w = [[sys->item item] window];
290  qDebug() << w << v;
291  QPoint p(qRound([w frame].origin.x), qRound([w frame].origin.y));
292  qDebug() << p;
293  QBalloonTip::showBalloon(icon, message, title, q, QPoint(0, 0), msecs);
294 #else
295  Q_UNUSED(icon);
296  Q_UNUSED(title);
297  Q_UNUSED(message);
298 #endif
299  }
300 }
QImage toImage() const
Converts the pixmap to a QImage.
Definition: qpixmap.cpp:542
bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret)
The QTemporaryFile class is an I/O device that operates on temporary files.
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
bool open()
A QTemporaryFile will always be opened in QIODevice::ReadWrite mode, this allows easy access to the d...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QStyle * style()
Returns the application&#39;s style object.
The QString class provides a Unicode character string.
Definition: qstring.h:83
static void showBalloon(QSystemTrayIcon::MessageIcon icon, const QString &title, const QString &msg, QSystemTrayIcon *trayIcon, const QPoint &pos, int timeout, bool showArrow=true)
#define Q_Q(Class)
Definition: qglobal.h:2483
Q_CORE_EXPORT void qDebug(const char *,...)
NSWindow * window
The QImageWriter class provides a format independent interface for writing images to files or other d...
Definition: qimagewriter.h:59
QSystemTrayIconSys * sys
signed long OSStatus
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QString fileName() const
Returns the complete unique filename backing the QTemporaryFile object.
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
static QString applicationName()
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt=0, const QWidget *widget=0) const =0
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
The QSystemTrayIcon class provides an icon for an application in the system tray. ...

◆ supportsMessages_sys()

bool QSystemTrayIconPrivate::supportsMessages_sys ( )
static

◆ updateIcon_sys()

void QSystemTrayIconPrivate::updateIcon_sys ( )

Definition at line 187 of file qsystemtrayicon_mac.mm.

Referenced by QSystemTrayIconSys::findIconGeometry(), QSystemTrayIconSys::findTrayGeometry(), QSystemTrayIconPrivate(), and QSystemTrayIconSys::x11Event().

188 {
189  if(sys && !icon.isNull()) {
191 #ifndef QT_MAC_USE_COCOA
192  const short scale = GetMBarHeight()-4;
193 #else
194  CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
195  const short scale = hgt - 4;
196 #endif
197  NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(icon.pixmap(QSize(scale, scale))));
198  [(NSImageView*)[[sys->item item] view] setImage: nsimage];
199  [nsimage release];
200  }
201 }
void * qt_mac_create_nsimage(const QPixmap &pm)
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
QSystemTrayIconSys * sys
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition: qicon.cpp:693
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
float CGFloat

◆ updateMenu_sys()

void QSystemTrayIconPrivate::updateMenu_sys ( )

Definition at line 203 of file qsystemtrayicon_mac.mm.

Referenced by QSystemTrayIconSys::findIconGeometry(), QSystemTrayIconSys::findTrayGeometry(), QSystemTrayIconPrivate(), and QSystemTrayIconSys::x11Event().

204 {
205  if(sys) {
207  if(menu && !menu->isEmpty()) {
208  [[sys->item item] setHighlightMode:YES];
209  } else {
210  [[sys->item item] setHighlightMode:NO];
211  }
212  }
213 }
QPointer< QMenu > menu
bool isEmpty() const
Returns true if there are no visible actions inserted into the menu, false otherwise.
Definition: qmenu.cpp:1737
QSystemTrayIconSys * sys

◆ updateToolTip_sys()

void QSystemTrayIconPrivate::updateToolTip_sys ( )

Definition at line 215 of file qsystemtrayicon_mac.mm.

Referenced by QSystemTrayIconSys::findIconGeometry(), QSystemTrayIconSys::findTrayGeometry(), QSystemTrayIconPrivate(), and QSystemTrayIconSys::x11Event().

216 {
217  if(sys) {
219  QCFString string(toolTip);
220  [[[sys->item item] view] setToolTip:(NSString*)static_cast<CFStringRef>(string)];
221  }
222 }
QSystemTrayIconSys * sys

Properties

◆ icon

QIcon QSystemTrayIconPrivate::icon

Definition at line 91 of file qsystemtrayicon_p.h.

Referenced by QSystemTrayIconPrivate().

◆ menu

QPointer<QMenu> QSystemTrayIconPrivate::menu

Definition at line 90 of file qsystemtrayicon_p.h.

◆ sys

QSystemTrayIconSys* QSystemTrayIconPrivate::sys

◆ toolTip

QString QSystemTrayIconPrivate::toolTip

Definition at line 92 of file qsystemtrayicon_p.h.

◆ visible

bool QSystemTrayIconPrivate::visible

Definition at line 94 of file qsystemtrayicon_p.h.


The documentation for this class was generated from the following files: