mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01:00
add a F2 shortcut for the widget "Edit the color of the given conductor"
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1313 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -73,6 +73,8 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : QGraphicsView(pare
|
|||||||
connect(&(scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(updateWindowTitle()));
|
connect(&(scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(updateWindowTitle()));
|
||||||
|
|
||||||
connect(this, SIGNAL(aboutToAddElement()), this, SLOT(addDroppedElement()), Qt::QueuedConnection);
|
connect(this, SIGNAL(aboutToAddElement()), this, SLOT(addDroppedElement()), Qt::QueuedConnection);
|
||||||
|
QShortcut *edit_conductor_color_shortcut = new QShortcut(QKeySequence(Qt::Key_F2), this);
|
||||||
|
connect(edit_conductor_color_shortcut, SIGNAL(activated()), this, SLOT(editSelectedConductorColor()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -736,6 +738,20 @@ void DiagramView::editSelectionProperties() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Edit the color of the selected conductor; does nothing if multiple conductors are selected
|
||||||
|
*/
|
||||||
|
void DiagramView::editSelectedConductorColor() {
|
||||||
|
// retrieve selected content
|
||||||
|
DiagramContent selection = scene -> selectedContent();
|
||||||
|
|
||||||
|
// we'll focus on the selected conductor (we do not handle multiple conductors edition)
|
||||||
|
QList<Conductor *> selected_conductors = selection.conductors(DiagramContent::AnyConductor | DiagramContent::SelectedOnly);
|
||||||
|
if (selected_conductors.count() == 1) {
|
||||||
|
editConductorColor(selected_conductors.at(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Affiche des informations sur un element
|
Affiche des informations sur un element
|
||||||
@param element Element a afficher
|
@param element Element a afficher
|
||||||
@@ -857,6 +873,41 @@ void DiagramView::editConductor(Conductor *edited_conductor) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Edit the color of the given conductor
|
||||||
|
@param edited_conductor Conductor we want to change the color
|
||||||
|
*/
|
||||||
|
void DiagramView::editConductorColor(Conductor *edited_conductor) {
|
||||||
|
if (scene -> isReadOnly()) return;
|
||||||
|
if (!edited_conductor) return;
|
||||||
|
|
||||||
|
// store the initial properties of the provided conductor
|
||||||
|
ConductorProperties initial_properties = edited_conductor -> properties();
|
||||||
|
|
||||||
|
// prepare a color dialog showing the initial conductor color
|
||||||
|
QColorDialog *color_dialog = new QColorDialog(this);
|
||||||
|
color_dialog -> setWindowTitle(tr("Choisir la nouvelle couleur de ce conducteur"));
|
||||||
|
#ifdef Q_WS_MAC
|
||||||
|
color_dialog.setWindowFlags(Qt::Sheet);
|
||||||
|
#endif
|
||||||
|
color_dialog -> setCurrentColor(initial_properties.color);
|
||||||
|
|
||||||
|
// asks the user what color he wishes to apply
|
||||||
|
if (color_dialog -> exec() == QDialog::Accepted) {
|
||||||
|
QColor new_color = color_dialog -> selectedColor();
|
||||||
|
if (new_color != initial_properties.color) {
|
||||||
|
// the user chose a different color
|
||||||
|
ConductorProperties new_properties = initial_properties;
|
||||||
|
new_properties.color = new_color;
|
||||||
|
|
||||||
|
ChangeConductorPropertiesCommand *ccpc = new ChangeConductorPropertiesCommand(edited_conductor);
|
||||||
|
ccpc -> setOldSettings(initial_properties);
|
||||||
|
ccpc -> setNewSettings(new_properties);
|
||||||
|
diagram() -> undoStack().push(ccpc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Reinitialise le profil des conducteurs selectionnes
|
Reinitialise le profil des conducteurs selectionnes
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -118,9 +118,11 @@ class DiagramView : public QGraphicsView {
|
|||||||
void adjustSceneRect();
|
void adjustSceneRect();
|
||||||
void updateWindowTitle();
|
void updateWindowTitle();
|
||||||
void editSelectionProperties();
|
void editSelectionProperties();
|
||||||
|
void editSelectedConductorColor();
|
||||||
void editElement(Element *);
|
void editElement(Element *);
|
||||||
void editConductor();
|
void editConductor();
|
||||||
void editConductor(Conductor *);
|
void editConductor(Conductor *);
|
||||||
|
void editConductorColor(Conductor *);
|
||||||
void resetConductors();
|
void resetConductors();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
Reference in New Issue
Block a user