Ticket #76: getcaption.patch
| File getcaption.patch, 5.7 KB (added by amroth, 4 years ago) |
|---|
-
kmess/chat/chatwindow.h
176 176 void emoticonButtonPressed(); 177 177 // Forward the application command to the ChatMaster 178 178 void forwardAppCommand(QString cookie, QString contact, QString command); 179 // Return a list of the contacts in the chat to be used as window caption 180 QString getCaption(); 179 181 // Invite a contact to the chat 180 182 void inviteContact(QString handle); 181 183 // Notify the user of a received nudge -
kmess/chat/chatwindow.cpp
231 231 { 232 232 ContactAction *contactAction; 233 233 234 if ( msnSwitchboardConnection_ != 0 ) 235 { 236 // Avoid newlines which cause problems to the UI layout. 237 caption_ = msnSwitchboardConnection_->getCaption().replace( "\n", " " ); 238 setCaption( caption_ ); 239 } 234 // Avoid newlines which cause problems to the UI layout. 235 caption_ = getCaption().replace( "\n", " " ); 236 setCaption( caption_ ); 240 237 241 238 if( ! participants_.contains( handle ) ) 242 239 { … … 287 284 contactAction->setInChat( false ); 288 285 } 289 286 290 if( msnSwitchboardConnection_ != 0 ) 291 { 292 caption_ = msnSwitchboardConnection_->getCaption().replace( "\n", "" ); 293 setCaption( caption_ ); 294 } 287 // Change the caption to remove the contact who has left 288 caption_ = getCaption().replace( "\n", "" ); 289 setCaption( caption_ ); 295 290 296 291 participants_.remove( handle ); 297 292 … … 546 541 547 542 548 543 544 // Return a list of the contacts in the chat to be used as window caption 545 QString ChatWindow::getCaption() 546 { 547 // The chat has no switchboard connection.. it is not even a chat! 548 if( msnSwitchboardConnection_ == 0 ) 549 { 550 return i18n( "Chat" ); 551 } 552 553 // Query the switchboard for the list of participants 554 QStringList activeContacts = msnSwitchboardConnection_->getContactsInChat(); 555 556 switch( activeContacts.count() ) 557 { 558 // The chat is empty 559 case 0: 560 return i18n("Chat"); 561 break; 562 563 // One contact is connected; or the only contact of the session has left 564 case 1: 565 return i18n( "%1 - Chat" ) 566 .arg( currentAccount_->getContactFriendlyNameByHandle( activeContacts[0] ) ); 567 break; 568 569 // Two contacts are connected 570 case 2: 571 return i18n( "%1 and %2 - Chat" ) 572 .arg( currentAccount_->getContactFriendlyNameByHandle( activeContacts[0] ) ) 573 .arg( currentAccount_->getContactFriendlyNameByHandle( activeContacts[1] ) ); 574 break; 575 576 // Three or more contacts are connected 577 default: 578 return i18n( "%1 et al. - Chat" ) 579 .arg( currentAccount_->getContactFriendlyNameByHandle( activeContacts[0] ) ); 580 break; 581 } 582 583 // We can't arrive here. Is there a clean way to avoid the useless compiler warning? 584 return QString::null; 585 } 586 587 588 549 589 // Return the contact action with the given handle 550 590 ContactAction* ChatWindow::getContactActionByHandle(const QString& handle) 551 591 { … … 1813 1853 // An event requires the window to update its properties 1814 1854 void ChatWindow::update() 1815 1855 { 1816 if( KMESS_NULL(msnSwitchboardConnection_) ) return; 1817 1818 caption_ = msnSwitchboardConnection_->getCaption().replace( "\n", " " ); 1856 caption_ = getCaption().replace( "\n", " " ); 1819 1857 setCaption( caption_ ); 1820 1858 } 1821 1859 -
kmess/network/msnswitchboardconnection.cpp
547 547 548 548 549 549 550 // Get the switchboard to make a list of the contacts in the chat551 QString MsnSwitchboardConnection::getCaption()552 {553 QString caption;554 QString contactString;555 556 // Make a list of the contacts in the chat557 if( contactsInChat_.count() == 0 )558 {559 // Pretend the chat is still active, it will re-connect when the user or contact starts typing again.560 return i18n("%1 - Chat")561 .arg( currentAccount_->getContactFriendlyNameByHandle(lastContact_) );562 }563 else if( contactsInChat_.count() == 1 )564 {565 return i18n("%1 - Chat")566 .arg( currentAccount_->getContactFriendlyNameByHandle(contactsInChat_[0]) );567 }568 else if ( contactsInChat_.count() == 2 )569 {570 return i18n("%1 and %2 - Chat")571 .arg( currentAccount_->getContactFriendlyNameByHandle(contactsInChat_[0]) )572 .arg( currentAccount_->getContactFriendlyNameByHandle(contactsInChat_[1]) );573 }574 else if ( contactsInChat_.count() > 2 )575 {576 return i18n("%1 et al. - Chat")577 .arg( currentAccount_->getContactFriendlyNameByHandle(contactsInChat_[0]) );578 }579 580 return i18n("Chat");581 }582 583 584 585 550 // Make a list of the contacts in the chat 586 551 QStringList MsnSwitchboardConnection::getContactsInChat() const 587 552 { -
kmess/network/msnswitchboardconnection.h
64 64 virtual void closeConnection(); 65 65 // Clean up, close the connection, destroy this object 66 66 void closeConnectionLater(bool autoDelete = false); 67 // Get the switchboard to make a list of the contacts in the chat68 QString getCaption();69 67 // Make a list of the contacts in the chat 70 68 QStringList getContactsInChat() const; 71 69 // Return the first contact the chat started with.
