Changeset View
Changeset View
Standalone View
Standalone View
kcms/fonts/fonts.cpp
Show All 25 Lines | |||||
26 | 26 | | |||
27 | 27 | | |||
28 | #include "fonts.h" | 28 | #include "fonts.h" | ||
29 | 29 | | |||
30 | #include <QQuickItem> | 30 | #include <QQuickItem> | ||
31 | #include <QWindow> | 31 | #include <QWindow> | ||
32 | #include <QQmlEngine> | 32 | #include <QQmlEngine> | ||
33 | #include <QQuickView> | 33 | #include <QQuickView> | ||
34 | #include <QFontDialog> | | |||
35 | #include <QApplication> | 34 | #include <QApplication> | ||
36 | #include <QFontDatabase> | 35 | #include <QFontDatabase> | ||
37 | 36 | | |||
38 | #include <KAcceleratorManager> | 37 | #include <KAcceleratorManager> | ||
39 | #include <KGlobalSettings> | 38 | #include <KGlobalSettings> | ||
40 | #include <KConfigGroup> | 39 | #include <KConfigGroup> | ||
41 | #include <KConfig> | 40 | #include <KConfig> | ||
42 | #include <KAboutData> | 41 | #include <KAboutData> | ||
43 | #include <KLocalizedString> | 42 | #include <KLocalizedString> | ||
44 | #include <KPluginFactory> | 43 | #include <KPluginFactory> | ||
45 | #include <KFontDialog> | 44 | #include <KFontChooserDialog> | ||
46 | #include <KWindowSystem> | 45 | #include <KWindowSystem> | ||
47 | 46 | | |||
48 | #include "../krdb/krdb.h" | 47 | #include "../krdb/krdb.h" | ||
49 | #include "previewimageprovider.h" | 48 | #include "previewimageprovider.h" | ||
50 | #include "kxftconfig.h" | 49 | #include "kxftconfig.h" | ||
51 | 50 | | |||
52 | #include "fontssettings.h" | 51 | #include "fontssettings.h" | ||
53 | #include "fontsaasettings.h" | 52 | #include "fontsaasettings.h" | ||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Line(s) | 222 | #endif | |||
225 | 224 | | |||
226 | KGlobalSettings::self()->emitChange(KGlobalSettings::FontChanged); | 225 | KGlobalSettings::self()->emitChange(KGlobalSettings::FontChanged); | ||
227 | 226 | | |||
228 | runRdb(KRdbExportXftSettings | KRdbExportGtkTheme); | 227 | runRdb(KRdbExportXftSettings | KRdbExportGtkTheme); | ||
229 | 228 | | |||
230 | emit fontsHaveChanged(); | 229 | emit fontsHaveChanged(); | ||
231 | } | 230 | } | ||
232 | 231 | | |||
232 | void KFonts::adjustFont(const QFont &font, const QString &category) | ||||
233 | { | ||||
234 | QFont selFont = font; | ||||
235 | int ret = KFontChooserDialog::getFont(selFont, KFontChooser::NoDisplayFlags); | ||||
236 | | ||||
237 | if (ret == QDialog::Accepted) { | ||||
238 | if (category == QLatin1String("font")) { | ||||
239 | m_settings->setFont(selFont); | ||||
240 | } else if (category == QLatin1String("menuFont")) { | ||||
241 | m_settings->setMenuFont(selFont); | ||||
242 | } else if (category == QLatin1String("toolBarFont")) { | ||||
243 | m_settings->setToolBarFont(selFont); | ||||
244 | } else if (category == QLatin1String("activeFont")) { | ||||
245 | m_settings->setActiveFont(selFont); | ||||
246 | } else if (category == QLatin1String("smallestReadableFont")) { | ||||
247 | m_settings->setSmallestReadableFont(selFont); | ||||
248 | } else if (category == QLatin1String("fixed")) { | ||||
249 | m_settings->setFixed(selFont); | ||||
250 | } | ||||
251 | } | ||||
252 | } | ||||
253 | | ||||
233 | void KFonts::adjustAllFonts() | 254 | void KFonts::adjustAllFonts() | ||
234 | { | 255 | { | ||
235 | QFont font = m_settings->font(); | 256 | QFont font = m_settings->font(); | ||
236 | KFontChooser::FontDiffFlags fontDiffFlags; | 257 | KFontChooser::FontDiffFlags fontDiffFlags; | ||
237 | int ret = KFontDialog::getFontDiff(font, fontDiffFlags, KFontChooser::NoDisplayFlags); | 258 | int ret = KFontChooserDialog::getFontDiff(font, fontDiffFlags, KFontChooser::NoDisplayFlags); | ||
238 | 259 | | |||
239 | if (ret == KDialog::Accepted && fontDiffFlags) { | 260 | if (ret == QDialog::Accepted && fontDiffFlags) { | ||
240 | if (!m_settings->isImmutable("font")) { | | |||
241 | m_settings->setFont(applyFontDiff(m_settings->font(), font, fontDiffFlags)); | 261 | m_settings->setFont(applyFontDiff(m_settings->font(), font, fontDiffFlags)); | ||
242 | } | | |||
243 | if (!m_settings->isImmutable("menuFont")) { | | |||
244 | m_settings->setMenuFont(applyFontDiff(m_settings->menuFont(), font, fontDiffFlags)); | 262 | m_settings->setMenuFont(applyFontDiff(m_settings->menuFont(), font, fontDiffFlags)); | ||
245 | } | | |||
246 | if (!m_settings->isImmutable("toolBarFont")) { | | |||
247 | m_settings->setToolBarFont(applyFontDiff(m_settings->toolBarFont(), font, fontDiffFlags)); | 263 | m_settings->setToolBarFont(applyFontDiff(m_settings->toolBarFont(), font, fontDiffFlags)); | ||
248 | } | | |||
249 | if (!m_settings->isImmutable("activeFont")) { | | |||
250 | m_settings->setActiveFont(applyFontDiff(m_settings->activeFont(), font, fontDiffFlags)); | 264 | m_settings->setActiveFont(applyFontDiff(m_settings->activeFont(), font, fontDiffFlags)); | ||
251 | } | | |||
252 | if (!m_settings->isImmutable("smallestReadableFont")) { | | |||
253 | m_settings->setSmallestReadableFont(applyFontDiff(m_settings->smallestReadableFont(), font, fontDiffFlags)); | 265 | m_settings->setSmallestReadableFont(applyFontDiff(m_settings->smallestReadableFont(), font, fontDiffFlags)); | ||
254 | } | 266 | | ||
255 | const QFont adjustedFont = applyFontDiff(m_settings->fixed(), font, fontDiffFlags); | 267 | const QFont adjustedFont = applyFontDiff(m_settings->fixed(), font, fontDiffFlags); | ||
256 | if (QFontInfo(adjustedFont).fixedPitch() && !m_settings->isImmutable("fixed")) { | 268 | if (QFontInfo(adjustedFont).fixedPitch()) { | ||
257 | m_settings->setFixed(adjustedFont); | 269 | m_settings->setFixed(adjustedFont); | ||
258 | } | 270 | } | ||
259 | } | 271 | } | ||
260 | } | 272 | } | ||
261 | 273 | | |||
262 | QFont KFonts::applyFontDiff(const QFont &fnt, const QFont &newFont, int fontDiffFlags) | 274 | QFont KFonts::applyFontDiff(const QFont &fnt, const QFont &newFont, int fontDiffFlags) | ||
263 | { | 275 | { | ||
264 | QFont font(fnt); | 276 | QFont font(fnt); | ||
265 | 277 | | |||
266 | if (fontDiffFlags & KFontChooser::FontDiffSize) { | 278 | if (fontDiffFlags & KFontChooser::FontDiffSize) { | ||
267 | font.setPointSizeF(newFont.pointSizeF()); | 279 | font.setPointSizeF(newFont.pointSizeF()); | ||
268 | } | 280 | } | ||
269 | if ((fontDiffFlags & KFontChooser::FontDiffFamily)) { | 281 | if ((fontDiffFlags & KFontChooser::FontDiffFamily)) { | ||
270 | font.setFamily(newFont.family()); | 282 | font.setFamily(newFont.family()); | ||
271 | } | 283 | } | ||
272 | if (fontDiffFlags & KFontChooser::FontDiffStyle) { | 284 | if (fontDiffFlags & KFontChooser::FontDiffStyle) { | ||
273 | font.setWeight(newFont.weight()); | 285 | font.setWeight(newFont.weight()); | ||
274 | font.setStyle(newFont.style()); | 286 | font.setStyle(newFont.style()); | ||
275 | font.setUnderline(newFont.underline()); | 287 | font.setUnderline(newFont.underline()); | ||
276 | font.setStyleName(newFont.styleName()); | 288 | font.setStyleName(newFont.styleName()); | ||
meven: s/monspace/monospace | |||||
277 | } | 289 | } | ||
278 | 290 | | |||
279 | return font; | 291 | return font; | ||
280 | } | 292 | } | ||
281 | 293 | | |||
282 | int KFonts::subPixelCurrentIndex() const | 294 | int KFonts::subPixelCurrentIndex() const | ||
283 | { | 295 | { | ||
284 | return m_settingsAA->subPixel() - KXftConfig::SubPixel::None; | 296 | return m_settingsAA->subPixel() - KXftConfig::SubPixel::None; | ||
Show All 19 Lines |
s/monspace/monospace