Fix issue. Elide a variable description in the formula wizard.
(cherry picked from commit 56ec62580c
)
This commit is contained in:
parent
c9e85e0266
commit
4970254607
|
@ -85,6 +85,7 @@
|
|||
- Fix dialog for tool Point along perpendicular. No memory of line color settings.
|
||||
- Fix crash after uniting three pieces in sequence.
|
||||
- Incorrect conversion to newer curve format.
|
||||
- Elide a variable description in the formula wizard.
|
||||
|
||||
# Version 0.6.1 October 23, 2018
|
||||
- [#885] Regression. Broken support for multi size measurements.
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>448</width>
|
||||
<height>478</height>
|
||||
<width>542</width>
|
||||
<height>481</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -23,7 +23,7 @@
|
|||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item alignment="Qt::AlignLeft">
|
||||
|
@ -172,34 +172,173 @@
|
|||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="3,1">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Input data</string>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Input data</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonStandardTable">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Measurements</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonIncrements">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Increments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonPC">
|
||||
<property name="text">
|
||||
<string>Preview calculations</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonLengthLine">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Length of lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonLengthSpline">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Length of curves</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonAngleLine">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Angle of lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonRadiusesArcs">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Radius of arcs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonAnglesCurves">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Angles of curves</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonCLength">
|
||||
<property name="text">
|
||||
<string>Lengths to control points</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonFunctions">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Functions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filterFormulaInputs">
|
||||
<property name="placeholderText">
|
||||
<string>Filter list by keyword</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonStandardTable">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QCheckBox" name="checkBoxHideEmpty">
|
||||
<property name="text">
|
||||
<string>Measurements</string>
|
||||
<string>Hide empty measurements</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
|
@ -207,117 +346,26 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonIncrements">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Increments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonPC">
|
||||
<property name="text">
|
||||
<string>Preview calculations</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonLengthLine">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Length of lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonLengthSpline">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Length of curves</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonAngleLine">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Angle of lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonRadiusesArcs">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Radius of arcs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonAnglesCurves">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Angles of curves</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonCLength">
|
||||
<property name="text">
|
||||
<string>Lengths to control points</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonFunctions">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Functions</string>
|
||||
<property name="cursor" stdset="0">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Full name</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -325,63 +373,25 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filterFormulaInputs">
|
||||
<property name="placeholderText">
|
||||
<string>Filter list by keyword</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxHideEmpty">
|
||||
<property name="text">
|
||||
<string>Hide empty measurements</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor" stdset="0">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Full name</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="VElidedLabel" name="labelDescription">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelDescription">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
|
@ -400,6 +410,12 @@
|
|||
<extends>QPlainTextEdit</extends>
|
||||
<header location="global">vplaintextedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>VElidedLabel</class>
|
||||
<extends>QFrame</extends>
|
||||
<header location="global">velidedlabel.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>toolButtonPutHere</tabstop>
|
||||
|
|
151
src/libs/vwidgets/velidedlabel.cpp
Normal file
151
src/libs/vwidgets/velidedlabel.cpp
Normal file
|
@ -0,0 +1,151 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file velidedlabel.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 8 5, 2020
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2020 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina 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 Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
#include "velidedlabel.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QTextLayout>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VElidedLabel::VElidedLabel(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
{
|
||||
// reserve size for one line of text
|
||||
setMinimumHeight(fontMetrics().lineSpacing());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VElidedLabel::VElidedLabel(const QString &text, QWidget *parent)
|
||||
: QFrame(parent),
|
||||
m_content(text)
|
||||
{
|
||||
// reserve size for one line of text
|
||||
setMinimumHeight(fontMetrics().lineSpacing());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VElidedLabel::setText(const QString &text)
|
||||
{
|
||||
m_content = text;
|
||||
update();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VElidedLabel::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QFrame::paintEvent(event);
|
||||
|
||||
QPainter painter(this);
|
||||
bool didElide = false;
|
||||
int y = 0;
|
||||
|
||||
// QTextLayout works with paragraphs
|
||||
QStringList paragraphs = m_content.split('\n');
|
||||
for (int i = 0; i < paragraphs.size(); ++i)
|
||||
{
|
||||
if (not DrawParagraph(painter, paragraphs.at(i), y, didElide))
|
||||
{
|
||||
// It text has empty strings a user will not see elided string, but we still want to show a tooltip.
|
||||
if (i != paragraphs.size()-1 && !didElide)
|
||||
{
|
||||
didElide = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (didElide != m_elided)
|
||||
{
|
||||
m_elided = didElide;
|
||||
|
||||
if (m_showElided)
|
||||
{
|
||||
if (m_elided)
|
||||
{
|
||||
// Show a tooltip in case we cannot show a whole text in the widget
|
||||
// Use dumb html tag to separate paragraphs.
|
||||
QString toolTip;
|
||||
for(int i = 0; i < paragraphs.size(); ++i)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
toolTip.append(QString("<br>"));
|
||||
}
|
||||
toolTip.append(QString("<font>%1</font>").arg(paragraphs.at(i)));
|
||||
}
|
||||
setToolTip(toolTip);
|
||||
}
|
||||
else
|
||||
{
|
||||
setToolTip(QString());
|
||||
}
|
||||
}
|
||||
emit ElisionChanged(didElide);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VElidedLabel::DrawParagraph(QPainter &painter, const QString& paragraph, int &y, bool &didElide)
|
||||
{
|
||||
QFontMetrics fontMetrics = painter.fontMetrics();
|
||||
|
||||
int lineSpacing = fontMetrics.lineSpacing();
|
||||
bool ok = true;
|
||||
|
||||
QTextLayout textLayout(paragraph, painter.font());
|
||||
textLayout.beginLayout();
|
||||
forever
|
||||
{
|
||||
QTextLine line = textLayout.createLine();
|
||||
|
||||
if (!line.isValid())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
line.setLineWidth(width());
|
||||
int nextLineY = y + lineSpacing;
|
||||
|
||||
if (height() >= nextLineY + lineSpacing)
|
||||
{
|
||||
line.draw(&painter, QPoint(0, y));
|
||||
y = nextLineY;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString lastLine = paragraph.mid(line.textStart());
|
||||
QString elidedLastLine = fontMetrics.elidedText(lastLine, Qt::ElideRight, width());
|
||||
painter.drawText(QPoint(0, y + fontMetrics.ascent()), elidedLastLine);
|
||||
y = nextLineY;
|
||||
ok = false;
|
||||
didElide = lastLine != elidedLastLine;
|
||||
break;
|
||||
}
|
||||
}
|
||||
textLayout.endLayout();
|
||||
return ok;
|
||||
}
|
90
src/libs/vwidgets/velidedlabel.h
Normal file
90
src/libs/vwidgets/velidedlabel.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file velidedlabel.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 8 5, 2020
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2020 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina 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 Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
#ifndef VELIDEDLABEL_H
|
||||
#define VELIDEDLABEL_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
class VElidedLabel : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(bool IsElided READ IsElided)
|
||||
Q_PROPERTY(bool showElided READ ShowElided WRITE SetShowElided)
|
||||
public:
|
||||
explicit VElidedLabel(QWidget *parent = nullptr);
|
||||
explicit VElidedLabel(const QString &text, QWidget *parent = nullptr);
|
||||
|
||||
void setText(const QString &text);
|
||||
const QString& text() const;
|
||||
|
||||
bool IsElided() const;
|
||||
|
||||
bool ShowElided() const;
|
||||
void SetShowElided(bool showElided);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
signals:
|
||||
void ElisionChanged(bool m_elided);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VElidedLabel)
|
||||
bool m_elided{false};
|
||||
bool m_showElided{true};
|
||||
QString m_content{};
|
||||
|
||||
bool DrawParagraph(QPainter &painter, const QString& paragraph, int &y, bool &didElide);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline const QString &VElidedLabel::text() const
|
||||
{
|
||||
return m_content;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline bool VElidedLabel::IsElided() const
|
||||
{
|
||||
return m_elided;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline bool VElidedLabel::ShowElided() const
|
||||
{
|
||||
return m_showElided;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline void VElidedLabel::SetShowElided(bool showElided)
|
||||
{
|
||||
m_showElided = showElided;
|
||||
}
|
||||
|
||||
#endif // VELIDEDLABEL_H
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
SOURCES += \
|
||||
$$PWD/vcomboboxdelegate.cpp \
|
||||
$$PWD/velidedlabel.cpp \
|
||||
$$PWD/vmaingraphicsscene.cpp \
|
||||
$$PWD/vmaingraphicsview.cpp \
|
||||
$$PWD/vwidgetpopup.cpp \
|
||||
|
@ -32,6 +33,7 @@ SOURCES += \
|
|||
HEADERS += \
|
||||
$$PWD/stable.h \
|
||||
$$PWD/vcomboboxdelegate.h \
|
||||
$$PWD/velidedlabel.h \
|
||||
$$PWD/vmaingraphicsscene.h \
|
||||
$$PWD/vmaingraphicsview.h \
|
||||
$$PWD/vwidgetpopup.h \
|
||||
|
|
Loading…
Reference in New Issue
Block a user