File indexing completed on 2024-04-28 04:32:01

0001 /*
0002  * Copyright (C) 2010-2015 by Stephen Allewell
0003  * steve.allewell@gmail.com
0004  *
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 2 of the License, or
0008  * (at your option) any later version.
0009  */
0010 
0011 #include "KeyElementDlg.h"
0012 
0013 #include <QCheckBox>
0014 
0015 #include <KHelpClient>
0016 #include <KLocalizedString>
0017 
0018 #include "Element.h"
0019 
0020 KeyElementDlg::KeyElementDlg(QWidget *parent, KeyElement *keyElement)
0021     : QDialog(parent)
0022     , m_keyElement(keyElement)
0023 {
0024     setWindowTitle(i18n("Key Element Properties"));
0025     ui.setupUi(this);
0026 
0027     ui.MarginLeft->setValue(keyElement->m_margins.left());
0028     ui.MarginTop->setValue(keyElement->m_margins.top());
0029     ui.MarginRight->setValue(keyElement->m_margins.right());
0030     ui.MarginBottom->setValue(keyElement->m_margins.bottom());
0031     ui.ShowBorder->setChecked(keyElement->m_showBorder);
0032     ui.BorderColor->setColor(keyElement->m_borderColor);
0033     ui.BorderThickness->setValue(double(keyElement->m_borderThickness) / 10);
0034     ui.FillBackground->setChecked(keyElement->m_fillBackground);
0035     ui.BackgroundColor->setColor(keyElement->m_backgroundColor);
0036     ui.BackgroundTransparency->setValue(keyElement->m_backgroundTransparency);
0037     ui.KeyFont->setFont(keyElement->m_textFont);
0038     ui.IndexStart->setValue(keyElement->m_indexStart);
0039     ui.IndexCount->setValue(keyElement->m_indexCount);
0040     ui.SymbolColumn->setChecked(keyElement->m_symbolColumn);
0041     ui.SymbolColumnColor->setChecked(keyElement->m_symbolColumnColor);
0042     ui.FlossNameColumn->setChecked(keyElement->m_flossNameColumn);
0043     ui.StrandsColumn->setChecked(m_keyElement->m_strandsColumn);
0044     ui.FlossDescriptionColumn->setChecked(m_keyElement->m_flossDescriptionColumn);
0045     ui.StitchesColumn->setChecked(m_keyElement->m_stitchesColumn);
0046     ui.LengthColumn->setChecked(m_keyElement->m_lengthColumn);
0047     ui.SkeinsColumn->setChecked(m_keyElement->m_skeinsColumn);
0048 }
0049 
0050 void KeyElementDlg::hideEvent(QHideEvent *event)
0051 {
0052     KConfigGroup(KSharedConfig::openConfig(), QStringLiteral("DialogSizes")).writeEntry(QStringLiteral("KeyElementDlg"), size());
0053 
0054     QDialog::hideEvent(event);
0055 }
0056 
0057 void KeyElementDlg::showEvent(QShowEvent *event)
0058 {
0059     QDialog::showEvent(event);
0060 
0061     if (KConfigGroup(KSharedConfig::openConfig(), QStringLiteral("DialogSizes")).hasKey(QStringLiteral("KeyElementDlg"))) {
0062         resize(KConfigGroup(KSharedConfig::openConfig(), QStringLiteral("DialogSizes")).readEntry(QStringLiteral("KeyElementDlg"), QSize()));
0063     }
0064 }
0065 
0066 void KeyElementDlg::on_DialogButtonBox_accepted()
0067 {
0068     m_keyElement->m_margins = QMargins(ui.MarginLeft->value(), ui.MarginTop->value(), ui.MarginRight->value(), ui.MarginBottom->value());
0069     m_keyElement->m_showBorder = ui.ShowBorder->isChecked();
0070     m_keyElement->m_borderColor = ui.BorderColor->color();
0071     m_keyElement->m_borderThickness = int(ui.BorderThickness->value() * 10);
0072     m_keyElement->m_fillBackground = ui.FillBackground->isChecked();
0073     m_keyElement->m_backgroundColor = ui.BackgroundColor->color();
0074     m_keyElement->m_backgroundTransparency = ui.BackgroundTransparency->value();
0075     m_keyElement->m_textFont = ui.KeyFont->font();
0076     m_keyElement->m_indexStart = ui.IndexStart->value();
0077     m_keyElement->m_indexCount = ui.IndexCount->value();
0078     m_keyElement->m_symbolColumn = ui.SymbolColumn->isChecked();
0079     m_keyElement->m_symbolColumnColor = ui.SymbolColumnColor->isChecked();
0080     m_keyElement->m_flossNameColumn = ui.FlossNameColumn->isChecked();
0081     m_keyElement->m_strandsColumn = ui.StrandsColumn->isChecked();
0082     m_keyElement->m_flossDescriptionColumn = ui.FlossDescriptionColumn->isChecked();
0083     m_keyElement->m_stitchesColumn = ui.StitchesColumn->isChecked();
0084     m_keyElement->m_lengthColumn = ui.LengthColumn->isChecked();
0085     m_keyElement->m_skeinsColumn = ui.SkeinsColumn->isChecked();
0086 
0087     accept();
0088 }
0089 
0090 void KeyElementDlg::on_DialogButtonBox_rejected()
0091 {
0092     reject();
0093 }
0094 
0095 void KeyElementDlg::on_DialogButtonBox_helpRequested()
0096 {
0097     KHelpClient::invokeHelp(QStringLiteral("KeyElement"), QStringLiteral("kxstitch"));
0098 }
0099 
0100 #include "moc_KeyElementDlg.cpp"