summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtChatWindow.cpp')
-rw-r--r--Swift/QtUI/QtChatWindow.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index 6500ba4..ed79dcc 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -239,75 +239,84 @@ QtChatWindow::AlertID QtChatWindow::addAlert(const std::string& alertText) {
void QtChatWindow::removeAlert(const AlertID id) {
std::map<AlertID, QWidget*>::iterator i = alertWidgets_.find(id);
if (i != alertWidgets_.end()) {
alertLayout_->removeWidget(i->second);
delete i->second;
alertWidgets_.erase(i);
}
}
void QtChatWindow::setTabComplete(TabComplete* completer) {
completer_ = completer;
}
void QtChatWindow::handleKeyPressEvent(QKeyEvent* event) {
event->ignore();
if (event->isAccepted()) {
return;
}
event->accept();
int key = event->key();
if (key == Qt::Key_Tab) {
tabComplete();
} else if ((key == Qt::Key_Up) && input_->toPlainText().isEmpty() && !(lastSentMessage_.isEmpty())) {
beginCorrection();
} else if (key == Qt::Key_Down && isCorrection_ && input_->textCursor().atBlockEnd()) {
cancelCorrection();
} else if (key == Qt::Key_Down || key == Qt::Key_Up) {
/* Drop */
} else {
messageLog_->handleKeyPressEvent(event);
}
}
void QtChatWindow::beginCorrection() {
+ boost::optional<AlertID> newCorrectingAlert;
if (correctionEnabled_ == ChatWindow::Maybe) {
- correctingAlert_ = addAlert(Q2PSTRING(tr("This chat may not support message correction. If you send a correction anyway, it may appear as a duplicate message")));
+ newCorrectingAlert = addAlert(Q2PSTRING(tr("This chat may not support message correction. If you send a correction anyway, it may appear as a duplicate message")));
} else if (correctionEnabled_ == ChatWindow::No) {
- correctingAlert_ = addAlert(Q2PSTRING(tr("This chat does not support message correction. If you send a correction anyway, it will appear as a duplicate message")));
+ newCorrectingAlert = addAlert(Q2PSTRING(tr("This chat does not support message correction. If you send a correction anyway, it will appear as a duplicate message")));
}
+
+ if (newCorrectingAlert) {
+ if (correctingAlert_) {
+ removeAlert(*correctingAlert_);
+ }
+ correctingAlert_ = newCorrectingAlert;
+ }
+
QTextCursor cursor = input_->textCursor();
cursor.select(QTextCursor::Document);
cursor.beginEditBlock();
cursor.insertText(QString(lastSentMessage_));
cursor.endEditBlock();
isCorrection_ = true;
correctingLabel_->show();
input_->setStyleSheet(alertStyleSheet_);
labelsWidget_->setEnabled(false);
}
void QtChatWindow::cancelCorrection() {
if (correctingAlert_) {
removeAlert(*correctingAlert_);
correctingAlert_.reset();
}
QTextCursor cursor = input_->textCursor();
cursor.select(QTextCursor::Document);
cursor.removeSelectedText();
isCorrection_ = false;
correctingLabel_->hide();
input_->setStyleSheet(qApp->styleSheet());
labelsWidget_->setEnabled(true);
}
QByteArray QtChatWindow::getSplitterState() {
return logRosterSplitter_->saveState();
}
void QtChatWindow::handleChangeSplitterState(QByteArray state) {
logRosterSplitter_->restoreState(state);
}
void QtChatWindow::handleSplitterMoved(int, int) {
emit splitterMoved();