summaryrefslogtreecommitdiffstats
path: root/kbfxlib/common/kbfxfontchooser.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-17 00:43:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-17 00:43:50 +0000
commitceea23677c61f20759ae986bd77b0d5c4d673edb (patch)
tree3fcec1702eaf9c14d1dd736e594f5df08dab4001 /kbfxlib/common/kbfxfontchooser.cpp
downloadkbfx-ceea23677c61f20759ae986bd77b0d5c4d673edb.tar.gz
kbfx-ceea23677c61f20759ae986bd77b0d5c4d673edb.zip
Added old KDE3 version of kbfx
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kbfx@1091549 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kbfxlib/common/kbfxfontchooser.cpp')
-rw-r--r--kbfxlib/common/kbfxfontchooser.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/kbfxlib/common/kbfxfontchooser.cpp b/kbfxlib/common/kbfxfontchooser.cpp
new file mode 100644
index 0000000..c05a81e
--- /dev/null
+++ b/kbfxlib/common/kbfxfontchooser.cpp
@@ -0,0 +1,79 @@
+//**************************************************************************
+// Copyright (C) 2004, 2005 by Petri Damstén
+// petri.damsten@iki.fi
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//**************************************************************************
+
+#include "kbfxfontchooser.h"
+
+KBFXFontChooser::KBFXFontChooser ( QWidget *parent, const char *name )
+ : QWidget ( parent, name )
+{
+ QHBoxLayout* layout = new QHBoxLayout ( this, 0, KDialog::spacingHint() );
+
+ m_label = new QLabel ( this, "fontLabel" );
+ m_label->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Fixed, TRUE);
+// m_label->setFrameShape ( QFrame::StyledPanel );
+// m_label->setFrameShadow ( QFrame::Sunken );
+
+ layout->addWidget ( m_label );
+
+ m_button = new QPushButton ( this, "fontButton" );
+ m_label->setMaximumHeight ( m_button -> height() );
+ m_label->setMinimumHeight ( m_button -> height() );
+ QString fontText = i18n ( "Font..." );
+// m_button->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Minimum, TRUE);
+ m_button->setText ( fontText );
+ QIconSet iconSet = SmallIconSet ( QString::fromLatin1 ( "fonts" ) );
+ QPixmap pixmap = iconSet.pixmap ( QIconSet::Small, QIconSet::Normal );
+ m_button->setIconSet ( iconSet );
+ m_button->setFixedWidth ( m_button->fontMetrics().width ( fontText ) +
+ 3 * KDialog::spacingHint() + pixmap.width() );
+ layout->addWidget ( m_button );
+
+ connect ( m_button, SIGNAL ( clicked() ), this, SLOT ( buttonClicked() ) );
+
+ updateFontLabel();
+
+ setFocusProxy ( m_button );
+}
+
+KBFXFontChooser::~KBFXFontChooser()
+{}
+
+void KBFXFontChooser::setFont ( const QFont& font )
+{
+ m_font = font;
+ updateFontLabel();
+}
+
+void KBFXFontChooser::updateFontLabel()
+{
+ QString s = QString ( "%1 (%2pt) " ).arg ( m_font.family() ).arg ( m_font.pointSize() );
+ m_label->setFont ( m_font );
+ m_label->setText ( s );
+ m_label->setAlignment ( Qt::AlignLeft | Qt::AlignVCenter );
+ emit FontChanged();
+}
+
+void KBFXFontChooser::buttonClicked()
+{
+ KFontDialog::getFont ( m_font );
+ updateFontLabel();
+}
+
+#include "kbfxfontchooser.moc"