From e9ae80694875f869892f13f4fcaf1170a00dea41 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kommander/widgets/fontdialog.cpp | 158 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 kommander/widgets/fontdialog.cpp (limited to 'kommander/widgets/fontdialog.cpp') diff --git a/kommander/widgets/fontdialog.cpp b/kommander/widgets/fontdialog.cpp new file mode 100644 index 00000000..432b2d7f --- /dev/null +++ b/kommander/widgets/fontdialog.cpp @@ -0,0 +1,158 @@ +// +// C++ Implementation: FontDialog +// +// Description: +// +// +// Author: Andras Mantia , (C) 2008 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "fontdialog.h" + +#include "kommanderplugin.h" +#include "specials.h" + +#include +#include +#include + +enum Functions { + FirstFunction = 139, + SetFont, + Family, + PointSize, + Bold, + Italic, + LastFunction +}; + +FontDialog::FontDialog(QWidget *parent, const char *name) + : QLabel(parent, name), KommanderWidget(this) +{ + QStringList states; + states << "default"; + setStates(states); + setDisplayStates(states); + if (KommanderWidget::inEditor) + { + setPixmap(KGlobal::iconLoader()->loadIcon("kfontcombo", KIcon::NoGroup, KIcon::SizeMedium)); + setFrameStyle(QFrame::Box | QFrame::Plain); + setLineWidth(1); + setFixedSize(pixmap()->size()); + } + else + setHidden(true); + KommanderPlugin::setDefaultGroup(Group::DCOP); + KommanderPlugin::registerFunction(SetFont, "setFont(QString widget, QString family, int pointSize, bool bold, bool italic)", + i18n("Sets the default font for the dialog, by specifying the family, the size and other style options."), 2, 5); + KommanderPlugin::registerFunction(Family, "family(QString widget)", + i18n("Returns the font family."), 1); + KommanderPlugin::registerFunction(PointSize, "pointSize(QString widget)", + i18n("Returns the font size in point."), 1); + KommanderPlugin::registerFunction(Bold, "bold(QString widget)", + i18n("Returns true, if the font is bold."), 1); + KommanderPlugin::registerFunction(Italic, "italic(QString widget)", + i18n("Returns true, if the font is italic."), 1); +} + +FontDialog::~FontDialog() +{ +} + +QString FontDialog::currentState() const +{ + return QString("default"); +} + +bool FontDialog::isKommanderWidget() const +{ + return true; +} + +QStringList FontDialog::associatedText() const +{ + return KommanderWidget::associatedText(); +} + +void FontDialog::setAssociatedText(const QStringList& a_at) +{ + KommanderWidget::setAssociatedText(a_at); +} + +void FontDialog::setWidgetText(const QString& a_text) +{ + KommanderWidget::setAssociatedText(a_text); +} + +void FontDialog::setPopulationText(const QString& a_text) +{ + KommanderWidget::setPopulationText(a_text); +} + +QString FontDialog::populationText() const +{ + return KommanderWidget::populationText(); +} + +void FontDialog::populate() +{ + setAssociatedText(KommanderWidget::evalAssociatedText( populationText())); +} + +bool FontDialog::isFunctionSupported(int f) +{ + return (f > FirstFunction && f < LastFunction) || f == DCOP::execute; +} + +QString FontDialog::handleDCOP(int function, const QStringList& args) +{ + switch (function) { + case SetFont: + { + m_font.setFamily(args[0]); + if (args[1].isEmpty()) + m_font.setPointSize(12); + else + m_font.setPointSize(args[1].toInt()); + m_font.setBold(args[2] == "1" || args[2].upper() == "TRUE"); + m_font.setItalic(args[3] == "1" || args[3].upper() == "TRUE"); + break; + } + case Family: + { + return m_font.family(); + break; + } + case PointSize: + { + return QString::number(m_font.pointSize()); + break; + } + case Bold: + { + return m_font.bold() ? "1" : "0"; + } + case Italic: + { + return m_font.italic() ? "1" : "0"; + } + case DCOP::execute: + { + int result = KFontDialog::getFont( m_font ); + if ( result == KFontDialog::Accepted ) + { + return m_font.toString(); + } + break; + } + default: + return KommanderWidget::handleDCOP(function, args); + } + return QString(); +} + + + +#include "fontdialog.moc" -- cgit v1.2.1