void SystemTrayIconBase::showFlash(const TrayIconData &trayIconData, int millisecondsTimeoutHint){
    
    if(trayIconData.isNull()){
        return;
    }
    
    stop();
    
    this->m_currentData = trayIconData;
    

    
    iconQueue = trayIconData.getIconList();
    setIcon(trayIconData.getFirstIcon());
    setToolTip(trayIconData.getToolTip());
    
    
    connect(timer, SIGNAL(timeout()), this, SLOT(slotShowFlash()));
    timer->setInterval(millisecondsTimeoutHint);
    timer->start();
    
    QMenu *menu = trayIconData.getMenu();
    if (menu) {
        QMenu *trayMenu = contextMenu();
        if (!trayMenu) {
            setContextMenu(menu);
        } else {
            trayMenu->addMenu(menu);
        }
    }
    


    
}
void SystemTrayIconBase::showIcon(const QIcon &icon, const QString &toolTip, QMenu *menu) {
    

    this->m_currentData.setToolTip(toolTip);
    this->m_currentData.setMenu(menu);
    this->m_currentData.settrayIconType(TrayIconData::TRAYICON_Normal);
    this->m_currentData.setFirstIcon(icon);
    
    
    stop();
    
    setIcon(icon);
    setToolTip(toolTip);
    
   
    if (menu) {
        QMenu *trayMenu = contextMenu();
        if (!trayMenu) {
            setContextMenu(menu);
        } else {
            trayMenu->addMenu(menu);
        }
    }
    
    
    
}
void SystemTrayIconBase::showIcon(const TrayIconData &trayIconData) {
    
    
    if(!trayIconData.isNull()){
        return;
    }
    
    stop();
    
    this->m_currentData = trayIconData;  
    
    
    setIcon(trayIconData.getFirstIcon());
    setToolTip(trayIconData.getToolTip());
    
    
    QMenu *menu = trayIconData.getMenu();
    if (menu) {
        QMenu *trayMenu = contextMenu();
        if (!trayMenu) {
            setContextMenu(menu);
        } else {
            trayMenu->addMenu(menu);
        }
    }
    
     

    
}
void SeafileTrayIcon::createContextMenu()
{
    // help_menu_ = new QMenu(tr("Help"), NULL);
    // help_menu_->addAction(about_action_);
    // help_menu_->addAction(open_help_action_);

    context_menu_ = new QMenu(NULL);
    context_menu_->addAction(view_unread_seahub_notifications_action_);
    context_menu_->addAction(show_main_window_action_);
    context_menu_->addAction(open_seafile_folder_action_);
    context_menu_->addAction(settings_action_);
    context_menu_->addAction(open_log_directory_action_);
    // context_menu_->addMenu(help_menu_);
    context_menu_->addSeparator();
    context_menu_->addAction(about_action_);
    context_menu_->addAction(open_help_action_);
    context_menu_->addSeparator();
    context_menu_->addAction(enable_auto_sync_action_);
    context_menu_->addAction(disable_auto_sync_action_);
    context_menu_->addSeparator();
    context_menu_->addAction(quit_action_);

    setContextMenu(context_menu_);
    connect(context_menu_, SIGNAL(aboutToShow()), this, SLOT(prepareContextMenu()));
}
//连续显示一组图标
//Show a group of icon
void SystemTrayIconBase::showAnimation(QList<QIcon> iconList,
                                       const QString &toolTip, QMenu *menu, int millisecondsTimeoutHint) {
    
    qDebug()<<"----SystemTrayIconBase::slotShowAnimation()";
    
    this->m_currentData.setToolTip(toolTip);
    this->m_currentData.setMenu(menu);
    this->m_currentData.settrayIconType(TrayIconData::TRAYICON_Animation);
    
    disconnect(timer, SIGNAL(timeout()), 0, 0);
    timer->stop();
    
    iconQueue.clear();
    iconQueue = iconList;
    setIcon(iconList.at(0));
    setToolTip(toolTip);
    
    
    connect(timer, SIGNAL(timeout()), this, SLOT(slotShowAnimation()));
    timer->setInterval(millisecondsTimeoutHint);
    timer->start();
    
    if (menu) {
        QMenu *trayMenu = contextMenu();
        if (!trayMenu) {
            setContextMenu(menu);
        } else {
            trayMenu->addMenu(menu);
        }
    }
    
    
}
示例#6
0
文件: tray.cpp 项目: zzilla/robocam
CTray::CTray( QObject * parent )
: QSystemTrayIcon( parent )
{
    m_proxy = 0;
    m_listenHost  = "";
    m_connectHost = "10.8.0.2";
    m_listenPort  = 26001;
    m_connectPort = 26001;

    setIcon( QIcon( ":images/arrow.png" ) );
    setToolTip( "Internetwork proxy" );

    m_menu = new QMenu();
    m_menu->setTitle( "Menu" );
    m_menu->setTearOffEnabled( true );

    m_actionListen = new QAction( "Listen clients", m_menu );
    m_actionListen->setCheckable( true );
    connect( m_actionListen, SIGNAL(triggered()), this, SLOT(slotListen()) );
    m_menu->addAction( m_actionListen );

    m_actionQuit = new QAction( "Quit", m_menu );
    connect( m_actionQuit, SIGNAL(triggered()), this, SLOT(slotQuit()) );
    m_menu->addAction( m_actionQuit );

    setContextMenu( m_menu );
    
    loadSettings();

    show();
}
示例#7
0
MainTray::MainTray(QObject *parent)
    : QSystemTrayIcon(parent)
    , m_updateInterval(2,0)
    , errorOccured(false)
{
#ifdef _DEBUG
    QPixmap debugIcon(48,48);
    debugIcon.fill(Qt::blue);
    setIcon(QIcon(debugIcon));
#else
    setIcon(QIcon(":/icons/Logo.png"));
#endif // _DEBUG

    
    setToolTip(tr("Scheduled Tasks"));
    createTasks();
    m_updateTimer.setTimerType(Qt::VeryCoarseTimer);
    m_updateTimer.setSingleShot(true);
    connect(&m_updateTimer, &QTimer::timeout, this, &MainTray::checkUpdateAll);

    contMenu = new QMenu(tr("Tasks Menu"), nullptr);
    createActions();
    setContextMenu(contMenu);
    readSettings();
    m_updateTimer.start(getUpdateMS());

    connect(this, &MainTray::taskGroupFinished, this, &MainTray::processQueue);
    connect(this, &MainTray::messageClicked, this, &MainTray::createErrorsDialog);
}
示例#8
0
Fortuner::TrayIcon::TrayIcon(QStringList fortuneArguments, QWidget* parent)
    : QSystemTrayIcon{qApp->windowIcon(), parent}
    , fortuneArgs{std::move(fortuneArguments)}
{
    setToolTip(tr("Fortuner"));

#ifndef Q_OS_MACOS
    // On macOS, left and right clicking a system tray icon have the same effect
    connect(this, &QSystemTrayIcon::activated,
            this, &Fortuner::TrayIcon::showFortune);
#endif

    contextMenu.addAction(icon(), tr("Show a fortune"), [this]() {
        showFortune(QSystemTrayIcon::ActivationReason::Unknown);
    });
    contextMenu.addSeparator();
    contextMenu.addAction(QIcon::fromTheme("help-about"), tr("About Fortuner…"), []() {
        QMessageBox::about(nullptr, tr("About Fortuner"),
                tr("<div style='text-align:center'>"
                   "<p><span style='font-size:35pt'>Fortuner</span><br>"
                   "Version %1</p>"
                   "<p>Fortuner shows fortunes as notifications.</p>"
                   "<p><a href='https://github.com/jnumm/fortuner'>Homepage</a></p>"
                   "<p style='font-size:small'>Copyright © Juhani Numminen 2017.<br>"
                   "Distributed under the terms of GPLv3+.</p>"
                   "</div>").arg(FORTUNER_VERSION));
    });
    contextMenu.addAction(QIcon::fromTheme("application-exit"), tr("Quit"), qApp, &QApplication::quit);
    setContextMenu(&contextMenu);
}
示例#9
0
HostTray::HostTray( QObject * parent )
: QSystemTrayIcon( parent )
{
    setIcon( QIcon( ":images/icon.png" ) );
    setToolTip( "Potentiostat" );

    m_menu = new QMenu();
    m_menu->setTitle( "Menu" );
    m_menu->setTearOffEnabled( true );

    m_actionShow = new QAction( "Show window", m_menu );
    m_actionShow->setCheckable( false );
    connect( m_actionShow, SIGNAL(triggered()), this, SLOT(slotShowMainWnd()) );
    m_menu->addAction( m_actionShow );

    m_actionQuit = new QAction( "Quit", m_menu );
    connect( m_actionQuit, SIGNAL(triggered()), this, SLOT(slotQuit()) );
    m_menu->addAction( m_actionQuit );

    setContextMenu( m_menu );

    m_mainWnd = new MainWnd( this );

    connect( this, SIGNAL(activated( QSystemTrayIcon::ActivationReason )), this, SLOT( slotActivted( QSystemTrayIcon::ActivationReason ) ) );

    show();
}
示例#10
0
KVSO_CLASS_FUNCTION(trayIcon,setContextMenu)
{
	CHECK_INTERNAL_POINTER(m_pTrayIcon)
	KviKvsObject *ob;
	kvs_hobject_t hObject;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
	KVSO_PARAMETERS_END(c)
	ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
	if (!ob)
	{
		c->warning(__tr2qs_ctx("Widget parameter is not an object","objects"));
		return true;
	}
	if (!ob->object())
	{
		c->warning(__tr2qs_ctx("Widget parameter is not a valid object","objects"));
		return true;
	}
	if(!ob->inheritsClass("popupmenu"))
	{
		c->warning(__tr2qs_ctx("Can't add a non-popupmenu object","objects"));
		return true;
	}
	 m_pTrayIcon->setContextMenu(((QMenu  *)(ob->object())));
	return true;
}
示例#11
0
文件: tray.cpp 项目: KDE/kget
/** class Tray
  * Reimplementation of the KStatusNotifierItem class
  */
