Skip to content

Commit fe3930e

Browse files
committed
Added copy/paste components, right click on pins to break linksand select all components action, fixed project load bug
1 parent d4b7eba commit fe3930e

12 files changed

Lines changed: 540 additions & 58 deletions

UI/linkitem.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "linkitem.h"
2222
#include "nodalview.h"
2323
#include "pinitem.h"
24+
#include <QtMath>
2425

2526
LinkItem::LinkItem(QGraphicsItem *parent)
2627
: QGraphicsItem(parent)
@@ -107,3 +108,24 @@ QRectF LinkItem::boundingRect() const
107108

108109
return bounds;
109110
}
111+
112+
QPainterPath LinkItem::shape() const
113+
{
114+
qreal width = 1.;
115+
qreal pinRadius = 10.;
116+
QPointF firstPoint = (m_pinA != nullptr) ? m_pinA->scenePos() : m_mousePos;
117+
QPointF secondPoint = (m_pinB != nullptr) ? m_pinB->scenePos() : m_mousePos;
118+
119+
QPointF delta = secondPoint - firstPoint;
120+
qreal length = qSqrt(delta.x() * delta.x() + delta.y() * delta.y());
121+
QPointF dir = delta / length;
122+
QPointF ortho(-dir.y(), dir.x());
123+
124+
QPainterPath path;
125+
path.moveTo(firstPoint + dir * pinRadius + ortho * width);
126+
path.lineTo(secondPoint - dir * pinRadius + ortho * width);
127+
path.lineTo(secondPoint - dir * pinRadius - ortho * width);
128+
path.lineTo(firstPoint + dir * pinRadius - ortho * width);
129+
path.closeSubpath();
130+
return path;
131+
}

UI/linkitem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class LinkItem : public QGraphicsItem
5757
protected:
5858
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget* widget) override;
5959
virtual QRectF boundingRect() const override;
60+
virtual QPainterPath shape() const override;
6061
private:
6162

6263
int m_size;

UI/mainwindow.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#define MAJOR_VERSION 0
3333
#define MINOR_VERSION 0
34-
#define BUGFIX_VERSION 1
34+
#define BUGFIX_VERSION 2
3535

3636
MainWindow::MainWindow(QWidget *parent) :
3737
QMainWindow(parent),
@@ -70,6 +70,26 @@ MainWindow::MainWindow(QWidget *parent) :
7070

7171
m_signal.setComponent(ui->nodalView->getOutput()->component());
7272

73+
// ===== Edit Menu =====
74+
75+
QAction* act_selectAll = new QAction("Select All", this);
76+
act_selectAll->setShortcut(QKeySequence::SelectAll);
77+
connect(act_selectAll, SIGNAL(triggered()), ui->nodalView, SLOT(selectAll()));
78+
79+
QAction* act_copy = new QAction("Copy", this);
80+
act_copy->setShortcut(QKeySequence::Copy);
81+
connect(act_copy, SIGNAL(triggered()), ui->nodalView, SLOT(copyComponents()));
82+
83+
QAction* act_paste = new QAction("Paste", this);
84+
act_paste->setShortcut(QKeySequence::Paste);
85+
connect(act_paste, SIGNAL(triggered()), ui->nodalView, SLOT(pasteComponents()));
86+
87+
ui->menuEdit->addAction(act_copy);
88+
ui->menuEdit->addAction(act_paste);
89+
ui->menuEdit->addAction(act_selectAll);
90+
91+
// ===== Component Menu =====
92+
7393
QMenu* menu_Add = new QMenu("Add", this);
7494
ui->menuComponents->addMenu(menu_Add);
7595

@@ -87,6 +107,8 @@ MainWindow::MainWindow(QWidget *parent) :
87107
menu_Add->addAction(action);
88108
}
89109

110+
// ===== Audio Menu =====
111+
90112
QAction* act_generate = new QAction("Generate", this);
91113
act_generate->setShortcut(QKeySequence::Refresh);
92114
connect(act_generate, SIGNAL(triggered()), &m_signal, SLOT(generate()));

0 commit comments

Comments
 (0)