2010-04-24 18:39:15 +00:00
|
|
|
/*
|
2021-02-06 19:00:48 +01:00
|
|
|
Copyright 2006-2020 The QElectroTech Team
|
2010-04-24 18:39:15 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech 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 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech 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 QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2010-02-09 19:29:55 +00:00
|
|
|
#include "qtextorientationspinboxwidget.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param parent QWidget parent de ce QTextOrientationSpinBoxWidget
|
|
|
|
*/
|
|
|
|
QTextOrientationSpinBoxWidget::QTextOrientationSpinBoxWidget(QWidget *parent) :
|
|
|
|
QWidget(parent)
|
|
|
|
{
|
|
|
|
build();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructeur
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
QTextOrientationSpinBoxWidget::~QTextOrientationSpinBoxWidget()
|
|
|
|
{
|
2010-02-09 19:29:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@return un pointeur vers le QTextOrientationWidget
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
QTextOrientationWidget *QTextOrientationSpinBoxWidget::orientationWidget() const
|
|
|
|
{
|
2010-02-09 19:29:55 +00:00
|
|
|
return(orientation_widget_);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@return un pointeur vers le QSpinBox
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
QDoubleSpinBox *QTextOrientationSpinBoxWidget::spinBox() const
|
|
|
|
{
|
2010-02-09 19:29:55 +00:00
|
|
|
return(spin_box_);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@return l'orientation en cours
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
double QTextOrientationSpinBoxWidget::orientation() const
|
|
|
|
{
|
2010-02-09 19:29:55 +00:00
|
|
|
return(orientation_widget_ -> orientation());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Synonyme pour orientation()
|
|
|
|
@return l'orientation en cours
|
|
|
|
@see orientation()
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
double QTextOrientationSpinBoxWidget::value() const
|
|
|
|
{
|
2010-02-09 19:29:55 +00:00
|
|
|
return(orientation());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@return true si le widget est en mode "lecture seule", false sinon
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
bool QTextOrientationSpinBoxWidget::isReadOnly() const
|
|
|
|
{
|
2010-02-09 19:29:55 +00:00
|
|
|
return(orientation_widget_ -> isReadOnly());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@param value Nouvelle valeur de l'orientation a afficher
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
void QTextOrientationSpinBoxWidget::setOrientation(const double &value)
|
|
|
|
{
|
2010-02-09 19:29:55 +00:00
|
|
|
orientation_widget_ -> setOrientation(value);
|
|
|
|
spin_box_ -> setValue(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Synonyme pour setOrientation(value)
|
|
|
|
@param value Nouvelle valeur de l'orientation a afficher
|
|
|
|
@see setOrientation
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
void QTextOrientationSpinBoxWidget::setValue(const double &value)
|
|
|
|
{
|
2010-02-09 19:29:55 +00:00
|
|
|
setOrientation(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@param ro true pour passer le widget en mode "lecture seule", false sinon
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
void QTextOrientationSpinBoxWidget::setReadOnly(bool ro)
|
|
|
|
{
|
2010-02-09 19:29:55 +00:00
|
|
|
orientation_widget_ -> setReadOnly(ro);
|
|
|
|
spin_box_ -> setReadOnly(ro);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Construit le widget
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
void QTextOrientationSpinBoxWidget::build()
|
|
|
|
{
|
2010-02-09 19:29:55 +00:00
|
|
|
orientation_widget_ = new QTextOrientationWidget();
|
|
|
|
orientation_widget_ -> setMinimumSize(90.0, 90.0);
|
|
|
|
|
|
|
|
spin_box_ = new QDoubleSpinBox();
|
|
|
|
spin_box_ -> setRange(-360.0, 360.0);
|
2015-03-02 20:14:56 +00:00
|
|
|
spin_box_ -> setSuffix("°");
|
2010-02-09 19:29:55 +00:00
|
|
|
|
|
|
|
// met en place les relations entre le SpinBox et le QTextOrientationWidget
|
2020-09-07 22:03:40 +02:00
|
|
|
connect(spin_box_,
|
|
|
|
SIGNAL(valueChanged(double)),
|
|
|
|
orientation_widget_,
|
|
|
|
SLOT(setOrientation(double)));
|
|
|
|
connect(orientation_widget_,
|
|
|
|
SIGNAL(orientationChanged(double)),
|
|
|
|
spin_box_,
|
|
|
|
SLOT(setValue(double)));
|
2010-02-09 19:29:55 +00:00
|
|
|
|
|
|
|
// cliquer sur un des carres du QTextOrientationWidget revient a finir une saisie dans le SpinBox
|
2020-09-07 22:03:40 +02:00
|
|
|
connect(orientation_widget_,
|
|
|
|
SIGNAL(orientationChanged(double)),
|
|
|
|
spin_box_,
|
|
|
|
SIGNAL(editingFinished()));
|
2010-02-09 19:29:55 +00:00
|
|
|
|
2020-09-07 22:03:40 +02:00
|
|
|
// lorsque l'utilisateur a change l'orientation,
|
|
|
|
// on emet un signal avec la valeur de la nouvelle orientation
|
|
|
|
connect(spin_box_, SIGNAL(editingFinished()),
|
|
|
|
this, SLOT(emitChangeSignals()));
|
2010-02-09 19:29:55 +00:00
|
|
|
|
|
|
|
// dispose les widgets : le QTextOrientationWidget a gauche, le SpinBox a droite
|
2018-07-30 15:24:29 +00:00
|
|
|
QHBoxLayout *main_layout = new QHBoxLayout();
|
2010-02-09 19:29:55 +00:00
|
|
|
main_layout -> addWidget(orientation_widget_);
|
|
|
|
main_layout -> addWidget(spin_box_);
|
2010-02-11 23:35:04 +00:00
|
|
|
main_layout -> addStretch();
|
2010-02-09 19:29:55 +00:00
|
|
|
setLayout(main_layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Emet le signal orientationEditingFinished avec la valeur de l'orientation en cours
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
void QTextOrientationSpinBoxWidget::emitChangeSignals()
|
|
|
|
{
|
2010-02-09 19:29:55 +00:00
|
|
|
emit(editingFinished(orientation()));
|
|
|
|
emit(editingFinished());
|
|
|
|
}
|