4
4
from typing import Sequence , Union
5
5
6
6
import rawpy
7
- from PySide6 .QtCore import QFile , QIODevice , Qt , QDir , QFileInfo
7
+ from PySide6 .QtCore import QFile , QIODevice , Qt , QDir , QFileInfo , QModelIndex
8
8
from PySide6 .QtGui import QPixmap , QScreen , QIcon
9
9
from PySide6 .QtUiTools import QUiLoader
10
10
from PySide6 .QtWidgets import QApplication , QLabel , QGraphicsScene , QFileDialog , QFileSystemModel , QListView , \
@@ -96,13 +96,29 @@ def __init__(self, data_root_path: Path):
96
96
print (loader .errorString ())
97
97
sys .exit (- 1 )
98
98
99
+ self .window .thumbnail_list_view .clicked .connect (self .on_file_selected )
100
+
99
101
self .window .show ()
100
102
101
103
def browse_directory (self ):
102
104
path = QFileDialog .getExistingDirectory (self .window , 'Select dataset directory' , str (self .data_root_path ),
103
105
options = QFileDialog .Option .ShowDirsOnly )
104
106
self .set_data_root_path (path )
105
107
108
+ def on_file_selected (self , index : QModelIndex ):
109
+ file_name = index .data ()
110
+ file_path = Path (self .data_root_path , file_name )
111
+
112
+ thumb = get_raw_thumbnail (file_path )
113
+ thumb_pixmap = QPixmap ()
114
+ thumb_pixmap .loadFromData (thumb .data )
115
+
116
+ image_label = QLabel ()
117
+ image_label .setPixmap (thumb_pixmap )
118
+ scene = QGraphicsScene ()
119
+ scene .addWidget (image_label )
120
+ self .window .photo_view .setScene (scene )
121
+
106
122
def set_data_root_path (self , path : str ):
107
123
self .window .path_edit .setText (path )
108
124
self .data_root_path = Path (path )
@@ -123,16 +139,6 @@ def load_images(self):
123
139
self .window .thumbnail_list_view .setModel (model )
124
140
self .window .thumbnail_list_view .setRootIndex (model .index (str (self .data_root_path )))
125
141
126
- thumb = get_raw_thumbnail (image_file_paths [0 ])
127
- thumb_pixmap = QPixmap ()
128
- thumb_pixmap .loadFromData (thumb .data )
129
-
130
- image_label = QLabel ()
131
- image_label .setPixmap (thumb_pixmap )
132
- scene = QGraphicsScene ()
133
- scene .addWidget (image_label )
134
- self .window .photo_view .setScene (scene )
135
-
136
142
137
143
def main ():
138
144
args = get_parsed_args ()
0 commit comments