本文整理汇总了C++中QSystemTrayIcon::contextMenu方法的典型用法代码示例。如果您正苦于以下问题:C++ QSystemTrayIcon::contextMenu方法的具体用法?C++ QSystemTrayIcon::contextMenu怎么用?C++ QSystemTrayIcon::contextMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSystemTrayIcon
的用法示例。
在下文中一共展示了QSystemTrayIcon::contextMenu方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: winEvent
bool QSystemTrayIconSys::winEvent( MSG *m, long *result )
{
switch(m->message) {
case WM_CREATE:
SetWindowLong(winId(), GWL_USERDATA, (LONG)((CREATESTRUCTW*)m->lParam)->lpCreateParams);
break;
case MYWM_NOTIFYICON:
{
QPoint gpos = QCursor::pos();
switch (m->lParam) {
case WM_LBUTTONUP:
if (ignoreNextMouseRelease)
ignoreNextMouseRelease = false;
else
emit q->activated(QSystemTrayIcon::Trigger);
break;
case WM_LBUTTONDBLCLK:
ignoreNextMouseRelease = true; // Since DBLCLICK Generates a second mouse
// release we must ignore it
emit q->activated(QSystemTrayIcon::DoubleClick);
break;
case WM_RBUTTONUP:
if (q->contextMenu()) {
q->contextMenu()->popup(gpos);
// We must ensure that the popup menu doesn't show up behind the task bar.
QRect desktopRect = qApp->desktop()->availableGeometry();
int maxY = desktopRect.y() + desktopRect.height() - q->contextMenu()->height();
if (gpos.y() > maxY) {
gpos.ry() = maxY;
q->contextMenu()->move(gpos);
}
}
emit q->activated(QSystemTrayIcon::Context);
break;
case WM_MBUTTONUP:
emit q->activated(QSystemTrayIcon::MiddleClick);
break;
default:
break;
}
break;
}
default:
return QWidget::winEvent(m, result);
}
return 0;
}
示例2: getSetCheck
// Testing get/set functions
void tst_QSystemTrayIcon::getSetCheck()
{
QSystemTrayIcon icon;
QCOMPARE(true, icon.toolTip().isEmpty());
icon.setToolTip("testToolTip");
QCOMPARE(true, "testToolTip" == icon.toolTip());
QCOMPARE(true, icon.icon().isNull());
icon.setIcon(QIcon("icons/icon.png"));
QCOMPARE(false, icon.icon().isNull());
QMenu menu;
QCOMPARE(true, icon.contextMenu() == 0);
icon.setContextMenu(&menu);
QCOMPARE(false, icon.contextMenu() == 0);
}
示例3: sipConvertFromType
static PyObject *meth_QSystemTrayIcon_contextMenu(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QSystemTrayIcon *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QSystemTrayIcon, &sipCpp))
{
QMenu *sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = sipCpp->contextMenu();
Py_END_ALLOW_THREADS
return sipConvertFromType(sipRes,sipType_QMenu,NULL);
}
}
示例4: winEvent
bool QSystemTrayIconSys::winEvent( MSG *m, long *result )
{
switch(m->message) {
case MYWM_NOTIFYICON:
{
int message = 0;
QPoint gpos;
if (version == NOTIFYICON_VERSION_4) {
Q_ASSERT(q_uNOTIFYICONID == HIWORD(m->lParam));
message = LOWORD(m->lParam);
gpos = QPoint(GET_X_LPARAM(m->wParam), GET_Y_LPARAM(m->wParam));
} else {
Q_ASSERT(q_uNOTIFYICONID == m->wParam);
message = m->lParam;
gpos = QCursor::pos();
}
switch (message) {
case NIN_SELECT:
case NIN_KEYSELECT:
if (ignoreNextMouseRelease)
ignoreNextMouseRelease = false;
else
emit q->activated(QSystemTrayIcon::Trigger);
break;
case WM_LBUTTONDBLCLK:
ignoreNextMouseRelease = true; // Since DBLCLICK Generates a second mouse
// release we must ignore it
emit q->activated(QSystemTrayIcon::DoubleClick);
break;
case WM_CONTEXTMENU:
if (q->contextMenu()) {
q->contextMenu()->popup(gpos);
q->contextMenu()->activateWindow();
}
emit q->activated(QSystemTrayIcon::Context);
break;
case NIN_BALLOONUSERCLICK:
emit q->messageClicked();
break;
case WM_MBUTTONUP:
emit q->activated(QSystemTrayIcon::MiddleClick);
break;
default:
break;
}
break;
}
default:
if (m->message == MYWM_TASKBARCREATED)
trayMessage(NIM_ADD);
else
return QWidget::winEvent(m, result);
break;
}
return 0;
}
示例5: winEvent
bool QSystemTrayIconSys::winEvent( MSG *m, long *result )
{
switch(m->message) {
case WM_CREATE:
#ifdef GWLP_USERDATA
SetWindowLongPtr(winId(), GWLP_USERDATA, (LONG_PTR)((CREATESTRUCTW*)m->lParam)->lpCreateParams);
#else
SetWindowLong(winId(), GWL_USERDATA, (LONG)((CREATESTRUCTW*)m->lParam)->lpCreateParams);
#endif
break;
case WM_DRAWITEM:
return iconDrawItem((LPDRAWITEMSTRUCT)m->lParam);
case MYWM_NOTIFYICON:
{
RECT r;
GetWindowRect(winId(), &r);
QEvent *e = 0;
Qt::KeyboardModifiers keys = QApplication::keyboardModifiers();
QPoint gpos = QCursor::pos();
switch (m->lParam) {
case WM_LBUTTONUP:
if (ignoreNextMouseRelease)
ignoreNextMouseRelease = false;
else
emit q->activated(QSystemTrayIcon::Trigger);
break;
case WM_LBUTTONDBLCLK:
ignoreNextMouseRelease = true; // Since DBLCLICK Generates a second mouse
// release we must ignore it
emit q->activated(QSystemTrayIcon::DoubleClick);
break;
case WM_RBUTTONUP:
if (q->contextMenu()) {
q->contextMenu()->popup(gpos);
#if defined(Q_WS_WINCE)
// We must ensure that the popup menu doesn't show up behind the task bar.
QRect desktopRect = qApp->desktop()->availableGeometry();
int maxY = desktopRect.y() + desktopRect.height() - q->contextMenu()->height();
if (gpos.y() > maxY) {
gpos.ry() = maxY;
q->contextMenu()->move(gpos);
}
#endif
q->contextMenu()->activateWindow();
//Must be activated for proper keyboardfocus and menu closing on windows:
}
emit q->activated(QSystemTrayIcon::Context);
break;
#if !defined(Q_WS_WINCE)
case NIN_BALLOONUSERCLICK:
emit q->messageClicked();
break;
#endif
case WM_MBUTTONUP:
emit q->activated(QSystemTrayIcon::MiddleClick);
break;
default:
break;
}
if (e) {
bool res = QApplication::sendEvent(q, e);
delete e;
return res;
}
break;
}
default:
if (m->message == MYWM_TASKBARCREATED)
trayMessage(NIM_ADD);
else
return QWidget::winEvent(m, result);
break;
}
return 0;
}