13
13
#include < iostream>
14
14
using namespace std ;
15
15
16
- ImageThumb::ImageThumb (QImage img, const QString& text, bool skip, QWidget* parent): QWidget(parent) {
16
+ ImageThumb::ImageThumb (QImage img, const QString& text, bool skip, bool visible, QWidget* parent): QWidget(parent) {
17
17
18
18
QVBoxLayout* layout = new QVBoxLayout (this );
19
+ {
20
+ QLabel *label = new QLabel;
21
+ label->setPixmap (QPixmap::fromImage (img));
22
+ layout->addWidget (label);
23
+ }
24
+ {
25
+ QHBoxLayout *checkline = new QHBoxLayout;
26
+ layout->addLayout (checkline);
27
+ {
28
+ skipbox = new QCheckBox (text);
29
+ skipbox->setChecked (!skip);
30
+ connect (skipbox, SIGNAL (stateChanged (int )), this , SIGNAL (skipChanged (int )));
31
+ checkline->addWidget (skipbox);
32
+ }
33
+ {
34
+ visibleicon = new QLabel ();
35
+ visibleicon->setPixmap (QIcon::fromTheme (visible ?" eye" :" eye-off" ).pixmap (20 , 20 ));
36
+ checkline->addWidget (visibleicon);
37
+
38
+ }
19
39
20
- QLabel *label = new QLabel;
21
- label->setPixmap (QPixmap::fromImage (img));
22
- layout->addWidget (label);
23
-
24
- QCheckBox *checkbox = new QCheckBox (text);
25
-
26
- checkbox->setChecked (!skip);
27
- connect (checkbox, SIGNAL (stateChanged (int )), this , SIGNAL (skipChanged (int )));
28
- layout->addWidget (checkbox);
29
-
40
+ }
30
41
layout->setSpacing (5 );
31
42
layout->setContentsMargins (5 , 5 , 5 , 5 );
32
43
}
33
44
34
- void ImageThumb::setSkipped (bool skip) {
35
- findChild<QCheckBox *>()->setChecked (!skip);
45
+ void ImageThumb::setSkipped (bool skip, bool visible) {
46
+ skipbox->setChecked (!skip);
47
+ visibleicon->setPixmap (QIcon::fromTheme (visible ?" eye" :" eye-off" ).pixmap (20 , 20 ));
48
+
36
49
}
37
50
38
51
void ImageThumb::setThumbnail (QImage thumb) {
@@ -63,7 +76,7 @@ void ImageGrid::init() {
63
76
QImage thumbnail = thumbnails[i];
64
77
Image &image = project.images [i];
65
78
QFileInfo info (image.filename );
66
- ImageThumb *thumb = new ImageThumb (thumbnail, info.fileName (), image.skip );
79
+ ImageThumb *thumb = new ImageThumb (thumbnail, info.fileName (), image.skip , image. visible );
67
80
connect (thumb, &ImageThumb::skipChanged, [this , i, &image](int state){
68
81
image.skip = (state==0 );
69
82
this ->emit skipChanged (i, image.skip );
@@ -72,9 +85,13 @@ void ImageGrid::init() {
72
85
}
73
86
}
74
87
75
- void ImageGrid::setSkipped (int image, bool skip) {
76
- ImageThumb *thumb = dynamic_cast <ImageThumb *>(flowlayout->itemAt (image)->widget ());
77
- thumb->setSkipped (skip);
88
+ void ImageGrid::setSkipped (int img_number, bool skip) {
89
+ auto &images = qRelightApp->project ().images ;
90
+ assert (img_number >= 0 && img_number < images.size ());
91
+ Image &img = images[img_number];
92
+
93
+ ImageThumb *thumb = dynamic_cast <ImageThumb *>(flowlayout->itemAt (img_number)->widget ());
94
+ thumb->setSkipped (img.skip , img.visible );
78
95
}
79
96
80
97
void ImageGrid::updateThumbnail (int pos) {
0 commit comments