当前位置: 首页>>代码示例>>C++>>正文


C++ TrayIcon类代码示例

本文整理汇总了C++中TrayIcon的典型用法代码示例。如果您正苦于以下问题:C++ TrayIcon类的具体用法?C++ TrayIcon怎么用?C++ TrayIcon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TrayIcon类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int  main(int argc, char *argv[]) {
   LTHEME::LoadCustomEnvSettings();
   LSingleApplication a(argc, argv, "lumina-terminal");
    if( !a.isPrimaryProcess() ){ return 0; } //poked the current process instead
	
   //First make sure a system tray is available
  /*qDebug() << "Checking for system tray";
   bool ready = false;
   for(int i=0; i<60 && !ready; i++){
      ready = QSystemTrayIcon::isSystemTrayAvailable();
      if(!ready){
	//Pause for 5 seconds
        sleep(5); //don't worry about stopping event handling - nothing running yet
      }
   }
   if(!ready){
     qDebug() << "Could not find any available system tray after 5 minutes: exiting....";
     return 1;
   }*/
   
   //Now go ahead and setup the app
   LuminaThemeEngine theme(&a);
     QApplication::setQuitOnLastWindowClosed(false);   
     
   //Now start the tray icon
   TrayIcon tray;
    QObject::connect(&a, SIGNAL(InputsAvailable(QStringList)), &tray, SLOT(slotSingleInstance(QStringList)) );
    QObject::connect(&theme, SIGNAL(updateIcons()), &tray, SLOT(updateIcons()) );
    tray.parseInputs(a.inputlist);
   tray.show();
   return  a.exec();
}
开发者ID:HenryHu,项目名称:lumina,代码行数:32,代码来源:main.cpp

示例2: switch

void LxQtTray::x11EventFilter(XEventType* event)
{
    TrayIcon* icon;
    int event_type;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) // use XCB for Qt5
    event_type = event->response_type & ~0x80;
#else // use XLib for Qt4
    event_type = event->type;
#endif

    switch (event_type)
    {
        case ClientMessage:
            clientMessageEvent(event);
            break;

//        case ConfigureNotify:
//            icon = findIcon(event->xconfigure.window);
//            if (icon)
//                icon->configureEvent(&(event->xconfigure));
//            break;

        case DestroyNotify: {
            unsigned long event_window;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) // use XCB for Qt5
            event_window = reinterpret_cast<xcb_destroy_notify_event_t*>(event)->window;
#else // use XLib for Qt4
            event_window = event->xany.window;
#endif
            icon = findIcon(event_window);
            if (icon)
            {
                mIcons.removeAll(icon);
                delete icon;
            }
            break;
        }
        default:
            if (event_type == mDamageEvent + XDamageNotify)
            {
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) // use XCB for Qt5
                //FIXME: implement for XCB
                xcb_damage_notify_event_t* dmg = reinterpret_cast<xcb_damage_notify_event_t*>(event);
#else // use XLib for Qt4
                XDamageNotifyEvent* dmg = reinterpret_cast<XDamageNotifyEvent*>(event);
#endif
                icon = findIcon(dmg->drawable);
                if (icon)
                    icon->update();
            }
            break;
    }
}
开发者ID:MoonLightDE,项目名称:lxqt-panel,代码行数:53,代码来源:lxqttray.cpp

示例3: showNotification

void WindowsPlatformIntegration::showNotification(Notification *notification)
{
	TrayIcon *trayIcon = Application::getInstance()->getTrayIcon();

	if (trayIcon && QSystemTrayIcon::supportsMessages())
	{
		trayIcon->showMessage(notification);
	}
	else
	{
		NotificationDialog *dialog = new NotificationDialog(notification);
		dialog->show();
	}
}
开发者ID:sietse,项目名称:otter-browser,代码行数:14,代码来源:WindowsPlatformIntegration.cpp

示例4: nativeEventFilter

