32 #include <xmlsettingsdialog/basesettingsmanager.h> 37 #include "ui_wkfontswidget.h" 46 , Ui_ { std::make_shared<Ui::WkFontsWidget> () }
70 [
this, pair] { PendingFontChanges_ [pair.first] = pair.second->GetFont (); });
84 Util::Overload<int> (&QSpinBox::valueChanged),
85 [
this, pair] { PendingSizeChanges_ [pair.first] = pair.second->value (); });
90 Settables_ << settable;
91 connect (settable->GetQObject (),
93 [
this, settable] { Settables_.removeOne (settable); });
96 settable->
SetFontFamily (pair.first, pair.second->GetFont ());
99 settable->SetFontSize (pair.first, pair.second->value ());
104 Size2Spinbox_ [type]->setValue (size);
105 PendingSizeChanges_ [type] = size;
107 QTimer::singleShot (1000,
this, [
this] { ApplyPendingSizeChanges (); });
110 void WkFontsWidget::ResetFontChoosers ()
114 const auto& option = Family2Name_ [pair.first];
115 pair.second->SetFont (BSM_->property (option).value<QFont> ());
119 void WkFontsWidget::ResetSizeChoosers ()
123 const auto& option = Size2Name_ [pair.first];
124 pair.second->setValue (BSM_->Property (option, 10).toInt ());
128 void WkFontsWidget::ApplyPendingSizeChanges ()
130 for (
const auto& pair :
Util::Stlize (PendingSizeChanges_))
132 BSM_->setProperty (Size2Name_ [pair.first], pair.second);
135 for (
const auto settable : Settables_)
136 settable->SetFontSize (pair.first, pair.second);
139 PendingSizeChanges_.clear ();
142 void WkFontsWidget::on_ChangeAll__released ()
144 QHash<QString, QList<IWkFontsSettable::FontFamily>> families;
146 families [pair.second->GetFont ().family ()] << pair.first;
149 const auto& maxPair = *std::max_element (stlized.begin (), stlized.end (),
150 ComparingBy ([] (
auto pair) {
return pair.second.size (); }));
152 const auto dialog =
new MassFontChangeDialog { maxPair.first, maxPair.second,
this };
156 [dialog,
this] (
int result)
158 if (result == QDialog::Rejected)
161 const auto& font = dialog->GetFont ();
162 for (
const auto family : dialog->GetFamilies ())
164 PendingFontChanges_ [family] = font;
165 Family2Chooser_ [family]->SetFont (font);
172 ApplyPendingSizeChanges ();
174 for (
const auto& pair :
Util::Stlize (PendingFontChanges_))
176 BSM_->setProperty (Family2Name_ [pair.first], pair.second);
179 for (
const auto settable : Settables_)
180 settable->SetFontFamily (pair.first, pair.second);
183 PendingFontChanges_.clear ();
188 ResetFontChoosers ();
189 ResetSizeChoosers ();
191 PendingFontChanges_.clear ();
192 PendingSizeChanges_.clear ();
auto Stlize(Assoc &&assoc)
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...
virtual void SetFontFamily(FontFamily family, const QFont &font)=0
Sets the font for the given font family.
FontSize
Enumeration for possible font sizes.