diff options
author | q5sys <jt@obs-sec.com> | 2017-07-20 19:26:19 -0400 |
---|---|---|
committer | q5sys <jt@obs-sec.com> | 2017-07-20 19:26:19 -0400 |
commit | 571d0ecb6386a9736db35291c029afeb866c4896 (patch) | |
tree | b8c0a446448cdb3a67384cad1926fc3c08088736 /src-qt5/core/lumina-theme-engine/src | |
parent | clean up appearance source files (diff) | |
download | lumina-571d0ecb6386a9736db35291c029afeb866c4896.tar.gz lumina-571d0ecb6386a9736db35291c029afeb866c4896.tar.bz2 lumina-571d0ecb6386a9736db35291c029afeb866c4896.zip |
clean up font pages
Diffstat (limited to 'src-qt5/core/lumina-theme-engine/src')
4 files changed, 111 insertions, 268 deletions
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontconfigdialog.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontconfigdialog.cpp index 398a2436..13c92bf0 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontconfigdialog.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontconfigdialog.cpp @@ -1,31 +1,3 @@ -/* - * Copyright (c) 2014-2017, Ilya Kotov <forkotov02@hotmail.ru> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - #include <QXmlStreamWriter> #include <QFile> #include <QDir> @@ -33,106 +5,80 @@ #include "fontconfigdialog.h" #include "ui_fontconfigdialog.h" -FontConfigDialog::FontConfigDialog(QWidget *parent) : - QDialog(parent), - m_ui(new Ui::FontConfigDialog) -{ - m_ui->setupUi(this); - - m_ui->hintingStyleComboBox->addItem(tr("None"), "hintnone"); - m_ui->hintingStyleComboBox->addItem(tr("Slight"), "hintslight"); - m_ui->hintingStyleComboBox->addItem(tr("Medium"), "hintmedium"); - m_ui->hintingStyleComboBox->addItem(tr("Full"), "hintfull"); - - m_ui->rgbaComboBox->addItem(tr("None"), "none"); - m_ui->rgbaComboBox->addItem("rgb", "rgb"); - m_ui->rgbaComboBox->addItem("bgr", "bgr"); - m_ui->rgbaComboBox->addItem("vrgb", "vrgb"); - m_ui->rgbaComboBox->addItem("vbgr", "vbgr"); - - m_ui->lcdFilterComboBox->addItem("lcdnone"); - m_ui->lcdFilterComboBox->addItem("lcddefault"); - m_ui->lcdFilterComboBox->addItem("lcdlight"); - m_ui->lcdFilterComboBox->addItem("lcdlegacy"); +FontConfigDialog::FontConfigDialog(QWidget *parent) : QDialog(parent), m_ui(new Ui::FontConfigDialog){ + m_ui->setupUi(this); + + m_ui->hintingStyleComboBox->addItem(tr("None"), "hintnone"); + m_ui->hintingStyleComboBox->addItem(tr("Slight"), "hintslight"); + m_ui->hintingStyleComboBox->addItem(tr("Medium"), "hintmedium"); + m_ui->hintingStyleComboBox->addItem(tr("Full"), "hintfull"); + m_ui->rgbaComboBox->addItem(tr("None"), "none"); + m_ui->rgbaComboBox->addItem("rgb", "rgb"); + m_ui->rgbaComboBox->addItem("bgr", "bgr"); + m_ui->rgbaComboBox->addItem("vrgb", "vrgb"); + m_ui->rgbaComboBox->addItem("vbgr", "vbgr"); + m_ui->lcdFilterComboBox->addItem("lcdnone"); + m_ui->lcdFilterComboBox->addItem("lcddefault"); + m_ui->lcdFilterComboBox->addItem("lcdlight"); + m_ui->lcdFilterComboBox->addItem("lcdlegacy"); } -FontConfigDialog::~FontConfigDialog() -{ - delete m_ui; +FontConfigDialog::~FontConfigDialog(){ + delete m_ui; } -void FontConfigDialog::accept() -{ - QDir::home().mkpath(".config/fontconfig/"); - QString path = QDir::homePath() + "/.config/fontconfig/fonts.conf"; - qDebug("FontConfigDialog: fontconfig path: %s", qPrintable(path)); - - - if(QFile::exists(path)) - { - if(QMessageBox::question(this, tr("Font Configuration"), - tr("<i>%1</i> already exists. Do you want to replace it?").arg(path), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) - { - QDialog::reject(); - return; - } - - QFile::remove(path + ".back"); - QFile::copy(path, path + ".back"); +void FontConfigDialog::accept(){ + QDir::home().mkpath(".config/fontconfig/"); + QString path = QDir::homePath() + "/.config/fontconfig/fonts.conf"; + qDebug("FontConfigDialog: fontconfig path: %s", qPrintable(path)); + if(QFile::exists(path)){ + if(QMessageBox::question(this, tr("Font Configuration"), tr("<i>%1</i> already exists. Do you want to replace it?").arg(path), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No){ + QDialog::reject(); + return; + } + QFile::remove(path + ".back"); + QFile::copy(path, path + ".back"); } - - QFile file(path); - if(!file.open(QIODevice::WriteOnly)) - { - qWarning("FontConfigDialog: unable to open file: %s", qPrintable(file.errorString())); - return; + QFile file(path); + if(!file.open(QIODevice::WriteOnly)){ + qWarning("FontConfigDialog: unable to open file: %s", qPrintable(file.errorString())); + return; } - - QXmlStreamWriter stream(&file); - stream.setAutoFormatting(true); - - stream.writeStartDocument(); - stream.writeDTD("<!DOCTYPE fontconfig SYSTEM \"fonts.dtd\">"); - stream.writeStartElement("fontconfig"); - + QXmlStreamWriter stream(&file); + stream.setAutoFormatting(true); + stream.writeStartDocument(); + stream.writeDTD("<!DOCTYPE fontconfig SYSTEM \"fonts.dtd\">"); + stream.writeStartElement("fontconfig"); + stream.writeStartElement("match"); + stream.writeAttribute("target", "font"); + writeOption(&stream, "antialias", "bool", m_ui->antialisingCheckBox->isChecked() ? "true" : "false"); + writeOption(&stream, "hinting", "bool", m_ui->hintingCheckBox->isChecked() ? "true" : "false"); + writeOption(&stream, "hintstyle", "const", m_ui->hintingStyleComboBox->currentData().toString()); + writeOption(&stream, "rgba", "const", m_ui->rgbaComboBox->currentData().toString()); + writeOption(&stream, "autohint", "bool", m_ui->autohinterCheckBox->isChecked() ? "true" : "false"); + writeOption(&stream, "lcdfilter", "const", m_ui->lcdFilterComboBox->currentText()); + writeOption(&stream, "dpi", "double", QString::number(m_ui->dpiSpinBox->value())); + stream.writeEndElement(); + if(m_ui->disableBoldAutohintCheckBox->isChecked()){ stream.writeStartElement("match"); stream.writeAttribute("target", "font"); - writeOption(&stream, "antialias", "bool", m_ui->antialisingCheckBox->isChecked() ? "true" : "false"); - writeOption(&stream, "hinting", "bool", m_ui->hintingCheckBox->isChecked() ? "true" : "false"); - writeOption(&stream, "hintstyle", "const", m_ui->hintingStyleComboBox->currentData().toString()); - writeOption(&stream, "rgba", "const", m_ui->rgbaComboBox->currentData().toString()); + stream.writeStartElement("test"); + stream.writeAttribute("name", "weight"); + stream.writeAttribute("compare", "more"); + stream.writeTextElement("const", "medium"); + stream.writeEndElement(); writeOption(&stream, "autohint", "bool", m_ui->autohinterCheckBox->isChecked() ? "true" : "false"); - writeOption(&stream, "lcdfilter", "const", m_ui->lcdFilterComboBox->currentText()); - writeOption(&stream, "dpi", "double", QString::number(m_ui->dpiSpinBox->value())); stream.writeEndElement(); - - if(m_ui->disableBoldAutohintCheckBox->isChecked()) - { - stream.writeStartElement("match"); - stream.writeAttribute("target", "font"); - - stream.writeStartElement("test"); - stream.writeAttribute("name", "weight"); - stream.writeAttribute("compare", "more"); - stream.writeTextElement("const", "medium"); - stream.writeEndElement(); - - writeOption(&stream, "autohint", "bool", m_ui->autohinterCheckBox->isChecked() ? "true" : "false"); - - stream.writeEndElement(); } - stream.writeEndElement(); - stream.writeEndDocument(); - - QDialog::accept(); + stream.writeEndElement(); + stream.writeEndDocument(); + QDialog::accept(); } -void FontConfigDialog::writeOption(QXmlStreamWriter *stream, const QString &name, const QString &type, const QString &value) -{ - stream->writeStartElement("edit"); - stream->writeAttribute("name", name); - stream->writeAttribute("mode", "assign"); - stream->writeTextElement(type, value); - stream->writeEndElement(); +void FontConfigDialog::writeOption(QXmlStreamWriter *stream, const QString &name, const QString &type, const QString &value){ + stream->writeStartElement("edit"); + stream->writeAttribute("name", name); + stream->writeAttribute("mode", "assign"); + stream->writeTextElement(type, value); + stream->writeEndElement(); } diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontconfigdialog.h b/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontconfigdialog.h index 5b7e31a5..09991787 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontconfigdialog.h +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontconfigdialog.h @@ -1,31 +1,3 @@ -/* - * Copyright (c) 2014-2017, Ilya Kotov <forkotov02@hotmail.ru> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - #ifndef FONTCONFIGDIALOG_H #define FONTCONFIGDIALOG_H diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontspage.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontspage.cpp index db48a3cc..8d1ed1ab 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontspage.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontspage.cpp @@ -1,31 +1,3 @@ -/* - * Copyright (c) 2014-2017, Ilya Kotov <forkotov02@hotmail.ru> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - #include <QSignalMapper> #include <QMessageBox> #include <QSettings> @@ -38,89 +10,70 @@ #include "fontconfigdialog.h" #include "ui_fontspage.h" -FontsPage::FontsPage(QWidget *parent) : - TabPage(parent), - m_ui(new Ui::FontsPage) -{ - m_ui->setupUi(this); - - QSignalMapper *mapper = new QSignalMapper(this); - mapper->setMapping(m_ui->changeGeneralFontButton, m_ui->generalFontLabel); - mapper->setMapping(m_ui->changeFixedWidthFontButton, m_ui->fixedFontLabel); - connect(m_ui->changeGeneralFontButton, SIGNAL(clicked()), mapper, SLOT(map())); - connect(m_ui->changeFixedWidthFontButton, SIGNAL(clicked()), mapper, SLOT(map())); - connect(mapper, SIGNAL(mapped(QWidget*)), SLOT(onFontChangeRequested(QWidget*))); +FontsPage::FontsPage(QWidget *parent) : TabPage(parent), m_ui(new Ui::FontsPage){ + m_ui->setupUi(this); - readSettings(); + QSignalMapper *mapper = new QSignalMapper(this); + mapper->setMapping(m_ui->changeGeneralFontButton, m_ui->generalFontLabel); + mapper->setMapping(m_ui->changeFixedWidthFontButton, m_ui->fixedFontLabel); + connect(m_ui->changeGeneralFontButton, SIGNAL(clicked()), mapper, SLOT(map())); + connect(m_ui->changeFixedWidthFontButton, SIGNAL(clicked()), mapper, SLOT(map())); + connect(mapper, SIGNAL(mapped(QWidget*)), SLOT(onFontChangeRequested(QWidget*))); + readSettings(); - //icons - m_ui->createFontsConfButton->setIcon(QIcon::fromTheme("document-new")); - m_ui->removeFontsConfButton->setIcon(QIcon::fromTheme("edit-delete")); + //icons + m_ui->createFontsConfButton->setIcon(QIcon::fromTheme("document-new")); + m_ui->removeFontsConfButton->setIcon(QIcon::fromTheme("edit-delete")); } -FontsPage::~FontsPage() -{ - delete m_ui; +FontsPage::~FontsPage(){ + delete m_ui; } -void FontsPage::writeSettings() -{ - QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); - settings.beginGroup("Fonts"); - settings.setValue("general", m_ui->generalFontLabel->font()); - settings.setValue("fixed", m_ui->fixedFontLabel->font()); - settings.endGroup(); +void FontsPage::writeSettings(){ + QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); + settings.beginGroup("Fonts"); + settings.setValue("general", m_ui->generalFontLabel->font()); + settings.setValue("fixed", m_ui->fixedFontLabel->font()); + settings.endGroup(); } -void FontsPage::onFontChangeRequested(QWidget *widget) -{ - bool ok = false; - QFont font = QFontDialog::getFont (&ok, widget->font(), this); - if(ok) - { - widget->setFont(font); - qobject_cast<QLabel*>(widget)->setText(font.family () + " " + QString::number(font.pointSize ())); +void FontsPage::onFontChangeRequested(QWidget *widget){ + bool ok = false; + QFont font = QFontDialog::getFont (&ok, widget->font(), this); + if(ok){ + widget->setFont(font); + qobject_cast<QLabel*>(widget)->setText(font.family () + " " + QString::number(font.pointSize ())); } } -void FontsPage::readSettings() -{ - QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); - settings.beginGroup("Fonts"); - loadFont(&settings, m_ui->generalFontLabel, "general"); - loadFont(&settings, m_ui->fixedFontLabel, "fixed"); - settings.endGroup(); +void FontsPage::readSettings(){ + QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); + settings.beginGroup("Fonts"); + loadFont(&settings, m_ui->generalFontLabel, "general"); + loadFont(&settings, m_ui->fixedFontLabel, "fixed"); + settings.endGroup(); } -void FontsPage::loadFont(QSettings *settings, QLabel *label, const QString &key) -{ - QFont font = settings->value(key, QApplication::font()).value<QFont>(); - label->setText(font.family () + " " + QString::number(font.pointSize ())); - label->setFont(font); +void FontsPage::loadFont(QSettings *settings, QLabel *label, const QString &key){ + QFont font = settings->value(key, QApplication::font()).value<QFont>(); + label->setText(font.family () + " " + QString::number(font.pointSize ())); + label->setFont(font); } -void FontsPage::on_createFontsConfButton_clicked() -{ - FontConfigDialog d(this); - d.exec(); +void FontsPage::on_createFontsConfButton_clicked(){ + FontConfigDialog d(this); + d.exec(); } -void FontsPage::on_removeFontsConfButton_clicked() -{ - QString path = QDir::homePath() + "/.config/fontconfig/fonts.conf"; - - - if(QFile::exists(path)) - { - if(QMessageBox::question(this, tr("Remove Font Configuration"), - tr("Are you sure you want to delete <i>%1</i>?").arg(path), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) - { - return; - } - - QFile::remove(path + ".back"); - QFile::copy(path, path + ".back"); - QFile::remove(path); +void FontsPage::on_removeFontsConfButton_clicked(){ + QString path = QDir::homePath() + "/.config/fontconfig/fonts.conf"; + if(QFile::exists(path)){ + if(QMessageBox::question(this, tr("Remove Font Configuration"), tr("Are you sure you want to delete <i>%1</i>?").arg(path), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No){ + return; } + QFile::remove(path + ".back"); + QFile::copy(path, path + ".back"); + QFile::remove(path); + } } diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontspage.h b/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontspage.h index a9c5f1f6..2b522fee 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontspage.h +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/fontspage.h @@ -1,31 +1,3 @@ -/* - * Copyright (c) 2014-2017, Ilya Kotov <forkotov02@hotmail.ru> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - #ifndef FONTSPAGE_H #define FONTSPAGE_H |