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::xKeyGrid = 10;
|
||||
int Diagram::yKeyGrid = 10;
|
||||
int Diagram::xKeyGridFine = 1;
|
||||
int Diagram::yKeyGridFine = 1;
|
||||
const qreal Diagram::margin = 5.0;
|
||||
|
||||
// static variable to keep track of present background color of the diagram.
|
||||
@@ -285,7 +287,8 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
||||
QSettings settings;
|
||||
int xKeyGrid = settings.value("DiagramEditor_xKeyGrid_sb", Diagram::xKeyGrid).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);
|
||||
|
||||
if (m_event_interface) {
|
||||
@@ -342,7 +345,46 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
||||
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
|
||||
if(selectedItems().size() == 1 && selectedItems().first()->type() == QGraphicsItemGroup::Type)
|
||||
|
||||
@@ -80,6 +80,10 @@ class Diagram : public QGraphicsScene
|
||||
static int xKeyGrid;
|
||||
/// Key grid y step size
|
||||
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
|
||||
static const qreal margin;
|
||||
/// 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_xKeyGrid_sb->setValue(settings.value("DiagramEditor_xKeyGrid_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";
|
||||
if(tabbed)
|
||||
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_xKeyGrid_sb", ui->DiagramEditor_xKeyGrid_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();
|
||||
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>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="Grid">
|
||||
<widget class="QWidget" name="GrilleClavier">
|
||||
<attribute name="title">
|
||||
<string>Grille</string>
|
||||
<string>Grille + Clavier</string>
|
||||
</attribute>
|
||||
<widget class="QLabel" name="Label_Diagram_xGrid">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>10</y>
|
||||
<x>90</x>
|
||||
<y>50</y>
|
||||
<width>191</width>
|
||||
<height>30</height>
|
||||
</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">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>50</y>
|
||||
<x>90</x>
|
||||
<y>90</y>
|
||||
<width>191</width>
|
||||
<height>30</height>
|
||||
</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">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>10</y>
|
||||
<x>540</x>
|
||||
<y>50</y>
|
||||
<width>55</width>
|
||||
<height>30</height>
|
||||
</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">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>50</y>
|
||||
<x>540</x>
|
||||
<y>90</y>
|
||||
<width>55</width>
|
||||
<height>30</height>
|
||||
</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">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>180</y>
|
||||
<width>321</width>
|
||||
<x>90</x>
|
||||
<y>280</y>
|
||||
<width>431</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DiagramEditor Key Left/Right xGrid</string>
|
||||
<string>DiagramEditor (touche : gauche / droite) xGrid</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="DiagramEditor_xKeyGrid_sb">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>180</y>
|
||||
<x>540</x>
|
||||
<y>280</y>
|
||||
<width>55</width>
|
||||
<height>30</height>
|
||||
</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">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>220</y>
|
||||
<width>321</width>
|
||||
<x>90</x>
|
||||
<y>320</y>
|
||||
<width>431</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DiagramEditor Key Up/Down yGrid</string>
|
||||
<string>DiagramEditor (touche : haut / bas) yGrid</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="DiagramEditor_yKeyGrid_sb">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>220</y>
|
||||
<x>540</x>
|
||||
<y>320</y>
|
||||
<width>55</width>
|
||||
<height>30</height>
|
||||
</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>
|
||||
</property>
|
||||
</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>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user