2019-02-08 00:24:46 +08:00
|
|
|
/*
|
2024-02-06 21:50:49 +08:00
|
|
|
Copyright (c) 2008-2024 Jan W. Krieger (<jan@jkrieger.de>)
|
2019-02-08 00:24:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This software is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "jkqtpkeystyle.h"
|
|
|
|
#include "jkqtpbaseplotterstyle.h"
|
|
|
|
#include <QApplication>
|
|
|
|
|
|
|
|
JKQTPKeyStyle::JKQTPKeyStyle():
|
|
|
|
frameVisible(true),
|
|
|
|
frameColor(QColor("black")),
|
2023-12-19 05:24:59 +08:00
|
|
|
frameLineStyle(Qt::SolidLine),
|
2019-02-08 00:24:46 +08:00
|
|
|
frameWidth(1),
|
|
|
|
frameRounding(0),
|
2019-04-25 01:33:51 +08:00
|
|
|
backgroundBrush(QColor("white")),
|
2019-02-08 00:24:46 +08:00
|
|
|
visible(true),
|
2023-07-02 05:21:12 +08:00
|
|
|
fontSize(QApplication::font().pointSizeF()),
|
2023-12-19 05:24:59 +08:00
|
|
|
fontName("GUI"),
|
2019-02-08 00:24:46 +08:00
|
|
|
textColor(QColor("black")),
|
|
|
|
sampleLineLength(3),
|
2023-12-19 05:24:59 +08:00
|
|
|
sampleHeight(1),
|
2019-02-08 00:24:46 +08:00
|
|
|
xMargin(0.5),
|
|
|
|
yMargin(0.5),
|
2023-07-02 05:21:12 +08:00
|
|
|
xOffset(1),
|
|
|
|
yOffset(1),
|
2023-12-19 05:24:59 +08:00
|
|
|
xSeparation(0.85),
|
|
|
|
ySeparation(0.35),
|
2024-01-23 20:09:37 +08:00
|
|
|
columnSeparation(0.75),
|
2019-02-08 00:24:46 +08:00
|
|
|
position(JKQTPKeyInsideTopRight),
|
2023-12-19 05:24:59 +08:00
|
|
|
layout(JKQTPKeyLayoutOneColumn)
|
2019-02-08 00:24:46 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPKeyStyle::JKQTPKeyStyle(const JKQTBasePlotterStyle &baseStyle):
|
|
|
|
JKQTPKeyStyle()
|
|
|
|
{
|
|
|
|
fontSize=baseStyle.defaultFontSize;
|
|
|
|
textColor=baseStyle.defaultTextColor;
|
2023-12-19 05:24:59 +08:00
|
|
|
fontName=baseStyle.defaultFontName;
|
2019-02-08 00:24:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPKeyStyle::loadSettings(const QSettings &settings, const QString &group, const JKQTPKeyStyle &defaultStyle)
|
|
|
|
{
|
|
|
|
xOffset = settings.value(group+"xoffset", defaultStyle.xOffset).toDouble();
|
|
|
|
yOffset = settings.value(group+"yoffset", defaultStyle.yOffset).toDouble();
|
|
|
|
xMargin = settings.value(group+"xmargin", defaultStyle.xMargin).toDouble();
|
|
|
|
yMargin = settings.value(group+"ymargin", defaultStyle.yMargin).toDouble();
|
|
|
|
xSeparation = settings.value(group+"xseparation", defaultStyle.xSeparation).toDouble();
|
|
|
|
ySeparation = settings.value(group+"yseparation", defaultStyle.ySeparation).toDouble();
|
2023-12-19 05:24:59 +08:00
|
|
|
columnSeparation = settings.value(group+"column_separation", defaultStyle.columnSeparation).toDouble();
|
2019-02-08 00:24:46 +08:00
|
|
|
frameColor = jkqtp_String2QColor(settings.value(group+"frame_color", jkqtp_QColor2String(defaultStyle.frameColor)).toString());
|
2023-12-19 05:24:59 +08:00
|
|
|
frameLineStyle=jkqtp_String2QPenStyle(settings.value(group+"frame_linestyle", jkqtp_QPenStyle2String(frameLineStyle)).toString());
|
2019-02-08 00:24:46 +08:00
|
|
|
textColor = jkqtp_String2QColor(settings.value(group+"text_color", jkqtp_QColor2String(defaultStyle.textColor)).toString());
|
|
|
|
frameWidth = settings.value(group+"frame_width", defaultStyle.frameWidth).toDouble();
|
|
|
|
frameRounding = settings.value(group+"frame_rounding", defaultStyle.frameRounding).toDouble();
|
|
|
|
frameVisible = settings.value(group+"frame_visible", defaultStyle.frameVisible).toBool();
|
2019-04-25 01:33:51 +08:00
|
|
|
backgroundBrush = QBrush(jkqtp_String2QColor(settings.value(group+"background_color", jkqtp_QColor2String(defaultStyle.backgroundBrush.color())).toString()));
|
2019-02-08 00:24:46 +08:00
|
|
|
visible = settings.value(group+"visible", defaultStyle.visible).toBool();
|
|
|
|
position = String2JKQTPKeyPosition(settings.value(group+"position", JKQTPKeyPosition2String(defaultStyle.position)).toString());
|
|
|
|
layout = String2JKQTPKeyLayout(settings.value(group+"layout", JKQTPKeyLayout2String(defaultStyle.layout)).toString());
|
|
|
|
fontSize = settings.value(group+"fontsize", defaultStyle.fontSize).toDouble();
|
2023-12-19 05:24:59 +08:00
|
|
|
fontName = settings.value(group+"fontname", defaultStyle.fontName).toString();
|
|
|
|
sampleLineLength = settings.value(group+"sample_width", settings.value(group+"line_width", defaultStyle.sampleLineLength).toDouble()).toDouble();
|
|
|
|
sampleHeight = settings.value(group+"sample_height", defaultStyle.sampleHeight).toDouble();
|
2019-02-08 00:24:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPKeyStyle::saveSettings(QSettings &settings, const QString &group) const
|
|
|
|
{
|
|
|
|
settings.setValue(group+"xoffset", xOffset);
|
|
|
|
settings.setValue(group+"yoffset", yOffset);
|
|
|
|
settings.setValue(group+"xmargin", xMargin);
|
|
|
|
settings.setValue(group+"ymargin", yMargin);
|
|
|
|
settings.setValue(group+"xseparation", xSeparation);
|
|
|
|
settings.setValue(group+"yseparation", ySeparation);
|
2023-12-19 05:24:59 +08:00
|
|
|
settings.setValue(group+"column_separation", columnSeparation);
|
2019-02-08 00:24:46 +08:00
|
|
|
settings.setValue(group+"frame_visible", frameVisible);
|
|
|
|
settings.setValue(group+"frame_color", jkqtp_QColor2String(frameColor));
|
2023-12-19 05:24:59 +08:00
|
|
|
settings.setValue(group+"frame_linestyle", jkqtp_QPenStyle2String(frameLineStyle));
|
2019-02-08 00:24:46 +08:00
|
|
|
settings.setValue(group+"frame_width", frameWidth);
|
|
|
|
settings.setValue(group+"frame_rounding", frameRounding);
|
2019-04-25 01:33:51 +08:00
|
|
|
settings.setValue(group+"background_color", jkqtp_QColor2String(backgroundBrush.color()));
|
2019-02-08 00:24:46 +08:00
|
|
|
settings.setValue(group+"visible", visible);
|
|
|
|
settings.setValue(group+"position", JKQTPKeyPosition2String(position));
|
|
|
|
settings.setValue(group+"layout", JKQTPKeyLayout2String(layout));
|
|
|
|
settings.setValue(group+"fontsize", fontSize);
|
2023-12-19 05:24:59 +08:00
|
|
|
settings.setValue(group+"fontname", fontName);
|
2019-02-08 00:24:46 +08:00
|
|
|
settings.setValue(group+"text_color", jkqtp_QColor2String(textColor));
|
2023-12-19 05:24:59 +08:00
|
|
|
settings.setValue(group+"sample_width", sampleLineLength);
|
|
|
|
settings.setValue(group+"sample_height", sampleHeight);
|
2019-02-08 00:24:46 +08:00
|
|
|
}
|