31 #include <xmlsettingsdialog/basesettingsmanager.h>
35 #include "ui_wkfontswidget.h"
44 , Ui_ { std::make_shared<Ui::WkFontsWidget> () }
49 Family2Chooser_ [QWebSettings::StandardFont] = Ui_->StandardChooser_;
50 Family2Chooser_ [QWebSettings::FixedFont] = Ui_->FixedChooser_;
51 Family2Chooser_ [QWebSettings::SerifFont] = Ui_->SerifChooser_;
52 Family2Chooser_ [QWebSettings::SansSerifFont] = Ui_->SansSerifChooser_;
53 Family2Chooser_ [QWebSettings::CursiveFont] = Ui_->CursiveChooser_;
54 Family2Chooser_ [QWebSettings::FantasyFont] = Ui_->FantasyChooser_;
56 Family2Name_ [QWebSettings::StandardFont] =
"StandardFont";
57 Family2Name_ [QWebSettings::FixedFont] =
"FixedFont";
58 Family2Name_ [QWebSettings::SerifFont] =
"SerifFont";
59 Family2Name_ [QWebSettings::SansSerifFont] =
"SansSerifFont";
60 Family2Name_ [QWebSettings::CursiveFont] =
"CursiveFont";
61 Family2Name_ [QWebSettings::FantasyFont] =
"FantasyFont";
68 [
this, pair] { PendingChanges_ [pair.first] = pair.second->GetFont (); },
70 SIGNAL (fontChanged (QFont)),
77 Settables_ << settable;
80 [settable,
this] { Settables_.removeAll (settable); },
81 settable->GetQObject (),
82 SIGNAL (destroyed ()),
87 settable->SetFontFamily (pair.first, pair.second->GetFont ());
90 void WkFontsWidget::ResetFontChoosers ()
94 const auto& option = Family2Name_ [pair.first];
95 pair.second->SetFont (BSM_->property (option).value<QFont> ());
99 void WkFontsWidget::on_ChangeAll__released ()
102 const auto dialog =
new MassFontChangeDialog
104 Family2Chooser_ [QWebSettings::StandardFont]->GetFont (),
105 Family2Chooser_.keys (),
109 QHash<QString, QList<QWebSettings::FontFamily>> families;
111 families [pair.second->GetFont ().family ()] << pair.first;
114 const auto& maxElem = std::max_element (stlized.begin (), stlized.end (),
115 [] (
auto left,
auto right) {
return left.second.size () < right.second.size (); });
117 const auto dialog =
new MassFontChangeDialog { maxElem->first, maxElem->second,
this };
120 new Util::SlotClosure<Util::DeleteLaterPolicy>
124 dialog->deleteLater ();
125 if (dialog->result () == QDialog::Rejected)
128 const auto& font = dialog->GetFont ();
129 for (
const auto family : dialog->GetFamilies ())
131 PendingChanges_ [family] = font;
132 Family2Chooser_ [family]->SetFont (font);
136 SIGNAL (finished (
int)),
146 BSM_->setProperty (Family2Name_ [pair.first], pair.second);
148 for (
const auto settable : Settables_)
149 settable->SetFontFamily (pair.first, pair.second);
152 PendingChanges_.clear ();
157 ResetFontChoosers ();
158 PendingChanges_.clear ();
Interface to aid WebKit-view-containing tabs to expose the view fonts configuration to the user...
Executes a given functor upon a signal (or a list of signals).
auto Stlize(Assoc &&assoc) -> detail::StlAssocRange< decltype(assoc.begin()), Assoc, PairType >
Converts an Qt's associative sequence assoc to an STL-like iteratable range.