Save provider enabled/disabled state and order
This commit is contained in:
parent
85ea3fe37f
commit
246b14d677
|
@ -261,10 +261,18 @@ void GlobalSearch::ReloadSettings() {
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
|
|
||||||
foreach (SearchProvider* provider, providers_.keys()) {
|
foreach (SearchProvider* provider, providers_.keys()) {
|
||||||
QVariant value = s.value(provider->id());
|
QVariant value = s.value("enabled_" + provider->id());
|
||||||
if (value.isValid()) {
|
if (!value.isValid())
|
||||||
|
continue;
|
||||||
|
|
||||||
providers_state_preference_.insert(provider->id(), value.toBool());
|
providers_state_preference_.insert(provider->id(), value.toBool());
|
||||||
providers_[provider].enabled_ = value.toBool() && provider->IsLoggedIn();
|
|
||||||
|
const bool old_state = providers_[provider].enabled_;
|
||||||
|
const bool new_state = value.toBool() && provider->IsLoggedIn();
|
||||||
|
|
||||||
|
if (old_state != new_state) {
|
||||||
|
providers_[provider].enabled_ = new_state;
|
||||||
|
emit ProviderToggled(provider, new_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,6 +281,6 @@ void GlobalSearch::SaveProvidersSettings() {
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
foreach (SearchProvider* provider, providers_.keys()) {
|
foreach (SearchProvider* provider, providers_.keys()) {
|
||||||
s.setValue(provider->id(), providers_[provider].enabled_);
|
s.setValue("enabled_" + provider->id(), providers_[provider].enabled_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,27 @@ void GlobalSearchSettingsPage::AddProviderItem(GlobalSearch* engine,
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalSearchSettingsPage::Save() {
|
void GlobalSearchSettingsPage::Save() {
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(GlobalSearch::kSettingsGroup);
|
||||||
|
|
||||||
|
QStringList provider_order;
|
||||||
|
|
||||||
|
for (int i=0 ; i<ui_->sources->invisibleRootItem()->childCount() ; ++i) {
|
||||||
|
const QTreeWidgetItem* item = ui_->sources->invisibleRootItem()->child(i);
|
||||||
|
const SearchProvider* provider = item->data(0, Qt::UserRole).value<SearchProvider*>();
|
||||||
|
|
||||||
|
provider_order << provider->id();
|
||||||
|
|
||||||
|
s.setValue("enabled_" + provider->id(),
|
||||||
|
item->data(0, Qt::CheckStateRole).toInt() == Qt::Checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
s.setValue("provider_order", provider_order);
|
||||||
|
s.setValue("show_globalsearch", ui_->show_globalsearch->isChecked());
|
||||||
|
s.setValue("hide_others", ui_->hide_others->isChecked() && ui_->show_globalsearch->isChecked());
|
||||||
|
s.setValue("combine_identical_results", ui_->combine->isChecked());
|
||||||
|
s.setValue("tooltip", ui_->tooltip->isChecked());
|
||||||
|
s.setValue("tooltip_help", ui_->tooltip_help->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalSearchSettingsPage::MoveUp() {
|
void GlobalSearchSettingsPage::MoveUp() {
|
||||||
|
|
|
@ -148,6 +148,8 @@ void GlobalSearchWidget::Init(GlobalSearch* engine) {
|
||||||
SLOT(ProviderAdded(const SearchProvider*)));
|
SLOT(ProviderAdded(const SearchProvider*)));
|
||||||
connect(engine_, SIGNAL(ProviderRemoved(const SearchProvider*)),
|
connect(engine_, SIGNAL(ProviderRemoved(const SearchProvider*)),
|
||||||
SLOT(ProviderRemoved(const SearchProvider*)));
|
SLOT(ProviderRemoved(const SearchProvider*)));
|
||||||
|
connect(engine_, SIGNAL(ProviderToggled(const SearchProvider*,bool)),
|
||||||
|
SLOT(ProviderToggled(const SearchProvider*,bool)));
|
||||||
|
|
||||||
// Take all the ProviderAdded signals we missed.
|
// Take all the ProviderAdded signals we missed.
|
||||||
foreach (const SearchProvider* provider, engine_->providers()) {
|
foreach (const SearchProvider* provider, engine_->providers()) {
|
||||||
|
@ -728,7 +730,7 @@ void GlobalSearchWidget::ProviderAdded(const SearchProvider* provider) {
|
||||||
// Find the appropriate insertion point.
|
// Find the appropriate insertion point.
|
||||||
bool inserted = false;
|
bool inserted = false;
|
||||||
for (int i = 0; i < ui_->provider_layout->count(); ++i) {
|
for (int i = 0; i < ui_->provider_layout->count(); ++i) {
|
||||||
const QToolButton* item_button = static_cast<QToolButton*>(
|
QToolButton* item_button = static_cast<QToolButton*>(
|
||||||
ui_->provider_layout->itemAt(i)->widget());
|
ui_->provider_layout->itemAt(i)->widget());
|
||||||
|
|
||||||
if (!item_button) {
|
if (!item_button) {
|
||||||
|
@ -776,3 +778,11 @@ void GlobalSearchWidget::ProviderButtonToggled(bool on) {
|
||||||
button->toggle();
|
button->toggle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GlobalSearchWidget::ProviderToggled(const SearchProvider* provider, bool on) {
|
||||||
|
QToolButton* button = provider_buttons_.left.find(provider)->second;
|
||||||
|
if (!button)
|
||||||
|
return;
|
||||||
|
|
||||||
|
button->setChecked(on);
|
||||||
|
}
|
||||||
|
|
|
@ -98,6 +98,7 @@ private slots:
|
||||||
void ProviderAdded(const SearchProvider* provider);
|
void ProviderAdded(const SearchProvider* provider);
|
||||||
void ProviderRemoved(const SearchProvider* provider);
|
void ProviderRemoved(const SearchProvider* provider);
|
||||||
void ProviderButtonToggled(bool on);
|
void ProviderButtonToggled(bool on);
|
||||||
|
void ProviderToggled(const SearchProvider* provider, bool on);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Return values from CanCombineResults
|
// Return values from CanCombineResults
|
||||||
|
@ -161,7 +162,7 @@ private:
|
||||||
QAction* replace_and_play_;
|
QAction* replace_and_play_;
|
||||||
QList<QAction*> actions_;
|
QList<QAction*> actions_;
|
||||||
|
|
||||||
typedef boost::bimap<const SearchProvider*, const QToolButton*> ProviderButtonMap;
|
typedef boost::bimap<const SearchProvider*, QToolButton*> ProviderButtonMap;
|
||||||
typedef ProviderButtonMap::value_type ProviderButton;
|
typedef ProviderButtonMap::value_type ProviderButton;
|
||||||
ProviderButtonMap provider_buttons_;
|
ProviderButtonMap provider_buttons_;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue