diff options
author | Tobias Markmann <tm@ayena.de> | 2015-01-18 19:12:02 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2015-02-05 09:34:57 (GMT) |
commit | edfd69a55e4f52576ab58306da8a82b1df890d5f (patch) | |
tree | 3d2a72b1014d11435f0a5592984d2894441c97e8 /Swift/QtUI/QtHighlightEditor.cpp | |
parent | 53c86d070255ae1a33b7a3642bb6eb9ce42e7f70 (diff) | |
download | swift-edfd69a55e4f52576ab58306da8a82b1df890d5f.zip swift-edfd69a55e4f52576ab58306da8a82b1df890d5f.tar.bz2 |
Add "Reset defaults" button to highlight editor window.
The button is only shown if the current rules are *not* the default
set of rules.
Test-Information:
Tested on Mac OS X 10.9.5.
Change-Id: Ibf1856af04c6bdacf6102d240e6fe5f6071cb46a
Diffstat (limited to 'Swift/QtUI/QtHighlightEditor.cpp')
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp index df9f6b2..c6e4319 100644 --- a/Swift/QtUI/QtHighlightEditor.cpp +++ b/Swift/QtUI/QtHighlightEditor.cpp @@ -2,13 +2,13 @@ * Copyright (c) 2012 Maciej Niedzielski * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2014 Isode Limited. + * Copyright (c) 2014-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <cassert> @@ -35,12 +35,13 @@ QtHighlightEditor::QtHighlightEditor(QtSettingsProvider* settings, QWidget* pare connect(ui_.newButton, SIGNAL(clicked()), SLOT(onNewButtonClicked())); connect(ui_.deleteButton, SIGNAL(clicked()), SLOT(onDeleteButtonClicked())); connect(ui_.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), SLOT(onApplyButtonClick())); connect(ui_.buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), SLOT(onCancelButtonClick())); connect(ui_.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), SLOT(onOkButtonClick())); + connect(ui_.buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()), SLOT(onResetToDefaultRulesClicked())); connect(ui_.noColorRadio, SIGNAL(clicked()), SLOT(colorOtherSelect())); connect(ui_.customColorRadio, SIGNAL(clicked()), SLOT(colorCustomSelect())); connect(ui_.noSoundRadio, SIGNAL(clicked()), SLOT(soundOtherSelect())); connect(ui_.defaultSoundRadio, SIGNAL(clicked()), SLOT(soundOtherSelect())); @@ -119,12 +120,14 @@ void QtHighlightEditor::show() populateList(); if (ui_.listWidget->count()) { selectRow(0); } + updateResetToDefaultRulesVisibility(); + /* prepare default states */ widgetClick(); QWidget::show(); QWidget::activateWindow(); } @@ -243,12 +246,14 @@ void QtHighlightEditor::onCurrentRowChanged(int currentRow) /* grey the dialog if we have nothing selected */ if (currentRow == -1) { disableDialog(); } previousRow_ = currentRow; + + updateResetToDefaultRulesVisibility(); } void QtHighlightEditor::onApplyButtonClick() { selectRow(getSelectedRow()); /* force save */ highlightManager_->storeSettings(); @@ -347,12 +352,18 @@ void QtHighlightEditor::handleContactSuggestionRequested(const QString& text) void QtHighlightEditor::selectSoundFile() { QString path = QFileDialog::getOpenFileName(this, tr("Select sound file..."), QString(), "Sounds (*.wav)"); ui_.soundFile->setText(path); } +void QtHighlightEditor::onResetToDefaultRulesClicked() { + highlightManager_->resetToDefaultRulesList(); + populateList(); + updateResetToDefaultRulesVisibility(); +} + void QtHighlightEditor::handleOnUserSelected(const Contact::ref& contact) { /* this might seem like it should be standard behaviour for the suggesting input box, but is not desirable in all cases */ if (contact->jid.isValid()) { jid_->setText(P2QSTRING(contact->jid.toString())); } else { jid_->setText(P2QSTRING(contact->name)); @@ -536,7 +547,11 @@ void QtHighlightEditor::ruleToDialog(const HighlightRule& rule) } /* set radio button child option states */ setChildWidgetStates(); } +void QtHighlightEditor::updateResetToDefaultRulesVisibility() { + ui_.buttonBox->button(QDialogButtonBox::RestoreDefaults)->setVisible(!highlightManager_->isDefaultRulesList()); +} + } |