Tray::Tray(MainWindow * parent)
    : KStatusNotifierItem(parent)
{
    // set up the context menu
    KMenu * cm = contextMenu();
    cm->addAction( parent->actionCollection()->action("new_download") );
    cm->addAction( parent->actionCollection()->action("import_links") );
    cm->addSeparator();
    cm->addAction( parent->actionCollection()->action("start_all_download") );
    cm->addAction( parent->actionCollection()->action("stop_all_download") );
    cm->addSeparator();
    cm->addAction( parent->actionCollection()->action("konqueror_integration") );
    cm->addAction( parent->actionCollection()->action("options_configure") );

    // Set up basic tray parameters
    setCategory(ApplicationStatus);
    setIconByName("kget");
    setTitle(i18n("KGet"));
    setContextMenu(cm);
    setAssociatedWidget(parent);
    setToolTipIconByName("kget");
    setToolTipTitle(i18n("Download Manager"));
    // Not of much use atm, but maybe we want to set this later?
    // setToolTipSubTitle("[..]");

    // filter middle mouse clicks to ask scheduler to paste URL
    connect( this, SIGNAL(secondaryActivateRequested(QPoint)),
             this, SLOT(slotActivated()) );
}
示例#12
0
void SeafileTrayIcon::createContextMenu()
{
    // help_menu_ = new QMenu(tr("Help"), NULL);
    // help_menu_->addAction(about_action_);
    // help_menu_->addAction(open_help_action_);

    context_menu_ = new QMenu(NULL);
    context_menu_->addAction(show_main_window_action_);
    context_menu_->addAction(open_seafile_folder_action_);
    context_menu_->addAction(settings_action_);
    context_menu_->addSeparator();
    context_menu_->addAction(open_log_directory_action_);
 #if defined(Q_OS_WIN32)
    context_menu_->addAction(shellext_fix_action_);
 #endif
    context_menu_->addSeparator();
    //context_menu_->addAction(upload_log_directory_action_);
    context_menu_->addAction(show_sync_errors_action_);
    // context_menu_->addMenu(help_menu_);
    context_menu_->addSeparator();
    context_menu_->addAction(about_action_);
    context_menu_->addAction(open_help_action_);
    context_menu_->addSeparator();
    context_menu_->addAction(enable_auto_sync_action_);
    context_menu_->addAction(disable_auto_sync_action_);
    context_menu_->addSeparator();
    context_menu_->addAction(quit_action_);

    setContextMenu(context_menu_);
    connect(context_menu_, SIGNAL(aboutToShow()), this, SLOT(prepareContextMenu()));
}
示例#13
0
cTrayIcon::cTrayIcon(cDataManager *DataManager):QSystemTrayIcon()
{    
    m_DataManager = DataManager;
    rebuildMenu();

    connect(&m_ProfilesMenu, SIGNAL(triggered(QAction*)), this, SLOT(onMenuSelection(QAction*)));
    m_ProfilesMenu.setTitle(tr("Profiles"));

    connect(&m_Menu, SIGNAL(triggered(QAction*)), this, SLOT(onMenuSelection(QAction*)));
    setContextMenu(&m_Menu);
    m_Menu.addAction(tr("Applications..."))->setData("APPLICATIONS");
    m_Menu.addAction(tr("Statistic..."))->setData("STATISTIC");
    m_Menu.addSeparator();
    m_Menu.addAction(tr("Settings..."))->setData("SETTINGS");
    m_Menu.addSeparator();
#ifdef Q_OS_WIN
    m_Menu.addMenu(&m_ProfilesMenu);
#else
    m_Menu.addAction(m_ProfilesMenu.title()+" ►")->setData("PROFILES");
#endif
    m_Menu.addSeparator();
    m_Menu.addAction(tr("About..."))->setData("ABOUT");
    m_Menu.addSeparator();
    m_Menu.addAction(tr("Exit"))->setData("EXIT");


    setActive();
    show();
}
示例#14
0
文件: tray.cpp 项目: AlbertR/cgru170
Tray::Tray( QWidget * parent, const QString & UserName):
   QSystemTrayIcon( parent),
   icon( afqt::stoq( af::Environment::getAfRoot()) + "/icons/talk_tray.png"),
   icon_msg( afqt::stoq( af::Environment::getAfRoot()) + "/icons/talk_tray_msg.png"),
   icon_flashing( false),
   icon_state( false),
   username( UserName),
   trayToolTipHeader("afTalk users:")
{
   connect( this, SIGNAL(     activated( QSystemTrayIcon::ActivationReason )),
            this, SLOT(   trayActivated( QSystemTrayIcon::ActivationReason )));

   QAction * restoreAction = new QAction(tr("&Hide|Raise"), this);
   connect(  restoreAction,  SIGNAL( triggered()), parent, SLOT( hideRaiseDialog()));
   QAction * quitAction    = new QAction(tr("&Quit" ), this);
   connect(  quitAction,     SIGNAL( triggered()), qApp,   SLOT( quit()));

   QMenu *trayIconMenu = new QMenu( parent);
   trayIconMenu->addAction( restoreAction);
   trayIconMenu->addSeparator();
   trayIconMenu->addAction( quitAction);
   setContextMenu(trayIconMenu);

   timer = new QTimer( this);
   timer->setInterval( 500);
   connect( timer, SIGNAL( timeout()), this, SLOT( changeIcon()));

   setIcon( icon);
   setToolTip("af Talk");
   show();
}
示例#15
0
KlipperTray::KlipperTray()
    : KSystemTrayIcon( "klipper" )
{
    klipper = new Klipper( this, KGlobal::config());
    setToolTip( i18n("Klipper - clipboard tool"));
    setContextMenu( NULL );
    show();
    connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason )), klipper,
        SLOT( slotPopupMenu()));
}
示例#16
0
avim_system_tray::avim_system_tray(const QIcon& ico)
	: QSystemTrayIcon(ico)
{
	m_context_menu.reset(new QMenu());
	auto action = m_context_menu->addAction(QStringLiteral("退出(&Q)"));
	auto action2 = m_context_menu->addAction(QStringLiteral("重新登录"));

	QObject::connect(action, &QAction::triggered, this, &avim_system_tray::menu_request_quit);
	setContextMenu(m_context_menu.get());
}
void SystemTrayIcon::iconActivated(QSystemTrayIcon::ActivationReason reason)
{
#ifndef Q_OS_MACX
    if(reason != Context)
    {
        setContextMenu(trayMenu);
        contextMenu()->popup(QCursor::pos());
    }
#endif
}
示例#18
0
VBoxTrayIcon::VBoxTrayIcon (VBoxSelectorWnd* aParent, UIVMItemModel* aVMModel)
{
    mParent = aParent;
    mVMModel = aVMModel;

    mShowSelectorAction = new QAction (this);
    Assert (mShowSelectorAction);
    mShowSelectorAction->setIcon(UIIconPool::iconSet(":/VirtualBox_16px.png"));

    mHideSystrayMenuAction = new QAction (this);
    Assert (mHideSystrayMenuAction);
    mHideSystrayMenuAction->setIcon(UIIconPool::iconSet(":/exit_16px.png"));

    /* reuse parent action data */

    mVmConfigAction = new QAction (this);
    Assert (mVmConfigAction);
    mVmConfigAction->setIcon (mParent->vmConfigAction()->icon());

    mVmDeleteAction = new QAction (this);
    Assert (mVmDeleteAction);
    mVmDeleteAction->setIcon (mParent->vmDeleteAction()->icon());

    mVmStartAction = new QAction (this);
    Assert (mVmStartAction);
    mVmStartAction->setIcon (mParent->vmStartAction()->icon());

    mVmDiscardAction = new QAction (this);
    Assert (mVmDiscardAction);
    mVmDiscardAction->setIcon (mParent->vmDiscardAction()->icon());

    mVmPauseAction = new QAction (this);
    Assert (mVmPauseAction);
    mVmPauseAction->setCheckable (true);
    mVmPauseAction->setIcon (mParent->vmPauseAction()->icon());

    mVmRefreshAction = new QAction (this);
    Assert (mVmRefreshAction);
    mVmRefreshAction->setIcon (mParent->vmRefreshAction()->icon());

    mVmShowLogsAction = new QAction (this);
    Assert (mVmConfigAction);
    mVmShowLogsAction->setIcon (mParent->vmShowLogsAction()->icon());

    mTrayIconMenu = new QMenu (aParent);
    Assert (mTrayIconMenu);

    setIcon (QIcon (":/VirtualBox_16px.png"));
    setContextMenu (mTrayIconMenu);

    connect (mShowSelectorAction, SIGNAL (triggered()), mParent, SLOT (showWindow()));
    connect (mHideSystrayMenuAction, SIGNAL (triggered()), this, SLOT (trayIconShow()));
}
示例#19
0
/// \brief Initiate and show the icon in the systray
SystrayIcon::SystrayIcon()
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
    //setup the systray icon
    haveListenerInfo	= false;
    havePluginLoaderInfo	= false;
    systrayMenu		= new QMenu();
    actionMenuAbout		= new QAction(this);
    actionMenuQuit		= new QAction(this);
    actionOptions		= new QAction(this);
    //actionTransfer		= new QAction(this);
    copyMenu		= new QMenu();
    //to prevent init bug
    stateListener=Ultracopier::NotListening;
    statePluginLoader=Ultracopier::Uncaught;

    setContextMenu(systrayMenu);
    setToolTip("Ultracopier");
    #ifdef Q_OS_WIN32
    setIcon(QIcon(":/systray_Uncaught_Windows.png"));
    #else
    setIcon(QIcon(":/systray_Uncaught_Unix.png"));
    #endif
    show();
    //connect the action
    connect(&timerCheckSetTooltip,	&QTimer::timeout,					this,	&SystrayIcon::checkSetTooltip);
    connect(actionMenuQuit,		&QAction::triggered,					this,	&SystrayIcon::quit);
    connect(actionMenuAbout,	&QAction::triggered,					this,	&SystrayIcon::showHelp);
    connect(actionOptions,		&QAction::triggered,					this,	&SystrayIcon::showOptions);
    connect(this,			&SystrayIcon::activated,				this,	&SystrayIcon::CatchAction);
    connect(plugins,		&PluginsManager::pluginListingIsfinish,			this,	&SystrayIcon::reloadEngineList);
    //display the icon
    updateCurrentTheme();
    //if theme/language change, update graphic part
    connect(themes,			&ThemesManager::theThemeIsReloaded,			this,	&SystrayIcon::updateCurrentTheme);
    connect(languages,		&LanguagesManager::newLanguageLoaded,			this,	&SystrayIcon::retranslateTheUI);
    systrayMenu->addMenu(copyMenu);
    systrayMenu->addAction(actionOptions);
    systrayMenu->addAction(actionMenuAbout);
    systrayMenu->addAction(actionMenuQuit);
    systrayMenu->insertSeparator(actionOptions);
    retranslateTheUI();
    updateSystrayIcon();

    timerCheckSetTooltip.setSingleShot(true);
    timerCheckSetTooltip.start(1000);

    //impossible with Qt on systray
    /// \note important for drag and drop, \see dropEvent()
    systrayMenu->setAcceptDrops(true);
}
示例#20
0
TrayIcon::~TrayIcon()
{
    if (debug) qDebug() << PDEBUG;

    setContextMenu(0);
    startProfileMenu->clear();
    switchToProfileMenu->clear();
    menuActions->clear();
    delete startProfileMenu;
    delete switchToProfileMenu;
    delete menuActions;
    for (int i=0; i<contextMenu.keys().count(); i++)
        delete contextMenu[contextMenu.keys()[i]];
}
示例#21
0
KugouSystemTray::KugouSystemTray(QWidget *parent)
    :QSystemTrayIcon(parent)
{
    this->setIcon(QIcon(":/image/kugou.png"));
    m_trayMenu = new QMenu();
    setContextMenu(m_trayMenu);

    this->initMusiControlInfo();
    this->initMidInfo();
    this->initBottomInfo();
    this->initAction();
    this->initForm();
    this->initConnect();
}
示例#22
0
文件: Tray.cpp 项目: coderwoo/QAltRun
void Tray::createContextMenu ()
{
    menu = new QMenu();

    exitAction = new QAction( tr("退出"),this );
    showDlgAction = new QAction( tr("显示查找对话框"),this );

    connect( exitAction,SIGNAL(triggered()),this,SLOT(exitSlot()) );
    connect( showDlgAction,SIGNAL(triggered()),this,SLOT(showDlgSlot()) );

    menu->addAction(showDlgAction);
    menu->addAction(exitAction);

    setContextMenu(menu);
}
示例#23
0
void SystemTray::createAction()
{
    setIcon(QIcon(":/main/inno"));

    m_pMenu = new QMenu();

    m_pActOpen = new QAction(this);
    m_pActLayout = new QAction(this);

    setContextMenu(m_pMenu);
    m_pMenu->setFixedWidth(100);

    connect( m_pActOpen, SIGNAL(triggered()), this, SIGNAL(showWidget()));
    connect (m_pActLayout, SIGNAL(triggered()), parent(), SLOT(close()));
}
示例#24
0
SysTray::SysTray(Playground *playground)
    : QSystemTrayIcon(playground)
{
  this->playground = playground;
  this->prefsWindow = new PrefsWindow(playground, playground); //Why isn't QSystemTray a QWidget?
  setIcon(QIcon(":/box/box.svg"));
  
  //Quit Action
  quitAction = new QAction(tr("&Quit"), this);
  connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
  
  //Clear Action
  clearAction = new QAction(tr("C&lear"), this);
  connect(clearAction, SIGNAL(triggered()), playground, SLOT(clear()));
  
  //Show Preferences Window
  prefsAction = new QAction(tr("&Preferences"), this);
  connect(prefsAction, SIGNAL(triggered()), prefsWindow, SLOT(showPreferences()));
  
  //Group of shape actions
  shapeActions = new QActionGroup(this);
     
  //Drop circle - enabled by default
  dropCircleAction = new QAction(tr("&Circles"), shapeActions);
  dropCircleAction->setCheckable(true);
  dropCircleAction->setChecked(true);
  connect(dropCircleAction, SIGNAL(triggered()), this, SLOT(setCircles()));
  setCircles();
  
  //Drop boxes
  dropSquareAction = new QAction(tr("&Squares"), shapeActions);
  dropSquareAction->setCheckable(true);
  connect(dropSquareAction, SIGNAL(triggered()), this, SLOT(setSquares()));

  //Build the menu
  trayIconMenu = new QMenu(playground);
  trayIconMenu->addAction(dropSquareAction);
  trayIconMenu->addAction(dropCircleAction);
  trayIconMenu->addSeparator();
  trayIconMenu->addAction(clearAction);
  trayIconMenu->addAction(prefsAction);
  trayIconMenu->addSeparator();
  trayIconMenu->addAction(quitAction);
  setContextMenu(trayIconMenu);
  
  //Tells us if a mouse click on the tray necessitates block creation
  connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(activation(QSystemTrayIcon::ActivationReason)));
}
示例#25
0
QlipperSystray::QlipperSystray(QObject *parent)
    : QSystemTrayIcon(parent)
