diff options
Diffstat (limited to 'Swift/QtUI/QtStatusWidget.cpp')
-rw-r--r-- | Swift/QtUI/QtStatusWidget.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Swift/QtUI/QtStatusWidget.cpp b/Swift/QtUI/QtStatusWidget.cpp index 2e9e4cc..b175e5c 100644 --- a/Swift/QtUI/QtStatusWidget.cpp +++ b/Swift/QtUI/QtStatusWidget.cpp @@ -117,120 +117,120 @@ QtStatusWidget::QtStatusWidget(StatusCache* statusCache, QWidget *parent) : QWid QtStatusWidget::~QtStatusWidget() { delete menu_; delete connectingMovie_; } void QtStatusWidget::handleApplicationFocusChanged(QWidget* /*old*/, QWidget* /*now*/) { QWidget* now = qApp->focusWidget(); if (!editing_ || stack_->currentIndex() == 0) { return; } if (!now || (now != menu_ && now != statusEdit_ && !now->isAncestorOf(statusEdit_) && !now->isAncestorOf(menu_) && !statusEdit_->isAncestorOf(now) && !menu_->isAncestorOf(now))) { handleEditCancelled(); } } void QtStatusWidget::mousePressEvent(QMouseEvent*) { if (stack_->currentIndex() == 0) { handleClicked(); } } void QtStatusWidget::generateList() { if (!editing_) { return; } QString text = statusEdit_->text(); newStatusText_ = text; menu_->clear(); - foreach (StatusShow::Type type, icons_.keys()) { + for (const auto& type : icons_.keys()) { QListWidgetItem* item = new QListWidgetItem(text == "" ? getNoMessage() : text, menu_); item->setIcon(icons_[type]); item->setToolTip(P2QSTRING(statusShowTypeToFriendlyName(type)) + ": " + item->text()); item->setStatusTip(item->toolTip()); item->setData(Qt::UserRole, QVariant(type)); } std::vector<StatusCache::PreviousStatus> previousStatuses = statusCache_->getMatches(Q2PSTRING(text), 8); - foreach (StatusCache::PreviousStatus savedStatus, previousStatuses) { + for (const auto& savedStatus : previousStatuses) { if (savedStatus.first.empty() || std::find_if(allTypes_.begin(), allTypes_.end(), savedStatus.second == lambda::_1 && savedStatus.first == lambda::bind(&statusShowTypeToFriendlyName, lambda::_1)) != allTypes_.end()) { continue; } QListWidgetItem* item = new QListWidgetItem(P2QSTRING(savedStatus.first), menu_); item->setIcon(icons_[savedStatus.second]); item->setToolTip(item->text()); item->setStatusTip(item->toolTip()); item->setData(Qt::UserRole, QVariant(savedStatus.second)); } - foreach (StatusShow::Type type, icons_.keys()) { + for (const auto& type : icons_.keys()) { if (Q2PSTRING(text) == statusShowTypeToFriendlyName(type)) { continue; } QListWidgetItem* item = new QListWidgetItem(P2QSTRING(statusShowTypeToFriendlyName(type)), menu_); item->setIcon(icons_[type]); item->setToolTip(item->text()); item->setStatusTip(item->toolTip()); item->setData(Qt::UserRole, QVariant(type)); } resizeMenu(); } void QtStatusWidget::resizeMenu() { int height = menu_->sizeHintForRow(0) * menu_->count(); int marginLeft; int marginTop; int marginRight; int marginBottom; menu_->getContentsMargins(&marginLeft, &marginTop, &marginRight, &marginBottom); height += marginTop + marginBottom; menu_->setGeometry(menu_->x(), menu_->y(), menu_->width(), height); } void QtStatusWidget::handleClicked() { editing_ = true; QDesktopWidget* desktop = QApplication::desktop(); int screen = desktop->screenNumber(this); QPoint point = mapToGlobal(QPoint(0, height())); QRect geometry = desktop->availableGeometry(screen); int x = point.x(); int y = point.y(); int width = 200; int height = 80; int screenWidth = geometry.x() + geometry.width(); if (x + width > screenWidth) { x = screenWidth - width; } - //foreach (StatusShow::Type type, allTypes_) { + //for (StatusShow::Type type : allTypes_) { // if (statusEdit_->text() == P2QSTRING(statusShowTypeToFriendlyName(type))) { statusEdit_->setText(""); // } //} generateList(); height = menu_->sizeHintForRow(0) * menu_->count(); int marginLeft; int marginTop; int marginRight; int marginBottom; menu_->getContentsMargins(&marginLeft, &marginTop, &marginRight, &marginBottom); height += marginTop + marginBottom; width += marginLeft + marginRight; menu_->setGeometry(x, y, width, height); menu_->move(x, y); menu_->setMaximumWidth(width); menu_->show(); activateWindow(); statusEdit_->selectAll(); stack_->setCurrentIndex(1); statusEdit_->setFocus(); connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(handleApplicationFocusChanged(QWidget*, QWidget*)), Qt::QueuedConnection); } void QtStatusWidget::viewMode() { disconnect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(handleApplicationFocusChanged(QWidget*, QWidget*))); editing_ = false; menu_->hide(); |