11 #include <xmlsettingsdialog/basesettingsmanager.h>
15 #include "ui_wkfontswidget.h"
24 , Ui_ { std::make_shared<Ui::WkFontsWidget> () }
48 [
this, pair] { PendingFontChanges_ [pair.first] = pair.second->GetFont (); });
62 qOverload<int> (&QSpinBox::valueChanged),
63 [
this, pair] { PendingSizeChanges_ [pair.first] = pair.second->value (); });
68 Settables_ << settable;
69 connect (settable->GetQObject (),
71 [
this, settable] { Settables_.removeOne (settable); });
74 settable->SetFontFamily (pair.first, pair.second->GetFont ());
77 settable->SetFontSize (pair.first, pair.second->value ());
82 Size2Spinbox_ [type]->setValue (size);
83 PendingSizeChanges_ [type] = size;
85 QTimer::singleShot (1000,
this, [
this] { ApplyPendingSizeChanges (); });
88 void WkFontsWidget::ResetFontChoosers ()
92 const auto& option = Family2Name_ [pair.first];
93 pair.second->SetFont (BSM_->property (option.data ()).value<QFont> ());
97 void WkFontsWidget::ResetSizeChoosers ()
101 const auto& option = Size2Name_ [pair.first];
102 pair.second->setValue (BSM_->Property (option, 10).toInt ());
106 void WkFontsWidget::ApplyPendingSizeChanges ()
108 for (
const auto& pair :
Util::Stlize (PendingSizeChanges_))
110 BSM_->setProperty (Size2Name_ [pair.first].data (), pair.second);
113 for (
const auto settable : Settables_)
114 settable->SetFontSize (pair.first, pair.second);
117 PendingSizeChanges_.clear ();
120 void WkFontsWidget::on_ChangeAll__released ()
122 QHash<QString, QList<IWkFontsSettable::FontFamily>> families;
124 families [pair.second->GetFont ().family ()] << pair.first;
127 const auto& maxPair = *std::max_element (stlized.begin (), stlized.end (),
128 ComparingBy ([] (
auto pair) {
return pair.second.size (); }));
130 const auto dialog =
new MassFontChangeDialog { maxPair.first, maxPair.second,
this };
134 [dialog,
this] (
int result)
136 if (result == QDialog::Rejected)
139 const auto& font = dialog->GetFont ();
140 for (
const auto family : dialog->GetFamilies ())
142 PendingFontChanges_ [family] = font;
143 Family2Chooser_ [family]->SetFont (font);
150 ApplyPendingSizeChanges ();
152 for (
const auto& pair :
Util::Stlize (PendingFontChanges_))
154 BSM_->setProperty (Family2Name_ [pair.first].data (), pair.second);
157 for (
const auto settable : Settables_)
158 settable->SetFontFamily (pair.first, pair.second);
161 PendingFontChanges_.clear ();
166 ResetFontChoosers ();
167 ResetSizeChoosers ();
169 PendingFontChanges_.clear ();
170 PendingSizeChanges_.clear ();