bool LXQtTray::nativeEventFilter(const QByteArray &eventType, void *message, long *)
{
    if (eventType != "xcb_generic_event_t")
        return false;

    xcb_generic_event_t* event = static_cast<xcb_generic_event_t *>(message);

    TrayIcon* icon;
    int event_type = event->response_type & ~0x80;

    switch (event_type)
    {
        case ClientMessage:
            clientMessageEvent(event);
            break;

//        case ConfigureNotify:
//            icon = findIcon(event->xconfigure.window);
//            if (icon)
//                icon->configureEvent(&(event->xconfigure));
//            break;

        case DestroyNotify: {
            unsigned long event_window;
            event_window = reinterpret_cast<xcb_destroy_notify_event_t*>(event)->window;
            icon = findIcon(event_window);
            if (icon)
            {
                icon->windowDestroyed(event_window);
                mIcons.removeAll(icon);
                delete icon;
            }
            break;
        }
        default:
            if (event_type == mDamageEvent + XDamageNotify)
            {
                xcb_damage_notify_event_t* dmg = reinterpret_cast<xcb_damage_notify_event_t*>(event);
                icon = findIcon(dmg->drawable);
                if (icon)
                    icon->update();
            }
            break;
    }

    return false;
}
开发者ID:RalfJung,项目名称:lxqt-panel,代码行数:47,代码来源:lxqttray.cpp

示例5: main

int main(int argc, char **argv)
{
	int err;

	QApplication app(argc, argv);
	err = setup_signal_handlers();
	if (err) {
		cerr << "Failed to initilize signal handlers" << endl;
		return 1;
	}
	if (!waitForSystray())
		return 1;
	TrayIcon icon;
	icon.show();
	if (!icon.init())
		return 1;
	return app.exec();
}
开发者ID:mbuesch,项目名称:pwrtray,代码行数:18,代码来源:main.cpp

示例6: switch

void RazorTray::x11EventFilter(XEvent* event) {
  TrayIcon* icon;

  switch(event->type) {
  case ClientMessage:
    if(event->xany.window == mTrayId)
      clientMessageEvent(&(event->xclient));
    break;

//        case ConfigureNotify:
//            icon = findIcon(event->xconfigure.window);
//            if (icon)
//                icon->configureEvent(&(event->xconfigure));
//            break;

  case SelectionClear:
    stopTray();
    break;

  case DestroyNotify:
    icon = findIcon(event->xany.window);

    if(icon) {
      mIcons.removeAll(icon);
      delete icon;
    }

    break;

  default:

    if(event->type == mDamageEvent + XDamageNotify) {
      XDamageNotifyEvent* dmg = reinterpret_cast<XDamageNotifyEvent*>(event);
      icon = findIcon(dmg->drawable);

      if(icon)
        icon->update();
    }

    break;
  }
}
开发者ID:victorzhao,项目名称:lxpanel-qt,代码行数:42,代码来源:razortray.cpp

示例7: qDebug

