31 #include <xmlsettingsdialog/basesettingsmanager.h> 35 #include "ui_wkfontswidget.h" 44 , Ui_ { std::make_shared<Ui::WkFontsWidget> () }
66 new Util::SlotClosure<Util::NoDeletePolicy>
68 [
this, pair] { PendingFontChanges_ [pair.first] = pair.second->GetFont (); },
70 SIGNAL (fontChanged (QFont)),
85 new Util::SlotClosure<Util::NoDeletePolicy>
87 [
this, pair] { PendingSizeChanges_ [pair.first] = pair.second->value (); },
89 SIGNAL (valueChanged (
int)),
95 new Util::SlotClosure<Util::NoDeletePolicy>
97 [
this] { IsFontZoomDirty_ =
true; },
99 SIGNAL (valueChanged (
int)),
106 Ui_->Zoom_->setToolTip (label);
111 Settables_ << settable;
114 [settable,
this] { Settables_.removeAll (settable); },
115 settable->GetQObject (),
116 SIGNAL (destroyed ()),
121 settable->SetFontFamily (pair.first, pair.second->GetFont ());
124 settable->SetFontSize (pair.first, pair.second->value ());
126 settable->SetFontSizeMultiplier (Ui_->Zoom_->value () / 100.);
129 void WkFontsWidget::ResetFontChoosers ()
133 const auto& option = Family2Name_ [pair.first];
134 pair.second->SetFont (BSM_->property (option).value<QFont> ());
138 void WkFontsWidget::ResetSizeChoosers ()
142 const auto& option = Size2Name_ [pair.first];
143 pair.second->setValue (BSM_->Property (option, 10).toInt ());
147 void WkFontsWidget::ResetZoom ()
149 const auto factor = BSM_->Property (
"FontSizeMultiplier", 1).toDouble ();
150 Ui_->Zoom_->setValue (factor * 100);
153 void WkFontsWidget::on_ChangeAll__released ()
155 QHash<QString, QList<IWkFontsSettable::FontFamily>> families;
157 families [pair.second->GetFont ().family ()] << pair.first;
160 const auto& maxElem = std::max_element (stlized.begin (), stlized.end (),
161 [] (
auto left,
auto right) {
return left.second.size () < right.second.size (); });
163 const auto dialog =
new MassFontChangeDialog { maxElem->first, maxElem->second,
this };
166 new Util::SlotClosure<Util::DeleteLaterPolicy>
170 dialog->deleteLater ();
171 if (dialog->result () == QDialog::Rejected)
174 const auto& font = dialog->GetFont ();
175 for (
const auto family : dialog->GetFamilies ())
177 PendingFontChanges_ [family] = font;
178 Family2Chooser_ [family]->SetFont (font);
182 SIGNAL (finished (
int)),
189 for (
const auto& pair :
Util::Stlize (PendingFontChanges_))
191 BSM_->setProperty (Family2Name_ [pair.first], pair.second);
194 for (
const auto settable : Settables_)
195 settable->SetFontFamily (pair.first, pair.second);
198 for (
const auto& pair :
Util::Stlize (PendingSizeChanges_))
200 BSM_->setProperty (Size2Name_ [pair.first], pair.second);
203 for (
const auto settable : Settables_)
204 settable->SetFontSize (pair.first, pair.second);
207 if (IsFontZoomDirty_)
209 const auto factor = Ui_->Zoom_->value () / 100.;
211 BSM_->setProperty (
"FontSizeMultiplier", factor);
214 for (
const auto settable : Settables_)
215 settable->SetFontSizeMultiplier (factor);
218 PendingFontChanges_.clear ();
219 PendingSizeChanges_.clear ();
220 IsFontZoomDirty_ =
false;
225 ResetFontChoosers ();
226 ResetSizeChoosers ();
229 PendingFontChanges_.clear ();
230 PendingSizeChanges_.clear ();
231 IsFontZoomDirty_ =
false;
auto Stlize(Assoc &&assoc) -> detail::StlAssocRange< detail::Identity, detail::Identity, decltype(assoc.begin()), Assoc, PairType >
Converts an Qt's associative sequence assoc to an STL-like iteratable range.
Interface to aid WebKit-like-view-containing tabs to expose the view fonts configuration to the user...
Executes a given functor upon a signal (or a list of signals).