diff options
-rw-r--r-- | Swift/QtUI/QtHighlightNotificationConfigDialog.cpp | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtSoundSelectionStyledItemDelegate.cpp | 10 |
2 files changed, 1 insertions, 11 deletions
diff --git a/Swift/QtUI/QtHighlightNotificationConfigDialog.cpp b/Swift/QtUI/QtHighlightNotificationConfigDialog.cpp index c4e64ab..19274a2 100644 --- a/Swift/QtUI/QtHighlightNotificationConfigDialog.cpp +++ b/Swift/QtUI/QtHighlightNotificationConfigDialog.cpp @@ -106,61 +106,61 @@ void QtHighlightNotificationConfigDialog::setHighlightManager(HighlightManager* highlightManager_ = highlightManager; } void QtHighlightNotificationConfigDialog::setContactSuggestions(const std::vector<Contact::ref>& /*suggestions*/) { } HighlightConfiguration QtHighlightNotificationConfigDialog::getHighlightConfigurationFromDialog() const { auto qtColorToOptionalString = [&](const QColor& color) { boost::optional<std::string> colorString; if (color.isValid()) { colorString = Q2PSTRING(color.name(QColor::HexRgb)); } return colorString; }; auto getHighlightActionFromWidgetItem = [&](const QTreeWidgetItem* item, int startingColumn) { HighlightAction action; action.setFrontColor(qtColorToOptionalString(item->data(startingColumn, QtColorSelectionStyledItemDelegate::DATA_ROLE).value<QColor>())); action.setBackColor(qtColorToOptionalString(item->data(startingColumn + 1, QtColorSelectionStyledItemDelegate::DATA_ROLE).value<QColor>())); std::string soundFilePath = Q2PSTRING(item->data(startingColumn + 2, Qt::EditRole).toString()); if (soundFilePath == "defaultSound") { action.setSoundFilePath(boost::optional<std::string>("")); } else if (soundFilePath.empty()) { action.setSoundFilePath(boost::optional<std::string>()); } else { - action.setSoundFilePath(boost::optional<std::string>(soundFilePath)); + action.setSoundFilePath(boost::optional<std::string>("")); } action.setSystemNotificationEnabled(item->data(startingColumn + 3, QtCheckBoxStyledItemDelegate::DATA_ROLE).toBool()); return action; }; HighlightConfiguration uiConfiguration; // contact highlights for (int i = 0; i < ui_.userHighlightTreeWidget->topLevelItemCount(); i++) { auto item = ui_.userHighlightTreeWidget->topLevelItem(i); HighlightConfiguration::ContactHighlight contactHighlight; contactHighlight.name = Q2PSTRING(item->data(0, Qt::EditRole).toString()); contactHighlight.action = getHighlightActionFromWidgetItem(item, 1); uiConfiguration.contactHighlights.push_back(contactHighlight); } // keyword highlights for (int i = 0; i < ui_.keywordHighlightTreeWidget->topLevelItemCount(); i++) { auto item = ui_.keywordHighlightTreeWidget->topLevelItem(i); HighlightConfiguration::KeywordHightlight keywordHighlight; keywordHighlight.keyword = Q2PSTRING(item->data(0, Qt::EditRole).toString()); keywordHighlight.matchCaseSensitive = item->data(1, QtCheckBoxStyledItemDelegate::DATA_ROLE).toBool(); keywordHighlight.action = getHighlightActionFromWidgetItem(item, 2); uiConfiguration.keywordHighlights.push_back(keywordHighlight); } // general configuration uiConfiguration.playSoundOnIncomingDirectMessages = ui_.playSoundOnDirectMessagesCheckBox->isChecked(); uiConfiguration.showNotificationOnIncomingDirectMessages = ui_.notificationOnDirectMessagesCheckBox->isChecked(); diff --git a/Swift/QtUI/QtSoundSelectionStyledItemDelegate.cpp b/Swift/QtUI/QtSoundSelectionStyledItemDelegate.cpp index 3811004..03af455 100644 --- a/Swift/QtUI/QtSoundSelectionStyledItemDelegate.cpp +++ b/Swift/QtUI/QtSoundSelectionStyledItemDelegate.cpp @@ -56,56 +56,46 @@ void QtSoundSelectionStyledItemDelegate::paint(QPainter* painter, const QStyleOp QApplication::style()->drawControl(QStyle::CE_ComboBoxLabel, &opt, painter); painter->restore(); } bool QtSoundSelectionStyledItemDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& /*option*/, const QModelIndex& index) { if (event->type() == QEvent::MouseButtonRelease) { auto mouseEvent = dynamic_cast<QMouseEvent*>(event); assert(mouseEvent); auto editRoleString = index.data(Qt::EditRole).toString(); auto popUpMenu = new QMenu(); auto noSound = popUpMenu->addAction(tr("No sound")); auto defaultSound = popUpMenu->addAction(tr("Default sound")); QAction* customSoundFile = nullptr; QAction* selectedAction = nullptr; if (editRoleString.isEmpty()) { selectedAction = noSound; } else if (editRoleString == "defaultSound") { selectedAction = defaultSound; } else { customSoundFile = popUpMenu->addAction(editRoleString); selectedAction = customSoundFile; } if (selectedAction) { selectedAction->setCheckable(true); selectedAction->setChecked(true); } - auto chooseSoundFile = popUpMenu->addAction(tr("Choose sound fileā¦")); selectedAction = popUpMenu->exec(mouseEvent->globalPos(), selectedAction); if (selectedAction == defaultSound) { model->setData(index, "defaultSound", Qt::EditRole); } - else if (customSoundFile && (selectedAction == customSoundFile)) { - model->setData(index, customSoundFile->text(), Qt::EditRole); - } else if (selectedAction == noSound) { model->setData(index, "", Qt::EditRole); } - else if (selectedAction == chooseSoundFile) { - auto newPath = QFileDialog::getOpenFileName(0, tr("Choose notification sound file"), "", tr("WAV Files (*.wav)")); - if (!newPath.isEmpty()) { - model->setData(index, newPath, Qt::EditRole); - } - } delete popUpMenu; } return true; } }; |