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->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
// always visible -> put first item on the top
vecpListViewItems.Init ( USED_NUM_CHANNELS );
@ -204,8 +210,17 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP,
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 -----------------------------------------------------------
pMenu = new QMenuBar ( this );
pMenu->addMenu ( pViewMenu );
pMenu->addMenu ( new CLlconHelpMenu ( this ) );
// Now tell the layout about the menu
@ -245,6 +260,10 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP,
QObject::connect ( pServer, SIGNAL ( Stopped() ),
this, SLOT ( OnServerStopped() ) );
QObject::connect ( &SystemTrayIcon,
SIGNAL ( activated ( QSystemTrayIcon::ActivationReason ) ),
this, SLOT ( OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ) ) );
// Timers ------------------------------------------------------------------
// start timer for GUI controls
@ -333,6 +352,15 @@ void CLlconServerDlg::OnComboBoxLocationCountryActivated ( int iCntryListItem )
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()
{
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
// 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();
{
const int iMessType = ( (CLlconEvent*) Event )->iMessType;
const int iStatus = ( (CLlconEvent*) Event )->iStatus;
const int iChanNum = ( (CLlconEvent*) Event )->iChanNum;
const int iMessType = ( (CLlconEvent*) pEvent )->iMessType;
const int iStatus = ( (CLlconEvent*) pEvent )->iStatus;
const int iChanNum = ( (CLlconEvent*) pEvent )->iChanNum;
switch(iMessType)
{

View File

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

View File

@ -169,16 +169,6 @@
</property>
</spacer>
</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>
</item>
</layout>
@ -186,22 +176,5 @@
<resources>
<include location="resources.qrc" />
</resources>
<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>
<connections/>
</ui>