File indexing completed on 2024-12-22 04:17:33
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2008 The University of Toronto * 0004 * netterfield@astro.utoronto.ca * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 ***************************************************************************/ 0012 0013 #include "labelcreator.h" 0014 0015 #include "application.h" 0016 #include "objectstore.h" 0017 #include "mainwindow.h" 0018 #include "document.h" 0019 #include "geticon.h" 0020 0021 #include "applicationsettings.h" 0022 #include "dialogdefaults.h" 0023 0024 0025 namespace Kst { 0026 0027 LabelCreator::LabelCreator(QWidget *parent) 0028 : QDialog(parent) { 0029 0030 setupUi(this); 0031 0032 setWindowTitle(tr("Create Label Dialog")); 0033 int h = fontMetrics().lineSpacing(); 0034 _bold->setFixedWidth(h); 0035 _bold->setFixedHeight(h); 0036 _bold->setIcon(KstGetIcon("kst_bold")); 0037 _italic->setFixedWidth(h); 0038 _italic->setFixedHeight(h); 0039 _italic->setIcon(KstGetIcon("kst_italic")); 0040 _labelColor->setFixedWidth(h); 0041 _labelColor->setFixedHeight(h); 0042 _labelText->setObjectStore(kstApp->mainWindow()->document()->objectStore()); 0043 0044 QFont font; 0045 font.fromString(dialogDefaults().value("label/font",font.toString()).toString()); 0046 _family->setCurrentFont(font); 0047 _bold->setChecked(font.bold()); 0048 _italic->setChecked(font.italic()); 0049 0050 _labelColor->setColor(dialogDefaults().value("label/color",QColor(Qt::black)).value<QColor>()); 0051 _labelFontScale->setValue(dialogDefaults().value("label/fontScale",12).toDouble()); 0052 if (dialogDefaults().value("label/fixLeft",true).toBool()) { 0053 _left->setChecked(true); 0054 } else { 0055 _right->setChecked(true); 0056 } 0057 _lockPosToData->setChecked(dialogDefaultsLockPosToData("label")); 0058 _saveAsDefault->show(); 0059 0060 } 0061 0062 0063 LabelCreator::~LabelCreator() { 0064 } 0065 0066 0067 QString LabelCreator::labelText() { 0068 return _labelText->labelText(); 0069 } 0070 0071 0072 qreal LabelCreator::labelScale() const { 0073 return _labelFontScale->value(); 0074 } 0075 0076 0077 QColor LabelCreator::labelColor() const { 0078 return _labelColor->color(); 0079 } 0080 0081 0082 QFont LabelCreator::labelFont() const { 0083 QFont font(_family->currentFont()); 0084 font.setItalic(_italic->isChecked()); 0085 font.setBold(_bold->isChecked()); 0086 return font; 0087 } 0088 0089 bool LabelCreator::fixLeft() const { 0090 return _left->isChecked(); 0091 } 0092 bool LabelCreator::lockPosToData() const { 0093 return _lockPosToData->isChecked(); 0094 } 0095 0096 } 0097 0098 // vim: ts=2 sw=2 et