diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e9ae80694875f869892f13f4fcaf1170a00dea41 (patch) | |
tree | aa2f8d8a217e2d376224c8d46b7397b68d35de2d /kommander/widgets/fontdialog.cpp | |
download | tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip |
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
Diffstat (limited to 'kommander/widgets/fontdialog.cpp')
-rw-r--r-- | kommander/widgets/fontdialog.cpp | 158 |
1 files changed, 158 insertions, 0 deletions
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 <amantia@kdewebdev.org>, (C) 2008 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "fontdialog.h" + +#include "kommanderplugin.h" +#include "specials.h" + +#include <kfontdialog.h> +#include <kiconloader.h> +#include <klocale.h> + +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" |