#ifndef NO_QXT
      , m_shortcutMenu(0)
#endif
{
    setIcon(QIcon(QlipperPreferences::Instance()->getPathToIcon()));

    m_model = new QlipperModel(this);

    m_contextMenu = new QMenu();
    m_contextMenu->addAction(QIcon::fromTheme("edit-clear-hstory", QIcon(":/icons/edit-clear-history.png")), tr("C&lear clipboard history")
            , m_model, &QlipperModel::clearHistory);
    m_contextMenu->addAction(QIcon::fromTheme("configure", QIcon(":/icons/configure.png")), tr("&Configure...")
            , this, &QlipperSystray::editPreferences);
    m_contextMenu->addSeparator();
    m_contextMenu->addAction(QIcon::fromTheme("help-about", QIcon(":/icons/help-about.png")), tr("&About Qlipper...")
            , this, &QlipperSystray::showAbout);
    m_contextMenu->addAction(QIcon::fromTheme("application-exit", QIcon(":/icons/application-exit.png")), tr("&Quit")
            , qApp, &QCoreApplication::quit);
    setContextMenu(m_contextMenu);

#ifndef NO_QXT
    m_shortcutMenu = new QMenuView();
    m_shortcutMenu->setModel(m_model);
    m_shortcutMenu->setWindowTitle(tr("Qlipper - a clipboard history applet"));

    // Windows API does not handle well some combinations of flags in custom widgets.
#ifndef Q_OS_WIN32
    // This flag is mandatory to get focus when user activates global_key.
    // OK, window gets a decoration but it works. Menu is displayed without the
    // the decoration if is the systray icon clicked.
    m_shortcutMenu->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint);
