@@ -67,6 +67,9 @@ ImageFrame::ImageFrame(QWidget *parent): QFrame(parent) {
67
67
connect (image_view, SIGNAL (skipChanged (int ,bool )), image_grid, SLOT (setSkipped (int ,bool )));
68
68
connect (image_view, SIGNAL (skipChanged (int ,bool )), image_list, SLOT (setSkipped (int ,bool )));
69
69
70
+ connect (qRelightApp->action (" rotate_left" ), SIGNAL (triggered (bool )), this , SLOT (rotateLeft ()));
71
+ connect (qRelightApp->action (" rotate_right" ), SIGNAL (triggered (bool )), this , SLOT (rotateRight ()));
72
+
70
73
connect (qRelightApp->action (" zoom_fit" ), SIGNAL (triggered (bool )), image_view, SLOT (fit ()));
71
74
connect (qRelightApp->action (" zoom_one" ), SIGNAL (triggered (bool )), image_view, SLOT (one ()));
72
75
connect (qRelightApp->action (" zoom_in" ), SIGNAL (triggered (bool )), image_view, SLOT (zoomIn ()));
@@ -110,6 +113,40 @@ int ImageFrame::currentImage() {
110
113
return image_list->currentRow ();
111
114
}
112
115
116
+ void ImageFrame::rotateLeft () {
117
+ QList<QListWidgetItem*> selectedItems = image_list->selectedItems ();
118
+ for (QListWidgetItem *item: selectedItems) {
119
+ int id = item->data (Qt::UserRole).toInt ();
120
+ rotateImage (id, false );
121
+ }
122
+ showImage (image_list->currentRow ());
123
+ }
124
+
125
+ void ImageFrame::rotateRight () {
126
+ QList<QListWidgetItem*> selectedItems = image_list->selectedItems ();
127
+ for (QListWidgetItem *item: selectedItems) {
128
+ int id = item->data (Qt::UserRole).toInt ();
129
+ rotateImage (id, true );
130
+ }
131
+ showImage (image_list->currentRow ());
132
+ }
133
+
134
+ void ImageFrame::rotateImage (int id, bool clockwise) {
135
+ QTransform rotate;
136
+ rotate.rotate (clockwise ? 90 : -90 );
137
+
138
+ Project &project = qRelightApp->project ();
139
+
140
+ assert (id >= 0 && id < project.images .size ());
141
+
142
+ Image &image = project.images [id];
143
+ QImage source (image.filename );
144
+ QImage rotated = source.transformed (rotate);
145
+ rotated.save (image.filename , " jpg" , 100 );
146
+ // thumbs needs to be rotated!!!
147
+ qRelightApp->loadThumbnails ();
148
+ }
149
+
113
150
void ImageFrame::showImage (int id) {
114
151
115
152
Project &project = qRelightApp->project ();
0 commit comments