Changeset View
Changeset View
Standalone View
Standalone View
src/ksaneviewer.cpp
Show All 23 Lines | |||||
24 | * You should have received a copy of the GNU Lesser General Public | 24 | * You should have received a copy of the GNU Lesser General Public | ||
25 | * License along with this program. If not, see <http://www.gnu.org/licenses/>. | 25 | * License along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
26 | * | 26 | * | ||
27 | * ============================================================ */ | 27 | * ============================================================ */ | ||
28 | 28 | | |||
29 | #include "ksaneviewer.h" | 29 | #include "ksaneviewer.h" | ||
30 | 30 | | |||
31 | #include "selectionitem.h" | 31 | #include "selectionitem.h" | ||
32 | #include "hiderectitem.h" | ||||
32 | 33 | | |||
33 | #include <QGraphicsPixmapItem> | 34 | #include <QGraphicsPixmapItem> | ||
34 | #include <QGraphicsScene> | 35 | #include <QGraphicsScene> | ||
35 | #include <QGraphicsRectItem> | 36 | #include <QGraphicsRectItem> | ||
36 | #include <QWheelEvent> | 37 | #include <QWheelEvent> | ||
37 | #include <QScrollBar> | 38 | #include <QScrollBar> | ||
38 | #include <QAction> | 39 | #include <QAction> | ||
39 | #include <QList> | 40 | #include <QList> | ||
Show All 20 Lines | 51 | struct KSaneViewer::Private { | |||
60 | int m_left_last_y; | 61 | int m_left_last_y; | ||
61 | 62 | | |||
62 | QAction *zoomInAction; | 63 | QAction *zoomInAction; | ||
63 | QAction *zoomOutAction; | 64 | QAction *zoomOutAction; | ||
64 | QAction *zoomSelAction; | 65 | QAction *zoomSelAction; | ||
65 | QAction *zoom2FitAction; | 66 | QAction *zoom2FitAction; | ||
66 | QAction *clrSelAction; | 67 | QAction *clrSelAction; | ||
67 | 68 | | |||
68 | QGraphicsRectItem *hideLeft; | 69 | HideRectItem *hideLeft; | ||
69 | QGraphicsRectItem *hideRight; | 70 | HideRectItem *hideRight; | ||
70 | QGraphicsRectItem *hideTop; | 71 | HideRectItem *hideTop; | ||
71 | QGraphicsRectItem *hideBottom; | 72 | HideRectItem *hideBottom; | ||
72 | QGraphicsRectItem *hideArea; | 73 | HideRectItem *hideArea; | ||
73 | 74 | | |||
74 | int wheelDelta = 0; | 75 | int wheelDelta = 0; | ||
75 | }; | 76 | }; | ||
76 | 77 | | |||
77 | KSaneViewer::KSaneViewer(QImage *img, QWidget *parent) : QGraphicsView(parent), d(new Private) | 78 | KSaneViewer::KSaneViewer(QImage *img, QWidget *parent) : QGraphicsView(parent), d(new Private) | ||
78 | { | 79 | { | ||
79 | d->img = img; | 80 | d->img = img; | ||
80 | 81 | | |||
Show All 9 Lines | |||||
90 | d->selection = new SelectionItem(QRectF()); | 91 | d->selection = new SelectionItem(QRectF()); | ||
91 | d->selection->setZValue(10); | 92 | d->selection->setZValue(10); | ||
92 | d->selection->setSaved(false); | 93 | d->selection->setSaved(false); | ||
93 | d->selection->setMaxRight(img->width()); | 94 | d->selection->setMaxRight(img->width()); | ||
94 | d->selection->setMaxBottom(img->height()); | 95 | d->selection->setMaxBottom(img->height()); | ||
95 | d->selection->setRect(d->scene->sceneRect()); | 96 | d->selection->setRect(d->scene->sceneRect()); | ||
96 | d->selection->setVisible(false); | 97 | d->selection->setVisible(false); | ||
97 | 98 | | |||
98 | d->hideTop = new QGraphicsRectItem; | 99 | d->hideTop = new HideRectItem; | ||
99 | d->hideBottom = new QGraphicsRectItem; | 100 | d->hideBottom = new HideRectItem; | ||
100 | d->hideRight = new QGraphicsRectItem; | 101 | d->hideRight = new HideRectItem; | ||
101 | d->hideLeft = new QGraphicsRectItem; | 102 | d->hideLeft = new HideRectItem; | ||
102 | d->hideArea = new QGraphicsRectItem; | 103 | d->hideArea = new HideRectItem; | ||
103 | | ||||
104 | d->hideTop->setOpacity(0.4); | | |||
105 | d->hideBottom->setOpacity(0.4); | | |||
106 | d->hideRight->setOpacity(0.4); | | |||
107 | d->hideLeft->setOpacity(0.4); | | |||
108 | d->hideArea->setOpacity(0.6); | 104 | d->hideArea->setOpacity(0.6); | ||
109 | 105 | | |||
110 | d->hideTop->setPen(Qt::NoPen); | | |||
111 | d->hideBottom->setPen(Qt::NoPen); | | |||
112 | d->hideRight->setPen(Qt::NoPen); | | |||
113 | d->hideLeft->setPen(Qt::NoPen); | | |||
114 | d->hideArea->setPen(Qt::NoPen); | | |||
115 | | ||||
116 | d->hideTop->setBrush(QBrush(Qt::black)); | | |||
117 | d->hideBottom->setBrush(QBrush(Qt::black)); | | |||
118 | d->hideRight->setBrush(QBrush(Qt::black)); | | |||
119 | d->hideLeft->setBrush(QBrush(Qt::black)); | | |||
120 | | ||||
121 | d->scene->addItem(d->selection); | 106 | d->scene->addItem(d->selection); | ||
122 | d->scene->addItem(d->hideLeft); | 107 | d->scene->addItem(d->hideLeft); | ||
123 | d->scene->addItem(d->hideRight); | 108 | d->scene->addItem(d->hideRight); | ||
124 | d->scene->addItem(d->hideTop); | 109 | d->scene->addItem(d->hideTop); | ||
125 | d->scene->addItem(d->hideBottom); | 110 | d->scene->addItem(d->hideBottom); | ||
126 | d->scene->addItem(d->hideArea); | 111 | d->scene->addItem(d->hideArea); | ||
127 | 112 | | |||
128 | d->change = SelectionItem::None; | 113 | d->change = SelectionItem::None; | ||
▲ Show 20 Lines • Show All 1032 Lines • Show Last 20 Lines |