mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-05 13:39:58 +01:00
image can be resized (not undo command and save to xml yet)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2488 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -219,15 +219,55 @@ void DiagramImageItem::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
@param event un QGraphicsSceneMouseEvent decrivant le double-clic
|
@param event un QGraphicsSceneMouseEvent decrivant le double-clic
|
||||||
*/
|
*/
|
||||||
void DiagramImageItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
void DiagramImageItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
/*if (!(textInteractionFlags() & Qt::imageditable)) {
|
Q_UNUSED (event);
|
||||||
// rend le champ de image editable
|
if (diagram() -> isReadOnly()) return;
|
||||||
setTextInteractionFlags(Qt::imageditorInteraction);
|
//the range for scale image and divisor factor
|
||||||
|
int min_range = 1;
|
||||||
// edite le champ de image
|
int max_range = 200;
|
||||||
setFocus(Qt::MouseFocusReason);
|
int factor_range = 100;
|
||||||
} else {
|
|
||||||
QGraphicsPixmapItem::mouseDoubleClickEvent(event);
|
//the dialog
|
||||||
}*/
|
QDialog property_dialog;
|
||||||
|
property_dialog.setWindowTitle(tr("\311diter les propri\351t\351s d'une image", "window title"));
|
||||||
|
//the main layout
|
||||||
|
QVBoxLayout *dialog_layout = new QVBoxLayout(&property_dialog);
|
||||||
|
|
||||||
|
//GroupBox for resizer image
|
||||||
|
QGroupBox *resize_groupe = new QGroupBox(tr("Dimension de l'image", "image size"));
|
||||||
|
dialog_layout -> addWidget(resize_groupe);
|
||||||
|
QHBoxLayout *resize_layout = new QHBoxLayout(resize_groupe);
|
||||||
|
|
||||||
|
//slider
|
||||||
|
QSlider *slider = new QSlider(Qt::Horizontal, &property_dialog);
|
||||||
|
slider->setRange(min_range, max_range);
|
||||||
|
qreal scale_= scale();
|
||||||
|
slider -> setValue(scale_*factor_range);
|
||||||
|
//spinbox
|
||||||
|
QSpinBox *spin_box = new QSpinBox(&property_dialog);
|
||||||
|
spin_box -> setRange(min_range, max_range);
|
||||||
|
spin_box -> setValue(scale_*factor_range);
|
||||||
|
spin_box -> setSuffix(" %");
|
||||||
|
//synchro slider with spinbox
|
||||||
|
connect(slider, SIGNAL(valueChanged(int)), spin_box, SLOT(setValue(int)));
|
||||||
|
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(setScale(int)));
|
||||||
|
connect(spin_box, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
|
||||||
|
//add slider and spinbox to layout
|
||||||
|
resize_layout -> addWidget(slider);
|
||||||
|
resize_layout -> addWidget(spin_box);
|
||||||
|
|
||||||
|
//dialog butto, box
|
||||||
|
QDialogButtonBox *dbb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
dialog_layout -> addWidget(dbb);
|
||||||
|
connect(dbb, SIGNAL(accepted()), &property_dialog, SLOT(accept()));
|
||||||
|
connect(dbb, SIGNAL(rejected()), &property_dialog, SLOT(reject()));
|
||||||
|
|
||||||
|
if (property_dialog.exec() == QDialog::Accepted) {
|
||||||
|
qreal new_scale = slider -> value();
|
||||||
|
new_scale /= factor_range;
|
||||||
|
if (scale_ != new_scale) QGraphicsPixmapItem::setScale(new_scale);
|
||||||
|
}
|
||||||
|
else QGraphicsPixmapItem::setScale(scale_);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,9 +367,16 @@ QPointF DiagramImageItem::pos() const {
|
|||||||
return(QGraphicsPixmapItem::pos());
|
return(QGraphicsPixmapItem::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Rend le champ de image non focusable
|
/**
|
||||||
void DiagramImageItem::setNonFocusable() {
|
* @brief DiagramImageItem::setScale
|
||||||
setFlag(QGraphicsPixmapItem::ItemIsFocusable, false);
|
* @param scale the value of @scale must be betwen 1 and 200
|
||||||
|
*/
|
||||||
|
void DiagramImageItem::setScale(int scale) {
|
||||||
|
if (scale >= 1 && scale <= 200) {
|
||||||
|
qreal new_scale = scale;
|
||||||
|
new_scale /= 100;
|
||||||
|
QGraphicsPixmapItem::setScale(new_scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ class DiagramImageItem : public QObject, public QGraphicsPixmapItem {
|
|||||||
/// signal emitted after image was changed
|
/// signal emitted after image was changed
|
||||||
void diagramImageChanged(DiagramImageItem *, const QString &, const QString &);
|
void diagramImageChanged(DiagramImageItem *, const QString &, const QString &);
|
||||||
|
|
||||||
public slots:
|
private slots:
|
||||||
void setNonFocusable();
|
void setScale(int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool first_move_;
|
bool first_move_;
|
||||||
|
|||||||
Reference in New Issue
Block a user