Enhance expression icon
- fix size and position on kubuntu - different icon for set or unset expression for better visual feedback
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="64px"
|
||||
height="64px"
|
||||
id="svg4069"
|
||||
version="1.1"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="bound-expression-unset.svg">
|
||||
<defs
|
||||
id="defs4071" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="11"
|
||||
inkscape:cx="30.557379"
|
||||
inkscape:cy="35.35507"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
inkscape:document-units="px"
|
||||
inkscape:grid-bbox="true"
|
||||
inkscape:window-width="1848"
|
||||
inkscape:window-height="1043"
|
||||
inkscape:window-x="66"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata4074">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer">
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:#0000ff;stroke-width:4.36290264;stroke-linejoin:round;stroke-miterlimit:4.19999981;stroke-opacity:1;stroke-dasharray:none"
|
||||
id="path2985"
|
||||
sodipodi:cx="325"
|
||||
sodipodi:cy="503.43362"
|
||||
sodipodi:rx="68.571426"
|
||||
sodipodi:ry="61.785713"
|
||||
d="m 393.57143,503.43362 a 68.571426,61.785713 0 1 1 -137.14286,0 68.571426,61.785713 0 1 1 137.14286,0 z"
|
||||
transform="matrix(0.44478506,0,0,0.49741082,-112.73696,-218.43771)" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:35.82092285px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#0000e6;fill-opacity:1;stroke:#ffffff;stroke-width:0.89552319;stroke-opacity:1;font-family:Arial;-inkscape-font-specification:Arial;"
|
||||
x="32.030895"
|
||||
y="41.949329"
|
||||
id="text3755"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3757"
|
||||
x="32.030895"
|
||||
y="41.949329"
|
||||
style="font-size:35.82092285px;font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;stroke-width:0.89552319;font-family:Arial;-inkscape-font-specification:Arial Italic;fill:#0000e6;fill-opacity:1;">f(x)</tspan></text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
@@ -42,6 +42,7 @@
|
||||
<file>ClassBrowser/type_module.svg</file>
|
||||
<file>Std_ViewScreenShot.svg</file>
|
||||
<file>bound-expression.svg</file>
|
||||
<file>bound-expression-unset.svg</file>
|
||||
<file>breakpoint.svg</file>
|
||||
<file>debug-marker.svg</file>
|
||||
<file>debug-start.svg</file>
|
||||
|
||||
@@ -229,6 +229,7 @@ end:
|
||||
double singleStep;
|
||||
QPalette defaultPalette;
|
||||
QLabel* iconLabel;
|
||||
int iconHeight;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -244,14 +245,16 @@ QuantitySpinBox::QuantitySpinBox(QWidget *parent)
|
||||
d_ptr->defaultPalette = lineEdit()->palette();
|
||||
|
||||
/* Icon for f(x) */
|
||||
QFontMetrics fm(lineEdit()->font());
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth);
|
||||
d_ptr->iconHeight = fm.height() - frameWidth;
|
||||
d_ptr->iconLabel = new ExpressionLabel(lineEdit());
|
||||
d_ptr->iconLabel->setCursor(Qt::ArrowCursor);
|
||||
QPixmap pixmap = getIcon(":/icons/bound-expression.svg", QSize(lineEdit()->sizeHint().height(), lineEdit()->sizeHint().height()));
|
||||
QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(d_ptr->iconHeight, d_ptr->iconHeight));
|
||||
d_ptr->iconLabel->setPixmap(pixmap);
|
||||
d_ptr->iconLabel->setStyleSheet(QString::fromAscii("QLabel { border: none; padding: 0px; }"));
|
||||
d_ptr->iconLabel->setStyleSheet(QString::fromAscii("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(d_ptr->iconHeight).arg(frameWidth/2));
|
||||
d_ptr->iconLabel->hide();
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth);
|
||||
lineEdit()->setStyleSheet(QString::fromAscii("QLineEdit { padding-right: %1px } ").arg(d_ptr->iconLabel->sizeHint().width() + frameWidth + 1));
|
||||
lineEdit()->setStyleSheet(QString::fromAscii("QLineEdit { padding-right: %1px } ").arg(d_ptr->iconHeight+frameWidth));
|
||||
|
||||
QObject::connect(d_ptr->iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog()));
|
||||
}
|
||||
@@ -304,6 +307,8 @@ void Gui::QuantitySpinBox::setExpression(boost::shared_ptr<Expression> expr)
|
||||
|
||||
lineEdit()->setText(value->getQuantity().getUserString());
|
||||
setReadOnly(true);
|
||||
QPixmap pixmap = getIcon(":/icons/bound-expression.svg", QSize(d_ptr->iconHeight, d_ptr->iconHeight));
|
||||
d_ptr->iconLabel->setPixmap(pixmap);
|
||||
|
||||
QPalette p(lineEdit()->palette());
|
||||
p.setColor(QPalette::Text, Qt::lightGray);
|
||||
@@ -313,6 +318,8 @@ void Gui::QuantitySpinBox::setExpression(boost::shared_ptr<Expression> expr)
|
||||
}
|
||||
else {
|
||||
setReadOnly(false);
|
||||
QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(d_ptr->iconHeight, d_ptr->iconHeight));
|
||||
d_ptr->iconLabel->setPixmap(pixmap);
|
||||
QPalette p(lineEdit()->palette());
|
||||
p.setColor(QPalette::Active, QPalette::Text, d->defaultPalette.color(QPalette::Text));
|
||||
lineEdit()->setPalette(p);
|
||||
@@ -352,12 +359,8 @@ void QuantitySpinBox::resizeEvent(QResizeEvent * event)
|
||||
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth);
|
||||
|
||||
QPixmap pixmap = getIcon(":/icons/bound-expression.svg", QSize(lineEdit()->rect().height() - frameWidth * 2,
|
||||
lineEdit()->rect().height() - frameWidth * 2));
|
||||
d->iconLabel->setPixmap(pixmap);
|
||||
QSize sz = d->iconLabel->sizeHint();
|
||||
d->iconLabel->move(lineEdit()->rect().right() - frameWidth - sz.width(),
|
||||
lineEdit()->rect().top() - frameWidth);
|
||||
d->iconLabel->move(lineEdit()->rect().right() - frameWidth - sz.width(), 0);
|
||||
|
||||
try {
|
||||
if (isBound() && getExpression()) {
|
||||
@@ -366,6 +369,8 @@ void QuantitySpinBox::resizeEvent(QResizeEvent * event)
|
||||
|
||||
if (value) {
|
||||
setReadOnly(true);
|
||||
QPixmap pixmap = getIcon(":/icons/bound-expression.svg", QSize(d_ptr->iconHeight, d_ptr->iconHeight));
|
||||
d->iconLabel->setPixmap(pixmap);
|
||||
|
||||
QPalette p(lineEdit()->palette());
|
||||
p.setColor(QPalette::Text, Qt::lightGray);
|
||||
@@ -375,6 +380,9 @@ void QuantitySpinBox::resizeEvent(QResizeEvent * event)
|
||||
}
|
||||
else {
|
||||
setReadOnly(false);
|
||||
QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(d_ptr->iconHeight, d_ptr->iconHeight));
|
||||
d->iconLabel->setPixmap(pixmap);
|
||||
|
||||
QPalette p(lineEdit()->palette());
|
||||
p.setColor(QPalette::Active, QPalette::Text, d->defaultPalette.color(QPalette::Text));
|
||||
lineEdit()->setPalette(p);
|
||||
|
||||
Reference in New Issue
Block a user