mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Add two speedsize for displacing items when working with a keyboard on
diagram editor : normal displacement "adjustable from 1 to 30" (keys : Left,Right,Up,Down) fine displacement "adjustable from 1 to 10" (ALT + keys : Left,Right,Up,Down ), thanks Erik for his patch git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5749 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -42,6 +42,8 @@ int Diagram::xGrid = 10;
|
|||||||
int Diagram::yGrid = 10;
|
int Diagram::yGrid = 10;
|
||||||
int Diagram::xKeyGrid = 10;
|
int Diagram::xKeyGrid = 10;
|
||||||
int Diagram::yKeyGrid = 10;
|
int Diagram::yKeyGrid = 10;
|
||||||
|
int Diagram::xKeyGridFine = 1;
|
||||||
|
int Diagram::yKeyGridFine = 1;
|
||||||
const qreal Diagram::margin = 5.0;
|
const qreal Diagram::margin = 5.0;
|
||||||
|
|
||||||
// static variable to keep track of present background color of the diagram.
|
// static variable to keep track of present background color of the diagram.
|
||||||
@@ -285,7 +287,8 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
int xKeyGrid = settings.value("DiagramEditor_xKeyGrid_sb", Diagram::xKeyGrid).toInt();
|
int xKeyGrid = settings.value("DiagramEditor_xKeyGrid_sb", Diagram::xKeyGrid).toInt();
|
||||||
int yKeyGrid = settings.value("DiagramEditor_yKeyGrid_sb", Diagram::yKeyGrid).toInt();
|
int yKeyGrid = settings.value("DiagramEditor_yKeyGrid_sb", Diagram::yKeyGrid).toInt();
|
||||||
|
int xKeyGridFine = settings.value("DiagramEditor_xKeyGridFine_sb", Diagram::xKeyGridFine).toInt();
|
||||||
|
int yKeyGridFine = settings.value("DiagramEditor_yKeyGridFine_sb", Diagram::yKeyGridFine).toInt();
|
||||||
event->setAccepted(false);
|
event->setAccepted(false);
|
||||||
|
|
||||||
if (m_event_interface) {
|
if (m_event_interface) {
|
||||||
@@ -342,7 +345,46 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(event->modifiers() == Qt::ControlModifier)
|
else if(event->modifiers() == Qt::AltModifier)
|
||||||
|
|
||||||
|
{
|
||||||
|
switch(event->key())
|
||||||
|
{
|
||||||
|
case Qt::Key_Left:
|
||||||
|
for (Element *item : dc.m_elements)
|
||||||
|
{
|
||||||
|
left_position = item->sceneBoundingRect().x();
|
||||||
|
if(left_position <= 5)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
movement = QPointF(-xKeyGridFine, 0.0);
|
||||||
|
break;
|
||||||
|
case Qt::Key_Right:
|
||||||
|
movement = QPointF(+xKeyGridFine, 0.0);
|
||||||
|
break;
|
||||||
|
case Qt::Key_Up:
|
||||||
|
for(Element *item : dc.m_elements)
|
||||||
|
{
|
||||||
|
top_position = item->sceneBoundingRect().y();
|
||||||
|
if(top_position <= 5)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
movement = QPointF(0.0, -yKeyGridFine);
|
||||||
|
break;
|
||||||
|
case Qt::Key_Down:
|
||||||
|
movement = QPointF(0.0, +yKeyGridFine);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!movement.isNull() && !focusItem())
|
||||||
|
{
|
||||||
|
m_elements_mover.beginMovement(this);
|
||||||
|
m_elements_mover.continueMovement(movement);
|
||||||
|
event->accept();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(event->modifiers() == Qt::ControlModifier)
|
||||||
{
|
{
|
||||||
//Adjust the alignment of a texts group
|
//Adjust the alignment of a texts group
|
||||||
if(selectedItems().size() == 1 && selectedItems().first()->type() == QGraphicsItemGroup::Type)
|
if(selectedItems().size() == 1 && selectedItems().first()->type() == QGraphicsItemGroup::Type)
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ class Diagram : public QGraphicsScene
|
|||||||
static int xKeyGrid;
|
static int xKeyGrid;
|
||||||
/// Key grid y step size
|
/// Key grid y step size
|
||||||
static int yKeyGrid;
|
static int yKeyGrid;
|
||||||
|
/// Key grid fine x step size
|
||||||
|
static int xKeyGridFine;
|
||||||
|
/// Key grid fine y step size
|
||||||
|
static int yKeyGridFine;
|
||||||
/// margin around the diagram
|
/// margin around the diagram
|
||||||
static const qreal margin;
|
static const qreal margin;
|
||||||
/// background color of diagram
|
/// background color of diagram
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
|||||||
ui->DiagramEditor_yGrid_sb->setValue(settings.value("DiagramEditor_yGrid_sb", 10).toInt());
|
ui->DiagramEditor_yGrid_sb->setValue(settings.value("DiagramEditor_yGrid_sb", 10).toInt());
|
||||||
ui->DiagramEditor_xKeyGrid_sb->setValue(settings.value("DiagramEditor_xKeyGrid_sb", 10).toInt());
|
ui->DiagramEditor_xKeyGrid_sb->setValue(settings.value("DiagramEditor_xKeyGrid_sb", 10).toInt());
|
||||||
ui->DiagramEditor_yKeyGrid_sb->setValue(settings.value("DiagramEditor_yKeyGrid_sb", 10).toInt());
|
ui->DiagramEditor_yKeyGrid_sb->setValue(settings.value("DiagramEditor_yKeyGrid_sb", 10).toInt());
|
||||||
ui->m_use_system_color_cb->setChecked(settings.value("usesystemcolors", "true").toBool());
|
ui->DiagramEditor_xKeyGridFine_sb->setValue(settings.value("DiagramEditor_xKeyGridFine_sb", 1).toInt());
|
||||||
|
ui->DiagramEditor_yKeyGridFine_sb->setValue(settings.value("DiagramEditor_yKeyGridFine_sb", 1).toInt());
|
||||||
|
ui->m_use_system_color_cb->setChecked(settings.value("usesystemcolors", "true").toBool());
|
||||||
bool tabbed = settings.value("diagrameditor/viewmode", "tabbed") == "tabbed";
|
bool tabbed = settings.value("diagrameditor/viewmode", "tabbed") == "tabbed";
|
||||||
if(tabbed)
|
if(tabbed)
|
||||||
ui->m_use_tab_mode_rb->setChecked(true);
|
ui->m_use_tab_mode_rb->setChecked(true);
|
||||||
@@ -145,7 +147,9 @@ void GeneralConfigurationPage::applyConf()
|
|||||||
settings.setValue("DiagramEditor_yGrid_sb", ui->DiagramEditor_yGrid_sb->value());
|
settings.setValue("DiagramEditor_yGrid_sb", ui->DiagramEditor_yGrid_sb->value());
|
||||||
settings.setValue("DiagramEditor_xKeyGrid_sb", ui->DiagramEditor_xKeyGrid_sb->value());
|
settings.setValue("DiagramEditor_xKeyGrid_sb", ui->DiagramEditor_xKeyGrid_sb->value());
|
||||||
settings.setValue("DiagramEditor_yKeyGrid_sb", ui->DiagramEditor_yKeyGrid_sb->value());
|
settings.setValue("DiagramEditor_yKeyGrid_sb", ui->DiagramEditor_yKeyGrid_sb->value());
|
||||||
|
settings.setValue("DiagramEditor_xKeyGridFine_sb", ui->DiagramEditor_xKeyGridFine_sb->value());
|
||||||
|
settings.setValue("DiagramEditor_yKeyGridFine_sb", ui->DiagramEditor_yKeyGridFine_sb->value());
|
||||||
|
|
||||||
QString path = settings.value("elements-collections/common-collection-path").toString();
|
QString path = settings.value("elements-collections/common-collection-path").toString();
|
||||||
if (ui->m_common_elmt_path_cb->currentIndex() == 1)
|
if (ui->m_common_elmt_path_cb->currentIndex() == 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -464,15 +464,15 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="Grid">
|
<widget class="QWidget" name="GrilleClavier">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Grille</string>
|
<string>Grille + Clavier</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<widget class="QLabel" name="Label_Diagram_xGrid">
|
<widget class="QLabel" name="Label_Diagram_xGrid">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>90</x>
|
||||||
<y>10</y>
|
<y>50</y>
|
||||||
<width>191</width>
|
<width>191</width>
|
||||||
<height>30</height>
|
<height>30</height>
|
||||||
</rect>
|
</rect>
|
||||||
@@ -484,8 +484,8 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
|||||||
<widget class="QLabel" name="Label_Diagram_yGrid">
|
<widget class="QLabel" name="Label_Diagram_yGrid">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>90</x>
|
||||||
<y>50</y>
|
<y>90</y>
|
||||||
<width>191</width>
|
<width>191</width>
|
||||||
<height>30</height>
|
<height>30</height>
|
||||||
</rect>
|
</rect>
|
||||||
@@ -497,8 +497,8 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
|||||||
<widget class="QSpinBox" name="DiagramEditor_xGrid_sb">
|
<widget class="QSpinBox" name="DiagramEditor_xGrid_sb">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>350</x>
|
<x>540</x>
|
||||||
<y>10</y>
|
<y>50</y>
|
||||||
<width>55</width>
|
<width>55</width>
|
||||||
<height>30</height>
|
<height>30</height>
|
||||||
</rect>
|
</rect>
|
||||||
@@ -519,8 +519,8 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
|||||||
<widget class="QSpinBox" name="DiagramEditor_yGrid_sb">
|
<widget class="QSpinBox" name="DiagramEditor_yGrid_sb">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>350</x>
|
<x>540</x>
|
||||||
<y>50</y>
|
<y>90</y>
|
||||||
<width>55</width>
|
<width>55</width>
|
||||||
<height>30</height>
|
<height>30</height>
|
||||||
</rect>
|
</rect>
|
||||||
@@ -538,21 +538,21 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
|||||||
<widget class="QLabel" name="Label_Diagram_Key_xGrid">
|
<widget class="QLabel" name="Label_Diagram_Key_xGrid">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>90</x>
|
||||||
<y>180</y>
|
<y>280</y>
|
||||||
<width>321</width>
|
<width>431</width>
|
||||||
<height>30</height>
|
<height>30</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>DiagramEditor Key Left/Right xGrid</string>
|
<string>DiagramEditor (touche : gauche / droite) xGrid</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QSpinBox" name="DiagramEditor_xKeyGrid_sb">
|
<widget class="QSpinBox" name="DiagramEditor_xKeyGrid_sb">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>350</x>
|
<x>540</x>
|
||||||
<y>180</y>
|
<y>280</y>
|
||||||
<width>55</width>
|
<width>55</width>
|
||||||
<height>30</height>
|
<height>30</height>
|
||||||
</rect>
|
</rect>
|
||||||
@@ -573,21 +573,21 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
|||||||
<widget class="QLabel" name="Label_Diagram_Key_yGrid">
|
<widget class="QLabel" name="Label_Diagram_Key_yGrid">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>90</x>
|
||||||
<y>220</y>
|
<y>320</y>
|
||||||
<width>321</width>
|
<width>431</width>
|
||||||
<height>30</height>
|
<height>30</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>DiagramEditor Key Up/Down yGrid</string>
|
<string>DiagramEditor (touche : haut / bas) yGrid</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QSpinBox" name="DiagramEditor_yKeyGrid_sb">
|
<widget class="QSpinBox" name="DiagramEditor_yKeyGrid_sb">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>350</x>
|
<x>540</x>
|
||||||
<y>220</y>
|
<y>320</y>
|
||||||
<width>55</width>
|
<width>55</width>
|
||||||
<height>30</height>
|
<height>30</height>
|
||||||
</rect>
|
</rect>
|
||||||
@@ -605,6 +605,128 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
|||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QLabel" name="Label_Grid">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>121</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Grille : 1 - 30</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="Label_Keys">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>240</y>
|
||||||
|
<width>281</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Déplacement au clavier : 1 - 30</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="Label_Keys_ALT">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>360</y>
|
||||||
|
<width>421</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Déplacement au clavier avec la touche ALT : 1 - 9</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="Label_Diagram_Key_xGrid_ALT">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>90</x>
|
||||||
|
<y>400</y>
|
||||||
|
<width>431</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>DiagramEditor (touche : gauche / droite ) xGrid</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="Label_Diagram_Key_yGrid_ALT">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>90</x>
|
||||||
|
<y>440</y>
|
||||||
|
<width>431</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>DiagramEditor (touche : haut / bas) yGrid</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox" name="DiagramEditor_xKeyGridFine_sb">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>540</x>
|
||||||
|
<y>400</y>
|
||||||
|
<width>55</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox" name="DiagramEditor_yKeyGridFine_sb">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>540</x>
|
||||||
|
<y>440</y>
|
||||||
|
<width>55</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="Label_Grid_Tip">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>130</y>
|
||||||
|
<width>481</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>La Grille doite etre active pour pouvoir voir les modifications.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user