62
63
extern KVIRC_API KviPointerHashTable<QString,KviWindow> * g_pGlobalWindowDict;
63
static KviPointerList<TrayIcon> * g_pTrayIconList = 0;
64
static KviTrayIconWidget * g_pTrayIcon = 0;
65
66
static QPixmap * g_pDock1 = 0;
66
67
static QPixmap * g_pDock2 = 0;
67
68
static QPixmap * g_pDock3 = 0;
69
TrayIcon::TrayIcon(KviMainWindow * frm)
70
: QSystemTrayIcon(frm), m_CurrentPixmap(ICON_SIZE,ICON_SIZE)
70
KviTrayIconWidget::KviTrayIconWidget()
71
: QSystemTrayIcon(g_pMainWindow), m_CurrentPixmap(ICON_SIZE,ICON_SIZE)
72
m_pContextPopup = new KviTalPopupMenu(0);
74
m_pContextPopup = new QMenu(0);
73
75
setContextMenu(m_pContextPopup);
81
83
m_pFlashingTimer->setObjectName("flashing_timer");
82
84
connect( m_pFlashingTimer, SIGNAL(timeout()), this, SLOT(flashingTimerShot()) );
84
g_pTrayIconList->append(this);
86
m_pFrm->setDockExtension(this);
88
m_pTip = new KviDynamicToolTip(frm,"dock_tooltip");
89
m_pAwayPopup = new KviTalPopupMenu(0);
87
g_pMainWindow->setTrayIcon(this);
89
m_pTip = new KviDynamicToolTip(g_pMainWindow,"dock_tooltip");
90
m_pAwayPopup = new QMenu(0);
91
92
m_pTitleLabel = new QLabel(__tr2qs("<b>KVIrc</b>"),m_pContextPopup);
93
94
m_pTitleLabel->setStyleSheet("background-color: " + p.color(QPalette::Normal, QPalette::Mid).name());
94
m_pContextPopup->insertItem(m_pTitleLabel);
95
QWidgetAction * pAction = new QWidgetAction(this);
96
pAction->setDefaultWidget(m_pTitleLabel);
97
m_pContextPopup->addAction(pAction);
95
99
m_pContextPopup->setWindowTitle(__tr2qs("Context"));
96
100
m_pAwayMenuId = m_pContextPopup->addMenu(m_pAwayPopup);
97
101
m_pAwayMenuId->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Away)));
103
107
id = m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::KVIrc)),__tr2qs("&About KVIrc"),this,SLOT(executeInternalCommand(bool)));
104
108
id->setData(KVI_INTERNALCOMMAND_ABOUT_ABOUTKVIRC);
106
m_pContextPopup->insertSeparator();
110
m_pContextPopup->addSeparator();
107
111
m_pToggleFrame = m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Raw)),__tr2qs("Hide/Show"),this,SLOT(toggleParentFrame()));
109
m_pContextPopup->insertSeparator();
113
m_pContextPopup->addSeparator();
111
115
id = m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::TrayIcon)),__tr2qs("Un&dock"),this,SLOT(executeInternalCommand(bool)));
112
116
id->setData(KVI_INTERNALCOMMAND_TRAYICON_HIDE);
136
void TrayIcon::executeInternalCommand(bool)
140
void KviTrayIconWidget::executeInternalCommand(bool)
140
144
iCmd=(((QAction*)QObject::sender())->data()).toInt(&bOk);
142
m_pFrm->executeInternalCommand(iCmd);
146
g_pMainWindow->executeInternalCommand(iCmd);
148
void KviTrayIconWidget::die()
149
void TrayIcon::flashingTimerShot()
153
void KviTrayIconWidget::flashingTimerShot()
151
155
m_bFlashed=!m_bFlashed;
176
180
__tr("idle idle idle idle!")
179
bool TrayIcon::event(QEvent *e)
183
bool KviTrayIconWidget::event(QEvent *e)
181
185
if(e->type()==QEvent::ToolTip)
183
QPoint pos= m_pFrm->mapFromGlobal(QCursor::pos());
187
QPoint pos= g_pMainWindow->mapFromGlobal(QCursor::pos());
186
KviWindowListBase * t = m_pFrm->windowListWidget();
190
KviWindowListBase * t = g_pMainWindow->windowListWidget();
189
193
bool first = true;
229
//int TrayIcon::message(int,void *)
233
//int KviTrayIconWidget::message(int,void *)
231
235
// qDebug("Message");
236
void TrayIcon::doAway(bool)
240
void KviTrayIconWidget::doAway(bool)
292
void TrayIcon::fillContextPopup()
296
void KviTrayIconWidget::fillContextPopup()
294
m_pToggleFrame->setText(m_pFrm->isVisible() ? __tr2qs("Hide Window") : __tr2qs("Show Window"));
298
m_pToggleFrame->setText(g_pMainWindow->isVisible() ? __tr2qs("Hide Window") : __tr2qs("Show Window"));
295
299
if(g_pApp->topmostConnectedConsole())
297
301
m_pAwayMenuId->setVisible(true);
350
void TrayIcon::toggleParentFrame()
354
void KviTrayIconWidget::toggleParentFrame()
352
356
qDebug("TrayIcon::toggleParentFrame()");
353
if(m_pFrm->isMinimized())
357
if(g_pMainWindow->isMinimized())
355
359
qDebug("- frame is minimized");
356
m_pFrm->setWindowState(m_pFrm->windowState() & (~Qt::WindowMinimized | Qt::WindowActive));
360
g_pMainWindow->setWindowState(g_pMainWindow->windowState() & (~Qt::WindowMinimized | Qt::WindowActive));
358
362
if(KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized))
360
364
qDebug("- window was maximized so calling showMaximized()");
361
m_pFrm->showMaximized();
365
g_pMainWindow->showMaximized();
363
367
qDebug("- window wasn't maximized so calling plain show()");
368
g_pMainWindow->show();
366
370
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
368
SetForegroundWindow((HWND)m_pFrm->winId());
372
SetForegroundWindow((HWND)g_pMainWindow->winId());
373
g_pMainWindow->activateWindow();
370
} else if(!m_pFrm->isVisible())
375
} else if(!g_pMainWindow->isVisible())
372
377
qDebug("- frame is not visible");
373
378
//restore mainwindow
374
379
if(KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized))
376
381
qDebug("- window was maximized so calling showMaximized()");
377
m_pFrm->showMaximized();
382
g_pMainWindow->showMaximized();
379
384
qDebug("- window wasn't maximized so calling plain show()");
385
g_pMainWindow->show();
382
387
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
384
SetForegroundWindow((HWND)m_pFrm->winId());
389
SetForegroundWindow((HWND)g_pMainWindow->winId());
390
g_pMainWindow->activateWindow();
387
qDebug("- frame is visible: maximized state=%d, hiding",m_pFrm->isMaximized());
388
KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized) = m_pFrm->isMaximized();
393
qDebug("- frame is visible: maximized state=%d, hiding",g_pMainWindow->isMaximized());
394
KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized) = g_pMainWindow->isMaximized();
395
g_pMainWindow->hide();
393
void TrayIcon::refresh()
399
void KviTrayIconWidget::refresh()
395
401
grabActivityInfo();
448
454
// This activates the context menu and is quite confusing if it *also* hides the kvirc window.
449
455
// So on mac we only _show_ the main window if it's hidden and the CloseInTray option is enabled.
450
456
if((KVI_OPTION_BOOL(KviOption_boolCloseInTray) || KVI_OPTION_BOOL(KviOption_boolMinimizeInTray))
451
&& ((!m_pFrm->isVisible()) || m_pFrm->isMinimized()))
457
&& ((!g_pMainWindow->isVisible()) || g_pMainWindow->isMinimized()))
452
458
toggleParentFrame();
453
459
#else //!COMPILE_ON_MAC
454
460
// on other platforms we always toggle the window
464
void TrayIcon::grabActivityInfo()
470
void KviTrayIconWidget::grabActivityInfo()
466
KviWindowListBase * t = m_pFrm->windowListWidget();
472
KviWindowListBase * t = g_pMainWindow->windowListWidget();
468
474
if(KVI_OPTION_BOOL(KviOption_boolUseLevelBasedTrayNotification))
556
void TrayIcon::updateIcon()
562
void KviTrayIconWidget::updateIcon()
558
564
setIcon(QIcon(m_CurrentPixmap));
561
static TrayIcon * trayicon_find(KviMainWindow *f)
563
if(!g_pTrayIconList)return 0;
564
for(TrayIcon * w = g_pTrayIconList->first();w;w = g_pTrayIconList->next())
566
if(w->frame() == f)return w;
572
568
@doc: trayicon.show
578
Shows the dock widget for the current frame window
574
Shows the tray icon (dock widget)
580
576
dock widget, system tray
584
Shows the dock widget for the current frame window.[br]
585
The dock widget is a small widget that docks in the KDE panel.[br]
586
It shows a small icon of the earth and eventually displays four squares
580
Shows the tray icon (sometimes called dock widget).[br]
581
The tray icon is a small widget that docks in the window manager panel.[br]
582
It shows a small kvirc icon and eventually displays four squares
587
583
that cover this icon: the bottom left square appears when there is some new
588
584
text in any console window, the square becomes red if the text is highlighted.[br]
589
585
The bottom right square appears when there is some new text in any channel window,
590
586
and it becomes red when the text is highlighted.[br] The upper right square refers to
591
587
query windows and the upper left one to any other kind of window (dcc, links...).[br]
592
If you move the mouse over the dock widget a tooltip will show you the last lines
588
If you move the mouse over the tray icon a tooltip will show you the last lines
593
589
of the "new" text in all these windows.[br]
594
590
This is useful when you keep the main KVIrc window minimized and you're working on something else:
595
if the dock widget shows nothing but the earth icon, nothing is happening in the main KVIrc window.
596
If the dock widget shows one or more white (or red) squares, you can move the mouse over
597
and check what's happened exactly and eventually bring up the main KVIrc window by clicking on the widget.[br]
598
[big]tecnical details[/big]
599
The dock widget is currently working in KDE compilation mode only:
600
it relies on the KWin implementation of the Window Manager interaction protocol.
591
if the tray icon shows nothing but the kvirc icon, nothing is happening in the main KVIrc window.
592
If the tray icon shows one or more white (or red) squares, you can move the mouse over
593
and check what's happened exactly and eventually bring up the main KVIrc window by clicking on the icon.[br]
602
595
[cmd]trayicon.hide[/cmd]
605
static bool trayicon_kvs_cmd_show(KviKvsModuleCommandCall * c)
598
static bool trayicon_kvs_cmd_show(KviKvsModuleCommandCall *)
607
if(!(trayicon_find(c->window()->frame())))
609
TrayIcon * w = new TrayIcon(c->window()->frame());
602
KviTrayIconWidget * w = new KviTrayIconWidget();
622
Hides the dock widget for the current frame window
615
Hides the tray icon for the current frame window
626
Hides the dock widget for the current frame window
619
Hides the tray icon for the current frame window
628
621
[cmd]trayicon.show[/cmd]
631
static bool trayicon_kvs_cmd_hide(KviKvsModuleCommandCall * c)
624
static bool trayicon_kvs_cmd_hide(KviKvsModuleCommandCall *)
633
TrayIcon * w= trayicon_find(c->window()->frame());
635
630
// show the parent frame.. otherwise there will be no way to get it back
636
if(!c->window()->frame()->isVisible())
638
c->window()->frame()->show();
631
if(!g_pMainWindow->isVisible())
632
g_pMainWindow->show();
656
650
[cmd]trayicon.show[/cmd], [cmd]trayicon.hide[/cmd]
659
static bool trayicon_kvs_cmd_hidewindow(KviKvsModuleCommandCall * c)
653
static bool trayicon_kvs_cmd_hidewindow(KviKvsModuleCommandCall *)
661
TrayIcon * w= trayicon_find(c->window()->frame());
664
c->window()->frame()->hide();
656
g_pMainWindow->hide();
716
708
g_pDock3 = new QPixmap(buffer);
718
g_pTrayIconList = new KviPointerList<TrayIcon>;
719
g_pTrayIconList->setAutoDelete(false);
722
710
KVSM_REGISTER_SIMPLE_COMMAND(m,"hide",trayicon_kvs_cmd_hide);
723
711
KVSM_REGISTER_SIMPLE_COMMAND(m,"hidewindow",trayicon_kvs_cmd_hidewindow);
724
712
KVSM_REGISTER_SIMPLE_COMMAND(m,"show",trayicon_kvs_cmd_show);