From 8a80de10bfbda629ef2cd7db7b81232d876cef0e Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Fri, 21 Aug 2009 16:12:18 +0000 Subject: [PATCH] show status if new message is received and dialog is not open --- src/llconclientdlg.cpp | 39 +++++++++++++++++++++++++++++++++------ src/llconclientdlg.h | 1 + 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index 3dae2209..6c4b4cb6 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -26,11 +26,14 @@ /* Implementation *************************************************************/ -CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, - const bool bNewConnectOnStartup, - const bool bNewDisalbeLEDs, - QWidget* parent, Qt::WindowFlags f ) : - pClient ( pNCliP ), QDialog ( parent, f ), +CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, + const bool bNewConnectOnStartup, + const bool bNewDisalbeLEDs, + QWidget* parent, + Qt::WindowFlags f ) : + pClient ( pNCliP ), + QDialog ( parent, f ), + bUnreadChatMessage ( false ), ClientSettingsDlg ( pNCliP, parent #ifdef _WIN32 // this somehow only works reliable on Windows @@ -360,6 +363,9 @@ void CLlconClientDlg::OnOpenGeneralSettings() void CLlconClientDlg::OnChatTextReceived ( QString strChatText ) { + // init flag (will maybe overwritten later in this function) + bUnreadChatMessage = false; + ChatDlg.AddChatText ( strChatText ); // if requested, open window @@ -367,6 +373,15 @@ void CLlconClientDlg::OnChatTextReceived ( QString strChatText ) { ShowChatWindow(); } + else + { + if ( !ChatDlg.isVisible() ) + { + bUnreadChatMessage = true; + } + } + + UpdateDisplay(); } void CLlconClientDlg::OnDisconnected() @@ -383,6 +398,11 @@ void CLlconClientDlg::ShowChatWindow() // make sure dialog is upfront and has focus ChatDlg.raise(); ChatDlg.activateWindow(); + + // chat dialog is opened, reset unread message flag + bUnreadChatMessage = false; + + UpdateDisplay(); } void CLlconClientDlg::OnFaderTagTextChanged ( const QString& strNewName ) @@ -501,7 +521,14 @@ void CLlconClientDlg::UpdateDisplay() // show connection status in status bar if ( pClient->IsConnected() && pClient->IsRunning() ) { - TextLabelStatus->setText ( tr ( "Connected" ) ); + QString strStatus = tr ( "Connected" ); + + if ( bUnreadChatMessage ) + { + strStatus += ", New Chat"; + } + + TextLabelStatus->setText ( strStatus ); } else { diff --git a/src/llconclientdlg.h b/src/llconclientdlg.h index 1f61c293..a1b095be 100755 --- a/src/llconclientdlg.h +++ b/src/llconclientdlg.h @@ -78,6 +78,7 @@ protected: CClient* pClient; bool bConnected; + bool bUnreadChatMessage; QTimer TimerSigMet; QTimer TimerStatus;