summaryrefslogtreecommitdiff
path: root/muse_qt4_evolution/muse/widgets/fontsel.cpp
diff options
context:
space:
mode:
authorRobert Jonsson <spamatica@gmail.com>2009-12-27 11:30:35 +0000
committerRobert Jonsson <spamatica@gmail.com>2009-12-27 11:30:35 +0000
commitb703eab295330e6f81564fbb39a10a1a2fdd2f54 (patch)
treee46b5c9a6bc22fd661c15d1d2123f5bf631cef80 /muse_qt4_evolution/muse/widgets/fontsel.cpp
parent5d5fa0fdf913907edbc3d2d29a7548f0cb658c94 (diff)
moved old qt4 branch
Diffstat (limited to 'muse_qt4_evolution/muse/widgets/fontsel.cpp')
-rw-r--r--muse_qt4_evolution/muse/widgets/fontsel.cpp138
1 files changed, 138 insertions, 0 deletions
diff --git a/muse_qt4_evolution/muse/widgets/fontsel.cpp b/muse_qt4_evolution/muse/widgets/fontsel.cpp
new file mode 100644
index 00000000..b0d6c95b
--- /dev/null
+++ b/muse_qt4_evolution/muse/widgets/fontsel.cpp
@@ -0,0 +1,138 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id:$
+//
+// Copyright (C) 2002-2006 by Werner Schweer and others
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#include "icons.h"
+#include "fontsel.h"
+
+//---------------------------------------------------------
+// FontSel
+//---------------------------------------------------------
+
+FontSel::FontSel(QWidget* parent, const QFont& f, const QString& name)
+ : QWidget(parent)
+ {
+ _font = f;
+ QHBoxLayout* box = new QHBoxLayout(this);
+
+ cb = new QComboBox(this);
+ cb->setFixedWidth(80);
+ cb->addItem(QString("arial"));
+ cb->addItem(QString("avantgarde"));
+ cb->addItem(QString("charter"));
+ cb->addItem(QString("garamond"));
+ cb->addItem(QString("gillsans"));
+ cb->addItem(QString("helvetica"));
+ cb->addItem(QString("times"));
+ cb->addItem(QString("terminal"));
+ cb->addItem(QString("utopia"));
+ cb->addItem(QString("new century schoolbook"));
+
+ QLabel* l1 = new QLabel(tr("Size:"), this);
+ s1 = new QSpinBox(this);
+ s1->setRange(8, 48);
+
+ fcb1 = new QToolButton(this);
+ fcb1->setCheckable(true);
+ fcb1->setIcon(*boldIcon);
+
+ fcb2 = new QToolButton(this);
+ fcb2->setCheckable(true);
+ fcb2->setIcon(*italicIcon);
+
+ fcb3 = new QToolButton(this);
+ fcb3->setCheckable(true);
+ fcb3->setIcon(*underlinedIcon);
+
+ QToolButton* pb = new QToolButton(this);
+ connect(pb, SIGNAL(pressed()), SLOT(fontSelect()));
+ pb->setText(QString("??"));
+
+ QLabel* l2 = new QLabel(name, this);
+
+ box->addWidget(cb);
+ box->addSpacing(8);
+ box->addWidget(l1);
+ box->addSpacing(5);
+ box->addWidget(s1);
+ box->addSpacing(5);
+ box->addWidget(fcb1);
+ box->addWidget(fcb2);
+ box->addWidget(fcb3);
+ box->addSpacing(2);
+ box->addWidget(pb);
+ box->addSpacing(5);
+ box->addWidget(l2);
+ box->addStretch(100);
+ setFixedHeight(18);
+ setFont();
+ }
+
+//---------------------------------------------------------
+// fontSelect
+//---------------------------------------------------------
+
+void FontSel::fontSelect()
+ {
+ bool ok;
+ QFont f = QFontDialog::getFont(&ok, _font, this);
+ if (ok) {
+ _font = f;
+ setFont();
+ }
+ }
+
+//---------------------------------------------------------
+// setFont
+//---------------------------------------------------------
+
+void FontSel::setFont()
+ {
+ s1->setValue(_font.pointSize());
+ fcb1->setChecked(_font.weight() == QFont::Bold);
+ fcb2->setChecked(_font.italic());
+ fcb3->setChecked(_font.underline());
+ int i;
+ for (i = 0; i < cb->count(); ++i) {
+ QString s = cb->itemText(i);
+ if (s == _font.family()) {
+ cb->setCurrentIndex(i);
+ break;
+ }
+ }
+ if (i == cb->count()) {
+ cb->addItem(_font.family());
+ cb->setCurrentIndex(i);
+ }
+ }
+
+//---------------------------------------------------------
+// font
+//---------------------------------------------------------
+
+const QFont& FontSel::font()
+ {
+ _font.setPointSize(s1->value());
+ _font.setWeight(fcb1->isChecked() ? QFont::Bold : QFont::Normal);
+ _font.setItalic(fcb2->isChecked());
+ _font.setUnderline(fcb3->isChecked());
+ _font.setFamily(cb->currentText());
+ return _font;
+ }
+