// ========================
//    PRIVATE FUNCTIONS
// ========================
void LSysTray::checkAll(){
  if(!isRunning || stopping || checking){ return; } //Don't check if not running at the moment
  checking = true;
  //Make sure this tray should handle the windows (was not disabled in the backend)
  bool TrayRunning = LSession::handle()->registerVisualTray(this->winId());
  //qDebug() << "System Tray: Check tray apps";
  bool listChanged = false;
  QList<WId> wins = LSession::handle()->currentTrayApps(this->winId());
  for(int i=0; i<trayIcons.length(); i++){
    int index = wins.indexOf(trayIcons[i]->appID());
    if(index < 0){
      //Tray Icon no longer exists: remove it
      qDebug() << " - Visual System Tray: Remove Icon";
      TrayIcon *cont = trayIcons.takeAt(i);
      LI->removeWidget(cont);
      delete cont;
      i--; //List size changed
      listChanged = true;
      //Re-adjust the maximum widget size to account for what is left
      if(this->layout()->direction()==QBoxLayout::LeftToRight){
        this->setMaximumSize( trayIcons.length()*this->height(), 10000);
      }else{
        this->setMaximumSize(10000, trayIcons.length()*this->width());
      }
    }else{
      //Tray Icon already exists
      //qDebug() << " - SysTray: Update Icon";
      //trayIcons[i]->update();
      wins.removeAt(index); //Already found - remove from the list
    }
  }
  //Now go through any remaining windows and add them
  for(int i=0; i<wins.length() && TrayRunning; i++){
    qDebug() << " - Visual System Tray: Add Icon";
    TrayIcon *cont = new TrayIcon(this);
      LSession::processEvents();
      trayIcons << cont;
      LI->addWidget(cont);
      //qDebug() << " - Update tray layout";
      if(this->layout()->direction()==QBoxLayout::LeftToRight){
        cont->setSizeSquare(this->height()-2*frame->frameWidth()); //horizontal tray
	this->setMaximumSize( trayIcons.length()*this->height(), 10000);
      }else{
	cont->setSizeSquare(this->width()-2*frame->frameWidth()); //vertical tray
	this->setMaximumSize(10000, trayIcons.length()*this->width());
      }
      LSession::processEvents();
      //qDebug() << " - Attach tray app";
      cont->attachApp(wins[i]);
      if(cont->appID()==0){ 
	//could not attach window - remove the widget
	qDebug() << "Invalid Tray Container:"; 
	trayIcons.takeAt(trayIcons.length()-1); //Always at the end
	LI->removeWidget(cont);
	delete cont;
	continue;
      }else{
	listChanged = true;
      }
    LI->update(); //make sure there is no blank space in the layout
  }
  /*if(listChanged){
    //Icons got moved around: be sure to re-draw all of them to fix visuals
    for(int i=0; i<trayIcons.length(); i++){
      trayIcons[i]->update();
    }
  }*/
  //qDebug() << " - System Tray: check done";
  checking = false;
}
开发者ID:beatgammit,项目名称:lumina,代码行数:73,代码来源:LSysTray.cpp

示例8: main


