1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 #include "imageinfodialog.h"
8
9 #include <QPixmap>
10 #include <QSpacerItem>
11 #include <QGridLayout>
12 #include <QHBoxLayout>
13 #include <QVBoxLayout>
14 #include <QLabel>
15 #include <QGroupBox>
16 #include <QPushButton>
17 #include "commonstrings.h"
18 #include "iconmanager.h"
19
ImageInfoDialog(QWidget * parent,ImageInfoRecord * info)20 ImageInfoDialog::ImageInfoDialog( QWidget* parent, ImageInfoRecord *info ) : QDialog( parent )
21 {
22 setModal(true);
23 setWindowTitle( tr( "Image Info" ) );
24 setWindowIcon(IconManager::instance().loadIcon("AppIcon.png"));
25
26 ImageInfoDialogLayout = new QVBoxLayout( this );
27 ImageInfoDialogLayout->setContentsMargins(9, 9, 9, 9);
28 ImageInfoDialogLayout->setSpacing(6);
29 GenGroup = new QGroupBox(this);
30 GenGroup->setTitle( tr("General Info"));
31 layout3 = new QGridLayout(GenGroup);
32 layout3->setContentsMargins(9, 9, 9, 9);
33 layout3->setSpacing(6);
34 Text0g = new QLabel( tr( "Date / Time:" ), GenGroup);
35 layout3->addWidget( Text0g, 0, 0 );
36 timeInfo = new QLabel( info->exifInfo.dateTime, GenGroup);
37 layout3->addWidget( timeInfo, 0, 1 );
38 Text1g = new QLabel( tr( "Has Embedded Profile:" ), GenGroup);
39 layout3->addWidget( Text1g, 1, 0 );
40 emProfile = new QLabel( "", GenGroup);
41 layout3->addWidget( emProfile, 1, 1 );
42 if (info->isEmbedded)
43 emProfile->setText(CommonStrings::trYes);
44 else
45 emProfile->setText(CommonStrings::trNo);
46 Text2g = new QLabel( tr( "Profile Name:" ), GenGroup);
47 layout3->addWidget( Text2g, 2, 0 );
48 emProfileN = new QLabel( info->profileName, GenGroup);
49 layout3->addWidget( emProfileN, 2, 1 );
50 Text3g = new QLabel( tr( "Has Embedded Paths:" ), GenGroup);
51 layout3->addWidget( Text3g, 3, 0 );
52 emPath = new QLabel( "", GenGroup );
53 layout3->addWidget( emPath, 3, 1 );
54 if (info->PDSpathData.count() != 0)
55 emPath->setText(CommonStrings::trYes);
56 else
57 emPath->setText(CommonStrings::trNo);
58 Text4g = new QLabel( tr( "Has Layers:" ), GenGroup);
59 layout3->addWidget( Text4g, 4, 0 );
60 emLayer = new QLabel( "", GenGroup);
61 layout3->addWidget( emLayer, 4, 1 );
62 if (info->layerInfo.count() != 0)
63 emLayer->setText(CommonStrings::trYes);
64 else
65 emLayer->setText(CommonStrings::trNo);
66 ImageInfoDialogLayout->addWidget(GenGroup);
67
68 ExGroup = new QGroupBox(this);
69 ExGroup->setTitle( tr("EXIF Info"));
70 layout2 = new QGridLayout(ExGroup);
71 layout2->setContentsMargins(9, 9, 9, 9);
72 layout2->setSpacing(6);
73 Text1 = new QLabel( "", ExGroup);
74 layout2->addWidget( Text1, 0, 0 );
75 Comment = new QLabel(info->exifInfo.comment, ExGroup);
76 layout2->addWidget( Comment, 0, 1 );
77 Text4 = new QLabel( "", ExGroup);
78 layout2->addWidget( Text4, 1, 0 );
79 UserComment = new QLabel(info->exifInfo.userComment, ExGroup);
80 layout2->addWidget( UserComment, 1, 1 );
81 int a = 2;
82 Artist = Text5 = nullptr;
83 if (info->type == 1)
84 {
85 Text5 = new QLabel( tr("Artist:"), ExGroup);
86 layout2->addWidget( Text5, 2, 0 );
87 Artist = new QLabel(info->exifInfo.artist, ExGroup);
88 layout2->addWidget( Artist, 2, 1 );
89 a = 3;
90 }
91 Text2 = new QLabel( "", ExGroup);
92 layout2->addWidget( Text2, a, 0 );
93 Model = new QLabel(info->exifInfo.cameraName, ExGroup);
94 layout2->addWidget( Model, a, 1 );
95 Text3 = new QLabel( "", ExGroup);
96 layout2->addWidget( Text3, a+1, 0 );
97 Manufact = new QLabel(info->exifInfo.cameraVendor, ExGroup);
98 layout2->addWidget( Manufact, a+1, 1 );
99
100 Text6 = new QLabel( "", ExGroup);
101 layout2->addWidget( Text6, a+2, 0 );
102 QString tag = "";
103 if (info->exifInfo.ExposureTime != 0)
104 {
105 float exposureTime = info->exifInfo.ExposureTime;
106 tag = QString::asprintf("%6.3f", exposureTime);
107 if ((exposureTime > 0.0) && (exposureTime <= 0.5))
108 tag += QString::asprintf(" (1/%d)", (int)(0.5 + 1/exposureTime) );
109 }
110 Text7 = Text8 = nullptr;
111 ExposureTime = nullptr;
112 ApertureFNumber= nullptr;
113 ISOequivalent = nullptr;
114 if (info->type == 0)
115 {
116 ExposureTime = new QLabel(tag, ExGroup);
117 layout2->addWidget( ExposureTime, a+2, 1 );
118 Text7 = new QLabel( "", ExGroup);
119 layout2->addWidget( Text7, a+3, 0 );
120 ApertureFNumber = new QLabel(QString::asprintf("f/%3.1f", info->exifInfo.ApertureFNumber), ExGroup);
121 layout2->addWidget( ApertureFNumber, a+3, 1 );
122 Text8 = new QLabel( "", ExGroup);
123 layout2->addWidget( Text8, a+4, 0 );
124 ISOequivalent = new QLabel(QString::asprintf("%2d", info->exifInfo.ISOequivalent), ExGroup);
125 layout2->addWidget( ISOequivalent, a+4, 1 );
126 }
127 ImageInfoDialogLayout->addWidget(ExGroup);
128 switch (info->type)
129 {
130 case 0:
131 Text1->setText( tr( "Comment:" ));
132 Text4->setText( tr( "User Comment:" ));
133 Text2->setText( tr( "Camera Model:" ));
134 Text3->setText( tr( "Camera Manufacturer:" ));
135 Text6->setText( tr( "Exposure time" ));
136 Text7->setText( tr( "Aperture:" ));
137 Text8->setText( tr( "ISO equiv.:" ));
138 break;
139 case 1:
140 Text1->setText( tr( "Description:" ));
141 Text4->setText( tr( "Copyright:" ));
142 Text2->setText( tr( "Scanner Model:" ));
143 Text3->setText( tr( "Scanner Manufacturer:" ));
144 break;
145 default:
146 ExGroup->hide();
147 break;
148 }
149 layout1 = new QHBoxLayout;
150 layout1->setContentsMargins(0, 0, 0, 0);
151 layout1->setSpacing(6);
152 QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
153 layout1->addItem( spacer );
154 okButton = new QPushButton( CommonStrings::tr_OK, this);
155 okButton->setDefault( true );
156 layout1->addWidget( okButton );
157 ImageInfoDialogLayout->addLayout( layout1 );
158 resize(minimumSizeHint());
159
160 // signals and slots connections
161 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
162 }
163