diff --git a/graphwidget.cpp b/graphwidget.cpp index 276cf4f..f1a9dc5 100644 --- a/graphwidget.cpp +++ b/graphwidget.cpp @@ -273,24 +273,26 @@ void GraphWidget::keyPressEvent(QKeyEvent *event) case Qt::Key_Down: case Qt::Key_Left: case Qt::Key_Right: - if (event->modifiers() == Qt::ControlModifier) + if (event->modifiers() & Qt::ControlModifier) { - if (event->key() == Qt::Key_Up) m_activeNode->moveBy(0, -20); - else if (event->key() == Qt::Key_Down) m_activeNode->moveBy(0, 20); - else if (event->key() == Qt::Key_Left) m_activeNode->moveBy(-20, 0); - else if (event->key() == Qt::Key_Right) m_activeNode->moveBy(20, 0); - contentChanged(); - } - else if (event->modifiers() & Qt::ControlModifier && - event->modifiers() & Qt::ShiftModifier) - { - QList nodeList = m_activeNode->subtree(); - foreach(Node *node, nodeList) + if (event->modifiers() & Qt::AltModifier) { - if (event->key() == Qt::Key_Up) node->moveBy(0, -20); - else if (event->key() == Qt::Key_Down) node->moveBy(0, 20); - else if (event->key() == Qt::Key_Left) node->moveBy(-20, 0); - else if (event->key() == Qt::Key_Right) node->moveBy(20, 0); + QList nodeList = m_activeNode->subtree(); + foreach(Node *node, nodeList) + { + if (event->key() == Qt::Key_Up) node->moveBy(0, -20); + else if (event->key() == Qt::Key_Down) node->moveBy(0, 20); + else if (event->key() == Qt::Key_Left) node->moveBy(-20, 0); + else if (event->key() == Qt::Key_Right) node->moveBy(20, 0); + contentChanged(); + } + } + else + { + if (event->key() == Qt::Key_Up) m_activeNode->moveBy(0, -20); + else if (event->key() == Qt::Key_Down) m_activeNode->moveBy(0, 20); + else if (event->key() == Qt::Key_Left) m_activeNode->moveBy(-20, 0); + else if (event->key() == Qt::Key_Right) m_activeNode->moveBy(20, 0); contentChanged(); } } @@ -302,34 +304,42 @@ void GraphWidget::keyPressEvent(QKeyEvent *event) // zoom in/out case Qt::Key_Plus: - if (event->modifiers() == Qt::ControlModifier) - { - m_activeNode->setScale(qreal(1.2),sceneRect()); - } - else if (event->modifiers() & Qt::ControlModifier && - event->modifiers() & Qt::ShiftModifier) + + if (event->modifiers() & Qt::ControlModifier) { - QList nodeList = m_activeNode->subtree(); - foreach(Node *node, nodeList) - node->setScale(qreal(1.2),sceneRect()); + if (event->modifiers() & Qt::AltModifier) + { + QList nodeList = m_activeNode->subtree(); + foreach(Node *node, nodeList) + node->setScale(qreal(1.2),sceneRect()); + } + else + { + m_activeNode->setScale(qreal(1.2),sceneRect()); + } } else { scaleView(qreal(1.2)); } break; + case Qt::Key_Minus: - if (event->modifiers() == Qt::ControlModifier) - { - m_activeNode->setScale(qreal(1 / 1.2),sceneRect()); - } - else if (event->modifiers() & Qt::ControlModifier && - event->modifiers() & Qt::ShiftModifier) + + if (event->modifiers() & Qt::ControlModifier) { - QList nodeList = m_activeNode->subtree(); - foreach(Node *node, nodeList) - node->setScale(qreal(1 / 1.2),sceneRect()); + if (event->modifiers() & Qt::AltModifier) + { + QList nodeList = m_activeNode->subtree(); + foreach(Node *node, nodeList) + node->setScale(qreal(1 / 1.2),sceneRect()); + } + else + { + m_activeNode->setScale(qreal(1 / 1.2),sceneRect()); + } } + else { scaleView(1 / qreal(1.2)); @@ -412,7 +422,7 @@ void GraphWidget::keyPressEvent(QKeyEvent *event) } QList nodeList; - if (event->modifiers() == Qt::ShiftModifier) + if (event->modifiers() == Qt::AltModifier) { nodeList = m_activeNode->subtree(); } @@ -453,7 +463,7 @@ void GraphWidget::keyPressEvent(QKeyEvent *event) case Qt::Key_C: { QList nodeList; - if (event->modifiers() == Qt::ShiftModifier) + if (event->modifiers() == Qt::AltModifier) { nodeList = m_activeNode->subtree(); } @@ -482,7 +492,7 @@ void GraphWidget::keyPressEvent(QKeyEvent *event) case Qt::Key_T: { QList nodeList; - if (event->modifiers() == Qt::ShiftModifier) + if (event->modifiers() == Qt::AltModifier) { nodeList = m_activeNode->subtree(); } @@ -757,7 +767,6 @@ void GraphWidget::addFirstNode() QString("")); m_scene->addItem(node); node->setPos(-25, -25); - node->setBorder(false); m_nodeList.append(node); diff --git a/node.cpp b/node.cpp index 3224ad9..55769b4 100644 --- a/node.cpp +++ b/node.cpp @@ -86,9 +86,14 @@ void Node::setBorder(const bool &hasBorder) update(); } +/** @note Used to have some disorder here, how does an active node looks like? +* Let is have border but the color shall not change, shadow is messy too. +*/ + void Node::setActive(const bool &active) { m_isActive = active; + setBorder(active); update(); } @@ -361,19 +366,15 @@ void Node::paint(QPainter *painter, else { m_hasBorder ? - painter->setPen(m_isActive ? Qt::red : Qt::blue) : + painter->setPen(QPen(QBrush(Qt::black), 1)) : // border is scaled painter->setPen(Qt::transparent); - m_isActive? -// painter->setBrush(Node::m_orange) : - painter->setBrush(m_color.darker(120)) : - painter->setBrush(m_color); - + painter->setBrush(m_color); painter->drawRoundedRect(boundingRect(), 20.0, 15.0); + } painter->setBrush(Qt::NoBrush); - // the text itself setDefaultTextColor(m_textColor); QGraphicsTextItem::paint(painter, option, w);