//.........这里部分代码省略.........
    app.processEvents(QEventLoop::AllEvents);

    quint16 port = 0L;

    // Find an unused port number. Essentially, we're just reserving one
    // here that Flask will use when we start up the server.
    // In order to use the socket, we need to free this socket ASAP.
    // Hence - putting this code in a code block so the scope of the socket
    // variable vanishes to make that socket available.
    {
#if QT_VERSION >= 0x050000
        QTcpSocket socket;

        #if QT_VERSION >= 0x050900
        socket.setProxy(QNetworkProxy::NoProxy);
        #endif

        socket.bind(0, QTcpSocket::ShareAddress);
#else
        QUdpSocket socket;
        socket.bind(0, QUdpSocket::ShareAddress);
#endif
        port = socket.localPort();
    }

    // Generate a random key to authenticate the client to the server
    QString key = QUuid::createUuid().toString();
    key = key.mid(1, key.length() - 2);

    // Generate the filename for the log
    logFileName = homeDir + (QString("/.%1.%2.log").arg(PGA_APP_NAME).arg(exeHash)).remove(" ");

    // Start the tray service
    TrayIcon *trayicon = new TrayIcon(logFileName);

    if (!trayicon->Init())
    {
        QString error = QString(QWidget::tr("An error occurred initialising the tray icon"));
        QMessageBox::critical(NULL, QString(QWidget::tr("Fatal Error")), error);

        exit(1);
    }

    // Fire up the webserver
    Server *server;

    bool done = false;

    while (done != true)
    {
        server = new Server(port, key, logFileName);

        if (!server->Init())
        {
            splash->finish(NULL);

            qDebug() << server->getError();

            QString error = QString(QWidget::tr("An error occurred initialising the application server:\n\n%1")).arg(server->getError());
            QMessageBox::critical(NULL, QString(QWidget::tr("Fatal Error")), error);

            exit(1);
        }

        server->start();
开发者ID:thaJeztah,项目名称:pgadmin4,代码行数:66,代码来源:pgAdmin4.cpp

示例9: switch

LRESULT TrayIcon::OnTryIcon(HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam)
{
	#ifdef _DEBUG
	wchar_t szMsg[128];
	#endif

	switch (lParam)
	{
		case WM_LBUTTONUP:
		case NIN_BALLOONUSERCLICK:
			#ifdef _DEBUG
			_wsprintf(szMsg, SKIPLEN(countof(szMsg)) (lParam==WM_LBUTTONUP) ? L"TSA: WM_LBUTTONUP(%i,0x%08X)\n" : L"TSA: NIN_BALLOONUSERCLICK(%i,0x%08X)\n", (int)wParam, (DWORD)lParam);
			DEBUGSTRICON(szMsg);
			#endif
			if (gpSet->isQuakeStyle)
			{
				bool bJustActivate = false;
				SingleInstanceShowHideType sih = sih_QuakeShowHide;
				SingleInstanceShowHideType sihHide = gpSet->isMinToTray() ? sih_HideTSA : sih_Minimize;

				if (IsWindowVisible(ghWnd) && !gpConEmu->isIconic())
				{
					if (gpSet->isAlwaysOnTop || (gpSet->isQuakeStyle == 2))
					{
						sih = sihHide;
					}
					else
					{
						UINT nVisiblePart = gpConEmu->IsQuakeVisible();
						if (nVisiblePart >= QUAKEVISIBLELIMIT)
						{
							sih = sihHide;
						}
						else
						{
							// Если поверх ConEmu есть какое-то окно, то ConEmu нужно поднять?
							// Не "выезжать" а просто "вынести наверх", если видимая область достаточно большая
							bJustActivate = (nVisiblePart >= QUAKEVISIBLETRASH) && !gpConEmu->isIconic();
						}
					}
				}

				if (bJustActivate)
				{
					SetForegroundWindow(ghWnd);
				}
				else
				{
					gpConEmu->DoMinimizeRestore(sih);
				}
			}
			else if (gpSet->isAlwaysShowTrayIcon() && IsWindowVisible(ghWnd))
			{
				if (gpSet->isMinToTray())
					Icon.HideWindowToTray();
				else
					SendMessage(ghWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
			}
			else
			{
				Icon.RestoreWindowFromTray();
			}

			switch (m_MsgSource)
			{
			case tsa_Source_Updater:
				m_MsgSource = tsa_Source_None;
				gpConEmu->CheckUpdates(2);
				break;
			case tsa_Push_Notify:
				gpConEmu->mp_PushInfo->OnNotificationClick();
				m_MsgSource = tsa_Source_None;
				break;
			}
			break;
		case NIN_BALLOONSHOW:
			#ifdef _DEBUG
			_wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"TSA: NIN_BALLOONSHOW(%i,0x%08X)\n", (int)wParam, (DWORD)lParam);
			DEBUGSTRICON(szMsg);
			#endif
			mn_BalloonShowTick = GetTickCount();
			break;
		case NIN_BALLOONTIMEOUT:
			{
				#ifdef _DEBUG
				_wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"TSA: NIN_BALLOONTIMEOUT(%i,0x%08X)\n", (int)wParam, (DWORD)lParam);
				DEBUGSTRICON(szMsg);
				#endif

				if (mb_SecondTimeoutMsg
					|| (mn_BalloonShowTick && ((GetTickCount() - mn_BalloonShowTick) > MY_BALLOON_TICK)))
				{
					m_MsgSource = tsa_Source_None;
					Icon.RestoreWindowFromTray(TRUE);
				}
				else if (!mb_SecondTimeoutMsg && (mn_BalloonShowTick && ((GetTickCount() - mn_BalloonShowTick) > MY_BALLOON_TICK)))
				{
					mb_SecondTimeoutMsg = true;
				}
			}
//.........这里部分代码省略.........
开发者ID:qyqx,项目名称:ConEmu,代码行数:101,代码来源:TrayIcon.cpp


注:本文中的TrayIcon类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。