#endif

    connect(m_shortcutMenu, SIGNAL(triggered(QModelIndex)), m_model, SLOT(indexTriggered(QModelIndex)));
    connect(m_shortcutMenu, SIGNAL(triggered(QModelIndex)), m_shortcutMenu, SLOT(close()));

    m_shortcut = new QxtGlobalShortcut(this);
    connect(m_shortcut, SIGNAL(activated()), this, SLOT(shortcut_activated()));
    m_shortcut->setShortcut(QlipperPreferences::Instance()->shortcut());
#else
    qWarning() << "Global keyboard shortcut is not compiled in.";
#endif

    connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this, SLOT(systray_activated(QSystemTrayIcon::ActivationReason)));
}
示例#26
0
TrayIcon::TrayIcon(const QString& trayIcon,const QString& programName, QObject *parent) :
    QSystemTrayIcon(QIcon(trayIcon),parent)
{
    setToolTip(programName);

    pMenu=new QMenu;
    pMenu->addAction("Головне вікно",this,SIGNAL(mainWindowSignal()));
    pMenu->addAction("Вікно налаштувань",this,SIGNAL(settingsSignal()));
    pMenu->addAction("Оновити курси",this,SIGNAL(updateSignal()));
    pMenu->addSeparator();
    pMenu->addAction("Вийти",qApp,SLOT(quit()));
    setContextMenu(pMenu);

    connect(this,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            SLOT(activatedSlot(QSystemTrayIcon::ActivationReason)));
}
示例#27
0
void TrayIcon::makeContextMenu()
{
    if (contextMenu() == 0)
    {
        setContextMenu(new QMenu());
    }
    else
    {
        contextMenu()->clear();
    }

    QAction* settingsAction = contextMenu()->addAction("Settings...");
    connect(settingsAction, SIGNAL(triggered()), &settingsDialog, SLOT(exec()));
    QAction* exitAction = contextMenu()->addAction("Exit");
    connect(exitAction, SIGNAL(triggered()), this, SLOT(exitAutoSuspender()));
}
示例#28
0
InTray::InTray(QObject *parent) : QSystemTrayIcon(parent)
{
    QIcon *icon = new QIcon("ico.png");
    setIcon(*icon);
    QAction *settingsAction, *quitAction;
    settingsAction = new QAction("Ustawienia", 0);
    quitAction = new QAction("Wyjście", 0);

    QMenu *trayMenu = new QMenu();
    trayMenu->addAction(settingsAction);
    trayMenu->addAction(quitAction);

    connect(settingsAction, SIGNAL(triggered()), this, SLOT(showSettings()) );
    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    setContextMenu(trayMenu);
}
示例#29
0
void SeafileTrayIcon::createContextMenu()
{
    context_menu_ = new QMenu(NULL);

    context_menu_->addAction(toggle_main_window_action_);
    context_menu_->addAction(settings_action_);
    context_menu_->addSeparator();
    context_menu_->addAction(enable_auto_sync_action_);
    context_menu_->addAction(disable_auto_sync_action_);
    context_menu_->addSeparator();
    context_menu_->addAction(quit_action_);

    setContextMenu(context_menu_);

    connect(context_menu_, SIGNAL(aboutToShow()),
            this, SLOT(prepareContextMenu()));
}
示例#30
0
void TrayIcon::initTrayMenu()
{
	if(m_trayMenu) return;

	m_trayMenu = new QMenu();
	m_pConfigWndAction = m_trayMenu->addAction("显示本机ip");
	//m_pConfigWndAction->setCheckable(true);
	//m_p = m_trayMenu->addAction("无功能");
	m_trayMenu->addSeparator();
	m_pExitAppAction = m_trayMenu->addAction("退出");

	connect(m_pConfigWndAction, SIGNAL(triggered()), this, SLOT(onTriggerConfigWnd()));
	//connect(m_p, SIGNAL(triggered()), this, SIGNAL(clearCache()));
	connect(m_pExitAppAction, SIGNAL(triggered()), this, SIGNAL(exitApp()));

	setContextMenu(m_trayMenu);
}