diff options
| author | Richard Maudsley <richard.maudsley@isode.com> | 2014-07-28 12:52:25 (GMT) |
|---|---|---|
| committer | Swift Review <review@swift.im> | 2014-07-29 06:46:46 (GMT) |
| commit | 8767caf20b83f5b6e4c52c3818c92a6238e208c4 (patch) | |
| tree | b18d96d2f04040b27a71754a3a5a7b197fbd5ad7 | |
| parent | 170e408e18579ceac6520a404ad945fcda404248 (diff) | |
| download | swift-contrib-8767caf20b83f5b6e4c52c3818c92a6238e208c4.zip swift-contrib-8767caf20b83f5b6e4c52c3818c92a6238e208c4.tar.bz2 | |
Add close button to chat window alerts.
Test-Information:
Check that close button is functional.
Change-Id: I45078cb50e410365704e6a8b2444e1a4b15db068
| -rw-r--r-- | Swift/Controllers/UIInterfaces/ChatWindow.h | 2 | ||||
| -rw-r--r-- | Swift/Controllers/UnitTest/MockChatWindow.h | 2 | ||||
| -rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 32 | ||||
| -rw-r--r-- | Swift/QtUI/QtChatWindow.h | 3 |
4 files changed, 22 insertions, 17 deletions
diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h index f2f5f76..6b2799b 100644 --- a/Swift/Controllers/UIInterfaces/ChatWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatWindow.h @@ -166,3 +166,3 @@ namespace Swift { */ - virtual AlertID addAlert(const std::string& alertText, const std::string& buttonText = "") = 0; + virtual AlertID addAlert(const std::string& alertText) = 0; /** diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h index ef7216b..774bdd9 100644 --- a/Swift/Controllers/UnitTest/MockChatWindow.h +++ b/Swift/Controllers/UnitTest/MockChatWindow.h @@ -58,3 +58,3 @@ namespace Swift { virtual void flash() {} - virtual AlertID addAlert(const std::string& /*alertText*/, const std::string& /*buttonText*/) { return 0; } + virtual AlertID addAlert(const std::string& /*alertText*/) { return 0; } virtual void removeAlert(const AlertID /*id*/) {} diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 574a0a2..3491d3c 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -201,6 +201,13 @@ void QtChatWindow::handleFontResized(int fontSizeSteps) { void QtChatWindow::handleAlertButtonClicked() { - onAlertButtonClicked(); + const QObject* alertWidget = QObject::sender()->parent(); + std::map<AlertID, QWidget*>::const_iterator i = alertWidgets_.begin(); + for ( ; i != alertWidgets_.end(); ++i) { + if (i->second == alertWidget) { + removeAlert(i->first); + break; + } + } } -QtChatWindow::AlertID QtChatWindow::addAlert(const std::string& alertText, const std::string& buttonText) { +QtChatWindow::AlertID QtChatWindow::addAlert(const std::string& alertText) { QWidget* alertWidget = new QWidget(this); @@ -209,6 +216,13 @@ QtChatWindow::AlertID QtChatWindow::addAlert(const std::string& alertText, const QLabel* alertLabel = new QLabel(this); + alertLabel->setText(alertText.c_str()); alertLayout->addWidget(alertLabel); - alertButton_ = new QPushButton(this); - connect (alertButton_, SIGNAL(clicked()), this, SLOT(handleAlertButtonClicked())); - alertLayout->addWidget(alertButton_); + + QToolButton* closeButton = new QToolButton(alertWidget); + closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton)); + closeButton->setIconSize(QSize(16,16)); + closeButton->setCursor(Qt::ArrowCursor); + closeButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"); + connect (closeButton, SIGNAL(clicked()), this, SLOT(handleAlertButtonClicked())); + + alertLayout->addWidget(closeButton); QPalette palette = alertWidget->palette(); @@ -219,10 +233,2 @@ QtChatWindow::AlertID QtChatWindow::addAlert(const std::string& alertText, const - alertLabel->setText(alertText.c_str()); - if (buttonText.empty()) { - alertButton_->hide(); - } else { - alertButton_->setText(buttonText.c_str()); - alertButton_->show(); - } - AlertID id = nextAlertId_++; diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index 45eaa6f..bf37557 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -136,3 +136,3 @@ namespace Swift { void handleFontResized(int fontSizeSteps); - AlertID addAlert(const std::string& alertText, const std::string& buttonText = ""); + AlertID addAlert(const std::string& alertText); void removeAlert(const AlertID id); @@ -199,3 +199,2 @@ namespace Swift { AlertID nextAlertId_; - QPushButton* alertButton_; TabComplete* completer_; |
Swift