summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtHighlightEditor.cpp17
-rw-r--r--Swift/QtUI/QtHighlightEditor.h4
-rw-r--r--Swift/QtUI/QtHighlightEditor.ui15
3 files changed, 20 insertions, 16 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());
+}
+
}
diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h
index ad51820..bcceb72 100644
--- a/Swift/QtUI/QtHighlightEditor.h
+++ b/Swift/QtUI/QtHighlightEditor.h
@@ -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.
*/
#pragma once
@@ -48,20 +48,22 @@ namespace Swift {
void onOkButtonClick();
void setChildWidgetStates();
void widgetClick();
void disableDialog();
void handleContactSuggestionRequested(const QString& text);
void selectSoundFile();
+ void onResetToDefaultRulesClicked();
private:
void handleOnUserSelected(const Contact::ref& contact);
void populateList();
void selectRow(int row);
int getSelectedRow() const;
HighlightRule ruleFromDialog();
void ruleToDialog(const HighlightRule& rule);
+ void updateResetToDefaultRulesVisibility();
Ui::QtHighlightEditor ui_;
QtSettingsProvider* settings_;
HighlightManager* highlightManager_;
QtSuggestingJIDInput* jid_;
int previousRow_;
diff --git a/Swift/QtUI/QtHighlightEditor.ui b/Swift/QtUI/QtHighlightEditor.ui
index 775771f..6d2338d 100644
--- a/Swift/QtUI/QtHighlightEditor.ui
+++ b/Swift/QtUI/QtHighlightEditor.ui
@@ -441,28 +441,15 @@
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
- <spacer name="horizontalSpacer_4">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
- <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>