@@ -21,89 +21,89 @@ StyledRect {
2121 signal itemSelected (int index, string path, string name, bool isDir)
2222
2323 function getFileExtension (fileName ) {
24- const parts = fileName .split (' .' )
24+ const parts = fileName .split (' .' );
2525 if (parts .length > 1 ) {
26- return parts[parts .length - 1 ].toLowerCase ()
26+ return parts[parts .length - 1 ].toLowerCase ();
2727 }
28- return " "
28+ return " " ;
2929 }
3030
3131 function determineFileType (fileName ) {
32- const ext = getFileExtension (fileName)
32+ const ext = getFileExtension (fileName);
3333
34- const imageExts = [" png" , " jpg" , " jpeg" , " gif" , " bmp" , " webp" , " svg" , " ico" ]
34+ const imageExts = [" png" , " jpg" , " jpeg" , " gif" , " bmp" , " webp" , " svg" , " ico" ];
3535 if (imageExts .includes (ext)) {
36- return " image"
36+ return " image" ;
3737 }
3838
39- const videoExts = [" mp4" , " mkv" , " avi" , " mov" , " webm" , " flv" , " wmv" , " m4v" ]
39+ const videoExts = [" mp4" , " mkv" , " avi" , " mov" , " webm" , " flv" , " wmv" , " m4v" ];
4040 if (videoExts .includes (ext)) {
41- return " video"
41+ return " video" ;
4242 }
4343
44- const audioExts = [" mp3" , " wav" , " flac" , " ogg" , " m4a" , " aac" , " wma" ]
44+ const audioExts = [" mp3" , " wav" , " flac" , " ogg" , " m4a" , " aac" , " wma" ];
4545 if (audioExts .includes (ext)) {
46- return " audio"
46+ return " audio" ;
4747 }
4848
49- const codeExts = [" js" , " ts" , " jsx" , " tsx" , " py" , " go" , " rs" , " c" , " cpp" , " h" , " java" , " kt" , " swift" , " rb" , " php" , " html" , " css" , " scss" , " json" , " xml" , " yaml" , " yml" , " toml" , " sh" , " bash" , " zsh" , " fish" , " qml" , " vue" , " svelte" ]
49+ const codeExts = [" js" , " ts" , " jsx" , " tsx" , " py" , " go" , " rs" , " c" , " cpp" , " h" , " java" , " kt" , " swift" , " rb" , " php" , " html" , " css" , " scss" , " json" , " xml" , " yaml" , " yml" , " toml" , " sh" , " bash" , " zsh" , " fish" , " qml" , " vue" , " svelte" ];
5050 if (codeExts .includes (ext)) {
51- return " code"
51+ return " code" ;
5252 }
5353
54- const docExts = [" txt" , " md" , " pdf" , " doc" , " docx" , " odt" , " rtf" ]
54+ const docExts = [" txt" , " md" , " pdf" , " doc" , " docx" , " odt" , " rtf" ];
5555 if (docExts .includes (ext)) {
56- return " document"
56+ return " document" ;
5757 }
5858
59- const archiveExts = [" zip" , " tar" , " gz" , " bz2" , " xz" , " 7z" , " rar" ]
59+ const archiveExts = [" zip" , " tar" , " gz" , " bz2" , " xz" , " 7z" , " rar" ];
6060 if (archiveExts .includes (ext)) {
61- return " archive"
61+ return " archive" ;
6262 }
6363
6464 if (! ext || fileName .indexOf (' .' ) === - 1 ) {
65- return " binary"
65+ return " binary" ;
6666 }
6767
68- return " file"
68+ return " file" ;
6969 }
7070
7171 function isImageFile (fileName ) {
7272 if (! fileName) {
73- return false
73+ return false ;
7474 }
75- return determineFileType (fileName) === " image"
75+ return determineFileType (fileName) === " image" ;
7676 }
7777
7878 function getIconForFile (fileName ) {
79- const lowerName = fileName .toLowerCase ()
79+ const lowerName = fileName .toLowerCase ();
8080 if (lowerName .startsWith (" dockerfile" )) {
81- return " docker"
81+ return " docker" ;
8282 }
83- const ext = fileName .split (' .' ).pop ()
84- return ext || " "
83+ const ext = fileName .split (' .' ).pop ();
84+ return ext || " " ;
8585 }
8686
8787 width: weMode ? 245 : iconSizes[iconSizeIndex] + 16
8888 height: weMode ? 205 : iconSizes[iconSizeIndex] + 48
8989 radius: Theme .cornerRadius
9090 color: {
9191 if (keyboardNavigationActive && delegateRoot .index === selectedIndex)
92- return Theme .surfacePressed
92+ return Theme .surfacePressed ;
9393
94- return mouseArea .containsMouse ? Theme .withAlpha (Theme .surfaceContainerHigh , Theme .popupTransparency ) : " transparent"
94+ return mouseArea .containsMouse ? Theme .withAlpha (Theme .surfaceContainerHigh , Theme .popupTransparency ) : " transparent" ;
9595 }
9696 border .color : keyboardNavigationActive && delegateRoot .index === selectedIndex ? Theme .primary : " transparent"
9797 border .width : (keyboardNavigationActive && delegateRoot .index === selectedIndex) ? 2 : 0
9898
9999 Component .onCompleted : {
100100 if (keyboardNavigationActive && delegateRoot .index === selectedIndex)
101- itemSelected (delegateRoot .index , delegateRoot .filePath , delegateRoot .fileName , delegateRoot .fileIsDir )
101+ itemSelected (delegateRoot .index , delegateRoot .filePath , delegateRoot .fileName , delegateRoot .fileIsDir );
102102 }
103103
104104 onSelectedIndexChanged: {
105105 if (keyboardNavigationActive && selectedIndex === delegateRoot .index )
106- itemSelected (delegateRoot .index , delegateRoot .filePath , delegateRoot .fileName , delegateRoot .fileIsDir )
106+ itemSelected (delegateRoot .index , delegateRoot .filePath , delegateRoot .fileName , delegateRoot .fileIsDir );
107107 }
108108
109109 Column {
@@ -121,19 +121,17 @@ StyledRect {
121121 anchors .margins : 2
122122 property var weExtensions: [" .jpg" , " .jpeg" , " .png" , " .webp" , " .gif" , " .bmp" , " .tga" ]
123123 property int weExtIndex: 0
124- source: {
125- if (weMode && delegateRoot .fileIsDir ) {
126- return " file://" + delegateRoot .filePath + " /preview" + weExtensions[weExtIndex]
127- }
128- return (! delegateRoot .fileIsDir && isImageFile (delegateRoot .fileName )) ? (" file://" + delegateRoot .filePath ) : " "
124+ imagePath: {
125+ if (weMode && delegateRoot .fileIsDir )
126+ return delegateRoot .filePath + " /preview" + weExtensions[weExtIndex];
127+ return (! delegateRoot .fileIsDir && isImageFile (delegateRoot .fileName )) ? delegateRoot .filePath : " " ;
129128 }
130129 onStatusChanged: {
131130 if (weMode && delegateRoot .fileIsDir && status === Image .Error ) {
132131 if (weExtIndex < weExtensions .length - 1 ) {
133- weExtIndex++
134- source = " file://" + delegateRoot .filePath + " /preview" + weExtensions[weExtIndex]
132+ weExtIndex++ ;
135133 } else {
136- source = " "
134+ imagePath = " " ;
137135 }
138136 }
139137 }
@@ -198,7 +196,7 @@ StyledRect {
198196 hoverEnabled: true
199197 cursorShape: Qt .PointingHandCursor
200198 onClicked: {
201- itemClicked (delegateRoot .index , delegateRoot .filePath , delegateRoot .fileName , delegateRoot .fileIsDir )
199+ itemClicked (delegateRoot .index , delegateRoot .filePath , delegateRoot .fileName , delegateRoot .fileIsDir );
202200 }
203201 }
204202}
0 commit comments