Mercurial > hg > easyhg
comparison uncommitteditem.cpp @ 141:e6c6b88d19b9
* Start hooking up right-button menus on changeset & uncommitted items
author | Chris Cannam |
---|---|
date | Tue, 30 Nov 2010 17:56:11 +0000 |
parents | 2550aaa09240 |
children | 644bd31e8301 |
comparison
equal
deleted
inserted
replaced
140:bad40d7e7a2b | 141:e6c6b88d19b9 |
---|---|
19 #include "colourset.h" | 19 #include "colourset.h" |
20 #include "debug.h" | 20 #include "debug.h" |
21 | 21 |
22 #include <QPainter> | 22 #include <QPainter> |
23 #include <QGraphicsScene> | 23 #include <QGraphicsScene> |
24 #include <QGraphicsSceneMouseEvent> | |
25 #include <QMenu> | |
26 #include <QAction> | |
27 #include <QLabel> | |
28 #include <QWidgetAction> | |
24 | 29 |
25 UncommittedItem::UncommittedItem() : | 30 UncommittedItem::UncommittedItem() : |
26 m_column(0), m_row(0), m_wide(false) | 31 m_column(0), m_row(0), m_wide(false) |
27 { | 32 { |
28 m_font = QFont(); | 33 m_font = QFont(); |
36 { | 41 { |
37 //!!! this stuff is gross, refactor with changesetitem and connectionitem | 42 //!!! this stuff is gross, refactor with changesetitem and connectionitem |
38 int w = 100; | 43 int w = 100; |
39 if (m_wide) w = 180; | 44 if (m_wide) w = 180; |
40 return QRectF(-((w-50)/2 - 1), -30, w - 3, 79 + 40); | 45 return QRectF(-((w-50)/2 - 1), -30, w - 3, 79 + 40); |
46 } | |
47 | |
48 void | |
49 UncommittedItem::mousePressEvent(QGraphicsSceneMouseEvent *e) | |
50 { | |
51 DEBUG << "UncommittedItem::mousePressEvent" << endl; | |
52 if (e->button() == Qt::RightButton) { | |
53 activateMenu(); | |
54 } | |
55 } | |
56 | |
57 void | |
58 UncommittedItem::activateMenu() | |
59 { | |
60 QMenu *menu = new QMenu; | |
61 QLabel *label = new QLabel(tr("<qt><b>Uncommitted changes</b></qt>")); | |
62 QWidgetAction *wa = new QWidgetAction(menu); | |
63 wa->setDefaultWidget(label); | |
64 menu->addAction(wa); | |
65 menu->addSeparator(); | |
66 | |
67 QAction *commit = menu->addAction(tr("Commit...")); | |
68 connect(commit, SIGNAL(triggered()), this, SIGNAL(commit())); | |
69 QAction *revert = menu->addAction(tr("Revert...")); | |
70 connect(revert, SIGNAL(triggered()), this, SIGNAL(revert())); | |
71 QAction *dif = menu->addAction(tr("Diff")); | |
72 connect(dif, SIGNAL(triggered()), this, SIGNAL(diff())); | |
73 | |
74 menu->exec(QCursor::pos()); | |
75 | |
76 ungrabMouse(); | |
41 } | 77 } |
42 | 78 |
43 void | 79 void |
44 UncommittedItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *option, | 80 UncommittedItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *option, |
45 QWidget *w) | 81 QWidget *w) |