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 dialog for tool Point along perpendicular. No memory of line color settings.
|
||||||
- Fix crash after uniting three pieces in sequence.
|
- Fix crash after uniting three pieces in sequence.
|
||||||
- Incorrect conversion to newer curve format.
|
- Incorrect conversion to newer curve format.
|
||||||
|
- Elide a variable description in the formula wizard.
|
||||||
|
|
||||||
# Version 0.6.1 October 23, 2018
|
# Version 0.6.1 October 23, 2018
|
||||||
- [#885] Regression. Broken support for multi size measurements.
|
- [#885] Regression. Broken support for multi size measurements.
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>448</width>
|
<width>542</width>
|
||||||
<height>478</height>
|
<height>481</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
<property name="modal">
|
<property name="modal">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item alignment="Qt::AlignLeft">
|
<item alignment="Qt::AlignLeft">
|
||||||
|
@ -172,34 +172,173 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="">
|
<widget class="QWidget" name="">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="3,1">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_8">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<property name="sizePolicy">
|
<item>
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<widget class="QLabel" name="label_8">
|
||||||
<horstretch>0</horstretch>
|
<property name="sizePolicy">
|
||||||
<verstretch>0</verstretch>
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
</sizepolicy>
|
<horstretch>0</horstretch>
|
||||||
</property>
|
<verstretch>0</verstretch>
|
||||||
<property name="text">
|
</sizepolicy>
|
||||||
<string>Input data</string>
|
</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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="radioButtonStandardTable">
|
<widget class="QCheckBox" name="checkBoxHideEmpty">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Measurements</string>
|
<string>Hide empty measurements</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -207,117 +346,26 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="radioButtonIncrements">
|
<widget class="QTableWidget" name="tableWidget">
|
||||||
<property name="sizePolicy">
|
<property name="minimumSize">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
<size>
|
||||||
<horstretch>0</horstretch>
|
<width>0</width>
|
||||||
<verstretch>0</verstretch>
|
<height>0</height>
|
||||||
</sizepolicy>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="cursor" stdset="0">
|
||||||
<string>Increments</string>
|
<cursorShape>PointingHandCursor</cursorShape>
|
||||||
</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>
|
</property>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Name</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Full name</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -325,63 +373,25 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<widget class="VElidedLabel" name="labelDescription">
|
||||||
<item>
|
<property name="sizePolicy">
|
||||||
<widget class="QLineEdit" name="filterFormulaInputs">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
<property name="placeholderText">
|
<horstretch>0</horstretch>
|
||||||
<string>Filter list by keyword</string>
|
<verstretch>0</verstretch>
|
||||||
</property>
|
</sizepolicy>
|
||||||
</widget>
|
</property>
|
||||||
</item>
|
<property name="frameShape">
|
||||||
<item>
|
<enum>QFrame::NoFrame</enum>
|
||||||
<widget class="QCheckBox" name="checkBoxHideEmpty">
|
</property>
|
||||||
<property name="text">
|
<property name="frameShadow">
|
||||||
<string>Hide empty measurements</string>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
</widget>
|
||||||
<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>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="labelDescription">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -400,6 +410,12 @@
|
||||||
<extends>QPlainTextEdit</extends>
|
<extends>QPlainTextEdit</extends>
|
||||||
<header location="global">vplaintextedit.h</header>
|
<header location="global">vplaintextedit.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>VElidedLabel</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header location="global">velidedlabel.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>toolButtonPutHere</tabstop>
|
<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 += \
|
SOURCES += \
|
||||||
$$PWD/vcomboboxdelegate.cpp \
|
$$PWD/vcomboboxdelegate.cpp \
|
||||||
|
$$PWD/velidedlabel.cpp \
|
||||||
$$PWD/vmaingraphicsscene.cpp \
|
$$PWD/vmaingraphicsscene.cpp \
|
||||||
$$PWD/vmaingraphicsview.cpp \
|
$$PWD/vmaingraphicsview.cpp \
|
||||||
$$PWD/vwidgetpopup.cpp \
|
$$PWD/vwidgetpopup.cpp \
|
||||||
|
@ -32,6 +33,7 @@ SOURCES += \
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/stable.h \
|
$$PWD/stable.h \
|
||||||
$$PWD/vcomboboxdelegate.h \
|
$$PWD/vcomboboxdelegate.h \
|
||||||
|
$$PWD/velidedlabel.h \
|
||||||
$$PWD/vmaingraphicsscene.h \
|
$$PWD/vmaingraphicsscene.h \
|
||||||
$$PWD/vmaingraphicsview.h \
|
$$PWD/vmaingraphicsview.h \
|
||||||
$$PWD/vwidgetpopup.h \
|
$$PWD/vwidgetpopup.h \
|
||||||
|
|
Loading…
Reference in New Issue
Block a user