forked from oferkv/phototonic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcroprubberband.cpp
60 lines (48 loc) · 2.13 KB
/
croprubberband.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Copyright (C) 2013-2014 Ofer Kashayov - [email protected]
* This file is part of Phototonic Image Viewer.
*
* Phototonic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Phototonic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Phototonic. If not, see <http://www.gnu.org/licenses/>.
*/
#include "croprubberband.h"
CropRubberBand::CropRubberBand(QWidget *parent) : QWidget(parent) {
setWindowFlags(Qt::SubWindow);
QVBoxLayout* mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout* topLayout = new QHBoxLayout();
topLayout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout* bottomLayout = new QHBoxLayout();
bottomLayout->setContentsMargins(0, 0, 0, 0);
QSizeGrip* grip1 = new QSizeGrip(this);
QSizeGrip* grip2 = new QSizeGrip(this);
QSizeGrip* grip3 = new QSizeGrip(this);
QSizeGrip* grip4 = new QSizeGrip(this);
grip1->setStyleSheet("background-color: rgba(0, 0, 0, 0%)");
grip2->setStyleSheet("background-color: rgba(0, 0, 0, 0%)");
grip3->setStyleSheet("background-color: rgba(0, 0, 0, 0%)");
grip4->setStyleSheet("background-color: rgba(0, 0, 0, 0%)");
topLayout->addWidget(grip1, 0, Qt::AlignTop | Qt::AlignLeft);
topLayout->addWidget(grip2, 1, Qt::AlignTop | Qt::AlignRight);
bottomLayout->addWidget(grip3, 0, Qt::AlignBottom | Qt::AlignLeft);
bottomLayout->addWidget(grip4, 1, Qt::AlignBottom | Qt::AlignRight);
mainLayout->addLayout(topLayout);
mainLayout->addLayout(bottomLayout);
rubberband = new QRubberBand(QRubberBand::Rectangle, this);
rubberband->setStyleSheet("background-color: rgb(255, 255, 255)");
rubberband->show();
}
void CropRubberBand::resizeEvent(QResizeEvent *)
{
rubberband->resize(size());
}