task bar button for server is not shown if it is minizied (minimized to tast bar icon)

This commit is contained in:
Volker Fischer 2011-05-07 13:04:32 +00:00
parent 1f459fff98
commit c46ad66a65
3 changed files with 49 additions and 42 deletions

View file

@ -140,6 +140,12 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP,
ListViewClients->setColumnWidth ( 2, 60 ); ListViewClients->setColumnWidth ( 2, 60 );
ListViewClients->clear(); ListViewClients->clear();
// TEST workaround for resize problem of window after iconize in task bar
ListViewClients->setMinimumWidth ( 170 + 130 + 60 + 205 );
ListViewClients->setMinimumHeight ( 140 );
// insert items in reverse order because in Windows all of them are // insert items in reverse order because in Windows all of them are
// always visible -> put first item on the top // always visible -> put first item on the top
vecpListViewItems.Init ( USED_NUM_CHANNELS ); vecpListViewItems.Init ( USED_NUM_CHANNELS );
@ -204,8 +210,17 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP,
UpdateGUIDependencies(); UpdateGUIDependencies();
// View menu --------------------------------------------------------------
QMenu* pViewMenu = new QMenu ( "&Window", this );
pViewMenu->addAction ( tr ( "E&xit" ), this,
SLOT ( close() ), QKeySequence ( Qt::CTRL + Qt::Key_Q ) );
// Main menu bar ----------------------------------------------------------- // Main menu bar -----------------------------------------------------------
pMenu = new QMenuBar ( this ); pMenu = new QMenuBar ( this );
pMenu->addMenu ( pViewMenu );
pMenu->addMenu ( new CLlconHelpMenu ( this ) ); pMenu->addMenu ( new CLlconHelpMenu ( this ) );
// Now tell the layout about the menu // Now tell the layout about the menu
@ -245,6 +260,10 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP,
QObject::connect ( pServer, SIGNAL ( Stopped() ), QObject::connect ( pServer, SIGNAL ( Stopped() ),
this, SLOT ( OnServerStopped() ) ); this, SLOT ( OnServerStopped() ) );
QObject::connect ( &SystemTrayIcon,
SIGNAL ( activated ( QSystemTrayIcon::ActivationReason ) ),
this, SLOT ( OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ) ) );
// Timers ------------------------------------------------------------------ // Timers ------------------------------------------------------------------
// start timer for GUI controls // start timer for GUI controls
@ -333,6 +352,15 @@ void CLlconServerDlg::OnComboBoxLocationCountryActivated ( int iCntryListItem )
pServer->UpdateServerList(); pServer->UpdateServerList();
} }
void CLlconServerDlg::OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ActReason )
{
// on double click on the icon, show window in fore ground
if ( ActReason == QSystemTrayIcon::DoubleClick )
{
ShowWindowInForeground();
}
}
void CLlconServerDlg::OnTimer() void CLlconServerDlg::OnTimer()
{ {
CVector<CHostAddress> vecHostAddresses; CVector<CHostAddress> vecHostAddresses;
@ -431,28 +459,31 @@ void CLlconServerDlg::UpdateSystemTrayIcon ( const bool bIsActive )
} }
} }
void CLlconServerDlg::hideEvent ( QHideEvent* ) void CLlconServerDlg::changeEvent ( QEvent* pEvent )
{ {
// TODO seems not to work correctly...
/*
// if we have a system tray icon, we make the window invisible if it is // if we have a system tray icon, we make the window invisible if it is
// minimized // minimized
if ( bSystemTrayIconAvaialbe ) if ( bSystemTrayIconAvaialbe &&
( pEvent->type() == QEvent::WindowStateChange ) )
{ {
setVisible ( false ); if ( isMinimized() )
{
// we have to call the hide function from another thread -> use
// the timer for this purpose
QTimer::singleShot ( 0, this, SLOT ( hide() ) );
}
} }
*/
} }
void CLlconServerDlg::customEvent ( QEvent* Event ) void CLlconServerDlg::customEvent ( QEvent* pEvent )
{ {
if ( Event->type() == QEvent::User + 11 ) if ( pEvent->type() == QEvent::User + 11 )
{ {
ListViewMutex.lock(); ListViewMutex.lock();
{ {
const int iMessType = ( (CLlconEvent*) Event )->iMessType; const int iMessType = ( (CLlconEvent*) pEvent )->iMessType;
const int iStatus = ( (CLlconEvent*) Event )->iStatus; const int iStatus = ( (CLlconEvent*) pEvent )->iStatus;
const int iChanNum = ( (CLlconEvent*) Event )->iChanNum; const int iChanNum = ( (CLlconEvent*) pEvent )->iChanNum;
switch(iMessType) switch(iMessType)
{ {

View file

@ -61,10 +61,12 @@ public:
Qt::WindowFlags f = 0 ); Qt::WindowFlags f = 0 );
protected: protected:
virtual void customEvent ( QEvent* Event ); virtual void customEvent ( QEvent* pEvent );
virtual void hideEvent ( QHideEvent* ); virtual void changeEvent ( QEvent* pEvent );
void UpdateGUIDependencies(); void UpdateGUIDependencies();
void UpdateSystemTrayIcon ( const bool bIsActive ); void UpdateSystemTrayIcon ( const bool bIsActive );
void ShowWindowInForeground() { showNormal(); raise(); }
QTimer Timer; QTimer Timer;
CServer* pServer; CServer* pServer;
@ -90,6 +92,7 @@ public slots:
void OnTimer(); void OnTimer();
void OnServerStarted() { UpdateSystemTrayIcon ( true ); } void OnServerStarted() { UpdateSystemTrayIcon ( true ); }
void OnServerStopped() { UpdateSystemTrayIcon ( false ); } void OnServerStopped() { UpdateSystemTrayIcon ( false ); }
void OnSysTrayMenuOpen() { showNormal(); raise(); } void OnSysTrayMenuOpen() { ShowWindowInForeground(); }
void OnSysTrayMenuExit() { close(); } void OnSysTrayMenuExit() { close(); }
void OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ActReason );
}; };

View file

@ -169,16 +169,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QPushButton" name="buttonOk" >
<property name="text" >
<string>E&amp;xit</string>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -186,22 +176,5 @@
<resources> <resources>
<include location="resources.qrc" /> <include location="resources.qrc" />
</resources> </resources>
<connections> <connections/>
<connection>
<sender>buttonOk</sender>
<signal>clicked()</signal>
<receiver>CLlconServerDlgBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>