summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2025-02-10 15:10:13 +0900
committerMichele Calgaro <[email protected]>2025-02-10 15:10:13 +0900
commit203fcb8d90752b546c672c625927a136b959fcfb (patch)
treea899621e4cb63e2cdd9b94f889ee9d0ae8561bf0 /src
parent98c274834c63c7fa4a9a494fdf7cd483336714d5 (diff)
downloadksquirrel-203fcb8d90752b546c672c625927a136b959fcfb.tar.gz
ksquirrel-203fcb8d90752b546c672c625927a136b959fcfb.zip
Rename 'ksquirrel' folder to 'src'
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/CMakeL10n.txt3
-rw-r--r--src/Makefile.am102
-rw-r--r--src/dolphksquirrel-dir.desktop14
-rw-r--r--src/file_broken.xpm831
-rw-r--r--src/fmt_filters.cpp2288
-rw-r--r--src/fmt_filters.h302
-rw-r--r--src/hi16-app-ksquirrel.pngbin0 -> 669 bytes
-rw-r--r--src/hi32-app-ksquirrel.pngbin0 -> 1148 bytes
-rw-r--r--src/imageedit/Makefile.am15
-rw-r--r--src/imageedit/sq_bcglabel.cpp28
-rw-r--r--src/imageedit/sq_bcglabel.h34
-rw-r--r--src/imageedit/sq_converter.cpp444
-rw-r--r--src/imageedit/sq_converter.h120
-rw-r--r--src/imageedit/sq_imagebcg.ui989
-rw-r--r--src/imageedit/sq_imagebcg.ui.h241
-rw-r--r--src/imageedit/sq_imageconvert.ui343
-rw-r--r--src/imageedit/sq_imageconvert.ui.h214
-rw-r--r--src/imageedit/sq_imageedit.h84
-rw-r--r--src/imageedit/sq_imageeditoptions.ui226
-rw-r--r--src/imageedit/sq_imageeditoptions.ui.h52
-rw-r--r--src/imageedit/sq_imagefilter.ui1559
-rw-r--r--src/imageedit/sq_imagefilter.ui.h610
-rw-r--r--src/imageedit/sq_label.cpp78
-rw-r--r--src/imageedit/sq_label.h41
-rw-r--r--src/imageedit/sq_writeoption.ui168
-rw-r--r--src/konqksquirrel-dir.desktop14
-rw-r--r--src/ksquirrel-libs-configurator/Makefile.am16
-rw-r--r--src/ksquirrel-libs-configurator/klc.cpp115
-rw-r--r--src/ksquirrel-libs-configurator/klc.ui190
-rw-r--r--src/ksquirrel-libs-configurator/klc.ui.h161
-rwxr-xr-xsrc/ksquirrel-libs-configurator/ksquirrel-libs-configurator3
-rw-r--r--src/ksquirrel-libs-configurator/main.cpp61
-rw-r--r--src/ksquirrel.cpp2216
-rw-r--r--src/ksquirrel.desktop17
-rw-r--r--src/ksquirrel.h801
-rw-r--r--src/ksquirrelpart/Makefile.am28
-rw-r--r--src/ksquirrelpart/file_broken.xpm831
-rw-r--r--src/ksquirrelpart/fmt_filters.cpp2287
-rw-r--r--src/ksquirrelpart/fmt_filters.h302
-rw-r--r--src/ksquirrelpart/ksquirrelpart.cpp271
-rw-r--r--src/ksquirrelpart/ksquirrelpart.desktop11
-rw-r--r--src/ksquirrelpart/ksquirrelpart.h89
-rw-r--r--src/ksquirrelpart/ksquirrelpart.rc20
-rw-r--r--src/ksquirrelpart/sq_bcglabel.cpp28
-rw-r--r--src/ksquirrelpart/sq_bcglabel.h34
-rw-r--r--src/ksquirrelpart/sq_codecsettings.cpp42
-rw-r--r--src/ksquirrelpart/sq_codecsettings.h34
-rw-r--r--src/ksquirrelpart/sq_codecsettingsskeleton.ui217
-rw-r--r--src/ksquirrelpart/sq_codecsettingsskeleton.ui.h171
-rw-r--r--src/ksquirrelpart/sq_config.cpp36
-rw-r--r--src/ksquirrelpart/sq_config.h136
-rw-r--r--src/ksquirrelpart/sq_diroperator.cpp86
-rw-r--r--src/ksquirrelpart/sq_diroperator.h58
-rw-r--r--src/ksquirrelpart/sq_downloader.cpp143
-rw-r--r--src/ksquirrelpart/sq_downloader.h74
-rw-r--r--src/ksquirrelpart/sq_errorstring.cpp58
-rw-r--r--src/ksquirrelpart/sq_errorstring.h56
-rw-r--r--src/ksquirrelpart/sq_externaltool.cpp245
-rw-r--r--src/ksquirrelpart/sq_externaltool.h104
-rw-r--r--src/ksquirrelpart/sq_filedialog.cpp44
-rw-r--r--src/ksquirrelpart/sq_filedialog.h39
-rw-r--r--src/ksquirrelpart/sq_glparts.cpp219
-rw-r--r--src/ksquirrelpart/sq_glparts.h152
-rw-r--r--src/ksquirrelpart/sq_glselectionpainter.cpp145
-rw-r--r--src/ksquirrelpart/sq_glselectionpainter.h151
-rw-r--r--src/ksquirrelpart/sq_glu.cpp110
-rw-r--r--src/ksquirrelpart/sq_glu.h50
-rw-r--r--src/ksquirrelpart/sq_glview.cpp114
-rw-r--r--src/ksquirrelpart/sq_glview.h83
-rw-r--r--src/ksquirrelpart/sq_glwidget.cpp2006
-rw-r--r--src/ksquirrelpart/sq_glwidget.h620
-rw-r--r--src/ksquirrelpart/sq_glwidget_helpers.cpp264
-rw-r--r--src/ksquirrelpart/sq_glwidget_helpers.h74
-rw-r--r--src/ksquirrelpart/sq_glwidget_stuff.cpp1782
-rw-r--r--src/ksquirrelpart/sq_helpwidget.ui334
-rw-r--r--src/ksquirrelpart/sq_helpwidget.ui.h45
-rw-r--r--src/ksquirrelpart/sq_iconloader.cpp82
-rw-r--r--src/ksquirrelpart/sq_iconloader.h58
-rw-r--r--src/ksquirrelpart/sq_iconloader_pixmaps.h2557
-rw-r--r--src/ksquirrelpart/sq_imagebcg.ui989
-rw-r--r--src/ksquirrelpart/sq_imagebcg.ui.h241
-rw-r--r--src/ksquirrelpart/sq_imageedit.h84
-rw-r--r--src/ksquirrelpart/sq_imagefilter.ui1559
-rw-r--r--src/ksquirrelpart/sq_imagefilter.ui.h610
-rw-r--r--src/ksquirrelpart/sq_imageproperties.ui969
-rw-r--r--src/ksquirrelpart/sq_imageproperties.ui.h264
-rw-r--r--src/ksquirrelpart/sq_label.cpp78
-rw-r--r--src/ksquirrelpart/sq_label.h41
-rw-r--r--src/ksquirrelpart/sq_library.h97
-rw-r--r--src/ksquirrelpart/sq_libraryhandler.cpp582
-rw-r--r--src/ksquirrelpart/sq_libraryhandler.h128
-rw-r--r--src/ksquirrelpart/sq_popupmenu.cpp39
-rw-r--r--src/ksquirrelpart/sq_popupmenu.h40
-rw-r--r--src/ksquirrelpart/sq_utils.cpp188
-rw-r--r--src/ksquirrelpart/sq_utils.h63
-rw-r--r--src/ksquirrelpart/sq_utils_asm_scale.S810
-rw-r--r--src/ksquirrelpart/sq_utils_scale.cpp1933
-rw-r--r--src/main.cpp186
-rw-r--r--src/mime/Makefile.am115
-rw-r--r--src/mime/ljpeg.desktop7
-rw-r--r--src/mime/x-avs.desktop7
-rw-r--r--src/mime/x-cut.desktop7
-rw-r--r--src/mime/x-dicom.desktop7
-rw-r--r--src/mime/x-dxf.desktop7
-rw-r--r--src/mime/x-iff.desktop7
-rw-r--r--src/mime/x-jbig.desktop7
-rw-r--r--src/mime/x-koala.desktop7
-rw-r--r--src/mime/x-leaf.desktop7
-rw-r--r--src/mime/x-lif.desktop7
-rw-r--r--src/mime/x-mac.desktop7
-rw-r--r--src/mime/x-mdl.desktop7
-rw-r--r--src/mime/x-msp.desktop7
-rw-r--r--src/mime/x-mtv.desktop7
-rw-r--r--src/mime/x-neo.desktop7
-rw-r--r--src/mime/x-pi1.desktop7
-rw-r--r--src/mime/x-pi3.desktop7
-rw-r--r--src/mime/x-pict.desktop7
-rw-r--r--src/mime/x-pix.desktop7
-rw-r--r--src/mime/x-psp.desktop8
-rw-r--r--src/mime/x-pxr.desktop7
-rw-r--r--src/mime/x-ras.desktop7
-rw-r--r--src/mime/x-ras.magic1
-rw-r--r--src/mime/x-rawrgb.desktop7
-rw-r--r--src/mime/x-sct.desktop7
-rw-r--r--src/mime/x-sun.desktop7
-rw-r--r--src/mime/x-sun.magic1
-rw-r--r--src/mime/x-utah.desktop7
-rw-r--r--src/mime/x-utah.magic1
-rw-r--r--src/mime/x-wal.desktop7
-rw-r--r--src/mime/x-wbmp.desktop7
-rw-r--r--src/mime/x-xim.desktop7
-rw-r--r--src/mime/x-xwd.desktop7
-rw-r--r--src/sidebar/Makefile.am15
-rw-r--r--src/sidebar/sq_categoriesview.cpp318
-rw-r--r--src/sidebar/sq_categoriesview.h131
-rw-r--r--src/sidebar/sq_categorybrowsermenu.cpp521
-rw-r--r--src/sidebar/sq_categorybrowsermenu.h83
-rw-r--r--src/sidebar/sq_directorybasket.cpp520
-rw-r--r--src/sidebar/sq_directorybasket.h195
-rw-r--r--src/sidebar/sq_imagebasket.cpp291
-rw-r--r--src/sidebar/sq_imagebasket.h62
-rw-r--r--src/sidebar/sq_mountview.cpp247
-rw-r--r--src/sidebar/sq_mountview.h84
-rw-r--r--src/sidebar/sq_mountviewitem.cpp44
-rw-r--r--src/sidebar/sq_mountviewitem.h58
-rw-r--r--src/sidebar/sq_multibar.cpp133
-rw-r--r--src/sidebar/sq_multibar.h111
-rw-r--r--src/sidebar/sq_previewwidget.cpp364
-rw-r--r--src/sidebar/sq_previewwidget.h132
-rw-r--r--src/sidebar/sq_storagefile.cpp79
-rw-r--r--src/sidebar/sq_storagefile.h34
-rw-r--r--src/sidebar/sq_threaddirlister.cpp145
-rw-r--r--src/sidebar/sq_threaddirlister.h153
-rw-r--r--src/sidebar/sq_treeview.cpp678
-rw-r--r--src/sidebar/sq_treeview.h174
-rw-r--r--src/sidebar/sq_treeviewitem.cpp107
-rw-r--r--src/sidebar/sq_treeviewitem.h85
-rw-r--r--src/sidebar/sq_treeviewmenu.cpp196
-rw-r--r--src/sidebar/sq_treeviewmenu.h59
-rw-r--r--src/sq_archivehandler.cpp114
-rw-r--r--src/sq_archivehandler.h67
-rw-r--r--src/sq_bookmarkowner.cpp62
-rw-r--r--src/sq_bookmarkowner.h75
-rw-r--r--src/sq_codecsettings.cpp42
-rw-r--r--src/sq_codecsettings.h34
-rw-r--r--src/sq_codecsettingsskeleton.ui217
-rw-r--r--src/sq_codecsettingsskeleton.ui.h171
-rw-r--r--src/sq_config.cpp36
-rw-r--r--src/sq_config.h136
-rw-r--r--src/sq_dir.cpp92
-rw-r--r--src/sq_dir.h104
-rw-r--r--src/sq_diroperator.cpp1074
-rw-r--r--src/sq_diroperator.h292
-rw-r--r--src/sq_dirthumbs.cpp104
-rw-r--r--src/sq_dirthumbs.h70
-rw-r--r--src/sq_downloader.cpp143
-rw-r--r--src/sq_downloader.h74
-rw-r--r--src/sq_dragprovider.cpp183
-rw-r--r--src/sq_dragprovider.h62
-rw-r--r--src/sq_errorstring.cpp58
-rw-r--r--src/sq_errorstring.h56
-rw-r--r--src/sq_externaltool.cpp245
-rw-r--r--src/sq_externaltool.h104
-rw-r--r--src/sq_externaltools.ui463
-rw-r--r--src/sq_externaltools.ui.h145
-rw-r--r--src/sq_filedetailview.cpp228
-rw-r--r--src/sq_filedetailview.h119
-rw-r--r--src/sq_filedialog.cpp44
-rw-r--r--src/sq_filedialog.h39
-rw-r--r--src/sq_fileiconview.cpp143
-rw-r--r--src/sq_fileiconview.h90
-rw-r--r--src/sq_fileiconviewbase.cpp156
-rw-r--r--src/sq_fileiconviewbase.h88
-rw-r--r--src/sq_filethumbview.cpp549
-rw-r--r--src/sq_filethumbview.h215
-rw-r--r--src/sq_filethumbviewitem.cpp67
-rw-r--r--src/sq_filethumbviewitem.h64
-rw-r--r--src/sq_filters.ui413
-rw-r--r--src/sq_filters.ui.h138
-rw-r--r--src/sq_glinfo.ui165
-rw-r--r--src/sq_glinfo.ui.h38
-rw-r--r--src/sq_glparts.cpp219
-rw-r--r--src/sq_glparts.h152
-rw-r--r--src/sq_glselectionpainter.cpp145
-rw-r--r--src/sq_glselectionpainter.h151
-rw-r--r--src/sq_glu.cpp110
-rw-r--r--src/sq_glu.h50
-rw-r--r--src/sq_glview.cpp360
-rw-r--r--src/sq_glview.h202
-rw-r--r--src/sq_glwidget.cpp2006
-rw-r--r--src/sq_glwidget.h620
-rw-r--r--src/sq_glwidget_helpers.cpp264
-rw-r--r--src/sq_glwidget_helpers.h74
-rw-r--r--src/sq_glwidget_stuff.cpp1782
-rw-r--r--src/sq_helpwidget.ui334
-rw-r--r--src/sq_helpwidget.ui.h45
-rw-r--r--src/sq_hloptions.cpp37
-rw-r--r--src/sq_hloptions.h47
-rw-r--r--src/sq_iconlistbox.cpp77
-rw-r--r--src/sq_iconlistbox.h46
-rw-r--r--src/sq_iconlistitem.cpp105
-rw-r--r--src/sq_iconlistitem.h53
-rw-r--r--src/sq_iconloader.cpp82
-rw-r--r--src/sq_iconloader.h58
-rw-r--r--src/sq_iconloader_pixmaps.h2557
-rw-r--r--src/sq_imageloader.cpp261
-rw-r--r--src/sq_imageloader.h108
-rw-r--r--src/sq_imageproperties.ui969
-rw-r--r--src/sq_imageproperties.ui.h264
-rw-r--r--src/sq_kipiinterface.cpp209
-rw-r--r--src/sq_kipiinterface.h66
-rw-r--r--src/sq_kipimanager.cpp189
-rw-r--r--src/sq_kipimanager.h121
-rw-r--r--src/sq_library.h97
-rw-r--r--src/sq_libraryhandler.cpp582
-rw-r--r--src/sq_libraryhandler.h128
-rw-r--r--src/sq_navigatordropmenu.cpp117
-rw-r--r--src/sq_navigatordropmenu.h91
-rw-r--r--src/sq_options.ui2108
-rw-r--r--src/sq_options.ui.h333
-rw-r--r--src/sq_pixmapcache.cpp167
-rw-r--r--src/sq_pixmapcache.h133
-rw-r--r--src/sq_pluginsinfo.ui272
-rw-r--r--src/sq_pluginsinfo.ui.h88
-rw-r--r--src/sq_popupmenu.cpp39
-rw-r--r--src/sq_popupmenu.h40
-rw-r--r--src/sq_progress.cpp137
-rw-r--r--src/sq_progress.h99
-rw-r--r--src/sq_progressbox.cpp59
-rw-r--r--src/sq_progressbox.h87
-rw-r--r--src/sq_selectdeselectgroup.ui106
-rw-r--r--src/sq_selectdeselectgroup.ui.h76
-rw-r--r--src/sq_slideshow.ui450
-rw-r--r--src/sq_slideshow.ui.h127
-rw-r--r--src/sq_slideshowlisting.ui111
-rw-r--r--src/sq_slideshowlisting.ui.h22
-rw-r--r--src/sq_slideshowwidget.cpp366
-rw-r--r--src/sq_slideshowwidget.h108
-rw-r--r--src/sq_splashscreen.cpp107
-rw-r--r--src/sq_splashscreen.h72
-rw-r--r--src/sq_tabopendialog.ui104
-rw-r--r--src/sq_tabopendialog.ui.h40
-rw-r--r--src/sq_thumbnailcachemaster.ui257
-rw-r--r--src/sq_thumbnailcachemaster.ui.h89
-rw-r--r--src/sq_thumbnailinfo.h52
-rw-r--r--src/sq_thumbnailloadjob.cpp480
-rw-r--r--src/sq_thumbnailloadjob.h102
-rw-r--r--src/sq_thumbnailsize.cpp70
-rw-r--r--src/sq_thumbnailsize.h145
-rw-r--r--src/sq_thumbnailsunused.cpp97
-rw-r--r--src/sq_thumbnailsunused.h56
-rw-r--r--src/sq_utils.cpp188
-rw-r--r--src/sq_utils.h63
-rw-r--r--src/sq_utils_asm_scale.S810
-rw-r--r--src/sq_utils_scale.cpp1933
-rw-r--r--src/sq_version1
-rw-r--r--src/sq_viewcache.ui168
-rw-r--r--src/sq_viewcache.ui.h45
-rw-r--r--src/sq_widgetstack.cpp781
-rw-r--r--src/sq_widgetstack.h251
280 files changed, 71315 insertions, 0 deletions
diff --git a/src/CMakeL10n.txt b/src/CMakeL10n.txt
new file mode 100644
index 0000000..519dbc6
--- /dev/null
+++ b/src/CMakeL10n.txt
@@ -0,0 +1,3 @@
+##### create translation templates ##############
+
+tde_l10n_create_template( "ksquirrel" )
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..21152aa
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,102 @@
+####### tdevelop will overwrite this part!!! (begin)##########
+bin_PROGRAMS = ksquirrel
+
+## INCLUDES were found outside tdevelop specific part
+
+ksquirrel_SOURCES = sq_slideshowwidget.cpp sq_slideshow.ui sq_slideshowlisting.ui fmt_filters.cpp sq_glwidget_stuff.cpp sq_tabopendialog.ui sq_dragprovider.cpp sq_utils_scale.cpp sq_utils.cpp sq_thumbnailsunused.cpp sq_dirthumbs.cpp sq_downloader.cpp sq_glselectionpainter.cpp sq_glwidget.cpp sq_glparts.cpp sq_codecsettings.cpp sq_filedialog.cpp sq_codecsettingsskeleton.ui sq_kipimanager.cpp sq_kipiinterface.cpp sq_progressbox.cpp sq_thumbnailloadjob.cpp sq_splashscreen.cpp sq_popupmenu.cpp sq_glinfo.ui sq_glwidget_helpers.cpp sq_imageloader.cpp sq_pluginsinfo.ui sq_iconloader.cpp sq_selectdeselectgroup.ui sq_thumbnailcachemaster.ui sq_errorstring.cpp sq_navigatordropmenu.cpp sq_fileiconviewbase.cpp sq_helpwidget.ui sq_glview.cpp sq_viewcache.ui sq_filethumbviewitem.cpp sq_progress.cpp sq_thumbnailsize.cpp sq_pixmapcache.cpp sq_filethumbview.cpp sq_dir.cpp sq_iconlistbox.cpp sq_iconlistitem.cpp sq_widgetstack.cpp sq_options.ui sq_libraryhandler.cpp sq_imageproperties.ui sq_hloptions.cpp sq_glu.cpp sq_filters.ui sq_fileiconview.cpp sq_filedetailview.cpp sq_externaltools.ui sq_externaltool.cpp sq_diroperator.cpp sq_config.cpp sq_bookmarkowner.cpp sq_archivehandler.cpp ksquirrel.cpp main.cpp
+ksquirrel_LDADD = ./sidebar/libsidebar.a ./imageedit/libimageedit.a $(KDE_LDFLAGS) $(QT_LDFLAGS) $(LIB_TDEPRINT) $(LIB_TDEUTILS) $(LIB_TDEIO) $(ksquirrellibs_LIBS) -lkonq $(LIB_QUI) $(LIB_TDEFILE) $(LIB_TDEUI) $(LIB_TDECORE) $(LIB_TQT) $(LIBSOCKET) -lDCOP -ltdefx
+
+SUBDIRS = sidebar imageedit mime
+
+EXTRA_DIST = main.cpp ksquirrel.cpp ksquirrel.h hi32-app-ksquirrel.png hi16-app-ksquirrel.png sq_archivehandler.cpp sq_archivehandler.h sq_bookmarkowner.cpp sq_bookmarkowner.h sq_config.cpp sq_config.h sq_diroperator.cpp sq_diroperator.h sq_externaltool.cpp sq_externaltool.h sq_externaltools.ui sq_filedetailview.cpp sq_filedetailview.h sq_fileiconview.cpp sq_fileiconview.h sq_filters.ui sq_glu.cpp sq_glu.h sq_hloptions.cpp sq_hloptions.h sq_imageproperties.ui sq_libraryhandler.cpp sq_libraryhandler.h sq_options.ui sq_widgetstack.cpp sq_widgetstack.h sq_iconlistitem.cpp sq_iconlistitem.h sq_iconlistbox.cpp sq_iconlistbox.h sq_dir.cpp sq_dir.h sq_filethumbview.cpp sq_filethumbview.h sq_pixmapcache.cpp sq_pixmapcache.h sq_thumbnailsize.cpp sq_thumbnailsize.h sq_progress.cpp sq_progress.h sq_thumbnailinfo.h sq_filethumbviewitem.cpp sq_filethumbviewitem.h sq_viewcache.ui sq_glview.cpp sq_glview.h sq_helpwidget.ui sq_fileiconviewbase.cpp sq_fileiconviewbase.h sq_navigatordropmenu.cpp sq_navigatordropmenu.h sq_errorstring.cpp sq_errorstring.h fmt_filters.h sq_thumbnailcachemaster.ui sq_glwidget_helpers.h sq_library.h sq_selectdeselectgroup.ui sq_iconloader.cpp sq_iconloader.h sq_pluginsinfo.ui sq_iconloader_pixmaps.h sq_imageloader.cpp sq_imageloader.h sq_glwidget_helpers.cpp file_broken.xpm sq_glinfo.ui sq_popupmenu.cpp sq_popupmenu.h sq_splashscreen.cpp sq_splashscreen.h sq_thumbnailloadjob.cpp sq_thumbnailloadjob.h sq_progressbox.cpp sq_progressbox.h sq_kipiinterface.cpp sq_kipiinterface.h sq_kipimanager.cpp sq_kipimanager.h sq_codecsettingsskeleton.ui sq_codecsettingsskeleton.ui.h sq_filedialog.cpp sq_filedialog.h sq_codecsettings.cpp sq_codecsettings.h sq_glparts.cpp sq_glparts.h sq_glwidget.cpp sq_glwidget.h sq_slideshowwidget.h sq_glselectionpainter.cpp sq_glselectionpainter.h sq_downloader.cpp sq_downloader.h sq_dirthumbs.cpp sq_dirthumbs.h sq_thumbnailsunused.cpp sq_thumbnailsunused.h sq_slideshowlisting.ui.h sq_utils.cpp sq_utils.h konqksquirrel-dir.desktop sq_utils_asm_scale.S sq_utils_scale.cpp sq_dragprovider.cpp sq_dragprovider.h sq_tabopendialog.ui sq_glwidget_stuff.cpp dolphksquirrel-dir.desktop fmt_filters.cpp sq_slideshowlisting.ui sq_slideshow.ui sq_slideshowwidget.cpp
+
+install-data-local:
+ $(mkinstalldirs) $(kde_icondir)/hicolor/32x32/apps/
+ $(INSTALL_DATA) $(srcdir)/hi32-app-ksquirrel.png $(kde_icondir)/hicolor/32x32/apps/ksquirrel.png
+ $(mkinstalldirs) $(kde_icondir)/hicolor/16x16/apps/
+ $(INSTALL_DATA) $(srcdir)/hi16-app-ksquirrel.png $(kde_icondir)/hicolor/16x16/apps/ksquirrel.png
+ $(mkinstalldirs) $(kde_datadir)/konqueror/servicemenus/
+ $(INSTALL_DATA) $(srcdir)/konqksquirrel-dir.desktop $(kde_datadir)/konqueror/servicemenus/konqksquirrel-dir.desktop
+ $(mkinstalldirs) $(kde_datadir)/dolphin/servicemenus/
+ $(INSTALL_DATA) $(srcdir)/dolphksquirrel-dir.desktop $(kde_datadir)/dolphin/servicemenus/dolphksquirrel-dir.desktop
+
+uninstall-local:
+ -rm -f $(kde_icondir)/hicolor/32x32/apps/ksquirrel.png
+ -rm -f $(kde_icondir)/hicolor/16x16/apps/ksquirrel.png
+ -rm -f $(kde_datadir)/konqueror/servicemenus/konqksquirrel-dir.desktop
+ -rm -f $(kde_datadir)/dolphin/servicemenus/dolphksquirrel-dir.desktop
+
+####### tdevelop will overwrite this part!!! (end)############
+
+xdg_apps_DATA = ksquirrel.desktop
+
+# do we have KPart enabled ?
+if SQ_HAVE_KPART
+SUBDIRS += ksquirrelpart
+endif
+
+if SQ_HAVE_KLCONF
+SUBDIRS += ksquirrel-libs-configurator
+endif
+
+METASOURCES = AUTO
+
+ksquirrel_SOURCES += sq_utils_asm_scale.S
+
+AM_CCASFLAGS = -I$(srcdir) $(KSQUIRREL_ASM_DEFS)
+
+INCLUDES = $(all_includes) -I$(srcdir) -I$(top_srcdir)/src/sidebar -I$(top_srcdir)/src/imageedit
+# ksquirrelpart
+
+# These paths are KDE specific. Use them:
+# kde_appsdir Where your application's menu entry (.desktop) should go to.
+# kde_icondir Where your icon should go to - better use KDE_ICON.
+# kde_sounddir Where your sounds should go to.
+# kde_htmldir Where your docs should go to. (contains lang subdirs)
+# kde_datadir Where you install application data. (Use a subdir)
+# kde_locale Where translation files should go to. (contains lang subdirs)
+# kde_cgidir Where cgi-bin executables should go to.
+# kde_confdir Where config files should go to (system-wide ones with default values).
+# kde_mimedir Where mimetypes .desktop files should go to.
+# kde_servicesdir Where services .desktop files should go to.
+# kde_servicetypesdir Where servicetypes .desktop files should go to.
+# kde_toolbardir Where general toolbar icons should go to (deprecated, use KDE_ICON).
+# kde_wallpaperdir Where general wallpapers should go to.
+# kde_templatesdir Where templates for the "New" menu (Konqueror/KDesktop) should go to.
+# kde_bindir Where executables should go to. Use bin_PROGRAMS or bin_SCRIPTS.
+# kde_libdir Where shared libraries should go to. Use lib_LTLIBRARIES.
+# kde_moduledir Where modules (e.g. parts) should go to. Use kde_module_LTLIBRARIES.
+# kde_styledir Where TQt/KDE widget styles should go to (new in KDE 3).
+# kde_designerdir Where TQt Designer plugins should go to (new in KDE 3).
+
+AM_CXXFLAGS =
+AM_LDFLAGS = $(all_libraries)
+
+if SQ_HAVE_KIPI
+AM_CXXFLAGS += $(libkipi_CFLAGS)
+AM_LDFLAGS += $(libkipi_LIBS)
+endif
+
+if SQ_HAVE_KEXIF
+AM_CXXFLAGS += $(libkexif_CFLAGS)
+AM_LDFLAGS += $(libkexif_LIBS)
+endif
+
+# Uncomment the following two lines if you add a ui.rc file for your application to make use of
+# KDE?s XML GUI builing
+#rcdir = $(kde_datadir)/ksquirrel
+#rc_DATA = ksquirrelui.rc
+
+#WARNING: if you use a ui.rc file above, use:
+
+# messages: rc.cpp
+
+# instead of
+
+# messages:
+
+messages:
+ LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \
+ if test -n "$$LIST"; then \
+ $(XGETTEXT) $$LIST -o $(podir)/ksquirrel.pot; \
+ fi
diff --git a/src/dolphksquirrel-dir.desktop b/src/dolphksquirrel-dir.desktop
new file mode 100644
index 0000000..67d4977
--- /dev/null
+++ b/src/dolphksquirrel-dir.desktop
@@ -0,0 +1,14 @@
+[Desktop Entry]
+X-TDE-ServiceTypes=inode/directory
+Actions=KSquirrel;
+Encoding=UTF-8
+Type=Application
+
+[Desktop Action KSquirrel]
+Type=Application
+Icon=ksquirrel
+Exec=ksquirrel %u
+
+Name=Browse with KSquirrel
+Name[ru]=Просмотреть в KSquirrel
+Name[de]=Mit KSquirrel durchsehen
diff --git a/src/file_broken.xpm b/src/file_broken.xpm
new file mode 100644
index 0000000..1040d96
--- /dev/null
+++ b/src/file_broken.xpm
@@ -0,0 +1,831 @@
+/* XPM */
+static const char * file_broken_xpm[] = {
+"64 64 764 2",
+" c None",
+". c #A5A9AA",
+"+ c #A4A8A9",
+"@ c #A3A7A8",
+"# c #A2A6A7",
+"$ c #A1A5A6",
+"% c #A0A4A5",
+"& c #9FA3A4",
+"* c #9EA2A3",
+"= c #9DA1A2",
+"- c #9CA0A1",
+"; c #9B9FA0",
+"> c #9A9E9F",
+", c #999D9E",
+"' c #989C9D",
+") c #979B9C",
+"! c #969A9B",
+"~ c #95999A",
+"{ c #949899",
+"] c #939798",
+"^ c #929697",
+"/ c #919596",
+"( c #909495",
+"_ c #8F9394",
+": c #8E9293",
+"< c #8D9192",
+"[ c #8C9091",
+"} c #8B8F90",
+"| c #8A8E8F",
+"1 c #898D8E",
+"2 c #888C8D",
+"3 c #878B8C",
+"4 c #A6AAAB",
+"5 c #ACB7BF",
+"6 c #B3C4D4",
+"7 c #B2C3D3",
+"8 c #B1C2D2",
+"9 c #B0C1D1",
+"0 c #AFC0D0",
+"a c #AEBFCF",
+"b c #ADBECE",
+"c c #ACBDCD",
+"d c #ABBCCC",
+"e c #AABBCB",
+"f c #A9BACA",
+"g c #A8B9C9",
+"h c #A7B8C8",
+"i c #A6B7C7",
+"j c #A5B6C6",
+"k c #A4B5C5",
+"l c #95A0A8",
+"m c #868A8B",
+"n c #B0BECA",
+"o c #C2E0FF",
+"p c #D1E7FF",
+"q c #D0E7FF",
+"r c #CFE7FF",
+"s c #CFE6FF",
+"t c #9CAAB6",
+"u c #828687",
+"v c #C0DCF9",
+"w c #E4F1FF",
+"x c #FFFFFF",
+"y c #FEFFFF",
+"z c #FEFEFF",
+"A c #FDFEFF",
+"B c #FCFEFF",
+"C c #FBFDFF",
+"D c #FAFDFF",
+"E c #FAFCFF",
+"F c #F9FCFF",
+"G c #F8FCFF",
+"H c #F8FBFF",
+"I c #F7FBFF",
+"J c #F6FAFF",
+"K c #F5FAFF",
+"L c #DEEEFF",
+"M c #BEDAF7",
+"N c #85898A",
+"O c #E8F3FF",
+"P c #EFF7FF",
+"Q c #F4FAFF",
+"R c #E7F3FF",
+"S c #F3F9FF",
+"T c #E6F2FF",
+"U c #F2F8FF",
+"V c #E5F2FF",
+"W c #F1F8FF",
+"X c #FAEFEF",
+"Y c #EAAFAF",
+"Z c #EFCECF",
+"` c #EECDCF",
+" . c #CA3434",
+".. c #C21616",
+"+. c #E59F9F",
+"@. c #BD1C1C",
+"#. c #BC1C1C",
+"$. c #EDCDCF",
+"%. c #F0F8FF",
+"&. c #FBEFEF",
+"*. c #CB3434",
+"=. c #DE3939",
+"-. c #F64747",
+";. c #C61A1A",
+">. c #BE1C1C",
+",. c #E83D3D",
+"'. c #E73C3C",
+"). c #BC1B1B",
+"!. c #ECCDCF",
+"~. c #F0F7FF",
+"{. c #E3F1FF",
+"]. c #CC3434",
+"^. c #DF3939",
+"/. c #FF6969",
+"(. c #FF7A7A",
+"_. c #F0CECF",
+":. c #BF1C1C",
+"<. c #FB6363",
+"[. c #FB6161",
+"}. c #E73737",
+"|. c #BC1A1A",
+"1. c #EBCCCF",
+"2. c #CD3434",
+"3. c #FFA3A3",
+"4. c #FF8080",
+"5. c #C01C1C",
+"6. c #FB9E9E",
+"7. c #FB9D9D",
+"8. c #FB5E5E",
+"9. c #E73333",
+"0. c #BC1919",
+"a. c #EBCBCF",
+"b. c #E0EFFF",
+"c. c #B5D9FF",
+"d. c #CE3434",
+"e. c #E03939",
+"f. c #FF6868",
+"g. c #FFA1A1",
+"h. c #FE7F7F",
+"i. c #F54747",
+"j. c #E59E9F",
+"k. c #C11C1C",
+"l. c #E93D3D",
+"m. c #FB6362",
+"n. c #FB9C9C",
+"o. c #FB9B9B",
+"p. c #FB9A9A",
+"q. c #FA9999",
+"r. c #FA5A59",
+"s. c #E62F2F",
+"t. c #BC1819",
+"u. c #EACBCF",
+"v. c #EBF5FF",
+"w. c #E5F1FF",
+"x. c #99CCFF",
+"y. c #CF3434",
+"z. c #E13939",
+"A. c #FE6665",
+"B. c #FE9C9B",
+"C. c #FE7C7A",
+"D. c #DC7F7F",
+"E. c #C21C1C",
+"F. c #FC6160",
+"G. c #FB9796",
+"H. c #FB9695",
+"I. c #FB9594",
+"J. c #FB9493",
+"K. c #FA9392",
+"L. c #FA9291",
+"M. c #F94242",
+"N. c #E62B2B",
+"O. c #BC1818",
+"P. c #E9CBCF",
+"Q. c #EDF6FF",
+"R. c #E9F4FF",
+"S. c #E2F0FF",
+"T. c #D03434",
+"U. c #E23939",
+"V. c #FE6463",
+"W. c #FE9794",
+"X. c #FD7876",
+"Y. c #F44646",
+"Z. c #C82222",
+"`. c #EA3D3D",
+" + c #FC5F5D",
+".+ c #FD928F",
+"++ c #FD918E",
+"@+ c #FD908D",
+"#+ c #FC8F8C",
+"$+ c #FC8E8B",
+"%+ c #FC8D8A",
+"&+ c #FB8683",
+"*+ c #F93434",
+"=+ c #F82C2C",
+"-+ c #E52727",
+";+ c #BC1717",
+">+ c #E8CBCF",
+",+ c #E1F0FF",
+"'+ c #D13434",
+")+ c #FE6260",
+"!+ c #FE918D",
+"~+ c #FD7370",
+"{+ c #FC5D5B",
+"]+ c #FD8D88",
+"^+ c #FD8C87",
+"/+ c #FD8A86",
+"(+ c #FC8985",
+"_+ c #FC8884",
+":+ c #FC8783",
+"<+ c #FC8682",
+"[+ c #FA6462",
+"}+ c #F82A2A",
+"|+ c #F82727",
+"1+ c #E52323",
+"2+ c #BC1616",
+"3+ c #E7CACF",
+"4+ c #EFF6FF",
+"5+ c #E6F3FF",
+"6+ c #CEE6FF",
+"7+ c #D23434",
+"8+ c #E33939",
+"9+ c #FE5C5A",
+"0+ c #FE8C87",
+"a+ c #FE8C86",
+"b+ c #FD8B85",
+"c+ c #FD8984",
+"d+ c #FC7672",
+"e+ c #FD8782",
+"f+ c #FD8681",
+"g+ c #FD8580",
+"h+ c #FC847F",
+"i+ c #FC837E",
+"j+ c #FC827D",
+"k+ c #FC817B",
+"l+ c #FC807A",
+"m+ c #F83636",
+"n+ c #F72525",
+"o+ c #F72323",
+"p+ c #E41F1F",
+"q+ c #BA1313",
+"r+ c #EAD9DF",
+"s+ c #EBF4FF",
+"t+ c #CDE6FF",
+"u+ c #DC5F5F",
+"v+ c #D92C2C",
+"w+ c #FC4B4A",
+"x+ c #FE7B76",
+"y+ c #FE8780",
+"z+ c #FD8780",
+"A+ c #FD8680",
+"B+ c #FD857F",
+"C+ c #FD847D",
+"D+ c #FC837C",
+"E+ c #FC827B",
+"F+ c #FC817A",
+"G+ c #FC8079",
+"H+ c #FC7F78",
+"I+ c #FC7E77",
+"J+ c #FB7D76",
+"K+ c #FB7C75",
+"L+ c #FB7A74",
+"M+ c #F95C58",
+"N+ c #F62121",
+"O+ c #D71919",
+"P+ c #C13031",
+"Q+ c #EBE7EF",
+"R+ c #DFEFFF",
+"S+ c #FC4A4A",
+"T+ c #FE7770",
+"U+ c #FD8179",
+"V+ c #FD8078",
+"W+ c #FD7F77",
+"X+ c #FC7E76",
+"Y+ c #FC7D75",
+"Z+ c #FC7C74",
+"`+ c #FC7A72",
+" @ c #FC7971",
+".@ c #FC7870",
+"+@ c #FB776F",
+"@@ c #FB766E",
+"#@ c #FB756D",
+"$@ c #FA6F68",
+"%@ c #F82E2E",
+"&@ c #C23031",
+"*@ c #EAE7EF",
+"=@ c #CCE5FF",
+"-@ c #FC4A49",
+";@ c #FD726B",
+">@ c #FD7C73",
+",@ c #FD7A71",
+"'@ c #FD7970",
+")@ c #FC786F",
+"!@ c #FC776E",
+"~@ c #FC766D",
+"{@ c #FC756C",
+"]@ c #FC746B",
+"^@ c #FC736A",
+"/@ c #FB7269",
+"(@ c #FB7168",
+"_@ c #FB7066",
+":@ c #FB6E65",
+"<@ c #F83F3C",
+"[@ c #D81919",
+"}@ c #C33031",
+"|@ c #E8E6EF",
+"1@ c #DDEEFF",
+"2@ c #CBE5FF",
+"3@ c #FB4A49",
+"4@ c #FC6E65",
+"5@ c #FC776C",
+"6@ c #FC766C",
+"7@ c #FC756B",
+"8@ c #FC746A",
+"9@ c #FC7369",
+"0@ c #FC7267",
+"a@ c #FC7166",
+"b@ c #FC7065",
+"c@ c #FB6F64",
+"d@ c #FB6E63",
+"e@ c #FB6D62",
+"f@ c #FB6B61",
+"g@ c #FB6A60",
+"h@ c #FA695F",
+"i@ c #F94944",
+"j@ c #D91919",
+"k@ c #C43031",
+"l@ c #DCEDFF",
+"m@ c #CBE4FF",
+"n@ c #FA4949",
+"o@ c #FC6960",
+"p@ c #FC7064",
+"q@ c #FC6F63",
+"r@ c #FC6E62",
+"s@ c #FC6D61",
+"t@ c #FC6C60",
+"u@ c #FC6A5F",
+"v@ c #FB695D",
+"w@ c #FB685C",
+"x@ c #FB675B",
+"y@ c #FB665A",
+"z@ c #FB6559",
+"A@ c #FA6458",
+"B@ c #F94641",
+"C@ c #C53031",
+"D@ c #E7E5EF",
+"E@ c #DBEDFF",
+"F@ c #CAE4FF",
+"G@ c #DB5F5F",
+"H@ c #D82C2C",
+"I@ c #FA4646",
+"J@ c #FC6258",
+"K@ c #FC685B",
+"L@ c #FC675A",
+"M@ c #FC6659",
+"N@ c #FC6558",
+"O@ c #FB6457",
+"P@ c #FB6356",
+"Q@ c #FB6255",
+"R@ c #FB6154",
+"S@ c #FB6053",
+"T@ c #FA5B4F",
+"U@ c #F83A36",
+"V@ c #DA1919",
+"W@ c #C52F31",
+"X@ c #C9E4FF",
+"Y@ c #F3CECF",
+"Z@ c #CB0C0C",
+"`@ c #F04242",
+" # c #FB4F48",
+".# c #FB6253",
+"+# c #FB6152",
+"@# c #FB6051",
+"## c #FB5E50",
+"$# c #FB5D4F",
+"%# c #FA5C4E",
+"&# c #FA5B4D",
+"*# c #FA5A4C",
+"=# c #F94B41",
+"-# c #F11F1F",
+";# c #C70C0C",
+"># c #D5898F",
+",# c #DAECFF",
+"'# c #CF1C1C",
+")# c #ED3D3D",
+"!# c #FB4B45",
+"~# c #FB5C4D",
+"{# c #FB5B4C",
+"]# c #FB5A4B",
+"^# c #FB594A",
+"/# c #FB5849",
+"(# c #FA5748",
+"_# c #FA5646",
+":# c #F95244",
+"<# c #F83834",
+"[# c #F72A2A",
+"}# c #F61F1F",
+"|# c #F31D1D",
+"1# c #E91A1A",
+"2# c #C50909",
+"3# c #D7989F",
+"4# c #D9ECFF",
+"5# c #C8E3FF",
+"6# c #D01C1C",
+"7# c #EE3D3D",
+"8# c #FB4943",
+"9# c #FB5948",
+"0# c #FB5847",
+"a# c #FB5746",
+"b# c #FB5545",
+"c# c #FA5444",
+"d# c #FA5343",
+"e# c #F95242",
+"f# c #F8463B",
+"g# c #F62E2D",
+"h# c #F52A2A",
+"i# c #F52727",
+"j# c #F52525",
+"k# c #F52323",
+"l# c #F51F1F",
+"m# c #F11D1D",
+"n# c #EF1A1A",
+"o# c #EF1818",
+"p# c #E91616",
+"q# c #C50707",
+"r# c #D6979F",
+"s# c #D8EBFF",
+"t# c #F4CECF",
+"u# c #D11C1C",
+"v# c #FA5545",
+"w# c #F95343",
+"x# c #F85041",
+"y# c #F53934",
+"z# c #F32C2C",
+"A# c #F12A2A",
+"B# c #F12727",
+"C# c #F12525",
+"D# c #F12323",
+"E# c #F22121",
+"F# c #EE1D1D",
+"G# c #EE1A1A",
+"H# c #EE1616",
+"I# c #ED1414",
+"J# c #E71212",
+"K# c #C50606",
+"L# c #D5979F",
+"M# c #D7EBFF",
+"N# c #C7E3FF",
+"O# c #D31C1C",
+"P# c #EF3D3D",
+"Q# c #F95444",
+"R# c #F85343",
+"S# c #F6493D",
+"T# c #F2302F",
+"U# c #F02C2C",
+"V# c #EF2A2A",
+"W# c #EE2727",
+"X# c #EE2525",
+"Y# c #ED2323",
+"Z# c #EE2121",
+"`# c #EB1F1F",
+" $ c #E91D1D",
+".$ c #EA1A1A",
+"+$ c #EB1818",
+"@$ c #EC1616",
+"#$ c #ED1212",
+"$$ c #ED0F0F",
+"%$ c #E70D0D",
+"&$ c #C50404",
+"*$ c #D4969F",
+"=$ c #D6EAFF",
+"-$ c #C6E2FF",
+";$ c #D41C1C",
+">$ c #F4433A",
+",$ c #F02E2E",
+"'$ c #EE2C2C",
+")$ c #EC2A2A",
+"!$ c #EB2727",
+"~$ c #EB2525",
+"{$ c #EA2323",
+"]$ c #E92121",
+"^$ c #E51F1F",
+"/$ c #E51D1D",
+"($ c #E51A1A",
+"_$ c #E71818",
+":$ c #E71616",
+"<$ c #E91414",
+"[$ c #EA1212",
+"}$ c #EC0F0F",
+"|$ c #EC0D0D",
+"1$ c #EB0B0B",
+"2$ c #E50909",
+"3$ c #C50202",
+"4$ c #D3969F",
+"5$ c #D5EAFF",
+"6$ c #EEF6FF",
+"7$ c #FAEEEF",
+"8$ c #D31414",
+"9$ c #EB3D3D",
+"0$ c #FB4843",
+"a$ c #F75343",
+"b$ c #F23D37",
+"c$ c #EF2E2E",
+"d$ c #EC2C2C",
+"e$ c #EA2A2A",
+"f$ c #E92727",
+"g$ c #E82525",
+"h$ c #E62323",
+"i$ c #E32121",
+"j$ c #E11F1F",
+"k$ c #E11D1D",
+"l$ c #E11A1A",
+"m$ c #E21818",
+"n$ c #E31616",
+"o$ c #E41414",
+"p$ c #E61212",
+"q$ c #E70F0F",
+"r$ c #E90D0D",
+"s$ c #EA0909",
+"t$ c #EA0707",
+"u$ c #E30404",
+"v$ c #C00000",
+"w$ c #D8C2CF",
+"x$ c #C5E2FF",
+"y$ c #EB9E9F",
+"z$ c #D71818",
+"A$ c #F53F3E",
+"B$ c #FB5245",
+"C$ c #EE2E2E",
+"D$ c #EB2C2C",
+"E$ c #E92A2A",
+"F$ c #E72727",
+"G$ c #E52525",
+"H$ c #E22323",
+"I$ c #DE2121",
+"J$ c #DD1F1F",
+"K$ c #DD1D1D",
+"L$ c #DD1A1A",
+"M$ c #DD1818",
+"N$ c #DE1616",
+"O$ c #DF1414",
+"P$ c #E11212",
+"Q$ c #E20F0F",
+"R$ c #E40D0D",
+"S$ c #E60B0B",
+"T$ c #E80909",
+"U$ c #E80404",
+"V$ c #CE0202",
+"W$ c #C9595F",
+"X$ c #D4E9FF",
+"Y$ c #C4E1FF",
+"Z$ c #EA9E9F",
+"`$ c #D71616",
+" % c #F53B3A",
+".% c #FA4F42",
+"+% c #F3433A",
+"@% c #E82A2A",
+"#% c #E62727",
+"$% c #E22525",
+"%% c #DD2323",
+"&% c #DB2121",
+"*% c #CE1D1D",
+"=% c #D71D1D",
+"-% c #D81A1A",
+";% c #D91818",
+">% c #D91616",
+",% c #DB1414",
+"'% c #DC1212",
+")% c #DE0F0F",
+"!% c #DF0D0D",
+"~% c #E20B0B",
+"{% c #E40909",
+"]% c #E60707",
+"^% c #E70404",
+"/% c #CF0202",
+"(% c #CA595F",
+"_% c #D3E9FF",
+":% c #EDF5FF",
+"<% c #EA9D9F",
+"[% c #D71414",
+"}% c #F33735",
+"|% c #F84D40",
+"1% c #F64E3F",
+"2% c #E42727",
+"3% c #DE2525",
+"4% c #DB2323",
+"5% c #D92121",
+"6% c #CA1919",
+"7% c #C91111",
+"8% c #C61010",
+"9% c #D31818",
+"0% c #D51616",
+"a% c #D61414",
+"b% c #D71212",
+"c% c #D90F0F",
+"d% c #DB0D0D",
+"e% c #DD0B0B",
+"f% c #DF0909",
+"g% c #E10707",
+"h% c #E20404",
+"i% c #CB595F",
+"j% c #D2E8FF",
+"k% c #C3E1FF",
+"l% c #ECF5FF",
+"m% c #E99D9F",
+"n% c #D61313",
+"o% c #EE3231",
+"p% c #F13230",
+"q% c #E62A2A",
+"r% c #E22727",
+"s% c #D82121",
+"t% c #C91919",
+"u% c #CF2F31",
+"v% c #E7E4EF",
+"w% c #D45B5F",
+"x% c #C40E0E",
+"y% c #D01414",
+"z% c #D21212",
+"A% c #D40F0F",
+"B% c #D60D0D",
+"C% c #D80B0B",
+"D% c #DA0909",
+"E% c #DC0707",
+"F% c #DE0404",
+"G% c #CC0202",
+"H% c #CC595F",
+"I% c #D1E8FF",
+"J% c #C2E1FF",
+"K% c #F7FAFF",
+"L% c #E79C9F",
+"M% c #D41111",
+"N% c #E72C2C",
+"O% c #E32727",
+"P% c #DF2525",
+"Q% c #D35B5F",
+"R% c #C30B0B",
+"S% c #CE0F0F",
+"T% c #D10D0D",
+"U% c #D30B0B",
+"V% c #D50909",
+"W% c #D80707",
+"X% c #D90404",
+"Y% c #CA0202",
+"Z% c #CD595F",
+"`% c #ADD6FF",
+" & c #F4F9FF",
+".& c #E49A9F",
+"+& c #D20F0F",
+"@& c #E12727",
+"#& c #E12525",
+"$& c #CB1919",
+"%& c #D12F31",
+"&& c #D25A5F",
+"*& c #C20808",
+"=& c #CD0B0B",
+"-& c #D10909",
+";& c #D30707",
+">& c #D50404",
+",& c #C80202",
+"'& c #CE595F",
+")& c #C1E0FF",
+"!& c #DEEFFF",
+"~& c #F2F9FF",
+"{& c #E39A9F",
+"]& c #D00E0E",
+"^& c #CD1919",
+"/& c #D22F31",
+"(& c #C30505",
+"_& c #CE0707",
+":& c #D00404",
+"<& c #C60202",
+"[& c #C0DFFF",
+"}& c #EEF7FF",
+"|& c #E2999F",
+"1& c #CF0C0C",
+"2& c #CF1919",
+"3& c #D32F31",
+"4& c #D15A5F",
+"5& c #C40303",
+"6& c #CF595F",
+"7& c #ECF6FF",
+"8& c #E1999F",
+"9& c #D52D2F",
+"0& c #D1595F",
+"a& c #D0595F",
+"b& c #BFDFFF",
+"c& c #EAF4FF",
+"d& c #BFDEFF",
+"e& c #BEDEFF",
+"f& c #CAE5FF",
+"g& c #BDDEFF",
+"h& c #BCDDFF",
+"i& c #BBDDFF",
+"j& c #BADCFF",
+"k& c #B9DCFF",
+"l& c #C4E2FF",
+"m& c #B8DBFF",
+"n& c #889299",
+"o& c #99C9F9",
+"p& c #B0D7FF",
+"q& c #97C7F7",
+"r& c #A1B6CA",
+"s& c #ACD5FF",
+"t& c #ABD5FF",
+"u& c #AAD5FF",
+"v& c #AAD4FF",
+"w& c #A9D4FF",
+"x& c #A8D4FF",
+"y& c #A8D3FF",
+"z& c #A7D3FF",
+"A& c #A6D2FF",
+"B& c #A5D2FF",
+"C& c #A4D2FF",
+"D& c #A4D1FF",
+"E& c #A3D1FF",
+"F& c #8DA2B6",
+"G& c #A2B2BF",
+"H& c #9DBEDF",
+"I& c #9BC3E9",
+"J& c #9BC2E9",
+"K& c #9BC2E8",
+"L& c #9AC2E8",
+"M& c #9AC1E8",
+"N& c #9AC1E7",
+"O& c #99C1E7",
+"P& c #99C0E7",
+"Q& c #99C0E6",
+"R& c #98C0E6",
+"S& c #98BFE6",
+"T& c #98BFE5",
+"U& c #97BFE5",
+"V& c #97BEE5",
+"W& c #97BEE4",
+"X& c #96BEE4",
+"Y& c #96BDE4",
+"Z& c #96BDE3",
+"`& c #95BDE3",
+" * c #95BCE3",
+".* c #95BCE2",
+"+* c #94BCE2",
+"@* c #90ABC5",
+"#* c #8B9BA8",
+"$* c #848889",
+"%* c #999C9D",
+"&* c #96999A",
+"** c #959899",
+"=* c #949798",
+"-* c #939697",
+";* c #929596",
+">* c #909394",
+",* c #8E9292",
+"'* c #8D9091",
+")* c #8B8E8F",
+"!* c #888B8C",
+"~* c #878A8B",
+"{* c #868A8A",
+"]* c #858889",
+"^* c #848788",
+"/* c #838787",
+"(* c #818586",
+"_* c #818485",
+":* c #808485",
+"<* c #7F8384",
+"[* c #7F8383",
+"}* c #787C7D",
+" ",
+" ",
+" ",
+" . + + @ # # $ % % & & * = = - ; ; > , , ' ) ) ! ! ~ { { ] ^ ^ / ( ( _ : : < < [ } } | 1 1 2 3 3 ",
+" 4 5 6 6 7 7 7 8 8 8 9 9 9 0 0 0 a a a b b b c c c c d d d e e e f f f g g g h h h i i i j j j k l m ",
+" 4 n o p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p q q q q q q q q r r s s s s s o t u ",
+" 4 v w x x x x x x x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K L M N ",
+" 4 o I x x x x x x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K O o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q R o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q Q R o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q Q S T o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q Q S S T o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q Q S S U T o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q Q S S U U V o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q Q S S U U W V o N ",
+" 4 o P x x x x x x x x x x X Y x x x x x x y z z A A Z ` C D D E F G H I I I J K K Q Q S S U U W W V o N ",
+" 4 o P x x x x x x x x x X ...+.x x x x y z z A A Z @.#.$.D E F G H I I I J K K Q Q S S U U W W %.w o N ",
+" 4 o P x x x x x x x x &.*.=.-.;.+.x x y z z A A Z >.,.'.).!.F G H I I I J K K Q Q S S U U W W %.~.{.o N ",
+" 4 o P x x x x x x x &.].^./.(.-.;.+.y z z A A _.:.,.<.[.}.|.1.H I I I J K K Q Q S S U U W W %.~.P {.o N ",
+" 4 o P x x x x x x &.2.^./.3.3.4.-.;.+.z A A _.5.,.<.6.7.8.9.0.a.I I J K K Q Q S S U U W W %.~.P P b.c.N ",
+" 4 o P x x x x x &.d.e.f.g.g.g.g.h.i.;.j.A _.k.l.m.n.o.p.q.r.s.t.u.J K K Q Q S S U U W W %.P v.O w.q x.N ",
+" 4 o P x x x x &.y.z.A.B.B.B.B.B.B.C.i.;.D.E.l.F.G.H.I.J.K.L.M.N.O.P.K Q Q S S U U W W Q.R.V w {.S.r x.N ",
+" 4 o P x x x &.T.U.V.W.W.W.W.W.W.W.W.X.Y.Z.`. +.+++@+#+$+%+&+*+=+-+;+>+Q S S U U W Q.O T V w {.S.,+r x.N ",
+" 4 o P x x &.'+U.)+!+!+!+!+!+!+!+!+!+!+~+M.{+]+^+/+(+_+:+<+[+=+}+|+1+2+3+S U U 4+O 5+T V w {.S.,+,+6+x.N ",
+" 4 o P x &.7+8+9+0+0+0+0+0+0+0+0+0+a+b+c+d+e+f+g+h+i+j+k+l+m+}+|+n+o+p+q+r+~.s+R 5+T V w {.S.,+,+b.t+x.N ",
+" 4 o P x x u+v+w+x+y+y+z+z+z+z+z+A+B+C+D+E+F+G+H+I+J+K+L+M+}+|+n+o+N+O+P+Q+R.R 5+T V w {.S.,+,+b.R+t+x.N ",
+" 4 o P x x x u+v+S+T+U+U+U+U+U+U+V+W+X+Y+Z+`+ @.@+@@@#@$@%@|+n+o+N+O+&@*@O R 5+T V w {.S.,+,+b.R+L [email protected] ",
+" 4 o P x x x x u+v+-@;@>@>@>@>@,@'@)@!@~@{@]@^@/@(@_@:@<@|+n+o+N+[@}@|@O R 5+T V w {.S.,+,+b.R+L 1@[email protected] ",
+" 4 o P x x x x x u+v+3@4@5@6@7@8@9@0@a@b@c@d@e@f@g@h@i@|+n+o+N+j@k@|@O R 5+T V w {.S.,+,+b.R+L 1@l@[email protected] ",
+" 4 o P x x x x y z u+v+n@o@p@q@r@s@t@u@v@w@x@y@z@A@B@|+n+o+N+j@C@D@O R 5+T V w {.S.,+,+b.R+L 1@l@E@[email protected] ",
+" 4 o P x x x y z z A G@H@I@J@K@L@M@N@O@P@Q@R@S@T@U@|+n+o+N+V@W@D@O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@[email protected] ",
+" 4 o P x x y z z A A Y@Z@`@ #.#+#@###$#%#&#*#=#=+|+n+o+N+-#;#>#O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#[email protected] ",
+" 4 o P x y z z A A Y@'#)#!#~#{#]#^#/#(#_#:#<#[#|+n+o+N+}#|#1#2#3#5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#5#x.N ",
+" 4 o P y z z A A Y@6#7#8#9#0#a#b#c#d#e#f#g#h#i#j#k#N+l#m#n#o#p#q#r#V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#5#x.N ",
+" 4 o P z z A A t#u#7#8#9#0#a#v#c#w#x#y#z#A#B#C#D#E#-#F#G#o#H#I#J#K#L#{.S.,+,+b.R+L 1@l@E@E@,#4#s#M#N#x.N ",
+" 4 o 4+z A A t#O#P#8#9#0#a#v#Q#R#S#T#U#V#W#X#Y#Z#`# $.$+$@$I##$$$%$&$*$,+,+b.R+L 1@l@E@E@,#4#s#M#=$-$x.N ",
+" 4 o 4+A A t#;$P#8#9#0#a#v#Q#R#>$,$'$)$!$~${$]$^$/$($_$:$<$[$}$|$1$2$3$4$b.R+L 1@l@E@E@,#4#s#M#=$5$-$x.N ",
+" 4 o 6$A 7$8$9$0$9#0#a#v#Q#a$b$c$d$e$f$g$h$i$j$k$l$m$n$o$p$q$r$1$s$t$u$v$w$L 1@l@E@E@,#4#s#M#=$5$5$x$x.N ",
+" 4 o 6$B C y$z$A$B$a#v#Q#a$b$C$D$E$F$G$H$I$J$K$L$M$N$O$P$Q$R$S$T$t$U$V$W$L 1@l@E@E@,#4#s#M#=$5$5$X$Y$x.N ",
+" 4 o 6$C C D Z$`$ %.%Q#R#+%C$D$@%#%$%%%&%*%=%-%;%>%,%'%)%!%~%{%]%^%/%(%L 1@l@E@E@,#4#s#M#=$5$5$X$_%Y$x.N ",
+" 4 o :%C D D E <%[%}%|%1%c$D$@%2%3%4%5%6%7%8%9%0%a%b%c%d%e%f%g%h%V$i%L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%k%x.N ",
+" 4 o l%D D E F G m%n%o%p%d$q%r%3%4%s%t%u%v%w%x%y%z%A%B%C%D%E%F%G%H%L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%J%x.N ",
+" 4 o l%D E F G H K%L%M%N%q%O%P%4%s%6%u%v%O R Q%R%S%T%U%V%W%X%Y%Z%L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q o x.N ",
+" 4 `%V H I J &S U W .&+&@&#&%%5%$&%&v%O R 5+T &&*&=&-&;&>&,&'&L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r )&x.N ",
+" 4 x.!&K Q S ~&U W ~.P {&]&4%&%^&/&v%O R 5+T V w &&(&_&:&<&'&L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r [&x.N ",
+" 4 x.L Q S ~&U W ~.P }&Q.|&1&2&3&v%O R 5+T V w {.S.4&5&3$6&L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+[&x.N ",
+" 4 x.1@S ~&U W ~.P }&Q.7&l%8&9&v%O R 5+T V w {.S.,+,+0&a&L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+b&x.N ",
+" 4 x.l@~&U W ~.P }&Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@d&x.N ",
+" 4 x.l@U W ~.P }&Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@e&x.N ",
+" 4 x.E@W ~.P }&Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&g&x.N ",
+" 4 x.E@~.P }&Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@g&x.N ",
+" 4 x.,#P }&Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@h&x.N ",
+" 4 x.4#}&Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#i&x.N ",
+" 4 x.4#Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#N#i&x.N ",
+" 4 x.s#7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#N#-$j&x.N ",
+" 4 x.M#l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#N#-$x$k&x.N ",
+" 4 x.M#v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#N#-$x$l&k&x.N ",
+" 4 x.=$c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#N#-$x$l&k%m&x.n& ",
+" 4 o&-$R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#N#-$x$l&k%J%p&q&N ",
+" 4 r&x.`%s&s&s&s&t&t&t&t&t&u&v&v&v&v&w&w&w&w&x&y&y&y&y&z&z&z&z&z&A&A&A&A&B&B&B&B&B&C&D&D&D&D&E&E&E&x.F&u ",
+" 4 G&H&I&J&J&J&K&L&L&M&M&M&N&N&O&P&P&P&Q&Q&R&S&S&S&S&T&U&U&V&V&V&W&X&X&Y&Y&Y&Z&Z&`& * * *.*.*+*@*#*$* ",
+" . > , %*' ) ) ! &*~ **=*] -*^ ;*/ ( >*_ : ,*< '*[ } )*| 1 1 2 !*3 ~*{*N ]*$*^*/*u u (*_*:*<*[*}* ",
+" ",
+" "};
diff --git a/src/fmt_filters.cpp b/src/fmt_filters.cpp
new file mode 100644
index 0000000..9f6222c
--- /dev/null
+++ b/src/fmt_filters.cpp
@@ -0,0 +1,2288 @@
+/*
+ * Copyright (c) 2005 Dmitry Baryshev <[email protected]>
+ */
+
+/* This file is part of the KDE libraries
+ Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <[email protected]>
+ (C) 1998, 1999 Christian Tibirna <[email protected]>
+ (C) 1998, 1999 Dirk A. Mueller <[email protected]>
+ (C) 1999 Geert Jansen <[email protected]>
+ (C) 2000 Josef Weidendorfer <[email protected]>
+ (C) 2004 Zack Rusin <[email protected]>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+//
+// ===================================================================
+// Effects originally ported from ImageMagick for PixiePlus, plus a few
+// new ones. (mosfet 05/26/2003)
+// ===================================================================
+//
+/*
+ Portions of this software are based on ImageMagick. Such portions are clearly
+marked as being ported from ImageMagick. ImageMagick is copyrighted under the
+following conditions:
+
+Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to
+making software imaging solutions freely available.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files ("ImageMagick"), to deal
+in ImageMagick without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of ImageMagick, and to permit persons to whom the ImageMagick is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of ImageMagick.
+
+The software is provided "as is", without warranty of any kind, express or
+implied, including but not limited to the warranties of merchantability,
+fitness for a particular purpose and noninfringement. In no event shall
+ImageMagick Studio be liable for any claim, damages or other liability,
+whether in an action of contract, tort or otherwise, arising from, out of or
+in connection with ImageMagick or the use or other dealings in ImageMagick.
+
+Except as contained in this notice, the name of the ImageMagick Studio shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in ImageMagick without prior written authorization from the
+ImageMagick Studio.
+*/
+
+#include "fmt_filters.h"
+
+#include <cmath>
+#include <algorithm>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+
+namespace fmt_filters
+{
+
+#define MaxRGB 255L
+#define DegreesToRadians(x) ((x)*M_PI/180.0)
+#define MagickSQ2PI 2.50662827463100024161235523934010416269302368164062
+#define MagickEpsilon 1.0e-12
+#define MagickPI 3.14159265358979323846264338327950288419716939937510
+
+#define F_MAX(a, b) ((b) < (a) ? (a) : (b))
+#define F_MIN(a, b) ((a) < (b) ? (a) : (b))
+
+static void rgb2hsv(const fmt_filters::rgb &rgb, s32 *h, s32 *s, s32 *v);
+static void hsv2rgb(s32 h, s32 s, s32 v, fmt_filters::rgb *rgb);
+static fmt_filters::rgba interpolateColor(const fmt_filters::image &image, double x_offset, double y_offset, const fmt_filters::rgba &background);
+static u32 generateNoise(u32 pixel, fmt_filters::NoiseType noise_type);
+static u32 intensityValue(s32 r, s32 g, s32 b);
+static u32 intensityValue(const fmt_filters::rgba &rr);
+static s32 getBlurKernel(s32 width, double sigma, double **kernel);
+static void blurScanLine(double *kernel, s32 width, fmt_filters::rgba *src, fmt_filters::rgba *dest, s32 columns);
+static void hull(const s32 x_offset, const s32 y_offset, const s32 polarity, const s32 columns,
+ const s32 rows, u8 *f, u8 *g);
+static bool convolveImage(fmt_filters::image *image, fmt_filters::rgba **dest, const unsigned int order, const double *kernel);
+static int getOptimalKernelWidth(double radius, double sigma);
+
+template<class T>
+static void scaleDown(T &val, T min, T max);
+
+struct double_packet
+{
+ double red;
+ double green;
+ double blue;
+ double alpha;
+};
+
+struct short_packet
+{
+ unsigned short int red;
+ unsigned short int green;
+ unsigned short int blue;
+ unsigned short int alpha;
+};
+
+bool checkImage(const image &im)
+{
+ return (im.rw && im.rh && im.w && im.h && im.data);
+}
+
+// colorize tool
+void colorize(const image &im, s32 red, s32 green, s32 blue)
+{
+ // check if all parameters are good
+ if(!checkImage(im))
+ return;
+
+ if(!red && !green && !blue)
+ return;
+
+ u8 *bits;
+ s32 val;
+ s32 V[3] = { red, green, blue };
+
+ // add to RED component 'red' value, and check if the result is out of bounds.
+ // do the same with GREEN and BLUE channels.
+ for(s32 y = 0;y < im.h;++y)
+ {
+ bits = im.data + im.rw * y * sizeof(rgba);
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ for(s32 v = 0;v < 3;++v)
+ {
+ val = (s32)*(bits + v) + V[v];
+
+ if(val > 255)
+ *(bits + v) = 255;
+ else if(val < 0)
+ *(bits + v) = 0;
+ else
+ *(bits + v) = val;
+ }
+
+ bits += 4;
+ }
+ }
+}
+
+// brightness tool
+void brightness(const image &im, s32 bn)
+{
+ // check if all parameters are good
+ if(!checkImage(im))
+ return;
+
+ u8 *bits;
+ s32 val;
+
+ // add to all color components 'bn' value, and check if the result is out of bounds.
+ for(s32 y = 0;y < im.h;++y)
+ {
+ bits = im.data + im.rw * y * sizeof(rgba);
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ for(s32 v = 0;v < 3;v++)
+ {
+ val = bn + *bits;
+ *bits = val < 0 ? 0 : (val > 255 ? 255 : val);
+
+ bits++;
+ }
+
+ bits++;
+ }
+ }
+}
+
+// gamma tool
+void gamma(const image &im, double L)
+{
+ // check if all parameters are good
+ if(!checkImage(im))
+ return;
+
+ if(L == 0 || L < 0) L = 0.01;
+
+ rgba *_rgba;
+ u8 R, G, B;
+ u8 GT[256];
+
+ GT[0] = 0;
+
+ // fill the array with gamma koefficients
+ for (s32 x = 1; x < 256; ++x)
+ GT[x] = (u8)round(255 * pow((double)x / 255.0, 1.0 / L));
+
+ // now change gamma
+ for(s32 y = 0;y < im.h;++y)
+ {
+ _rgba = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ R = _rgba[x].r;
+ G = _rgba[x].g;
+ B = _rgba[x].b;
+
+ _rgba[x].r = GT[R];
+ _rgba[x].g = GT[G];
+ _rgba[x].b = GT[B];
+ }
+ }
+}
+
+// contrast tool
+void contrast(const image &im, s32 contrast)
+{
+ if(!checkImage(im) || !contrast)
+ return;
+
+ if(contrast < -255) contrast = -255;
+ if(contrast > 255) contrast = 255;
+
+ rgba *bits;
+ u8 Ravg, Gavg, Bavg;
+ s32 Ra = 0, Ga = 0, Ba = 0, Rn, Gn, Bn;
+
+ // calculate the average values for RED, GREEN and BLUE
+ // color components
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ Ra += bits->r;
+ Ga += bits->g;
+ Ba += bits->b;
+
+ bits++;
+ }
+ }
+
+ s32 S = im.w * im.h;
+
+ Ravg = Ra / S;
+ Gavg = Ga / S;
+ Bavg = Ba / S;
+
+ // ok, now change contrast
+ // with the terms of alghoritm:
+ //
+ // if contrast > 0: I = (I - Avg) * 256 / (256 - contrast) + Avg
+ // if contrast < 0: I = (I - Avg) * (256 + contrast) / 256 + Avg
+ //
+ // where
+ // I - current color component value
+ // Avg - average value of this component (Ravg, Gavg or Bavg)
+ //
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ Rn = (contrast > 0) ? ((bits->r - Ravg) * 256 / (256 - contrast) + Ravg) : ((bits->r - Ravg) * (256 + contrast) / 256 + Ravg);
+ Gn = (contrast > 0) ? ((bits->g - Gavg) * 256 / (256 - contrast) + Gavg) : ((bits->g - Gavg) * (256 + contrast) / 256 + Gavg);
+ Bn = (contrast > 0) ? ((bits->b - Bavg) * 256 / (256 - contrast) + Bavg) : ((bits->b - Bavg) * (256 + contrast) / 256 + Bavg);
+
+ bits->r = Rn < 0 ? 0 : (Rn > 255 ? 255 : Rn);
+ bits->g = Gn < 0 ? 0 : (Gn > 255 ? 255 : Gn);
+ bits->b = Bn < 0 ? 0 : (Bn > 255 ? 255 : Bn);
+
+ bits++;
+ }
+ }
+}
+
+// negative
+void negative(const image &im)
+{
+ // check if all parameters are good
+ if(!checkImage(im))
+ return;
+
+ rgba *bits;
+ u8 R, G, B;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ R = bits->r;
+ G = bits->g;
+ B = bits->b;
+
+ bits->r = 255 - R;
+ bits->g = 255 - G;
+ bits->b = 255 - B;
+
+ bits++;
+ }
+ }
+}
+
+// swap RGB values
+void swapRGB(const image &im, s32 type)
+{
+ // check if all parameters are good
+ if(!checkImage(im) || (type != GBR && type != BRG))
+ return;
+
+ rgba *bits;
+ u8 R, G, B;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ R = bits->r;
+ G = bits->g;
+ B = bits->b;
+
+ bits->r = (type == GBR) ? G : B;
+ bits->g = (type == GBR) ? B : R;
+ bits->b = (type == GBR) ? R : G;
+
+ bits++;
+ }
+ }
+}
+
+// blend
+void blend(const image &im, const rgb &rgb, float opacity)
+{
+ // check parameters
+ if(!checkImage(im))
+ return;
+
+ scaleDown(opacity, 0.0f, 1.0f);
+
+ rgba *bits;
+ s32 r = rgb.r, g = rgb.g, b = rgb.b;
+
+ // blend!
+ for(s32 y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ bits->r = bits->r + (u8)((b - bits->r) * opacity);
+ bits->g = bits->g + (u8)((g - bits->g) * opacity);
+ bits->b = bits->b + (u8)((r - bits->b) * opacity);
+
+ bits++;
+ }
+ }
+}
+
+void flatten(const image &im, const rgb &ca, const rgb &cb)
+{
+ if(!checkImage(im))
+ return;
+
+ s32 r1 = ca.r; s32 r2 = cb.r;
+ s32 g1 = ca.g; s32 g2 = cb.g;
+ s32 b1 = ca.b; s32 b2 = cb.b;
+ s32 min = 0, max = 255;
+ s32 mean;
+
+ rgba *bits;
+ rgb _rgb;
+
+ for(s32 y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;++x)
+ {
+ mean = (bits->r + bits->g + bits->b) / 3;
+ min = F_MIN(min, mean);
+ max = F_MAX(max, mean);
+ bits++;
+ }
+ }
+
+ // Conversion factors
+ float sr = ((float) r2 - r1) / (max - min);
+ float sg = ((float) g2 - g1) / (max - min);
+ float sb = ((float) b2 - b1) / (max - min);
+
+ // Repaint the image
+ for(s32 y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.w*y;
+
+ for(s32 x = 0;x < im.w;++x)
+ {
+ mean = (bits->r + bits->g + bits->b) / 3;
+
+ bits->r = (s32)(sr * (mean - min) + r1 + 0.5);
+ bits->g = (s32)(sg * (mean - min) + g1 + 0.5);
+ bits->b = (s32)(sb * (mean - min) + b1 + 0.5);
+
+ bits++;
+ }
+ }
+}
+
+void fade(const image &im, const rgb &rgb, float val)
+{
+ if(!checkImage(im))
+ return;
+
+ u8 tbl[256];
+
+ for (s32 i = 0;i < 256;i++)
+ tbl[i] = (s32)(val * i + 0.5);
+
+ s32 r, g, b, cr, cg, cb;
+
+ rgba *bits;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ cr = bits->r;
+ cg = bits->g;
+ cb = bits->b;
+
+ r = (cr > rgb.r) ? (cr - tbl[cr - rgb.r]) : (cr + tbl[rgb.r - cr]);
+ g = (cg > rgb.g) ? (cg - tbl[cg - rgb.g]) : (cg + tbl[rgb.g - cg]);
+ b = (cb > rgb.b) ? (cb - tbl[cb - rgb.b]) : (cb + tbl[rgb.b - cb]);
+
+ bits->r = r;
+ bits->g = g;
+ bits->b = b;
+
+ bits++;
+ }
+ }
+}
+
+void gray(const image &im)
+{
+ if(!checkImage(im))
+ return;
+
+ rgba *bits;
+ s32 g;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ g = (bits->r * 11 + bits->g * 16 + bits->b * 5)/32;
+
+ bits->r = g;
+ bits->g = g;
+ bits->b = g;
+
+ bits++;
+ }
+ }
+}
+
+void desaturate(const image &im, float desat)
+{
+ if(!checkImage(im))
+ return;
+
+ scaleDown(desat, 0.0f, 1.0f);
+
+ rgba *bits;
+ s32 h = 0, s = 0, v = 0;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ rgb _rgb(bits->r, bits->g, bits->b);
+ rgb2hsv(_rgb, &h, &s, &v);
+ hsv2rgb(h, (s32)(s * (1.0 - desat)), v, &_rgb);
+
+ bits->r = _rgb.r;
+ bits->g = _rgb.g;
+ bits->b = _rgb.b;
+
+ bits++;
+ }
+ }
+}
+
+void threshold(const image &im, u32 trh)
+{
+ if(!checkImage(im))
+ return;
+
+ scaleDown(trh, (u32)0, (u32)255);
+
+ rgba *bits;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ if(intensityValue(bits->r, bits->g, bits->b) < trh)
+ bits->r = bits->g = bits->b = 0;
+ else
+ bits->r = bits->g = bits->b = 255;
+
+ bits++;
+ }
+ }
+}
+
+void solarize(const image &im, double factor)
+{
+ if(!checkImage(im))
+ return;
+
+ s32 threshold;
+ rgba *bits;
+
+ threshold = (s32)(factor * (MaxRGB+1)/100.0);
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ bits->r = bits->r > threshold ? MaxRGB-bits->r : bits->r;
+ bits->g = bits->g > threshold ? MaxRGB-bits->g : bits->g;
+ bits->b = bits->b > threshold ? MaxRGB-bits->b : bits->b;
+
+ bits++;
+ }
+ }
+}
+
+void spread(const image &im, u32 amount)
+{
+ if(!checkImage(im) || im.w < 3 || im.h < 3)
+ return;
+
+ rgba *n = new rgba [im.rw * im.rh];
+
+ if(!n)
+ return;
+
+ s32 quantum;
+ s32 x_distance, y_distance;
+ rgba *bits = (rgba *)im.data, *q;
+
+ memcpy(n, im.data, im.rw * im.rh * sizeof(rgba));
+
+ quantum = (amount+1) >> 1;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ q = n + im.rw*y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ x_distance = x + ((rand() & (amount+1))-quantum);
+ y_distance = y + ((rand() & (amount+1))-quantum);
+ x_distance = F_MIN(x_distance, im.w-1);
+ y_distance = F_MIN(y_distance, im.h-1);
+
+ if(x_distance < 0) x_distance = 0;
+ if(y_distance < 0) y_distance = 0;
+
+ *q++ = *(bits + y_distance*im.rw + x_distance);
+ }
+ }
+
+ memcpy(im.data, n, im.rw * im.rh * sizeof(rgba));
+
+ delete [] n;
+}
+
+void swirl(const image &im, double degrees, const rgba &background)
+{
+ if(!checkImage(im))
+ return;
+
+ double cosine, distance, factor, radius, sine, x_center, x_distance,
+ x_scale, y_center, y_distance, y_scale;
+ s32 x, y;
+
+ rgba *q, *p;
+ rgba *bits = (rgba *)im.data;
+ rgba *dest = new rgba [im.rw * im.rh];
+
+ if(!dest)
+ return;
+
+ memcpy(dest, im.data, im.rw * im.rh * sizeof(rgba));
+
+ // compute scaling factor
+ x_center = im.w / 2.0;
+ y_center = im.h / 2.0;
+
+ radius = F_MAX(x_center, y_center);
+ x_scale=1.0;
+ y_scale=1.0;
+
+ if(im.w > im.h)
+ y_scale=(double)im.w / im.h;
+ else if(im.w < im.h)
+ x_scale=(double)im.h / im.w;
+
+ degrees = DegreesToRadians(degrees);
+
+ // swirl each row
+
+ for(y = 0;y < im.h;y++)
+ {
+ p = bits + im.rw * y;
+ q = dest + im.rw * y;
+ y_distance = y_scale * (y-y_center);
+
+ for(x = 0;x < im.w;x++)
+ {
+ // determine if the pixel is within an ellipse
+ *q = *p;
+ x_distance = x_scale*(x-x_center);
+ distance = x_distance*x_distance+y_distance*y_distance;
+
+ if(distance < (radius*radius))
+ {
+ // swirl
+ factor = 1.0 - sqrt(distance)/radius;
+ sine = sin(degrees*factor*factor);
+ cosine = cos(degrees*factor*factor);
+
+ *q = interpolateColor(im,
+ (cosine*x_distance-sine*y_distance)/x_scale+x_center,
+ (sine*x_distance+cosine*y_distance)/y_scale+y_center,
+ background);
+ }
+
+ p++;
+ q++;
+ }
+ }
+
+ memcpy(im.data, dest, im.rw * im.rh * sizeof(rgba));
+
+ delete [] dest;
+}
+
+void noise(const image &im, NoiseType noise_type)
+{
+ if(!checkImage(im))
+ return;
+
+ s32 x, y;
+ rgba *dest = new rgba [im.rw * im.rh];
+
+ if(!dest)
+ return;
+
+ rgba *bits;
+ rgba *destData;
+
+ for(y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+ destData = dest + im.rw * y;
+
+ for(x = 0;x < im.w;++x)
+ {
+ destData[x].r = generateNoise(bits->r, noise_type);
+ destData[x].g = generateNoise(bits->g, noise_type);
+ destData[x].b = generateNoise(bits->b, noise_type);
+ destData[x].a = bits->a;
+
+ bits++;
+ }
+ }
+
+ memcpy(im.data, dest, im.rw * im.rh * sizeof(rgba));
+
+ delete [] dest;
+}
+
+void implode(const image &im, double _factor, const rgba &background)
+{
+ if(!checkImage(im))
+ return;
+
+ double amount, distance, radius;
+ double x_center, x_distance, x_scale;
+ double y_center, y_distance, y_scale;
+ rgba *dest;
+ s32 x, y;
+
+ rgba *n = new rgba [im.rw * im.rh];
+
+ if(!n)
+ return;
+
+ rgba *bits;
+
+ // compute scaling factor
+ x_scale = 1.0;
+ y_scale = 1.0;
+ x_center = (double)0.5*im.w;
+ y_center = (double)0.5*im.h;
+ radius=x_center;
+
+ if(im.w > im.h)
+ y_scale = (double)im.w/im.h;
+ else if(im.w < im.h)
+ {
+ x_scale = (double)im.h/im.w;
+ radius = y_center;
+ }
+
+ amount=_factor/10.0;
+
+ if(amount >= 0)
+ amount/=10.0;
+
+ double factor;
+
+ for(y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+ dest = n + im.rw * y;
+
+ y_distance = y_scale * (y-y_center);
+
+ for(x = 0;x < im.w;++x)
+ {
+ x_distance = x_scale*(x-x_center);
+ distance= x_distance*x_distance+y_distance*y_distance;
+
+ if(distance < (radius*radius))
+ {
+ // Implode the pixel.
+ factor = 1.0;
+
+ if(distance > 0.0)
+ factor = pow(sin(0.5000000000000001*M_PI*sqrt(distance)/radius),-amount);
+
+ *dest = interpolateColor(im, factor*x_distance/x_scale+x_center,
+ factor*y_distance/y_scale+y_center,
+ background);
+ }
+ else
+ *dest = *bits;
+
+ bits++;
+ dest++;
+ }
+ }
+
+ memcpy(im.data, n, im.rw * im.rh * sizeof(rgba));
+
+ delete [] n;
+}
+
+void despeckle(const image &im)
+{
+ if(!checkImage(im))
+ return;
+
+ s32 i, j, x, y;
+ u8 *blue_channel, *red_channel, *green_channel, *buffer, *alpha_channel;
+ s32 packets;
+
+ static const s32
+ X[4] = {0, 1, 1,-1},
+ Y[4] = {1, 0, 1, 1};
+
+ rgba *n = new rgba [im.rw * im.rh];
+
+ if(!n)
+ return;
+
+ packets = (im.w+2) * (im.h+2);
+
+ red_channel = new u8 [packets];
+ green_channel = new u8 [packets];
+ blue_channel = new u8 [packets];
+ alpha_channel = new u8 [packets];
+ buffer = new u8 [packets];
+
+ if(!red_channel || ! green_channel || ! blue_channel || ! alpha_channel || !buffer)
+ {
+ if(red_channel) delete [] red_channel;
+ if(green_channel) delete [] green_channel;
+ if(blue_channel) delete [] blue_channel;
+ if(alpha_channel) delete [] alpha_channel;
+ if(buffer) delete [] buffer;
+
+ delete [] n;
+
+ return;
+ }
+
+ // copy image pixels to color component buffers
+ j = im.w+2;
+
+ rgba *bits;
+
+ for(y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.rw*y;
+ ++j;
+
+ for(x = 0;x < im.w;++x)
+ {
+ red_channel[j] = bits->r;
+ green_channel[j] = bits->g;
+ blue_channel[j] = bits->b;
+ alpha_channel[j] = bits->a;
+
+ bits++;
+ ++j;
+ }
+
+ ++j;
+ }
+
+ // reduce speckle in red channel
+ for(i = 0;i < 4;i++)
+ {
+ hull(X[i],Y[i],1,im.w,im.h,red_channel,buffer);
+ hull(-X[i],-Y[i],1,im.w,im.h,red_channel,buffer);
+ hull(-X[i],-Y[i],-1,im.w,im.h,red_channel,buffer);
+ hull(X[i],Y[i],-1,im.w,im.h,red_channel,buffer);
+ }
+
+ // reduce speckle in green channel
+ for(i = 0;i < packets;i++)
+ buffer[i] = 0;
+
+ for(i = 0;i < 4;i++)
+ {
+ hull(X[i],Y[i],1,im.w,im.h,green_channel,buffer);
+ hull(-X[i],-Y[i],1,im.w,im.h,green_channel,buffer);
+ hull(-X[i],-Y[i],-1,im.w,im.h,green_channel,buffer);
+ hull(X[i],Y[i],-1,im.w,im.h,green_channel,buffer);
+ }
+
+ // reduce speckle in blue channel
+ for(i = 0;i < packets;i++)
+ buffer[i] = 0;
+
+ for(i = 0;i < 4;i++)
+ {
+ hull(X[i],Y[i],1,im.w,im.h,blue_channel,buffer);
+ hull(-X[i],-Y[i],1,im.w,im.h,blue_channel,buffer);
+ hull(-X[i],-Y[i],-1,im.w,im.h,blue_channel,buffer);
+ hull(X[i],Y[i],-1,im.w,im.h,blue_channel,buffer);
+ }
+
+ // copy color component buffers to despeckled image
+ j = im.w+2;
+
+ for(y = 0;y < im.h;++y)
+ {
+ bits = n + im.rw*y;
+ ++j;
+
+ for(x = 0;x < im.w;++x)
+ {
+ *bits = rgba(red_channel[j], green_channel[j], blue_channel[j], alpha_channel[j]);
+
+ bits++;
+ ++j;
+ }
+
+ ++j;
+ }
+
+ delete [] buffer;
+ delete [] red_channel;
+ delete [] green_channel;
+ delete [] blue_channel;
+ delete [] alpha_channel;
+
+ memcpy(im.data, n, im.rw * im.rh * sizeof(rgba));
+
+ delete [] n;
+}
+
+void blur(const image &im, double radius, double sigma)
+{
+ if(!checkImage(im))
+ return;
+
+ double *kernel;
+ rgba *dest;
+ s32 width;
+ s32 x, y;
+ rgba *scanline, *temp;
+ rgba *p, *q;
+
+ if(sigma == 0.0)
+ return;
+
+ kernel = 0;
+
+ if(radius > 0)
+ width = getBlurKernel((s32)(2*ceil(radius)+1), sigma, &kernel);
+ else
+ {
+ double *last_kernel = 0;
+
+ width = getBlurKernel(3, sigma, &kernel);
+
+ while((long)(MaxRGB * kernel[0]) > 0)
+ {
+ if(last_kernel)
+ delete [] last_kernel;
+
+ last_kernel = kernel;
+ kernel = 0;
+
+ width = getBlurKernel(width+2, sigma, &kernel);
+ }
+
+ if(last_kernel)
+ {
+ delete [] kernel;
+ width -= 2;
+ kernel = last_kernel;
+ }
+ }
+
+ if(width < 3)
+ {
+ delete [] kernel;
+ return;
+ }
+
+ dest = new rgba [im.rw * im.rh];
+
+ if(!dest)
+ {
+ delete [] kernel;
+ return;
+ }
+
+ scanline = new rgba [im.h];
+ temp = new rgba [im.h];
+
+ if(!scanline || !temp)
+ {
+ if(scanline) delete [] scanline;
+ if(temp) delete [] temp;
+
+ delete [] kernel;
+ return;
+ }
+
+ rgba *bits = (rgba *)im.data;
+
+ for(y = 0;y < im.h;++y)
+ {
+ p = bits + im.rw*y;
+ q = dest + im.rw*y;
+
+ blurScanLine(kernel, width, p, q, im.w);
+ }
+
+ for(x = 0;x < im.w;++x)
+ {
+ for(y = 0;y < im.h;++y)
+ scanline[y] = *(bits + im.rw*y + x);
+
+ blurScanLine(kernel, width, scanline, temp, im.h);
+
+ for(y = 0;y < im.h;++y)
+ *(dest + im.rw*y + x) = temp[y];
+
+ }
+
+ delete [] scanline;
+ delete [] temp;
+ delete [] kernel;
+
+ memcpy(im.data, dest, im.rw * im.rh * sizeof(rgba));
+
+ delete [] dest;
+}
+
+void equalize(const image &im)
+{
+ if(!checkImage(im))
+ return;
+
+ double_packet high, low, intensity, *map, *histogram;
+ short_packet *equalize_map;
+ s32 x, y;
+ rgba *p, *q;
+ long i;
+ u8 r, g, b, a;
+
+ histogram = new double_packet [256];
+ map = new double_packet [256];
+ equalize_map = new short_packet [256];
+
+ if(!histogram || !map || !equalize_map)
+ {
+ if(histogram) delete [] histogram;
+ if(map) delete [] map;
+ if(equalize_map) delete [] equalize_map;
+
+ return;
+ }
+
+ rgba *bits = (rgba *)im.data;
+
+ /*
+ * Form histogram.
+ */
+ memset(histogram, 0, 256 * sizeof(double_packet));
+
+ for(y = 0;y < im.h;++y)
+ {
+ p = bits + im.rw * y;
+
+ for(x = 0;x < im.w;++x)
+ {
+ histogram[p->r].red++;
+ histogram[p->g].green++;
+ histogram[p->b].blue++;
+ histogram[p->a].alpha++;
+
+ p++;
+ }
+ }
+ /*
+ Integrate the histogram to get the equalization map.
+ */
+ memset(&intensity, 0 ,sizeof(double_packet));
+
+ for(i = 0;i < 256;++i)
+ {
+ intensity.red += histogram[i].red;
+ intensity.green += histogram[i].green;
+ intensity.blue += histogram[i].blue;
+ intensity.alpha += histogram[i].alpha;
+
+ map[i] = intensity;
+ }
+
+ low=map[0];
+ high=map[255];
+ memset(equalize_map, 0, 256 * sizeof(short_packet));
+
+ for(i = 0;i < 256;++i)
+ {
+ if(high.red != low.red)
+ equalize_map[i].red=(unsigned short)
+ ((65535*(map[i].red-low.red))/(high.red-low.red));
+ if(high.green != low.green)
+ equalize_map[i].green=(unsigned short)
+ ((65535*(map[i].green-low.green))/(high.green-low.green));
+ if(high.blue != low.blue)
+ equalize_map[i].blue=(unsigned short)
+ ((65535*(map[i].blue-low.blue))/(high.blue-low.blue));
+ if(high.alpha != low.alpha)
+ equalize_map[i].alpha=(unsigned short)
+ ((65535*(map[i].alpha-low.alpha))/(high.alpha-low.alpha));
+ }
+
+ delete [] histogram;
+ delete [] map;
+
+ /*
+ Stretch the histogram.
+ */
+ for(y = 0;y < im.h;++y)
+ {
+ q = bits + im.rw*y;
+
+ for(x = 0;x < im.w;++x)
+ {
+ if(low.red != high.red)
+ r = (equalize_map[(unsigned short)(q->r)].red/257);
+ else
+ r = q->r;
+ if(low.green != high.green)
+ g = (equalize_map[(unsigned short)(q->g)].green/257);
+ else
+ g = q->g;
+ if(low.blue != high.blue)
+ b = (equalize_map[(unsigned short)(q->b)].blue/257);
+ else
+ b = q->b;
+ if(low.alpha != high.alpha)
+ a = (equalize_map[(unsigned short)(q->a)].alpha/257);
+ else
+ a = q->a;
+
+ *q = rgba(r, g, b, a);
+
+ q++;
+ }
+ }
+
+ delete [] equalize_map;
+}
+
+struct PointInfo
+{
+ double x, y, z;
+};
+
+void shade(const image &im, bool color_shading, double azimuth,
+ double elevation)
+{
+ if(!checkImage(im))
+ return;
+
+ rgba *n = new rgba [im.rw * im.rh];
+
+ if(!n)
+ return;
+
+ double distance, normal_distance, shade;
+ s32 x, y;
+
+ struct PointInfo light, normal;
+
+ rgba *bits;
+ rgba *q;
+
+ azimuth = DegreesToRadians(azimuth);
+ elevation = DegreesToRadians(elevation);
+ light.x = MaxRGB*cos(azimuth)*cos(elevation);
+ light.y = MaxRGB*sin(azimuth)*cos(elevation);
+ light.z = MaxRGB*sin(elevation);
+ normal.z= 2*MaxRGB; // constant Z of surface normal
+
+ rgba *s0, *s1, *s2;
+
+ for(y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.rw * (F_MIN(F_MAX(y-1,0),im.h-3));
+ q = n + im.rw * y;
+
+ // shade this row of pixels.
+ *q++ = (*(bits+im.rw));
+ bits++;
+
+ s0 = bits;
+ s1 = bits + im.rw;
+ s2 = bits + 2*im.rw;
+
+ for(x = 1;x < im.w-1;++x)
+ {
+ // determine the surface normal and compute shading.
+ normal.x = intensityValue(*(s0-1))+intensityValue(*(s1-1))+intensityValue(*(s2-1))-
+ (double) intensityValue(*(s0+1))-(double) intensityValue(*(s1+1))-
+ (double) intensityValue(*(s2+1));
+
+ normal.y = intensityValue(*(s2-1))+intensityValue(*s2)+intensityValue(*(s2+1))-
+ (double) intensityValue(*(s0-1))-(double) intensityValue(*s0)-
+ (double) intensityValue(*(s0+1));
+
+ if(normal.x == 0 && normal.y == 0)
+ shade = light.z;
+ else
+ {
+ shade = 0.0;
+ distance = normal.x*light.x+normal.y*light.y+normal.z*light.z;
+
+ if(distance > 0.0)
+ {
+ normal_distance = normal.x*normal.x+normal.y*normal.y+normal.z*normal.z;
+
+ if(fabs(normal_distance) > 0.0000001)
+ shade=distance/sqrt(normal_distance);
+ }
+ }
+
+ if(!color_shading)
+ {
+ *q = rgba((u8)(shade),
+ (u8)(shade),
+ (u8)(shade),
+ s1->a);
+ }
+ else
+ {
+ *q = rgba((u8)((shade * s1->r)/(MaxRGB+1)),
+ (u8)((shade * s1->g)/(MaxRGB+1)),
+ (u8)((shade * s1->b)/(MaxRGB+1)),
+ s1->a);
+ }
+
+ ++s0;
+ ++s1;
+ ++s2;
+ q++;
+ }
+
+ *q++ = (*s1);
+ }
+
+ memcpy(im.data, n, im.rw * im.rh * sizeof(rgba));
+
+ delete [] n;
+}
+
+void edge(image &im, double radius)
+{
+ if(!checkImage(im))
+ return;
+
+ double *kernel;
+ int width;
+ long i;
+ rgba *dest = 0;
+
+ width = getOptimalKernelWidth(radius, 0.5);
+
+ const int W = width*width;
+
+ if(im.w < width || im.h < width)
+ return;
+
+ kernel = new double [W];
+
+ if(!kernel)
+ return;
+
+ for(i = 0;i < W;i++)
+ kernel[i] = -1.0;
+
+ kernel[i/2] = W-1.0;
+
+ if(!convolveImage(&im, &dest, width, kernel))
+ {
+ delete [] kernel;
+
+ if(dest)
+ delete [] dest;
+
+ return;
+ }
+
+ delete [] kernel;
+
+ memcpy(im.data, dest, im.rw * im.rh * sizeof(rgba));
+
+ delete [] dest;
+}
+
+void emboss(image &im, double radius, double sigma)
+{
+ if(!checkImage(im))
+ return;
+
+ double alpha, *kernel;
+ int j, width;
+ long i, u, v;
+ rgba *dest = 0;
+
+ if(sigma == 0.0)
+ return;
+
+ width = getOptimalKernelWidth(radius, sigma);
+
+ if(im.w < width || im.h < width)
+ return;
+
+ kernel = new double [width*width];
+
+ if(!kernel)
+ return;
+
+ i = 0;
+ j = width/2;
+
+ const double S = sigma * sigma;
+
+ for(v = (-width/2);v <= (width/2);v++)
+ {
+ for(u=(-width/2); u <= (width/2); u++)
+ {
+ alpha = exp(-((double) u*u+v*v)/(2.0*S));
+
+ kernel[i] = ((u < 0) || (v < 0) ? -8.0 : 8.0)*alpha/(2.0*MagickPI*S);
+
+ if (u == j)
+ kernel[i]=0.0;
+
+ i++;
+ }
+
+ j--;
+ }
+
+ if(!convolveImage(&im, &dest, width, kernel))
+ {
+ delete [] kernel;
+ return;
+ }
+
+ delete [] kernel;
+
+ fmt_filters::image mm((u8 *)dest, im.w, im.h, im.rw, im.rh);
+
+ equalize(mm);
+
+ memcpy(im.data, dest, im.rw * im.rh * sizeof(rgba));
+
+ delete [] dest;
+}
+
+void sharpen(image &im, double radius, double sigma)
+{
+ if(!checkImage(im))
+ return;
+
+ double alpha, normalize, *kernel;
+ int width;
+ long i, u, v;
+ rgba *dest = 0;
+
+ if(sigma == 0.0)
+ sigma = 0.01;
+
+ width = getOptimalKernelWidth(radius, sigma);
+
+ if(im.w < width)
+ return;
+
+ kernel = new double [width*width];
+
+ if(!kernel)
+ return;
+
+ i = 0;
+ normalize = 0.0;
+ const double S = sigma * sigma;
+ const int w2 = width / 2;
+
+ for(v = -w2; v <= w2; v++)
+ {
+ for(u = -w2; u <= w2; u++)
+ {
+ alpha = exp(-((double) u*u+v*v)/(2.0*S));
+ kernel[i] = alpha/(2.0*MagickPI*S);
+ normalize += kernel[i];
+
+ i++;
+ }
+ }
+
+ kernel[i/2] = (-2.0)*normalize;
+
+ if(!convolveImage(&im, &dest, width, kernel))
+ {
+ delete [] kernel;
+
+ if(dest)
+ delete [] dest;
+
+ return;
+ }
+
+ delete [] kernel;
+
+ memcpy(im.data, dest, im.rw * im.rh * sizeof(rgba));
+
+ delete [] dest;
+}
+
+void oil(const image &im, double radius)
+{
+ if(!checkImage(im))
+ return;
+
+ unsigned long count;
+ unsigned long histogram[256];
+ unsigned int k;
+ int width;
+ int x, y, mx, my, sx, sy;
+ int mcx, mcy;
+ rgba *s = 0, *q;
+
+ scaleDown(radius, 1.0, 5.0);
+
+ rgba *n = new rgba [im.rw * im.rh];
+
+ if(!n)
+ return;
+
+ memcpy(n, im.data, im.rw * im.rh * sizeof(rgba));
+
+ width = getOptimalKernelWidth(radius, 0.5);
+
+ if(im.w < width)
+ {
+ delete [] n;
+ return;
+ }
+
+ rgba *bits = (rgba *)im.data;
+
+ for(y = 0;y < im.h;++y)
+ {
+ sy = y-(width/2);
+ q = n + im.rw*y;
+
+ for(x = 0;x < im.w;++x)
+ {
+ count = 0;
+ memset(histogram, 0, 256 * sizeof(unsigned long));
+ sy = y-(width/2);
+
+ for(mcy = 0;mcy < width;++mcy,++sy)
+ {
+ my = sy < 0 ? 0 : sy > im.h-1 ? im.h-1 : sy;
+ sx = x+(-width/2);
+
+ for(mcx = 0; mcx < width;++mcx,++sx)
+ {
+ mx = sx < 0 ? 0 : sx > im.w-1 ? im.w-1 : sx;
+
+ k = intensityValue(*(bits + my*im.rw + mx));
+
+ if(k > 255) k = 255;
+
+ histogram[k]++;
+
+ if(histogram[k] > count)
+ {
+ count = histogram[k];
+ s = bits + my*im.rw + mx;
+ }
+ }
+ }
+
+ *q++ = (*s);
+ }
+ }
+
+ memcpy(im.data, n, im.rw * im.rh * sizeof(rgba));
+
+ delete [] n;
+}
+/*
+ * Red-eye removal was taken from "redeye" plugin for GIMP
+ */
+
+/* redeye.c: redeye remover plugin code
+ *
+ * Copyright (C) 2004 Robert Merkel <[email protected]> (the "Author").
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Author of the
+ * Software shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Author.
+1;3B */
+
+void redeye(const image &im, const int w, const int h, const int x, const int y, int th)
+{
+ const double RED_FACTOR = 0.5133333;
+ const double GREEN_FACTOR = 1;
+ const double BLUE_FACTOR = 0.1933333;
+
+ if(!checkImage(im))
+ return;
+
+ scaleDown(th, 0, 255);
+
+ int y1, x1;
+ int adjusted_red, adjusted_green, adjusted_blue;
+
+ rgba *src = (rgba *)im.data, *s;
+
+ for(y1 = y;y1 < y+h;++y1)
+ {
+ s = src + im.w*y1 + x;
+
+ for(x1 = x;x1 < x+w;x1++)
+ {
+ adjusted_red = int(s->r * RED_FACTOR);
+ adjusted_green = int(s->g * GREEN_FACTOR);
+ adjusted_blue = int(s->b * BLUE_FACTOR);
+
+ if(adjusted_red >= adjusted_green - th && adjusted_red >= adjusted_blue - th)
+ s->r = (int)(((double)(adjusted_green + adjusted_blue)) / (2.0 * RED_FACTOR));
+
+ s++;
+ }
+ }
+}
+
+
+/*************************************************************************/
+
+/*
+ *
+ * Helper functions
+ *
+ */
+
+/*************************************************************************/
+
+static bool convolveImage(image *image, rgba **dest, const unsigned int order,
+ const double *kernel)
+{
+ long width;
+ double red, green, blue;
+ u8 alpha;
+ double normalize, *normal_kernel;
+ const double *k;
+ rgba *q;
+ int x, y, mx, my, sx, sy;
+ long i;
+ int mcx, mcy;
+
+ width = order;
+
+ if((width % 2) == 0)
+ return false;
+
+ const int W = width*width;
+
+ normal_kernel = new double [W];
+
+ if(!normal_kernel)
+ return false;
+
+ *dest = new rgba [image->rw * image->rh];
+
+ if(!*dest)
+ {
+ delete [] normal_kernel;
+ return false;
+ }
+
+ normalize = 0.0;
+
+ for(i = 0;i < W;i++)
+ normalize += kernel[i];
+
+ if(fabs(normalize) <= MagickEpsilon)
+ normalize = 1.0;
+
+ normalize=1.0/normalize;
+
+ for(i = 0;i < W;i++)
+ normal_kernel[i] = normalize*kernel[i];
+
+ rgba *bits = (rgba *)image->data;
+
+ for(y = 0;y < image->h;++y)
+ {
+ sy = y-(width/2);
+ q = *dest + image->rw * y;
+
+ for(x = 0;x < image->w;++x)
+ {
+ k = normal_kernel;
+ red = green = blue = alpha = 0;
+ sy = y-(width/2);
+ alpha = (bits + image->rw*y+x)->a;
+
+ for(mcy=0; mcy < width; ++mcy, ++sy)
+ {
+ my = sy < 0 ? 0 : sy > image->h-1 ? image->h-1 : sy;
+ sx = x+(-width/2);
+
+ for(mcx=0; mcx < width; ++mcx, ++sx)
+ {
+ mx = sx < 0 ? 0 : sx > image->w-1 ? image->w-1 : sx;
+ red += (*k) * ((bits + image->rw*my+mx)->r*257);
+ green += (*k) * ((bits + image->rw*my+mx)->g*257);
+ blue += (*k) * ((bits + image->rw*my+mx)->b*257);
+// alpha += (*k) * ((bits + image->rw*my+mx)->a*257);
+
+ ++k;
+ }
+ }
+
+ red = red < 0 ? 0 : red > 65535 ? 65535 : red+0.5;
+ green = green < 0 ? 0 : green > 65535 ? 65535 : green+0.5;
+ blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue+0.5;
+// alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha+0.5;
+
+ *q++ = rgba((unsigned char)(red/257UL),
+ (unsigned char)(green/257UL),
+ (unsigned char)(blue/257UL),
+ alpha);
+ }
+ }
+
+ delete [] normal_kernel;
+
+ return true;
+}
+
+static void rgb2hsv(const rgb &rgb, s32 *h, s32 *s, s32 *v)
+{
+ if(!h || !s || !v)
+ return;
+
+ s32 r = rgb.r;
+ s32 g = rgb.g;
+ s32 b = rgb.b;
+
+ u32 max = r;
+ s32 whatmax = 0; // r=>0, g=>1, b=>2
+
+ if((u32)g > max)
+ {
+ max = g;
+ whatmax = 1;
+ }
+
+ if((u32)b > max)
+ {
+ max = b;
+ whatmax = 2;
+ }
+
+ u32 min = r; // find minimum value
+ if((u32)g < min) min = g;
+ if((u32)b < min) min = b;
+
+ s32 delta = max-min;
+ *v = max; // calc value
+ *s = max ? (510*delta+max)/(2*max) : 0;
+
+ if(*s == 0)
+ {
+ *h = -1; // undefined hue
+ }
+ else
+ {
+ switch(whatmax)
+ {
+ case 0: // red is max component
+ if(g >= b)
+ *h = (120*(g-b)+delta)/(2*delta);
+ else
+ *h = (120*(g-b+delta)+delta)/(2*delta) + 300;
+ break;
+
+ case 1: // green is max component
+ if(b > r)
+ *h = 120 + (120*(b-r)+delta)/(2*delta);
+ else
+ *h = 60 + (120*(b-r+delta)+delta)/(2*delta);
+ break;
+
+ case 2: // blue is max component
+ if(r > g)
+ *h = 240 + (120*(r-g)+delta)/(2*delta);
+ else
+ *h = 180 + (120*(r-g+delta)+delta)/(2*delta);
+ break;
+ }
+ }
+}
+
+static void hsv2rgb(s32 h, s32 s, s32 v, rgb *rgb)
+{
+ if(h < -1 || (u32)s > 255 || (u32)v > 255 || !rgb)
+ return;
+
+ s32 r = v, g = v, b = v;
+
+ if(s == 0 || h == -1)
+ {
+ // Ignore
+ }
+ else
+ { // chromatic case
+ if((u32)h >= 360)
+ h %= 360;
+
+ u32 f = h%60;
+ h /= 60;
+ u32 p = (u32)(2*v*(255-s)+255)/510;
+ u32 q, t;
+
+ if(h&1)
+ {
+ q = (u32)(2*v*(15300-s*f)+15300)/30600;
+
+ switch(h)
+ {
+ case 1: r=(s32)q; g=(s32)v, b=(s32)p; break;
+ case 3: r=(s32)p; g=(s32)q, b=(s32)v; break;
+ case 5: r=(s32)v; g=(s32)p, b=(s32)q; break;
+ }
+ }
+ else
+ {
+ t = (u32)(2*v*(15300-(s*(60-f)))+15300)/30600;
+
+ switch(h)
+ {
+ case 0: r=(s32)v; g=(s32)t, b=(s32)p; break;
+ case 2: r=(s32)p; g=(s32)v, b=(s32)t; break;
+ case 4: r=(s32)t; g=(s32)p, b=(s32)v; break;
+ }
+ }
+ }
+
+ rgb->r = r;
+ rgb->g = g;
+ rgb->b = b;
+}
+
+static rgba interpolateColor(const image &im, double x_offset, double y_offset, const rgba &background)
+{
+ double alpha, beta;
+ rgba p, q, r, s;
+ s32 x, y;
+ rgba *bits = (rgba *)im.data;
+
+ if(!checkImage(im))
+ return background;
+
+ x = (s32)x_offset;
+ y = (s32)y_offset;
+
+ if((x < -1) || (x >= im.w) || (y < -1) || (y >= im.h))
+ return background;
+
+ if((x >= 0) && (y >= 0) && (x < (im.w-1)) && (y < (im.h-1)))
+ {
+ rgba *t = bits + y * im.rw;
+
+ p = t[x];
+ q = t[x+1];
+ r = t[x+im.rw];
+ s = t[x+im.rw+1];
+ }
+ else
+ {
+ rgba *t = bits + y * im.rw;
+
+ p = background;
+
+ if((x >= 0) && (y >= 0))
+ p = t[x];
+
+ q = background;
+
+ if(((x+1) < im.w) && (y >= 0))
+ q = t[x+1];
+
+ r = background;
+
+ if((x >= 0) && ((y+1) < im.h))
+ {
+ t = bits + (y+1) * im.rw;
+ r = t[x+im.rw];
+ }
+
+ s = background;
+
+ if(((x+1) < im.w) && ((y+1) < im.h))
+ {
+ t = bits + (y+1) * im.rw;
+ s = t[x+im.rw+1];
+ }
+ }
+
+ x_offset -= floor(x_offset);
+ y_offset -= floor(y_offset);
+ alpha = 1.0-x_offset;
+ beta = 1.0-y_offset;
+
+ rgba _r;
+
+ _r.r = (u8)(beta * (alpha*p.r + x_offset*q.r) + y_offset * (alpha*r.r + x_offset*s.r));
+ _r.g = (u8)(beta * (alpha*p.g + x_offset*q.g) + y_offset * (alpha*r.g + x_offset*s.g));
+ _r.b = (u8)(beta * (alpha*p.b + x_offset*q.b) + y_offset * (alpha*r.b + x_offset*s.b));
+ _r.a = (u8)(beta * (alpha*p.a + x_offset*q.a) + y_offset * (alpha*r.a + x_offset*s.a));
+
+ return _r;
+}
+
+static u32 generateNoise(u32 pixel, NoiseType noise_type)
+{
+#define NoiseEpsilon 1.0e-5
+#define NoiseMask 0x7fff
+#define SigmaUniform 4.0
+#define SigmaGaussian 4.0
+#define SigmaImpulse 0.10
+#define SigmaLaplacian 10.0
+#define SigmaMultiplicativeGaussian 0.5
+#define SigmaPoisson 0.05
+#define TauGaussian 20.0
+
+ double alpha, beta, sigma, value;
+ alpha=(double) (rand() & NoiseMask)/NoiseMask;
+ if (alpha == 0.0)
+ alpha=1.0;
+ switch(noise_type){
+ case UniformNoise:
+ default:
+ {
+ value=(double) pixel+SigmaUniform*(alpha-0.5);
+ break;
+ }
+ case GaussianNoise:
+ {
+ double tau;
+
+ beta=(double) (rand() & NoiseMask)/NoiseMask;
+ sigma=sqrt(-2.0*log(alpha))*cos(2.0*M_PI*beta);
+ tau=sqrt(-2.0*log(alpha))*sin(2.0*M_PI*beta);
+ value=(double) pixel+
+ (sqrt((double) pixel)*SigmaGaussian*sigma)+(TauGaussian*tau);
+ break;
+ }
+ case MultiplicativeGaussianNoise:
+ {
+ if (alpha <= NoiseEpsilon)
+ sigma=MaxRGB;
+ else
+ sigma=sqrt(-2.0*log(alpha));
+ beta=(rand() & NoiseMask)/NoiseMask;
+ value=(double) pixel+
+ pixel*SigmaMultiplicativeGaussian*sigma*cos(2.0*M_PI*beta);
+ break;
+ }
+ case ImpulseNoise:
+ {
+ if (alpha < (SigmaImpulse/2.0))
+ value=0;
+ else
+ if (alpha >= (1.0-(SigmaImpulse/2.0)))
+ value=MaxRGB;
+ else
+ value=pixel;
+ break;
+ }
+ case LaplacianNoise:
+ {
+ if (alpha <= 0.5)
+ {
+ if (alpha <= NoiseEpsilon)
+ value=(double) pixel-MaxRGB;
+ else
+ value=(double) pixel+SigmaLaplacian*log(2.0*alpha);
+ break;
+ }
+ beta=1.0-alpha;
+ if (beta <= (0.5*NoiseEpsilon))
+ value=(double) pixel+MaxRGB;
+ else
+ value=(double) pixel-SigmaLaplacian*log(2.0*beta);
+ break;
+ }
+ case PoissonNoise:
+ {
+ s32
+ i;
+
+ for (i=0; alpha > exp(-SigmaPoisson*pixel); i++)
+ {
+ beta=(double) (rand() & NoiseMask)/NoiseMask;
+ alpha=alpha*beta;
+ }
+ value=i/SigmaPoisson;
+ break;
+ }
+ }
+
+ if(value < 0.0)
+ return 0;
+ else if(value > MaxRGB)
+ return MaxRGB;
+ else
+ return ((u32) (value+0.5));
+}
+
+static inline u32 intensityValue(s32 r, s32 g, s32 b)
+{
+ return ((u32)((0.299*r + 0.587*g + 0.1140000000000001*b)));
+}
+
+static inline u32 intensityValue(const rgba &rr)
+{
+ return ((u32)((0.299*rr.r + 0.587*rr.g + 0.1140000000000001*rr.b)));
+}
+
+template<class T>
+static inline void scaleDown(T &val, T min, T max)
+{
+ if(val < min)
+ val = min;
+ else if(val > max)
+ val = max;
+}
+
+static void blurScanLine(double *kernel, s32 width, rgba *src, rgba *dest, s32 columns)
+{
+ double *p;
+ rgba *q;
+ s32 x;
+ long i;
+ double red, green, blue, alpha;
+ double scale = 0.0;
+
+ if(width > columns)
+ {
+ for(x = 0;x < columns;++x)
+ {
+ scale = 0.0;
+ red = blue = green = alpha = 0.0;
+ p = kernel;
+ q = src;
+
+ for(i = 0;i < columns;++i)
+ {
+ if((i >= (x-width/2)) && (i <= (x+width/2)))
+ {
+ red += (*p)*(q->r * 257);
+ green += (*p)*(q->g*257);
+ blue += (*p)*(q->b*257);
+ alpha += (*p)*(q->a*257);
+ }
+
+ if(((i+width/2-x) >= 0) && ((i+width/2-x) < width))
+ scale += kernel[i+width/2-x];
+
+ p++;
+ q++;
+ }
+
+ scale = 1.0/scale;
+ red = scale*(red+0.5);
+ green = scale*(green+0.5);
+ blue = scale*(blue+0.5);
+ alpha = scale*(alpha+0.5);
+
+ red = red < 0 ? 0 : red > 65535 ? 65535 : red;
+ green = green < 0 ? 0 : green > 65535 ? 65535 : green;
+ blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue;
+ alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha;
+
+ dest[x] = rgba((u8)(red/257UL),
+ (u8)(green/257UL),
+ (u8)(blue/257UL),
+ (u8)(alpha/257UL));
+ }
+
+ return;
+ }
+
+ for(x = 0;x < width/2;++x)
+ {
+ scale = 0.0;
+ red = blue = green = alpha = 0.0;
+ p = kernel+width/2-x;
+ q = src;
+
+ for(i = width/2-x;i < width;++i)
+ {
+ red += (*p)*(q->r*257);
+ green += (*p)*(q->g*257);
+ blue += (*p)*(q->b*257);
+ alpha += (*p)*(q->a*257);
+ scale += (*p);
+ p++;
+ q++;
+ }
+
+ scale=1.0/scale;
+
+ red = scale*(red+0.5);
+ green = scale*(green+0.5);
+ blue = scale*(blue+0.5);
+ alpha = scale*(alpha+0.5);
+
+ red = red < 0 ? 0 : red > 65535 ? 65535 : red;
+ green = green < 0 ? 0 : green > 65535 ? 65535 : green;
+ blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue;
+ alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha;
+
+ dest[x] = rgba((u8)(red/257UL),
+ (u8)(green/257UL),
+ (u8)(blue/257UL),
+ (u8)(alpha/257UL));
+ }
+
+ for(;x < columns-width/2;++x)
+ {
+ red = blue = green = alpha = 0.0;
+ p = kernel;
+ q = src+(x-width/2);
+
+ for(i = 0;i < (long)width;++i)
+ {
+ red += (*p)*(q->r*257);
+ green += (*p)*(q->g*257);
+ blue += (*p)*(q->b*257);
+ alpha += (*p)*(q->a*257);
+ p++;
+ q++;
+ }
+
+ red = scale*(red+0.5);
+ green = scale*(green+0.5);
+ blue = scale*(blue+0.5);
+ alpha = scale*(alpha+0.5);
+
+ red = red < 0 ? 0 : red > 65535 ? 65535 : red;
+ green = green < 0 ? 0 : green > 65535 ? 65535 : green;
+ blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue;
+ alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha;
+
+ dest[x] = rgba((u8)(red/257UL),
+ (u8)(green/257UL),
+ (u8)(blue/257UL),
+ (u8)(alpha/257UL));
+ }
+
+ for(;x < columns;++x)
+ {
+ red = blue = green = alpha = 0.0;
+ scale=0;
+ p = kernel;
+ q = src+(x-width/2);
+
+ for(i = 0;i < columns-x+width/2;++i)
+ {
+ red += (*p)*(q->r*257);
+ green += (*p)*(q->g*257);
+ blue += (*p)*(q->b*257);
+ alpha += (*p)*(q->a*257);
+ scale += (*p);
+ p++;
+ q++;
+ }
+
+ scale=1.0/scale;
+ red = scale*(red+0.5);
+ green = scale*(green+0.5);
+ blue = scale*(blue+0.5);
+ alpha = scale*(alpha+0.5);
+
+ red = red < 0 ? 0 : red > 65535 ? 65535 : red;
+ green = green < 0 ? 0 : green > 65535 ? 65535 : green;
+ blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue;
+ alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha;
+
+ dest[x] = rgba((u8)(red/257UL),
+ (u8)(green/257UL),
+ (u8)(blue/257UL),
+ (u8)(alpha/257UL));
+ }
+}
+
+static s32 getBlurKernel(s32 width, double sigma, double **kernel)
+{
+
+#define KernelRank 3
+#define KernelRankQ 18.0
+
+ double alpha, normalize;
+ long i;
+ s32 bias;
+
+ if(sigma == 0.0)
+ return 0;
+
+ if(width == 0)
+ width = 3;
+
+ *kernel = new double [width];
+
+ if(!*kernel)
+ return 0;
+
+ memset(*kernel, 0, width * sizeof(double));
+ bias = KernelRank * width/2;
+
+ for(i = (-bias);i <= bias; i++)
+ {
+ alpha = exp(-((double) i*i)/(KernelRankQ*sigma*sigma));
+ (*kernel)[(i+bias)/KernelRank] += alpha/(MagickSQ2PI*sigma);
+ }
+
+ normalize = 0;
+
+ for(i = 0;i < width;i++)
+ normalize += (*kernel)[i];
+
+ for(i = 0;i < width;i++)
+ (*kernel)[i] /= normalize;
+
+ return width;
+
+#undef KernelRankQ
+#undef KernelRank
+
+}
+
+static void hull(const s32 x_offset, const s32 y_offset, const s32 polarity, const s32 columns,
+ const s32 rows, u8 *f, u8 *g)
+{
+ s32 x, y;
+
+ u8 *p, *q, *r, *s;
+ u32 v;
+
+ if(f == 0 || g == 0)
+ return;
+
+ p = f+(columns+2);
+ q = g+(columns+2);
+ r = p+(y_offset*(columns+2)+x_offset);
+
+ for(y = 0;y < rows;y++)
+ {
+ p++;
+ q++;
+ r++;
+ if(polarity > 0)
+ for(x = 0;x < columns;x++)
+ {
+ v=(*p);
+ if (*r > v)
+ v++;
+ *q=v > 255 ? 255 : v;
+ p++;
+ q++;
+ r++;
+ }
+ else
+ for(x = 0;x < columns;x++)
+ {
+ v=(*p);
+ if (v > (u32) (*r+1))
+ v--;
+ *q=v;
+ p++;
+ q++;
+ r++;
+ }
+ p++;
+ q++;
+ r++;
+ }
+
+ p = f+(columns+2);
+ q = g+(columns+2);
+ r = q+(y_offset*(columns+2)+x_offset);
+ s = q-(y_offset*(columns+2)+x_offset);
+
+ for(y = 0;y < rows;y++)
+ {
+ p++;
+ q++;
+ r++;
+ s++;
+
+ if(polarity > 0)
+ for(x=0; x < (s32) columns; x++)
+ {
+ v=(*q);
+ if (((u32) (*s+1) > v) && (*r > v))
+ v++;
+ *p=v > 255 ? 255 : v;
+ p++;
+ q++;
+ r++;
+ s++;
+ }
+ else
+ for (x=0; x < columns; x++)
+ {
+ v=(*q);
+ if (((u32) (*s+1) < v) && (*r < v))
+ v--;
+ *p=v;
+ p++;
+ q++;
+ r++;
+ s++;
+ }
+
+ p++;
+ q++;
+ r++;
+ s++;
+ }
+}
+
+static int getOptimalKernelWidth(double radius, double sigma)
+{
+ double normalize, value;
+ long width;
+ long u;
+
+ if(sigma == 0.0)
+ sigma = 0.01;
+
+ if(radius > 0.0)
+ return((int)(2.0*ceil(radius)+1.0));
+
+ const double S = sigma * sigma;
+
+ for(width = 5;;)
+ {
+ normalize = 0.0;
+
+ for(u = (-width/2);u <= (width/2);u++)
+ normalize+=exp(-((double) u*u)/(2.0*S))/(MagickSQ2PI*sigma);
+
+ u = width/2;
+ value = exp(-((double) u*u)/(2.0*S))/(MagickSQ2PI*sigma)/normalize;
+
+ if((long)(65535*value) <= 0)
+ break;
+
+ width+=2;
+ }
+
+ return ((int)width-2);
+}
+
+} // namespace
diff --git a/src/fmt_filters.h b/src/fmt_filters.h
new file mode 100644
index 0000000..9f6cb5d
--- /dev/null
+++ b/src/fmt_filters.h
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 2005 Dmitry Baryshev <[email protected]>
+ */
+
+/*
+ * All methods (except redeye) in this namespace are ported from KDE 3.2.3.
+ * All of them are copyrighted by their authors. See fmt_filters_README for more.
+ */
+
+/* This file is part of the KDE libraries
+ Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <[email protected]>
+ (C) 1998, 1999 Christian Tibirna <[email protected]>
+ (C) 1998, 1999 Dirk A. Mueller <[email protected]>
+ (C) 1999 Geert Jansen <[email protected]>
+ (C) 2000 Josef Weidendorfer <[email protected]>
+ (C) 2004 Zack Rusin <[email protected]>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+//
+// ===================================================================
+// Effects originally ported from ImageMagick for PixiePlus, plus a few
+// new ones. (mosfet 05/26/2003)
+// ===================================================================
+//
+/*
+ Portions of this software are based on ImageMagick. Such portions are clearly
+marked as being ported from ImageMagick. ImageMagick is copyrighted under the
+following conditions:
+
+Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to
+making software imaging solutions freely available.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files ("ImageMagick"), to deal
+in ImageMagick without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of ImageMagick, and to permit persons to whom the ImageMagick is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of ImageMagick.
+
+The software is provided "as is", without warranty of any kind, express or
+implied, including but not limited to the warranties of merchantability,
+fitness for a particular purpose and noninfringement. In no event shall
+ImageMagick Studio be liable for any claim, damages or other liability,
+whether in an action of contract, tort or otherwise, arising from, out of or
+in connection with ImageMagick or the use or other dealings in ImageMagick.
+
+Except as contained in this notice, the name of the ImageMagick Studio shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in ImageMagick without prior written authorization from the
+ImageMagick Studio.
+*/
+
+#ifndef FMT_FILTERS_H
+#define FMT_FILTERS_H
+
+//////////////////////////////////////////
+// //
+// Pass the image through some filter //
+// //
+//////////////////////////////////////////
+
+
+namespace fmt_filters
+{
+ typedef char s8;
+ typedef unsigned char u8;
+
+ typedef short s16;
+ typedef unsigned short u16;
+
+ typedef int s32;
+ typedef unsigned int u32;
+
+ struct image
+ {
+ image() : data(0), w(0), h(0), rw(0), rh(0)
+ {}
+
+ image(unsigned char *d, int _w, int _h) : data(d), w(_w), h(_h), rw(_w), rh(_h)
+ {}
+
+ image(unsigned char *d, int _w, int _h, int _rw, int _rh) : data(d), w(_w), h(_h), rw(_rw), rh(_rh)
+ {}
+
+ unsigned char *data;
+ int w;
+ int h;
+ int rw;
+ int rh;
+ };
+
+ struct rgb
+ {
+ rgb() : r(0), g(0), b(0)
+ {}
+
+ rgb(int _r, int _g, int _b) : r(_r), g(_g), b(_b)
+ {}
+
+ unsigned char r;
+ unsigned char g;
+ unsigned char b;
+ };
+
+ struct rgba
+ {
+ rgba(int r1, int g1, int b1, int a1) : r(r1), g(g1), b(b1), a(a1)
+ {}
+
+ rgba() : r(0), g(0), b(0), a(0)
+ {}
+
+ unsigned char r;
+ unsigned char g;
+ unsigned char b;
+ unsigned char a;
+ };
+
+ enum NoiseType
+ {
+ UniformNoise = 0, // Uniform distribution
+ GaussianNoise, // Gaussian distribution
+ MultiplicativeGaussianNoise, // Multiplicative Gaussian distribution
+ ImpulseNoise, // Impulse distribution
+ LaplacianNoise, // Laplacian distribution
+ PoissonNoise // Poisson distribution
+ };
+
+
+ bool checkImage(const image &im);
+
+ // colorize the image, which is w x h, left alpha channel unchanged.
+ //
+ // it just adds to each pixel in the image
+ // aproproriate value.
+ void colorize(const image &im, int red, int green, int blue);
+
+ // change brightness of the image
+ void brightness(const image &im, int bn);
+
+ // change gamma
+ // gamma should be 0.0 <= L <= 6.0
+ //
+ // it is no problem to set L to 8.0 or 9.0, but the resulting
+ // image won't have much difference from 6.0
+ void gamma(const image &im, double L);
+
+ // change contrast with Photoshop-like method
+ // contrast should be -255 <= contrast <= 255
+ void contrast(const image &im, int contrast);
+
+ enum swapRGBtype { GBR = 0, BRG = 1 };
+
+ // negative
+ void negative(const image &im);
+
+ // swap RGB values
+ void swapRGB(const image &im, int type);
+
+ //
+ // All the following filters are ported from KDE's
+ // KImageEffect. See tdelibs/tdefx/kimageeffect.cpp
+ // for more.
+ //
+
+ // blend
+ // opacity = [0.0; 1.0]
+ void blend(const image &im, const rgb &rgb, float opacity);
+
+ // val = [0.0; 1.0]
+ void fade(const image &im, const rgb &rgb, float val);
+
+ void gray(const image &im);
+
+ // desat = [0.0; 1.0]
+ void desaturate(const image &im, float desat);
+
+ // threshold = [0; 255]
+ void threshold(const image &im, unsigned int threshold);
+
+ // factor = [0.0; 50.0]
+ void solarize(const image &im, double factor);
+
+ // amount = [1; 10]
+ void spread(const image &im, unsigned int amount);
+
+ // degrees = [-720.0; 720.0]
+ void swirl(const image &im, double degrees, const rgba &background);
+
+ void noise(const image &im, NoiseType noise_type);
+
+ void flatten(const image &im, const rgb &ca, const rgb &cb);
+
+ // azimuth = [0.0; 90.0], elevation = [0.0; 90.0]
+ void shade(const image &im, bool color, double azimuth, double elevation);
+
+ void equalize(const image &im);
+
+ // radius = [0.01; 90.0], sigma = [0.01; 50.0]
+ void blur(const image &im, double radius, double sigma);
+
+ void despeckle(const image &im);
+
+ // factor = [0; 100]
+ void implode(const image &im, double factor, const rgba &background);
+
+ // radius = [0.01; 30.0]
+ void edge(image &im, double radius);
+
+ // radius = [0.01; 99.9], sigma = [0.01; 99.9]
+ void emboss(image &im, double radius, double sigma);
+
+ // radius = [0.01; 99.9], sigma = [0.01; 30.0]
+ void sharpen(image &im, double radius, double sigma);
+
+ // radius = [1.0; 5.0]
+ void oil(const image &im, double radius);
+
+/*
+ * Red-eye removal was taken from "redeye" plugin for GIMP
+ */
+
+/* redeye.c: redeye remover plugin code
+ *
+ * Copyright (C) 2004 Robert Merkel <[email protected]> (the "Author").
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Author of the
+ * Software shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Author.
+1;3B */
+
+ // red-eye removal.
+ // th = [0; 255]
+ void redeye(const image &im, const int w, const int h,
+ const int x, const int y,
+ int th);
+
+ // Do we need some color definitions ?
+ static const rgba white = rgba(255, 255, 255, 255);
+ static const rgba black = rgba(0, 0, 0, 255);
+ static const rgba red = rgba(255, 0, 0, 255);
+ static const rgba green = rgba(0, 255, 0, 255);
+ static const rgba blue = rgba(0, 0, 255, 255);
+ static const rgba cyan = rgba(0, 255, 255, 255);
+ static const rgba magenta = rgba(255, 0, 255, 255);
+ static const rgba yellow = rgba(255, 255, 0, 255);
+ static const rgba mediumgray = rgba(128, 128, 128, 255);
+ static const rgba lightgray = rgba(160, 160, 164, 255);
+ static const rgba normalgray = rgba(192, 192, 192, 255);
+ static const rgba darkred = rgba(128, 0, 0, 255);
+ static const rgba darkgreen = rgba(0, 128, 0, 255);
+ static const rgba darkblue = rgba(0, 0, 128, 255);
+ static const rgba darkcyan = rgba(0, 128, 128, 255);
+ static const rgba darkmagenta = rgba(128, 0, 128, 255);
+ static const rgba darkyellow = rgba(128, 128, 0, 255);
+}
+
+#endif
diff --git a/src/hi16-app-ksquirrel.png b/src/hi16-app-ksquirrel.png
new file mode 100644
index 0000000..d78cdcd
--- /dev/null
+++ b/src/hi16-app-ksquirrel.png
Binary files differ
diff --git a/src/hi32-app-ksquirrel.png b/src/hi32-app-ksquirrel.png
new file mode 100644
index 0000000..42833fd
--- /dev/null
+++ b/src/hi32-app-ksquirrel.png
Binary files differ
diff --git a/src/imageedit/Makefile.am b/src/imageedit/Makefile.am
new file mode 100644
index 0000000..e513dd1
--- /dev/null
+++ b/src/imageedit/Makefile.am
@@ -0,0 +1,15 @@
+####### tdevelop will overwrite this part!!! (begin)##########
+noinst_LIBRARIES = libimageedit.a
+
+## INCLUDES were found outside tdevelop specific part
+
+libimageedit_a_METASOURCES = AUTO
+
+libimageedit_a_SOURCES = sq_writeoption.ui sq_label.cpp sq_imagefilter.ui sq_imageeditoptions.ui sq_imageconvert.ui sq_imagebcg.ui sq_converter.cpp sq_bcglabel.cpp
+
+
+EXTRA_DIST = sq_bcglabel.h sq_converter.h sq_imagebcg.ui.h sq_imageconvert.ui.h sq_imageedit.h sq_imageeditoptions.ui.h sq_imagefilter.ui.h sq_label.h sq_bcglabel.cpp sq_converter.cpp sq_imagebcg.ui sq_imageconvert.ui sq_imageeditoptions.ui sq_imagefilter.ui sq_label.cpp sq_writeoption.ui
+
+####### tdevelop will overwrite this part!!! (end)############
+
+INCLUDES = $(all_includes) -I$(srcdir) -I$(top_srcdir)/src
diff --git a/src/imageedit/sq_bcglabel.cpp b/src/imageedit/sq_bcglabel.cpp
new file mode 100644
index 0000000..41395e3
--- /dev/null
+++ b/src/imageedit/sq_bcglabel.cpp
@@ -0,0 +1,28 @@
+/***************************************************************************
+ sq_bcglabel.cpp - description
+ -------------------
+ begin : ??? May 4 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "sq_bcglabel.h"
+
+SQ_BCGLabel::SQ_BCGLabel(TQWidget *parent, const char *name, WFlags f) : TQLabel(parent, name, f | TQt::WNoAutoErase)
+{
+ setScaledContents(false);
+
+ setAlignment(TQt::AlignHCenter | TQt::AlignVCenter);
+}
+
+SQ_BCGLabel::~SQ_BCGLabel()
+{}
diff --git a/src/imageedit/sq_bcglabel.h b/src/imageedit/sq_bcglabel.h
new file mode 100644
index 0000000..d8546a9
--- /dev/null
+++ b/src/imageedit/sq_bcglabel.h
@@ -0,0 +1,34 @@
+/***************************************************************************
+ sq_bcglabel.h - description
+ -------------------
+ begin : ??? May 4 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_BCGLABEL_H
+#define SQ_BCGLABEL_H
+
+#include <tqlabel.h>
+
+/**
+ *@author Baryshev Dmitry
+ */
+
+class SQ_BCGLabel : public TQLabel
+{
+ public:
+ SQ_BCGLabel(TQWidget *parent, const char *name = 0, WFlags f = 0);
+ ~SQ_BCGLabel();
+};
+
+#endif
diff --git a/src/imageedit/sq_converter.cpp b/src/imageedit/sq_converter.cpp
new file mode 100644
index 0000000..04ab3aa
--- /dev/null
+++ b/src/imageedit/sq_converter.cpp
@@ -0,0 +1,444 @@
+/***************************************************************************
+ sq_converter.cpp - description
+ -------------------
+ begin : ??? Mar 3 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <tqapplication.h>
+#include <tqfile.h>
+
+#include <tdemessagebox.h>
+#include <kstringhandler.h>
+#include <kstandarddirs.h>
+#include <tdetempfile.h>
+#include <tdelocale.h>
+
+#include "ksquirrel.h"
+#include "sq_converter.h"
+#include "sq_widgetstack.h"
+#include "sq_diroperator.h"
+#include "sq_libraryhandler.h"
+#include "sq_config.h"
+#include "sq_errorstring.h"
+#include "sq_imageloader.h"
+#include "sq_imageconvert.h"
+
+SQ_Converter * SQ_Converter::m_sing = 0;
+
+SQ_Converter::SQ_Converter(TQObject *parent) : TQObject(parent)
+{
+ m_sing = this;
+
+ err_internal = i18n("internal error") + '\n';
+ err_failed = i18n("failed") + '\n';
+
+ special_action = i18n("Converting");
+
+ image = 0;
+}
+
+SQ_Converter::~SQ_Converter()
+{
+ if(image) free(image);
+}
+
+void SQ_Converter::slotStartEdit()
+{
+ files.clear();
+
+ KFileItemList *items = (KFileItemList *)SQ_WidgetStack::instance()->selectedItems();
+
+ if(!items || !items->count())
+ {
+ KMessageBox::information(KSquirrel::app(), i18n("Select files to edit"));
+ return;
+ }
+ else if(!items->first()->url().isLocalFile())
+ {
+ KMessageBox::information(KSquirrel::app(), i18n("Converter cannot work with remote files.\nSorry"));
+ return;
+ }
+
+ KFileItem *i = items->first();
+
+ for(;i;i = items->next())
+ {
+ if(i->isFile())
+ files.append(i->url().path());
+ }
+
+ startEditPrivate();
+}
+
+TQString SQ_Converter::adjustFileName(const TQString &globalprefix, const TQString &name1, int replace, TQString putto, bool paged, int page)
+{
+ TQFileInfo ff(name1);
+ TQString name = ff.dirPath() + '/' + (replace == 0 ? globalprefix : (replace == 2 ? TQString() : globalprefix)) + ff.fileName();
+ ff = TQFileInfo(name);
+
+ TQString result, inner, filter = lw->filter;
+ TQString ext = ff.extension(false);
+ TQString prefix, suffix, name2 = name;
+ TQString spage = TQString::fromLatin1("page_%1.").arg((TQString::fromLatin1("%1").arg(page)).rightJustify(3, '0'));
+
+ if(!putto.isEmpty())
+ {
+ if(TQFile::exists(putto))
+ name2 = putto + '/' + ff.fileName();
+ }
+
+ prefix = name2;
+
+ prefix.truncate(name2.length() - ext.length());
+
+ suffix = (SQ_LibraryHandler::instance()->knownExtension(TQString::fromLatin1("*.") + ext))
+ ? TQString(lw->codec->extension(32)) : ext;
+
+ if(replace == 0 || replace == 2)
+ result = (!paged) ? (prefix + inner + suffix) : (prefix + spage + inner + suffix);
+ else
+ {
+ result = (!paged) ? (prefix + inner + suffix) : (prefix + spage + inner + suffix);
+
+ if(TQFile::exists(result))
+ {
+ inner = TQString::fromLatin1("1.");
+ result = (!paged) ? (prefix + inner + suffix) : (prefix + spage + inner + suffix);
+ }
+ }
+
+ return result;
+}
+
+void SQ_Converter::errorjmp(jmp_buf jmp, const int code)
+{
+ error_code = code;
+ longjmp(jmp, 1);
+}
+
+void SQ_Converter::decodingCycle()
+{
+ int i, j;
+ TQString name;
+ jmp_buf jmp;
+ RGBA *scan;
+ int errors, gerrors = 0, current;
+ TQString putto;
+ int replace = imageopt.where_to_put;
+ bool brk;
+
+ SQ_Config::instance()->setGroup("Edit tools");
+
+ int allpages = SQ_Config::instance()->readNumEntry("load_pages", 0);
+ int pages_num = SQ_Config::instance()->readNumEntry("load_pages_number", 1);
+
+ if(pages_num < 1) pages_num = 1;
+
+ altw = SQ_LibraryHandler::instance()->libraryByName(SQ_Config::instance()->readEntry("altlibrary", "Portable Network Graphics"));
+ multi = SQ_Config::instance()->readBoolEntry("multi", true);
+
+ tempfile = new KTempFile;
+ tempfile->setAutoDelete(true);
+
+ if(tempfile->status())
+ {
+ KMessageBox::error(KSquirrel::app(), i18n("Temporary file creation failed"));
+ return;
+ }
+
+ tempfile->close();
+
+ TQStringList::iterator last_it = files.fromLast();
+ TQStringList::iterator itEnd = files.end();
+ convert->startConvertion(files.count());
+
+ putto = imageopt.putto;
+
+ for(TQStringList::iterator it = files.begin();it != itEnd;++it)
+ {
+ currentFile = *it;
+ last = (it == last_it);
+
+ TQFileInfo ff(*it);
+
+ emit convertText(special_action + ' ' + KStringHandler::rsqueeze(ff.fileName()) + "... ", false);
+
+ if((lr = SQ_LibraryHandler::instance()->libraryForFile(*it)))
+ {
+ lw = SQ_LibraryHandler::instance()->libraryByName(convopt.libname);
+
+ if(!lr || !lw)
+ {
+ gerrors++;
+ emit convertText(err_internal, true);
+ emit oneFileProcessed();
+ continue;
+ }
+
+ name = TQFile::encodeName(*it);
+
+ i = lr->codec->read_init(name.ascii());
+
+ if(setjmp(jmp))
+ {
+ gerrors++;
+
+ lr->codec->read_close();
+
+ emit convertText(SQ_ErrorString::instance()->stringSN(error_code), true);
+ emit oneFileProcessed();
+
+ continue;
+ }
+
+ if(i != SQE_OK)
+ errorjmp(jmp, i);
+
+ errors = 0;
+ current = 0;
+
+ while(true)
+ {
+ brk = (allpages == 1 && current) || (allpages == 2 && current == pages_num);
+
+ i = lr->codec->read_next();
+
+ im = lr->codec->image(current-1);
+
+ if(i != SQE_OK || brk)
+ {
+ if(i == SQE_NOTOK || brk)
+ {
+ if(current == 1)
+ name = adjustFileName(prefix, *it, replace, putto);
+ else
+ name = adjustFileName(prefix, *it, replace, putto, true, current);
+
+ lastFrame = last;
+
+ i = manipAndWriteDecodedImage(tempfile->name(), im);
+
+ emit convertText(errors ? (i18n("1 error", "%n errors", errors)+'\n') : SQ_ErrorString::instance()->stringSN(SQE_OK), true);
+ emit oneFileProcessed();
+
+ i = SQE_OK;
+
+ if(replace == 2)
+ {
+ emit convertText(i18n("Removing") + KStringHandler::rsqueeze(ff.fileName()) + TQString("... "), false);
+
+ bool b = TQFile::remove(*it);
+
+ emit convertText(b ? SQ_ErrorString::instance()->stringSN(SQE_OK) : err_failed, true);
+ emit oneFileProcessed();
+ }
+
+ i = copyFile(tempfile->name(), name);
+
+ break;
+ }
+ else
+ errorjmp(jmp, i);
+ }
+
+ if(current)
+ {
+ name = adjustFileName(prefix, *it, replace, putto, true, current);
+
+ lastFrame = false;
+
+ manipAndWriteDecodedImage(tempfile->name(), im);
+ i = copyFile(tempfile->name(), name);
+ }
+
+ im = lr->codec->image(current);
+
+ image = (RGBA *)realloc(image, im->w * im->h * sizeof(RGBA));
+
+ if(!image)
+ {
+ i = SQE_R_NOMEMORY;
+ errorjmp(jmp, i);
+ }
+
+ for(int pass = 0;pass < im->passes;pass++)
+ {
+ lr->codec->read_next_pass();
+
+ for(j = 0;j < im->h;j++)
+ {
+ scan = image + j * im->w;
+ i = lr->codec->read_scanline(scan);
+ errors += (int)(i != SQE_OK);
+ }
+ }
+
+ if(im->needflip)
+ fmt_utils::flipv((char *)image, im->w * sizeof(RGBA), im->h);
+
+ convert->fillWriteOptions(&opt, lw->opt);
+
+ opt.alpha = im->hasalpha;
+
+ current++;
+ }
+
+ lr->codec->read_close();
+ }
+ else
+ {
+ emit convertText(SQ_ErrorString::instance()->stringSN(SQE_R_NOTSUPPORTED), true);
+ emit oneFileProcessed();
+ }
+ }
+
+ if(image)
+ {
+ free(image);
+ image = 0;
+ }
+
+ delete convert;
+ delete tempfile;
+
+ if(imageopt.close && !gerrors)
+ emit done(true);
+ else
+ emit done(false);
+}
+
+int SQ_Converter::manipAndWriteDecodedImage(const TQString &name, fmt_image *im)
+{
+ int passes = opt.interlaced ? lw->opt.passes : 1;
+ int s, j, err;
+ RGBA *scan = 0;
+
+ scan = new RGBA [im->w];
+
+ if(!scan)
+ return SQE_W_NOMEMORY;
+
+ err = lw->codec->write_init(name.ascii(), *im, opt);
+
+ if(err != SQE_OK)
+ goto error_exit;
+
+ err = lw->codec->write_next();
+
+ if(err != SQE_OK)
+ goto error_exit;
+
+ for(s = 0;s < passes;s++)
+ {
+ err = lw->codec->write_next_pass();
+
+ if(err != SQE_OK)
+ goto error_exit;
+
+ for(j = 0;j < im->h;j++)
+ {
+ if(lw->opt.needflip)
+ determineNextScan(*im, scan, im->h-j-1);
+ else
+ determineNextScan(*im, scan, j);
+
+ err = lw->codec->write_scanline(scan);
+
+ if(err != SQE_OK)
+ goto error_exit;
+ }
+ }
+
+ err = SQE_OK;
+
+ error_exit:
+
+ lw->codec->write_close();
+
+ delete scan;
+
+ return err;
+}
+
+int SQ_Converter::copyFile(const TQString &src, const TQString &dst) const
+{
+ TQFile f_src(src), f_dst(dst);
+ TQ_LONG read;
+ char data[4096];
+
+ if(!f_src.open(IO_ReadOnly))
+ return SQE_R_NOFILE;
+
+ if(!f_dst.open(IO_WriteOnly))
+ {
+ f_src.close();
+ return SQE_W_NOFILE;
+ }
+
+ while(!f_src.atEnd())
+ {
+ read = f_src.readBlock(data, sizeof(data));
+
+ f_dst.writeBlock(data, read);
+
+ if(f_dst.status() != IO_Ok || f_src.status() != IO_Ok)
+ {
+ f_src.close();
+ f_dst.close();
+
+ return SQE_W_ERROR;
+ }
+ }
+
+ f_src.close();
+ f_dst.close();
+
+ return SQE_OK;
+}
+
+void SQ_Converter::determineNextScan(const fmt_image &im, RGBA *scan, int y)
+{
+ memcpy(scan, image + y * im.w, im.w * sizeof(RGBA));
+}
+
+void SQ_Converter::startEditPrivate()
+{
+ convert = new SQ_ImageConvert(KSquirrel::app());
+ convert->setCaption(i18n("Convert 1 file", "Convert %n files", files.count()));
+
+ connect(convert, TQ_SIGNAL(convert(SQ_ImageOptions*, SQ_ImageConvertOptions*)), this, TQ_SLOT(slotStartConvert(SQ_ImageOptions*, SQ_ImageConvertOptions*)));
+ connect(this, TQ_SIGNAL(convertText(const TQString &, bool)), convert, TQ_SLOT(slotDebugText(const TQString &, bool)));
+ connect(this, TQ_SIGNAL(oneFileProcessed()), convert, TQ_SLOT(slotOneProcessed()));
+ connect(this, TQ_SIGNAL(done(bool)), convert, TQ_SLOT(slotDone(bool)));
+
+ convert->exec();
+}
+
+void SQ_Converter::slotStartConvert(SQ_ImageOptions *o, SQ_ImageConvertOptions *copt)
+{
+ imageopt = *o;
+ convopt = *copt;
+
+ decodingCycle();
+}
+
+#include "sq_converter.moc"
diff --git a/src/imageedit/sq_converter.h b/src/imageedit/sq_converter.h
new file mode 100644
index 0000000..414dfe1
--- /dev/null
+++ b/src/imageedit/sq_converter.h
@@ -0,0 +1,120 @@
+/***************************************************************************
+ sq_converter.h - description
+ -------------------
+ begin : ??? Mar 3 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_CONVERTER_H
+#define SQ_CONVERTER_H
+
+#include <tqobject.h>
+#include <tqstringlist.h>
+
+#include <sstream>
+#include <csetjmp>
+
+#include <ksquirrel-libs/fmt_utils.h>
+#include <ksquirrel-libs/fmt_codec_base.h>
+#include <ksquirrel-libs/error.h>
+
+#include "sq_imageedit.h"
+
+struct SQ_LIBRARY;
+
+class KTempFile;
+
+class SQ_ImageConvert;
+class SQ_ImageConvertOptions;
+
+/*
+ * Base class for all edit tools. It contains all methods needed by
+ * converter, resizer, printer etc. It decodes an image, writes it back to
+ * disk. All specific actions (like colorizing, resizing etc.) are done by
+ * appropriate edit tool.
+ */
+
+class SQ_Converter : public TQObject
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_Converter(TQObject *parent);
+ ~SQ_Converter();
+
+ public:
+ static SQ_Converter* instance() { return m_sing; }
+
+ private:
+ /*
+ * Create edit tool-specific dialog, and wait for user
+ * input
+ */
+ void startEditPrivate();
+
+ /*
+ * Do something with decoded image(manipDecodedImage()) and write it
+ * on disk.
+ */
+ int manipAndWriteDecodedImage(const TQString &name, fmt_image *im);
+
+ /*
+ * Main decoding loop.
+ */
+ void decodingCycle();
+
+ /*
+ * Determine file name. In this file SQ_Converter will save new image.
+ */
+ TQString adjustFileName(const TQString &globalprefix, const TQString &name, int replace,
+ TQString putto, bool paged = false, int page = 0);
+
+ void determineNextScan(const fmt_image &im, RGBA *scan, int y);
+
+ /*
+ * Copy file :-)
+ */
+ int copyFile(const TQString &src, const TQString &dst) const;
+
+ void errorjmp(jmp_buf jmp, const int code);
+
+ signals:
+ void convertText(const TQString &, bool);
+ void oneFileProcessed();
+ void done(bool allok);
+
+ private slots:
+ void slotStartEdit();
+ void slotStartConvert(SQ_ImageOptions*, SQ_ImageConvertOptions*);
+
+ protected:
+ TQStringList files;
+ TQString err_internal, err_failed;
+ TQString currentFile;
+ int error_code, current_page;
+ SQ_ImageOptions imageopt;
+ fmt_writeoptions opt;
+ SQ_LIBRARY *lr, *lw, *altw;
+ RGBA *image;
+ TQString special_action, prefix;
+ bool multi, last, lastFrame;
+ KTempFile *tempfile;
+ fmt_image *im;
+ static SQ_Converter *m_sing;
+
+ SQ_ImageConvert *convert;
+ SQ_ImageConvertOptions convopt;
+};
+
+#endif
diff --git a/src/imageedit/sq_imagebcg.ui b/src/imageedit/sq_imagebcg.ui
new file mode 100644
index 0000000..c3466d5
--- /dev/null
+++ b/src/imageedit/sq_imagebcg.ui
@@ -0,0 +1,989 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_ImageBCG</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_ImageBCG</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>564</width>
+ <height>391</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Color balance</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQWidgetStack" row="1" column="0" rowspan="3" colspan="1">
+ <property name="name">
+ <cstring>widgetStackParams</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <widget class="TQSpinBox" row="2" column="0">
+ <property name="name">
+ <cstring>spinB</cstring>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="2">
+ <property name="name">
+ <cstring>pushResetG</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>pushResetC</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="KDoubleSpinBox" row="2" column="2">
+ <property name="name">
+ <cstring>spinG</cstring>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="2" column="1">
+ <property name="name">
+ <cstring>spinC</cstring>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushResetB</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_Label">
+ <property name="name">
+ <cstring>sQ_LabelB</cstring>
+ </property>
+ </widget>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>sliderB</cstring>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>Above</enum>
+ </property>
+ <property name="tickInterval">
+ <number>25</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Brightness</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="1">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_Label">
+ <property name="name">
+ <cstring>sQ_LabelC</cstring>
+ </property>
+ </widget>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>sliderC</cstring>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>Above</enum>
+ </property>
+ <property name="tickInterval">
+ <number>25</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Contrast</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="2">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_Label">
+ <property name="name">
+ <cstring>sQ_LabelG</cstring>
+ </property>
+ </widget>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>sliderG</cstring>
+ </property>
+ <property name="minValue">
+ <number>0</number>
+ </property>
+ <property name="maxValue">
+ <number>600</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>Above</enum>
+ </property>
+ <property name="tickInterval">
+ <number>22</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Gamma</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushResetRed</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="2" column="0">
+ <property name="name">
+ <cstring>spinRed</cstring>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="2" column="1">
+ <property name="name">
+ <cstring>spinGreen</cstring>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>pushResetGreen</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="2">
+ <property name="name">
+ <cstring>pushResetBlue</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="2" column="2">
+ <property name="name">
+ <cstring>spinBlue</cstring>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="2">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_Label">
+ <property name="name">
+ <cstring>sQ_LabelBlue</cstring>
+ </property>
+ </widget>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>sliderBlue</cstring>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="tickmarks">
+ <enum>Above</enum>
+ </property>
+ <property name="tickInterval">
+ <number>25</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Blue</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="1">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_Label">
+ <property name="name">
+ <cstring>sQ_LabelGreen</cstring>
+ </property>
+ </widget>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>sliderGreen</cstring>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="tickmarks">
+ <enum>Above</enum>
+ </property>
+ <property name="tickInterval">
+ <number>25</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Green</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_Label">
+ <property name="name">
+ <cstring>sQ_LabelRed</cstring>
+ </property>
+ </widget>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>sliderRed</cstring>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="tickmarks">
+ <enum>Above</enum>
+ </property>
+ <property name="tickInterval">
+ <number>25</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Red</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ <widget class="TQGroupBox" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>6</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="4">
+ <property name="name">
+ <cstring>push2</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>push1</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer row="0" column="1">
+ <property name="name">
+ <cstring>spacer26</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="0" column="3">
+ <property name="name">
+ <cstring>spacer27</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="0" column="2">
+ <property name="name">
+ <cstring>text</cstring>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignCenter</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="3" column="1">
+ <property name="name">
+ <cstring>spacer12_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLayoutWidget" row="5" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>249</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushGO</cstring>
+ </property>
+ <property name="text">
+ <string>Colorize</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushCancel</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="Line" row="4" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>line2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <spacer row="1" column="1">
+ <property name="name">
+ <cstring>spacer11</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLayoutWidget" row="2" column="1">
+ <property name="name">
+ <cstring>layout15</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer13</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Original image:</string>
+ </property>
+ </widget>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer35</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="SQ_BCGLabel" row="1" column="3">
+ <property name="name">
+ <cstring>pixmap1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>160</width>
+ <height>160</height>
+ </size>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="3" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Image after colorizing:</string>
+ </property>
+ </widget>
+ <spacer row="1" column="4">
+ <property name="name">
+ <cstring>spacer34</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="SQ_BCGLabel" row="1" column="1">
+ <property name="name">
+ <cstring>pixmap</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>160</width>
+ <height>160</height>
+ </size>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>SQ_BCGLabel</class>
+ <header location="local">sq_bcglabel.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+ <customwidget>
+ <class>SQ_Label</class>
+ <header location="local">sq_label.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="PNG" length="1002">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154388dad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a190172af6a9690000000049454e44ae426082</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>spinRed</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotRedChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>spinGreen</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotGreenChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>spinG</sender>
+ <signal>valueChanged(double)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotGSpinChanged(double)</slot>
+ </connection>
+ <connection>
+ <sender>spinC</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotCChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>spinBlue</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotBlueChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>spinB</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotBChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>sliderRed</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotRedChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>sliderGreen</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotGreenChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>sliderG</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotGChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>sliderC</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotCChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>sliderBlue</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotBlueChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>sliderB</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotBChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>pushResetRed</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotResetRed()</slot>
+ </connection>
+ <connection>
+ <sender>pushResetGreen</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotResetGreen()</slot>
+ </connection>
+ <connection>
+ <sender>pushResetG</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotResetG()</slot>
+ </connection>
+ <connection>
+ <sender>pushResetC</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotResetC()</slot>
+ </connection>
+ <connection>
+ <sender>pushResetBlue</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotResetBlue()</slot>
+ </connection>
+ <connection>
+ <sender>pushResetB</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotResetB()</slot>
+ </connection>
+ <connection>
+ <sender>pushGO</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotStartBCG()</slot>
+ </connection>
+ <connection>
+ <sender>push2</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotPush()</slot>
+ </connection>
+ <connection>
+ <sender>push1</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotPush()</slot>
+ </connection>
+ <connection>
+ <sender>pushCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>push1</tabstop>
+ <tabstop>push2</tabstop>
+ <tabstop>pushResetRed</tabstop>
+ <tabstop>pushResetGreen</tabstop>
+ <tabstop>pushResetBlue</tabstop>
+ <tabstop>sliderRed</tabstop>
+ <tabstop>sliderGreen</tabstop>
+ <tabstop>sliderBlue</tabstop>
+ <tabstop>spinRed</tabstop>
+ <tabstop>spinGreen</tabstop>
+ <tabstop>spinBlue</tabstop>
+ <tabstop>pushGO</tabstop>
+ <tabstop>pushCancel</tabstop>
+ <tabstop>pushResetB</tabstop>
+ <tabstop>pushResetC</tabstop>
+ <tabstop>pushResetG</tabstop>
+ <tabstop>sliderB</tabstop>
+ <tabstop>sliderC</tabstop>
+ <tabstop>sliderG</tabstop>
+ <tabstop>spinB</tabstop>
+ <tabstop>spinC</tabstop>
+ <tabstop>spinG</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in declaration">sq_imageedit.h</include>
+ <include location="global" impldecl="in declaration">tqimage.h</include>
+ <include location="global" impldecl="in declaration">tqstringlist.h</include>
+ <include location="local" impldecl="in implementation">fmt_filters.h</include>
+ <include location="global" impldecl="in implementation">knuminput.h</include>
+ <include location="global" impldecl="in implementation">ksquirrel-libs/fmt_defs.h</include>
+ <include location="global" impldecl="in implementation">ksquirrel-libs/fmt_types.h</include>
+ <include location="global" impldecl="in implementation">kstandarddirs.h</include>
+ <include location="global" impldecl="in implementation">sq_bcglabel.h</include>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="local" impldecl="in implementation">sq_imagebcg.ui.h</include>
+ <include location="global" impldecl="in implementation">sq_label.h</include>
+</includes>
+<variables>
+ <variable access="private">int id;</variable>
+ <variable access="private">TQImage sample, sample_saved;</variable>
+ <variable access="private">TQStringList strings;</variable>
+ <variable access="private">static SQ_ImageBCG *m_inst;</variable>
+</variables>
+<signals>
+ <signal>bcg(SQ_ImageBCGOptions*)</signal>
+</signals>
+<slots>
+ <slot access="private" specifier="non virtual">slotResetG()</slot>
+ <slot access="private" specifier="non virtual">slotResetC()</slot>
+ <slot access="private" specifier="non virtual">slotResetB()</slot>
+ <slot access="private" specifier="non virtual">slotResetRed()</slot>
+ <slot access="private" specifier="non virtual">slotResetGreen()</slot>
+ <slot access="private" specifier="non virtual">slotResetBlue()</slot>
+ <slot access="private" specifier="non virtual">slotStartBCG()</slot>
+ <slot access="private" specifier="non virtual">slotBChanged( int v )</slot>
+ <slot access="private" specifier="non virtual">slotCChanged( int v )</slot>
+ <slot access="private" specifier="non virtual">slotRedChanged( int v )</slot>
+ <slot access="private" specifier="non virtual">slotGreenChanged( int v )</slot>
+ <slot access="private" specifier="non virtual">slotBlueChanged( int v )</slot>
+ <slot access="private" specifier="non virtual">slotGChanged( int v )</slot>
+ <slot access="private" specifier="non virtual">slotGSpinChanged( double v )</slot>
+ <slot access="private" specifier="non virtual">slotPush()</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function access="private" specifier="non virtual" returnType="int">RGB2Y( int r, int g, int b )</function>
+ <function access="private" specifier="non virtual">assignNewImage( const TQImage &amp; im )</function>
+ <function access="private" specifier="non virtual">changeImage( int b, int c, int g1, int red, int green, int blue )</function>
+ <function specifier="non virtual">setPreviewImage( const TQImage &amp; im )</function>
+ <function specifier="static" returnType="SQ_ImageBCG *">instance()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/imageedit/sq_imagebcg.ui.h b/src/imageedit/sq_imagebcg.ui.h
new file mode 100644
index 0000000..31c3516
--- /dev/null
+++ b/src/imageedit/sq_imagebcg.ui.h
@@ -0,0 +1,241 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+SQ_ImageBCG * SQ_ImageBCG::m_inst = 0;
+
+void SQ_ImageBCG::init()
+{
+ m_inst = this;
+
+ TQPixmap p = TQPixmap::fromMimeSource(locate("data", "images/imageedit/reset_value.png"));
+
+ sQ_LabelB->setSingle(true);
+ sQ_LabelC->setSingle(true);
+ sQ_LabelG->setSingle(true);
+ sQ_LabelB->setText(tr2i18n("Brightness"));
+ sQ_LabelC->setText(tr2i18n("Contrast"));
+ sQ_LabelG->setText(tr2i18n("Gamma"));
+ sQ_LabelRed->setText(tr2i18n("Red"), tr2i18n("Cyan"));
+ sQ_LabelGreen->setText(tr2i18n("Green"), tr2i18n("Magenta"));
+ sQ_LabelBlue->setText(tr2i18n("Blue"), tr2i18n("Yellow"));
+
+ pushResetB->setPixmap(p);
+ pushResetC->setPixmap(p);
+ pushResetG->setPixmap(p);
+ pushResetRed->setPixmap(p);
+ pushResetGreen->setPixmap(p);
+ pushResetBlue->setPixmap(p);
+
+ strings.append(TQString("<b>") + tr2i18n("Brightness") + ",&nbsp;" + tr2i18n("Contrast") + ",&nbsp;" + tr2i18n("Gamma") + "</b>");
+ strings.append(TQString("<b>") + tr2i18n("Red") + ",&nbsp;" + tr2i18n("Green") + ",&nbsp;" + tr2i18n("Blue") + "</b>");
+
+ id = 0;
+ widgetStackParams->raiseWidget(id);
+ text->setText(strings[id]);
+
+ TQPixmap tool1 = TQPixmap::fromMimeSource(locate("data", "images/imageedit/resize_toolbutton.png"));
+ TQPixmap tool2 = TQPixmap::fromMimeSource(locate("data", "images/imageedit/resize_toolbutton2.png"));
+ push1->setPixmap(tool1);
+ push2->setPixmap(tool2);
+
+ spinG->setRange(0, 6.0, 0.01, 2);
+ spinG->setValue(1.0);
+ connect(spinG, TQ_SIGNAL(valueChanged(int)), spinG, TQ_SLOT(slotValueChanged(int)));
+}
+
+void SQ_ImageBCG::slotResetG()
+{
+ sliderG->setValue(100);
+}
+
+void SQ_ImageBCG::slotResetC()
+{
+ sliderC->setValue(0);
+}
+
+void SQ_ImageBCG::slotResetB()
+{
+ sliderB->setValue(0);
+}
+
+void SQ_ImageBCG::slotResetRed()
+{
+ sliderRed->setValue(0);
+}
+
+void SQ_ImageBCG::slotResetGreen()
+{
+ sliderGreen->setValue(0);
+}
+
+void SQ_ImageBCG::slotResetBlue()
+{
+ sliderBlue->setValue(0);
+}
+
+void SQ_ImageBCG::slotStartBCG()
+{
+ SQ_ImageBCGOptions opt;
+ opt.b = sliderB->value();
+ opt.c = sliderC->value();
+ opt.g = sliderG->value();
+ opt.red = sliderRed->value();
+ opt.green = sliderGreen->value();
+ opt.blue = sliderBlue->value();
+
+ emit bcg(&opt);
+}
+
+int SQ_ImageBCG::RGB2Y(int r, int g, int b)
+{
+ return (int)((double)r * 0.299 + (double)g * 0.587 + (double)b * 0.114);
+}
+
+void SQ_ImageBCG::slotBChanged(int v)
+{
+ spinB->blockSignals(true);
+ sliderB->blockSignals(true);
+ spinB->setValue(v);
+ sliderB->setValue(v);
+ spinB->blockSignals(false);
+ sliderB->blockSignals(false);
+
+ changeImage(v, sliderC->value(), sliderG->value(), sliderRed->value(), sliderGreen->value(), sliderBlue->value());
+}
+
+void SQ_ImageBCG::slotCChanged(int v)
+{
+ spinC->blockSignals(true);
+ sliderC->blockSignals(true);
+ spinC->setValue(v);
+ sliderC->setValue(v);
+ spinC->blockSignals(false);
+ sliderC->blockSignals(false);
+
+ changeImage(sliderB->value(), v, sliderG->value(), sliderRed->value(), sliderGreen->value(), sliderBlue->value());
+}
+
+void SQ_ImageBCG::slotRedChanged(int v)
+{
+ spinRed->blockSignals(true);
+ sliderRed->blockSignals(true);
+ spinRed->setValue(v);
+ sliderRed->setValue(v);
+ spinRed->blockSignals(false);
+ sliderRed->blockSignals(false);
+
+ changeImage(sliderB->value(), sliderC->value(), sliderG->value(), v, sliderGreen->value(), sliderBlue->value());
+}
+
+void SQ_ImageBCG::slotGreenChanged(int v)
+{
+ spinGreen->blockSignals(true);
+ sliderGreen->blockSignals(true);
+ spinGreen->setValue(v);
+ sliderGreen->setValue(v);
+ spinGreen->blockSignals(false);
+ sliderGreen->blockSignals(false);
+
+ changeImage(sliderB->value(), sliderC->value(), sliderG->value(), sliderRed->value(), v, sliderBlue->value());
+}
+
+void SQ_ImageBCG::slotBlueChanged(int v)
+{
+ spinBlue->blockSignals(true);
+ sliderBlue->blockSignals(true);
+ spinBlue->setValue(v);
+ sliderBlue->setValue(v);
+ spinBlue->blockSignals(false);
+ sliderBlue->blockSignals(false);
+
+ changeImage(sliderB->value(), sliderC->value(), sliderG->value(), sliderRed->value(), sliderGreen->value(), v);
+}
+
+void SQ_ImageBCG::slotGChanged(int v)
+{
+ double g = (double)v / 100.0;
+ spinG->blockSignals(true);
+ spinG->setValue(g);
+ spinG->blockSignals(false);
+
+ changeImage(sliderB->value(), sliderC->value(), v, sliderRed->value(), sliderGreen->value(), sliderBlue->value());
+}
+
+void SQ_ImageBCG::slotGSpinChanged(double v)
+{
+ int val = (int)(v * 100.0);
+ sliderG->blockSignals(true);
+ sliderG->setValue(val);
+ sliderG->blockSignals(false);
+
+ changeImage(sliderB->value(), sliderC->value(), val, sliderRed->value(), sliderGreen->value(), sliderBlue->value());
+}
+
+void SQ_ImageBCG::assignNewImage(const TQImage &im)
+{
+ TQPixmap p;
+ p.convertFromImage(im);
+ pixmap1->setPixmap(p);
+}
+
+void SQ_ImageBCG::changeImage(int b, int c, int g1, int red, int green, int blue)
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ double g = (double)g1 / 100.0;
+
+ sample = sample_saved.copy();
+
+ // change brightness
+ fmt_filters::brightness(fmt_filters::image(sample.bits(), sample.width(), sample.height()), b);
+
+ //change contrast
+ if(c)
+ fmt_filters::contrast(fmt_filters::image(sample.bits(), sample.width(), sample.height()), c);
+
+ // change gamma
+ if(g1 != 100)
+ fmt_filters::gamma(fmt_filters::image(sample.bits(), sample.width(), sample.height()), g);
+
+ if(red || green || blue)
+ fmt_filters::colorize(fmt_filters::image(sample.bits(), sample.width(), sample.height()), blue, green, red);
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageBCG::slotPush()
+{
+ if(!id) id = 1;
+ else id = 0;
+
+ widgetStackParams->raiseWidget(id);
+ text->setText(strings[id]);
+}
+
+void SQ_ImageBCG::setPreviewImage(const TQImage &im)
+{
+ if(im.isNull()) return;
+
+ sample = im.copy();
+ sample_saved = sample.copy();
+
+ TQPixmap p;
+
+ p.convertFromImage(sample_saved);
+ pixmap->setPixmap(p);
+ pixmap1->setPixmap(p);
+
+ changeImage(sliderB->value(), sliderC->value(), sliderG->value(), sliderRed->value(), sliderGreen->value(), sliderBlue->value());
+}
+
+SQ_ImageBCG* SQ_ImageBCG::instance()
+{
+ return m_inst;
+}
diff --git a/src/imageedit/sq_imageconvert.ui b/src/imageedit/sq_imageconvert.ui
new file mode 100644
index 0000000..d776515
--- /dev/null
+++ b/src/imageedit/sq_imageconvert.ui
@@ -0,0 +1,343 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_ImageConvert</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_ImageConvert</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>436</width>
+ <height>324</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>SQ_ImageConvert</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>237</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushConvert</cstring>
+ </property>
+ <property name="text">
+ <string>Convert</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushCancel</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="Line" row="1" column="0">
+ <property name="name">
+ <cstring>line8</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQWidgetStack" row="0" column="0">
+ <property name="name">
+ <cstring>widgetStack</cstring>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQGroupBox" row="0" column="1">
+ <property name="name">
+ <cstring>groupBoxActions</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushOptions</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer15</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>26</width>
+ <height>155</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pushWriteOptions</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Conversion options</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>col1</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>col2</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>tableLib</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQTextEdit" row="0" column="0">
+ <property name="name">
+ <cstring>textResult</cstring>
+ </property>
+ <property name="wordWrap">
+ <enum>NoWrap</enum>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="undoRedoEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="KProgress" row="1" column="0">
+ <property name="name">
+ <cstring>progress</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>pushCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageConvert</receiver>
+ <slot>slotReject()</slot>
+ </connection>
+ <connection>
+ <sender>pushOptions</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageConvert</receiver>
+ <slot>slotOptions()</slot>
+ </connection>
+ <connection>
+ <sender>pushWriteOptions</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>SQ_ImageConvert</receiver>
+ <slot>slotShowExtWrapper(bool)</slot>
+ </connection>
+ <connection>
+ <sender>pushConvert</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageConvert</receiver>
+ <slot>slotStartConvert()</slot>
+ </connection>
+ <connection>
+ <sender>tableLib</sender>
+ <signal>currentChanged(TQListViewItem*)</signal>
+ <receiver>SQ_ImageConvert</receiver>
+ <slot>slotCurrentLibraryChanged(TQListViewItem*)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>tableLib</tabstop>
+ <tabstop>pushOptions</tabstop>
+ <tabstop>pushWriteOptions</tabstop>
+ <tabstop>pushConvert</tabstop>
+ <tabstop>pushCancel</tabstop>
+ <tabstop>textResult</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in declaration">sq_imageedit.h</include>
+ <include location="global" impldecl="in implementation">knuminput.h</include>
+ <include location="global" impldecl="in implementation">kprogress.h</include>
+ <include location="global" impldecl="in implementation">ksquirrel-libs/fmt_defs.h</include>
+ <include location="global" impldecl="in implementation">ksquirrel-libs/fmt_types.h</include>
+ <include location="global" impldecl="in implementation">kstandarddirs.h</include>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="local" impldecl="in implementation">sq_errorstring.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="local" impldecl="in implementation">sq_imageconvert.ui.h</include>
+ <include location="local" impldecl="in implementation">sq_imageeditoptions.h</include>
+ <include location="local" impldecl="in implementation">sq_libraryhandler.h</include>
+ <include location="local" impldecl="in implementation">sq_writeoption.h</include>
+ <include location="global" impldecl="in implementation">tqapplication.h</include>
+ <include location="global" impldecl="in implementation">tqcheckbox.h</include>
+ <include location="global" impldecl="in implementation">tqfileinfo.h</include>
+ <include location="global" impldecl="in implementation">tqheader.h</include>
+</includes>
+<forwards>
+ <forward>struct fmt_writeoptions;</forward>
+ <forward>struct fmt_writeoptionsabs;</forward>
+</forwards>
+<variables>
+ <variable access="private">SQ_ImageOptions imageopt;</variable>
+ <variable access="private">int paragraph;</variable>
+ <variable access="private">bool done;</variable>
+</variables>
+<signals>
+ <signal>convert(SQ_ImageOptions*, SQ_ImageConvertOptions*)</signal>
+</signals>
+<slots>
+ <slot>slotShowExtWrapper( bool show )</slot>
+ <slot access="private">createExtension()</slot>
+ <slot access="private">slotDebugText( const TQString &amp; text, bool bold )</slot>
+ <slot access="private">slotStartConvert()</slot>
+ <slot access="private">slotOneProcessed()</slot>
+ <slot access="private">slotCurrentLibraryChanged( TQListViewItem * i )</slot>
+ <slot access="private">slotOptions()</slot>
+ <slot access="private">slotDone( bool close )</slot>
+ <slot access="private">slotReject()</slot>
+</slots>
+<functions>
+ <function>init()</function>
+ <function access="private">initLibs()</function>
+ <function>startConvertion( int count )</function>
+ <function>fillWriteOptions( fmt_writeoptions * opt, const fmt_writeoptionsabs &amp; opt2 )</function>
+ <function access="protected">closeEvent( TQCloseEvent * e )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/imageedit/sq_imageconvert.ui.h b/src/imageedit/sq_imageconvert.ui.h
new file mode 100644
index 0000000..7979c49
--- /dev/null
+++ b/src/imageedit/sq_imageconvert.ui.h
@@ -0,0 +1,214 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+void SQ_ImageConvert::init()
+{
+ tableLib->header()->hide();
+
+ createExtension();
+
+ initLibs();
+
+ pushWriteOptions->setPixmap(TQPixmap(locate("data", "images/imageedit/resize_toolbutton2.png")));
+ pushOptions->setPixmap(SQ_IconLoader::instance()->loadIcon("configure", TDEIcon::Desktop, TDEIcon::SizeSmall));
+
+ SQ_Config::instance()->setGroup("Image edit options");
+
+ imageopt.putto = SQ_Config::instance()->readEntry("convert_putto", TQString());
+ imageopt.where_to_put = SQ_Config::instance()->readNumEntry("convert_where_to_put", 0);
+ imageopt.close = SQ_Config::instance()->readBoolEntry("convert_close", true);
+
+ done = true;
+}
+
+void SQ_ImageConvert::initLibs()
+{
+ TQListViewItem *first;
+
+ TQValueVector<SQ_LIBRARY>::iterator itEnd = SQ_LibraryHandler::instance()->end();
+
+ for(TQValueVector<SQ_LIBRARY>::iterator it = SQ_LibraryHandler::instance()->begin();
+ it != itEnd;++it)
+ {
+ if((*it).writestatic)
+ {
+ TQFileInfo libfileinfo((*it).libpath);
+ TQListViewItem *item = new TQListViewItem(tableLib, TQString(), TQString((*it).quickinfo));
+
+ item->setPixmap(0, (*it).mime);
+
+ tableLib->insertItem(item);
+ }
+ }
+
+ first = tableLib->firstChild();
+
+ if(first)
+ {
+ tableLib->setSelected(first, true);
+ slotCurrentLibraryChanged(first);
+ }
+}
+
+void SQ_ImageConvert::slotShowExtWrapper(bool show)
+{
+ showExtension(show);
+}
+
+void SQ_ImageConvert::createExtension()
+{
+ SQ_WriteOption *c = new SQ_WriteOption(this);
+ c->slider->setRange(0, 255, 1, true);
+ setExtension(c);
+ setOrientation(TQt::Horizontal);
+}
+
+void SQ_ImageConvert::slotDebugText(const TQString &text, bool bold)
+{
+ textResult->setBold(bold);
+ textResult->insertAt(text, paragraph, textResult->paragraphLength(paragraph));
+ textResult->setBold(false);
+}
+
+void SQ_ImageConvert::slotStartConvert()
+{
+ pushConvert->setDefault(false);
+ pushConvert->setDisabled(true);
+ pushCancel->setDefault(true);
+ pushCancel->setFocus();
+ widgetStack->raiseWidget(1);
+ showExtension(false);
+
+ tqApp->processEvents();
+
+ TQListViewItem *i = tableLib->selectedItem();
+
+ if(!i)
+ return;
+
+ SQ_ImageConvertOptions copt;
+ copt.libname = i->text(1);
+
+ emit convert(&imageopt, &copt);
+}
+
+void SQ_ImageConvert::startConvertion(int count)
+{
+ done = false;
+ paragraph = 0;
+ progress->setProgress(0);
+ progress->setTotalSteps(count);
+}
+
+void SQ_ImageConvert::slotOneProcessed()
+{
+ progress->advance(1);
+ paragraph++;
+}
+
+void SQ_ImageConvert::slotCurrentLibraryChanged( TQListViewItem * i)
+{
+ if(!i)
+ return;
+
+ TQString name = i->text(1);
+
+ SQ_LIBRARY *l = SQ_LibraryHandler::instance()->libraryByName(name);
+
+ if(!l)
+ return;
+
+ SQ_WriteOption *e = (SQ_WriteOption*)extension();
+
+ if(!e)
+ return;
+
+ e->widgetStack->raiseWidget(0);
+
+ bool bslider = (l->opt.compression_scheme == CompressionInternal && (l->opt.compression_min || l->opt.compression_max));
+
+ e->slider->setShown(bslider);
+ e->checkRLE->setShown(!bslider);
+
+ if(bslider)
+ {
+ e->slider->setRange(l->opt.compression_min, l->opt.compression_max, 1, true);
+ e->slider->setValue(l->opt.compression_def);
+ }
+
+ bool rle = true;
+
+ if(!(l->opt.compression_scheme & CompressionRLE))
+ {
+ e->checkRLE->hide();
+ rle = false;
+ }
+
+ bool binter = l->opt.interlaced;
+
+ e->checkInterlaced->setShown(binter);
+
+ if(!binter && !rle && !bslider)
+ e->widgetStack->raiseWidget(1);
+}
+
+void SQ_ImageConvert::fillWriteOptions(fmt_writeoptions *opt, const fmt_writeoptionsabs &opt2)
+{
+ SQ_WriteOption *e = (SQ_WriteOption*)extension();
+
+ if(!e)
+ return;
+
+ opt->interlaced = (opt2.interlaced) ? e->checkInterlaced->isChecked() : false;
+
+ if(opt2.compression_scheme == CompressionInternal)
+ opt->compression_scheme = CompressionInternal;
+ else if(opt2.compression_scheme == CompressionRLE)
+ opt->compression_scheme = (e->checkRLE->isChecked()) ? CompressionRLE : CompressionNo;
+ else
+ opt->compression_scheme = CompressionNo;
+
+ opt->compression_level = (opt->compression_scheme != CompressionNo) ? e->slider->value() : 0;
+}
+
+void SQ_ImageConvert::slotOptions()
+{
+ SQ_ImageEditOptions o(this);
+
+ // SQ_ImageEditOptions will write needed TDEConfig entries, if
+ // exec() will return TQDialog::Accepted
+ o.setConfigPrefix("convert");
+
+ o.exec(&imageopt);
+}
+
+void SQ_ImageConvert::slotDone(bool close)
+{
+ done = true;
+
+ if(close)
+ reject();
+}
+
+void SQ_ImageConvert::slotReject()
+{
+ if(done)
+ reject();
+}
+
+void SQ_ImageConvert::closeEvent(TQCloseEvent *e)
+{
+ if(done)
+ e->accept();
+ else
+ {
+ e->ignore();
+ TQWhatsThis::display(SQ_ErrorString::instance()->string(SQE_NOTFINISHED));
+ }
+}
diff --git a/src/imageedit/sq_imageedit.h b/src/imageedit/sq_imageedit.h
new file mode 100644
index 0000000..a93e26b
--- /dev/null
+++ b/src/imageedit/sq_imageedit.h
@@ -0,0 +1,84 @@
+/***************************************************************************
+ sq_imageedit.h - description
+ -------------------
+ begin : ��� ��� 29 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_IMAGEEDIT_H
+#define SQ_IMAGEEDIT_H
+
+#include <tqfont.h>
+#include <tqcolor.h>
+
+#include "fmt_filters.h"
+
+struct SQ_ImageOptions
+{
+ TQString putto;
+ int where_to_put;
+ bool close;
+};
+
+struct SQ_ImageBCGOptions
+{
+ int b, c, g;
+ int red, green, blue;
+};
+
+struct SQ_ImageConvertOptions
+{
+ TQString libname;
+};
+
+struct SQ_ImageFilterOptions
+{
+ int type;
+
+ bool _bool;
+ fmt_filters::rgb rgb1, rgb2;
+ float _float;
+ unsigned int _uint;
+ double _double1, _double2;
+};
+
+namespace F
+{
+ enum ftype
+ {
+ fblend = 0,
+ fblur,
+ fdesaturate,
+ fdespeckle,
+ fedge,
+ femboss,
+ fequalize,
+ ffade,
+ fflatten,
+ fimplode,
+ fnegative,
+ fnoise,
+ foil,
+ fshade,
+ fsharpen,
+ fsolarize,
+ fspread,
+ fswapRGB,
+ fswirl,
+ fthreshold,
+ fgray,
+ fredeye
+ };
+}
+
+#endif
diff --git a/src/imageedit/sq_imageeditoptions.ui b/src/imageedit/sq_imageeditoptions.ui
new file mode 100644
index 0000000..1435010
--- /dev/null
+++ b/src/imageedit/sq_imageeditoptions.ui
@@ -0,0 +1,226 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_ImageEditOptions</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_ImageEditOptions</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>465</width>
+ <height>266</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Edit options</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQButtonGroup" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>buttonGroup1</cstring>
+ </property>
+ <property name="title">
+ <string>New files</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>2</number>
+ </property>
+ <widget class="TQRadioButton" row="3" column="0">
+ <property name="name">
+ <cstring>radioPutHere</cstring>
+ </property>
+ <property name="text">
+ <string>Place here</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>3</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>radioReplace</cstring>
+ </property>
+ <property name="text">
+ <string>Replace original files</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>2</number>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="4" column="0">
+ <property name="name">
+ <cstring>kurl</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioCurrentDir</cstring>
+ </property>
+ <property name="text">
+ <string>Place files in current directory, renaming them if necessary</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>1</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioCurrentDir_2</cstring>
+ </property>
+ <property name="text">
+ <string>Place files in current directory, replacing existing files</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>0</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQCheckBox" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>checkClose</cstring>
+ </property>
+ <property name="text">
+ <string>Close, when all operations succeeded</string>
+ </property>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton" row="4" column="1">
+ <property name="name">
+ <cstring>pushOK</cstring>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="4" column="2">
+ <property name="name">
+ <cstring>pushCancel</cstring>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ <spacer row="4" column="0">
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>260</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="Line" row="3" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>pushOK</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageEditOptions</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>pushCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageEditOptions</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>radioPutHere</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>kurl</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>radioCurrentDir_2</tabstop>
+ <tabstop>radioCurrentDir</tabstop>
+ <tabstop>radioReplace</tabstop>
+ <tabstop>radioPutHere</tabstop>
+ <tabstop>kurl</tabstop>
+ <tabstop>checkClose</tabstop>
+ <tabstop>pushOK</tabstop>
+ <tabstop>pushCancel</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in implementation">klineedit.h</include>
+ <include location="global" impldecl="in implementation">kpushbutton.h</include>
+ <include location="global" impldecl="in implementation">kurlrequester.h</include>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="local" impldecl="in implementation">sq_imageedit.h</include>
+ <include location="local" impldecl="in implementation">sq_imageeditoptions.ui.h</include>
+</includes>
+<forwards>
+ <forward>class SQ_ImageOptions;</forward>
+</forwards>
+<variables>
+ <variable access="private">int index;</variable>
+ <variable access="private">TQString putto, prefix;</variable>
+</variables>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function returnType="int">exec( SQ_ImageOptions * o )</function>
+ <function>setConfigPrefix( const TQString &amp; pr )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/imageedit/sq_imageeditoptions.ui.h b/src/imageedit/sq_imageeditoptions.ui.h
new file mode 100644
index 0000000..7640ce0
--- /dev/null
+++ b/src/imageedit/sq_imageeditoptions.ui.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+void SQ_ImageEditOptions::init()
+{
+ KFile::Mode mode = static_cast<KFile::Mode>(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly);
+ kurl->setMode(mode);
+}
+
+int SQ_ImageEditOptions::exec(SQ_ImageOptions *o)
+{
+ kurl->setURL(o->putto);
+
+ TQButton *b = buttonGroup1->find(o->where_to_put);
+
+ if(b)
+ b->animateClick();
+ else
+ {
+ tqWarning("SQ_ImageEditOptions::exec: wrong button Id");
+ radioCurrentDir->animateClick();
+ }
+
+ checkClose->setChecked(o->close);
+
+ int result = TQDialog::exec();
+
+ if(result == TQDialog::Accepted)
+ {
+ o->putto = (kurl->isEnabled()) ? kurl->url() : TQString();
+ o->where_to_put = buttonGroup1->selectedId();
+ o->close = checkClose->isChecked();
+
+ SQ_Config::instance()->setGroup("Image edit options");
+ SQ_Config::instance()->writeEntry(prefix + "_putto", o->putto);
+ SQ_Config::instance()->writeEntry(prefix + "_where_to_put", o->where_to_put);
+ SQ_Config::instance()->writeEntry(prefix + "_close", o->close);
+ }
+
+ return result;
+}
+
+void SQ_ImageEditOptions::setConfigPrefix( const TQString &pr )
+{
+ prefix = pr;
+}
diff --git a/src/imageedit/sq_imagefilter.ui b/src/imageedit/sq_imagefilter.ui
new file mode 100644
index 0000000..0e50f97
--- /dev/null
+++ b/src/imageedit/sq_imagefilter.ui
@@ -0,0 +1,1559 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_ImageFilter</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_ImageFilter</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>537</width>
+ <height>421</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Filter</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQWidgetStack" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>widgetStackFilters</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>blendWidget</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Color:</string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="1">
+ <property name="name">
+ <cstring>pushBlendColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer row="2" column="1">
+ <property name="name">
+ <cstring>spacer17</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>blendOpacity</cstring>
+ </property>
+ <property name="label">
+ <string>Opacity</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer9_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="1" column="0">
+ <property name="name">
+ <cstring>blurSigma</cstring>
+ </property>
+ <property name="label">
+ <string>Sigma</string>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>blurRadius</cstring>
+ </property>
+ <property name="label">
+ <string>Radius</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>2</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer10_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>45</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>desaturateValue</cstring>
+ </property>
+ <property name="label">
+ <string>Factor</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>3</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <property name="text">
+ <string>There are no special options available for this filter. Just click "Filter".</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer11</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>11</width>
+ <height>26</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>4</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer12</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>30</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KIntNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>edgeRadius</cstring>
+ </property>
+ <property name="label">
+ <string>Radius</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>5</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer13</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>30</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="1" column="0">
+ <property name="name">
+ <cstring>embossSigma</cstring>
+ </property>
+ <property name="label">
+ <string>Sigma</string>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>embossRadius</cstring>
+ </property>
+ <property name="label">
+ <string>Radius</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>6</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <property name="text">
+ <string>There are no special options available for this filter. Just click "Filter".</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer11_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>11</width>
+ <height>14</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>7</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KColorButton" row="0" column="1">
+ <property name="name">
+ <cstring>fadeColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer row="2" column="1">
+ <property name="name">
+ <cstring>spacer15</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_4</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Color:</string>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>fadeValue</cstring>
+ </property>
+ <property name="label">
+ <string>Value</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>8</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KColorButton" row="0" column="1">
+ <property name="name">
+ <cstring>flattenColor1</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer row="2" column="1">
+ <property name="name">
+ <cstring>spacer16</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>10</width>
+ <height>11</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KColorButton" row="1" column="1">
+ <property name="name">
+ <cstring>flattenColor2</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_4_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Color 1:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel1_4_3</cstring>
+ </property>
+ <property name="text">
+ <string>Color 2:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>9</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer15_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>25</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>implodeFactor</cstring>
+ </property>
+ <property name="label">
+ <string>Factor</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>10</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer11_2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>11</width>
+ <height>14</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2_2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <property name="text">
+ <string>There are no special options available for this filter. Just click "Filter".</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>11</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>buttonGroupNoise</cstring>
+ </property>
+ <property name="title">
+ <string>Noise type</string>
+ </property>
+ <property name="exclusive">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>2</number>
+ </property>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioButton1</cstring>
+ </property>
+ <property name="text">
+ <string>Uniform</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="0" column="1">
+ <property name="name">
+ <cstring>radioButton1_4</cstring>
+ </property>
+ <property name="text">
+ <string>Impulse</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>3</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>radioButton1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Multiplicative Gaussian</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="2" column="1">
+ <property name="name">
+ <cstring>radioButton1_6</cstring>
+ </property>
+ <property name="text">
+ <string>Poisson</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>5</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioButton1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Gaussian</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>1</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="1">
+ <property name="name">
+ <cstring>radioButton1_5</cstring>
+ </property>
+ <property name="text">
+ <string>Laplacian</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>4</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>12</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer15_2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>35</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KIntNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>oilRadius</cstring>
+ </property>
+ <property name="label">
+ <string>Radius</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>13</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>shadeColor</cstring>
+ </property>
+ <property name="text">
+ <string>Color</string>
+ </property>
+ </widget>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer21</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="2" column="0">
+ <property name="name">
+ <cstring>shadeElev</cstring>
+ </property>
+ <property name="label">
+ <string>Elevation</string>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput" row="1" column="0">
+ <property name="name">
+ <cstring>shadeAzim</cstring>
+ </property>
+ <property name="label">
+ <string>Azimuth</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>14</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer13_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="1" column="0">
+ <property name="name">
+ <cstring>sharpenSigma</cstring>
+ </property>
+ <property name="label">
+ <string>Sigma</string>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>sharpenRadius</cstring>
+ </property>
+ <property name="label">
+ <string>Radius</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>15</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer13_2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>60</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>solarizeValue</cstring>
+ </property>
+ <property name="label">
+ <string>Factor</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>16</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer24</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>35</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KIntNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>spreadValue</cstring>
+ </property>
+ <property name="label">
+ <string>Amount</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>17</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>buttonGroupSwapRGB</cstring>
+ </property>
+ <property name="title">
+ <string>Type</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>2</number>
+ </property>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioButton7</cstring>
+ </property>
+ <property name="text">
+ <string>GBR</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioButton8</cstring>
+ </property>
+ <property name="text">
+ <string>BRG</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer25</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>11</width>
+ <height>41</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>18</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer13_2_2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>25</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>swirlAngle</cstring>
+ </property>
+ <property name="label">
+ <string>Degrees</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>19</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer24_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>75</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KIntNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>thresholdValue</cstring>
+ </property>
+ <property name="label">
+ <string>Threshold</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>20</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2_2_2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <property name="text">
+ <string>There are no special options available for this filter. Just click "Filter".</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer11_2_2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>11</width>
+ <height>113</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>21</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KIntNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>thresholdRE</cstring>
+ </property>
+ <property name="label">
+ <string>Threshold</string>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer26_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>71</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ </widget>
+ <spacer row="1" column="1">
+ <property name="name">
+ <cstring>spacer27</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLayoutWidget" row="5" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer14</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>285</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushFilter</cstring>
+ </property>
+ <property name="text">
+ <string>Filter</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushCancel</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="Line" row="4" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>line7</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQListBox" row="0" column="0" rowspan="4" colspan="1">
+ <item>
+ <property name="text">
+ <string>Blend</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Blur</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Desaturate</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Despeckle</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Edge</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Emboss</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Equalize</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Fade</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Flatten</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Implode</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Negative</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Noise</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Oil</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Shade</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Sharpen</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Solarize</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Spread</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Swap colors</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Swirl</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Threshold</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Grayscale</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Redeye</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>listMain</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>140</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ <spacer row="3" column="2">
+ <property name="name">
+ <cstring>spacer26</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLayoutWidget" row="2" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_BCGLabel" row="1" column="3">
+ <property name="name">
+ <cstring>pixmap1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>160</width>
+ <height>160</height>
+ </size>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Original image:</string>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer27_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer28</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="SQ_BCGLabel" row="1" column="1">
+ <property name="name">
+ <cstring>pixmap</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>160</width>
+ <height>160</height>
+ </size>
+ </property>
+ </widget>
+ <spacer row="1" column="4">
+ <property name="name">
+ <cstring>spacer27_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="0" column="3" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Image after filtering:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>SQ_BCGLabel</class>
+ <header location="local">sq_bcglabel.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="PNG" length="1002">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154388dad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a190172af6a9690000000049454e44ae426082</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>pushCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageFilter</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>pushFilter</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageFilter</receiver>
+ <slot>slotStartFiltering()</slot>
+ </connection>
+ <connection>
+ <sender>listMain</sender>
+ <signal>selectionChanged()</signal>
+ <receiver>SQ_ImageFilter</receiver>
+ <slot>slotShowPage()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>pushFilter</tabstop>
+ <tabstop>pushCancel</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in declaration">sq_imageedit.h</include>
+ <include location="global" impldecl="in declaration">tqimage.h</include>
+ <include location="local" impldecl="in implementation">fmt_filters.h</include>
+ <include location="global" impldecl="in implementation">kcolorbutton.h</include>
+ <include location="global" impldecl="in implementation">knuminput.h</include>
+ <include location="global" impldecl="in implementation">sq_bcglabel.h</include>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="local" impldecl="in implementation">sq_imagefilter.ui.h</include>
+</includes>
+<variables>
+ <variable access="private">TQImage sample, sample_saved;</variable>
+ <variable access="private">static SQ_ImageFilter *m_inst;</variable>
+</variables>
+<signals>
+ <signal>filter(SQ_ImageFilterOptions*)</signal>
+</signals>
+<slots>
+ <slot access="private" specifier="non virtual">slotStartFiltering()</slot>
+ <slot access="private" specifier="non virtual">slotShowPage()</slot>
+ <slot access="private" specifier="non virtual">swapRGB()</slot>
+ <slot access="private" specifier="non virtual">blend()</slot>
+ <slot access="private" specifier="non virtual">fade()</slot>
+ <slot access="private" specifier="non virtual">desaturate()</slot>
+ <slot access="private" specifier="non virtual">threshold()</slot>
+ <slot access="private" specifier="non virtual">solarize()</slot>
+ <slot access="private" specifier="non virtual">spread()</slot>
+ <slot access="private" specifier="non virtual">swirl()</slot>
+ <slot access="private" specifier="non virtual">noise()</slot>
+ <slot access="private" specifier="non virtual">redeye()</slot>
+ <slot access="private" specifier="non virtual">flatten()</slot>
+ <slot access="private" specifier="non virtual">shade()</slot>
+ <slot access="private" specifier="non virtual">blur()</slot>
+ <slot access="private" specifier="non virtual">implode()</slot>
+ <slot access="private" specifier="non virtual">edge()</slot>
+ <slot access="private" specifier="non virtual">emboss()</slot>
+ <slot access="private" specifier="non virtual">sharpen()</slot>
+ <slot access="private" specifier="non virtual">oil()</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function specifier="non virtual">setPreviewImage( const TQImage &amp; im )</function>
+ <function access="private" specifier="non virtual">assignNewImage( const TQImage &amp; im )</function>
+ <function access="private" specifier="non virtual">negative()</function>
+ <function access="private" specifier="non virtual">togray()</function>
+ <function access="private" specifier="non virtual">equalize()</function>
+ <function access="private" specifier="non virtual">despeckle()</function>
+ <function access="private" specifier="non virtual">hackConnect()</function>
+ <function specifier="static" returnType="SQ_ImageFilter *">instance()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/imageedit/sq_imagefilter.ui.h b/src/imageedit/sq_imagefilter.ui.h
new file mode 100644
index 0000000..18eb263
--- /dev/null
+++ b/src/imageedit/sq_imagefilter.ui.h
@@ -0,0 +1,610 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+SQ_ImageFilter * SQ_ImageFilter::m_inst = 0;
+
+void SQ_ImageFilter::init()
+{
+ m_inst = this;
+
+ // restore NumInputs...
+ const double sigmaMax = 99.9, sigmaMin = 0.01;
+ const double radiusMax = 99.9, radiusMin = 0.01;
+
+ blendOpacity->setRange(0.0f, 1.0f, 0.01, true);
+ fadeValue->setRange(0.0f, 1.0f, 0.01f, true);
+ desaturateValue->setRange(0.0f, 1.0f, 0.01, true);
+ thresholdValue->setRange(0, 255, 1, true);
+ thresholdRE->setRange(0, 255, 1, true);
+ solarizeValue->setRange(0.0f, 50.0f, 0.01f, true);
+ spreadValue->setRange(1, 10, 1, true);
+ swirlAngle->setRange(-720.0f, 720.0f, 0.1f, true);
+ shadeAzim->setRange(0.0f, 90.0f, 0.01f, true);
+ shadeElev->setRange(0.0f, 90.0f, 0.01f, true);
+ blurRadius->setRange(radiusMin, radiusMax, 0.01f, true);
+ blurSigma->setRange(sigmaMin, 50.0, 0.01f, true);
+ implodeFactor->setRange(0, 100, 1, true);
+ edgeRadius->setRange((int)radiusMin, 30, 1, true);
+ embossRadius->setRange(radiusMin, radiusMax, 0.01f, true);
+ embossSigma->setRange(sigmaMin, sigmaMax, 0.01f, true);
+ sharpenRadius->setRange(radiusMin, radiusMax, 0.01f, true);
+ sharpenSigma->setRange(sigmaMin, 30.0, 0.01f, true);
+ oilRadius->setRange(1, 5, 1, true);
+
+ SQ_Config::instance()->setGroup("Image edit options");
+
+ buttonGroupSwapRGB->setButton(SQ_Config::instance()->readNumEntry("filter_swapRGB", 0));
+ // blend
+ TQColor c;
+ c.setNamedColor(SQ_Config::instance()->readEntry("filter_blend_color", "#00ff00"));
+ pushBlendColor->setColor(c);
+ blendOpacity->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_blend_opacity", 0.5));
+
+ // fade
+ c.setNamedColor(SQ_Config::instance()->readEntry("filter_flend_color", "#00ff00"));
+ fadeColor->setColor(c);
+ fadeValue->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_fade_value", 0.5));
+
+ // desaturate
+ desaturateValue->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_desaturate_value", 0.5));
+
+ // threshold
+ thresholdValue->setValue(SQ_Config::instance()->readNumEntry("filter_threshold_value", 1));
+
+ // threshold for redeye
+ thresholdRE->setValue(SQ_Config::instance()->readNumEntry("filter_threshold_redeye", 10));
+
+ // solarize
+ solarizeValue->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_solarize_value", 0.5));
+
+ // spread
+ spreadValue->setValue(SQ_Config::instance()->readNumEntry("filter_spread_value", 1));
+
+ // swirl
+ swirlAngle->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_swirl_value", 0.0));
+
+ // noise
+ buttonGroupNoise->setButton(SQ_Config::instance()->readNumEntry("filter_noise", 0));
+
+ // flatten
+ c.setNamedColor(SQ_Config::instance()->readEntry("filter_flatten_color1", "#00ff00"));
+ flattenColor1->setColor(c);
+ c.setNamedColor(SQ_Config::instance()->readEntry("filter_flatten_color2", "#00ff00"));
+ flattenColor2->setColor(c);
+
+ // shade
+ shadeAzim->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_shade_azim", 0.1));
+ shadeElev->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_shade_elev", 0.1));
+
+ if(SQ_Config::instance()->readBoolEntry("filter_shade_color", false))
+ shadeColor->toggle();
+
+ // blur
+ blurRadius->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_blur_radius", 0.1));
+ blurSigma->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_blur_sigma", 0.1));
+
+ // implode
+ implodeFactor->setValue(SQ_Config::instance()->readNumEntry("filter_implode_factor", 1));
+
+ // edge
+ edgeRadius->setValue(SQ_Config::instance()->readNumEntry("filter_egde_radius", 1));
+
+ // emboss
+ embossRadius->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_emboss_radius", 0.1));
+ embossSigma->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_emboss_sigma", 0.1));
+
+ // sharpen
+ sharpenRadius->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_sharpen_radius", 0.1));
+ sharpenSigma->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_sharpen_sigma", 0.1));
+
+ // oil
+ oilRadius->setValue(SQ_Config::instance()->readNumEntry("filter_oil_radius", 1));
+
+ listMain->setCurrentItem(SQ_Config::instance()->readNumEntry("filter_filter", 0));
+
+ hackConnect();
+}
+
+void SQ_ImageFilter::slotStartFiltering()
+{
+ SQ_Config *tdeconf = SQ_Config::instance();
+
+ tdeconf->setGroup("Image edit options");
+ tdeconf->writeEntry("filter_swapRGB", buttonGroupSwapRGB->selectedId());
+ tdeconf->writeEntry("filter_blend_color", pushBlendColor->color().name());
+ tdeconf->writeEntry("filter_blend_opacity", blendOpacity->value());
+ tdeconf->writeEntry("filter_fade_color", fadeColor->color().name());
+ tdeconf->writeEntry("filter_fade_value", fadeValue->value());
+ tdeconf->writeEntry("filter_desaturate_value", desaturateValue->value());
+ tdeconf->writeEntry("filter_threshold_value", thresholdValue->value());
+ tdeconf->writeEntry("filter_threshold_redeye", thresholdRE->value());
+ tdeconf->writeEntry("filter_solarize_value", solarizeValue->value());
+ tdeconf->writeEntry("filter_spread_value", spreadValue->value());
+ tdeconf->writeEntry("filter_swirl_value", swirlAngle->value());
+ tdeconf->writeEntry("filter_noise", buttonGroupNoise->selectedId());
+ tdeconf->writeEntry("filter_flatten_color1", flattenColor1->color().name());
+ tdeconf->writeEntry("filter_flatten_color2", flattenColor2->color().name());
+ tdeconf->writeEntry("filter_shade_azim", shadeAzim->value());
+ tdeconf->writeEntry("filter_shade_elev", shadeElev->value());
+ tdeconf->writeEntry("filter_shade_color", shadeColor->isChecked());
+ tdeconf->writeEntry("filter_blur_radius", blurRadius->value());
+ tdeconf->writeEntry("filter_blur_sigma", blurSigma->value());
+ tdeconf->writeEntry("filter_implode_factor", implodeFactor->value());
+ tdeconf->writeEntry("filter_egde_radius", edgeRadius->value());
+ tdeconf->writeEntry("filter_emboss_radius", embossRadius->value());
+ tdeconf->writeEntry("filter_emboss_sigma", embossSigma->value());
+ tdeconf->writeEntry("filter_sharpen_radius", sharpenRadius->value());
+ tdeconf->writeEntry("filter_sharpen_sigma", sharpenSigma->value());
+ tdeconf->writeEntry("filter_oil_radius", oilRadius->value());
+ tdeconf->writeEntry("filter_filter", listMain->currentItem());
+
+ SQ_ImageFilterOptions opt;
+
+ opt.type = listMain->currentItem();
+
+ switch(opt.type)
+ {
+ case F::fblend:
+ {
+ TQColor c = pushBlendColor->color();
+ opt.rgb1 = fmt_filters::rgb(c.red(), c.green(), c.blue());
+ opt._float = blendOpacity->value();
+ }
+ break;
+ case F::fblur: opt._double1 = blurRadius->value(); opt._double2 = blurSigma->value(); break;
+ case F::fdesaturate: opt._float = (float)desaturateValue->value(); break;
+ case F::fdespeckle: break;
+ case F::fedge: opt._double1 = (double)edgeRadius->value(); break;
+ case F::femboss: opt._double1 = embossRadius->value(); opt._double2 = embossSigma->value(); break;
+ case F::fequalize: break;
+ case F::ffade:
+ {
+ TQColor c = fadeColor->color();
+ opt.rgb1 = fmt_filters::rgb(c.red(), c.green(), c.blue());
+ opt._float = (float)fadeValue->value();
+ }
+ break;
+ case F::fflatten:
+ {
+ TQColor c = flattenColor1->color();
+ opt.rgb1 = fmt_filters::rgb(c.red(), c.green(), c.blue());
+ c = flattenColor2->color();
+ opt.rgb2 = fmt_filters::rgb(c.red(), c.green(), c.blue());
+ }
+ break;
+ case F::fimplode: opt._double1 = implodeFactor->value(); break;
+ case F::fnegative: break;
+ case F::fnoise: opt._uint = buttonGroupNoise->selectedId(); break;
+ case F::foil: opt._double1 = (double)oilRadius->value(); break;
+ case F::fshade: opt._bool = shadeColor->isChecked(); opt._double1 = shadeAzim->value(); opt._double2 = shadeElev->value(); break;
+ case F::fsharpen: opt._double1 = sharpenRadius->value(); opt._double2 = sharpenSigma->value();break;
+ case F::fsolarize: opt._double1 = solarizeValue->value(); break;
+ case F::fspread: opt._uint = spreadValue->value(); break;
+ case F::fswapRGB: opt._uint = buttonGroupSwapRGB->selectedId(); break;
+ case F::fswirl: opt._double1 = swirlAngle->value(); break;
+ case F::fthreshold: opt._uint = thresholdValue->value(); break;
+ case F::fgray: break;
+ case F::fredeye: opt._uint = thresholdRE->value(); break;
+ }
+
+ emit filter(&opt);
+}
+
+void SQ_ImageFilter::slotShowPage()
+{
+ int id = listMain->currentItem();
+
+ widgetStackFilters->raiseWidget(id);
+
+ switch(id)
+ {
+ case F::fblend: blend(); break;
+ case F::fblur: blur(); break;
+ case F::fdesaturate: desaturate(); break;
+ case F::fdespeckle: despeckle(); break;
+ case F::fedge: edge(); break;
+ case F::femboss: emboss(); break;
+ case F::fequalize: equalize(); break;
+ case F::ffade: fade(); break;
+ case F::fflatten: flatten(); break;
+ case F::fimplode: implode(); break;
+ case F::fnegative: negative(); break;
+ case F::fnoise: noise(); break;
+ case F::foil: oil(); break;
+ case F::fshade: shade(); break;
+ case F::fsharpen: sharpen(); break;
+ case F::fsolarize: solarize(); break;
+ case F::fspread: spread(); break;
+ case F::fswapRGB: swapRGB(); break;
+ case F::fswirl: swirl(); break;
+ case F::fthreshold: threshold(); break;
+ case F::fgray: togray(); break;
+ case F::fredeye: redeye(); break;
+ }
+}
+
+void SQ_ImageFilter::setPreviewImage(const TQImage &im)
+{
+ if(im.isNull()) return;
+
+ sample = im.copy();
+ sample_saved = sample.copy();
+
+ TQPixmap p;
+
+ p.convertFromImage(sample_saved);
+ pixmap->setPixmap(p);
+ pixmap1->setPixmap(p);
+
+ slotShowPage();
+}
+
+void SQ_ImageFilter::assignNewImage(const TQImage &im)
+{
+ TQPixmap p;
+ p.convertFromImage(im);
+ pixmap1->setPixmap(p);
+}
+
+void SQ_ImageFilter::swapRGB()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ int id = buttonGroupSwapRGB->selectedId();
+
+ if(id == -1)
+ return;
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::swapRGB(im, (id ? fmt_filters::GBR : fmt_filters::BRG));
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::negative()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::negative(im);
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::blend()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ TQColor c = pushBlendColor->color();
+
+ fmt_filters::rgb rgb(c.red(), c.green(), c.blue());
+
+ fmt_filters::blend(im, rgb, blendOpacity->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::fade()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ TQColor c = fadeColor->color();
+
+ fmt_filters::fade(im, fmt_filters::rgb(c.red(), c.green(), c.blue()), fadeValue->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::togray()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::gray(im);
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::desaturate()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::desaturate(im, desaturateValue->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::threshold()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::threshold(im, thresholdValue->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::solarize()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::solarize(im, solarizeValue->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::spread()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::spread(im, spreadValue->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::swirl()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::swirl(im, swirlAngle->value(), fmt_filters::rgba(255,255,255,255));
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::noise()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::noise(im, (fmt_filters::NoiseType)buttonGroupNoise->selectedId());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::redeye()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::redeye(im, im.w, im.h, 0, 0, thresholdRE->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::flatten()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ TQColor c1 = flattenColor1->color();
+ TQColor c2 = flattenColor2->color();
+
+ fmt_filters::flatten(im, fmt_filters::rgb(c1.red(), c1.green(), c1.blue()), fmt_filters::rgb(c2.red(), c2.green(), c2.blue()));
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::shade()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::shade(im, shadeColor->isChecked(), shadeAzim->value(), shadeElev->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::equalize()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::equalize(im);
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::blur()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::blur(im, blurRadius->value(), blurSigma->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::despeckle()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::despeckle(im);
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::implode()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::implode(im, implodeFactor->value(), fmt_filters::white);
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::edge()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::edge(im, (double)edgeRadius->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::emboss()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::emboss(im, embossRadius->value(), embossSigma->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::sharpen()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::sharpen(im, sharpenRadius->value(), sharpenSigma->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::oil()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::oil(im, oilRadius->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::hackConnect()
+{
+ connect( blendOpacity, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( blend() ) );
+ connect( pushBlendColor, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT( blend() ) );
+ connect( blurRadius, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( blur() ) );
+ connect( blurSigma, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( blur() ) );
+ connect( desaturateValue, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( desaturate() ) );
+ connect( edgeRadius, TQ_SIGNAL( valueChanged(int) ), this, TQ_SLOT( edge() ) );
+ connect( embossRadius, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( emboss() ) );
+ connect( embossSigma, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( emboss() ) );
+ connect( fadeColor, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT( fade() ) );
+ connect( fadeValue, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( fade() ) );
+ connect( flattenColor1, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT( flatten() ) );
+ connect( flattenColor2, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT( flatten() ) );
+ connect( implodeFactor, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( implode() ) );
+ connect( buttonGroupNoise, TQ_SIGNAL( clicked(int) ), this, TQ_SLOT( noise() ) );
+ connect( oilRadius, TQ_SIGNAL( valueChanged(int) ), this, TQ_SLOT( oil() ) );
+ connect( shadeAzim, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( shade() ) );
+ connect( shadeColor, TQ_SIGNAL( toggled(bool) ), this, TQ_SLOT( shade() ) );
+ connect( shadeElev, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( shade() ) );
+ connect( sharpenRadius, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( sharpen() ) );
+ connect( sharpenSigma, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( sharpen() ) );
+ connect( solarizeValue, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( solarize() ) );
+ connect( spreadValue, TQ_SIGNAL( valueChanged(int) ), this, TQ_SLOT( spread() ) );
+ connect( buttonGroupSwapRGB, TQ_SIGNAL( clicked(int) ), this, TQ_SLOT( swapRGB() ) );
+ connect( swirlAngle, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( swirl() ) );
+ connect( thresholdValue, TQ_SIGNAL( valueChanged(int) ), this, TQ_SLOT( threshold() ) );
+ connect( thresholdRE, TQ_SIGNAL( valueChanged(int) ), this, TQ_SLOT( redeye() ) );
+}
+
+SQ_ImageFilter* SQ_ImageFilter::instance()
+{
+ return m_inst;
+}
diff --git a/src/imageedit/sq_label.cpp b/src/imageedit/sq_label.cpp
new file mode 100644
index 0000000..a55a6eb
--- /dev/null
+++ b/src/imageedit/sq_label.cpp
@@ -0,0 +1,78 @@
+/***************************************************************************
+ sq_label.cpp - description
+ -------------------
+ begin : June 10 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tqpainter.h>
+
+#include "sq_label.h"
+
+#define MARGIN 15
+
+SQ_Label::SQ_Label(TQWidget *parent, const char *name) : TQWidget(parent, name), single(false)
+{}
+
+SQ_Label::~SQ_Label()
+{}
+
+void SQ_Label::paintEvent(TQPaintEvent *)
+{
+ if((single && ltext.isEmpty() && rtext.isEmpty()) || (!single && ltext.isEmpty()))
+ return;
+
+ TQPainter paint(this);
+
+ TQFont font = paint.font();
+ font.setBold(true);
+ font.setPointSize(10);
+ paint.setFont(font);
+
+ if(!single)
+ {
+ paint.translate((width() + paint.fontMetrics().height()) / 2, height());
+ paint.rotate(-90);
+ paint.drawText(MARGIN, 0, ltext);
+
+ paint.translate(height() - paint.fontMetrics().width(rtext), 0);
+ paint.drawText(-MARGIN, 0, rtext);
+ }
+ else
+ {
+ paint.translate((width() + paint.fontMetrics().height()) / 2,
+ (height() + paint.fontMetrics().width(ltext)) / 2);
+ paint.rotate(-90);
+ paint.drawText(0, 0, ltext);
+ }
+}
+
+void SQ_Label::setText(const TQString &lt, const TQString &rt)
+{
+ ltext = lt;
+ rtext = rt;
+
+ update();
+}
+
+void SQ_Label::setText(const TQString &lt)
+{
+ ltext = lt;
+
+ update();
+}
+
+void SQ_Label::setSingle(bool s)
+{
+ single = s;
+}
diff --git a/src/imageedit/sq_label.h b/src/imageedit/sq_label.h
new file mode 100644
index 0000000..6d0edd5
--- /dev/null
+++ b/src/imageedit/sq_label.h
@@ -0,0 +1,41 @@
+/***************************************************************************
+ sq_label.h - description
+ -------------------
+ begin : June 10 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_LABEL_H
+#define SQ_LABEL_H
+
+#include <tqwidget.h>
+
+class SQ_Label : public TQWidget
+{
+ public:
+ SQ_Label(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_Label();
+
+ void setText(const TQString &lt, const TQString &rt);
+ void setText(const TQString &lt);
+ void setSingle(bool s);
+
+ protected:
+ void paintEvent(TQPaintEvent *);
+
+ private:
+ TQString ltext, rtext;
+ bool single;
+};
+
+#endif
diff --git a/src/imageedit/sq_writeoption.ui b/src/imageedit/sq_writeoption.ui
new file mode 100644
index 0000000..43cf07e
--- /dev/null
+++ b/src/imageedit/sq_writeoption.ui
@@ -0,0 +1,168 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_WriteOption</class>
+<widget class="TQWidget">
+ <property name="name">
+ <cstring>SQ_WriteOption</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>250</width>
+ <height>340</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>250</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="caption">
+ <string>SQ_WriteOption</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQWidgetStack" row="0" column="0">
+ <property name="name">
+ <cstring>widgetStack</cstring>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>checkRLE</cstring>
+ </property>
+ <property name="text">
+ <string>RLE compression</string>
+ </property>
+ </widget>
+ <widget class="KIntNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>slider</cstring>
+ </property>
+ <property name="label">
+ <string>Compression level</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>checkInterlaced</cstring>
+ </property>
+ <property name="text">
+ <string>Interlaced</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;i&gt;No special options available for this format&lt;/i&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop|AlignHCenter</set>
+ </property>
+ <property name="indent">
+ <number>20</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<layoutdefaults spacing="6" margin="11"/>
+<includes>
+ <include location="global" impldecl="in implementation">knuminput.h</include>
+</includes>
+</UI>
diff --git a/src/konqksquirrel-dir.desktop b/src/konqksquirrel-dir.desktop
new file mode 100644
index 0000000..67d4977
--- /dev/null
+++ b/src/konqksquirrel-dir.desktop
@@ -0,0 +1,14 @@
+[Desktop Entry]
+X-TDE-ServiceTypes=inode/directory
+Actions=KSquirrel;
+Encoding=UTF-8
+Type=Application
+
+[Desktop Action KSquirrel]
+Type=Application
+Icon=ksquirrel
+Exec=ksquirrel %u
+
+Name=Browse with KSquirrel
+Name[ru]=Просмотреть в KSquirrel
+Name[de]=Mit KSquirrel durchsehen
diff --git a/src/ksquirrel-libs-configurator/Makefile.am b/src/ksquirrel-libs-configurator/Makefile.am
new file mode 100644
index 0000000..2dd4785
--- /dev/null
+++ b/src/ksquirrel-libs-configurator/Makefile.am
@@ -0,0 +1,16 @@
+INCLUDES = $(all_includes) -I$(srcdir)
+
+bin_PROGRAMS = ksquirrel-libs-configurator-real
+bin_SCRIPTS = ksquirrel-libs-configurator
+
+ksquirrel_libs_configurator_real_SOURCES = main.cpp klc.ui
+ksquirrel_libs_configurator_real_LDADD = $(KDE_LDFLAGS) $(QT_LDFLAGS) $(LIB_TDEIO) $(LIB_TDEUI) -lDCOP $(LIB_TDECORE) $(LIB_TQT)
+ksquirrel_libs_configurator_real_LDFLAGS = $(all_libraries) $(KDE_LDFLAGS) $(QT_LDFLAGS) $(LIB_TDEIO) $(LIB_TDEUI) -lDCOP $(LIB_TDECORE) $(LIB_TQT)
+
+AM_CXXFLAGS = $(ksquirrellibs_CFLAGS)
+
+messages:
+ LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \
+ if test -n "$$LIST"; then \
+ $(XGETTEXT) $$LIST -o $(podir)/ksquirrel.pot; \
+ fi
diff --git a/src/ksquirrel-libs-configurator/klc.cpp b/src/ksquirrel-libs-configurator/klc.cpp
new file mode 100644
index 0000000..4f9a3ef
--- /dev/null
+++ b/src/ksquirrel-libs-configurator/klc.cpp
@@ -0,0 +1,115 @@
+#include <kdialog.h>
+#include <tdelocale.h>
+/****************************************************************************
+** Form implementation generated from reading ui file './klc.ui'
+**
+** Created: Птн Дек 7 20:18:10 2007
+** by: The User Interface Compiler ($Id: tqt/main.cpp 3.3.7 edited Aug 31 2005 $)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "klc.h"
+
+#include <tqvariant.h>
+#include <kdirlister.h>
+#include <tdeio/job.h>
+#include <tqheader.h>
+#include <tqtimer.h>
+#include <tdeio/netaccess.h>
+#include <tdeapplication.h>
+#include <dcopclient.h>
+#include <tqpushbutton.h>
+#include <tqlistview.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
+#include <tqtooltip.h>
+#include <tqwhatsthis.h>
+#include "./klc.ui.h"
+
+/*
+ * Constructs a KLC as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ */
+KLC::KLC( TQWidget* parent, const char* name, WFlags fl )
+ : TQWidget( parent, name, fl )
+{
+ if ( !name )
+ setName( "KLC" );
+ KLCLayout = new TQGridLayout( this, 1, 1, 11, 6, "KLCLayout");
+
+ layout1 = new TQHBoxLayout( 0, 0, 6, "layout1");
+ spacer1 = new TQSpacerItem( 371, 26, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
+ layout1->addItem( spacer1 );
+
+ pushApply = new TQPushButton( this, "pushApply" );
+ layout1->addWidget( pushApply );
+
+ pushClose = new TQPushButton( this, "pushClose" );
+ layout1->addWidget( pushClose );
+
+ KLCLayout->addMultiCellLayout( layout1, 2, 2, 0, 1 );
+
+ listDisabled = new TQListView( this, "listDisabled" );
+ listDisabled->addColumn( tr2i18n( "..." ) );
+ listDisabled->setEnabled( FALSE );
+ listDisabled->setAllColumnsShowFocus( TRUE );
+ listDisabled->setResizeMode( TQListView::AllColumns );
+
+ KLCLayout->addWidget( listDisabled, 1, 1 );
+
+ textLabel1_2 = new TQLabel( this, "textLabel1_2" );
+
+ KLCLayout->addWidget( textLabel1_2, 0, 1 );
+
+ textLabel1 = new TQLabel( this, "textLabel1" );
+
+ KLCLayout->addWidget( textLabel1, 0, 0 );
+
+ listEnabled = new TQListView( this, "listEnabled" );
+ listEnabled->addColumn( tr2i18n( "..." ) );
+ listEnabled->setEnabled( FALSE );
+ listEnabled->setAllColumnsShowFocus( TRUE );
+ listEnabled->setResizeMode( TQListView::AllColumns );
+
+ KLCLayout->addWidget( listEnabled, 1, 0 );
+ languageChange();
+ resize( TQSize(586, 425).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+
+ // signals and slots connections
+ connect( pushApply, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotApply() ) );
+ connect( pushClose, TQ_SIGNAL( clicked() ), this, TQ_SLOT( close() ) );
+
+ // tab order
+ setTabOrder( listEnabled, listDisabled );
+ setTabOrder( listDisabled, pushApply );
+ setTabOrder( pushApply, pushClose );
+ init();
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+KLC::~KLC()
+{
+ destroy();
+ // no need to delete child widgets, TQt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void KLC::languageChange()
+{
+ setCaption( tr2i18n( "Codec manager" ) );
+ pushApply->setText( tr2i18n( "Apply" ) );
+ pushClose->setText( tr2i18n( "Close" ) );
+ listDisabled->header()->setLabel( 0, tr2i18n( "..." ) );
+ textLabel1_2->setText( tr2i18n( "<b>Select codecs to enable:</b>" ) );
+ textLabel1->setText( tr2i18n( "<b>Select codecs to disable:</b>" ) );
+ listEnabled->header()->setLabel( 0, tr2i18n( "..." ) );
+}
+
+#include "klc.moc"
diff --git a/src/ksquirrel-libs-configurator/klc.ui b/src/ksquirrel-libs-configurator/klc.ui
new file mode 100644
index 0000000..624d07b
--- /dev/null
+++ b/src/ksquirrel-libs-configurator/klc.ui
@@ -0,0 +1,190 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KLC</class>
+<widget class="TQWidget">
+ <property name="name">
+ <cstring>KLC</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>586</width>
+ <height>425</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Codec manager</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>371</width>
+ <height>26</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushApply</cstring>
+ </property>
+ <property name="text">
+ <string>Apply</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushClose</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQListView" row="1" column="1">
+ <column>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>listDisabled</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;Select codecs to enable:&lt;/b&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;Select codecs to disable:&lt;/b&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQListView" row="1" column="0">
+ <column>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>listEnabled</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushApply</sender>
+ <signal>clicked()</signal>
+ <receiver>KLC</receiver>
+ <slot>slotApply()</slot>
+ </connection>
+ <connection>
+ <sender>pushClose</sender>
+ <signal>clicked()</signal>
+ <receiver>KLC</receiver>
+ <slot>close()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>listEnabled</tabstop>
+ <tabstop>listDisabled</tabstop>
+ <tabstop>pushApply</tabstop>
+ <tabstop>pushClose</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in declaration">tdefileitem.h</include>
+ <include location="global" impldecl="in declaration">kurl.h</include>
+ <include location="global" impldecl="in implementation">kdirlister.h</include>
+ <include location="global" impldecl="in implementation">tdeio/job.h</include>
+ <include location="global" impldecl="in implementation">tqheader.h</include>
+ <include location="global" impldecl="in implementation">tqtimer.h</include>
+ <include location="global" impldecl="in implementation">tdeio/netaccess.h</include>
+ <include location="global" impldecl="in implementation">tdeapplication.h</include>
+ <include location="global" impldecl="in implementation">dcopclient.h</include>
+ <include location="local" impldecl="in implementation">klc.ui.h</include>
+</includes>
+<forwards>
+ <forward>class KDirLister;</forward>
+ <forward>namespace TDEIO { class Job; }</forward>
+</forwards>
+<variables>
+ <variable access="private">KURL base, backup;</variable>
+ <variable access="private">KDirLister *lister;</variable>
+ <variable access="private">TQString backupDir;</variable>
+ <variable access="private">bool changed;</variable>
+</variables>
+<slots>
+ <slot access="private">slotLoad()</slot>
+ <slot access="private">slotApply()</slot>
+ <slot access="private">slotCompleted( const KURL &amp; u )</slot>
+ <slot access="private">slotNewItems( const KFileItemList &amp; list )</slot>
+ <slot access="private">slotDeleteItem( KFileItem * fi )</slot>
+ <slot access="private">slotDelResult( TDEIO::Job * job )</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function access="private" specifier="non virtual">destroy()</function>
+ <function access="private" specifier="non virtual">moveCodecs( bool e2d )</function>
+ <function access="protected">closeEvent( TQCloseEvent * ev )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/ksquirrel-libs-configurator/klc.ui.h b/src/ksquirrel-libs-configurator/klc.ui.h
new file mode 100644
index 0000000..9d0ab7c
--- /dev/null
+++ b/src/ksquirrel-libs-configurator/klc.ui.h
@@ -0,0 +1,161 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** TQt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+#if !defined(QT_STRINGIFY)
+# define QT_STRINGIFY2(x) #x
+# define QT_STRINGIFY(x) QT_STRINGIFY2(x)
+#endif
+
+void KLC::init()
+{
+ changed = false;
+
+ listEnabled->setSorting(0);
+ listEnabled->header()->hide();
+
+ listDisabled->setSorting(0);
+ listDisabled->header()->hide();
+
+ lister = new KDirLister;
+ connect(lister, TQ_SIGNAL(completed(const KURL &)), this, TQ_SLOT(slotCompleted(const KURL &)));
+ connect(lister, TQ_SIGNAL(deleteItem(KFileItem *)), this, TQ_SLOT(slotDeleteItem(KFileItem *)));
+ connect(lister, TQ_SIGNAL(newItems(const KFileItemList &)), this, TQ_SLOT(slotNewItems(const KFileItemList &)));
+
+ base = KURL::fromPathOrURL(QT_STRINGIFY(SQ_KLIBS));
+
+ backup = base;
+ backup.addPath("backup");
+
+ backupDir = backup.path();
+
+ TDEIO::NetAccess::mkdir(backup, this);
+
+ TQTimer::singleShot(0, this, TQ_SLOT(slotLoad()));
+}
+
+void KLC::slotLoad()
+{
+ lister->openURL(base);
+ lister->openURL(backup, true);
+}
+
+void KLC::destroy()
+{
+ delete lister;
+}
+
+void KLC::slotApply()
+{
+ changed = true;
+
+ moveCodecs(true);
+ moveCodecs(false);
+}
+
+void KLC::moveCodecs(bool e2d)
+{
+ KURL::List list;
+ KURL codec;
+
+ TQListViewItemIterator it(e2d ? listEnabled : listDisabled);
+ TQCheckListItem *li;
+
+ while((li = static_cast<TQCheckListItem *>(it.current())))
+ {
+ if(li->isOn())
+ {
+ codec = e2d ? base : backup;
+ codec.addPath(li->text());
+ list.append(codec);
+ }
+
+ ++it;
+ }
+
+ TDEIO::Job *job = TDEIO::move(list, e2d ? backup : base);
+
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotDelResult(TDEIO::Job *)));
+}
+
+void KLC::slotCompleted(const KURL &u)
+{
+ if(u == base)
+ {
+ listEnabled->setEnabled(true);
+ listEnabled->setCurrentItem(listEnabled->firstChild());
+ }
+ else
+ {
+ listDisabled->setEnabled(true);
+ listDisabled->setCurrentItem(listDisabled->firstChild());
+ }
+}
+
+void KLC::slotNewItems(const KFileItemList &list)
+{
+ KFileItemListIterator it(list);
+ KFileItem *fi;
+ TQString soname = TQString::fromLatin1(".so.%1").arg(QT_STRINGIFY(SQ_KL_VER));
+
+ while((fi = it.current()))
+ {
+ if(fi->isFile() && fi->name().endsWith(soname))
+ new TQCheckListItem(fi->url().directory().startsWith(backupDir) ? listDisabled:listEnabled, fi->name(), TQCheckListItem::CheckBox);
+
+ ++it;
+ }
+}
+
+void KLC::slotDeleteItem(KFileItem *fi)
+{
+ TQListView *l = fi->url().directory().startsWith(backupDir) ? listDisabled:listEnabled;
+
+ TQListViewItemIterator it(l);
+ TQCheckListItem *li;
+ TQListViewItem *li2;
+
+ while((li = static_cast<TQCheckListItem *>(it.current())))
+ {
+ if(li->text() == fi->name())
+ {
+ li2 = li->itemBelow();
+
+ if(!li2)
+ li2 = li->itemAbove();
+
+ delete li;
+
+ l->setCurrentItem(li2);
+ l->setSelected(li2, true);
+
+ return;
+ }
+
+ ++it;
+ }
+}
+
+void KLC::slotDelResult(TDEIO::Job *job)
+{
+ if(job && job->error())
+ job->showErrorDialog(this);
+}
+
+void KLC::closeEvent(TQCloseEvent *ev)
+{
+ TQString data;
+
+ if(changed)
+ tdeApp->dcopClient()->send("ksquirrel", "ksquirrel", "reload_codecs()", data);
+
+ ev->accept();
+}
diff --git a/src/ksquirrel-libs-configurator/ksquirrel-libs-configurator b/src/ksquirrel-libs-configurator/ksquirrel-libs-configurator
new file mode 100755
index 0000000..d09c739
--- /dev/null
+++ b/src/ksquirrel-libs-configurator/ksquirrel-libs-configurator
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+tdesu --nonewdcop -c "${0}-real"
diff --git a/src/ksquirrel-libs-configurator/main.cpp b/src/ksquirrel-libs-configurator/main.cpp
new file mode 100644
index 0000000..4bfc26c
--- /dev/null
+++ b/src/ksquirrel-libs-configurator/main.cpp
@@ -0,0 +1,61 @@
+/***************************************************************************
+ main.cpp - description
+ -------------------
+ begin : Dec 03 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tdeapplication.h>
+#include <tdecmdlineargs.h>
+#include <tdeaboutdata.h>
+#include <tdeglobal.h>
+#include <tdelocale.h>
+
+#include "klc.h"
+
+static TDECmdLineOptions options[] =
+{
+ TDECmdLineLastOption
+};
+
+int main(int argc, char *argv[])
+{
+ const TQCString App = "ksquirrel-libs-configurator";
+
+ TDEAboutData aboutData(
+ "ksquirrel-libs-configurator",
+ "ksquirrel-libs-configurator",
+ "0.1",
+ I18N_NOOP("ksquirrel-libs-configurator"),
+ TDEAboutData::License_GPL,
+ "(c) 2007 Baryshev Dmitry",
+ TQString(),
+ "http://ksquirrel.sourceforge.net",
+
+ TDECmdLineArgs::init(argc, argv, &aboutData);
+ TDECmdLineArgs::addCmdLineOptions(options);
+
+ TDEApplication app;
+
+ TDEGlobal::locale()->insertCatalogue("ksquirrel");
+ TDEGlobal::locale()->setActiveCatalogue("ksquirrel");
+
+ KLC *klc = new KLC(0, App);
+
+ app.setMainWidget(klc);
+
+ klc->show();
+
+ return app.exec();
+}
diff --git a/src/ksquirrel.cpp b/src/ksquirrel.cpp
new file mode 100644
index 0000000..14f12d7
--- /dev/null
+++ b/src/ksquirrel.cpp
@@ -0,0 +1,2216 @@
+/***************************************************************************
+ ksquirrel.cpp - description
+ -------------------
+ begin : Dec 10 2003
+ copyright : (C) 2003 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqapplication.h>
+#include <tqeventloop.h>
+#include <tqpixmap.h>
+#include <tqcolor.h>
+#include <tqlabel.h>
+#include <tqvbox.h>
+#include <tqvaluevector.h>
+#include <tqvaluelist.h>
+#include <tqcursor.h>
+#include <tqpainter.h>
+#include <tqfile.h>
+#include <tqtoolbutton.h>
+#include <tqfileinfo.h>
+#include <tqtimer.h>
+#include <tqstylesheet.h>
+#include <tqwidgetstack.h>
+
+#include <tdeapplication.h>
+#include <khelpmenu.h>
+#include <tdepopupmenu.h>
+#include <twin.h>
+#include <kstatusbar.h>
+#include <tdemenubar.h>
+#include <tdetoolbar.h>
+#include <tdeaction.h>
+#include <kbookmarkmanager.h>
+#include <kbookmarkmenu.h>
+#include <kstandarddirs.h>
+#include <kcombobox.h>
+#include <kstdaction.h>
+#include <tdelocale.h>
+#include <kdebug.h>
+#include <tdemessagebox.h>
+#include <tdefiledialog.h>
+#include <krun.h>
+#include <kanimwidget.h>
+#include <tdeglobalsettings.h>
+#include <tdeactioncollection.h>
+#include <tdemultitabbar.h>
+#include <kurlcompletion.h>
+#include <konq_pixmapprovider.h>
+#include <tdeio/job.h>
+#include <tdeio/netaccess.h>
+#include <kinputdialog.h>
+#include <ksystemtray.h>
+#include <ksqueezedtextlabel.h>
+#include <ktabbar.h>
+#include <tdeprocess.h>
+
+#include "ksquirrel.h"
+#include "sq_iconloader.h"
+#include "sq_widgetstack.h"
+#include "sq_treeview.h"
+#include "sq_options.h"
+#include "sq_glview.h"
+#include "sq_glwidget.h"
+#include "sq_libraryhandler.h"
+#include "sq_externaltool.h"
+#include "sq_externaltools.h"
+#include "sq_config.h"
+#include "sq_filters.h"
+#include "sq_bookmarkowner.h"
+#include "sq_hloptions.h"
+#include "sq_pixmapcache.h"
+#include "sq_thumbnailsize.h"
+#include "sq_pixmapcache.h"
+#include "sq_archivehandler.h"
+#include "sq_dir.h"
+#include "sq_dirthumbs.h"
+#include "sq_thumbnailloadjob.h"
+#include "sq_navigatordropmenu.h"
+#include "sq_errorstring.h"
+#include "sq_thumbnailcachemaster.h"
+#include "sq_glwidget_helpers.h"
+#include "sq_pluginsinfo.h"
+#include "sq_imageloader.h"
+#include "sq_multibar.h"
+#include "sq_glinfo.h"
+#include "sq_splashscreen.h"
+#include "sq_previewwidget.h"
+#include "sq_progress.h"
+#include "sq_thumbnailsunused.h"
+#include "sq_downloader.h"
+#include "sq_dragprovider.h"
+
+#include "sq_slideshow.h"
+#include "sq_slideshowwidget.h"
+#include "sq_slideshowlisting.h"
+#include "sq_categoriesview.h"
+#include "sq_mountview.h"
+#include "sq_imagebasket.h"
+#include "sq_directorybasket.h"
+#include "sq_converter.h"
+
+#ifdef SQ_HAVE_KIPI
+#include "sq_kipimanager.h"
+#endif
+
+#include <cstdlib>
+#include <iostream>
+
+static const int menuParam = 100000;
+
+KSquirrel * KSquirrel::m_instance = 0;
+
+KSquirrel::KSquirrel(TQWidget *parent, const char *name)
+ : TDEMainWindow (parent, name), DCOPObject(name)
+{
+ // singleton setup
+ m_instance = this;
+
+ kdDebug() << "+KSquirrel" << endl;
+
+ slideShowStop = true;
+ slideShowPaused = false;
+ m_intray = false;
+ waitForShow = true;
+ m_demo = false;
+
+ writeDefaultEntries();
+
+ // create TDEConfig instance.
+ // It will help us to read and write config entries
+ tdeconf = new SQ_Config(this);
+
+ old_id = 0;
+
+ tdeconf->setGroup("Thumbnails");
+
+ thumbSize = new SQ_ThumbnailSize(this, static_cast<SQ_ThumbnailSize::Size>(tdeconf->readNumEntry("size",
+ SQ_ThumbnailSize::Large)));
+ thumbSize->setExtended(tdeconf->readBoolEntry("extended", false));
+
+ sqFiltersName = 0;
+ pCurrentURL = 0;
+ mainPage = 0;
+
+ SQ_SplashScreen::advance();
+
+ fillMessages();
+
+ preCreate();
+}
+
+KSquirrel::~KSquirrel()
+{
+ kdDebug() << "-KSquirrel" << endl;
+
+ delete sqFiltersExt;
+ delete sqFiltersName;
+ delete gl_view;
+ delete tdeconf;
+}
+
+/*
+ * Restore saved position & size
+ */
+void KSquirrel::handlePositionSize()
+{
+ TQPoint p_def(0,0);
+ TQSize sz_def(800, 600);
+
+ tdeconf->setGroup("Interface");
+
+ TQPoint p = SQ_Config::instance()->readPointEntry("pos", &p_def);
+ TQSize sz = SQ_Config::instance()->readSizeEntry("size", &sz_def);
+
+ resize(sz);
+ move(p);
+}
+
+/*
+ * Invoke 'Options' dialog.
+ */
+void KSquirrel::slotOptions()
+{
+ // create dialog
+ SQ_Options optd(this, "sq_options", true);
+
+ tdeconf->setGroup("Fileview");
+ old_disable = tdeconf->readBoolEntry("disable_dirs", false);
+ old_calc = tdeconf->readBoolEntry("calculate", true);
+
+ tdeconf->setGroup("Thumbnails");
+
+ tdeconf->setGroup("GL view");
+ old_marks = tdeconf->readBoolEntry("marks", true);
+
+ // if user clicked "OK", apply new settings
+ if(optd.start() == TQDialog::Accepted)
+ {
+ applyDefaultSettings();
+
+ if(SQ_HLOptions::instance()->have_mountview)
+ SQ_MountView::instance()->setupColumns();
+
+ SQ_TreeView::instance()->setupRecursion();
+ SQ_PreviewWidget::instance()->rereadColor();
+ SQ_PreviewWidget::instance()->update();
+ emit resetToolTip();
+
+ // create or delete animated logo
+ configAnime(false);
+ }
+}
+
+bool KSquirrel::eventFilter(TQObject *o, TQEvent *e)
+{
+ if(o == mainPage && e->type() == TQEvent::Show)
+ {
+ // delayed init, hehe...
+ if(waitForShow)
+ {
+ kdDebug() << "Creating additional widgets..." << endl;
+
+ tdeconf->setGroup("Thumbnails");
+ SQ_PixmapCache::instance()->setCacheLimit(tdeconf->readNumEntry("cache", 1024*10));
+
+#ifdef SQ_HAVE_KIPI
+ tdeconf->setGroup("Main");
+
+ // load KIPI plugins on demand ?
+ if(!tdeconf->readBoolEntry("kipi_ondemand", true))
+ kipiManager->loadPlugins();
+#endif
+
+ if(SQ_HLOptions::instance()->have_mountview)
+ {
+ sideBar->addWidget(new SQ_MountView, i18n("Mount points"), "blockdevice");
+ connect(SQ_MountView::instance(), TQ_SIGNAL(path(const TQString &)), pWidgetStack, TQ_SLOT(setURLForCurrent(const TQString &)));
+ }
+
+ if(SQ_HLOptions::instance()->have_categories)
+ sideBar->addWidget(new SQ_CategoriesBox, i18n("Categories"), "bookmark");
+
+ if(SQ_HLOptions::instance()->have_imagebasket)
+ sideBar->addWidget(new SQ_ImageBasket, i18n("Image basket"), "folder_image");
+
+ if(SQ_HLOptions::instance()->have_directorybasket)
+ sideBar->addWidget(new SQ_DirectoryBasket, i18n("Folder basket"), "folder");
+
+ tdeconf->setGroup("Interface");
+
+ // restore opened page in sidebar
+ int pg = tdeconf->readNumEntry("last page", -1);
+
+ TQPushButton *b = sideBar->multiBar()->tab(pg);
+
+ if(pg >= 0 && !b)
+ {
+ pg = 0;
+ b = sideBar->multiBar()->tab(0);
+ tdeconf->writeEntry("last page", 0);
+ }
+
+ if(pg >= 0 && b)
+ b->animateClick();
+
+ waitForShow = false;
+ }
+ }
+
+ return false;
+}
+
+/*
+ * Catches close events.
+ */
+void KSquirrel::closeEvent(TQCloseEvent *ev)
+{
+ tdeconf->setGroup("Main");
+
+ if((m_demo && !m_intray) || tdeApp->sessionSaving())
+ {
+ // finalActions() called by slotSaveYourself()
+ if(!tdeApp->sessionSaving())
+ finalActions();
+
+ ev->accept();
+ }
+ else
+ {
+ // Minimize to tray ?
+ if(tdeconf->readBoolEntry("minimize to tray", false) || m_intray)
+ {
+ // Yes, let's hide to tray
+ slotGotoTray();
+ // ignore close event
+ ev->ignore();
+ }
+ else // No, close app
+ {
+ // do final stuff
+ finalActions();
+ // accept close event - exit
+ ev->accept();
+ }
+ }
+}
+
+// Show List view
+void KSquirrel::slotRaiseListView()
+{
+ pWidgetStack->raiseWidget(SQ_DirOperator::TypeList);
+}
+
+// Show icon view
+void KSquirrel::slotRaiseIconView()
+{
+ pWidgetStack->raiseWidget(SQ_DirOperator::TypeIcons);
+}
+
+// Show Detailed view
+void KSquirrel::slotRaiseDetailView()
+{
+ pWidgetStack->raiseWidget(SQ_DirOperator::TypeDetailed);
+}
+
+// Show Thumbnail view
+void KSquirrel::slotRaiseThumbView()
+{
+ pWidgetStack->raiseWidget(SQ_DirOperator::TypeThumbs);
+}
+
+// Create location toolbar
+void KSquirrel::createLocationToolbar(TDEToolBar *pTLocation)
+{
+ // create new KHistoryCombo
+ pCurrentURL = new KHistoryCombo(true, pTLocation, "history combobox");
+
+ // some additional setup
+ pTLocation->setFullSize();
+ pTLocation->insertButton("button_cancel", 0, TQ_SIGNAL(clicked()), pCurrentURL, TQ_SLOT(clearHistory()), true, i18n("Clear history"));
+ pTLocation->insertButton("locationbar_erase", 1, TQ_SIGNAL(clicked()), pCurrentURL, TQ_SLOT(clearEdit()), true, i18n("Clear address"));
+ pTLocation->insertWidget(2, 10, new TQLabel("URL:", pTLocation, "tde toolbar widget"));
+ pTLocation->setItemAutoSized(2);
+ pTLocation->insertWidget(3, 10, pCurrentURL);
+ pTLocation->setItemAutoSized(3);
+ pTLocation->insertButton("goto", 4, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotGo()), true, i18n("Go!"));
+
+ tdeconf->setGroup("History");
+
+ // some additional setup
+
+ pCurrentURL->setPixmapProvider(KonqPixmapProvider::self());
+ pCurrentURL->setCompletionObject(new KURLCompletion(KURLCompletion::DirCompletion));
+ pCurrentURL->setDuplicatesEnabled(false);
+ pCurrentURL->setSizeLimit(20);
+ pCurrentURL->setHistoryItems(tdeconf->readListEntry("items"), true);
+}
+
+// Create menu with filters
+void KSquirrel::initFilterMenu()
+{
+ TQString ext, tmp;
+ unsigned int i = menuParam;
+
+ TQString last;
+
+ tdeconf->setGroup("Filters");
+
+ // create TQStringLists with names and extensions
+ // of custom filters
+ if(!sqFiltersName)
+ {
+ sqFiltersName = new TQStringList(tdeconf->readListEntry("items"));
+ sqFiltersExt = new TQStringList(tdeconf->readListEntry("extensions"));
+
+ // last used filter
+ last = tdeconf->readEntry("last", "*");
+
+ // allow user to check/uncheck menuitems
+ actionFilterMenu->setCheckable(true);
+ }
+ else // if TQStringLists already exist
+ last = pWidgetStack->nameFilter();
+
+ actionFilterMenu->clear();
+ int id, Id = old_id;
+ bool both = tdeconf->readBoolEntry("menuitem both", true);
+ TQStringList quickInfo;
+
+ // Get extensions and names of libraries' filters
+ libhandler->allFilters(libFilters, quickInfo);
+
+ actionFilterMenu->insertTitle(i18n("Libraries' filters"));
+
+ // insert libraries' filters to menu
+ for(TQValueList<TQString>::iterator it = libFilters.begin(), it1 = quickInfo.begin();
+ it != libFilters.end();++it, ++it1)
+ {
+ // show both name and extension ?
+ if(both)
+ id = actionFilterMenu->insertItem(*it1 + " (" + *it + ')');
+ else
+ id = actionFilterMenu->insertItem(*it1);
+
+ actionFilterMenu->setItemParameter(id, i++);
+
+ if(last == *it && !last.isEmpty())
+ Id = id;
+ }
+
+ // all filters' extension in one string
+ TQString allF = libhandler->allFiltersString();
+
+ libFilters.append(allF);
+
+ id = actionFilterMenu->insertItem(i18n("All supported formats"));
+ actionFilterMenu->setItemParameter(id, i++);
+
+ if(last == allF && !last.isEmpty())
+ Id = id;
+
+ TQValueList<TQString>::iterator nEND = sqFiltersName->end();
+ TQValueList<TQString>::iterator it_name = sqFiltersName->begin();
+ TQValueList<TQString>::iterator it_ext = sqFiltersExt->begin();
+
+ actionFilterMenu->insertTitle(i18n("User's filters"));
+ i = 0;
+// actionFilterMenu->setItemParameter(id, i++);
+
+ // add custom filters
+ for(;it_name != nEND;it_name++,it_ext++)
+ {
+ if(both)
+ id = actionFilterMenu->insertItem(*it_name + " (" + *it_ext + ')');
+ else
+ id = actionFilterMenu->insertItem(*it_name);
+
+ if(last == *it_ext && !last.isEmpty())
+ Id = id;
+
+ actionFilterMenu->setItemParameter(id, i++);
+ }
+
+ disconnect(actionFilterMenu, TQ_SIGNAL(activated(int)), 0, 0);
+ connect(actionFilterMenu, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotSetFilter(int)));
+
+ // finally, set current filter
+ setFilter(last, Id);
+}
+
+// "Go" clicked in url box
+void KSquirrel::slotGo()
+{
+ pWidgetStack->setURLForCurrent(pCurrentURL->currentText());
+}
+
+// Set filter for a filemanager and check appropriate
+// menuitem (by 'id')
+void KSquirrel::setFilter(const TQString &f, const int id)
+{
+ if(pWidgetStack->nameFilter() != f)
+ pWidgetStack->setNameFilter(f);
+
+// actionFilterMenu->setItemChecked(old_id, false);
+ actionFilterMenu->setItemChecked(id, true);
+ old_id = id;
+}
+
+// User seleced some filter from menu
+void KSquirrel::slotSetFilter(int id)
+{
+ // uncheck old item being checked
+ actionFilterMenu->setItemChecked(old_id, false);
+
+ // new item's index
+ int index = actionFilterMenu->itemParameter(id);
+
+ TQString filt;
+
+ // Is it libraries' filter or custom ?
+ if(index >= menuParam)
+ filt = libFilters[index - menuParam];
+ else
+ filt = (*sqFiltersExt)[index];
+
+ // If new filter differences from current -
+ // let's apply it
+ if(pWidgetStack->nameFilter() != filt)
+ pWidgetStack->setNameFilter(filt);
+
+ // finally, check new item
+ actionFilterMenu->setItemChecked(id, true);
+ old_id = id;
+}
+
+// Create all widgets (toolbar, menubar, image window ...)
+void KSquirrel::createWidgets(int createFirst)
+{
+ // check if location toolbar should be separated
+ m_urlbox = tdeconf->readBoolEntry("has_url", false);
+
+ // main TQVBox
+ mainPage = new TQVBox(this, TQString::fromLatin1("SQ_BROWSER_VBOX"));
+ mainPage->resize(size());
+
+ SQ_SplashScreen::advance();
+
+ mainPage->installEventFilter(this);
+
+ // menubar & toolbar
+ menubar = new KMenuBar(mainPage);
+ tools = new TDEToolBar(mainPage);
+
+ // location toolbar
+ pTLocation = new TDEToolBar(mainPage, TQString::fromLatin1("Location toolbar"));
+ pTLocation->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Minimum);
+
+ // main splitter
+ mainView = new TQSplitter(TQt::Horizontal, mainPage); Q_ASSERT(mainView);
+
+ KStatusBar *s = new KStatusBar(mainPage);
+
+ createLocationToolbar(pTLocation);
+ createStatusBar(s);
+
+ new SQ_NavigatorDropMenu(this);
+
+ sideBar = new SQ_MultiBar(mainView);
+
+ SQ_SplashScreen::advance();
+
+ // create widgetstack containing views
+ pWidgetStack = new SQ_WidgetStack(mainView, createFirst);
+
+ tdeconf->setGroup("Interface");
+ TQValueList<int> sz = SQ_Config::instance()->readIntListEntry("splitter");
+
+ if(sz.count() != 2)
+ {
+ sz.clear();
+ sz.append(1500);
+ sz.append(3500);
+ }
+
+ mainView->setSizes(sz);
+
+ SQ_SplashScreen::advance();
+
+ ptree = new SQ_TreeView;
+
+ SQ_SplashScreen::advance();
+
+ sideBar->addWidget(ptree, i18n("Folder tree"), "view_tree");
+ sideBar->updateLayout();
+
+ connect(ptree, TQ_SIGNAL(urlAdded(const KURL &)), pWidgetStack->diroperator(), TQ_SLOT(urlAdded(const KURL &)));
+ connect(ptree, TQ_SIGNAL(urlRemoved(const KURL &)), pWidgetStack->diroperator(), TQ_SLOT(urlRemoved(const KURL &)));
+ connect(pWidgetStack->diroperator(), TQ_SIGNAL(urlEntered(const KURL &)), ptree, TQ_SLOT(slotClearChecked()));
+ connect(pWidgetStack, TQ_SIGNAL(newLastURL(const TQString &)), pWidgetStack->action("dirop_repeat"), TQ_SLOT(setText(const TQString &)));
+ connect(SQ_PreviewWidget::instance(), TQ_SIGNAL(first()), pWidgetStack, TQ_SLOT(slotSelectFirstFile()));
+ connect(SQ_PreviewWidget::instance(), TQ_SIGNAL(last()), pWidgetStack, TQ_SLOT(slotSelectLastFile()));
+ connect(SQ_PreviewWidget::instance(), TQ_SIGNAL(next()), this, TQ_SLOT(slotPreviewWidgetNext()));
+ connect(SQ_PreviewWidget::instance(), TQ_SIGNAL(previous()), this, TQ_SLOT(slotPreviewWidgetPrevious()));
+ connect(SQ_PreviewWidget::instance(), TQ_SIGNAL(execute()), this, TQ_SLOT(slotPreviewWidgetExecute()));
+
+ pWidgetStack->init();
+
+ pTLocation->setShown(m_urlbox);
+ pAURL->setChecked(m_urlbox);
+ mainPage->setStretchFactor(mainView, 1);
+
+ // connect signals from location toolbar
+ connect(pCurrentURL, TQ_SIGNAL(returnPressed(const TQString&)), pWidgetStack, TQ_SLOT(setURLForCurrent(const TQString&)));
+ connect(pCurrentURL, TQ_SIGNAL(activated(const TQString&)), pWidgetStack, TQ_SLOT(setURLForCurrent(const TQString&)));
+
+ gl_view = new SQ_GLView;
+
+ SQ_SplashScreen::advance();
+
+// KIPI support
+#ifdef SQ_HAVE_KIPI
+ kipiManager = new SQ_KIPIManager(this);
+#endif
+
+ // insert actions in toolbar and menu
+ createToolbar(tools);
+ createMenu(menubar);
+
+ switch(createFirst)
+ {
+ case 1: pARaiseIconView->setChecked(true); break;
+ case 2: pARaiseDetailView->setChecked(true); break;
+ case 3: pARaiseThumbView->setChecked(true); break;
+
+ default:
+ pARaiseListView->setChecked(true);
+ }
+
+ // connect signals from widgets
+ connect(pAURL, TQ_SIGNAL(toggled(bool)), pTLocation, TQ_SLOT(setShown(bool)));
+ connect(pASelectGroup, TQ_SIGNAL(activated()), pWidgetStack, TQ_SLOT(slotSelectGroup()));
+ connect(pADeselectGroup, TQ_SIGNAL(activated()), pWidgetStack, TQ_SLOT(slotDeselectGroup()));
+ connect(pASelectAll, TQ_SIGNAL(activated()), pWidgetStack, TQ_SLOT(slotSelectAll()));
+ connect(pADeselectAll, TQ_SIGNAL(activated()), pWidgetStack, TQ_SLOT(slotDeselectAll()));
+
+ SQ_SplashScreen::advance();
+
+#if 0
+ KWin::setState(gl_view->winId(), NET::SkipTaskbar | NET::SkipPager);
+#endif
+}
+
+// Create statusbar and all needed TQLabels
+void KSquirrel::createStatusBar(KStatusBar *bar)
+{
+ sbar = bar;
+ sbar->setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Fixed);
+ sbar->setSizeGripEnabled(true);
+ sbar->show();
+
+ // directory information (for example "3 dirs, 12 files")
+ dirInfo = new TQLabel(TQString(), sbar, "dirInfo");
+
+ TQHBox *vb = new TQHBox(sbar);
+
+ // mime icon of current file
+ fileIcon = new TQLabel(TQString(), vb, "fileIcon");
+ fileIcon->setScaledContents(false);
+
+ // name of current file
+ fileName = new KSqueezedTextLabel(TQString::fromLatin1("----"), vb, "fileName");
+ fileName->setTextFormat(TQt::RichText);
+ fileName->setAlignment(TQt::AlignAuto | TQt::AlignVCenter | TQt::ExpandTabs);
+
+ diskSpace = new TQLabel(TQString(), sbar, "diskSpace");
+
+ // insert pointers to map, now it is possible
+ // to call KSquirrel::sbarWidget(name)
+ sbarwidgets["dirInfo"] = dirInfo;
+ sbarwidgets["fileIcon"] = fileIcon;
+ sbarwidgets["fileName"] = fileName;
+ sbarwidgets["diskSpace"] = diskSpace;
+
+ // finally, add TQLabels to statusbar
+ sbar->addWidget(dirInfo, 0, true);
+ sbar->addWidget(vb, 1, true);
+
+ TQToolButton *fireDisk = new TQToolButton(sbar, "reload disk size");
+ fireDisk->setIconSet(SQ_IconLoader::instance()->loadIcon("reload", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ fireDisk->setTextLabel(i18n("Reload"));
+ fireDisk->setUsesTextLabel(false);
+ connect(fireDisk, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotFireDisk()));
+
+ diskProg = new SQ_Progress(sbar, "SQ_Progress [disk space]");
+ diskProg->setFixedWidth(150);
+
+ sbar->addWidget(fireDisk, 0, true);
+ sbar->addWidget(diskSpace, 0, true);
+ sbar->addWidget(diskProg, 0, true);
+}
+
+void KSquirrel::slotFireDisk()
+{
+ pWidgetStack->diroperator()->fireDiskSize(pWidgetStack->diroperator()->url());
+}
+
+// Create menu
+void KSquirrel::createMenu(KMenuBar *menubar)
+{
+ pop_file = new TDEPopupMenu(menubar);
+ pop_view = new TDEPopupMenu(menubar);
+ pop_action = new TDEPopupMenu(menubar);
+ pop_nav = new TDEPopupMenu(menubar);
+
+ // create bookmarks and filters
+ initBookmarks();
+ initFilterMenu();
+
+ // inset new submenus
+ menubar->insertItem(i18n("&File"), pop_file);
+ menubar->insertItem(i18n("&View"), pop_view);
+ menubar->insertItem(i18n("&Navigator"), pop_nav);
+ menubar->insertItem(i18n("&Action"), pop_action);
+
+#ifdef SQ_HAVE_KIPI
+ menubar->insertItem(i18n("&KIPI Plugins"), kipiManager->popup());
+#endif
+
+ bookmarks->plug(menubar);
+ menubar->insertItem(i18n("&Help"), helpMenu());
+
+ // plug actions to menus
+ pAOpen->plug(pop_file);
+ pAOpenAndSet->plug(pop_file);
+ pop_file->insertSeparator();
+ pARename->plug(pop_file);
+ pWidgetStack->action("properties")->plug(pop_file);
+ pWidgetStack->action("delete")->plug(pop_file);
+ pop_file->insertSeparator();
+ pAExit->plug(pop_file);
+
+ pWidgetStack->action("home")->plug(pop_nav);
+ pWidgetStack->action("up")->plug(pop_nav);
+ pWidgetStack->action("back")->plug(pop_nav);
+ pWidgetStack->action("forward")->plug(pop_nav);
+ pWidgetStack->action("mkdir")->plug(pop_nav);
+ pop_nav->insertSeparator();
+ pWidgetStack->action("show hidden")->plug(pop_nav);
+ pop_nav->insertSeparator();
+ pASelectAll->plug(pop_nav);
+ pADeselectAll->plug(pop_nav);
+ pASelectGroup->plug(pop_nav);
+ pADeselectGroup->plug(pop_nav);
+ pop_nav->insertSeparator();
+ pop_nav->insertItem(i18n("Fi&lter"), actionFilterMenu);
+
+ pAGotoTray->plug(pop_view);
+ pop_view->insertSeparator();
+ pARaiseListView->plug(pop_view);
+ pARaiseIconView->plug(pop_view);
+ pARaiseDetailView->plug(pop_view);
+ pARaiseThumbView->plug(pop_view);
+ pop_view->insertSeparator();
+ pAURL->plug(pop_view);
+
+ pASlideShow->plug(pop_action);
+ pASlideShowDialog->plug(pop_action);
+ pop_action->insertSeparator();
+
+ pATCMaster->plug(pop_action);
+ pARescan->plug(pop_action);
+ pAExtTools->plug(pop_action);
+ pAFilters->plug(pop_action);
+ pAPluginsInfo->plug(pop_action);
+ pAPluginsDel->plug(pop_action);
+ pAGLInfo->plug(pop_action);
+ pop_action->insertSeparator();
+ pAConfigure->plug(pop_action);
+}
+
+// Create toolbar
+void KSquirrel::createToolbar(TDEToolBar *tools)
+{
+ pWidgetStack->action("back")->plug(tools);
+ pWidgetStack->action("forward")->plug(tools);
+ pWidgetStack->action("up")->plug(tools);
+ pWidgetStack->action("home")->plug(tools);
+ pWidgetStack->action("dirop_repeat")->plug(tools);
+
+ pASlideShow->plug(tools);
+
+ tools->insertLineSeparator();
+ pARaiseListView->plug(tools);
+ pARaiseIconView->plug(tools);
+ pARaiseDetailView->plug(tools);
+ pARaiseThumbView->plug(tools);
+ pAThumbs->plug(tools);
+
+ tools->insertLineSeparator();
+ pAGLView->plug(tools);
+ pAExtTools->plug(tools);
+ pAFilters->plug(tools);
+
+ tools->insertLineSeparator();
+ pAURL->plug(tools);
+ pAConfigure->plug(tools);
+ pAExit->plug(tools);
+
+ // insert animated widget
+ configAnime();
+}
+
+// Create all TDEActions
+void KSquirrel::createActions()
+{
+ pAThumbs = new TDEActionMenu(i18n("Thumbnail size"), "thumbnail");
+ pAExit = KStdAction::quit(this, TQ_SLOT(slotClose()), actionCollection(), "SQ close");
+ pAConfigure = KStdAction::preferences(this, TQ_SLOT(slotOptions()), actionCollection(), "SQ Configure");
+ pAGLView = new TDEAction(i18n("Image window"), "raise", CTRL+TQt::Key_I, this, TQ_SLOT(raiseGLWidget()), actionCollection(), "SQ gl view widget");
+ pARescan = KStdAction::redisplay(this, TQ_SLOT(slotRescan()), actionCollection(), "SQ rescan libraries");
+ pARescan->setText(i18n("Reload codecs from disk"));
+ pAExtTools = new TDEAction(i18n("Configure external tools..."), "launch", 0, this, TQ_SLOT(slotExtTools()), actionCollection(), "SQ external tools");
+ pAFilters = new TDEAction(i18n("Configure filters..."), "filefind", 0, this, TQ_SLOT(slotFilters()), actionCollection(), "SQ filters");
+ pAGotoTray = new TDEAction(i18n("Go to tray"), "background", CTRL+TQt::Key_T, this, TQ_SLOT(slotGotoTray()), actionCollection(), "SQ goto tray");
+ pAOpenAndSet = new TDEAction(i18n("Open file and change directory"), "document-open", CTRL+ALT+TQt::Key_O, this, TQ_SLOT(slotOpenFileAndSet()), actionCollection(), "SQ open and set");
+ pAOpen = new TDEAction(i18n("Open file"), "document-open", CTRL+TQt::Key_O, this, TQ_SLOT(slotOpenFile()), actionCollection(), "SQ open file");
+ pATCMaster = new TDEAction(i18n("Thumbnail cache manager..."), "cache", 0, this, TQ_SLOT(slotTCMaster()), actionCollection(), "SQ TC Master");
+ pASelectAll = KStdAction::selectAll(0, 0, actionCollection(), "SQ Select All");
+ pADeselectAll = KStdAction::deselect(0, 0, actionCollection(), "SQ Deselect All");
+
+ pARaiseListView = new TDERadioAction(i18n("List"), "view_multicolumn", 0, this, TQ_SLOT(slotRaiseListView()), actionCollection(), "SQ raise list view");
+ pARaiseIconView = new TDERadioAction(i18n("Icons"), "view_icon", 0, this, TQ_SLOT(slotRaiseIconView()), actionCollection(), "SQ raise icon view");
+ pARaiseDetailView = new TDERadioAction(i18n("Details"), "view_detailed", 0, this, TQ_SLOT(slotRaiseDetailView()), actionCollection(), "SQ raise detailed view");
+ pARaiseThumbView = new TDERadioAction(i18n("Thumbnails"), "view_icon", 0, this, TQ_SLOT(slotRaiseThumbView()), actionCollection(), "SQ raise thumbs view");
+
+ pAURL = new TDEToggleAction(i18n("Show URL box"), "history", CTRL+TQt::Key_U, 0, 0, actionCollection(), "SQ toggle url box");
+
+ pASlideShow = new TDEAction(i18n("Slideshow"), "folder_video", CTRL+TQt::Key_S, this, TQ_SLOT(slotSlideShowStart()), actionCollection(), "SQ Slideshow");
+ pASlideShowDialog = new TDEAction(i18n("Slideshow advanced"), 0, CTRL+ALT+TQt::Key_S, this, TQ_SLOT(slotSlideShowDialog()), actionCollection(), "SQ SlideShow Dialog");
+ pARename = new TDEAction(i18n("Rename"), "file_move", TQt::Key_F2, this, TQ_SLOT(slotRename()), actionCollection(), "SQ Rename");
+ pAPluginsInfo = new TDEAction(i18n("Codec information..."), "application-vnd.tde.info", 0, this, TQ_SLOT(slotPluginsInfo()), actionCollection(), "SQ Plugins Info");
+ pAPluginsDel = new TDEAction(i18n("Codec manager..."), 0, 0, this, TQ_SLOT(slotPluginsDel()), actionCollection(), "SQ Plugins Deleter");
+ pAGLInfo = new TDEAction(i18n("OpenGL information..."), 0, 0, this, TQ_SLOT(slotGLInfo()), actionCollection(), "SQ OpenGL Info");
+
+ pAThumb1 = new TDERadioAction(i18n("Medium thumbnails"), locate("data", "images/thumbs/thumbs_medium.png"), 0, this, TQ_SLOT(slotThumbsMedium()), actionCollection(), "SQ thumbs1");
+ pAThumb2 = new TDERadioAction(i18n("Large thumbnails"), locate("data", "images/thumbs/thumbs_large.png"), 0, this, TQ_SLOT(slotThumbsLarge()), actionCollection(), "SQ thumbs2");
+ pAThumb3 = new TDERadioAction(i18n("Huge thumbnails"), locate("data", "images/thumbs/thumbs_huge.png"), 0, this, TQ_SLOT(slotThumbsHuge()), actionCollection(), "SQ thumbs3");
+
+ pASelectGroup = new TDEAction(i18n("Select group"), "zoom-in", CTRL+TQt::Key_Plus, 0, 0, actionCollection(), "SQ Select Group");
+ pADeselectGroup = new TDEAction(i18n("Deselect group"), "zoom-out", CTRL+TQt::Key_Minus, 0, 0, actionCollection(), "SQ Deselect Group");
+
+ const TQString thumbs_size__ = TQString::fromLatin1("thumbs_size__");
+ pAThumb1->setExclusiveGroup(thumbs_size__);
+ pAThumb2->setExclusiveGroup(thumbs_size__);
+ pAThumb3->setExclusiveGroup(thumbs_size__);
+
+ switch(thumbSize->value())
+ {
+ case SQ_ThumbnailSize::Medium: pAThumb1->setChecked(true); break;
+ case SQ_ThumbnailSize::Large: pAThumb2->setChecked(true); break;
+
+ default: pAThumb3->setChecked(true);
+ }
+
+ pAThumbs->insert(pAThumb1);
+ pAThumbs->insert(pAThumb2);
+ pAThumbs->insert(pAThumb3);
+ pAThumbs->insert(new TDEActionSeparator(actionCollection()));
+
+ pAThumbsE = new TDEToggleAction(i18n("Extended thumbnails"), "", CTRL+TQt::Key_E, 0, 0, actionCollection(), "SQ Extended thumbs");
+ tdeconf->setGroup("Thumbnails");
+ pAThumbsE->setChecked(tdeconf->readBoolEntry("extended", false));
+ connect(pAThumbsE, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotExtendedToggled(bool)));
+ pAThumbs->insert(pAThumbsE);
+
+ pAThumbs->setDelayed(false);
+
+ TQString raise_some_widget_from_stack = TQString::fromLatin1("raise_some_widget_from_stack");
+ pARaiseListView->setExclusiveGroup(raise_some_widget_from_stack);
+ pARaiseIconView->setExclusiveGroup(raise_some_widget_from_stack);
+ pARaiseDetailView->setExclusiveGroup(raise_some_widget_from_stack);
+ pARaiseThumbView->setExclusiveGroup(raise_some_widget_from_stack);
+}
+
+// Goto tray
+void KSquirrel::slotGotoTray()
+{
+ // show tray icon
+ tray->show();
+
+ // hide image window
+ gl_view->hide();
+
+ m_intray = true;
+
+ // hide main window
+ hide();
+}
+
+// create external tools
+void KSquirrel::initExternalTools()
+{
+ // create SQ_ExternalTool and create new
+ // popup menu with tools
+ extool = new SQ_ExternalTool(this);
+ extool->newPopupMenu();
+}
+
+// Edit custom filters
+void KSquirrel::slotFilters()
+{
+ SQ_Filters f(this);
+
+ if(f.start() != TQDialog::Accepted) return;
+
+ // Recreate menu with filters
+ initFilterMenu();
+}
+
+// Edit external tools
+void KSquirrel::slotExtTools()
+{
+ SQ_ExternalTools etd(this, "sq_exttools", true);
+
+ // If user clicked "OK", recreate menu with
+ // tools
+ if(etd.start() == TQDialog::Accepted)
+ extool->newPopupMenu();
+}
+
+// Show image window
+void KSquirrel::raiseGLWidget()
+{
+ // if image window is separate, just show and raise it
+ gl_view->show();
+ gl_view->raise();
+ KWin::forceActiveWindow(gl_view->winId());
+
+ if(SQ_GLWidget::window()->fullscreen())
+ {
+ gl_view->statusbar()->setShown(false);
+ gl_view->boxBar()->setShown(false);
+ }
+}
+
+// Hide image window
+void KSquirrel::closeGLWidget()
+{
+ gl_view->hide();
+
+ if(m_demo)
+ {
+ finalActions();
+ tqApp->quit();
+ }
+ else
+ {
+ tdeconf->setGroup("GL view");
+
+ if(tdeconf->readBoolEntry("closeall", false))
+ SQ_GLWidget::window()->closeAllTabsFull();
+ }
+}
+
+// create bookmarks
+void KSquirrel::initBookmarks()
+{
+ // locate bookmarks file
+ TQString file = locate("data", "tdefile/bookmarks.xml");
+
+ if(file.isEmpty())
+ file = locateLocal("data", "tdefile/bookmarks.xml");
+
+ KBookmarkManager *bmanager = KBookmarkManager::managerForFile(file, false);
+ bmanager->setUpdate(true);
+ bmanager->setShowNSBookmarks(false);
+
+ SQ_BookmarkOwner *bookmarkOwner = new SQ_BookmarkOwner(this);
+
+ // setup menu
+ bookmarks = new TDEActionMenu(i18n("&Bookmarks"), "bookmark", actionCollection(), "bookmarks");
+ bookmarkMenu = new KBookmarkMenu(bmanager, bookmarkOwner, bookmarks->popupMenu(), actionCollection(), true);
+
+ connect(bookmarkOwner, TQ_SIGNAL(openURL(const KURL&)), pWidgetStack, TQ_SLOT(setURLForCurrent(const KURL&)));
+
+ bookmarkOwner->setURL(pWidgetStack->diroperator()->url());
+}
+
+// Create new config file in
+// local directory (~/.trinity/share/config)
+void KSquirrel::writeDefaultEntries()
+{
+ TDEConfig conf("ksquirrelrc");
+
+ if(!conf.hasGroup("External tools"))
+ {
+ conf.setGroup("External tools");
+ conf.writeEntry("names", "Run within KDE,View in hexadecimal mode,Print file,Set as wallpaper on desktop,Set as tiled wallpaper on desktop,Open with GIMP,Open with GQview,Open with ShowImg,Open with KuickShow,Open with KView,Open with Opera,Open with Konqueror,Open with KWrite");
+ conf.writeEntry("commands", "kfmclient exec %f,khexedit %f,kprinter %f,dcop kdesktop KBackgroundIface setWallpaper %f 6,dcop kdesktop KBackgroundIface setWallpaper %f 2,gimp %F,gqview %F,showimg %F,kuickshow %F,kview %F,opera %F,konqueror %F,kwrite %F");
+ conf.writeEntry("icons", "kfm,khexedit,tdeprintfax,mac,mac,gimp,gqview,showimg,kuickshow,kview,opera,konqueror,kwrite");
+ }
+
+ if(!conf.hasGroup("Filters"))
+ {
+ conf.setGroup("Filters");
+ conf.writeEntry("extensions", "*,*.mpg *.mpeg *.avi *.asf *.divx,*.mp3 *.ogg *.wma *.wav *.it");
+ conf.writeEntry("items", "All files,Video tapes,Audio files");
+ conf.writeEntry("last", "*");
+ conf.writeEntry("menuitem both", "false");
+ }
+
+ if(!conf.hasGroup("Navigator Icons"))
+ {
+ conf.setGroup("Navigator Icons");
+ conf.writeEntry("ShowPreviews", "false");
+ conf.writeEntry("ViewMode", "LargeRows");
+ }
+
+ if(!conf.hasGroup("Navigator List"))
+ {
+ conf.setGroup("Navigator List");
+ conf.writeEntry("ShowPreviews", "false");
+ conf.writeEntry("ViewMode", "SmallColumns");
+ }
+
+ conf.setGroup("Main");
+ conf.writeEntry("version", VERSION);
+
+ conf.sync();
+}
+
+// Apply settings
+void KSquirrel::applyDefaultSettings()
+{
+ bool updateDirs;
+
+ tdeconf->setGroup("GL view");
+
+ // set background color, zoom & move factors
+ SQ_GLWidget::window()->setClearColor();
+ SQ_GLWidget::window()->updateFactors();
+
+ // Show/hide tickmarks if needed
+ if(old_marks != tdeconf->readBoolEntry("marks", true))
+ SQ_GLWidget::window()->updateGLA();
+
+ gl_view->setupTabbar();
+
+ tdeconf->setGroup("Fileview");
+
+ // switching from 'off' to 'on' requires recalculating size
+ if(!old_calc && tdeconf->readBoolEntry("calculate", true))
+ pWidgetStack->diroperator()->calcTotalSize();
+
+ updateDirs = (old_disable != tdeconf->readBoolEntry("disable_dirs", false));
+
+ updateDirs &= (bool)pWidgetStack->diroperator()->numDirs();
+
+ tdeconf->setGroup("Thumbnails");
+ bool lazy = tdeconf->readBoolEntry("lazy", true);
+ int lazyDelay = tdeconf->readNumEntry("lazy_delay", 500);
+ int lazyRows = tdeconf->readNumEntry("rows", 2);
+
+ pWidgetStack->updateGrid(updateDirs);
+
+ // set cache limit for pixmap cache
+ SQ_PixmapCache::instance()->setCacheLimit(tdeconf->readNumEntry("cache", 1024*10));
+
+ tdeconf->setGroup("Main");
+
+ if(tdeconf->readBoolEntry("sync", false))
+ tdeconf->sync();
+
+ pWidgetStack->diroperator()->setLazy(lazy, lazyDelay, lazyRows);
+
+ // reload directory
+ if(updateDirs)
+ pWidgetStack->updateView();
+}
+
+void KSquirrel::slotExtendedToggled(bool e)
+{
+ thumbSize->setExtended(e);
+ pWidgetStack->diroperator()->slotSetThumbSize(SQ_ThumbnailSize::instance()->pixelSizeString());
+}
+
+// Toggle fullscreen state for image window
+void KSquirrel::slotFullScreen(bool full)
+{
+ WId id = gl_view->winId();
+
+ tdeconf->setGroup("GL view");
+
+ // avoid automatic image resizing
+ gl_view->statusbar()->setShown(!full);
+ gl_view->boxBar()->setShown(!full);
+
+ // goto fullscreen
+ if(full)
+ {
+ gl_view->saveGeometry();
+ KWin::setState(id, NET::FullScreen);
+ }
+ else // leave fullscreen
+ KWin::clearState(id, NET::FullScreen);
+}
+
+// Save parameters to config file
+void KSquirrel::saveValues()
+{
+ extool->writeEntries();
+
+ tdeconf->setGroup("Filters");
+ tdeconf->writeEntry("items", *sqFiltersName);
+ tdeconf->writeEntry("extensions", *sqFiltersExt);
+ tdeconf->writeEntry("last", pWidgetStack->nameFilter());
+
+ tdeconf->setGroup("Fileview");
+ pWidgetStack->saveState();
+
+ if(SQ_HLOptions::instance()->have_imagebasket)
+ if(!waitForShow)
+ SQ_ImageBasket::instance()->saveConfig();
+
+ if(tdeconf->readBoolEntry("history", true) && pCurrentURL)
+ {
+ tdeconf->setGroup("History");
+ tdeconf->writeEntry("items", pCurrentURL->historyItems());
+ }
+
+ tdeconf->setGroup("GL view");
+
+ if(!SQ_GLWidget::window()->fullscreen())
+ gl_view->saveGeometry();
+
+ tdeconf->writeEntry("ignore", dynamic_cast<TDEToggleAction *>(SQ_GLWidget::window()->actionCollection()->action("if less"))->isChecked());
+ tdeconf->writeEntry("zoom type", SQ_GLWidget::window()->zoomType());
+
+ tdeconf->setGroup("Interface");
+ tdeconf->writeEntry("last view", pWidgetStack->diroperator()->viewType());
+ if(!waitForShow) tdeconf->writeEntry("last page", sideBar->currentPage());
+ tdeconf->writeEntry("pos", pos());
+ tdeconf->writeEntry("size", size());
+ tdeconf->writeEntry("has_url", pTLocation->isShown());
+
+ // splitter sizes are saved automatically
+ // only when all sidebar pages are closed
+ if(sideBar->currentPage() != -1 && !waitForShow)
+ saveLayout();
+
+ tdeconf->setGroup("Thumbnails");
+ tdeconf->writeEntry("size", thumbSize->value());
+ tdeconf->writeEntry("extended", thumbSize->extended());
+}
+
+// Reload libraries from disk
+void KSquirrel::slotRescan()
+{
+ libhandler->reload();
+}
+
+// Create a final splash screen, if needed (if pixmap cache is not empty)
+void KSquirrel::createPostSplash()
+{
+ TQColor cc(255,255,255);
+ TQHBox *hbox = new TQHBox(0, 0, TQt::WStyle_StaysOnTop | TQt::WStyle_Customize | TQt::WStyle_NoBorder | TQt::WX11BypassWM);
+ hbox->setFrameShape(TQFrame::Box);
+
+ TQLabel *pp = new TQLabel(hbox);
+ pp->setPalette(TQPalette(cc, cc));
+ pp->setAlignment(TQt::AlignCenter);
+
+ TQPixmap todo = TQPixmap::fromMimeSource(locate("data", "images/tray.png"));
+
+ if(todo.isNull())
+ todo = SQ_IconLoader::instance()->loadIcon("ksquirrel", TDEIcon::Desktop, 16);
+
+ pp->setPixmap(todo);
+ pp->setFixedWidth(18);
+
+ TQLabel *l = new TQLabel(i18n(" writing settings and thumbnails... "), hbox);
+ l->setPalette(TQPalette(cc, cc));
+ l->setAlignment(TQt::AlignLeft | TQt::AlignVCenter);
+
+ hbox->setStretchFactor(pp, 0);
+ hbox->setStretchFactor(l, 1);
+
+ TQRect rc = TDEGlobalSettings::splashScreenDesktopGeometry();
+
+ int w = 200, h = 20;
+ hbox->setGeometry(rc.center().x() - w/2, rc.center().y() - h/2, w, h);
+
+ hbox->show();
+}
+
+void KSquirrel::slotThumbsMedium()
+{
+ emit thumbSizeChanged("medium");
+}
+
+void KSquirrel::slotThumbsLarge()
+{
+ emit thumbSizeChanged("large");
+}
+
+void KSquirrel::slotThumbsHuge()
+{
+ emit thumbSizeChanged("huge");
+}
+
+// Final actions before exiting
+void KSquirrel::finalActions()
+{
+ gl_view->hide();
+
+ // save parameters to config file
+ saveValues();
+
+ hide();
+
+ diskProg->flush();
+
+ tdeconf->setGroup("Thumbnails");
+
+ bool create_splash = !waitForShow && !tdeconf->readBoolEntry("dont write", false) && !SQ_PixmapCache::instance()->empty();
+
+ // create post splash
+ if(create_splash)
+ {
+ createPostSplash();
+ TDEApplication::eventLoop()->processEvents(TQEventLoop::ExcludeUserInput | TQEventLoop::ExcludeSocketNotifiers);
+ }
+
+ // write config file to disk (it is currently in memory cache)
+ tdeconf->sync();
+
+ // Save thumbnails from memory cache to disk
+ if(create_splash)
+ SQ_PixmapCache::instance()->sync();
+}
+
+/*
+ * Enable/disable popup menu with thumnail sizes. Called
+ * from SQ_WidgetStack, when user changed current view
+ * type (for example Thumbnail view -> Icon view).
+ */
+void KSquirrel::enableThumbsMenu(bool enable)
+{
+ pAThumbsE->setEnabled(enable); // extended thumbnails
+ pAThumbs->setEnabled(enable);
+}
+
+/*
+ * Create all needed objects
+ */
+void KSquirrel::preCreate()
+{
+ new SQ_IconLoader(this);
+ new SQ_PixmapCache(this);
+ new SQ_ArchiveHandler(this);
+ new SQ_ImageLoader(this);
+ new SQ_DragProvider(this);
+
+ libhandler = new SQ_LibraryHandler(this);
+
+ initExternalTools();
+
+ new SQ_ErrorString(this);
+ new SQ_ThumbnailsUnused(this);
+ new SQ_Converter(this);
+
+ listingDialog = new SQ_SlideShowListing(this, "SlideShow Listing", true, TQt::WStyle_Customize | TQt::WStyle_NoBorder);
+ connect(listingDialog, TQ_SIGNAL(kill()), this, TQ_SLOT(slotSlideShowListingKill()));
+
+ slideShowItems.setAutoDelete(true);
+
+ down = new SQ_Downloader(this);
+
+ connect(down, TQ_SIGNAL(result(const KURL &)), this, TQ_SLOT(slotDownloaderResult(const KURL &)));
+
+ SQ_SlideShowWidget *sls = new SQ_SlideShowWidget(0, "ksquirrel-slideshow");
+
+ connect(sls, TQ_SIGNAL(stopSlideShow()), this, TQ_SLOT(slotStopSlideShow()));
+ connect(sls, TQ_SIGNAL(pause()), this, TQ_SLOT(slotPauseSlideShow()));
+ connect(sls, TQ_SIGNAL(next()), this, TQ_SLOT(slotNextSlideShow()));
+ connect(sls, TQ_SIGNAL(previous()), this, TQ_SLOT(slotPreviousSlideShow()));
+
+ // timer for slideshow
+ slideShowTimer = new TQTimer(this);
+ timerShowListing = new TQTimer(this);
+ connect(timerShowListing, TQ_SIGNAL(timeout()), listingDialog, TQ_SLOT(show()));
+
+ SQ_SplashScreen::advance();
+
+ // create main actions
+ createActions();
+
+ SQ_SplashScreen::advance();
+
+ actionFilterMenu = new TDEPopupMenu;
+
+ actionViews = new TDEPopupMenu;
+
+ pARaiseListView->plug(actionViews);
+ pARaiseIconView->plug(actionViews);
+ pARaiseDetailView->plug(actionViews);
+ pARaiseThumbView->plug(actionViews);
+
+ SQ_SplashScreen::advance();
+
+ // if -l option specified, exit
+ if(SQ_HLOptions::instance()->showLibsAndExit)
+ exit(0);
+
+ if(!SQ_HLOptions::instance()->param.isEmpty())
+ {
+ // at first try to stat as local url
+ KURL url;
+
+ if(TQDir::isRelativePath(SQ_HLOptions::instance()->param))
+ {
+ url = KURL::fromPathOrURL(TQDir::currentDirPath());
+ url.addPath(SQ_HLOptions::instance()->param);
+ }
+ else
+ url.setPath(SQ_HLOptions::instance()->param);
+
+ statStage = false;
+ TDEIO::StatJob *job = TDEIO::stat(url, false);
+ job->setSide(true);
+ job->setDetails(0);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotStatResult(TDEIO::Job *)));
+ }
+ else
+ continueLoading();
+}
+
+void KSquirrel::slotStatResult(TDEIO::Job *_job)
+{
+ if(_job)
+ {
+ TDEIO::StatJob *job = static_cast<TDEIO::StatJob *>(_job);
+
+ if(job->error())
+ {
+ // both local and remote urls are failed
+ if(statStage)
+ {
+ job->showErrorDialog(this);
+ continueLoading();
+ return;
+ }
+ }
+
+ // found local/remote URL
+ TDEIO::UDSEntry udsEntry = job->statResult();
+ TDEIO::UDSEntry::ConstIterator itEnd = udsEntry.end();
+
+ for(TDEIO::UDSEntry::ConstIterator it = udsEntry.begin(); it != itEnd;++it)
+ {
+ // we need just file type...
+ if((*it).m_uds == TDEIO::UDS_FILE_TYPE)
+ {
+ if(S_ISDIR((mode_t)((*it).m_long)))
+ {
+ SQ_HLOptions::instance()->dir = job->url();
+ }
+ else
+ {
+ SQ_HLOptions::instance()->file = job->url();
+ SQ_HLOptions::instance()->dir = job->url();
+ SQ_HLOptions::instance()->dir.cd("..");
+ }
+
+ m_demo = !SQ_HLOptions::instance()->file.isEmpty();
+
+ // Ok, it's existing URL
+ continueLoading();
+ return;
+ }
+ }
+
+ // this should not occur, but for safety reasons...
+ if(statStage)
+ {
+ continueLoading();
+ return;
+ }
+
+ // local url is not found. construct remote url and stat() it again
+ KURL url = KURL::fromPathOrURL(SQ_HLOptions::instance()->param);
+ statStage = true;
+ TDEIO::StatJob *job2 = TDEIO::stat(url, false);
+ job2->setSide(true);
+ job2->setDetails(0);
+ connect(job2, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotStatResult(TDEIO::Job *)));
+ }
+ else
+ continueLoading();
+}
+
+void KSquirrel::resizeEvent(TQResizeEvent *e)
+{
+ if(mainPage)
+ mainPage->resize(e->size());
+}
+
+void KSquirrel::continueLoading()
+{
+ tdeconf->setGroup("Interface");
+ int createFirst = tdeconf->readNumEntry("last view", 0);
+
+ // create toolbar, menubar, tree, filemanager ...
+ createWidgets(createFirst);
+
+ // set position & size
+ handlePositionSize();
+
+ if(m_demo)
+ raiseGLWidget();
+
+ // don't show navigator when running with file argument
+ if(!m_demo && !tdeApp->isRestored())
+ show();
+
+ // in demo mode may be invisible
+ if(mainPage->isVisible())
+ {
+ TQEvent e(TQEvent::Show);
+ eventFilter(mainPage, &e);
+ }
+
+ tray = new KSystemTray(this);
+ tray->setPixmap(TQPixmap(locate("data", "images/tray.png")));
+
+ connect(tray, TQ_SIGNAL(quitSelected()), this, TQ_SLOT(slotTrayQuit()));
+
+ SQ_SplashScreen::advance();
+ SQ_SplashScreen::finish();
+
+ // Check if we need to load a file at startup
+ // (if one was specified in command line)
+ if(!SQ_HLOptions::instance()->file.isEmpty())
+ {
+ raiseGLWidget();
+
+ if(libhandler->maybeSupported(SQ_HLOptions::instance()->file) != SQ_LibraryHandler::No)
+ {
+ pWidgetStack->diroperator()->setPendingFile(SQ_HLOptions::instance()->file.fileName(false));
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, SQ_HLOptions::instance()->file);
+ pWidgetStack->diroperator()->execute(&fi);
+ }
+ }
+
+ pWidgetStack->diroperator()->setFocus();
+
+ // show tray icon when restored
+ if(tdeApp->isRestored())
+ slotGotoTray();
+
+ connect(tdeApp, TQ_SIGNAL(saveYourself()), this, TQ_SLOT(slotSaveYourself()));
+}
+
+// Set caption to main window or to image window
+void KSquirrel::setCaption(const TQString &cap)
+{
+#if 0
+ TDEMainWindow::setCaption(cap);
+#endif
+
+ gl_view->setCaption(cap.isEmpty() ? "ksquirrel" : tdeApp->makeStdCaption(cap));
+}
+
+// User selected "Open file" or "Open file #2" from menu.
+// Let's load file and set new URL for filemanager (if parseURL == true)
+void KSquirrel::openFile(bool parseURL)
+{
+ KURL url = KFileDialog::getOpenURL();
+
+ if(url.isEmpty())
+ return;
+
+ // if it is known file type
+ if(libhandler->maybeSupported(url) != SQ_LibraryHandler::No)
+ {
+ if(parseURL)
+ {
+ KURL d = url;
+ d.cd("..");
+ pWidgetStack->diroperator()->setPendingFile(url.fileName());
+ pWidgetStack->setURLForCurrent(d);
+ }
+
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, url);
+ pWidgetStack->diroperator()->execute(&fi);
+ }
+ else
+ {
+ tdeconf->setGroup("Fileview");
+
+ if(tdeconf->readBoolEntry("run unknown", false))
+ new KRun(url);
+ }
+}
+
+// "Open file" in menu
+void KSquirrel::slotOpenFile()
+{
+ openFile();
+}
+
+// "Open file #2" in menu
+void KSquirrel::slotOpenFileAndSet()
+{
+ openFile(true);
+}
+
+// User clicked animated widget in toolbar,
+// let's goto KSquirrel's homepage
+void KSquirrel::slotAnimatedClicked()
+{
+ // invoke default browser
+ tdeApp->invokeBrowser(TQString::fromLatin1("http://ksquirrel.sourceforge.net/"));
+}
+
+// Create SQ_ThumbnailCacheMaster, which can do something with thumbnails
+// and thumbnail cache
+void KSquirrel::slotTCMaster()
+{
+ SQ_ThumbnailCacheMaster m(this);
+
+ m.exec();
+}
+
+// Return a pointer to widget in statusbar by name
+TQLabel* KSquirrel::sbarWidget(const TQString &name)
+{
+ return sbarwidgets[name];
+}
+
+// Convert TQByteArray to TQString
+TQString KSquirrel::getArg(const TQByteArray &data)
+{
+ TQDataStream args(data, IO_ReadOnly);
+
+ TQString arg;
+
+ args >> arg;
+
+ return arg;
+}
+
+// Process incoming DCOP messages
+bool KSquirrel::process(const TQCString &fun, const TQByteArray &data, TQCString& replyType, TQByteArray &replyData)
+{
+ if(fun == "control(TQString)")
+ {
+ // Yes, user wants to call our "control" method
+ control(getArg(data));
+
+ replyType = "void";
+
+ return true;
+ }
+ else if(fun == "navigator(TQString)")
+ {
+ navigatorSend(getArg(data));
+
+ replyType = "void";
+
+ return true;
+ }
+ else if(fun == "activate()")
+ {
+ activate();
+
+ replyType = "void";
+
+ return true;
+ }
+ else if(fun == "activate_image_window()")
+ {
+ raiseGLWidget();
+
+ replyType = "void";
+
+ return true;
+ }
+ else if(fun == "reload_codecs()")
+ {
+ slotRescan();
+
+ replyType = "void";
+
+ return true;
+ }
+ // load specified image
+ else if(fun == "load(TQString)")
+ {
+ TQString arg = getArg(data);
+
+ KURL url = KURL::fromPathOrURL(arg);
+
+ TDEIO::StatJob *job = TDEIO::stat(url, false);
+ job->setSide(true);
+ job->setDetails(0);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotDCOPStatResult(TDEIO::Job *)));
+
+ replyType = "void";
+
+ return true;
+ }
+
+ // we have to call it
+ return DCOPObject::process(fun, data, replyType, replyData);
+}
+
+void KSquirrel::slotDCOPStatResult(TDEIO::Job *_job)
+{
+ if(_job)
+ {
+ TDEIO::StatJob *job = static_cast<TDEIO::StatJob *>(_job);
+
+ if(job->error())
+ {
+ job->showErrorDialog(this);
+ return;
+ }
+
+ KURL url = job->url();
+ bool isdir = false, setc = true;
+ KURL dir = url;
+
+ TDEIO::UDSEntry udsEntry = job->statResult();
+ TDEIO::UDSEntry::ConstIterator itEnd = udsEntry.end();
+
+ for(TDEIO::UDSEntry::ConstIterator it = udsEntry.begin(); it != itEnd;++it)
+ {
+ // we need just file type...
+ if((*it).m_uds == TDEIO::UDS_FILE_TYPE)
+ {
+ isdir = S_ISDIR((mode_t)((*it).m_long));
+ break;
+ }
+ }
+
+ if(!isdir) dir.cd("..");
+
+ if(!pWidgetStack->diroperator()->url().equals(dir, true))
+ {
+ // don't set current item
+ setc = false;
+ pWidgetStack->diroperator()->setPendingFile(url.fileName(false));
+ pWidgetStack->diroperator()->setURL(dir, true);
+ }
+
+ // activate this window
+ if(isdir)
+ activate();
+ else
+ {
+ raiseGLWidget();
+
+ if(setc)
+ {
+ KFileView *v = pWidgetStack->diroperator()->view();
+
+ if(v)
+ {
+ v->clearSelection();
+ v->setCurrentItem(url.fileName(false));
+ pWidgetStack->diroperator()->setCurrentItem(v->currentFileItem());
+ }
+ }
+
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, url);
+
+ if(libhandler->maybeSupported(fi.url()) != SQ_LibraryHandler::No)
+ {
+ // stop slideshow if running
+ slotStopSlideShow();
+
+ // load
+ pWidgetStack->diroperator()->execute(&fi);
+ }
+ }
+ }
+}
+
+// Returnes all available DCOP methods.
+// Used by DCOP infrastructure
+QCStringList KSquirrel::functions()
+{
+ QCStringList result = DCOPObject::functions();
+
+ result << "void control(TQString)";
+ result << "void navigator(TQString)";
+ result << "void load(TQString)";
+ result << "void activate()";
+ result << "void activate_image_window()";
+ result << "void reload_codecs()";
+
+ return result;
+}
+
+// Activate this instance
+void KSquirrel::activate()
+{
+ m_demo = false;
+
+ // just in case
+ show();
+
+ // force activation
+ KWin::forceActiveWindow(winId());
+}
+
+void KSquirrel::printDCOP()
+{
+ navigatorSend("duuummmmyyyyy");
+ control("duuummmmyyyyy");
+
+ std::cerr << "Other:" << std::endl;
+ std::cerr << "*****************************" << std::endl;
+ std::cerr << "activate" << std::endl;
+ std::cerr << "activate_image_window" << std::endl;
+ std::cerr << "load <file or directory>" << std::endl;
+ std::cerr << "******************************" << std::endl;
+}
+
+void KSquirrel::navigatorSend(const TQString &command)
+{
+ if(command == "next")
+ pWidgetStack->moveTo(SQ_WidgetStack::Next, 0, false);
+ else if(command == "previous")
+ pWidgetStack->moveTo(SQ_WidgetStack::Previous, 0, false);
+ else if(command == "execute")
+ {
+ KFileItem *fi = pWidgetStack->diroperator()->view()->currentFileItem();
+
+ if(fi)
+ {
+ if(fi->isFile())
+ pWidgetStack->diroperator()->execute(fi);
+ else
+ pWidgetStack->diroperator()->setURL(fi->url(), true);
+ }
+ }
+ else // unknown parameter !
+ {
+ std::cerr << "List of available DCOP parameters for navigator() method:" << std::endl;
+ std::cerr << "*****************************" << std::endl;
+ std::cerr << "next" << std::endl;
+ std::cerr << "previous" << std::endl;
+ std::cerr << "execute" << std::endl;
+ std::cerr << "******************************" << std::endl;
+ }
+}
+
+// User sent us some message through DCOP, let's determine
+// what he wants to do.
+//
+// The main idea is that SQ_GLWidget already has all needed actions,
+// located in keyPressEvent() handler. Let's construct TQKeyEvent and send
+// it to SQ_GLWidget - SQ_GLWidget will catch this event and will do what
+// user wants.
+//
+void KSquirrel::control(const TQString &command)
+{
+ TQMap<TQString, int>::iterator it = messages.find(command);
+
+ // known action
+ if(it != messages.end())
+ {
+ int id = it.data();
+
+ TDEAction *a = SQ_GLWidget::window()->actionCollection()->action(TQString::fromLatin1("action_%1").arg(id));
+
+ if(a) a->activate();
+ }
+ else // unknown parameter !
+ {
+ std::cerr << "List of available DCOP parameters for control() method:" << std::endl;
+ std::cerr << "*****************************" << std::endl;
+
+ for(TQMap<TQString, int>::iterator it = messages.begin();it != messages.end();++it)
+ {
+ std::cerr << it.key() << std::endl;
+ }
+
+ std::cerr << "******************************" << std::endl;
+ }
+}
+
+void KSquirrel::fillMessages()
+{
+ messages.insert("image_next", TQt::Key_PageDown);
+ messages.insert("image_previous", TQt::Key_PageUp);
+ messages.insert("image_first", TQt::Key_Home);
+ messages.insert("image_last", TQt::Key_End);
+ messages.insert("image_reset", TQt::Key_R);
+ messages.insert("image_information", TQt::Key_I);
+ messages.insert("image_delete", TQt::Key_Delete);
+
+ messages.insert("image_animation_toggle", TQt::Key_A);
+
+ messages.insert("image_page_first", TQt::Key_F1);
+ messages.insert("image_page_last", TQt::Key_F4);
+ messages.insert("image_page_next", TQt::Key_F3);
+ messages.insert("image_page_previous", TQt::Key_F2);
+
+ messages.insert("image_window_fullscreen", TQt::Key_F);
+ messages.insert("image_window_quickbrowser", TQt::Key_Q);
+ messages.insert("image_window_close", TQt::Key_X);
+ messages.insert("image_window_help", TQt::Key_Slash);
+
+ messages.insert("zoom_plus", TQt::Key_Plus);
+ messages.insert("zoom_minus", TQt::Key_Minus);
+ messages.insert("zoom_1", TQt::Key_1);
+ messages.insert("zoom_2", TQt::Key_2);
+ messages.insert("zoom_3", TQt::Key_3);
+ messages.insert("zoom_4", TQt::Key_4);
+ messages.insert("zoom_5", TQt::Key_5);
+ messages.insert("zoom_6", TQt::Key_6);
+ messages.insert("zoom_7", TQt::Key_7);
+ messages.insert("zoom_8", TQt::Key_8);
+ messages.insert("zoom_9", TQt::Key_9);
+ messages.insert("zoom_10", TQt::Key_0);
+}
+
+// Start/stop slideshow
+void KSquirrel::slotSlideShowStart()
+{
+ if(slideShowDir.isEmpty())
+ slideShowDir = SQ_WidgetStack::instance()->url().prettyURL();
+
+ tdeconf->setGroup("Slideshow");
+
+ // recursion ?
+ bool recurs = tdeconf->readBoolEntry("recurs", false);
+
+ listing = recurs ? TDEIO::listRecursive(slideShowDir, false, false)
+ : TDEIO::listDir(slideShowDir, false, false);
+
+ connect(listing, TQ_SIGNAL(entries(TDEIO::Job *, const TDEIO::UDSEntryList &)),
+ this, TQ_SLOT(slotSlideShowEntries(TDEIO::Job *, const TDEIO::UDSEntryList &)));
+
+ connect(listing, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotSlideShowJobResult(TDEIO::Job *)));
+
+ timerShowListing->start(1000, true);
+}
+
+void KSquirrel::slotSlideShowListingKill()
+{
+ if(listing) listing->kill();
+
+ slideShowItems.clear();
+ listingDialog->setFile(0, TQString());
+ listingDialog->hide();
+}
+
+void KSquirrel::slotSlideShowEntries(TDEIO::Job *, const TDEIO::UDSEntryList &list)
+{
+ TDEIO::UDSEntryListConstIterator itEnd = list.end();
+
+ KURL url = KURL::fromPathOrURL(slideShowDir);
+ TQString sfile;
+
+ // go through list of TDEIO::UDSEntrys
+ for(TDEIO::UDSEntryListConstIterator it = list.begin(); it != itEnd; ++it)
+ {
+ KFileItem *file = new KFileItem(*it, url, true, true);
+
+ if(file && file->isFile())
+ {
+ slideShowItems.append(file);
+
+ if(sfile.isEmpty()) sfile = file->name();
+ }
+ else
+ delete file;
+ }
+
+ if(!sfile.isEmpty())
+ listingDialog->setFile(slideShowItems.count(), sfile);
+}
+
+void KSquirrel::slotSlideShowJobResult(TDEIO::Job *job)
+{
+ listingDialog->setFile(0, TQString());
+ listingDialog->hide();
+ timerShowListing->stop();
+
+ if(!job->error())
+ slideShowPrivate();
+
+ listing = 0;
+}
+
+// Invoke dialog for advanced slideshow
+void KSquirrel::slotSlideShowDialog()
+{
+ SQ_SlideShow s(this);
+
+ if(s.exec(slideShowDir) == TQDialog::Accepted)
+ slotSlideShowStart();
+}
+
+// Start new slidehsow!
+void KSquirrel::slideShowPrivate()
+{
+ // stop timer, if active
+ slideShowTimer->stop();
+ slideShowStop = false;
+ slideShowInit = true;
+ slideShowDirection = KSquirrel::Default;
+
+ disconnect(slideShowTimer, TQ_SIGNAL(timeout()), 0, 0);
+ connect(slideShowTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotSlideShowNextImage()));
+
+ tdeconf->setGroup("Slideshow");
+
+ // determine delay
+ slideShowDelay = tdeconf->readNumEntry("delay", 1000);
+ slideShowRepeat = tdeconf->readNumEntry("repeat", 0);
+
+ if(slideShowDelay < 0) slideShowDelay = 1000;
+ if(slideShowRepeat < 0) slideShowRepeat = 0;
+ if(slideShowRepeat > 1000) slideShowRepeat = 1000;
+
+ slideShowTotal = slideShowItems.count();
+
+ // No files to show ?
+ if(!slideShowTotal)
+ {
+ slotStopSlideShow();
+ return;
+ }
+
+ // initial setup
+ slideShowIndex = -1;
+
+ // start!
+ SQ_SlideShowWidget::instance()->beginSlideShow(slideShowTotal);
+
+ TQTimer::singleShot(1, this, TQ_SLOT(slideShowDetermine()));
+}
+
+void KSquirrel::slotDownloaderResult(const KURL &u)
+{
+ if(u.isEmpty()) // error occured
+ slideShowDetermine();
+ else
+ {
+ KURL u2 = u;
+ slideShowName = u2;
+ int delay = slideShowInit ? 0 : slideShowDelay;
+
+ if(libhandler->libraryForFile(slideShowName.path()))
+ {
+ slideShowInit = false;
+ slideShowTimer->start(delay, true);
+ }
+ else
+ slideShowDetermine();
+ }
+}
+
+void KSquirrel::slideShowDetermine()
+{
+ do
+ {
+ // goto next file
+ if(slideShowDirection == KSquirrel::Default)
+ {
+ slideShowIndex++;
+
+ // all files loaded ?
+ if(slideShowIndex == slideShowTotal)
+ {
+ // slideshow done
+ if(!slideShowRepeat)
+ {
+ // nice hack to make final delay
+ disconnect(slideShowTimer, TQ_SIGNAL(timeout()), 0, 0);
+ connect(slideShowTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotStopSlideShow()));
+ slideShowTimer->start(slideShowDelay, true);
+ return;
+ }
+ // we should repeat slideshow
+ else
+ {
+ slideShowRepeat--;
+ slideShowIndex = 0;
+ }
+ }
+ }
+ else // KSquirrel::MBack
+ {
+ slideShowIndex--;
+
+ if(slideShowIndex < 0)
+ {
+ slideShowDirection = KSquirrel::Default;
+ slideShowIndex = -1;
+ continue;
+ }
+ }
+
+ // construct new file name
+ slideShowFile = slideShowItems.at(slideShowIndex);
+ slideShowName = slideShowFile->url();
+ }
+ while(libhandler->maybeSupported(slideShowName) == SQ_LibraryHandler::No);
+
+ slideShowDirection = KSquirrel::Default;
+
+ if(slideShowName.isLocalFile())
+ slotDownloaderResult(slideShowName);
+ else
+ down->start(slideShowFile);
+}
+
+// Load the next image
+void KSquirrel::slotSlideShowNextImage()
+{
+ // stopped ?
+ if(slideShowStop)
+ return;
+
+ SQ_SlideShowWidget::instance()->loadImage(slideShowName.path(), slideShowIndex);
+
+ slideShowDetermine();
+}
+
+void KSquirrel::slotNextSlideShow()
+{
+ slideShowTimer->stop();
+ slideShowTimer->start(0, true);
+}
+
+void KSquirrel::slotPreviousSlideShow()
+{
+ slideShowTimer->stop();
+ slideShowDirection = KSquirrel::MBack;
+ int ssi = slideShowIndex;
+ KURL ssn;
+
+ do
+ {
+ // goto next file
+ ssi--;
+
+ if(ssi < 0)
+ {
+ slideShowDirection = KSquirrel::Default;
+ slideShowTimer->start(0, true);
+ return;
+ }
+
+ // construct new file name
+ ssn = slideShowItems.at(ssi)->url();
+ }
+ while(libhandler->maybeSupported(ssn) == SQ_LibraryHandler::No);
+
+ slideShowIndex = ssi;
+ slideShowName = ssn;
+
+ slideShowInit = true;
+ slideShowDetermine();
+}
+
+// Stop slideshow, if running
+void KSquirrel::slotStopSlideShow()
+{
+ if(!slideShowRunning())
+ return;
+
+ // reset values
+ slideShowStop = true;
+ slideShowTimer->stop();
+ slideShowDir = TQString();
+ slideShowPaused = false;
+ slideShowItems.clear();
+ slideShowDirection = KSquirrel::Default;
+
+ tdeconf->setGroup("Slideshow");
+
+ SQ_SlideShowWidget::instance()->endSlideShow();
+}
+
+// Show information on libraries
+void KSquirrel::slotPluginsInfo()
+{
+ SQ_PluginsInfo pi(this);
+
+ pi.exec();
+}
+
+void KSquirrel::slotPluginsDel()
+{
+ KShellProcess proc;
+
+ proc << "ksquirrel-libs-configurator";
+
+ proc.start(TDEProcess::DontCare);
+}
+
+void KSquirrel::slotPauseSlideShow()
+{
+ if(!slideShowRunning())
+ return;
+
+ if(slideShowPaused)
+ {
+ slideShowTimer->start(slideShowDelay, true);
+ slideShowPaused = false;
+ }
+ else
+ {
+ slideShowTimer->stop();
+ slideShowPaused = true;
+ }
+}
+
+// show imformation on OpenGL
+void KSquirrel::slotGLInfo()
+{
+ SQ_GLInfo gi(this);
+
+ gi.exec();
+}
+
+void KSquirrel::saveLayout()
+{
+ if(!waitForShow)
+ {
+ tdeconf->setGroup("Interface");
+ tdeconf->writeEntry("splitter", mainView->sizes());
+ }
+}
+
+void KSquirrel::configAnime(bool init)
+{
+ KAnimWidget *anim = tools->animatedWidget(1000); // get animated widget, if exist
+
+ tdeconf->setGroup("Main");
+
+ // show animated logo in toolbar if needed
+ if(!tdeconf->readBoolEntry("anime_dont", false) && (init || (!init && !anim)))
+ {
+ tools->insertAnimatedWidget(1000, this, TQ_SLOT(slotAnimatedClicked()), locate("data", "images/anime.png"));
+ tools->alignItemRight(1000);
+ tools->animatedWidget(1000)->start();
+ }
+ else if(!init && tdeconf->readBoolEntry("anime_dont", false) && anim)
+ delete anim;
+}
+
+void KSquirrel::slotTrayQuit()
+{
+ m_demo = true;
+ m_intray = false;
+}
+
+void KSquirrel::slotClose()
+{
+ m_demo = true;
+ m_intray = false;
+
+ close();
+}
+
+void KSquirrel::slotRename()
+{
+ bool ok;
+
+ KFileItemList *items = const_cast<KFileItemList *>(pWidgetStack->diroperator()->view()->selectedItems());
+
+ if(!items || !items->count())
+ return;
+
+ renameSrcURL = items->first()->url();
+
+ TQString filename = TQStyleSheet::escape(renameSrcURL.filename());
+
+ TQString mNewFilename = KInputDialog::getText(i18n("Renaming File"),
+ i18n("<p>Rename file <b>%1</b> to:</p>").arg(filename),
+ renameSrcURL.filename(), &ok, this);
+
+ if(!ok) return;
+
+ renameDestURL = renameSrcURL;
+ renameDestURL.setFileName(mNewFilename);
+
+ TDEIO::Job *job = TDEIO::move(renameSrcURL, renameDestURL);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job*)), this, TQ_SLOT(slotRenameResult(TDEIO::Job*)));
+}
+
+void KSquirrel::slotRenameResult(TDEIO::Job *job)
+{
+ if(job->error())
+ {
+ job->showErrorDialog(this);
+ return;
+ }
+
+ SQ_PixmapCache::instance()->removeEntryFull(renameSrcURL);
+}
+
+void KSquirrel::slotRepeat()
+{
+ pWidgetStack->repeat();
+}
+
+void KSquirrel::slotSaveYourself()
+{
+ finalActions();
+}
+
+void KSquirrel::slotPreviewWidgetNext()
+{
+ pWidgetStack->moveTo(SQ_WidgetStack::Next);
+}
+
+void KSquirrel::slotPreviewWidgetPrevious()
+{
+ pWidgetStack->moveTo(SQ_WidgetStack::Previous);
+}
+
+void KSquirrel::slotPreviewWidgetExecute()
+{
+ KURL u = SQ_PreviewWidget::instance()->url();
+
+ if(!u.isEmpty())
+ {
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, u);
+ pWidgetStack->diroperator()->execute(&fi);
+ }
+}
+
+#include "ksquirrel.moc"
diff --git a/src/ksquirrel.desktop b/src/ksquirrel.desktop
new file mode 100644
index 0000000..43b75ee
--- /dev/null
+++ b/src/ksquirrel.desktop
@@ -0,0 +1,17 @@
+[Desktop Entry]
+Type=Application
+Exec=ksquirrel %i %u
+Icon=ksquirrel
+X-DocPath=ksquirrel/index.html
+Terminal=false
+Name=KSquirrel
+MimeType=image/x-vnd.adobe.photoshop;image/x-hdr;image/x-exr;image/x-eps;image/x-psp;image/x-dds;image/x-mdl;image/ljpeg;image/x-dicom;image/x-xfig;image/svg+xml;image/gif;image/x-xpm;image/x-xbm;image/jpeg;image/x-bmp;image/png;image/tiff;image/x-portable-bitmap;image/x-portable-pixmap;image/x-portable-anymap;image/x-portable-greymap;image/jp2;image/x-jng;image/x-wmf;video/x-mng;video/x-flic;image/x-targa;image/x-pcx;image/x-photo-cd;image/x-rgb;image/x-xcursor;image/x-ico;image/psd;image/x-djvu;image/x-xcf-gimp;image/x-avs;image/x-cut;image/x-dxf;image/x-iff;image/x-jbig;image/x-koala;image/x-leaf;image/x-lif;image/x-mac;image/x-msp;image/x-mtv;image/x-neo;image/x-pi1;image/x-pi3;image/x-pict;image/x-pix;image/x-pxr;image/x-ras;image/x-raw;image/x-rawrgb;image/x-sct;image/x-sun;image/x-utah;image/x-wal;image/x-wbmp;image/x-xim;image/x-xwd;application/x-font-ttf;application/x-font-ttc;application/x-font-otf;application/x-font-type1
+Categories=Qt;TDE;Application;Graphics;Viewer;
+
+Comment=Image Viewer
+Comment[ru]=Просмотр изображений
+Comment[de]=Bildbetrachter
+
+GenericName=Image Viewer
+GenericName[ru]=Просмотр изображений
+GenericName[de]=Bildbetrachter
diff --git a/src/ksquirrel.h b/src/ksquirrel.h
new file mode 100644
index 0000000..5a4a3ed
--- /dev/null
+++ b/src/ksquirrel.h
@@ -0,0 +1,801 @@
+/***************************************************************************
+ ksquirrel.h - description
+ -------------------
+ begin : Dec 10 2003
+ copyright : (C) 2003 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KSQUIRREL_H
+#define KSQUIRREL_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <tqstringlist.h>
+#include <tqmap.h>
+
+#include <tdemainwindow.h>
+#include <dcopobject.h>
+#include <tdefileitem.h>
+#include <kurl.h>
+
+// forward declarations
+
+template <class T> class TQValueVector;
+class TQLabel;
+class TQWidgetStack;
+class TQHBox;
+class TQVBox;
+class TQTimer;
+class TQSplitter;
+
+namespace TDEIO { class Job; }
+
+class KMenuBar;
+class TDEToolBar;
+class KStatusBar;
+class KSystemTray;
+class TDEAction;
+class TDERadioAction;
+class TDEActionMenu;
+class KHistoryCombo;
+class TDEToggleAction;
+class KBookmarkMenu;
+
+class SQ_SplashScreen;
+class SQ_WidgetStack;
+class SQ_LibraryHandler;
+class SQ_Config;
+class SQ_ExternalTool;
+class SQ_TreeView;
+class SQ_ThumbnailSize;
+class SQ_PixmapCache;
+class SQ_GLView;
+class SQ_GLWidget;
+class SQ_ArchiveHandler;
+class SQ_MultiBar;
+class SQ_KIPIManager;
+class SQ_Progress;
+class SQ_Dir;
+class SQ_Downloader;
+class SQ_SlideShowListing;
+
+/*
+ * Main widget, which can accept DCOP messages
+ */
+
+class KSquirrel : public TDEMainWindow, public DCOPObject
+{
+ TQ_OBJECT
+
+
+ public:
+ /*
+ * Constructor & destructor
+ */
+ KSquirrel(TQWidget *parent, const char *name);
+ ~KSquirrel();
+
+ SQ_Progress* diskProgress();
+
+ void printDCOP();
+
+ /*
+ * "history combo"
+ */
+ KHistoryCombo* historyCombo();
+
+ bool demo() const;
+
+ /*
+ * Activate main window.
+ */
+ void activate();
+
+ /*
+ * Close (hide) SQ_GLWidget.
+ */
+ void closeGLWidget();
+
+ /*
+ * Do some actions before exit - show final splash (if needed),
+ * save parameters to config file,
+ * write config file to disk, write cached thumbnails, etc.
+ */
+ void finalActions();
+
+ /*
+ * Enable/disable popup menu with thumnail sizes. Called
+ * from SQ_WidgetStack, when user changed current view
+ * type (for example Thumbnail view -> Icon view).
+ */
+ void enableThumbsMenu(bool);
+
+ /*
+ * Set caption. When SQ_GLView is separated, the caption
+ * will be set to it, and to KSquirrel's main window
+ * otherwise. Called from SQ_GLWidget.
+ */
+ void setCaption(const TQString &cap);
+
+ void saveLayout();
+
+ /*
+ * Check if slideshow is running.
+ */
+ bool slideShowRunning() const;
+
+ /*
+ * Return popup menu with filters for filemanager.
+ */
+ TDEPopupMenu* menuFilters();
+
+ /*
+ * Return popup menu with view types -
+ * Icon view, Detail view ...
+ */
+ TDEPopupMenu* menuViews();
+
+ /*
+ * Get pointer to a widget, located in status bar.
+ * All pointers to statusbar widgets are saved in
+ * 'sbarwidgets' object (TQMap).
+ */
+ TQLabel* sbarWidget(const TQString &name);
+
+ /*
+ * DCOP methods
+ */
+
+ /*
+ * Return a list of available functions
+ */
+ QCStringList functions();
+
+ /*
+ * Process incoming DCOP message
+ */
+ bool process(const TQCString &fun, const TQByteArray &data, TQCString& replyType, TQByteArray &replyData);
+
+ bool separateImageWindow() const;
+
+ /*
+ * Names and extensions of name filters for
+ * file manager.
+ */
+ TQStringList* filtersNames() const;
+ TQStringList* filtersExtensions() const;
+
+ static KSquirrel* app() { return m_instance; }
+
+ protected:
+ /*
+ * Catch some events and do specific actions.
+ */
+ virtual bool eventFilter(TQObject *o, TQEvent *e);
+ virtual void closeEvent(TQCloseEvent *e);
+ virtual void resizeEvent(TQResizeEvent *e);
+
+ /*
+ * Internal methods
+ */
+ private:
+
+ // create or delete animated logo
+ void configAnime(bool init = true);
+
+ void continueLoading();
+
+ /*
+ * Create a final splash. It will be shown only if SQ_PixmapCache
+ * is not empty.
+ */
+ void createPostSplash();
+
+ /*
+ * Create location toolbar and store a pointer to
+ * it in passed argument.
+ */
+ void createLocationToolbar(TDEToolBar *);
+
+ /*
+ * Create statusbar.
+ */
+ void createStatusBar(KStatusBar*);
+
+ /*
+ * Create main toolbar.
+ */
+ void createToolbar(TDEToolBar *);
+
+ /*
+ * Create main menu.
+ */
+ void createMenu(KMenuBar *);
+
+ /*
+ * Create all TDEActions
+ */
+ void createActions();
+
+ /*
+ * Create all needed objects
+ */
+ void preCreate();
+
+ /*
+ * Create TQStrinLists, containing filters and filters' names (if needed)
+ * and fill popup menu with new filters.
+ */
+ void initFilterMenu();
+
+ /*
+ * Do the same for external tools.
+ */
+ void initExternalTools();
+
+ /*
+ * Init bookmarks and create popup menu for them.
+ */
+ void initBookmarks();
+
+ /*
+ * Create all widgets (filemanager, file tree, toolbar, etc.)
+ */
+ void createWidgets(int);
+
+ /*
+ * Restore saved position & size
+ */
+ void handlePositionSize();
+
+ /*
+ * If user-depended config file doesn't exist (~/.trinity/share/config/ksquirrelrc),
+ * create it and write default entries. Called before SQ_Config object is being
+ * created
+ */
+ void writeDefaultEntries();
+
+ /*
+ * Fill all parameters with its default values (form config
+ * file). Affects to clicking policy in SQ_WidgetStack,
+ * cache limit in SQ_PixmapCache etc.
+ */
+ void applyDefaultSettings();
+
+ /*
+ * Save all parameters to config file before exit.
+ */
+ void saveValues();
+
+ /*
+ * Open image and/or change current directory
+ * to its URL. Called when user clicks "Open file" and
+ * "Open file #2" in main menu.
+ */
+ void openFile(bool parseURL = false);
+
+ /*
+ * Run slideshow
+ */
+ void slideShowPrivate();
+
+ /*
+ * Set filter for a filemanager to 'f' and check
+ * appropriate menu item
+ */
+ void setFilter(const TQString &f, const int id);
+
+ /*
+ * Fill 'messages' map with values. 'messages' map is used
+ * to determine which key sequence should KSquirrel pass to SQ_GLWidget
+ * to perform an action, needed by DCOP client.
+ */
+ void fillMessages();
+
+ /*
+ * DCOP helper methods
+ */
+
+ /*
+ * Determine the incoming DCOP message, create appropriate
+ * key sequence and send this sequence to SQ_GLWidget.
+ *
+ * The main idea is that KSquirrel will find needed key sequence
+ * by its name (in 'messages' map), costruct TQKeyEvent and send to
+ * SQ_GLWidget. SQ_GLWidget already has keyEvent() handler, so it will
+ * do what DCOP client wants.
+ *
+ * For example,
+ *
+ * $ dcop ksquirrel ksquirrel control image_next
+ *
+ * will call KSquirrel::control("image_next"), which will
+ * construct TQKeyEvent(TQEvent::KeyPress, TQt::Key_PageDown,
+ * TQt::Key_PageDown, TQt::NoButton)
+ * and send it to SQ_GLWidget. SQ_GLWidget will catch keypress event,
+ * and load next image in the current directory.
+ */
+ void control(const TQString &command);
+
+ /*
+ * Send a message to navigator from incoming DCOP message
+ */
+ void navigatorSend(const TQString &command);
+
+ /*
+ * Get TQString argument from incoming TQByteArray.
+ */
+ TQString getArg(const TQByteArray &data);
+
+ signals:
+
+ /*
+ * emitted, when user chages thumbails' size (from menu).
+ */
+ void thumbSizeChanged(const TQString&);
+
+ void resetToolTip();
+
+ public slots:
+
+ /*
+ * Show SQ_GLWidget.
+ */
+ void raiseGLWidget();
+
+ /*
+ * Switch fullscreen state of SQ_GLView.
+ */
+ void slotFullScreen(bool full);
+
+ /*
+ * Stop slideshow, if running.
+ */
+ void slotStopSlideShow();
+
+ /*
+ * Pause or unpause slideshow, if running.
+ */
+ void slotPauseSlideShow();
+
+ /*
+ * Load next or previuos file in slideshow sequence
+ * without waiting. (coming from SQ_SlideshowWidget's toolbar)
+ */
+ void slotNextSlideShow();
+ void slotPreviousSlideShow();
+
+ private slots:
+
+ void slotStatResult(TDEIO::Job *job);
+ void slotDCOPStatResult(TDEIO::Job *job);
+
+ void slotPreviewWidgetNext();
+ void slotPreviewWidgetPrevious();
+ void slotPreviewWidgetExecute();
+
+ void slotSaveYourself();
+ void slotRename();
+ void slotRenameResult(TDEIO::Job *);
+ void slotExtendedToggled(bool);
+ void slotTrayQuit();
+ void slotClose();
+
+ void slotRepeat();
+
+ /*
+ * Reload disk usage information
+ */
+ void slotFireDisk();
+
+ /*
+ * Deetrmine next supported image in slideshow
+ */
+ void slideShowDetermine();
+
+ /*
+ * Non-local file downloaded (for slideshow)
+ */
+ void slotDownloaderResult(const KURL &);
+
+ /*
+ * Got new urls while listing directory for slideshow
+ */
+ void slotSlideShowEntries(TDEIO::Job *, const TDEIO::UDSEntryList &);
+
+ /*
+ * Directory listed for slideshow
+ */
+ void slotSlideShowJobResult(TDEIO::Job *);
+
+ void slotSlideShowListingKill();
+
+ /*
+ * Invoke 'Options' dialog.
+ */
+ void slotOptions();
+
+ /*
+ * Invoke 'Filters' dialog.
+ */
+ void slotFilters();
+
+ /*
+ * Invoke 'External tools' dialog.
+ */
+ void slotExtTools();
+
+ /*
+ * Raise list view in filemanager.
+ */
+ void slotRaiseListView();
+
+ /*
+ * Raise icon view in filemanager.
+ */
+ void slotRaiseIconView();
+
+ /*
+ * Raise detail view in filemanager.
+ */
+ void slotRaiseDetailView();
+
+ /*
+ * Raise thumbnail view in filemanager.
+ */
+ void slotRaiseThumbView();
+
+ /*
+ * Invoked, when user clicked "Go" button in location toolbar.
+ */
+ void slotGo();
+
+ /*
+ * Invoked, when user selected to filter for filemanager.
+ */
+ void slotSetFilter(int);
+
+ /*
+ * Invoked, when user clicked "Go to tray".
+ */
+ void slotGotoTray();
+
+ /*
+ * Next four slots will be called, when user selected
+ * subitem in 'Thumbnail size' menu.
+ */
+ void slotThumbsMedium();
+ void slotThumbsLarge();
+ void slotThumbsHuge();
+
+ /*
+ * Invoked, when user clicked "Open file" button.
+ */
+ void slotOpenFile();
+
+ /*
+ * Invoked, when user clicked "Open file #2" button.
+ * This slot will decode selected image, and change
+ * current directory.
+ */
+ void slotOpenFileAndSet();
+
+ /*
+ * Invoked, when user clicked an animated logo in toolbar.
+ * This slot will open KSquirrel's homepage with default browser.
+ */
+ void slotAnimatedClicked();
+
+ /*
+ * Invokes a dialog with specific thumbnails actions:
+ * delete thumbnails on disk, show thumbnails on disk, ...
+ */
+ void slotTCMaster();
+
+ /*
+ * Invoked, when user clicked "Slideshow through dialog".
+ * Creates SQ_SlideShow dialog.
+ */
+ void slotSlideShowDialog();
+
+ /*
+ * Determine the next image, which should be shown in slideshow.
+ */
+ void slotSlideShowNextImage();
+
+ /*
+ * Invoked, when user presses slideshow button.
+ * Will stop or run slideshow.
+ */
+ void slotSlideShowStart();
+
+ /*
+ * Invoked, when user clicked "Plugins information" button.
+ * Creates a dialog with information on all found libraries
+ */
+ void slotPluginsInfo();
+ void slotPluginsDel();
+
+ /*
+ * Invoked, when user clicked "OpenGL information" button.
+ */
+ void slotGLInfo();
+
+ /*
+ * Convinience slot.
+ * Reload libraries from disk.
+ */
+ void slotRescan();
+
+ private:
+ static KSquirrel *m_instance;
+
+ bool m_demo;
+
+ TDEToggleAction *pAThumbsE;
+
+ // main toolbar
+ TDEToolBar *tools;
+
+ //main menu
+ KMenuBar *menubar;
+
+ // different views (Icon view, List view ...)
+ TDERadioAction *pARaiseListView, *pARaiseIconView, *pARaiseDetailView, *pARaiseThumbView;
+
+ // popup menu with thumbnail sizes
+ TDEActionMenu *pAThumbs;
+
+ // thumbnail sizes (small, normal, ...)
+ TDERadioAction *pAThumb0, *pAThumb1, *pAThumb2, *pAThumb3;
+
+ // show/hide url box
+ TDEToggleAction *pAURL;
+
+ // popup menus: "File", "View" ...
+ TDEPopupMenu *pop_file, *pop_view, *pop_action, *pop_nav;
+
+ // filters and views
+ TDEPopupMenu *actionFilterMenu, *actionViews;
+
+ // menus with bookmarks
+ TDEActionMenu *bookmarks;
+ KBookmarkMenu *bookmarkMenu;
+
+ // "Open file", "open file #2"
+ TDEAction *pAOpen, *pAOpenAndSet,
+
+ *pARename,
+
+ // Open "SQ_ThumbnailCacheMaster"
+ *pATCMaster,
+
+ // Show image window
+ *pAGLView,
+
+ // Exit
+ *pAExit,
+
+ // Reload libraries from disk (from /usr/lib/ksquirrel-libs)
+ *pARescan,
+
+ // External tool and filters
+ *pAExtTools, *pAFilters,
+
+ // Goto tray
+ *pAGotoTray,
+
+ // Dialog for advanced slideshow
+ *pASlideShowDialog,
+
+ // OpenGL information
+ *pAGLInfo,
+
+ // Plugins information
+ *pAPluginsInfo,
+ *pAPluginsDel;
+
+ // Main statusbar
+ KStatusBar *sbar;
+
+ // contains paths of found libraries
+ TQStringList strlibFound;
+
+ // sizes for mainSplitter
+ TQValueList<int> mainSizes;
+
+ // libraries' filters
+ TQStringList libFilters;
+
+ // TQMap, which contains pointers to statusbar widgets.
+ // I can get a pointer by widget's name.
+ //
+ // For example:
+ //
+ // KSquirrel::app()->sbarWidget("fileName")->setText("Filename.txt");
+ //
+ TQMap<TQString, TQLabel*> sbarwidgets;
+
+ // TQLabels for statusbar
+ TQLabel *dirInfo, *fileIcon, *fileName, *diskSpace;
+
+ // TQMap, which contains available DCOP
+ // parameters (such as "image_next", "image_prev")
+ // and its appropriate key sequences.
+ //
+ // For example, "image_next" is mapped to TQt::Key_PageDown
+ // "image_prev" - to "TQt::Key_PageUp"
+ TQMap<TQString, int> messages;
+
+ // combobox with history urls
+ KHistoryCombo *pCurrentURL;
+
+ // filters' names and extensions
+ TQStringList *sqFiltersName, *sqFiltersExt;
+
+ // "Configure KSquirrel"
+ TDEAction *pAConfigure,
+
+ // "Select group", "Deselect group", "Select all", "Deselect"
+ // actions for filemanager
+ *pASelectGroup, *pADeselectGroup, *pASelectAll, *pADeselectAll;
+
+ // "Slideshow"
+ TDEAction *pASlideShow;
+
+ /*
+ * Slideshow-specififc members.
+ *
+ * Is slideshow paused by user (with 'Pause') ?
+ */
+ bool slideShowPaused;
+
+ TDEIO::Job *listing;
+
+ SQ_SlideShowListing *listingDialog;
+
+ // Directory for slideshow.
+ // KSquirrel will use it to load file names.
+ TQString slideShowDir;
+
+ bool slideShowInit;
+
+ KFileItem *slideShowFile;
+
+ // Contains found files
+ KFileItemList slideShowItems;
+
+ // Delay, total files in selected directory and
+ // current file index
+ int slideShowIndex, slideShowDelay, slideShowTotal, slideShowRepeat;
+
+ // current file name
+ KURL slideShowName;
+
+ // timers for slideshow
+ TQTimer *slideShowTimer, *timerShowListing;
+
+ // is slideshow stopped ?
+ bool slideShowStop;
+
+ // url box
+ TDEToolBar *pTLocation;
+
+ // our config file
+ SQ_Config *tdeconf;
+
+ // widget stack containing different views (Icon view, List view ...)
+ SQ_WidgetStack *pWidgetStack;
+
+ // our library handler
+ SQ_LibraryHandler *libhandler;
+
+ // ou tray instance
+ KSystemTray *tray;
+
+ // external tools
+ SQ_ExternalTool *extool;
+
+ TQSplitter *mainView;
+
+ // file tree
+ SQ_TreeView *ptree;
+
+ // widget containing SQ_GLWidget and statusbar
+ SQ_GLView *gl_view;
+
+ // archive handler, can unpack different archives
+ SQ_ArchiveHandler *ar;
+
+ // object containing different useful information
+ // on thumbnails (size, margin ...)
+ SQ_ThumbnailSize *thumbSize;
+
+ // thumbnails' memory cache
+ SQ_PixmapCache *cache;
+
+ // sidebar
+ SQ_MultiBar *sideBar;
+
+ SQ_SplashScreen *splash_to_delete;
+
+ SQ_Progress *diskProg;
+
+ // KIPI plugins loader
+#ifdef SQ_HAVE_KIPI
+ SQ_KIPIManager *kipiManager;
+#endif
+
+ enum SSD { MBack, Default } slideShowDirection;
+
+ // not interesting ;)
+ KURL renameSrcURL, renameDestURL;
+ int old_id;
+ bool old_disable, m_urlbox, old_marks, old_calc, m_intray, waitForShow;
+ SQ_Downloader *down;
+ TQVBox *mainPage;
+ bool statStage;
+};
+
+// Is slideshow running ?
+inline
+bool KSquirrel::slideShowRunning() const
+{
+ return !slideShowStop;
+}
+
+inline
+KHistoryCombo* KSquirrel::historyCombo()
+{
+ return pCurrentURL;
+}
+
+inline
+TQStringList* KSquirrel::filtersNames() const
+{
+ return sqFiltersName;
+}
+
+inline
+TQStringList* KSquirrel::filtersExtensions() const
+{
+ return sqFiltersExt;
+}
+
+inline
+TDEPopupMenu* KSquirrel::menuFilters()
+{
+ return actionFilterMenu;
+}
+
+inline
+TDEPopupMenu* KSquirrel::menuViews()
+{
+ return actionViews;
+}
+
+inline
+SQ_Progress* KSquirrel::diskProgress()
+{
+ return diskProg;
+}
+
+inline
+bool KSquirrel::demo() const
+{
+ return m_demo;
+}
+
+#endif
diff --git a/src/ksquirrelpart/Makefile.am b/src/ksquirrelpart/Makefile.am
new file mode 100644
index 0000000..2e50ce8
--- /dev/null
+++ b/src/ksquirrelpart/Makefile.am
@@ -0,0 +1,28 @@
+INCLUDES = $(all_includes) -I$(srcdir)
+
+# These are not really libraries, but modules dynamically opened.
+# So they should be installed in kde_module_dir, which is usually $kde_prefix/lib/trinity
+kde_module_LTLIBRARIES = libksquirrelpart.la
+
+AM_CXXFLAGS = -DKSQUIRREL_PART
+
+if SQ_HAVE_KEXIF
+AM_CXXFLAGS += $(libkexif_CFLAGS)
+endif
+
+AM_CCASFLAGS = -I$(srcdir) $(KSQUIRREL_ASM_DEFS)
+
+libksquirrelpart_la_SOURCES = ksquirrelpart.cpp sq_glparts.cpp sq_glu.cpp sq_glwidget.cpp sq_glwidget_stuff.cpp sq_libraryhandler.cpp sq_downloader.cpp sq_iconloader.cpp fmt_filters.cpp sq_externaltool.cpp sq_config.cpp sq_filedialog.cpp sq_imagefilter.ui sq_imagebcg.ui sq_glselectionpainter.cpp sq_glwidget_helpers.cpp sq_label.cpp sq_bcglabel.cpp sq_popupmenu.cpp sq_codecsettingsskeleton.ui sq_codecsettings.cpp sq_imageproperties.ui sq_utils.cpp sq_helpwidget.ui sq_utils_asm_scale.S sq_utils_scale.cpp sq_diroperator.cpp sq_glview.cpp sq_errorstring.cpp
+libksquirrelpart_la_LIBADD = $(LIB_TDEPARTS)
+libksquirrelpart_la_LDFLAGS = $(all_libraries) $(LIB_TQT) $(LIB_TDECORE) $(LIB_TDEUI) $(LIB_TDEIO) $(LIB_TDEFX) $(KDE_PLUGIN) $(ksquirrellibs_LIBS) $(LIB_TDEPRINT) -lkonq -ltdefx $(LIB_QUI)
+
+if SQ_HAVE_KEXIF
+libksquirrelpart_la_LDFLAGS += $(libkexif_LIBS)
+endif
+
+METASOURCES = AUTO
+
+ksquirreldir = $(kde_datadir)/ksquirrelpart
+ksquirrel_DATA = ksquirrelpart.rc
+
+kde_services_DATA = ksquirrelpart.desktop
diff --git a/src/ksquirrelpart/file_broken.xpm b/src/ksquirrelpart/file_broken.xpm
new file mode 100644
index 0000000..1040d96
--- /dev/null
+++ b/src/ksquirrelpart/file_broken.xpm
@@ -0,0 +1,831 @@
+/* XPM */
+static const char * file_broken_xpm[] = {
+"64 64 764 2",
+" c None",
+". c #A5A9AA",
+"+ c #A4A8A9",
+"@ c #A3A7A8",
+"# c #A2A6A7",
+"$ c #A1A5A6",
+"% c #A0A4A5",
+"& c #9FA3A4",
+"* c #9EA2A3",
+"= c #9DA1A2",
+"- c #9CA0A1",
+"; c #9B9FA0",
+"> c #9A9E9F",
+", c #999D9E",
+"' c #989C9D",
+") c #979B9C",
+"! c #969A9B",
+"~ c #95999A",
+"{ c #949899",
+"] c #939798",
+"^ c #929697",
+"/ c #919596",
+"( c #909495",
+"_ c #8F9394",
+": c #8E9293",
+"< c #8D9192",
+"[ c #8C9091",
+"} c #8B8F90",
+"| c #8A8E8F",
+"1 c #898D8E",
+"2 c #888C8D",
+"3 c #878B8C",
+"4 c #A6AAAB",
+"5 c #ACB7BF",
+"6 c #B3C4D4",
+"7 c #B2C3D3",
+"8 c #B1C2D2",
+"9 c #B0C1D1",
+"0 c #AFC0D0",
+"a c #AEBFCF",
+"b c #ADBECE",
+"c c #ACBDCD",
+"d c #ABBCCC",
+"e c #AABBCB",
+"f c #A9BACA",
+"g c #A8B9C9",
+"h c #A7B8C8",
+"i c #A6B7C7",
+"j c #A5B6C6",
+"k c #A4B5C5",
+"l c #95A0A8",
+"m c #868A8B",
+"n c #B0BECA",
+"o c #C2E0FF",
+"p c #D1E7FF",
+"q c #D0E7FF",
+"r c #CFE7FF",
+"s c #CFE6FF",
+"t c #9CAAB6",
+"u c #828687",
+"v c #C0DCF9",
+"w c #E4F1FF",
+"x c #FFFFFF",
+"y c #FEFFFF",
+"z c #FEFEFF",
+"A c #FDFEFF",
+"B c #FCFEFF",
+"C c #FBFDFF",
+"D c #FAFDFF",
+"E c #FAFCFF",
+"F c #F9FCFF",
+"G c #F8FCFF",
+"H c #F8FBFF",
+"I c #F7FBFF",
+"J c #F6FAFF",
+"K c #F5FAFF",
+"L c #DEEEFF",
+"M c #BEDAF7",
+"N c #85898A",
+"O c #E8F3FF",
+"P c #EFF7FF",
+"Q c #F4FAFF",
+"R c #E7F3FF",
+"S c #F3F9FF",
+"T c #E6F2FF",
+"U c #F2F8FF",
+"V c #E5F2FF",
+"W c #F1F8FF",
+"X c #FAEFEF",
+"Y c #EAAFAF",
+"Z c #EFCECF",
+"` c #EECDCF",
+" . c #CA3434",
+".. c #C21616",
+"+. c #E59F9F",
+"@. c #BD1C1C",
+"#. c #BC1C1C",
+"$. c #EDCDCF",
+"%. c #F0F8FF",
+"&. c #FBEFEF",
+"*. c #CB3434",
+"=. c #DE3939",
+"-. c #F64747",
+";. c #C61A1A",
+">. c #BE1C1C",
+",. c #E83D3D",
+"'. c #E73C3C",
+"). c #BC1B1B",
+"!. c #ECCDCF",
+"~. c #F0F7FF",
+"{. c #E3F1FF",
+"]. c #CC3434",
+"^. c #DF3939",
+"/. c #FF6969",
+"(. c #FF7A7A",
+"_. c #F0CECF",
+":. c #BF1C1C",
+"<. c #FB6363",
+"[. c #FB6161",
+"}. c #E73737",
+"|. c #BC1A1A",
+"1. c #EBCCCF",
+"2. c #CD3434",
+"3. c #FFA3A3",
+"4. c #FF8080",
+"5. c #C01C1C",
+"6. c #FB9E9E",
+"7. c #FB9D9D",
+"8. c #FB5E5E",
+"9. c #E73333",
+"0. c #BC1919",
+"a. c #EBCBCF",
+"b. c #E0EFFF",
+"c. c #B5D9FF",
+"d. c #CE3434",
+"e. c #E03939",
+"f. c #FF6868",
+"g. c #FFA1A1",
+"h. c #FE7F7F",
+"i. c #F54747",
+"j. c #E59E9F",
+"k. c #C11C1C",
+"l. c #E93D3D",
+"m. c #FB6362",
+"n. c #FB9C9C",
+"o. c #FB9B9B",
+"p. c #FB9A9A",
+"q. c #FA9999",
+"r. c #FA5A59",
+"s. c #E62F2F",
+"t. c #BC1819",
+"u. c #EACBCF",
+"v. c #EBF5FF",
+"w. c #E5F1FF",
+"x. c #99CCFF",
+"y. c #CF3434",
+"z. c #E13939",
+"A. c #FE6665",
+"B. c #FE9C9B",
+"C. c #FE7C7A",
+"D. c #DC7F7F",
+"E. c #C21C1C",
+"F. c #FC6160",
+"G. c #FB9796",
+"H. c #FB9695",
+"I. c #FB9594",
+"J. c #FB9493",
+"K. c #FA9392",
+"L. c #FA9291",
+"M. c #F94242",
+"N. c #E62B2B",
+"O. c #BC1818",
+"P. c #E9CBCF",
+"Q. c #EDF6FF",
+"R. c #E9F4FF",
+"S. c #E2F0FF",
+"T. c #D03434",
+"U. c #E23939",
+"V. c #FE6463",
+"W. c #FE9794",
+"X. c #FD7876",
+"Y. c #F44646",
+"Z. c #C82222",
+"`. c #EA3D3D",
+" + c #FC5F5D",
+".+ c #FD928F",
+"++ c #FD918E",
+"@+ c #FD908D",
+"#+ c #FC8F8C",
+"$+ c #FC8E8B",
+"%+ c #FC8D8A",
+"&+ c #FB8683",
+"*+ c #F93434",
+"=+ c #F82C2C",
+"-+ c #E52727",
+";+ c #BC1717",
+">+ c #E8CBCF",
+",+ c #E1F0FF",
+"'+ c #D13434",
+")+ c #FE6260",
+"!+ c #FE918D",
+"~+ c #FD7370",
+"{+ c #FC5D5B",
+"]+ c #FD8D88",
+"^+ c #FD8C87",
+"/+ c #FD8A86",
+"(+ c #FC8985",
+"_+ c #FC8884",
+":+ c #FC8783",
+"<+ c #FC8682",
+"[+ c #FA6462",
+"}+ c #F82A2A",
+"|+ c #F82727",
+"1+ c #E52323",
+"2+ c #BC1616",
+"3+ c #E7CACF",
+"4+ c #EFF6FF",
+"5+ c #E6F3FF",
+"6+ c #CEE6FF",
+"7+ c #D23434",
+"8+ c #E33939",
+"9+ c #FE5C5A",
+"0+ c #FE8C87",
+"a+ c #FE8C86",
+"b+ c #FD8B85",
+"c+ c #FD8984",
+"d+ c #FC7672",
+"e+ c #FD8782",
+"f+ c #FD8681",
+"g+ c #FD8580",
+"h+ c #FC847F",
+"i+ c #FC837E",
+"j+ c #FC827D",
+"k+ c #FC817B",
+"l+ c #FC807A",
+"m+ c #F83636",
+"n+ c #F72525",
+"o+ c #F72323",
+"p+ c #E41F1F",
+"q+ c #BA1313",
+"r+ c #EAD9DF",
+"s+ c #EBF4FF",
+"t+ c #CDE6FF",
+"u+ c #DC5F5F",
+"v+ c #D92C2C",
+"w+ c #FC4B4A",
+"x+ c #FE7B76",
+"y+ c #FE8780",
+"z+ c #FD8780",
+"A+ c #FD8680",
+"B+ c #FD857F",
+"C+ c #FD847D",
+"D+ c #FC837C",
+"E+ c #FC827B",
+"F+ c #FC817A",
+"G+ c #FC8079",
+"H+ c #FC7F78",
+"I+ c #FC7E77",
+"J+ c #FB7D76",
+"K+ c #FB7C75",
+"L+ c #FB7A74",
+"M+ c #F95C58",
+"N+ c #F62121",
+"O+ c #D71919",
+"P+ c #C13031",
+"Q+ c #EBE7EF",
+"R+ c #DFEFFF",
+"S+ c #FC4A4A",
+"T+ c #FE7770",
+"U+ c #FD8179",
+"V+ c #FD8078",
+"W+ c #FD7F77",
+"X+ c #FC7E76",
+"Y+ c #FC7D75",
+"Z+ c #FC7C74",
+"`+ c #FC7A72",
+" @ c #FC7971",
+".@ c #FC7870",
+"+@ c #FB776F",
+"@@ c #FB766E",
+"#@ c #FB756D",
+"$@ c #FA6F68",
+"%@ c #F82E2E",
+"&@ c #C23031",
+"*@ c #EAE7EF",
+"=@ c #CCE5FF",
+"-@ c #FC4A49",
+";@ c #FD726B",
+">@ c #FD7C73",
+",@ c #FD7A71",
+"'@ c #FD7970",
+")@ c #FC786F",
+"!@ c #FC776E",
+"~@ c #FC766D",
+"{@ c #FC756C",
+"]@ c #FC746B",
+"^@ c #FC736A",
+"/@ c #FB7269",
+"(@ c #FB7168",
+"_@ c #FB7066",
+":@ c #FB6E65",
+"<@ c #F83F3C",
+"[@ c #D81919",
+"}@ c #C33031",
+"|@ c #E8E6EF",
+"1@ c #DDEEFF",
+"2@ c #CBE5FF",
+"3@ c #FB4A49",
+"4@ c #FC6E65",
+"5@ c #FC776C",
+"6@ c #FC766C",
+"7@ c #FC756B",
+"8@ c #FC746A",
+"9@ c #FC7369",
+"0@ c #FC7267",
+"a@ c #FC7166",
+"b@ c #FC7065",
+"c@ c #FB6F64",
+"d@ c #FB6E63",
+"e@ c #FB6D62",
+"f@ c #FB6B61",
+"g@ c #FB6A60",
+"h@ c #FA695F",
+"i@ c #F94944",
+"j@ c #D91919",
+"k@ c #C43031",
+"l@ c #DCEDFF",
+"m@ c #CBE4FF",
+"n@ c #FA4949",
+"o@ c #FC6960",
+"p@ c #FC7064",
+"q@ c #FC6F63",
+"r@ c #FC6E62",
+"s@ c #FC6D61",
+"t@ c #FC6C60",
+"u@ c #FC6A5F",
+"v@ c #FB695D",
+"w@ c #FB685C",
+"x@ c #FB675B",
+"y@ c #FB665A",
+"z@ c #FB6559",
+"A@ c #FA6458",
+"B@ c #F94641",
+"C@ c #C53031",
+"D@ c #E7E5EF",
+"E@ c #DBEDFF",
+"F@ c #CAE4FF",
+"G@ c #DB5F5F",
+"H@ c #D82C2C",
+"I@ c #FA4646",
+"J@ c #FC6258",
+"K@ c #FC685B",
+"L@ c #FC675A",
+"M@ c #FC6659",
+"N@ c #FC6558",
+"O@ c #FB6457",
+"P@ c #FB6356",
+"Q@ c #FB6255",
+"R@ c #FB6154",
+"S@ c #FB6053",
+"T@ c #FA5B4F",
+"U@ c #F83A36",
+"V@ c #DA1919",
+"W@ c #C52F31",
+"X@ c #C9E4FF",
+"Y@ c #F3CECF",
+"Z@ c #CB0C0C",
+"`@ c #F04242",
+" # c #FB4F48",
+".# c #FB6253",
+"+# c #FB6152",
+"@# c #FB6051",
+"## c #FB5E50",
+"$# c #FB5D4F",
+"%# c #FA5C4E",
+"&# c #FA5B4D",
+"*# c #FA5A4C",
+"=# c #F94B41",
+"-# c #F11F1F",
+";# c #C70C0C",
+"># c #D5898F",
+",# c #DAECFF",
+"'# c #CF1C1C",
+")# c #ED3D3D",
+"!# c #FB4B45",
+"~# c #FB5C4D",
+"{# c #FB5B4C",
+"]# c #FB5A4B",
+"^# c #FB594A",
+"/# c #FB5849",
+"(# c #FA5748",
+"_# c #FA5646",
+":# c #F95244",
+"<# c #F83834",
+"[# c #F72A2A",
+"}# c #F61F1F",
+"|# c #F31D1D",
+"1# c #E91A1A",
+"2# c #C50909",
+"3# c #D7989F",
+"4# c #D9ECFF",
+"5# c #C8E3FF",
+"6# c #D01C1C",
+"7# c #EE3D3D",
+"8# c #FB4943",
+"9# c #FB5948",
+"0# c #FB5847",
+"a# c #FB5746",
+"b# c #FB5545",
+"c# c #FA5444",
+"d# c #FA5343",
+"e# c #F95242",
+"f# c #F8463B",
+"g# c #F62E2D",
+"h# c #F52A2A",
+"i# c #F52727",
+"j# c #F52525",
+"k# c #F52323",
+"l# c #F51F1F",
+"m# c #F11D1D",
+"n# c #EF1A1A",
+"o# c #EF1818",
+"p# c #E91616",
+"q# c #C50707",
+"r# c #D6979F",
+"s# c #D8EBFF",
+"t# c #F4CECF",
+"u# c #D11C1C",
+"v# c #FA5545",
+"w# c #F95343",
+"x# c #F85041",
+"y# c #F53934",
+"z# c #F32C2C",
+"A# c #F12A2A",
+"B# c #F12727",
+"C# c #F12525",
+"D# c #F12323",
+"E# c #F22121",
+"F# c #EE1D1D",
+"G# c #EE1A1A",
+"H# c #EE1616",
+"I# c #ED1414",
+"J# c #E71212",
+"K# c #C50606",
+"L# c #D5979F",
+"M# c #D7EBFF",
+"N# c #C7E3FF",
+"O# c #D31C1C",
+"P# c #EF3D3D",
+"Q# c #F95444",
+"R# c #F85343",
+"S# c #F6493D",
+"T# c #F2302F",
+"U# c #F02C2C",
+"V# c #EF2A2A",
+"W# c #EE2727",
+"X# c #EE2525",
+"Y# c #ED2323",
+"Z# c #EE2121",
+"`# c #EB1F1F",
+" $ c #E91D1D",
+".$ c #EA1A1A",
+"+$ c #EB1818",
+"@$ c #EC1616",
+"#$ c #ED1212",
+"$$ c #ED0F0F",
+"%$ c #E70D0D",
+"&$ c #C50404",
+"*$ c #D4969F",
+"=$ c #D6EAFF",
+"-$ c #C6E2FF",
+";$ c #D41C1C",
+">$ c #F4433A",
+",$ c #F02E2E",
+"'$ c #EE2C2C",
+")$ c #EC2A2A",
+"!$ c #EB2727",
+"~$ c #EB2525",
+"{$ c #EA2323",
+"]$ c #E92121",
+"^$ c #E51F1F",
+"/$ c #E51D1D",
+"($ c #E51A1A",
+"_$ c #E71818",
+":$ c #E71616",
+"<$ c #E91414",
+"[$ c #EA1212",
+"}$ c #EC0F0F",
+"|$ c #EC0D0D",
+"1$ c #EB0B0B",
+"2$ c #E50909",
+"3$ c #C50202",
+"4$ c #D3969F",
+"5$ c #D5EAFF",
+"6$ c #EEF6FF",
+"7$ c #FAEEEF",
+"8$ c #D31414",
+"9$ c #EB3D3D",
+"0$ c #FB4843",
+"a$ c #F75343",
+"b$ c #F23D37",
+"c$ c #EF2E2E",
+"d$ c #EC2C2C",
+"e$ c #EA2A2A",
+"f$ c #E92727",
+"g$ c #E82525",
+"h$ c #E62323",
+"i$ c #E32121",
+"j$ c #E11F1F",
+"k$ c #E11D1D",
+"l$ c #E11A1A",
+"m$ c #E21818",
+"n$ c #E31616",
+"o$ c #E41414",
+"p$ c #E61212",
+"q$ c #E70F0F",
+"r$ c #E90D0D",
+"s$ c #EA0909",
+"t$ c #EA0707",
+"u$ c #E30404",
+"v$ c #C00000",
+"w$ c #D8C2CF",
+"x$ c #C5E2FF",
+"y$ c #EB9E9F",
+"z$ c #D71818",
+"A$ c #F53F3E",
+"B$ c #FB5245",
+"C$ c #EE2E2E",
+"D$ c #EB2C2C",
+"E$ c #E92A2A",
+"F$ c #E72727",
+"G$ c #E52525",
+"H$ c #E22323",
+"I$ c #DE2121",
+"J$ c #DD1F1F",
+"K$ c #DD1D1D",
+"L$ c #DD1A1A",
+"M$ c #DD1818",
+"N$ c #DE1616",
+"O$ c #DF1414",
+"P$ c #E11212",
+"Q$ c #E20F0F",
+"R$ c #E40D0D",
+"S$ c #E60B0B",
+"T$ c #E80909",
+"U$ c #E80404",
+"V$ c #CE0202",
+"W$ c #C9595F",
+"X$ c #D4E9FF",
+"Y$ c #C4E1FF",
+"Z$ c #EA9E9F",
+"`$ c #D71616",
+" % c #F53B3A",
+".% c #FA4F42",
+"+% c #F3433A",
+"@% c #E82A2A",
+"#% c #E62727",
+"$% c #E22525",
+"%% c #DD2323",
+"&% c #DB2121",
+"*% c #CE1D1D",
+"=% c #D71D1D",
+"-% c #D81A1A",
+";% c #D91818",
+">% c #D91616",
+",% c #DB1414",
+"'% c #DC1212",
+")% c #DE0F0F",
+"!% c #DF0D0D",
+"~% c #E20B0B",
+"{% c #E40909",
+"]% c #E60707",
+"^% c #E70404",
+"/% c #CF0202",
+"(% c #CA595F",
+"_% c #D3E9FF",
+":% c #EDF5FF",
+"<% c #EA9D9F",
+"[% c #D71414",
+"}% c #F33735",
+"|% c #F84D40",
+"1% c #F64E3F",
+"2% c #E42727",
+"3% c #DE2525",
+"4% c #DB2323",
+"5% c #D92121",
+"6% c #CA1919",
+"7% c #C91111",
+"8% c #C61010",
+"9% c #D31818",
+"0% c #D51616",
+"a% c #D61414",
+"b% c #D71212",
+"c% c #D90F0F",
+"d% c #DB0D0D",
+"e% c #DD0B0B",
+"f% c #DF0909",
+"g% c #E10707",
+"h% c #E20404",
+"i% c #CB595F",
+"j% c #D2E8FF",
+"k% c #C3E1FF",
+"l% c #ECF5FF",
+"m% c #E99D9F",
+"n% c #D61313",
+"o% c #EE3231",
+"p% c #F13230",
+"q% c #E62A2A",
+"r% c #E22727",
+"s% c #D82121",
+"t% c #C91919",
+"u% c #CF2F31",
+"v% c #E7E4EF",
+"w% c #D45B5F",
+"x% c #C40E0E",
+"y% c #D01414",
+"z% c #D21212",
+"A% c #D40F0F",
+"B% c #D60D0D",
+"C% c #D80B0B",
+"D% c #DA0909",
+"E% c #DC0707",
+"F% c #DE0404",
+"G% c #CC0202",
+"H% c #CC595F",
+"I% c #D1E8FF",
+"J% c #C2E1FF",
+"K% c #F7FAFF",
+"L% c #E79C9F",
+"M% c #D41111",
+"N% c #E72C2C",
+"O% c #E32727",
+"P% c #DF2525",
+"Q% c #D35B5F",
+"R% c #C30B0B",
+"S% c #CE0F0F",
+"T% c #D10D0D",
+"U% c #D30B0B",
+"V% c #D50909",
+"W% c #D80707",
+"X% c #D90404",
+"Y% c #CA0202",
+"Z% c #CD595F",
+"`% c #ADD6FF",
+" & c #F4F9FF",
+".& c #E49A9F",
+"+& c #D20F0F",
+"@& c #E12727",
+"#& c #E12525",
+"$& c #CB1919",
+"%& c #D12F31",
+"&& c #D25A5F",
+"*& c #C20808",
+"=& c #CD0B0B",
+"-& c #D10909",
+";& c #D30707",
+">& c #D50404",
+",& c #C80202",
+"'& c #CE595F",
+")& c #C1E0FF",
+"!& c #DEEFFF",
+"~& c #F2F9FF",
+"{& c #E39A9F",
+"]& c #D00E0E",
+"^& c #CD1919",
+"/& c #D22F31",
+"(& c #C30505",
+"_& c #CE0707",
+":& c #D00404",
+"<& c #C60202",
+"[& c #C0DFFF",
+"}& c #EEF7FF",
+"|& c #E2999F",
+"1& c #CF0C0C",
+"2& c #CF1919",
+"3& c #D32F31",
+"4& c #D15A5F",
+"5& c #C40303",
+"6& c #CF595F",
+"7& c #ECF6FF",
+"8& c #E1999F",
+"9& c #D52D2F",
+"0& c #D1595F",
+"a& c #D0595F",
+"b& c #BFDFFF",
+"c& c #EAF4FF",
+"d& c #BFDEFF",
+"e& c #BEDEFF",
+"f& c #CAE5FF",
+"g& c #BDDEFF",
+"h& c #BCDDFF",
+"i& c #BBDDFF",
+"j& c #BADCFF",
+"k& c #B9DCFF",
+"l& c #C4E2FF",
+"m& c #B8DBFF",
+"n& c #889299",
+"o& c #99C9F9",
+"p& c #B0D7FF",
+"q& c #97C7F7",
+"r& c #A1B6CA",
+"s& c #ACD5FF",
+"t& c #ABD5FF",
+"u& c #AAD5FF",
+"v& c #AAD4FF",
+"w& c #A9D4FF",
+"x& c #A8D4FF",
+"y& c #A8D3FF",
+"z& c #A7D3FF",
+"A& c #A6D2FF",
+"B& c #A5D2FF",
+"C& c #A4D2FF",
+"D& c #A4D1FF",
+"E& c #A3D1FF",
+"F& c #8DA2B6",
+"G& c #A2B2BF",
+"H& c #9DBEDF",
+"I& c #9BC3E9",
+"J& c #9BC2E9",
+"K& c #9BC2E8",
+"L& c #9AC2E8",
+"M& c #9AC1E8",
+"N& c #9AC1E7",
+"O& c #99C1E7",
+"P& c #99C0E7",
+"Q& c #99C0E6",
+"R& c #98C0E6",
+"S& c #98BFE6",
+"T& c #98BFE5",
+"U& c #97BFE5",
+"V& c #97BEE5",
+"W& c #97BEE4",
+"X& c #96BEE4",
+"Y& c #96BDE4",
+"Z& c #96BDE3",
+"`& c #95BDE3",
+" * c #95BCE3",
+".* c #95BCE2",
+"+* c #94BCE2",
+"@* c #90ABC5",
+"#* c #8B9BA8",
+"$* c #848889",
+"%* c #999C9D",
+"&* c #96999A",
+"** c #959899",
+"=* c #949798",
+"-* c #939697",
+";* c #929596",
+">* c #909394",
+",* c #8E9292",
+"'* c #8D9091",
+")* c #8B8E8F",
+"!* c #888B8C",
+"~* c #878A8B",
+"{* c #868A8A",
+"]* c #858889",
+"^* c #848788",
+"/* c #838787",
+"(* c #818586",
+"_* c #818485",
+":* c #808485",
+"<* c #7F8384",
+"[* c #7F8383",
+"}* c #787C7D",
+" ",
+" ",
+" ",
+" . + + @ # # $ % % & & * = = - ; ; > , , ' ) ) ! ! ~ { { ] ^ ^ / ( ( _ : : < < [ } } | 1 1 2 3 3 ",
+" 4 5 6 6 7 7 7 8 8 8 9 9 9 0 0 0 a a a b b b c c c c d d d e e e f f f g g g h h h i i i j j j k l m ",
+" 4 n o p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p q q q q q q q q r r s s s s s o t u ",
+" 4 v w x x x x x x x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K L M N ",
+" 4 o I x x x x x x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K O o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q R o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q Q R o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q Q S T o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q Q S S T o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q Q S S U T o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q Q S S U U V o N ",
+" 4 o P x x x x x x x x x x x x x x x x x x x y z z A A B C C D D E F G H I I I J K K Q Q S S U U W V o N ",
+" 4 o P x x x x x x x x x x X Y x x x x x x y z z A A Z ` C D D E F G H I I I J K K Q Q S S U U W W V o N ",
+" 4 o P x x x x x x x x x X ...+.x x x x y z z A A Z @.#.$.D E F G H I I I J K K Q Q S S U U W W %.w o N ",
+" 4 o P x x x x x x x x &.*.=.-.;.+.x x y z z A A Z >.,.'.).!.F G H I I I J K K Q Q S S U U W W %.~.{.o N ",
+" 4 o P x x x x x x x &.].^./.(.-.;.+.y z z A A _.:.,.<.[.}.|.1.H I I I J K K Q Q S S U U W W %.~.P {.o N ",
+" 4 o P x x x x x x &.2.^./.3.3.4.-.;.+.z A A _.5.,.<.6.7.8.9.0.a.I I J K K Q Q S S U U W W %.~.P P b.c.N ",
+" 4 o P x x x x x &.d.e.f.g.g.g.g.h.i.;.j.A _.k.l.m.n.o.p.q.r.s.t.u.J K K Q Q S S U U W W %.P v.O w.q x.N ",
+" 4 o P x x x x &.y.z.A.B.B.B.B.B.B.C.i.;.D.E.l.F.G.H.I.J.K.L.M.N.O.P.K Q Q S S U U W W Q.R.V w {.S.r x.N ",
+" 4 o P x x x &.T.U.V.W.W.W.W.W.W.W.W.X.Y.Z.`. +.+++@+#+$+%+&+*+=+-+;+>+Q S S U U W Q.O T V w {.S.,+r x.N ",
+" 4 o P x x &.'+U.)+!+!+!+!+!+!+!+!+!+!+~+M.{+]+^+/+(+_+:+<+[+=+}+|+1+2+3+S U U 4+O 5+T V w {.S.,+,+6+x.N ",
+" 4 o P x &.7+8+9+0+0+0+0+0+0+0+0+0+a+b+c+d+e+f+g+h+i+j+k+l+m+}+|+n+o+p+q+r+~.s+R 5+T V w {.S.,+,+b.t+x.N ",
+" 4 o P x x u+v+w+x+y+y+z+z+z+z+z+A+B+C+D+E+F+G+H+I+J+K+L+M+}+|+n+o+N+O+P+Q+R.R 5+T V w {.S.,+,+b.R+t+x.N ",
+" 4 o P x x x u+v+S+T+U+U+U+U+U+U+V+W+X+Y+Z+`+ @.@+@@@#@$@%@|+n+o+N+O+&@*@O R 5+T V w {.S.,+,+b.R+L [email protected] ",
+" 4 o P x x x x u+v+-@;@>@>@>@>@,@'@)@!@~@{@]@^@/@(@_@:@<@|+n+o+N+[@}@|@O R 5+T V w {.S.,+,+b.R+L 1@[email protected] ",
+" 4 o P x x x x x u+v+3@4@5@6@7@8@9@0@a@b@c@d@e@f@g@h@i@|+n+o+N+j@k@|@O R 5+T V w {.S.,+,+b.R+L 1@l@[email protected] ",
+" 4 o P x x x x y z u+v+n@o@p@q@r@s@t@u@v@w@x@y@z@A@B@|+n+o+N+j@C@D@O R 5+T V w {.S.,+,+b.R+L 1@l@E@[email protected] ",
+" 4 o P x x x y z z A G@H@I@J@K@L@M@N@O@P@Q@R@S@T@U@|+n+o+N+V@W@D@O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@[email protected] ",
+" 4 o P x x y z z A A Y@Z@`@ #.#+#@###$#%#&#*#=#=+|+n+o+N+-#;#>#O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#[email protected] ",
+" 4 o P x y z z A A Y@'#)#!#~#{#]#^#/#(#_#:#<#[#|+n+o+N+}#|#1#2#3#5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#5#x.N ",
+" 4 o P y z z A A Y@6#7#8#9#0#a#b#c#d#e#f#g#h#i#j#k#N+l#m#n#o#p#q#r#V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#5#x.N ",
+" 4 o P z z A A t#u#7#8#9#0#a#v#c#w#x#y#z#A#B#C#D#E#-#F#G#o#H#I#J#K#L#{.S.,+,+b.R+L 1@l@E@E@,#4#s#M#N#x.N ",
+" 4 o 4+z A A t#O#P#8#9#0#a#v#Q#R#S#T#U#V#W#X#Y#Z#`# $.$+$@$I##$$$%$&$*$,+,+b.R+L 1@l@E@E@,#4#s#M#=$-$x.N ",
+" 4 o 4+A A t#;$P#8#9#0#a#v#Q#R#>$,$'$)$!$~${$]$^$/$($_$:$<$[$}$|$1$2$3$4$b.R+L 1@l@E@E@,#4#s#M#=$5$-$x.N ",
+" 4 o 6$A 7$8$9$0$9#0#a#v#Q#a$b$c$d$e$f$g$h$i$j$k$l$m$n$o$p$q$r$1$s$t$u$v$w$L 1@l@E@E@,#4#s#M#=$5$5$x$x.N ",
+" 4 o 6$B C y$z$A$B$a#v#Q#a$b$C$D$E$F$G$H$I$J$K$L$M$N$O$P$Q$R$S$T$t$U$V$W$L 1@l@E@E@,#4#s#M#=$5$5$X$Y$x.N ",
+" 4 o 6$C C D Z$`$ %.%Q#R#+%C$D$@%#%$%%%&%*%=%-%;%>%,%'%)%!%~%{%]%^%/%(%L 1@l@E@E@,#4#s#M#=$5$5$X$_%Y$x.N ",
+" 4 o :%C D D E <%[%}%|%1%c$D$@%2%3%4%5%6%7%8%9%0%a%b%c%d%e%f%g%h%V$i%L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%k%x.N ",
+" 4 o l%D D E F G m%n%o%p%d$q%r%3%4%s%t%u%v%w%x%y%z%A%B%C%D%E%F%G%H%L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%J%x.N ",
+" 4 o l%D E F G H K%L%M%N%q%O%P%4%s%6%u%v%O R Q%R%S%T%U%V%W%X%Y%Z%L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q o x.N ",
+" 4 `%V H I J &S U W .&+&@&#&%%5%$&%&v%O R 5+T &&*&=&-&;&>&,&'&L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r )&x.N ",
+" 4 x.!&K Q S ~&U W ~.P {&]&4%&%^&/&v%O R 5+T V w &&(&_&:&<&'&L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r [&x.N ",
+" 4 x.L Q S ~&U W ~.P }&Q.|&1&2&3&v%O R 5+T V w {.S.4&5&3$6&L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+[&x.N ",
+" 4 x.1@S ~&U W ~.P }&Q.7&l%8&9&v%O R 5+T V w {.S.,+,+0&a&L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+b&x.N ",
+" 4 x.l@~&U W ~.P }&Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@d&x.N ",
+" 4 x.l@U W ~.P }&Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@e&x.N ",
+" 4 x.E@W ~.P }&Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&g&x.N ",
+" 4 x.E@~.P }&Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@g&x.N ",
+" 4 x.,#P }&Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@h&x.N ",
+" 4 x.4#}&Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#i&x.N ",
+" 4 x.4#Q.7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#N#i&x.N ",
+" 4 x.s#7&l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#N#-$j&x.N ",
+" 4 x.M#l%v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#N#-$x$k&x.N ",
+" 4 x.M#v.c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#N#-$x$l&k&x.N ",
+" 4 x.=$c&R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#N#-$x$l&k%m&x.n& ",
+" 4 o&-$R.O R 5+T V w {.S.,+,+b.R+L 1@l@E@E@,#4#s#M#=$5$5$X$_%j%I%q r r 6+t+=@2@f&X@X@5#N#-$x$l&k%J%p&q&N ",
+" 4 r&x.`%s&s&s&s&t&t&t&t&t&u&v&v&v&v&w&w&w&w&x&y&y&y&y&z&z&z&z&z&A&A&A&A&B&B&B&B&B&C&D&D&D&D&E&E&E&x.F&u ",
+" 4 G&H&I&J&J&J&K&L&L&M&M&M&N&N&O&P&P&P&Q&Q&R&S&S&S&S&T&U&U&V&V&V&W&X&X&Y&Y&Y&Z&Z&`& * * *.*.*+*@*#*$* ",
+" . > , %*' ) ) ! &*~ **=*] -*^ ;*/ ( >*_ : ,*< '*[ } )*| 1 1 2 !*3 ~*{*N ]*$*^*/*u u (*_*:*<*[*}* ",
+" ",
+" "};
diff --git a/src/ksquirrelpart/fmt_filters.cpp b/src/ksquirrelpart/fmt_filters.cpp
new file mode 100644
index 0000000..860cdeb
--- /dev/null
+++ b/src/ksquirrelpart/fmt_filters.cpp
@@ -0,0 +1,2287 @@
+/*
+ * Copyright (c) 2005 Dmitry Baryshev <[email protected]>
+ */
+
+/* This file is part of the KDE libraries
+ Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <[email protected]>
+ (C) 1998, 1999 Christian Tibirna <[email protected]>
+ (C) 1998, 1999 Dirk A. Mueller <[email protected]>
+ (C) 1999 Geert Jansen <[email protected]>
+ (C) 2000 Josef Weidendorfer <[email protected]>
+ (C) 2004 Zack Rusin <[email protected]>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+//
+// ===================================================================
+// Effects originally ported from ImageMagick for PixiePlus, plus a few
+// new ones. (mosfet 05/26/2003)
+// ===================================================================
+//
+/*
+ Portions of this software are based on ImageMagick. Such portions are clearly
+marked as being ported from ImageMagick. ImageMagick is copyrighted under the
+following conditions:
+
+Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to
+making software imaging solutions freely available.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files ("ImageMagick"), to deal
+in ImageMagick without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of ImageMagick, and to permit persons to whom the ImageMagick is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of ImageMagick.
+
+The software is provided "as is", without warranty of any kind, express or
+implied, including but not limited to the warranties of merchantability,
+fitness for a particular purpose and noninfringement. In no event shall
+ImageMagick Studio be liable for any claim, damages or other liability,
+whether in an action of contract, tort or otherwise, arising from, out of or
+in connection with ImageMagick or the use or other dealings in ImageMagick.
+
+Except as contained in this notice, the name of the ImageMagick Studio shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in ImageMagick without prior written authorization from the
+ImageMagick Studio.
+*/
+
+#include "fmt_filters.h"
+
+#include <cmath>
+#include <algorithm>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+namespace fmt_filters
+{
+
+#define MaxRGB 255L
+#define DegreesToRadians(x) ((x)*M_PI/180.0)
+#define MagickSQ2PI 2.50662827463100024161235523934010416269302368164062
+#define MagickEpsilon 1.0e-12
+#define MagickPI 3.14159265358979323846264338327950288419716939937510
+
+#define F_MAX(a, b) ((b) < (a) ? (a) : (b))
+#define F_MIN(a, b) ((a) < (b) ? (a) : (b))
+
+static void rgb2hsv(const fmt_filters::rgb &rgb, s32 *h, s32 *s, s32 *v);
+static void hsv2rgb(s32 h, s32 s, s32 v, fmt_filters::rgb *rgb);
+static fmt_filters::rgba interpolateColor(const fmt_filters::image &image, double x_offset, double y_offset, const fmt_filters::rgba &background);
+static u32 generateNoise(u32 pixel, fmt_filters::NoiseType noise_type);
+static u32 intensityValue(s32 r, s32 g, s32 b);
+static u32 intensityValue(const fmt_filters::rgba &rr);
+static s32 getBlurKernel(s32 width, double sigma, double **kernel);
+static void blurScanLine(double *kernel, s32 width, fmt_filters::rgba *src, fmt_filters::rgba *dest, s32 columns);
+static void hull(const s32 x_offset, const s32 y_offset, const s32 polarity, const s32 columns,
+ const s32 rows, u8 *f, u8 *g);
+static bool convolveImage(fmt_filters::image *image, fmt_filters::rgba **dest, const unsigned int order, const double *kernel);
+static int getOptimalKernelWidth(double radius, double sigma);
+
+template<class T>
+static void scaleDown(T &val, T min, T max);
+
+struct double_packet
+{
+ double red;
+ double green;
+ double blue;
+ double alpha;
+};
+
+struct short_packet
+{
+ unsigned short int red;
+ unsigned short int green;
+ unsigned short int blue;
+ unsigned short int alpha;
+};
+
+bool checkImage(const image &im)
+{
+ return (im.rw && im.rh && im.w && im.h && im.data);
+}
+
+// colorize tool
+void colorize(const image &im, s32 red, s32 green, s32 blue)
+{
+ // check if all parameters are good
+ if(!checkImage(im))
+ return;
+
+ if(!red && !green && !blue)
+ return;
+
+ u8 *bits;
+ s32 val;
+ s32 V[3] = { red, green, blue };
+
+ // add to RED component 'red' value, and check if the result is out of bounds.
+ // do the same with GREEN and BLUE channels.
+ for(s32 y = 0;y < im.h;++y)
+ {
+ bits = im.data + im.rw * y * sizeof(rgba);
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ for(s32 v = 0;v < 3;++v)
+ {
+ val = (s32)*(bits + v) + V[v];
+
+ if(val > 255)
+ *(bits + v) = 255;
+ else if(val < 0)
+ *(bits + v) = 0;
+ else
+ *(bits + v) = val;
+ }
+
+ bits += 4;
+ }
+ }
+}
+
+// brightness tool
+void brightness(const image &im, s32 bn)
+{
+ // check if all parameters are good
+ if(!checkImage(im))
+ return;
+
+ u8 *bits;
+ s32 val;
+
+ // add to all color components 'bn' value, and check if the result is out of bounds.
+ for(s32 y = 0;y < im.h;++y)
+ {
+ bits = im.data + im.rw * y * sizeof(rgba);
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ for(s32 v = 0;v < 3;v++)
+ {
+ val = bn + *bits;
+ *bits = val < 0 ? 0 : (val > 255 ? 255 : val);
+
+ bits++;
+ }
+
+ bits++;
+ }
+ }
+}
+
+// gamma tool
+void gamma(const image &im, double L)
+{
+ // check if all parameters are good
+ if(!checkImage(im))
+ return;
+
+ if(L == 0 || L < 0) L = 0.01;
+
+ rgba *_rgba;
+ u8 R, G, B;
+ u8 GT[256];
+
+ GT[0] = 0;
+
+ // fill the array with gamma koefficients
+ for (s32 x = 1; x < 256; ++x)
+ GT[x] = (u8)round(255 * pow((double)x / 255.0, 1.0 / L));
+
+ // now change gamma
+ for(s32 y = 0;y < im.h;++y)
+ {
+ _rgba = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ R = _rgba[x].r;
+ G = _rgba[x].g;
+ B = _rgba[x].b;
+
+ _rgba[x].r = GT[R];
+ _rgba[x].g = GT[G];
+ _rgba[x].b = GT[B];
+ }
+ }
+}
+
+// contrast tool
+void contrast(const image &im, s32 contrast)
+{
+ if(!checkImage(im) || !contrast)
+ return;
+
+ if(contrast < -255) contrast = -255;
+ if(contrast > 255) contrast = 255;
+
+ rgba *bits;
+ u8 Ravg, Gavg, Bavg;
+ s32 Ra = 0, Ga = 0, Ba = 0, Rn, Gn, Bn;
+
+ // calculate the average values for RED, GREEN and BLUE
+ // color components
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ Ra += bits->r;
+ Ga += bits->g;
+ Ba += bits->b;
+
+ bits++;
+ }
+ }
+
+ s32 S = im.w * im.h;
+
+ Ravg = Ra / S;
+ Gavg = Ga / S;
+ Bavg = Ba / S;
+
+ // ok, now change contrast
+ // with the terms of alghoritm:
+ //
+ // if contrast > 0: I = (I - Avg) * 256 / (256 - contrast) + Avg
+ // if contrast < 0: I = (I - Avg) * (256 + contrast) / 256 + Avg
+ //
+ // where
+ // I - current color component value
+ // Avg - average value of this component (Ravg, Gavg or Bavg)
+ //
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ Rn = (contrast > 0) ? ((bits->r - Ravg) * 256 / (256 - contrast) + Ravg) : ((bits->r - Ravg) * (256 + contrast) / 256 + Ravg);
+ Gn = (contrast > 0) ? ((bits->g - Gavg) * 256 / (256 - contrast) + Gavg) : ((bits->g - Gavg) * (256 + contrast) / 256 + Gavg);
+ Bn = (contrast > 0) ? ((bits->b - Bavg) * 256 / (256 - contrast) + Bavg) : ((bits->b - Bavg) * (256 + contrast) / 256 + Bavg);
+
+ bits->r = Rn < 0 ? 0 : (Rn > 255 ? 255 : Rn);
+ bits->g = Gn < 0 ? 0 : (Gn > 255 ? 255 : Gn);
+ bits->b = Bn < 0 ? 0 : (Bn > 255 ? 255 : Bn);
+
+ bits++;
+ }
+ }
+}
+
+// negative
+void negative(const image &im)
+{
+ // check if all parameters are good
+ if(!checkImage(im))
+ return;
+
+ rgba *bits;
+ u8 R, G, B;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ R = bits->r;
+ G = bits->g;
+ B = bits->b;
+
+ bits->r = 255 - R;
+ bits->g = 255 - G;
+ bits->b = 255 - B;
+
+ bits++;
+ }
+ }
+}
+
+// swap RGB values
+void swapRGB(const image &im, s32 type)
+{
+ // check if all parameters are good
+ if(!checkImage(im) || (type != GBR && type != BRG))
+ return;
+
+ rgba *bits;
+ u8 R, G, B;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ R = bits->r;
+ G = bits->g;
+ B = bits->b;
+
+ bits->r = (type == GBR) ? G : B;
+ bits->g = (type == GBR) ? B : R;
+ bits->b = (type == GBR) ? R : G;
+
+ bits++;
+ }
+ }
+}
+
+// blend
+void blend(const image &im, const rgb &rgb, float opacity)
+{
+ // check parameters
+ if(!checkImage(im))
+ return;
+
+ scaleDown(opacity, 0.0f, 1.0f);
+
+ rgba *bits;
+ s32 r = rgb.r, g = rgb.g, b = rgb.b;
+
+ // blend!
+ for(s32 y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ bits->r = bits->r + (u8)((b - bits->r) * opacity);
+ bits->g = bits->g + (u8)((g - bits->g) * opacity);
+ bits->b = bits->b + (u8)((r - bits->b) * opacity);
+
+ bits++;
+ }
+ }
+}
+
+void flatten(const image &im, const rgb &ca, const rgb &cb)
+{
+ if(!checkImage(im))
+ return;
+
+ s32 r1 = ca.r; s32 r2 = cb.r;
+ s32 g1 = ca.g; s32 g2 = cb.g;
+ s32 b1 = ca.b; s32 b2 = cb.b;
+ s32 min = 0, max = 255;
+ s32 mean;
+
+ rgba *bits;
+ rgb _rgb;
+
+ for(s32 y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;++x)
+ {
+ mean = (bits->r + bits->g + bits->b) / 3;
+ min = F_MIN(min, mean);
+ max = F_MAX(max, mean);
+ bits++;
+ }
+ }
+
+ // Conversion factors
+ float sr = ((float) r2 - r1) / (max - min);
+ float sg = ((float) g2 - g1) / (max - min);
+ float sb = ((float) b2 - b1) / (max - min);
+
+ // Repaint the image
+ for(s32 y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.w*y;
+
+ for(s32 x = 0;x < im.w;++x)
+ {
+ mean = (bits->r + bits->g + bits->b) / 3;
+
+ bits->r = (s32)(sr * (mean - min) + r1 + 0.5);
+ bits->g = (s32)(sg * (mean - min) + g1 + 0.5);
+ bits->b = (s32)(sb * (mean - min) + b1 + 0.5);
+
+ bits++;
+ }
+ }
+}
+
+void fade(const image &im, const rgb &rgb, float val)
+{
+ if(!checkImage(im))
+ return;
+
+ u8 tbl[256];
+
+ for (s32 i = 0;i < 256;i++)
+ tbl[i] = (s32)(val * i + 0.5);
+
+ s32 r, g, b, cr, cg, cb;
+
+ rgba *bits;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ cr = bits->r;
+ cg = bits->g;
+ cb = bits->b;
+
+ r = (cr > rgb.r) ? (cr - tbl[cr - rgb.r]) : (cr + tbl[rgb.r - cr]);
+ g = (cg > rgb.g) ? (cg - tbl[cg - rgb.g]) : (cg + tbl[rgb.g - cg]);
+ b = (cb > rgb.b) ? (cb - tbl[cb - rgb.b]) : (cb + tbl[rgb.b - cb]);
+
+ bits->r = r;
+ bits->g = g;
+ bits->b = b;
+
+ bits++;
+ }
+ }
+}
+
+void gray(const image &im)
+{
+ if(!checkImage(im))
+ return;
+
+ rgba *bits;
+ s32 g;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ g = (bits->r * 11 + bits->g * 16 + bits->b * 5)/32;
+
+ bits->r = g;
+ bits->g = g;
+ bits->b = g;
+
+ bits++;
+ }
+ }
+}
+
+void desaturate(const image &im, float desat)
+{
+ if(!checkImage(im))
+ return;
+
+ scaleDown(desat, 0.0f, 1.0f);
+
+ rgba *bits;
+ s32 h = 0, s = 0, v = 0;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ rgb _rgb(bits->r, bits->g, bits->b);
+ rgb2hsv(_rgb, &h, &s, &v);
+ hsv2rgb(h, (s32)(s * (1.0 - desat)), v, &_rgb);
+
+ bits->r = _rgb.r;
+ bits->g = _rgb.g;
+ bits->b = _rgb.b;
+
+ bits++;
+ }
+ }
+}
+
+void threshold(const image &im, u32 trh)
+{
+ if(!checkImage(im))
+ return;
+
+ scaleDown(trh, (u32)0, (u32)255);
+
+ rgba *bits;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ if(intensityValue(bits->r, bits->g, bits->b) < trh)
+ bits->r = bits->g = bits->b = 0;
+ else
+ bits->r = bits->g = bits->b = 255;
+
+ bits++;
+ }
+ }
+}
+
+void solarize(const image &im, double factor)
+{
+ if(!checkImage(im))
+ return;
+
+ s32 threshold;
+ rgba *bits;
+
+ threshold = (s32)(factor * (MaxRGB+1)/100.0);
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ bits->r = bits->r > threshold ? MaxRGB-bits->r : bits->r;
+ bits->g = bits->g > threshold ? MaxRGB-bits->g : bits->g;
+ bits->b = bits->b > threshold ? MaxRGB-bits->b : bits->b;
+
+ bits++;
+ }
+ }
+}
+
+void spread(const image &im, u32 amount)
+{
+ if(!checkImage(im) || im.w < 3 || im.h < 3)
+ return;
+
+ rgba *n = new rgba [im.rw * im.rh];
+
+ if(!n)
+ return;
+
+ s32 quantum;
+ s32 x_distance, y_distance;
+ rgba *bits = (rgba *)im.data, *q;
+
+ memcpy(n, im.data, im.rw * im.rh * sizeof(rgba));
+
+ quantum = (amount+1) >> 1;
+
+ for(s32 y = 0;y < im.h;y++)
+ {
+ q = n + im.rw*y;
+
+ for(s32 x = 0;x < im.w;x++)
+ {
+ x_distance = x + ((rand() & (amount+1))-quantum);
+ y_distance = y + ((rand() & (amount+1))-quantum);
+ x_distance = F_MIN(x_distance, im.w-1);
+ y_distance = F_MIN(y_distance, im.h-1);
+
+ if(x_distance < 0) x_distance = 0;
+ if(y_distance < 0) y_distance = 0;
+
+ *q++ = *(bits + y_distance*im.rw + x_distance);
+ }
+ }
+
+ memcpy(im.data, n, im.rw * im.rh * sizeof(rgba));
+
+ delete [] n;
+}
+
+void swirl(const image &im, double degrees, const rgba &background)
+{
+ if(!checkImage(im))
+ return;
+
+ double cosine, distance, factor, radius, sine, x_center, x_distance,
+ x_scale, y_center, y_distance, y_scale;
+ s32 x, y;
+
+ rgba *q, *p;
+ rgba *bits = (rgba *)im.data;
+ rgba *dest = new rgba [im.rw * im.rh];
+
+ if(!dest)
+ return;
+
+ memcpy(dest, im.data, im.rw * im.rh * sizeof(rgba));
+
+ // compute scaling factor
+ x_center = im.w / 2.0;
+ y_center = im.h / 2.0;
+
+ radius = F_MAX(x_center, y_center);
+ x_scale=1.0;
+ y_scale=1.0;
+
+ if(im.w > im.h)
+ y_scale=(double)im.w / im.h;
+ else if(im.w < im.h)
+ x_scale=(double)im.h / im.w;
+
+ degrees = DegreesToRadians(degrees);
+
+ // swirl each row
+
+ for(y = 0;y < im.h;y++)
+ {
+ p = bits + im.rw * y;
+ q = dest + im.rw * y;
+ y_distance = y_scale * (y-y_center);
+
+ for(x = 0;x < im.w;x++)
+ {
+ // determine if the pixel is within an ellipse
+ *q = *p;
+ x_distance = x_scale*(x-x_center);
+ distance = x_distance*x_distance+y_distance*y_distance;
+
+ if(distance < (radius*radius))
+ {
+ // swirl
+ factor = 1.0 - sqrt(distance)/radius;
+ sine = sin(degrees*factor*factor);
+ cosine = cos(degrees*factor*factor);
+
+ *q = interpolateColor(im,
+ (cosine*x_distance-sine*y_distance)/x_scale+x_center,
+ (sine*x_distance+cosine*y_distance)/y_scale+y_center,
+ background);
+ }
+
+ p++;
+ q++;
+ }
+ }
+
+ memcpy(im.data, dest, im.rw * im.rh * sizeof(rgba));
+
+ delete [] dest;
+}
+
+void noise(const image &im, NoiseType noise_type)
+{
+ if(!checkImage(im))
+ return;
+
+ s32 x, y;
+ rgba *dest = new rgba [im.rw * im.rh];
+
+ if(!dest)
+ return;
+
+ rgba *bits;
+ rgba *destData;
+
+ for(y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+ destData = dest + im.rw * y;
+
+ for(x = 0;x < im.w;++x)
+ {
+ destData[x].r = generateNoise(bits->r, noise_type);
+ destData[x].g = generateNoise(bits->g, noise_type);
+ destData[x].b = generateNoise(bits->b, noise_type);
+ destData[x].a = bits->a;
+
+ bits++;
+ }
+ }
+
+ memcpy(im.data, dest, im.rw * im.rh * sizeof(rgba));
+
+ delete [] dest;
+}
+
+void implode(const image &im, double _factor, const rgba &background)
+{
+ if(!checkImage(im))
+ return;
+
+ double amount, distance, radius;
+ double x_center, x_distance, x_scale;
+ double y_center, y_distance, y_scale;
+ rgba *dest;
+ s32 x, y;
+
+ rgba *n = new rgba [im.rw * im.rh];
+
+ if(!n)
+ return;
+
+ rgba *bits;
+
+ // compute scaling factor
+ x_scale = 1.0;
+ y_scale = 1.0;
+ x_center = (double)0.5*im.w;
+ y_center = (double)0.5*im.h;
+ radius=x_center;
+
+ if(im.w > im.h)
+ y_scale = (double)im.w/im.h;
+ else if(im.w < im.h)
+ {
+ x_scale = (double)im.h/im.w;
+ radius = y_center;
+ }
+
+ amount=_factor/10.0;
+
+ if(amount >= 0)
+ amount/=10.0;
+
+ double factor;
+
+ for(y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.rw * y;
+ dest = n + im.rw * y;
+
+ y_distance = y_scale * (y-y_center);
+
+ for(x = 0;x < im.w;++x)
+ {
+ x_distance = x_scale*(x-x_center);
+ distance= x_distance*x_distance+y_distance*y_distance;
+
+ if(distance < (radius*radius))
+ {
+ // Implode the pixel.
+ factor = 1.0;
+
+ if(distance > 0.0)
+ factor = pow(sin(0.5000000000000001*M_PI*sqrt(distance)/radius),-amount);
+
+ *dest = interpolateColor(im, factor*x_distance/x_scale+x_center,
+ factor*y_distance/y_scale+y_center,
+ background);
+ }
+ else
+ *dest = *bits;
+
+ bits++;
+ dest++;
+ }
+ }
+
+ memcpy(im.data, n, im.rw * im.rh * sizeof(rgba));
+
+ delete [] n;
+}
+
+void despeckle(const image &im)
+{
+ if(!checkImage(im))
+ return;
+
+ s32 i, j, x, y;
+ u8 *blue_channel, *red_channel, *green_channel, *buffer, *alpha_channel;
+ s32 packets;
+
+ static const s32
+ X[4] = {0, 1, 1,-1},
+ Y[4] = {1, 0, 1, 1};
+
+ rgba *n = new rgba [im.rw * im.rh];
+
+ if(!n)
+ return;
+
+ packets = (im.w+2) * (im.h+2);
+
+ red_channel = new u8 [packets];
+ green_channel = new u8 [packets];
+ blue_channel = new u8 [packets];
+ alpha_channel = new u8 [packets];
+ buffer = new u8 [packets];
+
+ if(!red_channel || ! green_channel || ! blue_channel || ! alpha_channel || !buffer)
+ {
+ if(red_channel) delete [] red_channel;
+ if(green_channel) delete [] green_channel;
+ if(blue_channel) delete [] blue_channel;
+ if(alpha_channel) delete [] alpha_channel;
+ if(buffer) delete [] buffer;
+
+ delete [] n;
+
+ return;
+ }
+
+ // copy image pixels to color component buffers
+ j = im.w+2;
+
+ rgba *bits;
+
+ for(y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.rw*y;
+ ++j;
+
+ for(x = 0;x < im.w;++x)
+ {
+ red_channel[j] = bits->r;
+ green_channel[j] = bits->g;
+ blue_channel[j] = bits->b;
+ alpha_channel[j] = bits->a;
+
+ bits++;
+ ++j;
+ }
+
+ ++j;
+ }
+
+ // reduce speckle in red channel
+ for(i = 0;i < 4;i++)
+ {
+ hull(X[i],Y[i],1,im.w,im.h,red_channel,buffer);
+ hull(-X[i],-Y[i],1,im.w,im.h,red_channel,buffer);
+ hull(-X[i],-Y[i],-1,im.w,im.h,red_channel,buffer);
+ hull(X[i],Y[i],-1,im.w,im.h,red_channel,buffer);
+ }
+
+ // reduce speckle in green channel
+ for(i = 0;i < packets;i++)
+ buffer[i] = 0;
+
+ for(i = 0;i < 4;i++)
+ {
+ hull(X[i],Y[i],1,im.w,im.h,green_channel,buffer);
+ hull(-X[i],-Y[i],1,im.w,im.h,green_channel,buffer);
+ hull(-X[i],-Y[i],-1,im.w,im.h,green_channel,buffer);
+ hull(X[i],Y[i],-1,im.w,im.h,green_channel,buffer);
+ }
+
+ // reduce speckle in blue channel
+ for(i = 0;i < packets;i++)
+ buffer[i] = 0;
+
+ for(i = 0;i < 4;i++)
+ {
+ hull(X[i],Y[i],1,im.w,im.h,blue_channel,buffer);
+ hull(-X[i],-Y[i],1,im.w,im.h,blue_channel,buffer);
+ hull(-X[i],-Y[i],-1,im.w,im.h,blue_channel,buffer);
+ hull(X[i],Y[i],-1,im.w,im.h,blue_channel,buffer);
+ }
+
+ // copy color component buffers to despeckled image
+ j = im.w+2;
+
+ for(y = 0;y < im.h;++y)
+ {
+ bits = n + im.rw*y;
+ ++j;
+
+ for(x = 0;x < im.w;++x)
+ {
+ *bits = rgba(red_channel[j], green_channel[j], blue_channel[j], alpha_channel[j]);
+
+ bits++;
+ ++j;
+ }
+
+ ++j;
+ }
+
+ delete [] buffer;
+ delete [] red_channel;
+ delete [] green_channel;
+ delete [] blue_channel;
+ delete [] alpha_channel;
+
+ memcpy(im.data, n, im.rw * im.rh * sizeof(rgba));
+
+ delete [] n;
+}
+
+void blur(const image &im, double radius, double sigma)
+{
+ if(!checkImage(im))
+ return;
+
+ double *kernel;
+ rgba *dest;
+ s32 width;
+ s32 x, y;
+ rgba *scanline, *temp;
+ rgba *p, *q;
+
+ if(sigma == 0.0)
+ return;
+
+ kernel = 0;
+
+ if(radius > 0)
+ width = getBlurKernel((s32)(2*ceil(radius)+1), sigma, &kernel);
+ else
+ {
+ double *last_kernel = 0;
+
+ width = getBlurKernel(3, sigma, &kernel);
+
+ while((long)(MaxRGB * kernel[0]) > 0)
+ {
+ if(last_kernel)
+ delete [] last_kernel;
+
+ last_kernel = kernel;
+ kernel = 0;
+
+ width = getBlurKernel(width+2, sigma, &kernel);
+ }
+
+ if(last_kernel)
+ {
+ delete [] kernel;
+ width -= 2;
+ kernel = last_kernel;
+ }
+ }
+
+ if(width < 3)
+ {
+ delete [] kernel;
+ return;
+ }
+
+ dest = new rgba [im.rw * im.rh];
+
+ if(!dest)
+ {
+ delete [] kernel;
+ return;
+ }
+
+ scanline = new rgba [im.h];
+ temp = new rgba [im.h];
+
+ if(!scanline || !temp)
+ {
+ if(scanline) delete [] scanline;
+ if(temp) delete [] temp;
+
+ delete [] kernel;
+ return;
+ }
+
+ rgba *bits = (rgba *)im.data;
+
+ for(y = 0;y < im.h;++y)
+ {
+ p = bits + im.rw*y;
+ q = dest + im.rw*y;
+
+ blurScanLine(kernel, width, p, q, im.w);
+ }
+
+ for(x = 0;x < im.w;++x)
+ {
+ for(y = 0;y < im.h;++y)
+ scanline[y] = *(bits + im.rw*y + x);
+
+ blurScanLine(kernel, width, scanline, temp, im.h);
+
+ for(y = 0;y < im.h;++y)
+ *(dest + im.rw*y + x) = temp[y];
+
+ }
+
+ delete [] scanline;
+ delete [] temp;
+ delete [] kernel;
+
+ memcpy(im.data, dest, im.rw * im.rh * sizeof(rgba));
+
+ delete [] dest;
+}
+
+void equalize(const image &im)
+{
+ if(!checkImage(im))
+ return;
+
+ double_packet high, low, intensity, *map, *histogram;
+ short_packet *equalize_map;
+ s32 x, y;
+ rgba *p, *q;
+ long i;
+ u8 r, g, b, a;
+
+ histogram = new double_packet [256];
+ map = new double_packet [256];
+ equalize_map = new short_packet [256];
+
+ if(!histogram || !map || !equalize_map)
+ {
+ if(histogram) delete [] histogram;
+ if(map) delete [] map;
+ if(equalize_map) delete [] equalize_map;
+
+ return;
+ }
+
+ rgba *bits = (rgba *)im.data;
+
+ /*
+ * Form histogram.
+ */
+ memset(histogram, 0, 256 * sizeof(double_packet));
+
+ for(y = 0;y < im.h;++y)
+ {
+ p = bits + im.rw * y;
+
+ for(x = 0;x < im.w;++x)
+ {
+ histogram[p->r].red++;
+ histogram[p->g].green++;
+ histogram[p->b].blue++;
+ histogram[p->a].alpha++;
+
+ p++;
+ }
+ }
+ /*
+ Integrate the histogram to get the equalization map.
+ */
+ memset(&intensity, 0 ,sizeof(double_packet));
+
+ for(i = 0;i < 256;++i)
+ {
+ intensity.red += histogram[i].red;
+ intensity.green += histogram[i].green;
+ intensity.blue += histogram[i].blue;
+ intensity.alpha += histogram[i].alpha;
+
+ map[i] = intensity;
+ }
+
+ low=map[0];
+ high=map[255];
+ memset(equalize_map, 0, 256 * sizeof(short_packet));
+
+ for(i = 0;i < 256;++i)
+ {
+ if(high.red != low.red)
+ equalize_map[i].red=(unsigned short)
+ ((65535*(map[i].red-low.red))/(high.red-low.red));
+ if(high.green != low.green)
+ equalize_map[i].green=(unsigned short)
+ ((65535*(map[i].green-low.green))/(high.green-low.green));
+ if(high.blue != low.blue)
+ equalize_map[i].blue=(unsigned short)
+ ((65535*(map[i].blue-low.blue))/(high.blue-low.blue));
+ if(high.alpha != low.alpha)
+ equalize_map[i].alpha=(unsigned short)
+ ((65535*(map[i].alpha-low.alpha))/(high.alpha-low.alpha));
+ }
+
+ delete [] histogram;
+ delete [] map;
+
+ /*
+ Stretch the histogram.
+ */
+ for(y = 0;y < im.h;++y)
+ {
+ q = bits + im.rw*y;
+
+ for(x = 0;x < im.w;++x)
+ {
+ if(low.red != high.red)
+ r = (equalize_map[(unsigned short)(q->r)].red/257);
+ else
+ r = q->r;
+ if(low.green != high.green)
+ g = (equalize_map[(unsigned short)(q->g)].green/257);
+ else
+ g = q->g;
+ if(low.blue != high.blue)
+ b = (equalize_map[(unsigned short)(q->b)].blue/257);
+ else
+ b = q->b;
+ if(low.alpha != high.alpha)
+ a = (equalize_map[(unsigned short)(q->a)].alpha/257);
+ else
+ a = q->a;
+
+ *q = rgba(r, g, b, a);
+
+ q++;
+ }
+ }
+
+ delete [] equalize_map;
+}
+
+struct PointInfo
+{
+ double x, y, z;
+};
+
+void shade(const image &im, bool color_shading, double azimuth,
+ double elevation)
+{
+ if(!checkImage(im))
+ return;
+
+ rgba *n = new rgba [im.rw * im.rh];
+
+ if(!n)
+ return;
+
+ double distance, normal_distance, shade;
+ s32 x, y;
+
+ struct PointInfo light, normal;
+
+ rgba *bits;
+ rgba *q;
+
+ azimuth = DegreesToRadians(azimuth);
+ elevation = DegreesToRadians(elevation);
+ light.x = MaxRGB*cos(azimuth)*cos(elevation);
+ light.y = MaxRGB*sin(azimuth)*cos(elevation);
+ light.z = MaxRGB*sin(elevation);
+ normal.z= 2*MaxRGB; // constant Z of surface normal
+
+ rgba *s0, *s1, *s2;
+
+ for(y = 0;y < im.h;++y)
+ {
+ bits = (rgba *)im.data + im.rw * (F_MIN(F_MAX(y-1,0),im.h-3));
+ q = n + im.rw * y;
+
+ // shade this row of pixels.
+ *q++ = (*(bits+im.rw));
+ bits++;
+
+ s0 = bits;
+ s1 = bits + im.rw;
+ s2 = bits + 2*im.rw;
+
+ for(x = 1;x < im.w-1;++x)
+ {
+ // determine the surface normal and compute shading.
+ normal.x = intensityValue(*(s0-1))+intensityValue(*(s1-1))+intensityValue(*(s2-1))-
+ (double) intensityValue(*(s0+1))-(double) intensityValue(*(s1+1))-
+ (double) intensityValue(*(s2+1));
+
+ normal.y = intensityValue(*(s2-1))+intensityValue(*s2)+intensityValue(*(s2+1))-
+ (double) intensityValue(*(s0-1))-(double) intensityValue(*s0)-
+ (double) intensityValue(*(s0+1));
+
+ if(normal.x == 0 && normal.y == 0)
+ shade = light.z;
+ else
+ {
+ shade = 0.0;
+ distance = normal.x*light.x+normal.y*light.y+normal.z*light.z;
+
+ if(distance > 0.0)
+ {
+ normal_distance = normal.x*normal.x+normal.y*normal.y+normal.z*normal.z;
+
+ if(fabs(normal_distance) > 0.0000001)
+ shade=distance/sqrt(normal_distance);
+ }
+ }
+
+ if(!color_shading)
+ {
+ *q = rgba((u8)(shade),
+ (u8)(shade),
+ (u8)(shade),
+ s1->a);
+ }
+ else
+ {
+ *q = rgba((u8)((shade * s1->r)/(MaxRGB+1)),
+ (u8)((shade * s1->g)/(MaxRGB+1)),
+ (u8)((shade * s1->b)/(MaxRGB+1)),
+ s1->a);
+ }
+
+ ++s0;
+ ++s1;
+ ++s2;
+ q++;
+ }
+
+ *q++ = (*s1);
+ }
+
+ memcpy(im.data, n, im.rw * im.rh * sizeof(rgba));
+
+ delete [] n;
+}
+
+void edge(image &im, double radius)
+{
+ if(!checkImage(im))
+ return;
+
+ double *kernel;
+ int width;
+ long i;
+ rgba *dest = 0;
+
+ width = getOptimalKernelWidth(radius, 0.5);
+
+ const int W = width*width;
+
+ if(im.w < width || im.h < width)
+ return;
+
+ kernel = new double [W];
+
+ if(!kernel)
+ return;
+
+ for(i = 0;i < W;i++)
+ kernel[i] = -1.0;
+
+ kernel[i/2] = W-1.0;
+
+ if(!convolveImage(&im, &dest, width, kernel))
+ {
+ delete [] kernel;
+
+ if(dest)
+ delete [] dest;
+
+ return;
+ }
+
+ delete [] kernel;
+
+ memcpy(im.data, dest, im.rw * im.rh * sizeof(rgba));
+
+ delete [] dest;
+}
+
+void emboss(image &im, double radius, double sigma)
+{
+ if(!checkImage(im))
+ return;
+
+ double alpha, *kernel;
+ int j, width;
+ long i, u, v;
+ rgba *dest = 0;
+
+ if(sigma == 0.0)
+ return;
+
+ width = getOptimalKernelWidth(radius, sigma);
+
+ if(im.w < width || im.h < width)
+ return;
+
+ kernel = new double [width*width];
+
+ if(!kernel)
+ return;
+
+ i = 0;
+ j = width/2;
+
+ const double S = sigma * sigma;
+
+ for(v = (-width/2);v <= (width/2);v++)
+ {
+ for(u=(-width/2); u <= (width/2); u++)
+ {
+ alpha = exp(-((double) u*u+v*v)/(2.0*S));
+
+ kernel[i] = ((u < 0) || (v < 0) ? -8.0 : 8.0)*alpha/(2.0*MagickPI*S);
+
+ if (u == j)
+ kernel[i]=0.0;
+
+ i++;
+ }
+
+ j--;
+ }
+
+ if(!convolveImage(&im, &dest, width, kernel))
+ {
+ delete [] kernel;
+ return;
+ }
+
+ delete [] kernel;
+
+ fmt_filters::image mm((u8 *)dest, im.w, im.h, im.rw, im.rh);
+
+ equalize(mm);
+
+ memcpy(im.data, dest, im.rw * im.rh * sizeof(rgba));
+
+ delete [] dest;
+}
+
+void sharpen(image &im, double radius, double sigma)
+{
+ if(!checkImage(im))
+ return;
+
+ double alpha, normalize, *kernel;
+ int width;
+ long i, u, v;
+ rgba *dest = 0;
+
+ if(sigma == 0.0)
+ sigma = 0.01;
+
+ width = getOptimalKernelWidth(radius, sigma);
+
+ if(im.w < width)
+ return;
+
+ kernel = new double [width*width];
+
+ if(!kernel)
+ return;
+
+ i = 0;
+ normalize = 0.0;
+ const double S = sigma * sigma;
+ const int w2 = width / 2;
+
+ for(v = -w2; v <= w2; v++)
+ {
+ for(u = -w2; u <= w2; u++)
+ {
+ alpha = exp(-((double) u*u+v*v)/(2.0*S));
+ kernel[i] = alpha/(2.0*MagickPI*S);
+ normalize += kernel[i];
+
+ i++;
+ }
+ }
+
+ kernel[i/2] = (-2.0)*normalize;
+
+ if(!convolveImage(&im, &dest, width, kernel))
+ {
+ delete [] kernel;
+
+ if(dest)
+ delete [] dest;
+
+ return;
+ }
+
+ delete [] kernel;
+
+ memcpy(im.data, dest, im.rw * im.rh * sizeof(rgba));
+
+ delete [] dest;
+}
+
+void oil(const image &im, double radius)
+{
+ if(!checkImage(im))
+ return;
+
+ unsigned long count;
+ unsigned long histogram[256];
+ unsigned int k;
+ int width;
+ int x, y, mx, my, sx, sy;
+ int mcx, mcy;
+ rgba *s = 0, *q;
+
+ scaleDown(radius, 1.0, 5.0);
+
+ rgba *n = new rgba [im.rw * im.rh];
+
+ if(!n)
+ return;
+
+ memcpy(n, im.data, im.rw * im.rh * sizeof(rgba));
+
+ width = getOptimalKernelWidth(radius, 0.5);
+
+ if(im.w < width)
+ {
+ delete [] n;
+ return;
+ }
+
+ rgba *bits = (rgba *)im.data;
+
+ for(y = 0;y < im.h;++y)
+ {
+ sy = y-(width/2);
+ q = n + im.rw*y;
+
+ for(x = 0;x < im.w;++x)
+ {
+ count = 0;
+ memset(histogram, 0, 256 * sizeof(unsigned long));
+ sy = y-(width/2);
+
+ for(mcy = 0;mcy < width;++mcy,++sy)
+ {
+ my = sy < 0 ? 0 : sy > im.h-1 ? im.h-1 : sy;
+ sx = x+(-width/2);
+
+ for(mcx = 0; mcx < width;++mcx,++sx)
+ {
+ mx = sx < 0 ? 0 : sx > im.w-1 ? im.w-1 : sx;
+
+ k = intensityValue(*(bits + my*im.rw + mx));
+
+ if(k > 255) k = 255;
+
+ histogram[k]++;
+
+ if(histogram[k] > count)
+ {
+ count = histogram[k];
+ s = bits + my*im.rw + mx;
+ }
+ }
+ }
+
+ *q++ = (*s);
+ }
+ }
+
+ memcpy(im.data, n, im.rw * im.rh * sizeof(rgba));
+
+ delete [] n;
+}
+/*
+ * Red-eye removal was taken from "redeye" plugin for GIMP
+ */
+
+/* redeye.c: redeye remover plugin code
+ *
+ * Copyright (C) 2004 Robert Merkel <[email protected]> (the "Author").
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Author of the
+ * Software shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Author.
+1;3B */
+
+void redeye(const image &im, const int w, const int h, const int x, const int y, int th)
+{
+ const double RED_FACTOR = 0.5133333;
+ const double GREEN_FACTOR = 1;
+ const double BLUE_FACTOR = 0.1933333;
+
+ if(!checkImage(im))
+ return;
+
+ scaleDown(th, 0, 255);
+
+ int y1, x1;
+ int adjusted_red, adjusted_green, adjusted_blue;
+
+ rgba *src = (rgba *)im.data, *s;
+
+ for(y1 = y;y1 < y+h;++y1)
+ {
+ s = src + im.w*y1 + x;
+
+ for(x1 = x;x1 < x+w;x1++)
+ {
+ adjusted_red = int(s->r * RED_FACTOR);
+ adjusted_green = int(s->g * GREEN_FACTOR);
+ adjusted_blue = int(s->b * BLUE_FACTOR);
+
+ if(adjusted_red >= adjusted_green - th && adjusted_red >= adjusted_blue - th)
+ s->r = (int)(((double)(adjusted_green + adjusted_blue)) / (2.0 * RED_FACTOR));
+
+ s++;
+ }
+ }
+}
+
+
+/*************************************************************************/
+
+/*
+ *
+ * Helper functions
+ *
+ */
+
+/*************************************************************************/
+
+static bool convolveImage(image *image, rgba **dest, const unsigned int order,
+ const double *kernel)
+{
+ long width;
+ double red, green, blue;
+ u8 alpha;
+ double normalize, *normal_kernel;
+ const double *k;
+ rgba *q;
+ int x, y, mx, my, sx, sy;
+ long i;
+ int mcx, mcy;
+
+ width = order;
+
+ if((width % 2) == 0)
+ return false;
+
+ const int W = width*width;
+
+ normal_kernel = new double [W];
+
+ if(!normal_kernel)
+ return false;
+
+ *dest = new rgba [image->rw * image->rh];
+
+ if(!*dest)
+ {
+ delete [] normal_kernel;
+ return false;
+ }
+
+ normalize = 0.0;
+
+ for(i = 0;i < W;i++)
+ normalize += kernel[i];
+
+ if(fabs(normalize) <= MagickEpsilon)
+ normalize = 1.0;
+
+ normalize=1.0/normalize;
+
+ for(i = 0;i < W;i++)
+ normal_kernel[i] = normalize*kernel[i];
+
+ rgba *bits = (rgba *)image->data;
+
+ for(y = 0;y < image->h;++y)
+ {
+ sy = y-(width/2);
+ q = *dest + image->rw * y;
+
+ for(x = 0;x < image->w;++x)
+ {
+ k = normal_kernel;
+ red = green = blue = alpha = 0;
+ sy = y-(width/2);
+ alpha = (bits + image->rw*y+x)->a;
+
+ for(mcy=0; mcy < width; ++mcy, ++sy)
+ {
+ my = sy < 0 ? 0 : sy > image->h-1 ? image->h-1 : sy;
+ sx = x+(-width/2);
+
+ for(mcx=0; mcx < width; ++mcx, ++sx)
+ {
+ mx = sx < 0 ? 0 : sx > image->w-1 ? image->w-1 : sx;
+ red += (*k) * ((bits + image->rw*my+mx)->r*257);
+ green += (*k) * ((bits + image->rw*my+mx)->g*257);
+ blue += (*k) * ((bits + image->rw*my+mx)->b*257);
+// alpha += (*k) * ((bits + image->rw*my+mx)->a*257);
+
+ ++k;
+ }
+ }
+
+ red = red < 0 ? 0 : red > 65535 ? 65535 : red+0.5;
+ green = green < 0 ? 0 : green > 65535 ? 65535 : green+0.5;
+ blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue+0.5;
+// alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha+0.5;
+
+ *q++ = rgba((unsigned char)(red/257UL),
+ (unsigned char)(green/257UL),
+ (unsigned char)(blue/257UL),
+ alpha);
+ }
+ }
+
+ delete [] normal_kernel;
+
+ return true;
+}
+
+static void rgb2hsv(const rgb &rgb, s32 *h, s32 *s, s32 *v)
+{
+ if(!h || !s || !v)
+ return;
+
+ s32 r = rgb.r;
+ s32 g = rgb.g;
+ s32 b = rgb.b;
+
+ u32 max = r;
+ s32 whatmax = 0; // r=>0, g=>1, b=>2
+
+ if((u32)g > max)
+ {
+ max = g;
+ whatmax = 1;
+ }
+
+ if((u32)b > max)
+ {
+ max = b;
+ whatmax = 2;
+ }
+
+ u32 min = r; // find minimum value
+ if((u32)g < min) min = g;
+ if((u32)b < min) min = b;
+
+ s32 delta = max-min;
+ *v = max; // calc value
+ *s = max ? (510*delta+max)/(2*max) : 0;
+
+ if(*s == 0)
+ {
+ *h = -1; // undefined hue
+ }
+ else
+ {
+ switch(whatmax)
+ {
+ case 0: // red is max component
+ if(g >= b)
+ *h = (120*(g-b)+delta)/(2*delta);
+ else
+ *h = (120*(g-b+delta)+delta)/(2*delta) + 300;
+ break;
+
+ case 1: // green is max component
+ if(b > r)
+ *h = 120 + (120*(b-r)+delta)/(2*delta);
+ else
+ *h = 60 + (120*(b-r+delta)+delta)/(2*delta);
+ break;
+
+ case 2: // blue is max component
+ if(r > g)
+ *h = 240 + (120*(r-g)+delta)/(2*delta);
+ else
+ *h = 180 + (120*(r-g+delta)+delta)/(2*delta);
+ break;
+ }
+ }
+}
+
+static void hsv2rgb(s32 h, s32 s, s32 v, rgb *rgb)
+{
+ if(h < -1 || (u32)s > 255 || (u32)v > 255 || !rgb)
+ return;
+
+ s32 r = v, g = v, b = v;
+
+ if(s == 0 || h == -1)
+ {
+ // Ignore
+ }
+ else
+ { // chromatic case
+ if((u32)h >= 360)
+ h %= 360;
+
+ u32 f = h%60;
+ h /= 60;
+ u32 p = (u32)(2*v*(255-s)+255)/510;
+ u32 q, t;
+
+ if(h&1)
+ {
+ q = (u32)(2*v*(15300-s*f)+15300)/30600;
+
+ switch(h)
+ {
+ case 1: r=(s32)q; g=(s32)v, b=(s32)p; break;
+ case 3: r=(s32)p; g=(s32)q, b=(s32)v; break;
+ case 5: r=(s32)v; g=(s32)p, b=(s32)q; break;
+ }
+ }
+ else
+ {
+ t = (u32)(2*v*(15300-(s*(60-f)))+15300)/30600;
+
+ switch(h)
+ {
+ case 0: r=(s32)v; g=(s32)t, b=(s32)p; break;
+ case 2: r=(s32)p; g=(s32)v, b=(s32)t; break;
+ case 4: r=(s32)t; g=(s32)p, b=(s32)v; break;
+ }
+ }
+ }
+
+ rgb->r = r;
+ rgb->g = g;
+ rgb->b = b;
+}
+
+static rgba interpolateColor(const image &im, double x_offset, double y_offset, const rgba &background)
+{
+ double alpha, beta;
+ rgba p, q, r, s;
+ s32 x, y;
+ rgba *bits = (rgba *)im.data;
+
+ if(!checkImage(im))
+ return background;
+
+ x = (s32)x_offset;
+ y = (s32)y_offset;
+
+ if((x < -1) || (x >= im.w) || (y < -1) || (y >= im.h))
+ return background;
+
+ if((x >= 0) && (y >= 0) && (x < (im.w-1)) && (y < (im.h-1)))
+ {
+ rgba *t = bits + y * im.rw;
+
+ p = t[x];
+ q = t[x+1];
+ r = t[x+im.rw];
+ s = t[x+im.rw+1];
+ }
+ else
+ {
+ rgba *t = bits + y * im.rw;
+
+ p = background;
+
+ if((x >= 0) && (y >= 0))
+ p = t[x];
+
+ q = background;
+
+ if(((x+1) < im.w) && (y >= 0))
+ q = t[x+1];
+
+ r = background;
+
+ if((x >= 0) && ((y+1) < im.h))
+ {
+ t = bits + (y+1) * im.rw;
+ r = t[x+im.rw];
+ }
+
+ s = background;
+
+ if(((x+1) < im.w) && ((y+1) < im.h))
+ {
+ t = bits + (y+1) * im.rw;
+ s = t[x+im.rw+1];
+ }
+ }
+
+ x_offset -= floor(x_offset);
+ y_offset -= floor(y_offset);
+ alpha = 1.0-x_offset;
+ beta = 1.0-y_offset;
+
+ rgba _r;
+
+ _r.r = (u8)(beta * (alpha*p.r + x_offset*q.r) + y_offset * (alpha*r.r + x_offset*s.r));
+ _r.g = (u8)(beta * (alpha*p.g + x_offset*q.g) + y_offset * (alpha*r.g + x_offset*s.g));
+ _r.b = (u8)(beta * (alpha*p.b + x_offset*q.b) + y_offset * (alpha*r.b + x_offset*s.b));
+ _r.a = (u8)(beta * (alpha*p.a + x_offset*q.a) + y_offset * (alpha*r.a + x_offset*s.a));
+
+ return _r;
+}
+
+static u32 generateNoise(u32 pixel, NoiseType noise_type)
+{
+#define NoiseEpsilon 1.0e-5
+#define NoiseMask 0x7fff
+#define SigmaUniform 4.0
+#define SigmaGaussian 4.0
+#define SigmaImpulse 0.10
+#define SigmaLaplacian 10.0
+#define SigmaMultiplicativeGaussian 0.5
+#define SigmaPoisson 0.05
+#define TauGaussian 20.0
+
+ double alpha, beta, sigma, value;
+ alpha=(double) (rand() & NoiseMask)/NoiseMask;
+ if (alpha == 0.0)
+ alpha=1.0;
+ switch(noise_type){
+ case UniformNoise:
+ default:
+ {
+ value=(double) pixel+SigmaUniform*(alpha-0.5);
+ break;
+ }
+ case GaussianNoise:
+ {
+ double tau;
+
+ beta=(double) (rand() & NoiseMask)/NoiseMask;
+ sigma=sqrt(-2.0*log(alpha))*cos(2.0*M_PI*beta);
+ tau=sqrt(-2.0*log(alpha))*sin(2.0*M_PI*beta);
+ value=(double) pixel+
+ (sqrt((double) pixel)*SigmaGaussian*sigma)+(TauGaussian*tau);
+ break;
+ }
+ case MultiplicativeGaussianNoise:
+ {
+ if (alpha <= NoiseEpsilon)
+ sigma=MaxRGB;
+ else
+ sigma=sqrt(-2.0*log(alpha));
+ beta=(rand() & NoiseMask)/NoiseMask;
+ value=(double) pixel+
+ pixel*SigmaMultiplicativeGaussian*sigma*cos(2.0*M_PI*beta);
+ break;
+ }
+ case ImpulseNoise:
+ {
+ if (alpha < (SigmaImpulse/2.0))
+ value=0;
+ else
+ if (alpha >= (1.0-(SigmaImpulse/2.0)))
+ value=MaxRGB;
+ else
+ value=pixel;
+ break;
+ }
+ case LaplacianNoise:
+ {
+ if (alpha <= 0.5)
+ {
+ if (alpha <= NoiseEpsilon)
+ value=(double) pixel-MaxRGB;
+ else
+ value=(double) pixel+SigmaLaplacian*log(2.0*alpha);
+ break;
+ }
+ beta=1.0-alpha;
+ if (beta <= (0.5*NoiseEpsilon))
+ value=(double) pixel+MaxRGB;
+ else
+ value=(double) pixel-SigmaLaplacian*log(2.0*beta);
+ break;
+ }
+ case PoissonNoise:
+ {
+ s32
+ i;
+
+ for (i=0; alpha > exp(-SigmaPoisson*pixel); i++)
+ {
+ beta=(double) (rand() & NoiseMask)/NoiseMask;
+ alpha=alpha*beta;
+ }
+ value=i/SigmaPoisson;
+ break;
+ }
+ }
+
+ if(value < 0.0)
+ return 0;
+ else if(value > MaxRGB)
+ return MaxRGB;
+ else
+ return ((u32) (value+0.5));
+}
+
+static inline u32 intensityValue(s32 r, s32 g, s32 b)
+{
+ return ((u32)((0.299*r + 0.587*g + 0.1140000000000001*b)));
+}
+
+static inline u32 intensityValue(const rgba &rr)
+{
+ return ((u32)((0.299*rr.r + 0.587*rr.g + 0.1140000000000001*rr.b)));
+}
+
+template<class T>
+static inline void scaleDown(T &val, T min, T max)
+{
+ if(val < min)
+ val = min;
+ else if(val > max)
+ val = max;
+}
+
+static void blurScanLine(double *kernel, s32 width, rgba *src, rgba *dest, s32 columns)
+{
+ double *p;
+ rgba *q;
+ s32 x;
+ long i;
+ double red, green, blue, alpha;
+ double scale = 0.0;
+
+ if(width > columns)
+ {
+ for(x = 0;x < columns;++x)
+ {
+ scale = 0.0;
+ red = blue = green = alpha = 0.0;
+ p = kernel;
+ q = src;
+
+ for(i = 0;i < columns;++i)
+ {
+ if((i >= (x-width/2)) && (i <= (x+width/2)))
+ {
+ red += (*p)*(q->r * 257);
+ green += (*p)*(q->g*257);
+ blue += (*p)*(q->b*257);
+ alpha += (*p)*(q->a*257);
+ }
+
+ if(((i+width/2-x) >= 0) && ((i+width/2-x) < width))
+ scale += kernel[i+width/2-x];
+
+ p++;
+ q++;
+ }
+
+ scale = 1.0/scale;
+ red = scale*(red+0.5);
+ green = scale*(green+0.5);
+ blue = scale*(blue+0.5);
+ alpha = scale*(alpha+0.5);
+
+ red = red < 0 ? 0 : red > 65535 ? 65535 : red;
+ green = green < 0 ? 0 : green > 65535 ? 65535 : green;
+ blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue;
+ alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha;
+
+ dest[x] = rgba((u8)(red/257UL),
+ (u8)(green/257UL),
+ (u8)(blue/257UL),
+ (u8)(alpha/257UL));
+ }
+
+ return;
+ }
+
+ for(x = 0;x < width/2;++x)
+ {
+ scale = 0.0;
+ red = blue = green = alpha = 0.0;
+ p = kernel+width/2-x;
+ q = src;
+
+ for(i = width/2-x;i < width;++i)
+ {
+ red += (*p)*(q->r*257);
+ green += (*p)*(q->g*257);
+ blue += (*p)*(q->b*257);
+ alpha += (*p)*(q->a*257);
+ scale += (*p);
+ p++;
+ q++;
+ }
+
+ scale=1.0/scale;
+
+ red = scale*(red+0.5);
+ green = scale*(green+0.5);
+ blue = scale*(blue+0.5);
+ alpha = scale*(alpha+0.5);
+
+ red = red < 0 ? 0 : red > 65535 ? 65535 : red;
+ green = green < 0 ? 0 : green > 65535 ? 65535 : green;
+ blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue;
+ alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha;
+
+ dest[x] = rgba((u8)(red/257UL),
+ (u8)(green/257UL),
+ (u8)(blue/257UL),
+ (u8)(alpha/257UL));
+ }
+
+ for(;x < columns-width/2;++x)
+ {
+ red = blue = green = alpha = 0.0;
+ p = kernel;
+ q = src+(x-width/2);
+
+ for(i = 0;i < (long)width;++i)
+ {
+ red += (*p)*(q->r*257);
+ green += (*p)*(q->g*257);
+ blue += (*p)*(q->b*257);
+ alpha += (*p)*(q->a*257);
+ p++;
+ q++;
+ }
+
+ red = scale*(red+0.5);
+ green = scale*(green+0.5);
+ blue = scale*(blue+0.5);
+ alpha = scale*(alpha+0.5);
+
+ red = red < 0 ? 0 : red > 65535 ? 65535 : red;
+ green = green < 0 ? 0 : green > 65535 ? 65535 : green;
+ blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue;
+ alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha;
+
+ dest[x] = rgba((u8)(red/257UL),
+ (u8)(green/257UL),
+ (u8)(blue/257UL),
+ (u8)(alpha/257UL));
+ }
+
+ for(;x < columns;++x)
+ {
+ red = blue = green = alpha = 0.0;
+ scale=0;
+ p = kernel;
+ q = src+(x-width/2);
+
+ for(i = 0;i < columns-x+width/2;++i)
+ {
+ red += (*p)*(q->r*257);
+ green += (*p)*(q->g*257);
+ blue += (*p)*(q->b*257);
+ alpha += (*p)*(q->a*257);
+ scale += (*p);
+ p++;
+ q++;
+ }
+
+ scale=1.0/scale;
+ red = scale*(red+0.5);
+ green = scale*(green+0.5);
+ blue = scale*(blue+0.5);
+ alpha = scale*(alpha+0.5);
+
+ red = red < 0 ? 0 : red > 65535 ? 65535 : red;
+ green = green < 0 ? 0 : green > 65535 ? 65535 : green;
+ blue = blue < 0 ? 0 : blue > 65535 ? 65535 : blue;
+ alpha = alpha < 0 ? 0 : alpha > 65535 ? 65535 : alpha;
+
+ dest[x] = rgba((u8)(red/257UL),
+ (u8)(green/257UL),
+ (u8)(blue/257UL),
+ (u8)(alpha/257UL));
+ }
+}
+
+static s32 getBlurKernel(s32 width, double sigma, double **kernel)
+{
+
+#define KernelRank 3
+#define KernelRankQ 18.0
+
+ double alpha, normalize;
+ long i;
+ s32 bias;
+
+ if(sigma == 0.0)
+ return 0;
+
+ if(width == 0)
+ width = 3;
+
+ *kernel = new double [width];
+
+ if(!*kernel)
+ return 0;
+
+ memset(*kernel, 0, width * sizeof(double));
+ bias = KernelRank * width/2;
+
+ for(i = (-bias);i <= bias; i++)
+ {
+ alpha = exp(-((double) i*i)/(KernelRankQ*sigma*sigma));
+ (*kernel)[(i+bias)/KernelRank] += alpha/(MagickSQ2PI*sigma);
+ }
+
+ normalize = 0;
+
+ for(i = 0;i < width;i++)
+ normalize += (*kernel)[i];
+
+ for(i = 0;i < width;i++)
+ (*kernel)[i] /= normalize;
+
+ return width;
+
+#undef KernelRankQ
+#undef KernelRank
+
+}
+
+static void hull(const s32 x_offset, const s32 y_offset, const s32 polarity, const s32 columns,
+ const s32 rows, u8 *f, u8 *g)
+{
+ s32 x, y;
+
+ u8 *p, *q, *r, *s;
+ u32 v;
+
+ if(f == 0 || g == 0)
+ return;
+
+ p = f+(columns+2);
+ q = g+(columns+2);
+ r = p+(y_offset*(columns+2)+x_offset);
+
+ for(y = 0;y < rows;y++)
+ {
+ p++;
+ q++;
+ r++;
+ if(polarity > 0)
+ for(x = 0;x < columns;x++)
+ {
+ v=(*p);
+ if (*r > v)
+ v++;
+ *q=v > 255 ? 255 : v;
+ p++;
+ q++;
+ r++;
+ }
+ else
+ for(x = 0;x < columns;x++)
+ {
+ v=(*p);
+ if (v > (u32) (*r+1))
+ v--;
+ *q=v;
+ p++;
+ q++;
+ r++;
+ }
+ p++;
+ q++;
+ r++;
+ }
+
+ p = f+(columns+2);
+ q = g+(columns+2);
+ r = q+(y_offset*(columns+2)+x_offset);
+ s = q-(y_offset*(columns+2)+x_offset);
+
+ for(y = 0;y < rows;y++)
+ {
+ p++;
+ q++;
+ r++;
+ s++;
+
+ if(polarity > 0)
+ for(x=0; x < (s32) columns; x++)
+ {
+ v=(*q);
+ if (((u32) (*s+1) > v) && (*r > v))
+ v++;
+ *p=v > 255 ? 255 : v;
+ p++;
+ q++;
+ r++;
+ s++;
+ }
+ else
+ for (x=0; x < columns; x++)
+ {
+ v=(*q);
+ if (((u32) (*s+1) < v) && (*r < v))
+ v--;
+ *p=v;
+ p++;
+ q++;
+ r++;
+ s++;
+ }
+
+ p++;
+ q++;
+ r++;
+ s++;
+ }
+}
+
+static int getOptimalKernelWidth(double radius, double sigma)
+{
+ double normalize, value;
+ long width;
+ long u;
+
+ if(sigma == 0.0)
+ sigma = 0.01;
+
+ if(radius > 0.0)
+ return((int)(2.0*ceil(radius)+1.0));
+
+ const double S = sigma * sigma;
+
+ for(width = 5;;)
+ {
+ normalize = 0.0;
+
+ for(u = (-width/2);u <= (width/2);u++)
+ normalize+=exp(-((double) u*u)/(2.0*S))/(MagickSQ2PI*sigma);
+
+ u = width/2;
+ value = exp(-((double) u*u)/(2.0*S))/(MagickSQ2PI*sigma)/normalize;
+
+ if((long)(65535*value) <= 0)
+ break;
+
+ width+=2;
+ }
+
+ return ((int)width-2);
+}
+
+} // namespace
diff --git a/src/ksquirrelpart/fmt_filters.h b/src/ksquirrelpart/fmt_filters.h
new file mode 100644
index 0000000..9f6cb5d
--- /dev/null
+++ b/src/ksquirrelpart/fmt_filters.h
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 2005 Dmitry Baryshev <[email protected]>
+ */
+
+/*
+ * All methods (except redeye) in this namespace are ported from KDE 3.2.3.
+ * All of them are copyrighted by their authors. See fmt_filters_README for more.
+ */
+
+/* This file is part of the KDE libraries
+ Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <[email protected]>
+ (C) 1998, 1999 Christian Tibirna <[email protected]>
+ (C) 1998, 1999 Dirk A. Mueller <[email protected]>
+ (C) 1999 Geert Jansen <[email protected]>
+ (C) 2000 Josef Weidendorfer <[email protected]>
+ (C) 2004 Zack Rusin <[email protected]>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+//
+// ===================================================================
+// Effects originally ported from ImageMagick for PixiePlus, plus a few
+// new ones. (mosfet 05/26/2003)
+// ===================================================================
+//
+/*
+ Portions of this software are based on ImageMagick. Such portions are clearly
+marked as being ported from ImageMagick. ImageMagick is copyrighted under the
+following conditions:
+
+Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to
+making software imaging solutions freely available.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files ("ImageMagick"), to deal
+in ImageMagick without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of ImageMagick, and to permit persons to whom the ImageMagick is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of ImageMagick.
+
+The software is provided "as is", without warranty of any kind, express or
+implied, including but not limited to the warranties of merchantability,
+fitness for a particular purpose and noninfringement. In no event shall
+ImageMagick Studio be liable for any claim, damages or other liability,
+whether in an action of contract, tort or otherwise, arising from, out of or
+in connection with ImageMagick or the use or other dealings in ImageMagick.
+
+Except as contained in this notice, the name of the ImageMagick Studio shall
+not be used in advertising or otherwise to promote the sale, use or other
+dealings in ImageMagick without prior written authorization from the
+ImageMagick Studio.
+*/
+
+#ifndef FMT_FILTERS_H
+#define FMT_FILTERS_H
+
+//////////////////////////////////////////
+// //
+// Pass the image through some filter //
+// //
+//////////////////////////////////////////
+
+
+namespace fmt_filters
+{
+ typedef char s8;
+ typedef unsigned char u8;
+
+ typedef short s16;
+ typedef unsigned short u16;
+
+ typedef int s32;
+ typedef unsigned int u32;
+
+ struct image
+ {
+ image() : data(0), w(0), h(0), rw(0), rh(0)
+ {}
+
+ image(unsigned char *d, int _w, int _h) : data(d), w(_w), h(_h), rw(_w), rh(_h)
+ {}
+
+ image(unsigned char *d, int _w, int _h, int _rw, int _rh) : data(d), w(_w), h(_h), rw(_rw), rh(_rh)
+ {}
+
+ unsigned char *data;
+ int w;
+ int h;
+ int rw;
+ int rh;
+ };
+
+ struct rgb
+ {
+ rgb() : r(0), g(0), b(0)
+ {}
+
+ rgb(int _r, int _g, int _b) : r(_r), g(_g), b(_b)
+ {}
+
+ unsigned char r;
+ unsigned char g;
+ unsigned char b;
+ };
+
+ struct rgba
+ {
+ rgba(int r1, int g1, int b1, int a1) : r(r1), g(g1), b(b1), a(a1)
+ {}
+
+ rgba() : r(0), g(0), b(0), a(0)
+ {}
+
+ unsigned char r;
+ unsigned char g;
+ unsigned char b;
+ unsigned char a;
+ };
+
+ enum NoiseType
+ {
+ UniformNoise = 0, // Uniform distribution
+ GaussianNoise, // Gaussian distribution
+ MultiplicativeGaussianNoise, // Multiplicative Gaussian distribution
+ ImpulseNoise, // Impulse distribution
+ LaplacianNoise, // Laplacian distribution
+ PoissonNoise // Poisson distribution
+ };
+
+
+ bool checkImage(const image &im);
+
+ // colorize the image, which is w x h, left alpha channel unchanged.
+ //
+ // it just adds to each pixel in the image
+ // aproproriate value.
+ void colorize(const image &im, int red, int green, int blue);
+
+ // change brightness of the image
+ void brightness(const image &im, int bn);
+
+ // change gamma
+ // gamma should be 0.0 <= L <= 6.0
+ //
+ // it is no problem to set L to 8.0 or 9.0, but the resulting
+ // image won't have much difference from 6.0
+ void gamma(const image &im, double L);
+
+ // change contrast with Photoshop-like method
+ // contrast should be -255 <= contrast <= 255
+ void contrast(const image &im, int contrast);
+
+ enum swapRGBtype { GBR = 0, BRG = 1 };
+
+ // negative
+ void negative(const image &im);
+
+ // swap RGB values
+ void swapRGB(const image &im, int type);
+
+ //
+ // All the following filters are ported from KDE's
+ // KImageEffect. See tdelibs/tdefx/kimageeffect.cpp
+ // for more.
+ //
+
+ // blend
+ // opacity = [0.0; 1.0]
+ void blend(const image &im, const rgb &rgb, float opacity);
+
+ // val = [0.0; 1.0]
+ void fade(const image &im, const rgb &rgb, float val);
+
+ void gray(const image &im);
+
+ // desat = [0.0; 1.0]
+ void desaturate(const image &im, float desat);
+
+ // threshold = [0; 255]
+ void threshold(const image &im, unsigned int threshold);
+
+ // factor = [0.0; 50.0]
+ void solarize(const image &im, double factor);
+
+ // amount = [1; 10]
+ void spread(const image &im, unsigned int amount);
+
+ // degrees = [-720.0; 720.0]
+ void swirl(const image &im, double degrees, const rgba &background);
+
+ void noise(const image &im, NoiseType noise_type);
+
+ void flatten(const image &im, const rgb &ca, const rgb &cb);
+
+ // azimuth = [0.0; 90.0], elevation = [0.0; 90.0]
+ void shade(const image &im, bool color, double azimuth, double elevation);
+
+ void equalize(const image &im);
+
+ // radius = [0.01; 90.0], sigma = [0.01; 50.0]
+ void blur(const image &im, double radius, double sigma);
+
+ void despeckle(const image &im);
+
+ // factor = [0; 100]
+ void implode(const image &im, double factor, const rgba &background);
+
+ // radius = [0.01; 30.0]
+ void edge(image &im, double radius);
+
+ // radius = [0.01; 99.9], sigma = [0.01; 99.9]
+ void emboss(image &im, double radius, double sigma);
+
+ // radius = [0.01; 99.9], sigma = [0.01; 30.0]
+ void sharpen(image &im, double radius, double sigma);
+
+ // radius = [1.0; 5.0]
+ void oil(const image &im, double radius);
+
+/*
+ * Red-eye removal was taken from "redeye" plugin for GIMP
+ */
+
+/* redeye.c: redeye remover plugin code
+ *
+ * Copyright (C) 2004 Robert Merkel <[email protected]> (the "Author").
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Author of the
+ * Software shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the Author.
+1;3B */
+
+ // red-eye removal.
+ // th = [0; 255]
+ void redeye(const image &im, const int w, const int h,
+ const int x, const int y,
+ int th);
+
+ // Do we need some color definitions ?
+ static const rgba white = rgba(255, 255, 255, 255);
+ static const rgba black = rgba(0, 0, 0, 255);
+ static const rgba red = rgba(255, 0, 0, 255);
+ static const rgba green = rgba(0, 255, 0, 255);
+ static const rgba blue = rgba(0, 0, 255, 255);
+ static const rgba cyan = rgba(0, 255, 255, 255);
+ static const rgba magenta = rgba(255, 0, 255, 255);
+ static const rgba yellow = rgba(255, 255, 0, 255);
+ static const rgba mediumgray = rgba(128, 128, 128, 255);
+ static const rgba lightgray = rgba(160, 160, 164, 255);
+ static const rgba normalgray = rgba(192, 192, 192, 255);
+ static const rgba darkred = rgba(128, 0, 0, 255);
+ static const rgba darkgreen = rgba(0, 128, 0, 255);
+ static const rgba darkblue = rgba(0, 0, 128, 255);
+ static const rgba darkcyan = rgba(0, 128, 128, 255);
+ static const rgba darkmagenta = rgba(128, 0, 128, 255);
+ static const rgba darkyellow = rgba(128, 128, 0, 255);
+}
+
+#endif
diff --git a/src/ksquirrelpart/ksquirrelpart.cpp b/src/ksquirrelpart/ksquirrelpart.cpp
new file mode 100644
index 0000000..7021e54
--- /dev/null
+++ b/src/ksquirrelpart/ksquirrelpart.cpp
@@ -0,0 +1,271 @@
+/***************************************************************************
+ sq_ksquirrelpart.cpp - description
+ -------------------
+ begin : Thu Nov 29 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tdeaction.h>
+#include <tdeparts/browserextension.h>
+#include <tdeparts/genericfactory.h>
+#include <tdefileitem.h>
+#include <tdeglobal.h>
+#include <tdelocale.h>
+#include <kstandarddirs.h>
+#include <kdebug.h>
+
+#include "ksquirrelpart.h"
+#include "sq_glwidget.h"
+
+#include "sq_glview.h"
+#include "sq_config.h"
+#include "sq_diroperator.h"
+#include "sq_libraryhandler.h"
+#include "sq_iconloader.h"
+#include "sq_externaltool.h"
+#include "sq_errorstring.h"
+
+typedef KParts::GenericFactory<KSquirrelPart> KSquirrelFactory;
+K_EXPORT_COMPONENT_FACTORY(libksquirrelpart, KSquirrelFactory)
+
+KSquirrelPart::KSquirrelPart(TQWidget *parentWidget, const char *,
+ TQObject* parent, const char *name,
+ const TQStringList &) : KParts::ReadOnlyPart(parent, name)
+{
+ kdDebug() << "+KSquirrelPart" << endl;
+
+ setInstance(KSquirrelFactory::instance());
+
+ ext = new KSquirrelPartBrowserExtension(this);
+
+ TDEGlobal::dirs()->addResourceType("data", TDEStandardDirs::kde_default("data") + TQString::fromLatin1("ksquirrel"));
+ TDEGlobal::locale()->setActiveCatalogue(KSquirrelFactory::instance()->instanceName());
+
+ if(!SQ_ErrorString::instance())
+ new SQ_ErrorString(parentWidget);
+
+ if(!SQ_Config::instance())
+ new SQ_Config;
+
+ if(!SQ_IconLoader::instance())
+ new SQ_IconLoader;
+
+ if(!SQ_ExternalTool::instance())
+ new SQ_ExternalTool;
+
+ SQ_ExternalTool::instance()->newPopupMenu();
+
+ // This will allow global object of SQ_LibraryHandler, which
+ // will exist until Konqueror will be closed
+ if(!SQ_LibraryHandler::instance())
+ new SQ_LibraryHandler;
+
+ new SQ_DirOperator;
+
+ gl = new SQ_GLWidget(parentWidget, "ksquirrelpart-opengl-widget");
+ gl->glInitA();
+
+ connect(gl, TQ_SIGNAL(message(const TQString &)), this, TQ_SIGNAL(setStatusBarText(const TQString&)));
+ setWidget(gl);
+
+ TDEAction *a;
+
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_Plus));
+ new TDEAction(i18n("Zoom +"), "zoom-in", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart zoom in");
+
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_Minus));
+ new TDEAction(i18n("Zoom -"), "zoom-out", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart zoom out");
+
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_P));
+ new TDEAction(i18n("Properties"), "image-x-generic", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart properties");
+
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_R));
+ new TDEAction(i18n("Normalize"), "rebuild", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart normalize");
+
+ // colorize & filters
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_D));
+ new TDEAction(i18n("Color balance..."), "colorize", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart colorbalance");
+
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_U));
+ new TDEAction(i18n("Apply filter..."), "effect", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart filter");
+
+ // rotate
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_Left+CTRL));
+ new TDEAction(i18n("Rotate left"), "object-rotate-left", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart rotateleft");
+
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_Right+CTRL));
+ new TDEAction(i18n("Rotate right"), "object-rotate-right", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart rotateright");
+
+ // copy/move
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_F5));
+ new TDEAction(i18n("Copy to..."), "edit-copy", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart copyto");
+
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_F7));
+ new TDEAction(i18n("Move to..."), "edit-cut", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart moveto");
+
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_F6));
+ new TDEAction(i18n("Copy to last folder"), "", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart copy");
+
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_F8));
+ new TDEAction(i18n("Move to last folder"), "", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart move");
+
+ a = gl->actionCollection()->action(TQString("action_%1").arg(TQt::Key_S));
+ new TDEAction(i18n("Save As..."), "document-save-as", 0, a, TQ_SLOT(activate()), actionCollection(), "ksquirrelpart saveas");
+
+ sa = new TDESelectAction(i18n("Zoom"), 0, actionCollection(), "ksquirrelpart zoom");
+ sa->setEditable(true);
+
+ TQStringList zooms;
+ zooms << TQString::number(10) + '%';
+ zooms << TQString::number(25) + '%';
+ zooms << TQString::number(33) + '%';
+ zooms << TQString::number(50) + '%';
+ zooms << TQString::number(75) + '%';
+ zooms << TQString::number(100) + '%';
+ zooms << TQString::number(150) + '%';
+ zooms << TQString::number(200) + '%';
+ zooms << TQString::number(250) + '%';
+ zooms << TQString::number(300) + '%';
+ zooms << TQString::number(350) + '%';
+ zooms << TQString::number(400) + '%';
+ zooms << TQString::number(450) + '%';
+ zooms << TQString::number(500) + '%';
+ zooms << TQString::number(600) + '%';
+ zooms << TQString::number(700) + '%';
+ zooms << TQString::number(800) + '%';
+ zooms << TQString::number(900) + '%';
+ zooms << TQString::number(1000) + '%';
+
+ sa->setItems(zooms);
+ sa->setCurrentItem(5);
+ connect(sa, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotZoom()));
+
+ TQString group = "selection_group";
+
+ ar = new TDEToggleAction(i18n("Rectangle"), "rectangle", TDEShortcut(TQt::Key_R+CTRL), 0, 0, actionCollection(), "ksquirrelpart rectangle");
+ ar->setExclusiveGroup(group);
+ connect(ar, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotSelectionRect(bool)));
+
+ ae = new TDEToggleAction(i18n("Ellipse"), "circle", TDEShortcut(TQt::Key_E+CTRL), 0, 0, actionCollection(), "ksquirrelpart ellipse");
+ ae->setExclusiveGroup(group);
+ connect(ae, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotSelectionEllipse(bool)));
+
+ setXMLFile("ksquirrelpart/ksquirrelpart.rc");
+}
+
+KSquirrelPart::~KSquirrelPart()
+{
+ kdDebug() << "-KSquirrelPart" << endl;
+}
+
+void KSquirrelPart::slotZoom()
+{
+ bool ok;
+
+ int z = sa->currentText().replace(TQChar('%'), "").toInt(&ok);
+
+ if(ok)
+ gl->zoom((float)z / 100.0f);
+}
+
+void KSquirrelPart::slotSelectionRect(bool b)
+{
+ if(b)
+ gl->slotSelectionRect();
+ else if(!ae->isChecked())
+ gl->slotSelectionClear();
+}
+
+void KSquirrelPart::slotSelectionEllipse(bool b)
+{
+ if(b)
+ gl->slotSelectionEllipse();
+ else if(!ar->isChecked())
+ gl->slotSelectionClear();
+}
+
+void KSquirrelPart::print()
+{
+ gl->slotPrint();
+}
+
+TDEAboutData* KSquirrelPart::createAboutData()
+{
+ TDEAboutData *kAboutData = new TDEAboutData(
+ "ksquirrel",
+ I18N_NOOP("KSquirrelPart"),
+ "0.1.2",
+ I18N_NOOP("Image Viewer"),
+ TDEAboutData::License_GPL,
+ "(c) 2007, Dmitry Baryshev <[email protected]>");
+
+ return kAboutData;
+}
+
+bool KSquirrelPart::openFile()
+{
+ emit started(0);
+
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, m_url);
+ SQ_DirOperator::instance()->execute(&fi);
+
+ emit setWindowCaption(m_url.prettyURL());
+
+ emit completed(0);
+
+ return true;
+}
+
+void KSquirrelPart::setKonquerorWindowCaption(const KURL &, const TQString &filename)
+{
+ TQString caption = TQString("%1").arg(filename);
+ emit setWindowCaption(caption);
+}
+
+void KSquirrelPart::partActivateEvent(KParts::PartActivateEvent *e)
+{
+ if(e->activated())
+ {
+ if(!gl->manualBlocked())
+ gl->startAnimation();
+ }
+ else
+ {
+ // stop animation when KPart becomes inactive
+ gl->stopAnimation();
+
+ SQ_LibraryHandler::instance()->sync();
+ SQ_Config::instance()->sync();
+ }
+
+ KParts::ReadOnlyPart::partActivateEvent(e);
+}
+
+/***************************************************************/
+
+KSquirrelPartBrowserExtension::KSquirrelPartBrowserExtension(KSquirrelPart *viewPart, const char *name)
+ :KParts::BrowserExtension(viewPart, name)
+{
+ mPart = viewPart;
+ emit enableAction("print", true);
+}
+
+KSquirrelPartBrowserExtension::~KSquirrelPartBrowserExtension()
+{}
+
+void KSquirrelPartBrowserExtension::print()
+{
+ mPart->print();
+}
+
+#include "ksquirrelpart.moc"
diff --git a/src/ksquirrelpart/ksquirrelpart.desktop b/src/ksquirrelpart/ksquirrelpart.desktop
new file mode 100644
index 0000000..b4f7e9e
--- /dev/null
+++ b/src/ksquirrelpart/ksquirrelpart.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Type=Service
+MimeType=image/x-vnd.adobe.photoshop;image/x-hdr;image/x-exr;image/x-eps;image/x-psp;image/x-dds;image/x-mdl;image/ljpeg;image/x-dicom;image/x-xfig;image/svg+xml;image/gif;image/x-xpm;image/x-xbm;image/jpeg;image/x-bmp;image/png;image/tiff;image/x-portable-bitmap;image/x-portable-pixmap;image/x-portable-anymap;image/x-portable-greymap;image/jp2;image/x-jng;image/x-wmf;video/x-mng;video/x-flic;image/x-targa;image/x-pcx;image/x-photo-cd;image/x-rgb;image/x-xcursor;image/x-ico;image/psd;image/x-djvu;image/x-xcf-gimp;image/x-avs;image/x-cut;image/x-dxf;image/x-iff;image/x-jbig;image/x-koala;image/x-leaf;image/x-lif;image/x-mac;image/x-msp;image/x-mtv;image/x-neo;image/x-pi1;image/x-pi3;image/x-pict;image/x-pix;image/x-pxr;image/x-ras;image/x-raw;image/x-rawrgb;image/x-sct;image/x-sun;image/x-utah;image/x-wal;image/x-wbmp;image/x-xim;image/x-xwd;application/x-font-ttf;application/x-font-ttc;application/x-font-otf;application/x-font-type1
+X-TDE-ServiceTypes=KParts/ReadOnlyPart
+X-TDE-Library=libksquirrelpart
+X-TDE-InitialPreference=5
+Icon=ksquirrel
+
+Name=KSquirrel Image Viewer
+Name[ru]=KSquirrel Просмотр изображений
+Name[de]=KSquirrel Bildbetrachter
diff --git a/src/ksquirrelpart/ksquirrelpart.h b/src/ksquirrelpart/ksquirrelpart.h
new file mode 100644
index 0000000..0c2a91f
--- /dev/null
+++ b/src/ksquirrelpart/ksquirrelpart.h
@@ -0,0 +1,89 @@
+/***************************************************************************
+ sq_ksquirrelpart.h - description
+ -------------------
+ begin : Thu Nov 29 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef KSQUIRRELPART_H
+#define KSQUIRRELPART_H
+
+#include <tdeparts/part.h>
+
+class TDEAboutData;
+class TDEToggleAction;
+class TDESelectAction;
+
+class SQ_GLWidget;
+
+class KSquirrelPart;
+
+class KSquirrelPartBrowserExtension: public KParts::BrowserExtension
+{
+ TQ_OBJECT
+
+
+ public:
+ KSquirrelPartBrowserExtension(KSquirrelPart* viewPart, const char *name = 0);
+ ~KSquirrelPartBrowserExtension();
+
+ public slots:
+ void print();
+
+ private:
+ KSquirrelPart *mPart;
+};
+
+/***********************************************************/
+
+class KSquirrelPart : public KParts::ReadOnlyPart
+{
+ TQ_OBJECT
+
+
+ public:
+ KSquirrelPart(TQWidget*, const char*, TQObject*, const char*, const TQStringList &);
+ virtual ~KSquirrelPart();
+
+ static TDEAboutData* createAboutData();
+
+ TQString filePath();
+
+ void print();
+
+ protected:
+ void partActivateEvent(KParts::PartActivateEvent *);
+
+ protected slots:
+ virtual bool openFile();
+ virtual void setKonquerorWindowCaption(const KURL &url, const TQString &filename);
+
+ private slots:
+ void slotSelectionRect(bool);
+ void slotSelectionEllipse(bool);
+ void slotZoom();
+
+ private:
+ SQ_GLWidget *gl;
+ TDEToggleAction *ar, *ae;
+ TDESelectAction *sa;
+ KSquirrelPartBrowserExtension *ext;
+};
+
+inline
+TQString KSquirrelPart::filePath()
+{
+ return m_file;
+}
+
+#endif
diff --git a/src/ksquirrelpart/ksquirrelpart.rc b/src/ksquirrelpart/ksquirrelpart.rc
new file mode 100644
index 0000000..10aa894
--- /dev/null
+++ b/src/ksquirrelpart/ksquirrelpart.rc
@@ -0,0 +1,20 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="KSquirrelPart">
+<ToolBar name="mainToolBar"><text>Main Toolbar</text>
+ <Separator/>
+
+ <Action name="ksquirrelpart zoom in"/>
+ <Action name="ksquirrelpart zoom out"/>
+ <Action name="ksquirrelpart rotateleft"/>
+ <Action name="ksquirrelpart rotateright"/>
+
+ <Separator/>
+
+ <Action name="ksquirrelpart normalize"/>
+ <Action name="ksquirrelpart properties"/>
+
+ <Action name="ksquirrelpart saveas"/>
+ <Action name="ksquirrelpart zoom"/>
+
+</ToolBar>
+</kpartgui>
diff --git a/src/ksquirrelpart/sq_bcglabel.cpp b/src/ksquirrelpart/sq_bcglabel.cpp
new file mode 100644
index 0000000..41395e3
--- /dev/null
+++ b/src/ksquirrelpart/sq_bcglabel.cpp
@@ -0,0 +1,28 @@
+/***************************************************************************
+ sq_bcglabel.cpp - description
+ -------------------
+ begin : ??? May 4 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "sq_bcglabel.h"
+
+SQ_BCGLabel::SQ_BCGLabel(TQWidget *parent, const char *name, WFlags f) : TQLabel(parent, name, f | TQt::WNoAutoErase)
+{
+ setScaledContents(false);
+
+ setAlignment(TQt::AlignHCenter | TQt::AlignVCenter);
+}
+
+SQ_BCGLabel::~SQ_BCGLabel()
+{}
diff --git a/src/ksquirrelpart/sq_bcglabel.h b/src/ksquirrelpart/sq_bcglabel.h
new file mode 100644
index 0000000..d8546a9
--- /dev/null
+++ b/src/ksquirrelpart/sq_bcglabel.h
@@ -0,0 +1,34 @@
+/***************************************************************************
+ sq_bcglabel.h - description
+ -------------------
+ begin : ??? May 4 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_BCGLABEL_H
+#define SQ_BCGLABEL_H
+
+#include <tqlabel.h>
+
+/**
+ *@author Baryshev Dmitry
+ */
+
+class SQ_BCGLabel : public TQLabel
+{
+ public:
+ SQ_BCGLabel(TQWidget *parent, const char *name = 0, WFlags f = 0);
+ ~SQ_BCGLabel();
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_codecsettings.cpp b/src/ksquirrelpart/sq_codecsettings.cpp
new file mode 100644
index 0000000..47b3609
--- /dev/null
+++ b/src/ksquirrelpart/sq_codecsettings.cpp
@@ -0,0 +1,42 @@
+/***************************************************************************
+ sq_codecsettings.cpp - description
+ -------------------
+ begin : Mon Mar 5 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <ksquirrel-libs/fmt_codec_base.h>
+
+#include "sq_codecsettings.h"
+#include "sq_library.h"
+#include "sq_config.h"
+
+void SQ_CodecSettings::applySettings(SQ_LIBRARY *lib, SQ_CodecSettings::settings fromwhere)
+{
+ SQ_Config::instance()->setGroup("Main");
+
+ int set = SQ_Config::instance()->readNumEntry("applyto", SQ_CodecSettings::Both);
+
+ // thumbnail loader and image viewer will use default settings
+ if((fromwhere == SQ_CodecSettings::ThumbnailLoader && (set == SQ_CodecSettings::ThumbnailLoader || set == SQ_CodecSettings::Both))
+ || (fromwhere == SQ_CodecSettings::ImageViewer && (set == SQ_CodecSettings::ImageViewer || set == SQ_CodecSettings::Both)))
+ {
+ lib->codec->set_settings(lib->settings);
+ lib->codec_il->set_settings(lib->settings);
+ }
+ else
+ {
+ lib->codec->fill_default_settings();
+ lib->codec_il->fill_default_settings();
+ }
+}
diff --git a/src/ksquirrelpart/sq_codecsettings.h b/src/ksquirrelpart/sq_codecsettings.h
new file mode 100644
index 0000000..f789e9f
--- /dev/null
+++ b/src/ksquirrelpart/sq_codecsettings.h
@@ -0,0 +1,34 @@
+/***************************************************************************
+ sq_codecsettings.h - description
+ -------------------
+ begin : Mon Mar 5 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_CODECSETTINGS_H
+#define SQ_CODECSETTINGS_H
+
+/**
+ *@author Baryshev Dmitry
+ */
+
+struct SQ_LIBRARY;
+
+struct SQ_CodecSettings
+{
+ enum settings { ThumbnailLoader = 0, ImageViewer, Both, RunTume, None };
+
+ static void applySettings(SQ_LIBRARY *l, SQ_CodecSettings::settings fromwhere);
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_codecsettingsskeleton.ui b/src/ksquirrelpart/sq_codecsettingsskeleton.ui
new file mode 100644
index 0000000..1314543
--- /dev/null
+++ b/src/ksquirrelpart/sq_codecsettingsskeleton.ui
@@ -0,0 +1,217 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_CodecSettingsSkeleton</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_CodecSettingsSkeleton</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>283</width>
+ <height>335</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Codec settings</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>codecIcon</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="Line" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>line2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>codecName</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQGroupBox" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>groupBox</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="Line" row="3" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="4" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushApply</cstring>
+ </property>
+ <property name="text">
+ <string>Apply</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushOK</cstring>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushCancel</cstring>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushOK</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_CodecSettingsSkeleton</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>pushCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_CodecSettingsSkeleton</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>pushApply</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_CodecSettingsSkeleton</receiver>
+ <slot>slotApply()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>pushOK</tabstop>
+ <tabstop>pushApply</tabstop>
+ <tabstop>pushCancel</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in declaration">ksquirrel-libs/settings.h</include>
+ <include location="global" impldecl="in implementation">tqcheckbox.h</include>
+ <include location="global" impldecl="in implementation">tqmessagebox.h</include>
+ <include location="global" impldecl="in implementation">tqobjectlist.h</include>
+ <include location="global" impldecl="in implementation">tqbuttongroup.h</include>
+ <include location="global" impldecl="in implementation">tqslider.h</include>
+ <include location="global" impldecl="in implementation">kurlrequester.h</include>
+ <include location="global" impldecl="in implementation">knuminput.h</include>
+ <include location="global" impldecl="in implementation">tqwidgetfactory.h</include>
+ <include location="global" impldecl="in implementation">tqspinbox.h</include>
+ <include location="global" impldecl="in implementation">tqtextedit.h</include>
+ <include location="global" impldecl="in implementation">kurl.h</include>
+ <include location="global" impldecl="in implementation">kcolorbutton.h</include>
+ <include location="local" impldecl="in implementation">sq_codecsettingsskeleton.ui.h</include>
+</includes>
+<variables>
+ <variable access="private">TQWidget *w;</variable>
+ <variable access="private">fmt_settings *sett;</variable>
+</variables>
+<signals>
+ <signal>apply();</signal>
+</signals>
+<slots>
+ <slot access="private" specifier="non virtual">slotApply()</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function specifier="non virtual">addSettingsWidget( const TQString &amp; path )</function>
+ <function access="private" specifier="non virtual">recursivelyReadWrite( fmt_settings &amp; settings, bool r )</function>
+ <function returnType="int">exec( fmt_settings &amp; settings )</function>
+ <function specifier="non virtual">setCodecInfo( const TQPixmap &amp; pixmap, const TQString &amp; text )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/ksquirrelpart/sq_codecsettingsskeleton.ui.h b/src/ksquirrelpart/sq_codecsettingsskeleton.ui.h
new file mode 100644
index 0000000..d976149
--- /dev/null
+++ b/src/ksquirrelpart/sq_codecsettingsskeleton.ui.h
@@ -0,0 +1,171 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+void SQ_CodecSettingsSkeleton::init()
+{
+ w = 0;
+ sett = 0;
+}
+
+void SQ_CodecSettingsSkeleton::addSettingsWidget(const TQString &path)
+{
+ w = TQWidgetFactory::create(path, 0, this, "skeleton_settings");
+ TQWidget *fake;
+
+ if(w)
+ fake = w;
+ else
+ {
+ pushApply->setEnabled(false);
+ pushOK->setEnabled(false);
+
+ TQTextEdit *t = new TQTextEdit(i18n("Error loading widget from <b>%1</b>. Please check your installation or contact <a href=\"mailto:[email protected]\">[email protected]</a>").arg(path), TQString(), groupBox);
+ t->setReadOnly(true);
+ fake = t;
+ }
+
+ fake->reparent(groupBox, TQPoint(0,0), true);
+
+ TQGridLayout *grid = new TQGridLayout(groupBox, 1, 1, 11, 6);
+ grid->addMultiCellWidget(fake, 1, 1, 0, 3);
+
+ TQSpacerItem *spacer = new TQSpacerItem(15, 1, TQSizePolicy::Minimum, TQSizePolicy::Expanding);
+ grid->addItem(spacer, 2, 1);
+}
+
+void SQ_CodecSettingsSkeleton::recursivelyReadWrite(fmt_settings &settings, bool r)
+{
+ if(!w)
+ return;
+
+ TQObjectList ch = w->childrenListObject();
+ fmt_settings::iterator t;
+
+ for(TQObjectList::iterator it = ch.begin();it != ch.end();++it)
+ {
+ t = settings.find((*it)->name());
+
+ if((*it)->inherits("TQCheckBox"))
+ {
+ TQCheckBox *c = dynamic_cast<TQCheckBox *>(*it);
+
+ if(c && t != settings.end())
+ {
+ if(r)
+ c->setChecked((*t).second.bVal);
+ else
+ (*t).second.bVal = c->isChecked();
+ }
+ }
+ else if((*it)->inherits("TQButtonGroup"))
+ {
+ TQButtonGroup *c = dynamic_cast<TQButtonGroup *>(*it);
+
+ if(c && t != settings.end())
+ {
+ if(r)
+ c->setButton((*t).second.iVal);
+ else
+ (*t).second.iVal = c->selectedId();
+ }
+ }
+ else if((*it)->inherits("TQSlider"))
+ {
+ TQSlider *c = dynamic_cast<TQSlider *>(*it);
+
+ if(c && t != settings.end())
+ {
+ if(r)
+ c->setValue((*t).second.iVal);
+ else
+ (*t).second.iVal = c->value();
+ }
+ }
+ else if((*it)->inherits("KURLRequester"))
+ {
+ KURLRequester *u = dynamic_cast<KURLRequester *>(*it);
+
+ if(u && t != settings.end())
+ {
+ if(r)
+ u->setURL((*t).second.sVal);
+ else
+ {
+ KURL url = u->url(); // get rid of "file://" if present
+ (*t).second.sVal = url.isEmpty() ? "" : url.path().ascii();
+ }
+ }
+ }
+ else if((*it)->inherits("KDoubleSpinBox"))
+ {
+ KDoubleSpinBox *d = dynamic_cast<KDoubleSpinBox *>(*it);
+
+ if(d && t != settings.end())
+ {
+ if(r)
+ d->setValue((*t).second.dVal);
+ else
+ (*t).second.dVal = d->value();
+ }
+ }
+ // TQSpinBox should be checked after KDoubleSpinBox !
+ else if((*it)->inherits("TQSpinBox"))
+ {
+ TQSpinBox *c = dynamic_cast<TQSpinBox *>(*it);
+
+ if(c && t != settings.end())
+ {
+ if(r)
+ c->setValue((*t).second.iVal);
+ else
+ (*t).second.iVal = c->value();
+ }
+ }
+ else if((*it)->inherits("KColorButton"))
+ {
+ KColorButton *c = dynamic_cast<KColorButton *>(*it);
+
+ if(c && t != settings.end())
+ {
+ if(r)
+ c->setColor(TQColor(TQString((*t).second.sVal)));
+ else
+ (*t).second.sVal = TQString(c->color().name()).ascii();
+ }
+ }
+ }
+}
+
+int SQ_CodecSettingsSkeleton::exec(fmt_settings &settings)
+{
+ // read settings
+ recursivelyReadWrite(settings, true);
+
+ sett = &settings;
+
+ int result = TQDialog::exec();
+
+ // save settings
+ if(result == TQDialog::Accepted)
+ recursivelyReadWrite(settings, false);
+
+ return result;
+}
+
+void SQ_CodecSettingsSkeleton::setCodecInfo( const TQPixmap &pixmap, const TQString &text )
+{
+ codecIcon->setPixmap(pixmap);
+ codecName->setText(text);
+}
+
+void SQ_CodecSettingsSkeleton::slotApply()
+{
+ recursivelyReadWrite(*sett, false);
+ emit apply();
+}
diff --git a/src/ksquirrelpart/sq_config.cpp b/src/ksquirrelpart/sq_config.cpp
new file mode 100644
index 0000000..ea0fc4b
--- /dev/null
+++ b/src/ksquirrelpart/sq_config.cpp
@@ -0,0 +1,36 @@
+/***************************************************************************
+ sq_config.cpp - description
+ -------------------
+ begin : ??? ??? 14 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_config.h"
+
+SQ_Config * SQ_Config::m_instance = 0;
+
+SQ_Config::SQ_Config(TQObject *parent) : TQObject(parent)
+{
+ m_instance = this;
+
+ tdeconf = new TDEConfig("ksquirrelrc");
+}
+
+SQ_Config::~SQ_Config()
+{
+ delete tdeconf;
+}
diff --git a/src/ksquirrelpart/sq_config.h b/src/ksquirrelpart/sq_config.h
new file mode 100644
index 0000000..73cf0c4
--- /dev/null
+++ b/src/ksquirrelpart/sq_config.h
@@ -0,0 +1,136 @@
+/***************************************************************************
+ sq_config.h - description
+ -------------------
+ begin : ??? ??? 14 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_CONFIG_H
+#define SQ_CONFIG_H
+
+#include <tqobject.h>
+#include <tdeconfig.h>
+
+class TDEConfig;
+
+/*
+ * Class for reading/writing config file
+ */
+
+class SQ_Config : public TQObject
+{
+ public:
+ SQ_Config(TQObject *parent = 0);
+ ~SQ_Config();
+
+ static SQ_Config* instance() { return m_instance; }
+
+ void sync();
+
+ void setGroup(const TQString &group);
+ bool hasGroup(const TQString &group) const;
+ bool deleteGroup( const TQString& group, bool bDeep = true, bool bGlobal = false );
+ TQString readEntry(const TQString& pKey, const TQString& aDefault = TQString() ) const;
+ TQStringList readListEntry( const TQString& pKey, char sep = ',' ) const;
+ int readNumEntry( const TQString& pKey, int nDefault = 0 ) const;
+ bool readBoolEntry( const TQString& pKey, bool bDefault = false ) const;
+ TQRect readRectEntry( const TQString& pKey, const TQRect* pDefault = 0L ) const;
+ TQPoint readPointEntry( const TQString& pKey, const TQPoint* pDefault = 0L ) const;
+ TQSize readSizeEntry( const TQString& pKey, const TQSize* pDefault = 0L ) const;
+ double readDoubleNumEntry( const TQString& pKey, double nDefault = 0.0 ) const;
+ TQValueList<int> readIntListEntry( const TQString& pKey ) const;
+
+ void writeEntry( const TQString& pKey, const TQString& pValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, const TQStringList &rValue, char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, int nValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, bool bValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, const TQRect& rValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, const TQPoint& rValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, const TQSize& rValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, double nValue, bool bPersistent = true, bool bGlobal = false, char format = 'g', int precision = 6, bool bNLS = false );
+ void writeEntry( const TQString& pKey, const TQValueList<int>& rValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+
+ private:
+ TDEConfig *tdeconf;
+ static SQ_Config *m_instance;
+};
+
+inline
+void SQ_Config::sync() { tdeconf->sync(); }
+
+inline
+void SQ_Config::setGroup(const TQString &group) { tdeconf->setGroup(group) ; }
+
+inline
+bool SQ_Config::hasGroup(const TQString &group) const { return tdeconf->hasGroup(group) ; }
+
+inline
+bool SQ_Config::deleteGroup(const TQString& group, bool bDeep, bool bGlobal) { return tdeconf->deleteGroup(group, bDeep, bGlobal) ; }
+
+inline
+TQString SQ_Config::readEntry(const TQString& pKey, const TQString& aDefault) const { return tdeconf->readEntry(pKey, aDefault) ; }
+
+inline
+TQStringList SQ_Config::readListEntry(const TQString& pKey, char sep) const { return tdeconf->readListEntry(pKey, sep) ; }
+
+inline
+int SQ_Config::readNumEntry(const TQString& pKey, int nDefault) const { return tdeconf->readNumEntry(pKey, nDefault) ; }
+
+inline
+bool SQ_Config::readBoolEntry(const TQString& pKey, bool bDefault) const { return tdeconf->readBoolEntry(pKey, bDefault ) ; }
+
+inline
+TQRect SQ_Config::readRectEntry(const TQString& pKey, const TQRect* pDefault) const { return tdeconf->readRectEntry(pKey, pDefault) ; }
+
+inline
+TQPoint SQ_Config::readPointEntry(const TQString& pKey, const TQPoint* pDefault) const { return tdeconf->readPointEntry(pKey, pDefault) ; }
+
+inline
+TQSize SQ_Config::readSizeEntry(const TQString& pKey, const TQSize* pDefault) const { return tdeconf->readSizeEntry(pKey, pDefault) ; }
+
+inline
+double SQ_Config::readDoubleNumEntry(const TQString& pKey, double nDefault) const { return tdeconf->readDoubleNumEntry(pKey, nDefault); }
+
+inline
+TQValueList<int> SQ_Config::readIntListEntry( const TQString& pKey ) const { return tdeconf->readIntListEntry(pKey); }
+
+/**********************************************/
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, const TQString& pValue, bool bPersistent, bool bGlobal, bool bNLS) { tdeconf->writeEntry( pKey, pValue, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, const TQStringList &rValue, char sep, bool bPersistent, bool bGlobal, bool bNLS ) { tdeconf->writeEntry(pKey, rValue, sep, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, int nValue, bool bPersistent, bool bGlobal, bool bNLS ) { tdeconf->writeEntry(pKey, nValue, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, bool bValue, bool bPersistent, bool bGlobal, bool bNLS ) { tdeconf->writeEntry(pKey, bValue, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, const TQRect& rValue, bool bPersistent, bool bGlobal, bool bNLS ) { tdeconf->writeEntry(pKey, rValue, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, const TQPoint& rValue, bool bPersistent, bool bGlobal, bool bNLS ) { tdeconf->writeEntry(pKey, rValue, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, const TQSize& rValue, bool bPersistent, bool bGlobal, bool bNLS ) { tdeconf->writeEntry(pKey,rValue, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry( const TQString& pKey, double nValue, bool bPersistent, bool bGlobal, char format, int precision, bool bNLS) { tdeconf->writeEntry(pKey, nValue, bPersistent, bGlobal, format, precision, bNLS); }
+
+inline
+void SQ_Config::writeEntry( const TQString& pKey, const TQValueList<int>& rValue, bool bPersistent, bool bGlobal, bool bNLS) { tdeconf->writeEntry(pKey, rValue, bPersistent, bGlobal, bNLS); }
+
+#endif
diff --git a/src/ksquirrelpart/sq_diroperator.cpp b/src/ksquirrelpart/sq_diroperator.cpp
new file mode 100644
index 0000000..bf2232f
--- /dev/null
+++ b/src/ksquirrelpart/sq_diroperator.cpp
@@ -0,0 +1,86 @@
+/***************************************************************************
+ sq_diroperator.cpp - description
+ -------------------
+ begin : Thu Nov 29 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <kurl.h>
+#include <konq_operations.h>
+
+#include "sq_diroperator.h"
+#include "sq_libraryhandler.h"
+#include "sq_downloader.h"
+#include "sq_glwidget.h"
+
+SQ_DirOperator * SQ_DirOperator::m_inst = 0;
+
+SQ_DirOperator::SQ_DirOperator(TQObject *parent) : TQObject(parent)
+{
+ m_inst = this;
+
+ down = new SQ_Downloader(this, "SQ_Downloader [dirop]");
+
+ connect(down, TQ_SIGNAL(result(const KURL &)), this, TQ_SLOT(slotDownloaderResult(const KURL &)));
+ connect(down, TQ_SIGNAL(percents(int)), this, TQ_SLOT(slotDownloadPercents(int)));
+}
+
+SQ_DirOperator::~SQ_DirOperator()
+{}
+
+void SQ_DirOperator::execute(KFileItem *fi)
+{
+ down->kill();
+
+ SQ_GLWidget::window()->setOriginalURL(fi->url());
+
+ if(fi->url().isLocalFile())
+ executePrivate(fi);
+ else if(SQ_LibraryHandler::instance()->maybeSupported(fi->url(), fi->mimetype()) != SQ_LibraryHandler::No)
+ down->start(fi);
+}
+
+void SQ_DirOperator::slotDownloaderResult(const KURL &url)
+{
+ SQ_GLWidget::window()->setDownloadPercents(-1);
+
+ if(url.isEmpty())
+ return;
+
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, url);
+
+ executePrivate(&fi);
+}
+
+void SQ_DirOperator::executePrivate(KFileItem *fi)
+{
+ TQString fullpath = fi->url().path();
+
+ if(SQ_LibraryHandler::instance()->libraryForFile(fullpath))
+ SQ_GLWidget::window()->startDecoding(fullpath);
+}
+
+void SQ_DirOperator::slotDownloadPercents(int p)
+{
+ SQ_GLWidget::window()->setDownloadPercents(p);
+}
+
+void SQ_DirOperator::del(const KURL &u, TQWidget *parent)
+{
+ KURL::List list;
+ list.append(u);
+
+ KonqOperations::del(parent, KonqOperations::DEL, list);
+}
+
+#include "sq_diroperator.moc"
diff --git a/src/ksquirrelpart/sq_diroperator.h b/src/ksquirrelpart/sq_diroperator.h
new file mode 100644
index 0000000..73eceac
--- /dev/null
+++ b/src/ksquirrelpart/sq_diroperator.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ sq_diroperator.h - description
+ -------------------
+ begin : Thu Nov 29 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_DIROPERATOR_H
+#define SQ_DIROPERATOR_H
+
+#include <tdefileitem.h>
+
+#include <tqobject.h>
+
+class SQ_Downloader;
+
+class KURL;
+
+class SQ_DirOperator : public TQObject
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_DirOperator(TQObject *parent = 0);
+ ~SQ_DirOperator();
+
+ static SQ_DirOperator* instance() { return m_inst; }
+
+ void execute(KFileItem *item);
+
+ void del(const KURL &u, TQWidget *parent = 0);
+
+ private:
+ void executePrivate(KFileItem *);
+
+ private slots:
+
+ void slotDownloadPercents(int);
+ void slotDownloaderResult(const KURL &);
+
+ private:
+ SQ_Downloader *down;
+
+ static SQ_DirOperator *m_inst;
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_downloader.cpp b/src/ksquirrelpart/sq_downloader.cpp
new file mode 100644
index 0000000..e877850
--- /dev/null
+++ b/src/ksquirrelpart/sq_downloader.cpp
@@ -0,0 +1,143 @@
+/***************************************************************************
+ sq_downloader.cpp - description
+ -------------------
+ begin : Fri Jun 07 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tqfile.h>
+
+#include <tdeio/job.h>
+#include <tdefileitem.h>
+#include <tdetempfile.h>
+
+#include "sq_libraryhandler.h"
+#include "sq_downloader.h"
+
+#ifndef KSQUIRREL_PART
+#include "sq_archivehandler.h"
+#endif
+
+#define SQ_PREDOWNLOAD_SIZE 50
+
+SQ_Downloader::SQ_Downloader(TQObject *parent, const char *name) : TQObject(parent, name), job(0), m_error(false)
+{
+ tmp = new KTempFile;
+ tmp->setAutoDelete(true);
+ tmp->close();
+}
+
+SQ_Downloader::~SQ_Downloader()
+{
+ clean();
+
+ delete tmp;
+}
+
+void SQ_Downloader::start(KFileItem *fi)
+{
+ m_error = false;
+ mURL = fi->url();
+
+ emitPercents = false;
+ startTime = TQTime::currentTime();
+ size = 0;
+ totalSize = fi->size();
+
+#ifndef KSQUIRREL_PART
+ nomime = SQ_ArchiveHandler::instance()->findProtocolByMime(fi->mimetype()).isEmpty();
+#else
+ nomime = true;
+#endif
+
+ job = TDEIO::get(mURL, false, false);
+
+ clean();
+
+ continueDownload = false;
+
+ connect(job, TQ_SIGNAL(data(TDEIO::Job *, const TQByteArray &)), this, TQ_SLOT(slotData(TDEIO::Job *, const TQByteArray &)));
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotDataResult(TDEIO::Job *)));
+}
+
+void SQ_Downloader::slotData(TDEIO::Job *job, const TQByteArray &ba)
+{
+ size += ba.size();
+
+ TQFile f(tmp->name());
+
+ if(f.open(IO_WriteOnly | IO_Append))
+ {
+ f.writeBlock(ba);
+ f.close();
+ }
+
+ if(emitPercents || startTime.msecsTo(TQTime::currentTime()) > 1000)
+ {
+ emit percents(size);
+ emitPercents = true;
+ }
+
+ // 50 bytes are enough to determine file type
+ if(size >= SQ_PREDOWNLOAD_SIZE && !continueDownload && totalSize != size)
+ {
+ // cancel download (file type is not supported)
+ SQ_LIBRARY *lib = SQ_LibraryHandler::instance()->libraryForFile(tmp->name());
+
+ if(nomime && !lib)
+ {
+ job->kill(false); // kill job & emit result
+ }
+ else
+ {
+ // nice, we can open this image/archive - continue download
+ continueDownload = true;
+ }
+ }
+}
+
+void SQ_Downloader::slotDataResult(TDEIO::Job *cpjob)
+{
+ job = 0;
+
+ // job error
+ if(cpjob->error() && cpjob->error() != TDEIO::ERR_USER_CANCELED)
+ {
+ m_error = true;
+ emit result(mEmptyURL);
+ }
+ else if(cpjob->error() == TDEIO::ERR_USER_CANCELED) // not supported image/archive type -
+ // emit empty url without errors
+ {
+ emit result(mEmptyURL);
+ }
+ else // supported image type/archive type (no errors or job killed)
+ {
+ emit result(KURL::fromPathOrURL(tmp->name()));
+ }
+}
+
+void SQ_Downloader::clean()
+{
+ TQFile f(tmp->name());
+
+ if(f.open(IO_WriteOnly))
+ f.close();
+}
+
+void SQ_Downloader::kill()
+{
+ if(job) job->kill();
+}
+
+#include "sq_downloader.moc"
diff --git a/src/ksquirrelpart/sq_downloader.h b/src/ksquirrelpart/sq_downloader.h
new file mode 100644
index 0000000..6b91a3f
--- /dev/null
+++ b/src/ksquirrelpart/sq_downloader.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ sq_downloader.h - description
+ -------------------
+ begin : Fri Jun 07 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_DOWNLOADER_H
+#define SQ_DOWNLOADER_H
+
+#include <tqobject.h>
+#include <tqdatetime.h>
+
+#include <kurl.h>
+
+class KFileItem;
+class KTempFile;
+
+namespace TDEIO { class Job; }
+
+class SQ_Downloader : public TQObject
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_Downloader(TQObject *parent = 0, const char *name = 0);
+ ~SQ_Downloader();
+
+ void start(KFileItem *fi);
+
+ bool error() const;
+
+ void clean();
+
+ void kill();
+
+ signals:
+ void result(const KURL &);
+ void percents(int);
+
+ private slots:
+ void slotData(TDEIO::Job *job, const TQByteArray &data);
+ void slotDataResult(TDEIO::Job *);
+
+ private:
+ TDEIO::Job *job;
+ KURL mEmptyURL, mURL;
+ KTempFile *tmp;
+ TDEIO::filesize_t totalSize, size;
+ bool continueDownload;
+ bool nomime;
+ bool m_error, m_lightmode;
+ TQTime startTime;
+ bool emitPercents;
+};
+
+inline
+bool SQ_Downloader::error() const
+{
+ return m_error;
+}
+
+#endif
diff --git a/src/ksquirrelpart/sq_errorstring.cpp b/src/ksquirrelpart/sq_errorstring.cpp
new file mode 100644
index 0000000..f762ee3
--- /dev/null
+++ b/src/ksquirrelpart/sq_errorstring.cpp
@@ -0,0 +1,58 @@
+/***************************************************************************
+ sq_errorstring.cpp - description
+ -------------------
+ begin : ??? ??? 26 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_errorstring.h"
+
+#include <ksquirrel-libs/error.h>
+
+SQ_ErrorString * SQ_ErrorString::m_instance = 0;
+
+SQ_ErrorString::SQ_ErrorString(TQObject *parent) : TQObject(parent)
+{
+ m_instance = this;
+
+ // fill map with translated messages
+ messages.insert(SQE_OK, TQString::fromLatin1("OK"));
+ messages.insert(SQE_R_NOFILE, i18n("cannot open file for reading"));
+ messages.insert(SQE_R_BADFILE, i18n("file corrupted"));
+ messages.insert(SQE_R_NOMEMORY, i18n("no memory"));
+ messages.insert(SQE_R_NOTSUPPORTED, i18n("file type not supported"));
+ messages.insert(SQE_R_WRONGDIM, i18n("wrong image dimensions"));
+ messages.insert(SQE_W_NOFILE, i18n("cannot open file for writing"));
+ messages.insert(SQE_W_NOTSUPPORTED, i18n("write feature is not supported"));
+ messages.insert(SQE_W_ERROR, i18n("write error (check free space)"));
+ messages.insert(SQE_W_WRONGPARAMS, i18n("wrong parameters"));
+ messages.insert(SQE_NOTFINISHED, i18n("Editing process is not finished yet"));
+}
+
+SQ_ErrorString::~SQ_ErrorString()
+{}
+
+// Get string by error code.
+TQString SQ_ErrorString::string(const int code)
+{
+ return messages[code];
+}
+
+TQString SQ_ErrorString::stringSN(const int code)
+{
+ return messages[code] + '\n';
+}
diff --git a/src/ksquirrelpart/sq_errorstring.h b/src/ksquirrelpart/sq_errorstring.h
new file mode 100644
index 0000000..400451d
--- /dev/null
+++ b/src/ksquirrelpart/sq_errorstring.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ sq_errorstring.h - description
+ -------------------
+ begin : ??? ??? 26 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_ERRORSTRING_H
+#define SQ_ERRORSTRING_H
+
+#include <tqmap.h>
+#include <tqobject.h>
+
+#include <tdelocale.h>
+
+#define SQE_NOTFINISHED 10000
+
+/*
+ * Class SQ_ErrorString will return translated string representation of
+ * error code.
+ */
+
+class SQ_ErrorString : public TQObject
+{
+ public:
+ SQ_ErrorString(TQObject *parent = 0);
+ ~SQ_ErrorString();
+
+ /*
+ * Get string representation of error.
+ */
+ TQString string(const int code);
+
+ /*
+ * string() + "\n"
+ */
+ TQString stringSN(const int code);
+
+ static SQ_ErrorString* instance() { return m_instance; }
+
+ private:
+ TQMap<int, TQString> messages;
+ static SQ_ErrorString *m_instance;
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_externaltool.cpp b/src/ksquirrelpart/sq_externaltool.cpp
new file mode 100644
index 0000000..4f6c752
--- /dev/null
+++ b/src/ksquirrelpart/sq_externaltool.cpp
@@ -0,0 +1,245 @@
+/***************************************************************************
+ sq_externaltool.cpp - description
+ -------------------
+ begin : ??? ??? 12 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqfile.h>
+
+#include <kstringhandler.h>
+#include <tdelocale.h>
+#include <kicontheme.h>
+#include <kstandarddirs.h>
+#include <tdeprocess.h>
+#include <tdemessagebox.h>
+
+#include "sq_iconloader.h"
+#include "sq_externaltool.h"
+#include "sq_popupmenu.h"
+#include "sq_config.h"
+
+SQ_ExternalTool * SQ_ExternalTool::m_instance = 0;
+
+Tool::Tool()
+{}
+
+Tool::Tool(const TQString &pix, const TQString &nam, const TQString &com)
+{
+ icon = pix;
+ name = nam;
+ command = com;
+}
+
+SQ_ExternalTool::SQ_ExternalTool(TQObject *parent) : TQObject(parent), TQValueVector<Tool>()
+{
+ m_instance = this;
+ menu = new SQ_PopupMenu(0, "External tools");
+
+ connect(menu, TQ_SIGNAL(aboutToShow()), this, TQ_SLOT(slotAboutToShowMenu()));
+ connect(menu, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotActivateTool(int)));
+
+ TQString str, tmp;
+
+ SQ_Config::instance()->setGroup("External tools");
+
+ TQStringList names = SQ_Config::instance()->readListEntry("names");
+ TQStringList commands = SQ_Config::instance()->readListEntry("commands");
+ TQStringList icons = SQ_Config::instance()->readListEntry("icons");
+
+ for(TQStringList::iterator it_n = names.begin(),it_c = commands.begin(),it_i = icons.begin();
+ it_n != names.end() || it_c != commands.end() || it_i != icons.end();
+ ++it_n, ++it_c, ++it_i)
+ {
+ append(Tool(*it_i, *it_n, *it_c));
+ }
+}
+
+SQ_ExternalTool::~SQ_ExternalTool()
+{
+ delete menu;
+}
+
+TQString SQ_ExternalTool::toolPixmap(const int i)
+{
+ return (*this)[i].icon;
+}
+
+TQString SQ_ExternalTool::toolName(const int i)
+{
+ return (*this)[i].name;
+}
+
+TQString SQ_ExternalTool::toolCommand(const int i)
+{
+ return (*this)[i].command;
+}
+
+/*
+ * Recreate current popop menu.
+ */
+SQ_PopupMenu* SQ_ExternalTool::newPopupMenu()
+{
+ int id;
+
+ // clear menu
+ menu->clear();
+
+ menu->insertTitle(i18n("No file selected"));
+
+ // construct new menu
+ for(unsigned int i = 0;i < count();i++)
+ {
+ id = menu->insertItem(SQ_IconLoader::instance()->loadIcon(toolPixmap(i), TDEIcon::Desktop, TDEIcon::SizeSmall), toolName(i));
+ menu->setItemParameter(id, i);
+ }
+
+ return menu;
+}
+
+/*
+ * Get current popup menu.
+ */
+SQ_PopupMenu* SQ_ExternalTool::constPopupMenu() const
+{
+ return menu;
+}
+
+/*
+ * Write tools to config file
+ */
+void SQ_ExternalTool::writeEntries()
+{
+ // no tools ?
+ if(!count()) return;
+
+ TQString num;
+
+ // delete old group with old items
+ SQ_Config::instance()->deleteGroup("External tools");
+ SQ_Config::instance()->setGroup("External tools");
+ TQStringList names, icons, commands;
+
+ // write items in config file
+ for(TQValueVector<Tool>::iterator it = begin();it != end();++it)
+ {
+ names.append((*it).name);
+ icons.append((*it).icon);
+ commands.append((*it).command);
+ }
+
+ SQ_Config::instance()->writeEntry("names", names);
+ SQ_Config::instance()->writeEntry("commands", commands);
+ SQ_Config::instance()->writeEntry("icons", icons);
+}
+
+/*
+ * Invoked, when user executed popup menu with external tools.
+ * This slot will do some useful stuff.
+ */
+void SQ_ExternalTool::slotAboutToShowMenu()
+{
+ if(!items.count())
+ {
+ menu->changeTitle(i18n("No file selected"));
+ return;
+ }
+
+ KFileItem *item = items.first();
+
+ if(!item)
+ {
+ menu->changeTitle(i18n("No file selected"));
+ return;
+ }
+
+ // make title shorter
+ TQString file = KStringHandler::rsqueeze(item->name(), 30);
+
+ // finally, change title
+ TQString final = (items.count() == 1 || items.count() == 0) ? file : (file + TQString::fromLatin1(" (+%1)").arg(items.count()-1));
+ menu->changeTitle(final);
+}
+
+void SQ_ExternalTool::slotActivateTool(int id)
+{
+ KURL::List list;
+
+ if(items.isEmpty()) return;
+
+ int index = menu->itemParameter(id);
+
+ KFileItem *f = items.first();
+
+ while(f)
+ {
+ list.append(f->url());
+ f = items.next();
+ }
+
+ items.clear();
+
+ if(list.empty()) return;
+
+ KShellProcess proc;
+
+ // get appropriate tool
+ Tool *tool = &at(index);
+ TQString comm = tool->command;
+
+ int per_f = comm.contains("%f");
+ int per_F = comm.contains("%F");
+
+ // %f = single file
+ // %F = multiple files
+ if(per_f && per_F)
+ {
+ KMessageBox::error(0, i18n("Command cannot contain both \"%f\" and \"%F\""), i18n("Error processing command"));
+ return;
+ }
+ else if(!per_f && !per_F)
+ {
+ KMessageBox::error(0, i18n("Command should contain \"%f\" or \"%F\""), i18n("Error processing command"));
+ return;
+ }
+ else if(per_f)
+ {
+ KURL u = list.first();
+ comm.replace("%f", KShellProcess::quote(u.isLocalFile() ? u.path() : u.prettyURL()));
+ proc << comm;
+ }
+ else
+ {
+ TQString files;
+
+ KURL::List::iterator itEnd = list.end();
+
+ for(KURL::List::iterator it = list.begin();it != itEnd;++it)
+ {
+ files.append(KShellProcess::quote((*it).isLocalFile() ? (*it).path() : (*it).prettyURL()));
+ files.append(" ");
+ }
+
+ comm.replace("%F", files);
+ proc << comm;
+ }
+
+ // start process
+ proc.start(TDEProcess::DontCare);
+}
+
+#include "sq_externaltool.moc"
diff --git a/src/ksquirrelpart/sq_externaltool.h b/src/ksquirrelpart/sq_externaltool.h
new file mode 100644
index 0000000..12e6858
--- /dev/null
+++ b/src/ksquirrelpart/sq_externaltool.h
@@ -0,0 +1,104 @@
+/***************************************************************************
+ sq_externaltool.h - description
+ -------------------
+ begin : ??? ??? 12 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_EXTERNALTOOL_H
+#define SQ_EXTERNALTOOL_H
+
+#include <tqstring.h>
+#include <tqobject.h>
+#include <tqvaluevector.h>
+
+#include <tdefileitem.h>
+
+class SQ_PopupMenu;
+
+struct Tool
+{
+ Tool();
+ Tool(const TQString &, const TQString &, const TQString &);
+
+ TQString name, command;
+ TQString icon;
+};
+
+/*
+ * Class which manages external tools. It store all available external tools
+ * in memory, and create popup menu where external tools been inserted.
+ */
+
+class SQ_ExternalTool : public TQObject, public TQValueVector<Tool>
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_ExternalTool(TQObject *parent = 0);
+ ~SQ_ExternalTool();
+
+ /*
+ * Get pixmap, name or command of external tool.
+ */
+ TQString toolPixmap(const int i);
+ TQString toolName(const int i);
+ TQString toolCommand(const int i);
+
+ void setItems(const KFileItemList &);
+
+ /*
+ * Recreate current popop menu.
+ */
+ SQ_PopupMenu* newPopupMenu();
+
+ /*
+ * Get current popup menu.
+ */
+ SQ_PopupMenu* constPopupMenu() const;
+
+ /*
+ * Write tools to config file as TQStringLists
+ */
+ void writeEntries();
+
+ static SQ_ExternalTool* instance() { return m_instance; }
+
+ private slots:
+
+ /*
+ * Invoked, when user executed popup menu with external tools.
+ * This slot will do some useful stuff.
+ */
+ void slotAboutToShowMenu();
+ void slotActivateTool(int);
+
+ private:
+ /*
+ * Popup menu with all tools.
+ */
+ SQ_PopupMenu *menu;
+
+ KFileItemList items;
+
+ static SQ_ExternalTool *m_instance;
+};
+
+inline
+void SQ_ExternalTool::setItems(const KFileItemList &itms)
+{
+ items = itms;
+}
+
+#endif
diff --git a/src/ksquirrelpart/sq_filedialog.cpp b/src/ksquirrelpart/sq_filedialog.cpp
new file mode 100644
index 0000000..5bfccdb
--- /dev/null
+++ b/src/ksquirrelpart/sq_filedialog.cpp
@@ -0,0 +1,44 @@
+/***************************************************************************
+ sq_filedialog.cpp - description
+ -------------------
+ begin : Mon Mar 5 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tdefilefiltercombo.h>
+
+#include "sq_filedialog.h"
+
+SQ_FileDialog::SQ_FileDialog(const TQString &path, TQWidget *parent)
+ : KFileDialog(path, TQString(), parent, "select_a_file", true)
+{}
+
+SQ_FileDialog::~SQ_FileDialog()
+{}
+
+void SQ_FileDialog::updateCombo(bool enable)
+{
+ filterWidget->setEditable(enable);
+
+ slotFilterChanged();
+}
+
+TQString SQ_FileDialog::nameFilter() const
+{
+ return filterWidget->currentText();
+}
+
+void SQ_FileDialog::setCurrentFilter(const TQString &f)
+{
+ filterWidget->setCurrentFilter(f);
+}
diff --git a/src/ksquirrelpart/sq_filedialog.h b/src/ksquirrelpart/sq_filedialog.h
new file mode 100644
index 0000000..7fe79cb
--- /dev/null
+++ b/src/ksquirrelpart/sq_filedialog.h
@@ -0,0 +1,39 @@
+/***************************************************************************
+ sq_filedialog.h - description
+ -------------------
+ begin : Mon Mar 5 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_FILEDIALOG_H
+#define SQ_FILEDIALOG_H
+
+#include <tdefiledialog.h>
+
+/**
+ *@author Baryshev Dmitry
+ */
+
+class SQ_FileDialog : public KFileDialog
+{
+ public:
+ SQ_FileDialog(const TQString &path, TQWidget *parent);
+ ~SQ_FileDialog();
+
+ TQString nameFilter() const;
+ void updateCombo(bool enable);
+
+ void setCurrentFilter(const TQString &);
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_glparts.cpp b/src/ksquirrelpart/sq_glparts.cpp
new file mode 100644
index 0000000..ec55d89
--- /dev/null
+++ b/src/ksquirrelpart/sq_glparts.cpp
@@ -0,0 +1,219 @@
+/***************************************************************************
+ sq_glparts.cpp - description
+ -------------------
+ begin : ??? ??? 13 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "sq_glparts.h"
+#include "sq_library.h"
+
+#include <ksquirrel-libs/fmt_codec_base.h>
+
+/* ***************************************************************************************** */
+
+Parts::Parts() : w(0), h(0), realw(0), realh(0), m_parts(0), buffer(0)
+{}
+
+Part::Part() : x1(0), y1(0), x2(0), y2(0), tex(0), list(0)
+{}
+
+/* ***************************************************************************************** */
+
+memoryPart::memoryPart(const int sz) : m_size(sz), m_data(0)
+{}
+
+memoryPart::~memoryPart()
+{
+ del();
+}
+
+void memoryPart::create()
+{
+ m_data = new RGBA [m_size];
+
+// if(m_data)
+// memset(m_data, 0, m_size * sizeof(RGBA));
+}
+
+// Delete textures and display lists.
+void Parts::removeParts()
+{
+ if(!m_parts.empty())
+ {
+ int toy = tilesy.size();
+ int toxy = tilesx.size() * toy;
+
+ for(int z = 0;z < toxy;z++)
+ glDeleteTextures(1, &m_parts[z].tex);
+
+ glDeleteLists(m_parts[0].list, toy);
+
+ m_parts.clear();
+ }
+}
+
+// Create parts: generate textures and display lists.
+bool Parts::makeParts()
+{
+ int z;
+ int toy = tilesy.size();
+
+ GLuint base = glGenLists(toy);
+
+ if(!base)
+ return false;
+
+ Part pt;
+ int tox = tilesx.size();
+ int toxy = tox * toy;
+
+ for(z = 0;z < toxy;z++)
+ {
+ glGenTextures(1, &pt.tex);
+ m_parts.push_back(pt);
+ }
+
+ // calculate display list's id
+ for(z = 0;z < toy;z++)
+ m_parts[z * tox].list = base + z;
+
+ return true;
+}
+
+// Calculate coordinates for textures
+void Parts::computeCoords()
+{
+ Part *p;
+ int index = 0;
+ float X, Y;
+
+ Y = (float)h / 2.0;
+
+ int tlsy = tilesy.size();
+ int tlsx = tilesx.size();
+
+ for(int y = 0;y < tlsy;y++)
+ {
+ X = -(float)w / 2.0;
+
+ for(int x = 0;x < tlsx;x++)
+ {
+ p = &m_parts[index];
+
+ p->x1 = X;
+ p->y1 = Y;
+ p->x2 = X + tilesx[x];
+ p->y2 = Y - tilesy[y];
+
+ p->tx1 = 0.0;
+ p->tx2 = 1.0;
+ p->ty1 = 0.0;
+ p->ty2 = 1.0;
+
+ index++;
+ X += tilesx[x];
+ }
+
+ Y -= tilesy[y];
+ }
+}
+
+/* ***************************************************************************************** */
+
+Tab::Tab()
+{
+ empty();
+}
+
+Tab::~Tab()
+{}
+
+void Tab::clearParts()
+{
+ if(broken) return;
+
+ std::vector<Parts>::iterator itEnd = parts.end();
+
+ for(std::vector<Parts>::iterator it = parts.begin();it != itEnd;++it)
+ {
+ // delete textures and memory buffers
+ (*it).removeParts();
+ (*it).deleteBuffer();
+ }
+
+ parts.clear();
+
+ finfo.image.clear();
+ finfo.meta.clear();
+}
+
+void Tab::removeParts()
+{
+ if(broken) return;
+
+ std::vector<Parts>::iterator itEnd = parts.end();
+
+ for(std::vector<Parts>::iterator it = parts.begin();it != itEnd;++it)
+ (*it).removeParts();
+}
+
+void Tab::remakeParts()
+{
+ if(broken) return;
+
+ std::vector<Parts>::iterator itEnd = parts.end();
+
+ for(std::vector<Parts>::iterator it = parts.begin();it != itEnd;++it)
+ {
+ (*it).makeParts();
+ (*it).computeCoords();
+ }
+}
+
+void Tab::empty()
+{
+ nullMatrix();
+
+ orient = -1;
+ rotate = 0;
+ fmt_size = 0;
+ lib = 0;
+ codeK = 0;
+ current = 0;
+ curangle = 0;
+ total = 0;
+ sx = sy = sw = sh = 0;
+ elapsed = 0;
+
+ wm = TQWMatrix();
+
+ glselection = -1;
+ srect = TQRect();
+
+ manualBlocked = false;
+ isflippedV = isflippedH = false;
+ broken = false;
+
+ m_original = KURL();
+ File = TQString();
+ m_File = TQString();
+ quickImageInfo = TQString();
+ fmt_ext = TQString();
+}
+
+void Tab::nullMatrix()
+{
+ for(int i = 0;i < 12;i++)
+ matrix[i] = (GLfloat)(i % 5 == 0);
+}
diff --git a/src/ksquirrelpart/sq_glparts.h b/src/ksquirrelpart/sq_glparts.h
new file mode 100644
index 0000000..24c538c
--- /dev/null
+++ b/src/ksquirrelpart/sq_glparts.h
@@ -0,0 +1,152 @@
+/***************************************************************************
+ sq_glparts.h - description
+ -------------------
+ begin : ??? Mar 13 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_GLPARTS_H
+#define SQ_GLPARTS_H
+
+#include <tqgl.h>
+
+#include <tqwmatrix.h>
+#include <tqrect.h>
+
+#include <kurl.h>
+
+#include <vector>
+
+#include <ksquirrel-libs/fmt_defs.h>
+
+struct SQ_LIBRARY;
+class fmt_codec_base;
+
+class memoryPart
+{
+ public:
+ memoryPart(const int sz);
+ ~memoryPart();
+
+ // create/delete memory buffer
+ void create();
+ void del();
+
+ bool valid() const;
+ RGBA *data();
+
+ private:
+ int m_size;
+ RGBA *m_data;
+};
+
+inline
+RGBA* memoryPart::data()
+{
+ return m_data;
+}
+
+inline
+void memoryPart::del()
+{
+ delete [] m_data;
+ m_data = 0;
+}
+
+inline
+bool memoryPart::valid() const
+{
+ return m_data != 0;
+}
+
+/* *************************************************************** */
+
+struct Part
+{
+ Part();
+
+ float x1, y1, x2, y2, tx1, tx2, ty1, ty2;
+ unsigned int tex;
+ GLuint list;
+};
+
+/* *************************************************************** */
+
+// one image page. All pages are stored in SQ_GLWidget::parts
+struct Parts
+{
+ Parts();
+
+ int w, h, realw, realh;
+
+ std::vector<Part> m_parts;
+ std::vector<int> tilesx, tilesy;
+ memoryPart *buffer;
+
+ bool makeParts();
+ void removeParts();
+ void computeCoords();
+ void deleteBuffer();
+};
+
+inline
+void Parts::deleteBuffer()
+{
+ delete buffer;
+ buffer = 0;
+}
+
+/* *************************************************************** */
+
+struct Tab
+{
+ Tab();
+ ~Tab();
+
+ void nullMatrix();
+ void empty();
+ void clearParts();
+ void removeParts();
+ void remakeParts();
+
+ GLfloat matrix[12];
+ GLfloat curangle;
+
+ KURL m_original;
+ TQString File, m_File, quickImageInfo;
+ TQString fmt_ext;
+
+ TQWMatrix wm;
+ TQRect srect;
+
+ int orient;
+ int current;
+ int fmt_size;
+ int total;
+ int glselection;
+ int sx, sy, sw, sh;
+ int elapsed;
+
+ bool rotate;
+ bool manualBlocked;
+ bool isflippedV, isflippedH;
+ bool broken;
+
+ std::vector<Parts> parts;
+ fmt_info finfo;
+
+ SQ_LIBRARY *lib;
+ fmt_codec_base *codeK;
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_glselectionpainter.cpp b/src/ksquirrelpart/sq_glselectionpainter.cpp
new file mode 100644
index 0000000..9594f28
--- /dev/null
+++ b/src/ksquirrelpart/sq_glselectionpainter.cpp
@@ -0,0 +1,145 @@
+/***************************************************************************
+ sq_glselectionpainter.cpp - description
+ -------------------
+ begin : Apr 4 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tqbitmap.h>
+#include <tqpainter.h>
+
+#include <cmath>
+
+#include "sq_glwidget.h"
+#include "sq_glselectionpainter.h"
+
+static const int len = 4;
+static const int len2 = 10;
+static const int lenc = 2;
+static const int lenc2 = lenc / 2;
+static const double rad_const = 3.14159265358979323846 / 180.0;
+
+/* ******************************************************************* */
+
+SQ_GLSelectionPainter::SQ_GLSelectionPainter(SQ_GLWidget *widget)
+ : w(widget), sourcew(1), sourceh(1), sw(0), sh(0), sx(0), sy(0),
+ angle(0), m_valid(false), m_shown(false)
+{}
+
+SQ_GLSelectionPainter::~SQ_GLSelectionPainter()
+{}
+
+void SQ_GLSelectionPainter::begin(Type tp, int x, int y, bool U)
+{
+ // end previous drawing if any
+ end();
+
+ m_type = tp;
+
+ hackXY(x, y);
+
+ sx = xmoveold = x;
+ sy = ymoveold = y;
+ sw = 0;
+ sh = 0;
+
+ m_valid = true;
+ m_shown = true;
+
+ if(U) w->updateGLA();
+}
+
+void SQ_GLSelectionPainter::move(int x, int y)
+{
+ hackXY(x, y);
+
+ int X = TQMAX(x, xmoveold);
+ int Y = TQMIN(y, ymoveold);
+ int Xmin = TQMIN(x, xmoveold);
+ int Ymin = TQMAX(y, ymoveold);
+
+ sx = Xmin;
+ sy = Ymin;
+ sw = X - Xmin;
+ sh = Ymin - Y;
+
+ angle += 3;
+
+ if(angle > 360)
+ angle = 0;
+
+ // SQ_GLWidget::paintGL() will call draw()
+ w->updateGLA();
+}
+
+void SQ_GLSelectionPainter::end()
+{
+ m_valid = false;
+ m_shown = false;
+
+ w->updateGLA();
+}
+
+void SQ_GLSelectionPainter::drawEllipse(float xradius, float yradius)
+{
+ w->makeCurrent();
+
+ double degInRad;
+
+ glBegin(GL_LINE_LOOP);
+ glColor4f(1,0,1,1);
+
+ for(int i = 0; i < 360; i++)
+ {
+ degInRad = rad_const * i;
+ glVertex2f(cos(degInRad) * xradius, sin(degInRad) * yradius);
+ }
+
+ glColor4f(1,1,1,1);
+ glEnd();
+}
+
+void SQ_GLSelectionPainter::drawRect()
+{
+ w->makeCurrent();
+
+ glBegin(GL_LINE_LOOP);
+ glColor4f(1,0,1,1);
+
+ glVertex2f(-sw/2, sh/2);
+ glVertex2f(sw/2, sh/2);
+ glVertex2f(sw/2, -sh/2);
+ glVertex2f(-sw/2, -sh/2);
+
+ glColor4f(1,1,1,1);
+ glEnd();
+}
+
+void SQ_GLSelectionPainter::draw()
+{
+ if(!sw || !sh)
+ return;
+
+ if(m_type == Ellipse)
+ drawEllipse(sw/2, sh/2);
+ else
+ drawRect();
+
+ // center rectangle
+ if(sw > lenc && sh > lenc)
+ {
+ glColor4f(1,0,1,1);
+ glRectf(-lenc2, lenc2, lenc2, -lenc2);
+ glColor4f(1,1,1,1);
+ }
+}
diff --git a/src/ksquirrelpart/sq_glselectionpainter.h b/src/ksquirrelpart/sq_glselectionpainter.h
new file mode 100644
index 0000000..ea39286
--- /dev/null
+++ b/src/ksquirrelpart/sq_glselectionpainter.h
@@ -0,0 +1,151 @@
+/***************************************************************************
+ sq_glselectionpainter.h - description
+ -------------------
+ begin : Apr 4 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_GLSELECTIONPAINTER_H
+#define SQ_GLSELECTIONPAINTER_H
+
+#include <tqrect.h>
+#include <tqpoint.h>
+
+class SQ_GLWidget;
+
+/*
+ * This is a selection painter for SQ_GLWidget.
+ *
+ * Selection can be shown as rectangle and ellipse.
+ *
+ * Ellipsis selection mainly used in redeye filter.
+ */
+
+class SQ_GLSelectionPainter
+{
+ public:
+ enum Type { Rectangle, Ellipse };
+
+ SQ_GLSelectionPainter(SQ_GLWidget *widget);
+ ~SQ_GLSelectionPainter();
+
+ void setSourceSize(int, int);
+
+ TQPoint center() const;
+
+ void draw();
+
+ /*
+ * Set selection type - rectangle or ellipse
+ */
+ int type() const;
+
+ /*
+ * when selection is drawn and visible, it's valid.
+ * After end() it becomes invalid.
+ */
+ bool valid() const;
+
+ void setVisible(bool vis);
+
+ void begin(Type tp, int x, int y, bool U = true);
+ void move(int x, int y);
+ void setGeometry(const TQRect &rc);
+ void end();
+
+ /*
+ * Selected rectangle geometry
+ */
+ TQPoint pos() const;
+ TQSize size() const;
+
+ private:
+ void drawEllipse(float xradius, float yradius);
+ void drawRect();
+ void hackXY(int &x, int &y);
+
+ private:
+ SQ_GLWidget *w;
+ int sourcew, sourceh;
+ int sw, sh, sx, sy;
+
+ int angle;
+ int xmoveold, ymoveold;
+ bool m_valid, m_shown;
+ Type m_type;
+};
+
+inline
+TQPoint SQ_GLSelectionPainter::pos() const
+{
+ return valid() ? TQPoint(sourcew/2 + sx, sourceh/2 - sy) : TQPoint();
+}
+
+inline
+TQSize SQ_GLSelectionPainter::size() const
+{
+ return valid() ? TQSize(sw, sh) : TQSize();
+}
+
+inline
+int SQ_GLSelectionPainter::type() const
+{
+ return m_type;
+}
+
+inline
+void SQ_GLSelectionPainter::setGeometry(const TQRect &rc)
+{
+ int X = rc.x(), Y = rc.y();
+
+ hackXY(X, Y);
+
+ sx = X;
+ sy = Y;
+ sw = rc.width();
+ sh = rc.height();
+}
+
+inline
+void SQ_GLSelectionPainter::setSourceSize(int w, int h)
+{
+ sourcew = w;
+ sourceh = h;
+}
+
+inline
+void SQ_GLSelectionPainter::setVisible(bool vis)
+{
+ if(m_valid) m_shown = vis;
+}
+
+inline
+bool SQ_GLSelectionPainter::valid() const
+{
+ return m_valid && m_shown;
+}
+
+inline
+TQPoint SQ_GLSelectionPainter::center() const
+{
+ return TQPoint(sx + sw/2, sy - sh/2);
+}
+
+inline
+void SQ_GLSelectionPainter::hackXY(int &x, int &y)
+{
+ x -= sourcew / 2;
+ y = sourceh / 2 - y;
+}
+
+#endif
diff --git a/src/ksquirrelpart/sq_glu.cpp b/src/ksquirrelpart/sq_glu.cpp
new file mode 100644
index 0000000..8e17e31
--- /dev/null
+++ b/src/ksquirrelpart/sq_glu.cpp
@@ -0,0 +1,110 @@
+/***************************************************************************
+ sq_glu.cpp - description
+ -------------------
+ begin : ??? ??? 29 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ * Copyright (C) 1995-2001 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_glu.h"
+
+#include <cmath>
+
+/*
+ * Replacement for gluLookAt().
+ */
+void SQ_GLU::gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz)
+{
+ GLdouble m[16];
+ GLdouble x[3], y[3], z[3];
+ GLdouble mag;
+
+ z[0] = eyex - centerx;
+ z[1] = eyey - centery;
+ z[2] = eyez - centerz;
+
+ mag = sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
+
+ if(mag)
+ {
+ z[0] /= mag;
+ z[1] /= mag;
+ z[2] /= mag;
+ }
+
+ y[0] = upx;
+ y[1] = upy;
+ y[2] = upz;
+
+ x[0] = y[1] * z[2] - y[2] * z[1];
+ x[1] = -y[0] * z[2] + y[2] * z[0];
+ x[2] = y[0] * z[1] - y[1] * z[0];
+
+ y[0] = z[1] * x[2] - z[2] * x[1];
+ y[1] = -z[0] * x[2] + z[2] * x[0];
+ y[2] = z[0] * x[1] - z[1] * x[0];
+
+ mag = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
+
+ if(mag)
+ {
+ x[0] /= mag;
+ x[1] /= mag;
+ x[2] /= mag;
+ }
+
+ mag = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
+
+ if(mag)
+ {
+ y[0] /= mag;
+ y[1] /= mag;
+ y[2] /= mag;
+ }
+
+#define M(row,col) m[col*4+row]
+ M(0, 0) = x[0];
+ M(0, 1) = x[1];
+ M(0, 2) = x[2];
+ M(0, 3) = 0.0;
+ M(1, 0) = y[0];
+ M(1, 1) = y[1];
+ M(1, 2) = y[2];
+ M(1, 3) = 0.0;
+ M(2, 0) = z[0];
+ M(2, 1) = z[1];
+ M(2, 2) = z[2];
+ M(2, 3) = 0.0;
+ M(3, 0) = 0.0;
+ M(3, 1) = 0.0;
+ M(3, 2) = 0.0;
+ M(3, 3) = 1.0;
+#undef M
+
+ glMultMatrixd(m);
+ glTranslated(-eyex, -eyey, -eyez);
+}
diff --git a/src/ksquirrelpart/sq_glu.h b/src/ksquirrelpart/sq_glu.h
new file mode 100644
index 0000000..7da7a80
--- /dev/null
+++ b/src/ksquirrelpart/sq_glu.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ sq_glu.h - description
+ -------------------
+ begin : ??? ??? 29 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ * Copyright (C) 1995-2001 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef SQ_GLU_H
+#define SQ_GLU_H
+
+#include <GL/gl.h>
+
+/*
+ * SQ_GLU is a replacement for libGLU. SQ_GLWidget uses only one method
+ * in original GLU library - gluLookAt(). It would be better to place it
+ * in standalone namespace, and remove -lGLU dependency at all.
+ *
+ * Note: Now KSquirrel doesn't use GLU, but TQt's TQGLWidget still
+ * depends on <GL/glu.h>
+ */
+
+namespace SQ_GLU
+{
+ /*
+ * Replacement for gluLookAt().
+ */
+ void gluLookAt(GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble);
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_glview.cpp b/src/ksquirrelpart/sq_glview.cpp
new file mode 100644
index 0000000..8fb909a
--- /dev/null
+++ b/src/ksquirrelpart/sq_glview.cpp
@@ -0,0 +1,114 @@
+/***************************************************************************
+ sq_glview.cpp - description
+ -------------------
+ begin : Thu Nov 29 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tdeglobal.h>
+
+#include "sq_glview.h"
+
+SQ_GLView * SQ_GLView::m_inst = 0;
+
+/***************************************/
+
+SQ_TextSetter::SQ_TextSetter(TQObject *parent) : TQObject(parent)
+{
+ dest = "---";
+}
+
+SQ_TextSetter::~SQ_TextSetter()
+{}
+
+void SQ_TextSetter::setText(const TQString &s)
+{
+ dest = s;
+
+ emit changed();
+}
+
+/***************************************/
+
+SQ_GLView::SQ_GLView() : TQObject()
+{
+ m_inst = this;
+
+ map.insert("SBDecoded", new SQ_TextSetter(this));
+ map.insert("SBFrame", new SQ_TextSetter(this));
+ map.insert("SBLoaded", new SQ_TextSetter(this));
+ map.insert("SBGLZoom", new SQ_TextSetter(this));
+ map.insert("SBGLAngle", new SQ_TextSetter(this));
+ map.insert("SBFile", new SQ_TextSetter(this));
+
+ tmp = new SQ_TextSetter(this);
+
+ SQ_Setters::iterator itEnd = map.end();
+
+ for(SQ_Setters::iterator it = map.begin();it != itEnd;++it)
+ connect(it.data(), TQ_SIGNAL(changed()), this, TQ_SLOT(slotChanged()));
+}
+
+SQ_GLView::~SQ_GLView()
+{}
+
+SQ_TextSetter* SQ_GLView::sbarWidget(const TQString &name)
+{
+ SQ_Setters::iterator it = map.find(name);
+
+ return (it == map.end() ? tmp : it.data());
+}
+
+void SQ_GLView::resetStatusBar()
+{
+ SQ_Setters::iterator itEnd = map.end();
+
+ for(SQ_Setters::iterator it = map.begin();it != itEnd;++it)
+ {
+ it.data()->blockSignals(true);
+ it.data()->setText("---");
+ it.data()->blockSignals(false);
+ }
+
+ slotChanged();
+}
+
+void SQ_GLView::slotChanged()
+{
+ TQString result;
+
+ static const TQString &line = TDEGlobal::staticQString(" | ");
+
+ result.append(map["SBDecoded"]->text());
+ result.append(line);
+
+ result.append(map["SBFrame"]->text());
+ result.append(line);
+
+ result.append(map["SBLoaded"]->text());
+ result.append(line);
+
+ result.append(map["SBGLZoom"]->text());
+ result.append(line);
+
+ result.append(map["SBGLAngle"]->text());
+ result.append(line);
+
+ result.append("<b>");
+ result.append(map["SBFile"]->text());
+ result.append("</b>");
+
+ emit message(result);
+}
+
+#include "sq_glview.moc"
diff --git a/src/ksquirrelpart/sq_glview.h b/src/ksquirrelpart/sq_glview.h
new file mode 100644
index 0000000..01973d2
--- /dev/null
+++ b/src/ksquirrelpart/sq_glview.h
@@ -0,0 +1,83 @@
+/***************************************************************************
+ sq_glview.h - description
+ -------------------
+ begin : Thu Nov 29 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_GLVIEW_H
+#define SQ_GLVIEW_H
+
+#include <tqobject.h>
+#include <tqmap.h>
+#include <tqstring.h>
+
+class SQ_TextSetter : public TQObject
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_TextSetter(TQObject *parent = 0);
+ ~SQ_TextSetter();
+
+ void setText(const TQString &);
+
+ TQString text() const;
+
+ signals:
+ void changed();
+
+ private:
+ TQString dest;
+};
+
+inline
+TQString SQ_TextSetter::text() const
+{
+ return dest;
+}
+
+/***********************************************/
+
+class SQ_GLView : public TQObject
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_GLView();
+ ~SQ_GLView();
+
+ SQ_TextSetter* sbarWidget(const TQString &);
+
+ void resetStatusBar();
+
+ static SQ_GLView* window() { return m_inst; }
+
+ signals:
+ void message(const TQString &);
+
+ private slots:
+ void slotChanged();
+
+ private:
+ static SQ_GLView *m_inst;
+
+ typedef TQMap<TQString, SQ_TextSetter*> SQ_Setters;
+
+ SQ_Setters map;
+ SQ_TextSetter *tmp;
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_glwidget.cpp b/src/ksquirrelpart/sq_glwidget.cpp
new file mode 100644
index 0000000..0380090
--- /dev/null
+++ b/src/ksquirrelpart/sq_glwidget.cpp
@@ -0,0 +1,2006 @@
+/***************************************************************************
+ sq_glwidget.cpp - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqeventloop.h>
+#include <tqstringlist.h>
+#include <tqfileinfo.h>
+#include <tqdatetime.h>
+#include <tqlabel.h>
+#include <tqtimer.h>
+#include <tqdatetime.h>
+#include <tqslider.h>
+#include <tqlabel.h>
+
+#include <tdeapplication.h>
+#include <tdeaction.h>
+#include <kcursor.h>
+#include <kstandarddirs.h>
+#include <kstatusbar.h>
+#include <tdefiledialog.h>
+#include <tdeglobal.h>
+#include <tdelocale.h>
+#include <kstringhandler.h>
+#include <tdemessagebox.h>
+#include <kdebug.h>
+#include <tdeio/job.h>
+#include <tdetempfile.h>
+#include <twin.h>
+#include <ktabbar.h>
+
+#include <cmath>
+#include <cstdlib>
+
+#ifndef KSQUIRREL_PART
+#include "ksquirrel.h"
+#include "sq_widgetstack.h"
+#include "sq_glview.h"
+#include "sq_fileiconview.h"
+#include "sq_diroperator.h"
+#include "sq_hloptions.h"
+#include "sq_previewwidget.h"
+#include "sq_tabopendialog.h"
+#endif
+
+#include "sq_popupmenu.h"
+#include "sq_libraryhandler.h"
+#include "sq_config.h"
+#include "sq_glwidget_helpers.h"
+#include "sq_glwidget.h"
+#include "sq_glu.h"
+#include "sq_codecsettings.h"
+#include "sq_glselectionpainter.h"
+#include "sq_utils.h"
+#include "sq_errorstring.h"
+#include "fmt_filters.h"
+
+#include <ksquirrel-libs/fileio.h>
+#include <ksquirrel-libs/fmt_codec_base.h>
+#include <ksquirrel-libs/fmt_utils.h>
+#include <ksquirrel-libs/error.h>
+
+#ifdef SQ_HAVE_KEXIF
+#include <libkexif/kexifdata.h>
+#endif
+
+// is it enough ?
+#define SQ_FLOAT_SIGMA 1e-5
+
+#define ISFLOAT(a,b) (fabs(a - b) < SQ_FLOAT_SIGMA)
+#define ISFLOAT1(a) ISFLOAT(a, 1.0)
+#define ISFLOAT0(a) ISFLOAT(a, 0.0)
+
+#define SQ_TAB_TEXT_LENGTH 30
+
+/* ***************************************************************************************** */
+
+SQ_GLWidget * SQ_GLWidget::m_instance = 0;
+
+static const int timer_delay_file = 5;
+static const double rad_const = 3.14159265358979323846 / 180.0;
+
+static const float SQ_WINDOW_BACKGROUND_POS = -1000.0;
+static const float SQ_IMAGE_CHECKER_POS = -999.0;
+static const float SQ_FIRST_FRAME_POS = -998.0;
+static const float SQ_MARKS_POS = -997.0;
+static const float SQ_FIRST_TILE_LAYER = -995.0;
+static const float SQ_ONSCREEN_LAYER = 10000.0;
+
+/* ***************************************************************************************** */
+
+SQ_GLWidget::SQ_GLWidget(TQWidget *parent, const char *name) : TQGLWidget(parent, name)
+{
+ kdDebug() << "+SQ_GLWidget" << endl;
+
+ // init all variables...
+ m_instance = this;
+
+#ifdef KSQUIRREL_PART
+ connect(&t_glv, TQ_SIGNAL(message(const TQString &)), this, TQ_SIGNAL(message(const TQString &)));
+#endif
+
+ zoomMenu = 0;
+ selectionMenu = 0;
+ images = 0;
+ parts_broken = 0;
+
+ ac = new TDEActionCollection(this, this, "GLWidget actionCollection");
+ changed = blocked = decoded = reset_mode = false;
+ movetype = -1;
+ buffer = new RGBA [512 * 512];
+ zoomFactor = 1.0;
+ old_id = -1;
+ menu = new TQPopupMenu(this);
+ hackResizeGL = false;
+ lastCopy = KURL::fromPathOrURL("/");
+ oldZoom = -1;
+
+ percentsLabel = new TQLabel(this);
+ percentsLabel->move(4, 4);
+ percentsLabel->hide();
+
+ tabold = tab = &taborig;
+
+ tmp = new KTempFile;
+ tmp->setAutoDelete(true);
+ tmp->close();
+
+ SQ_Config::instance()->setGroup("GL view");
+ zoom_type = SQ_Config::instance()->readNumEntry("zoom type", 2);
+ linear = SQ_Config::instance()->readBoolEntry("zoom_nice", true);
+
+ // load background for transparent image
+ BGquads = TQImage(locate("data", "images/checker.png"));
+
+ if(BGquads.isNull())
+ {
+ BGquads = TQImage(32, 32, 32);
+ BGquads.setAlphaBuffer(true);
+ BGquads.fill(0);
+ }
+
+ bindChecker = true;
+
+ zoomfactor = SQ_Config::instance()->readNumEntry("zoom", 25);
+ movefactor = SQ_Config::instance()->readNumEntry("move", 5);
+ rotatefactor = SQ_Config::instance()->readNumEntry("angle", 90);
+
+ // load cursors
+ setCursor(KCursor::arrowCursor());
+
+ setFocusPolicy(TQWidget::WheelFocus);
+ setAcceptDrops(true);
+
+ // popup menu with image pages
+ images = new TDEPopupMenu;
+ images->setCheckable(true);
+
+ // create actions
+ createActions();
+
+ // create toolbars
+ createToolbar();
+
+ // create tickmarks
+ createMarks();
+
+ initAccelsAndMenu();
+
+ enableActions(false);
+
+ KCursor::setAutoHideCursor(this, true);
+ KCursor::setHideCursorDelay(2500);
+
+#ifndef KSQUIRREL_PART
+ timer_prev = new TQTimer(this);
+ timer_next = new TQTimer(this);
+
+ TQ_CHECK_PTR(timer_prev);
+ TQ_CHECK_PTR(timer_next);
+
+ connect(timer_prev, TQ_SIGNAL(timeout()), SQ_WidgetStack::instance(), TQ_SLOT(emitPreviousSelected()));
+ connect(timer_next, TQ_SIGNAL(timeout()), SQ_WidgetStack::instance(), TQ_SLOT(emitNextSelected()));
+#endif
+
+ timer_anim = new TQTimer(this);
+
+ TQ_CHECK_PTR(timer_anim);
+
+ connect(timer_anim, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotAnimateNext()));
+
+ connect(images, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotSetCurrentImage(int)));
+ connect(images, TQ_SIGNAL(aboutToHide()), this, TQ_SLOT(slotImagesHidden()));
+ connect(images, TQ_SIGNAL(aboutToShow()), this, TQ_SLOT(slotImagesShown()));
+
+ gls = new SQ_GLSelectionPainter(this);
+}
+
+SQ_GLWidget::~SQ_GLWidget()
+{
+ kdDebug() << "-SQ_GLWidget" << endl;
+
+ delete gls;
+
+ delete parts_broken;
+
+ removeCurrentTabs();
+
+ delete selectionMenu;
+ delete zoomMenu;
+ delete images;
+ delete [] buffer;
+ delete tmp;
+}
+
+// Initialize OpenGL context. Used internally by TQGLWidget.
+void SQ_GLWidget::initializeGL()
+{
+ setClearColor();
+ glClearDepth(1.0);
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_ALPHA_TEST);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glShadeModel(GL_FLAT);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+
+ // finally, clear
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ // create "broken" image
+ initBrokenImage();
+
+ initMarks();
+}
+
+// Resize OpenGL context. Used internally by TQGLWidget.
+void SQ_GLWidget::resizeGL(int width, int height)
+{
+ gls->setSourceSize(width, height);
+
+ // set new viewport
+ glViewport(0, 0, width, height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+
+ // O(0,0) will be in the center of the window
+ glOrtho(-width/2, width/2, -height/2, height/2, 0.1f, 10000.0);
+
+ // camera setup
+ SQ_GLU::gluLookAt(0,0,1, 0,0,0, 0,1,0);
+ glMatrixMode(GL_MODELVIEW);
+
+ if(decoded && !hackResizeGL)
+ slotZoomIfLess();
+
+ hackResizeGL = false;
+}
+
+/*
+ * Fill a w x h region with texture. Generate texture if needed.
+ */
+void SQ_GLWidget::draw_background(void *bits, unsigned int *tex, int dim, GLfloat w, GLfloat h, bool &bind, bool deleteOld)
+{
+ float half_w, half_h;
+
+ half_w = w / 2.0;
+ half_h = h / 2.0;
+
+ // bind texture ?
+ if(bind)
+ {
+ // delete old texture before binding ?
+ if(deleteOld)
+ glDeleteTextures(1, tex);
+
+ // generate and bind texture
+ glGenTextures(1, tex);
+ glBindTexture(GL_TEXTURE_2D, *tex);
+
+ // setup parameters
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+
+ // assign image to texture
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dim, dim, 0, GL_RGBA, GL_UNSIGNED_BYTE, bits);
+
+ bind = false;
+ }
+ else
+ glBindTexture(GL_TEXTURE_2D, *tex);
+
+ // draw
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0, 0.0); glVertex2f(-half_w, half_h);
+ glTexCoord2f(w/(GLfloat)dim, 0.0); glVertex2f(half_w, half_h);
+ glTexCoord2f(w/(GLfloat)dim, h/(GLfloat)dim); glVertex2f(half_w, -half_h);
+ glTexCoord2f(0.0, h/(GLfloat)dim); glVertex2f(-half_w, -half_h);
+ glEnd();
+}
+
+// Redraw OpenGL context. Used internally by TQGLWidget.
+void SQ_GLWidget::paintGL()
+{
+ int z;
+
+ // clear
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ if(gls->valid())
+ {
+ matrix_push();
+ matrix_pure_reset();
+ TQPoint p = gls->center();
+
+ // move to selection center
+ MATRIX_X = p.x();
+ MATRIX_Y = p.y();
+ write_gl_matrix();
+
+ gls->draw();
+
+ matrix_pop();
+ write_gl_matrix();
+ }
+
+ glEnable(GL_TEXTURE_2D);
+
+ // draw window background ?
+ SQ_Config::instance()->setGroup("GL view");
+ if(SQ_Config::instance()->readNumEntry("GL view background type", 1) == 2)
+ {
+ static bool del = false;
+ matrix_push();
+ matrix_pure_reset();
+ matrix_move_z(SQ_WINDOW_BACKGROUND_POS);
+ draw_background(BGpixmap.bits(), &texPixmap, BGpixmap.width(), width(), height(), changed, del);
+ del = true;
+ matrix_pop();
+ write_gl_matrix();
+ }
+
+ // draw image
+ if(!reset_mode && decoded)
+ {
+ SQ_Config::instance()->setGroup("GL view");
+
+ fmt_image *im = &tab->finfo.image[tab->current];
+
+ // if the image is transparent, and we should draw background for image
+ if(im->hasalpha && SQ_Config::instance()->readBoolEntry("alpha_bkgr", true))
+ {
+ GLfloat w = (float)im->w / 2.0, h = (float)im->h / 2.0;
+
+ static const GLdouble eq[4][4] =
+ {
+ {0.0, 1.0, 0.0, 0.0},
+ {1.0, 0.0, 0.0, 0.0},
+ {0.0, -1.0, 0.0, 0.0},
+ {-1.0, 0.0, 0.0, 0.0}
+ };
+
+ // we will draw background for transparent image (quads) within
+ // entire window, and cut off useless regions with clip planes
+ glPushMatrix();
+ glTranslatef(-w, -h, 0.0);
+ glClipPlane(GL_CLIP_PLANE0, eq[0]);
+ glClipPlane(GL_CLIP_PLANE1, eq[1]);
+ glEnable(GL_CLIP_PLANE0);
+ glEnable(GL_CLIP_PLANE1);
+ glPopMatrix();
+ glPushMatrix();
+ glTranslatef(w, h, 0.0);
+ glClipPlane(GL_CLIP_PLANE2, eq[2]);
+ glClipPlane(GL_CLIP_PLANE3, eq[3]);
+ glEnable(GL_CLIP_PLANE2);
+ glEnable(GL_CLIP_PLANE3);
+ glPopMatrix();
+
+ // draw background
+ matrix_push();
+ matrix_pure_reset();
+ matrix_move_z(SQ_IMAGE_CHECKER_POS);
+ draw_background(BGquads.bits(), &texQuads, 32, width(), height(), bindChecker, !bindChecker);
+ matrix_pop();
+ write_gl_matrix();
+
+ // don't need planes any more...
+ glDisable(GL_CLIP_PLANE3);
+ glDisable(GL_CLIP_PLANE2);
+ glDisable(GL_CLIP_PLANE1);
+ glDisable(GL_CLIP_PLANE0);
+ }
+
+ matrix_move_z(SQ_FIRST_FRAME_POS);
+
+ Parts *pt = tab->broken ? parts_broken : &tab->parts[tab->current];
+
+ // draw current image
+ int toy = pt->tilesy.size();
+ int tox = pt->tilesx.size();
+ for(z = 0;z < toy;z++)
+ if(glIsList(pt->m_parts[z * tox].list))
+ glCallList(pt->m_parts[z * tox].list);
+
+ // draw tickmarks ("broken" image won't have tickmarks)
+ if(!tab->broken && marks && SQ_Config::instance()->readBoolEntry("marks", true))
+ {
+ GLfloat zum = getZoom();
+ GLfloat x = fabsf(pt->m_parts[0].x1) * zum, y = pt->m_parts[0].y1 * zum;
+ GLfloat X = MATRIX_X, Y = MATRIX_Y;
+
+ if(x < 0.0)
+ x = -x;
+
+ const GLfloat ly = y+16, ry = -y-16;
+ const GLfloat lx = x+16, rx = -x-16;
+
+ matrix_push();
+ matrix_pure_reset();
+ MATRIX_X = X;
+ MATRIX_Y = Y;
+ matrix_rotate2(tab->curangle);
+ matrix_move_z(SQ_MARKS_POS);
+
+ GLfloat coords[4][8] =
+ {
+ {rx, ly, -x, ly, -x, y, rx, y},
+ {x, ly, lx, ly, lx, y, x, y},
+ {x, -y, lx, -y, lx, ry, x, ry},
+ {rx, -y, -x, -y, -x, ry, rx, ry}
+ };
+
+ for(z = 0;z < 4;z++)
+ {
+ glBindTexture(GL_TEXTURE_2D, mark[z]);
+
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0, 0.0); glVertex2f(coords[z][0], coords[z][1]);
+ glTexCoord2f(1.0, 0.0); glVertex2f(coords[z][2], coords[z][3]);
+ glTexCoord2f(1.0, 1.0); glVertex2f(coords[z][4], coords[z][5]);
+ glTexCoord2f(0.0, 1.0); glVertex2f(coords[z][6], coords[z][7]);
+ glEnd();
+ }
+
+ matrix_pop();
+ write_gl_matrix();
+ }
+ }
+
+ glDisable(GL_TEXTURE_2D);
+
+ matrixChanged();
+
+ if(!tab->broken && tab->total > 1)
+ frameChanged();
+}
+
+/*
+ * Change statusbar info according with
+ * current matrix (it shows current zoom & angle values).
+ */
+void SQ_GLWidget::matrixChanged()
+{
+ TQString str;
+
+ float m = getZoom();
+ float fzoom = m * 100.0;
+ float z = (m < 1.0) ? 1.0/m : m;
+
+ // construct zoom
+ str = TQString::fromLatin1("%1% [%2:%3]")
+ .arg(fzoom, 0, 'f', 1)
+ .arg((m < 1.0)?1.0:z, 0, 'f', 1)
+ .arg((m > 1.0)?1.0:z, 0, 'f', 1);
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBGLZoom")->setText(str);
+#else
+ t_glv.sbarWidget("SBGLZoom")->setText(str);
+#endif
+
+ // construct rotation angle
+ str = TQString::fromLatin1("%1%2 %3 deg")
+ .arg((tab->isflippedV)?"V":"")
+ .arg((tab->isflippedH)?"H":"")
+ .arg(tab->curangle, 0, 'f', 1);
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBGLAngle")->setText(str);
+#else
+ t_glv.sbarWidget("SBGLAngle")->setText(str);
+#endif
+}
+
+/*
+ * Mouse wheel event. Let's load next/previous image, or
+ * zoom in/zoom out (depends on settings).
+ */
+void SQ_GLWidget::wheelEvent(TQWheelEvent *e)
+{
+ if(e->delta() < 0 && e->state() == TQt::NoButton)
+ {
+#ifndef KSQUIRREL_PART
+ SQ_Config::instance()->setGroup("GL view");
+
+ // load next file in current directory
+ if(SQ_Config::instance()->readNumEntry("scroll", 0))
+ slotNext();
+ else
+#endif
+
+ slotZoomPlus();
+ }
+ else if(e->delta() > 0 && e->state() == TQt::NoButton)
+ {
+#ifndef KSQUIRREL_PART
+ SQ_Config::instance()->setGroup("GL view");
+
+ if(SQ_Config::instance()->readNumEntry("scroll", 0))
+ slotPrev();
+ else
+#endif
+
+ slotZoomMinus();
+ }
+ // some special bindings:
+ // if CTRL key is pressed, zoom 2x or 0.5x
+ else if(e->delta() < 0 && e->state() == TQt::ControlButton)
+ matrix_zoom(2.0);
+ else if(e->delta() > 0 && e->state() == TQt::ControlButton)
+ matrix_zoom(0.5f);
+ else if(e->delta() < 0 && e->state() == TQt::ShiftButton)
+ slotZoomPlus();
+ else if(e->delta() > 0 && e->state() == TQt::ShiftButton)
+ slotZoomMinus();
+}
+
+// User pressed mouse button down.
+void SQ_GLWidget::mousePressEvent(TQMouseEvent *e)
+{
+ setFocus();
+
+ // left button, update cursor
+ if(e->button() == TQt::LeftButton && e->state() == TQt::NoButton && tab->glselection == -1)
+ {
+#ifndef KSQUIRREL_PART
+ TQTime t = TQTime::currentTime();
+
+ SQ_Config::instance()->setGroup("GL view");
+ int dc = SQ_Config::instance()->readNumEntry("double_click", 0);
+
+ if(dc && clickTime.isValid() && clickTime.msecsTo(t) <= TDEApplication::doubleClickInterval())
+ {
+ if(dc == 1)
+ KSquirrel::app()->closeGLWidget();
+ else
+ toggleFullScreen();
+
+ return;
+ }
+ else
+ clickTime = t;
+
+#endif
+ setCursor(KCursor::sizeAllCursor());
+
+ xmoveold = e->x();
+ ymoveold = e->y();
+
+ movetype = 1;
+ }
+ // left button + SHIFT, let's start drawing zoom frame
+ else if(e->button() == TQt::LeftButton && (e->state() == TQt::ShiftButton || tab->glselection != -1))
+ {
+ // stop animation!
+ stopAnimation();
+
+ // update cursor to crosshair
+ setCursor(KCursor::crossCursor());
+
+ if(tab->glselection == SQ_GLSelectionPainter::Rectangle || tab->glselection == SQ_GLSelectionPainter::Ellipse)
+ gls->begin(static_cast<SQ_GLSelectionPainter::Type>(tab->glselection), e->x(), e->y());
+ else
+ gls->begin(SQ_GLSelectionPainter::Rectangle, e->x(), e->y());
+
+ movetype = 2;
+ }
+ // right button - show context menu
+ else if(e->button() == TQt::RightButton)
+ menu->popup(TQCursor::pos());
+ // middle button - toggle fullscreen state
+ else if(e->button() == TQt::MidButton)
+ toggleFullScreen();
+}
+
+// User moved mouse.
+void SQ_GLWidget::mouseMoveEvent(TQMouseEvent *e)
+{
+ // user didn't press any mouse button before ?
+ if(movetype == -1 && fullscreen())
+ {
+#if 0
+// bool tvis = SQ_GLView::window()->toolbar()->isShown();
+// bool svis = SQ_GLView::window()->statusbar()->isShown();
+
+ int h = SQ_GLView::window()->toolbar()->height() +
+ SQ_GLView::window()->tabbar()->height();
+
+#warning FIXME
+#ifndef KSQUIRREL_PART
+ hackResizeGL = true;
+ SQ_GLView::window()->boxBar()->setShown((/*tvis ? false:*/(e->y() < h)));
+ SQ_GLView::window()->statusbar()->setShown((/*svis ? false:*/(e->y() >
+ height()-SQ_GLView::window()->statusbar()->height())));
+#endif
+#endif
+ return;
+ }
+
+ // left mouse button, lets move image (or matrix :-) )
+ if(movetype == 1)
+ {
+ xmove = e->x();
+ ymove = e->y();
+
+ matrix_move(xmove-xmoveold, -ymove+ymoveold);
+
+ xmoveold = e->x();
+ ymoveold = e->y();
+ }
+ // left + SHIFT
+ else if(movetype == 2)
+ gls->move(e->x(), e->y());
+}
+
+// User released some mouse button.
+void SQ_GLWidget::mouseReleaseEvent(TQMouseEvent *)
+{
+ if(movetype == -1)
+ return;
+
+ // left button - restore cursor
+ if(movetype == 1 || (movetype == 2 && tab->glselection != -1)) // permanent selection
+ setCursor(KCursor::arrowCursor());
+ // left button + SHIFT - zoom to selected rectangle (if needed)
+ else if(movetype == 2 && tab->glselection == -1)
+ {
+ setCursor(KCursor::arrowCursor());
+
+ TQSize sz = gls->size();
+ TQPoint pt = gls->pos();
+ TQRect lastRect(pt.x(), pt.y(), sz.width(), sz.height());
+
+ gls->end();
+
+ TQPoint lastC = lastRect.center();
+ TQPoint O(width() / 2, height() / 2);
+
+ if(lastRect.width() > 2 && lastRect.height() > 2)
+ {
+ bool lastReset = reset_mode;
+ reset_mode = true;
+ float X = MATRIX_X, Y = MATRIX_Y;
+ matrix_move(O.x() - lastC.x(), lastC.y() - O.y());
+ reset_mode = lastReset;
+
+ // try to zoom
+ bool zoomed = tab->broken ? false : zoomRect(lastRect);
+
+ // not zoomed ? (zoom > maximum zoom)
+ if(!zoomed)
+ {
+ MATRIX_X = X;
+ MATRIX_Y = Y;
+ write_gl_matrix();
+ }
+ }
+
+ updateGL();
+
+ // start animation, if needed
+ if(!manualBlocked())
+ startAnimation();
+ }
+
+ movetype = -1;
+}
+
+/*
+ * Zoom to 'r'. Will be called after somebody used right mouse button
+ * to select zoom region.
+ */
+bool SQ_GLWidget::zoomRect(const TQRect &r)
+{
+ // calculate zoom factor
+ float factor = 1.0;
+ float w = (float)width(), h = (float)height();
+ float factorw = w / (float)r.width();
+ float factorh = h / (float)r.height();
+ float t = w / h;
+
+ if(t > (float)r.width() / (float)r.height())
+ factor = factorh;
+ else
+ factor = factorw;
+
+ // try to zoom
+ return matrix_zoom(factor);
+}
+
+// Fit width.
+void SQ_GLWidget::slotZoomW()
+{
+ zoom_type = 0;
+ pAZoomW->setChecked(true);
+
+ // no image decoded
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ // calculate zoom factor
+ float factor = (float)width() / (tab->rotate ? (float)tab->finfo.image[tab->current].h : (float)tab->finfo.image[tab->current].w);
+
+ // "Ignore, if the image is less than window" - restore zoom factor to 1.0
+ if(pAIfLess->isChecked() && (tab->finfo.image[tab->current].w < width() && tab->finfo.image[tab->current].h < height()))
+ factor = 1.0;
+
+ // zoom...
+ internalZoom(factor);
+}
+
+// Fit height.
+void SQ_GLWidget::slotZoomH()
+{
+ zoom_type = 1;
+ pAZoomH->setChecked(true);
+
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ float factor = (float)height() / (tab->rotate ? (float)tab->finfo.image[tab->current].w : (float)tab->finfo.image[tab->current].h);
+
+ if(pAIfLess->isChecked() && (tab->finfo.image[tab->current].w < width() && tab->finfo.image[tab->current].h < height()))
+ factor = 1.0;
+
+ internalZoom(factor);
+}
+
+// Fit image (e.g. width and height).
+void SQ_GLWidget::slotZoomWH()
+{
+ zoom_type = 2;
+ pAZoomWH->setChecked(true);
+
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ float factor = 1.0;
+ float w = (float)width(), h = (float)height();
+ float factorw = w / (tab->rotate ? (float)tab->finfo.image[tab->current].h : (float)tab->finfo.image[tab->current].w);
+ float factorh = h / (tab->rotate ? (float)tab->finfo.image[tab->current].w : (float)tab->finfo.image[tab->current].h);
+ float t = w / h;
+ float F = tab->rotate ? ((float)tab->finfo.image[tab->current].h / (float)tab->finfo.image[tab->current].w) : ((float)tab->finfo.image[tab->current].w / (float)tab->finfo.image[tab->current].h);
+
+ if(t > F)
+ factor = factorh;
+ else
+ factor = factorw;
+
+ if(pAIfLess->isChecked() && (tab->finfo.image[tab->current].w < width() && tab->finfo.image[tab->current].h < height()))
+ factor = 1.0;
+
+ internalZoom(factor);
+}
+
+// Previous zoom.
+void SQ_GLWidget::slotZoomLast()
+{
+ zoom_type = 4;
+ pAZoomLast->setChecked(true);
+
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ internalZoom(zoomFactor);
+}
+
+// Zoom 100%.
+void SQ_GLWidget::slotZoom100()
+{
+ zoom_type = 3;
+ pAZoom100->setChecked(true);
+
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ internalZoom(1.0);
+}
+
+// "Ignore, if the image is less than window"
+void SQ_GLWidget::slotZoomIfLess()
+{
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ switch(zoom_type)
+ {
+ case 0: slotZoomW(); break;
+ case 1: slotZoomH(); break;
+ case 2: slotZoomWH(); break;
+ case 3: break;
+
+ default:
+ slotZoomLast();
+ }
+}
+
+// Zoom+
+void SQ_GLWidget::slotZoomPlus()
+{
+ matrix_zoom(1.0+zoomfactor/100.0);
+}
+
+// Zoom-
+void SQ_GLWidget::slotZoomMinus()
+{
+ matrix_zoom(1.0/(1.0+zoomfactor/100.0));
+}
+
+// Rotate left.
+void SQ_GLWidget::slotRotateLeft()
+{
+ matrix_rotate(-rotatefactor);
+}
+
+// Rotate right.
+void SQ_GLWidget::slotRotateRight()
+{
+ matrix_rotate(rotatefactor);
+}
+
+/*
+ operations with matrices are taken from GLiv =)
+
+ thanks to Guillaume Chazarian.
+*/
+void SQ_GLWidget::flip(int id, bool U)
+{
+ GLfloat x = MATRIX_X, y = MATRIX_Y;
+ MATRIX_X = 0;
+ MATRIX_Y = 0;
+
+ tab->matrix[id] *= -1.0;
+ tab->matrix[id + 1] *= -1.0;
+ tab->matrix[id + 3] *= -1.0;
+
+ MATRIX_X = x;
+ MATRIX_Y = y;
+
+ write_gl_matrix();
+
+ if(!reset_mode && U)
+ updateGL();
+}
+
+void SQ_GLWidget::slotFlipH()
+{
+ if(!tab->broken)
+ {
+ tab->isflippedH = !tab->isflippedH;
+ flip(0);
+ }
+}
+
+void SQ_GLWidget::slotFlipV()
+{
+ if(!tab->broken)
+ {
+ tab->isflippedV = !tab->isflippedV;
+ flip(4);
+ }
+}
+
+void SQ_GLWidget::slotMatrixReset()
+{
+ if(!tab->broken)
+ {
+ oldZoom = getZoom();
+ matrix_reset(false);
+ matrix_zoom(1.0);
+ }
+}
+
+void SQ_GLWidget::write_gl_matrix()
+{
+ GLfloat transposed[16] =
+ {
+ 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0
+ };
+
+ transposed[0] = MATRIX_C1;
+ transposed[5] = MATRIX_C2;
+ transposed[4] = MATRIX_S1;
+ transposed[1] = MATRIX_S2;
+ transposed[12] = MATRIX_X;
+ transposed[13] = MATRIX_Y;
+ transposed[14] = MATRIX_Z;
+
+ glLoadMatrixf(transposed);
+}
+
+void SQ_GLWidget::matrix_move(GLfloat x, GLfloat y)
+{
+ if(tab->broken) return;
+
+ MATRIX_X += x;
+ MATRIX_Y += y;
+
+ write_gl_matrix();
+
+ if(!reset_mode)
+ updateGL();
+}
+
+void SQ_GLWidget::matrix_move_z(GLfloat z)
+{
+ MATRIX_Z = z;
+
+ write_gl_matrix();
+}
+
+void SQ_GLWidget::matrix_push()
+{
+ memcpy(saved, tab->matrix, sizeof(tab->matrix));
+}
+
+void SQ_GLWidget::matrix_pop()
+{
+ memcpy(tab->matrix, saved, sizeof(tab->matrix));
+}
+
+void SQ_GLWidget::matrix_reset(bool U)
+{
+ tab->nullMatrix();
+
+ tab->curangle = 0.0;
+ tab->isflippedH = tab->isflippedV = false;
+
+ if(decoded)
+ exifRotate(U);
+}
+
+void SQ_GLWidget::matrix_pure_reset()
+{
+ tab->nullMatrix();
+ write_gl_matrix();
+}
+
+bool SQ_GLWidget::matrix_zoom(GLfloat ratio)
+{
+ if(tab->broken) return false;
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ int zoom_lim = SQ_Config::instance()->readNumEntry("zoom limit", 1);
+ GLfloat zoom_min, zoom_max, zoom_tobe;
+
+ zoom_tobe = hypot(MATRIX_C1 * ratio, MATRIX_S1 * ratio) * 100.0;
+
+ switch(zoom_lim)
+ {
+ case 2:
+ zoom_min = (float)SQ_Config::instance()->readNumEntry("zoom_min", 1);
+ zoom_max = (float)SQ_Config::instance()->readNumEntry("zoom_max", 10000);
+ break;
+
+ default: // "case 1:" too
+ zoom_min = 1.0;
+ zoom_max = 10000.0;
+ }
+
+ if(zoom_lim)
+ {
+ float z = getZoomPercents();
+
+ // zoom limit exceeded - do nothing
+ if((z >= zoom_max && ratio > 1.0) || (z <= zoom_min && ratio < 1.0))
+ return false;
+
+ // if the new zoom will be greater (smaller) than maximum
+ // (minimum) zoom - scale it.
+ if(ratio < 1.0 && zoom_min >= zoom_tobe)
+ ratio = ratio * zoom_min / zoom_tobe;
+ else if(ratio > 1.0 && zoom_max <= zoom_tobe)
+ ratio = ratio * zoom_max / zoom_tobe;
+ }
+
+ GLfloat oldz = (oldZoom == -1 ? getZoom() : oldZoom);
+
+ MATRIX_C1 *= ratio;
+ MATRIX_S1 *= ratio;
+ MATRIX_X *= ratio;
+ MATRIX_S2 *= ratio;
+ MATRIX_C2 *= ratio;
+ MATRIX_Y *= ratio;
+
+ hackMatrix();
+
+ GLfloat z = getZoom();
+ int filter = -1;
+
+ if(ISFLOAT1(oldz) && !ISFLOAT1(z))
+ filter = linear ? GL_LINEAR : GL_NEAREST;
+ else if(ISFLOAT1(z))
+ filter = GL_NEAREST;
+
+ // update all textures
+ if(filter != -1)
+ {
+ for(int i = 0;i < tab->total;i++)
+ {
+ int toxy = tab->parts[i].m_parts.size();
+
+ for(int j = 0;j < toxy;j++)
+ {
+ glBindTexture(GL_TEXTURE_2D, tab->parts[i].m_parts[j].tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+ }
+ }
+ }
+
+ oldZoom = -1;
+ write_gl_matrix();
+
+ changeSlider(z);
+
+ if(!reset_mode)
+ updateGL();
+
+ return true;
+}
+
+/*
+ * Floating point operations are not 100% exact.
+ * We should correct matrix values.
+ */
+void SQ_GLWidget::hackMatrix()
+{
+ if(ISFLOAT1(MATRIX_C1)) MATRIX_C1 = MATRIX_C1 < 0 ? -1.0 : 1.0;
+ else if(ISFLOAT0(MATRIX_C1)) MATRIX_C1 = 0.0;
+
+ if(ISFLOAT1(MATRIX_C2)) MATRIX_C2 = MATRIX_C2 < 0 ? -1.0 : 1.0;
+ else if(ISFLOAT0(MATRIX_C2)) MATRIX_C2 = 0.0;
+
+ if(ISFLOAT1(MATRIX_S1)) MATRIX_S1 = MATRIX_S1 < 0 ? -1.0 : 1.0;
+ else if(ISFLOAT0(MATRIX_S1)) MATRIX_S1 = 0.0;
+
+ if(ISFLOAT1(MATRIX_S2)) MATRIX_S2 = MATRIX_S2 < 0 ? -1.0 : 1.0;
+ else if(ISFLOAT0(MATRIX_S2)) MATRIX_S2 = 0.0;
+
+ if(ISFLOAT0(MATRIX_X)) MATRIX_X = 0.0;
+ if(ISFLOAT0(MATRIX_Y)) MATRIX_Y = 0.0;
+}
+
+GLfloat SQ_GLWidget::getZoom() const
+{
+ return hypot(MATRIX_C1, MATRIX_S1);
+}
+
+GLfloat SQ_GLWidget::getZoomPercents() const
+{
+ return getZoom() * 100.0;
+}
+
+void SQ_GLWidget::matrix_rotate(GLfloat angle, bool U)
+{
+ if(tab->broken) return;
+
+ GLfloat c1 = MATRIX_C1, c2 = MATRIX_C2, s1 = MATRIX_S1, s2 = MATRIX_S2;
+
+ double rad = angle * rad_const;
+ double cosine = cos(rad);
+ double sine = sin(rad);
+
+ MATRIX_C1 = c1 * cosine + s2 * sine;
+ MATRIX_S1 = s1 * cosine + c2 * sine;
+ MATRIX_S2 = -c1 * sine + s2 * cosine;
+ MATRIX_C2 = -s1 * sine + c2 * cosine;
+
+ hackMatrix();
+
+ tab->curangle += angle;
+
+ if(tab->curangle == 360.0 || tab->curangle == -360.0)
+ tab->curangle = 0.0;
+ else if(tab->curangle > 360.0)
+ tab->curangle -= 360.0;
+ else if(tab->curangle < -360.0)
+ tab->curangle += 360.0;
+
+ write_gl_matrix();
+
+ if(U)
+ updateGL();
+}
+
+void SQ_GLWidget::matrix_rotate2(GLfloat angle)
+{
+ GLfloat c1 = MATRIX_C1, c2 = MATRIX_C2, s1 = MATRIX_S1, s2 = MATRIX_S2;
+
+ double rad = angle * rad_const;
+ double cosine = cos(rad);
+ double sine = sin(rad);
+
+ MATRIX_C1 = c1 * cosine + s2 * sine;
+ MATRIX_S1 = s1 * cosine + c2 * sine;
+ MATRIX_S2 = -c1 * sine + s2 * cosine;
+ MATRIX_C2 = -s1 * sine + c2 * cosine;
+
+ write_gl_matrix();
+}
+
+/*
+ * Bind textures, draw them and create GL lists.
+ * Also show textures by executing GL lists, if 'swap' = true.
+ */
+bool SQ_GLWidget::showFrames(int i, Parts *p, bool swap)
+{
+ int z, k = 0;
+ const int a = p->tilesx.size() * i, b = a + p->tilesx.size();
+ int filter = linear ? GL_LINEAR : GL_NEAREST;
+
+ // for safety...
+ makeCurrent();
+
+ glEnable(GL_TEXTURE_2D);
+
+ float zm = getZoom();
+
+ for(z = a;z < b;z++)
+ {
+ glBindTexture(GL_TEXTURE_2D, p->m_parts[z].tex);
+
+ // setup texture parameters
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ISFLOAT1(zm) ? GL_NEAREST : filter);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ISFLOAT1(zm) ? GL_NEAREST : filter);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ setupBits(p, buffer, i, k);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, p->tilesx[k], p->tilesy[i], 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+
+ k++;
+ }
+
+ // create new display list
+ glNewList(p->m_parts[a].list, swap ? GL_COMPILE_AND_EXECUTE : GL_COMPILE);
+
+ // bind & draw textures (if needed)
+ for(z = a;z < b;z++)
+ {
+ glBindTexture(GL_TEXTURE_2D, p->m_parts[z].tex);
+
+ glBegin(GL_QUADS);
+ glTexCoord2f(p->m_parts[z].tx1, p->m_parts[z].ty1); glVertex2f(p->m_parts[z].x1, p->m_parts[z].y1);
+ glTexCoord2f(p->m_parts[z].tx2, p->m_parts[z].ty1); glVertex2f(p->m_parts[z].x2, p->m_parts[z].y1);
+ glTexCoord2f(p->m_parts[z].tx2, p->m_parts[z].ty2); glVertex2f(p->m_parts[z].x2, p->m_parts[z].y2);
+ glTexCoord2f(p->m_parts[z].tx1, p->m_parts[z].ty2); glVertex2f(p->m_parts[z].x1, p->m_parts[z].y2);
+ glEnd();
+ }
+
+ glEndList();
+
+ glDisable(GL_TEXTURE_2D);
+
+ // swap buffers...
+ if(swap)
+ swapBuffers();
+
+ return GL_TRUE;
+}
+
+void SQ_GLWidget::setupBits(Parts *p, RGBA *_buffer, int y, int x)
+{
+ TQPair<int, int> pair = SQ_GLWidget::calcRealDimensions(*p, y, x);
+
+ int offs = p->realw * pair.second + pair.first;
+ RGBA *orig = p->buffer->data() + offs;
+
+ int toy = p->tilesy[y];
+ int tox = p->tilesx[x];
+
+ for(int j = 0;j < toy;j++)
+ memcpy(_buffer + tox*j, orig + p->realw*j, tox*sizeof(RGBA));
+}
+
+/*
+ * Start decoding given image. We can call it from anywhere.
+ */
+void SQ_GLWidget::startDecoding(const TQString &file)
+{
+#ifndef KSQUIRREL_PART
+ if(SQ_PreviewWidget::instance()->cancel())
+ SQ_WidgetStack::instance()->diroperator()->stopPreview();
+#endif
+
+ if(reset_mode)
+ return;
+
+ started.start();
+
+ tabold = tab;
+ tmptab.empty();
+ tab = &tmptab;
+ reset_mode = true;
+
+ timer_anim->stop();
+ images->clear();
+
+ tab->m_File = file; // original name
+ tab->File = TQFile::encodeName(tab->m_File); // translated name
+ tab->m_original = m_original;
+
+ TQFileInfo fm(file);
+ tab->fmt_ext = fm.extension(false);
+ tab->fmt_size = fm.size();
+
+#ifndef KSQUIRREL_PART
+ // show window with image
+ KSquirrel::app()->raiseGLWidget();
+#endif
+
+ if(m_expected.isEmpty())
+ TDEApplication::eventLoop()->processEvents(TQEventLoop::ExcludeUserInput | TQEventLoop::ExcludeSocketNotifiers);
+
+ decode();
+}
+
+/*
+ * Prepare decoding. It will find proper library for decoding,
+ * clear old memory buffers, etc.
+ */
+bool SQ_GLWidget::prepare()
+{
+ TQString status;
+
+ tab = &tmptab;
+
+ // get library from cache
+ SQ_LIBRARY *m_lib = SQ_LibraryHandler::instance()->libraryForFile(tab->m_File);
+
+ if(!m_lib)
+ {
+ KMessageBox::error(this, i18n("Codec for %1 format not found").arg(tab->fmt_ext));
+ reset_mode = false;
+ tab = tabold;
+ return false;
+ }
+ else
+ tmptab.lib = m_lib;
+
+ enableActions(true);
+
+ int already = -1, result = -1, i = 0;
+ SQ_Config::instance()->setGroup("GL view");
+
+#ifndef KSQUIRREL_PART
+ bool use_tabs = SQ_GLView::window()->tabs();
+#endif
+
+ bool useCurrent = false;
+
+#ifndef KSQUIRREL_PART
+ if(!use_tabs)
+ {
+ removeCurrentTabs();
+
+ SQ_GLView::window()->removeTabs();
+ }
+ else
+ {
+ if(m_expected != m_original)
+ {
+ std::vector<Tab>::iterator it = tabs.begin();
+ std::vector<Tab>::iterator itEnd = tabs.end();
+ for(;it != itEnd;++it, ++i)
+ {
+ if((*it).m_original == m_original)
+ {
+ already = i;
+ useCurrent = true;
+ break;
+ }
+ }
+ }
+
+ // 0 - new page
+ // 1 - replace current tab
+ // 2 - close all and open in a new tab
+ // -1 - ignore 'result' at all
+ if(already == -1
+ && decoded
+ && m_expected != m_original
+ && !useCurrent
+ && SQ_Config::instance()->readBoolEntry("tabs_ask", false))
+ {
+ SQ_TabOpenDialog tbo(this);
+ tbo.exec();
+ result = tbo.result();
+ }
+ }
+#else
+ removeCurrentTabs();
+#endif
+
+#ifndef KSQUIRREL_PART
+ int curtab = SQ_GLView::window()->tabbar()->indexOf(SQ_GLView::window()->tabbar()->currentTab());
+#else
+ int curtab = -1;
+#endif
+
+ int curindex = (already == -1) ? curtab : already;
+
+ if(curindex != -1 && (m_expected == m_original || result == 1 || useCurrent))
+ {
+ if(curtab != curindex)
+ tabs[curtab].removeParts();
+
+ tabs[curindex].clearParts();
+ tabs[curindex] = tmptab;
+ tab = &tabs[curindex];
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->tabbar()->blockSignals(true);
+ SQ_GLView::window()->tabbar()->setCurrentTab(SQ_GLView::window()->tabbar()->tabAt(curindex));
+ SQ_GLView::window()->tabbar()->tabAt(curindex)->setText(KStringHandler::csqueeze(tab->m_original.fileName(), SQ_TAB_TEXT_LENGTH));
+ SQ_GLView::window()->tabbar()->blockSignals(false);
+#endif
+ }
+ else
+ {
+ if(curindex != -1)
+ {
+ if(result == 2)
+ closeAllTabs();
+ else
+ tabs[curindex].removeParts();
+ }
+
+ tabs.push_back(tmptab);
+ int lastId = tabs.size() - 1;
+ tab = &tabs[lastId];
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->tabbar()->blockSignals(true);
+ SQ_GLView::window()->addPage(KStringHandler::csqueeze(tab->m_original.fileName(), SQ_TAB_TEXT_LENGTH));
+ SQ_GLView::window()->tabbar()->setCurrentTab(SQ_GLView::window()->tabbar()->tabAt(lastId));
+
+ // TQTabBar::show will emit selected(int),
+ // we don't want it
+ emit tabCountChanged();
+ SQ_GLView::window()->tabbar()->blockSignals(false);
+#endif
+ }
+
+ gls->setVisible(false);
+
+ SQ_CodecSettings::applySettings(tab->lib, SQ_CodecSettings::ImageViewer);
+
+ // determine codec
+ tab->codeK = tab->lib->codec;
+
+ // start decoding!
+ i = tab->codeK->read_init(tab->File.ascii());
+
+ // oops, error...
+ if(i != SQE_OK)
+ {
+ decodeFailedOn0(i);
+ m_expected = KURL();
+ return false;
+ }
+
+ return true;
+}
+
+void SQ_GLWidget::decode()
+{
+ // prepare decoding...
+ if(!prepare())
+ return;
+
+#ifndef KSQUIRREL_PART
+ KSquirrel::app()->setCaption(originalURL());
+#endif
+
+ zoomFactor = getZoom();
+ matrix_pure_reset();
+ matrixChanged();
+
+#ifdef SQ_HAVE_KEXIF
+ KExifData d;
+ d.readFromFile(tab->m_File);
+ tab->orient = d.getImageQt::Orientation();
+ tab->wm = SQ_Utils::exifGetMatrix(TQString(), tab->orient);
+
+ tab->rotate = (tab->orient == KExifData::ROT_90_HFLIP || tab->orient == KExifData::ROT_90
+ || tab->orient == KExifData::ROT_90_VFLIP || tab->orient == KExifData::ROT_270);
+#else
+ tab->orient = -1;
+ tab->rotate = false;
+#endif
+
+ errors = 0;
+
+/* *********************************************************** */
+
+ int i, j, id;
+ int line, res, first_id = 0;
+ fmt_image *im;
+ memoryPart *pt;
+ bool progr;
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ // in fullscreen mode progressive loading is disabled anyway
+ if(fullscreen())
+ progr = false;
+ else
+ progr = SQ_Config::instance()->readBoolEntry("progressiv", true);
+
+ int allpages = SQ_Config::instance()->readNumEntry("load_pages", 0);
+ int pages_num = SQ_Config::instance()->readNumEntry("load_pages_number", 1);
+
+ if(pages_num < 1) pages_num = 1;
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBFile")->setText(tab->m_original.fileName());
+#else
+ t_glv.sbarWidget("SBFile")->setText(tab->m_original.fileName());
+#endif
+
+ tab->current = 0;
+
+ bool notexpected = m_expected.isEmpty();
+ m_expected = KURL();
+
+ // start time counting
+ while(true)
+ {
+ if((allpages == 1 && tab->current) || (allpages == 2 && tab->current == pages_num))
+ break;
+
+ // absolute evil, but should do...
+ if(notexpected)
+ TDEApplication::eventLoop()->processEvents(TQEventLoop::ExcludeUserInput | TQEventLoop::ExcludeSocketNotifiers);
+
+ i = tab->codeK->read_next();
+
+ // something went wrong. SQE_NOTOK is a special type of error. It means
+ // that we decoded all pages.
+ if(i != SQE_OK)
+ {
+ if(i == SQE_NOTOK || tab->current)
+ break;
+ else
+ {
+ decodeFailedOn0(i);
+ return;
+ }
+ }
+
+ im = tab->codeK->image(tab->current);
+
+ Parts pp;
+
+ // find tile size
+ SQ_GLWidget::findCloserTiles(im->w, im->h, pp.tilesx, pp.tilesy);
+ TQPair<int, int> pair = SQ_GLWidget::calcRealDimensions(pp);
+ pp.realw = pair.first;
+ pp.realh = pair.second;
+
+ // setup current Part
+ pp.w = im->w;
+ pp.h = im->h;
+
+ // create textures and display lists
+ if(!pp.makeParts())
+ {
+ if(tab->current)
+ break;
+ else
+ {
+ KMessageBox::error(this,
+ i18n("Memory allocation failed for %1 of memory")
+ .arg(TDEIO::convertSize(pp.realw * pp.realh * sizeof(RGBA))));
+
+ decodeFailedOn0(SQE_R_NOMEMORY);
+ return;
+ }
+ }
+
+ pt = new memoryPart(pp.realw * pp.realh);
+ pt->create();
+
+ if(!pt->valid())
+ {
+ pp.removeParts();
+
+ if(tab->current)
+ break;
+ else
+ {
+ KMessageBox::error(this, i18n("Memory allocation failed"));
+ decodeFailedOn0(SQE_R_NOMEMORY);
+ return;
+ }
+ }
+
+ line = 0;
+
+ pp.computeCoords();
+ pp.buffer = pt;
+
+ tab->finfo = tab->codeK->information();
+
+ if(!tab->current)
+ {
+ tab->isflippedH = tab->isflippedV = false;
+ slotZoomIfLess();
+ matrixChanged();
+ updateCurrentFileInfo();
+ }
+
+ matrix_move_z(SQ_FIRST_TILE_LAYER+tab->current);
+
+ for(int pass = 0;pass < im->passes;pass++)
+ {
+ if(tab->codeK->read_next_pass() != SQE_OK)
+ break;
+
+ bool flip = tab->finfo.image[tab->current].needflip;
+ line = 0;
+ int tlsy = pp.tilesy.size();
+ int tlsyval, offs = 0, O, iA;
+
+ for(i = 0;i < tlsy;i++)
+ {
+ iA = flip ? (tlsy-i-1) : i;
+ tlsyval = pp.tilesy[iA];
+
+ for(j = 0;j < tlsyval;j++)
+ {
+ O = flip ? (pp.realw*(im->h - offs - j-1)) : (offs + j)*pp.realw;
+ res = tab->codeK->read_scanline(pp.buffer->data() + O);
+ errors += (int)(res != SQE_OK);
+
+ if(++line == im->h)
+ break;
+ }
+
+ offs += tlsyval;
+
+ // last pass
+ if(pass == im->passes-1)
+ {
+// if(!tab->current)
+ {
+ bool b = showFrames(iA, &pp, progr);
+
+ if(!b)
+ kdWarning() << "Showframes failed for image " << tab->current << ", tiley " << i << endl;
+ }
+ }
+
+ }
+ }
+
+ id = images->insertItem(TQString::fromLatin1("#%1 [%2x%3@%4]").arg(tab->current+1).arg(im->w).arg(im->h).arg(im->bpp));
+
+ images->setItemParameter(id, tab->current);
+
+ if(!tab->current)
+ {
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBDecodedI")->setPixmap(tab->lib->mime);
+#endif
+ old_id = first_id = id;
+ }
+
+ tab->parts.push_back(pp);
+
+ calcFrameLabelWidth();
+ frameChanged();
+ tab->current++;
+ }
+
+ tab->finfo = tab->codeK->information();
+ tab->codeK->read_close();
+ tab->total = tab->finfo.image.size();
+ tab->current = 0;
+ frameChanged();
+
+ enableSettingsButton(!tab->lib->config.isEmpty());
+
+ decoded = true;
+ reset_mode = false;
+ updateGL();
+
+ tab->quickImageInfo = tab->lib->quickinfo;
+ tab->elapsed = started.elapsed();
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBLoaded")->setText(TDEGlobal::locale()->formatLong(tab->elapsed) + i18n(" ms."));
+#else
+ t_glv.sbarWidget("SBLoaded")->setText(TDEGlobal::locale()->formatLong(tab->elapsed) + i18n(" ms."));
+#endif
+
+ images->setItemChecked(first_id, true);
+
+ if(tab->finfo.animated)
+ TQTimer::singleShot(tab->finfo.image[tab->current].delay, this, TQ_SLOT(slotAnimateNext()));
+}
+
+/*
+ * Palette changed. Let's update tickmarks and background color.
+ */
+void SQ_GLWidget::paletteChange(const TQPalette &oldPalette)
+{
+ TQGLWidget::paletteChange(oldPalette);
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ if(SQ_Config::instance()->readNumEntry("GL view background type", 1) == 0)
+ {
+ TQColor color = colorGroup().color(TQColorGroup::Base);
+ qglClearColor(color);
+ updateGL();
+ }
+}
+
+void SQ_GLWidget::slotFirst()
+{
+#ifndef KSQUIRREL_PART
+ if(!reset_mode)
+ SQ_WidgetStack::instance()->firstFile();
+#endif
+}
+
+void SQ_GLWidget::slotLast()
+{
+#ifndef KSQUIRREL_PART
+ if(!reset_mode)
+ SQ_WidgetStack::instance()->lastFile();
+#endif
+}
+
+void SQ_GLWidget::slotNext()
+{
+#ifndef KSQUIRREL_PART
+ timer_next->stop();
+ timer_prev->stop();
+
+ timer_next->start(timer_delay_file, true);
+#endif
+}
+
+void SQ_GLWidget::slotPrev()
+{
+#ifndef KSQUIRREL_PART
+ timer_prev->stop();
+ timer_next->stop();
+
+ timer_prev->start(timer_delay_file, true);
+#endif
+}
+
+void SQ_GLWidget::slotZoomMenu()
+{
+ zoomMenu->exec(TQCursor::pos());
+}
+
+void SQ_GLWidget::slotAnimateNext()
+{
+ // Some time ago we started to decode new image, but it is
+ // not guaranteed that animation stopped!
+ //
+ // We should return now to avoid segfaults...
+ if(reset_mode)
+ return;
+
+// tab->parts[tab->current].removeParts();
+
+ tab->current++;
+
+ if(tab->current >= (int)tab->finfo.image.size())
+ tab->current = 0;
+
+ updateCurrentFileInfo();
+ updateGL();
+
+ int delay = tab->finfo.image[tab->current].delay;
+
+ timer_anim->start(delay, true);
+}
+
+void SQ_GLWidget::startAnimation()
+{
+ if(!tab->finfo.animated) return;
+
+ timer_anim->start(tab->finfo.image[tab->current].delay, true);
+}
+
+void SQ_GLWidget::stopAnimation()
+{
+ timer_anim->stop();
+}
+
+void SQ_GLWidget::slotToggleAnimate()
+{
+ if(!tab->finfo.animated || gls->valid()) return;
+
+ if(!timer_anim->isActive())
+ {
+ tab->manualBlocked = false;
+ startAnimation();
+ }
+ else
+ {
+ tab->manualBlocked = true;
+ stopAnimation();
+ }
+}
+
+/*
+ * Next image in animated sequence. Called by user (with F3).
+ */
+void SQ_GLWidget::nextImage()
+{
+ // if the image has only one page - do nothing
+ if(tab->total == 1)
+ return;
+
+ tab->current++;
+
+ if(tab->current >= tab->total)
+ tab->current = 0;
+
+ updateGL();
+ updateCurrentFileInfo();
+}
+
+/*
+ * Previous image in animated sequence. Called by user (with F2).
+ */
+void SQ_GLWidget::prevImage()
+{
+ if(tab->total == 1)
+ return;
+
+ tab->current--;
+
+ if(tab->current < 0)
+ tab->current = tab->total - 1;
+
+ updateGL();
+ updateCurrentFileInfo();
+}
+
+/*
+ * Jump to first/last image page.
+ */
+void SQ_GLWidget::jumpToImage(bool last)
+{
+ // if the image has only one page - do nothing
+ if(tab->total == 1)
+ return;
+
+ tab->current = (last) ? tab->finfo.image.size() - 1 : 0;
+
+ updateGL();
+ updateCurrentFileInfo();
+}
+
+void SQ_GLWidget::initMarks()
+{
+ for(int i = 0;i < 4;i++)
+ {
+ glGenTextures(1, &mark[i]);
+
+ glBindTexture(GL_TEXTURE_2D, mark[i]);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, mm[i].bits());
+ }
+}
+
+void SQ_GLWidget::internalZoom(const GLfloat &zF)
+{
+ tab->curangle = 0.0;
+
+ oldZoom = getZoom();
+ matrix_pure_reset();
+
+ exifRotate(false);
+
+ matrix_zoom(zF);
+}
+
+void SQ_GLWidget::updateFilter(bool nice)
+{
+ if(nice == linear)
+ return;
+
+ // store
+ linear = nice;
+
+ int filter = nice ? GL_LINEAR : GL_NEAREST;
+ Parts *pt;
+
+ // update all textures
+ for(int i = 0;i < tab->total;i++)
+ {
+ pt = tab->broken ? parts_broken : &tab->parts[i];
+ int toxy = pt->m_parts.size();
+
+ for(int j = 0;j < toxy;j++)
+ {
+ glBindTexture(GL_TEXTURE_2D, pt->m_parts[j].tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+ }
+ }
+
+ updateGL();
+}
+
+/*
+ * Cleanup method.
+ */
+void SQ_GLWidget::decodeFailedOn0(const int err_code)
+{
+ tab->codeK->read_close();
+ tab->finfo.image.clear();
+ tab->finfo.meta.clear();
+ tab->total = 0;
+ decoded = (bool)tabs.size();
+ reset_mode = false;
+ tab->broken = true;
+ tab->lib = 0;
+
+ useBrokenImage(err_code);
+}
+
+/*
+ * Force using broken image + update context.
+ * Show appropriate error message in statusbar.
+ */
+void SQ_GLWidget::useBrokenImage(const int err_index)
+{
+ enableSettingsButton(false);
+ enableActions(false);
+
+ // save "broken" image information in 'tab->finfo'
+ tab->finfo.image.push_back(image_broken);
+
+ // reset statusbar widgets
+ SQ_GLView::window()->resetStatusBar();
+
+#ifndef KSQUIRREL_PART
+ // show error message instead of file name
+ SQ_GLView::window()->sbarWidget("SBFile")->setText(SQ_ErrorString::instance()->string(err_index));
+ KSquirrel::app()->setCaption(TQString());
+#else
+ t_glv.sbarWidget("SBFile")->setText(SQ_ErrorString::instance()->string(err_index));
+#endif
+
+ matrix_pure_reset();
+ tab->curangle = 0;
+ tab->isflippedH = tab->isflippedV = false;
+
+ changeSlider(1.0);
+
+ // update context and show "broken" image
+ updateGL();
+}
+
+/*
+ * Are we in fullscreen state ?
+ */
+bool SQ_GLWidget::fullscreen() const
+{
+#ifndef KSQUIRREL_PART
+ KWin::WindowInfo wi = KWin::windowInfo(SQ_GLView::window()->winId());
+
+ if(wi.valid())
+ pAFull->setChecked((wi.state() & NET::FullScreen));
+
+ return pAFull->isChecked();
+#else
+ return false;
+#endif
+}
+
+/*
+ * Toggle fullscreen state.
+ */
+void SQ_GLWidget::toggleFullScreen()
+{
+#ifndef KSQUIRREL_PART
+ bool fs = !fullscreen();
+
+ pAFull->setChecked(fs);
+ pAToolFull->setOn(fs);
+
+ KSquirrel::app()->slotFullScreen(fs);
+#endif
+}
+
+void SQ_GLWidget::slotSetZoomPercents(int perc)
+{
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ GLfloat z = (perc <= 20) ? (GLfloat)perc / 20 : ((GLfloat)perc - 20)/2 + 1.0;
+
+ internalZoom(z);
+}
+
+void SQ_GLWidget::updateFactors()
+{
+ zoomfactor = SQ_Config::instance()->readNumEntry("zoom", 25);
+ movefactor = SQ_Config::instance()->readNumEntry("move", 5);
+ rotatefactor = SQ_Config::instance()->readNumEntry("angle", 90);
+}
+
+void SQ_GLWidget::slotSelectionRect()
+{
+ stopAnimation();
+ tab->glselection = SQ_GLSelectionPainter::Rectangle;
+ gls->end();
+}
+
+void SQ_GLWidget::slotSelectionEllipse()
+{
+ stopAnimation();
+ tab->glselection = SQ_GLSelectionPainter::Ellipse;
+ gls->end();
+}
+
+void SQ_GLWidget::slotSelectionClear()
+{
+ tab->glselection = -1;
+ gls->end();
+
+ pASelectionEllipse->setChecked(false);
+ pASelectionRect->setChecked(false);
+
+ if(!manualBlocked())
+ startAnimation();
+}
+
+bool SQ_GLWidget::manualBlocked()
+{
+ // selection is also blocks animation
+ return tab->manualBlocked || gls->valid();
+}
+
+void SQ_GLWidget::setDownloadPercents(int p)
+{
+ if(p < 0)
+ percentsLabel->hide();
+ else
+ {
+ percentsLabel->setText(i18n("Downloading...") + ' ' + TDEIO::convertSize(p));
+ percentsLabel->adjustSize();
+ percentsLabel->show();
+ }
+}
+
+#include "sq_glwidget.moc"
diff --git a/src/ksquirrelpart/sq_glwidget.h b/src/ksquirrelpart/sq_glwidget.h
new file mode 100644
index 0000000..be4903f
--- /dev/null
+++ b/src/ksquirrelpart/sq_glwidget.h
@@ -0,0 +1,620 @@
+/***************************************************************************
+ sq_glwidget.h - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef SQ_GLWIDGET_H
+#define SQ_GLWIDGET_H
+
+#include <tqimage.h>
+#include <tqrect.h>
+#include <tqpair.h>
+#include <tqdatetime.h>
+
+#include <kurl.h>
+
+#include <vector>
+
+#include "sq_glparts.h"
+
+#ifdef KSQUIRREL_PART
+#include "sq_glview.h"
+#endif
+
+class SQ_GLSelectionPainter;
+struct SQ_ImageFilterOptions;
+struct SQ_ImageBCGOptions;
+struct RGBA;
+
+// parameters in GL matrix
+#define MATRIX_C1 tab->matrix[0]
+#define MATRIX_S1 tab->matrix[1]
+#define MATRIX_X tab->matrix[3]
+#define MATRIX_S2 tab->matrix[4]
+#define MATRIX_C2 tab->matrix[5]
+#define MATRIX_Y tab->matrix[7]
+#define MATRIX_Z tab->matrix[11]
+
+class TDEAction;
+class TDEActionCollection;
+class TDEToggleAction;
+class TDEPopupMenu;
+class TDERadioAction;
+class KTempFile;
+
+namespace TDEIO { class Job; }
+
+class TQTimer;
+class TQPopupMenu;
+class TQSlider;
+class TQLabel;
+
+class SQ_ToolButtonPopup;
+class SQ_ToolButton;
+class SQ_ToolBar;
+
+/* *************************************************************** */
+
+/*
+ * SQ_GLWidget represents a widget, which loads, shows and manipulates
+ * an image.
+ *
+ * It contains complex decoding method. Since OpenGL can show textures
+ * only with dimensions of power of 2 (32x62, 512, 256 etc.), we should divide
+ * decoded image into quads and only then generate textures.
+ * It means, that the image you see consists of several parts:
+ *
+ * |----------------------------------
+ * | | |
+ * | tex N1 | tex N2 |
+ * | | |
+ * ----------------------------------- <= Entire image
+ * | | |
+ * | tex N3 | tex N4 |
+ * | | |
+ * -----------------------------------
+ *
+ *
+ * The main class member is 'parts'. It's an array of decoded images
+ * and appropriate memory buffers and textures. Here comes an explanation:
+ * [ use monotype fonts :) ]
+ *
+ * textures & coordinates Part
+ * +-----------------------------------+ ##################### ##################
+ * | parts[2] | # # #===> # #
+ * | +-------------------------------------+ # # # # texture id #
+ * | | parts[1] | |======> ##################### # texture coords #
+ * | | +-------------------------------------+ | # # # # ... #
+ * | | | m_parts parts[0] | | # # # ##################
+ * | | | ##### | | #####################
+ * | | | # # | |
+ * | | | # #===============================|
+ * | | | # # |
+ * | | | ##### |
+ * | | | | memory buffers
+ * | | | m32 | ###############################
+ * | | | ##### | #RGBA.#.....#.....#.....#.....#
+ * | | | # # | #RGBA.#.....#.....#.....#.....#
+ * | | | # #==================================> ###############################
+ * +-| | # # | #RGBA.#.....#.....#.....#.....#
+ * +-| ##### | #RGBA.#.....#.....#.....#.....#
+ * +-------------------------------------+ ###############################
+ * \ /
+ * \ /
+ * parts
+ *
+ *
+ ******************************************************************************
+ *
+ */
+
+class SQ_GLWidget : public TQGLWidget
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_GLWidget(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_GLWidget();
+
+ void setDownloadPercents(int);
+
+ void removeNonCurrentTabs(int);
+
+ void setExpectedURL(const KURL &u);
+
+ TQString originalURL() const;
+
+ /*
+ * Start decoding given image. We can call it from anywhere.
+ */
+ void startDecoding(const TQString &file);
+ void startDecoding(const KURL &url);
+
+ void zoom(GLfloat);
+
+ /*
+ * Set zoom, move and rotate factors from config.
+ */
+ void updateFactors();
+
+ /*
+ * Set clear color for context.
+ */
+ void setClearColor();
+
+ void setOriginalURL(const KURL &);
+
+ /*
+ * Get zoom value, e.g. 1.5, 2.2 ...
+ */
+ GLfloat getZoom() const;
+
+ /*
+ * Get zoom value in percents, e.g. 150, 220 ...
+ */
+ GLfloat getZoomPercents() const;
+
+ TDEActionCollection* actionCollection() const;
+
+ /*
+ * Are we in fullscreen state ?
+ */
+ bool fullscreen() const;
+
+ /*
+ * Toggle fullscreen state.
+ */
+ void toggleFullScreen();
+
+ /*
+ * Direct call to updateGL().
+ */
+ void updateGLA() { updateGL(); }
+
+ /*
+ * Type of zoom: fit width, fit height...
+ */
+ int zoomType();
+
+ /*
+ * Filter is GL_LINEAR ?
+ */
+ bool isnice();
+
+ /*
+ * Direct call to glInit();
+ */
+ void glInitA() { TQGLWidget::glInit(); }
+
+ /*
+ * Start animation, if loaded image is animated.
+ */
+ void startAnimation();
+
+ /*
+ * Stop animation, if loaded image is animated.
+ */
+ void stopAnimation();
+
+ /*
+ * Is animation stopped by user ?
+ */
+ bool manualBlocked();
+
+ /*
+ * Change statusbar info according with
+ * current matrix (it shows current zoom & angle values).
+ */
+ void matrixChanged();
+
+ /*
+ * Check or uncheck 'Slideshow' button in toolbar.
+ */
+ void updateSlideShowButton(bool toggled);
+
+ void closeAllTabsFull();
+
+ static SQ_GLWidget* window() { return m_instance; }
+
+ protected:
+
+ /*
+ * Next three methods should be reimplemented in
+ * every TQGLWidget's subclass.
+ */
+ void initializeGL();
+ void paintGL();
+ void resizeGL(int,int);
+
+ /*
+ * Mouse wheel event. Let's load next/previous image, or
+ * zoom in/zoom out (depends on settings).
+ */
+ void wheelEvent(TQWheelEvent *);
+
+ /*
+ * Palette changed. Let's update tickmarks and background color.
+ */
+ void paletteChange(const TQPalette &oldPalette);
+
+ /*
+ * Accept drag-and-drop events. We can drop some images
+ * on this widget, SQ_GLWidget will try to decode first file.
+ *
+ * TODO: find first supported image and decode it ?
+ */
+ void dragEnterEvent(TQDragEnterEvent *);
+ void dropEvent(TQDropEvent *);
+
+ /*
+ * Mouse events.
+ */
+ void mousePressEvent(TQMouseEvent *);
+ void mouseReleaseEvent(TQMouseEvent *);
+ void mouseMoveEvent(TQMouseEvent *);
+
+ private:
+ void copyURL();
+
+ TQImage generatePreview();
+
+ bool calcSelection();
+
+ void changeSlider(GLfloat z = -1.0);
+
+ void hackMatrix();
+
+ void enableActions(bool U);
+
+ void initAccelsAndMenu();
+
+ void crop();
+ void bcg();
+ void filter();
+ void editUpdate();
+
+ /*
+ * Save current image page to clipboard
+ */
+ void toClipboard();
+
+ /*
+ * Save current image page to file
+ */
+ void saveAs();
+
+ void enableSettingsButton(bool enab);
+
+ /*
+ * Remove currently loaded textures and memory buffers.
+ */
+ void removeCurrentParts();
+ void removeCurrentTabs();
+
+ void closeAllTabs();
+
+ /*
+ * Since 0.6.0-final KSquirrel doesn't show error messages,
+ * if the image is broken or not supported. It uses "broken" image
+ * instead. This method does all needed init.
+ */
+ void initBrokenImage();
+
+ /*
+ * Force using broken image + update context.
+ * Show appropriate error message in statusbar.
+ */
+ void useBrokenImage(const int err_index);
+
+ /*
+ * Update filter. If 'nice' is true, use GL_LINEAR
+ * and GL_NEAREST otherwise.
+ */
+ void updateFilter(bool nice);
+
+ /*
+ * Cleanup method.
+ */
+ void decodeFailedOn0(const int err_code);
+
+ /*
+ * Create TDEActions.
+ */
+ void createActions();
+
+ /*
+ * Create toolbars.
+ */
+ void createToolbar();
+
+ /*
+ * Fill a w x h region with texture. Generate texture if needed.
+ */
+ void draw_background(void *bits, unsigned int *tex, int dim, GLfloat w, GLfloat h, bool &bind, bool deleteOld);
+
+ void setupBits(Parts *p, RGBA *buffer, int y, int x);
+
+ /*
+ * Jump to first or last image in animated sequence.
+ */
+ void jumpToImage(bool);
+
+ /*
+ * Next image in animated sequence. Called by user (with F3).
+ */
+ void nextImage();
+
+ /*
+ * Previous image in animated sequence. Called by user (with F2).
+ */
+ void prevImage();
+
+ /*
+ * Draw (or not) image's background.
+ */
+ void toggleDrawingBackground();
+
+ /*
+ * Show popup menu with external tools.
+ */
+ void showExternalTools();
+
+ /*
+ * Generate textures for tickmarks and bind them.
+ */
+ void initMarks();
+
+ /*
+ * Load and check tickmarks from disk.
+ */
+ void createMarks();
+
+ /*
+ * Wrapper for 'delete' key. Called from keyPressEvent().
+ */
+ void deleteWrapper();
+
+ /*
+ * Show current image's width, height and bpp in statusbar.
+ */
+ void updateCurrentFileInfo();
+
+ /*
+ * Show/hide tickmarks.
+ */
+ void toogleTickmarks();
+
+ /*
+ * Show current page number in multipaged images.
+ *
+ * For example: "3/11" means that current page is the third in current image,
+ * which has 11 pages.
+ */
+ void frameChanged();
+ void calcFrameLabelWidth();
+
+ /*
+ * Set current zoom to 'z'.
+ */
+ void internalZoom(const GLfloat &z);
+
+ /*
+ * Find best tile's width and height for given width and height.
+ */
+ static void findCloserTiles(int w, int h, std::vector<int> &x, std::vector<int> &y);
+ static TQPair<int, int> calcRealDimensions(Parts &, int y = -1, int x = -1);
+
+ /*
+ * Prepare decoding. It will find proper library for decoding,
+ * clear old memory buffers, etc.
+ */
+ bool prepare();
+
+ /*
+ * Zoom to 'r'. Will be called after somebody used mouse button
+ * to select zoom region. Return true, if zoomed.
+ */
+ bool zoomRect(const TQRect &r);
+
+ /*
+ * Bind textures, draw them and create GL lists.
+ * If 'swap' it true, swap buffers.
+ */
+ bool showFrames(int y, Parts *, bool swap);
+
+ /*
+ * OpenGL-related methods, not interesting :-)
+ *
+ * Move, zoom, reset, flip and rotate current matrix.
+ */
+ void matrix_move(GLfloat x, GLfloat y);
+ void matrix_move_z(GLfloat z);
+ bool matrix_zoom(GLfloat ratio);
+ void matrix_reset(bool = true);
+ void matrix_pure_reset();
+ void matrix_push();
+ void matrix_pop();
+ void write_gl_matrix();
+ void matrix_rotate(GLfloat angle, bool = true);
+ void matrix_rotate2(GLfloat angle);
+ void flip(int, bool = true);
+ void flip_h();
+ void flip_v();
+ void exifRotate(bool);
+
+ signals:
+ void tabCountChanged();
+ void message(const TQString &);
+
+ public slots:
+ void slotPrint();
+
+ void slotSelectionEllipse();
+ void slotSelectionRect();
+ void slotSelectionClear();
+
+ private slots:
+ void decode();
+
+ void slotAccelActivated();
+
+ void slotChangeTab(int);
+ void slotCloseRequest(int);
+
+ void slotCopyJobResult(TDEIO::Job *job);
+
+ /*
+ * Slots for toolbar's actions:
+ * fit width, fit height, zoom+, zoom-, rotate, flip,
+ * first file, last file, reset...
+ */
+ void slotShowNav();
+ void slotSetZoomPercents(int);
+ void slotZoomW();
+ void slotZoomH();
+ void slotZoomWH();
+ void slotZoomPlus();
+ void slotZoom100();
+ void slotZoomLast();
+ void slotZoomMinus();
+ void slotZoomIfLess();
+ void slotRotateLeft();
+ void slotRotateRight();
+ void slotFlipV();
+ void slotFlipH();
+ void slotMatrixReset();
+ void slotProperties(); // show image properties
+ void slotFirst();
+ void slotLast();
+ void slotNext();
+ void slotPrev();
+ void slotZoomMenu();
+ void slotAnimateNext();
+ void slotToggleAnimate(); // start/stop animation
+ void slotSetCurrentImage(int);
+ void slotShowImages();
+ void slotImagesHidden();
+ void slotImagesShown();
+ void slotShowHelp();
+ void slotShowCodecSettings();
+ void slotApplyCodecSettings();
+
+ void slotBCG(SQ_ImageBCGOptions *);
+ void slotFilter(SQ_ImageFilterOptions *fltopt);
+
+ void slotCopyResult(TDEIO::Job *);
+
+ private:
+ TDEAction *pASelectionClear;
+ TDEToggleAction *pAFull, *pAIfLess, *pAZoomW,
+ *pAZoomH, *pAZoomWH, *pAZoom100,
+ *pAZoomLast,
+ *pASelectionEllipse, *pASelectionRect;
+
+ SQ_ToolButton *pAToolQuick, *pAToolFull, *pAToolProp, *pAToolPrint;
+ SQ_ToolButtonPopup *pAToolZoom, *pAToolImages;
+
+ TDEActionCollection *ac, *acMain;
+ TQPopupMenu *menu, *menuFile, *menuImage;
+ int id_saveas, id_settings,
+ id_f5, id_f6, id_f7, id_f8, id_del,
+ id_prop;
+
+ // popup menu with zoom types (fit width, fit height, zoom 100%...)
+ TDEPopupMenu *zoomMenu, *selectionMenu,
+
+ // popup menu with image pages
+ *images;
+
+ TQImage BGpixmap, BGquads;
+
+ TQTimer *timer_prev, *timer_next;
+ TQTimer *timer_anim;
+
+ TQImage mm[4];
+
+ fmt_image image_broken;
+ SQ_GLSelectionPainter *gls;
+
+ Parts *parts_broken;
+
+ GLfloat saved[12], zoomfactor, movefactor, rotatefactor;
+
+ unsigned int texQuads, texPixmap, mark[4];
+ int xmoveold, ymoveold, xmove, ymove,
+ zoom_type, old_id, total, errors, movetype;
+ bool reset_mode, decoded, blocked,
+ changed, marks, linear;
+ float zoomFactor, oldZoom;
+ RGBA *buffer;
+ TQSlider *slider_zoom;
+
+ KTempFile *tmp;
+ KURL lastCopy, m_expected, m_original;
+ TQTime clickTime, started;
+
+ std::vector<Tab> tabs;
+ Tab *tab, *tabold;
+ Tab tmptab, taborig;
+ bool hackResizeGL, bindChecker;
+
+ TQLabel *percentsLabel;
+
+#ifdef KSQUIRREL_PART
+ SQ_GLView t_glv;
+#endif
+
+ static SQ_GLWidget *m_instance;
+};
+
+inline
+int SQ_GLWidget::zoomType()
+{
+ return zoom_type;
+}
+
+inline
+bool SQ_GLWidget::isnice()
+{
+ return linear;
+}
+
+inline
+TDEActionCollection* SQ_GLWidget::actionCollection() const
+{
+ return ac;
+}
+
+inline
+void SQ_GLWidget::setOriginalURL(const KURL &u)
+{
+ m_original = u;
+}
+
+inline
+TQString SQ_GLWidget::originalURL() const
+{
+ return tab->m_original.isLocalFile() ? tab->m_original.path() : tab->m_original.prettyURL();
+}
+
+inline
+void SQ_GLWidget::setExpectedURL(const KURL &u)
+{
+ m_expected = u;
+}
+
+#endif
diff --git a/src/ksquirrelpart/sq_glwidget_helpers.cpp b/src/ksquirrelpart/sq_glwidget_helpers.cpp
new file mode 100644
index 0000000..0dd96c0
--- /dev/null
+++ b/src/ksquirrelpart/sq_glwidget_helpers.cpp
@@ -0,0 +1,264 @@
+/***************************************************************************
+ sq_glwidget_helpers.cpp - description
+ -------------------
+ begin : ��� ��� 7 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqwmatrix.h>
+#include <tqrect.h>
+#include <tqpoint.h>
+#include <tqpointarray.h>
+
+#include <algorithm>
+#include <cstdlib>
+
+#include <tdetoolbar.h>
+
+#include <ksquirrel-libs/fmt_defs.h>
+
+#ifdef SQ_HAVE_KEXIF
+#include <libkexif/kexifdata.h>
+#endif
+
+#include "sq_glwidget_helpers.h"
+
+SQ_ToolButtonPopup::SQ_ToolButtonPopup(const TQPixmap &pix, const TQString &textLabel, TDEToolBar *parent)
+ : TDEToolBarButton(pix, -1, parent, 0, textLabel)
+{
+ setFixedWidth(SQ_ToolButton::fixedWidth());
+}
+
+SQ_ToolButtonPopup::~SQ_ToolButtonPopup()
+{}
+
+SQ_ToolButton::SQ_ToolButton(const TQIconSet &iconSet, const TQString &textLabel,
+ TQObject *receiver, const char *slot, TDEToolBar *parent, const char *name)
+ : TQToolButton(iconSet, textLabel, TQString(), receiver, slot, parent, name)
+{
+ setFixedWidth(SQ_ToolButton::fixedWidth());
+}
+
+SQ_ToolButton::~SQ_ToolButton()
+{}
+
+int SQ_GLHelpers::roundAngle(int curangle)
+{
+ int sign = (curangle < 0 ? -1 : 1);
+ curangle = std::abs(curangle);
+
+ if((curangle > 0 && curangle < 45) || (curangle >= 315 && curangle < 360))
+ curangle = 0;
+ else if(curangle >= 45 && curangle < 135)
+ curangle = 90;
+ else if(curangle >= 135 && curangle < 225)
+ curangle = 180;
+ else if(curangle >= 225 && curangle < 315)
+ curangle = 270;
+
+ curangle *= sign;
+
+ return curangle;
+}
+
+void SQ_GLHelpers::subRotation(TQWMatrix &wm, int curangle, int orient)
+{
+ curangle = SQ_GLHelpers::roundAngle(curangle);
+
+#ifdef SQ_HAVE_KEXIF
+ switch(orient)
+ {
+ case KExifData::ROT_180: curangle -= 180; break;
+ case KExifData::ROT_90_HFLIP:
+ case KExifData::ROT_90:
+ case KExifData::ROT_90_VFLIP: curangle -= 90; break;
+ case KExifData::ROT_270: curangle -= 270; break;
+
+ default: ;
+ }
+#endif
+
+ switch(curangle)
+ {
+ case -180:
+ case 180: wm.rotate(180); break;
+
+ case -270:
+ case 90: wm.rotate(90); break;
+
+ case -90:
+ case 270: wm.rotate(270); break;
+
+ default: ;
+ }
+}
+
+bool SQ_GLHelpers::normalizeSelection(int &sx, int &sy, int &sw, int &sh, int w, int h, const TQWMatrix &matr, int curangle, int orient)
+{
+ TQWMatrix wm = matr;
+
+ SQ_GLHelpers::subRotation(wm, curangle, orient);
+
+ if(!wm.isIdentity())
+ {
+ int ax = -w/2 + sx;
+ int ay = h/2 - sy;
+
+ TQPointArray pa(4), pb;
+
+ pa.setPoint(0, ax, ay-sh);
+ pa.setPoint(1, ax+sw, ay-sh);
+ pa.setPoint(2, ax+sw, ay);
+ pa.setPoint(3, ax, ay);
+
+ pb = wm.map(pa);
+
+ int fx, fy, fx2, fy2;
+ fx = std::min(std::min(pb.point(0).x(), pb.point(1).x()), std::min(pb.point(2).x(), pb.point(3).x()));
+ fy = std::max(std::max(pb.point(0).y(), pb.point(1).y()), std::max(pb.point(2).y(), pb.point(3).y()));
+
+ fx2 = std::max(std::max(pb.point(0).x(), pb.point(1).x()), std::max(pb.point(2).x(), pb.point(3).x()));
+ fy2 = std::min(std::min(pb.point(0).y(), pb.point(1).y()), std::min(pb.point(2).y(), pb.point(3).y()));
+
+ sx = fx;
+ sy = fy;
+ sw = fx2 - fx;
+ sh = fy - fy2;
+
+ sx += w/2;
+ sy = h/2-sy;
+ }
+
+ if(sx > w || sy > h || sx + sw < 0 || sy + sh < 0)
+ return false;
+
+ if(sx < 0) { sw = sw+sx; sx = 0; }
+ if(sy < 0) { sh = sh+sy; sy = 0; }
+
+ if(sx + sw > w) sw = w - sx;
+ if(sy + sh > h) sh = h - sy;
+
+ return (sw && sh);
+}
+
+void SQ_GLHelpers::scanLine0(RGBA *data, RGBA *scan, int rw, int w, int h, int y, int flip)
+{
+ if(flip == 1)
+ {
+ data = data + rw*y + w-1;
+
+ for(int i = 0;i < w;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data--;
+ }
+ }
+ else if(flip == 2)
+ {
+ data = data + rw*(h-1-y);
+
+ for(int i = 0;i < w;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data++;
+ }
+ }
+ else
+ memcpy(scan, data + rw*y, w * sizeof(RGBA));
+}
+
+void SQ_GLHelpers::scanLine90(RGBA *data, RGBA *scan, int rw, int w, int h, int y, int flip)
+{
+ if(flip == 2)
+ {
+ data = data + y;
+
+ for(int i = 0;i < h;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data += rw;
+ }
+ }
+ else
+ {
+ data = flip == 1 ? (data + rw*(h-1) + w-y-1) : (data + rw*(h-1) + y);
+
+ for(int i = 0;i < h;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data -= rw;
+ }
+ }
+}
+
+void SQ_GLHelpers::scanLine180(RGBA *data, RGBA *scan, int rw, int w, int h, int y, int flip)
+{
+ if(flip == 1)
+ {
+ data = data + rw*(h-1-y);
+
+ memcpy(scan, data, w * sizeof(RGBA));
+ }
+ else
+ {
+ data = flip == 2 ? (data + rw*y + w-1) : (data + rw*(h-1-y) + w-1);
+
+ for(int i = 0;i < w;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data--;
+ }
+ }
+}
+
+void SQ_GLHelpers::scanLine270(RGBA *data, RGBA *scan, int rw, int w, int h, int y, int flip)
+{
+ if(flip == 2)
+ {
+ data = data + rw*(h-1) + w-y-1;
+
+ for(int i = 0;i < h;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data -= rw;
+ }
+ }
+ else
+ {
+ data = flip == 1 ? (data + y) : (data + w-y-1);
+
+ for(int i = 0;i < h;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data += rw;
+ }
+ }
+}
diff --git a/src/ksquirrelpart/sq_glwidget_helpers.h b/src/ksquirrelpart/sq_glwidget_helpers.h
new file mode 100644
index 0000000..f8cfbd3
--- /dev/null
+++ b/src/ksquirrelpart/sq_glwidget_helpers.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ sq_glwidget_helpers.h - description
+ -------------------
+ begin : May 31 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_GLWIDGET_HELPERS
+#define SQ_GLWIDGET_HELPERS
+
+#include <tdetoolbarbutton.h>
+
+class TQWMatrix;
+
+class TDEToolBar;
+
+struct RGBA;
+
+class SQ_ToolButtonPopup : public TDEToolBarButton
+{
+ public:
+ SQ_ToolButtonPopup(const TQPixmap &pix, const TQString &textLabel, TDEToolBar *parent);
+ ~SQ_ToolButtonPopup();
+};
+
+class SQ_ToolButton : public TQToolButton
+{
+ public:
+ SQ_ToolButton(const TQIconSet &iconSet, const TQString &textLabel, TQObject *receiver,
+ const char *slot, TDEToolBar *parent, const char *name = 0);
+ ~SQ_ToolButton();
+
+ static int fixedWidth();
+};
+
+inline
+int SQ_ToolButton::fixedWidth()
+{
+ return 26;
+}
+
+namespace SQ_GLHelpers
+{
+ // 0, 1, 2
+ typedef void (* scanLineGetter)(RGBA *data, RGBA *, int rw, int w, int h, int y, int flip);
+
+ void scanLine0(RGBA *, RGBA *, int, int, int, int, int);
+ void scanLine90(RGBA *, RGBA *, int, int, int, int, int);
+ void scanLine180(RGBA *, RGBA *, int, int, int, int, int);
+ void scanLine270(RGBA *, RGBA *, int, int, int, int, int);
+
+ int roundAngle(int ang);
+
+ void subRotation(TQWMatrix &wm, int curangle, int orient);
+
+ /*
+ * normalize selection rectangle
+ * sx,sy are X and Y coordinates
+ * sw x sh is a selection geometry
+ */
+ bool normalizeSelection(int &sx, int &sy, int &sw, int &sh, int w, int h, const TQWMatrix&, int curangle, int orient);
+}
+
+#endif
diff --git a/src/ksquirrelpart/sq_glwidget_stuff.cpp b/src/ksquirrelpart/sq_glwidget_stuff.cpp
new file mode 100644
index 0000000..bde87c4
--- /dev/null
+++ b/src/ksquirrelpart/sq_glwidget_stuff.cpp
@@ -0,0 +1,1782 @@
+/***************************************************************************
+ sq_glwidget_stuff.cpp - description
+ -------------------
+ begin : Wed Oct 31 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqclipboard.h>
+#include <tqslider.h>
+#include <tqdragobject.h>
+#include <tqtimer.h>
+#include <tqlabel.h>
+#include <tqpainter.h>
+#include <tqpaintdevicemetrics.h>
+
+#include <tdeapplication.h>
+#include <tdeaction.h>
+#include <kstandarddirs.h>
+#include <tdelocale.h>
+#include <tdepopupmenu.h>
+#include <ktabbar.h>
+#include <kcursor.h>
+#include <tdetempfile.h>
+#include <tdemessagebox.h>
+#include <tdefileitem.h>
+#include <kprinter.h>
+
+#include <algorithm>
+
+#ifndef KSQUIRREL_PART
+#include "ksquirrel.h"
+#include "sq_widgetstack.h"
+#endif
+
+#include "sq_config.h"
+#include "sq_libraryhandler.h"
+#include "sq_glview.h"
+#include "sq_glwidget.h"
+#include "sq_glwidget_helpers.h"
+#include "sq_imageproperties.h"
+#include "sq_helpwidget.h"
+#include "sq_filedialog.h"
+#include "sq_iconloader.h"
+#include "sq_codecsettingsskeleton.h"
+#include "sq_externaltool.h"
+#include "sq_diroperator.h"
+#include "sq_popupmenu.h"
+#include "sq_glselectionpainter.h"
+#include "sq_utils.h"
+#include "sq_imagefilter.h"
+#include "sq_imagebcg.h"
+#include "fmt_filters.h"
+
+#ifdef SQ_HAVE_KEXIF
+#include <libkexif/kexifdata.h>
+#include <libexif/exif-data.h>
+#endif
+
+#include <ksquirrel-libs/fmt_codec_base.h>
+#include <ksquirrel-libs/error.h>
+
+#include "file_broken.xpm"
+
+// Create actions
+void SQ_GLWidget::createActions()
+{
+ pASelectionRect = new TDEToggleAction(i18n("Rectangle"), TQPixmap(locate("data", "images/actions/glselection_rect.png")), 0, this, TQ_SLOT(slotSelectionRect()), ac, "SQ Selection Rect");
+ pASelectionEllipse = new TDEToggleAction(i18n("Ellipse"), TQPixmap(locate("data", "images/actions/glselection_ellipse.png")), 0, this, TQ_SLOT(slotSelectionEllipse()), ac, "SQ Selection Ellipse");
+ pASelectionClear = new TDEAction(i18n("Clear"), 0, 0, this, TQ_SLOT(slotSelectionClear()), ac, "SQ Selection Clear");
+
+ pAZoomW = new TDEToggleAction(i18n("Fit width"), TQPixmap(locate("data", "images/actions/zoomW.png")), 0, this, TQ_SLOT(slotZoomW()), ac, "SQ ZoomW");
+ pAZoomH = new TDEToggleAction(i18n("Fit height"), TQPixmap(locate("data", "images/actions/zoomH.png")), 0, this, TQ_SLOT(slotZoomH()), ac, "SQ ZoomH");
+ pAZoomWH = new TDEToggleAction(i18n("Fit image"), TQPixmap(locate("data", "images/actions/zoomWH.png")), 0, this, TQ_SLOT(slotZoomWH()), ac, "SQ ZoomWH");
+ pAZoom100 = new TDEToggleAction(i18n("Zoom 100%"), TQPixmap(locate("data", "images/actions/zoom100.png")), 0, this, TQ_SLOT(slotZoom100()), ac, "SQ Zoom100");
+ pAZoomLast = new TDEToggleAction(i18n("Leave previous zoom"), TQPixmap(locate("data", "images/actions/zoomlast.png")), 0, this, TQ_SLOT(slotZoomLast()), ac, "SQ ZoomLast");
+ pAIfLess = new TDEToggleAction(i18n("Ignore, if image is smaller than window"), TQPixmap(locate("data", "images/actions/ifless.png")), 0, 0, 0, ac, "if less");
+
+ pAFull = new TDEToggleAction(TQString(), 0, 0, 0, ac, "SQ GL Full");
+
+ TQString squirrel_zoom_actions = TQString::fromLatin1("squirrel_zoom_actions");
+ pAZoomW->setExclusiveGroup(squirrel_zoom_actions);
+ pAZoomH->setExclusiveGroup(squirrel_zoom_actions);
+ pAZoomWH->setExclusiveGroup(squirrel_zoom_actions);
+ pAZoom100->setExclusiveGroup(squirrel_zoom_actions);
+ pAZoomLast->setExclusiveGroup(squirrel_zoom_actions);
+
+ TQString squirrel_selection_type = TQString::fromLatin1("squirrel_selection_type");
+ pASelectionEllipse->setExclusiveGroup(squirrel_selection_type);
+ pASelectionRect->setExclusiveGroup(squirrel_selection_type);
+
+ connect(pAIfLess, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotZoomIfLess()));
+
+#ifndef KSQUIRREL_PART
+ connect(pAFull, TQ_SIGNAL(toggled(bool)), KSquirrel::app(), TQ_SLOT(slotFullScreen(bool)));
+#endif
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ pAIfLess->setChecked(SQ_Config::instance()->readBoolEntry("ignore", true));
+}
+
+void SQ_GLWidget::createToolbar()
+{
+ zoomMenu = new TDEPopupMenu;
+
+#ifndef KSQUIRREL_PART
+ selectionMenu = new TDEPopupMenu;
+
+ SQ_ToolButton *pATool;
+
+ SQ_ToolBar *toolbar = SQ_GLView::window()->toolbar();
+
+ pASelectionRect->plug(selectionMenu);
+ pASelectionEllipse->plug(selectionMenu);
+ selectionMenu->insertSeparator();
+ pASelectionClear->plug(selectionMenu);
+
+ // hack to show accels
+ selectionMenu->changeItem(pASelectionRect->itemId(0), pASelectionRect->text() + "\tCtrl+R");
+ selectionMenu->changeItem(pASelectionEllipse->itemId(0), pASelectionEllipse->text() + "\tCtrl+E");
+ selectionMenu->changeItem(pASelectionClear->itemId(0), pASelectionClear->text() + "\tCtrl+C");
+
+ pAZoom100->plug(zoomMenu);
+ pAZoomLast->plug(zoomMenu);
+ zoomMenu->insertSeparator();
+ pAZoomW->plug(zoomMenu);
+ pAZoomH->plug(zoomMenu);
+ pAZoomWH->plug(zoomMenu);
+ zoomMenu->insertSeparator();
+ pAIfLess->plug(zoomMenu);
+
+ switch(zoom_type)
+ {
+ case 0: pAZoomW->setChecked(true); break;
+ case 1: pAZoomH->setChecked(true); break;
+ case 3: pAZoom100->setChecked(true); break;
+ case 4: pAZoomLast->setChecked(true); break;
+
+ // "case 2" too
+ default: pAZoomWH->setChecked(true);
+ }
+
+/*
+ * We will create TQToolButtons and put them in toolbar.
+ * Of course, we can just TDEAction::plug(), BUT plugged TDEActions
+ * will produce buttons, which cann't be clicked twise! I think
+ * plugged TDEActions will treat our attempt as double-click, not two single-clicks.
+ * On the other hand, we can click TQToolButton as frequently as we want.
+ *
+ * Plugged TDEActions also don't know about autorepeat :(
+ */
+ new SQ_ToolButton(TQPixmap(locate("data", "images/actions/file_first.png")), i18n("Go to first image"), this, TQ_SLOT(slotFirst()), toolbar);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/file_prev.png")), i18n("Previous image"), this, TQ_SLOT(slotPrev()), toolbar);
+ pATool->setAutoRepeat(true);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/file_next.png")), i18n("Next image"), this, TQ_SLOT(slotNext()), toolbar);
+ pATool->setAutoRepeat(true);
+ new SQ_ToolButton(TQPixmap(locate("data", "images/actions/file_last.png")), i18n("Go to last image"), this, TQ_SLOT(slotLast()), toolbar);
+
+ // some toolbuttons need autorepeat...
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/zoom+.png")), i18n("Zoom +"), this, TQ_SLOT(slotZoomPlus()), toolbar);
+ pATool->setAutoRepeat(true);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/zoom-.png")), i18n("Zoom -"), this, TQ_SLOT(slotZoomMinus()), toolbar);
+ pATool->setAutoRepeat(true);
+ pAToolZoom = new SQ_ToolButtonPopup(TQPixmap(locate("data", "images/actions/zoom_template.png")), i18n("Zoom"), toolbar);
+ pAToolZoom->setPopup(zoomMenu);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/rotateL.png")), i18n("Rotate left"), this, TQ_SLOT(slotRotateLeft()), toolbar);
+ pATool->setAutoRepeat(true);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/rotateR.png")), i18n("Rotate right"), this, TQ_SLOT(slotRotateRight()), toolbar);
+ pATool->setAutoRepeat(true);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/flipV.png")), i18n("Flip vertically"), this, TQ_SLOT(slotFlipV()), toolbar);
+ pATool->setAutoRepeat(true);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/flipH.png")), i18n("Flip horizontally"), this, TQ_SLOT(slotFlipH()), toolbar);
+ pATool->setAutoRepeat(true);
+ new SQ_ToolButton(TQPixmap(locate("data", "images/actions/reload.png")), i18n("Normalize"), this, TQ_SLOT(slotMatrixReset()), toolbar);
+
+ pAToolFull = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/fullscreen.png")), i18n("Fullscreen"), pAFull, TQ_SLOT(activate()), toolbar);
+ pAToolFull->setToggleButton(true);
+ pAToolImages = new SQ_ToolButtonPopup(TQPixmap(locate("data", "images/actions/images.png")), i18n("Select image"), toolbar);
+ pAToolImages->setPopup(images);
+ SQ_ToolButtonPopup *pAToolSel = new SQ_ToolButtonPopup(TQPixmap(locate("data", "images/actions/glselection.png")), i18n("Selection"), toolbar);
+ pAToolSel->setPopup(selectionMenu);
+ pAToolQuick = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/configure.png")), i18n("Codec settings"), this, TQ_SLOT(slotShowCodecSettings()), toolbar);
+ pAToolQuick->setEnabled(false);
+ pAToolProp = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/prop.png")), i18n("Image Properties"), this, TQ_SLOT(slotProperties()), toolbar);
+ pAToolPrint = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/print.png")), i18n("Print"), this, TQ_SLOT(slotPrint()), toolbar);
+ new SQ_ToolButton(TQPixmap(locate("data", "images/actions/shownav.png")), i18n("Show navigator"), this, TQ_SLOT(slotShowNav()), toolbar);
+
+ slider_zoom = new TQSlider(1, 38, 2, 19, TQt::Horizontal, toolbar);
+ slider_zoom->setTickmarks(TQSlider::Below);
+ slider_zoom->setTickInterval(19);
+ connect(slider_zoom, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(slotSetZoomPercents(int)));
+ toolbar->insertWidget(1000, 0, slider_zoom);
+ toolbar->setItemAutoSized(1000);
+ toolbar->alignItemRight(1000);
+
+ changeSlider(1.0);
+#endif
+}
+
+// Show image properties.
+void SQ_GLWidget::slotProperties()
+{
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ // Stop animation...
+ stopAnimation();
+
+ const int real_size = tab->finfo.image[tab->current].w * tab->finfo.image[tab->current].h * sizeof(RGBA);
+ TQString sz = TDEIO::convertSize(real_size);
+ TQStringList list;
+
+ TQValueVector<TQPair<TQString,TQString> > meta;
+
+ if(!tab->finfo.meta.empty())
+ {
+ for(std::vector<fmt_metaentry>::iterator it = tab->finfo.meta.begin();it != tab->finfo.meta.end();++it)
+ {
+ meta.append(TQPair<TQString,TQString>((*it).group, (*it).data));
+ }
+ }
+
+ // save tab->current image parameters and some additioanl information
+ // in list
+ list << tab->quickImageInfo
+ << TQString::fromLatin1("%1x%2").arg(tab->finfo.image[tab->current].w).arg(tab->finfo.image[tab->current].h)
+ << TQString::fromLatin1("%1").arg(tab->finfo.image[tab->current].bpp)
+ << tab->finfo.image[tab->current].colorspace
+ << tab->finfo.image[tab->current].compression
+ << sz
+ << TQString::fromLatin1("%1").arg((double)real_size / tab->fmt_size, 0, 'f', 2)
+ << ((tab->finfo.image[tab->current].interlaced) ? i18n("yes") : i18n("no"))
+ << TQString::fromLatin1("%1").arg(errors)
+ << TQString::fromLatin1("%1").arg(tab->finfo.image.size())
+ << TQString::fromLatin1("#%1").arg(tab->current+1)
+ << TQString::fromLatin1("%1").arg(tab->finfo.image[tab->current].delay);
+
+ // create dialog and setup it
+ SQ_ImageProperties prop(this);
+ prop.setFile(tab->m_File);
+ prop.setURL(tab->m_original);
+ prop.setParams(list);
+ prop.setMetaInfo(meta);
+
+ // show!
+ prop.exec();
+
+ // restore animation
+ if(!manualBlocked())
+ startAnimation();
+}
+
+void SQ_GLWidget::findCloserTiles(int w, int h, std::vector<int> &x, std::vector<int> &y)
+{
+ static int s = 9;
+ static int dims[10] = { 2, 4, 8, 16, 32, 64, 128, 256, 512 };
+
+ int *dd[2] = { &w, &h };
+ std::vector<int> *dv[2] = { &x, &y };
+ int del;
+
+ for(int ff = 0;ff < 2;ff++)
+ {
+ if(*dd[ff] == 1) *dd[ff]=2;
+ else if((*dd[ff])%2) (*dd[ff])++;
+
+ while((*dd[ff]) >= 512)
+ {
+ (*dv[ff]).push_back(512);
+ (*dd[ff]) -= 512;
+ }
+
+ for(int i = 0;i < s-1;i++)
+ if((*dd[ff]) >= dims[i] && (*dd[ff]) < dims[i+1])
+ {
+ del = dims[i] + (dims[i]>>1);
+
+ if((*dd[ff]) <= del)
+ {
+ (*dv[ff]).push_back(dims[i]);
+ (*dd[ff]) -= dims[i];
+ }
+ else
+ {
+ (*dv[ff]).push_back(dims[i+1]);
+ (*dd[ff]) -= dims[i+1];
+ }
+
+ i = -1;
+ }
+ }
+}
+
+TQPair<int, int> SQ_GLWidget::calcRealDimensions(Parts &p, int y, int x)
+{
+ int rw = 0, rh = 0;
+ int toy = y == -1 ? p.tilesy.size() : y;
+ int tox = x == -1 ? p.tilesx.size() : x;
+
+ std::vector<int>::iterator itEnd = p.tilesx.end();
+
+ for(std::vector<int>::iterator it = p.tilesx.begin();it != itEnd && tox--;++it)
+ rw += (*it);
+
+ itEnd = p.tilesy.end();
+
+ for(std::vector<int>::iterator it = p.tilesy.begin();it != itEnd && toy--;++it)
+ rh += (*it);
+
+ return TQPair<int, int>(rw, rh);
+}
+
+void SQ_GLWidget::slotShowCodecSettings()
+{
+ tab->lib = SQ_LibraryHandler::instance()->libraryForFile(tab->m_File);
+
+ if(!tab->lib || tab->lib->config.isEmpty()) // oops ?
+ {
+ enableSettingsButton(false);
+ return;
+ }
+
+ SQ_CodecSettingsSkeleton skel(this);
+
+ connect(&skel, TQ_SIGNAL(apply()), this, TQ_SLOT(slotApplyCodecSettings()));
+
+ skel.addSettingsWidget(tab->lib->config);
+ skel.setCodecInfo(tab->lib->mime, tab->lib->quickinfo);
+ skel.adjustSize();
+
+ if(skel.exec(tab->lib->settings) == TQDialog::Accepted)
+ tab->lib->codec->set_settings(tab->lib->settings);
+}
+
+void SQ_GLWidget::slotApplyCodecSettings()
+{
+ if(tab->lib)
+ {
+ // new settings are already set by SQ_CodecSettingsSkeleton
+ tab->lib->codec->set_settings(tab->lib->settings);
+ m_original = tab->m_original;
+ startDecoding(TQString(tab->m_File));
+ }
+}
+
+void SQ_GLWidget::slotSetCurrentImage(int id)
+{
+ if(tab->total == 1)
+ return;
+
+ images->setItemChecked(old_id, false);
+ tab->current = images->itemParameter(id);
+
+ images->setItemChecked(id, true);
+ old_id = id;
+
+ updateCurrentFileInfo();
+ updateGL();
+}
+
+void SQ_GLWidget::slotImagesShown()
+{
+ if(tab->finfo.animated)
+ {
+ if(!timer_anim->isActive())
+ blocked = false;
+ else
+ {
+ stopAnimation();
+ blocked = true;
+ }
+ }
+
+ images->setItemChecked(old_id, false);
+ int id = images->idAt(tab->current);
+ images->setItemChecked(id, true);
+ old_id = id;
+}
+
+void SQ_GLWidget::slotShowImages()
+{
+ images->exec(TQCursor::pos());
+}
+
+void SQ_GLWidget::slotImagesHidden()
+{
+ if(blocked && tab->finfo.animated)
+ startAnimation();
+}
+
+void SQ_GLWidget::slotShowHelp()
+{
+ SQ_HelpWidget help_w(this);
+
+ help_w.exec();
+}
+
+void SQ_GLWidget::showExternalTools()
+{
+ bool v_ogorogde_buzina_a_v_kieve_dzyadka = SQ_ExternalTool::instance()->constPopupMenu()->isEnabled();
+ SQ_ExternalTool::instance()->constPopupMenu()->setEnabled(true);
+
+ KFileItemList items;
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, tab->m_original);
+
+ if(!tab->m_original.isEmpty())
+ {
+ items.append(&fi);
+ SQ_ExternalTool::instance()->setItems(items);
+ }
+
+ SQ_ExternalTool::instance()->constPopupMenu()->exec(TQCursor::pos());
+ SQ_ExternalTool::instance()->constPopupMenu()->setEnabled(v_ogorogde_buzina_a_v_kieve_dzyadka);
+}
+
+// Delete current image (user pressed 'Delete' key).
+void SQ_GLWidget::deleteWrapper()
+{
+ if(tab->m_original.isEmpty())
+ return;
+
+#ifndef KSQUIRREL_PART
+ KFileItemList list;
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, tab->m_original);
+ list.append(&fi);
+ SQ_WidgetStack::instance()->diroperator()->del(list, this);
+#else
+ SQ_DirOperator::instance()->del(tab->m_original, this);
+#endif
+}
+
+void SQ_GLWidget::enableSettingsButton(bool enab)
+{
+#ifndef KSQUIRREL_PART
+ pAToolQuick->setEnabled(enab);
+#endif
+
+ menuImage->setItemEnabled(id_settings, enab);
+}
+
+void SQ_GLWidget::saveAs()
+{
+ if(!tab->lib || tab->finfo.image.empty()) // nothing to save
+ return;
+
+ SQ_Config::instance()->setGroup("GL view");
+ TQString lastPath = SQ_Config::instance()->readEntry("saveasPath");
+ TQString lastFilt = SQ_Config::instance()->readEntry("saveasFilter");
+
+ if(lastPath.isEmpty())
+ {
+ KURL u = tab->m_original;
+ u.cd("..");
+ lastPath = u.prettyURL();
+ }
+
+ SQ_FileDialog d(lastPath, this);
+
+ // set filter: writable codecs without *.*
+ d.setFilter(SQ_LibraryHandler::instance()->allFiltersFileDialogString(false, false));
+ d.setOperationMode(KFileDialog::Saving);
+ d.setSelection(tab->m_original.fileName());
+ d.setCurrentFilter(lastFilt);
+ d.updateCombo(false);
+
+ if(d.exec() == TQDialog::Rejected || d.selectedURL().isEmpty())
+ return;
+
+ KURL url = d.selectedURL();
+
+ // cut off file name
+ KURL u = url;
+ u.cd("..");
+ SQ_Config::instance()->writeEntry("saveasPath", u.prettyURL());
+ SQ_Config::instance()->writeEntry("saveasFilter", d.nameFilter());
+
+ TQString path = url.isLocalFile() ? url.path() : tmp->name();
+
+ SQ_LIBRARY *wlib = SQ_LibraryHandler::instance()->libraryByName(d.nameFilter());
+
+ if(!wlib || !wlib->writestatic)
+ {
+ KMessageBox::error(this, i18n("Sorry, could not perform write operation\nfor codec \"%1\"").arg(d.nameFilter()));
+ return;
+ }
+
+ SQ_GLHelpers::scanLineGetter scgetter;
+ int flp = 0;
+ int curangle = SQ_GLHelpers::roundAngle((int)tab->curangle);
+
+ fmt_image im = tab->finfo.image[tab->current];
+
+/*
+ * The easiest way to rotate image is to use TQImage + TQImage::xForm(),
+ * but this method is VERY memory inefficient. We will use our own tranformation
+ * routins... Yes, they will be a little bit slower, but they require only
+ * one scaline in stack.
+ */
+
+ int w = im.w, h = im.h;
+ int rw = tab->parts[tab->current].realw;
+
+#ifdef SQ_HAVE_KEXIF
+ switch(tab->orient)
+ {
+ case KExifData::HFLIP:
+ case KExifData::ROT_90_HFLIP:
+ flp = 1;
+ break;
+
+ case KExifData::VFLIP:
+ case KExifData::ROT_90_VFLIP:
+ flp = 2;
+ break;
+
+ default: ;
+ }
+#endif
+
+ switch(curangle)
+ {
+ case -270:
+ case 90: scgetter = SQ_GLHelpers::scanLine90; std::swap(w, h); break;
+
+ case -180:
+ case 180: scgetter = SQ_GLHelpers::scanLine180; break;
+
+ case -90:
+ case 270: scgetter = SQ_GLHelpers::scanLine270; std::swap(w, h); break;
+
+ default: scgetter = SQ_GLHelpers::scanLine0;
+ }
+
+ RGBA *scan = new RGBA[w];
+ RGBA *data = tab->parts[tab->current].buffer->data();
+
+ fmt_image im2 = im;
+ im2.w = w;
+ im2.h = h;
+
+ fmt_writeoptions opt;
+ opt.interlaced = false;
+ opt.alpha = im.hasalpha;
+ opt.bitdepth = im.bpp;
+ opt.compression_scheme = (wlib->opt.compression_scheme & CompressionNo) ? CompressionNo : CompressionInternal;
+ opt.compression_level = wlib->opt.compression_def;
+
+ int err = wlib->codec->write_init(TQString(TQFile::encodeName(path)).ascii(), im2, opt);
+
+ if(err != SQE_OK)
+ {
+ KMessageBox::error(this, i18n("Error writing image"));
+ delete [] scan;
+ return;
+ }
+
+ err = wlib->codec->write_next();
+
+ if(err != SQE_OK)
+ {
+ KMessageBox::error(this, i18n("Error writing image"));
+ delete [] scan;
+ return;
+ }
+
+ wlib->codec->write_next_pass();
+
+ int H = im2.h;
+ int Y0 = wlib->opt.needflip ? (-H+1):0;
+ int Y = wlib->opt.needflip ? 1:H;
+ int f;
+
+ for(int j = Y0;j < Y;j++)
+ {
+ f = (j < 0) ? -j : j;
+
+ scgetter(data, scan, rw, im.w, im.h, f, flp);
+
+ err = wlib->codec->write_scanline(scan);
+
+ if(err != SQE_OK)
+ {
+ wlib->codec->write_close();
+ KMessageBox::error(this, i18n("Error writing image"));
+ delete [] scan;
+ return;
+ }
+ }
+
+ wlib->codec->write_close();
+ delete [] scan;
+
+ // copy to non-local directory
+ if(!url.isLocalFile())
+ {
+ // src dst perm overwrite resume progress
+ TDEIO::Job *j = TDEIO::file_copy(path, url, -1, true, false, false);
+
+ connect(j, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotCopyResult(TDEIO::Job *)));
+ }
+}
+
+void SQ_GLWidget::slotCopyResult(TDEIO::Job *job)
+{
+ if(job->error())
+ {
+ if(KMessageBox::questionYesNoCancel(this, job->errorString() + '\n' + i18n("Try another location?")) == KMessageBox::Yes)
+ {
+ SQ_FileDialog d(TQString(), this);
+
+ // set filter: writable codecs without *.*
+ d.setFilter(SQ_LibraryHandler::instance()->allFiltersFileDialogString(false, false));
+ d.setOperationMode(KFileDialog::Saving);
+ d.updateCombo(false);
+
+ int result = d.exec();
+
+ if(result == TQDialog::Rejected || d.selectedURL().isEmpty())
+ return;
+
+ TDEIO::Job *j = TDEIO::file_copy(tmp->name(), d.selectedURL(), -1, true, false, false);
+ connect(j, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotCopyResult(TDEIO::Job *)));
+ }
+ }
+}
+
+void SQ_GLWidget::toClipboard()
+{
+ if(!decoded || tab->broken)
+ return;
+
+ TQImage im((uchar *)tab->parts[tab->current].buffer->data(), tab->parts[tab->current].realw, tab->parts[tab->current].realh, 32, 0, 0, TQImage::LittleEndian);
+
+ im = im.swapRGB();
+
+ // image doesn't have extra regions
+ if(tab->parts[tab->current].realw == tab->parts[tab->current].w && tab->parts[tab->current].realh == tab->parts[tab->current].h)
+ TDEApplication::clipboard()->setImage(im, TQClipboard::Clipboard);
+ else
+ TDEApplication::clipboard()->setImage(im.copy(0, 0, tab->parts[tab->current].w, tab->parts[tab->current].h), TQClipboard::Clipboard);
+}
+
+void SQ_GLWidget::bcg()
+{
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ SQ_ImageBCG _bcg(this);
+
+ stopAnimation();
+
+ _bcg.setPreviewImage(generatePreview());
+
+ connect(&_bcg, TQ_SIGNAL(bcg(SQ_ImageBCGOptions *)), this, TQ_SLOT(slotBCG(SQ_ImageBCGOptions *)));
+
+ _bcg.exec();
+
+ if(!manualBlocked())
+ startAnimation();
+}
+
+void SQ_GLWidget::filter()
+{
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ SQ_ImageFilter flt(this);
+
+ stopAnimation();
+
+ flt.setPreviewImage(generatePreview());
+
+ connect(&flt, TQ_SIGNAL(filter(SQ_ImageFilterOptions *)), this, TQ_SLOT(slotFilter(SQ_ImageFilterOptions *)));
+
+ flt.exec();
+
+ if(!manualBlocked())
+ startAnimation();
+}
+
+void SQ_GLWidget::slotFilter(SQ_ImageFilterOptions *filtopt)
+{
+ TQImage im((uchar *)tab->parts[tab->current].buffer->data(), tab->parts[tab->current].realw, tab->parts[tab->current].realh, 32, 0, 0, TQImage::LittleEndian);
+ TQImage img = gls->valid() ? im.copy(tab->sx, tab->sy, tab->sw, tab->sh) : im;
+
+ fmt_filters::image image =
+ gls->valid() ? fmt_filters::image((unsigned char *)img.bits(), img.width(), img.height())
+ : fmt_filters::image((unsigned char *)img.bits(), tab->parts[tab->current].w, tab->parts[tab->current].h, img.width(), img.height());
+
+ fmt_filters::rgba c = fmt_filters::white;
+
+ switch(filtopt->type)
+ {
+ case F::fblend: fmt_filters::blend(image, filtopt->rgb1, filtopt->_float); break;
+ case F::fblur: fmt_filters::blur(image, filtopt->_double1, filtopt->_double2);break;
+ case F::fdesaturate: fmt_filters::desaturate(image, filtopt->_float); break;
+ case F::fdespeckle: fmt_filters::despeckle(image); break;
+ case F::fedge: fmt_filters::edge(image, filtopt->_double1); break;
+ case F::femboss: fmt_filters::emboss(image, filtopt->_double1, filtopt->_double2); break;
+ case F::fequalize: fmt_filters::equalize(image); break;
+ case F::ffade: fmt_filters::fade(image, filtopt->rgb1, filtopt->_float); break;
+ case F::fflatten: fmt_filters::flatten(image, filtopt->rgb1, filtopt->rgb2); break;
+ case F::fimplode: fmt_filters::implode(image, filtopt->_double1, c); break;
+ case F::fnegative: fmt_filters::negative(image); break;
+ case F::fnoise: fmt_filters::noise(image, (fmt_filters::NoiseType)filtopt->_uint); break;
+ case F::foil: fmt_filters::oil(image, filtopt->_double1); break;
+ case F::fshade: fmt_filters::shade(image, filtopt->_bool, filtopt->_double1, filtopt->_double2); break;
+ case F::fsharpen: fmt_filters::sharpen(image, filtopt->_double1, filtopt->_double2); break;
+ case F::fsolarize: fmt_filters::solarize(image, filtopt->_double1); break;
+ case F::fspread: fmt_filters::spread(image, filtopt->_uint); break;
+ case F::fswapRGB: fmt_filters::swapRGB(image, filtopt->_uint); break;
+ case F::fswirl: fmt_filters::swirl(image, filtopt->_double1, c); break;
+ case F::fthreshold: fmt_filters::threshold(image, filtopt->_uint); break;
+ case F::fgray: fmt_filters::gray(image); break;
+ case F::fredeye: fmt_filters::redeye(image, image.w, image.h, 0, 0, filtopt->_uint); break;
+ }
+
+ if(gls->valid()) bitBlt(&im, tab->sx, tab->sy, &img, 0, 0, img.width(), img.height());
+
+ editUpdate();
+
+ SQ_ImageFilter::instance()->setPreviewImage(generatePreview());
+}
+
+void SQ_GLWidget::slotBCG(SQ_ImageBCGOptions *bcgopt)
+{
+ TQImage im((uchar *)tab->parts[tab->current].buffer->data(), tab->parts[tab->current].realw, tab->parts[tab->current].realh, 32, 0, 0, TQImage::LittleEndian);
+ TQImage img = gls->valid() ? im.copy(tab->sx, tab->sy, tab->sw, tab->sh) : im;
+
+ fmt_filters::image image =
+ gls->valid() ? fmt_filters::image((unsigned char *)img.bits(), img.width(), img.height())
+ : fmt_filters::image((unsigned char *)img.bits(), tab->parts[tab->current].w, tab->parts[tab->current].h, img.width(), img.height());
+ if(bcgopt->b)
+ fmt_filters::brightness(image, bcgopt->b);
+
+ if(bcgopt->c)
+ fmt_filters::contrast(image, bcgopt->c);
+
+ if(bcgopt->g != 100)
+ fmt_filters::gamma(image, (double)bcgopt->g / 100.0);
+
+ if(bcgopt->red || bcgopt->green || bcgopt->blue)
+ fmt_filters::colorize(image, bcgopt->red, bcgopt->green, bcgopt->blue);
+
+ if(gls->valid()) bitBlt(&im, tab->sx, tab->sy, &img, 0, 0, img.width(), img.height());
+
+ editUpdate();
+
+ SQ_ImageBCG::instance()->setPreviewImage(generatePreview());
+}
+
+bool SQ_GLWidget::calcSelection()
+{
+ TQSize sz = gls->size();
+ TQPoint pt = gls->pos();
+
+ float z = getZoom();
+ float x = pt.x(), y = pt.y(), w = sz.width(), h = sz.height();
+ x = x - (float)width()/2 - MATRIX_X + (float)tab->parts[tab->current].w/2 * z;
+ y = y - (float)height()/2 + MATRIX_Y + (float)tab->parts[tab->current].h/2 * z;
+
+ int sx = (int)(x/z + 0.5);
+ int sy = (int)(y/z + 0.5);
+ int sw = (int)(w/z + 0.5);
+ int sh = (int)(h/z + 0.5);
+
+ if(!sw || !sh)
+ {
+ gls->end();
+ return false;
+ }
+ else
+ {
+ if(SQ_GLHelpers::normalizeSelection(sx,
+ sy,
+ sw,
+ sh,
+ tab->parts[tab->current].w,
+ tab->parts[tab->current].h,
+ tab->wm,
+ (int)tab->curangle,
+ tab->orient))
+ {
+ tab->srect = TQRect(pt, sz);
+ tab->sx = sx;
+ tab->sy = sy;
+ tab->sw = sw;
+ tab->sh = sh;
+ }
+ else
+ return false;
+ }
+
+ return true;
+}
+
+TQImage SQ_GLWidget::generatePreview()
+{
+ TQImage im((uchar *)tab->parts[tab->current].buffer->data(), tab->parts[tab->current].realw, tab->parts[tab->current].realh, 32, 0, 0, TQImage::LittleEndian);
+ TQImage img, ret;
+
+ if(gls->valid() && calcSelection())
+ img = im.copy(tab->sx, tab->sy, tab->sw, tab->sh);
+ else
+ {
+ if(tab->parts[tab->current].realw == tab->parts[tab->current].w && tab->parts[tab->current].realh == tab->parts[tab->current].h)
+ img = im;
+ else
+ img = im.copy(0, 0, tab->parts[tab->current].w, tab->parts[tab->current].h);
+ }
+
+ ret = SQ_Utils::scaleImage((unsigned char *)img.bits(), img.width(), img.height(), 160).swapRGB();
+
+ SQ_Utils::exifRotate(TQString(), ret, tab->orient);
+
+ return ret;
+}
+
+void SQ_GLWidget::editUpdate()
+{
+ int tlsy = tab->parts[tab->current].tilesy.size();
+
+ glDeleteLists(tab->parts[tab->current].m_parts[0].list, tlsy);
+
+ for(int i = 0;i < tlsy;i++)
+ showFrames(i, &tab->parts[tab->current], false);
+
+ updateGL();
+}
+
+void SQ_GLWidget::slotShowNav()
+{
+#ifndef KSQUIRREL_PART
+ KSquirrel::app()->activate();
+#endif
+}
+
+void SQ_GLWidget::initAccelsAndMenu()
+{
+ TQPopupMenu *menuRotate = new TQPopupMenu(menu);
+ TQPopupMenu *menuZoom = new TQPopupMenu(menu);
+ TQPopupMenu *menuMove = new TQPopupMenu(menu);
+
+#ifndef KSQUIRREL_PART
+ TQPopupMenu *menuWindow = new TQPopupMenu(menu);
+#endif
+
+ menuImage = new TQPopupMenu(menu);
+ menuFile = new TQPopupMenu(menu);
+
+ menu->insertItem(SQ_IconLoader::instance()->loadIcon("icons", TDEIcon::Desktop, TDEIcon::SizeSmall), i18n("File"), menuFile);
+ menu->insertItem(SQ_IconLoader::instance()->loadIcon("view_orientation", TDEIcon::Desktop, TDEIcon::SizeSmall), i18n("Rotate"), menuRotate);
+ menu->insertItem(SQ_IconLoader::instance()->loadIcon("viewmag", TDEIcon::Desktop, TDEIcon::SizeSmall), i18n("Zoom"), menuZoom);
+ menu->insertItem(i18n("Move"), menuMove);
+
+#ifndef KSQUIRREL_PART
+ menu->insertItem(i18n("Window"), menuWindow);
+#endif
+
+ menu->insertItem(i18n("Image"), menuImage);
+
+#define SQ_ADD_KACTION(b) \
+ (new TDEAction(TQString(), b, this, TQ_SLOT(slotAccelActivated()), ac, TQString::fromLatin1("action_%1").arg(b)))
+
+ id_saveas = menuFile->insertItem(SQ_IconLoader::instance()->loadIcon("document-save-as", TDEIcon::Desktop, TDEIcon::SizeSmall), i18n("Save As...") + "\tS", SQ_ADD_KACTION(TQt::Key_S), TQ_SLOT(activate()));
+
+#ifndef KSQUIRREL_PART
+ menuFile->insertSeparator();
+ menuFile->insertItem(TQPixmap(locate("data", "images/menu/next16.png")), i18n("Next") + "\tPageDown", SQ_ADD_KACTION(TQt::Key_PageDown), TQ_SLOT(activate()));
+ menuFile->insertItem(TQPixmap(locate("data", "images/menu/prev16.png")), i18n("Previous") + "\tPageUp", SQ_ADD_KACTION(TQt::Key_PageUp), TQ_SLOT(activate()));
+ menuFile->insertItem(TQPixmap(locate("data", "images/menu/first16.png")), i18n("First") + "\tHome", SQ_ADD_KACTION(TQt::Key_Home), TQ_SLOT(activate()));
+ menuFile->insertItem(TQPixmap(locate("data", "images/menu/last16.png")), i18n("Last") + "\tEnd", SQ_ADD_KACTION(TQt::Key_End), TQ_SLOT(activate()));
+#endif
+
+ menuFile->insertSeparator();
+ id_f5 = menuFile->insertItem(i18n("Copy to...") + "\tF5", SQ_ADD_KACTION(TQt::Key_F5), TQ_SLOT(activate()));
+ id_f6 = menuFile->insertItem(i18n("Move to...") + "\tF6", SQ_ADD_KACTION(TQt::Key_F7), TQ_SLOT(activate()));
+ id_f7 = menuFile->insertItem(i18n("Copy to last folder") + "\tF7", SQ_ADD_KACTION(TQt::Key_F6), TQ_SLOT(activate()));
+ id_f8 = menuFile->insertItem(i18n("Move to last folder") + "\tF8", SQ_ADD_KACTION(TQt::Key_F8), TQ_SLOT(activate()));
+ menuFile->insertSeparator();
+ id_del = menuFile->insertItem(i18n("Delete") + "\tDelete", SQ_ADD_KACTION(TQt::Key_Delete), TQ_SLOT(activate()));
+
+ menuRotate->insertItem(TQPixmap(locate("data", "images/menu/rotateLeft16.png")), i18n("Rotate left") + "\tCtrl+Left", SQ_ADD_KACTION(TQt::Key_Left+CTRL), TQ_SLOT(activate()));
+ menuRotate->insertItem(TQPixmap(locate("data", "images/menu/rotateRight16.png")), i18n("Rotate right") + "\tCtrl+Right", SQ_ADD_KACTION(TQt::Key_Right+CTRL), TQ_SLOT(activate()));
+ menuRotate->insertSeparator();
+ menuRotate->insertItem(TQPixmap(locate("data", "images/menu/18016.png")), i18n("Rotate 180'") + "\tCtrl+Up", SQ_ADD_KACTION(TQt::Key_Up+CTRL), TQ_SLOT(activate()));
+ menuRotate->insertSeparator();
+ menuRotate->insertItem(i18n("Rotate 1' left") + "\tAlt+Left", SQ_ADD_KACTION(TQt::Key_Left+ALT), TQ_SLOT(activate()));
+ menuRotate->insertItem(i18n("Rotate 1' right") + "\tAlt+Right", SQ_ADD_KACTION(TQt::Key_Right+ALT), TQ_SLOT(activate()));
+
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom+16.png")), i18n("Zoom +") + "\t+", SQ_ADD_KACTION(TQt::Key_Plus), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom-16.png")), i18n("Zoom -") + "\t-", SQ_ADD_KACTION(TQt::Key_Minus), TQ_SLOT(activate()));
+ menuZoom->insertItem(i18n("Zoom 2x") + "\tCtrl++", SQ_ADD_KACTION(TQt::Key_Plus+CTRL), TQ_SLOT(activate()));
+ menuZoom->insertItem(i18n("Zoom 1/2x") + "\tCtrl+-", SQ_ADD_KACTION(TQt::Key_Minus+CTRL), TQ_SLOT(activate()));
+ menuZoom->insertSeparator();
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom10016.png")), TQString::fromLatin1("100%") + "\t1", SQ_ADD_KACTION(TQt::Key_1), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom20016.png")), TQString::fromLatin1("200%") + "\t2", SQ_ADD_KACTION(TQt::Key_2), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom30016.png")), TQString::fromLatin1("300%") + "\t3", SQ_ADD_KACTION(TQt::Key_3), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom50016.png")), TQString::fromLatin1("500%") + "\t5", SQ_ADD_KACTION(TQt::Key_5), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom70016.png")), TQString::fromLatin1("700%") + "\t7", SQ_ADD_KACTION(TQt::Key_7), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom90016.png")), TQString::fromLatin1("900%") + "\t9", SQ_ADD_KACTION(TQt::Key_9), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom100016.png")), TQString::fromLatin1("1000%") + "\t0", SQ_ADD_KACTION(TQt::Key_0), TQ_SLOT(activate()));
+
+ menuMove->insertItem(TQPixmap(locate("data", "images/menu/moveLeft16.png")), i18n("Move left") + "\tRight", SQ_ADD_KACTION(TQt::Key_Right), TQ_SLOT(activate()));
+ menuMove->insertItem(TQPixmap(locate("data", "images/menu/moveRight16.png")), i18n("Move right") + "\tLeft", SQ_ADD_KACTION(TQt::Key_Left), TQ_SLOT(activate()));
+ menuMove->insertItem(TQPixmap(locate("data", "images/menu/moveUp16.png")), i18n("Move up") + "\tDown", SQ_ADD_KACTION(TQt::Key_Down), TQ_SLOT(activate()));
+ menuMove->insertItem(TQPixmap(locate("data", "images/menu/moveDown16.png")), i18n("Move down") + "\tUp", SQ_ADD_KACTION(TQt::Key_Up), TQ_SLOT(activate()));
+
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/animate16.png")), i18n("Start/stop animation") + "\tA", SQ_ADD_KACTION(TQt::Key_A), TQ_SLOT(activate()));
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/background16.png")), i18n("Hide/show background") + "\tB", SQ_ADD_KACTION(TQt::Key_B), TQ_SLOT(activate()));
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/tickmarks16.png")), i18n("Hide/show tickmarks") + "\tK", SQ_ADD_KACTION(TQt::Key_K), TQ_SLOT(activate()));
+ menuImage->insertSeparator();
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/flipV16.png")), i18n("Flip vertically") + "\tV", SQ_ADD_KACTION(TQt::Key_V), TQ_SLOT(activate()));
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/flipH16.png")), i18n("Flip horizontally") + "\tH", SQ_ADD_KACTION(TQt::Key_H), TQ_SLOT(activate()));
+ menuImage->insertSeparator();
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/page116.png")), i18n("First page") + "\tF1", SQ_ADD_KACTION(TQt::Key_F1), TQ_SLOT(activate()));
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/page216.png")), i18n("Previous page") + "\tF2", SQ_ADD_KACTION(TQt::Key_F2), TQ_SLOT(activate()));
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/page316.png")), i18n("Next page") + "\tF3", SQ_ADD_KACTION(TQt::Key_F3), TQ_SLOT(activate()));
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/page416.png")), i18n("Last page") + "\tF4", SQ_ADD_KACTION(TQt::Key_F4), TQ_SLOT(activate()));
+ menuImage->insertSeparator();
+ menuImage->insertItem(i18n("Copy file url") + "\tF9", SQ_ADD_KACTION(TQt::Key_F9), TQ_SLOT(activate()));
+ menuImage->insertItem(i18n("To clipboard") + "\tQ", SQ_ADD_KACTION(TQt::Key_Q), TQ_SLOT(activate()));
+ menuImage->insertItem(i18n("Print") + "\tCtrl+P", SQ_ADD_KACTION(TQt::Key_P+CTRL), TQ_SLOT(activate()));
+ menuImage->insertSeparator();
+ id_settings = menuImage->insertItem(SQ_IconLoader::instance()->loadIcon("configure", TDEIcon::Desktop, TDEIcon::SizeSmall), i18n("Codec settings") + "\tC", SQ_ADD_KACTION(TQt::Key_C), TQ_SLOT(activate()));
+ menuImage->setItemEnabled(id_settings, false);
+ menuImage->insertSeparator();
+ menuImage->insertItem(i18n("Color balance...") + "\tD", SQ_ADD_KACTION(TQt::Key_D), TQ_SLOT(activate()));
+ menuImage->insertItem(i18n("Apply filter...") + "\tU", SQ_ADD_KACTION(TQt::Key_U), TQ_SLOT(activate()));
+
+ menuImage->insertItem(i18n("Crop") + "\tY", SQ_ADD_KACTION(TQt::Key_Y), TQ_SLOT(activate()));
+
+#ifndef KSQUIRREL_PART
+ menuWindow->insertItem(TQPixmap(locate("data", "images/menu/fullscreen16.png")), i18n("Fullscreen") + "\tF", SQ_ADD_KACTION(TQt::Key_F), TQ_SLOT(activate()));
+ menuWindow->insertSeparator();
+ menuWindow->insertItem(i18n("Previous tab") + "\tShift+Left", SQ_ADD_KACTION(TQt::Key_Left+SHIFT), TQ_SLOT(activate()));
+ menuWindow->insertItem(i18n("Next tab") + "\tShift+Right", SQ_ADD_KACTION(TQt::Key_Right+SHIFT), TQ_SLOT(activate()));
+ menuWindow->insertSeparator();
+ menuWindow->insertItem(i18n("Close tab") + "\tW", SQ_ADD_KACTION(TQt::Key_W), TQ_SLOT(activate()));
+
+ menuWindow->insertItem(i18n("Close all tabs") + "\tCtrl+W", SQ_ADD_KACTION(TQt::Key_W+CTRL), TQ_SLOT(activate()));
+#endif
+
+ menu->insertSeparator();
+ menu->insertItem(TQPixmap(locate("data", "images/menu/reset16.png")), i18n("Reset") + "\tR", SQ_ADD_KACTION(TQt::Key_R), TQ_SLOT(activate()));
+ id_prop = menu->insertItem(TQPixmap(locate("data", "images/menu/prop16.png")), i18n("Properties") + "\tP", SQ_ADD_KACTION(TQt::Key_P), TQ_SLOT(activate()));
+ menu->insertSeparator();
+ menu->insertItem(i18n("Hotkeys") + "\t/", SQ_ADD_KACTION(TQt::Key_Slash), TQ_SLOT(activate()));
+
+#ifndef KSQUIRREL_PART
+ menu->insertSeparator();
+ menu->insertItem(TQPixmap(locate("data", "images/menu/close16.png")), i18n("Close") + "\tX", SQ_ADD_KACTION(TQt::Key_X), TQ_SLOT(activate()));
+#endif
+
+ SQ_ADD_KACTION(TQt::Key_Down+CTRL);
+ SQ_ADD_KACTION(TQt::Key_Equal);
+ SQ_ADD_KACTION(TQt::Key_Equal+CTRL);
+ SQ_ADD_KACTION(TQt::Key_N);
+ SQ_ADD_KACTION(TQt::Key_Space);
+ SQ_ADD_KACTION(TQt::Key_BackSpace);
+ SQ_ADD_KACTION(TQt::Key_Escape);
+ SQ_ADD_KACTION(TQt::Key_Return);
+ SQ_ADD_KACTION(TQt::Key_Enter);
+ SQ_ADD_KACTION(TQt::Key_Z);
+ SQ_ADD_KACTION(TQt::Key_I);
+ SQ_ADD_KACTION(TQt::Key_E);
+
+#ifndef KSQUIRREL_PART
+ SQ_ADD_KACTION(TQt::Key_R+CTRL);
+ SQ_ADD_KACTION(TQt::Key_E+CTRL);
+ SQ_ADD_KACTION(TQt::Key_C+CTRL);
+#endif
+
+ SQ_ADD_KACTION(TQt::Key_Menu);
+ SQ_ADD_KACTION(TQt::Key_M);
+ SQ_ADD_KACTION(TQt::Key_4);
+ SQ_ADD_KACTION(TQt::Key_6);
+ SQ_ADD_KACTION(TQt::Key_8);
+ SQ_ADD_KACTION(TQt::Key_Comma);
+ SQ_ADD_KACTION(TQt::Key_Period);
+ SQ_ADD_KACTION(TQt::Key_Asterisk);
+ SQ_ADD_KACTION(TQt::Key_L);
+}
+
+
+void SQ_GLWidget::slotAccelActivated()
+{
+ TDEAction *accel = static_cast<TDEAction *>(const_cast<TQObject *>(sender()));
+
+ TDEShortcut ks = accel->shortcut();
+
+ if(!ks.compare(TQt::Key_Left)) matrix_move(movefactor, 0);
+ else if(!ks.compare(TQt::Key_Right)) matrix_move(-movefactor, 0);
+ else if(!ks.compare(TQt::Key_Up)) matrix_move(0, -movefactor);
+ else if(!ks.compare(TQt::Key_Down)) matrix_move(0, movefactor);
+ else if(!ks.compare(TQt::Key_Equal) ||
+ !ks.compare(TQt::Key_Plus)) slotZoomPlus();
+ else if(!ks.compare(TQt::Key_Minus)) slotZoomMinus();
+ else if(!ks.compare(TQt::Key_Equal+CTRL) ||
+ !ks.compare(TQt::Key_Plus+CTRL)) matrix_zoom(2.0f);
+ else if(!ks.compare(TQt::Key_Minus+CTRL)) matrix_zoom(0.5f);
+ else if(!ks.compare(TQt::Key_Q)) toClipboard();
+ else if(!ks.compare(TQt::Key_V)) slotFlipV();
+ else if(!ks.compare(TQt::Key_H)) slotFlipH();
+ else if(!ks.compare(TQt::Key_Left+CTRL)) slotRotateLeft();
+ else if(!ks.compare(TQt::Key_Right+CTRL)) slotRotateRight();
+ else if(!ks.compare(TQt::Key_R)) slotMatrixReset();
+ else if(!ks.compare(TQt::Key_Up+CTRL)) matrix_rotate(180.0f);
+ else if(!ks.compare(TQt::Key_Down+CTRL)) matrix_rotate(-180.0f);
+ else if(!ks.compare(TQt::Key_Left+ALT)) matrix_rotate(-1.0f);
+ else if(!ks.compare(TQt::Key_Right+ALT)) matrix_rotate(1.0f);
+
+#ifndef KSQUIRREL_PART
+ else if(!ks.compare(TQt::Key_Left+SHIFT)) SQ_GLView::window()->leftTab();
+ else if(!ks.compare(TQt::Key_Right+SHIFT)) SQ_GLView::window()->rightTab();
+ else if(!ks.compare(TQt::Key_W)) slotCloseRequest(SQ_GLView::window()->tabbar()->indexOf(SQ_GLView::window()->tabbar()->currentTab()));
+ else if(!ks.compare(TQt::Key_W+CTRL)) closeAllTabsFull();
+#else
+ else if(!ks.compare(TQt::Key_W)) closeAllTabsFull();
+#endif
+
+ else if(!ks.compare(TQt::Key_N)) updateFilter(!linear);
+ else if(!ks.compare(TQt::Key_P)) slotProperties();
+ else if(!ks.compare(TQt::Key_C)) slotShowCodecSettings();
+
+#ifndef KSQUIRREL_PART
+ else if(!ks.compare(TQt::Key_PageDown) ||
+ !ks.compare(TQt::Key_Space)) slotNext();
+ else if(!ks.compare(TQt::Key_PageUp) ||
+ !ks.compare(TQt::Key_BackSpace)) slotPrev();
+ else if(!ks.compare(TQt::Key_X) ||
+ !ks.compare(TQt::Key_Escape) ||
+ !ks.compare(TQt::Key_Return) ||
+ !ks.compare(TQt::Key_Enter)) KSquirrel::app()->closeGLWidget();
+ else if(!ks.compare(TQt::Key_Home)) slotFirst();
+ else if(!ks.compare(TQt::Key_End)) slotLast();
+ else if(!ks.compare(TQt::Key_F)) toggleFullScreen();
+#endif
+
+ else if(!ks.compare(TQt::Key_Z)) slotZoomMenu();
+ else if(!ks.compare(TQt::Key_S)) saveAs();
+ else if(!ks.compare(TQt::Key_A)) slotToggleAnimate();
+ else if(!ks.compare(TQt::Key_I)) slotShowImages();
+ else if(!ks.compare(TQt::Key_F1)) jumpToImage(false);
+ else if(!ks.compare(TQt::Key_F2)) prevImage();
+ else if(!ks.compare(TQt::Key_F3)) nextImage();
+ else if(!ks.compare(TQt::Key_F4)) jumpToImage(true);
+ else if(!ks.compare(TQt::Key_F5) || !ks.compare(TQt::Key_F6))
+ {
+ // select a directory
+ KURL url = KFileDialog::getExistingURL(lastCopy.prettyURL(), this);
+
+ if(url.isEmpty())
+ return;
+
+ lastCopy = url;
+ TDEIO::Job *job;
+
+ if(!ks.compare(TQt::Key_F5))
+ job = TDEIO::copy(tab->m_original, url);
+ else
+ job = TDEIO::move(tab->m_original, url);
+
+ job->setWindow(this);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotCopyJobResult(TDEIO::Job *)));
+ }
+ else if(!ks.compare(TQt::Key_F7) || !ks.compare(TQt::Key_F8))
+ {
+ TDEIO::Job *job;
+
+ if(!ks.compare(TQt::Key_F6))
+ job = TDEIO::copy(tab->m_original, lastCopy);
+ else
+ job = TDEIO::move(tab->m_original, lastCopy);
+
+ job->setWindow(this);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotCopyJobResult(TDEIO::Job *)));
+ }
+ else if(!ks.compare(TQt::Key_F9)) copyURL();
+ else if(!ks.compare(TQt::Key_Slash)) slotShowHelp();
+ else if(!ks.compare(TQt::Key_B)) toggleDrawingBackground();
+ else if(!ks.compare(TQt::Key_K)) toogleTickmarks();
+ else if(!ks.compare(TQt::Key_E)) showExternalTools();
+ else if(!ks.compare(TQt::Key_Delete)) deleteWrapper();
+ else if(!ks.compare(TQt::Key_D)) bcg();
+ else if(!ks.compare(TQt::Key_U)) filter();
+ else if(!ks.compare(TQt::Key_Y)) crop();
+
+#ifndef KSQUIRREL_PART
+ else if(!ks.compare(TQt::Key_R+CTRL)) slotSelectionRect();
+ else if(!ks.compare(TQt::Key_E+CTRL)) slotSelectionEllipse();
+ else if(!ks.compare(TQt::Key_C+CTRL)) slotSelectionClear();
+#endif
+
+ else if(!ks.compare(TQt::Key_P+CTRL)) slotPrint();
+ else if(!ks.compare(TQt::Key_Menu) ||
+ !ks.compare(TQt::Key_M)) menu->exec(TQCursor::pos());
+ else if(!ks.compare(TQt::Key_Comma)) slotZoomW();
+ else if(!ks.compare(TQt::Key_Period)) slotZoomH();
+ else if(!ks.compare(TQt::Key_Asterisk)) slotZoomWH();
+ else if(!ks.compare(TQt::Key_L))
+ {
+ bool b = pAIfLess->isChecked();
+ pAIfLess->setChecked(!b);
+ slotZoomIfLess();
+ }
+ else
+ {
+ int val = -1;
+
+ if(!ks.compare(TQt::Key_1)) val = 1;
+ else if(!ks.compare(TQt::Key_2)) val = 2;
+ else if(!ks.compare(TQt::Key_3)) val = 3;
+ else if(!ks.compare(TQt::Key_4)) val = 4;
+ else if(!ks.compare(TQt::Key_5)) val = 5;
+ else if(!ks.compare(TQt::Key_6)) val = 6;
+ else if(!ks.compare(TQt::Key_7)) val = 7;
+ else if(!ks.compare(TQt::Key_8)) val = 8;
+ else if(!ks.compare(TQt::Key_9)) val = 9;
+ else if(!ks.compare(TQt::Key_0)) val = 10;
+
+ if(val != -1)
+ {
+ if(tab->broken || tab->finfo.image.empty())
+ return;
+
+ zoom(val);
+ }
+ }
+}
+
+void SQ_GLWidget::zoom(GLfloat val)
+{
+ oldZoom = getZoom();
+ matrix_reset(false);
+ matrix_zoom(val);
+}
+
+void SQ_GLWidget::slotCopyJobResult(TDEIO::Job *job)
+{
+ if(job->error())
+ job->showErrorDialog(this);
+}
+
+void SQ_GLWidget::exifRotate(bool U)
+{
+#ifdef SQ_HAVE_KEXIF
+ switch(tab->orient)
+ {
+ // flipping
+ case KExifData::HFLIP: tab->isflippedH = !tab->isflippedH; flip(0, U); break;
+ case KExifData::VFLIP: tab->isflippedV = !tab->isflippedV; flip(4, U); break;
+
+ // rotating
+ case KExifData::ROT_90: matrix_rotate(90, U); break;
+ case KExifData::ROT_180: matrix_rotate(180, U); break;
+ case KExifData::ROT_270: matrix_rotate(270, U); break;
+
+ // flipping & rotating
+ case KExifData::ROT_90_HFLIP: tab->isflippedH = !tab->isflippedH; flip(0, false); matrix_rotate(90, U); break;
+ case KExifData::ROT_90_VFLIP: tab->isflippedV = !tab->isflippedV; flip(4, false); matrix_rotate(90, U); break;
+
+ // normal rotation or unspecified
+ default: if(U) updateGL();
+ }
+#else
+ if(U)
+ updateGL();
+#endif
+}
+
+void SQ_GLWidget::enableActions(bool U)
+{
+#ifndef KSQUIRREL_PART
+ pASelectionRect->setEnabled(U);
+ pASelectionEllipse->setEnabled(U);
+ pASelectionClear->setEnabled(U);
+ pAToolProp->setEnabled(U);
+ pAToolPrint->setEnabled(U);
+#endif
+
+ menuFile->setItemEnabled(id_f5, U);
+ menuFile->setItemEnabled(id_f6, U);
+ menuFile->setItemEnabled(id_f7, U);
+ menuFile->setItemEnabled(id_f8, U);
+ menuFile->setItemEnabled(id_del, U);
+ menuFile->setItemEnabled(id_saveas, U);
+
+ menu->setItemEnabled(id_prop, U);
+
+ menuImage->setEnabled(U);
+}
+
+void SQ_GLWidget::crop()
+{
+ if(tab->broken
+ || tab->finfo.image.empty()
+ || !gls->valid()
+ || !calcSelection()
+ || (tab->sw == tab->parts[tab->current].w && tab->sh == tab->parts[tab->current].h))
+ return;
+
+ const int RW = tab->parts[tab->current].realw;
+ RGBA *img = tab->parts[tab->current].buffer->data() + tab->sy * RW + tab->sx;
+
+ Parts pp;
+ memoryPart *pt;
+
+ SQ_GLWidget::findCloserTiles(tab->sw, tab->sh, pp.tilesx, pp.tilesy);
+ TQPair<int, int> pair = SQ_GLWidget::calcRealDimensions(pp);
+ pp.realw = pair.first;
+ pp.realh = pair.second;
+ pp.w = tab->sw;
+ pp.h = tab->sh;
+
+ if(!pp.makeParts())
+ {
+ KMessageBox::error(this,
+ i18n("Memory allocation failed for %1 of memory")
+ .arg(TDEIO::convertSize(pp.realw * pp.realh * sizeof(RGBA))));
+ return;
+ }
+
+ pt = new memoryPart(pp.realw * pp.realh);
+ pt->create();
+
+ if(!pt->valid())
+ {
+ pp.removeParts();
+ return;
+ }
+
+ memset(pt->data(), 0, pp.realw * pp.realh * sizeof(RGBA));
+
+ for(int i = 0;i < tab->sh;i++)
+ memcpy(pt->data()+i*pp.realw, img + i*RW, tab->sw * sizeof(RGBA));
+
+ pp.computeCoords();
+ pp.buffer = pt;
+
+ tab->parts[tab->current].removeParts();
+ tab->parts[tab->current].deleteBuffer();
+ tab->finfo.image[tab->current].w = tab->sw;
+ tab->finfo.image[tab->current].h = tab->sh;
+
+ int tlsy = pp.tilesy.size();
+ for(int i = 0;i < tlsy;i++)
+ showFrames(i, &pp, false);
+
+ tab->parts[tab->current] = pp;
+
+ slotSelectionClear();
+ updateCurrentFileInfo();
+ tab->isflippedH = tab->isflippedV = false;
+ slotZoomIfLess();
+ matrixChanged();
+}
+
+void SQ_GLWidget::slotChangeTab(int id)
+{
+#ifndef KSQUIRREL_PART
+ id = SQ_GLView::window()->tabbar()->indexOf(id);
+
+ Tab *newtab = (id == -1) ? &taborig : &tabs[id];
+
+ if(tab == newtab)
+ return;
+
+ if(tab)
+ {
+ tab->removeParts();
+ gls->setVisible(false);
+ }
+
+ tab = newtab;
+
+ images->clear();
+ old_id = -1;
+ stopAnimation();
+
+ enableSettingsButton(id != -1 && tab->lib && !tab->lib->config.isEmpty());
+ enableActions(!tab->broken && id != -1);
+
+ if(id == -1)
+ {
+ SQ_GLView::window()->resetStatusBar();
+ KSquirrel::app()->setCaption(TQString());
+ decoded = false;
+ changeSlider(1.0);
+ }
+ else
+ {
+ changeSlider();
+ KSquirrel::app()->setCaption(originalURL());
+ enableActions(!tab->broken);
+
+ if(!tab->broken)
+ {
+ SQ_GLView::window()->sbarWidget("SBDecodedI")->setPixmap(tab->lib->mime);
+
+ // fill menu
+ std::vector<fmt_image>::iterator itEnd = tab->finfo.image.end();
+ std::vector<fmt_image>::iterator it = tab->finfo.image.begin();
+ int mid, i = 0, first_id = 0;
+
+ for(;it != itEnd;++it, ++i)
+ {
+ mid = images->insertItem(TQString::fromLatin1("#%1 [%2x%3@%4]").arg(i+1).arg((*it).w).arg((*it).h).arg((*it).bpp));
+ images->setItemParameter(mid, i);
+
+ if(i == tab->current)
+ old_id = first_id = mid;
+ }
+
+ images->setItemChecked(first_id, true);
+ updateCurrentFileInfo();
+ frameChanged();
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBFile")->setText(tab->m_original.fileName(false));
+ SQ_GLView::window()->sbarWidget("SBLoaded")->setText(TDEGlobal::locale()->formatLong(tab->elapsed) + i18n(" ms."));
+#else
+ t_glv.sbarWidget("SBFile")->setText(tab->m_original.fileName(false));
+ t_glv.sbarWidget("SBLoaded")->setText(TDEGlobal::locale()->formatLong(tab->elapsed) + i18n(" ms."));
+#endif
+ }
+ else
+ SQ_GLView::window()->resetStatusBar();
+
+ std::vector<Parts>::iterator itp = tab->parts.begin();
+ std::vector<Parts>::iterator itpEnd = tab->parts.end();
+ int tlsy;
+
+ tab->remakeParts();
+
+ if(tab->glselection != -1)
+ {
+ if(!gls->valid())
+ gls->begin(static_cast<SQ_GLSelectionPainter::Type>(tab->glselection), 0, 0, false);
+
+ gls->setGeometry(tab->srect);
+ }
+ else
+ gls->end();
+
+ gls->setVisible(tab->glselection != -1);
+
+ for(;itp != itpEnd;++itp)
+ {
+ tlsy = (*itp).tilesy.size();
+
+ for(int i = 0;i < tlsy;i++)
+ showFrames(i, &(*itp), false);
+ }
+
+ if(!manualBlocked())
+ startAnimation();
+ }
+
+ matrixChanged();
+ updateGL();
+#endif
+}
+
+void SQ_GLWidget::slotCloseRequest(int index)
+{
+#ifndef KSQUIRREL_PART
+ if(index < 0)
+ return;
+
+ SQ_GLView::window()->tabbar()->blockSignals(true);
+
+ // prevent matrix from changing. When tab count == 1,
+ // SQ_GLView will hide tabbar and SQ_GLWIdget will be resized.
+ // We don't want it.
+ if(SQ_GLView::window()->tabbar()->count() == 2)
+ hackResizeGL = true;
+
+ SQ_GLView::window()->removePage(index);
+ emit tabCountChanged();
+ SQ_GLView::window()->tabbar()->blockSignals(false);
+
+ // workaround bug in KTabBar
+ TQMouseEvent ev(TQEvent::MouseMove,
+ TQCursor::pos(),
+ SQ_GLView::window()->tabbar()->mapFromGlobal(TQCursor::pos()),
+ TQt::NoButton,
+ TQt::NoButton);
+
+ TDEApplication::sendEvent(SQ_GLView::window()->tabbar(), &ev);
+
+ std::vector<Tab>::iterator itEnd = tabs.end();
+ std::vector<Tab>::iterator it = tabs.begin();
+ int i = 0;
+
+ for(;(it != itEnd && i != index);++it, ++i)
+ ;
+
+ (*it).clearParts();
+ tabs.erase(it);
+ tab = 0;
+
+ gls->setVisible(false);
+
+ slotChangeTab(SQ_GLView::window()->tabbar()->currentTab());
+#endif
+}
+
+void SQ_GLWidget::initBrokenImage()
+{
+ memoryPart *pt;
+ TQImage broken = TQPixmap(file_broken_xpm).convertToImage().swapRGB();
+ broken.setAlphaBuffer(true);
+
+ parts_broken = new Parts;
+
+ // setup parts_broken. It will have only one 64x64 tile
+ parts_broken->tilesx.push_back(broken.width());
+ parts_broken->tilesy.push_back(broken.height());
+ parts_broken->realw = broken.width();
+ parts_broken->realh = broken.height();
+ parts_broken->w = broken.width();
+ parts_broken->h = broken.height();
+ parts_broken->makeParts();
+ parts_broken->computeCoords();
+
+ pt = new memoryPart(broken.width() * broken.width());
+ pt->create();
+
+ memcpy(pt->data(), broken.bits(), broken.numBytes());
+
+ parts_broken->buffer = pt;
+
+ showFrames(0, parts_broken, false);
+
+ image_broken.w = parts_broken->w;
+ image_broken.h = parts_broken->h;
+ image_broken.bpp = broken.depth();
+ image_broken.compression = "-";
+ image_broken.colorspace = "RGBA";
+ image_broken.hasalpha = false;
+
+ // we don't need memory buffer any more...
+ parts_broken->deleteBuffer();
+}
+
+// Accept drop events.
+void SQ_GLWidget::dropEvent(TQDropEvent *e)
+{
+ TQStringList files;
+
+ if(TQUriDrag::decodeLocalFiles(e, files))
+ {
+ // go through array and find first supported image format
+ for(TQStringList::iterator it = files.begin();it != files.end();++it)
+ {
+ if(SQ_LibraryHandler::instance()->libraryForFile(*it))
+ {
+ KURL u = KURL::fromPathOrURL(*it);
+ m_expected = u;
+ m_original = u;
+ startDecoding(u);
+ break;
+ }
+ }
+ }
+}
+
+// Accept drag events.
+void SQ_GLWidget::dragEnterEvent(TQDragEnterEvent *e)
+{
+ e->accept(TQUriDrag::canDecode(e));
+}
+
+/*
+ * Set clear color for context.
+ */
+void SQ_GLWidget::setClearColor()
+{
+ TQColor color;
+ TQString path;
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ switch(SQ_Config::instance()->readNumEntry("GL view background type", 1))
+ {
+ // system color
+ case 0:
+ color = colorGroup().color(TQColorGroup::Base);
+ break;
+
+ // custom color
+ case 1:
+ color.setNamedColor(SQ_Config::instance()->readEntry("GL view background", "#4e4e4e"));
+ break;
+
+ // repeated texture
+ case 2:
+ path = SQ_Config::instance()->readEntry("GL view custom texture", "");
+ BGpixmap.load(path);
+
+ if(BGpixmap.isNull())
+ {
+ SQ_Config::instance()->writeEntry("GL view background type", 0);
+ setClearColor();
+ return;
+ }
+
+ BGpixmap.convertDepth(32);
+ BGpixmap = BGpixmap.swapRGB();
+
+ changed = true;
+ break;
+
+ default: ;
+ }
+
+ // update clear color
+ qglClearColor(color);
+
+ if(decoded)
+ updateGL();
+}
+
+void SQ_GLWidget::removeCurrentParts()
+{
+ // if tab->broken, 'tab->parts' has no members
+ if(decoded && !tab->broken)
+ {
+ std::vector<Parts>::iterator itEnd = tab->parts.end();
+
+ for(std::vector<Parts>::iterator it = tab->parts.begin();it != itEnd;++it)
+ {
+ // delete textures and memory buffers
+ (*it).removeParts();
+ (*it).deleteBuffer();
+ }
+
+ tab->parts.clear();
+ }
+}
+
+void SQ_GLWidget::removeCurrentTabs()
+{
+ std::vector<Tab>::iterator itEnd = tabs.end();
+
+ for(std::vector<Tab>::iterator it = tabs.begin();it != itEnd;++it)
+ (*it).clearParts();
+
+ tabs.clear();
+ tab = &taborig;
+}
+
+void SQ_GLWidget::removeNonCurrentTabs(int index)
+{
+ std::vector<Tab>::iterator itEnd = tabs.end();
+ Tab tm;
+ int i = 0;
+
+ for(std::vector<Tab>::iterator it = tabs.begin();it != itEnd;++it, ++i)
+ {
+ if(i == index)
+ {
+ tm = *it;
+ continue;
+ }
+
+ (*it).clearParts();
+ }
+
+ tabs.clear();
+ tabs.push_back(tm);
+ tab = &tabs[0];
+}
+
+void SQ_GLWidget::startDecoding(const KURL &url)
+{
+ startDecoding(url.path());
+}
+
+// Show/hide background for transparent image.
+void SQ_GLWidget::toggleDrawingBackground()
+{
+ SQ_Config::instance()->setGroup("GL view");
+
+ bool b = SQ_Config::instance()->readBoolEntry("alpha_bkgr", true);
+
+ b = !b;
+
+ SQ_Config::instance()->writeEntry("alpha_bkgr", b);
+
+ updateGL();
+}
+
+void SQ_GLWidget::createMarks()
+{
+ mm[0] = TQImage(locate("data", "images/marks/mark_1.png"));
+ mm[1] = TQImage(locate("data", "images/marks/mark_2.png"));
+ mm[2] = TQImage(locate("data", "images/marks/mark_3.png"));
+ mm[3] = TQImage(locate("data", "images/marks/mark_4.png"));
+
+ marks = (mm[0].isNull() || mm[1].isNull() || mm[2].isNull() || mm[3].isNull()) ? false : true;
+
+ if(!marks)
+ return;
+
+ for(int i = 0;i < 4;i++)
+ {
+ mm[i] = mm[i].convertDepth(32);
+ mm[i].setAlphaBuffer(true);
+ }
+}
+
+/*
+ * Show current image's width, height and bpp in statusbar.
+ */
+void SQ_GLWidget::updateCurrentFileInfo()
+{
+ TQString status = TQString::fromLatin1("%1x%2@%3")
+ .arg(tab->finfo.image[tab->current].w)
+ .arg(tab->finfo.image[tab->current].h)
+ .arg(tab->finfo.image[tab->current].bpp);
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBDecoded")->setText(status);
+#else
+ t_glv.sbarWidget("SBDecoded")->setText(status);
+#endif
+}
+
+// Show/hide tickmarks around the image.
+void SQ_GLWidget::toogleTickmarks()
+{
+ SQ_Config::instance()->setGroup("GL view");
+
+ bool b = SQ_Config::instance()->readBoolEntry("marks", true);
+
+ b = !b;
+
+ SQ_Config::instance()->writeEntry("marks", b);
+
+ updateGL();
+}
+
+void SQ_GLWidget::changeSlider(GLfloat z1)
+{
+#ifndef KSQUIRREL_PART
+ GLfloat z = z1 < 0 ? getZoom() : z1;
+
+ int i_zoom = (int)(z * 100);
+
+ slider_zoom->blockSignals(true);
+ slider_zoom->setValue((i_zoom <= 100) ? i_zoom/5 : (19+i_zoom/50));
+ slider_zoom->blockSignals(false);
+#endif
+}
+
+void SQ_GLWidget::calcFrameLabelWidth()
+{
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBFrame")->setFixedWidth(
+ SQ_GLView::window()->sbarWidget("SBFrame")->fontMetrics()
+ .boundingRect(TQString::fromLatin1("0%1/0%2").arg(tab->total).arg(tab->total)).width());
+#endif
+}
+
+/*
+ * Show current page number in multipaged images.
+ *
+ * For example: "3/11" means that current page is the third in current image,
+ * which has 11 pages.
+ */
+void SQ_GLWidget::frameChanged()
+{
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBFrame")->setText(TQString::fromLatin1("%1/%2").arg(tab->current+1).arg(tab->total));
+#else
+ t_glv.sbarWidget("SBFrame")->setText(TQString::fromLatin1("%1/%2").arg(tab->current+1).arg(tab->total));
+#endif
+}
+
+void SQ_GLWidget::closeAllTabs()
+{
+ removeCurrentTabs();
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->removeTabs();
+#endif
+}
+
+void SQ_GLWidget::closeAllTabsFull()
+{
+ stopAnimation();
+
+ closeAllTabs();
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->resetStatusBar();
+ SQ_GLView::window()->tabbar()->hide();
+
+ KSquirrel::app()->setCaption(TQString());
+#endif
+
+ decoded = false;
+ m_original = KURL();
+ m_expected = KURL();
+
+ images->clear();
+ old_id = -1;
+
+ enableSettingsButton(false);
+ enableActions(false);
+ changeSlider(1.0);
+
+ updateGL();
+}
+
+void SQ_GLWidget::slotPrint()
+{
+ if(!decoded || tab->broken)
+ return;
+
+ TQImage im((uchar *)tab->parts[tab->current].buffer->data(), tab->parts[tab->current].realw, tab->parts[tab->current].realh, 32, 0, 0, TQImage::LittleEndian);
+ TQImage img;
+
+ if(gls->valid() && calcSelection())
+ img = TQImage(im.copy(tab->sx, tab->sy, tab->sw, tab->sh)).swapRGB();
+ else
+ {
+ if(tab->parts[tab->current].realw == tab->parts[tab->current].w && tab->parts[tab->current].realh == tab->parts[tab->current].h)
+ img = im.swapRGB();
+ else
+ img = TQImage(im.copy(0, 0, tab->parts[tab->current].w, tab->parts[tab->current].h)).swapRGB();
+ }
+
+ img.setAlphaBuffer(true);
+
+ KPrinter printer;
+
+ printer.setCreator("KSquirrel");
+
+ if(printer.setup(this))
+ {
+ TQPainter p(&printer);
+
+ TQPaintDeviceMetrics mt(&printer);
+
+ TQSize sz(img.width(), img.height());
+
+ if(img.width() > mt.width() || img.height() > mt.height())
+ sz.scale(mt.width(), mt.height(), TQSize::ScaleMin);
+
+ int cp = printer.numCopies();
+
+ for(int i = 0;i < cp;i++)
+ {
+ p.drawImage(TQRect((mt.width()-sz.width())/2, (mt.height()-sz.height())/2, sz.width(), sz.height()), img);
+
+ if(i < cp-1)
+ printer.newPage();
+ }
+ }
+}
+
+void SQ_GLWidget::copyURL()
+{
+ if(!decoded || tab->broken)
+ return;
+
+ TQApplication::clipboard()->setText(tab->m_original.prettyURL());
+}
diff --git a/src/ksquirrelpart/sq_helpwidget.ui b/src/ksquirrelpart/sq_helpwidget.ui
new file mode 100644
index 0000000..cb2a4bc
--- /dev/null
+++ b/src/ksquirrelpart/sq_helpwidget.ui
@@ -0,0 +1,334 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_HelpWidget</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_HelpWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>512</width>
+ <height>430</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Hotkeys</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>false</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQWidgetStack" row="1" column="0">
+ <property name="name">
+ <cstring>widgetStack1</cstring>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p align=center&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Esc,X,Return&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;close&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Middle click, F&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;fullscreen&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Z&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;show 'Zoom' menu&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;/&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;show this help&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Right click, M, ContextMenu&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;show context menu&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;N&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;toggle filter&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Shift + Left button&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;select a region&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Shift + Left&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;previous tab&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Shift + Right&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;next tab&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;W&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;close tab&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p align=center&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Space, Page Down&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;next image&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Backspace, Page Up&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;previous image&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Home&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;first image&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;End&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;last image&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>2</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p align=center&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Left, Right, Up, Down&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;move the image&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Ctrl + Left&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;rotate left&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Ctrl + Right&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;rotate right&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Ctrl + Up/Down&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;rotate for 180 degrees up/down&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Alt + Left/Right&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;rotate for 1 degree left/right&lt;/td&gt;&lt;/tr&gt;&lt;/table&lt;/p&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>3</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel6</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p align=center&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;+/-&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;zoom Nx&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Ctrl + +/-&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;zoom 2x/0.5x&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Scroll&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;load next/prev file OR zoom+/zoom-&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Shift + Scroll&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;zoom+/zoom-&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Ctrl + Scroll&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;zoom+ 2x/zoom- 2x&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;1..9&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;zoom 1..9x&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;0&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;zoom 10x&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;comma&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;fit width&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;period&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;fit height&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;*&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;fit image&lt;/td&gt;&lt;/tr&gt;&lt;/table&lt;/p&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>4</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel5</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p align=center&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;S&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;save as&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;V&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;flip vertically&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;H&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;flip horizontally&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;R&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;reset&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;P&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;image properties&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;C&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;codec settings&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;L&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;ignore zoom if image is smaller than window&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;I&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;menu with images&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;A&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;stop/start animation&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;B&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;toggle drawing background for transparent images&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;K&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;toggle drawing tickmarks&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;E&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;show menu with external tools&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;Y&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;crop&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;F1&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;first image in multi-paged image&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;F2&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;previous&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;F3&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;next&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;F4&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;last&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ <widget class="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>buttonGroup</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <property name="exclusive">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushButton3</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>General</string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="on">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="buttonGroupId">
+ <number>0</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>pushButton3_2</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Filing</string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="buttonGroupId">
+ <number>1</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="2">
+ <property name="name">
+ <cstring>pushButton3_3</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Moving</string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="buttonGroupId">
+ <number>2</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="4">
+ <property name="name">
+ <cstring>pushButton3_5</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Current image</string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="buttonGroupId">
+ <number>4</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="3">
+ <property name="name">
+ <cstring>pushButton3_4</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Zoom</string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="buttonGroupId">
+ <number>3</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>buttonGroup</sender>
+ <signal>clicked(int)</signal>
+ <receiver>widgetStack1</receiver>
+ <slot>raiseWidget(int)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>pushButton3</tabstop>
+ <tabstop>pushButton3_2</tabstop>
+ <tabstop>pushButton3_3</tabstop>
+ <tabstop>pushButton3_5</tabstop>
+ <tabstop>pushButton3_4</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in implementation">tqtooltip.h</include>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="local" impldecl="in implementation">sq_helpwidget.ui.h</include>
+</includes>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function access="private" specifier="non virtual">destroy()</function>
+ <function returnType="bool">event( TQEvent * e )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/ksquirrelpart/sq_helpwidget.ui.h b/src/ksquirrelpart/sq_helpwidget.ui.h
new file mode 100644
index 0000000..c0f2673
--- /dev/null
+++ b/src/ksquirrelpart/sq_helpwidget.ui.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** TQt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+/*
+ * SQ_HelpWidget is a helper widget. It shows hotkeys, which
+ * are accepted by SQ_GLWidget. Called from SQ_GLWidget.
+ */
+
+void SQ_HelpWidget::init()
+{
+ setPalette(TQToolTip::palette());
+ SQ_Config::instance()->setGroup("GL view");
+
+ int pg = SQ_Config::instance()->readNumEntry("help_id", 0);
+
+ buttonGroup->setButton(pg);
+ widgetStack1->raiseWidget(pg);
+}
+
+void SQ_HelpWidget::destroy()
+{
+ SQ_Config::instance()->setGroup("GL view");
+ SQ_Config::instance()->writeEntry("help_id", buttonGroup->selectedId());
+}
+
+bool SQ_HelpWidget::event(TQEvent *e)
+{
+ if(e->type() == TQEvent::WindowDeactivate
+ || e->type() == TQEvent::MouseButtonPress
+ || e->type() == TQEvent::KeyPress)
+ {
+ reject();
+ }
+
+ return TQDialog::event(e);
+}
diff --git a/src/ksquirrelpart/sq_iconloader.cpp b/src/ksquirrelpart/sq_iconloader.cpp
new file mode 100644
index 0000000..c8c9ec8
--- /dev/null
+++ b/src/ksquirrelpart/sq_iconloader.cpp
@@ -0,0 +1,82 @@
+/***************************************************************************
+ sq_iconloader.cpp - description
+ -------------------
+ begin : ??? Aug 20 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tdeglobal.h>
+#include <kiconloader.h>
+
+#include "sq_iconloader.h"
+#include "sq_iconloader_pixmaps.h"
+
+SQ_IconLoader * SQ_IconLoader::m_instance = 0;
+
+SQ_IconLoader::SQ_IconLoader(TQObject *parent) : TQObject(parent)
+{
+ m_instance = this;
+
+ fillPixmaps();
+}
+
+SQ_IconLoader::~SQ_IconLoader()
+{}
+
+TQPixmap SQ_IconLoader::loadIcon(const TQString& name, TDEIcon::Group group, int size) const
+{
+ // try to load from installed icon theme
+ TQPixmap p = TDEGlobal::iconLoader()->loadIcon(name, group, size, TDEIcon::DefaultState, 0, true);
+
+ // requested pixmap not found, let's
+ // try to find it in our pixmaps
+ if(p.isNull())
+ {
+ if(name == "move_task_up")
+ p = pixmap_up;
+ else if(name == "move_task_down")
+ p = pixmap_down;
+ else if(name == "display" && size == 32)
+ p = pixmap_display;
+ else if(name == "folder" && size == 32)
+ p = pixmap_folder;
+ else if(name == "images" && size == 32)
+ p = pixmap_images;
+ else if(name == "binary" && size == 32)
+ p = pixmap_binary;
+ else if(name == "edit" && size == 32)
+ p = pixmap_edit;
+ else
+ p = TDEGlobal::iconLoader()->loadIcon("unknown", group, size);
+ }
+
+ return p;
+}
+
+/*
+ * Internal. Load all pixmaps.
+ */
+void SQ_IconLoader::fillPixmaps()
+{
+ pixmap_up = TQPixmap(xpm_up);
+ pixmap_down = TQPixmap(xpm_down);
+ pixmap_display = TQPixmap(xpm_display);
+ pixmap_folder = TQPixmap(xpm_folder);
+ pixmap_images = TQPixmap(xpm_images);
+ pixmap_binary = TQPixmap(xpm_binary);
+ pixmap_edit = TQPixmap(xpm_edit);
+}
diff --git a/src/ksquirrelpart/sq_iconloader.h b/src/ksquirrelpart/sq_iconloader.h
new file mode 100644
index 0000000..dec6a6e
--- /dev/null
+++ b/src/ksquirrelpart/sq_iconloader.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ sq_iconloader.h - description
+ -------------------
+ begin : ??? Aug 20 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_ICONLOADER_H
+#define SQ_ICONLOADER_H
+
+#include <tqobject.h>
+#include <tqpixmap.h>
+
+#include <kicontheme.h>
+
+/*
+ * SQ_IconLoader represents an icon loader. It tries to load pixmap from
+ * installed icon theme. If icon was not found, it uses internal pixmaps
+ * instead.
+ */
+
+class SQ_IconLoader : public TQObject
+{
+ public:
+ SQ_IconLoader(TQObject *parent = 0);
+ ~SQ_IconLoader();
+
+ TQPixmap loadIcon(const TQString &name, TDEIcon::Group group = TDEIcon::Desktop, int size = 16) const;
+
+ private:
+ static SQ_IconLoader *m_instance;
+
+ /*
+ * Internal. Load all pixmaps.
+ */
+ void fillPixmaps();
+
+ public:
+ static SQ_IconLoader* instance() { return m_instance; }
+
+ private:
+ TQPixmap pixmap_up, pixmap_down,
+ pixmap_display, pixmap_folder,
+ pixmap_images, pixmap_binary,
+ pixmap_edit;
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_iconloader_pixmaps.h b/src/ksquirrelpart/sq_iconloader_pixmaps.h
new file mode 100644
index 0000000..0bc6183
--- /dev/null
+++ b/src/ksquirrelpart/sq_iconloader_pixmaps.h
@@ -0,0 +1,2557 @@
+/***************************************************************************
+ sq_iconloader_pixmaps.h - description
+ -------------------
+ begin : ��� ��� 3 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_ICONLOADER_PIXMAPS
+#define SQ_ICONLOADER_PIXMAPS
+
+static const char * xpm_up[] = {
+"22 22 139 2",
+" c None",
+". c #AE5300",
+"+ c #AD5204",
+"@ c #B35E10",
+"# c #EBD4BF",
+"$ c #C78851",
+"% c #AD5203",
+"& c #F0DDBF",
+"* c #FFED80",
+"= c #FAEDBF",
+"- c #BD7331",
+"; c #FFE330",
+"> c #FFD900",
+", c #FFD710",
+"' c #FAECBF",
+") c #F0D99F",
+"! c #FFE420",
+"~ c #FFDC00",
+"{ c #FFD700",
+"] c #FFD300",
+"^ c #FFD210",
+"/ c #FAEBBF",
+"( c #BD7330",
+"_ c #F0DA9F",
+": c #FFE410",
+"< c #FFDE00",
+"[ c #FFDA00",
+"} c #FFD600",
+"| c #FFD100",
+"1 c #FFCD00",
+"2 c #FFCC10",
+"3 c #FAE9BF",
+"4 c #BD7332",
+"5 c #FAF0BF",
+"6 c #FFE710",
+"7 c #FFE100",
+"8 c #FFDD00",
+"9 c #FFD800",
+"0 c #FFD400",
+"a c #FFD000",
+"b c #FFCB00",
+"c c #FFC700",
+"d c #FFC710",
+"e c #FAE8BF",
+"f c #B25D12",
+"g c #AE5302",
+"h c #FFE910",
+"i c #FFE400",
+"j c #FFDF00",
+"k c #FFDB00",
+"l c #FFD200",
+"m c #FFCE00",
+"n c #FFCA00",
+"o c #FFC500",
+"p c #FFC100",
+"q c #FFC110",
+"r c #F0D29F",
+"s c #AD5202",
+"t c #FAEE8F",
+"u c #FFEC10",
+"v c #FFE600",
+"w c #FFE200",
+"x c #FFD500",
+"y c #FFCC00",
+"z c #FFC800",
+"A c #FFC400",
+"B c #FFBF00",
+"C c #FFBB00",
+"D c #FFBB10",
+"E c #F0D19F",
+"F c #FAEF8F",
+"G c #FFED00",
+"H c #FFE900",
+"I c #FFE500",
+"J c #FFE000",
+"K c #FFCF00",
+"L c #FFC600",
+"M c #FFC200",
+"N c #FFBE00",
+"O c #FFB900",
+"P c #FFB500",
+"Q c #FFB610",
+"R c #F0CF9F",
+"S c #B25C15",
+"T c #F5E78E",
+"U c #FBE802",
+"V c #FBE402",
+"W c #FBDF02",
+"X c #FBDB02",
+"Y c #FDDB01",
+"Z c #FFC900",
+"` c #FFC000",
+" . c #F6B104",
+".. c #F6AD04",
+"+. c #F6A904",
+"@. c #F6A504",
+"#. c #F5A514",
+"$. c #D9A36E",
+"%. c #B46107",
+"&. c #BC7008",
+"*. c #BC6F08",
+"=. c #BC6E08",
+"-. c #DEA404",
+";. c #FFC300",
+">. c #D58508",
+",. c #BD6506",
+"'. c #BD6406",
+"). c #BD6306",
+"!. c #B95E06",
+"~. c #AE5301",
+"{. c #D79700",
+"]. c #FFBD00",
+"^. c #CD7A08",
+"/. c #D79600",
+"(. c #FFBC00",
+"_. c #D79500",
+":. c #FFBA00",
+"<. c #CD7908",
+"[. c #D79400",
+"}. c #FFB800",
+"|. c #CD7808",
+"1. c #D79300",
+"2. c #FFB700",
+"3. c #CD7708",
+"4. c #D79200",
+"5. c #FFB300",
+"6. c #CD7608",
+"7. c #D79100",
+"8. c #FFB600",
+"9. c #F9AB03",
+"0. c #C07008",
+"a. c #EDB008",
+"b. c #EDAD08",
+"c. c #EDA908",
+"d. c #EDA608",
+"e. c #EDA208",
+"f. c #ED9F08",
+"g. c #ED9B08",
+"h. c #C16807",
+" . . + ",
+" . @ # $ % ",
+" . @ & * = - % ",
+" . @ & ; > , ' - % ",
+" . @ ) ! ~ { ] ^ / - % ",
+" . ( _ : < [ } | 1 2 3 4 + ",
+" . ( 5 6 7 8 9 0 a b c d e f g ",
+" . ( 5 h i j k { l m n o p q r f s ",
+" . ( t u v w < > x | y z A B C D E f s ",
+". ( F G H I J ~ 9 ] K b L M N O P Q R S g ",
+"g T U V W X Y [ } l 1 Z o ` ...+.@.#.$.+ ",
+"% %.&.*.*.=.-.> 0 a y c ;.B >.,.,.'.).!.~. ",
+" . . . . . {.{ ] m n L p ].^.. . . . . ",
+" . /.x | 1 z A ` (.^.. ",
+" . _.0 K b c ;.N :.<.. ",
+" . [.l m Z o p ].}.|.. ",
+" . 1.a y z A B C 2.|.. ",
+" . 1.K n L M N O P 3.. ",
+" . 4.1 Z o ` (.}.5.6.. ",
+" . 7.y c ;.B :.8.9.6.. ",
+" ~.0.a.b.c.d.e.f.g.h.. ",
+" ~.g g g g g g g ~. "};
+
+static const char * xpm_down[] = {
+"22 22 138 2",
+" c None",
+". c #AE5300",
+"+ c #C78950",
+"@ c #FFFABF",
+"# c #FFF9BF",
+"$ c #FFF8BF",
+"% c #FFF7BF",
+"& c #FFF6BF",
+"* c #FFF4BF",
+"= c #FFF3BF",
+"- c #D7A000",
+"; c #FFEA00",
+"> c #FFE600",
+", c #FFE100",
+"' c #FFDD00",
+") c #FFD800",
+"! c #FFD400",
+"~ c #FFCF00",
+"{ c #D79000",
+"] c #D79F00",
+"^ c #FFE800",
+"/ c #FFE400",
+"( c #FFDF00",
+"_ c #FFDB00",
+": c #FFD700",
+"< c #FFD200",
+"[ c #FFCE00",
+"} c #D78F00",
+"| c #FFE700",
+"1 c #FFE200",
+"2 c #FFDE00",
+"3 c #FFD900",
+"4 c #FFD500",
+"5 c #FFD000",
+"6 c #FFCC00",
+"7 c #D78E00",
+"8 c #D79E00",
+"9 c #FFE500",
+"0 c #FFDC00",
+"a c #FFD300",
+"b c #FFCA00",
+"c c #D78D00",
+"d c #D79D00",
+"e c #FFE300",
+"f c #FFDA00",
+"g c #FFD600",
+"h c #FFCD00",
+"i c #FFC900",
+"j c #D78C00",
+"k c #D79C00",
+"l c #FFCB00",
+"m c #FFC700",
+"n c #D78B00",
+"o c #D79B00",
+"p c #FFE000",
+"q c #FFC500",
+"r c #D78A00",
+"s c #D79A00",
+"t c #FFD100",
+"u c #FFC800",
+"v c #FFC300",
+"w c #BB6F2A",
+"x c #C27E40",
+"y c #E1AD10",
+"z c #FFC600",
+"A c #FFC200",
+"B c #E19A10",
+"C c #B86920",
+"D c #D9AF6C",
+"E c #F8E843",
+"F c #FFF140",
+"G c #FFEE40",
+"H c #FFEA40",
+"I c #FFE110",
+"J c #FFC000",
+"K c #FFC010",
+"L c #FFC940",
+"M c #FFC640",
+"N c #FFC240",
+"O c #FCBB41",
+"P c #EAC7A3",
+"Q c #B25B01",
+"R c #E1B707",
+"S c #FBE302",
+"T c #FFBE00",
+"U c #FFBA00",
+"V c #FFB500",
+"W c #FFB100",
+"X c #FCA902",
+"Y c #EA9207",
+"Z c #BA5F02",
+"` c #E2B506",
+" . c #FCDF02",
+".. c #FFC100",
+"+. c #FFBD00",
+"@. c #FFB800",
+"#. c #FFB400",
+"$. c #FCAC02",
+"%. c #EA9407",
+"&. c #B25A01",
+"*. c #E2B106",
+"=. c #FCD902",
+"-. c #FFC400",
+";. c #FFBF00",
+">. c #FFBB00",
+",. c #FFB700",
+"'. c #FCAE02",
+"). c #EA9707",
+"!. c #BA6002",
+"~. c #EABA07",
+"{. c #FCD302",
+"]. c #FFB900",
+"^. c #FCB102",
+"/. c #EA9907",
+"(. c #BA6702",
+"_. c #EAB607",
+":. c #FCCD02",
+"<. c #FFBC00",
+"[. c #FCB302",
+"}. c #E29206",
+"|. c #BA6102",
+"1. c #BA6602",
+"2. c #EAB107",
+"3. c #FECA01",
+"4. c #FBB502",
+"5. c #E29306",
+"6. c #B25801",
+"7. c #BA6502",
+"8. c #ECB006",
+"9. c #FEC401",
+"0. c #F8B403",
+"a. c #E19407",
+"b. c #BA6402",
+"c. c #ECAB06",
+"d. c #F5B305",
+"e. c #E19507",
+"f. c #C26E03",
+"g. c #DD9206",
+" . . . . . . . . . ",
+" . + @ # $ % & * = + . ",
+" . - ; > , ' ) ! ~ { . ",
+" . ] ^ / ( _ : < [ } . ",
+" . ] | 1 2 3 4 5 6 7 . ",
+" . 8 9 , 0 ) a ~ b c . ",
+" . d e ( f g < h i j . ",
+" . k 1 ' 3 ! 5 l m n . ",
+" . o p _ : a [ b q r . ",
+" . . . . . s 2 f 4 t 6 u v r . . . . . ",
+". w x x x x y ' ) ! ~ l z A B x x x x C . ",
+". D E F G H I _ g < h i q J K L M N O P . ",
+". Q R S > 1 2 3 4 5 6 m v T U V W X Y Z . ",
+" . Q ` .p 0 : a [ b z ..+.@.#.$.%.Z . ",
+" . &.*.=.f g t h u -.;.>.,.'.).!.. ",
+" . &.~.{.! 5 l m A T ].^./.!.. ",
+" . (._.:.[ i q ..<.[.}.|.. ",
+" . 1.2.3.u v ;.4.5.6.. ",
+" . 7.8.9.A 0.a.6.. ",
+" . b.c.d.e.6.. ",
+" . f.g.6.. ",
+" . . . "};
+
+static const char * xpm_binary[] = {
+"32 32 246 2",
+" c None",
+". c #6E6E6E",
+"+ c #8E8F8F",
+"@ c #898A8B",
+"# c #88898B",
+"$ c #88898A",
+"% c #87888A",
+"& c #86878A",
+"* c #868789",
+"= c #878889",
+"- c #878789",
+"; c #868788",
+"> c #858688",
+", c #858687",
+"' c #848687",
+") c #848587",
+"! c #858586",
+"~ c #6A6A6A",
+"{ c #706F6F",
+"] c #F6FAFF",
+"^ c #E7EFFF",
+"/ c #F0F5FF",
+"( c #E9F0FE",
+"_ c #E8F0FE",
+": c #E3ECFD",
+"< c #E4EDFD",
+"[ c #DFEAFB",
+"} c #E8F0FD",
+"| c #E6EFFC",
+"1 c #E2ECFB",
+"2 c #E1EBFB",
+"3 c #D5E3F8",
+"4 c #D3E1F8",
+"5 c #D1E1F7",
+"6 c #D0DFF6",
+"7 c #CEDFF6",
+"8 c #CDDEF5",
+"9 c #CBDDF5",
+"0 c #CADCF5",
+"a c #C9DBF4",
+"b c #C7DAF3",
+"c c #C6D9F3",
+"d c #C4D8F2",
+"e c #C2D7F2",
+"f c #C1D6F2",
+"g c #E7EEF6",
+"h c #696968",
+"i c #6F6F6F",
+"j c #F3F7FF",
+"k c #A0BDF9",
+"l c #E1EAFC",
+"m c #C8D9F9",
+"n c #BBD1F6",
+"o c #D7E4FA",
+"p c #B6CDF4",
+"q c #D0DFF8",
+"r c #AEC7F1",
+"s c #CBDBF6",
+"t c #BAD0F3",
+"u c #A7C3EF",
+"v c #9ABBEC",
+"w c #4E87DC",
+"x c #4F86DC",
+"y c #4983D9",
+"z c #437FD6",
+"A c #3D7CD5",
+"B c #3878D2",
+"C c #3374D1",
+"D c #2E72D0",
+"E c #296ECE",
+"F c #236ACC",
+"G c #1C67C9",
+"H c #1762C6",
+"I c #105EC4",
+"J c #0A5AC5",
+"K c #E3EAF4",
+"L c #F4F8FF",
+"M c #9DBCF8",
+"N c #C2D4F9",
+"O c #ACC6F5",
+"P c #A3C0F3",
+"Q c #A4C0F1",
+"R c #9FBDF0",
+"S c #97B9EE",
+"T c #99B9ED",
+"U c #8FB3EB",
+"V c #7EA7E7",
+"W c #709EE3",
+"X c #578DDE",
+"Y c #548BDD",
+"Z c #4E87DA",
+"` c #4983D7",
+" . c #4380D6",
+".. c #3E7CD3",
+"+. c #3978D2",
+"@. c #3476D1",
+"#. c #2D72CF",
+"$. c #296ECD",
+"%. c #236BCB",
+"&. c #1E67C9",
+"*. c #1763C6",
+"=. c #1160C7",
+"-. c #E4EBF5",
+";. c #6F6F6E",
+">. c #FEFFFF",
+",. c #E7EFFE",
+"'. c #E2EAFC",
+"). c #E1EBFC",
+"!. c #DEE9FA",
+"~. c #DDE8FA",
+"{. c #DBE6F9",
+"]. c #DEE9FC",
+"^. c #DAE6FA",
+"/. c #D8E4F8",
+"(. c #D8E5F7",
+"_. c #D6E3F7",
+":. c #D6E2F5",
+"<. c #D3E0F3",
+"[. c #D1DFF2",
+"}. c #D0DEF1",
+"|. c #CDDBF0",
+"1. c #CCDBEF",
+"2. c #CBDAEE",
+"3. c #C8D8ED",
+"4. c #C7D7ED",
+"5. c #C7D8ED",
+"6. c #C4D4EB",
+"7. c #C0D1E9",
+"8. c #C1D3EC",
+"9. c #F4F6F8",
+"0. c #686868",
+"a. c #FFFFFF",
+"b. c #FEFEFE",
+"c. c #EDECE9",
+"d. c #F5F5F3",
+"e. c #FEFDFB",
+"f. c #FFFEFC",
+"g. c #FFFFFC",
+"h. c #FFFFFB",
+"i. c #FFFEFB",
+"j. c #FFFDFA",
+"k. c #FFFDF9",
+"l. c #FEFCF8",
+"m. c #FFFCF8",
+"n. c #FCFAF6",
+"o. c #EBE8E5",
+"p. c #FBF8F4",
+"q. c #FCF9F5",
+"r. c #FEFAF6",
+"s. c #F9F9F8",
+"t. c #E1E1E1",
+"u. c #BDBDBD",
+"v. c #C1C1C1",
+"w. c #FAFAFA",
+"x. c #F6F6F6",
+"y. c #B4B4B4",
+"z. c #F2F2F2",
+"A. c #FCFCFC",
+"B. c #F9F9F9",
+"C. c #F7F7F7",
+"D. c #F8F8F8",
+"E. c #CFCFCF",
+"F. c #B6B6B6",
+"G. c #D2D2D2",
+"H. c #F5F5F5",
+"I. c #CACACA",
+"J. c #E2E2E2",
+"K. c #BEBEBE",
+"L. c #EFEFEF",
+"M. c #FBFBFB",
+"N. c #ECECEC",
+"O. c #BCBCBC",
+"P. c #D3D3D3",
+"Q. c #C2C2C2",
+"R. c #F4F4F4",
+"S. c #B1B1B1",
+"T. c #DEDEDE",
+"U. c #BABABA",
+"V. c #E3E3E3",
+"W. c #F1F1F1",
+"X. c #EEEEEE",
+"Y. c #FDFDFD",
+"Z. c #F0F0F0",
+"`. c #F3F3F3",
+" + c #EDEDED",
+".+ c #E7E7E7",
+"++ c #E6E6E6",
+"@+ c #C0C0C0",
+"#+ c #D8D8D8",
+"$+ c #DADADA",
+"%+ c #D1D1D1",
+"&+ c #E0E0E0",
+"*+ c #DFDFDF",
+"=+ c #C6C6C6",
+"-+ c #A6A6A6",
+";+ c #E8E8E8",
+">+ c #B5B5B5",
+",+ c #EAEAEA",
+"'+ c #D4D4D4",
+")+ c #DCDCDC",
+"!+ c #D5D5D5",
+"~+ c #B2B2B2",
+"{+ c #CDCDCD",
+"]+ c #C3C3C3",
+"^+ c #DDDDDD",
+"/+ c #D0D0D0",
+"(+ c #EBEBEB",
+"_+ c #B3B3B3",
+":+ c #A7A7A7",
+"<+ c #A4A4A4",
+"[+ c #D9D9D9",
+"}+ c #C7C7C7",
+"|+ c #BFBFBF",
+"1+ c #DBDBDB",
+"2+ c #979797",
+"3+ c #909090",
+"4+ c #6D6D6D",
+"5+ c #ACACAC",
+"6+ c #939393",
+"7+ c #A9A9A9",
+"8+ c #949494",
+"9+ c #E4E4E4",
+"0+ c #929292",
+"a+ c #8E8E8E",
+"b+ c #8D8D8D",
+"c+ c #8F8F8F",
+"d+ c #8C8C8C",
+"e+ c #676767",
+"f+ c #A2A2A2",
+"g+ c #D6D6D6",
+"h+ c #9C9C9C",
+"i+ c #BBBBBB",
+"j+ c #C5C5C5",
+"k+ c #717171",
+"l+ c #E9E9E9",
+"m+ c #CBCBCB",
+"n+ c #AFAFAF",
+"o+ c #ABABAB",
+"p+ c #CECECE",
+"q+ c #707070",
+"r+ c #B9B9B9",
+"s+ c #B0B0B0",
+"t+ c #E5E5E5",
+"u+ c #6C6C6C",
+"v+ c #959595",
+"w+ c #8A8A8A",
+" . + @ # # # $ $ % % & * * * = - * * ; ; ; > > , , ' ) > ! ~ ",
+" { ] ^ / ( _ _ : < [ } | 1 2 3 4 5 6 7 8 9 0 a b c d e f g h ",
+" i j k l m n o p q r s t u v w x y z A B C D E F G H I J K h ",
+" i L M N O P P Q R S T U V W X Y Z ` ...+.@.#.$.%.&.*.=.-.h ",
+" ;.>.,.'.).2 !.~.{.].^./.(._.(.:.<.[.}.|.1.2.3.4.5.6.7.8.9.0. ",
+" . a.a.a.a.a.a.a.b.c.d.a.a.a.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.0. ",
+" . a.a.a.a.a.a.a.t.u.v.w.a.x.y.z.A.B.B.C.C.x.D.E.F.G.H.z.D.0. ",
+" . a.a.a.a.a.a.a.I.J.K.L.a.M.y.N.A.B.D.C.C.x.D.O.P.Q.R.L.D.0. ",
+" . a.a.a.a.a.a.a.R.u.G.a.b.H.S.T.b.D.D.D.x.x.C.J.U.V.W.X.D.0. ",
+" . a.a.a.Y.b.a.a.a.a.a.Y.A.A.R.B.w.D.B.Z.B.x.R.x.`.`. +Z.B.0. ",
+" . a.a.a.U..+a.a.a.b.b.Y.b.++@+#+w.w.$+u.%+R.C.&+U.Z. +W.B.0. ",
+" . a.a.a.O.*+a.a.b.Y.Y.A.a.=+P.@+H.w.v.#+-+Z.C.;+>+,+X.W.B.0. ",
+" . a.a.a.Q.'+a.b.b.Y.A.A.b.V.O.P.B.B.)+O.!+R.x.V.~+J.Z.z.B.0. ",
+" . a.a.a.B.M.a.b.Y.Y.A.M.w.Y.C.B.D.x.B.`.C.R.z.L.L.L.L.`.B.0. ",
+" . a.a.H.Q.{+A.b.Y.A.M.M.M.R.]+W.D.D.++Q.`.`.Z.Z.W.W.Z.R.B.0. ",
+" . a.a.^+/+v.(+a.Y.M.M.M.w.C.~+N.D.D.;+_+z.z.W.W.W.W.W.H.B.0. ",
+" . a.a.`.Q.I.w.Y.A.A.M.B.w.`.:+$+w.D.V.<+[+x.z.z.`.z.z.x.B.0. ",
+" . a.B.Y.C.w.b.Y.Y.b.w.B.B.x.X.Z.H.`.z.,+Z.`.z.R.x.z.z.x.B.0. ",
+" . a.R.`.x.D.D.w.z.}+`.D.D.L.|+X.R.H.^+_+1+H.C.&+U.R.H.D.B.0. ",
+" . a.x.H.R.R.R.H.Z.>+ +x.x.L.2+;+D.C.~+{+3+Z.w.t.<+H.x.B.B.0. ",
+" 4+a.x.H.H.H.H.x.Z.5+/+D.C.W.6+'+M.D.=+7+F.`.B.&+8+9+D.B.B.0. ",
+" 4+a.C.x.M.D.x.x.H.z.L.x.C.z.)+(+D.C.R.$+C.D.C.`.N.R.B.A.w.0. ",
+" 4+a.C.D.@+9+B.C.Z.Q.W.C.x.C.M.D.x.x.D.M.0+a+a+a+b+b+b+c+d+e+ ",
+" 4+a.w.A.f+g+Y.w.z.f+X.w.D.D.D.D.D.D.D.B.c+(+D.x.H.H.M.H.i ",
+" 4+a.w.M.h+i+Y.w.Z.0+j+A.D.D.D.D.D.D.D.B.c+L.A.A.b.a.M.k+ ",
+" 4+a.w.B.++l+w.w.x.J.l+w.B.w.b.M.B.B.B.w.c+,+H.H.M.B.k+ ",
+" 4+a.A.D.m+[+A.A.R.K.g+Y.M.B.g+L.A.w.w.M.c+++L.R.`.k+ ",
+" 4+a.a.!+i+n+.+a.|+{+o+(+a.p+7+i+w.M.w.M.a+V.L. +q+ ",
+" 4+a.a.*+~+n+X.a.I.r+o+W.a.r+@+s+C.A.M.A.a+9+.+q+ ",
+" 4+a.a.a.)+.+a.a.Y.E.t+a.a.x.@+t+a.a.a.a.3+&+i ",
+" u+v+6+0+8+6+0+0+6+8+8+0+0+6+v+6+0+0+0+6+w+. ",
+" "};
+static const char * xpm_display[] = {
+"32 32 488 2",
+" c None",
+". c #868686",
+"+ c #9E9E9E",
+"@ c #9D9D9D",
+"# c #9C9C9C",
+"$ c #9B9B9B",
+"% c #9A9A9A",
+"& c #666666",
+"* c #949494",
+"= c #FDFDFD",
+"- c #FFFFFF",
+"; c #F1F1F1",
+"> c #717171",
+", c #EAEAEA",
+"' c #FFFFFD",
+") c #FFFFFC",
+"! c #FFFFFA",
+"~ c #FFFEFA",
+"{ c #FFFEF9",
+"] c #FFFDF9",
+"^ c #FFFCF9",
+"/ c #FFFCF8",
+"( c #FEFEFE",
+"_ c #C8C8C8",
+": c #F5F5F5",
+"< c #D7D8DB",
+"[ c #7087AE",
+"} c #7D98BE",
+"| c #8AA7CA",
+"1 c #8CA9CB",
+"2 c #8FACCD",
+"3 c #92B0D0",
+"4 c #95B3D2",
+"5 c #98B6D4",
+"6 c #9BB9D6",
+"7 c #9EBCD7",
+"8 c #A0BED8",
+"9 c #A0BFD8",
+"0 c #9BB9D4",
+"a c #98B6D3",
+"b c #95B3D1",
+"c c #92AFCF",
+"d c #8EACCD",
+"e c #8BA8CA",
+"f c #87A5C9",
+"g c #85A2C7",
+"h c #758FB7",
+"i c #899CC0",
+"j c #F8F9FA",
+"k c #D3D3D3",
+"l c #F4F4F4",
+"m c #C6C9D0",
+"n c #083FA5",
+"o c #2A6ECA",
+"p c #3B80D5",
+"q c #4287D9",
+"r c #488EDD",
+"s c #4F95E2",
+"t c #579DE6",
+"u c #5EA4EB",
+"v c #64ABEF",
+"w c #6AB1F3",
+"x c #6EB5F5",
+"y c #6EB6F6",
+"z c #6DB4F5",
+"A c #69B1F2",
+"B c #63AAEF",
+"C c #5DA3EA",
+"D c #559CE6",
+"E c #4F94E1",
+"F c #478DDC",
+"G c #4084D7",
+"H c #397ED3",
+"I c #3478D0",
+"J c #1A5DBF",
+"K c #2C5CB7",
+"L c #F3F5F8",
+"M c #D2D2D2",
+"N c #F6F6F6",
+"O c #C8CCD3",
+"P c #225DB7",
+"Q c #397BD1",
+"R c #4081D3",
+"S c #4788D8",
+"T c #4D8FDB",
+"U c #5395DF",
+"V c #599BE3",
+"W c #5EA2E7",
+"X c #64A7EA",
+"Y c #68ABED",
+"Z c #6AAEEF",
+"` c #6BAFEF",
+" . c #6AAEEE",
+".. c #63A7EA",
+"+. c #5FA1E6",
+"@. c #5294DF",
+"#. c #4B8DDB",
+"$. c #4586D6",
+"%. c #3F80D2",
+"&. c #3879CE",
+"*. c #2C6EC8",
+"=. c #3F73C5",
+"-. c #F0F2F6",
+";. c #FFFEFD",
+">. c #CDD0D7",
+",. c #2B66BC",
+"'. c #3576CE",
+"). c #3D7DD1",
+"!. c #4384D5",
+"~. c #498AD8",
+"{. c #4E90DC",
+"]. c #5395E0",
+"^. c #5D9FE5",
+"/. c #60A3E8",
+"(. c #62A5E9",
+"_. c #62A4E9",
+":. c #60A3E7",
+"<. c #5C9FE6",
+"[. c #589AE2",
+"}. c #4E8FDC",
+"|. c #4182D3",
+"1. c #3B7CD0",
+"2. c #3575CC",
+"3. c #296BC7",
+"4. c #467AC9",
+"5. c #EAEBEF",
+"6. c #F1F0EF",
+"7. c #CECECE",
+"8. c #F8F8F8",
+"9. c #CED1D8",
+"0. c #2560B9",
+"a. c #3072CB",
+"b. c #3F7FD2",
+"c. c #488AD8",
+"d. c #4D8FDC",
+"e. c #5294DE",
+"f. c #5597E0",
+"g. c #589BE2",
+"h. c #5A9CE3",
+"i. c #599CE3",
+"j. c #5597E1",
+"k. c #5193DE",
+"l. c #4D8EDB",
+"m. c #4889D8",
+"n. c #4283D4",
+"o. c #3C7CD1",
+"p. c #3777CD",
+"q. c #3271C9",
+"r. c #2667C4",
+"s. c #4276C6",
+"t. c #E1E3E7",
+"u. c #E4E3E1",
+"v. c #CACACA",
+"w. c #F9F9F9",
+"x. c #CED2D9",
+"y. c #1550AF",
+"z. c #2C6CC7",
+"A. c #3474CB",
+"B. c #3979CE",
+"C. c #3D7ED1",
+"D. c #4282D4",
+"E. c #4788D7",
+"F. c #4B8CDA",
+"G. c #5092DD",
+"H. c #4A8BD9",
+"I. c #4687D7",
+"J. c #4182D4",
+"K. c #3C7DD1",
+"L. c #3272CA",
+"M. c #2E6DC7",
+"N. c #1F5FBF",
+"O. c #3467BE",
+"P. c #E1E3E6",
+"Q. c #E3E2E1",
+"R. c #CCCCCC",
+"S. c #FBFBFB",
+"T. c #D2D6DC",
+"U. c #0740A5",
+"V. c #1656B9",
+"W. c #2F6FC8",
+"X. c #3373CB",
+"Y. c #3F80D3",
+"Z. c #4889D7",
+"`. c #4587D6",
+" + c #4283D5",
+".+ c #3B7BD0",
+"++ c #3676CD",
+"@+ c #3171C9",
+"#+ c #2968C3",
+"$+ c #0949B1",
+"%+ c #2C5EB7",
+"&+ c #E1E0DF",
+"*+ c #FCFCFC",
+"=+ c #D4D7DE",
+"-+ c #0841A5",
+";+ c #003BA8",
+">+ c #1654B7",
+",+ c #2B6BC5",
+"'+ c #3171CA",
+")+ c #3878CE",
+"!+ c #3E7FD1",
+"~+ c #3A7BD0",
+"{+ c #3878CD",
+"]+ c #3070C9",
+"^+ c #2C6BC6",
+"/+ c #2362C0",
+"(+ c #0F4DB2",
+"_+ c #0037A6",
+":+ c #2D60B9",
+"<+ c #E0E2E5",
+"[+ c #DFDEDC",
+"}+ c #D6D9E0",
+"|+ c #0942A6",
+"1+ c #003CA9",
+"2+ c #0341AB",
+"3+ c #0F4DB4",
+"4+ c #1E5DBD",
+"5+ c #2A69C5",
+"6+ c #3374CB",
+"7+ c #3676CC",
+"8+ c #3778CD",
+"9+ c #3576CC",
+"0+ c #2C6CC6",
+"a+ c #2463C0",
+"b+ c #1552B7",
+"c+ c #0642AD",
+"d+ c #003CA8",
+"e+ c #0038A6",
+"f+ c #DFE1E4",
+"g+ c #DCDBDA",
+"h+ c #D7DBE2",
+"i+ c #0B44A9",
+"j+ c #0443AE",
+"k+ c #0C4AB1",
+"l+ c #0F4DB3",
+"m+ c #1250B5",
+"n+ c #1857B9",
+"o+ c #205FBE",
+"p+ c #2766C2",
+"q+ c #2A6AC5",
+"r+ c #2E6EC7",
+"s+ c #2E6EC8",
+"t+ c #2D6DC7",
+"u+ c #2767C3",
+"v+ c #2161BF",
+"w+ c #1A59BA",
+"x+ c #114FB4",
+"y+ c #0A48B0",
+"z+ c #0744AD",
+"A+ c #0441AB",
+"B+ c #0038A7",
+"C+ c #DEDFE2",
+"D+ c #D9D8D7",
+"E+ c #D9DDE4",
+"F+ c #114BAD",
+"G+ c #0B4AB2",
+"H+ c #1452B6",
+"I+ c #1B5ABB",
+"J+ c #1F5EBD",
+"K+ c #2261C0",
+"L+ c #2464C1",
+"M+ c #2767C2",
+"N+ c #2968C4",
+"O+ c #2969C4",
+"P+ c #2665C1",
+"Q+ c #2262C0",
+"R+ c #1756B8",
+"S+ c #1351B5",
+"T+ c #0A47B0",
+"U+ c #003BA9",
+"V+ c #DBDDE0",
+"W+ c #D6D5D4",
+"X+ c #DCE0E6",
+"Y+ c #1852B2",
+"Z+ c #1250B6",
+"`+ c #1B59BB",
+" @ c #205EBD",
+".@ c #2766C3",
+"+@ c #2B6AC6",
+"@@ c #2D6EC7",
+"#@ c #3070C8",
+"$@ c #3272C9",
+"%@ c #2867C3",
+"&@ c #1A58BA",
+"*@ c #1653B7",
+"=@ c #114EB4",
+"-@ c #0242AE",
+";@ c #3063BB",
+">@ c #DADCDF",
+",@ c #D4D3D2",
+"'@ c #DDE1E8",
+")@ c #1E58B6",
+"!@ c #1857BA",
+"~@ c #2160BF",
+"{@ c #2665C2",
+"]@ c #2F6EC8",
+"^@ c #3372CA",
+"/@ c #3A7BCF",
+"(@ c #3B7BCF",
+"_@ c #3677CD",
+":@ c #2B6BC6",
+"<@ c #215FBE",
+"[@ c #1C5ABB",
+"}@ c #1654B8",
+"|@ c #0848B2",
+"1@ c #3567BF",
+"2@ c #D9DBDE",
+"3@ c #D1D1CF",
+"4@ c #DEE2E8",
+"5@ c #235DB9",
+"6@ c #1D5EBF",
+"7@ c #3E7FD2",
+"8@ c #4284D4",
+"9@ c #4484D5",
+"0@ c #0E4EB5",
+"a@ c #396CC1",
+"b@ c #D8D9DC",
+"c@ c #CFCECD",
+"d@ c #CDCDCD",
+"e@ c #DEE1E7",
+"f@ c #2763BC",
+"g@ c #2364C2",
+"h@ c #3372CB",
+"i@ c #4B8DDA",
+"j@ c #4C8EDB",
+"k@ c #4C8EDA",
+"l@ c #498BD9",
+"m@ c #3D7ED2",
+"n@ c #3373CA",
+"o@ c #1353B8",
+"p@ c #3C70C3",
+"q@ c #D6D8DB",
+"r@ c #CDCCCA",
+"s@ c #DBDFE5",
+"t@ c #1F5EBC",
+"u@ c #1C60C2",
+"v@ c #266AC7",
+"w@ c #2D71CB",
+"x@ c #3377CF",
+"y@ c #397DD3",
+"z@ c #3E83D7",
+"A@ c #4389DA",
+"B@ c #478DDD",
+"C@ c #4A90DE",
+"D@ c #4C92DF",
+"E@ c #4489DB",
+"F@ c #3F85D7",
+"G@ c #3A7FD4",
+"H@ c #3379D0",
+"I@ c #2D71CC",
+"J@ c #2063C3",
+"K@ c #195CBF",
+"L@ c #0A4FB7",
+"M@ c #356CC3",
+"N@ c #D5D7DA",
+"O@ c #CAC9C8",
+"P@ c #E9ECEF",
+"Q@ c #88AADC",
+"R@ c #86ABDF",
+"S@ c #8CB1E2",
+"T@ c #90B5E4",
+"U@ c #93B8E6",
+"V@ c #96BBE8",
+"W@ c #99BFEA",
+"X@ c #9DC2EB",
+"Y@ c #9FC4EE",
+"Z@ c #A0C6EE",
+"`@ c #A1C6EF",
+" # c #A0C5EE",
+".# c #9EC4ED",
+"+# c #9CC2EC",
+"@# c #92B7E5",
+"## c #8EB3E3",
+"$# c #8AAFE0",
+"%# c #87ABDD",
+"&# c #83A7DC",
+"*# c #7BA0D7",
+"=# c #92AFDD",
+"-# c #D6D7D9",
+";# c #C6C6C5",
+"># c #CBCBCB",
+",# c #FDFDFC",
+"'# c #F4F6F8",
+")# c #F6F7F8",
+"!# c #F4F3F3",
+"~# c #F1F2F2",
+"{# c #F0F0F0",
+"]# c #EFEEEF",
+"^# c #EDEDEC",
+"/# c #EBEBEB",
+"(# c #E9EAEA",
+"_# c #E8E8E8",
+":# c #E6E6E6",
+"<# c #E3E3E3",
+"[# c #E2E2E2",
+"}# c #E1E1E1",
+"|# c #DFDFDF",
+"1# c #DCDCDC",
+"2# c #DBDBDB",
+"3# c #D9D9D9",
+"4# c #D7D8D7",
+"5# c #D5D6D6",
+"6# c #D4D3D3",
+"7# c #D0D0D1",
+"8# c #CFCFCF",
+"9# c #C4C4C4",
+"0# c #FBFAFA",
+"a# c #F9F7F7",
+"b# c #F6F6F4",
+"c# c #F4F4F3",
+"d# c #ECEBEA",
+"e# c #E9E9E8",
+"f# c #E8E7E7",
+"g# c #E6E5E5",
+"h# c #E4E2E3",
+"i# c #E2E1E0",
+"j# c #E0DFDD",
+"k# c #DEDDDC",
+"l# c #DBDBDA",
+"m# c #D8D9D8",
+"n# c #D6D6D5",
+"o# c #D4D4D3",
+"p# c #D2D2D1",
+"q# c #D0CFCF",
+"r# c #CECCCC",
+"s# c #CBCAC9",
+"t# c #A5A5A5",
+"u# c #ACACAC",
+"v# c #C9C9C9",
+"w# c #C7C7C7",
+"x# c #D5D5D5",
+"y# c #D1D1D1",
+"z# c #C1C1C1",
+"A# c #B4B4B4",
+"B# c #B9B9B9",
+"C# c #BBBBBB",
+"D# c #BABABA",
+"E# c #B8B8B8",
+"F# c #BCBCBC",
+"G# c #595959",
+"H# c #D0D0D0",
+"I# c #C3C3C3",
+"J# c #C2C2C2",
+"K# c #BFBFBF",
+"L# c #BEBEBE",
+"M# c #878787",
+"N# c #3A3A3A",
+"O# c #8B8B8B",
+"P# c #C6C6C6",
+"Q# c #E7E7E7",
+"R# c #F3F3F3",
+"S# c #5E5E5E",
+"T# c #FAFAFA",
+"U# c #F2F2F2",
+"V# c #DADADA",
+"W# c #A8A8A8",
+"X# c #787878",
+"Y# c #ECECEC",
+"Z# c #DDDDDD",
+"`# c #E5E5E5",
+" $ c #E4E4E4",
+".$ c #DEDEDE",
+"+$ c #4C4C4C",
+"@$ c #F7F7F7",
+"#$ c #EDEDED",
+"$$ c #D8D8D8",
+"%$ c #D7D7D7",
+"&$ c #393939",
+"*$ c #808080",
+"=$ c #EFEFEF",
+"-$ c #EEEEEE",
+";$ c #D6D6D6",
+">$ c #686868",
+",$ c #414141",
+"'$ c #898989",
+")$ c #D4D4D4",
+"!$ c #B5B5B5",
+"~$ c #757575",
+"{$ c #2D2D2D",
+"]$ c #454545",
+"^$ c #848484",
+"/$ c #A4A4A4",
+"($ c #A6A6A6",
+"_$ c #A3A3A3",
+":$ c #979797",
+"<$ c #7E7E7E",
+"[$ c #606060",
+"}$ c #3C3C3C",
+" . + @ @ @ @ @ @ @ @ @ # # # # # # # # # $ $ $ % % % $ & ",
+" * = - - - - - - - - - - - - - - - - - - - - - - - - - - ; > ",
+" , - - ' ) ! ! ! ~ { ] ] ^ / / / ] ] ] ] { { { { { ! ) ( - _ ",
+" : - < [ } | 1 2 3 4 5 6 7 8 9 8 7 0 a b c d e f g h i j - k ",
+" l - m n o p q r s t u v w x y z A B C D E F G H I J K L - M ",
+" N - O P Q R S T U V W X Y Z ` .Y ..+.V @.#.$.%.&.*.=.-.;.M ",
+" N - >.,.'.).!.~.{.].V ^./.(.(._.:.<.[.U }.S |.1.2.3.4.5.6.7. ",
+" 8.- 9.0.a.&.b.!.c.d.e.f.g.h.h.i.[.j.k.l.m.n.o.p.q.r.s.t.u.v. ",
+" w.- x.y.z.A.B.C.D.E.F.d.G.k.k.k.G.T H.I.J.K.p.L.M.N.O.P.Q.R. ",
+" S.- T.U.V.W.X.p.1.Y.!.$.S ~.~.~.Z.`. +%..+++@+M.#+$+%+P.&+R. ",
+" *+- =+-+;+>+,+'+2.)+1.!+%.R R R %.C.~+{+A.]+^+/+(+_+:+<+[+R. ",
+" *+- }+|+1+2+3+4+5+]+6+7+8+)+)+{+p.9+X.]+0+a+b+c+d+e+:+f+g+R. ",
+" = - h+i+j+k+l+m+n+o+p+q+M.r+s+s+t+,+u+v+w+x+y+z+A+B+:+C+D+R. ",
+" ( - E+F+G+H+n+I+J+K+L+M+N+O+O+N+u+P+Q+J+I+R+S+l+T+U+:+V+W+R. ",
+" - - X+Y+Z+`+ @/+.@+@@@#@@+$@$@@+#@M.,+%@a+J+&@*@=@-@;@>@,@R. ",
+" - - '@)@!@~@{@q+]@^@7+B./@(@(@/@[email protected].:@{@<@[@}@|@1@2@3@R. ",
+" - - 4@5@6@u+t+@+++/@7@R 8@9@9@[email protected]@.+p.'+0+.@v+[@0@a@b@c@d@ ",
+" - - e@f@[email protected]@{+).n.I.c.i@j@[email protected]@I.n.m@&.n@0+.@~@o@p@q@r@R. ",
+" - - s@t@u@v@w@x@y@z@A@B@C@D@D@C@r E@F@G@H@I@v@J@K@L@M@N@O@R. ",
+" - - P@Q@R@S@T@U@V@W@X@Y@Z@`@`@ #.#+#W@V@@###$#%#&#*#=#-#;#># ",
+" - ,#'#)#N !#~#{#]#^#/#(#_#:#<#[#}#|#1#2#3#4#5#6#M 7#8#_ 9#R. ",
+" 7.- ( ,#0#a#b#c#6.d#e#f#g#h#i#j#k#l#m#n#W+W+o#p#q#r#s#_ 2#t# ",
+" u#M d@R.>#v#9#w#x#k M y#8#7.d@R.>#v.v.z#A#B#C#D#B#E#F#* ",
+" G#w#H#>#v#w#9#I#J#K#L#L#M#N# ",
+" O#P#/#H#:#/#_#_#_#Q#Q#_#/#x#:#R#A#S# ",
+" y#- - - ; 2#/#: w.w.T#8.U#V#k w.- - - W# ",
+" X#- = S.w.N Y#Z#|#`#:# $1#7.v#R..$*+S.- - +$ ",
+" S#@$@$U#U#; #$, <#1#2#$$%$2#|#Q#; U#U#T#Y#&$ ",
+" *$[#=$=$Y#, , , , , , , /#Y#Y##$=$-$;$>$ ",
+" ,$'$C#%$[#<#<# $ $ $ $<#<#[#)$!$~${$ ",
+" ]$& ^$% /$($($_$:$<$[$}$ ",
+" "};
+static const char * xpm_edit[] = {
+"32 32 281 2",
+" c None",
+". c #C4D0E5",
+"+ c #9DAAC1",
+"@ c #FBFFFF",
+"# c #FFFFFF",
+"$ c #FEFFFF",
+"% c #F5FAFF",
+"& c #EDF3FE",
+"* c #E4EBF9",
+"= c #D8E1F2",
+"- c #C2D0E9",
+"; c #A7B2C4",
+"> c #FCFFFF",
+", c #F8FDFF",
+"' c #F2F7FF",
+") c #EAF1FD",
+"! c #E1E9F7",
+"~ c #D5DFF0",
+"{ c #DBAC55",
+"] c #F2C584",
+"^ c #E6AE84",
+"/ c #DD9A6F",
+"( c #EDF4FE",
+"_ c #E6EDFA",
+": c #DBD6D4",
+"< c #F5BC00",
+"[ c #FEE43E",
+"} c #FEE8C3",
+"| c #FEECD3",
+"1 c #EEC5A3",
+"2 c #F8FCFF",
+"3 c #F1F7FF",
+"4 c #E9EFFC",
+"5 c #E6B76B",
+"6 c #FEE600",
+"7 c #FECA00",
+"8 c #FEB610",
+"9 c #FEC451",
+"0 c #FECB93",
+"a c #C15B1D",
+"b c #FAFEFF",
+"c c #F3F9FF",
+"d c #EBEAED",
+"e c #F5C40F",
+"f c #FEB600",
+"g c #FEAF00",
+"h c #FE9610",
+"i c #F98219",
+"j c #AF725E",
+"k c #F5F9FF",
+"l c #EDC07F",
+"m c #FDDE00",
+"n c #FED201",
+"o c #FEB001",
+"p c #FEAC01",
+"q c #FE871C",
+"r c #E1701E",
+"s c #CED1E2",
+"t c #9EABC1",
+"u c #F7FBFF",
+"v c #F5C120",
+"w c #FEBB07",
+"x c #FEB306",
+"y c #FE9C0E",
+"z c #AF684C",
+"A c #98A9C5",
+"B c #FDFFFF",
+"C c #F3CF9F",
+"D c #FDE005",
+"E c #FEDB06",
+"F c #FEB70D",
+"G c #FEB30C",
+"H c #FE8C1C",
+"I c #E06510",
+"J c #B5B1C1",
+"K c #B4C3DC",
+"L c #AEBEDB",
+"M c #8495B1",
+"N c #F5B824",
+"O c #FEE80D",
+"P c #FEC613",
+"Q c #FEB913",
+"R c #FEA918",
+"S c #FE8E23",
+"T c #C7805B",
+"U c #BBC9E0",
+"V c #B9C6DF",
+"W c #B5C5E0",
+"X c #FBE1BF",
+"Y c #FCDC15",
+"Z c #FEE117",
+"` c #FEBE1C",
+" . c #FEBD19",
+".. c #FE9929",
+"+. c #E9781D",
+"@. c #BFA9AC",
+"#. c #C2CFE5",
+"$. c #C1CDE4",
+"%. c #BDCBE5",
+"&. c #F8C449",
+"*. c #FEEB22",
+"=. c #FED123",
+"-. c #FEC023",
+";. c #FEB128",
+">. c #FE9A34",
+",. c #CD7947",
+"'. c #C9D4E9",
+"). c #C7D2E7",
+"!. c #C6D2E6",
+"~. c #C3D0E8",
+"{. c #FDEACF",
+"]. c #F9D121",
+"^. c #FEE72C",
+"/. c #FEC42E",
+"(. c #FEC32A",
+"_. c #FEA938",
+":. c #F59031",
+"<. c #C5A5A3",
+"[. c #CED9EC",
+"}. c #CCD7EA",
+"|. c #CBD7EA",
+"1. c #C8D5EC",
+"2. c #F8CE6C",
+"3. c #FEED39",
+"4. c #FED837",
+"5. c #FEC835",
+"6. c #FEBE37",
+"7. c #FEA645",
+"8. c #D06F31",
+"9. c #D2DCEF",
+"0. c #D0DBED",
+"a. c #CEDAF0",
+"b. c #FEF1DF",
+"c. c #F9C828",
+"d. c #FEEC44",
+"e. c #FECE3F",
+"f. c #FECA3C",
+"g. c #FEB649",
+"h. c #F9A247",
+"i. c #C9A098",
+"j. c #D9E2F3",
+"k. c #D7E1F2",
+"l. c #D4DEF0",
+"m. c #D4DDEF",
+"n. c #D2DEF2",
+"o. c #F3CD87",
+"p. c #FEF054",
+"q. c #FEE04D",
+"r. c #FECE48",
+"s. c #FECA47",
+"t. c #FEB258",
+"u. c #D87833",
+"v. c #DEE6F5",
+"w. c #DDE5F4",
+"x. c #DBE4F3",
+"y. c #D8E1F1",
+"z. c #D5E0F4",
+"A. c #F2F1EF",
+"B. c #FAD148",
+"C. c #FEF15F",
+"D. c #FED654",
+"E. c #FED150",
+"F. c #FEC35B",
+"G. c #F9AF58",
+"H. c #CC947F",
+"I. c #E1E9F8",
+"J. c #DDE6F4",
+"K. c #DCE5F4",
+"L. c #DAE4F3",
+"M. c #D9E3F6",
+"N. c #F6FBFF",
+"O. c #F5D193",
+"P. c #FDEC66",
+"Q. c #FEE766",
+"R. c #FED55C",
+"S. c #FED259",
+"T. c #FEBF6B",
+"U. c #E2914A",
+"V. c #E0DFE9",
+"W. c #E4EBF8",
+"X. c #E2EAF8",
+"Y. c #DFE7F7",
+"Z. c #7C8CA8",
+"`. c #F9FEFF",
+" + c #F8C74E",
+".+ c #FEF37A",
+"++ c #FEDC69",
+"@+ c #FED864",
+"#+ c #FECF6B",
+"$+ c #FEC573",
+"%+ c #CD8968",
+"&+ c #E7EEFB",
+"*+ c #E5ECF9",
+"=+ c #E3EBF9",
+"-+ c #DBE3F1",
+";+ c #D2D9E9",
+">+ c #CBD2E3",
+",+ c #C6CFE3",
+"'+ c #7786A3",
+")+ c #F9FDFF",
+"!+ c #F5B651",
+"~+ c #FEEE86",
+"{+ c #FEDC70",
+"]+ c #FEDA6E",
+"^+ c #FECE7D",
+"/+ c #E4964E",
+"(+ c #E2D8DC",
+"_+ c #E3E9F6",
+":+ c #D8DEED",
+"<+ c #CFD7E5",
+"[+ c #CCD2E2",
+"}+ c #CAD1E2",
+"|+ c #CAD1E1",
+"1+ c #C8D1E5",
+"2+ c #EEAB59",
+"3+ c #FEEBCE",
+"4+ c #FEE4A4",
+"5+ c #FEDD8D",
+"6+ c #FBD08B",
+"7+ c #CB9373",
+"8+ c #D7DCEA",
+"9+ c #D2D8E6",
+"0+ c #CFD6E5",
+"a+ c #CED5E4",
+"b+ c #CDD4E4",
+"c+ c #C9D0E2",
+"d+ c #C9D2E5",
+"e+ c #E7A259",
+"f+ c #F8E7D0",
+"g+ c #C0856A",
+"h+ c #D0D0DA",
+"i+ c #D4DAE7",
+"j+ c #D0D7E5",
+"k+ c #CDD4E3",
+"l+ c #CCD3E3",
+"m+ c #F7FDFF",
+"n+ c #C6966D",
+"o+ c #F5DBC0",
+"p+ c #B67252",
+"q+ c #D3D2DB",
+"r+ c #D8DDE9",
+"s+ c #D5DAE8",
+"t+ c #D1D8E6",
+"u+ c #CBD2E2",
+"v+ c #CAD2E5",
+"w+ c #936D5C",
+"x+ c #978585",
+"y+ c #B88571",
+"z+ c #D9DFE9",
+"A+ c #D8DEE9",
+"B+ c #D7DCE9",
+"C+ c #D5DAE7",
+"D+ c #CDD3E4",
+"E+ c #CCD4E7",
+"F+ c #8D6050",
+"G+ c #AA7A69",
+"H+ c #DBE0E9",
+"I+ c #D3D9E7",
+"J+ c #CFD5E4",
+"K+ c #D4DBEA",
+"L+ c #DFE9FA",
+"M+ c #F4F9FC",
+"N+ c #BF968A",
+"O+ c #E2E6EE",
+"P+ c #DADFE9",
+"Q+ c #D6DBE8",
+"R+ c #D9DFEC",
+"S+ c #DFE6F3",
+"T+ c #E3EBF8",
+"U+ c #E0E9FB",
+"V+ c #F7FCFF",
+"W+ c #F4F9FF",
+"X+ c #F2F8FF",
+"Y+ c #F0F6FF",
+"Z+ c #EBF1FC",
+"`+ c #E7EEFA",
+" @ c #E4ECF9",
+".@ c #E1E8F7",
+"+@ c #E0EAFC",
+"@@ c #E9F0FC",
+"#@ c #F4FDFF",
+". . . . . . . . . . . . . . . + ",
+". @ # # # # # # # # $ % & * = - ; ",
+". > # # # # # # # # , ' ) ! ~ { ] ^ / ",
+". > # # # # # # # # @ % ( _ : < [ } | 1 ",
+". > # # # # # # # # $ 2 3 4 5 6 7 8 9 0 a ",
+". > # # # # # # # # # b c d e 6 f g h i j ",
+". > # # # # # # # # # > k l m n o p q r s t ",
+". > # # # # # # # # # > u v 6 w x y q z A A A ",
+". > # # # # # # # # # B C D E F G H I J K L M ",
+". > # # # # # # # # # # N O P Q R S T U V W M ",
+". > # # # # # # # # # X Y Z ` ...+.@.#.$.%.M ",
+". > # # # # # # # # # &.*.=.-.;.>.,.'.).!.~.M ",
+". > # # # # # # # # {.].^./.(._.:.<.[.}.|.1.M ",
+". > # # # # # # # # 2.3.4.5.6.7.8.~ 9.0.0.a.M ",
+". > # # # # # # # b.c.d.e.f.g.h.i.j.k.l.m.n.M ",
+". > # # # # # # B o.p.q.r.s.t.u.v.w.x.= y.z.M ",
+". > # # # # # > A.B.C.D.E.F.G.H.I.v.J.K.L.M.M ",
+". > # # # # # N.O.P.Q.R.S.T.U.V.W.X.Y.v.J.l.Z. ",
+". > # # # # `., +.+++@+#+$+%+&+*+=+-+;+>+,+'+ ",
+". > # # # # )+, !+~+{+]+^+/+(+_+:+<+[+}+|+1+'+ ",
+". > # # # > `.`.2+3+4+5+6+7+8+9+0+a+b+}+c+d+'+ ",
+". > # # # > `., e+| | f+g+h+i+9+j+0+k+l+>+d+'+ ",
+". > # # # @ `.m+n+| o+p+q+r+s+9+t+0+a+u+l+v+'+ ",
+". > # # $ b `., w+x+y+z+A+B+C+9+j+0+D+u+l+E+Z. ",
+". > # # $ b `., F+G+H+z+A+r+i+I+j+0+J+K+-+L+M ",
+". > # # > b , M+N+O+P+z+A+Q+i+9+R+S+T+X.! U+M ",
+". > # # `.`., V+W+W+X+3 Y+Z+W.`+_ @X.X..@+@M ",
+". > # # `.`., V+W+W+X+3 Y+& ) @@_ @X.X..@+@M ",
+". #@# # `.`., V+W+W+X+3 Y+& ) @@_ @X.X..@+@M ",
+". M M M M M M M M M M M M M M M M M M M M M M ",
+" ",
+" "};
+static const char * xpm_folder[] = {
+"32 32 465 2",
+" c None",
+". c #2F69EF",
+"+ c #1650E9",
+"@ c #3D76F2",
+"# c #5E91FD",
+"$ c #104AEB",
+"% c #3F7AF4",
+"& c #5E93FD",
+"* c #0043FF",
+"= c #0541F5",
+"- c #1243E3",
+"; c #3776F5",
+"> c #95B9FE",
+", c #0047FF",
+"' c #003BFF",
+") c #0D3DE5",
+"! c #B0B0D3",
+"~ c #D6D6E9",
+"{ c #C6C6E0",
+"] c #AEAED1",
+"^ c #2C6FF7",
+"/ c #85AFFC",
+"( c #0651FF",
+"_ c #0046FF",
+": c #0042FF",
+"< c #0039FF",
+"[ c #0434F3",
+"} c #0D38DB",
+"| c #CECEE4",
+"1 c #FEFEFF",
+"2 c #F9F9FC",
+"3 c #E0E0EE",
+"4 c #CBCBE3",
+"5 c #A7AED8",
+"6 c #2E74F9",
+"7 c #8EB5FA",
+"8 c #135FFF",
+"9 c #054FFF",
+"0 c #0041FF",
+"a c #002DFF",
+"b c #082FE3",
+"c c #B8B8D8",
+"d c #F0F6FF",
+"e c #4687FB",
+"f c #B9D3FD",
+"g c #6797F2",
+"h c #4E80EE",
+"i c #2E68F0",
+"j c #1255F7",
+"k c #0040FF",
+"l c #0037FF",
+"m c #002BFF",
+"n c #0020FB",
+"o c #082BD6",
+"p c #D8D8EA",
+"q c #488CFD",
+"r c #91BBFD",
+"s c #91BCFF",
+"t c #7AABFF",
+"u c #6CA0FF",
+"v c #5C90FB",
+"w c #4C7FF3",
+"x c #4172EE",
+"y c #2B5AEF",
+"z c #1740F5",
+"A c #001CFF",
+"B c #021EEB",
+"C c #0524CE",
+"D c #BFBFDC",
+"E c #629FFF",
+"F c #95BFFE",
+"G c #9FC8FF",
+"H c #88B6FF",
+"I c #78A9FF",
+"J c #6A9FFF",
+"K c #6196FF",
+"L c #5E92FF",
+"M c #5E8EFF",
+"N c #5A84FC",
+"O c #5070F5",
+"P c #445BEE",
+"Q c #1B34F3",
+"R c #031FD6",
+"S c #B6B6D6",
+"T c #E2E2EF",
+"U c #498EFE",
+"V c #C0DDFF",
+"W c #97C2FF",
+"X c #85B3FF",
+"Y c #76A7FF",
+"Z c #699CFF",
+"` c #6095FF",
+" . c #5E91FF",
+".. c #5E8DFF",
+"+. c #5E86FF",
+"@. c #5E7FFF",
+"#. c #4A60F1",
+"$. c #0822FA",
+"%. c #0018F9",
+"&. c #0119CB",
+"*. c #C5C5DF",
+"=. c #FBFBFD",
+"-. c #5495FD",
+";. c #B9D8FE",
+">. c #92BEFE",
+",. c #82B1FE",
+"'. c #73A4FE",
+"). c #669AFE",
+"!. c #5E92FE",
+"~. c #5D90FE",
+"{. c #5D8BFE",
+"]. c #5E85FF",
+"^. c #5A78FC",
+"/. c #3249EC",
+"(. c #0017FE",
+"_. c #0017FF",
+":. c #0017EE",
+"<. c #0013C4",
+"[. c #ECECF5",
+"}. c #F8F8FB",
+"|. c #4689FC",
+"1. c #B6D6FD",
+"2. c #8FBCFD",
+"3. c #7FAEFD",
+"4. c #6FA2FD",
+"5. c #6498FD",
+"6. c #5C91FD",
+"7. c #5C8EFD",
+"8. c #5C89FD",
+"9. c #5E84FF",
+"0. c #4B67F2",
+"a. c #1129EF",
+"b. c #0016FA",
+"c. c #0014DF",
+"d. c #0011C0",
+"e. c #CFCFE5",
+"f. c #FDFDFE",
+"g. c #F6F6FA",
+"h. c #E7EDFA",
+"i. c #4587FB",
+"j. c #B3D3FD",
+"k. c #8CB8FD",
+"l. c #7BABFD",
+"m. c #6D9FFD",
+"n. c #6196FD",
+"o. c #5B90FD",
+"p. c #5B8DFD",
+"q. c #5A80FC",
+"r. c #304FEB",
+"s. c #0017E3",
+"t. c #0017F1",
+"u. c #0019FF",
+"v. c #4157DE",
+"w. c #BBBBD9",
+"x. c #F3F3F9",
+"y. c #E4EBF9",
+"z. c #98BFFC",
+"A. c #9AC4FC",
+"B. c #88B6FC",
+"C. c #78A8FC",
+"D. c #6A9CFC",
+"E. c #5F93FC",
+"F. c #5A8EFC",
+"G. c #5A8CFC",
+"H. c #5E89FF",
+"I. c #4F72F5",
+"J. c #1E46F4",
+"K. c #1139F9",
+"L. c #0828F1",
+"M. c #0017E7",
+"N. c #0019EF",
+"O. c #A6B8FE",
+"P. c #4A5DD8",
+"Q. c #F1F1F7",
+"R. c #E2E8F7",
+"S. c #468BFD",
+"T. c #97C0FD",
+"U. c #AED2FB",
+"V. c #96C0FB",
+"W. c #85B2FB",
+"X. c #75A6FB",
+"Y. c #679AFB",
+"Z. c #5D91FB",
+"`. c #598DFB",
+" + c #5C8CFD",
+".+ c #5C87FD",
+"++ c #395FEE",
+"@+ c #153FF8",
+"#+ c #1640FF",
+"$+ c #133DFF",
+"%+ c #0B39FD",
+"&+ c #8EA6FA",
+"*+ c #FCFCFE",
+"=+ c #1F34CC",
+"-+ c #C2C2DD",
+";+ c #F0F0F7",
+">+ c #EEEEF6",
+",+ c #E0E6F6",
+"'+ c #478CFD",
+")+ c #9BC4FD",
+"!+ c #BDDEFB",
+"~+ c #A6CCFB",
+"{+ c #92BDFB",
+"]+ c #81AFFB",
+"^+ c #72A2FB",
+"/+ c #6598FB",
+"(+ c #5B8FFB",
+"_+ c #588CFB",
+":+ c #5D8DFE",
+"<+ c #5078F5",
+"[+ c #2551F3",
+"}+ c #1541FB",
+"|+ c #113FFF",
+"1+ c #0B3CFF",
+"2+ c #557CFE",
+"3+ c #FCFCFD",
+"4+ c #E8EBFA",
+"5+ c #1328C8",
+"6+ c #EBEBF4",
+"7+ c #468CFD",
+"8+ c #A1C8FE",
+"9+ c #D1ECFB",
+"0+ c #B5D8FA",
+"a+ c #A1C9FA",
+"b+ c #8FB9FA",
+"c+ c #7DABFA",
+"d+ c #6EA0FA",
+"e+ c #6295FA",
+"f+ c #588DFA",
+"g+ c #5A8DFC",
+"h+ c #5B8BFE",
+"i+ c #3964F0",
+"j+ c #1146F9",
+"k+ c #0D40FE",
+"l+ c #0B3DFF",
+"m+ c #F9F9FD",
+"n+ c #CFD0F1",
+"o+ c #091CC2",
+"p+ c #C8C8E1",
+"q+ c #E9E9F3",
+"r+ c #E8E8F3",
+"s+ c #3D87FF",
+"t+ c #EDF9FD",
+"u+ c #D5EBFB",
+"v+ c #BDD8FB",
+"w+ c #A3C6FB",
+"x+ c #8EB6FB",
+"y+ c #7BA7FB",
+"z+ c #6999FB",
+"A+ c #5A8DFB",
+"B+ c #4E83FB",
+"C+ c #4980FE",
+"D+ c #396DFA",
+"E+ c #1C53F7",
+"F+ c #0F46FD",
+"G+ c #0C3FFF",
+"H+ c #4872FE",
+"I+ c #F8F8FC",
+"J+ c #F8F8FD",
+"K+ c #D8DBF5",
+"L+ c #1528C6",
+"M+ c #F7F7FB",
+"N+ c #E7E7F2",
+"O+ c #E6E6F1",
+"P+ c #73A6F9",
+"Q+ c #A1C6FD",
+"R+ c #D1E7FB",
+"S+ c #B8D5FB",
+"T+ c #A1C3FB",
+"U+ c #8CB2FB",
+"V+ c #78A3FB",
+"W+ c #6695FB",
+"X+ c #5688FB",
+"Y+ c #4B81FD",
+"Z+ c #477CFF",
+"`+ c #2F63F5",
+" @ c #134DFA",
+".@ c #1046FF",
+"+@ c #2E5DFE",
+"@@ c #E4E9FB",
+"#@ c #F6F6FB",
+"$@ c #F7F7FC",
+"%@ c #E8E8F7",
+"&@ c #283ACB",
+"*@ c #EDEDF5",
+"=@ c #E3E3F0",
+"-@ c #D5DCF1",
+";@ c #4586FB",
+">@ c #CEE2FC",
+",@ c #B3D1FB",
+"'@ c #9EC0FB",
+")@ c #88B0FB",
+"!@ c #75A1FB",
+"~@ c #6392FB",
+"{@ c #5386FB",
+"]@ c #4C82FE",
+"^@ c #3F75FB",
+"/@ c #225BF7",
+"(@ c #134DFC",
+"_@ c #3163FE",
+":@ c #E3E7FB",
+"<@ c #F5F5FB",
+"[@ c #F3F3FB",
+"}@ c #394BD0",
+"|@ c #C3C3DE",
+"1@ c #C0C0DC",
+"2@ c #D7D7E9",
+"3@ c #7DA9F7",
+"4@ c #82ACFA",
+"5@ c #B5D1FA",
+"6@ c #99BDFA",
+"7@ c #84ACFA",
+"8@ c #729EFA",
+"9@ c #6090FA",
+"0@ c #5286FB",
+"a@ c #4C82FF",
+"b@ c #366AF6",
+"c@ c #1954F9",
+"d@ c #1D57FE",
+"e@ c #E1E6FA",
+"f@ c #F2F2F9",
+"g@ c #F2F2FA",
+"h@ c #F3F3FA",
+"i@ c #3F52D3",
+"j@ c #3572E7",
+"k@ c #B3BFE6",
+"l@ c #C3C5E2",
+"m@ c #D2D2E7",
+"n@ c #417CF5",
+"o@ c #B9D2FB",
+"p@ c #98BDFB",
+"q@ c #81AAFA",
+"r@ c #6D9BFA",
+"s@ c #5D8EFA",
+"t@ c #5387FD",
+"u@ c #457AFB",
+"v@ c #2862F7",
+"w@ c #225DFB",
+"x@ c #BFCFF9",
+"y@ c #F0F0F9",
+"z@ c #F1F1F9",
+"A@ c #7884E0",
+"B@ c #2470FA",
+"C@ c #CADBF8",
+"D@ c #D0DBF3",
+"E@ c #BCCBED",
+"F@ c #B5C3E9",
+"G@ c #B5BEE3",
+"H@ c #C8CAE3",
+"I@ c #A0B3E9",
+"J@ c #4A7FF3",
+"K@ c #B1CFFF",
+"L@ c #86B0FF",
+"M@ c #709FFD",
+"N@ c #5F90FD",
+"O@ c #5388FF",
+"P@ c #3C72F7",
+"Q@ c #2864F9",
+"R@ c #BFCEF8",
+"S@ c #EDEDF7",
+"T@ c #EDEDF8",
+"U@ c #EEEEF8",
+"V@ c #818DE3",
+"W@ c #2776FF",
+"X@ c #A2C6FE",
+"Y@ c #F0F7FF",
+"Z@ c #E2EEFF",
+"`@ c #D5E7FF",
+" # c #C0D7F9",
+".# c #AEC8F4",
+"+# c #9CBBF0",
+"@# c #9AB5E9",
+"## c #4A7BEB",
+"$# c #80A4F5",
+"%# c #81A9F9",
+"&# c #6B9AFB",
+"*# c #6092FF",
+"=# c #4E83FC",
+"-# c #2E68F7",
+";# c #A2BBF7",
+"># c #E9E9F7",
+",# c #EBEBF7",
+"'# c #ECECF7",
+")# c #959FE7",
+"!# c #327FFE",
+"~# c #86B3FD",
+"{# c #E1EDFE",
+"]# c #C9E0FF",
+"^# c #BCD8FF",
+"/# c #AFD1FF",
+"(# c #9FC5FB",
+"_# c #85B0F6",
+":# c #275EEB",
+"<# c #90B0F7",
+"[# c #5387F8",
+"}# c #497DF6",
+"|# c #4377F6",
+"1# c #99B5F6",
+"2# c #E7E7F5",
+"3# c #E8E8F6",
+"4# c #B9BFEF",
+"5# c #081CC3",
+"6# c #2D70F7",
+"7# c #7AA6F9",
+"8# c #CADEFE",
+"9# c #A2CAFF",
+"0# c #96C2FF",
+"a# c #72A4FA",
+"b# c #2F5EE7",
+"c# c #76A2FB",
+"d# c #3875FB",
+"e# c #8DACF7",
+"f# c #E3E3F4",
+"g# c #E4E4F4",
+"h# c #E4E4F5",
+"i# c #E6E6F5",
+"j# c #BEC4F1",
+"k# c #081CC4",
+"l# c #2763EF",
+"m# c #6D99F5",
+"n# c #B3D1FD",
+"o# c #89BBFF",
+"p# c #5286F3",
+"q# c #345FE5",
+"r# c #8CB0FB",
+"s# c #E1E1F3",
+"t# c #E2E2F3",
+"u# c #E2E4F7",
+"v# c #081DC4",
+"w# c #2156E8",
+"x# c #618CF1",
+"y# c #9CC3FD",
+"z# c #7FB3FF",
+"A# c #3567EB",
+"B# c #5675E5",
+"C# c #DEDEF2",
+"D# c #E0E0F2",
+"E# c #E3E6F8",
+"F# c #1E34CC",
+"G# c #1B49E1",
+"H# c #5580EE",
+"I# c #87B5FC",
+"J# c #73ACFF",
+"K# c #2958E5",
+"L# c #7D93E9",
+"M# c #DEDEF1",
+"N# c #E4E7F9",
+"O# c #1F35CD",
+"P# c #163CDA",
+"Q# c #4973E9",
+"R# c #73A8FC",
+"S# c #6CA7FF",
+"T# c #143AD9",
+"U# c #8C9CE9",
+"V# c #3C52D6",
+"W# c #0012C0",
+"X# c #1130D2",
+"Y# c #4067E5",
+"Z# c #6095F8",
+"`# c #1032D4",
+" $ c #2F48D5",
+".$ c #0014C2",
+"+$ c #0C25CA",
+"@$ c #0D2CD0",
+"#$ c #0117C5",
+" . + ",
+" @ # $ ",
+" % & * = - ",
+" ; > , * ' ) ",
+" ! ~ { ] ^ / ( _ : < [ } ",
+" | 1 1 2 3 4 5 6 7 8 9 _ 0 < a b ",
+" c 2 1 1 1 1 d e f g h i j k l m n o ",
+" p 1 1 1 1 d q r s t u v w x y z A B C ",
+" D 2 1 1 1 1 E F G H I J K L M N O P Q R ",
+" S T 1 1 1 1 1 U V W X Y Z ` ...+.@.#.$.%.&. ",
+" *.1 =.=.=.=.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<. ",
+" c [.=.}.}.}.}.}.|.1.2.3.4.5.6.7.8.9.0.a.b._._.c.d. ",
+" e.f.g.g.g.g.g.h.i.j.k.l.m.n.o.p.8.q.r.s.t._._.u.v.d. ",
+" w.g.g.x.x.x.x.y.i.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.f.P. ",
+" p =.Q.Q.Q.Q.R.S.T.U.V.W.X.Y.Z.`. +.+++@+#+$+%+&+*+f.f.=+ ",
+" -+=.;+>+>+>+,+'+)+!+~+{+]+^+/+(+_+:+<+[+}+|+1+2+=.3+3+3+4+5+",
+" T g.6+6+6+6+7+8+9+0+a+b+c+d+e+f+g+h+i+j+k+l+2+m+m+=.=.=.n+o+",
+" p+f.q+r+r+r+r+s+t+u+v+w+x+y+z+A+B+C+D+E+F+G+H+I+I+J+J+m+K+L+ ",
+"-+6+M+N+O+O+O+O+P+Q+R+S+T+U+V+W+X+Y+Z+`+ @.@+@@@#@M+$@$@%@&@ ",
+"{ ;+1 1 g.*@O+=@-@;@>@,@'@)@!@~@{@]@^@/@(@_@:@<@<@<@#@[@}@d. ",
+" |@1@2@6+=.1 2 ;+3@4@5@6@7@8@9@0@a@b@c@d@e@f@g@g@h@g@i@d. ",
+" j@k@l@m@T g.1 n@o@p@q@r@s@t@u@v@w@x@y@y@z@z@z@A@d. ",
+" B@C@D@E@F@G@H@I@J@K@L@M@N@O@P@Q@R@S@T@T@U@f@V@d. ",
+" W@X@Y@Z@`@ #.#+#@###$#%#&#*#=#-#;#>#,#,#'#U@)#d. ",
+" !#~#{#Z@`@]#^#/#(#_#:#<#[#}#|#1#2#2#3#3#'#4#5# ",
+" 6#7#8#]#^#/#9#0#a#b#c#d#e#f#g#h#i#>#j#k# ",
+" l#m#n#/#9#0#o#p#q#r#s#s#t#t#g#u#v# ",
+" w#x#y#0#o#z#A#B#t#C#D#t#E#F# ",
+" G#H#I#z#J#K#L#M#C#N#O# ",
+" P#Q#R#S#T#U#z@V#W# ",
+" X#Y#Z#`# $.$ ",
+" +$@$#$ "};
+
+static const char * xpm_images[] = {
+"32 32 557 2",
+" c None",
+". c #C4D0E5",
+"+ c #9DAAC1",
+"@ c #FBFFFF",
+"# c #FFFFFF",
+"$ c #FEFFFF",
+"% c #F5FAFF",
+"& c #EDF3FE",
+"* c #E4EBF9",
+"= c #D8E1F2",
+"- c #C2D0E9",
+"; c #ACB7CA",
+"> c #FCFFFF",
+", c #F8FDFF",
+"' c #F2F7FF",
+") c #EAF1FD",
+"! c #E1E9F7",
+"~ c #D5DFF0",
+"{ c #BFCCE3",
+"] c #EBF4FF",
+"^ c #A6B2C6",
+"/ c #EDF4FE",
+"( c #E6EDFA",
+"_ c #D9E2F2",
+": c #C2CEE5",
+"< c #F0F6FF",
+"[ c #DCE7F9",
+"} c #A6B2C8",
+"| c #F8FCFF",
+"1 c #F1F7FF",
+"2 c #E9EFFC",
+"3 c #DCE5F4",
+"4 c #C4D0E6",
+"5 c #E8EEFB",
+"6 c #DBE5F9",
+"7 c #A7B3C9",
+"8 c #FAFEFF",
+"9 c #F3F9FF",
+"0 c #EBF1FD",
+"a c #DFE7F6",
+"b c #C6D1E5",
+"c c #FDFFFF",
+"d c #ECF2FD",
+"e c #DEE9FB",
+"f c #A9B5CA",
+"g c #C3C4CD",
+"h c #F3EADD",
+"i c #EFD9C2",
+"j c #E4C09A",
+"k c #E4C29E",
+"l c #E5C6A4",
+"m c #F0DECC",
+"n c #F5EADF",
+"o c #F7EFE7",
+"p c #FBF7F3",
+"q c #F5F9FF",
+"r c #E3EBF9",
+"s c #BECBE1",
+"t c #F3F5FB",
+"u c #ECF2F9",
+"v c #E4EBF7",
+"w c #D8E1F0",
+"x c #D0DCF1",
+"y c #A1AEC5",
+"z c #BF6300",
+"A c #C1721B",
+"B c #C26F14",
+"C c #BD6F19",
+"D c #B76B1A",
+"E c #BD701D",
+"F c #C0731F",
+"G c #BB6E18",
+"H c #B6660F",
+"I c #BC7529",
+"J c #D1A273",
+"K c #EDDBC9",
+"L c #F6F3ED",
+"M c #F7FBFF",
+"N c #E8EFFC",
+"O c #C8D4E7",
+"P c #98A9C5",
+"Q c #C16601",
+"R c #C6751D",
+"S c #CF8C41",
+"T c #D9AB7A",
+"U c #CAB8A7",
+"V c #B6B8C3",
+"W c #B2B7CB",
+"X c #C4C2CD",
+"Y c #EEE6DE",
+"Z c #F2E0C8",
+"` c #E1C19B",
+" . c #CB9355",
+".. c #BC772E",
+"+. c #AE600C",
+"@. c #C38D57",
+"#. c #E4D4C3",
+"$. c #EFF3FA",
+"%. c #EBF1FE",
+"&. c #E5EDFA",
+"*. c #D7E0F1",
+"=. c #C1CEE4",
+"-. c #B6C4DD",
+";. c #B4C3DC",
+">. c #AEBEDB",
+",. c #8495B1",
+"'. c #C16400",
+"). c #C77416",
+"!. c #D69C59",
+"~. c #EFD9BB",
+"{. c #E2F2FF",
+"]. c #81AFEB",
+"^. c #97BFF1",
+"/. c #BDD8FA",
+"(. c #8CABE2",
+"_. c #A3B2DE",
+":. c #F3F6FD",
+"<. c #ECEBDB",
+"[. c #D2AC7A",
+"}. c #B8732C",
+"|. c #A25200",
+"1. c #CFB191",
+"2. c #E9EDF4",
+"3. c #CCD6EA",
+"4. c #BECAE2",
+"5. c #BBC9E0",
+"6. c #B9C6DF",
+"7. c #B5C5E0",
+"8. c #C26400",
+"9. c #CF8A37",
+"0. c #ECD1A7",
+"a. c #FFFFFC",
+"b. c #FCFAEB",
+"c. c #AFC8E2",
+"d. c #57A0EE",
+"e. c #8DCDFF",
+"f. c #80C4FF",
+"g. c #70C4FF",
+"h. c #4877C8",
+"i. c #C0BBD1",
+"j. c #EFF3E2",
+"k. c #CCDDC3",
+"l. c #B7D3B6",
+"m. c #C5E6D6",
+"n. c #D5CDAE",
+"o. c #C28A4B",
+"p. c #9E5103",
+"q. c #C5A280",
+"r. c #E6ECF8",
+"s. c #D5DFEF",
+"t. c #C7D3E8",
+"u. c #C5D1E6",
+"v. c #C2CFE5",
+"w. c #C1CDE4",
+"x. c #BDCBE5",
+"y. c #D18C3A",
+"z. c #EED3A5",
+"A. c #F3E2C1",
+"B. c #F1DBB3",
+"C. c #FBF1D0",
+"D. c #F9F7DF",
+"E. c #8EB2D8",
+"F. c #137DF3",
+"G. c #2296FF",
+"H. c #178EFF",
+"I. c #0089FF",
+"J. c #0A5BCC",
+"K. c #BCB5C4",
+"L. c #A5C889",
+"M. c #80BE7F",
+"N. c #ABD9AD",
+"O. c #9ACE9C",
+"P. c #8CC38E",
+"Q. c #EAEBD3",
+"R. c #C38D51",
+"S. c #9A4F01",
+"T. c #C1A996",
+"U. c #D0DAED",
+"V. c #CCD7EA",
+"W. c #C9D4E9",
+"X. c #C7D2E7",
+"Y. c #C6D2E6",
+"Z. c #C3D0E8",
+"`. c #CB7F25",
+" + c #E0B373",
+".+ c #D08E40",
+"++ c #BE6807",
+"@+ c #C17117",
+"#+ c #D49C55",
+"$+ c #F6E3AC",
+"%+ c #C2C9CD",
+"&+ c #0F58CD",
+"*+ c #007AFC",
+"=+ c #0C8DFF",
+"-+ c #0061E8",
+";+ c #4C67B4",
+">+ c #C7B6A1",
+",+ c #75C765",
+"'+ c #6CDC70",
+")+ c #7DE47D",
+"!+ c #75E574",
+"~+ c #34B638",
+"{+ c #B6CC94",
+"]+ c #FFEAC5",
+"^+ c #B57329",
+"/+ c #954E07",
+"(+ c #CBCCD2",
+"_+ c #D0DBED",
+":+ c #CED9EC",
+"<+ c #CBD7EA",
+"[+ c #C8D5EC",
+"}+ c #C06500",
+"|+ c #C16907",
+"1+ c #EBCA8C",
+"2+ c #BE6809",
+"3+ c #D49648",
+"4+ c #F4EFCA",
+"5+ c #9A9EAE",
+"6+ c #4F7CC4",
+"7+ c #467DCC",
+"8+ c #4D61A6",
+"9+ c #C7B0A7",
+"0+ c #F5D9A6",
+"a+ c #4DBC3D",
+"b+ c #15CB18",
+"c+ c #17CD17",
+"d+ c #06CC05",
+"e+ c #009F00",
+"f+ c #9DB66A",
+"g+ c #FEE3B4",
+"h+ c #EABE7D",
+"i+ c #974E03",
+"j+ c #AD8763",
+"k+ c #D2DCEF",
+"l+ c #CEDAF0",
+"m+ c #BF6401",
+"n+ c #CF8C34",
+"o+ c #FFF6BF",
+"p+ c #C77C22",
+"q+ c #B15C04",
+"r+ c #DBA75B",
+"s+ c #FFF7B9",
+"t+ c #FFE7A6",
+"u+ c #D9BB94",
+"v+ c #BA9987",
+"w+ c #E4C294",
+"x+ c #FFE7A3",
+"y+ c #FEDEA1",
+"z+ c #609B38",
+"A+ c #00A502",
+"B+ c #07CC10",
+"C+ c #00C009",
+"D+ c #118A0C",
+"E+ c #CBBF75",
+"F+ c #FDD493",
+"G+ c #FFDF9B",
+"H+ c #B06714",
+"I+ c #93500E",
+"J+ c #D8E0F0",
+"K+ c #D7E1F2",
+"L+ c #D4DEF0",
+"M+ c #D4DDEF",
+"N+ c #D2DEF2",
+"O+ c #BD6402",
+"P+ c #E6BC6F",
+"Q+ c #FFF4B0",
+"R+ c #F2D48A",
+"S+ c #D9A14C",
+"T+ c #CD8A33",
+"U+ c #CF903A",
+"V+ c #E1B160",
+"W+ c #FBDA8F",
+"X+ c #FFE197",
+"Y+ c #FFDF92",
+"Z+ c #FFE391",
+"`+ c #FFE58F",
+" @ c #FFDE8B",
+".@ c #FFD687",
+"+@ c #FFD98B",
+"@@ c #D7BC6E",
+"#@ c #87A946",
+"$@ c #5AAC38",
+"%@ c #64A938",
+"&@ c #A9AD4E",
+"*@ c #FED078",
+"=@ c #FFCE78",
+"-@ c #FFCD7C",
+";@ c #D28B30",
+">@ c #8B4500",
+",@ c #CFCBCC",
+"'@ c #DBE4F3",
+")@ c #D8E1F1",
+"!@ c #D5E0F4",
+"~@ c #BA6202",
+"{@ c #E4B763",
+"]@ c #FFF4A4",
+"^@ c #FFED9C",
+"/@ c #FFEC9C",
+"(@ c #FAD983",
+"_@ c #FEDC86",
+":@ c #FFE791",
+"<@ c #FFDB83",
+"[@ c #FFD67C",
+"}@ c #FFD47A",
+"|@ c #FFD277",
+"1@ c #FFD074",
+"2@ c #FFCE70",
+"3@ c #FFCB6D",
+"4@ c #FFC869",
+"5@ c #FFCC6D",
+"6@ c #FFC367",
+"7@ c #DDB654",
+"8@ c #E89F49",
+"9@ c #F99056",
+"0@ c #EA8752",
+"a@ c #F29E4A",
+"b@ c #FFBF58",
+"c@ c #E49832",
+"d@ c #894300",
+"e@ c #C7BBB4",
+"f@ c #DDE6F4",
+"g@ c #DAE4F3",
+"h@ c #D9E3F6",
+"i@ c #B76001",
+"j@ c #C37A1D",
+"k@ c #F3D27A",
+"l@ c #FFF197",
+"m@ c #FFE68A",
+"n@ c #FFDF82",
+"o@ c #FFDA7B",
+"p@ c #FFD473",
+"q@ c #FFD16E",
+"r@ c #FFCF69",
+"s@ c #FFCB64",
+"t@ c #FFC860",
+"u@ c #FFC55B",
+"v@ c #FFC356",
+"w@ c #FFC052",
+"x@ c #FFBD4E",
+"y@ c #FFBA4A",
+"z@ c #FFBD49",
+"A@ c #FE9D39",
+"B@ c #F6916A",
+"C@ c #F3A19A",
+"D@ c #EFA6A2",
+"E@ c #EB9C88",
+"F@ c #F59B3D",
+"G@ c #E58F1E",
+"H@ c #864300",
+"I@ c #CBC0BA",
+"J@ c #DFE7F7",
+"K@ c #DEE6F5",
+"L@ c #DBE5F7",
+"M@ c #B15B00",
+"N@ c #C0771B",
+"O@ c #D1953A",
+"P@ c #E7B559",
+"Q@ c #FFD979",
+"R@ c #FFDC79",
+"S@ c #FFCF6A",
+"T@ c #FFCC64",
+"U@ c #FFC95F",
+"V@ c #FFC559",
+"W@ c #FFC253",
+"X@ c #FFBF4E",
+"Y@ c #FFBD48",
+"Z@ c #FFB942",
+"`@ c #FFB53E",
+" # c #FFB238",
+".# c #FFB832",
+"+# c #EE6924",
+"@# c #F77471",
+"## c #FF9498",
+"$# c #FF9698",
+"%# c #F96971",
+"&# c #D7471C",
+"*# c #E1820A",
+"=# c #844100",
+"-# c #C9BDB6",
+";# c #E2EAF8",
+"># c #E0E7F6",
+",# c #DCE6F8",
+"'# c #AB5600",
+")# c #B4670F",
+"!# c #C47E25",
+"~# c #E5AC4C",
+"{# c #FFD76D",
+"]# c #FFCA60",
+"^# c #FFBF4D",
+"/# c #FFBC48",
+"(# c #FFB842",
+"_# c #FFB43C",
+":# c #FFB036",
+"<# c #FFAD30",
+"[# c #FFB72B",
+"}# c #E9541C",
+"|# c #FB2725",
+"1# c #FE2526",
+"2# c #F91B1B",
+"3# c #FF0D0D",
+"4# c #C41803",
+"5# c #C86C01",
+"6# c #823F00",
+"7# c #D7D6D9",
+"8# c #E2E9F7",
+"9# c #E0E8F7",
+"0# c #E0E8F6",
+"a# c #DEE8FA",
+"b# c #A35100",
+"c# c #AC5F0A",
+"d# c #CF8C2D",
+"e# c #FFC959",
+"f# c #FFC252",
+"g# c #FFBD4B",
+"h# c #FFBA45",
+"i# c #FFB740",
+"j# c #FFB43A",
+"k# c #FFB034",
+"l# c #FFAC2F",
+"m# c #FFA929",
+"n# c #FFB125",
+"o# c #E05F11",
+"p# c #E50C0B",
+"q# c #FF0E14",
+"r# c #FF1014",
+"s# c #E4000A",
+"t# c #D14301",
+"u# c #A45600",
+"v# c #8C531C",
+"w# c #E3EBF7",
+"x# c #DFE9FA",
+"y# c #A25403",
+"z# c #D58F2C",
+"A# c #FFC650",
+"B# c #FFB844",
+"C# c #FFB63E",
+"D# c #FFB339",
+"E# c #FFB033",
+"F# c #FFAB2D",
+"G# c #FFA828",
+"H# c #FFA522",
+"I# c #FFA31C",
+"J# c #F89A15",
+"K# c #D84A08",
+"L# c #D22814",
+"M# c #D02518",
+"N# c #C02D06",
+"O# c #E77A01",
+"P# c #874400",
+"Q# c #A47B55",
+"R# c #E3EBF8",
+"S# c #E1E9F8",
+"T# c #AA5F0A",
+"U# c #E69F32",
+"V# c #FFBC41",
+"W# c #FFB237",
+"X# c #FFAE32",
+"Y# c #FFAA2C",
+"Z# c #FFA726",
+"`# c #FFA421",
+" $ c #FFA11B",
+".$ c #FF9D15",
+"+$ c #FF9D0F",
+"@$ c #F88E07",
+"#$ c #F48105",
+"$$ c #F38005",
+"%$ c #F68A02",
+"&$ c #B96400",
+"*$ c #D2C9C6",
+"=$ c #E4ECF9",
+"-$ c #E0E9FB",
+";$ c #954A00",
+">$ c #BA6E13",
+",$ c #FEB036",
+"'$ c #FFAF31",
+")$ c #FFAA2B",
+"!$ c #FFA625",
+"~$ c #FFA31F",
+"{$ c #FFA01A",
+"]$ c #FF9D14",
+"^$ c #FF990E",
+"/$ c #FF9607",
+"($ c #FF9404",
+"_$ c #FF9402",
+":$ c #FF9802",
+"<$ c #EA8501",
+"[$ c #8C4600",
+"}$ c #A0744C",
+"|$ c #E6ECF7",
+"1$ c #E3EAF9",
+"2$ c #9A5309",
+"3$ c #D1821A",
+"4$ c #FFB22C",
+"5$ c #FFA723",
+"6$ c #FFA21D",
+"7$ c #FF9F17",
+"8$ c #FF9C12",
+"9$ c #FF980C",
+"0$ c #FF9506",
+"a$ c #FF9202",
+"b$ c #FF9602",
+"c$ c #ED8701",
+"d$ c #934B00",
+"e$ c #884C12",
+"f$ c #DCD9DA",
+"g$ c #E7EEFA",
+"h$ c #E3EAF8",
+"i$ c #AD9480",
+"j$ c #974F03",
+"k$ c #C67610",
+"l$ c #FDA01A",
+"m$ c #FFA316",
+"n$ c #FF9D10",
+"o$ c #FF990A",
+"p$ c #FF9505",
+"q$ c #FF9302",
+"r$ c #FF9502",
+"s$ c #FF9601",
+"t$ c #D77901",
+"u$ c #904900",
+"v$ c #803F00",
+"w$ c #C9B9AD",
+"x$ c #E8EFFA",
+"y$ c #C2CADB",
+"z$ c #C6A583",
+"A$ c #8D4803",
+"B$ c #924B02",
+"C$ c #B06005",
+"D$ c #CA7205",
+"E$ c #DE7E02",
+"F$ c #E78301",
+"G$ c #E38001",
+"H$ c #CB7000",
+"I$ c #994F00",
+"J$ c #854100",
+"K$ c #8E551E",
+"L$ c #D9D2CF",
+"M$ c #E9EFFA",
+"N$ c #E9F0FC",
+"O$ c #E1E8F7",
+"P$ c #E0EAFC",
+"Q$ c #FBFDFC",
+"R$ c #F0E6DD",
+"S$ c #C3A07E",
+"T$ c #A2703E",
+"U$ c #8A490B",
+"V$ c #834000",
+"W$ c #834100",
+"X$ c #945F2C",
+"Y$ c #C9B5A3",
+"Z$ c #EBEDF3",
+"`$ c #EDF2FD",
+" % c #F4FDFF",
+".% c #F9FEFF",
+"+% c #F7FCFF",
+"@% c #F4F9FF",
+"#% c #F2F8FF",
+" ",
+" . . . . . . . . . . . . . . . + ",
+" . @ # # # # # # # # $ % & * = - ; ",
+" . > # # # # # # # # , ' ) ! ~ { ] ^ ",
+" . > # # # # # # # # @ % / ( _ : < [ } ",
+" . > # # # # # # # # $ | 1 2 3 4 # 5 6 7 ",
+" . > # # # # # # # # # 8 9 0 a b # c d e f ",
+" g h i j k l m n o p # > q & r s t u v w x y ",
+" z A B C D E F G H I J K L M < N O P P P P P P P ",
+" Q R S T U V W X Y Z ` ...+.@.#.$.%.&.! *.=.-.;.>.,.",
+" '.).!.~.# {.].^./.(._.:.# # <.[.}.|.1.2.&.a 3.4.5.6.7.,.",
+" 8.9.0.# a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.,.",
+" '.y.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.,.",
+" Q `. +.+++@+#+$+%+&+*+=+-+;+>+,+'+)+!+~+{+]+^+/+(+_+:+V.<+[+,.",
+"}+|+1+2+ 3+4+5+6+7+8+9+0+a+b+c+d+e+f+g+h+i+j+~ k+_+_+l+,.",
+"m+n+o+p+ q+r+s+t+u+v+w+x+y+z+A+B+C+D+E+F+G+H+I+J+K+L+M+N+,.",
+"O+P+Q+R+S+T+U+V+W+X+Y+Z+`+ @.@+@@@#@$@%@&@*@=@-@;@>@,@'@= )@!@,.",
+"~@{@]@^@/@(@_@:@<@[@}@|@1@2@3@4@5@6@7@8@9@0@a@b@c@d@e@f@3 g@h@,.",
+"i@j@k@l@m@n@o@p@q@r@s@t@u@v@w@x@y@z@A@B@C@D@E@F@G@H@I@J@K@f@L@,.",
+" M@N@O@P@Q@R@S@T@U@V@W@X@Y@Z@`@ #.#+#@###$#%#&#*#=#-#;#>#a ,#,.",
+" '#)#!#~#{#]#V@W@^#/#(#_#:#<#[#}#|#1#2#3#4#5#6#7#8#9#0#a#,.",
+" b#c#d#e#f#g#h#i#j#k#l#m#n#o#p#q#r#s#t#u#v#w#r 9#J@x#,.",
+" y#z#A#B#C#D#E#F#G#H#I#J#K#L#M#N#O#P#Q#( R#;#S#x#,.",
+" T#U#V#W#X#Y#Z#`# $.$+$@$#$$$%$&$6#*$( =$! ;#-$,.",
+" ;$>$,$'$)$!$~${$]$^$/$($_$:$<$[$}$|$( 1$! ;#-$,.",
+" 2$3$4$5$6$7$8$9$0$a$a$b$c$d$e$f$g$( h$;#;#x#,.",
+" i$j$k$l$m$n$o$p$q$r$s$t$u$v$w$x$g$( R#;#! -$,.",
+" y$z$A$B$C$D$E$F$G$H$I$J$K$L$M$N$( =$;#;#O$P$,.",
+" . Q$R$S$T$U$V$W$V$V$X$Y$Z$`$) N$( =$;#;#O$P$,.",
+" . %# # .%.%, +%@%@%#%1 < & ) N$( =$;#;#O$P$,.",
+" . ,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.",
+" "};
+
+#endif
diff --git a/src/ksquirrelpart/sq_imagebcg.ui b/src/ksquirrelpart/sq_imagebcg.ui
new file mode 100644
index 0000000..c3466d5
--- /dev/null
+++ b/src/ksquirrelpart/sq_imagebcg.ui
@@ -0,0 +1,989 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_ImageBCG</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_ImageBCG</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>564</width>
+ <height>391</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Color balance</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQWidgetStack" row="1" column="0" rowspan="3" colspan="1">
+ <property name="name">
+ <cstring>widgetStackParams</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <widget class="TQSpinBox" row="2" column="0">
+ <property name="name">
+ <cstring>spinB</cstring>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="2">
+ <property name="name">
+ <cstring>pushResetG</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>pushResetC</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="KDoubleSpinBox" row="2" column="2">
+ <property name="name">
+ <cstring>spinG</cstring>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="2" column="1">
+ <property name="name">
+ <cstring>spinC</cstring>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushResetB</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_Label">
+ <property name="name">
+ <cstring>sQ_LabelB</cstring>
+ </property>
+ </widget>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>sliderB</cstring>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>Above</enum>
+ </property>
+ <property name="tickInterval">
+ <number>25</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Brightness</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="1">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_Label">
+ <property name="name">
+ <cstring>sQ_LabelC</cstring>
+ </property>
+ </widget>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>sliderC</cstring>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>Above</enum>
+ </property>
+ <property name="tickInterval">
+ <number>25</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Contrast</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="2">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_Label">
+ <property name="name">
+ <cstring>sQ_LabelG</cstring>
+ </property>
+ </widget>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>sliderG</cstring>
+ </property>
+ <property name="minValue">
+ <number>0</number>
+ </property>
+ <property name="maxValue">
+ <number>600</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>Above</enum>
+ </property>
+ <property name="tickInterval">
+ <number>22</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Gamma</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushResetRed</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="2" column="0">
+ <property name="name">
+ <cstring>spinRed</cstring>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="2" column="1">
+ <property name="name">
+ <cstring>spinGreen</cstring>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>pushResetGreen</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="2">
+ <property name="name">
+ <cstring>pushResetBlue</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="2" column="2">
+ <property name="name">
+ <cstring>spinBlue</cstring>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="2">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_Label">
+ <property name="name">
+ <cstring>sQ_LabelBlue</cstring>
+ </property>
+ </widget>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>sliderBlue</cstring>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="tickmarks">
+ <enum>Above</enum>
+ </property>
+ <property name="tickInterval">
+ <number>25</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Blue</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="1">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_Label">
+ <property name="name">
+ <cstring>sQ_LabelGreen</cstring>
+ </property>
+ </widget>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>sliderGreen</cstring>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="tickmarks">
+ <enum>Above</enum>
+ </property>
+ <property name="tickInterval">
+ <number>25</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Green</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_Label">
+ <property name="name">
+ <cstring>sQ_LabelRed</cstring>
+ </property>
+ </widget>
+ <widget class="TQSlider">
+ <property name="name">
+ <cstring>sliderRed</cstring>
+ </property>
+ <property name="minValue">
+ <number>-255</number>
+ </property>
+ <property name="maxValue">
+ <number>255</number>
+ </property>
+ <property name="tickmarks">
+ <enum>Above</enum>
+ </property>
+ <property name="tickInterval">
+ <number>25</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Red</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ <widget class="TQGroupBox" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>6</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="4">
+ <property name="name">
+ <cstring>push2</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>push1</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer row="0" column="1">
+ <property name="name">
+ <cstring>spacer26</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="0" column="3">
+ <property name="name">
+ <cstring>spacer27</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="0" column="2">
+ <property name="name">
+ <cstring>text</cstring>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignCenter</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="3" column="1">
+ <property name="name">
+ <cstring>spacer12_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLayoutWidget" row="5" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>249</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushGO</cstring>
+ </property>
+ <property name="text">
+ <string>Colorize</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushCancel</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="Line" row="4" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>line2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <spacer row="1" column="1">
+ <property name="name">
+ <cstring>spacer11</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLayoutWidget" row="2" column="1">
+ <property name="name">
+ <cstring>layout15</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer13</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Original image:</string>
+ </property>
+ </widget>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer35</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="SQ_BCGLabel" row="1" column="3">
+ <property name="name">
+ <cstring>pixmap1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>160</width>
+ <height>160</height>
+ </size>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="3" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Image after colorizing:</string>
+ </property>
+ </widget>
+ <spacer row="1" column="4">
+ <property name="name">
+ <cstring>spacer34</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="SQ_BCGLabel" row="1" column="1">
+ <property name="name">
+ <cstring>pixmap</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>160</width>
+ <height>160</height>
+ </size>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>SQ_BCGLabel</class>
+ <header location="local">sq_bcglabel.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+ <customwidget>
+ <class>SQ_Label</class>
+ <header location="local">sq_label.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="PNG" length="1002">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154388dad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a190172af6a9690000000049454e44ae426082</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>spinRed</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotRedChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>spinGreen</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotGreenChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>spinG</sender>
+ <signal>valueChanged(double)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotGSpinChanged(double)</slot>
+ </connection>
+ <connection>
+ <sender>spinC</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotCChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>spinBlue</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotBlueChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>spinB</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotBChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>sliderRed</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotRedChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>sliderGreen</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotGreenChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>sliderG</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotGChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>sliderC</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotCChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>sliderBlue</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotBlueChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>sliderB</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotBChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>pushResetRed</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotResetRed()</slot>
+ </connection>
+ <connection>
+ <sender>pushResetGreen</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotResetGreen()</slot>
+ </connection>
+ <connection>
+ <sender>pushResetG</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotResetG()</slot>
+ </connection>
+ <connection>
+ <sender>pushResetC</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotResetC()</slot>
+ </connection>
+ <connection>
+ <sender>pushResetBlue</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotResetBlue()</slot>
+ </connection>
+ <connection>
+ <sender>pushResetB</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotResetB()</slot>
+ </connection>
+ <connection>
+ <sender>pushGO</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotStartBCG()</slot>
+ </connection>
+ <connection>
+ <sender>push2</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotPush()</slot>
+ </connection>
+ <connection>
+ <sender>push1</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>slotPush()</slot>
+ </connection>
+ <connection>
+ <sender>pushCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageBCG</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>push1</tabstop>
+ <tabstop>push2</tabstop>
+ <tabstop>pushResetRed</tabstop>
+ <tabstop>pushResetGreen</tabstop>
+ <tabstop>pushResetBlue</tabstop>
+ <tabstop>sliderRed</tabstop>
+ <tabstop>sliderGreen</tabstop>
+ <tabstop>sliderBlue</tabstop>
+ <tabstop>spinRed</tabstop>
+ <tabstop>spinGreen</tabstop>
+ <tabstop>spinBlue</tabstop>
+ <tabstop>pushGO</tabstop>
+ <tabstop>pushCancel</tabstop>
+ <tabstop>pushResetB</tabstop>
+ <tabstop>pushResetC</tabstop>
+ <tabstop>pushResetG</tabstop>
+ <tabstop>sliderB</tabstop>
+ <tabstop>sliderC</tabstop>
+ <tabstop>sliderG</tabstop>
+ <tabstop>spinB</tabstop>
+ <tabstop>spinC</tabstop>
+ <tabstop>spinG</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in declaration">sq_imageedit.h</include>
+ <include location="global" impldecl="in declaration">tqimage.h</include>
+ <include location="global" impldecl="in declaration">tqstringlist.h</include>
+ <include location="local" impldecl="in implementation">fmt_filters.h</include>
+ <include location="global" impldecl="in implementation">knuminput.h</include>
+ <include location="global" impldecl="in implementation">ksquirrel-libs/fmt_defs.h</include>
+ <include location="global" impldecl="in implementation">ksquirrel-libs/fmt_types.h</include>
+ <include location="global" impldecl="in implementation">kstandarddirs.h</include>
+ <include location="global" impldecl="in implementation">sq_bcglabel.h</include>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="local" impldecl="in implementation">sq_imagebcg.ui.h</include>
+ <include location="global" impldecl="in implementation">sq_label.h</include>
+</includes>
+<variables>
+ <variable access="private">int id;</variable>
+ <variable access="private">TQImage sample, sample_saved;</variable>
+ <variable access="private">TQStringList strings;</variable>
+ <variable access="private">static SQ_ImageBCG *m_inst;</variable>
+</variables>
+<signals>
+ <signal>bcg(SQ_ImageBCGOptions*)</signal>
+</signals>
+<slots>
+ <slot access="private" specifier="non virtual">slotResetG()</slot>
+ <slot access="private" specifier="non virtual">slotResetC()</slot>
+ <slot access="private" specifier="non virtual">slotResetB()</slot>
+ <slot access="private" specifier="non virtual">slotResetRed()</slot>
+ <slot access="private" specifier="non virtual">slotResetGreen()</slot>
+ <slot access="private" specifier="non virtual">slotResetBlue()</slot>
+ <slot access="private" specifier="non virtual">slotStartBCG()</slot>
+ <slot access="private" specifier="non virtual">slotBChanged( int v )</slot>
+ <slot access="private" specifier="non virtual">slotCChanged( int v )</slot>
+ <slot access="private" specifier="non virtual">slotRedChanged( int v )</slot>
+ <slot access="private" specifier="non virtual">slotGreenChanged( int v )</slot>
+ <slot access="private" specifier="non virtual">slotBlueChanged( int v )</slot>
+ <slot access="private" specifier="non virtual">slotGChanged( int v )</slot>
+ <slot access="private" specifier="non virtual">slotGSpinChanged( double v )</slot>
+ <slot access="private" specifier="non virtual">slotPush()</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function access="private" specifier="non virtual" returnType="int">RGB2Y( int r, int g, int b )</function>
+ <function access="private" specifier="non virtual">assignNewImage( const TQImage &amp; im )</function>
+ <function access="private" specifier="non virtual">changeImage( int b, int c, int g1, int red, int green, int blue )</function>
+ <function specifier="non virtual">setPreviewImage( const TQImage &amp; im )</function>
+ <function specifier="static" returnType="SQ_ImageBCG *">instance()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/ksquirrelpart/sq_imagebcg.ui.h b/src/ksquirrelpart/sq_imagebcg.ui.h
new file mode 100644
index 0000000..31c3516
--- /dev/null
+++ b/src/ksquirrelpart/sq_imagebcg.ui.h
@@ -0,0 +1,241 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+SQ_ImageBCG * SQ_ImageBCG::m_inst = 0;
+
+void SQ_ImageBCG::init()
+{
+ m_inst = this;
+
+ TQPixmap p = TQPixmap::fromMimeSource(locate("data", "images/imageedit/reset_value.png"));
+
+ sQ_LabelB->setSingle(true);
+ sQ_LabelC->setSingle(true);
+ sQ_LabelG->setSingle(true);
+ sQ_LabelB->setText(tr2i18n("Brightness"));
+ sQ_LabelC->setText(tr2i18n("Contrast"));
+ sQ_LabelG->setText(tr2i18n("Gamma"));
+ sQ_LabelRed->setText(tr2i18n("Red"), tr2i18n("Cyan"));
+ sQ_LabelGreen->setText(tr2i18n("Green"), tr2i18n("Magenta"));
+ sQ_LabelBlue->setText(tr2i18n("Blue"), tr2i18n("Yellow"));
+
+ pushResetB->setPixmap(p);
+ pushResetC->setPixmap(p);
+ pushResetG->setPixmap(p);
+ pushResetRed->setPixmap(p);
+ pushResetGreen->setPixmap(p);
+ pushResetBlue->setPixmap(p);
+
+ strings.append(TQString("<b>") + tr2i18n("Brightness") + ",&nbsp;" + tr2i18n("Contrast") + ",&nbsp;" + tr2i18n("Gamma") + "</b>");
+ strings.append(TQString("<b>") + tr2i18n("Red") + ",&nbsp;" + tr2i18n("Green") + ",&nbsp;" + tr2i18n("Blue") + "</b>");
+
+ id = 0;
+ widgetStackParams->raiseWidget(id);
+ text->setText(strings[id]);
+
+ TQPixmap tool1 = TQPixmap::fromMimeSource(locate("data", "images/imageedit/resize_toolbutton.png"));
+ TQPixmap tool2 = TQPixmap::fromMimeSource(locate("data", "images/imageedit/resize_toolbutton2.png"));
+ push1->setPixmap(tool1);
+ push2->setPixmap(tool2);
+
+ spinG->setRange(0, 6.0, 0.01, 2);
+ spinG->setValue(1.0);
+ connect(spinG, TQ_SIGNAL(valueChanged(int)), spinG, TQ_SLOT(slotValueChanged(int)));
+}
+
+void SQ_ImageBCG::slotResetG()
+{
+ sliderG->setValue(100);
+}
+
+void SQ_ImageBCG::slotResetC()
+{
+ sliderC->setValue(0);
+}
+
+void SQ_ImageBCG::slotResetB()
+{
+ sliderB->setValue(0);
+}
+
+void SQ_ImageBCG::slotResetRed()
+{
+ sliderRed->setValue(0);
+}
+
+void SQ_ImageBCG::slotResetGreen()
+{
+ sliderGreen->setValue(0);
+}
+
+void SQ_ImageBCG::slotResetBlue()
+{
+ sliderBlue->setValue(0);
+}
+
+void SQ_ImageBCG::slotStartBCG()
+{
+ SQ_ImageBCGOptions opt;
+ opt.b = sliderB->value();
+ opt.c = sliderC->value();
+ opt.g = sliderG->value();
+ opt.red = sliderRed->value();
+ opt.green = sliderGreen->value();
+ opt.blue = sliderBlue->value();
+
+ emit bcg(&opt);
+}
+
+int SQ_ImageBCG::RGB2Y(int r, int g, int b)
+{
+ return (int)((double)r * 0.299 + (double)g * 0.587 + (double)b * 0.114);
+}
+
+void SQ_ImageBCG::slotBChanged(int v)
+{
+ spinB->blockSignals(true);
+ sliderB->blockSignals(true);
+ spinB->setValue(v);
+ sliderB->setValue(v);
+ spinB->blockSignals(false);
+ sliderB->blockSignals(false);
+
+ changeImage(v, sliderC->value(), sliderG->value(), sliderRed->value(), sliderGreen->value(), sliderBlue->value());
+}
+
+void SQ_ImageBCG::slotCChanged(int v)
+{
+ spinC->blockSignals(true);
+ sliderC->blockSignals(true);
+ spinC->setValue(v);
+ sliderC->setValue(v);
+ spinC->blockSignals(false);
+ sliderC->blockSignals(false);
+
+ changeImage(sliderB->value(), v, sliderG->value(), sliderRed->value(), sliderGreen->value(), sliderBlue->value());
+}
+
+void SQ_ImageBCG::slotRedChanged(int v)
+{
+ spinRed->blockSignals(true);
+ sliderRed->blockSignals(true);
+ spinRed->setValue(v);
+ sliderRed->setValue(v);
+ spinRed->blockSignals(false);
+ sliderRed->blockSignals(false);
+
+ changeImage(sliderB->value(), sliderC->value(), sliderG->value(), v, sliderGreen->value(), sliderBlue->value());
+}
+
+void SQ_ImageBCG::slotGreenChanged(int v)
+{
+ spinGreen->blockSignals(true);
+ sliderGreen->blockSignals(true);
+ spinGreen->setValue(v);
+ sliderGreen->setValue(v);
+ spinGreen->blockSignals(false);
+ sliderGreen->blockSignals(false);
+
+ changeImage(sliderB->value(), sliderC->value(), sliderG->value(), sliderRed->value(), v, sliderBlue->value());
+}
+
+void SQ_ImageBCG::slotBlueChanged(int v)
+{
+ spinBlue->blockSignals(true);
+ sliderBlue->blockSignals(true);
+ spinBlue->setValue(v);
+ sliderBlue->setValue(v);
+ spinBlue->blockSignals(false);
+ sliderBlue->blockSignals(false);
+
+ changeImage(sliderB->value(), sliderC->value(), sliderG->value(), sliderRed->value(), sliderGreen->value(), v);
+}
+
+void SQ_ImageBCG::slotGChanged(int v)
+{
+ double g = (double)v / 100.0;
+ spinG->blockSignals(true);
+ spinG->setValue(g);
+ spinG->blockSignals(false);
+
+ changeImage(sliderB->value(), sliderC->value(), v, sliderRed->value(), sliderGreen->value(), sliderBlue->value());
+}
+
+void SQ_ImageBCG::slotGSpinChanged(double v)
+{
+ int val = (int)(v * 100.0);
+ sliderG->blockSignals(true);
+ sliderG->setValue(val);
+ sliderG->blockSignals(false);
+
+ changeImage(sliderB->value(), sliderC->value(), val, sliderRed->value(), sliderGreen->value(), sliderBlue->value());
+}
+
+void SQ_ImageBCG::assignNewImage(const TQImage &im)
+{
+ TQPixmap p;
+ p.convertFromImage(im);
+ pixmap1->setPixmap(p);
+}
+
+void SQ_ImageBCG::changeImage(int b, int c, int g1, int red, int green, int blue)
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ double g = (double)g1 / 100.0;
+
+ sample = sample_saved.copy();
+
+ // change brightness
+ fmt_filters::brightness(fmt_filters::image(sample.bits(), sample.width(), sample.height()), b);
+
+ //change contrast
+ if(c)
+ fmt_filters::contrast(fmt_filters::image(sample.bits(), sample.width(), sample.height()), c);
+
+ // change gamma
+ if(g1 != 100)
+ fmt_filters::gamma(fmt_filters::image(sample.bits(), sample.width(), sample.height()), g);
+
+ if(red || green || blue)
+ fmt_filters::colorize(fmt_filters::image(sample.bits(), sample.width(), sample.height()), blue, green, red);
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageBCG::slotPush()
+{
+ if(!id) id = 1;
+ else id = 0;
+
+ widgetStackParams->raiseWidget(id);
+ text->setText(strings[id]);
+}
+
+void SQ_ImageBCG::setPreviewImage(const TQImage &im)
+{
+ if(im.isNull()) return;
+
+ sample = im.copy();
+ sample_saved = sample.copy();
+
+ TQPixmap p;
+
+ p.convertFromImage(sample_saved);
+ pixmap->setPixmap(p);
+ pixmap1->setPixmap(p);
+
+ changeImage(sliderB->value(), sliderC->value(), sliderG->value(), sliderRed->value(), sliderGreen->value(), sliderBlue->value());
+}
+
+SQ_ImageBCG* SQ_ImageBCG::instance()
+{
+ return m_inst;
+}
diff --git a/src/ksquirrelpart/sq_imageedit.h b/src/ksquirrelpart/sq_imageedit.h
new file mode 100644
index 0000000..a93e26b
--- /dev/null
+++ b/src/ksquirrelpart/sq_imageedit.h
@@ -0,0 +1,84 @@
+/***************************************************************************
+ sq_imageedit.h - description
+ -------------------
+ begin : ��� ��� 29 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_IMAGEEDIT_H
+#define SQ_IMAGEEDIT_H
+
+#include <tqfont.h>
+#include <tqcolor.h>
+
+#include "fmt_filters.h"
+
+struct SQ_ImageOptions
+{
+ TQString putto;
+ int where_to_put;
+ bool close;
+};
+
+struct SQ_ImageBCGOptions
+{
+ int b, c, g;
+ int red, green, blue;
+};
+
+struct SQ_ImageConvertOptions
+{
+ TQString libname;
+};
+
+struct SQ_ImageFilterOptions
+{
+ int type;
+
+ bool _bool;
+ fmt_filters::rgb rgb1, rgb2;
+ float _float;
+ unsigned int _uint;
+ double _double1, _double2;
+};
+
+namespace F
+{
+ enum ftype
+ {
+ fblend = 0,
+ fblur,
+ fdesaturate,
+ fdespeckle,
+ fedge,
+ femboss,
+ fequalize,
+ ffade,
+ fflatten,
+ fimplode,
+ fnegative,
+ fnoise,
+ foil,
+ fshade,
+ fsharpen,
+ fsolarize,
+ fspread,
+ fswapRGB,
+ fswirl,
+ fthreshold,
+ fgray,
+ fredeye
+ };
+}
+
+#endif
diff --git a/src/ksquirrelpart/sq_imagefilter.ui b/src/ksquirrelpart/sq_imagefilter.ui
new file mode 100644
index 0000000..0e50f97
--- /dev/null
+++ b/src/ksquirrelpart/sq_imagefilter.ui
@@ -0,0 +1,1559 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_ImageFilter</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_ImageFilter</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>537</width>
+ <height>421</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Filter</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQWidgetStack" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>widgetStackFilters</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>blendWidget</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Color:</string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="1">
+ <property name="name">
+ <cstring>pushBlendColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer row="2" column="1">
+ <property name="name">
+ <cstring>spacer17</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>blendOpacity</cstring>
+ </property>
+ <property name="label">
+ <string>Opacity</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer9_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="1" column="0">
+ <property name="name">
+ <cstring>blurSigma</cstring>
+ </property>
+ <property name="label">
+ <string>Sigma</string>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>blurRadius</cstring>
+ </property>
+ <property name="label">
+ <string>Radius</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>2</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer10_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>45</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>desaturateValue</cstring>
+ </property>
+ <property name="label">
+ <string>Factor</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>3</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <property name="text">
+ <string>There are no special options available for this filter. Just click "Filter".</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer11</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>11</width>
+ <height>26</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>4</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer12</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>30</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KIntNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>edgeRadius</cstring>
+ </property>
+ <property name="label">
+ <string>Radius</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>5</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer13</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>30</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="1" column="0">
+ <property name="name">
+ <cstring>embossSigma</cstring>
+ </property>
+ <property name="label">
+ <string>Sigma</string>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>embossRadius</cstring>
+ </property>
+ <property name="label">
+ <string>Radius</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>6</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <property name="text">
+ <string>There are no special options available for this filter. Just click "Filter".</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer11_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>11</width>
+ <height>14</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>7</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KColorButton" row="0" column="1">
+ <property name="name">
+ <cstring>fadeColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer row="2" column="1">
+ <property name="name">
+ <cstring>spacer15</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_4</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Color:</string>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>fadeValue</cstring>
+ </property>
+ <property name="label">
+ <string>Value</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>8</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KColorButton" row="0" column="1">
+ <property name="name">
+ <cstring>flattenColor1</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer row="2" column="1">
+ <property name="name">
+ <cstring>spacer16</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>10</width>
+ <height>11</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KColorButton" row="1" column="1">
+ <property name="name">
+ <cstring>flattenColor2</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_4_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Color 1:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel1_4_3</cstring>
+ </property>
+ <property name="text">
+ <string>Color 2:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>9</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer15_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>25</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>implodeFactor</cstring>
+ </property>
+ <property name="label">
+ <string>Factor</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>10</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer11_2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>11</width>
+ <height>14</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2_2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <property name="text">
+ <string>There are no special options available for this filter. Just click "Filter".</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>11</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>buttonGroupNoise</cstring>
+ </property>
+ <property name="title">
+ <string>Noise type</string>
+ </property>
+ <property name="exclusive">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>2</number>
+ </property>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioButton1</cstring>
+ </property>
+ <property name="text">
+ <string>Uniform</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="0" column="1">
+ <property name="name">
+ <cstring>radioButton1_4</cstring>
+ </property>
+ <property name="text">
+ <string>Impulse</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>3</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>radioButton1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Multiplicative Gaussian</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="2" column="1">
+ <property name="name">
+ <cstring>radioButton1_6</cstring>
+ </property>
+ <property name="text">
+ <string>Poisson</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>5</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioButton1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Gaussian</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>1</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="1">
+ <property name="name">
+ <cstring>radioButton1_5</cstring>
+ </property>
+ <property name="text">
+ <string>Laplacian</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>4</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>12</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer15_2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>35</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KIntNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>oilRadius</cstring>
+ </property>
+ <property name="label">
+ <string>Radius</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>13</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>shadeColor</cstring>
+ </property>
+ <property name="text">
+ <string>Color</string>
+ </property>
+ </widget>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer21</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="2" column="0">
+ <property name="name">
+ <cstring>shadeElev</cstring>
+ </property>
+ <property name="label">
+ <string>Elevation</string>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput" row="1" column="0">
+ <property name="name">
+ <cstring>shadeAzim</cstring>
+ </property>
+ <property name="label">
+ <string>Azimuth</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>14</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer13_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="1" column="0">
+ <property name="name">
+ <cstring>sharpenSigma</cstring>
+ </property>
+ <property name="label">
+ <string>Sigma</string>
+ </property>
+ </widget>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>sharpenRadius</cstring>
+ </property>
+ <property name="label">
+ <string>Radius</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>15</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer13_2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>60</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>solarizeValue</cstring>
+ </property>
+ <property name="label">
+ <string>Factor</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>16</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer24</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>35</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KIntNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>spreadValue</cstring>
+ </property>
+ <property name="label">
+ <string>Amount</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>17</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>buttonGroupSwapRGB</cstring>
+ </property>
+ <property name="title">
+ <string>Type</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>2</number>
+ </property>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioButton7</cstring>
+ </property>
+ <property name="text">
+ <string>GBR</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioButton8</cstring>
+ </property>
+ <property name="text">
+ <string>BRG</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer25</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>11</width>
+ <height>41</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>18</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer13_2_2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>25</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KDoubleNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>swirlAngle</cstring>
+ </property>
+ <property name="label">
+ <string>Degrees</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>19</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer24_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>75</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KIntNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>thresholdValue</cstring>
+ </property>
+ <property name="label">
+ <string>Threshold</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>20</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2_2_2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <property name="text">
+ <string>There are no special options available for this filter. Just click "Filter".</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer11_2_2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>11</width>
+ <height>113</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>21</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KIntNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>thresholdRE</cstring>
+ </property>
+ <property name="label">
+ <string>Threshold</string>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer26_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>71</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ </widget>
+ <spacer row="1" column="1">
+ <property name="name">
+ <cstring>spacer27</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLayoutWidget" row="5" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer14</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>285</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushFilter</cstring>
+ </property>
+ <property name="text">
+ <string>Filter</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushCancel</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="Line" row="4" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>line7</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQListBox" row="0" column="0" rowspan="4" colspan="1">
+ <item>
+ <property name="text">
+ <string>Blend</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Blur</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Desaturate</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Despeckle</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Edge</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Emboss</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Equalize</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Fade</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Flatten</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Implode</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Negative</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Noise</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Oil</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Shade</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Sharpen</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Solarize</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Spread</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Swap colors</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Swirl</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Threshold</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Grayscale</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Redeye</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>listMain</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>140</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ <spacer row="3" column="2">
+ <property name="name">
+ <cstring>spacer26</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLayoutWidget" row="2" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_BCGLabel" row="1" column="3">
+ <property name="name">
+ <cstring>pixmap1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>160</width>
+ <height>160</height>
+ </size>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Original image:</string>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer27_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer28</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="SQ_BCGLabel" row="1" column="1">
+ <property name="name">
+ <cstring>pixmap</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>160</width>
+ <height>160</height>
+ </size>
+ </property>
+ </widget>
+ <spacer row="1" column="4">
+ <property name="name">
+ <cstring>spacer27_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>1</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="0" column="3" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Image after filtering:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>SQ_BCGLabel</class>
+ <header location="local">sq_bcglabel.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="PNG" length="1002">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154388dad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a190172af6a9690000000049454e44ae426082</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>pushCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageFilter</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>pushFilter</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageFilter</receiver>
+ <slot>slotStartFiltering()</slot>
+ </connection>
+ <connection>
+ <sender>listMain</sender>
+ <signal>selectionChanged()</signal>
+ <receiver>SQ_ImageFilter</receiver>
+ <slot>slotShowPage()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>pushFilter</tabstop>
+ <tabstop>pushCancel</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in declaration">sq_imageedit.h</include>
+ <include location="global" impldecl="in declaration">tqimage.h</include>
+ <include location="local" impldecl="in implementation">fmt_filters.h</include>
+ <include location="global" impldecl="in implementation">kcolorbutton.h</include>
+ <include location="global" impldecl="in implementation">knuminput.h</include>
+ <include location="global" impldecl="in implementation">sq_bcglabel.h</include>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="local" impldecl="in implementation">sq_imagefilter.ui.h</include>
+</includes>
+<variables>
+ <variable access="private">TQImage sample, sample_saved;</variable>
+ <variable access="private">static SQ_ImageFilter *m_inst;</variable>
+</variables>
+<signals>
+ <signal>filter(SQ_ImageFilterOptions*)</signal>
+</signals>
+<slots>
+ <slot access="private" specifier="non virtual">slotStartFiltering()</slot>
+ <slot access="private" specifier="non virtual">slotShowPage()</slot>
+ <slot access="private" specifier="non virtual">swapRGB()</slot>
+ <slot access="private" specifier="non virtual">blend()</slot>
+ <slot access="private" specifier="non virtual">fade()</slot>
+ <slot access="private" specifier="non virtual">desaturate()</slot>
+ <slot access="private" specifier="non virtual">threshold()</slot>
+ <slot access="private" specifier="non virtual">solarize()</slot>
+ <slot access="private" specifier="non virtual">spread()</slot>
+ <slot access="private" specifier="non virtual">swirl()</slot>
+ <slot access="private" specifier="non virtual">noise()</slot>
+ <slot access="private" specifier="non virtual">redeye()</slot>
+ <slot access="private" specifier="non virtual">flatten()</slot>
+ <slot access="private" specifier="non virtual">shade()</slot>
+ <slot access="private" specifier="non virtual">blur()</slot>
+ <slot access="private" specifier="non virtual">implode()</slot>
+ <slot access="private" specifier="non virtual">edge()</slot>
+ <slot access="private" specifier="non virtual">emboss()</slot>
+ <slot access="private" specifier="non virtual">sharpen()</slot>
+ <slot access="private" specifier="non virtual">oil()</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function specifier="non virtual">setPreviewImage( const TQImage &amp; im )</function>
+ <function access="private" specifier="non virtual">assignNewImage( const TQImage &amp; im )</function>
+ <function access="private" specifier="non virtual">negative()</function>
+ <function access="private" specifier="non virtual">togray()</function>
+ <function access="private" specifier="non virtual">equalize()</function>
+ <function access="private" specifier="non virtual">despeckle()</function>
+ <function access="private" specifier="non virtual">hackConnect()</function>
+ <function specifier="static" returnType="SQ_ImageFilter *">instance()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/ksquirrelpart/sq_imagefilter.ui.h b/src/ksquirrelpart/sq_imagefilter.ui.h
new file mode 100644
index 0000000..18eb263
--- /dev/null
+++ b/src/ksquirrelpart/sq_imagefilter.ui.h
@@ -0,0 +1,610 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+SQ_ImageFilter * SQ_ImageFilter::m_inst = 0;
+
+void SQ_ImageFilter::init()
+{
+ m_inst = this;
+
+ // restore NumInputs...
+ const double sigmaMax = 99.9, sigmaMin = 0.01;
+ const double radiusMax = 99.9, radiusMin = 0.01;
+
+ blendOpacity->setRange(0.0f, 1.0f, 0.01, true);
+ fadeValue->setRange(0.0f, 1.0f, 0.01f, true);
+ desaturateValue->setRange(0.0f, 1.0f, 0.01, true);
+ thresholdValue->setRange(0, 255, 1, true);
+ thresholdRE->setRange(0, 255, 1, true);
+ solarizeValue->setRange(0.0f, 50.0f, 0.01f, true);
+ spreadValue->setRange(1, 10, 1, true);
+ swirlAngle->setRange(-720.0f, 720.0f, 0.1f, true);
+ shadeAzim->setRange(0.0f, 90.0f, 0.01f, true);
+ shadeElev->setRange(0.0f, 90.0f, 0.01f, true);
+ blurRadius->setRange(radiusMin, radiusMax, 0.01f, true);
+ blurSigma->setRange(sigmaMin, 50.0, 0.01f, true);
+ implodeFactor->setRange(0, 100, 1, true);
+ edgeRadius->setRange((int)radiusMin, 30, 1, true);
+ embossRadius->setRange(radiusMin, radiusMax, 0.01f, true);
+ embossSigma->setRange(sigmaMin, sigmaMax, 0.01f, true);
+ sharpenRadius->setRange(radiusMin, radiusMax, 0.01f, true);
+ sharpenSigma->setRange(sigmaMin, 30.0, 0.01f, true);
+ oilRadius->setRange(1, 5, 1, true);
+
+ SQ_Config::instance()->setGroup("Image edit options");
+
+ buttonGroupSwapRGB->setButton(SQ_Config::instance()->readNumEntry("filter_swapRGB", 0));
+ // blend
+ TQColor c;
+ c.setNamedColor(SQ_Config::instance()->readEntry("filter_blend_color", "#00ff00"));
+ pushBlendColor->setColor(c);
+ blendOpacity->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_blend_opacity", 0.5));
+
+ // fade
+ c.setNamedColor(SQ_Config::instance()->readEntry("filter_flend_color", "#00ff00"));
+ fadeColor->setColor(c);
+ fadeValue->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_fade_value", 0.5));
+
+ // desaturate
+ desaturateValue->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_desaturate_value", 0.5));
+
+ // threshold
+ thresholdValue->setValue(SQ_Config::instance()->readNumEntry("filter_threshold_value", 1));
+
+ // threshold for redeye
+ thresholdRE->setValue(SQ_Config::instance()->readNumEntry("filter_threshold_redeye", 10));
+
+ // solarize
+ solarizeValue->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_solarize_value", 0.5));
+
+ // spread
+ spreadValue->setValue(SQ_Config::instance()->readNumEntry("filter_spread_value", 1));
+
+ // swirl
+ swirlAngle->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_swirl_value", 0.0));
+
+ // noise
+ buttonGroupNoise->setButton(SQ_Config::instance()->readNumEntry("filter_noise", 0));
+
+ // flatten
+ c.setNamedColor(SQ_Config::instance()->readEntry("filter_flatten_color1", "#00ff00"));
+ flattenColor1->setColor(c);
+ c.setNamedColor(SQ_Config::instance()->readEntry("filter_flatten_color2", "#00ff00"));
+ flattenColor2->setColor(c);
+
+ // shade
+ shadeAzim->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_shade_azim", 0.1));
+ shadeElev->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_shade_elev", 0.1));
+
+ if(SQ_Config::instance()->readBoolEntry("filter_shade_color", false))
+ shadeColor->toggle();
+
+ // blur
+ blurRadius->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_blur_radius", 0.1));
+ blurSigma->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_blur_sigma", 0.1));
+
+ // implode
+ implodeFactor->setValue(SQ_Config::instance()->readNumEntry("filter_implode_factor", 1));
+
+ // edge
+ edgeRadius->setValue(SQ_Config::instance()->readNumEntry("filter_egde_radius", 1));
+
+ // emboss
+ embossRadius->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_emboss_radius", 0.1));
+ embossSigma->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_emboss_sigma", 0.1));
+
+ // sharpen
+ sharpenRadius->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_sharpen_radius", 0.1));
+ sharpenSigma->setValue(SQ_Config::instance()->readDoubleNumEntry("filter_sharpen_sigma", 0.1));
+
+ // oil
+ oilRadius->setValue(SQ_Config::instance()->readNumEntry("filter_oil_radius", 1));
+
+ listMain->setCurrentItem(SQ_Config::instance()->readNumEntry("filter_filter", 0));
+
+ hackConnect();
+}
+
+void SQ_ImageFilter::slotStartFiltering()
+{
+ SQ_Config *tdeconf = SQ_Config::instance();
+
+ tdeconf->setGroup("Image edit options");
+ tdeconf->writeEntry("filter_swapRGB", buttonGroupSwapRGB->selectedId());
+ tdeconf->writeEntry("filter_blend_color", pushBlendColor->color().name());
+ tdeconf->writeEntry("filter_blend_opacity", blendOpacity->value());
+ tdeconf->writeEntry("filter_fade_color", fadeColor->color().name());
+ tdeconf->writeEntry("filter_fade_value", fadeValue->value());
+ tdeconf->writeEntry("filter_desaturate_value", desaturateValue->value());
+ tdeconf->writeEntry("filter_threshold_value", thresholdValue->value());
+ tdeconf->writeEntry("filter_threshold_redeye", thresholdRE->value());
+ tdeconf->writeEntry("filter_solarize_value", solarizeValue->value());
+ tdeconf->writeEntry("filter_spread_value", spreadValue->value());
+ tdeconf->writeEntry("filter_swirl_value", swirlAngle->value());
+ tdeconf->writeEntry("filter_noise", buttonGroupNoise->selectedId());
+ tdeconf->writeEntry("filter_flatten_color1", flattenColor1->color().name());
+ tdeconf->writeEntry("filter_flatten_color2", flattenColor2->color().name());
+ tdeconf->writeEntry("filter_shade_azim", shadeAzim->value());
+ tdeconf->writeEntry("filter_shade_elev", shadeElev->value());
+ tdeconf->writeEntry("filter_shade_color", shadeColor->isChecked());
+ tdeconf->writeEntry("filter_blur_radius", blurRadius->value());
+ tdeconf->writeEntry("filter_blur_sigma", blurSigma->value());
+ tdeconf->writeEntry("filter_implode_factor", implodeFactor->value());
+ tdeconf->writeEntry("filter_egde_radius", edgeRadius->value());
+ tdeconf->writeEntry("filter_emboss_radius", embossRadius->value());
+ tdeconf->writeEntry("filter_emboss_sigma", embossSigma->value());
+ tdeconf->writeEntry("filter_sharpen_radius", sharpenRadius->value());
+ tdeconf->writeEntry("filter_sharpen_sigma", sharpenSigma->value());
+ tdeconf->writeEntry("filter_oil_radius", oilRadius->value());
+ tdeconf->writeEntry("filter_filter", listMain->currentItem());
+
+ SQ_ImageFilterOptions opt;
+
+ opt.type = listMain->currentItem();
+
+ switch(opt.type)
+ {
+ case F::fblend:
+ {
+ TQColor c = pushBlendColor->color();
+ opt.rgb1 = fmt_filters::rgb(c.red(), c.green(), c.blue());
+ opt._float = blendOpacity->value();
+ }
+ break;
+ case F::fblur: opt._double1 = blurRadius->value(); opt._double2 = blurSigma->value(); break;
+ case F::fdesaturate: opt._float = (float)desaturateValue->value(); break;
+ case F::fdespeckle: break;
+ case F::fedge: opt._double1 = (double)edgeRadius->value(); break;
+ case F::femboss: opt._double1 = embossRadius->value(); opt._double2 = embossSigma->value(); break;
+ case F::fequalize: break;
+ case F::ffade:
+ {
+ TQColor c = fadeColor->color();
+ opt.rgb1 = fmt_filters::rgb(c.red(), c.green(), c.blue());
+ opt._float = (float)fadeValue->value();
+ }
+ break;
+ case F::fflatten:
+ {
+ TQColor c = flattenColor1->color();
+ opt.rgb1 = fmt_filters::rgb(c.red(), c.green(), c.blue());
+ c = flattenColor2->color();
+ opt.rgb2 = fmt_filters::rgb(c.red(), c.green(), c.blue());
+ }
+ break;
+ case F::fimplode: opt._double1 = implodeFactor->value(); break;
+ case F::fnegative: break;
+ case F::fnoise: opt._uint = buttonGroupNoise->selectedId(); break;
+ case F::foil: opt._double1 = (double)oilRadius->value(); break;
+ case F::fshade: opt._bool = shadeColor->isChecked(); opt._double1 = shadeAzim->value(); opt._double2 = shadeElev->value(); break;
+ case F::fsharpen: opt._double1 = sharpenRadius->value(); opt._double2 = sharpenSigma->value();break;
+ case F::fsolarize: opt._double1 = solarizeValue->value(); break;
+ case F::fspread: opt._uint = spreadValue->value(); break;
+ case F::fswapRGB: opt._uint = buttonGroupSwapRGB->selectedId(); break;
+ case F::fswirl: opt._double1 = swirlAngle->value(); break;
+ case F::fthreshold: opt._uint = thresholdValue->value(); break;
+ case F::fgray: break;
+ case F::fredeye: opt._uint = thresholdRE->value(); break;
+ }
+
+ emit filter(&opt);
+}
+
+void SQ_ImageFilter::slotShowPage()
+{
+ int id = listMain->currentItem();
+
+ widgetStackFilters->raiseWidget(id);
+
+ switch(id)
+ {
+ case F::fblend: blend(); break;
+ case F::fblur: blur(); break;
+ case F::fdesaturate: desaturate(); break;
+ case F::fdespeckle: despeckle(); break;
+ case F::fedge: edge(); break;
+ case F::femboss: emboss(); break;
+ case F::fequalize: equalize(); break;
+ case F::ffade: fade(); break;
+ case F::fflatten: flatten(); break;
+ case F::fimplode: implode(); break;
+ case F::fnegative: negative(); break;
+ case F::fnoise: noise(); break;
+ case F::foil: oil(); break;
+ case F::fshade: shade(); break;
+ case F::fsharpen: sharpen(); break;
+ case F::fsolarize: solarize(); break;
+ case F::fspread: spread(); break;
+ case F::fswapRGB: swapRGB(); break;
+ case F::fswirl: swirl(); break;
+ case F::fthreshold: threshold(); break;
+ case F::fgray: togray(); break;
+ case F::fredeye: redeye(); break;
+ }
+}
+
+void SQ_ImageFilter::setPreviewImage(const TQImage &im)
+{
+ if(im.isNull()) return;
+
+ sample = im.copy();
+ sample_saved = sample.copy();
+
+ TQPixmap p;
+
+ p.convertFromImage(sample_saved);
+ pixmap->setPixmap(p);
+ pixmap1->setPixmap(p);
+
+ slotShowPage();
+}
+
+void SQ_ImageFilter::assignNewImage(const TQImage &im)
+{
+ TQPixmap p;
+ p.convertFromImage(im);
+ pixmap1->setPixmap(p);
+}
+
+void SQ_ImageFilter::swapRGB()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ int id = buttonGroupSwapRGB->selectedId();
+
+ if(id == -1)
+ return;
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::swapRGB(im, (id ? fmt_filters::GBR : fmt_filters::BRG));
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::negative()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::negative(im);
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::blend()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ TQColor c = pushBlendColor->color();
+
+ fmt_filters::rgb rgb(c.red(), c.green(), c.blue());
+
+ fmt_filters::blend(im, rgb, blendOpacity->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::fade()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ TQColor c = fadeColor->color();
+
+ fmt_filters::fade(im, fmt_filters::rgb(c.red(), c.green(), c.blue()), fadeValue->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::togray()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::gray(im);
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::desaturate()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::desaturate(im, desaturateValue->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::threshold()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::threshold(im, thresholdValue->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::solarize()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::solarize(im, solarizeValue->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::spread()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::spread(im, spreadValue->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::swirl()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::swirl(im, swirlAngle->value(), fmt_filters::rgba(255,255,255,255));
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::noise()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::noise(im, (fmt_filters::NoiseType)buttonGroupNoise->selectedId());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::redeye()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::redeye(im, im.w, im.h, 0, 0, thresholdRE->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::flatten()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ TQColor c1 = flattenColor1->color();
+ TQColor c2 = flattenColor2->color();
+
+ fmt_filters::flatten(im, fmt_filters::rgb(c1.red(), c1.green(), c1.blue()), fmt_filters::rgb(c2.red(), c2.green(), c2.blue()));
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::shade()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::shade(im, shadeColor->isChecked(), shadeAzim->value(), shadeElev->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::equalize()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::equalize(im);
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::blur()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::blur(im, blurRadius->value(), blurSigma->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::despeckle()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::despeckle(im);
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::implode()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::implode(im, implodeFactor->value(), fmt_filters::white);
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::edge()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::edge(im, (double)edgeRadius->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::emboss()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::emboss(im, embossRadius->value(), embossSigma->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::sharpen()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::sharpen(im, sharpenRadius->value(), sharpenSigma->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::oil()
+{
+ if(sample.isNull() || sample_saved.isNull())
+ return;
+
+ sample = sample_saved.copy();
+
+ fmt_filters::image im(sample.bits(), sample.width(), sample.height());
+
+ fmt_filters::oil(im, oilRadius->value());
+
+ assignNewImage(sample);
+}
+
+void SQ_ImageFilter::hackConnect()
+{
+ connect( blendOpacity, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( blend() ) );
+ connect( pushBlendColor, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT( blend() ) );
+ connect( blurRadius, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( blur() ) );
+ connect( blurSigma, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( blur() ) );
+ connect( desaturateValue, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( desaturate() ) );
+ connect( edgeRadius, TQ_SIGNAL( valueChanged(int) ), this, TQ_SLOT( edge() ) );
+ connect( embossRadius, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( emboss() ) );
+ connect( embossSigma, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( emboss() ) );
+ connect( fadeColor, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT( fade() ) );
+ connect( fadeValue, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( fade() ) );
+ connect( flattenColor1, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT( flatten() ) );
+ connect( flattenColor2, TQ_SIGNAL( changed(const TQColor&) ), this, TQ_SLOT( flatten() ) );
+ connect( implodeFactor, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( implode() ) );
+ connect( buttonGroupNoise, TQ_SIGNAL( clicked(int) ), this, TQ_SLOT( noise() ) );
+ connect( oilRadius, TQ_SIGNAL( valueChanged(int) ), this, TQ_SLOT( oil() ) );
+ connect( shadeAzim, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( shade() ) );
+ connect( shadeColor, TQ_SIGNAL( toggled(bool) ), this, TQ_SLOT( shade() ) );
+ connect( shadeElev, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( shade() ) );
+ connect( sharpenRadius, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( sharpen() ) );
+ connect( sharpenSigma, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( sharpen() ) );
+ connect( solarizeValue, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( solarize() ) );
+ connect( spreadValue, TQ_SIGNAL( valueChanged(int) ), this, TQ_SLOT( spread() ) );
+ connect( buttonGroupSwapRGB, TQ_SIGNAL( clicked(int) ), this, TQ_SLOT( swapRGB() ) );
+ connect( swirlAngle, TQ_SIGNAL( valueChanged(double) ), this, TQ_SLOT( swirl() ) );
+ connect( thresholdValue, TQ_SIGNAL( valueChanged(int) ), this, TQ_SLOT( threshold() ) );
+ connect( thresholdRE, TQ_SIGNAL( valueChanged(int) ), this, TQ_SLOT( redeye() ) );
+}
+
+SQ_ImageFilter* SQ_ImageFilter::instance()
+{
+ return m_inst;
+}
diff --git a/src/ksquirrelpart/sq_imageproperties.ui b/src/ksquirrelpart/sq_imageproperties.ui
new file mode 100644
index 0000000..a85d9c2
--- /dev/null
+++ b/src/ksquirrelpart/sq_imageproperties.ui
@@ -0,0 +1,969 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_ImageProperties</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_ImageProperties</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>495</width>
+ <height>384</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Image properties</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>pushButton1</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ <property name="toggleButton">
+ <bool>false</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>470</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQTabWidget" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>tabWidget</cstring>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>File</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer12</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Attributes</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel4_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Owner:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel5_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Group:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textOwner</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel27_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Permissions:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="1">
+ <property name="name">
+ <cstring>textPermissions</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="1">
+ <property name="name">
+ <cstring>textGroup</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQGroupBox" row="1" column="1">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>Time</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Created:</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2_2_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Last read:</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel3_2_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Last modified:</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textCreated</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="1">
+ <property name="name">
+ <cstring>textLastRead</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="1">
+ <property name="name">
+ <cstring>textLastMod</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQGroupBox" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>General</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2_3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>File:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="1">
+ <property name="name">
+ <cstring>textSize</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_4</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Directory:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel3_3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Size:</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>lineDirectory</cstring>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>lineFile</cstring>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Image</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel6_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel11_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Number of frames:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel23_2_2_2_2_3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Current frame</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel23_2_2_2_2_4</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Delay:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel7_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Dimensions:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel8_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Bits per pixel:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel9_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Color space:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel10_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Compression:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel21_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Uncompressed size:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel23_2_2_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Compression ratio:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel23_2_2_2_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Interlaced:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel23_2_2_2_2_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Status:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer10</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>210</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textType</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textFrames</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textFrame</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textDelay</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textDimensions</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textBpp</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textColorModel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textCompression</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textUncompressed</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textRatio</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textInterlaced</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textStatusIcon</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textStatus</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer11</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>205</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>Metadata</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Group</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>listMeta</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushButton1</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageProperties</receiver>
+ <slot>close()</slot>
+ </connection>
+ <connection>
+ <sender>listMeta</sender>
+ <signal>contextMenuRequested(TQListViewItem*,const TQPoint&amp;,int)</signal>
+ <receiver>SQ_ImageProperties</receiver>
+ <slot>slotContextMenu(TQListViewItem*,const TQPoint&amp;,int)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>tabWidget</tabstop>
+ <tabstop>lineDirectory</tabstop>
+ <tabstop>lineFile</tabstop>
+ <tabstop>listMeta</tabstop>
+ <tabstop>pushButton1</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in declaration">tqvaluevector.h</include>
+ <include location="global" impldecl="in declaration">tqvariant.h</include>
+ <include location="global" impldecl="in declaration">tqpair.h</include>
+ <include location="global" impldecl="in declaration">tqpixmap.h</include>
+ <include location="global" impldecl="in declaration">kurl.h</include>
+ <include location="global" impldecl="in declaration">tdeio/job.h</include>
+ <include location="global" impldecl="in declaration">tdefileitem.h</include>
+ <include location="global" impldecl="in implementation">tqstringlist.h</include>
+ <include location="global" impldecl="in implementation">tqfileinfo.h</include>
+ <include location="global" impldecl="in implementation">tdeio/global.h</include>
+ <include location="global" impldecl="in implementation">tdepopupmenu.h</include>
+ <include location="global" impldecl="in implementation">kstdaction.h</include>
+ <include location="global" impldecl="in implementation">tdeaction.h</include>
+ <include location="global" impldecl="in implementation">tqapplication.h</include>
+ <include location="global" impldecl="in implementation">tqclipboard.h</include>
+ <include location="global" impldecl="in implementation">tqdir.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="global" impldecl="in implementation">tqbuttongroup.h</include>
+ <include location="global" impldecl="in implementation">tdelocale.h</include>
+ <include location="local" impldecl="in implementation">sq_imageproperties.ui.h</include>
+</includes>
+<forwards>
+ <forward>class TDEPopupMenu;</forward>
+ <forward>class TDEAction;</forward>
+ <forward>namespace TDEIO { class Job; }</forward>
+</forwards>
+<variables>
+ <variable access="private">KURL url;</variable>
+ <variable access="private">TQWidget *kew;</variable>
+ <variable access="private">TQPixmap ok, error;</variable>
+ <variable access="private">TDEPopupMenu *menu;</variable>
+ <variable access="private">TQListViewItem *data;</variable>
+ <variable access="private">int z, exifMode;</variable>
+ <variable access="private">TDEAction *copy, *copyentry, *copyall;</variable>
+ <variable access="private">TQString file;</variable>
+</variables>
+<slots>
+ <slot access="private">slotContextMenu( TQListViewItem * item, const TQPoint &amp; p, int z1 )</slot>
+ <slot access="private">slotCopyString()</slot>
+ <slot access="private">slotCopyAll()</slot>
+ <slot access="private">slotCopyEntry()</slot>
+ <slot access="private" specifier="non virtual">slotModeClicked( int id )</slot>
+ <slot access="private">slotStatResult( TDEIO::Job * job )</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function access="private" specifier="non virtual">destroy()</function>
+ <function>setParams( TQStringList &amp; l )</function>
+ <function specifier="non virtual">setURL( const KURL &amp; _url )</function>
+ <function access="private">setFileParams()</function>
+ <function>setMetaInfo( TQValueVector&lt;TQPair&lt;TQString, TQString&gt; &gt; meta )</function>
+ <function specifier="non virtual">setFile( const TQString &amp; _file )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/ksquirrelpart/sq_imageproperties.ui.h b/src/ksquirrelpart/sq_imageproperties.ui.h
new file mode 100644
index 0000000..5265d46
--- /dev/null
+++ b/src/ksquirrelpart/sq_imageproperties.ui.h
@@ -0,0 +1,264 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+/*
+ * SQ_ImageProperties shows image properties.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef SQ_HAVE_KEXIF
+#include <libkexif/kexifwidget.h>
+#include <libkexif/kexifdata.h>
+#include <tqobjectlist.h>
+#include "sq_config.h"
+#endif
+
+void SQ_ImageProperties::init()
+{
+ menu = new TDEPopupMenu;
+ copy = KStdAction::copy(this, TQ_SLOT(slotCopyString()), 0);
+ copyentry = new TDEAction(i18n("Copy entry"), 0, this, TQ_SLOT(slotCopyEntry()), 0);
+ copyall = new TDEAction(i18n("Copy all entries"), 0, this, TQ_SLOT(slotCopyAll()), 0);
+
+ copyentry->setIcon(copy->icon());
+ copyall->setIcon(copy->icon());
+
+ copy->plug(menu);
+ copyentry->plug(menu);
+ copyall->plug(menu);
+
+ ok = SQ_IconLoader::instance()->loadIcon("ok", TDEIcon::Desktop, 16);
+ error = SQ_IconLoader::instance()->loadIcon("error", TDEIcon::Desktop, 16);
+}
+
+void SQ_ImageProperties::destroy()
+{
+#ifdef SQ_HAVE_KEXIF
+ SQ_Config::instance()->setGroup("GL view");
+ SQ_Config::instance()->writeEntry("exifmode", exifMode);
+#endif
+
+ delete copyall;
+ delete copyentry;
+ delete copy;
+ delete menu;
+}
+
+void SQ_ImageProperties::setParams(TQStringList &l)
+{
+ setFileParams();
+
+ TQStringList::Iterator it = l.begin();
+ textType->setText(*it); ++it;
+ textDimensions->setText(*it); ++it;
+ textBpp->setText(*it); ++it;
+ textColorModel->setText(*it); ++it;
+ textCompression->setText(*it); ++it;
+ textUncompressed->setText(*it); ++it;
+ textRatio->setText(*it); ++it;
+ textInterlaced->setText(*it); ++it;
+ int errors = (*it).toInt(); ++it;
+ textFrames->setText(*it); ++it;
+ textFrame->setText(*it); ++it;
+ TQString s = TQString::fromLatin1("%1").arg(i18n("1 error", "%n errors", errors));
+ textStatus->setText((errors)?s:TQString());
+ textStatusIcon->setPixmap((errors)?error:ok);
+
+ s = TQString::fromLatin1("%1%2").arg(*it).arg(i18n(" ms."));
+ textDelay->setText(s);
+}
+
+void SQ_ImageProperties::setURL(const KURL &_url)
+{
+ url = _url;
+}
+
+void SQ_ImageProperties::setFileParams()
+{
+ TDEIO::Job *stjob = TDEIO::stat(url, false);
+ connect(stjob, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotStatResult(TDEIO::Job *)));
+
+#ifdef SQ_HAVE_KEXIF
+ SQ_Config::instance()->setGroup("GL view");
+ exifMode = SQ_Config::instance()->readNumEntry("exifmode", 0);
+
+ TQWidget *tabWidgetEXIF = new TQWidget(tabWidget, "tabWidgetEXIF");
+ tabWidget->addTab(tabWidgetEXIF, i18n("EXIF"));
+ TQGridLayout *pageLayout6 = new TQGridLayout(tabWidgetEXIF, 2, 1, 11, 6, "tabWidgetEXIFLayout");
+
+ TQButtonGroup *gr = new TQButtonGroup(tabWidgetEXIF, "EXIF mode");
+ gr->setFrameShape(TQFrame::NoFrame);
+ gr->setExclusive(true);
+ connect(gr, TQ_SIGNAL(clicked(int)), this, TQ_SLOT(slotModeClicked(int)));
+
+ TQGridLayout *pageLayoutGR = new TQGridLayout(gr, 1, 3, 0, -1, "tabWidgetEXIFGRLayout");
+
+ TQPushButton *mode1 = new TQPushButton(i18n("Simple"), gr, "mode1");
+ mode1->setToggleButton(true);
+
+ TQPushButton *mode2 = new TQPushButton(i18n("Full"), gr, "mode2");
+ mode2->setToggleButton(true);
+
+ TQSpacerItem *spacer = new TQSpacerItem(15, 1, TQSizePolicy::Expanding, TQSizePolicy::Minimum);
+
+ // create KEXIF widget and load metadata from file
+ KExifWidget *kew1 = new KExifWidget(tabWidgetEXIF);
+ kew1->loadFile(file);
+
+ // hack to workaround poor libkexif API
+ TQObjectList *ch = const_cast<TQObjectList *>(kew1->children());
+ for(TQObjectList::iterator it = ch->begin();it != ch->end();++it)
+ {
+ if((*it)->inherits("TQListView"))
+ {
+ TQListView *l = dynamic_cast<TQListView *>(*it);
+ TQWidget *w = tabWidget->page(3);
+
+ if(l && w && !l->childCount())
+ tabWidget->changeTab(w, i18n("EXIF (no)"));
+
+ break;
+ }
+ }
+
+ // set proper button on
+ if(exifMode)
+ {
+ mode2->setOn(true);
+ kew1->setMode(KExifWidget::FULL);
+ }
+ else
+ {
+ mode1->setOn(true);
+ kew1->setMode(KExifWidget::SIMPLE);
+ }
+
+ // finally, add all widgets to layouts
+ pageLayoutGR->addWidget(mode1, 0, 0);
+ pageLayoutGR->addWidget(mode2, 0, 1);
+ pageLayoutGR->addItem(spacer, 0, 2);
+
+ pageLayout6->addWidget(gr, 0, 0);
+ pageLayout6->addWidget(kew1, 1, 0);
+ kew = kew1;
+#endif
+}
+
+void SQ_ImageProperties::setMetaInfo(TQValueVector<TQPair<TQString,TQString> > meta )
+{
+ TQListViewItem *after = 0, *item;
+
+ TQValueVector<TQPair<TQString,TQString> >::iterator itEnd = meta.end();
+
+ for(TQValueVector<TQPair<TQString,TQString> >::iterator it = meta.begin();it != itEnd;++it)
+ {
+ if(after)
+ item = new TQListViewItem(listMeta, after, (*it).first+TQString::fromLatin1(" "), (*it).second.replace(TQChar('\n'), TQChar(' ')));
+ else
+ after = item = new TQListViewItem(listMeta, (*it).first+TQString::fromLatin1(" "), (*it).second.replace(TQChar('\n'), TQChar(' ')));
+
+ listMeta->insertItem(item);
+ }
+
+ if(!listMeta->childCount())
+ {
+ listMeta->header()->hide();
+
+ TQWidget *w = tabWidget->page(2);
+
+ if(w)
+ tabWidget->changeTab(w, i18n("Metadata (no)"));
+ }
+}
+
+void SQ_ImageProperties::slotContextMenu( TQListViewItem *item, const TQPoint &p, int z1 )
+{
+ if(item)
+ {
+ data = item;
+ z = z1;
+ menu->exec(p);
+ }
+}
+
+void SQ_ImageProperties::slotCopyString()
+{
+ TQApplication::clipboard()->setText(data->text(z), TQClipboard::Clipboard);
+}
+
+void SQ_ImageProperties::slotCopyAll()
+{
+ if(!data)
+ return;
+
+ TQString app;
+ TQListViewItem *item = listMeta->firstChild();
+
+ for(;item;item = item->itemBelow())
+ {
+ app.append(item->text(0) + "\n" + item->text(1) + "\n");
+ }
+
+ TQApplication::clipboard()->setText(app, TQClipboard::Clipboard);
+}
+
+void SQ_ImageProperties::slotCopyEntry()
+{
+ if(!data)
+ return;
+
+ TQString app = data->text(0) + "\n" + data->text(1) + "\n";
+
+ TQApplication::clipboard()->setText(app, TQClipboard::Clipboard);
+}
+
+void SQ_ImageProperties::slotModeClicked(int id)
+{
+// change mode: simple or full
+#ifdef SQ_HAVE_KEXIF
+ exifMode = id;
+ static_cast<KExifWidget *>(kew)->setMode(id ? KExifWidget::FULL : KExifWidget::SIMPLE);
+#endif
+}
+
+void SQ_ImageProperties::slotStatResult(TDEIO::Job *job)
+{
+ if(!job->error())
+ {
+ TDEIO::UDSEntry entry = static_cast<TDEIO::StatJob*>(job)->statResult();
+ KFileItem fi(entry, url);
+
+ KURL t = url;
+ t.cd("..");
+ lineDirectory->setText(t.isLocalFile() ? t.path() : t.prettyURL());
+ lineFile->setText(fi.name());
+
+ textSize->setText(TDEIO::convertSize(fi.size()));
+ textOwner->setText(TQString("%1").arg(fi.user()));
+ textGroup->setText(TQString("%1").arg(fi.group()));
+ textPermissions->setText(fi.permissionsString());
+
+ TQDateTime abs;
+ abs.setTime_t(fi.time(TDEIO::UDS_CREATION_TIME));
+ textCreated->setText(abs.toString("dd/MM/yyyy hh:mm:ss"));
+ abs.setTime_t(fi.time(TDEIO::UDS_ACCESS_TIME));
+ textLastRead->setText(abs.toString("dd/MM/yyyy hh:mm:ss"));
+ abs.setTime_t(fi.time(TDEIO::UDS_MODIFICATION_TIME));
+ textLastMod->setText(abs.toString("dd/MM/yyyy hh:mm:ss"));
+ }
+}
+
+// set local file for KEXIF
+void SQ_ImageProperties::setFile(const TQString &_file)
+{
+ file = _file;
+}
diff --git a/src/ksquirrelpart/sq_label.cpp b/src/ksquirrelpart/sq_label.cpp
new file mode 100644
index 0000000..a55a6eb
--- /dev/null
+++ b/src/ksquirrelpart/sq_label.cpp
@@ -0,0 +1,78 @@
+/***************************************************************************
+ sq_label.cpp - description
+ -------------------
+ begin : June 10 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tqpainter.h>
+
+#include "sq_label.h"
+
+#define MARGIN 15
+
+SQ_Label::SQ_Label(TQWidget *parent, const char *name) : TQWidget(parent, name), single(false)
+{}
+
+SQ_Label::~SQ_Label()
+{}
+
+void SQ_Label::paintEvent(TQPaintEvent *)
+{
+ if((single && ltext.isEmpty() && rtext.isEmpty()) || (!single && ltext.isEmpty()))
+ return;
+
+ TQPainter paint(this);
+
+ TQFont font = paint.font();
+ font.setBold(true);
+ font.setPointSize(10);
+ paint.setFont(font);
+
+ if(!single)
+ {
+ paint.translate((width() + paint.fontMetrics().height()) / 2, height());
+ paint.rotate(-90);
+ paint.drawText(MARGIN, 0, ltext);
+
+ paint.translate(height() - paint.fontMetrics().width(rtext), 0);
+ paint.drawText(-MARGIN, 0, rtext);
+ }
+ else
+ {
+ paint.translate((width() + paint.fontMetrics().height()) / 2,
+ (height() + paint.fontMetrics().width(ltext)) / 2);
+ paint.rotate(-90);
+ paint.drawText(0, 0, ltext);
+ }
+}
+
+void SQ_Label::setText(const TQString &lt, const TQString &rt)
+{
+ ltext = lt;
+ rtext = rt;
+
+ update();
+}
+
+void SQ_Label::setText(const TQString &lt)
+{
+ ltext = lt;
+
+ update();
+}
+
+void SQ_Label::setSingle(bool s)
+{
+ single = s;
+}
diff --git a/src/ksquirrelpart/sq_label.h b/src/ksquirrelpart/sq_label.h
new file mode 100644
index 0000000..6d0edd5
--- /dev/null
+++ b/src/ksquirrelpart/sq_label.h
@@ -0,0 +1,41 @@
+/***************************************************************************
+ sq_label.h - description
+ -------------------
+ begin : June 10 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_LABEL_H
+#define SQ_LABEL_H
+
+#include <tqwidget.h>
+
+class SQ_Label : public TQWidget
+{
+ public:
+ SQ_Label(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_Label();
+
+ void setText(const TQString &lt, const TQString &rt);
+ void setText(const TQString &lt);
+ void setSingle(bool s);
+
+ protected:
+ void paintEvent(TQPaintEvent *);
+
+ private:
+ TQString ltext, rtext;
+ bool single;
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_library.h b/src/ksquirrelpart/sq_library.h
new file mode 100644
index 0000000..cf350d6
--- /dev/null
+++ b/src/ksquirrelpart/sq_library.h
@@ -0,0 +1,97 @@
+/***************************************************************************
+ sq_library.h - description
+ -------------------
+ begin : ��� ��� 27 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_LIBRARY_H
+#define SQ_LIBRARY_H
+
+#include <tqstring.h>
+#include <tqregexp.h>
+#include <tqpixmap.h>
+
+#include <ksquirrel-libs/fmt_defs.h>
+#include <ksquirrel-libs/settings.h>
+
+class TQLibrary;
+
+class KTempFile;
+
+class fmt_codec_base;
+
+/*
+ * SQ_LIBRARY represents a library. It contains all information
+ * needed by other classes, e.g. pointer to codec, mime image,
+ * version string, filter string, etc.
+ *
+ * Used by SQ_LibraryHandler.
+ */
+
+struct SQ_LIBRARY
+{
+ SQ_LIBRARY() : lib(0), codec(0), codec_il(0), tmp(0), tmp_il(0)
+ {}
+
+ // pointer to library
+ TQLibrary *lib;
+
+ // path to a library on disk
+ TQString libpath;
+
+ // converted regular expression
+ TQRegExp regexp;
+
+ // filter for a filemanager
+ TQString filter;
+
+ // path to config file (.ui)
+ TQString config;
+
+ fmt_settings settings;
+
+ // regular expression as string
+ TQString regexp_str;
+
+ TQString mimetype;
+
+ bool mime_multi;
+
+ // information on codec
+ TQString quickinfo;
+
+ // codec's version
+ TQString version;
+
+ // pointer to a codec
+ fmt_codec_base *codec, *codec_il;
+
+ // 'create' and 'destroy' functions.
+ // should exist in library!
+ fmt_codec_base* (*codec_create)();
+ void (*codec_destroy)(fmt_codec_base*);
+
+ TQPixmap mime;
+
+ // options for writers.
+ fmt_writeoptionsabs opt;
+
+ bool writestatic, writeanimated;
+ bool readable;
+ bool canbemultiple, needtempfile;
+
+ KTempFile *tmp, *tmp_il;
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_libraryhandler.cpp b/src/ksquirrelpart/sq_libraryhandler.cpp
new file mode 100644
index 0000000..3b6cf2c
--- /dev/null
+++ b/src/ksquirrelpart/sq_libraryhandler.cpp
@@ -0,0 +1,582 @@
+/***************************************************************************
+ sq_libraryhandler.cpp - description
+ -------------------
+ begin : Mar 5 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqlibrary.h>
+#include <tqfileinfo.h>
+#include <tqstringlist.h>
+#include <tqfile.h>
+#include <tqdir.h>
+
+#include <kstringhandler.h>
+#include <tdetempfile.h>
+#include <tdeconfig.h>
+#include <tdelocale.h>
+#include <kdebug.h>
+#include <kurl.h>
+#include <kmimetype.h>
+
+#include "sq_libraryhandler.h"
+#include "sq_config.h"
+
+#include <ksquirrel-libs/fmt_codec_base.h>
+
+#include <iostream>
+#include <iomanip>
+
+#if !defined(QT_STRINGIFY)
+# define QT_STRINGIFY2(x) #x
+# define QT_STRINGIFY(x) QT_STRINGIFY2(x)
+#endif
+
+static const int buffer_size = 10;
+
+SQ_LibraryHandler * SQ_LibraryHandler::m_instance = 0;
+
+// SQ_LibraryHandler
+SQ_LibraryHandler::SQ_LibraryHandler(TQObject *parent)
+ : TQObject(parent), TQValueVector<SQ_LIBRARY>()
+{
+ m_instance = this;
+
+ kdDebug() << "+SQ_LibraryHandler" << endl;
+
+ tdeconf = new TDEConfig("ksquirrel-codec-settings");
+
+ load();
+}
+
+SQ_LibraryHandler::~SQ_LibraryHandler()
+{
+ clear();
+
+ delete tdeconf;
+
+ kdDebug() << "-SQ_LibraryHandler" << endl;
+}
+
+/*
+ * Find appropriate SQ_LIBRARY by filename. If
+ * not found, return NULL.
+ */
+SQ_LIBRARY* SQ_LibraryHandler::libraryForFile(const KURL &url)
+{
+ KMimeType::Ptr mime = KMimeType::findByURL(url);
+
+ iterator itEnd = end();
+
+ SQ_LIBRARY *l = 0;
+
+ // go through array and compare names
+ for(iterator it = begin();it != itEnd;++it)
+ {
+ if((*it).mime_multi)
+ {
+ if((*it).mimetype.find(mime->name()) != -1)
+ {
+ l = &(*it);
+ break;
+ }
+ }
+ else if((*it).mimetype == mime->name())
+ {
+ l = &(*it);
+ break;
+ }
+ }
+
+#if 0
+ if(l)
+ kdDebug() << KStringHandler::lsqueeze(url.prettyURL())
+ << "\" => "
+ << l->quickinfo
+ << endl;
+#endif
+
+ return l;
+}
+
+SQ_LIBRARY* SQ_LibraryHandler::libraryForFile(const TQString &path)
+{
+ KURL u;
+ u.setPath(path);
+
+ return libraryForFile(u);
+}
+
+/*
+ * Get all filters as one string.
+ */
+TQString SQ_LibraryHandler::allFiltersString() const
+{
+ TQString ret;
+
+ const_iterator itEnd = end();
+
+ // construct string
+ for(const_iterator it = begin();it != itEnd;++it)
+ {
+ if(!(*it).filter.isEmpty())
+ ret = ret + (*it).filter + ' ';
+ }
+
+ return ret;
+}
+
+TQString SQ_LibraryHandler::allFiltersFileDialogString(bool r, bool allfiles) const
+{
+ TQString ret;
+
+ const_iterator itEnd = end();
+
+ // construct string
+ for(const_iterator it = begin();it != itEnd;++it)
+ {
+ if(!r)
+ if((*it).writestatic)
+ ret = ret + (*it).filter + '|' + (*it).quickinfo + '\n';
+ else;
+ else if((*it).readable)
+ ret = ret + (*it).filter + '|' + (*it).quickinfo + '\n';
+ }
+
+ return allfiles ? (ret + "*.*|" + i18n("All files")) : ret.left(ret.length() - 1);
+}
+
+/*
+ * Fill 'filters' with all found filters, and
+ * 'quick' with appropriate information.
+ */
+void SQ_LibraryHandler::allFilters(TQStringList &filters, TQStringList &quick) const
+{
+ // clear rubbish
+ filters.clear();
+ quick.clear();
+
+ // no found libraries ?
+ if(empty())
+ return;
+
+ const_iterator itEnd = end();
+
+ // go through array and fill TQStringLists
+ for(const_iterator it = begin();it != itEnd;++it)
+ if(!(*it).filter.isEmpty())
+ {
+ filters.append((*it).filter);
+ quick.append((*it).quickinfo);
+ }
+}
+
+void SQ_LibraryHandler::allWritableFilters(TQStringList &filters, TQStringList &quick) const
+{
+ // clear rubbish
+ filters.clear();
+ quick.clear();
+
+ // no libraries ?
+ if(empty())
+ return;
+
+ const_iterator itEnd = end();
+
+ // go through array and fill TQStringLists
+ for(const_iterator it = begin();it != itEnd;++it)
+ if((*it).writestatic && !(*it).filter.isEmpty())
+ {
+ filters.append((*it).filter);
+ quick.append((*it).quickinfo);
+ }
+}
+
+/*
+ * Remove and unload all libraries.
+ */
+void SQ_LibraryHandler::clear()
+{
+ kdDebug() << "SQ_LibraryHandler::clear()" << endl;
+
+ iterator itEnd = end();
+
+ // unload libraries on clear()
+ for(iterator it = begin();it != itEnd;++it)
+ {
+ writeSettings(&(*it));
+
+ // delete temp file
+ if((*it).needtempfile)
+ {
+ delete (*it).tmp_il;
+ delete (*it).tmp;
+ }
+
+ (*it).codec_destroy((*it).codec_il);
+ (*it).codec_destroy((*it).codec);
+ delete (*it).lib;
+ (*it).lib = 0;
+ }
+
+ TQValueVector<SQ_LIBRARY>::clear();
+}
+
+/*
+ * Add new libraries.
+ */
+void SQ_LibraryHandler::add(TQStringList &foundLibraries)
+{
+ codec_options o;
+
+ TQStringList::iterator itEnd = foundLibraries.end();
+
+ for(TQStringList::iterator it = foundLibraries.begin();it != itEnd;++it)
+ {
+ TQFileInfo ff(*it);
+
+ SQ_LIBRARY libtmp;
+
+ // create TQLibrary object
+ libtmp.lib = new TQLibrary(*it);
+ libtmp.libpath = *it;
+ libtmp.lib->load();
+
+ // resolve create() and destroy() functions
+ libtmp.codec_create = (fmt_codec_base*(*)())(libtmp.lib)->resolve(TQString::fromLatin1("codec_create"));
+ libtmp.codec_destroy = (void (*)(fmt_codec_base*))(libtmp.lib)->resolve(TQString::fromLatin1("codec_destroy"));
+
+ // couldn't resolve - corrupted library ?
+ if(!libtmp.codec_create || !libtmp.codec_destroy)
+ {
+ libtmp.lib->unload();
+ delete libtmp.lib;
+ }
+ else
+ {
+ // create codec !
+ fmt_codec_base *codeK = libtmp.codec_create();
+
+ // read options
+ codeK->options(&o);
+
+ TQString q = o.name;
+
+ // Yet unknown library ?
+ if(!alreadyInMap(q))
+ {
+ libtmp.mime = TQPixmap(reinterpret_cast<const char **>(o.pixmap));
+ libtmp.mimetype = o.mimetype;
+ libtmp.mime_multi = libtmp.mimetype.find(';') != -1;
+ libtmp.quickinfo = q;
+ libtmp.filter = o.filter;
+ libtmp.version = o.version;
+ libtmp.regexp_str = o.mime;
+ libtmp.config = o.config;
+ libtmp.regexp.setPattern(libtmp.regexp_str);
+ libtmp.regexp.setCaseSensitive(true);
+ libtmp.writestatic = o.writestatic;
+ libtmp.writeanimated = o.writeanimated;
+ libtmp.readable = o.readable;
+ libtmp.canbemultiple = o.canbemultiple;
+ libtmp.needtempfile = o.needtempfile;
+ libtmp.tmp = 0;
+
+ libtmp.codec_il = libtmp.codec_create();
+
+ if(libtmp.needtempfile)
+ {
+ libtmp.tmp = new KTempFile;
+ libtmp.tmp->setAutoDelete(true);
+ libtmp.tmp->close();
+ codeK->settempfile(libtmp.tmp->name().ascii());
+
+ libtmp.tmp_il = new KTempFile;
+ libtmp.tmp_il->setAutoDelete(true);
+ libtmp.tmp_il->close();
+ libtmp.codec_il->settempfile(libtmp.tmp_il->name().ascii());
+ }
+
+ if(libtmp.writestatic)
+ codeK->getwriteoptions(&libtmp.opt);
+
+ libtmp.codec = codeK;
+
+ readSettings(&libtmp);
+
+ append(libtmp);
+ }
+ else // already known library
+ {
+ // destroy codec
+ libtmp.codec_destroy(codeK);
+
+ // unload library
+ libtmp.lib->unload();
+
+ delete libtmp.lib;
+ }
+ }
+ }
+
+ // print some information
+ dump();
+}
+
+/*
+ * Is library named 'quick' already been handled ?
+ */
+bool SQ_LibraryHandler::alreadyInMap(const TQString &quick) const
+{
+ const_iterator itEnd = end();
+
+ // go through array and find 'quick'
+ for(const_iterator it = begin();it != itEnd;++it)
+ if((*it).quickinfo == quick)
+ return true;
+
+ return false;
+}
+
+/*
+ * Print some information on found libraries.
+ */
+void SQ_LibraryHandler::dump() const
+{
+ std::cerr << "SQ_LibraryHandler: memory dump (total " << count() << ")" << endl;
+
+ const_iterator itEnd = end();
+
+ std::cerr.setf(ios::left);
+
+ for(const_iterator it = begin();it != itEnd;++it)
+ {
+ std::cerr << std::setw(30)
+ << KStringHandler::csqueeze(TQFileInfo((*it).libpath).fileName(), 30)
+ << std::setw(0)
+ << " ["
+ << KStringHandler::rsqueeze((*it).quickinfo, 45)
+ << "]"
+ << endl;
+ }
+}
+
+/*
+ * Does any of found libraries handle given extension ?
+ */
+bool SQ_LibraryHandler::knownExtension(const TQString &ext)
+{
+ iterator itEnd = end();
+
+ // go through array and compare extensions
+ for(iterator it = begin();it != itEnd;++it)
+ {
+ if((*it).filter.contains(ext, false))
+ return true;
+ }
+
+ return false;
+}
+
+/*
+ * Find appropriate SQ_LIBRARY by its name. If
+ * not found, return NULL.
+ *
+ * Name is a string, returned by fmt_quickinfo()
+ */
+SQ_LIBRARY* SQ_LibraryHandler::libraryByName(const TQString &name)
+{
+ SQ_LIBRARY *l;
+
+ iterator itEnd = end();
+
+ // go through array and compare names
+ for(iterator it = begin();it != itEnd;++it)
+ {
+ l = &(*it);
+
+ if(l->quickinfo == name)
+ return l;
+ }
+
+ return 0;
+}
+
+void SQ_LibraryHandler::writeSettings(SQ_LIBRARY *lib)
+{
+ // no config - no settings
+ if(lib->config.isEmpty())
+ return;
+
+ tdeconf->setGroup(lib->quickinfo);
+
+ fmt_settings::iterator itEnd = lib->settings.end();
+
+ TQString k;
+
+ for(fmt_settings::iterator it = lib->settings.begin();it != itEnd;++it)
+ {
+ k = (*it).first;
+
+ if((*it).second.type == settings_value::v_bool) // boolean
+ {
+ k.prepend("b");
+ tdeconf->writeEntry(k, (*it).second.bVal);
+ }
+ else if((*it).second.type == settings_value::v_int) // integer
+ {
+ k.prepend("i");
+ tdeconf->writeEntry(k, (*it).second.iVal);
+ }
+ else if((*it).second.type == settings_value::v_double) // double
+ {
+ k.prepend("d");
+ tdeconf->writeEntry(k, (*it).second.dVal);
+ }
+ else // string
+ {
+ k.prepend("s");
+ tdeconf->writeEntry(k, (*it).second.sVal);
+ }
+ }
+}
+
+void SQ_LibraryHandler::readSettings(SQ_LIBRARY *lib)
+{
+ // no config - no settings
+ if(lib->config.isEmpty())
+ return;
+
+ TQMap<TQString, TQString> map = tdeconf->entryMap(lib->quickinfo);
+
+ if(!map.size())
+ {
+ lib->codec->fill_default_settings();
+ lib->settings = lib->codec->settings();
+ return;
+ }
+
+ TQMap<TQString, TQString>::iterator mapEnd = map.end();
+ fmt_settings &sett = lib->settings;
+ TQString d, k;
+ settings_value val;
+
+ for(TQMap<TQString, TQString>::iterator mapIt = map.begin();mapIt != mapEnd;++mapIt)
+ {
+ k = mapIt.key();
+ d = mapIt.data();
+
+ if(k.startsWith(TQChar('i')))
+ {
+ val.type = settings_value::v_int;
+ val.iVal = d.toInt();
+ }
+ else if(k.startsWith(TQChar('d')))
+ {
+ val.type = settings_value::v_double;
+ val.dVal = d.toDouble();
+ }
+ else if(k.startsWith(TQChar('b')))
+ {
+ val.type = settings_value::v_bool;
+ val.bVal = (d == "true");
+ }
+ else // all other values are treated as strings
+ {
+ val.type = settings_value::v_string;
+ val.sVal = d.ascii();
+ }
+
+ k = k.right(k.length() - 1);
+ sett[k.ascii()] = val;
+ }
+
+ lib->codec->set_settings(sett);
+}
+
+void SQ_LibraryHandler::reload()
+{
+ clear();
+ load();
+}
+
+void SQ_LibraryHandler::load()
+{
+ TQStringList libs;
+
+ TQDir dir(QT_STRINGIFY(SQ_KLIBS), TQString(), TQDir::Unsorted, TQDir::Files);
+
+ const TQFileInfoList *list = dir.entryInfoList();
+
+ if(list)
+ {
+ TQFileInfoListIterator it(*list);
+ TQFileInfo *fi;
+
+ while((fi = it.current()) != 0)
+ {
+ libs.append(fi->absFilePath());
+ ++it;
+ }
+ }
+
+ // just show dump, if no libs were found
+ add(libs);
+}
+
+SQ_LibraryHandler::Support SQ_LibraryHandler::maybeSupported(const KURL &u, const TQString &mime) const
+{
+ const_iterator itEnd = constEnd();
+
+ SQ_Config::instance()->setGroup("Main");
+ bool treat = SQ_Config::instance()->readBoolEntry("treat", true);
+
+ // we can determine mimetype by hand or use "mime"
+ TQString mimeDet = mime.isEmpty() ? KMimeType::findByURL(u)->name() : mime;
+
+ // mimetype by magic is not determined automatically
+ // for non-local urls - we may support this file type or may not
+ // (we don't know exactly at this moment)
+ if(!u.isLocalFile() && mimeDet == KMimeType::defaultMimeType())
+ return (treat ? SQ_LibraryHandler::No : SQ_LibraryHandler::Maybe);
+
+ // go through array and compare mimetype names
+ for(const_iterator it = constBegin();it != itEnd;++it)
+ {
+ if((*it).mime_multi)
+ {
+ if((*it).mimetype.find(mimeDet, 0, false) != -1)
+ return SQ_LibraryHandler::Yes;
+ }
+ else if((*it).mimetype == mimeDet) // don't waste CPU time with find()
+ return SQ_LibraryHandler::Yes;
+ }
+
+ // we don't know about given mimetype
+ return SQ_LibraryHandler::No;
+}
+
+void SQ_LibraryHandler::sync()
+{
+ iterator itEnd = end();
+
+ // unload libraries on clear()
+ for(iterator it = begin();it != itEnd;++it)
+ writeSettings(&(*it));
+
+ tdeconf->sync();
+}
diff --git a/src/ksquirrelpart/sq_libraryhandler.h b/src/ksquirrelpart/sq_libraryhandler.h
new file mode 100644
index 0000000..8a3b25d
--- /dev/null
+++ b/src/ksquirrelpart/sq_libraryhandler.h
@@ -0,0 +1,128 @@
+/***************************************************************************
+ sq_libraryhandler.h - description
+ -------------------
+ begin : Mar 5 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_LIBRARY_HANDLER_H
+#define SQ_LIBRARY_HANDLER_H
+
+#include <tqvaluevector.h>
+#include <tqdatetime.h>
+#include <tqobject.h>
+
+#include "sq_library.h"
+
+class TQStringList;
+
+class TDEConfig;
+class KURL;
+
+/*
+ * SQ_LibraryHandler is a library manager. It's the main class
+ * in library loading mechanizm.
+ */
+
+class SQ_LibraryHandler : public TQObject, public TQValueVector<SQ_LIBRARY>
+{
+ public:
+ SQ_LibraryHandler(TQObject *parent = 0);
+ ~SQ_LibraryHandler();
+
+ enum Support { Maybe = 0, Yes, No };
+
+ /*
+ * Reload libraries from disk
+ */
+ void reload();
+
+ void sync();
+
+ Support maybeSupported(const KURL &, const TQString& = TQString()) const;
+
+ /*
+ * Find appropriate SQ_LIBRARY by filename. If
+ * not found, return NULL.
+ */
+ SQ_LIBRARY* libraryForFile(const KURL &);
+ SQ_LIBRARY* libraryForFile(const TQString &);
+
+ /*
+ * Find appropriate SQ_LIBRARY by its name. If
+ * not found, return NULL.
+ *
+ * Name is a string, returned by fmt_quickinfo()
+ */
+ SQ_LIBRARY* libraryByName(const TQString &name);
+
+ /*
+ * Does any of found libraries handle given extension ?
+ */
+ bool knownExtension(const TQString &ext);
+
+ /*
+ * Fill 'filters' with all found filters, and
+ * 'quick' with appropriate information.
+ */
+ void allFilters(TQStringList &filters, TQStringList &quick) const;
+
+ void allWritableFilters(TQStringList &filters, TQStringList &quick) const;
+
+ /*
+ * Get all filters as one string.
+ */
+ TQString allFiltersString() const;
+
+ /*
+ * Filters as one string suitable for KFileDialogs.
+ * If r == true, return readable codecs
+ * If allfiles == true, append *.* to result
+ */
+ TQString allFiltersFileDialogString(bool r, bool allfiles = true) const;
+
+ /*
+ * Remove and unload all libraries.
+ */
+ void clear();
+
+ /*
+ * Print some information on found libraries.
+ */
+ void dump() const;
+
+ static SQ_LibraryHandler* instance() { return m_instance; }
+
+ private:
+
+ void add(TQStringList &foundLibraries);
+
+ /*
+ * Load libraries from disk.
+ */
+ void load();
+ /*
+ * Is library with name 'quick' already been handled ?
+ */
+ bool alreadyInMap(const TQString &quick) const;
+
+ void writeSettings(SQ_LIBRARY *lib);
+ void readSettings(SQ_LIBRARY *lib);
+
+ private:
+ TDEConfig *tdeconf;
+
+ static SQ_LibraryHandler *m_instance;
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_popupmenu.cpp b/src/ksquirrelpart/sq_popupmenu.cpp
new file mode 100644
index 0000000..553d9ef
--- /dev/null
+++ b/src/ksquirrelpart/sq_popupmenu.cpp
@@ -0,0 +1,39 @@
+/***************************************************************************
+ sq_popupmenu.cpp - description
+ -------------------
+ begin : ??? June 3 2006
+ copyright : (C) 2006 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_popupmenu.h"
+
+SQ_PopupMenu::SQ_PopupMenu(TQWidget *parent, const char *name)
+ : TDEPopupMenu(parent, name), title(0)
+{}
+
+SQ_PopupMenu::~SQ_PopupMenu()
+{}
+
+void SQ_PopupMenu::insertTitle(const TQString &t)
+{
+ title = TDEPopupMenu::insertTitle(t);
+}
+
+void SQ_PopupMenu::changeTitle(const TQString &t)
+{
+ TDEPopupMenu::changeTitle(title, t);
+}
diff --git a/src/ksquirrelpart/sq_popupmenu.h b/src/ksquirrelpart/sq_popupmenu.h
new file mode 100644
index 0000000..efc12f2
--- /dev/null
+++ b/src/ksquirrelpart/sq_popupmenu.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ sq_popupmenu.h - description
+ -------------------
+ begin : ??? June 3 2006
+ copyright : (C) 2006 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_POPUPMENU_H
+#define SQ_POPUPMENU_H
+
+#include <tdepopupmenu.h>
+
+/**
+ *@author Baryshev Dmitry
+ */
+
+class SQ_PopupMenu : public TDEPopupMenu
+{
+ public:
+ SQ_PopupMenu(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_PopupMenu();
+
+ void insertTitle(const TQString &t);
+ void changeTitle(const TQString &t);
+
+ private:
+ int title;
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_utils.cpp b/src/ksquirrelpart/sq_utils.cpp
new file mode 100644
index 0000000..20eea42
--- /dev/null
+++ b/src/ksquirrelpart/sq_utils.cpp
@@ -0,0 +1,188 @@
+/***************************************************************************
+ sq_utils.cpp - description
+ -------------------
+ begin : Thu Aug 2 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqstring.h>
+
+#include <ksquirrel-libs/fmt_defs.h>
+
+#include "sq_libraryhandler.h"
+#include "sq_utils.h"
+
+#ifndef KSQUIRREL_PART
+#include <kurl.h>
+#include "sq_imageloader.h"
+#include "sq_thumbnailinfo.h"
+#include "sq_thumbnailsize.h"
+#endif
+
+#ifdef SQ_HAVE_KEXIF
+#include <libkexif/kexifdata.h>
+#endif
+
+void SQ_Utils::exifRotate(const TQString &file, TQImage &im, int o)
+{
+#ifdef SQ_HAVE_KEXIF
+ im = im.xForm(SQ_Utils::exifGetMatrix(file, o));
+#endif
+}
+
+TQWMatrix SQ_Utils::exifGetMatrix(const TQString &file, int o)
+{
+ TQWMatrix matrix;
+
+#ifdef SQ_HAVE_KEXIF
+ int O;
+
+ if(o == -1)
+ {
+ KExifData data;
+ data.readFromFile(file);
+ O = data.getImageQt::Orientation();
+ }
+ else
+ O = o;
+
+ switch(O)
+ {
+ case KExifData::HFLIP: matrix.scale(-1,1); break;
+ case KExifData::ROT_180: matrix.rotate(180); break;
+ case KExifData::VFLIP: matrix.scale(1,-1); break;
+ case KExifData::ROT_90_HFLIP: matrix.scale(-1,1); matrix.rotate(90); break;
+ case KExifData::ROT_90: matrix.rotate(90); break;
+ case KExifData::ROT_90_VFLIP: matrix.scale(1,-1); matrix.rotate(90); break;
+ case KExifData::ROT_270: matrix.rotate(270); break;
+
+ // normal rotation or unspecified
+ default: ;
+ }
+
+#endif
+
+ return matrix;
+}
+
+TQImage SQ_Utils::scaleImage(unsigned char *im, int w, int h, int fitwithin)
+{
+ if(w <= fitwithin && h <= fitwithin)
+ {
+ TQImage scaled(im, w, h, 32, 0, 0, TQImage::LittleEndian);
+ scaled.setAlphaBuffer(true);
+ return scaled.copy();
+ }
+
+ TQImage orig(im, w, h, 32, 0, 0, TQImage::LittleEndian);
+ orig.setAlphaBuffer(true);
+
+ // return scaled image
+ return SQ_Utils::scale(orig, fitwithin, fitwithin, SQ_Utils::SMOOTH_FAST, TQImage::ScaleMin);
+}
+
+#ifndef KSQUIRREL_PART
+bool SQ_Utils::loadThumbnail(const KURL &pixPath, SQ_Thumbnail &t)
+{
+ SQ_LIBRARY *lib = 0;
+
+#ifdef SQ_HAVE_KEXIF
+ lib = SQ_LibraryHandler::instance()->libraryForFile(pixPath.path());
+ bool th = false;
+
+ if(lib)
+ {
+ KExifData data;
+ data.readFromFile(pixPath.path());
+ TQImage im = data.getThumbnail();
+
+ if(!im.isNull())
+ {
+ SQ_Utils::exifRotate(TQString(), im, data.getImageQt::Orientation());
+
+ th = true;
+ t.w = 0;
+ t.h = 0;
+ t.mime = lib->mime;
+
+ TQString w, h;
+ w = im.text("Thumb::Image::Width");
+ h = im.text("Thumb::Image::Height");
+ t.w = w.toInt();
+ t.h = h.toInt();
+
+ if(!t.w || !t.h)
+ SQ_ImageLoader::instance()->tasteImage(pixPath.path(), &t.w, &t.h, lib);
+
+ t.thumbnail = SQ_Utils::scaleImage((unsigned char *)im.bits(), im.width(),
+ im.height(), SQ_ThumbnailSize::biggest());
+ t.thumbnail = t.thumbnail.swapRGB();
+ }
+ }
+ else
+ return false;
+
+ // thumbnail loaded - nothing to do,
+ // or load thumbnail by hands otherwise.
+ if(th)
+ return true;
+#endif
+
+ fmt_info *finfo;
+
+ RGBA *all;
+
+ bool b = SQ_ImageLoader::instance()->loadImage(pixPath.path(), SQ_CodecSettings::ThumbnailLoader);
+
+ finfo = SQ_ImageLoader::instance()->info();
+ all = SQ_ImageLoader::instance()->bits();
+
+ // memory allocation failed in SQ_ImageLoader::loadImage()
+ if(!all)
+ return false;
+
+ // another error occured...
+ if(!b)
+ {
+ // if our image is partially corrupted - show it. The image
+ // is partially corrupted, if number of errors < number of scanlines
+ // and at least one page was loaded.
+ if(!finfo->image.size()
+ || (SQ_ImageLoader::instance()->errors() == finfo->image[0].h && finfo->image.size() == 1))
+ {
+ SQ_ImageLoader::instance()->cleanup();
+ return false;
+ }
+ }
+
+ if(!lib) lib = SQ_LibraryHandler::instance()->libraryForFile(pixPath.path());
+
+ t.w = finfo->image[0].w;
+ t.h = finfo->image[0].h;
+ t.mime = lib->mime;
+
+ t.thumbnail = SQ_Utils::scaleImage((unsigned char *)all, finfo->image[0].w,
+ finfo->image[0].h, SQ_ThumbnailSize::biggest());
+
+ SQ_ImageLoader::instance()->cleanup();
+
+ // finally, rotate thumbnail using EXIF
+ SQ_Utils::exifRotate(pixPath.path(), t.thumbnail);
+
+ return true;
+}
+#endif
diff --git a/src/ksquirrelpart/sq_utils.h b/src/ksquirrelpart/sq_utils.h
new file mode 100644
index 0000000..6d92104
--- /dev/null
+++ b/src/ksquirrelpart/sq_utils.h
@@ -0,0 +1,63 @@
+/***************************************************************************
+ sq_utils.h - description
+ -------------------
+ begin : Thu Aug 2 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_UTILS_H
+#define SQ_UTILS_H
+
+#include <tqimage.h>
+#include <tqwmatrix.h>
+
+class KURL;
+
+class TQString;
+
+class SQ_Thumbnail;
+
+/*
+ * Helper class for SQ_GLWidget and SQ_ThumbnailLoadJob:
+ *
+ * thumbnail loader, rotater, mmx scaler
+ */
+
+namespace SQ_Utils
+{
+ enum SmoothAlgorithm { SMOOTH_NONE, SMOOTH_FAST, SMOOTH_NORMAL, SMOOTH_BEST };
+
+ TQImage scale(const TQImage& image, int width, int height,
+ SmoothAlgorithm alg, TQImage::ScaleMode mode = TQImage::ScaleFree, double blur = 1.0);
+
+ /*
+ * Scale given image to fit it within 'fitwithin'
+ */
+ TQImage scaleImage(unsigned char *im, int w, int h, int fitwithin);
+
+#ifndef KSQUIRREL_PART
+ /*
+ * Create and save thumbnail for 'pixPath'
+ */
+ bool loadThumbnail(const KURL &pixPath, SQ_Thumbnail&);
+#endif
+
+ /*
+ * determine EXIF rotation and rotate image if needed
+ */
+ void exifRotate(const TQString &file, TQImage &i, int o = -1);
+
+ TQWMatrix exifGetMatrix(const TQString &file, int o = -1);
+};
+
+#endif
diff --git a/src/ksquirrelpart/sq_utils_asm_scale.S b/src/ksquirrelpart/sq_utils_asm_scale.S
new file mode 100644
index 0000000..08b43da
--- /dev/null
+++ b/src/ksquirrelpart/sq_utils_asm_scale.S
@@ -0,0 +1,810 @@
+#ifdef HAVE_X86_MMX
+
+#ifdef __EMX__
+/* Due to strange behaviour of as.exe we use this macros */
+/* For all OS/2 coders - please use PGCC to compile this code */
+#define PR_(foo) ___##foo
+#define PT_(foo,func) ___##foo,func
+#define SIZE(sym) \
+ .___end_##sym:; \
+ .size ___##sym,.___end_##sym-___##sym; \
+ .align 8;
+#else
+#define PR_(foo) __##foo
+#define PT_(foo,func) __##foo,func
+#define SIZE(sym) \
+ .__end_##sym:; \
+ .size __##sym,.__end_##sym-__##sym; \
+ .align 8;
+#endif
+
+/*\
+|*| MMX assembly scaling routine for Imlib2
+|*| Written by Willem Monsuwe <[email protected]>
+\*/
+
+.text
+ .align 8
+.globl PR_(mimageScale_mmx_AARGBA)
+/* .type PT_(mimageScale_mmx_AARGBA,@function) */
+
+
+/*\ Prototype: __mimageScale_mmx_AARGBA(ImlibScaleInfo *isi, DATA32 *dest,
+|*| int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow)
+\*/
+
+#define isi 8(%ebp)
+#define dest 12(%ebp)
+#define dxx 16(%ebp)
+#define dyy 20(%ebp)
+#define dx 24(%ebp)
+#define dy 28(%ebp)
+#define dw 32(%ebp)
+#define dh 36(%ebp)
+#define dow 40(%ebp)
+#define sow 44(%ebp)
+
+/*\ Local variables that didn't fit in registers \*/
+#define y -4(%ebp)
+#define yp -8(%ebp)
+#define yap -12(%ebp)
+#define xp -16(%ebp)
+#define xap -20(%ebp)
+#define Cx -24(%ebp)
+#define Mx -28(%ebp)
+#define Cy -32(%ebp)
+#define My -36(%ebp)
+#define sow_4 -40(%ebp)
+
+/*\ When %edx points to ImlibScaleInfo, these are the members \*/
+#define xpoints (%edx)
+#define ypoints 4(%edx)
+#define xapoints 8(%edx)
+#define yapoints 12(%edx)
+#define xup_yup 16(%edx)
+
+PR_(mimageScale_mmx_AARGBA):
+ pushl %ebp
+ movl %esp, %ebp
+ subl $40, %esp
+ pushl %ebx
+ pushl %ecx
+ pushl %edx
+ pushl %edi
+ pushl %esi
+ movl isi, %edx
+
+ /*\ Check (dw > 0) && (dh > 0) \*/
+ cmpl $0, dw
+ jle .scale_leave
+ cmpl $0, dh
+ jle .scale_leave
+
+ /*\ X-based array pointers point to the end; we're looping up to 0 \*/
+ /*\ %edi = dest + dow * dy + dx + dw \*/
+ movl dow, %eax
+ imull dy, %eax
+ addl dx, %eax
+ addl dw, %eax
+ movl dest, %edi
+ leal (%edi, %eax, 4), %edi
+ /*\ xp = xpoints + dxx + dw \*/
+ movl dxx, %ebx
+ addl dw, %ebx
+ movl xpoints, %eax
+ leal (%eax, %ebx, 4), %eax
+ movl %eax, xp
+ /*\ xap = xapoints + dxx + dw \*/
+ movl xapoints, %eax
+ leal (%eax, %ebx, 4), %eax
+ movl %eax, xap
+ /*\ y = dh \*/
+ movl dh, %eax
+ movl %eax, y
+ /*\ yp = ypoints + dyy \*/
+ movl dyy, %ebx
+ movl ypoints, %eax
+ leal (%eax, %ebx, 4), %eax
+ movl %eax, yp
+ /*\ yap = yapoints + dyy \*/
+ movl yapoints, %eax
+ leal (%eax, %ebx, 4), %eax
+ movl %eax, yap
+
+ pxor %mm7, %mm7
+
+ /*\ Test xup bit \*/
+ movl xup_yup, %eax
+ sarl $1, %eax
+ jnc .scale_x_down
+
+.scale_x_up:
+ /*\ Test yup bit \*/
+ sarl $1, %eax
+ jnc .scale_x_up_y_down
+
+
+/*\ Scaling up both ways \*/
+
+.scale_x_up_y_up:
+ movl sow, %ebx
+
+.up_up_loop_y:
+
+ /*\ x = -dw \*/
+ movl dw, %ecx
+ negl %ecx
+
+ /*\ %eax = *yap << 4 \*/
+ movl yap, %eax
+ movl (%eax), %eax
+ sall $4, %eax
+ jz .up_up_yap_0
+ movd %eax, %mm1
+ punpcklwd %mm1, %mm1
+ punpckldq %mm1, %mm1
+
+.up_up_loop1_x:
+ /*\ %esi = *yp + xp[x] \*/
+ movl yp, %eax
+ movl (%eax), %esi
+ movl xp, %eax
+ movl (%eax, %ecx, 4), %eax
+ leal (%esi, %eax, 4), %esi
+
+ /*\ %eax = xap[x] << 4 \*/
+ movl xap, %eax
+ movl (%eax, %ecx, 4), %eax
+ sall $4, %eax
+ jz .up_up_xap_0
+
+ /*\ %mm0 = xap[x] << 4 \*/
+ movd %eax, %mm0
+ punpcklwd %mm0, %mm0
+ punpckldq %mm0, %mm0
+
+ /*\ Load and unpack four pixels in parralel
+ |*| %mm2 = ptr[0], %mm3 = ptr[1]
+ |*| %mm4 = ptr[sow], %mm5 = ptr[sow + 1]
+ \*/
+ movq (%esi), %mm2
+ movq (%esi, %ebx, 4), %mm4
+ movq %mm2, %mm3
+ movq %mm4, %mm5
+ punpcklbw %mm7, %mm2
+ punpcklbw %mm7, %mm4
+ punpckhbw %mm7, %mm3
+ punpckhbw %mm7, %mm5
+
+ /*\ X interpolation: r = l + (r - l) * xap \*/
+ psubw %mm2, %mm3
+ psubw %mm4, %mm5
+ psllw $4, %mm3
+ psllw $4, %mm5
+ pmulhw %mm0, %mm3
+ pmulhw %mm0, %mm5
+ paddw %mm2, %mm3
+ paddw %mm4, %mm5
+ /*\ Now %mm3 = I(ptr[0], ptr[1]), %mm5 = I(ptr[sow], ptr[sow + 1]) \*/
+ jmp .up_up_common
+.up_up_xap_0:
+ /*\ Load and unpack two pixels
+ |*| %mm3 = ptr[0], %mm5 = ptr[sow]
+ \*/
+ movd (%esi), %mm3
+ movd (%esi, %ebx, 4), %mm5
+ punpcklbw %mm7, %mm3
+ punpcklbw %mm7, %mm5
+.up_up_common:
+ /*\ Y interpolation: d = u + (d - u) * yap \*/
+ psubw %mm3, %mm5
+ psllw $4, %mm5
+ pmulhw %mm1, %mm5
+ paddw %mm3, %mm5
+ packuswb %mm5, %mm5
+ movd %mm5, (%edi, %ecx, 4)
+
+ /*\ while (++x) \*/
+ incl %ecx
+ jnz .up_up_loop1_x
+ jmp .up_up_yap_end
+.up_up_yap_0:
+
+.up_up_loop2_x:
+ /*\ %esi = *yp + xp[x] \*/
+ movl yp, %eax
+ movl (%eax), %esi
+ movl xp, %eax
+ movl (%eax, %ecx, 4), %eax
+ leal (%esi, %eax, 4), %esi
+
+ /*\ %eax = xap[x] << 4 \*/
+ movl xap, %eax
+ movl (%eax, %ecx, 4), %eax
+ sall $4, %eax
+ jz .up_up_0
+
+ /*\ %mm0 = xap[x] << 4 \*/
+ movd %eax, %mm0
+ punpcklwd %mm0, %mm0
+ punpckldq %mm0, %mm0
+
+ /*\ Load and unpack two pixels in parralel
+ |*| %mm2 = ptr[0], %mm3 = ptr[1]
+ \*/
+ movq (%esi), %mm2
+ movq %mm2, %mm3
+ punpcklbw %mm7, %mm2
+ punpckhbw %mm7, %mm3
+
+ /*\ X interpolation: r = l + (r - l) * xap \*/
+ psubw %mm2, %mm3
+ psllw $4, %mm3
+ pmulhw %mm0, %mm3
+ paddw %mm2, %mm3
+ packuswb %mm3, %mm3
+ movd %mm3, (%edi, %ecx, 4)
+ jmp .up_up_1
+.up_up_0:
+ /*\ dptr[x] = *sptr \*/
+ movl (%esi), %eax
+ movl %eax, (%edi, %ecx, 4)
+.up_up_1:
+ incl %ecx
+ jnz .up_up_loop2_x
+
+.up_up_yap_end:
+ /*\ dptr += dow \*/
+ movl dow, %eax
+ leal (%edi, %eax, 4), %edi
+ /*\ yap++; yp++ \*/
+ addl $4, yap
+ addl $4, yp
+ /*\ while (y--) \*/
+ decl y
+ jnz .up_up_loop_y
+
+ jmp .scale_leave
+
+
+/*\ Scaling down vertically \*/
+
+.scale_x_up_y_down:
+ /*\ sow_4 = sow * 4 \*/
+ movl sow, %eax
+ sall $2, %eax
+ movl %eax, sow_4
+
+.up_down_loop_y:
+
+ /*\ Setup My and Cy \*/
+ movl yap, %eax
+ movzwl (%eax), %ebx
+ movl %ebx, My
+ movzwl 2(%eax), %eax
+ movl %eax, Cy
+
+ /*\ mm4 = Cy \*/
+ movd %eax, %mm4
+ punpcklwd %mm4, %mm4
+ punpckldq %mm4, %mm4
+ /*\ mm5 = My \*/
+ movd %ebx, %mm5
+ punpcklwd %mm5, %mm5
+ punpckldq %mm5, %mm5
+
+ /*\ x = -dw \*/
+ movl dw, %ecx
+ negl %ecx
+.up_down_loop_x:
+ /*\ %esi = *yp + xp[x] \*/
+ movl yp, %eax
+ movl (%eax), %esi
+ movl xp, %eax
+ movl (%eax, %ecx, 4), %eax
+ leal (%esi, %eax, 4), %esi
+
+ movl %esi, %eax
+ /*\ v = (*p * My) >> 10 \*/
+ movd (%eax), %mm0
+ punpcklbw %mm7, %mm0
+ psllw $6, %mm0
+ pmulhw %mm5, %mm0
+
+ /*\ i = 0x4000 - My \*/
+ movl $0x4000, %ebx
+ subl My, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ p += sow; v += (*p * Cy) >> 10 \*/
+ addl sow_4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm4, %mm1
+ paddw %mm1, %mm0
+
+ /*\ i -= Cy; while (i > Cy) \*/
+ subl Cy, %ebx
+2:
+ cmpl Cy, %ebx
+ jg 1b
+
+ /*\ mm6 = i \*/
+ movd %ebx, %mm6
+ punpcklwd %mm6, %mm6
+ punpckldq %mm6, %mm6
+
+ /*\ p += sow; v += (*p * i) >> 10 \*/
+ addl sow_4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm6, %mm1
+ paddw %mm1, %mm0
+5:
+ /*\ %eax = xap[x] << 5 \*/
+ movl xap, %eax
+ movl (%eax, %ecx, 4), %eax
+ sall $5, %eax
+ jz 6f
+ /*\ mm3 = xap[x] << 5 \*/
+ movd %eax, %mm3
+ punpcklwd %mm3, %mm3
+ punpckldq %mm3, %mm3
+
+ /*\ p + 1 \*/
+ movl %esi, %eax
+ addl $4, %eax
+ /*\ vv = (*p * My) >> 10 \*/
+ movd (%eax), %mm2
+ punpcklbw %mm7, %mm2
+ psllw $6, %mm2
+ pmulhw %mm5, %mm2
+
+ /*\ i = 0x4000 - My \*/
+ movl $0x4000, %ebx
+ subl My, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ p += sow; vv += (*p * Cy) >> 10 \*/
+ addl sow_4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm4, %mm1
+ paddw %mm1, %mm2
+
+ /*\ i -= Cy; while (i > Cy) \*/
+ subl Cy, %ebx
+2:
+ cmpl Cy, %ebx
+ jg 1b
+
+ /*\ p += sow; v += (*p * i) >> 10 \*/
+ addl sow_4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm6, %mm1
+ paddw %mm1, %mm2
+5:
+ /*\ v = v + (vv - v) * xap \*/
+ psubw %mm0, %mm2
+ psllw $3, %mm2
+ pmulhw %mm3, %mm2
+ paddw %mm2, %mm0
+6:
+ /*\ dest[x] = v >> 4 \*/
+ psrlw $4, %mm0
+ packuswb %mm0, %mm0
+ movd %mm0, (%edi, %ecx, 4)
+
+ /*\ while (++x) \*/
+ incl %ecx
+ jnz .up_down_loop_x
+
+ /*\ dptr += dow \*/
+ movl dow, %eax
+ leal (%edi, %eax, 4), %edi
+ /*\ yap++; yp++ \*/
+ addl $4, yap
+ addl $4, yp
+ /*\ while (y--) \*/
+ decl y
+ jnz .up_down_loop_y
+
+ jmp .scale_leave
+
+.scale_x_down:
+ /*\ Test yup bit \*/
+ sarl $1, %eax
+ jnc .scale_x_down_y_down
+
+
+/*\ Scaling down horizontally \*/
+
+.scale_x_down_y_up:
+ /*\ sow_4 = sow * 4 \*/
+ movl sow, %eax
+ sall $2, %eax
+ movl %eax, sow_4
+
+.down_up_loop_y:
+
+ /*\ %eax = *yap << 5 \*/
+ movl yap, %eax
+ movl (%eax), %eax
+ sall $5, %eax
+ /*\ mm3 = *yap << 5 \*/
+ movd %eax, %mm3
+ punpcklwd %mm3, %mm3
+ punpckldq %mm3, %mm3
+
+ /*\ x = -dw \*/
+ movl dw, %ecx
+ negl %ecx
+.down_up_loop_x:
+ /*\ %esi = *yp + xp[x] \*/
+ movl yp, %eax
+ movl (%eax), %esi
+ movl xp, %eax
+ movl (%eax, %ecx, 4), %eax
+ leal (%esi, %eax, 4), %esi
+
+ /*\ Setup Mx and Cx \*/
+ movl xap, %eax
+ movzwl (%eax, %ecx, 4), %ebx
+ movl %ebx, Mx
+ movzwl 2(%eax, %ecx, 4), %eax
+ movl %eax, Cx
+
+ /*\ mm4 = Cx \*/
+ movd %eax, %mm4
+ punpcklwd %mm4, %mm4
+ punpckldq %mm4, %mm4
+ /*\ mm5 = Mx \*/
+ movd %ebx, %mm5
+ punpcklwd %mm5, %mm5
+ punpckldq %mm5, %mm5
+
+ movl %esi, %eax
+ /*\ v = (*p * Mx) >> 10 \*/
+ movd (%eax), %mm0
+ punpcklbw %mm7, %mm0
+ psllw $6, %mm0
+ pmulhw %mm5, %mm0
+
+ /*\ i = 0x4000 - Mx \*/
+ movl $0x4000, %ebx
+ subl Mx, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ p += sow; v += (*p * Cx) >> 10 \*/
+ addl $4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm4, %mm1
+ paddw %mm1, %mm0
+
+ /*\ i -= Cx; while (i > Cx) \*/
+ subl Cx, %ebx
+2:
+ cmpl Cx, %ebx
+ jg 1b
+
+ /*\ mm6 = i \*/
+ movd %ebx, %mm6
+ punpcklwd %mm6, %mm6
+ punpckldq %mm6, %mm6
+
+ /*\ p += sow; v += (*p * i) >> 10 \*/
+ addl $4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm6, %mm1
+ paddw %mm1, %mm0
+5:
+ movd %mm3, %eax
+ testl %eax, %eax
+ jz 6f
+ /*\ p + sow \*/
+ movl %esi, %eax
+ addl sow_4, %eax
+ /*\ vv = (*p * Mx) >> 10 \*/
+ movd (%eax), %mm2
+ punpcklbw %mm7, %mm2
+ psllw $6, %mm2
+ pmulhw %mm5, %mm2
+
+ /*\ i = 0x4000 - Mx \*/
+ movl $0x4000, %ebx
+ subl Mx, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ p += sow; vv += (*p * Cx) >> 10 \*/
+ addl $4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm4, %mm1
+ paddw %mm1, %mm2
+
+ /*\ i -= Cx; while (i > Cx) \*/
+ subl Cx, %ebx
+2:
+ cmpl Cx, %ebx
+ jg 1b
+
+ /*\ p += sow; v += (*p * i) >> 10 \*/
+ addl $4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm6, %mm1
+ paddw %mm1, %mm2
+5:
+ /*\ v = v + (vv - v) * yap \*/
+ psubw %mm0, %mm2
+ psllw $3, %mm2
+ pmulhw %mm3, %mm2
+ paddw %mm2, %mm0
+6:
+ /*\ dest[x] = v >> 4 \*/
+ psrlw $4, %mm0
+ packuswb %mm0, %mm0
+ movd %mm0, (%edi, %ecx, 4)
+
+ /*\ while (++x) \*/
+ incl %ecx
+ jnz .down_up_loop_x
+
+ /*\ dptr += dow \*/
+ movl dow, %eax
+ leal (%edi, %eax, 4), %edi
+ /*\ yap++; yp++ \*/
+ addl $4, yap
+ addl $4, yp
+ /*\ while (y--) \*/
+ decl y
+ jnz .down_up_loop_y
+
+ jmp .scale_leave
+
+
+/*\ Scaling down both ways \*/
+
+.scale_x_down_y_down:
+ /*\ sow_4 = sow * 4 \*/
+ movl sow, %eax
+ sall $2, %eax
+ movl %eax, sow_4
+
+.down_down_loop_y:
+
+ /*\ Setup My and Cy \*/
+ movl yap, %eax
+ movzwl (%eax), %ebx
+ movl %ebx, My
+ movzwl 2(%eax), %eax
+ movl %eax, Cy
+
+ /*\ x = -dw \*/
+ movl dw, %ecx
+ negl %ecx
+.down_down_loop_x:
+ /*\ %esi = *yp + xp[x] \*/
+ movl yp, %eax
+ movl (%eax), %esi
+ movl xp, %eax
+ movl (%eax, %ecx, 4), %eax
+ leal (%esi, %eax, 4), %esi
+
+ /*\ Setup Mx and Cx \*/
+ movl xap, %eax
+ movzwl (%eax, %ecx, 4), %ebx
+ movl %ebx, Mx
+ movzwl 2(%eax, %ecx, 4), %eax
+ movl %eax, Cx
+
+ /*\ mm3 = Cx \*/
+ movd %eax, %mm3
+ punpcklwd %mm3, %mm3
+ punpckldq %mm3, %mm3
+ /*\ mm5 = Mx \*/
+ movd %ebx, %mm5
+ punpcklwd %mm5, %mm5
+ punpckldq %mm5, %mm5
+
+ /*\ p = sptr; v = (*p * Mx) >> 9 \*/
+ movl %esi, %eax
+ movd (%eax), %mm0
+ punpcklbw %mm7, %mm0
+ psllw $7, %mm0
+ pmulhw %mm5, %mm0
+
+ /*\ i = 0x4000 - Mx \*/
+ movl $0x4000, %ebx
+ subl Mx, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ v += (*++p * Cx) >> 9 \*/
+ addl $4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $7, %mm1
+ pmulhw %mm3, %mm1
+ paddw %mm1, %mm0
+
+ /*\ i -= Cx; while (i > Cx) \*/
+ subl Cx, %ebx
+2:
+ cmpl Cx, %ebx
+ jg 1b
+
+ /*\ mm6 = i \*/
+ movd %ebx, %mm6
+ punpcklwd %mm6, %mm6
+ punpckldq %mm6, %mm6
+
+ /*\ v += (*++p * i) >> 9 \*/
+ addl $4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $7, %mm1
+ pmulhw %mm6, %mm1
+ paddw %mm1, %mm0
+5:
+ /*\ v *= My \*/
+ movd My, %mm4
+ punpcklwd %mm4, %mm4
+ punpckldq %mm4, %mm4
+ psllw $2, %mm0
+ pmulhw %mm4, %mm0
+
+ /*\ j = 0x4000 - My \*/
+ movl $0x4000, %edx
+ subl My, %edx
+ jbe 6f
+ jmp 4f
+3:
+ /*\ sptr += sow; p = sptr \*/
+ addl sow_4, %esi
+ movl %esi, %eax
+ /*\ vx = (*p * Mx) >> 9 \*/
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $7, %mm1
+ pmulhw %mm5, %mm1
+
+ /*\ i = 0x4000 - Mx \*/
+ movl $0x4000, %ebx
+ subl Mx, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ vx += (*++p * Cx) >> 9 \*/
+ addl $4, %eax
+ movd (%eax), %mm2
+ punpcklbw %mm7, %mm2
+ psllw $7, %mm2
+ pmulhw %mm3, %mm2
+ paddw %mm2, %mm1
+
+ /*\ i -= Cx; while (i > Cx) \*/
+ subl Cx, %ebx
+2:
+ cmpl Cx, %ebx
+ jg 1b
+
+ /*\ vx += (*++p * i) >> 9 \*/
+ addl $4, %eax
+ movd (%eax), %mm2
+ punpcklbw %mm7, %mm2
+ psllw $7, %mm2
+ pmulhw %mm6, %mm2
+ paddw %mm2, %mm1
+5:
+ /*\ v += (vx * Cy) >> 14 \*/
+ movd Cy, %mm4
+ punpcklwd %mm4, %mm4
+ punpckldq %mm4, %mm4
+ psllw $2, %mm1
+ pmulhw %mm4, %mm1
+ paddw %mm1, %mm0
+
+ /*\ j -= Cy; while (j > Cy) \*/
+ subl Cy, %edx
+4:
+ cmpl Cy, %edx
+ jg 3b
+
+ /*\ sptr += sow; p = sptr \*/
+ addl sow_4, %esi
+ movl %esi, %eax
+ /*\ vx = (*p * Mx) >> 9 \*/
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $7, %mm1
+ pmulhw %mm5, %mm1
+
+ /*\ i = 0x4000 - Mx \*/
+ movl $0x4000, %ebx
+ subl Mx, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ vx += (*++p * Cx) >> 9 \*/
+ addl $4, %eax
+ movd (%eax), %mm2
+ punpcklbw %mm7, %mm2
+ psllw $7, %mm2
+ pmulhw %mm3, %mm2
+ paddw %mm2, %mm1
+
+ /*\ i -= Cx; while (i > Cx) \*/
+ subl Cx, %ebx
+2:
+ cmpl Cx, %ebx
+ jg 1b
+
+ /*\ vx += (*++p * i) >> 9 \*/
+ addl $4, %eax
+ movd (%eax), %mm2
+ punpcklbw %mm7, %mm2
+ psllw $7, %mm2
+ pmulhw %mm6, %mm2
+ paddw %mm2, %mm1
+5:
+ /*\ v += (vx * j) >> 14 \*/
+ movd %edx, %mm4
+ punpcklwd %mm4, %mm4
+ punpckldq %mm4, %mm4
+ psllw $2, %mm1
+ pmulhw %mm4, %mm1
+ paddw %mm1, %mm0
+6:
+ /*\ dptr[x] = mm0 >> 5 \*/
+ psrlw $5, %mm0
+ packuswb %mm0, %mm0
+ movd %mm0, (%edi, %ecx, 4)
+
+ /*\ while (++x) \*/
+ incl %ecx
+ jnz .down_down_loop_x
+
+ /*\ dptr += dow \*/
+ movl dow, %eax
+ leal (%edi, %eax, 4), %edi
+ /*\ yap++; yp++ \*/
+ addl $4, yap
+ addl $4, yp
+ /*\ while (y--) \*/
+ decl y
+ jnz .down_down_loop_y
+
+ jmp .scale_leave
+
+.scale_leave:
+ emms
+ popl %esi
+ popl %edi
+ popl %edx
+ popl %ecx
+ popl %ebx
+ movl %ebp, %esp
+ popl %ebp
+ ret
+
+SIZE(mimageScale_mmx_AARGBA)
+
+#endif
+
+.section .note.GNU-stack,"",%progbits
diff --git a/src/ksquirrelpart/sq_utils_scale.cpp b/src/ksquirrelpart/sq_utils_scale.cpp
new file mode 100644
index 0000000..b4d05f1
--- /dev/null
+++ b/src/ksquirrelpart/sq_utils_scale.cpp
@@ -0,0 +1,1933 @@
+// This file includes code for scaling images, in two versions.
+// One ported from ImageMagick (slower, but can achieve better quality),
+// and from Imlib2 ported by Mosfet (very fast).
+
+
+// ImageMagick code begin
+// ----------------------
+
+// This code is ImageMagick's resize code, adapted for TQImage, with
+// fastfloat class added as an optimization.
+// The original license text follows.
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% RRRR EEEEE SSSSS IIIII ZZZZZ EEEEE %
+% R R E SS I ZZ E %
+% RRRR EEE SSS I ZZZ EEE %
+% R R E SS I ZZ E %
+% R R EEEEE SSSSS IIIII ZZZZZ EEEEE %
+% %
+% ImageMagick Image Resize Methods %
+% %
+% %
+% Software Design %
+% John Cristy %
+% July 1992 %
+% %
+% %
+% Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated %
+% to making software imaging solutions freely available. %
+% %
+% Permission is hereby granted, free of charge, to any person obtaining a %
+% copy of this software and associated documentation files ("ImageMagick"), %
+% to deal in ImageMagick without restriction, including without limitation %
+% the rights to use, copy, modify, merge, publish, distribute, sublicense, %
+% and/or sell copies of ImageMagick, and to permit persons to whom the %
+% ImageMagick is furnished to do so, subject to the following conditions: %
+% %
+% The above copyright notice and this permission notice shall be included in %
+% all copies or substantial portions of ImageMagick. %
+% %
+% The software is provided "as is", without warranty of any kind, express or %
+% implied, including but not limited to the warranties of merchantability, %
+% fitness for a particular purpose and noninfringement. In no event shall %
+% ImageMagick Studio be liable for any claim, damages or other liability, %
+% whether in an action of contract, tort or otherwise, arising from, out of %
+% or in connection with ImageMagick or the use or other dealings in %
+% ImageMagick. %
+% %
+% Except as contained in this notice, the name of the ImageMagick Studio %
+% shall not be used in advertising or otherwise to promote the sale, use or %
+% other dealings in ImageMagick without prior written authorization from the %
+% ImageMagick Studio. %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%
+*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+// System
+#ifdef HAVE_ENDIAN_H
+#include <endian.h>
+#else
+#ifdef HAVE_SYS_ENDIAN_H
+#include <sys/endian.h>
+#endif
+#endif
+
+#include <tqimage.h>
+#include <tqcolor.h>
+
+#include <tdeversion.h>
+#include <kcpuinfo.h>
+
+#include <cstring>
+#include <cstdlib>
+
+#include "sq_utils.h"
+
+// everything in namespace
+namespace SQ_Utils {
+
+#define Max TQMAX
+#define Min TQMIN
+
+// mustn't be less than used precision (i.e. 1/fastfloat::RATIO)
+#define MagickEpsilon 0.0002
+
+// fastfloat begin
+// this class stores floating point numbers as integers, with BITS shift,
+// i.e. value XYZ is stored as XYZ * RATIO
+struct fastfloat
+ {
+ private:
+ enum { BITS = 12, RATIO = 4096 };
+ public:
+ fastfloat() {}
+ fastfloat( long v ) : value( v << BITS ) {}
+ fastfloat( int v ) : value( v << BITS ) {}
+ fastfloat( double v ) : value( static_cast< long >( v * RATIO + 0.5 )) {}
+ double toDouble() const { return static_cast< double >( value ) / RATIO; }
+ long toLong() const { return value >> BITS; }
+ fastfloat& operator += ( fastfloat r ) { value += r.value; return *this; }
+ fastfloat& operator -= ( fastfloat r ) { value -= r.value; return *this; }
+ fastfloat& operator *= ( fastfloat r ) { value = static_cast< long long >( value ) * r.value >> BITS; return *this; }
+ fastfloat& operator /= ( fastfloat r ) { value = ( static_cast< long long >( value ) << BITS ) / r.value; return *this; }
+ bool operator< ( fastfloat r ) const { return value < r.value; }
+ bool operator<= ( fastfloat r ) const { return value <= r.value; }
+ bool operator> ( fastfloat r ) const { return value > r.value; }
+ bool operator>= ( fastfloat r ) const { return value >= r.value; }
+ bool operator== ( fastfloat r ) const { return value == r.value; }
+ bool operator!= ( fastfloat r ) const { return value != r.value; }
+ fastfloat operator-() const { return fastfloat( -value, false ); }
+ private:
+ fastfloat( long v, bool ) : value( v ) {} // for operator-()
+ long value;
+ };
+
+inline fastfloat operator+ ( fastfloat l, fastfloat r ) { return fastfloat( l ) += r; }
+inline fastfloat operator- ( fastfloat l, fastfloat r ) { return fastfloat( l ) -= r; }
+inline fastfloat operator* ( fastfloat l, fastfloat r ) { return fastfloat( l ) *= r; }
+inline fastfloat operator/ ( fastfloat l, fastfloat r ) { return fastfloat( l ) /= r; }
+
+inline bool operator< ( fastfloat l, double r ) { return l < fastfloat( r ); }
+inline bool operator<= ( fastfloat l, double r ) { return l <= fastfloat( r ); }
+inline bool operator> ( fastfloat l, double r ) { return l > fastfloat( r ); }
+inline bool operator>= ( fastfloat l, double r ) { return l >= fastfloat( r ); }
+inline bool operator== ( fastfloat l, double r ) { return l == fastfloat( r ); }
+inline bool operator!= ( fastfloat l, double r ) { return l != fastfloat( r ); }
+
+inline bool operator< ( double l, fastfloat r ) { return fastfloat( l ) < r ; }
+inline bool operator<= ( double l, fastfloat r ) { return fastfloat( l ) <= r ; }
+inline bool operator> ( double l, fastfloat r ) { return fastfloat( l ) > r ; }
+inline bool operator>= ( double l, fastfloat r ) { return fastfloat( l ) >= r ; }
+inline bool operator== ( double l, fastfloat r ) { return fastfloat( l ) == r ; }
+inline bool operator!= ( double l, fastfloat r ) { return fastfloat( l ) != r ; }
+
+inline double fasttodouble( fastfloat v ) { return v.toDouble(); }
+inline long fasttolong( fastfloat v ) { return v.toLong(); }
+
+#if 1 // change to 0 to turn fastfloat usage off
+#else
+#define fastfloat double
+#define fasttodouble( v ) double( v )
+#define fasttolong( v ) long( v )
+#endif
+
+//fastfloat end
+
+
+typedef fastfloat (*Filter)(const fastfloat, const fastfloat);
+
+typedef struct _ContributionInfo
+{
+ fastfloat
+ weight;
+
+ long
+ pixel;
+} ContributionInfo;
+
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% R e s i z e I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% ResizeImage() scales an image to the desired dimensions with one of these
+% filters:
+%
+% Bessel Blackman Box
+% Catrom Cubic Gaussian
+% Hanning Hermite Lanczos
+% Mitchell Point Quandratic
+% Sinc Triangle
+%
+% Most of the filters are FIR (finite impulse response), however, Bessel,
+% Gaussian, and Sinc are IIR (infinite impulse response). Bessel and Sinc
+% are windowed (brought down to zero) with the Blackman filter.
+%
+% ResizeImage() was inspired by Paul Heckbert's zoom program.
+%
+% The format of the ResizeImage method is:
+%
+% Image *ResizeImage(Image *image,const unsigned long columns,
+% const unsigned long rows,const FilterTypes filter,const double blur,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o image: The image.
+%
+% o columns: The number of columns in the scaled image.
+%
+% o rows: The number of rows in the scaled image.
+%
+% o filter: Image filter to use.
+%
+% o blur: The blur factor where > 1 is blurry, < 1 is sharp.
+%
+% o exception: Return any errors or warnings in this structure.
+%
+%
+*/
+
+#if 0
+static fastfloat Bessel(const fastfloat x,const fastfloat)
+{
+ if (x == 0.0)
+ return(MagickPI/4.0);
+ return(BesselOrderOne(MagickPI*x)/(2.0*x));
+}
+
+static fastfloat Sinc(const fastfloat x,const fastfloat)
+{
+ if (x == 0.0)
+ return(1.0);
+ return(sin(MagickPI*x)/(MagickPI*x));
+}
+
+static fastfloat Blackman(const fastfloat x,const fastfloat)
+{
+ return(0.42+0.5*cos(MagickPI*x)+0.08*cos(2*MagickPI*x));
+}
+
+static fastfloat BlackmanBessel(const fastfloat x,const fastfloat)
+{
+ return(Blackman(x/support,support)*Bessel(x,support));
+}
+
+static fastfloat BlackmanSinc(const fastfloat x,const fastfloat)
+{
+ return(Blackman(x/support,support)*Sinc(x,support));
+}
+#endif
+
+static fastfloat Box(const fastfloat x,const fastfloat)
+{
+ if (x < -0.5)
+ return(0.0);
+ if (x < 0.5)
+ return(1.0);
+ return(0.0);
+}
+
+#if 0
+static fastfloat Catrom(const fastfloat x,const fastfloat)
+{
+ if (x < -2.0)
+ return(0.0);
+ if (x < -1.0)
+ return(0.5*(4.0+x*(8.0+x*(5.0+x))));
+ if (x < 0.0)
+ return(0.5*(2.0+x*x*(-5.0-3.0*x)));
+ if (x < 1.0)
+ return(0.5*(2.0+x*x*(-5.0+3.0*x)));
+ if (x < 2.0)
+ return(0.5*(4.0+x*(-8.0+x*(5.0-x))));
+ return(0.0);
+}
+
+static fastfloat Cubic(const fastfloat x,const fastfloat)
+{
+ if (x < -2.0)
+ return(0.0);
+ if (x < -1.0)
+ return((2.0+x)*(2.0+x)*(2.0+x)/6.0);
+ if (x < 0.0)
+ return((4.0+x*x*(-6.0-3.0*x))/6.0);
+ if (x < 1.0)
+ return((4.0+x*x*(-6.0+3.0*x))/6.0);
+ if (x < 2.0)
+ return((2.0-x)*(2.0-x)*(2.0-x)/6.0);
+ return(0.0);
+}
+
+static fastfloat Gaussian(const fastfloat x,const fastfloat)
+{
+ return(exp(-2.0*x*x)*sqrt(2.0/MagickPI));
+}
+
+static fastfloat Hanning(const fastfloat x,const fastfloat)
+{
+ return(0.5+0.5*cos(MagickPI*x));
+}
+
+static fastfloat Hamming(const fastfloat x,const fastfloat)
+{
+ return(0.54+0.46*cos(MagickPI*x));
+}
+
+static fastfloat Hermite(const fastfloat x,const fastfloat)
+{
+ if (x < -1.0)
+ return(0.0);
+ if (x < 0.0)
+ return((2.0*(-x)-3.0)*(-x)*(-x)+1.0);
+ if (x < 1.0)
+ return((2.0*x-3.0)*x*x+1.0);
+ return(0.0);
+}
+
+static fastfloat Lanczos(const fastfloat x,const fastfloat support)
+{
+ if (x < -3.0)
+ return(0.0);
+ if (x < 0.0)
+ return(Sinc(-x,support)*Sinc(-x/3.0,support));
+ if (x < 3.0)
+ return(Sinc(x,support)*Sinc(x/3.0,support));
+ return(0.0);
+}
+
+static fastfloat Mitchell(const fastfloat x,const fastfloat)
+{
+#define B (1.0/3.0)
+#define C (1.0/3.0)
+#define P0 (( 6.0- 2.0*B )/6.0)
+#define P2 ((-18.0+12.0*B+ 6.0*C)/6.0)
+#define P3 (( 12.0- 9.0*B- 6.0*C)/6.0)
+#define Q0 (( 8.0*B+24.0*C)/6.0)
+#define Q1 (( -12.0*B-48.0*C)/6.0)
+#define Q2 (( 6.0*B+30.0*C)/6.0)
+#define Q3 (( - 1.0*B- 6.0*C)/6.0)
+
+ if (x < -2.0)
+ return(0.0);
+ if (x < -1.0)
+ return(Q0-x*(Q1-x*(Q2-x*Q3)));
+ if (x < 0.0)
+ return(P0+x*x*(P2-x*P3));
+ if (x < 1.0)
+ return(P0+x*x*(P2+x*P3));
+ if (x < 2.0)
+ return(Q0+x*(Q1+x*(Q2+x*Q3)));
+ return(0.0);
+
+#undef B
+#undef C
+#undef P0
+#undef P2
+#undef P3
+#undef Q0
+#undef Q1
+#undef Q2
+#undef Q3
+}
+#endif
+
+// this is the same like Mitchell, but it has different values
+// for B and C, resulting in sharper images
+// http://sourceforge.net/mailarchive/forum.php?thread_id=7445822&forum_id=1210
+static fastfloat Bicubic(const fastfloat x,const fastfloat)
+{
+#define B (0.0/3.0)
+#define C (2.0/3.0)
+#define P0 (( 6.0- 2.0*B )/6.0)
+#define P2 ((-18.0+12.0*B+ 6.0*C)/6.0)
+#define P3 (( 12.0- 9.0*B- 6.0*C)/6.0)
+#define Q0 (( 8.0*B+24.0*C)/6.0)
+#define Q1 (( -12.0*B-48.0*C)/6.0)
+#define Q2 (( 6.0*B+30.0*C)/6.0)
+#define Q3 (( - 1.0*B- 6.0*C)/6.0)
+
+ if (x < -2.0)
+ return(0.0);
+ if (x < -1.0)
+ return(Q0-x*(Q1-x*(Q2-x*Q3)));
+ if (x < 0.0)
+ return(P0+x*x*(P2-x*P3));
+ if (x < 1.0)
+ return(P0+x*x*(P2+x*P3));
+ if (x < 2.0)
+ return(Q0+x*(Q1+x*(Q2+x*Q3)));
+ return(0.0);
+
+#undef B
+#undef C
+#undef P0
+#undef P2
+#undef P3
+#undef Q0
+#undef Q1
+#undef Q2
+#undef Q3
+}
+
+#if 0
+static fastfloat Quadratic(const fastfloat x,const fastfloat)
+{
+ if (x < -1.5)
+ return(0.0);
+ if (x < -0.5)
+ return(0.5*(x+1.5)*(x+1.5));
+ if (x < 0.5)
+ return(0.75-x*x);
+ if (x < 1.5)
+ return(0.5*(x-1.5)*(x-1.5));
+ return(0.0);
+}
+#endif
+
+static fastfloat Triangle(const fastfloat x,const fastfloat)
+{
+ if (x < -1.0)
+ return(0.0);
+ if (x < 0.0)
+ return(1.0+x);
+ if (x < 1.0)
+ return(1.0-x);
+ return(0.0);
+}
+
+static void HorizontalFilter(const TQImage& source,TQImage& destination,
+ const fastfloat x_factor,const fastfloat blur,
+ ContributionInfo *contribution, Filter filter, fastfloat filtersupport)
+{
+ fastfloat
+ center,
+ density,
+ scale,
+ support;
+
+ long
+ n,
+ start,
+ stop,
+ y;
+
+ long
+ i,
+ x;
+
+ /*
+ Apply filter to resize horizontally from source to destination.
+ */
+ scale=blur*Max(1.0/x_factor,1.0);
+ support=scale* filtersupport;
+ if (support <= 0.5)
+ {
+ /*
+ Reduce to point sampling.
+ */
+ support=0.5+MagickEpsilon;
+ scale=1.0;
+ }
+ scale=1.0/scale;
+ for (x=0; x < (long) destination.width(); x++)
+ {
+ center=(fastfloat) (x+0.5)/x_factor;
+ start= fasttolong(Max(center-support+0.5,0));
+ stop= fasttolong(Min(center+support+0.5,source.width()));
+ density=0.0;
+ for (n=0; n < (stop-start); n++)
+ {
+ contribution[n].pixel=start+n;
+ contribution[n].weight=
+ filter (scale*(start+n-center+0.5), filtersupport );
+ density+=contribution[n].weight;
+ }
+ if ((density != 0.0) && (density != 1.0))
+ {
+ /*
+ Normalize.
+ */
+ density=1.0/density;
+ for (i=0; i < n; i++)
+ contribution[i].weight*=density;
+ }
+// p=AcquireImagePixels(source,contribution[0].pixel,0,contribution[n-1].pixel-
+// contribution[0].pixel+1,source->rows,exception);
+// q=SetImagePixels(destination,x,0,1,destination->rows);
+ for (y=0; y < (long) destination.height(); y++)
+ {
+ fastfloat red = 0;
+ fastfloat green = 0;
+ fastfloat blue = 0;
+ fastfloat alpha = 0;
+ for (i=0; i < n; i++)
+ {
+ int px = contribution[i].pixel;
+ int py = y;
+ TQRgb p = reinterpret_cast< TQRgb* >( const_cast<TQImage&>(source).jumpTable()[ py ])[ px ];
+ red+=contribution[i].weight*tqRed(p);
+ green+=contribution[i].weight*tqGreen(p);
+ blue+=contribution[i].weight*tqBlue(p);
+ alpha+=contribution[i].weight*tqAlpha(p);
+ }
+ TQRgb pix = tqRgba(
+ fasttolong( red < 0 ? 0 : red > 255 ? 255 : red + 0.5 ),
+ fasttolong( green < 0 ? 0 : green > 255 ? 255 : green + 0.5 ),
+ fasttolong( blue < 0 ? 0 : blue > 255 ? 255 : blue + 0.5 ),
+ fasttolong( alpha < 0 ? 0 : alpha > 255 ? 255 : alpha + 0.5 ));
+ reinterpret_cast< TQRgb* >( destination.jumpTable()[ y ])[ x ] = pix;
+ }
+ }
+}
+
+static void VerticalFilter(const TQImage& source,TQImage& destination,
+ const fastfloat y_factor,const fastfloat blur,
+ ContributionInfo *contribution, Filter filter, fastfloat filtersupport )
+{
+ fastfloat
+ center,
+ density,
+ scale,
+ support;
+
+ long
+ n,
+ start,
+ stop,
+ x;
+
+ long
+ i,
+ y;
+
+ /*
+ Apply filter to resize vertically from source to destination.
+ */
+ scale=blur*Max(1.0/y_factor,1.0);
+ support=scale* filtersupport;
+ if (support <= 0.5)
+ {
+ /*
+ Reduce to point sampling.
+ */
+ support=0.5+MagickEpsilon;
+ scale=1.0;
+ }
+ scale=1.0/scale;
+ for (y=0; y < (long) destination.height(); y++)
+ {
+ center=(fastfloat) (y+0.5)/y_factor;
+ start= fasttolong(Max(center-support+0.5,0));
+ stop= fasttolong(Min(center+support+0.5,source.height()));
+ density=0.0;
+ for (n=0; n < (stop-start); n++)
+ {
+ contribution[n].pixel=start+n;
+ contribution[n].weight=
+ filter (scale*(start+n-center+0.5), filtersupport);
+ density+=contribution[n].weight;
+ }
+ if ((density != 0.0) && (density != 1.0))
+ {
+ /*
+ Normalize.
+ */
+ density=1.0/density;
+ for (i=0; i < n; i++)
+ contribution[i].weight*=density;
+ }
+// p=AcquireImagePixels(source,0,contribution[0].pixel,source->columns,
+// contribution[n-1].pixel-contribution[0].pixel+1,exception);
+// q=SetImagePixels(destination,0,y,destination->columns,1);
+ for (x=0; x < (long) destination.width(); x++)
+ {
+ fastfloat red = 0;
+ fastfloat green = 0;
+ fastfloat blue = 0;
+ fastfloat alpha = 0;
+ for (i=0; i < n; i++)
+ {
+ int px = x;
+ int py = contribution[i].pixel;
+ TQRgb p = reinterpret_cast< TQRgb* >( const_cast<TQImage&>(source).jumpTable()[ py ])[ px ];
+ red+=contribution[i].weight*tqRed(p);
+ green+=contribution[i].weight*tqGreen(p);
+ blue+=contribution[i].weight*tqBlue(p);
+ alpha+=contribution[i].weight*tqAlpha(p);
+ }
+ TQRgb pix = tqRgba(
+ fasttolong( red < 0 ? 0 : red > 255 ? 255 : red + 0.5 ),
+ fasttolong( green < 0 ? 0 : green > 255 ? 255 : green + 0.5 ),
+ fasttolong( blue < 0 ? 0 : blue > 255 ? 255 : blue + 0.5 ),
+ fasttolong( alpha < 0 ? 0 : alpha > 255 ? 255 : alpha + 0.5 ));
+ reinterpret_cast< TQRgb* >( destination.jumpTable()[ y ])[ x ] = pix;
+ }
+ }
+}
+
+static TQImage ResizeImage(const TQImage& image,const int columns,
+ const int rows, Filter filter, fastfloat filtersupport, double blur)
+{
+ ContributionInfo
+ *contribution;
+
+ fastfloat
+ support,
+ x_factor,
+ x_support,
+ y_factor,
+ y_support;
+
+ /*
+ Initialize resize image attributes.
+ */
+ if ((columns == image.width()) && (rows == image.height()) && (blur == 1.0))
+ return image.copy();
+ TQImage resize_image( columns, rows, 32 );
+ resize_image.setAlphaBuffer( image.hasAlphaBuffer());
+ /*
+ Allocate filter contribution info.
+ */
+ x_factor=(fastfloat) resize_image.width()/image.width();
+ y_factor=(fastfloat) resize_image.height()/image.height();
+// i=(long) LanczosFilter;
+// if (image->filter != UndefinedFilter)
+// i=(long) image->filter;
+// else
+// if ((image->storage_class == PseudoClass) || image->matte ||
+// ((x_factor*y_factor) > 1.0))
+// i=(long) MitchellFilter;
+ x_support=blur*Max(1.0/x_factor,1.0)*filtersupport;
+ y_support=blur*Max(1.0/y_factor,1.0)*filtersupport;
+ support=Max(x_support,y_support);
+ if (support < filtersupport)
+ support=filtersupport;
+ contribution=new ContributionInfo[ fasttolong( 2.0*Max(support,0.5)+3 ) ];
+ TQ_CHECK_PTR( contribution );
+ /*
+ Resize image.
+ */
+ if (((fastfloat) columns*(image.height()+rows)) >
+ ((fastfloat) rows*(image.width()+columns)))
+ {
+ TQImage source_image( columns, image.height(), 32 );
+ source_image.setAlphaBuffer( image.hasAlphaBuffer());
+ HorizontalFilter(image,source_image,x_factor,blur,
+ contribution,filter,filtersupport);
+ VerticalFilter(source_image,resize_image,y_factor,
+ blur,contribution,filter,filtersupport);
+ }
+ else
+ {
+ TQImage source_image( image.width(), rows, 32 );
+ source_image.setAlphaBuffer( image.hasAlphaBuffer());
+ VerticalFilter(image,source_image,y_factor,blur,
+ contribution,filter,filtersupport);
+ HorizontalFilter(source_image,resize_image,x_factor,
+ blur,contribution,filter,filtersupport);
+ }
+ /*
+ Free allocated memory.
+ */
+ delete[] contribution;
+ return(resize_image);
+}
+
+
+#undef Max
+#undef Min
+#undef MagickEpsilon
+
+
+// filters and their matching support values
+#if 0
+ static const FilterInfo
+ filters[SincFilter+1] =
+ {
+ { Box, 0.0 },
+ { Box, 0.0 },
+ { Box, 0.5 },
+ { Triangle, 1.0 },
+ { Hermite, 1.0 },
+ { Hanning, 1.0 },
+ { Hamming, 1.0 },
+ { Blackman, 1.0 },
+ { Gaussian, 1.25 },
+ { Quadratic, 1.5 },
+ { Cubic, 2.0 },
+ { Catrom, 2.0 },
+ { Mitchell, 2.0 },
+ { Lanczos, 3.0 },
+ { BlackmanBessel, 3.2383 },
+ { BlackmanSinc, 4.0 }
+ };
+#endif
+
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% S a m p l e I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% SampleImage() scales an image to the desired dimensions with pixel
+% sampling. Unlike other scaling methods, this method does not introduce
+% any additional color into the scaled image.
+%
+% The format of the SampleImage method is:
+%
+% Image *SampleImage(const Image *image,const unsigned long columns,
+% const unsigned long rows,ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o image: The image.
+%
+% o columns: The number of columns in the sampled image.
+%
+% o rows: The number of rows in the sampled image.
+%
+% o exception: Return any errors or warnings in this structure.
+%
+%
+*/
+TQImage SampleImage(const TQImage& image,const int columns,
+ const int rows)
+{
+ int
+ *x_offset,
+ *y_offset;
+
+ long
+ j,
+ y;
+
+ uchar
+ *pixels;
+
+ const uchar
+ *p;
+
+ long
+ x;
+
+ uchar
+ *q;
+
+ /*
+ Initialize sampled image attributes.
+ */
+ if ((columns == image.width()) && (rows == image.height()))
+ return image;
+ // This function is modified to handle any image depth, not only
+ // 32bit like the ImageMagick original. This avoids the relatively
+ // expensive conversion.
+ const int d = image.depth() / 8;
+ TQImage sample_image( columns, rows, image.depth());
+ sample_image.setAlphaBuffer( image.hasAlphaBuffer());
+ /*
+ Allocate scan line buffer and column offset buffers.
+ */
+ pixels= new uchar[ image.width() * d ];
+ x_offset= new int[ sample_image.width() ];
+ y_offset= new int[ sample_image.height() ];
+ /*
+ Initialize pixel offsets.
+ */
+// In the following several code 0.5 needs to be added, otherwise the image
+// would be moved by half a pixel to bottom-right, just like
+// with TQt's TQImage::scale()
+ for (x=0; x < (long) sample_image.width(); x++)
+ {
+ x_offset[x]=int((x+0.5)*image.width()/sample_image.width());
+ }
+ for (y=0; y < (long) sample_image.height(); y++)
+ {
+ y_offset[y]=int((y+0.5)*image.height()/sample_image.height());
+ }
+ /*
+ Sample each row.
+ */
+ j=(-1);
+ for (y=0; y < (long) sample_image.height(); y++)
+ {
+ q= sample_image.scanLine( y );
+ if (j != y_offset[y] )
+ {
+ /*
+ Read a scan line.
+ */
+ j= y_offset[y];
+ p= image.scanLine( j );
+ (void) memcpy(pixels,p,image.width()*d);
+ }
+ /*
+ Sample each column.
+ */
+ switch( d )
+ {
+ case 1: // 8bit
+ for (x=0; x < (long) sample_image.width(); x++)
+ {
+ *q++=pixels[ x_offset[x] ];
+ }
+ break;
+ case 4: // 32bit
+ for (x=0; x < (long) sample_image.width(); x++)
+ {
+ *(TQRgb*)q=((TQRgb*)pixels)[ x_offset[x] ];
+ q += d;
+ }
+ break;
+ default:
+ for (x=0; x < (long) sample_image.width(); x++)
+ {
+ memcpy( q, pixels + x_offset[x] * d, d );
+ q += d;
+ }
+ break;
+ }
+ }
+ if( d != 4 ) // != 32bit
+ {
+ sample_image.setNumColors( image.numColors());
+ for( int i = 0; i < image.numColors(); ++i )
+ sample_image.setColor( i, image.color( i ));
+ }
+ delete[] y_offset;
+ delete[] x_offset;
+ delete[] pixels;
+ return sample_image;
+}
+
+
+// ImageMagick code end
+
+
+// Imlib2/Mosfet code begin
+// ------------------------
+
+// This code is Imlib2 code, additionally modified by Mosfet, and with few small
+// modifications for Gwenview. The MMX scaling code also belongs to it.
+
+// The original license texts follow.
+
+/**
+ * This is the normal smoothscale method, based on Imlib2's smoothscale.
+ *
+ * Originally I took the algorithm used in NetPBM and TQt and added MMX/3dnow
+ * optimizations. It ran in about 1/2 the time as TQt. Then I ported Imlib's
+ * C algorithm and it ran at about the same speed as my MMX optimized one...
+ * Finally I ported Imlib's MMX version and it ran in less than half the
+ * time as my MMX algorithm, (taking only a quarter of the time TQt does).
+ *
+ * Changes include formatting, namespaces and other C++'ings, removal of old
+ * #ifdef'ed code, and removal of unneeded border calculation code.
+ *
+ * Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code
+ * is by Willem Monsuwe <[email protected]>. All other modifications are
+ * (C) Daniel M. Duley.
+ */
+
+/*
+ Copyright (C) 2004 Daniel M. Duley <[email protected]>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+/*
+Copyright (C) 2000 Carsten Haitzler and various contributors (see AUTHORS)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies of the Software and its Copyright notices. In addition publicly
+documented acknowledgment must be given that this software has been used if no
+source code of this software is made available publicly. This includes
+acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
+documents or any documentation provided with any product containing this
+software. This License does not apply to any software that links to the
+libraries provided by this software (statically or dynamically), but only to
+the software provided.
+
+Please see the COPYING.PLAIN for a plain-english explanation of this notice
+and it's intent.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+namespace MImageScale{
+ typedef struct __mimage_scale_info
+ {
+ int *xpoints;
+ unsigned int **ypoints;
+ int *xapoints, *yapoints;
+ int xup_yup;
+ } MImageScaleInfo;
+
+ unsigned int** mimageCalcYPoints(unsigned int *src, int sow, int sh,
+ int dh);
+ int* mimageCalcXPoints(int sw, int dw);
+ int* mimageCalcApoints(int s, int d, int up);
+ MImageScaleInfo* mimageFreeScaleInfo(MImageScaleInfo *isi);
+ MImageScaleInfo *mimageCalcScaleInfo(TQImage &img, int sw, int sh,
+ int dw, int dh, char aa, int sow);
+ void mimageSampleRGBA(MImageScaleInfo *isi, unsigned int *dest, int dxx,
+ int dyy, int dx, int dy, int dw, int dh, int dow);
+ void mimageScaleAARGBA(MImageScaleInfo *isi, unsigned int *dest, int dxx,
+ int dyy, int dx, int dy, int dw, int dh, int dow,
+ int sow);
+ void mimageScaleAARGB(MImageScaleInfo *isi, unsigned int *dest, int dxx,
+ int dyy, int dx, int dy, int dw, int dh, int dow, int
+ sow);
+ TQImage smoothScale(const TQImage& img, int dw, int dh);
+}
+
+#ifdef HAVE_X86_MMX
+extern "C" {
+ void __mimageScale_mmx_AARGBA(MImageScale::MImageScaleInfo *isi,
+ unsigned int *dest, int dxx, int dyy,
+ int dx, int dy, int dw, int dh,
+ int dow, int sow);
+}
+#endif
+
+using namespace MImageScale;
+
+TQImage MImageScale::smoothScale(const TQImage& image, int dw, int dh)
+{
+ TQImage img = image.depth() < 32 ? image.convertDepth( 32 ) : image;
+ int w = img.width();
+ int h = img.height();
+
+ int sow = img.bytesPerLine();
+ // handle CroppedTQImage
+ if( img.height() > 1 && sow != img.scanLine( 1 ) - img.scanLine( 0 ))
+ sow = img.scanLine( 1 ) - img.scanLine( 0 );
+ sow = sow / ( img.depth() / 8 );
+
+ MImageScaleInfo *scaleinfo =
+ mimageCalcScaleInfo(img, w, h, dw, dh, true, sow);
+ if(!scaleinfo)
+ return TQImage();
+
+ TQImage buffer(dw, dh, 32);
+ buffer.setAlphaBuffer(img.hasAlphaBuffer());
+
+#ifdef HAVE_X86_MMX
+//#warning Using MMX Smoothscale
+ bool haveMMX = KCPUInfo::haveExtension( KCPUInfo::IntelMMX );
+ if(haveMMX){
+ __mimageScale_mmx_AARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0),
+ 0, 0, 0, 0, dw, dh, dw, sow);
+ }
+ else
+#endif
+ {
+ if(img.hasAlphaBuffer())
+ mimageScaleAARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0), 0, 0,
+ 0, 0, dw, dh, dw, sow);
+ else
+ mimageScaleAARGB(scaleinfo, (unsigned int *)buffer.scanLine(0), 0, 0,
+ 0, 0, dw, dh, dw, sow);
+ }
+ mimageFreeScaleInfo(scaleinfo);
+ return(buffer);
+}
+
+//
+// Code ported from Imlib...
+//
+
+// FIXME: replace with mRed, etc... These work on pointers to pixels, not
+// pixel values
+#if BYTE_ORDER == BIG_ENDIAN
+#define A_VAL(p) ((unsigned char *)(p))[0]
+#define R_VAL(p) ((unsigned char *)(p))[1]
+#define G_VAL(p) ((unsigned char *)(p))[2]
+#define B_VAL(p) ((unsigned char *)(p))[3]
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define A_VAL(p) ((unsigned char *)(p))[3]
+#define R_VAL(p) ((unsigned char *)(p))[2]
+#define G_VAL(p) ((unsigned char *)(p))[1]
+#define B_VAL(p) ((unsigned char *)(p))[0]
+#else
+#error "BYTE_ORDER is not defined"
+#endif
+
+#define INV_XAP (256 - xapoints[x])
+#define XAP (xapoints[x])
+#define INV_YAP (256 - yapoints[dyy + y])
+#define YAP (yapoints[dyy + y])
+
+unsigned int** MImageScale::mimageCalcYPoints(unsigned int *src,
+ int sow, int sh, int dh)
+{
+ unsigned int **p;
+ int i, j = 0;
+ int val, inc, rv = 0;
+
+ if(dh < 0){
+ dh = -dh;
+ rv = 1;
+ }
+ p = new unsigned int* [dh+1];
+
+ val = 0;
+ inc = (sh << 16) / dh;
+ for(i = 0; i < dh; i++){
+ p[j++] = src + ((val >> 16) * sow);
+ val += inc;
+ }
+ if(rv){
+ for(i = dh / 2; --i >= 0; ){
+ unsigned int *tmp = p[i];
+ p[i] = p[dh - i - 1];
+ p[dh - i - 1] = tmp;
+ }
+ }
+ return(p);
+}
+
+int* MImageScale::mimageCalcXPoints(int sw, int dw)
+{
+ int *p, i, j = 0;
+ int val, inc, rv = 0;
+
+ if(dw < 0){
+ dw = -dw;
+ rv = 1;
+ }
+ p = new int[dw+1];
+
+ val = 0;
+ inc = (sw << 16) / dw;
+ for(i = 0; i < dw; i++){
+ p[j++] = (val >> 16);
+ val += inc;
+ }
+
+ if(rv){
+ for(i = dw / 2; --i >= 0; ){
+ int tmp = p[i];
+ p[i] = p[dw - i - 1];
+ p[dw - i - 1] = tmp;
+ }
+ }
+ return(p);
+}
+
+int* MImageScale::mimageCalcApoints(int s, int d, int up)
+{
+ int *p, i, j = 0, rv = 0;
+
+ if(d < 0){
+ rv = 1;
+ d = -d;
+ }
+ p = new int[d];
+
+ /* scaling up */
+ if(up){
+ int val, inc;
+
+ val = 0;
+ inc = (s << 16) / d;
+ for(i = 0; i < d; i++){
+ p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00);
+ if((val >> 16) >= (s - 1))
+ p[j - 1] = 0;
+ val += inc;
+ }
+ }
+ /* scaling down */
+ else{
+ int val, inc, ap, Cp;
+ val = 0;
+ inc = (s << 16) / d;
+ Cp = ((d << 14) / s) + 1;
+ for(i = 0; i < d; i++){
+ ap = ((0x100 - ((val >> 8) & 0xff)) * Cp) >> 8;
+ p[j] = ap | (Cp << 16);
+ j++;
+ val += inc;
+ }
+ }
+ if(rv){
+ int tmp;
+ for(i = d / 2; --i >= 0; ){
+ tmp = p[i];
+ p[i] = p[d - i - 1];
+ p[d - i - 1] = tmp;
+ }
+ }
+ return(p);
+}
+
+MImageScaleInfo* MImageScale::mimageFreeScaleInfo(MImageScaleInfo *isi)
+{
+ if(isi){
+ delete[] isi->xpoints;
+ delete[] isi->ypoints;
+ delete[] isi->xapoints;
+ delete[] isi->yapoints;
+ delete isi;
+ }
+ return(NULL);
+}
+
+MImageScaleInfo* MImageScale::mimageCalcScaleInfo(TQImage &img, int sw, int sh,
+ int dw, int dh, char aa, int sow)
+{
+ MImageScaleInfo *isi;
+ int scw, sch;
+
+ scw = dw * img.width() / sw;
+ sch = dh * img.height() / sh;
+
+ isi = new MImageScaleInfo;
+ if(!isi)
+ return(NULL);
+ memset(isi, 0, sizeof(MImageScaleInfo));
+
+ isi->xup_yup = (abs(dw) >= sw) + ((abs(dh) >= sh) << 1);
+
+ isi->xpoints = mimageCalcXPoints(img.width(), scw);
+ if(!isi->xpoints)
+ return(mimageFreeScaleInfo(isi));
+ isi->ypoints = mimageCalcYPoints((unsigned int *)img.scanLine(0),
+ sow, img.height(), sch );
+ if (!isi->ypoints)
+ return(mimageFreeScaleInfo(isi));
+ if(aa){
+ isi->xapoints = mimageCalcApoints(img.width(), scw, isi->xup_yup & 1);
+ if(!isi->xapoints)
+ return(mimageFreeScaleInfo(isi));
+ isi->yapoints = mimageCalcApoints(img.height(), sch, isi->xup_yup & 2);
+ if(!isi->yapoints)
+ return(mimageFreeScaleInfo(isi));
+ }
+ return(isi);
+}
+
+/* scale by pixel sampling only */
+void MImageScale::mimageSampleRGBA(MImageScaleInfo *isi, unsigned int *dest,
+ int dxx, int dyy, int dx, int dy, int dw,
+ int dh, int dow)
+{
+ unsigned int *sptr, *dptr;
+ int x, y, end;
+ unsigned int **ypoints = isi->ypoints;
+ int *xpoints = isi->xpoints;
+
+ /* whats the last pixel ont he line so we stop there */
+ end = dxx + dw;
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ /* get the pointer to the start of the destination scanline */
+ dptr = dest + dx + ((y + dy) * dow);
+ /* calculate the source line we'll scan from */
+ sptr = ypoints[dyy + y];
+ /* go thru the scanline and copy across */
+ for(x = dxx; x < end; x++)
+ *dptr++ = sptr[xpoints[x]];
+ }
+}
+
+/* FIXME: NEED to optimise ScaleAARGBA - currently its "ok" but needs work*/
+
+/* scale by area sampling */
+void MImageScale::mimageScaleAARGBA(MImageScaleInfo *isi, unsigned int *dest,
+ int dxx, int dyy, int dx, int dy, int dw,
+ int dh, int dow, int sow)
+{
+ unsigned int *sptr, *dptr;
+ int x, y, end;
+ unsigned int **ypoints = isi->ypoints;
+ int *xpoints = isi->xpoints;
+ int *xapoints = isi->xapoints;
+ int *yapoints = isi->yapoints;
+
+ end = dxx + dw;
+ /* scaling up both ways */
+ if(isi->xup_yup == 3){
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ /* calculate the source line we'll scan from */
+ dptr = dest + dx + ((y + dy) * dow);
+ sptr = ypoints[dyy + y];
+ if(YAP > 0){
+ for(x = dxx; x < end; x++){
+ int r, g, b, a;
+ int rr, gg, bb, aa;
+ unsigned int *pix;
+
+ if(XAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ a = A_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ a += A_VAL(pix) * XAP;
+ pix += sow;
+ rr = R_VAL(pix) * XAP;
+ gg = G_VAL(pix) * XAP;
+ bb = B_VAL(pix) * XAP;
+ aa = A_VAL(pix) * XAP;
+ pix--;
+ rr += R_VAL(pix) * INV_XAP;
+ gg += G_VAL(pix) * INV_XAP;
+ bb += B_VAL(pix) * INV_XAP;
+ aa += A_VAL(pix) * INV_XAP;
+ r = ((rr * YAP) + (r * INV_YAP)) >> 16;
+ g = ((gg * YAP) + (g * INV_YAP)) >> 16;
+ b = ((bb * YAP) + (b * INV_YAP)) >> 16;
+ a = ((aa * YAP) + (a * INV_YAP)) >> 16;
+ *dptr++ = tqRgba(r, g, b, a);
+ }
+ else{
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_YAP;
+ g = G_VAL(pix) * INV_YAP;
+ b = B_VAL(pix) * INV_YAP;
+ a = A_VAL(pix) * INV_YAP;
+ pix += sow;
+ r += R_VAL(pix) * YAP;
+ g += G_VAL(pix) * YAP;
+ b += B_VAL(pix) * YAP;
+ a += A_VAL(pix) * YAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ a >>= 8;
+ *dptr++ = tqRgba(r, g, b, a);
+ }
+ }
+ }
+ else{
+ for(x = dxx; x < end; x++){
+ int r, g, b, a;
+ unsigned int *pix;
+
+ if(XAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ a = A_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ a += A_VAL(pix) * XAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ a >>= 8;
+ *dptr++ = tqRgba(r, g, b, a);
+ }
+ else
+ *dptr++ = sptr[xpoints[x] ];
+ }
+ }
+ }
+ }
+ /* if we're scaling down vertically */
+ else if(isi->xup_yup == 1){
+ /*\ 'Correct' version, with math units prepared for MMXification \*/
+ int Cy, j;
+ unsigned int *pix;
+ int r, g, b, a, rr, gg, bb, aa;
+ int yap;
+
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ Cy = YAP >> 16;
+ yap = YAP & 0xffff;
+
+ dptr = dest + dx + ((y + dy) * dow);
+ for(x = dxx; x < end; x++){
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = (R_VAL(pix) * yap) >> 10;
+ g = (G_VAL(pix) * yap) >> 10;
+ b = (B_VAL(pix) * yap) >> 10;
+ a = (A_VAL(pix) * yap) >> 10;
+ for(j = (1 << 14) - yap; j > Cy; j -= Cy){
+ pix += sow;
+ r += (R_VAL(pix) * Cy) >> 10;
+ g += (G_VAL(pix) * Cy) >> 10;
+ b += (B_VAL(pix) * Cy) >> 10;
+ a += (A_VAL(pix) * Cy) >> 10;
+ }
+ if(j > 0){
+ pix += sow;
+ r += (R_VAL(pix) * j) >> 10;
+ g += (G_VAL(pix) * j) >> 10;
+ b += (B_VAL(pix) * j) >> 10;
+ a += (A_VAL(pix) * j) >> 10;
+ }
+ if(XAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x] + 1;
+ rr = (R_VAL(pix) * yap) >> 10;
+ gg = (G_VAL(pix) * yap) >> 10;
+ bb = (B_VAL(pix) * yap) >> 10;
+ aa = (A_VAL(pix) * yap) >> 10;
+ for(j = (1 << 14) - yap; j > Cy; j -= Cy){
+ pix += sow;
+ rr += (R_VAL(pix) * Cy) >> 10;
+ gg += (G_VAL(pix) * Cy) >> 10;
+ bb += (B_VAL(pix) * Cy) >> 10;
+ aa += (A_VAL(pix) * Cy) >> 10;
+ }
+ if(j > 0){
+ pix += sow;
+ rr += (R_VAL(pix) * j) >> 10;
+ gg += (G_VAL(pix) * j) >> 10;
+ bb += (B_VAL(pix) * j) >> 10;
+ aa += (A_VAL(pix) * j) >> 10;
+ }
+ r = r * INV_XAP;
+ g = g * INV_XAP;
+ b = b * INV_XAP;
+ a = a * INV_XAP;
+ r = (r + ((rr * XAP))) >> 12;
+ g = (g + ((gg * XAP))) >> 12;
+ b = (b + ((bb * XAP))) >> 12;
+ a = (a + ((aa * XAP))) >> 12;
+ }
+ else{
+ r >>= 4;
+ g >>= 4;
+ b >>= 4;
+ a >>= 4;
+ }
+ *dptr = tqRgba(r, g, b, a);
+ dptr++;
+ }
+ }
+ }
+ /* if we're scaling down horizontally */
+ else if(isi->xup_yup == 2){
+ /*\ 'Correct' version, with math units prepared for MMXification \*/
+ int Cx, j;
+ unsigned int *pix;
+ int r, g, b, a, rr, gg, bb, aa;
+ int xap;
+
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ dptr = dest + dx + ((y + dy) * dow);
+ for(x = dxx; x < end; x++){
+ Cx = XAP >> 16;
+ xap = XAP & 0xffff;
+
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = (R_VAL(pix) * xap) >> 10;
+ g = (G_VAL(pix) * xap) >> 10;
+ b = (B_VAL(pix) * xap) >> 10;
+ a = (A_VAL(pix) * xap) >> 10;
+ for(j = (1 << 14) - xap; j > Cx; j -= Cx){
+ pix++;
+ r += (R_VAL(pix) * Cx) >> 10;
+ g += (G_VAL(pix) * Cx) >> 10;
+ b += (B_VAL(pix) * Cx) >> 10;
+ a += (A_VAL(pix) * Cx) >> 10;
+ }
+ if(j > 0){
+ pix++;
+ r += (R_VAL(pix) * j) >> 10;
+ g += (G_VAL(pix) * j) >> 10;
+ b += (B_VAL(pix) * j) >> 10;
+ a += (A_VAL(pix) * j) >> 10;
+ }
+ if(YAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x] + sow;
+ rr = (R_VAL(pix) * xap) >> 10;
+ gg = (G_VAL(pix) * xap) >> 10;
+ bb = (B_VAL(pix) * xap) >> 10;
+ aa = (A_VAL(pix) * xap) >> 10;
+ for(j = (1 << 14) - xap; j > Cx; j -= Cx){
+ pix++;
+ rr += (R_VAL(pix) * Cx) >> 10;
+ gg += (G_VAL(pix) * Cx) >> 10;
+ bb += (B_VAL(pix) * Cx) >> 10;
+ aa += (A_VAL(pix) * Cx) >> 10;
+ }
+ if(j > 0){
+ pix++;
+ rr += (R_VAL(pix) * j) >> 10;
+ gg += (G_VAL(pix) * j) >> 10;
+ bb += (B_VAL(pix) * j) >> 10;
+ aa += (A_VAL(pix) * j) >> 10;
+ }
+ r = r * INV_YAP;
+ g = g * INV_YAP;
+ b = b * INV_YAP;
+ a = a * INV_YAP;
+ r = (r + ((rr * YAP))) >> 12;
+ g = (g + ((gg * YAP))) >> 12;
+ b = (b + ((bb * YAP))) >> 12;
+ a = (a + ((aa * YAP))) >> 12;
+ }
+ else{
+ r >>= 4;
+ g >>= 4;
+ b >>= 4;
+ a >>= 4;
+ }
+ *dptr = tqRgba(r, g, b, a);
+ dptr++;
+ }
+ }
+ }
+ /* if we're scaling down horizontally & vertically */
+ else{
+ /*\ 'Correct' version, with math units prepared for MMXification:
+ |*| The operation 'b = (b * c) >> 16' translates to pmulhw,
+ |*| so the operation 'b = (b * c) >> d' would translate to
+ |*| psllw (16 - d), %mmb; pmulh %mmc, %mmb
+ \*/
+ int Cx, Cy, i, j;
+ unsigned int *pix;
+ int a, r, g, b, ax, rx, gx, bx;
+ int xap, yap;
+
+ for(y = 0; y < dh; y++){
+ Cy = YAP >> 16;
+ yap = YAP & 0xffff;
+
+ dptr = dest + dx + ((y + dy) * dow);
+ for(x = dxx; x < end; x++){
+ Cx = XAP >> 16;
+ xap = XAP & 0xffff;
+
+ sptr = ypoints[dyy + y] + xpoints[x];
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ ax = (A_VAL(pix) * xap) >> 9;
+ pix++;
+ for(i = (1 << 14) - xap; i > Cx; i -= Cx){
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ ax += (A_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if(i > 0){
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ ax += (A_VAL(pix) * i) >> 9;
+ }
+
+ r = (rx * yap) >> 14;
+ g = (gx * yap) >> 14;
+ b = (bx * yap) >> 14;
+ a = (ax * yap) >> 14;
+
+ for(j = (1 << 14) - yap; j > Cy; j -= Cy){
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ ax = (A_VAL(pix) * xap) >> 9;
+ pix++;
+ for(i = (1 << 14) - xap; i > Cx; i -= Cx){
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ ax += (A_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if(i > 0){
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ ax += (A_VAL(pix) * i) >> 9;
+ }
+
+ r += (rx * Cy) >> 14;
+ g += (gx * Cy) >> 14;
+ b += (bx * Cy) >> 14;
+ a += (ax * Cy) >> 14;
+ }
+ if(j > 0){
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ ax = (A_VAL(pix) * xap) >> 9;
+ pix++;
+ for(i = (1 << 14) - xap; i > Cx; i -= Cx){
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ ax += (A_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if(i > 0){
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ ax += (A_VAL(pix) * i) >> 9;
+ }
+
+ r += (rx * j) >> 14;
+ g += (gx * j) >> 14;
+ b += (bx * j) >> 14;
+ a += (ax * j) >> 14;
+ }
+
+ R_VAL(dptr) = r >> 5;
+ G_VAL(dptr) = g >> 5;
+ B_VAL(dptr) = b >> 5;
+ A_VAL(dptr) = a >> 5;
+ dptr++;
+ }
+ }
+ }
+}
+
+/* scale by area sampling - IGNORE the ALPHA byte*/
+void MImageScale::mimageScaleAARGB(MImageScaleInfo *isi, unsigned int *dest,
+ int dxx, int dyy, int dx, int dy, int dw,
+ int dh, int dow, int sow)
+{
+ unsigned int *sptr, *dptr;
+ int x, y, end;
+ unsigned int **ypoints = isi->ypoints;
+ int *xpoints = isi->xpoints;
+ int *xapoints = isi->xapoints;
+ int *yapoints = isi->yapoints;
+
+ end = dxx + dw;
+ /* scaling up both ways */
+ if(isi->xup_yup == 3){
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ /* calculate the source line we'll scan from */
+ dptr = dest + dx + ((y + dy) * dow);
+ sptr = ypoints[dyy + y];
+ if(YAP > 0){
+ for(x = dxx; x < end; x++){
+ int r = 0, g = 0, b = 0;
+ int rr = 0, gg = 0, bb = 0;
+ unsigned int *pix;
+
+ if(XAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ pix += sow;
+ rr = R_VAL(pix) * XAP;
+ gg = G_VAL(pix) * XAP;
+ bb = B_VAL(pix) * XAP;
+ pix --;
+ rr += R_VAL(pix) * INV_XAP;
+ gg += G_VAL(pix) * INV_XAP;
+ bb += B_VAL(pix) * INV_XAP;
+ r = ((rr * YAP) + (r * INV_YAP)) >> 16;
+ g = ((gg * YAP) + (g * INV_YAP)) >> 16;
+ b = ((bb * YAP) + (b * INV_YAP)) >> 16;
+ *dptr++ = tqRgba(r, g, b, 0xff);
+ }
+ else{
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_YAP;
+ g = G_VAL(pix) * INV_YAP;
+ b = B_VAL(pix) * INV_YAP;
+ pix += sow;
+ r += R_VAL(pix) * YAP;
+ g += G_VAL(pix) * YAP;
+ b += B_VAL(pix) * YAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ *dptr++ = tqRgba(r, g, b, 0xff);
+ }
+ }
+ }
+ else{
+ for(x = dxx; x < end; x++){
+ int r = 0, g = 0, b = 0;
+ unsigned int *pix;
+
+ if(XAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ *dptr++ = tqRgba(r, g, b, 0xff);
+ }
+ else
+ *dptr++ = sptr[xpoints[x] ];
+ }
+ }
+ }
+ }
+ /* if we're scaling down vertically */
+ else if(isi->xup_yup == 1){
+ /*\ 'Correct' version, with math units prepared for MMXification \*/
+ int Cy, j;
+ unsigned int *pix;
+ int r, g, b, rr, gg, bb;
+ int yap;
+
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ Cy = YAP >> 16;
+ yap = YAP & 0xffff;
+
+ dptr = dest + dx + ((y + dy) * dow);
+ for(x = dxx; x < end; x++){
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = (R_VAL(pix) * yap) >> 10;
+ g = (G_VAL(pix) * yap) >> 10;
+ b = (B_VAL(pix) * yap) >> 10;
+ pix += sow;
+ for(j = (1 << 14) - yap; j > Cy; j -= Cy){
+ r += (R_VAL(pix) * Cy) >> 10;
+ g += (G_VAL(pix) * Cy) >> 10;
+ b += (B_VAL(pix) * Cy) >> 10;
+ pix += sow;
+ }
+ if(j > 0){
+ r += (R_VAL(pix) * j) >> 10;
+ g += (G_VAL(pix) * j) >> 10;
+ b += (B_VAL(pix) * j) >> 10;
+ }
+ if(XAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x] + 1;
+ rr = (R_VAL(pix) * yap) >> 10;
+ gg = (G_VAL(pix) * yap) >> 10;
+ bb = (B_VAL(pix) * yap) >> 10;
+ pix += sow;
+ for(j = (1 << 14) - yap; j > Cy; j -= Cy){
+ rr += (R_VAL(pix) * Cy) >> 10;
+ gg += (G_VAL(pix) * Cy) >> 10;
+ bb += (B_VAL(pix) * Cy) >> 10;
+ pix += sow;
+ }
+ if(j > 0){
+ rr += (R_VAL(pix) * j) >> 10;
+ gg += (G_VAL(pix) * j) >> 10;
+ bb += (B_VAL(pix) * j) >> 10;
+ }
+ r = r * INV_XAP;
+ g = g * INV_XAP;
+ b = b * INV_XAP;
+ r = (r + ((rr * XAP))) >> 12;
+ g = (g + ((gg * XAP))) >> 12;
+ b = (b + ((bb * XAP))) >> 12;
+ }
+ else{
+ r >>= 4;
+ g >>= 4;
+ b >>= 4;
+ }
+ *dptr = tqRgba(r, g, b, 0xff);
+ dptr++;
+ }
+ }
+ }
+ /* if we're scaling down horizontally */
+ else if(isi->xup_yup == 2){
+ /*\ 'Correct' version, with math units prepared for MMXification \*/
+ int Cx, j;
+ unsigned int *pix;
+ int r, g, b, rr, gg, bb;
+ int xap;
+
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ dptr = dest + dx + ((y + dy) * dow);
+ for(x = dxx; x < end; x++){
+ Cx = XAP >> 16;
+ xap = XAP & 0xffff;
+
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = (R_VAL(pix) * xap) >> 10;
+ g = (G_VAL(pix) * xap) >> 10;
+ b = (B_VAL(pix) * xap) >> 10;
+ pix++;
+ for(j = (1 << 14) - xap; j > Cx; j -= Cx){
+ r += (R_VAL(pix) * Cx) >> 10;
+ g += (G_VAL(pix) * Cx) >> 10;
+ b += (B_VAL(pix) * Cx) >> 10;
+ pix++;
+ }
+ if(j > 0){
+ r += (R_VAL(pix) * j) >> 10;
+ g += (G_VAL(pix) * j) >> 10;
+ b += (B_VAL(pix) * j) >> 10;
+ }
+ if(YAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x] + sow;
+ rr = (R_VAL(pix) * xap) >> 10;
+ gg = (G_VAL(pix) * xap) >> 10;
+ bb = (B_VAL(pix) * xap) >> 10;
+ pix++;
+ for(j = (1 << 14) - xap; j > Cx; j -= Cx){
+ rr += (R_VAL(pix) * Cx) >> 10;
+ gg += (G_VAL(pix) * Cx) >> 10;
+ bb += (B_VAL(pix) * Cx) >> 10;
+ pix++;
+ }
+ if(j > 0){
+ rr += (R_VAL(pix) * j) >> 10;
+ gg += (G_VAL(pix) * j) >> 10;
+ bb += (B_VAL(pix) * j) >> 10;
+ }
+ r = r * INV_YAP;
+ g = g * INV_YAP;
+ b = b * INV_YAP;
+ r = (r + ((rr * YAP))) >> 12;
+ g = (g + ((gg * YAP))) >> 12;
+ b = (b + ((bb * YAP))) >> 12;
+ }
+ else{
+ r >>= 4;
+ g >>= 4;
+ b >>= 4;
+ }
+ *dptr = tqRgba(r, g, b, 0xff);
+ dptr++;
+ }
+ }
+ }
+ /* fully optimized (i think) - onyl change of algorithm can help */
+ /* if we're scaling down horizontally & vertically */
+ else{
+ /*\ 'Correct' version, with math units prepared for MMXification \*/
+ int Cx, Cy, i, j;
+ unsigned int *pix;
+ int r, g, b, rx, gx, bx;
+ int xap, yap;
+
+ for(y = 0; y < dh; y++){
+ Cy = YAP >> 16;
+ yap = YAP & 0xffff;
+
+ dptr = dest + dx + ((y + dy) * dow);
+ for(x = dxx; x < end; x++){
+ Cx = XAP >> 16;
+ xap = XAP & 0xffff;
+
+ sptr = ypoints[dyy + y] + xpoints[x];
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ pix++;
+ for(i = (1 << 14) - xap; i > Cx; i -= Cx){
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if(i > 0){
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ }
+
+ r = (rx * yap) >> 14;
+ g = (gx * yap) >> 14;
+ b = (bx * yap) >> 14;
+
+ for(j = (1 << 14) - yap; j > Cy; j -= Cy){
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ pix++;
+ for(i = (1 << 14) - xap; i > Cx; i -= Cx){
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if(i > 0){
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ }
+
+ r += (rx * Cy) >> 14;
+ g += (gx * Cy) >> 14;
+ b += (bx * Cy) >> 14;
+ }
+ if(j > 0){
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ pix++;
+ for(i = (1 << 14) - xap; i > Cx; i -= Cx){
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if(i > 0){
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ }
+
+ r += (rx * j) >> 14;
+ g += (gx * j) >> 14;
+ b += (bx * j) >> 14;
+ }
+
+ R_VAL(dptr) = r >> 5;
+ G_VAL(dptr) = g >> 5;
+ B_VAL(dptr) = b >> 5;
+ dptr++;
+ }
+ }
+ }
+}
+
+// Imlib2/Mosfet code end
+
+TQImage scale(const TQImage& image, int width, int height,
+ SmoothAlgorithm alg, TQImage::ScaleMode mode, double blur )
+{
+ if( image.isNull()) return image.copy();
+
+ TQSize newSize( image.size() );
+ newSize.scale( TQSize( width, height ), (TQSize::ScaleMode)mode ); // ### remove cast in TQt 4.0
+ newSize = newSize.expandedTo( TQSize( 1, 1 )); // make sure it doesn't become null
+
+ if ( newSize == image.size() ) return image.copy();
+
+ width = newSize.width();
+ height = newSize.height();
+ Filter filter = NULL;
+ fastfloat filtersupport;
+
+ switch( alg ) {
+ case SMOOTH_NONE:
+ filter = NULL;
+ filtersupport = 0.0;
+ break;
+ case SMOOTH_FAST:
+ filter = Box;
+ filtersupport = 0.5;
+ break;
+ case SMOOTH_NORMAL:
+ default:
+ filter = Triangle;
+ filtersupport = 1.0;
+ break;
+ case SMOOTH_BEST:
+// filter = Mitchell;
+ filter = Bicubic;
+ filtersupport = 2.0;
+ break;
+ }
+
+ if( filter == Box && blur == 1.0 )
+ return MImageScale::smoothScale( image, width, height );
+
+ if( filter == Box && width > image.width() && height > image.height() && blur == 1.0 ) {
+ filter = NULL; // Box doesn't really smooth when enlarging
+ }
+
+ if( filter == NULL ) {
+ return SampleImage( image, width, height ); // doesn't need 32bit
+ }
+
+ return ResizeImage( image.convertDepth( 32 ), width, height, filter, filtersupport, blur );
+ // unlike TQt's smoothScale() this function introduces new colors to grayscale images ... oh well
+}
+
+
+} // namespace
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..ba4f08c
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,186 @@
+/***************************************************************************
+ main.cpp - description
+ -------------------
+ begin : Dec 10 2003
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tqgl.h>
+#include <tqdir.h>
+#include <tqfile.h>
+
+#include <tdeapplication.h>
+#include <tdecmdlineargs.h>
+#include <tdeaboutdata.h>
+#include <tdelocale.h>
+#include <tdeconfig.h>
+#include <dcopclient.h>
+#include <tdeglobal.h>
+#include <kstandarddirs.h>
+
+#include <cstdlib>
+
+#include "ksquirrel.h"
+#include "sq_splashscreen.h"
+#include "sq_hloptions.h"
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* ****************************************************************** */
+
+// Our command line options
+static TDECmdLineOptions options[] =
+{
+ {"+[file to open]", I18N_NOOP("File to be opened at startup."), 0},
+ {"l", I18N_NOOP("Print found libraries and exit."), 0},
+ {"d", 0, 0},
+ {"print-dcop", I18N_NOOP("Print available DCOP parameters"), 0},
+ {"nodirectorybasket", I18N_NOOP("Folder basket"), 0},
+ {"noimagebasket", I18N_NOOP("Image basket"), 0},
+ {"nocategories", I18N_NOOP("Categories"), 0},
+ {"nomountview", I18N_NOOP("Mount view"), 0},
+
+ TDECmdLineLastOption
+};
+
+int main(int argc, char *argv[])
+{
+ KSquirrel *SQ;
+ SQ_HLOptions *high;
+ const TQCString App = "ksquirrel";
+
+ TDEAboutData aboutData(
+ "ksquirrel",
+ "KSquirrel",
+ VERSION,
+ I18N_NOOP("KSquirrel - image viewer for TDE"),
+ TDEAboutData::License_GPL,
+ "(c) 2003-2007 Baryshev Dmitry",
+ TQString(),
+ "http://ksquirrel.sourceforge.net",
+
+ // setup 'About' dialog
+ aboutData.addAuthor("Dmitry Baryshev aka Krasu", "Author", "[email protected]", TQString());
+ aboutData.addCredit("Andrey Rahmatullin aka wrar", I18N_NOOP("Bug reports, patches"), "[email protected]", TQString());
+ aboutData.addCredit("SeaJey", I18N_NOOP("Testing"), "[email protected]", TQString());
+ aboutData.addCredit("JaguarWan", I18N_NOOP("Bug reports"), "[email protected]", TQString());
+ aboutData.addCredit("NightGoblin", I18N_NOOP("Translation help"), 0, "http://nightgoblin.info");
+ aboutData.addCredit(I18N_NOOP("TiamaT"), I18N_NOOP("Initial artwork for edit tools"), "[email protected]", "http://www.livejournal.com/users/tiamatik/");
+ aboutData.addCredit(I18N_NOOP("Fera"), I18N_NOOP("Great artwork for edit tools"), "[email protected]", TQString());
+ aboutData.addCredit(I18N_NOOP("OpenGL forum at"), 0, 0, "http://opengl.org");
+ aboutData.addCredit(I18N_NOOP("GameDev forum at"), 0, 0, "http://gamedev.ru");
+
+ // parse command line
+ TDECmdLineArgs::init(argc, argv, &aboutData);
+ TDECmdLineArgs::addCmdLineOptions(options);
+ TDECmdLineArgs *sq_args = TDECmdLineArgs::parsedArgs();
+
+ //create high level options
+ high = new SQ_HLOptions;
+
+ if(sq_args->count())
+ high->param = TQFile::decodeName(sq_args->arg(0));
+
+ high->showLibsAndExit = sq_args->isSet("l");
+ bool printDCOP = sq_args->isSet("d");
+
+ high->have_directorybasket = sq_args->isSet("directorybasket");
+ high->have_imagebasket = sq_args->isSet("imagebasket");
+ high->have_categories = sq_args->isSet("categories");
+ high->have_mountview = sq_args->isSet("mountview");
+
+ TDEApplication a;
+
+ if(!TQGLFormat::hasOpenGL())
+ {
+ tqWarning("KSquirrel: this system has no OpenGL support. Exiting." );
+ exit(1);
+ }
+
+ // don't even try to connect to DCOP if -l specified -
+ // anyway we will exit later
+ if(!high->showLibsAndExit)
+ {
+ bool reg = a.dcopClient()->isApplicationRegistered(App);
+
+ // Check if KSquirrel already registered.
+ // If registered, send an url to it.
+ if(reg && !high->param.isEmpty())
+ {
+ // Yes, it is registered. Let's send a message to it.
+ TQCString replyType;
+ TQByteArray data, replyData;
+ TQDataStream dataStream(data, IO_WriteOnly);
+
+ dataStream << high->param;
+
+ if(!a.dcopClient()->call(App, App, "load(TQString)", data, replyType, replyData))
+ tqDebug("\nUnable to send data to old instance of KSquirrel: exiting.\n");
+
+ sq_args->clear();
+ delete high;
+
+ exit(0);
+ }
+ // If registered, but no url was specified in command line
+ else if(reg)
+ {
+ TQString data;
+
+ if(!a.dcopClient()->send(App, App, "activate()", data))
+ tqDebug("\nUnable to send data to old instance of KSquirrel: exiting.\n");
+
+ sq_args->clear();
+ delete high;
+
+ exit(0);
+ }
+ }
+
+ TDEGlobal::dirs()->addResourceType("data", TDEStandardDirs::kde_default("data") + TQString::fromLatin1("ksquirrel"));
+
+ SQ_SplashScreen *splash = 0;
+
+ // should we show a splash screen ?
+ TDEConfig *config = new TDEConfig("ksquirrelrc");
+ config->setGroup("Main");
+
+ if(config->readBoolEntry("splash", true))
+ {
+ splash = new SQ_SplashScreen(0, "ksquirrel-splash-screen");
+ if(!high->showLibsAndExit) splash->show(); // don't show splash when -l
+ TDEApplication::flush();
+ }
+
+ delete config;
+
+ // connect to DCOP server and register KSquirrel. Now we can
+ // send messages to KSquirrel (see README for parameters)
+ if(a.dcopClient()->attach())
+ a.dcopClient()->registerAs(App, false);
+
+ // create an instance
+ SQ = new KSquirrel(0, App);
+
+ if(printDCOP)
+ SQ->printDCOP();
+
+ a.setMainWidget(SQ);
+
+ sq_args->clear();
+
+ return a.exec();
+}
diff --git a/src/mime/Makefile.am b/src/mime/Makefile.am
new file mode 100644
index 0000000..f211e08
--- /dev/null
+++ b/src/mime/Makefile.am
@@ -0,0 +1,115 @@
+####### tdevelop will overwrite this part!!! (begin)##########
+
+
+EXTRA_DIST = x-avs.desktop x-cut.desktop x-dxf.desktop x-iff.desktop x-jbig.desktop x-koala.desktop x-leaf.desktop x-lif.desktop x-mac.desktop x-msp.desktop x-mtv.desktop x-neo.desktop x-pi1.desktop x-pict.desktop x-pix.desktop x-pxr.desktop x-ras.desktop x-ras.magic x-rawrgb.desktop x-sct.desktop x-sun.desktop x-sun.magic x-utah.desktop x-utah.magic x-wal.desktop x-wbmp.desktop x-xim.desktop x-xwd.desktop x-pi3.desktop ljpeg.desktop x-dicom.desktop x-mdl.desktop x-psp.desktop
+
+install-data-local:
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-avs.desktop $(kde_mimedir)/image/x-avs.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-cut.desktop $(kde_mimedir)/image/x-cut.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-dxf.desktop $(kde_mimedir)/image/x-dxf.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-iff.desktop $(kde_mimedir)/image/x-iff.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-jbig.desktop $(kde_mimedir)/image/x-jbig.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-koala.desktop $(kde_mimedir)/image/x-koala.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-leaf.desktop $(kde_mimedir)/image/x-leaf.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-lif.desktop $(kde_mimedir)/image/x-lif.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-mac.desktop $(kde_mimedir)/image/x-mac.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-msp.desktop $(kde_mimedir)/image/x-msp.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-mtv.desktop $(kde_mimedir)/image/x-mtv.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-neo.desktop $(kde_mimedir)/image/x-neo.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-pi1.desktop $(kde_mimedir)/image/x-pi1.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-pict.desktop $(kde_mimedir)/image/x-pict.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-pix.desktop $(kde_mimedir)/image/x-pix.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-pxr.desktop $(kde_mimedir)/image/x-pxr.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-ras.desktop $(kde_mimedir)/image/x-ras.desktop
+ $(mkinstalldirs) $(kde_confdir)/magic/
+ $(INSTALL_DATA) $(srcdir)/x-ras.magic $(kde_confdir)/magic/x-ras.magic
+ (cd $(DESTDIR)$(kde_confdir)/magic && file -C -m x-ras.magic)
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-rawrgb.desktop $(kde_mimedir)/image/x-rawrgb.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-sct.desktop $(kde_mimedir)/image/x-sct.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-sun.desktop $(kde_mimedir)/image/x-sun.desktop
+ $(mkinstalldirs) $(kde_confdir)/magic/
+ $(INSTALL_DATA) $(srcdir)/x-sun.magic $(kde_confdir)/magic/x-sun.magic
+ (cd $(DESTDIR)$(kde_confdir)/magic && file -C -m x-sun.magic)
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-utah.desktop $(kde_mimedir)/image/x-utah.desktop
+ $(mkinstalldirs) $(kde_confdir)/magic/
+ $(INSTALL_DATA) $(srcdir)/x-utah.magic $(kde_confdir)/magic/x-utah.magic
+ (cd $(DESTDIR)$(kde_confdir)/magic && file -C -m x-utah.magic)
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-wal.desktop $(kde_mimedir)/image/x-wal.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-wbmp.desktop $(kde_mimedir)/image/x-wbmp.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-xim.desktop $(kde_mimedir)/image/x-xim.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-xwd.desktop $(kde_mimedir)/image/x-xwd.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-pi3.desktop $(kde_mimedir)/image/x-pi3.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/ljpeg.desktop $(kde_mimedir)/image/ljpeg.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-dicom.desktop $(kde_mimedir)/image/x-dicom.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-mdl.desktop $(kde_mimedir)/image/x-mdl.desktop
+ $(mkinstalldirs) $(kde_mimedir)/image/
+ $(INSTALL_DATA) $(srcdir)/x-psp.desktop $(kde_mimedir)/image/x-psp.desktop
+
+uninstall-local:
+ -rm -f $(kde_mimedir)/image/x-avs.desktop
+ -rm -f $(kde_mimedir)/image/x-cut.desktop
+ -rm -f $(kde_mimedir)/image/x-dxf.desktop
+ -rm -f $(kde_mimedir)/image/x-iff.desktop
+ -rm -f $(kde_mimedir)/image/x-jbig.desktop
+ -rm -f $(kde_mimedir)/image/x-koala.desktop
+ -rm -f $(kde_mimedir)/image/x-leaf.desktop
+ -rm -f $(kde_mimedir)/image/x-lif.desktop
+ -rm -f $(kde_mimedir)/image/x-mac.desktop
+ -rm -f $(kde_mimedir)/image/x-msp.desktop
+ -rm -f $(kde_mimedir)/image/x-mtv.desktop
+ -rm -f $(kde_mimedir)/image/x-neo.desktop
+ -rm -f $(kde_mimedir)/image/x-pi1.desktop
+ -rm -f $(kde_mimedir)/image/x-pict.desktop
+ -rm -f $(kde_mimedir)/image/x-pix.desktop
+ -rm -f $(kde_mimedir)/image/x-pxr.desktop
+ -rm -f $(kde_mimedir)/image/x-ras.desktop
+ -rm -f $(kde_confdir)/magic/x-ras.magic
+ -rm -f $(kde_confdir)/magic/x-ras.magic.mgc
+ -rm -f $(kde_mimedir)/image/x-rawrgb.desktop
+ -rm -f $(kde_mimedir)/image/x-sct.desktop
+ -rm -f $(kde_mimedir)/image/x-sun.desktop
+ -rm -f $(kde_confdir)/magic/x-sun.magic
+ -rm -f $(kde_confdir)/magic/x-sun.magic.mgc
+ -rm -f $(kde_mimedir)/image/x-utah.desktop
+ -rm -f $(kde_confdir)/magic/x-utah.magic
+ -rm -f $(kde_confdir)/magic/x-utah.magic.mgc
+ -rm -f $(kde_mimedir)/image/x-wal.desktop
+ -rm -f $(kde_mimedir)/image/x-wbmp.desktop
+ -rm -f $(kde_mimedir)/image/x-xim.desktop
+ -rm -f $(kde_mimedir)/image/x-xwd.desktop
+ -rm -f $(kde_mimedir)/image/x-pi3.desktop
+ -rm -f $(kde_mimedir)/image/ljpeg.desktop
+ -rm -f $(kde_mimedir)/image/x-dicom.desktop
+ -rm -f $(kde_mimedir)/image/x-mdl.desktop
+ -rm -f $(kde_mimedir)/image/x-psp.desktop
+
+####### tdevelop will overwrite this part!!! (end)############
diff --git a/src/mime/ljpeg.desktop b/src/mime/ljpeg.desktop
new file mode 100644
index 0000000..02b2f41
--- /dev/null
+++ b/src/mime/ljpeg.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/ljpeg
+Icon=image-x-generic
+Patterns=*.ljpg;*.LJPG;*.ljpeg;*.LJPEG;
+Comment=Lossless JPEG
diff --git a/src/mime/x-avs.desktop b/src/mime/x-avs.desktop
new file mode 100644
index 0000000..90540f4
--- /dev/null
+++ b/src/mime/x-avs.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-avs
+Icon=image-x-generic
+Patterns=*.x;*.X;
+Comment=AVS X image
diff --git a/src/mime/x-cut.desktop b/src/mime/x-cut.desktop
new file mode 100644
index 0000000..fae61c6
--- /dev/null
+++ b/src/mime/x-cut.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-cut
+Icon=image-x-generic
+Patterns=*.cut;*.CUT;
+Comment=Dr. Halo CUT
diff --git a/src/mime/x-dicom.desktop b/src/mime/x-dicom.desktop
new file mode 100644
index 0000000..1482401
--- /dev/null
+++ b/src/mime/x-dicom.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-dicom
+Icon=image-x-generic
+Patterns=*.dcm;*.DCM;*.dicom;*.DICOM
+Comment=DICOM
diff --git a/src/mime/x-dxf.desktop b/src/mime/x-dxf.desktop
new file mode 100644
index 0000000..9861c0b
--- /dev/null
+++ b/src/mime/x-dxf.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-dxf
+Icon=image-x-generic
+Patterns=*.dxf;*.DXF;
+Comment=AutoCAD/QCAD Drawing
diff --git a/src/mime/x-iff.desktop b/src/mime/x-iff.desktop
new file mode 100644
index 0000000..8c28ae0
--- /dev/null
+++ b/src/mime/x-iff.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-iff
+Icon=image-x-generic
+Patterns=*.iff;*.IFF;*.ilbm;*.ILBM;*.lbm;*.LBM;
+Comment=Interchange File Format
diff --git a/src/mime/x-jbig.desktop b/src/mime/x-jbig.desktop
new file mode 100644
index 0000000..6630ce5
--- /dev/null
+++ b/src/mime/x-jbig.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-jbig
+Icon=image-x-generic
+Patterns=*.jbg;*.JBG;*.jbig;*.JBIG;
+Comment=JBIG
diff --git a/src/mime/x-koala.desktop b/src/mime/x-koala.desktop
new file mode 100644
index 0000000..0fba0e0
--- /dev/null
+++ b/src/mime/x-koala.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-koala
+Icon=image-x-generic
+Patterns=*.koa;*.KOA;*.kla;*.KLA
+Comment=Commodore 64 Koala
diff --git a/src/mime/x-leaf.desktop b/src/mime/x-leaf.desktop
new file mode 100644
index 0000000..0bbe3f1
--- /dev/null
+++ b/src/mime/x-leaf.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-leaf
+Icon=image-x-generic
+Patterns=*.leaf;*.LEAF;
+Comment=ILEAF Image
diff --git a/src/mime/x-lif.desktop b/src/mime/x-lif.desktop
new file mode 100644
index 0000000..1293c99
--- /dev/null
+++ b/src/mime/x-lif.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-lif
+Icon=image-x-generic
+Patterns=*.lif;*.LIF;
+Comment=Homeworld LIF
diff --git a/src/mime/x-mac.desktop b/src/mime/x-mac.desktop
new file mode 100644
index 0000000..ae31899
--- /dev/null
+++ b/src/mime/x-mac.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-mac
+Icon=image-x-generic
+Patterns=*.mac;*.MAC;
+Comment=Macintosh Paint
diff --git a/src/mime/x-mdl.desktop b/src/mime/x-mdl.desktop
new file mode 100644
index 0000000..5b10c57
--- /dev/null
+++ b/src/mime/x-mdl.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-mdl
+Icon=image-x-generic
+Patterns=*.mdl;*.MDL;
+Comment=HalfLife Model
diff --git a/src/mime/x-msp.desktop b/src/mime/x-msp.desktop
new file mode 100644
index 0000000..4eae799
--- /dev/null
+++ b/src/mime/x-msp.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-msp
+Icon=image-x-generic
+Patterns=*.msp;*.MSP;
+Comment=Microsoft Paint
diff --git a/src/mime/x-mtv.desktop b/src/mime/x-mtv.desktop
new file mode 100644
index 0000000..5ff5217
--- /dev/null
+++ b/src/mime/x-mtv.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-mtv
+Icon=image-x-generic
+Patterns=*.mtv;*.MTV;
+Comment=MTV Ray Tracer
diff --git a/src/mime/x-neo.desktop b/src/mime/x-neo.desktop
new file mode 100644
index 0000000..358d541
--- /dev/null
+++ b/src/mime/x-neo.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-neo
+Icon=image-x-generic
+Patterns=*.neo;*.NEO;
+Comment=Neochrome NEO
diff --git a/src/mime/x-pi1.desktop b/src/mime/x-pi1.desktop
new file mode 100644
index 0000000..208be05
--- /dev/null
+++ b/src/mime/x-pi1.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-pi1
+Icon=image-x-generic
+Patterns=*.pi1;*.PI1;
+Comment=Degas PI1
diff --git a/src/mime/x-pi3.desktop b/src/mime/x-pi3.desktop
new file mode 100644
index 0000000..16505d9
--- /dev/null
+++ b/src/mime/x-pi3.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-pi3
+Icon=image-x-generic
+Patterns=*.pi3;*.PI3;
+Comment=Degas PI3
diff --git a/src/mime/x-pict.desktop b/src/mime/x-pict.desktop
new file mode 100644
index 0000000..32be22d
--- /dev/null
+++ b/src/mime/x-pict.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-pict
+Icon=image-x-generic
+Patterns=*.pict;*.PICT;
+Comment=Macintosh PICT
diff --git a/src/mime/x-pix.desktop b/src/mime/x-pix.desktop
new file mode 100644
index 0000000..6ba2637
--- /dev/null
+++ b/src/mime/x-pix.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-pix
+Icon=image-x-generic
+Patterns=*.pix;*.PIX;
+Comment=Irix PIX Image
diff --git a/src/mime/x-psp.desktop b/src/mime/x-psp.desktop
new file mode 100644
index 0000000..c2fc926
--- /dev/null
+++ b/src/mime/x-psp.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Encoding=UTF-8
+Comment=PaintShop Pro
+Hidden=false
+Icon=
+MimeType=image/x-psp
+Patterns=*.psp;*.PSP
+Type=MimeType
diff --git a/src/mime/x-pxr.desktop b/src/mime/x-pxr.desktop
new file mode 100644
index 0000000..f6ca65a
--- /dev/null
+++ b/src/mime/x-pxr.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-pxr
+Icon=image-x-generic
+Patterns=*.pxr;*.PXR;
+Comment=Pxrar format
diff --git a/src/mime/x-ras.desktop b/src/mime/x-ras.desktop
new file mode 100644
index 0000000..2d27b3b
--- /dev/null
+++ b/src/mime/x-ras.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-ras
+Icon=image-x-generic
+Patterns=*.ras;*.RAS;
+Comment=SUN Raster
diff --git a/src/mime/x-ras.magic b/src/mime/x-ras.magic
new file mode 100644
index 0000000..d043906
--- /dev/null
+++ b/src/mime/x-ras.magic
@@ -0,0 +1 @@
+0 string \x59\xA6\x6A\x95 image/x-ras
diff --git a/src/mime/x-rawrgb.desktop b/src/mime/x-rawrgb.desktop
new file mode 100644
index 0000000..a51d236
--- /dev/null
+++ b/src/mime/x-rawrgb.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-rawrgb
+Icon=image-x-generic
+Patterns=*.rawrgb;*.RAWRGB;
+Comment=KSquirrel RAWRGB
diff --git a/src/mime/x-sct.desktop b/src/mime/x-sct.desktop
new file mode 100644
index 0000000..f9d1525
--- /dev/null
+++ b/src/mime/x-sct.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-sct
+Icon=image-x-generic
+Patterns=*.sct;*.SCT;*.ct;*.CT;
+Comment=Scitex CT
diff --git a/src/mime/x-sun.desktop b/src/mime/x-sun.desktop
new file mode 100644
index 0000000..51359e5
--- /dev/null
+++ b/src/mime/x-sun.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-sun
+Icon=image-x-generic
+Patterns=*.sun;*.SUN;
+Comment=SUN Icon
diff --git a/src/mime/x-sun.magic b/src/mime/x-sun.magic
new file mode 100644
index 0000000..f747352
--- /dev/null
+++ b/src/mime/x-sun.magic
@@ -0,0 +1 @@
+0 string /\\* Format_ image/x-sun
diff --git a/src/mime/x-utah.desktop b/src/mime/x-utah.desktop
new file mode 100644
index 0000000..1e0c31c
--- /dev/null
+++ b/src/mime/x-utah.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-utah
+Icon=image-x-generic
+Patterns=*.rle;*.RLE;
+Comment=UTAH RLE
diff --git a/src/mime/x-utah.magic b/src/mime/x-utah.magic
new file mode 100644
index 0000000..1099635
--- /dev/null
+++ b/src/mime/x-utah.magic
@@ -0,0 +1 @@
+0 string \x52\xCC image/x-utah
diff --git a/src/mime/x-wal.desktop b/src/mime/x-wal.desktop
new file mode 100644
index 0000000..89a681d
--- /dev/null
+++ b/src/mime/x-wal.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-wal
+Icon=image-x-generic
+Patterns=*.wal;*.WAL;
+Comment=Quake2 texture
diff --git a/src/mime/x-wbmp.desktop b/src/mime/x-wbmp.desktop
new file mode 100644
index 0000000..7720b4d
--- /dev/null
+++ b/src/mime/x-wbmp.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-wbmp
+Icon=image-x-generic
+Patterns=*.wbmp;*.WBMP;
+Comment=Wireless Application Protocol Bitmap
diff --git a/src/mime/x-xim.desktop b/src/mime/x-xim.desktop
new file mode 100644
index 0000000..7d557db
--- /dev/null
+++ b/src/mime/x-xim.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-xim
+Icon=image-x-generic
+Patterns=*.xim;*.XIM;
+Comment=X Image
diff --git a/src/mime/x-xwd.desktop b/src/mime/x-xwd.desktop
new file mode 100644
index 0000000..c7531ab
--- /dev/null
+++ b/src/mime/x-xwd.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=MimeType
+MimeType=image/x-xwd
+Icon=image-x-generic
+Patterns=*.xwd;*.XWD;
+Comment=X Window Dump
diff --git a/src/sidebar/Makefile.am b/src/sidebar/Makefile.am
new file mode 100644
index 0000000..f2c04d1
--- /dev/null
+++ b/src/sidebar/Makefile.am
@@ -0,0 +1,15 @@
+####### tdevelop will overwrite this part!!! (begin)##########
+noinst_LIBRARIES = libsidebar.a
+
+## INCLUDES were found outside tdevelop specific part
+
+libsidebar_a_METASOURCES = AUTO
+
+libsidebar_a_SOURCES = sq_mountviewitem.cpp sq_mountview.cpp sq_imagebasket.cpp sq_directorybasket.cpp sq_categorybrowsermenu.cpp sq_categoriesview.cpp sq_treeviewmenu.cpp sq_previewwidget.cpp sq_storagefile.cpp sq_treeviewitem.cpp sq_threaddirlister.cpp sq_treeview.cpp sq_multibar.cpp
+
+
+EXTRA_DIST = sq_mountview.h sq_multibar.cpp sq_multibar.h sq_treeview.cpp sq_treeview.h sq_categoriesview.h sq_categorybrowsermenu.h sq_threaddirlister.cpp sq_threaddirlister.h sq_treeviewitem.h sq_treeviewitem.cpp sq_mountviewitem.h sq_imagebasket.h sq_storagefile.h sq_storagefile.cpp sq_previewwidget.cpp sq_previewwidget.h sq_treeviewmenu.cpp sq_treeviewmenu.h sq_directorybasket.h sq_categoriesview.cpp sq_categorybrowsermenu.cpp sq_directorybasket.cpp sq_imagebasket.cpp sq_mountview.cpp sq_mountviewitem.cpp
+
+####### tdevelop will overwrite this part!!! (end)############
+
+INCLUDES = $(all_includes) -I$(srcdir) -I$(top_srcdir)/src
diff --git a/src/sidebar/sq_categoriesview.cpp b/src/sidebar/sq_categoriesview.cpp
new file mode 100644
index 0000000..0508e8d
--- /dev/null
+++ b/src/sidebar/sq_categoriesview.cpp
@@ -0,0 +1,318 @@
+/***************************************************************************
+ sq_categoriesview.cpp - description
+ -------------------
+ begin : ??? June 3 2006
+ copyright : (C) 2006 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqfile.h>
+#include <tqheader.h>
+
+#include <tdeio/job.h>
+#include <tdetoolbar.h>
+#include <kicontheme.h>
+#include <tdelocale.h>
+#include <kmimetype.h>
+#include <tdefileitem.h>
+#include <kurldrag.h>
+#include <kinputdialog.h>
+#include <kpropertiesdialog.h>
+#include <tdefiletreeviewitem.h>
+#include <tdemessagebox.h>
+
+#include "ksquirrel.h"
+#include "sq_dir.h"
+#include "sq_iconloader.h"
+#include "sq_categoriesview.h"
+#include "sq_libraryhandler.h"
+#include "sq_externaltool.h"
+#include "sq_widgetstack.h"
+#include "sq_categorybrowsermenu.h"
+#include "sq_storagefile.h"
+#include "sq_widgetstack.h"
+#include "sq_diroperator.h"
+#include "sq_treeviewmenu.h"
+
+SQ_CategoriesBox * SQ_CategoriesBox::sing = 0;
+
+/* *************************************************************************************** */
+
+SQ_CategoriesViewBranch::SQ_CategoriesViewBranch(KFileTreeView *parent, const KURL &url, const TQString &name, const TQPixmap &pix)
+ : KFileTreeBranch(parent, url, name, pix)
+{}
+
+SQ_CategoriesViewBranch::~SQ_CategoriesViewBranch()
+{}
+
+KFileTreeViewItem* SQ_CategoriesViewBranch::createTreeViewItem(KFileTreeViewItem *parent, KFileItem *fileItem)
+{
+ KFileTreeViewItem *i = KFileTreeBranch::createTreeViewItem(parent, fileItem);
+
+ /*
+ * In storage there are files with MD5 sum appended to their names.
+ * We should cut off MD5.
+ */
+ if(i)
+ {
+ TQString n = i->fileItem()->name();
+ int ind = n.findRev('.');
+
+ // OOPS
+ if(ind != -1)
+ n.truncate(ind);
+
+ i->setText(0, n);
+ }
+
+ return i;
+}
+
+/* *************************************************************************************** */
+
+SQ_CategoriesView::SQ_CategoriesView(TQWidget *parent, const char *name) : KFileTreeView(parent, name)
+{
+ setAcceptDrops(true);
+
+ m_dir = new SQ_Dir(SQ_Dir::Categories);
+
+ // create custom branch
+ root = new SQ_CategoriesViewBranch(this, m_dir->root(), i18n("Categories"),
+ SQ_IconLoader::instance()->loadIcon("bookmark", TDEIcon::Desktop, TDEIcon::SizeSmall));
+
+ addBranch(root);
+
+ header()->hide();
+ addColumn(i18n("File"));
+ setDirOnlyMode(root, false);
+ setRootIsDecorated(true);
+ setCurrentItem(root->root());
+ root->setChildRecurse(true);
+ root->setOpen(true);
+
+ menu = new SQ_TreeViewMenu(this);
+
+ connect(this, TQ_SIGNAL(spacePressed(TQListViewItem*)), this, TQ_SIGNAL(executed(TQListViewItem*)));
+ connect(this, TQ_SIGNAL(returnPressed(TQListViewItem*)), this, TQ_SIGNAL(executed(TQListViewItem*)));
+ connect(this, TQ_SIGNAL(executed(TQListViewItem*)), this, TQ_SLOT(slotItemExecuted(TQListViewItem*)));
+ connect(this, TQ_SIGNAL(contextMenu(TDEListView*, TQListViewItem*, const TQPoint&)), this, TQ_SLOT(slotContextMenu(TDEListView*, TQListViewItem*, const TQPoint&)));
+}
+
+SQ_CategoriesView::~SQ_CategoriesView()
+{
+ delete m_dir;
+}
+
+void SQ_CategoriesView::slotContextMenu(TDEListView *, TQListViewItem *item, const TQPoint &p)
+{
+ if(item)
+ {
+ KFileTreeViewItem *kfi = static_cast<KFileTreeViewItem*>(item);
+ menu->updateDirActions(kfi->isDir(), (item == root->root()));
+ menu->setURL(kfi->url());
+ menu->exec(p);
+ }
+}
+
+void SQ_CategoriesView::slotItemExecuted(TQListViewItem *item)
+{
+ if(!item) return;
+
+ if(item == root->root())
+ {
+ root->setOpen(true);
+ return;
+ }
+
+ KFileTreeViewItem *cur = static_cast<KFileTreeViewItem *>(item);
+
+ // file item
+ if(cur && !cur->isDir())
+ {
+ KURL inpath = SQ_StorageFile::readStorageFile(cur->path());
+
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, inpath);
+ SQ_WidgetStack::instance()->diroperator()->execute(&fi);
+ }
+}
+
+/* ************************************************************** */
+
+SQ_CategoriesBox::SQ_CategoriesBox(TQWidget *parent, const char *name) : TQVBox(parent, name)
+{
+ sing = this;
+
+ lastdir = i18n("New Category");
+
+ view = new SQ_CategoriesView(this);
+ toolbar = new TDEToolBar(this);
+
+ connect(view, TQ_SIGNAL(dropped(TQDropEvent*, TQListViewItem*, TQListViewItem*)), this, TQ_SLOT(slotDropped(TQDropEvent*, TQListViewItem*, TQListViewItem*)));
+
+ menu = new SQ_CategoryBrowserMenu(view->dir()->root(), 0, "Categories menu");
+
+ toolbar->setIconSize(TDEIcon::SizeSmall);
+
+ toolbar->insertButton("folder-new", 0, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotNewCategory()), true, i18n("New category"));
+ toolbar->insertButton("edittrash", 0, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotDeleteItem()), true, i18n("Delete"));
+ toolbar->insertButton("application-vnd.tde.info", 0, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotItemProperties()), true, i18n("Properties"));
+ toolbar->insertButton("bookmark_add", 0, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotDefaultCategories()), true, i18n("Create default categories"));
+
+ view->popupMenu()->reconnect(SQ_TreeViewMenu::New, this, TQ_SLOT(slotNewCategory()));
+ view->popupMenu()->reconnect(SQ_TreeViewMenu::Delete, this, TQ_SLOT(slotDeleteItem()));
+ view->popupMenu()->reconnect(SQ_TreeViewMenu::Properties, this, TQ_SLOT(slotItemProperties()));
+}
+
+SQ_CategoriesBox::~SQ_CategoriesBox()
+{}
+
+void SQ_CategoriesBox::addToCategory(const TQString &path)
+{
+ KFileItemList *selected = const_cast<KFileItemList *>(SQ_WidgetStack::instance()->selectedItems());
+
+ if(!selected) return;
+
+ KFileItem *item;
+
+ item = selected->first();
+
+ while(item)
+ {
+ if(item->isFile())
+ SQ_StorageFile::writeStorageFile(path + TQDir::separator() + item->name(), item->url().path());
+
+ item = selected->next();
+ }
+}
+
+void SQ_CategoriesBox::slotDefaultCategories()
+{
+ if(KMessageBox::questionYesNo(KSquirrel::app(),
+ i18n("This will create default categories: Concerts, Pets, Home, Friends, Free time, Travelling and Nature. Continue?"),
+ i18n("Create default categories")) == KMessageBox::Yes)
+ {
+ TQStringList list;
+
+ list << "Concerts" << "Pets" << "Home" << "Friends" << "Free time" << "Traveling" << "Nature";
+
+ for(TQStringList::iterator it = list.begin();it != list.end();++it)
+ view->dir()->mkdir(*it);
+ }
+}
+
+void SQ_CategoriesBox::slotNewCategory()
+{
+ bool ok;
+
+ KFileTreeViewItem *cur = view->currentKFileTreeViewItem();
+
+ if(!cur) return;
+
+ if(!cur->isDir())
+ cur = static_cast<KFileTreeViewItem *>(cur->parent());
+
+ if(!cur) return;
+
+ TQString tmp = KInputDialog::getText(i18n("New Category"), i18n("Create new category:"),
+ lastdir, &ok, this);
+ if(ok)
+ {
+ lastdir = tmp;
+ TDEIO::mkdir(cur->path() + TQDir::separator() + lastdir);
+ }
+}
+
+void SQ_CategoriesBox::slotDropped(TQDropEvent *e, TQListViewItem *parent, TQListViewItem *item)
+{
+ if(!item) item = parent;
+
+ KFileTreeViewItem *cur = static_cast<KFileTreeViewItem *>(item);
+
+ if(!cur) return;
+
+ KURL::List list;
+ KURLDrag::decode(e, list);
+ TQString path = cur->path();
+
+ if(list.first().path().startsWith(view->dir()->root()))
+ TDEIO::move(list, cur->url());
+ else
+ {
+ KURL::List::iterator itEnd = list.end();
+ TQString mimeDet;
+
+ for(KURL::List::iterator it = list.begin(); it != itEnd;++it)
+ {
+ mimeDet = KMimeType::findByURL(*it)->name();
+
+ if(mimeDet != "inode/directory")
+ SQ_StorageFile::writeStorageFile(path + TQDir::separator() + (*it).fileName(), (*it));
+ }
+ }
+}
+
+void SQ_CategoriesBox::slotDeleteItem()
+{
+ KFileTreeViewItem *cur = view->currentKFileTreeViewItem();
+
+ if(!cur) return;
+
+ KURL root;
+ root.setPath(view->dir()->root());
+
+ if(cur->url().equals(root, true))
+ return;
+
+ TQListViewItem *next = cur->itemBelow();
+ if(!next) next = cur->itemAbove();
+
+ if(next)
+ {
+ view->setCurrentItem(next);
+ view->setSelected(next, true);
+ }
+
+ TQString tmp = cur->path();
+
+ // remove this item manually
+ delete cur;
+ cur = 0;
+
+ // physically remove file from storage
+ TDEIO::del(tmp, false, false);
+}
+
+void SQ_CategoriesBox::slotItemProperties()
+{
+ KFileTreeViewItem *cur = view->currentKFileTreeViewItem();
+
+ if(!cur) return;
+
+ // directory - just show its properties
+ if(cur->isDir())
+ (void)new KPropertiesDialog(cur->url(), KSquirrel::app());
+
+ // link to real file
+ else
+ {
+ KURL inpath = SQ_StorageFile::readStorageFile(cur->path());
+
+ if(!inpath.isEmpty())
+ (void)new KPropertiesDialog(inpath, KSquirrel::app());
+ }
+}
+
+#include "sq_categoriesview.moc"
diff --git a/src/sidebar/sq_categoriesview.h b/src/sidebar/sq_categoriesview.h
new file mode 100644
index 0000000..4fba48a
--- /dev/null
+++ b/src/sidebar/sq_categoriesview.h
@@ -0,0 +1,131 @@
+/***************************************************************************
+ sq_categoriesview.h - description
+ -------------------
+ begin : ??? June 3 2006
+ copyright : (C) 2006 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_CATEGORIESVIEW_H
+#define SQ_CATEGORIESVIEW_H
+
+#include <tqvbox.h>
+
+#include <tdefiletreeview.h>
+#include <tdefiletreebranch.h>
+
+class TDEToolBar;
+
+class SQ_CategoryBrowserMenu;
+class SQ_TreeViewMenu;
+class SQ_Dir;
+
+/**
+ *@author Baryshev Dmitry
+ */
+
+/* *************************************************** */
+
+class SQ_CategoriesViewBranch : public KFileTreeBranch
+{
+ public:
+ SQ_CategoriesViewBranch(KFileTreeView*, const KURL &url, const TQString &name, const TQPixmap &pix);
+ ~SQ_CategoriesViewBranch();
+
+ protected:
+ virtual KFileTreeViewItem *createTreeViewItem(KFileTreeViewItem *parent, KFileItem *fileItem);
+};
+
+/* *************************************************** */
+
+class SQ_CategoriesView : public KFileTreeView
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_CategoriesView(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_CategoriesView();
+
+ SQ_TreeViewMenu *popupMenu() const;
+
+ SQ_Dir* dir();
+
+ private slots:
+ void slotItemExecuted(TQListViewItem *item);
+ void slotContextMenu(TDEListView *, TQListViewItem *i, const TQPoint &p);
+
+ private:
+ KFileTreeBranch *root;
+ SQ_TreeViewMenu *menu;
+
+ SQ_Dir *m_dir;
+};
+
+inline
+SQ_TreeViewMenu* SQ_CategoriesView::popupMenu() const
+{
+ return menu;
+}
+
+inline
+SQ_Dir* SQ_CategoriesView::dir()
+{
+ return m_dir;
+}
+
+/* *************************************************** */
+
+class SQ_CategoriesBox : public TQVBox
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_CategoriesBox(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_CategoriesBox();
+
+ /*
+ * Get current popup menu.
+ */
+ SQ_CategoryBrowserMenu* popupMenu() const;
+
+ /*
+ * Add selected files to some category
+ */
+ void addToCategory(const TQString &);
+
+ static SQ_CategoriesBox* instance() { return sing; };
+
+ private slots:
+ void slotNewCategory();
+ void slotDefaultCategories();
+ void slotDeleteItem();
+ void slotItemProperties();
+ void slotDropped(TQDropEvent *, TQListViewItem *, TQListViewItem *);
+
+ private:
+ SQ_CategoriesView *view;
+ TDEToolBar *toolbar;
+ TQString lastdir, copypath;
+ SQ_CategoryBrowserMenu *menu;
+
+ static SQ_CategoriesBox *sing;
+};
+
+inline
+SQ_CategoryBrowserMenu* SQ_CategoriesBox::popupMenu() const
+{
+ return menu;
+}
+
+#endif
diff --git a/src/sidebar/sq_categorybrowsermenu.cpp b/src/sidebar/sq_categorybrowsermenu.cpp
new file mode 100644
index 0000000..4f03e44
--- /dev/null
+++ b/src/sidebar/sq_categorybrowsermenu.cpp
@@ -0,0 +1,521 @@
+/*
+ * Copyright (C) 2006 Baryshev Dmitry, KSquirrel project
+ *
+ * Originally based on browser_mnu.cpp by (C) Matthias Elter
+ * from kde-3.2.3
+ */
+
+/*****************************************************************
+
+Copyright (c) 2001 Matthias Elter <[email protected]>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqpixmap.h>
+#include <tqdir.h>
+
+#include <tdeglobal.h>
+#include <tdeconfig.h>
+#include <tdelocale.h>
+#include <tdeapplication.h>
+#include <tdeprocess.h>
+#include <kiconloader.h>
+#include <ksimpleconfig.h>
+#include <kdesktopfile.h>
+#include <kmimetype.h>
+#include <tdeglobalsettings.h>
+#include <tdeio/global.h>
+#include <krun.h>
+#include <konq_operations.h>
+#include <tdefileitem.h>
+#include <kdirwatch.h>
+#include <kstringhandler.h>
+#include <kurldrag.h>
+
+#include "sq_dir.h"
+#include "sq_categoriesview.h"
+#include "sq_categorybrowsermenu.h"
+
+#define CICON(a) (*_icons)[a]
+
+TQMap<TQString, TQPixmap> *SQ_CategoryBrowserMenu::_icons = 0;
+
+SQ_CategoryBrowserMenu::SQ_CategoryBrowserMenu(TQString path, TQWidget *parent, const char *name, int startid)
+ : KPanelMenu(path, parent, name)
+ , _mimecheckTimer(0)
+ , _startid(startid)
+ , _dirty(false)
+{
+ _subMenus.setAutoDelete(true);
+ _lastpress = TQPoint(-1, -1);
+ setAcceptDrops(true); // Should depend on permissions of path.
+
+ // we are not interested for dirty events on files inside the
+ // directory (see slotClearIfNeeded)
+ connect( &_dirWatch, TQ_SIGNAL(dirty(const TQString&)),
+ this, TQ_SLOT(slotClearIfNeeded(const TQString&)) );
+ connect( &_dirWatch, TQ_SIGNAL(created(const TQString&)),
+ this, TQ_SLOT(slotClear()) );
+ connect( &_dirWatch, TQ_SIGNAL(deleted(const TQString&)),
+ this, TQ_SLOT(slotClear()) );
+}
+
+SQ_CategoryBrowserMenu::~SQ_CategoryBrowserMenu()
+{}
+
+void SQ_CategoryBrowserMenu::slotClearIfNeeded(const TQString& p)
+{
+ if (p == path())
+ slotClear();
+}
+
+
+void SQ_CategoryBrowserMenu::initialize()
+{
+ _lastpress = TQPoint(-1, -1);
+
+ // don't change menu if already visible
+ if (isVisible())
+ return;
+
+ if (_dirty) {
+ // directory content changed while menu was visible
+ slotClear();
+ setInitialized(false);
+ _dirty = false;
+ }
+
+ if (initialized()) return;
+ setInitialized(true);
+
+ // start watching if not already done
+ if (!_dirWatch.contains(path()))
+ _dirWatch.addDir( path() );
+
+ // setup icon map
+ initIconMap();
+
+ // read configuration
+ TDEConfig *c = TDEGlobal::config();
+ c->setGroup("menus");
+ _showhidden = c->readBoolEntry("ShowHiddenFiles", false);
+ _maxentries = c->readNumEntry("MaxEntries2", 30);
+
+ // clear maps
+ _filemap.clear();
+ _mimemap.clear();
+
+ int filter = TQDir::Dirs | TQDir::Files;
+ if(_showhidden)
+ filter |= TQDir::Hidden;
+
+ TQDir dir(path(), TQString(), TQDir::DirsFirst | TQDir::Name | TQDir::IgnoreCase, filter);
+
+ // does the directory exist?
+ if (!dir.exists()) {
+ insertItem(i18n("Failed to Read Folder"));
+ return;
+ }
+
+ // get entry list
+ const TQFileInfoList *list = dir.entryInfoList();
+
+ // no list -> read error
+ if (!list) {
+ insertItem(i18n("Failed to Read Folder"));
+ return;
+ }
+
+ KURL url;
+ url.setPath(path());
+ if (!tdeApp->authorizeURLAction("list", KURL(), url))
+ {
+ insertItem(i18n("Not Authorized to Read Folder"));
+ return;
+ }
+
+ // insert file manager and terminal entries
+ // only the first part menu got them
+ if(_startid == 0)
+ {
+ SQ_Dir dir(SQ_Dir::Categories);
+
+ if(dir.root() != path())
+ {
+ insertTitle(path().right(path().length() - dir.root().length()));
+ insertItem(CICON("bookmark_add"), i18n("Add here"), this, TQ_SLOT(slotAddToCategory()));
+ }
+ }
+
+ bool first_entry = true;
+ bool dirfile_separator = false;
+ int item_count = 0;
+ int run_id = _startid;
+
+ // get list iterator
+ TQFileInfoListIterator it(*list);
+
+ // jump to startid
+ it += _startid;
+
+ // iterate over entry list
+ for (; it.current(); ++it)
+ {
+ // bump id
+ run_id++;
+
+ TQFileInfo *fi = it.current();
+ // handle directories
+ if (fi->isDir())
+ {
+ TQString name = fi->fileName();
+
+ // ignore . and .. entries
+ if (name == "." || name == "..") continue;
+
+ TQPixmap icon;
+ TQString path = fi->absFilePath();
+
+ // parse .directory if it does exist
+ if (TQFile::exists(path + "/.directory")) {
+
+ KSimpleConfig c(path + "/.directory", true);
+ c.setDesktopGroup();
+ icon = TDEGlobal::iconLoader()->loadIcon(c.readEntry("Icon"),
+ TDEIcon::Small, TDEIcon::SizeSmall,
+ TDEIcon::DefaultState, 0, true);
+ if(icon.isNull())
+ icon = CICON("folder");
+ name = c.readEntry("Name", name);
+ }
+
+ // use cached folder icon for directories without special icon
+ if (icon.isNull())
+ icon = CICON("folder");
+
+ // insert separator if we are the first menu entry
+ if(first_entry) {
+ if (_startid == 0)
+ insertSeparator();
+ first_entry = false;
+ }
+
+ // append menu entry
+ append(icon, KStringHandler::cEmSqueeze( name, fontMetrics(), 20 ),
+ new SQ_CategoryBrowserMenu(path, this));
+
+ // bump item count
+ item_count++;
+
+ dirfile_separator = true;
+ }
+/*
+ // handle files
+ else if(fi->isFile())
+ {
+ TQString name = fi->fileName();
+ TQString title = TDEIO::decodeFileName(name);
+
+ // ignore .directory and .order files
+ if (name == ".directory" || name == ".order") continue;
+
+ TQPixmap icon;
+ TQString path = fi->absFilePath();
+
+ bool mimecheck = false;
+
+ // .desktop files
+ if(KDesktopFile::isDesktopFile(path))
+ {
+ KSimpleConfig c(path, true);
+ c.setDesktopGroup();
+ title = c.readEntry("Name", title);
+
+ TQString s = c.readEntry("Icon");
+ if(!_icons->contains(s)) {
+ icon = TDEGlobal::iconLoader()->loadIcon(s, TDEIcon::Small, TDEIcon::SizeSmall,
+ TDEIcon::DefaultState, 0, true);
+
+ if(icon.isNull()) {
+ TQString type = c.readEntry("Type", "Application");
+ if (type == "Directory")
+ icon = CICON("folder");
+ else if (type == "Mimetype")
+ icon = CICON("txt");
+ else if (type == "FSDevice")
+ icon = CICON("chardevice");
+ else
+ icon = CICON("exec");
+ }
+ else
+ _icons->insert(s, icon);
+ }
+ else
+ icon = CICON(s);
+ }
+ else {
+ // set unknown icon
+ icon = CICON("unknown");
+
+ // mark for delayed mimetime check
+ mimecheck = true;
+ }
+
+ // insert separator if we are the first menu entry
+ if(first_entry) {
+ if(_startid == 0)
+ insertSeparator();
+ first_entry = false;
+ }
+
+ // insert separator if we we first file after at least one directory
+ if (dirfile_separator) {
+ insertSeparator();
+ dirfile_separator = false;
+ }
+
+ // append file entry
+ append(icon, title, name, mimecheck);
+
+ // bump item count
+ item_count++;
+ }
+*/
+ if(item_count == _maxentries) {
+ // Only insert a "More..." item if there are actually more items.
+ ++it;
+ if( it.current() ) {
+ insertSeparator();
+ append(CICON("folder_open"), i18n("More..."), new SQ_CategoryBrowserMenu(path(), this, 0, run_id));
+ }
+ break;
+ }
+ }
+
+#if 0
+ // WABA: tear off handles don't work together with dynamically updated
+ // menus. We can't update the menu while torn off, and we don't know
+ // when it is torn off.
+ if(TDEGlobalSettings::insertTearOffHandle() && item_count > 0)
+ insertTearOffHandle();
+#endif
+
+ adjustSize();
+
+ TQString dirname = path();
+
+ int maxlen = contentsRect().width() - 40;
+ if(item_count == 0)
+ maxlen = fontMetrics().width(dirname);
+
+ if (fontMetrics().width(dirname) > maxlen) {
+ while ((!dirname.isEmpty()) && (fontMetrics().width(dirname) > (maxlen - fontMetrics().width("..."))))
+ dirname = dirname.remove(0, 1);
+ dirname.prepend("...");
+ }
+ setCaption(dirname);
+
+ // setup and start delayed mimetype check timer
+ if(_mimemap.count() > 0) {
+
+ if(!_mimecheckTimer)
+ _mimecheckTimer = new TQTimer(this);
+
+ connect(_mimecheckTimer, TQ_SIGNAL(timeout()), TQ_SLOT(slotMimeCheck()));
+ _mimecheckTimer->start(0);
+ }
+}
+
+void SQ_CategoryBrowserMenu::append(const TQPixmap &pixmap, const TQString &title, const TQString &file, bool mimecheck)
+{
+ // avoid &'s being converted to accelerators
+ TQString newTitle = title;
+ newTitle.replace("&", "&&");
+ newTitle = KStringHandler::cEmSqueeze( newTitle, fontMetrics(), 20 );
+
+ // insert menu item
+ int id = insertItem(pixmap, newTitle);
+
+ // insert into file map
+ _filemap.insert(id, file);
+
+ // insert into mimetype check map
+ if(mimecheck)
+ _mimemap.insert(id, true);
+}
+
+void SQ_CategoryBrowserMenu::append(const TQPixmap &pixmap, const TQString &title, SQ_CategoryBrowserMenu *subMenu)
+{
+ // avoid &'s being converted to accelerators
+ TQString newTitle = title;
+ newTitle.replace("&", "&&");
+ newTitle = KStringHandler::cEmSqueeze( newTitle, fontMetrics(), 20 );
+
+ // insert submenu
+ insertItem(pixmap, newTitle, subMenu);
+ // remember submenu for later deletion
+ _subMenus.append(subMenu);
+}
+
+void SQ_CategoryBrowserMenu::mousePressEvent(TQMouseEvent *e)
+{
+ TQPopupMenu::mousePressEvent(e);
+ _lastpress = e->pos();
+}
+
+void SQ_CategoryBrowserMenu::mouseMoveEvent(TQMouseEvent *e)
+{
+ TQPopupMenu::mouseMoveEvent(e);
+
+ if (!(e->state() & TQt::LeftButton)) return;
+ if(_lastpress == TQPoint(-1, -1)) return;
+
+ // DND delay
+ if((_lastpress - e->pos()).manhattanLength() < 12) return;
+
+ // get id
+ int id = idAt(_lastpress);
+ if(!_filemap.contains(id)) return;
+
+ // reset _lastpress
+ _lastpress = TQPoint(-1, -1);
+
+ // start drag
+ KURL url;
+ url.setPath(path() + '/' + _filemap[id]);
+ KURL::List files(url);
+ KURLDrag *d = new KURLDrag(files, this);
+ d->setPixmap(iconSet(id)->pixmap());
+ d->drag();
+}
+
+void SQ_CategoryBrowserMenu::dragEnterEvent( TQDragEnterEvent *ev )
+{
+ if (KURLDrag::canDecode(ev))
+ ev->accept(rect());
+ KPanelMenu::dragEnterEvent(ev);
+}
+
+void SQ_CategoryBrowserMenu::dropEvent( TQDropEvent *ev )
+{
+ KFileItem item( path(), TQString::fromLatin1( "inode/directory" ), KFileItem::Unknown );
+ KonqOperations::doDrop( &item, path(), ev, this );
+ KPanelMenu::dropEvent(ev);
+ // ### TODO: Update list
+}
+
+void SQ_CategoryBrowserMenu::slotExec(int id)
+{
+ tdeApp->propagateSessionManager();
+
+ if(!_filemap.contains(id)) return;
+
+ KURL url;
+ url.setPath(path() + '/' + _filemap[id]);
+ new KRun(url, 0, true); // will delete itself
+ _lastpress = TQPoint(-1, -1);
+}
+
+void SQ_CategoryBrowserMenu::slotAddToCategory()
+{
+ SQ_CategoriesBox::instance()->addToCategory(path());
+}
+
+void SQ_CategoryBrowserMenu::slotMimeCheck()
+{
+ // get the first map entry
+ TQMap<int, bool>::Iterator it = _mimemap.begin();
+
+ // no mime types left to check -> stop timer
+ if(it == _mimemap.end()) {
+ _mimecheckTimer->stop();
+ return;
+ }
+
+ int id = it.key();
+ TQString file = _filemap[id];
+
+ _mimemap.remove(it);
+
+ KURL url;
+ url.setPath( path() + '/' + file );
+
+// KMimeType::Ptr mt = KMimeType::findByURL(url, 0, true, false);
+// TQString icon(mt->icon(url, true));
+ TQString icon = KMimeType::iconForURL( url );
+// kdDebug() << url.url() << ": " << icon << endl;
+
+ file = KStringHandler::cEmSqueeze( file, fontMetrics(), 20 );
+
+ file.replace("&", "&&");
+ if(!_icons->contains(icon)) {
+ TQPixmap pm = SmallIcon(icon);
+ if( pm.height() > 16 )
+ {
+ TQPixmap cropped( 16, 16 );
+ copyBlt( &cropped, 0, 0, &pm, 0, 0, 16, 16 );
+ pm = cropped;
+ }
+ _icons->insert(icon, pm);
+ changeItem(id, pm, file);
+ }
+ else
+ changeItem(id, CICON(icon), file);
+}
+
+void SQ_CategoryBrowserMenu::slotClear()
+{
+ // no need to watch any further
+ if (_dirWatch.contains(path()))
+ _dirWatch.removeDir( path() );
+
+ // don't change menu if already visible
+ if (isVisible()) {
+ _dirty = true;
+ return;
+ }
+ KPanelMenu::slotClear();
+ _subMenus.clear(); // deletes submenus
+}
+
+void SQ_CategoryBrowserMenu::initIconMap()
+{
+ if(_icons) return;
+
+// kdDebug() << "SQ_CategoryBrowserMenu::initIconMap" << endl;
+
+ _icons = new TQMap<TQString, TQPixmap>;
+
+ _icons->insert("folder", SmallIcon("folder"));
+ _icons->insert("unknown", SmallIcon("unknown"));
+ _icons->insert("folder_open", SmallIcon("folder_open"));
+ _icons->insert("kdisknav", SmallIcon("kdisknav"));
+ _icons->insert("kfm", SmallIcon("kfm"));
+ _icons->insert("terminal", SmallIcon("terminal"));
+ _icons->insert("txt", SmallIcon("text-plain"));
+ _icons->insert("exec", SmallIcon("application-x-executable"));
+ _icons->insert("chardevice", SmallIcon("chardevice"));
+}
+
+#include "sq_categorybrowsermenu.moc"
diff --git a/src/sidebar/sq_categorybrowsermenu.h b/src/sidebar/sq_categorybrowsermenu.h
new file mode 100644
index 0000000..c2e0b77
--- /dev/null
+++ b/src/sidebar/sq_categorybrowsermenu.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2006 Baryshev Dmitry, KSquirrel project
+ *
+ * Originally based on browser_mnu.h by (C) Matthias Elter
+ * from kde-3.2.3
+ */
+
+/*****************************************************************
+
+Copyright (c) 2001 Matthias Elter <[email protected]>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#ifndef __browser_mnu_h__
+#define __browser_mnu_h__
+
+#include <tqmap.h>
+#include <tqptrlist.h>
+#include <kpanelmenu.h>
+#include <kdirwatch.h>
+
+class SQ_CategoryBrowserMenu : public KPanelMenu
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_CategoryBrowserMenu(TQString path, TQWidget *parent = 0, const char *name = 0, int startid = 0);
+ ~SQ_CategoryBrowserMenu();
+
+ void append(const TQPixmap &pixmap, const TQString &title, const TQString &filename, bool mimecheck);
+ void append(const TQPixmap &pixmap, const TQString &title, SQ_CategoryBrowserMenu *subMenu);
+
+ public slots:
+ void initialize();
+
+ protected slots:
+ void slotExec(int id);
+ void slotAddToCategory();
+ void slotMimeCheck();
+ void slotClearIfNeeded(const TQString&);
+ void slotClear();
+
+ protected:
+ void mousePressEvent(TQMouseEvent *);
+ void mouseMoveEvent(TQMouseEvent *);
+ void dropEvent(TQDropEvent *ev);
+ void dragEnterEvent(TQDragEnterEvent *ev);
+ void initIconMap();
+
+ TQPoint _lastpress;
+ TQMap<int, TQString> _filemap;
+ TQMap<int, bool> _mimemap;
+ TQTimer *_mimecheckTimer;
+ KDirWatch _dirWatch;
+ TQPtrList<SQ_CategoryBrowserMenu> _subMenus;
+
+ int _startid;
+ bool _showhidden;
+ int _maxentries;
+ bool _dirty;
+
+ static TQMap<TQString, TQPixmap> *_icons;
+};
+
+#endif
diff --git a/src/sidebar/sq_directorybasket.cpp b/src/sidebar/sq_directorybasket.cpp
new file mode 100644
index 0000000..74ba7e2
--- /dev/null
+++ b/src/sidebar/sq_directorybasket.cpp
@@ -0,0 +1,520 @@
+/***************************************************************************
+ sq_directorybasket.cpp - description
+ -------------------
+ begin : ??? Sep 29 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tqvaluevector.h>
+#include <tqstringlist.h>
+#include <tqheader.h>
+#include <tqcursor.h>
+#include <tqtimer.h>
+
+#include <tdeglobal.h>
+#include <tdelocale.h>
+#include <kurldrag.h>
+#include <kmimetype.h>
+#include <tdefiledialog.h>
+#include <kinputdialog.h>
+#include <kicondialog.h>
+#include <kiconloader.h>
+#include <tdeio/netaccess.h>
+#include <tdeio/job.h>
+#include <kprogress.h>
+#include <tdeglobalsettings.h>
+
+#include "ksquirrel.h"
+#include "sq_directorybasket.h"
+#include "sq_storagefile.h"
+#include "sq_iconloader.h"
+#include "sq_treeviewmenu.h"
+#include "sq_widgetstack.h"
+#include "sq_diroperator.h"
+#include "sq_navigatordropmenu.h"
+#include "sq_dir.h"
+
+SQ_DirectoryBasket * SQ_DirectoryBasket::m_inst = 0;
+
+/* ******************************************************************************* */
+
+SQ_DBMenu::SQ_DBMenu(TQWidget *parent, const char *name) : SQ_TreeViewMenu(parent, name), item(0)
+{
+ insertSeparator();
+ id_icon = insertItem(i18n("Change icon"), this, TQ_SLOT(slotChangeIcon()));
+}
+
+SQ_DBMenu::~SQ_DBMenu()
+{}
+
+void SQ_DBMenu::slotChangeIcon()
+{
+ TDEIconDialog dialog(TDEGlobal::iconLoader());
+ dialog.setup(TDEIcon::Desktop, TDEIcon::MimeType, true, TDEIcon::SizeSmall);
+ TQString result = dialog.openDialog();
+
+ if(!result.isEmpty() && item)
+ {
+ item->setIcon(result);
+ item->setPixmap(0, SQ_IconLoader::instance()->loadIcon(result, TDEIcon::Desktop, TDEIcon::SizeSmall));
+ }
+}
+
+void SQ_DBMenu::updateDirActions(bool, bool isroot)
+{
+ setItemEnabled(id_new, isroot);
+ setItemEnabled(id_clear, isroot);
+ setItemEnabled(id_prop, !isroot);
+
+ setItemEnabled(id_delete, !isroot);
+ setItemEnabled(id_rename, !isroot);
+ setItemEnabled(id_icon, !isroot);
+}
+
+void SQ_DBMenu::slotDirectoryRename()
+{
+ if(item)
+ {
+ TQString renameSrc = item->text(0);
+ bool ok;
+
+ TQString mNewFilename = KInputDialog::getText(i18n("Rename Folder"),
+ i18n("<p>Rename item <b>%1</b> to:</p>").arg(renameSrc),
+ renameSrc, &ok, KSquirrel::app());
+
+ if(ok)
+ {
+ item->setName(mNewFilename);
+ item->setText(0, mNewFilename);
+ }
+ }
+}
+
+void SQ_DBMenu::slotDirectoryResult(TDEIO::Job *job)
+{
+ if(job && job->error())
+ job->showErrorDialog(KSquirrel::app());
+}
+
+void SQ_DBMenu::slotDirectoryDelete()
+{
+ if(item)
+ {
+ TDEIO::Job *job = TDEIO::del(item->KFileTreeViewItem::url());
+
+ connect(job, TQ_SIGNAL(result(TDEIO::Job*)), this, TQ_SLOT(slotDirectoryResult(TDEIO::Job *)));
+ }
+}
+
+/* ******************************************************************************* */
+
+SQ_DirectoryItem::SQ_DirectoryItem(KFileTreeViewItem *parentItem, KFileItem *fileItem, KFileTreeBranch *parentBranch)
+ : KFileTreeViewItem(parentItem, fileItem, parentBranch), m_index(0)
+{}
+
+SQ_DirectoryItem::SQ_DirectoryItem(KFileTreeView *parent, KFileItem *fileItem, KFileTreeBranch *parentBranch)
+ : KFileTreeViewItem(parent, fileItem, parentBranch), m_index(0)
+{}
+
+SQ_DirectoryItem::~SQ_DirectoryItem()
+{}
+
+/* ******************************************************************************* */
+
+SQ_DirectoryBasketBranch::SQ_DirectoryBasketBranch(KFileTreeView *parent, const KURL &url, const TQString &name, const TQPixmap &pix)
+ : KFileTreeBranch(parent, url, name, pix)
+{}
+
+SQ_DirectoryBasketBranch::~SQ_DirectoryBasketBranch()
+{}
+
+KFileTreeViewItem* SQ_DirectoryBasketBranch::createTreeViewItem(KFileTreeViewItem *parent, KFileItem *fileItem)
+{
+ if(!parent || !fileItem)
+ return 0;
+
+ // hehe...
+ fileItem->setMimeType("inode/directory");
+
+ SQ_DirectoryItem *i = new SQ_DirectoryItem(parent, fileItem, this);
+
+ if(i)
+ {
+ // inpath = "<URL><name><index>"
+ TQStringList list = TQStringList::split(TQChar('\n'), SQ_StorageFile::readStorageFileAsString(i->path()), true);
+
+ if(list.count() < 4)
+ return i;
+
+ TQStringList::iterator it = list.begin();
+
+ bool ok;
+ TQString name, icon;
+
+ // get url
+ KURL inpath = KURL::fromPathOrURL(*it);
+ ++it;
+
+ // get name
+ name = *it;
+ ++it;
+
+ // get icon
+ icon = *it;
+ ++it;
+
+ // get index
+ int index = (*it).toInt(&ok);
+
+ i->setURL(inpath);
+
+ if(name.isEmpty())
+ i->setText(0, inpath.isLocalFile() ? inpath.path() : inpath.prettyURL());
+ else
+ {
+ i->setText(0, name);
+ i->setName(name);
+ }
+
+ if(!icon.isEmpty())
+ {
+ i->setIcon(icon);
+ i->setPixmap(0, SQ_IconLoader::instance()->loadIcon(icon, TDEIcon::Desktop, TDEIcon::SizeSmall));
+ }
+
+ if(ok) i->setIndex(index);
+ }
+
+ return i;
+}
+
+/* ******************************************************************************* */
+
+SQ_DirectoryBasket::SQ_DirectoryBasket(TQWidget *parent, const char *name) : KFileTreeView(parent, name)
+{
+ m_inst = this;
+
+ progressAdd = new KProgress(0, "progress add", TQt::WStyle_StaysOnTop | TQt::WStyle_Customize | TQt::WStyle_NoBorder | TQt::WX11BypassWM);
+
+ menu = new SQ_DBMenu(this);
+
+ timer = new TQTimer(this);
+ connect(timer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotSortReal()));
+
+ timerAdd = new TQTimer(this);
+ connect(timerAdd, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotDelayedShowAdd()));
+
+ setSorting(-1);
+ setAcceptDrops(true);
+
+ dir = new SQ_Dir(SQ_Dir::DirectoryBasket);
+
+ // create custom branch
+ root = new SQ_DirectoryBasketBranch(this, dir->root(), TQString(),
+ SQ_IconLoader::instance()->loadIcon("folder", TDEIcon::Desktop, TDEIcon::SizeSmall));
+
+ // some hacks to create our SQ_TreeViewItem as root item
+ SQ_DirectoryItem *ritem = new SQ_DirectoryItem(this,
+ new KFileItem(dir->root(),
+ "inode/directory", S_IFDIR),
+ root);
+
+ ritem->setText(0, i18n("Folders"));
+ ritem->setExpandable(true);
+ ritem->setURL(dir->root());
+ delete root->root();
+ root->setRoot(ritem);
+
+ addBranch(root);
+
+ disconnect(root, TQ_SIGNAL(refreshItems(const KFileItemList &)), 0, 0);
+
+ header()->hide();
+ addColumn(i18n("File"));
+ setDirOnlyMode(root, false);
+ setCurrentItem(root->root());
+ root->setOpen(true);
+ setRootIsDecorated(false);
+
+ menu->reconnect(SQ_TreeViewMenu::New, this, TQ_SLOT(slotNewDirectory()));
+
+ connect(this, TQ_SIGNAL(spacePressed(TQListViewItem*)), this, TQ_SIGNAL(executed(TQListViewItem*)));
+ connect(this, TQ_SIGNAL(returnPressed(TQListViewItem*)), this, TQ_SIGNAL(executed(TQListViewItem*)));
+ connect(this, TQ_SIGNAL(executed(TQListViewItem*)), this, TQ_SLOT(slotItemExecuted(TQListViewItem*)));
+ connect(this, TQ_SIGNAL(contextMenu(TDEListView*, TQListViewItem*, const TQPoint&)), this, TQ_SLOT(slotContextMenu(TDEListView*, TQListViewItem*, const TQPoint&)));
+ connect(this, TQ_SIGNAL(dropped(TQDropEvent*, TQListViewItem*, TQListViewItem*)), this, TQ_SLOT(slotDropped(TQDropEvent*, TQListViewItem*, TQListViewItem*)));
+ connect(this, TQ_SIGNAL(itemRenamed(TQListViewItem *, int, const TQString &)), this, TQ_SLOT(slotItemRenamedMy(TQListViewItem *, int, const TQString &)));
+ connect(this, TQ_SIGNAL(itemAdded(TQListViewItem *)), this, TQ_SLOT(slotSort()));
+ connect(this, TQ_SIGNAL(moved()), this, TQ_SLOT(slotReindex()));
+}
+
+SQ_DirectoryBasket::~SQ_DirectoryBasket()
+{
+ SQ_DirectoryItem *item = static_cast<SQ_DirectoryItem *>(root->root()->firstChild());
+
+ static const TQString &nl = TDEGlobal::staticQString("\n");
+
+ if(item)
+ {
+ TQString url;
+ int index = 0;
+
+ do
+ {
+ url = item->url().prettyURL() + nl + item->name() + nl + item->icon() + nl + TQString::number(index);
+
+ SQ_StorageFile::writeStorageFileAsString(
+ dir->root() + TQDir::separator() + item->url().fileName(),
+ item->url(), url);
+
+ ++index;
+ }
+ while((item = static_cast<SQ_DirectoryItem *>(item->nextSibling())));
+ }
+
+ delete dir;
+ delete progressAdd;
+}
+
+void SQ_DirectoryBasket::slotNewDirectory()
+{
+ static const TQString &nl = TDEGlobal::staticQString("\n");
+
+ KURL url = KFileDialog::getExistingURL(TQString(), KSquirrel::app());
+
+ if(url.isEmpty())
+ return;
+
+ SQ_StorageFile::writeStorageFileAsString(
+ dir->root() + TQDir::separator() + url.fileName(),
+ url,
+ (url.prettyURL() + nl + nl + nl + TQString::number(root->root()->childCount())));
+}
+
+void SQ_DirectoryBasket::slotDropped(TQDropEvent *e, TQListViewItem *_parent, TQListViewItem *_item)
+{
+ if(!_parent) return;
+ if(!_item) _item = _parent;
+
+ SQ_DirectoryItem *item = static_cast<SQ_DirectoryItem *>(_item);
+ SQ_DirectoryItem *parent = static_cast<SQ_DirectoryItem *>(_parent);
+
+ KURL::List list;
+ KURLDrag::decode(e, list);
+
+ // drag'n'drop inside basket
+ if(e->source() == this)
+ {
+ SQ_DirectoryItem *tomove = static_cast<SQ_DirectoryItem *>(root->findTVIByURL(list.first()));
+
+ if(!tomove || tomove == root->root()) return;
+
+ SQ_DirectoryItem *it;
+
+ if(item->index() < tomove->index() && item != root->root())
+ it = static_cast<SQ_DirectoryItem *>(item->itemAbove());
+ else
+ it = static_cast<SQ_DirectoryItem *>(item);
+
+ if(it)
+ {
+ if(it != root->root())
+ moveItem(tomove, parent, it);
+ else
+ moveItem(tomove, parent, 0);
+
+ emit moved();
+
+ setCurrentItem(tomove);
+ setSelected(tomove, true);
+ }
+ }
+ else if(item == root->root()) // some files were dropped from another source
+ {
+ KURL::List::iterator itEnd = list.end();
+ KFileItemList flist;
+ TDEIO::UDSEntry entry;
+
+ progressAdd->setTotalSteps(list.count());
+ timerAdd->start(1000, true);
+
+ for(KURL::List::iterator it = list.begin();it != itEnd;++it)
+ {
+ if(TDEIO::NetAccess::stat(*it, entry, KSquirrel::app()))
+ flist.append(new KFileItem(entry, *it));
+
+ progressAdd->advance(1);
+ }
+
+ timerAdd->stop();
+ progressAdd->hide();
+
+ add(flist);
+ flist.setAutoDelete(true);
+ }
+ else
+ {
+ SQ_NavigatorDropMenu::instance()->setupFiles(list, item->url());
+ SQ_NavigatorDropMenu::instance()->exec(TQCursor::pos(), true);
+ }
+}
+
+void SQ_DirectoryBasket::slotItemExecuted(TQListViewItem *item)
+{
+ if(!item) return;
+
+ if(item == root->root())
+ {
+ root->setOpen(true);
+ return;
+ }
+
+ KFileTreeViewItem *cur = static_cast<KFileTreeViewItem *>(item);
+
+ if(cur && !cur->isDir())
+ {
+ KURL inpath = SQ_StorageFile::readStorageFile(cur->path());
+ SQ_WidgetStack::instance()->diroperator()->setURL(inpath, true);
+ }
+}
+
+void SQ_DirectoryBasket::slotContextMenu(TDEListView *, TQListViewItem *item, const TQPoint &p)
+{
+ if(item)
+ {
+ SQ_DirectoryItem *kfi = static_cast<SQ_DirectoryItem *>(item);
+
+ if(kfi)
+ {
+ menu->updateDirActions(true, item == root->root());
+ menu->setURL(kfi->url());
+ menu->setItem(kfi);
+ menu->exec(p);
+ }
+ }
+}
+
+void SQ_DirectoryBasket::add(const KFileItemList &list)
+{
+ static const TQString &nl = TDEGlobal::staticQString("\n");
+
+ KFileItemListIterator it(list);
+ KFileItem *fi;
+ TQString url;
+
+ while((fi = it.current()))
+ {
+ if(fi->isDir())
+ {
+ url = fi->url().prettyURL() + nl + nl + nl + TQString::number(root->root()->childCount());
+
+ SQ_StorageFile::writeStorageFileAsString(
+ dir->root() + TQDir::separator() + fi->url().fileName(),
+ fi->url(),
+ url);
+ }
+
+ ++it;
+ }
+}
+
+void SQ_DirectoryBasket::slotSort()
+{
+ timer->start(100, true);
+}
+
+void SQ_DirectoryBasket::slotSortReal()
+{
+ sort();
+}
+
+struct SortableItem
+{
+ SortableItem(TQListViewItem *i, int ind) : item(i), index(ind)
+ {}
+
+ SortableItem() : item(0), index(0)
+ {}
+
+ bool operator< (const SortableItem &i)
+ {
+ return index > i.index;
+ }
+
+ TQListViewItem *item;
+ int index;
+};
+
+void SQ_DirectoryBasket::sort()
+{
+ TQListViewItemIterator it(this);
+ SQ_DirectoryItem *item;
+
+ TQValueVector<SortableItem> items;
+ int i = 0;
+ ++it;
+
+ while((item = static_cast<SQ_DirectoryItem *>(it.current())))
+ {
+ items.append(SortableItem(item, item->index()));
+ ++it;
+ }
+
+ const int nChildren = items.count();
+
+ for(i = 0;i < nChildren;i++)
+ root->root()->takeItem(items[i].item);
+
+ qHeapSort(items);
+
+ blockSignals(true);
+ for(i = 0;i < nChildren;i++)
+ root->root()->insertItem(items[i].item);
+ blockSignals(false);
+}
+
+void SQ_DirectoryBasket::slotReindex()
+{
+ SQ_DirectoryItem *item = static_cast<SQ_DirectoryItem *>(root->root()->firstChild());
+
+ if(item)
+ {
+ int index = 0;
+
+ do
+ {
+ item->setIndex(index++);
+ }
+ while((item = static_cast<SQ_DirectoryItem *>(item->nextSibling())));
+ }
+}
+
+void SQ_DirectoryBasket::slotItemRenamedMy(TQListViewItem *_item, int, const TQString &name)
+{
+ SQ_DirectoryItem *item = static_cast<SQ_DirectoryItem *>(_item);
+
+ if(item)
+ item->setName(name);
+}
+
+void SQ_DirectoryBasket::slotDelayedShowAdd()
+{
+ int w = 200, h = 32;
+
+ TQRect rc = TDEGlobalSettings::splashScreenDesktopGeometry();
+
+ progressAdd->setGeometry(rc.center().x() - w/2, rc.center().y() - h/2, w, h);
+ progressAdd->show();
+}
+
+#include "sq_directorybasket.moc"
diff --git a/src/sidebar/sq_directorybasket.h b/src/sidebar/sq_directorybasket.h
new file mode 100644
index 0000000..6f2858d
--- /dev/null
+++ b/src/sidebar/sq_directorybasket.h
@@ -0,0 +1,195 @@
+/***************************************************************************
+ sq_directorybasket.h - description
+ -------------------
+ begin : ??? Sep 29 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_DIRECTORYBASKET_H
+#define SQ_DIRECTORYBASKET_H
+
+#include <tdefiletreeview.h>
+#include <tdefiletreebranch.h>
+
+#include "sq_treeviewmenu.h"
+
+class TQTimer;
+
+class KProgress;
+
+namespace TDEIO { class Job; }
+
+class SQ_DirectoryItem;
+class SQ_Dir;
+
+class SQ_DBMenu : public SQ_TreeViewMenu
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_DBMenu(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_DBMenu();
+
+ virtual void updateDirActions(bool, bool isroot = false);
+
+ void setItem(SQ_DirectoryItem *);
+
+ private slots:
+ void slotChangeIcon();
+ void slotDirectoryRename();
+ void slotDirectoryDelete();
+ void slotDirectoryResult(TDEIO::Job *job);
+
+ private:
+ SQ_DirectoryItem *item;
+ int id_icon;
+};
+
+inline
+void SQ_DBMenu::setItem(SQ_DirectoryItem *i)
+{
+ item = i;
+}
+
+class SQ_DirectoryItem : public KFileTreeViewItem
+{
+ public:
+ SQ_DirectoryItem(KFileTreeViewItem *parentItem, KFileItem *fileItem, KFileTreeBranch *parentBranch);
+ SQ_DirectoryItem(KFileTreeView *parent, KFileItem *fileItem, KFileTreeBranch *parentBranch);
+ ~SQ_DirectoryItem();
+
+ int index() const;
+ void setIndex(int ind);
+
+ KURL url() const;
+ void setURL(const KURL &u);
+
+ TQString name() const;
+ void setName(const TQString &n);
+
+ TQString icon() const;
+ void setIcon(const TQString &n);
+
+ bool hasName() const;
+
+ private:
+ int m_index;
+ TQString m_name, m_icon;
+ KURL m_url;
+};
+
+inline
+KURL SQ_DirectoryItem::url() const
+{
+ return m_url;
+}
+
+inline
+void SQ_DirectoryItem::setURL(const KURL &u)
+{
+ m_url = u;
+}
+
+inline
+int SQ_DirectoryItem::index() const
+{
+ return m_index;
+}
+
+inline
+void SQ_DirectoryItem::setIndex(int ind)
+{
+ m_index = ind;
+}
+
+inline
+TQString SQ_DirectoryItem::name() const
+{
+ return m_name;
+}
+
+inline
+void SQ_DirectoryItem::setName(const TQString &n)
+{
+ m_name = n;
+}
+
+inline
+TQString SQ_DirectoryItem::icon() const
+{
+ return m_icon;
+}
+
+inline
+void SQ_DirectoryItem::setIcon(const TQString &n)
+{
+ m_icon = n;
+}
+
+inline
+bool SQ_DirectoryItem::hasName() const
+{
+ return !m_name.isEmpty();
+}
+
+/* ****************************************************************** */
+
+class SQ_DirectoryBasketBranch : public KFileTreeBranch
+{
+ public:
+ SQ_DirectoryBasketBranch(KFileTreeView*, const KURL &url, const TQString &name, const TQPixmap &pix);
+ ~SQ_DirectoryBasketBranch();
+
+ protected:
+ virtual KFileTreeViewItem *createTreeViewItem(KFileTreeViewItem *parent, KFileItem *fileItem);
+};
+
+class SQ_DirectoryBasket : public KFileTreeView
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_DirectoryBasket(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_DirectoryBasket();
+
+ void add(const KFileItemList &list);
+
+ static SQ_DirectoryBasket* instance() { return m_inst; }
+
+ private:
+ void sort();
+
+ private slots:
+ void slotDropped(TQDropEvent *, TQListViewItem *, TQListViewItem *);
+ void slotItemExecuted(TQListViewItem *item);
+ void slotContextMenu(TDEListView *, TQListViewItem *item, const TQPoint &p);
+ void slotNewDirectory();
+ void slotSortReal();
+ void slotSort();
+ void slotReindex();
+ void slotItemRenamedMy(TQListViewItem *, int, const TQString &);
+ void slotDelayedShowAdd();
+
+ private:
+ KFileTreeBranch *root;
+ SQ_Dir *dir;
+ TQTimer *timer, *timerAdd;
+ SQ_DBMenu *menu;
+ KProgress *progressAdd;
+
+ static SQ_DirectoryBasket *m_inst;
+};
+
+#endif
diff --git a/src/sidebar/sq_imagebasket.cpp b/src/sidebar/sq_imagebasket.cpp
new file mode 100644
index 0000000..eeba95c
--- /dev/null
+++ b/src/sidebar/sq_imagebasket.cpp
@@ -0,0 +1,291 @@
+/***************************************************************************
+ sq_imagebasket.cpp - description
+ -------------------
+ begin : ??? Feb 24 2007
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tqfile.h>
+
+#include <kmdcodec.h>
+#include <tdefileview.h>
+#include <tdelocale.h>
+#include <tdeglobal.h>
+#include <tdepopupmenu.h>
+#include <tdefileiconview.h>
+#include <kpropertiesdialog.h>
+#include <tdeio/netaccess.h>
+#include <tdeapplication.h>
+#include <kmimetype.h>
+
+#include "ksquirrel.h"
+#include "sq_config.h"
+#include "sq_imagebasket.h"
+#include "sq_storagefile.h"
+#include "sq_dir.h"
+#include "sq_widgetstack.h"
+#include "sq_diroperator.h"
+
+SQ_ImageBasket * SQ_ImageBasket::m_inst;
+
+SQ_ImageBasket::SQ_ImageBasket(TQWidget *parent, const char *name) : KDirOperator((dir = new SQ_Dir(SQ_Dir::Basket))->root(), parent, name)
+{
+ m_inst = this;
+
+ connect(this, TQ_SIGNAL(dropped(const KFileItem *, TQDropEvent*, const KURL::List&)),
+ this, TQ_SLOT(slotDropped(const KFileItem *, TQDropEvent*, const KURL::List&)));
+
+ disconnect(dirLister(), TQ_SIGNAL(refreshItems(const KFileItemList &)), 0, 0);
+
+ // redirect "Properties" dialog
+ disconnect(actionCollection()->action("properties"), 0, 0, 0);
+ connect(actionCollection()->action("properties"), TQ_SIGNAL(activated()), this, TQ_SLOT(slotBasketProperties()));
+
+ disconnect(dirLister(), TQ_SIGNAL(newItems(const KFileItemList &)), 0, 0);
+ connect(dirLister(), TQ_SIGNAL(newItems(const KFileItemList &)), this, TQ_SLOT(insertNewFiles(const KFileItemList &)));
+
+ connect(this, TQ_SIGNAL(viewChanged(KFileView *)), this, TQ_SLOT(slotViewChanged(KFileView *)));
+ connect(this, TQ_SIGNAL(fileSelected(const KFileItem *)), this, TQ_SLOT(slotExecuted(const KFileItem *)));
+
+ setView(KFile::Simple);
+ setMode(KFile::Files);
+
+ setAcceptDrops(true);
+
+ SQ_Config::instance()->setGroup("Fileview");
+ int sorting = 0;
+
+ if(SQ_Config::instance()->readBoolEntry("basket_sorting_name", true)) sorting |= TQDir::Name;
+ if(SQ_Config::instance()->readBoolEntry("basket_sorting_time", false)) sorting |= TQDir::Time;
+ if(SQ_Config::instance()->readBoolEntry("basket_sorting_size", false)) sorting |= TQDir::Size;
+ if(SQ_Config::instance()->readBoolEntry("basket_sorting_dirs", true)) sorting |= TQDir::DirsFirst;
+ if(SQ_Config::instance()->readBoolEntry("basket_sorting_reverse", false)) sorting |= TQDir::Reversed;
+ if(SQ_Config::instance()->readBoolEntry("basket_sorting_ignore", false)) sorting |= TQDir::IgnoreCase;
+
+ setSorting(static_cast<TQDir::SortSpec>(sorting));
+}
+
+SQ_ImageBasket::~SQ_ImageBasket()
+{
+ delete dir;
+}
+
+void SQ_ImageBasket::insertNewFiles(const KFileItemList &list)
+{
+ TQString n;
+ int ind;
+ KFileItemListIterator it(list);
+ KFileItem *tmp;
+
+ for(; (tmp = it.current()); ++it)
+ {
+ n = tmp->name();
+ ind = n.findRev('.');
+
+ // OOPS
+ if(ind != -1)
+ n.truncate(ind);
+
+ // force determining mimetype
+ (void)tmp->mimetype();
+ tmp->setName(n);
+
+ TQStringList list = TQStringList::split(TQChar('\n'), SQ_StorageFile::readStorageFileAsString(tmp->url().path()), true);
+ TQStringList::iterator it = list.begin();
+
+ if(list.count() > 1)
+ {
+ ++it; // skip url
+ tmp->setMimeType(*it);
+ }
+ else
+ {
+ KURL url = KURL::fromPathOrURL(*it);
+ TQString mime = KMimeType::findByURL(url)->name();
+ tmp->setMimeType(mime);
+
+ static const TQString &nl = TDEGlobal::staticQString("\n");
+
+ TQString inurl = url.prettyURL() + nl + mime;
+
+ SQ_StorageFile::writeStorageFileAsString(
+ dir->root() + TQDir::separator() + url.fileName(),
+ url, inurl);
+ }
+ }
+
+ view()->addItemList(list);
+}
+
+void SQ_ImageBasket::add(const KFileItemList &list)
+{
+ KFileItem *tmp;
+ static const TQString &nl = TDEGlobal::staticQString("\n");
+
+ for(KFileItemListIterator it(list); (tmp = it.current()); ++it)
+ {
+ if(tmp->isFile())
+ {
+ TQString inurl = tmp->url().prettyURL() + nl + tmp->mimetype();
+
+ SQ_StorageFile::writeStorageFileAsString(
+ dir->root() + TQDir::separator() + tmp->name(),
+ tmp->url(), inurl);
+ }
+ }
+}
+
+void SQ_ImageBasket::slotDropped(const KFileItem *, TQDropEvent*, const KURL::List &list)
+{
+ TQString name;
+ KURL::List::const_iterator itEnd = list.end();
+ static const TQString &nl = TDEGlobal::staticQString("\n");
+
+ for(KURL::List::const_iterator it = list.begin();it != itEnd;++it)
+ {
+ TQString inurl = (*it).prettyURL() + nl + KMimeType::findByURL(*it)->name();
+
+ SQ_StorageFile::writeStorageFileAsString(
+ dir->root() + TQDir::separator() + (*it).fileName(),
+ *it, inurl);
+ }
+}
+
+void SQ_ImageBasket::slotBasketProperties()
+{
+ KFileView *fileView = view();
+
+ if(fileView)
+ {
+ KFileItemList newlist;
+ KFileItem *item = 0;
+
+ newlist.setAutoDelete(true);
+
+ for((item = fileView->firstFileItem()); item; item = fileView->nextItem(item))
+ {
+ if(fileView->isSelected(item))
+ {
+ KFileItem *realFile = new KFileItem(KFileItem::Unknown, KFileItem::Unknown,
+ SQ_StorageFile::readStorageFile(item->url().path()));
+
+ newlist.append(realFile);
+ }
+ }
+
+ if (!newlist.isEmpty())
+ (void)new KPropertiesDialog(newlist, KSquirrel::app(), "props dlg", true);
+ }
+}
+
+KFileItemList SQ_ImageBasket::realItems() const
+{
+ KFileView *fileView = view();
+ KFileItemList newlist;
+
+ newlist.setAutoDelete(true);
+
+ if(fileView)
+ {
+ KFileItem *item = 0;
+
+ for((item = fileView->firstFileItem()); item; item = fileView->nextItem(item))
+ {
+ KFileItem *realFile = new KFileItem(KFileItem::Unknown, KFileItem::Unknown,
+ SQ_StorageFile::readStorageFile(item->url().path()));
+
+ newlist.append(realFile);
+ }
+ }
+
+ return newlist;
+}
+
+void SQ_ImageBasket::slotSync()
+{
+ KFileView *fileView = view();
+
+ if(fileView)
+ {
+ KFileItem *item = 0;
+ KURL path;
+ TDEIO::UDSEntry entry;
+
+ for((item = fileView->firstFileItem()); item; item = fileView->nextItem(item))
+ {
+ path = SQ_StorageFile::readStorageFile(item->url().path());
+
+ if(!TDEIO::NetAccess::stat(path, entry, KSquirrel::app()))
+ TQFile::remove(item->url().path());
+ }
+ }
+}
+
+void SQ_ImageBasket::slotViewChanged(KFileView *v)
+{
+ KFileIconView *iv = dynamic_cast<KFileIconView *>(v);
+
+ if(iv)
+ {
+ TDEAction *a;
+
+ a = iv->actionCollection()->action("zoomIn");
+ if(a) a->setShortcut(0);
+
+ a = iv->actionCollection()->action("zoomOut");
+ if(a) a->setShortcut(0);
+
+ a = iv->actionCollection()->action("show previews");
+ if(a) a->setShortcut(0);
+ }
+}
+
+void SQ_ImageBasket::slotExecuted(const KFileItem *fi)
+{
+ if(!fi)
+ return;
+
+ KURL inpath = SQ_StorageFile::readStorageFile(fi->url().path());
+
+ KFileItem f(KFileItem::Unknown, KFileItem::Unknown, inpath);
+
+ SQ_WidgetStack::instance()->diroperator()->execute(&f);
+}
+
+void SQ_ImageBasket::activatedMenu(const KFileItem *, const TQPoint &pos)
+{
+ setupMenu(KDirOperator::AllActions ^ KDirOperator::NavActions ^ KDirOperator::ViewActions);
+ updateSelectionDependentActions();
+
+ TDEActionMenu *pADirOperatorMenu = dynamic_cast<TDEActionMenu *>(actionCollection()->action("popupMenu"));
+ pADirOperatorMenu->popupMenu()->insertItem(i18n("Synchronize"), this, TQ_SLOT(slotSync()), 0, -1, 0);
+ pADirOperatorMenu->popupMenu()->insertSeparator(1);
+
+ pADirOperatorMenu->popup(pos);
+}
+
+void SQ_ImageBasket::saveConfig()
+{
+ TQDir::SortSpec sort = sorting();
+
+ SQ_Config::instance()->writeEntry("basket_sorting_name", KFile::isSortByName(sort));
+ SQ_Config::instance()->writeEntry("basket_sorting_time", KFile::isSortByDate(sort));
+ SQ_Config::instance()->writeEntry("basket_sorting_size", KFile::isSortBySize(sort));
+ SQ_Config::instance()->writeEntry("basket_sorting_dirs", KFile::isSortDirsFirst(sort));
+ SQ_Config::instance()->writeEntry("basket_sorting_reverse", (sort & TQDir::Reversed) == TQDir::Reversed);
+ SQ_Config::instance()->writeEntry("basket_sorting_ignore", KFile::isSortCaseInsensitive(sort));
+
+ SQ_Config::instance()->writeEntry("show hidden", showHiddenFiles());
+}
+
+#include "sq_imagebasket.moc"
diff --git a/src/sidebar/sq_imagebasket.h b/src/sidebar/sq_imagebasket.h
new file mode 100644
index 0000000..406b3c4
--- /dev/null
+++ b/src/sidebar/sq_imagebasket.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+ sq_imagebasket.h - description
+ -------------------
+ begin : ??? Feb 24 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_IMAGEBASKET_H
+#define SQ_IMAGEBASKET_H
+
+#include <tdediroperator.h>
+
+class SQ_Dir;
+
+/**
+ *@author Baryshev Dmitry
+ */
+
+class SQ_ImageBasket : public KDirOperator
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_ImageBasket(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_ImageBasket();
+
+ void add(const KFileItemList &);
+
+ KFileItemList realItems() const;
+
+ void saveConfig();
+
+ static SQ_ImageBasket* instance() { return m_inst; }
+
+ private slots:
+ // coming from KDirOperator
+ void insertNewFiles(const KFileItemList &);
+ void slotDropped(const KFileItem *, TQDropEvent*, const KURL::List&);
+ void slotBasketProperties();
+ void slotSync();
+ void slotViewChanged(KFileView *);
+ void slotExecuted(const KFileItem *fi);
+
+ void activatedMenu(const KFileItem *, const TQPoint &pos);
+
+ private:
+ SQ_Dir *dir;
+ static SQ_ImageBasket *m_inst;
+};
+
+#endif
diff --git a/src/sidebar/sq_mountview.cpp b/src/sidebar/sq_mountview.cpp
new file mode 100644
index 0000000..c52b199
--- /dev/null
+++ b/src/sidebar/sq_mountview.cpp
@@ -0,0 +1,247 @@
+/***************************************************************************
+ sq_mountview.cpp - description
+ -------------------
+ begin : ??? Nov 29 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tdemessagebox.h>
+#include <kmountpoint.h>
+#include <tdeglobal.h>
+#include <tdelocale.h>
+#include <kautomount.h>
+#include <tdepopupmenu.h>
+
+#include "ksquirrel.h"
+#include "sq_mountview.h"
+#include "sq_mountviewitem.h"
+#include "sq_iconloader.h"
+#include "sq_config.h"
+
+SQ_MountView * SQ_MountView::m_inst = 0;
+
+SQ_MountView::SQ_MountView(TQWidget *parent, const char *name) : TDEListView(parent, name), m_columns(-1)
+{
+ m_inst = this;
+
+ popup = new TDEPopupMenu;
+ id_mount = popup->insertItem(SQ_IconLoader::instance()->loadIcon("drive-harddisk-mounted", TDEIcon::Desktop, TDEIcon::SizeSmall),
+ i18n("Mount"), this, TQ_SLOT(slotMount()));
+ id_unmount = popup->insertItem(SQ_IconLoader::instance()->loadIcon("drive-harddisk-unmounted", TDEIcon::Desktop, TDEIcon::SizeSmall),
+ i18n("Unmount"), this, TQ_SLOT(slotUnmount()));
+ popup->insertItem(SQ_IconLoader::instance()->loadIcon("reload", TDEIcon::Desktop, TDEIcon::SizeSmall),
+ i18n("Refresh"), this, TQ_SLOT(slotRefresh()));
+ popup->insertSeparator();
+ popup->insertItem(i18n("Cancel"));
+
+ connect(this, TQ_SIGNAL(contextMenu(TDEListView *, TQListViewItem *, const TQPoint &)),
+ this, TQ_SLOT(slotContextMenu(TDEListView *, TQListViewItem *, const TQPoint &)));
+ setAcceptDrops(false);
+
+ connect(this, TQ_SIGNAL(returnPressed(TQListViewItem*)), this, TQ_SLOT(slotExecuted(TQListViewItem *)));
+ connect(this, TQ_SIGNAL(clicked(TQListViewItem*)), this, TQ_SLOT(slotExecuted(TQListViewItem *)));
+
+ setShowSortIndicator(true);
+ setAllColumnsShowFocus(true);
+ setSelectionMode(TQListView::Single);
+ setItemsMovable(false);
+
+ // "Name" column will always exist
+ addColumn(i18n("Name"));
+
+ setupColumns();
+}
+
+SQ_MountView::~SQ_MountView()
+{}
+
+void SQ_MountView::slotExecuted(TQListViewItem *i)
+{
+ SQ_MountViewItem *mvi = static_cast<SQ_MountViewItem *>(i);
+
+ if(!mvi)
+ return;
+
+ if(mvi->mounted())
+ emit path(mvi->text(0));
+ else
+ {
+ mountItem = mvi;
+ KAutoMount *mounter = new KAutoMount(false, TQString(), mvi->device(), TQString(), TQString(), false);
+ connect(mounter, TQ_SIGNAL(finished()), this, TQ_SLOT(slotMountFinished()));
+ }
+}
+
+void SQ_MountView::slotMountFinished()
+{
+ mountItem->setMounted(true);
+ emit path(mountItem->text(0));
+}
+
+void SQ_MountView::slotMountError()
+{
+ mountItem->setMounted(false);
+}
+
+void SQ_MountView::reload(bool current)
+{
+ // get currently mounted filesystems
+ KMountPoint::List mt = current ?
+ KMountPoint::currentMountPoints(KMountPoint::NeedMountOptions | KMountPoint::NeedRealDeviceName)
+ : KMountPoint::possibleMountPoints(KMountPoint::NeedMountOptions | KMountPoint::NeedRealDeviceName);
+
+ SQ_MountViewItem *fi;
+ int colum;
+
+ for(KMountPoint::List::iterator it = mt.begin();it != mt.end();++it)
+ {
+ colum = 1;
+
+ if(mounted.find((*it)->mountPoint()) == mounted.end())
+ {
+ mounted.append((*it)->mountPoint());
+
+ // filter out /proc, swap etc.
+ if(!(*it)->mountedFrom().startsWith(TQChar('/')) || !(*it)->mountPoint().startsWith(TQChar('/')))
+ continue;
+
+ fi = new SQ_MountViewItem(this, (*it)->mountPoint());
+ fi->setMounted(current);
+ fi->setDevice((*it)->realDeviceName());
+
+ if(m_columns & OPT_COL_DEVICE)
+ fi->setText(colum++, (*it)->realDeviceName());
+
+ if(m_columns & OPT_COL_FSTYPE)
+ fi->setText(colum++, (*it)->mountType());
+
+ if(m_columns & OPT_COL_OPTIONS)
+ fi->setText(colum, (*it)->mountOptions().join(TQString::fromLatin1(", ")));
+ }
+ }
+}
+
+bool SQ_MountView::exists(const TQString &name)
+{
+ TQListViewItemIterator it(this);
+
+ while(it.current())
+ {
+ SQ_MountViewItem *mvi = static_cast<SQ_MountViewItem *>(it.current());
+
+ if(mvi && mvi->text(0) == name)
+ return true;
+
+ ++it;
+ }
+
+ return false;
+}
+
+void SQ_MountView::setColumns(int cols)
+{
+ if(m_columns == cols)
+ return;
+
+ m_columns = cols;
+
+ int cur = columns() - 1;
+
+ // remove old columns, 0 is always "Name"
+ for(int i = 0;i < cur;i++)
+ removeColumn(1);
+
+ // add new
+ if(m_columns & OPT_COL_DEVICE)
+ addColumn(i18n("Device"));
+
+ if(m_columns & OPT_COL_FSTYPE)
+ addColumn(i18n("FS Type"));
+
+ if(m_columns & OPT_COL_OPTIONS)
+ addColumn(i18n("Options"));
+
+ slotRefresh();
+}
+
+void SQ_MountView::setupColumns()
+{
+ SQ_Config::instance()->setGroup("Sidebar");
+ int p = 0;
+
+ if(SQ_Config::instance()->readBoolEntry("mount_options", false))
+ p |= SQ_MountView::OPT_COL_OPTIONS;
+
+ if(SQ_Config::instance()->readBoolEntry("mount_fstype", true))
+ p |= SQ_MountView::OPT_COL_FSTYPE;
+
+ if(SQ_Config::instance()->readBoolEntry("mount_device", false))
+ p |= SQ_MountView::OPT_COL_DEVICE;
+
+ setColumns(p);
+}
+
+void SQ_MountView::slotContextMenu(TDEListView *, TQListViewItem *i, const TQPoint &p)
+{
+ SQ_MountViewItem *mvi = static_cast<SQ_MountViewItem *>(i);
+
+ citem = mvi;
+
+ popup->setItemEnabled(id_mount, !!mvi);
+ popup->setItemEnabled(id_unmount, !!mvi);
+
+ popup->exec(p);
+}
+
+void SQ_MountView::slotUnmount()
+{
+ if(citem)
+ {
+ KAutoUnmount *mounter = new KAutoUnmount(citem->text(0), TQString());
+ connect(mounter, TQ_SIGNAL(finished()), this, TQ_SLOT(slotUnmountFinished()));
+ }
+}
+
+void SQ_MountView::slotMount()
+{
+ if(citem)
+ {
+ KAutoMount *mounter = new KAutoMount(false, TQString(), citem->device(), TQString(), TQString(), false);
+ connect(mounter, TQ_SIGNAL(finished()), this, TQ_SLOT(slotMountFinished2()));
+// connect(mounter, TQ_SIGNAL(error()), this, TQ_SLOT(slotMountError()));
+ }
+}
+
+void SQ_MountView::slotUnmountFinished()
+{
+ citem->setMounted(false);
+}
+
+void SQ_MountView::slotMountFinished2()
+{
+ citem->setMounted(true);
+}
+
+void SQ_MountView::slotRefresh()
+{
+ clear();
+ mounted.clear();
+ reload();
+ reload(false);
+}
+
+#include "sq_mountview.moc"
diff --git a/src/sidebar/sq_mountview.h b/src/sidebar/sq_mountview.h
new file mode 100644
index 0000000..d14aa13
--- /dev/null
+++ b/src/sidebar/sq_mountview.h
@@ -0,0 +1,84 @@
+/***************************************************************************
+ sq_mountview.h - description
+ -------------------
+ begin : ??? Nov 29 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_MOUNTVIEW_H
+#define SQ_MOUNTVIEW_H
+
+#include <tqstringlist.h>
+
+#include <tdelistview.h>
+
+class TDEPopupMenu;
+
+class SQ_MountViewItem;
+
+/*
+ * SQ_MountView is an detailed view representing mount points.
+ */
+
+class SQ_MountView : public TDEListView
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_MountView(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_MountView();
+
+ enum { OPT_COL_MOUNTPOINT = 1, OPT_COL_DEVICE = 2, OPT_COL_FSTYPE = 4, OPT_COL_OPTIONS = 8 };
+
+ static SQ_MountView* instance() { return m_inst; }
+
+ void setupColumns();
+
+ void reload(bool current = true);
+
+ private:
+ void setColumns(int cols);
+ bool exists(const TQString &);
+
+ private slots:
+
+ void slotContextMenu(TDEListView *, TQListViewItem *i, const TQPoint &p);
+ /*
+ * Item executed. We should emit path() signal.
+ */
+ void slotExecuted(TQListViewItem *i);
+
+ // for context menu
+ void slotRefresh();
+ void slotMount();
+ void slotUnmount();
+ void slotUnmountFinished();
+ void slotMountFinished();
+ void slotMountFinished2();
+ void slotMountError();
+
+ signals:
+ void path(const TQString &);
+
+ private:
+ int m_columns;
+ SQ_MountViewItem *mountItem, *citem;
+ TQStringList mounted;
+ TDEPopupMenu *popup;
+ int id_mount, id_unmount;
+
+ static SQ_MountView *m_inst;
+};
+
+#endif
diff --git a/src/sidebar/sq_mountviewitem.cpp b/src/sidebar/sq_mountviewitem.cpp
new file mode 100644
index 0000000..532c0c8
--- /dev/null
+++ b/src/sidebar/sq_mountviewitem.cpp
@@ -0,0 +1,44 @@
+/***************************************************************************
+ sq_mountviewitem.cpp - description
+ -------------------
+ begin : ??? Feb 24 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqfileinfo.h>
+
+#include "sq_mountviewitem.h"
+#include "sq_iconloader.h"
+
+SQ_MountViewItem::SQ_MountViewItem(TDEListView *parent, const TQString &mpoint)
+ : TDEListViewItem(parent, mpoint), m_mounted(false)
+{}
+
+SQ_MountViewItem::~SQ_MountViewItem()
+{}
+
+void SQ_MountViewItem::setMounted(bool b)
+{
+ m_mounted = b;
+ TQFileInfo inf(text(0));
+
+ if(m_mounted)
+ setPixmap(0, inf.isReadable() ? SQ_IconLoader::instance()->loadIcon("folder", TDEIcon::Desktop, TDEIcon::SizeMedium)
+ : SQ_IconLoader::instance()->loadIcon("folder_locked", TDEIcon::Desktop, TDEIcon::SizeMedium));
+ else
+ setPixmap(0, SQ_IconLoader::instance()->loadIcon("folder_red", TDEIcon::Desktop, TDEIcon::SizeMedium));
+}
diff --git a/src/sidebar/sq_mountviewitem.h b/src/sidebar/sq_mountviewitem.h
new file mode 100644
index 0000000..7056c39
--- /dev/null
+++ b/src/sidebar/sq_mountviewitem.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ sq_mountviewitem.h - description
+ -------------------
+ begin : ??? Feb 24 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_MOUNTVIEWITEM_H
+#define SQ_MOUNTVIEWITEM_H
+
+#include <tdelistview.h>
+
+class SQ_MountViewItem : public TDEListViewItem
+{
+ public:
+ SQ_MountViewItem(TDEListView *parent, const TQString &mpoint);
+ ~SQ_MountViewItem();
+
+ bool mounted() const;
+ void setMounted(bool b);
+
+ TQString device() const;
+ void setDevice(const TQString &dev);
+
+ private:
+ bool m_mounted;
+ TQString m_device;
+};
+
+inline
+bool SQ_MountViewItem::mounted() const
+{
+ return m_mounted;
+}
+
+inline
+TQString SQ_MountViewItem::device() const
+{
+ return m_device;
+}
+
+inline
+void SQ_MountViewItem::setDevice(const TQString &dev)
+{
+ m_device = dev;
+}
+
+#endif
diff --git a/src/sidebar/sq_multibar.cpp b/src/sidebar/sq_multibar.cpp
new file mode 100644
index 0000000..399929d
--- /dev/null
+++ b/src/sidebar/sq_multibar.cpp
@@ -0,0 +1,133 @@
+/***************************************************************************
+ sq_multibar.cpp - description
+ -------------------
+ begin : ??? Nov 28 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqwidgetstack.h>
+#include <tqsignalmapper.h>
+#include <tqsplitter.h>
+
+#include <tdemultitabbar.h>
+#include <tdeglobal.h>
+#include <kiconloader.h>
+
+#include "ksquirrel.h"
+#include "sq_previewwidget.h"
+#include "sq_multibar.h"
+#include "sq_config.h"
+
+SQ_MultiBar * SQ_MultiBar::m_inst = 0;
+
+SQ_MultiBar::SQ_MultiBar(TQWidget *parent, const char *name) : TQHBox(parent, name)
+{
+ m_inst = this;
+ m_id = 0;
+ m_selected = -1;
+
+ SQ_Config::instance()->setGroup("Interface");
+ m_width = SQ_Config::instance()->readNumEntry("splitter", 220);
+
+ mapper = new TQSignalMapper(this);
+
+ connect(mapper, TQ_SIGNAL(mapped(int)), this, TQ_SLOT(raiseWidget(int)));
+
+ mt = new KMultiTabBar(KMultiTabBar::Vertical, this);
+
+ // setup multibar: style = VSNET, show text labels on the left side
+ mt->setStyle(KMultiTabBar::VSNET);
+ mt->setPosition(KMultiTabBar::Left);
+ mt->showActiveTabTexts(true);
+
+ setSpacing(0);
+
+ TQSplitter *ts = new TQSplitter(TQt::Vertical, this);
+ ts->setOpaqueResize(false);
+
+ // TQWigdetStack will contain all widgets
+ stack = new TQWidgetStack(ts);
+
+ new SQ_PreviewWidget(ts);
+
+ TQValueList<int> sz;
+ sz.append(5500);
+ sz.append(4500);
+ ts->setSizes(sz);
+}
+
+SQ_MultiBar::~SQ_MultiBar()
+{}
+
+void SQ_MultiBar::addWidget(TQWidget *new_w, const TQString &text, const TQString &icon)
+{
+ // add widget to stack
+ stack->addWidget(new_w, m_id);
+
+ // add button
+ mt->appendTab(TDEGlobal::iconLoader()->loadIcon(icon, TDEIcon::Desktop, 22), m_id, text);
+
+ // since we cann't determine which tab was clicked,
+ // we should use TQSignalMapper to determine it.
+ mapper->setMapping(mt->tab(m_id), m_id);
+
+ connect(mt->tab(m_id), TQ_SIGNAL(clicked()), mapper, TQ_SLOT(map()));
+
+ m_id++;
+}
+
+void SQ_MultiBar::raiseWidget(int id)
+{
+ if(m_selected != -1)
+ mt->setTab(m_selected, false);
+
+ if(mt->isTabRaised(id))
+ {
+ if(m_selected != -1)
+ m_width = stack->width();
+
+ m_selected = id;
+
+ setMinimumSize(TQSize(0, 0));
+ setMaximumSize(TQSize(10000, 10000));
+ stack->raiseWidget(id);
+ stack->resize(m_width, stack->height());
+ stack->show();
+
+ SQ_PreviewWidget::instance()->ignore(false);
+ SQ_PreviewWidget::instance()->loadPending();
+ }
+ else
+ {
+ SQ_PreviewWidget::instance()->ignore(true);
+
+ KSquirrel::app()->saveLayout();
+
+ m_selected = -1;
+ m_width = stack->width();
+ stack->hide();
+ setFixedWidth(mt->width());
+ }
+}
+
+void SQ_MultiBar::updateLayout()
+{
+ setFixedWidth(mt->sizeHint().width());
+ stack->hide();
+}
+
+#include "sq_multibar.moc"
diff --git a/src/sidebar/sq_multibar.h b/src/sidebar/sq_multibar.h
new file mode 100644
index 0000000..12ce455
--- /dev/null
+++ b/src/sidebar/sq_multibar.h
@@ -0,0 +1,111 @@
+/***************************************************************************
+ sq_multibar.h - description
+ -------------------
+ begin : ??? Nov 28 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_MULTIBAR_H
+#define SQ_MULTIBAR_H
+
+#include <tqhbox.h>
+
+class KMultiTabBar;
+
+class TQWidgetStack;
+class TQSignalMapper;
+
+/*
+ * Konqueror-like sidebar.
+ *
+ * +----------------------------------> KMultiTabBar, only contains buttons
+ * | +-----------------+
+ * | | |
+ * | | |
+ * +------------------------+ |
+ * | 1 | | +----> TQWidgetStack, contains all widgets
+ * |---| |
+ * | 2 | |
+ * |---| |
+ * | 3 | |
+ * |---| |
+ * | | visible page |
+ * | | |
+ * | 4 | N4 |
+ * | | |
+ * | | |
+ * |---| |
+ * | | |
+ * | | |
+ * | | |
+ * | | |
+ * +------------------------+
+ *
+ */
+
+class SQ_MultiBar : public TQHBox
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_MultiBar(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_MultiBar();
+
+ /*
+ * Add new widget with text label 'text' and icon 'icon'. SQ_MultiBar
+ * will use SQ_IconLoader to load given icon.
+ */
+ void addWidget(TQWidget *new_w, const TQString &text, const TQString &icon);
+
+ /*
+ * Current page index. 0 means first page.
+ */
+ int currentPage();
+
+ void updateLayout();
+
+ KMultiTabBar* multiBar() const;
+
+ static SQ_MultiBar* instance() { return m_inst; }
+
+ public slots:
+
+ /*
+ * Hide current widget and show a widget with
+ * id 'id'.
+ */
+ void raiseWidget(int id);
+
+ private:
+ KMultiTabBar *mt;
+ TQWidgetStack *stack;
+ int m_id, m_selected, m_width;
+ TQSignalMapper *mapper;
+
+ static SQ_MultiBar *m_inst;
+};
+
+inline
+int SQ_MultiBar::currentPage()
+{
+ return m_selected;
+}
+
+inline
+KMultiTabBar* SQ_MultiBar::multiBar() const
+{
+ return mt;
+}
+
+#endif
diff --git a/src/sidebar/sq_previewwidget.cpp b/src/sidebar/sq_previewwidget.cpp
new file mode 100644
index 0000000..ca9f668
--- /dev/null
+++ b/src/sidebar/sq_previewwidget.cpp
@@ -0,0 +1,364 @@
+/***************************************************************************
+ sq_previewwidget.cpp - description
+ -------------------
+ begin : ??? Mar 13 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqsize.h>
+#include <tqimage.h>
+#include <tqpainter.h>
+
+#include <tdelocale.h>
+#include <tdefileitem.h>
+#include <tdepopupmenu.h>
+#include <kcolordialog.h>
+#include <tdeio/global.h>
+
+#include <ksquirrel-libs/fmt_defs.h>
+
+#include "ksquirrel.h"
+#include "sq_previewwidget.h"
+#include "sq_iconloader.h"
+#include "sq_imageloader.h"
+#include "sq_libraryhandler.h"
+#include "sq_config.h"
+#include "sq_downloader.h"
+#include "sq_utils.h"
+
+#ifdef SQ_HAVE_KEXIF
+#include <libkexif/kexifdata.h>
+#include <algorithm>
+#include "sq_utils.h"
+#endif
+
+SQ_PreviewWidget * SQ_PreviewWidget::m_inst = 0;
+
+SQ_PreviewWidget::SQ_PreviewWidget(TQWidget *parent, const char *name)
+ : TQWidget(parent, name, TQt::WNoAutoErase), all(0), small(0), m_ignore(true)
+{
+ m_inst = this;
+
+ rereadColor();
+
+ down = new SQ_Downloader(this);
+ connect(down, TQ_SIGNAL(result(const KURL &)), this, TQ_SLOT(slotDownloadResult(const KURL &)));
+ connect(down, TQ_SIGNAL(percents(int)), this, TQ_SLOT(slotDownloadPercents(int)));
+
+ popup = new TDEPopupMenu;
+ popup->insertItem(i18n("Background color..."), this, TQ_SLOT(slotBackground()));
+ popup->insertItem(i18n("Text color..."), this, TQ_SLOT(slotText()));
+ popup->insertSeparator();
+ popup->insertItem(i18n("Go to first image")+"\tHome", this, TQ_SIGNAL(first()));
+ popup->insertItem(i18n("Next image")+"\tSpace", this, TQ_SIGNAL(next()));
+ popup->insertItem(i18n("Previous image")+"\tBackSpace", this, TQ_SIGNAL(previous()));
+ popup->insertItem(i18n("Go to last image")+"\tEnd", this, TQ_SIGNAL(last()));
+ popup->insertSeparator();
+ popup->insertItem(i18n("Execute")+"\tEnter", this, TQ_SIGNAL(execute()));
+
+ multi_pix = SQ_IconLoader::instance()->loadIcon("application-vnd.tde.tdemultiple", TDEIcon::Desktop, TDEIcon::SizeSmall);
+
+ setMinimumHeight(20);
+ setFocusPolicy(TQWidget::WheelFocus);
+}
+
+SQ_PreviewWidget::~SQ_PreviewWidget()
+{
+ delete popup;
+ delete small;
+ delete all;
+}
+
+void SQ_PreviewWidget::load(const KURL &_url)
+{
+ if(SQ_LibraryHandler::instance()->maybeSupported(_url) == SQ_LibraryHandler::No)
+ return;
+
+ if(!percentString.isEmpty())
+ {
+ percentString = TQString();
+ update();
+ }
+
+ down->kill();
+
+ if(m_forceignore || m_ignore)
+ {
+ pending = m_url = _url;
+ return;
+ }
+ else
+ pending = KURL();
+
+ m_url = _url;
+
+ if(m_url.isLocalFile())
+ slotDownloadResult(m_url);
+ else
+ {
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, m_url);
+ down->start(&fi);
+ }
+}
+
+void SQ_PreviewWidget::fitAndConvert()
+{
+ if(!m_ignore && fit())
+ pixmap.convertFromImage(small?*small:*all);
+}
+
+void SQ_PreviewWidget::resizeEvent(TQResizeEvent *)
+{
+ fitAndConvert();
+}
+
+void SQ_PreviewWidget::paintEvent(TQPaintEvent *)
+{
+ TQPainter p(this);
+
+ p.fillRect(rect(), color);
+
+ int x = 4;
+
+ if(!percentString.isEmpty())
+ {
+ TQFont fnt = p.font();
+ fnt.setBold(true);
+ p.setFont(fnt);
+ p.setPen(colorText);
+ p.drawText(x, 4, width(), height(), TQt::AlignLeft, percentString);
+ }
+
+ if(!m_ignore && !pixmap.isNull())
+ {
+ p.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap);
+
+ if(multi)
+ {
+ x = x + multi_pix.width() + 4;
+ p.drawPixmap(4, 4, multi_pix);
+ }
+
+ if(dim)
+ {
+ TQFont fnt = p.font();
+ fnt.setBold(true);
+ p.setFont(fnt);
+ p.setPen(colorText);
+ p.drawText(x, 4, width(), height(), TQt::AlignLeft, dimstring);
+ }
+ }
+}
+
+bool SQ_PreviewWidget::fit()
+{
+ if(!all)
+ return false;
+
+ // image is bigger than preview widget -
+ // scale it down
+ if(width() < 2 || height() < 2)
+ return false;
+
+ delete small;
+ small = 0;
+
+ if(all->width() > width() || all->height() > height())
+ {
+ small = new TQImage();
+
+ *small = SQ_Utils::scale(*all, width(), height(), SQ_Utils::SMOOTH_FAST, TQImage::ScaleMin);
+ }
+
+ return true;
+}
+
+void SQ_PreviewWidget::saveValues()
+{
+ SQ_Config::instance()->setGroup("Sidebar");
+ SQ_Config::instance()->writeEntry("preview_background", color.name());
+ SQ_Config::instance()->writeEntry("preview_text", colorText.name());
+}
+
+void SQ_PreviewWidget::rereadColor()
+{
+ SQ_Config::instance()->setGroup("Sidebar");
+ bool b = SQ_Config::instance()->readBoolEntry("preview", true);
+ m_forceignore = !b;
+ setShown(b);
+ color.setNamedColor(SQ_Config::instance()->readEntry("preview_background", "#4e4e4e"));
+ dim = SQ_Config::instance()->readBoolEntry("preview_text_enable", true);
+ colorText.setNamedColor(SQ_Config::instance()->readEntry("preview_text", "#ffffff"));
+ m_delay = SQ_Config::instance()->readNumEntry("preview_delay", 400);
+ m_cancel = SQ_Config::instance()->readBoolEntry("preview_dont", true);
+
+ if(m_delay < 50 || m_delay > 2000)
+ m_delay = 400;
+}
+
+
+void SQ_PreviewWidget::slotBackground()
+{
+ KColorDialog dlg(KSquirrel::app(), 0, true);
+
+ dlg.setColor(color);
+
+ if(dlg.exec() == TQDialog::Accepted)
+ {
+ color = dlg.color();
+ saveValues();
+ update();
+ }
+}
+
+void SQ_PreviewWidget::slotText()
+{
+ KColorDialog dlg(KSquirrel::app(), 0, true);
+
+ dlg.setColor(colorText);
+
+ if(dlg.exec() == TQDialog::Accepted)
+ {
+ colorText = dlg.color();
+ saveValues();
+ update();
+ }
+}
+
+void SQ_PreviewWidget::mousePressEvent(TQMouseEvent *e)
+{
+ e->accept();
+
+ if(e->button() == TQt::RightButton)
+ popup->exec(e->globalPos());
+}
+
+void SQ_PreviewWidget::loadPending()
+{
+ if(pending.isValid())
+ {
+ KURL tmp = pending;
+ load(tmp);
+ }
+}
+
+void SQ_PreviewWidget::slotDownloadResult(const KURL &url)
+{
+ percentString = TQString();
+ TQString path = url.path();
+ fmt_info *finfo;
+ RGBA *bits;
+
+ // load first page
+ bool b = SQ_ImageLoader::instance()->loadImage(path, SQ_CodecSettings::ImageViewer, true, 2);
+
+ finfo = SQ_ImageLoader::instance()->info();
+ bits = SQ_ImageLoader::instance()->bits();
+
+ // memory allocation failed in SQ_ImageLoader::loadImage()
+ if(!b || !bits || !finfo->image.size())
+ return;
+
+ delete small;
+ delete all;
+ all = small = 0;
+ pixmap = TQPixmap();
+
+ int w = finfo->image[0].w;
+ int h = finfo->image[0].h;
+ dimstring = TQString::fromLatin1("%1x%2").arg(w).arg(h);
+
+ const int wh = w * h;
+ unsigned char t;
+
+ for(int i = 0;i < wh;i++)
+ {
+ t = (bits+i)->r;
+ (bits+i)->r = (bits+i)->b;
+ (bits+i)->b = t;
+ }
+
+ all = new TQImage((uchar *)bits, w, h, 32, 0, 0, TQImage::LittleEndian);
+ all->setAlphaBuffer(true);
+
+#ifdef SQ_HAVE_KEXIF
+ KExifData data;
+ data.readFromFile(path);
+ int O = data.getImageQt::Orientation();
+
+ if(O != KExifData::UNSPECIFIED && O != KExifData::NORMAL)
+ {
+ // copy original image
+ TQImage img = *all;
+
+ // rotate image
+ SQ_Utils::exifRotate(TQString(), img, O);
+
+ // transfer back
+ *all = img;
+ }
+ else
+#endif
+ *all = all->copy();
+
+ multi = finfo->image.size() > 1;
+
+ SQ_ImageLoader::instance()->cleanup();
+
+ fitAndConvert();
+ update();
+}
+
+void SQ_PreviewWidget::keyPressEvent(TQKeyEvent *e)
+{
+ e->accept();
+
+ int key = e->key();
+
+ if(key == TQt::Key_PageDown || key == TQt::Key_Space)
+ emit next();
+ else if(key == TQt::Key_PageUp || key == TQt::Key_BackSpace)
+ emit previous();
+ else if(key == TQt::Key_Return || key == TQt::Key_Enter)
+ emit execute();
+ else if(key == TQt::Key_Home)
+ emit first();
+ else if(key == TQt::Key_End)
+ emit last();
+}
+
+void SQ_PreviewWidget::wheelEvent(TQWheelEvent *e)
+{
+ if(e->delta() < 0)
+ emit next();
+ else
+ emit previous();
+}
+
+void SQ_PreviewWidget::mouseDoubleClickEvent(TQMouseEvent *e)
+{
+ e->accept();
+ emit execute();
+}
+
+void SQ_PreviewWidget::slotDownloadPercents(int p)
+{
+ percentString = i18n("Downloading...") + ' ' + TDEIO::convertSize(p);
+ update();
+}
+
+#include "sq_previewwidget.moc"
diff --git a/src/sidebar/sq_previewwidget.h b/src/sidebar/sq_previewwidget.h
new file mode 100644
index 0000000..25e8c37
--- /dev/null
+++ b/src/sidebar/sq_previewwidget.h
@@ -0,0 +1,132 @@
+/***************************************************************************
+ sq_previewwidget.h - description
+ -------------------
+ begin : ??? Mar 13 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_PREVIEWWIDGET_H
+#define SQ_PREVIEWWIDGET_H
+
+#include <tqwidget.h>
+#include <tqpixmap.h>
+#include <tqcolor.h>
+#include <tqwmatrix.h>
+#include <tqimage.h>
+
+#include <kurl.h>
+
+class TDEPopupMenu;
+
+class SQ_Downloader;
+
+/**
+ *@author Baryshev Dmitry
+ */
+
+class SQ_PreviewWidget : public TQWidget
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_PreviewWidget(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_PreviewWidget();
+
+ void rereadColor();
+
+ void load(const KURL &url);
+
+ void ignore(bool ign);
+
+ void loadPending();
+
+ static SQ_PreviewWidget* instance() { return m_inst; }
+
+ int delay() const;
+
+ bool cancel() const;
+
+ KURL url() const;
+
+ private:
+ void saveValues();
+
+ signals:
+ void next();
+ void previous();
+ void execute();
+ void first();
+ void last();
+
+ private slots:
+ void slotBackground();
+ void slotText();
+ void slotDownloadResult(const KURL &);
+ void slotDownloadPercents(int);
+
+ protected:
+ virtual void resizeEvent(TQResizeEvent *);
+ virtual void paintEvent(TQPaintEvent *);
+ virtual void mousePressEvent(TQMouseEvent *e);
+ virtual void keyPressEvent(TQKeyEvent *e);
+ virtual void wheelEvent(TQWheelEvent *e);
+ virtual void mouseDoubleClickEvent(TQMouseEvent *e);
+
+ private:
+ bool fit();
+ void fitAndConvert();
+
+ private:
+ TQImage *all, *small;
+ TQPixmap pixmap;
+ bool m_ignore, m_forceignore, m_cancel;
+ TQColor color, colorText;
+ TDEPopupMenu *popup;
+ KURL pending, m_url;
+ int m_delay;
+ TQWMatrix matrix;
+ SQ_Downloader *down;
+ bool multi;
+ TQPixmap multi_pix;
+ TQString dimstring, percentString;
+ bool dim;
+
+ static SQ_PreviewWidget *m_inst;
+};
+
+inline
+void SQ_PreviewWidget::ignore(bool ign)
+{
+ m_ignore = ign;
+}
+
+inline
+int SQ_PreviewWidget::delay() const
+{
+ return m_delay;
+}
+
+inline
+bool SQ_PreviewWidget::cancel() const
+{
+ return m_cancel;
+}
+
+inline
+KURL SQ_PreviewWidget::url() const
+{
+ return m_url;
+}
+
+#endif
diff --git a/src/sidebar/sq_storagefile.cpp b/src/sidebar/sq_storagefile.cpp
new file mode 100644
index 0000000..cb26937
--- /dev/null
+++ b/src/sidebar/sq_storagefile.cpp
@@ -0,0 +1,79 @@
+/***************************************************************************
+ sq_storagefile.cpp - description
+ -------------------
+ begin : Sat Mar 3 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tqfile.h>
+#include <tqstring.h>
+#include <tqstring.h>
+
+#include <kmdcodec.h>
+
+#include "sq_storagefile.h"
+
+void SQ_StorageFile::writeStorageFile(const TQString &path, const KURL &inpath, KURL w)
+{
+ SQ_StorageFile::writeStorageFileAsString(path, inpath, w.prettyURL());
+}
+
+void SQ_StorageFile::writeStorageFileAsString(const TQString &path, const KURL &inpath, TQString content)
+{
+ if(content.isEmpty())
+ content = inpath.prettyURL();
+
+ KMD5 md5(TQFile::encodeName(inpath.prettyURL()).data());
+ TQFile file(path + TQString::fromLatin1(".") + TQString(md5.hexDigest()));
+
+ if(file.open(IO_WriteOnly))
+ {
+ TQString k = content.utf8();
+ file.writeBlock(k, k.length());
+ file.close();
+ }
+}
+
+KURL SQ_StorageFile::readStorageFile(const TQString &path)
+{
+ TQString n = SQ_StorageFile::readStorageFileAsString(path);
+
+ int ind = n.find('\n');
+
+ if(ind != -1)
+ n.truncate(ind);
+
+ return KURL::fromPathOrURL(n);
+}
+
+TQString SQ_StorageFile::readStorageFileAsString(const TQString &path)
+{
+ TQFile file(path);
+ TQString str;
+
+ if(file.open(IO_ReadOnly))
+ {
+ TQByteArray ba = file.readAll();
+
+ if(file.status() == IO_Ok)
+ {
+ TQString k;
+ str.append(ba);
+ str = TQString::fromUtf8(str);
+ }
+ }
+
+ file.close();
+
+ return str;
+}
diff --git a/src/sidebar/sq_storagefile.h b/src/sidebar/sq_storagefile.h
new file mode 100644
index 0000000..6e0b8c4
--- /dev/null
+++ b/src/sidebar/sq_storagefile.h
@@ -0,0 +1,34 @@
+/***************************************************************************
+ sq_storagefile.h - description
+ -------------------
+ begin : Sat Mar 3 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_STORAGEFILE_H
+#define SQ_STORAGEFILE_H
+
+#include <tqstring.h>
+
+#include <kurl.h>
+
+namespace SQ_StorageFile
+{
+ void writeStorageFile(const TQString &path, const KURL &inpath, KURL w = KURL());
+ void writeStorageFileAsString(const TQString &path, const KURL &inpath, TQString content = TQString());
+
+ KURL readStorageFile(const TQString &path);
+ TQString readStorageFileAsString(const TQString &path);
+};
+
+#endif
diff --git a/src/sidebar/sq_threaddirlister.cpp b/src/sidebar/sq_threaddirlister.cpp
new file mode 100644
index 0000000..9c6610f
--- /dev/null
+++ b/src/sidebar/sq_threaddirlister.cpp
@@ -0,0 +1,145 @@
+/***************************************************************************
+ sq_threaddirlister.cpp - description
+ -------------------
+ begin : Feb 10 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqfile.h>
+#include <tqdir.h>
+#include <tqobject.h>
+#include <tqfileinfo.h>
+#include <tqdatetime.h>
+#include <tqapplication.h>
+
+#include <tdeconfig.h>
+#include <tdeglobal.h>
+
+#include "sq_threaddirlister.h"
+
+SQ_ThreadDirLister::SQ_ThreadDirLister(TQObject *o)
+ : TQThread(), obj(o)
+{
+ cache = new TDEConfig("ksquirrel-tree-cache");
+ dir = 0;
+}
+
+SQ_ThreadDirLister::~SQ_ThreadDirLister()
+{
+ // sync() & delete
+ delete cache;
+}
+
+void SQ_ThreadDirLister::run()
+{
+ KURL url;
+ TQString path, name, filepath;
+ dirent *file;
+ int count_files, count_dirs;
+ TQDateTime dt, dt_def;
+ TQFileInfo fi;
+ bool b_read;
+
+ static const TQString &dot = TDEGlobal::staticQString(".");
+ static const TQString &dotdot = TDEGlobal::staticQString("..");
+
+ while(true)
+ {
+ waitMutex();
+ count_files = todo.count();
+ unlock();
+
+ if(!count_files) break;
+
+ waitMutex();
+ url = todo.first();
+ unlock();
+
+ path = url.path();
+ count_files = count_dirs = 0;
+ b_read = true;
+ fi.setFile(path);
+
+ if(cache->hasGroup(path))
+ {
+ cache->setGroup(path);
+ dt = cache->readDateTimeEntry("modified", &dt_def);
+
+ // compare cached time and real time
+ if(dt.isValid() && fi.lastModified() == dt)
+ {
+ count_files = cache->readNumEntry("count_files", 0);
+ count_dirs = cache->readNumEntry("count_dirs", 0);
+ b_read = false;
+ }
+ }
+
+ if(b_read)
+ {
+ dir = opendir(TQFile::encodeName(path));
+ dt = fi.lastModified(); // save directory last modified time
+
+ if(dir)
+ {
+ while((file = readdir(dir)))
+ {
+ name = TQFile::decodeName(file->d_name);
+
+ if(name != dot && name != dotdot)
+ {
+ filepath = path + TQDir::separator() + name;
+
+ fi.setFile(filepath);
+
+ if(fi.isDir())
+ count_dirs++;
+ else
+ count_files++;
+ }
+ }
+
+ closeDir();
+ }
+ else // opendir() failed, this value won't be cached
+ b_read = false;
+ }
+
+ waitMutex();
+ todo.pop_front();
+ unlock();
+
+ // cache only new values
+ if(b_read)
+ {
+ cache->setGroup(path);
+ cache->writeEntry("modified", dt);
+ cache->writeEntry("count_files", count_files);
+ cache->writeEntry("count_dirs", count_dirs);
+ }
+
+ TQApplication::postEvent(obj, new SQ_ItemsEvent(url, count_files, count_dirs));
+ }// while
+}
+
+void SQ_ThreadDirLister::closeDir()
+{
+ if(dir)
+ {
+ closedir(dir);
+ dir = 0;
+ }
+}
diff --git a/src/sidebar/sq_threaddirlister.h b/src/sidebar/sq_threaddirlister.h
new file mode 100644
index 0000000..7aa58fc
--- /dev/null
+++ b/src/sidebar/sq_threaddirlister.h
@@ -0,0 +1,153 @@
+/***************************************************************************
+ sq_threaddirlister.h - description
+ -------------------
+ begin : Feb 10 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef SQ_THREADDIRLISTER_H
+#define SQ_THREADDIRLISTER_H
+
+#include <tqthread.h>
+#include <tqevent.h>
+#include <tqmutex.h>
+
+#include <kurl.h>
+
+#include <sys/types.h>
+#include <dirent.h>
+
+class TQObject;
+
+class TDEConfig;
+
+/********************************************************/
+
+#define SQ_ItemsEventId (TQEvent::User + 1)
+
+class SQ_ItemsEvent : public TQCustomEvent
+{
+ public:
+ SQ_ItemsEvent(const KURL &parent, int c1, int c2)
+ : TQCustomEvent(SQ_ItemsEventId), m_files(c1), m_dirs(c2), m_url(parent)
+ {}
+
+ int files() const;
+ int dirs() const;
+
+ KURL url() const;
+
+ private:
+ int m_files, m_dirs;
+ KURL m_url;
+};
+
+inline
+KURL SQ_ItemsEvent::url() const
+{
+ return m_url;
+}
+
+inline
+int SQ_ItemsEvent::files() const
+{
+ return m_files;
+}
+
+inline
+int SQ_ItemsEvent::dirs() const
+{
+ return m_dirs;
+}
+
+/********************************************************/
+
+/*
+ * This thread will read directory and determine
+ * number of files in it. Finally
+ * it will post an event to main thread with
+ * calculated count. This function is threaded
+ * due to perfomance reason.
+ */
+class SQ_ThreadDirLister : public TQThread
+{
+ public:
+ SQ_ThreadDirLister(TQObject *o);
+ ~SQ_ThreadDirLister();
+
+ void appendURL(const KURL &url);
+
+ bool hasURL(const KURL &url);
+ bool isCurrent(const KURL &url);
+
+ void lock();
+ void unlock();
+
+ void closeDir();
+
+ protected:
+ virtual void run();
+
+ private:
+ void waitMutex();
+
+ private:
+ // urls to read
+ KURL::List todo;
+
+ // this object will recieve our events
+ TQObject *obj;
+ TQMutex mutex;
+ TDEConfig *cache;
+ DIR *dir;
+};
+
+inline
+void SQ_ThreadDirLister::appendURL(const KURL &url)
+{
+ todo.append(url);
+}
+
+inline
+bool SQ_ThreadDirLister::hasURL(const KURL &url)
+{
+ return todo.find(url) != todo.end();
+}
+
+inline
+bool SQ_ThreadDirLister::isCurrent(const KURL &url)
+{
+ return todo.first().equals(url, true);
+}
+
+inline
+void SQ_ThreadDirLister::lock()
+{
+ mutex.lock();
+}
+
+inline
+void SQ_ThreadDirLister::unlock()
+{
+ mutex.unlock();
+}
+
+inline
+void SQ_ThreadDirLister::waitMutex()
+{
+ while(!mutex.tryLock())
+ TQThread::msleep(1);
+}
+
+#endif
diff --git a/src/sidebar/sq_treeview.cpp b/src/sidebar/sq_treeview.cpp
new file mode 100644
index 0000000..22207a9
--- /dev/null
+++ b/src/sidebar/sq_treeview.cpp
@@ -0,0 +1,678 @@
+/***************************************************************************
+ sq_treeview.cpp - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqdir.h>
+#include <tqheader.h>
+#include <tqtimer.h>
+#include <tqcursor.h>
+
+#include <tdelocale.h>
+#include <kurldrag.h>
+#include <kurl.h>
+#include <kdirwatch.h>
+
+#include "ksquirrel.h"
+#include "sq_iconloader.h"
+#include "sq_widgetstack.h"
+#include "sq_filethumbview.h"
+#include "sq_config.h"
+#include "sq_treeview.h"
+#include "sq_treeviewitem.h"
+#include "sq_threaddirlister.h"
+#include "sq_navigatordropmenu.h"
+#include "sq_treeviewmenu.h"
+#include "sq_hloptions.h"
+
+#include "sq_directorybasket.h"
+
+SQ_TreeView * SQ_TreeView::m_instance = 0;
+
+SQ_FileTreeViewBranch::SQ_FileTreeViewBranch(KFileTreeView *parent, const KURL &url,
+ const TQString &name, const TQPixmap &pix) : KFileTreeBranch(parent, url, name, pix)
+{}
+
+SQ_FileTreeViewBranch::~SQ_FileTreeViewBranch()
+{}
+
+KFileTreeViewItem* SQ_FileTreeViewBranch::createTreeViewItem(KFileTreeViewItem *parent, KFileItem *fileItem)
+{
+ KFileTreeViewItem *tvi = 0;
+
+ if(parent && fileItem)
+ tvi = new SQ_TreeViewItem(parent, fileItem, this);
+
+ return tvi;
+}
+
+/******************************************************************************************************/
+
+SQ_TreeView::SQ_TreeView(TQWidget *parent, const char *name) : KFileTreeView(parent, name)
+{
+ m_instance = this;
+
+ itemToBeOpened = 0;
+ m_animTimer = new TQTimer(this);
+ scanTimer = new TQTimer(this);
+ m_ignoreClick = false;
+
+ connect(m_animTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotAnimation()));
+ connect(scanTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotDelayedScan()));
+
+ dw = 0;
+ m_recurs = No;
+ lister = new SQ_ThreadDirLister(this);
+ setupRecursion();
+
+ setFrameShape(TQFrame::NoFrame);
+ addColumn("Name");
+ addColumn("Check");
+
+ header()->hide();
+ header()->moveSection(1, 0);
+ setColumnWidthMode(1, TQListView::Manual);
+ setColumnWidth(1, 18);
+
+ root = new SQ_FileTreeViewBranch(this, TQDir::rootDirPath(), TQString(),
+ SQ_IconLoader::instance()->loadIcon("folder_red", TDEIcon::Desktop, TDEIcon::SizeSmall));
+
+ // some hacks to create our SQ_TreeViewItem as root item
+ SQ_TreeViewItem *ritem = new SQ_TreeViewItem(this,
+ new KFileItem(TQDir::rootDirPath(),
+ "inode/directory", S_IFDIR),
+ root);
+
+ ritem->setText(0, i18n("root"));
+ ritem->setExpandable(true);
+
+ // oops :)
+ delete root->root();
+
+ // set new root
+ root->setRoot(ritem);
+
+ addBranch(root);
+
+ // don't show files
+ setDirOnlyMode(root, true);
+
+ // show '+'
+ setRootIsDecorated(true);
+
+ // connect signals
+
+ // Space and Return will open item
+ connect(this, TQ_SIGNAL(spacePressed(TQListViewItem*)), this, TQ_SIGNAL(executed(TQListViewItem*)));
+ connect(this, TQ_SIGNAL(returnPressed(TQListViewItem*)), this, TQ_SIGNAL(executed(TQListViewItem*)));
+ connect(this, TQ_SIGNAL(currentChanged(TQListViewItem *)), this, TQ_SLOT(slotCurrentChanged(TQListViewItem*)));
+
+ connect(this, TQ_SIGNAL(executed(TQListViewItem*)), this, TQ_SLOT(slotItemExecuted(TQListViewItem*)));
+ connect(this, TQ_SIGNAL(newURL(const KURL&)), this, TQ_SLOT(slotNewURL(const KURL&)));
+ connect(root, TQ_SIGNAL(populateFinished(KFileTreeViewItem *)), this, TQ_SLOT(slotOpened(KFileTreeViewItem *)));
+ connect(root, TQ_SIGNAL(deleteItem(KFileItem *)), this, TQ_SLOT(slotDeleteItemMy(KFileItem *)));
+
+ setCurrentItem(root->root());
+ root->setChildRecurse(false);
+
+ SQ_Config::instance()->setGroup("Fileview");
+ int sync_type = SQ_Config::instance()->readNumEntry("sync type", 0);
+
+ // load url, if needed
+ if(sync_type != 1)
+ emitNewURL(SQ_WidgetStack::instance()->url());
+
+ setAcceptDrops(true);
+
+ connect(this, TQ_SIGNAL(dropped(TQDropEvent *, TQListViewItem *, TQListViewItem *)),
+ this, TQ_SLOT(slotDropped(TQDropEvent *, TQListViewItem *, TQListViewItem *)));
+
+ connect(this, TQ_SIGNAL(contextMenu(TDEListView *, TQListViewItem *, const TQPoint &)),
+ this, TQ_SLOT(slotContextMenu(TDEListView *, TQListViewItem *, const TQPoint &)));
+
+ menu = new SQ_TreeViewMenu(this);
+
+ if(SQ_HLOptions::instance()->have_directorybasket)
+ {
+ menu->insertSeparator();
+ menu->insertItem(i18n("Add to Folder Basket"), this, TQ_SLOT(slotAddToFolderBasket()));
+ }
+}
+
+SQ_TreeView::~SQ_TreeView()
+{
+ lister->terminate();
+ lister->wait();
+
+ delete lister;
+}
+
+void SQ_TreeView::slotCurrentChanged(TQListViewItem *item)
+{
+ SQ_TreeViewItem *tvi = static_cast<SQ_TreeViewItem *>(item);
+
+ if(tvi) cURL = tvi->url();
+}
+
+void SQ_TreeView::setRecursion(int b)
+{
+ // avoid duplicate calls
+ if(m_recurs == b)
+ return;
+
+ TQListViewItemIterator it(this);
+ SQ_TreeViewItem *tvi;
+
+ // ignore root item
+ ++it;
+
+ // turn recursion on
+ if(m_recurs == No && b)
+ {
+ dw = new KDirWatch(this);
+ connect(dw, TQ_SIGNAL(dirty(const TQString &)), this, TQ_SLOT(slotDirty(const TQString &)));
+
+ dw->blockSignals(true);
+ lister->lock();
+ while(it.current())
+ {
+ tvi = static_cast<SQ_TreeViewItem *>(it.current());
+
+ if(tvi)
+ {
+ tvi->setParams((m_recurs == Files || m_recurs == FilesDirs),
+ (m_recurs == Dirs || m_recurs == FilesDirs));
+
+ lister->appendURL(tvi->url());
+ dw->addDir(tvi->path());
+ }
+
+ ++it;
+ }
+ lister->unlock();
+ dw->blockSignals(false);
+
+ m_recurs = b;
+
+ if(!lister->running())
+ scanTimer->start(1, true);
+ }
+ // turn recursion off
+ else
+ {
+ delete dw;
+ dw = 0;
+
+ m_recurs = b;
+ while(it.current())
+ {
+ tvi = static_cast<SQ_TreeViewItem *>(it.current());
+
+ // reset item names
+ if(tvi)
+ {
+ tvi->setParams((m_recurs == Files || m_recurs == FilesDirs),
+ (m_recurs == Dirs || m_recurs == FilesDirs));
+ tvi->setCount(tvi->files(), tvi->dirs());
+ }
+
+ ++it;
+ }
+ }
+}
+
+void SQ_TreeView::slotClearChecked()
+{
+ TQListViewItemIterator it(this);
+ SQ_TreeViewItem *tvi;
+
+ while(it.current())
+ {
+ tvi = static_cast<SQ_TreeViewItem *>(it.current());
+
+ if(tvi && tvi->checked())
+ tvi->setChecked(false);
+
+ ++it;
+ }
+}
+
+/*
+ * Item executed. Let's pass its url to SQ_WidgetStack (if needed).
+ */
+void SQ_TreeView::slotItemExecuted(TQListViewItem *item)
+{
+ if(!item) return;
+
+ item->setOpen(true);
+
+ SQ_Config::instance()->setGroup("Fileview");
+ int sync_type = SQ_Config::instance()->readNumEntry("sync type", 0);
+
+ // current sychronization type doesn't require
+ // passing url to SQ_WidgetStack - return
+ if(sync_type == 1)
+ return;
+
+ KFileTreeViewItem *cur = static_cast<KFileTreeViewItem*>(item);
+ KURL Curl = cur->url();
+
+ // pass url to SQ_WidgetStack
+ SQ_WidgetStack::instance()->setURLForCurrent(Curl, false);
+}
+
+void SQ_TreeView::emitNewURL(const KURL &url)
+{
+ // already selected?
+ if(!url.isLocalFile() || url.equals(currentURL(), true) || url.equals(cURL, true))
+ return;
+
+ cURL = url;
+
+ // tree is invisible.
+ // save url for future use
+ if(!isVisible())
+ {
+ pendingURL = url;
+ pendingURL.adjustPath(1);
+ return;
+ }
+ else
+ pendingURL = KURL();
+
+ emit newURL(url);
+}
+
+/*
+ * Set given item visible, current, and populate it.
+ */
+void SQ_TreeView::populateItem(KFileTreeViewItem *item)
+{
+ if(item->url().equals(cURL, true))
+ {
+ setSelected(item, true);
+ setCurrentItem(item);
+
+ // 1/5 of height give above items
+ // 4/5 of height give below items
+ setContentsPos(contentsX(), itemPos(item)-visibleHeight()/5);
+ }
+
+ itemToBeOpened = item;
+ item->setOpen(true);
+}
+
+/*
+ * Load url.
+ */
+void SQ_TreeView::slotNewURL(const KURL &url)
+{
+ KURL k(url);
+ k.adjustPath(1);
+
+ KURL last = k;
+
+ TQString s;
+
+ // divide url to paths.
+ // for example, "/home/krasu/1/2" will be divided to
+ //
+ // "/home/krasu/1/2"
+ // "/home/krasu/1"
+ // "/home/krasu"
+ // "/home"
+ // "/"
+ //
+ while(true)
+ {
+ s = k.path(); // remove "/"
+ s.remove(0, 1);
+
+ paths.prepend(s);
+ k = k.upURL();
+
+ if(k.equals(last, true))
+ break;
+
+ last = k;
+ }
+
+ while(doSearch())
+ {}
+}
+
+/*
+ * New item is opened. Try to continue loading url.
+ */
+void SQ_TreeView::slotOpened(KFileTreeViewItem *item)
+{
+ if(!item) return;
+
+ // continue searhing...
+ if(item == itemToBeOpened)
+ doSearch();
+}
+
+/*
+ * Search first available url in variable 'paths'. Open found item.
+ * If item was found return true.
+ */
+bool SQ_TreeView::doSearch()
+{
+ // all items are opened
+ if(paths.empty())
+ {
+ itemToBeOpened = 0;
+ return false;
+ }
+
+ TQStringList::iterator it = paths.begin();
+
+ KFileTreeViewItem *found = findItem(root, *it);
+
+ // item not found. It means that
+ //
+ // * we loaded all subpaths - nothing to do
+ // * item we needed is not loaded yet. populateItem() _now_ is trying to open
+ // new subpath, and we will continue searching in slotOpened().
+ //
+ if(!found)
+ return false;
+
+ // ok, item is found
+ //
+ // remove first entry from 'paths'
+ // and try to open item
+ paths.erase(it);
+ populateItem(found);
+
+ // done, but subpaths are pending...
+ return true;
+}
+
+/*
+ * On show event load saved url, if any. See emitNewURL().
+ */
+void SQ_TreeView::showEvent(TQShowEvent *)
+{
+ // if pending url is valid
+ if(!pendingURL.isEmpty())
+ {
+ // set pending url to current url
+ KURL url = pendingURL;
+
+ // reset pending url
+ pendingURL = KURL();
+
+ // finally, load url
+ emit newURL(url);
+ }
+}
+
+void SQ_TreeView::slotNewTreeViewItems(KFileTreeBranch *, const KFileTreeViewItemList &list)
+{
+ if(m_recurs == No)
+ return;
+
+// uuuuuuuggggggghhhhhhh :)
+ KFileTreeViewItemListIterator it(list);
+ KFileTreeViewItem *item;
+
+ lister->lock();
+ while((item = it.current()))
+ {
+ lister->appendURL(item->url());
+ dw->addDir(item->path());
+ ++it;
+ }
+ lister->unlock();
+
+ if(!lister->running())
+ scanTimer->start(1, true);
+}
+
+void SQ_TreeView::slotDelayedScan()
+{
+ if(!lister->running())
+ lister->start();
+}
+
+void SQ_TreeView::customEvent(TQCustomEvent *e)
+{
+ if(!e || e->type() != SQ_ItemsEventId)
+ return;
+
+ SQ_ItemsEvent *ie = static_cast<SQ_ItemsEvent *>(e);
+
+ SQ_TreeViewItem *tvi = static_cast<SQ_TreeViewItem *>(root->findTVIByURL(ie->url()));
+
+ if(tvi)
+ {
+ tvi->setParams((m_recurs == Files || m_recurs == FilesDirs),
+ (m_recurs == Dirs || m_recurs == FilesDirs));
+ tvi->setCount(ie->files(), ie->dirs());
+ }
+}
+
+void SQ_TreeView::slotAnimation()
+{
+ KFileTreeViewItem *it = m_mapFolders.first();
+
+ for(;it;it = m_mapFolders.next())
+ it->setPixmap(0, SmallIcon("clock"));
+}
+
+void SQ_TreeView::startAnimation(KFileTreeViewItem *item, const char *, uint)
+{
+ if(!item)
+ return;
+
+ m_mapFolders.append(item);
+
+ if(!m_animTimer->isActive())
+ m_animTimer->start(50, true);
+}
+
+void SQ_TreeView::stopAnimation(KFileTreeViewItem *item)
+{
+ if(!item)
+ return;
+
+ int f = m_mapFolders.find(item);
+
+ if(f != -1)
+ {
+ item->setPixmap(0, itemIcon(item));
+ m_mapFolders.remove(item);
+ }
+
+ m_animTimer->stop();
+}
+
+void SQ_TreeView::viewportResizeEvent(TQResizeEvent *)
+{
+ setColumnWidth(0, viewport()->width() - columnWidth(1));
+ triggerUpdate();
+}
+
+void SQ_TreeView::clearSelection()
+{
+ if(!m_ignoreClick) KFileTreeView::clearSelection();
+}
+
+void SQ_TreeView::setSelected(TQListViewItem *item, bool selected)
+{
+ if(!m_ignoreClick) KFileTreeView::setSelected(item, selected);
+}
+
+void SQ_TreeView::setCurrentItem(TQListViewItem *item)
+{
+ if(!m_ignoreClick) KFileTreeView::setCurrentItem(item);
+}
+
+void SQ_TreeView::setOpen(TQListViewItem *item, bool open)
+{
+ if(!m_ignoreClick) KFileTreeView::setOpen(item, open);
+}
+
+void SQ_TreeView::contentsMousePressEvent(TQMouseEvent *e)
+{
+ TQListViewItem *item;
+
+ TQPoint point = e->pos();
+ point.setY(point.y() - contentsY());
+
+ if(header()->sectionAt(point.x()) && (item = itemAt(point)))
+ {
+ SQ_TreeViewItem *m = static_cast<SQ_TreeViewItem *>(item);
+
+ if(m)
+ {
+ int state = e->state();
+
+ if(!state)
+ toggle(m, true);
+ else
+ {
+ TQListViewItemIterator it(this);
+
+ // toggle parent item
+ if(state == TQt::ShiftButton) toggle(m, true);
+ else if(state == TQt::ControlButton) toggle(m, false, true);
+ else if(state == TQt::AltButton) toggle(m, false, false);
+
+ SQ_TreeViewItem *tvi = static_cast<SQ_TreeViewItem *>(m->firstChild());
+
+ // toggle all child items
+ while(tvi)
+ {
+ if(state == TQt::ShiftButton) toggle(tvi, false, m->checked());
+ else if(state == TQt::ControlButton) toggle(tvi, false, true);
+ else if(state == TQt::AltButton) toggle(tvi, false, false);
+
+ tvi = static_cast<SQ_TreeViewItem *>(tvi->nextSibling());
+ }
+ }
+ }
+
+ m_ignoreClick = true;
+ }
+
+ KFileTreeView::contentsMousePressEvent(e);
+
+ m_ignoreClick = false;
+}
+
+void SQ_TreeView::contentsMouseDoubleClickEvent(TQMouseEvent *e)
+{
+ if(header()->sectionAt(e->x()))
+ m_ignoreClick = true;
+
+ KFileTreeView::contentsMouseDoubleClickEvent(e);
+
+ m_ignoreClick = false;
+}
+
+void SQ_TreeView::setupRecursion()
+{
+ SQ_Config::instance()->setGroup("Sidebar");
+
+ setRecursion(SQ_Config::instance()->readNumEntry("recursion_type", No));
+}
+
+void SQ_TreeView::toggle(SQ_TreeViewItem *item, bool togg, bool set)
+{
+ if(togg)
+ item->setChecked(!item->checked());
+ else
+ item->setChecked(set);
+
+ if(item->checked())
+ emit urlAdded(item->url());
+ else
+ emit urlRemoved(item->url());
+}
+
+void SQ_TreeView::slotDropped(TQDropEvent *e, TQListViewItem *parent, TQListViewItem *item)
+{
+ if(!item) item = parent;
+
+ KFileTreeViewItem *cur = static_cast<KFileTreeViewItem *>(item);
+
+ if(!cur) return;
+
+ KURL::List list;
+ KURLDrag::decode(e, list);
+
+ SQ_NavigatorDropMenu::instance()->setupFiles(list, cur->url());
+ SQ_NavigatorDropMenu::instance()->exec(TQCursor::pos(), true);
+}
+
+void SQ_TreeView::slotContextMenu(TDEListView *, TQListViewItem *item, const TQPoint &point)
+{
+ if(item)
+ {
+ KFileTreeViewItem *kfi = static_cast<KFileTreeViewItem*>(item);
+ menu->updateDirActions(kfi->isDir());
+ menu->setURL(kfi->url());
+ menu->exec(point);
+ }
+}
+
+void SQ_TreeView::slotDirty(const TQString &path)
+{
+ KURL url;
+ url.setPath(path);
+
+ lister->lock();
+
+ // we don't need update urls that are not yet updated
+ // by threaded lister
+ if(!lister->hasURL(url))
+ lister->appendURL(url);
+ else if(lister->isCurrent(url))
+ {
+ lister->terminate();
+ lister->wait();
+ lister->closeDir();
+ }
+
+ lister->unlock();
+
+ if(!lister->running())
+ scanTimer->start(1000, true);
+}
+
+void SQ_TreeView::slotDeleteItemMy(KFileItem *fi)
+{
+ if(m_recurs != No && fi)
+ dw->removeDir(fi->url().path());
+}
+
+void SQ_TreeView::slotAddToFolderBasket()
+{
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, menu->url());
+
+ KFileItemList list;
+ list.append(&fi);
+
+ SQ_DirectoryBasket::instance()->add(list);
+}
+
+#include "sq_treeview.moc"
diff --git a/src/sidebar/sq_treeview.h b/src/sidebar/sq_treeview.h
new file mode 100644
index 0000000..dd39480
--- /dev/null
+++ b/src/sidebar/sq_treeview.h
@@ -0,0 +1,174 @@
+/***************************************************************************
+ sq_treeview.h - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_TREEVIEW_H
+#define SQ_TREEVIEW_H
+
+#include <tqstringlist.h>
+
+#include <tdefiletreeview.h>
+#include <kurl.h>
+
+class KDirWatch;
+
+class SQ_TreeViewItem;
+class SQ_ThreadDirLister;
+class SQ_TreeViewMenu;
+
+/*
+ * We should subclass KFileTreeBranch to let us create
+ * our own items. See SQ_TreeViewitem.
+ */
+class SQ_FileTreeViewBranch : public KFileTreeBranch
+{
+ public:
+ SQ_FileTreeViewBranch(KFileTreeView*, const KURL &url, const TQString &name, const TQPixmap &pix);
+ ~SQ_FileTreeViewBranch();
+
+ protected:
+ virtual KFileTreeViewItem *createTreeViewItem(KFileTreeViewItem *parent, KFileItem *fileItem);
+};
+
+/*
+ * SQ_TreeView represents a file tree.
+ */
+
+class SQ_TreeView : public KFileTreeView
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_TreeView(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_TreeView();
+
+ enum Recursion { No = 0, Files, Dirs, FilesDirs };
+
+ /*
+ * Recursion settings. If recursion > 0, treeview will
+ * show a number of files/directories in the given directory.
+ * It will look like that:
+ *
+ * + mypictures [8]
+ * | + wallpapers [231]
+ * | + nature [12]
+ * | + pets [43]
+ * | + cats [22]
+ * | + dogs [32]
+ *
+ * This operation is threaded.
+ */
+ void setupRecursion();
+
+ /*
+ * Load new url, if tree is visible. Save url and do nothing
+ * otherwise.
+ */
+ void emitNewURL(const KURL &url);
+
+ virtual void clearSelection();
+ virtual void setSelected(TQListViewItem *item, bool selected);
+ virtual void setCurrentItem(TQListViewItem *item);
+ virtual void setOpen(TQListViewItem *item, bool open);
+
+ static SQ_TreeView* instance() { return m_instance; }
+
+ protected:
+ virtual void customEvent(TQCustomEvent *e);
+ virtual void startAnimation(KFileTreeViewItem* item, const char*, uint);
+ virtual void stopAnimation(KFileTreeViewItem* item);
+ virtual void viewportResizeEvent(TQResizeEvent *);
+ virtual void contentsMousePressEvent(TQMouseEvent *e);
+ virtual void contentsMouseDoubleClickEvent(TQMouseEvent *e);
+
+ /*
+ * On show event load saved url, if any. See emitNewURL().
+ */
+ virtual void showEvent(TQShowEvent *);
+
+ private:
+ void toggle(SQ_TreeViewItem *, bool, bool = false);
+ void setRecursion(int);
+
+ /*
+ * Set given item visible, current, and populate it.
+ */
+ void populateItem(KFileTreeViewItem *);
+
+ /*
+ * Search first available url in variable 'paths'. Open found item.
+ * If item was found return true.
+ */
+ bool doSearch();
+
+ private slots:
+ /*
+ * Load url.
+ */
+ void slotNewURL(const KURL &url);
+
+ void slotCurrentChanged(TQListViewItem *);
+ void slotAddToFolderBasket();
+ void slotClearChecked();
+ void slotDirty(const TQString &);
+ void slotDeleteItemMy(KFileItem *);
+
+ /*
+ * Item executed. Let's pass its url to SQ_WidgetStack (if needed).
+ */
+ void slotItemExecuted(TQListViewItem*);
+
+ /*
+ * New item is opened. Try to continue loading url.
+ */
+ void slotOpened(KFileTreeViewItem *);
+
+ void slotNewTreeViewItems(KFileTreeBranch*, const KFileTreeViewItemList &);
+ void slotDelayedScan();
+ void slotAnimation();
+
+ void slotDropped(TQDropEvent *, TQListViewItem *, TQListViewItem *);
+ void slotContextMenu(TDEListView *, TQListViewItem *, const TQPoint &);
+
+ signals:
+ void newURL(const KURL &url);
+
+ /*
+ * Since 0.7.0 our file manager supports multiple directories.
+ * These signals tell SQ_DirOperator to add or remove some
+ * urls.
+ */
+ void urlAdded(const KURL &);
+ void urlRemoved(const KURL &);
+
+ private:
+ SQ_FileTreeViewBranch *root;
+ TQStringList paths;
+ KURL pendingURL, cURL;
+ SQ_ThreadDirLister *lister;
+ KFileTreeViewItemList m_mapFolders;
+ TQTimer *m_animTimer, *scanTimer;
+ bool m_ignoreClick;
+ int m_recurs;
+ SQ_TreeViewMenu *menu;
+ KDirWatch *dw;
+ KFileTreeViewItem *itemToBeOpened;
+
+ static SQ_TreeView *m_instance;
+};
+
+#endif
diff --git a/src/sidebar/sq_treeviewitem.cpp b/src/sidebar/sq_treeviewitem.cpp
new file mode 100644
index 0000000..cb3c1ab
--- /dev/null
+++ b/src/sidebar/sq_treeviewitem.cpp
@@ -0,0 +1,107 @@
+/***************************************************************************
+ sq_treeviewitem.cpp - description
+ -------------------
+ begin : Feb 22 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqpainter.h>
+
+#include "sq_treeviewitem.h"
+
+SQ_TreeViewItem::SQ_TreeViewItem(KFileTreeViewItem *parentItem, KFileItem *fileItem, KFileTreeBranch *parentBranch)
+ : KFileTreeViewItem(parentItem, fileItem, parentBranch),
+ m_checked(false), count_files(0), count_dirs(0), use_c1(false), use_c2(false)
+{}
+
+SQ_TreeViewItem::SQ_TreeViewItem(KFileTreeView *parent, KFileItem *fileItem, KFileTreeBranch *parentBranch)
+ : KFileTreeViewItem(parent, fileItem, parentBranch),
+ m_checked(false), count_files(0), count_dirs(0), use_c1(false), use_c2(false)
+{}
+
+SQ_TreeViewItem::~SQ_TreeViewItem()
+{}
+
+void SQ_TreeViewItem::paintFocus(TQPainter *, const TQColorGroup &, const TQRect &)
+{}
+
+void SQ_TreeViewItem::paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment)
+{
+ TDEListView *klv = static_cast<TDEListView *>(listView());
+
+ // mark item
+ if(column)
+ {
+ int h = height();
+ int w = klv->columnWidth(1);
+ const int m = 6;
+ const int marg = 2;
+
+ p->fillRect(0,0,w,h,cg.base());
+
+ p->setPen(black);
+ p->setBrush(cg.base());
+ p->drawRect(marg, marg, w-marg*2, h-marg*2);
+
+ if(m_checked)
+ p->fillRect((w-m)/2, (h-m)/2, m, m, cg.highlight());
+ }
+ else // file name and pixmap
+ {
+ TQColorGroup cc = cg;
+
+ if(m_checked)
+ {
+ if(klv->viewport()->backgroundMode() == TQt::FixedColor)
+ cc.setColor(TQColorGroup::Background, cg.highlight());
+ else
+ cc.setColor(TQColorGroup::Base, cg.highlight());
+ }
+ else if(isAlternate())
+ {
+ if(klv->viewport()->backgroundMode() == TQt::FixedColor)
+ cc.setColor(TQColorGroup::Background, klv->alternateBackground());
+ else
+ cc.setColor(TQColorGroup::Base, klv->alternateBackground());
+ }
+
+ TQListViewItem::paintCell(p, cc, column, width, alignment);
+ }
+}
+
+void SQ_TreeViewItem::setCount(int c1, int c2)
+{
+ count_files = c1 < 0 ? 0 : c1;
+ count_dirs = c2 < 0 ? 0 : c2;
+
+ setText(0, fileItem()->name());
+}
+
+void SQ_TreeViewItem::setText(int column, const TQString &text)
+{
+ TQString s;
+
+ if(use_c1 && use_c2) // files + dirs: show these two values anyway
+ s = TQString::fromLatin1(" [%1/%2]").arg(count_dirs).arg(count_files);
+ else if(use_c1 && count_files) // files, file count is > 0
+ s = TQString::fromLatin1(" [%1]").arg(count_files);
+ else if(use_c2 && count_dirs) // dirs, dir count is > 0
+ s = TQString::fromLatin1(" [%1]").arg(count_dirs);
+
+ KFileTreeViewItem::setText(column, text + s);
+}
+
diff --git a/src/sidebar/sq_treeviewitem.h b/src/sidebar/sq_treeviewitem.h
new file mode 100644
index 0000000..c51109c
--- /dev/null
+++ b/src/sidebar/sq_treeviewitem.h
@@ -0,0 +1,85 @@
+/***************************************************************************
+ sq_treeviewitem.h - description
+ -------------------
+ begin : Feb 22 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_TREEVIEWITEM_H
+#define SQ_TREEVIEWITEM_H
+
+#include <tdefiletreeviewitem.h>
+
+class KFileTreeBranch;
+
+class SQ_TreeViewItem : public KFileTreeViewItem
+{
+ public:
+ SQ_TreeViewItem(KFileTreeViewItem *parentItem, KFileItem *fileItem, KFileTreeBranch *parentBranch);
+ SQ_TreeViewItem(KFileTreeView *parent, KFileItem *fileItem, KFileTreeBranch *parentBranch);
+ ~SQ_TreeViewItem();
+
+ bool checked() const;
+ void setChecked(bool c);
+
+ int files() const;
+ int dirs() const;
+
+ void setCount(int c1, int c2);
+ void setParams(bool _use_c1, bool _use_c2);
+
+ virtual void paintFocus(TQPainter *, const TQColorGroup &, const TQRect &);
+ virtual void setText(int column, const TQString &text);
+
+ protected:
+ virtual void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int alignment);
+
+ private:
+ bool m_checked;
+ int count_files, count_dirs;
+ bool use_c1, use_c2;
+};
+
+inline
+void SQ_TreeViewItem::setParams(bool _use_c1, bool _use_c2)
+{
+ use_c1 = _use_c1;
+ use_c2 = _use_c2;
+}
+
+inline
+bool SQ_TreeViewItem::checked() const
+{
+ return m_checked;
+}
+
+inline
+void SQ_TreeViewItem::setChecked(bool c)
+{
+ m_checked = c;
+ repaint();
+}
+
+inline
+int SQ_TreeViewItem::files() const
+{
+ return count_files;
+}
+
+inline
+int SQ_TreeViewItem::dirs() const
+{
+ return count_dirs;
+}
+
+#endif
diff --git a/src/sidebar/sq_treeviewmenu.cpp b/src/sidebar/sq_treeviewmenu.cpp
new file mode 100644
index 0000000..624c753
--- /dev/null
+++ b/src/sidebar/sq_treeviewmenu.cpp
@@ -0,0 +1,196 @@
+#include <tqpoint.h>
+#include <tqwidget.h>
+#include <tqstylesheet.h>
+
+#include <tdelocale.h>
+#include <kurl.h>
+#include <tdeio/job.h>
+#include <kpropertiesdialog.h>
+#include <kinputdialog.h>
+#include <tdemessagebox.h>
+
+#include "sq_treeviewmenu.h"
+#include "ksquirrel.h"
+#include "sq_iconloader.h"
+
+SQ_TreeViewMenu::SQ_TreeViewMenu(TQWidget *parent, const char *name) : TDEPopupMenu(parent, name)
+{
+ id_new = insertItem(SQ_IconLoader::instance()->loadIcon("folder-new", TDEIcon::Desktop, TDEIcon::SizeSmall), i18n("New folder..."), this, TQ_SLOT(slotDirectoryNew()));
+ insertSeparator();
+ id_rename = insertItem(i18n("Rename"), this, TQ_SLOT(slotDirectoryRename()));
+ id_clear = insertItem(i18n("Clear contents"), this, TQ_SLOT(slotDirectoryClear()));
+ id_delete = insertItem(SQ_IconLoader::instance()->loadIcon("edit-delete", TDEIcon::Desktop, TDEIcon::SizeSmall), i18n("Delete"), this, TQ_SLOT(slotDirectoryDelete()));
+ insertSeparator();
+ id_prop = insertItem(i18n("Properties"), this, TQ_SLOT(slotDirectoryProperties()));
+}
+
+SQ_TreeViewMenu::~SQ_TreeViewMenu()
+{}
+
+void SQ_TreeViewMenu::reconnect(Element elem, TQObject *receiver, const char *member)
+{
+ int id;
+
+ if(elem == SQ_TreeViewMenu::New)
+ id = id_new;
+ else if(elem == SQ_TreeViewMenu::Delete)
+ id = id_delete;
+ else if(elem == SQ_TreeViewMenu::Rename)
+ id = id_rename;
+ else if(elem == SQ_TreeViewMenu::Clear)
+ id = id_clear;
+ else
+ id = id_prop;
+
+ disconnectItem(id, 0, 0);
+ connectItem(id, receiver, member);
+}
+
+void SQ_TreeViewMenu::updateDirActions(bool isdir, bool isroot)
+{
+ setItemEnabled(id_new, isdir);
+ setItemEnabled(id_clear, isdir);
+
+ setItemEnabled(id_delete, !isroot);
+ setItemEnabled(id_rename, isdir && !isroot);
+}
+
+void SQ_TreeViewMenu::slotDirectoryNew()
+{
+ if(!m_url.isEmpty())
+ {
+ bool ok;
+
+ TQString mNewFilename = KInputDialog::getText(i18n("Create Subfolder"),
+ i18n("<p>Create new folder in <b>%1</b>:</p>").arg(TQStyleSheet::escape(m_url.filename())),
+ TQString(), &ok, KSquirrel::app());
+
+ if(ok)
+ {
+ KURL dstURL = m_url;
+ dstURL.addPath(mNewFilename);
+ TDEIO::Job *job = TDEIO::mkdir(dstURL);
+
+ connect(job, TQ_SIGNAL(result(TDEIO::Job*)), this, TQ_SLOT(slotDirectoryResult(TDEIO::Job *)));
+ }
+ }
+}
+
+void SQ_TreeViewMenu::slotDirectoryRename()
+{
+ if(!m_url.isEmpty())
+ {
+ KURL renameSrcURL = m_url;
+ bool ok;
+
+ TQString filename = TQStyleSheet::escape(renameSrcURL.filename());
+
+ TQString mNewFilename = KInputDialog::getText(i18n("Rename Folder"),
+ i18n("<p>Rename folder <b>%1</b> to:</p>").arg(filename),
+ renameSrcURL.filename(), &ok, KSquirrel::app());
+
+ if(ok)
+ {
+ KURL renameDstURL = renameSrcURL;
+ renameDstURL.setFileName(mNewFilename);
+
+ TDEIO::Job *job = TDEIO::rename(renameSrcURL, renameDstURL, true);
+
+ connect(job, TQ_SIGNAL(result(TDEIO::Job*)), this, TQ_SLOT(slotDirectoryResult(TDEIO::Job *)));
+ }
+ }
+}
+
+void SQ_TreeViewMenu::slotDirectoryDelete()
+{
+ if(!m_url.isEmpty())
+ {
+ TQString dir = TQStyleSheet::escape(m_url.path());
+
+ if(KMessageBox::questionYesNo(KSquirrel::app(),
+ "<qt>" + i18n("Are you sure you want to delete <b>%1</b>?").arg(dir) + "</qt>") == KMessageBox::No)
+ return;
+
+ TDEIO::Job *job = TDEIO::del(m_url);
+
+ connect(job, TQ_SIGNAL(result(TDEIO::Job*)), this, TQ_SLOT(slotDirectoryResult(TDEIO::Job *)));
+ }
+}
+
+void SQ_TreeViewMenu::slotDirectoryClear()
+{
+ if(!m_url.isEmpty())
+ {
+ urlstodel.clear();
+
+ if(KMessageBox::questionYesNo(KSquirrel::app(),
+ "<qt>" + i18n("Are you sure you want to delete contents of <b>%1</b>?").arg(m_url.path()) + "</qt>") == KMessageBox::No)
+ return;
+
+ TDEIO::Job *job = TDEIO::listDir(m_url, false, true);
+
+ connect(job, TQ_SIGNAL(entries(TDEIO::Job *, const TDEIO::UDSEntryList &)), this, TQ_SLOT(slotEntries(TDEIO::Job *, const TDEIO::UDSEntryList &)));
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotListResult(TDEIO::Job *)));
+ }
+}
+
+void SQ_TreeViewMenu::slotEntries(TDEIO::Job *, const TDEIO::UDSEntryList &list)
+{
+ TDEIO::UDSEntryListConstIterator itEnd = list.end();
+ TQString suff;
+ KURL u;
+
+ static const TQString &dot = TDEGlobal::staticQString(".");
+ static const TQString &dotdot = TDEGlobal::staticQString("..");
+
+ // go through list of TDEIO::UDSEntrys
+ for(TDEIO::UDSEntryListConstIterator it = list.begin(); it != itEnd; ++it)
+ {
+ TDEIO::UDSEntry entry = *it;
+ TDEIO::UDSEntry::ConstIterator itEnd = entry.end();
+
+ for(TDEIO::UDSEntry::ConstIterator it = entry.begin(); it != itEnd; ++it)
+ {
+ if((*it).m_uds == TDEIO::UDS_NAME)
+ {
+ suff = (*it).m_str;
+
+ if(suff != dot && suff != dotdot)
+ {
+ u = m_url;
+ u.addPath(suff);
+ urlstodel.append(u);
+ }
+
+ break;
+ }
+ }
+ }
+}
+
+void SQ_TreeViewMenu::slotListResult(TDEIO::Job *job)
+{
+ if(!job) return;
+
+ if(job->error())
+ job->showErrorDialog(KSquirrel::app());
+ else if(!urlstodel.isEmpty())
+ {
+ TDEIO::Job *job = TDEIO::del(urlstodel);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotDirectoryResult(TDEIO::Job *)));
+ }
+}
+
+void SQ_TreeViewMenu::slotDirectoryResult(TDEIO::Job *job)
+{
+ if(job && job->error())
+ job->showErrorDialog(KSquirrel::app());
+}
+
+void SQ_TreeViewMenu::slotDirectoryProperties()
+{
+ if(!m_url.isEmpty())
+ (void)new KPropertiesDialog(m_url, KSquirrel::app());
+}
+
+#include "sq_treeviewmenu.moc"
diff --git a/src/sidebar/sq_treeviewmenu.h b/src/sidebar/sq_treeviewmenu.h
new file mode 100644
index 0000000..72d900a
--- /dev/null
+++ b/src/sidebar/sq_treeviewmenu.h
@@ -0,0 +1,59 @@
+#ifndef SQ_TREEVIEWMENU_H
+#define SQ_TREEVIEWMENU_H
+
+#include <tdepopupmenu.h>
+#include <kurl.h>
+
+class TQPoint;
+
+namespace TDEIO { class Job; }
+
+class SQ_TreeViewMenu : public TDEPopupMenu
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_TreeViewMenu(TQWidget *parent = 0, const char *name = 0);
+ virtual ~SQ_TreeViewMenu();
+
+ enum Element { New, Rename, Delete, Properties, Clear };
+
+ void setURL(const KURL &_url);
+ KURL url() const;
+
+ void reconnect(Element, TQObject *receiver, const char *member);
+ virtual void updateDirActions(bool isdir, bool isroot = false);
+
+ protected slots:
+ virtual void slotDirectoryNew();
+ virtual void slotDirectoryRename();
+ virtual void slotDirectoryDelete();
+ virtual void slotDirectoryProperties();
+ virtual void slotDirectoryResult(TDEIO::Job *job);
+
+ void slotDirectoryClear();
+ void slotEntries(TDEIO::Job *, const TDEIO::UDSEntryList &);
+ void slotListResult(TDEIO::Job *);
+
+ protected:
+ int id_new, id_rename, id_delete, id_prop, id_clear;
+
+ private:
+ KURL m_url;
+ KURL::List urlstodel;
+};
+
+inline
+void SQ_TreeViewMenu::setURL(const KURL &_url)
+{
+ m_url = _url;
+}
+
+inline
+KURL SQ_TreeViewMenu::url() const
+{
+ return m_url;
+}
+
+#endif
diff --git a/src/sq_archivehandler.cpp b/src/sq_archivehandler.cpp
new file mode 100644
index 0000000..9c4ce55
--- /dev/null
+++ b/src/sq_archivehandler.cpp
@@ -0,0 +1,114 @@
+/***************************************************************************
+ sq_archivehandler.cpp - description
+ -------------------
+ begin : ??? ??? 26 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tdemessagebox.h>
+#include <tdeglobal.h>
+#include <kstandarddirs.h>
+#include <tdefileitem.h>
+#include <tdelocale.h>
+#include <kurl.h>
+
+#include "sq_archivehandler.h"
+
+SQ_ArchiveHandler * SQ_ArchiveHandler::m_instance = 0;
+
+SQ_ArchiveHandler::SQ_ArchiveHandler(TQObject * parent, const char *name)
+ : TQObject(parent, name), TQMap<TQString, TQString>()
+{
+ m_instance = this;
+
+ fillProtocols();
+}
+
+SQ_ArchiveHandler::~SQ_ArchiveHandler()
+{}
+
+void SQ_ArchiveHandler::fillProtocols()
+{
+ // search for tar protocol
+ if(!TDEGlobal::dirs()->findResource("services", "tar.protocol").isEmpty())
+ {
+ insert("application/x-tgz", "tar");
+ insert("application/x-tar", "tar");
+ insert("application/x-tarz", "tar");
+ insert("application/x-tbz", "tar");
+ insert("application/x-tzo", "tar");
+ }
+
+ // search for rar protocol (tdeio_rar from
+ // http://kde-apps.org/content/show.php/tdeio_rar?content=17527)
+ if(!TDEGlobal::dirs()->findResource("services", "rar.protocol").isEmpty())
+ {
+ insert("application/x-rar", "rar");
+ }
+
+ // search for ar protocol
+ if(!TDEGlobal::dirs()->findResource("services", "ar.protocol").isEmpty())
+ insert("application/x-archive", "ar");
+
+ // search for iso protocol
+ if(!TDEGlobal::dirs()->findResource("services", "iso.protocol").isEmpty())
+ insert("application/x-iso", "iso");
+
+ // search for zip protocol
+ if(!TDEGlobal::dirs()->findResource("services", "zip.protocol").isEmpty())
+ insert("application/x-zip", "zip");
+
+ // search for 7zip protocol (tdeio_p7zip
+ // from http://kde-apps.org/content/show.php/tdeio_p7zip?content=17829)
+ if(!TDEGlobal::dirs()->findResource("services", "p7zip.protocol").isEmpty())
+ insert("application/x-7z", "p7zip");
+}
+
+/*
+ * Find protocol name by mimetype name.
+ *
+ * For example findProtocolByMime(""application/x-tgz"") will
+ * return "tar".
+ */
+TQString SQ_ArchiveHandler::findProtocolByMime(const TQString &mime)
+{
+ // find protocol
+ TQMap<TQString, TQString>::iterator it = find(mime);
+
+ // return protocol number, if found, and -1 otherwise
+ return (it == end() ? TQString() : it.data());
+}
+
+/*
+ * Find protocol name by KFileItem's mimetype.
+ */
+TQString SQ_ArchiveHandler::findProtocolByFile(KFileItem *item)
+{
+ return item ? findProtocolByMime(item->mimetype()) : TQString();
+}
+
+void SQ_ArchiveHandler::tryUnpack(KFileItem *item)
+{
+ if(item) tryUnpack(item->url(), item->mimetype());
+}
+
+void SQ_ArchiveHandler::tryUnpack(const KURL &url, const TQString &mime)
+{
+ TQString prot = findProtocolByMime(mime);
+
+ if(!prot.isEmpty())
+ {
+ // just change protocol, TDEIO::get() will do all for us
+ KURL _url = url;
+ _url.setProtocol(prot);
+
+ emit unpack(_url);
+ }
+}
+
+#include "sq_archivehandler.moc"
diff --git a/src/sq_archivehandler.h b/src/sq_archivehandler.h
new file mode 100644
index 0000000..bc46a48
--- /dev/null
+++ b/src/sq_archivehandler.h
@@ -0,0 +1,67 @@
+/***************************************************************************
+ sq_archivehandler.h - description
+ -------------------
+ begin : ??? ??? 26 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+#ifndef SQ_ARCHIVEHANDLER_H
+#define SQ_ARCHIVEHANDLER_H
+
+#include <tqobject.h>
+#include <tqstring.h>
+#include <tqmap.h>
+
+// forward declarations
+class KFileItem;
+class KURL;
+
+#define SQ_AH SQ_ArchiveHandler
+
+/*
+ * Helper class for archive extracting via tdeio-slaves (since 0.7.1).
+ */
+
+class SQ_ArchiveHandler : public TQObject, TQMap<TQString, TQString>
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_ArchiveHandler(TQObject *parent = 0, const char *name = 0);
+ ~SQ_ArchiveHandler();
+
+ /*
+ * Find protocol name by mimetype name.
+ *
+ * For example findProtocolByMime(""application/x-tgz"") will
+ * return "tar".
+ */
+ TQString findProtocolByMime(const TQString &mime);
+
+ /*
+ * Find protocol name by KFileItem's mimetype.
+ */
+ TQString findProtocolByFile(KFileItem *item);
+
+ /*
+ * Determine mimetype and emit unpack() signal
+ */
+ void tryUnpack(KFileItem *);
+
+ void tryUnpack(const KURL &, const TQString &mime);
+
+ static SQ_ArchiveHandler* instance() { return m_instance; }
+
+ private:
+ void fillProtocols();
+
+ signals:
+ void unpack(const KURL &);
+
+ private:
+ static SQ_ArchiveHandler *m_instance;
+};
+
+#endif
diff --git a/src/sq_bookmarkowner.cpp b/src/sq_bookmarkowner.cpp
new file mode 100644
index 0000000..24b6d86
--- /dev/null
+++ b/src/sq_bookmarkowner.cpp
@@ -0,0 +1,62 @@
+/***************************************************************************
+ sq_bookmarkowner.cpp - description
+ -------------------
+ begin : ??? ??? 27 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_bookmarkowner.h"
+
+SQ_BookmarkOwner * SQ_BookmarkOwner::m_instance = 0;
+
+SQ_BookmarkOwner::SQ_BookmarkOwner(TQWidget *parent) : TQObject(parent)
+{
+ m_instance = this;
+}
+
+SQ_BookmarkOwner::~SQ_BookmarkOwner()
+{}
+
+/*
+ * User selected some bookmark. It will emit 'openURL' signal,
+ * and SQ_WidgetStack will catch it.
+ */
+void SQ_BookmarkOwner::openBookmarkURL(const TQString &url)
+{
+ KURL u = KURL::fromPathOrURL(url);
+
+ emit openURL(u);
+}
+
+/*
+ * Current url. If user selected "Add bookmark", this
+ * url will be added to bookmarks. See also KBookmarkOwner::setURL()
+ */
+TQString SQ_BookmarkOwner::currentURL() const
+{
+ return URL.prettyURL();
+}
+
+/*
+ * Set current url
+ */
+void SQ_BookmarkOwner::setURL(const KURL &new_url)
+{
+ URL = new_url;
+}
+
+#include "sq_bookmarkowner.moc"
diff --git a/src/sq_bookmarkowner.h b/src/sq_bookmarkowner.h
new file mode 100644
index 0000000..93dc62f
--- /dev/null
+++ b/src/sq_bookmarkowner.h
@@ -0,0 +1,75 @@
+/***************************************************************************
+ sq_bookmarkowner.h - description
+ -------------------
+ begin : ??? ??? 27 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_BOOKMARKOWNER_H
+#define SQ_BOOKMARKOWNER_H
+
+#include <kbookmarkmanager.h>
+#include <kurl.h>
+
+#include <tqobject.h>
+#include <tqwidget.h>
+
+/*
+ * Class for managing bookmarks. It used in main class (KSquirrel::initBookmarks())
+ * and in SQ_WidgetStack to store and manage bookmarks.
+ */
+
+class SQ_BookmarkOwner : public TQObject, public KBookmarkOwner
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_BookmarkOwner(TQWidget *parent = 0);
+ virtual ~SQ_BookmarkOwner();
+
+ /*
+ * User selected some bookmark. It will emit 'openURL' signal,
+ * and SQ_WidgetStack will catch it.
+ */
+ virtual void openBookmarkURL(const TQString &);
+
+ /*
+ * Current url. If user selected "Add bookmark", this
+ * url will be added to bookmarks. See also SQ_BookmarkOwner::setURL()
+ */
+ virtual TQString currentURL() const;
+
+ static SQ_BookmarkOwner* instance() { return m_instance; }
+
+ /*
+ * Set current url
+ */
+ public slots:
+ void setURL(const KURL &);
+
+ /*
+ * Signal to open some url. SQ_WidgetStack will catch it
+ * and change current directory.
+ */
+ signals:
+ void openURL(const KURL &);
+
+ private:
+ KURL URL;
+
+ // singleton
+ static SQ_BookmarkOwner *m_instance;
+};
+
+#endif
diff --git a/src/sq_codecsettings.cpp b/src/sq_codecsettings.cpp
new file mode 100644
index 0000000..47b3609
--- /dev/null
+++ b/src/sq_codecsettings.cpp
@@ -0,0 +1,42 @@
+/***************************************************************************
+ sq_codecsettings.cpp - description
+ -------------------
+ begin : Mon Mar 5 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <ksquirrel-libs/fmt_codec_base.h>
+
+#include "sq_codecsettings.h"
+#include "sq_library.h"
+#include "sq_config.h"
+
+void SQ_CodecSettings::applySettings(SQ_LIBRARY *lib, SQ_CodecSettings::settings fromwhere)
+{
+ SQ_Config::instance()->setGroup("Main");
+
+ int set = SQ_Config::instance()->readNumEntry("applyto", SQ_CodecSettings::Both);
+
+ // thumbnail loader and image viewer will use default settings
+ if((fromwhere == SQ_CodecSettings::ThumbnailLoader && (set == SQ_CodecSettings::ThumbnailLoader || set == SQ_CodecSettings::Both))
+ || (fromwhere == SQ_CodecSettings::ImageViewer && (set == SQ_CodecSettings::ImageViewer || set == SQ_CodecSettings::Both)))
+ {
+ lib->codec->set_settings(lib->settings);
+ lib->codec_il->set_settings(lib->settings);
+ }
+ else
+ {
+ lib->codec->fill_default_settings();
+ lib->codec_il->fill_default_settings();
+ }
+}
diff --git a/src/sq_codecsettings.h b/src/sq_codecsettings.h
new file mode 100644
index 0000000..f789e9f
--- /dev/null
+++ b/src/sq_codecsettings.h
@@ -0,0 +1,34 @@
+/***************************************************************************
+ sq_codecsettings.h - description
+ -------------------
+ begin : Mon Mar 5 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_CODECSETTINGS_H
+#define SQ_CODECSETTINGS_H
+
+/**
+ *@author Baryshev Dmitry
+ */
+
+struct SQ_LIBRARY;
+
+struct SQ_CodecSettings
+{
+ enum settings { ThumbnailLoader = 0, ImageViewer, Both, RunTume, None };
+
+ static void applySettings(SQ_LIBRARY *l, SQ_CodecSettings::settings fromwhere);
+};
+
+#endif
diff --git a/src/sq_codecsettingsskeleton.ui b/src/sq_codecsettingsskeleton.ui
new file mode 100644
index 0000000..1314543
--- /dev/null
+++ b/src/sq_codecsettingsskeleton.ui
@@ -0,0 +1,217 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_CodecSettingsSkeleton</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_CodecSettingsSkeleton</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>283</width>
+ <height>335</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Codec settings</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>codecIcon</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="Line" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>line2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>codecName</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQGroupBox" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>groupBox</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="Line" row="3" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="4" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushApply</cstring>
+ </property>
+ <property name="text">
+ <string>Apply</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushOK</cstring>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushCancel</cstring>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushOK</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_CodecSettingsSkeleton</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>pushCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_CodecSettingsSkeleton</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>pushApply</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_CodecSettingsSkeleton</receiver>
+ <slot>slotApply()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>pushOK</tabstop>
+ <tabstop>pushApply</tabstop>
+ <tabstop>pushCancel</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in declaration">ksquirrel-libs/settings.h</include>
+ <include location="global" impldecl="in implementation">tqcheckbox.h</include>
+ <include location="global" impldecl="in implementation">tqmessagebox.h</include>
+ <include location="global" impldecl="in implementation">tqobjectlist.h</include>
+ <include location="global" impldecl="in implementation">tqbuttongroup.h</include>
+ <include location="global" impldecl="in implementation">tqslider.h</include>
+ <include location="global" impldecl="in implementation">kurlrequester.h</include>
+ <include location="global" impldecl="in implementation">knuminput.h</include>
+ <include location="global" impldecl="in implementation">tqwidgetfactory.h</include>
+ <include location="global" impldecl="in implementation">tqspinbox.h</include>
+ <include location="global" impldecl="in implementation">tqtextedit.h</include>
+ <include location="global" impldecl="in implementation">kurl.h</include>
+ <include location="global" impldecl="in implementation">kcolorbutton.h</include>
+ <include location="local" impldecl="in implementation">sq_codecsettingsskeleton.ui.h</include>
+</includes>
+<variables>
+ <variable access="private">TQWidget *w;</variable>
+ <variable access="private">fmt_settings *sett;</variable>
+</variables>
+<signals>
+ <signal>apply();</signal>
+</signals>
+<slots>
+ <slot access="private" specifier="non virtual">slotApply()</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function specifier="non virtual">addSettingsWidget( const TQString &amp; path )</function>
+ <function access="private" specifier="non virtual">recursivelyReadWrite( fmt_settings &amp; settings, bool r )</function>
+ <function returnType="int">exec( fmt_settings &amp; settings )</function>
+ <function specifier="non virtual">setCodecInfo( const TQPixmap &amp; pixmap, const TQString &amp; text )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_codecsettingsskeleton.ui.h b/src/sq_codecsettingsskeleton.ui.h
new file mode 100644
index 0000000..d976149
--- /dev/null
+++ b/src/sq_codecsettingsskeleton.ui.h
@@ -0,0 +1,171 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+void SQ_CodecSettingsSkeleton::init()
+{
+ w = 0;
+ sett = 0;
+}
+
+void SQ_CodecSettingsSkeleton::addSettingsWidget(const TQString &path)
+{
+ w = TQWidgetFactory::create(path, 0, this, "skeleton_settings");
+ TQWidget *fake;
+
+ if(w)
+ fake = w;
+ else
+ {
+ pushApply->setEnabled(false);
+ pushOK->setEnabled(false);
+
+ TQTextEdit *t = new TQTextEdit(i18n("Error loading widget from <b>%1</b>. Please check your installation or contact <a href=\"mailto:[email protected]\">[email protected]</a>").arg(path), TQString(), groupBox);
+ t->setReadOnly(true);
+ fake = t;
+ }
+
+ fake->reparent(groupBox, TQPoint(0,0), true);
+
+ TQGridLayout *grid = new TQGridLayout(groupBox, 1, 1, 11, 6);
+ grid->addMultiCellWidget(fake, 1, 1, 0, 3);
+
+ TQSpacerItem *spacer = new TQSpacerItem(15, 1, TQSizePolicy::Minimum, TQSizePolicy::Expanding);
+ grid->addItem(spacer, 2, 1);
+}
+
+void SQ_CodecSettingsSkeleton::recursivelyReadWrite(fmt_settings &settings, bool r)
+{
+ if(!w)
+ return;
+
+ TQObjectList ch = w->childrenListObject();
+ fmt_settings::iterator t;
+
+ for(TQObjectList::iterator it = ch.begin();it != ch.end();++it)
+ {
+ t = settings.find((*it)->name());
+
+ if((*it)->inherits("TQCheckBox"))
+ {
+ TQCheckBox *c = dynamic_cast<TQCheckBox *>(*it);
+
+ if(c && t != settings.end())
+ {
+ if(r)
+ c->setChecked((*t).second.bVal);
+ else
+ (*t).second.bVal = c->isChecked();
+ }
+ }
+ else if((*it)->inherits("TQButtonGroup"))
+ {
+ TQButtonGroup *c = dynamic_cast<TQButtonGroup *>(*it);
+
+ if(c && t != settings.end())
+ {
+ if(r)
+ c->setButton((*t).second.iVal);
+ else
+ (*t).second.iVal = c->selectedId();
+ }
+ }
+ else if((*it)->inherits("TQSlider"))
+ {
+ TQSlider *c = dynamic_cast<TQSlider *>(*it);
+
+ if(c && t != settings.end())
+ {
+ if(r)
+ c->setValue((*t).second.iVal);
+ else
+ (*t).second.iVal = c->value();
+ }
+ }
+ else if((*it)->inherits("KURLRequester"))
+ {
+ KURLRequester *u = dynamic_cast<KURLRequester *>(*it);
+
+ if(u && t != settings.end())
+ {
+ if(r)
+ u->setURL((*t).second.sVal);
+ else
+ {
+ KURL url = u->url(); // get rid of "file://" if present
+ (*t).second.sVal = url.isEmpty() ? "" : url.path().ascii();
+ }
+ }
+ }
+ else if((*it)->inherits("KDoubleSpinBox"))
+ {
+ KDoubleSpinBox *d = dynamic_cast<KDoubleSpinBox *>(*it);
+
+ if(d && t != settings.end())
+ {
+ if(r)
+ d->setValue((*t).second.dVal);
+ else
+ (*t).second.dVal = d->value();
+ }
+ }
+ // TQSpinBox should be checked after KDoubleSpinBox !
+ else if((*it)->inherits("TQSpinBox"))
+ {
+ TQSpinBox *c = dynamic_cast<TQSpinBox *>(*it);
+
+ if(c && t != settings.end())
+ {
+ if(r)
+ c->setValue((*t).second.iVal);
+ else
+ (*t).second.iVal = c->value();
+ }
+ }
+ else if((*it)->inherits("KColorButton"))
+ {
+ KColorButton *c = dynamic_cast<KColorButton *>(*it);
+
+ if(c && t != settings.end())
+ {
+ if(r)
+ c->setColor(TQColor(TQString((*t).second.sVal)));
+ else
+ (*t).second.sVal = TQString(c->color().name()).ascii();
+ }
+ }
+ }
+}
+
+int SQ_CodecSettingsSkeleton::exec(fmt_settings &settings)
+{
+ // read settings
+ recursivelyReadWrite(settings, true);
+
+ sett = &settings;
+
+ int result = TQDialog::exec();
+
+ // save settings
+ if(result == TQDialog::Accepted)
+ recursivelyReadWrite(settings, false);
+
+ return result;
+}
+
+void SQ_CodecSettingsSkeleton::setCodecInfo( const TQPixmap &pixmap, const TQString &text )
+{
+ codecIcon->setPixmap(pixmap);
+ codecName->setText(text);
+}
+
+void SQ_CodecSettingsSkeleton::slotApply()
+{
+ recursivelyReadWrite(*sett, false);
+ emit apply();
+}
diff --git a/src/sq_config.cpp b/src/sq_config.cpp
new file mode 100644
index 0000000..ea0fc4b
--- /dev/null
+++ b/src/sq_config.cpp
@@ -0,0 +1,36 @@
+/***************************************************************************
+ sq_config.cpp - description
+ -------------------
+ begin : ??? ??? 14 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_config.h"
+
+SQ_Config * SQ_Config::m_instance = 0;
+
+SQ_Config::SQ_Config(TQObject *parent) : TQObject(parent)
+{
+ m_instance = this;
+
+ tdeconf = new TDEConfig("ksquirrelrc");
+}
+
+SQ_Config::~SQ_Config()
+{
+ delete tdeconf;
+}
diff --git a/src/sq_config.h b/src/sq_config.h
new file mode 100644
index 0000000..73cf0c4
--- /dev/null
+++ b/src/sq_config.h
@@ -0,0 +1,136 @@
+/***************************************************************************
+ sq_config.h - description
+ -------------------
+ begin : ??? ??? 14 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_CONFIG_H
+#define SQ_CONFIG_H
+
+#include <tqobject.h>
+#include <tdeconfig.h>
+
+class TDEConfig;
+
+/*
+ * Class for reading/writing config file
+ */
+
+class SQ_Config : public TQObject
+{
+ public:
+ SQ_Config(TQObject *parent = 0);
+ ~SQ_Config();
+
+ static SQ_Config* instance() { return m_instance; }
+
+ void sync();
+
+ void setGroup(const TQString &group);
+ bool hasGroup(const TQString &group) const;
+ bool deleteGroup( const TQString& group, bool bDeep = true, bool bGlobal = false );
+ TQString readEntry(const TQString& pKey, const TQString& aDefault = TQString() ) const;
+ TQStringList readListEntry( const TQString& pKey, char sep = ',' ) const;
+ int readNumEntry( const TQString& pKey, int nDefault = 0 ) const;
+ bool readBoolEntry( const TQString& pKey, bool bDefault = false ) const;
+ TQRect readRectEntry( const TQString& pKey, const TQRect* pDefault = 0L ) const;
+ TQPoint readPointEntry( const TQString& pKey, const TQPoint* pDefault = 0L ) const;
+ TQSize readSizeEntry( const TQString& pKey, const TQSize* pDefault = 0L ) const;
+ double readDoubleNumEntry( const TQString& pKey, double nDefault = 0.0 ) const;
+ TQValueList<int> readIntListEntry( const TQString& pKey ) const;
+
+ void writeEntry( const TQString& pKey, const TQString& pValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, const TQStringList &rValue, char sep = ',', bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, int nValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, bool bValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, const TQRect& rValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, const TQPoint& rValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, const TQSize& rValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+ void writeEntry( const TQString& pKey, double nValue, bool bPersistent = true, bool bGlobal = false, char format = 'g', int precision = 6, bool bNLS = false );
+ void writeEntry( const TQString& pKey, const TQValueList<int>& rValue, bool bPersistent = true, bool bGlobal = false, bool bNLS = false );
+
+ private:
+ TDEConfig *tdeconf;
+ static SQ_Config *m_instance;
+};
+
+inline
+void SQ_Config::sync() { tdeconf->sync(); }
+
+inline
+void SQ_Config::setGroup(const TQString &group) { tdeconf->setGroup(group) ; }
+
+inline
+bool SQ_Config::hasGroup(const TQString &group) const { return tdeconf->hasGroup(group) ; }
+
+inline
+bool SQ_Config::deleteGroup(const TQString& group, bool bDeep, bool bGlobal) { return tdeconf->deleteGroup(group, bDeep, bGlobal) ; }
+
+inline
+TQString SQ_Config::readEntry(const TQString& pKey, const TQString& aDefault) const { return tdeconf->readEntry(pKey, aDefault) ; }
+
+inline
+TQStringList SQ_Config::readListEntry(const TQString& pKey, char sep) const { return tdeconf->readListEntry(pKey, sep) ; }
+
+inline
+int SQ_Config::readNumEntry(const TQString& pKey, int nDefault) const { return tdeconf->readNumEntry(pKey, nDefault) ; }
+
+inline
+bool SQ_Config::readBoolEntry(const TQString& pKey, bool bDefault) const { return tdeconf->readBoolEntry(pKey, bDefault ) ; }
+
+inline
+TQRect SQ_Config::readRectEntry(const TQString& pKey, const TQRect* pDefault) const { return tdeconf->readRectEntry(pKey, pDefault) ; }
+
+inline
+TQPoint SQ_Config::readPointEntry(const TQString& pKey, const TQPoint* pDefault) const { return tdeconf->readPointEntry(pKey, pDefault) ; }
+
+inline
+TQSize SQ_Config::readSizeEntry(const TQString& pKey, const TQSize* pDefault) const { return tdeconf->readSizeEntry(pKey, pDefault) ; }
+
+inline
+double SQ_Config::readDoubleNumEntry(const TQString& pKey, double nDefault) const { return tdeconf->readDoubleNumEntry(pKey, nDefault); }
+
+inline
+TQValueList<int> SQ_Config::readIntListEntry( const TQString& pKey ) const { return tdeconf->readIntListEntry(pKey); }
+
+/**********************************************/
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, const TQString& pValue, bool bPersistent, bool bGlobal, bool bNLS) { tdeconf->writeEntry( pKey, pValue, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, const TQStringList &rValue, char sep, bool bPersistent, bool bGlobal, bool bNLS ) { tdeconf->writeEntry(pKey, rValue, sep, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, int nValue, bool bPersistent, bool bGlobal, bool bNLS ) { tdeconf->writeEntry(pKey, nValue, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, bool bValue, bool bPersistent, bool bGlobal, bool bNLS ) { tdeconf->writeEntry(pKey, bValue, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, const TQRect& rValue, bool bPersistent, bool bGlobal, bool bNLS ) { tdeconf->writeEntry(pKey, rValue, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, const TQPoint& rValue, bool bPersistent, bool bGlobal, bool bNLS ) { tdeconf->writeEntry(pKey, rValue, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry(const TQString& pKey, const TQSize& rValue, bool bPersistent, bool bGlobal, bool bNLS ) { tdeconf->writeEntry(pKey,rValue, bPersistent, bGlobal, bNLS ) ; }
+
+inline
+void SQ_Config::writeEntry( const TQString& pKey, double nValue, bool bPersistent, bool bGlobal, char format, int precision, bool bNLS) { tdeconf->writeEntry(pKey, nValue, bPersistent, bGlobal, format, precision, bNLS); }
+
+inline
+void SQ_Config::writeEntry( const TQString& pKey, const TQValueList<int>& rValue, bool bPersistent, bool bGlobal, bool bNLS) { tdeconf->writeEntry(pKey, rValue, bPersistent, bGlobal, bNLS); }
+
+#endif
diff --git a/src/sq_dir.cpp b/src/sq_dir.cpp
new file mode 100644
index 0000000..a4dbd0c
--- /dev/null
+++ b/src/sq_dir.cpp
@@ -0,0 +1,92 @@
+/***************************************************************************
+ sq_dir.cpp - description
+ -------------------
+ begin : ??? ??? 20 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqstringlist.h>
+#include <tqfile.h>
+#include <tqdatetime.h>
+#include <tqfileinfo.h>
+
+#include <kurl.h>
+
+#include "sq_dir.h"
+#include "sq_thumbnailinfo.h"
+
+SQ_Dir::SQ_Dir() : TQDir()
+{}
+
+SQ_Dir::SQ_Dir(Prefix p) : TQDir()
+{
+ switch(p)
+ {
+ case SQ_Dir::DirectoryBasket:
+ setRoot("directorybasket");
+ break;
+ case SQ_Dir::Basket:
+ setRoot("basket");
+ break;
+ case SQ_Dir::Categories:
+ setRoot("categories");
+ break;
+ }
+}
+
+SQ_Dir::~SQ_Dir()
+{}
+
+/*
+ * Create relative directory in storage.
+ *
+ * For example, if prefix == Thumbnails,
+ * mkdir("/mnt/win_c") will create
+ * ~/.ksquirrel/thumbnails/mnt/win_c.
+ */
+bool SQ_Dir::mkdir(const TQString &relpath)
+{
+ TQStringList paths = TQStringList::split('/', TQDir::cleanDirPath(relpath));
+
+ cd(m_root);
+
+ // recursively create directories
+ for(TQStringList::iterator it = paths.begin();it != paths.end();++it)
+ {
+ if(!exists(*it, false))
+ if(!TQDir::mkdir(*it))
+ return false;
+
+ cd(*it);
+ }
+
+ return true;
+}
+
+void SQ_Dir::setRoot(const TQString &name)
+{
+ m_root = TQDir::cleanDirPath(homeDirPath() + TQDir::separator() + TQString::fromLatin1(".ksquirrel"));
+ TQDir::mkdir(m_root);
+
+ m_root = TQDir::cleanDirPath(m_root + TQDir::separator() + name);
+ TQDir::mkdir(m_root);
+}
+
+TQString SQ_Dir::absPath(const KURL &relurl)
+{
+ return m_root + TQDir::separator() + relurl.path();
+}
diff --git a/src/sq_dir.h b/src/sq_dir.h
new file mode 100644
index 0000000..31cf151
--- /dev/null
+++ b/src/sq_dir.h
@@ -0,0 +1,104 @@
+/***************************************************************************
+ sq_dir.h - description
+ -------------------
+ begin : ??? ??? 20 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_DIR_H
+#define SQ_DIR_H
+
+#include <tqdir.h>
+
+#include <ctime>
+
+class KURL;
+
+/*
+ * Class for managing application-specific data. It takes care
+ * of storing thumbnails, unpacked archives.
+ *
+ * All data stored in ~/.ksquirrel (called 'storage').
+ *
+ * Objects of this class are used by SQ_Archivehandler, SQ_PixmapCache,
+ * SQ_ThumbnailJob etc.
+ */
+
+class SQ_Dir : public TQDir
+{
+ public:
+ enum Prefix {
+
+ DirectoryBasket,
+
+ // image basket cache
+ Basket,
+
+ // image categories (~/.ksquirrel/categories).
+ Categories};
+
+ /*
+ * don't create root directory
+ */
+ SQ_Dir();
+
+ /*
+ * create root directory according to Prefix
+ */
+ SQ_Dir(Prefix);
+ ~SQ_Dir();
+
+ /*
+ * Create relative directory in storage.
+ *
+ * For example, if prefix == Thumbnails,
+ * mkdir("/mnt/win_c") will create
+ * ~/.ksquirrel/thumbnails/mnt/win_c.
+ *
+ * Return true, if operation succeded.
+ */
+ bool mkdir(const TQString &relpath);
+
+ /*
+ * Get current root directory.
+ *
+ * For example, if prefix == Basket, it will
+ * return "/home/krasu/.ksquirrel/basket".
+ */
+ virtual TQString root() const;
+
+ /*
+ * Get absolute path for relative path 'relpath'.
+ *
+ * Reimplemented in SQ_DirThumbs to handle MD5-encoded
+ * urls.
+ */
+ virtual TQString absPath(const KURL &relurl);
+
+ private:
+ /*
+ * Internal, used by mkdir().
+ */
+ virtual void setRoot(const TQString &name);
+
+ protected:
+ TQString m_root;
+};
+
+inline
+TQString SQ_Dir::root() const
+{
+ return m_root;
+}
+
+#endif
diff --git a/src/sq_diroperator.cpp b/src/sq_diroperator.cpp
new file mode 100644
index 0000000..398d859
--- /dev/null
+++ b/src/sq_diroperator.cpp
@@ -0,0 +1,1074 @@
+/***************************************************************************
+ sq_diroperator.cpp - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqtimer.h>
+#include <tqlabel.h>
+#include <tqfileinfo.h>
+#include <tqapplication.h>
+#include <tqtooltip.h>
+#include <tqclipboard.h>
+
+#include <tdeapplication.h>
+#include <kstringhandler.h>
+#include <tdelocale.h>
+#include <kprogress.h>
+#include <tdeglobal.h>
+#include <tdestdaccel.h>
+#include <kdiskfreesp.h>
+#include <konq_operations.h>
+#include <kiconeffect.h>
+
+#include "ksquirrel.h"
+#include "sq_archivehandler.h"
+#include "sq_diroperator.h"
+#include "sq_fileiconview.h"
+#include "sq_filethumbview.h"
+#include "sq_filethumbviewitem.h"
+#include "sq_filedetailview.h"
+#include "sq_widgetstack.h"
+#include "sq_config.h"
+#include "sq_glview.h"
+#include "sq_glwidget.h"
+#include "sq_thumbnailsize.h"
+#include "sq_pixmapcache.h"
+#include "sq_libraryhandler.h"
+#include "sq_externaltool.h"
+#include "sq_popupmenu.h"
+#include "sq_navigatordropmenu.h"
+#include "sq_previewwidget.h"
+#include "sq_treeview.h"
+#include "sq_progress.h"
+#include "sq_downloader.h"
+#include "sq_hloptions.h"
+
+#include "sq_categoriesview.h"
+#include "sq_categorybrowsermenu.h"
+#include "sq_imagebasket.h"
+#include "sq_converter.h"
+#include "sq_directorybasket.h"
+
+static const int SQ_MAX_WORD_LENGTH = 50;
+
+SQ_DirOperator::SQ_DirOperator(const KURL &url, ViewT type_, TQWidget *parent, const char *name)
+ : KDirOperator(url, parent, name), type(type_)
+{
+ usenew = false;
+
+ totalSize = static_cast<TDEIO::filesize_t>(0);
+
+ // create and insert new actions in context menu
+ setupActionsMy();
+
+ connect(this, TQ_SIGNAL(finishedLoading()), this, TQ_SLOT(slotFinishedLoading()));
+ connect(this, TQ_SIGNAL(updateInformation(int,int)), this, TQ_SLOT(slotUpdateInformation(int,int)));
+ connect(this, TQ_SIGNAL(urlEntered(const KURL&)), this, TQ_SLOT(slotUrlEntered(const KURL&)));
+ connect(this, TQ_SIGNAL(dropped(const KFileItem *, TQDropEvent*, const KURL::List&)),
+ this, TQ_SLOT(slotDropped(const KFileItem *, TQDropEvent*, const KURL::List&)));
+ connect(this, TQ_SIGNAL(fileSelected(const KFileItem *)), this, TQ_SLOT(slotExecutedConst(const KFileItem *)));
+
+ connect(dirLister(), TQ_SIGNAL(deleteItem(KFileItem *)), this, TQ_SLOT(slotItemDeleted(KFileItem *)));
+ connect(dirLister(), TQ_SIGNAL(newItems(const KFileItemList &)), this, TQ_SLOT(slotNewItems(const KFileItemList &)));
+ connect(dirLister(), TQ_SIGNAL(refreshItems(const KFileItemList &)), this, TQ_SLOT(slotRefreshItems(const KFileItemList &)));
+
+ timer_preview = new TQTimer(this);
+ connect(timer_preview, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotPreview()));
+
+ setAcceptDrops(true);
+
+ fileview = 0;
+ oldCurrentItem = 0;
+
+ fireDiskSize(url);
+
+ down = new SQ_Downloader(this, "SQ_Downloader [dirop]");
+ connect(down, TQ_SIGNAL(result(const KURL &)), this, TQ_SLOT(slotDownloaderResult(const KURL &)));
+ connect(down, TQ_SIGNAL(percents(int)), this, TQ_SLOT(slotDownloadPercents(int)));
+
+ connect(SQ_ArchiveHandler::instance(), TQ_SIGNAL(unpack(const KURL &)), this, TQ_SLOT(slotSetURL(const KURL &)));
+
+ // read sorting settings
+ SQ_Config::instance()->setGroup("Fileview");
+ int sorting = 0;
+
+ if(SQ_Config::instance()->readBoolEntry("sorting_name", true)) sorting |= TQDir::Name;
+ if(SQ_Config::instance()->readBoolEntry("sorting_time", false)) sorting |= TQDir::Time;
+ if(SQ_Config::instance()->readBoolEntry("sorting_size", false)) sorting |= TQDir::Size;
+ if(SQ_Config::instance()->readBoolEntry("sorting_dirs", true)) sorting |= TQDir::DirsFirst;
+ if(SQ_Config::instance()->readBoolEntry("sorting_reverse", false)) sorting |= TQDir::Reversed;
+ if(SQ_Config::instance()->readBoolEntry("sorting_ignore", false)) sorting |= TQDir::IgnoreCase;
+
+ actionHidden = dynamic_cast<TDEToggleAction *>(actionCollection()->action("show hidden"));
+
+ if(SQ_Config::instance()->readBoolEntry("show hidden", false) && actionHidden)
+ {
+ actionHidden->setChecked(false);
+ actionHidden->activate();
+ }
+
+ setSorting(static_cast<TQDir::SortSpec>(sorting));
+ setEnableDirHighlighting(true);
+}
+
+SQ_DirOperator::~SQ_DirOperator()
+{}
+
+void SQ_DirOperator::slotUrlEntered(const KURL &url)
+{
+ usenew = false;
+
+ totalSize = static_cast<TDEIO::filesize_t>(0);
+
+ clearListers();
+
+ SQ_WidgetStack::instance()->setURLForCurrent(url);
+
+ fireDiskSize(url);
+}
+
+void SQ_DirOperator::fireDiskSize(const KURL &url)
+{
+ if(url.isLocalFile())
+ {
+ KDiskFreeSp *sp = KDiskFreeSp::findUsageInfo(url.path());
+
+ connect(sp, TQ_SIGNAL(foundMountPoint(const unsigned long&,
+ const unsigned long&,
+ const unsigned long&,
+ const TQString&)),
+ this, TQ_SLOT(slotFoundMountPoint(const unsigned long&,
+ const unsigned long&,
+ const unsigned long&,
+ const TQString&)));
+ }
+ else
+ {
+ KSquirrel::app()->diskProgress()->flush();
+ KSquirrel::app()->diskProgress()->setTotalSteps(1);
+ KSquirrel::app()->diskProgress()->setIndicator(0);
+ KSquirrel::app()->diskProgress()->update();
+ KSquirrel::app()->sbarWidget("diskSpace")->setText(i18n("remote filesystem"));
+ TQToolTip::remove(KSquirrel::app()->sbarWidget("diskSpace"));
+ }
+}
+
+void SQ_DirOperator::slotFoundMountPoint(const unsigned long &kbSize,
+ const unsigned long &kbUsed,
+ const unsigned long &kbAvail,
+ const TQString &mount)
+{
+ // clear any previous drawing
+ KSquirrel::app()->diskProgress()->flush();
+
+ KSquirrel::app()->diskProgress()->setTotalSteps(kbSize);
+ KSquirrel::app()->diskProgress()->setIndicator(kbSize-kbAvail); // kbSize != kbAvail+kbUsed
+ KSquirrel::app()->sbarWidget("diskSpace")->setText(TQString::fromLatin1("%1: %2/%3")
+ .arg(mount)
+ .arg(TDEIO::convertSizeFromKB(kbAvail))
+ .arg(TDEIO::convertSizeFromKB(kbSize)));
+
+ TQToolTip::add(KSquirrel::app()->sbarWidget("diskSpace"), i18n("<table><tr><td>Mount point:</td><td>%1</td></tr><tr><td>Total size:</td><td>%2</td></tr><tr><td>Used:</td><td>%3</td></tr><tr><td>Available:</td><td>%4</td></tr></table>")
+ .arg(mount)
+ .arg(TDEIO::convertSizeFromKB(kbSize))
+ .arg(TDEIO::convertSizeFromKB(kbUsed))
+ .arg(TDEIO::convertSizeFromKB(kbAvail))
+ );
+}
+
+void SQ_DirOperator::slotExecutedConst(const KFileItem *fi)
+{
+ execute(const_cast<KFileItem *>(fi));
+}
+
+void SQ_DirOperator::execute(KFileItem *fi)
+{
+ down->kill();
+
+ SQ_GLWidget::window()->setOriginalURL(fi->url());
+
+ if(fi->url().isLocalFile())
+ executePrivate(fi);
+ else if(SQ_LibraryHandler::instance()->maybeSupported(fi->url(), fi->mimetype()) != SQ_LibraryHandler::No)
+ down->start(fi);
+}
+
+void SQ_DirOperator::slotDownloaderResult(const KURL &url)
+{
+ SQ_GLWidget::window()->setDownloadPercents(-1);
+
+ if(url.isEmpty())
+ return;
+
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, url);
+
+ executePrivate(&fi);
+}
+
+void SQ_DirOperator::prepareView(ViewT t)
+{
+ type = t;
+
+ if(fileview)
+ {
+ oldSelected = *fileview->selectedItems();
+ oldCurrentItem = fileview->currentFileItem();
+ }
+
+ switch(type)
+ {
+ case SQ_DirOperator::TypeDetailed:
+ {
+ SQ_FileDetailView *dv;
+ fileview = dv = new SQ_FileDetailView(this, "detail view");
+
+ connect(dv, TQ_SIGNAL(currentChanged(TQListViewItem *)), this, TQ_SLOT(slotCurrentChanged(TQListViewItem *)));
+ connect(dv, TQ_SIGNAL(selectionChanged()), this, TQ_SLOT(slotSelectionChanged()));
+ connect(dv, TQ_SIGNAL(invokeBrowser()), this, TQ_SLOT(slotInvokeBrowser()));
+ connect(KSquirrel::app(), TQ_SIGNAL(resetToolTip()), dv, TQ_SLOT(slotResetToolTip()));
+ }
+ break;
+
+ case SQ_DirOperator::TypeList:
+ case SQ_DirOperator::TypeIcons:
+ {
+ SQ_FileIconView *iv;
+ fileview = iv = new SQ_FileIconView(this, (type == SQ_DirOperator::TypeIcons) ? "icon view":"list view");
+
+ connect(iv, TQ_SIGNAL(currentChanged(TQIconViewItem *)), this, TQ_SLOT(slotCurrentChanged(TQIconViewItem *)));
+ connect(iv, TQ_SIGNAL(selectionChanged()), this, TQ_SLOT(slotSelectionChanged()));
+ connect(iv, TQ_SIGNAL(invokeBrowser()), this, TQ_SLOT(slotInvokeBrowser()));
+ connect(KSquirrel::app(), TQ_SIGNAL(resetToolTip()), iv, TQ_SLOT(slotResetToolTip()));
+
+ disableSpecificActions(iv);
+ }
+ break;
+
+ case SQ_DirOperator::TypeThumbs:
+ {
+ SQ_FileThumbView *tv;
+ fileview = tv = new SQ_FileThumbView(this, "thumb view");
+
+ connect(tv, TQ_SIGNAL(currentChanged(TQIconViewItem *)), this, TQ_SLOT(slotCurrentChanged(TQIconViewItem *)));
+ connect(tv, TQ_SIGNAL(selectionChanged()), this, TQ_SLOT(slotSelectionChanged()));
+ connect(tv, TQ_SIGNAL(invokeBrowser()), this, TQ_SLOT(slotInvokeBrowser()));
+ connect(dirLister(), TQ_SIGNAL(canceled()), tv, TQ_SLOT(stopThumbnailUpdate()));
+ connect(KSquirrel::app(), TQ_SIGNAL(resetToolTip()), tv, TQ_SLOT(slotResetToolTip()));
+
+ disableSpecificActions(tv);
+ }
+ break;
+ }
+}
+
+void SQ_DirOperator::slotCurrentChanged(TQListViewItem *)
+{
+ timer_preview->start(SQ_PreviewWidget::instance()->delay(), true);
+}
+
+void SQ_DirOperator::slotCurrentChanged(TQIconViewItem *)
+{
+ timer_preview->start(SQ_PreviewWidget::instance()->delay(), true);
+}
+
+void SQ_DirOperator::slotSelectionChanged()
+{
+ TQString str = i18n("no files selected");
+ TQPixmap px;
+ TDEIO::filesize_t sz = static_cast<TDEIO::filesize_t>(0);
+ int add = 0;
+ KFileItem *fi = 0;
+
+ // which items are selected ?
+ for(KFileItem *it = fileview->firstFileItem();it;it = fileview->nextItem(it))
+ {
+ if(fileview->isSelected(it))
+ {
+ // _current_ fileitem and currently _selected_ fileitem
+ // may differ, so lets count only first _selected_ item
+ if(!fi)
+ fi = it;
+
+ add++;
+
+ // count only files
+ if(it->isFile())
+ sz += it->size();
+ }
+ }
+
+ if(fi)
+ {
+ // determine pixmap
+ px = fi->pixmap(TDEIcon::SizeSmall);
+
+ // costruct name and size
+ str = TQString("%1 %2 %3")
+ .arg(KStringHandler::csqueeze(fi->name(), SQ_MAX_WORD_LENGTH))
+ .arg(TDEIO::convertSize(fi->size()))
+ .arg(add > 1 ? TQString("<b>[%1/%2]</b>").arg(TDEIO::convertSize(sz)).arg(add):"");
+ }
+
+ // update statusbar
+ KSquirrel::app()->sbarWidget("fileIcon")->setPixmap(px);
+ KSquirrel::app()->sbarWidget("fileName")->setText(str);
+}
+
+void SQ_DirOperator::setPreparedView()
+{
+ setView(fileview);
+
+ fileview->setOnlyDoubleClickSelectsFiles(true);
+}
+
+void SQ_DirOperator::slotDropped(const KFileItem *i, TQDropEvent*, const KURL::List &urls)
+{
+ KURL u = i ? i->url() : url();
+
+ // setup and show popup menu with actions
+ SQ_NavigatorDropMenu::instance()->setupFiles(urls, u);
+ SQ_NavigatorDropMenu::instance()->exec(TQCursor::pos());
+}
+
+// Insert new actions in context menu.
+void SQ_DirOperator::setupActionsMy()
+{
+ new TDEAction(i18n("Edit file type"), 0, 0, this, TQ_SLOT(slotEditMime()), actionCollection(), "dirop_edit_mime");
+
+ if(SQ_HLOptions::instance()->have_imagebasket)
+ new TDEAction(i18n("Add to Basket"), "folder_image", CTRL+TQt::Key_B, this, TQ_SLOT(slotAddToBasket()), actionCollection(), "dirop_tobasket");
+
+ if(SQ_HLOptions::instance()->have_directorybasket)
+ new TDEAction(i18n("Add to Folder Basket"), "folder_image", CTRL+TQt::Key_D, this, TQ_SLOT(slotAddToDirectoryBasket()), actionCollection(), "dirop_todirbasket");
+
+ TDEActionMenu *file = new TDEActionMenu(i18n("File actions"), actionCollection(), "dirop_file_menu");
+ TDEAction *prop = actionCollection()->action("properties");
+
+ TDEAction *reload = actionCollection()->action("mkdir");
+ if(reload && reload->shortcut().isNull()) reload->setShortcut(TDEShortcut(CTRL+TQt::Key_N));
+ reload = actionCollection()->action("reload");
+
+ connect(prop, TQ_SIGNAL(enabled(bool)), this, TQ_SLOT(slotEnableFileActions(bool)));
+
+ TDEAction *sep = actionCollection()->action("separator");
+
+ file->insert(new TDEAction(i18n("Copy"), "edit-copy", TDEStdAccel::copy(), SQ_WidgetStack::instance(), TQ_SLOT(slotFileCopy()), actionCollection(), "dirop_copy"));
+ file->insert(new TDEAction(i18n("Cut"), "edit-cut", TDEStdAccel::cut(), SQ_WidgetStack::instance(), TQ_SLOT(slotFileCut()), actionCollection(), "dirop_cut"));
+ file->insert(new TDEAction(i18n("Paste"), "edit-paste", TDEStdAccel::paste(), SQ_WidgetStack::instance(), TQ_SLOT(slotFilePaste()), actionCollection(), "dirop_paste"));
+ file->insert(sep);
+ file->insert(new TDEAction(i18n("Copy to..."), 0, TQt::Key_F5, SQ_WidgetStack::instance(), TQ_SLOT(slotFileCopyTo()), actionCollection(), "dirop_copyto"));
+ file->insert(new TDEAction(i18n("Move to..."), 0, TQt::Key_F6, SQ_WidgetStack::instance(), TQ_SLOT(slotFileMoveTo()),actionCollection(), "dirop_cutto"));
+ file->insert(new TDEAction(i18n("Link to..."), 0, TQt::Key_F7, SQ_WidgetStack::instance(), TQ_SLOT(slotFileLinkTo()), actionCollection(), "dirop_linkto"));
+ file->insert(sep);
+ file->insert(new TDEAction(i18n("Run"), "launch", CTRL+Key_J, SQ_WidgetStack::instance(), TQ_SLOT(slotRunSeparately()), actionCollection(), "dirop_runsepar"));
+ file->insert(new TDEAction(i18n("Repeat (nothing to repeat)"), "go-down", TQt::Key_F10, KSquirrel::app(), TQ_SLOT(slotRepeat()), actionCollection(), "dirop_repeat"));
+ file->insert(new TDEAction(i18n("Convert..."), 0, CTRL+TQt::Key_K, SQ_Converter::instance(), TQ_SLOT(slotStartEdit()), actionCollection(), "dirop_convert"));
+
+ file->insert(sep);
+ file->insert(new TDEAction(i18n("Recreate selected thumbnails"), "reload", CTRL+TQt::Key_R, SQ_WidgetStack::instance(),
+ TQ_SLOT(slotRecreateThumbnail()), actionCollection(), "dirop_recreate_thumbnails"));
+ file->insert(sep);
+ file->insert(new TDEAction(i18n("Copy file path"), 0, TQt::Key_F8, this, TQ_SLOT(slotCopyPath()), actionCollection(), "dirop_copypath"));
+ file->insert(new TDEAction(i18n("Copy file url"), 0, TQt::Key_F9, this, TQ_SLOT(slotCopyURL()), actionCollection(), "dirop_copyurl"));
+
+ if(reload) reload->setShortcut(CTRL+TQt::Key_F5);
+}
+
+void SQ_DirOperator::slotEnableFileActions(bool e)
+{
+ actionCollection()->action("dirop_tobasket")->setEnabled(e);
+ actionCollection()->action("dirop_todirbasket")->setEnabled(e);
+
+ actionCollection()->action("dirop_copy")->setEnabled(e);
+ actionCollection()->action("dirop_cut")->setEnabled(e);
+ actionCollection()->action("dirop_copyto")->setEnabled(e);
+ actionCollection()->action("dirop_cutto")->setEnabled(e);
+ actionCollection()->action("dirop_linkto")->setEnabled(e);
+
+ actionCollection()->action("dirop_runsepar")->setEnabled(e);
+ actionCollection()->action("dirop_convert")->setEnabled(e);
+
+ actionCollection()->action("dirop_copypath")->setEnabled(e);
+ actionCollection()->action("dirop_copyurl")->setEnabled(e);
+
+ actionCollection()->action("dirop_recreate_thumbnails")->setEnabled(type == SQ_DirOperator::TypeThumbs && e);
+ SQ_ExternalTool::instance()->constPopupMenu()->setEnabled(e);
+
+ if(SQ_HLOptions::instance()->have_categories)
+ SQ_CategoriesBox::instance()->popupMenu()->setEnabled(e);
+}
+
+void SQ_DirOperator::slotCopyPath()
+{
+ KFileItem *f = fileview->currentFileItem();
+
+ if(f)
+ TQApplication::clipboard()->setText(f->url().path());
+}
+
+void SQ_DirOperator::slotCopyURL()
+{
+ KFileItem *f = fileview->currentFileItem();
+
+ if(f)
+ TQApplication::clipboard()->setText(f->url().prettyURL());
+}
+
+void SQ_DirOperator::slotEditMime()
+{
+ KFileItem *f = fileview->currentFileItem();
+
+ if(f)
+ KonqOperations::editMimeType(f->mimetype());
+}
+
+void SQ_DirOperator::slotAddToBasket()
+{
+ SQ_ImageBasket::instance()->add(*selectedItems());
+}
+
+void SQ_DirOperator::slotAddToDirectoryBasket()
+{
+ SQ_DirectoryBasket::instance()->add(*selectedItems());
+}
+
+void SQ_DirOperator::slotFinishedLoading()
+{
+ // force sort if invisible
+ if(!isVisible())
+ {
+ // derived from KFileDetailView
+ if(type == SQ_DirOperator::TypeDetailed)
+ {
+ KFileDetailView *dv = dynamic_cast<KFileDetailView *>(fileview);
+ if(dv) dv->sort();
+ }
+ // derived from KFileIconView
+ else
+ {
+ KFileIconView *tv = dynamic_cast<KFileIconView *>(fileview);
+ if(tv) tv->sort(!tv->isReversed());
+ }
+ }
+
+ int dirs = numDirs(), files = numFiles();
+ int total = dirs+files;
+
+ slotUpdateInformation(files, dirs);
+
+ if(lasturl.equals(url(), true))
+ return;
+ else
+ {
+ lasturl = url();
+ usenew = true;
+ }
+
+ // clear TQLabels in statusbar, if current directory has
+ // no files/directories
+ if(!total)
+ {
+ lasturl = KURL();
+ usenew = false;
+ m_pending = TQString();
+ KSquirrel::app()->sbarWidget("fileIcon")->clear();
+ KSquirrel::app()->sbarWidget("fileName")->clear();
+ return;
+ }
+
+ // setting current file directly doesn't work. let
+ // events to be processed and only then set current file
+ TQTimer::singleShot(0, this, TQ_SLOT(slotDelayedFinishedLoading()));
+}
+
+void SQ_DirOperator::slotDelayedFinishedLoading()
+{
+ // select pending file if any
+ if(!m_pending.isEmpty())
+ {
+ if(fileview)
+ {
+ fileview->clearSelection();
+ fileview->setCurrentItem(m_pending);
+ setCurrentItem(fileview->currentFileItem());
+ }
+
+ m_pending = TQString();
+ startOrNotThumbnailUpdate();
+
+ return;
+ }
+
+ KURL up_url = url().upURL();
+
+ KFileItem *first = fileview->firstFileItem();
+
+ if(!first) return;
+
+ // ignore ".." item
+ if(up_url.equals(first->url(), true))
+ first = fileview->nextItem(first);
+
+ // hell!
+ if(!first) return;
+
+ SQ_Config::instance()->setGroup("Fileview");
+
+ bool goto_first = false;
+
+ // SQ_WidgetStack will select first supported image for us
+ if(SQ_Config::instance()->readBoolEntry("tofirst", true))
+ goto_first = SQ_WidgetStack::instance()->moveTo(SQ_WidgetStack::Next, first) == SQ_WidgetStack::moveFailed;
+ else
+ goto_first = true;
+
+ if(goto_first)
+ {
+ KFileItem *fi = fileview->currentFileItem();
+
+ if(fi && !up_url.equals(fi->url(), true))
+ setCurrentItem(fileview->currentFileItem());
+ else
+ setCurrentItem(first);
+ }
+
+ startOrNotThumbnailUpdate();
+}
+
+void SQ_DirOperator::slotUpdateInformation(int files, int dirs)
+{
+ int total = dirs + files;
+
+ SQ_Config::instance()->setGroup("Fileview");
+
+ TQString str = i18n("Total %1 in %2 (%3, %4)")
+ .arg(TDEIO::convertSize(totalSize))
+ .arg(i18n("1 item", "%n items", total))
+ .arg(i18n("1 folder", "%n folders", dirs))
+ .arg(i18n("1 file", "%n files", files));
+
+ KSquirrel::app()->sbarWidget("dirInfo")->setText(str);
+}
+
+/*
+ * Deselect all items, set current item, select this item,
+ * and ensure it visible.
+ */
+void SQ_DirOperator::setCurrentItem(KFileItem *item)
+{
+ // for safety...
+ if(!item)
+ return;
+
+ // clear selection
+ fileview->clearSelection();
+
+ // set current item and select it
+ fileview->setCurrentItem(item);
+ fileview->setSelected(item, true);
+
+ // make this item visible
+ fileview->ensureItemVisible(item);
+}
+
+/*
+ * Change thumbnail size. KSquirrel will emit thumbSizeChanged() signal, and
+ * diroperator will catch it. Only diroperator, which manages SQ_FileThumbView
+ * won't ignore this signal. See also SQ_WidgetStack::raiseWidget().
+ */
+void SQ_DirOperator::slotSetThumbSize(const TQString &size)
+{
+ // for safety...
+ if(type != SQ_DirOperator::TypeThumbs)
+ return;
+
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(fileview);
+
+ SQ_ThumbnailSize::instance()->setPixelSize(size);
+
+ tv->rebuildCachedPixmaps();
+
+ // reinsert files
+ removeCdUpItem();
+ smartUpdate();
+
+ // finally, update thumbnails
+ startOrNotThumbnailUpdate();
+}
+
+/*
+ * Smart update. Store all file items, reset view,
+ * and transfer all items back.
+ *
+ * Taken from tdelibs-3.2.3/tdeio/tdefile/tdediroperator.cpp
+ */
+void SQ_DirOperator::smartUpdate()
+{
+ // store old file items
+ KFileItemList items = *fileview->items();
+ oldSelected = *fileview->selectedItems();
+ oldCurrentItem = fileview->currentFileItem();
+
+ // heh, 'items' now contains "..", we should remove it!
+ removeCdUpItem();
+
+ // clear view and add items (see SQ_FileThumbView::insertItem() for more)
+ fileview->clear();
+
+ if(type == SQ_DirOperator::TypeThumbs)
+ {
+ SQ_Config::instance()->setGroup("Thumbnails");
+
+ int newgrid = SQ_ThumbnailSize::instance()->extended() ?
+ SQ_ThumbnailSize::instance()->extendedSize().width()
+ : SQ_ThumbnailSize::instance()->pixelSize();
+
+ newgrid += (SQ_Config::instance()->readNumEntry("margin", 2) + 2);
+
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(fileview);
+
+ tv->setGridX(newgrid);
+ tv->arrangeItemsInGrid();
+ }
+
+ fileview->addItemList(items);
+
+ selectOld();
+}
+
+void SQ_DirOperator::selectOld()
+{
+ // set current item...
+ fileview->setCurrentItem(oldCurrentItem);
+
+ // restore selection
+ KFileItemListIterator it(oldSelected);
+
+ fileview->ensureItemVisible(it.current());
+
+ for(; it.current();++it)
+ fileview->setSelected(it.current(), true);
+
+ oldSelected.clear();
+
+ stopPreview();
+}
+
+/*
+ * Remove ".." from currently listed items
+ */
+void SQ_DirOperator::removeCdUpItem()
+{
+ // for safety...
+ if(!fileview)
+ return;
+
+ KFileItemList m_items = *fileview->items();
+ KFileItemListIterator it_s(m_items);
+ KURL up_url = url().upURL();
+
+ for(; it_s.current();++it_s)
+ {
+ if(it_s.current()->url() == up_url)
+ {
+ fileview->removeItem(it_s.current());
+ break;
+ }
+ }
+}
+
+void SQ_DirOperator::startOrNotThumbnailUpdate()
+{
+ // start delayed thumbnail update, if needed
+ if(type == SQ_DirOperator::TypeThumbs)
+ {
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(fileview);
+
+ // start thumbnail update only when this
+ // diroperator is visible
+ if(tv)
+ {
+ if(tv->isVisible())
+ tv->startThumbnailUpdate();
+ else
+ tv->waitForShowEvent();
+ }
+ }
+}
+
+void SQ_DirOperator::clearListers()
+{
+ SQ_Listers::iterator itEnd = listers.end();
+
+ // delete all listers
+ for(SQ_Listers::iterator it = listers.begin();it != itEnd;++it)
+ delete it.data();
+
+ listers.clear();
+}
+
+void SQ_DirOperator::urlAdded(const KURL &_url)
+{
+ // avoid duplications
+ if(listers.contains(_url) || _url.equals(url(), true))
+ return;
+
+ KDirLister *lister = new KDirLister(true);
+
+ lister->setMainWindow(dirLister()->mainWindow());
+
+ // redirect all signals to dirLister() - nice hack
+ connect(lister, TQ_SIGNAL(refreshItems(const KFileItemList &)), dirLister(), TQ_SIGNAL(refreshItems(const KFileItemList &)));
+ connect(lister, TQ_SIGNAL(deleteItem(KFileItem *)), dirLister(), TQ_SIGNAL(deleteItem(KFileItem *)));
+ connect(lister, TQ_SIGNAL(newItems(const KFileItemList &)), dirLister(), TQ_SIGNAL(newItems(const KFileItemList &)));
+
+ connect(lister, TQ_SIGNAL(started(const KURL &)), dirLister(), TQ_SIGNAL(started(const KURL &)));
+ connect(lister, TQ_SIGNAL(completed()), dirLister(), TQ_SIGNAL(completed()));
+ connect(lister, TQ_SIGNAL(canceled()), dirLister(), TQ_SIGNAL(canceled()));
+
+ // save this lister for us
+ listers[_url] = lister;
+
+ lister->openURL(_url);
+}
+
+void SQ_DirOperator::urlRemoved(const KURL &url)
+{
+ // for safety
+ SQ_Listers::iterator it = listers.find(url);
+
+ if(it == listers.end())
+ return;
+
+ KDirLister *lister = it.data();
+
+ KFileItemList list = lister->items();
+
+ // start delayed thumbnail update, if needed
+ if(type == SQ_DirOperator::TypeThumbs)
+ {
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(fileview);
+
+ if(tv && tv->updateRunning())
+ tv->itemsRemoved(list);
+ }
+
+ SQ_Config::instance()->setGroup("Fileview");
+ bool c = SQ_Config::instance()->readBoolEntry("calculate", true);
+
+ for(KFileItem *itit_tvoyu_mats = list.first();itit_tvoyu_mats;itit_tvoyu_mats = list.next())
+ {
+ itemDeleted(itit_tvoyu_mats);
+
+ if(c) totalSize -= itit_tvoyu_mats->size();
+ }
+
+ slotUpdateInformation(numFiles(), numDirs());
+
+ // remove this lister from map
+ listers.remove(url);
+
+ delete lister;
+
+ // update view
+ KFileIconView *vi = dynamic_cast<KFileIconView *>(fileview);
+
+ if(vi)
+ vi->arrangeItemsInGrid();
+}
+
+void SQ_DirOperator::executePrivate(KFileItem *fi)
+{
+ KURL url = fi->url();
+ TQString fullpath = url.path();
+ TQFileInfo fm(fullpath);
+
+ // Ok, this file is image file. Let's try to load it
+ if(SQ_LibraryHandler::instance()->libraryForFile(fullpath))
+ SQ_GLWidget::window()->startDecoding(fullpath);
+ else
+ {
+ SQ_Config::instance()->setGroup("Fileview");
+
+ // archive ?
+ if(!SQ_ArchiveHandler::instance()->findProtocolByFile(fi).isEmpty())
+ if(SQ_Config::instance()->readBoolEntry("archives", true))
+ SQ_ArchiveHandler::instance()->tryUnpack(fi);
+ else;
+ // not image, not archive. Read settings and run this file separately
+ // with default application (if needed).
+ else if(SQ_Config::instance()->readBoolEntry("run unknown", false))
+ emit runSeparately(fi);
+ }
+}
+
+void SQ_DirOperator::disableSpecificActions(KFileIconView *v)
+{
+ TDEAction *a;
+
+ a = v->actionCollection()->action("zoomIn");
+ if(a) a->setEnabled(false);
+
+ a = v->actionCollection()->action("zoomOut");
+ if(a) a->setEnabled(false);
+
+ a = v->actionCollection()->action("show previews");
+ if(a) a->setEnabled(false);
+}
+
+void SQ_DirOperator::slotPreview()
+{
+ KFileItem *fi = fileview ? fileview->currentFileItem() : 0;
+
+ if(fi) SQ_PreviewWidget::instance()->load(fi->url());
+}
+
+void SQ_DirOperator::slotNewItems(const KFileItemList &list)
+{
+ SQ_Config::instance()->setGroup("Fileview");
+
+ if(SQ_Config::instance()->readBoolEntry("calculate", true))
+ {
+ KFileItemListIterator it(list);
+ KFileItem *fi;
+
+ while((fi = it.current()) != 0)
+ {
+ ++it;
+ if(fi->isFile()) totalSize += fi->size();
+ }
+ }
+
+ // start delayed thumbnail update, if needed
+ if(type == SQ_DirOperator::TypeThumbs && usenew)
+ {
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(fileview);
+
+ if(tv)
+ tv->addItemsToJob(list);
+ }
+}
+
+void SQ_DirOperator::slotRefreshItems(const KFileItemList &list)
+{
+ KFileItemListIterator it(list);
+ KFileItem *fci = fileview ? fileview->currentFileItem() : 0;
+ KFileItem *fi;
+
+ // refresh image been previewed
+ while((fi = it.current()))
+ {
+ if(fi == fci)
+ {
+ timer_preview->start(SQ_PreviewWidget::instance()->delay(), true);
+ break;
+ }
+
+ ++it;
+ }
+
+ // start delayed thumbnail update, if needed
+ if(type == SQ_DirOperator::TypeThumbs)
+ {
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(fileview);
+
+ if(tv)
+ {
+ KFileItemListIterator it(list);
+ SQ_FileThumbViewItem *tfi;
+
+ if(tv->updateRunning())
+ tv->itemsRemoved(list);
+
+ while((fi = it.current()))
+ {
+ // force thumbnail to be updated by setting listed = false
+ tfi = reinterpret_cast<SQ_FileThumbViewItem *>(fi->extraData(tv));
+
+ if(tfi)
+ tfi->setListed(false);
+
+ // remove thumbnail from pixmap cache and from disk
+ SQ_PixmapCache::instance()->removeEntryFull(fi->url().path());
+ ++it;
+ }
+
+ tv->addItemsToJob(list, false);
+ }
+ }
+}
+
+/*
+ * Invoked, when some item has been deleted. We should
+ * remove appropriate thumbnail from pixmap cache.
+ */
+void SQ_DirOperator::slotItemDeleted(KFileItem *item)
+{
+ if(!item) return;
+
+ itemKill(item);
+
+ // remove thumbnail from cache,
+ SQ_PixmapCache::instance()->removeEntryFull(item->url());
+}
+
+void SQ_DirOperator::itemKill(KFileItem *item)
+{
+ if(!item) return;
+
+ SQ_Config::instance()->setGroup("Fileview");
+ if(SQ_Config::instance()->readBoolEntry("calculate", true))
+ totalSize -= item->size();
+
+ slotUpdateInformation(numFiles(), numDirs());
+
+ // start delayed thumbnail update, if needed
+ if(type == SQ_DirOperator::TypeThumbs)
+ {
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(fileview);
+
+ if(tv && tv->updateRunning())
+ tv->itemRemoved(item);
+ }
+}
+
+void SQ_DirOperator::stopPreview()
+{
+ timer_preview->stop();
+}
+
+void SQ_DirOperator::activatedMenu(const KFileItem *, const TQPoint &pos)
+{
+ // remove "View" submenu, since we will insert our's one.
+ setupMenu(KDirOperator::AllActions ^ KDirOperator::ViewActions);
+ updateSelectionDependentActions();
+
+ TDEActionMenu *pADirOperatorMenu = dynamic_cast<TDEActionMenu *>(actionCollection()->action("popupMenu"));
+
+ pADirOperatorMenu->insert(actionCollection()->action("dirop_edit_mime"));
+ pADirOperatorMenu->insert(actionCollection()->action("separator"));
+
+ if(SQ_HLOptions::instance()->have_categories)
+ pADirOperatorMenu->popupMenu()->insertItem(i18n("Add to &Category"), SQ_CategoriesBox::instance()->popupMenu());
+
+ if(SQ_HLOptions::instance()->have_imagebasket)
+ pADirOperatorMenu->insert(actionCollection()->action("dirop_tobasket"));
+
+ if(SQ_HLOptions::instance()->have_directorybasket)
+ pADirOperatorMenu->insert(actionCollection()->action("dirop_todirbasket"));
+
+ pADirOperatorMenu->popupMenu()->insertItem(i18n("File actions"), dynamic_cast<TDEActionMenu *>(actionCollection()->action("dirop_file_menu"))->popupMenu(), -1, 0);
+ pADirOperatorMenu->popupMenu()->insertItem(i18n("&External tools"), SQ_ExternalTool::instance()->constPopupMenu(), -1, 1);
+ pADirOperatorMenu->popupMenu()->insertSeparator(2);
+
+ KFileItemList *items = const_cast<KFileItemList *>(selectedItems());
+
+ if(items)
+ SQ_ExternalTool::instance()->setItems(*items);
+
+ pADirOperatorMenu->popup(pos);
+}
+
+void SQ_DirOperator::slotSetURL(const KURL &url)
+{
+ setURL(url, true);
+}
+
+void SQ_DirOperator::calcTotalSize()
+{
+ totalSize = static_cast<TDEIO::filesize_t>(0);
+
+ KFileItemList *list = const_cast<KFileItemList *>(fileview->items());
+
+ if(!list) return;
+
+ KFileItemListIterator it(*list);
+ KFileItem *fi;
+
+ while((fi = it.current()) != 0)
+ {
+ ++it;
+
+ if(fi->isFile())
+ totalSize += fi->size();
+ }
+
+ slotUpdateInformation(numFiles(), numDirs());
+}
+
+void SQ_DirOperator::saveConfig()
+{
+ TQDir::SortSpec sort = sorting();
+
+ SQ_Config::instance()->writeEntry("sorting_name", KFile::isSortByName(sort));
+ SQ_Config::instance()->writeEntry("sorting_time", KFile::isSortByDate(sort));
+ SQ_Config::instance()->writeEntry("sorting_size", KFile::isSortBySize(sort));
+ SQ_Config::instance()->writeEntry("sorting_dirs", KFile::isSortDirsFirst(sort));
+ SQ_Config::instance()->writeEntry("sorting_reverse", (sort & TQDir::Reversed) == TQDir::Reversed);
+ SQ_Config::instance()->writeEntry("sorting_ignore", KFile::isSortCaseInsensitive(sort));
+
+ SQ_Config::instance()->writeEntry("show hidden", showHiddenFiles());
+}
+
+void SQ_DirOperator::setLazy(bool l, int delay, int rows)
+{
+ if(type == SQ_DirOperator::TypeThumbs)
+ {
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(fileview);
+
+ if(tv)
+ {
+ if(tv->lazy() != l)
+ tv->setLazy(l, delay);
+
+ tv->setAddRows(rows);
+
+ if(tv->updateRunning())
+ tv->startThumbnailUpdate();
+ }
+ }
+}
+
+void SQ_DirOperator::slotInvokeBrowser()
+{
+ tdeApp->invokeBrowser(url().prettyURL());
+}
+
+void SQ_DirOperator::enableThumbnailActions(bool enable)
+{
+ actionCollection()->action("dirop_recreate_thumbnails")->setEnabled(enable);
+}
+
+void SQ_DirOperator::stopThumbnailUpdate()
+{
+ if(type == SQ_DirOperator::TypeThumbs)
+ {
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(fileview);
+
+ if(tv && tv->updateRunning())
+ tv->stopThumbnailUpdate();
+ }
+}
+
+void SQ_DirOperator::slotDownloadPercents(int p)
+{
+ SQ_GLWidget::window()->setDownloadPercents(p);
+}
+
+#include "sq_diroperator.moc"
diff --git a/src/sq_diroperator.h b/src/sq_diroperator.h
new file mode 100644
index 0000000..98ffc9f
--- /dev/null
+++ b/src/sq_diroperator.h
@@ -0,0 +1,292 @@
+/***************************************************************************
+ sq_diroperator.h - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_DIROPERATOR_H
+#define SQ_DIROPERATOR_H
+
+#include <tqmap.h>
+
+#include <tdediroperator.h>
+
+class TQTimer;
+class TQListViewItem;
+class TQIconViewItem;
+
+class KDirLister;
+class KFileIconView;
+class KFileItem;
+
+class SQ_Downloader;
+
+class SQ_DirOperator : public KDirOperator
+{
+ TQ_OBJECT
+
+
+ public:
+ /*
+ * View type.
+ *
+ * - list view with small icons
+ * - icon view with large icons
+ * - detailed view with file details
+ * - thumbnail view with image thumbnails
+ */
+ enum ViewT {TypeList = 0, TypeIcons, TypeDetailed, TypeThumbs };
+
+ /*
+ * Constructor. Creates diroperator with specified view type. SQ_DirOperatorBase
+ * reimplements createView() to create different custom views.
+ * View type is determined by 'type_'.
+ */
+ SQ_DirOperator(const KURL &url = KURL(), ViewT type_ = SQ_DirOperator::TypeList,
+ TQWidget *parent = 0, const char *name = 0);
+
+ ~SQ_DirOperator();
+
+ void stopThumbnailUpdate();
+
+ void enableThumbnailActions(bool enable);
+
+ void fireDiskSize(const KURL &url);
+
+ void setLazy(bool l, int delay, int rows);
+
+ /*
+ * Deselect all items, set current item, select this item,
+ * and ensure it visible.
+ */
+ void setCurrentItem(KFileItem *item);
+
+ void calcTotalSize();
+
+ /*
+ * Save new view type for future use. It means that SQ_WidgetStack
+ * wants to change view type (for example "list view" => "thumbnail view"),
+ * and will activate an SQ_DirOperator's action, which will change view type.
+ *
+ * See SQ_WidgetStack::raiseWidget() for more.
+ */
+ void prepareView(ViewT);
+
+ KFileView* preparedView();
+
+ void setPreparedView();
+
+ void startOrNotThumbnailUpdate();
+
+ /*
+ * Is current diropertor manages thumbnail view ?
+ */
+ bool isThumbView() const;
+
+ int viewType() const;
+
+ /*
+ * Smart update. Store all file items, reset view,
+ * and transfer all items back.
+ */
+ void smartUpdate();
+
+ /*
+ * Remove ".." item from current view
+ */
+ void removeCdUpItem();
+
+ void stopPreview();
+
+ void setPendingFile(const TQString &p);
+
+ void execute(KFileItem *item);
+
+ void saveConfig();
+
+ void selectOld();
+
+ protected:
+ /*
+ * Reimplement createView() to create custom views.
+ */
+ virtual KFileView* createView(TQWidget *parent, KFile::FileView view);
+
+ private:
+ void itemKill(KFileItem *);
+
+ void executePrivate(KFileItem *);
+
+ void disableSpecificActions(KFileIconView *);
+
+ /*
+ * SQ_DirOperator has context menu, derived from KDirOperator.
+ * This method will change this menu, insert new actions.
+ */
+ void setupActionsMy();
+
+ void clearListers();
+
+ signals:
+ /*
+ * If user clicked on item, and it is archive file,
+ * emit this signal. Normally SQ_WidgetStack will catch it.
+ */
+ void tryUnpack(KFileItem *item);
+
+ /*
+ * Run selected file separately (with default application)
+ */
+ void runSeparately(KFileItem *item);
+
+ public slots:
+ void urlAdded(const KURL &);
+ void urlRemoved(const KURL &);
+
+ /*
+ * Invoked, when current directory has been loaded.
+ */
+ void slotFinishedLoading();
+
+ /*
+ * Change thumbnail size.
+ */
+ void slotSetThumbSize(const TQString&);
+
+ private slots:
+
+ void slotDownloadPercents(int);
+
+ void slotCopyPath();
+ void slotCopyURL();
+
+ void slotEnableFileActions(bool);
+
+ void slotInvokeBrowser();
+ /*
+ * Since KDE 3.4 (or 3.5 ?) it is neccessary to reimplement this slot
+ * to insert our own actions in context menu.
+ */
+ void activatedMenu(const KFileItem *, const TQPoint &pos);
+
+ void slotDownloaderResult(const KURL &);
+
+ void slotSetURL(const KURL &);
+
+ /*
+ * Connected to dirLister()
+ */
+ void slotNewItems(const KFileItemList &);
+ void slotRefreshItems(const KFileItemList &);
+
+ void slotDelayedFinishedLoading();
+
+ void slotFoundMountPoint(const unsigned long&,
+ const unsigned long&,
+ const unsigned long&,
+ const TQString&);
+
+ /*
+ * Edit current item's mimetype (Konqueror-related action).
+ */
+ void slotEditMime();
+
+ void slotPreview();
+
+ void slotDropped(const KFileItem *, TQDropEvent*, const KURL::List&);
+ void slotAddToBasket();
+ void slotAddToDirectoryBasket();
+
+ /*
+ * Execute item. If current clicking policy is "Single click",
+ * single click will execute item, and double click otherwise.
+ */
+ void slotExecutedConst(const KFileItem *item);
+
+ /*
+ * URL entered.
+ */
+ void slotUrlEntered(const KURL&);
+
+ /*
+ * Invoked, when some item has been deleted. We should
+ * remove appropriate thumbnail from pixmap cache.
+ */
+ void slotItemDeleted(KFileItem *);
+
+ void slotUpdateInformation(int,int);
+
+ void slotSelectionChanged();
+
+ void slotCurrentChanged(TQListViewItem *);
+ void slotCurrentChanged(TQIconViewItem *);
+
+ private:
+ typedef TQMap<KURL, KDirLister *> SQ_Listers;
+ SQ_Listers listers;
+
+ /*
+ * Pointer to current view. All view types (such as icon view, list view ...)
+ * are derived from KFileView.
+ */
+ KFileView *fileview;
+
+ /*
+ * Some additional menus.
+ */
+ TDEActionMenu *pADirOperatorMenu, *pAFileActions, *pAImageActions;
+ TDEToggleAction *actionHidden;
+
+ ViewT type;
+ TQTimer *timer_preview;
+ KURL lasturl;
+ bool usenew;
+ TQString m_pending;
+ TDEIO::filesize_t totalSize;
+ KFileItemList oldSelected;
+ KFileItem *oldCurrentItem;
+ SQ_Downloader *down;
+};
+
+inline
+int SQ_DirOperator::viewType() const
+{
+ return static_cast<int>(type);
+}
+
+inline
+bool SQ_DirOperator::isThumbView() const
+{
+ return (type == SQ_DirOperator::TypeThumbs);
+}
+
+inline
+KFileView* SQ_DirOperator::preparedView()
+{
+ return fileview;
+}
+
+inline
+KFileView* SQ_DirOperator::createView(TQWidget *, KFile::FileView)
+{
+ return fileview;
+}
+
+inline
+void SQ_DirOperator::setPendingFile(const TQString &p)
+{
+ m_pending = p;
+}
+
+#endif
diff --git a/src/sq_dirthumbs.cpp b/src/sq_dirthumbs.cpp
new file mode 100644
index 0000000..03e73bc
--- /dev/null
+++ b/src/sq_dirthumbs.cpp
@@ -0,0 +1,104 @@
+/***************************************************************************
+ sq_dirthumbs.cpp - description
+ -------------------
+ begin : ??? Jul 18 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_UTIME_H
+#include <sys/types.h>
+#include <utime.h>
+#endif
+
+#include <tqimage.h>
+#include <tqfileinfo.h>
+#include <tqdatetime.h>
+
+#include <kurl.h>
+#include <kmdcodec.h>
+
+#include "sq_dirthumbs.h"
+#include "sq_thumbnailinfo.h"
+
+SQ_DirThumbs::SQ_DirThumbs() : SQ_Dir()
+{
+ setRoot();
+}
+
+SQ_DirThumbs::~SQ_DirThumbs()
+{}
+
+/*
+ * Save thumbnail to storage.
+ */
+void SQ_DirThumbs::saveThumbnail(const KURL &url, SQ_Thumbnail &thumb)
+{
+ TQString ab = absPath(url);
+
+ if(!thumb.thumbnail.isNull() && needUpdate(ab, thumb.originalTime))
+ {
+ // thumbnail standard tags
+ thumb.thumbnail.setText("Thumb::Image::Width", 0, TQString::number(thumb.w));
+ thumb.thumbnail.setText("Thumb::Image::Height", 0, TQString::number(thumb.h));
+ thumb.thumbnail.setText("Thumb::URI", 0, url.prettyURL());
+ thumb.thumbnail.setText("Thumb::MTime", 0, TQString::number(thumb.originalTime));
+ thumb.thumbnail.setText("Software", 0, "KSquirrel");
+
+ thumb.thumbnail.save(ab, sqdirThumbFormat, sqdirThumbQuality);
+
+#ifdef HAVE_UTIME_H
+ struct utimbuf ut;
+ ut.actime = thumb.originalTime;
+ ut.modtime = thumb.originalTime;
+ utime((const char *)ab, &ut);
+#endif
+ }
+}
+
+TQString SQ_DirThumbs::absPath(const KURL &relurl)
+{
+ KMD5 md5(TQString(TQFile::encodeName(relurl.prettyURL())));
+
+ TQString ext = TQString::fromLatin1(".%1").arg(sqdirThumbFormat);
+
+ return m_orig + TQDir::separator() + TQString(md5.hexDigest()) + ext.lower();
+}
+
+void SQ_DirThumbs::setRoot()
+{
+ m_orig = TQDir::cleanDirPath(homeDirPath() + TQDir::separator() + TQString::fromLatin1(".thumbnails"));
+ TQDir::mkdir(m_orig);
+
+ m_orig = TQDir::cleanDirPath(m_orig + TQDir::separator() + TQString::fromLatin1("normal"));
+ TQDir::mkdir(m_orig);
+}
+
+void SQ_DirThumbs::removeFile(const KURL &url)
+{
+ // determine absolute path and remove file
+ TQFile::remove(absPath(url));
+}
+
+bool SQ_DirThumbs::needUpdate(const TQString &turl, time_t tm)
+{
+ TQFileInfo fthumbpath(turl);
+
+ TQDateTime dt_orig;
+ dt_orig.setTime_t(tm);
+
+ return (dt_orig > fthumbpath.lastModified());
+}
diff --git a/src/sq_dirthumbs.h b/src/sq_dirthumbs.h
new file mode 100644
index 0000000..e59063f
--- /dev/null
+++ b/src/sq_dirthumbs.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ sq_dirthumbs.h - description
+ -------------------
+ begin : ??? Jul 18 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_DIR_THUMBS_H
+#define SQ_DIR_THUMBS_H
+
+#include "sq_dir.h"
+
+struct SQ_Thumbnail;
+
+class SQ_DirThumbs : public SQ_Dir
+{
+ public:
+ SQ_DirThumbs();
+ ~SQ_DirThumbs();
+
+ virtual TQString absPath(const KURL &relurl);
+
+ /*
+ * Save thumbnail to storage.
+ */
+ void saveThumbnail(const KURL &url, SQ_Thumbnail &thumb);
+
+ /*
+ * Remove file from storage
+ */
+ void removeFile(const KURL &url);
+
+ /*
+ * Compare 'last modified' time of 'url'
+ * and thumbnail time.
+ */
+ bool needUpdate(const TQString &turl, time_t tm);
+
+ virtual TQString root() const;
+
+ private:
+ /*
+ * Thumbnail cache will have ~/.thumbnails/normal path
+ */
+ void setRoot();
+
+ private:
+ /*
+ * m_orig to save thumbnails
+ */
+ TQString m_orig;
+};
+
+inline
+TQString SQ_DirThumbs::root() const
+{
+ return m_orig;
+}
+
+#endif
diff --git a/src/sq_downloader.cpp b/src/sq_downloader.cpp
new file mode 100644
index 0000000..e877850
--- /dev/null
+++ b/src/sq_downloader.cpp
@@ -0,0 +1,143 @@
+/***************************************************************************
+ sq_downloader.cpp - description
+ -------------------
+ begin : Fri Jun 07 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tqfile.h>
+
+#include <tdeio/job.h>
+#include <tdefileitem.h>
+#include <tdetempfile.h>
+
+#include "sq_libraryhandler.h"
+#include "sq_downloader.h"
+
+#ifndef KSQUIRREL_PART
+#include "sq_archivehandler.h"
+#endif
+
+#define SQ_PREDOWNLOAD_SIZE 50
+
+SQ_Downloader::SQ_Downloader(TQObject *parent, const char *name) : TQObject(parent, name), job(0), m_error(false)
+{
+ tmp = new KTempFile;
+ tmp->setAutoDelete(true);
+ tmp->close();
+}
+
+SQ_Downloader::~SQ_Downloader()
+{
+ clean();
+
+ delete tmp;
+}
+
+void SQ_Downloader::start(KFileItem *fi)
+{
+ m_error = false;
+ mURL = fi->url();
+
+ emitPercents = false;
+ startTime = TQTime::currentTime();
+ size = 0;
+ totalSize = fi->size();
+
+#ifndef KSQUIRREL_PART
+ nomime = SQ_ArchiveHandler::instance()->findProtocolByMime(fi->mimetype()).isEmpty();
+#else
+ nomime = true;
+#endif
+
+ job = TDEIO::get(mURL, false, false);
+
+ clean();
+
+ continueDownload = false;
+
+ connect(job, TQ_SIGNAL(data(TDEIO::Job *, const TQByteArray &)), this, TQ_SLOT(slotData(TDEIO::Job *, const TQByteArray &)));
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotDataResult(TDEIO::Job *)));
+}
+
+void SQ_Downloader::slotData(TDEIO::Job *job, const TQByteArray &ba)
+{
+ size += ba.size();
+
+ TQFile f(tmp->name());
+
+ if(f.open(IO_WriteOnly | IO_Append))
+ {
+ f.writeBlock(ba);
+ f.close();
+ }
+
+ if(emitPercents || startTime.msecsTo(TQTime::currentTime()) > 1000)
+ {
+ emit percents(size);
+ emitPercents = true;
+ }
+
+ // 50 bytes are enough to determine file type
+ if(size >= SQ_PREDOWNLOAD_SIZE && !continueDownload && totalSize != size)
+ {
+ // cancel download (file type is not supported)
+ SQ_LIBRARY *lib = SQ_LibraryHandler::instance()->libraryForFile(tmp->name());
+
+ if(nomime && !lib)
+ {
+ job->kill(false); // kill job & emit result
+ }
+ else
+ {
+ // nice, we can open this image/archive - continue download
+ continueDownload = true;
+ }
+ }
+}
+
+void SQ_Downloader::slotDataResult(TDEIO::Job *cpjob)
+{
+ job = 0;
+
+ // job error
+ if(cpjob->error() && cpjob->error() != TDEIO::ERR_USER_CANCELED)
+ {
+ m_error = true;
+ emit result(mEmptyURL);
+ }
+ else if(cpjob->error() == TDEIO::ERR_USER_CANCELED) // not supported image/archive type -
+ // emit empty url without errors
+ {
+ emit result(mEmptyURL);
+ }
+ else // supported image type/archive type (no errors or job killed)
+ {
+ emit result(KURL::fromPathOrURL(tmp->name()));
+ }
+}
+
+void SQ_Downloader::clean()
+{
+ TQFile f(tmp->name());
+
+ if(f.open(IO_WriteOnly))
+ f.close();
+}
+
+void SQ_Downloader::kill()
+{
+ if(job) job->kill();
+}
+
+#include "sq_downloader.moc"
diff --git a/src/sq_downloader.h b/src/sq_downloader.h
new file mode 100644
index 0000000..6b91a3f
--- /dev/null
+++ b/src/sq_downloader.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ sq_downloader.h - description
+ -------------------
+ begin : Fri Jun 07 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_DOWNLOADER_H
+#define SQ_DOWNLOADER_H
+
+#include <tqobject.h>
+#include <tqdatetime.h>
+
+#include <kurl.h>
+
+class KFileItem;
+class KTempFile;
+
+namespace TDEIO { class Job; }
+
+class SQ_Downloader : public TQObject
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_Downloader(TQObject *parent = 0, const char *name = 0);
+ ~SQ_Downloader();
+
+ void start(KFileItem *fi);
+
+ bool error() const;
+
+ void clean();
+
+ void kill();
+
+ signals:
+ void result(const KURL &);
+ void percents(int);
+
+ private slots:
+ void slotData(TDEIO::Job *job, const TQByteArray &data);
+ void slotDataResult(TDEIO::Job *);
+
+ private:
+ TDEIO::Job *job;
+ KURL mEmptyURL, mURL;
+ KTempFile *tmp;
+ TDEIO::filesize_t totalSize, size;
+ bool continueDownload;
+ bool nomime;
+ bool m_error, m_lightmode;
+ TQTime startTime;
+ bool emitPercents;
+};
+
+inline
+bool SQ_Downloader::error() const
+{
+ return m_error;
+}
+
+#endif
diff --git a/src/sq_dragprovider.cpp b/src/sq_dragprovider.cpp
new file mode 100644
index 0000000..6ae0ada
--- /dev/null
+++ b/src/sq_dragprovider.cpp
@@ -0,0 +1,183 @@
+/***************************************************************************
+ sq_dragprovider.cpp - description
+ -------------------
+ begin : ??? Sep 17 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tqwidget.h>
+#include <tqdragobject.h>
+#include <tqpainter.h>
+#include <tqpixmap.h>
+#include <tqfontmetrics.h>
+#include <tqtooltip.h>
+#include <tqvaluevector.h>
+#include <tqsize.h>
+
+#include <kstringhandler.h>
+#include <kurldrag.h>
+#include <tdelocale.h>
+#include <kurl.h>
+
+#include <algorithm>
+
+#include "sq_dragprovider.h"
+#include "sq_iconloader.h"
+#include "sq_filethumbviewitem.h"
+#include "sq_thumbnailsize.h"
+
+#define SQ_THUMB_SIZE 96
+
+SQ_DragProvider * SQ_DragProvider::m_inst = 0;
+
+SQ_DragProvider::SQ_DragProvider(TQObject *parent) : TQObject(parent), source(0)
+{
+ m_inst = this;
+}
+
+SQ_DragProvider::~SQ_DragProvider()
+{}
+
+void SQ_DragProvider::setParams(TQWidget *_source, const KFileItemList &_files, SourceType tp)
+{
+ source = _source;
+ files = _files;
+ type = tp;
+}
+
+void SQ_DragProvider::start()
+{
+ if(!source)
+ return;
+
+ int count = files.count();
+
+ if(!count)
+ return;
+
+ KURL::List urls;
+ KFileItem *fi;
+ SQ_FileThumbViewItem *kfi;
+ TQStringList names;
+ int capas = type == Thumbnails ? 2 : 10; // 2 thumbnails or 10 file names
+ int _capas = capas;
+ TQValueVector<TQPixmap> pixmaps;
+ TQPixmap *pix;
+ int pixw = 0, pixh = 0;
+ const int margin = 2;
+
+ KFileItem *first = files.first();
+
+ KFileItemListIterator it(files);
+
+ while((fi = it.current()))
+ {
+ urls.append(fi->url());
+
+ if(_capas)
+ {
+ if(type == Thumbnails)
+ {
+ kfi = reinterpret_cast<SQ_FileThumbViewItem *>(fi->extraData(source));
+
+ if(kfi && (pix = kfi->pixmap()))
+ {
+ pixmaps.append(*pix);
+
+ if(!pixw || !pixh)
+ {
+ pixw = pix->width();
+ pixh = pix->height();
+
+ if(pixw > SQ_THUMB_SIZE)
+ {
+ TQSize sz(pixw, pixh);
+ sz.scale(SQ_THUMB_SIZE, SQ_THUMB_SIZE, TQSize::ScaleMin);
+ pixw = sz.width();
+ pixh = sz.height();
+ }
+ }
+ }
+ }
+ else
+ names.append(KStringHandler::csqueeze(fi->name()));
+
+ --_capas;
+ }
+
+ ++it;
+ }
+
+ TQDragObject *drag = new KURLDrag(urls, source);
+ TQPixmap dragIcon;
+
+ if(urls.count() > 1)
+ dragIcon = SQ_IconLoader::instance()->loadIcon("application-vnd.tde.tdemultiple", TDEIcon::Desktop, TDEIcon::SizeSmall);
+ else
+ dragIcon = first->pixmap(TDEIcon::SizeSmall);
+
+ const int flags = TQt::AlignAuto|TQt::AlignVCenter|TQt::ShowPrefix;
+ TQPixmap dragPixmap;
+ TQString text;
+
+ // construct text
+ if(type == Icons)
+ {
+ TQStringList::iterator sEnd = names.end();
+ for(TQStringList::iterator sit = names.begin();sit != sEnd;++sit)
+ text = text + *sit + '\n';
+ }
+
+ text += TQString::fromLatin1("%1 %2").arg(i18n("Total")).arg(i18n("1 file", "%n files", count));
+
+ TQFontMetrics ms(source->font());
+ TQRect r = ms.boundingRect(0, 0, 1, 1, flags, text);
+
+ // resize pixmap
+ if(type == Icons)
+ dragPixmap.resize(r.width(), r.height());
+ else
+ dragPixmap.resize(std::max(r.width(), pixw)+margin*2, r.height()+margin+(pixh+margin)*pixmaps.count());
+
+ TQPalette pal = TQToolTip::palette();
+ TQPainter p;
+ p.begin(&dragPixmap);
+
+ // draw frame
+ p.setPen(TQPen(pal.color(TQPalette::Active, TQColorGroup::Text)));
+ p.setBrush(TQBrush(pal.color(TQPalette::Active, TQColorGroup::Background)));
+ p.drawRect(dragPixmap.rect());
+
+ // draw file names
+ if(type == Icons)
+ p.drawText(dragPixmap.rect(), flags, text);
+ else // or thumbnails
+ {
+ int y = margin;
+ TQValueVector<TQPixmap>::iterator itEnd = pixmaps.end();
+
+ for(TQValueVector<TQPixmap>::iterator it = pixmaps.begin();it != itEnd;++it)
+ {
+ p.drawPixmap(TQRect((dragPixmap.width()-pixw)/2, y, pixw, pixh), *it);
+ y = y + pixh + margin;
+ }
+
+ p.drawText(0, y, dragPixmap.width(), dragPixmap.height()-y, flags, text);
+ }
+
+ p.end();
+
+ // finally, setup drag object
+ drag->setPixmap(dragPixmap, TQPoint(16, -16));
+ drag->dragCopy();
+}
diff --git a/src/sq_dragprovider.h b/src/sq_dragprovider.h
new file mode 100644
index 0000000..5d9d08f
--- /dev/null
+++ b/src/sq_dragprovider.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+ sq_dragprovider.h - description
+ -------------------
+ begin : ??? Sep 17 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_DRAGPROVIDER_H
+#define SQ_DRAGPROVIDER_H
+
+#include <tqobject.h>
+
+#include <tdefileitem.h>
+
+class TQWidget;
+
+/*
+ * Class for making drag operations easier.
+ *
+ * All fileview types (Details, Thumbnails...) use an instance of
+ * this class in startDrag() method.
+ */
+
+class SQ_DragProvider : public TQObject
+{
+ public:
+ enum SourceType { Icons, Thumbnails };
+
+ SQ_DragProvider(TQObject *parent);
+ ~SQ_DragProvider();
+
+ /*
+ * Set drag source (fileview), file list and fileview type.
+ */
+ void setParams(TQWidget *_source, const KFileItemList &_files, SourceType tp);
+
+ /*
+ * Start drag operation.
+ */
+ void start();
+
+ static SQ_DragProvider* instance() { return m_inst; }
+
+ private:
+ TQWidget *source;
+ KFileItemList files;
+ SourceType type;
+
+ static SQ_DragProvider *m_inst;
+};
+
+#endif
diff --git a/src/sq_errorstring.cpp b/src/sq_errorstring.cpp
new file mode 100644
index 0000000..f762ee3
--- /dev/null
+++ b/src/sq_errorstring.cpp
@@ -0,0 +1,58 @@
+/***************************************************************************
+ sq_errorstring.cpp - description
+ -------------------
+ begin : ??? ??? 26 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_errorstring.h"
+
+#include <ksquirrel-libs/error.h>
+
+SQ_ErrorString * SQ_ErrorString::m_instance = 0;
+
+SQ_ErrorString::SQ_ErrorString(TQObject *parent) : TQObject(parent)
+{
+ m_instance = this;
+
+ // fill map with translated messages
+ messages.insert(SQE_OK, TQString::fromLatin1("OK"));
+ messages.insert(SQE_R_NOFILE, i18n("cannot open file for reading"));
+ messages.insert(SQE_R_BADFILE, i18n("file corrupted"));
+ messages.insert(SQE_R_NOMEMORY, i18n("no memory"));
+ messages.insert(SQE_R_NOTSUPPORTED, i18n("file type not supported"));
+ messages.insert(SQE_R_WRONGDIM, i18n("wrong image dimensions"));
+ messages.insert(SQE_W_NOFILE, i18n("cannot open file for writing"));
+ messages.insert(SQE_W_NOTSUPPORTED, i18n("write feature is not supported"));
+ messages.insert(SQE_W_ERROR, i18n("write error (check free space)"));
+ messages.insert(SQE_W_WRONGPARAMS, i18n("wrong parameters"));
+ messages.insert(SQE_NOTFINISHED, i18n("Editing process is not finished yet"));
+}
+
+SQ_ErrorString::~SQ_ErrorString()
+{}
+
+// Get string by error code.
+TQString SQ_ErrorString::string(const int code)
+{
+ return messages[code];
+}
+
+TQString SQ_ErrorString::stringSN(const int code)
+{
+ return messages[code] + '\n';
+}
diff --git a/src/sq_errorstring.h b/src/sq_errorstring.h
new file mode 100644
index 0000000..400451d
--- /dev/null
+++ b/src/sq_errorstring.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ sq_errorstring.h - description
+ -------------------
+ begin : ??? ??? 26 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_ERRORSTRING_H
+#define SQ_ERRORSTRING_H
+
+#include <tqmap.h>
+#include <tqobject.h>
+
+#include <tdelocale.h>
+
+#define SQE_NOTFINISHED 10000
+
+/*
+ * Class SQ_ErrorString will return translated string representation of
+ * error code.
+ */
+
+class SQ_ErrorString : public TQObject
+{
+ public:
+ SQ_ErrorString(TQObject *parent = 0);
+ ~SQ_ErrorString();
+
+ /*
+ * Get string representation of error.
+ */
+ TQString string(const int code);
+
+ /*
+ * string() + "\n"
+ */
+ TQString stringSN(const int code);
+
+ static SQ_ErrorString* instance() { return m_instance; }
+
+ private:
+ TQMap<int, TQString> messages;
+ static SQ_ErrorString *m_instance;
+};
+
+#endif
diff --git a/src/sq_externaltool.cpp b/src/sq_externaltool.cpp
new file mode 100644
index 0000000..4f6c752
--- /dev/null
+++ b/src/sq_externaltool.cpp
@@ -0,0 +1,245 @@
+/***************************************************************************
+ sq_externaltool.cpp - description
+ -------------------
+ begin : ??? ??? 12 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqfile.h>
+
+#include <kstringhandler.h>
+#include <tdelocale.h>
+#include <kicontheme.h>
+#include <kstandarddirs.h>
+#include <tdeprocess.h>
+#include <tdemessagebox.h>
+
+#include "sq_iconloader.h"
+#include "sq_externaltool.h"
+#include "sq_popupmenu.h"
+#include "sq_config.h"
+
+SQ_ExternalTool * SQ_ExternalTool::m_instance = 0;
+
+Tool::Tool()
+{}
+
+Tool::Tool(const TQString &pix, const TQString &nam, const TQString &com)
+{
+ icon = pix;
+ name = nam;
+ command = com;
+}
+
+SQ_ExternalTool::SQ_ExternalTool(TQObject *parent) : TQObject(parent), TQValueVector<Tool>()
+{
+ m_instance = this;
+ menu = new SQ_PopupMenu(0, "External tools");
+
+ connect(menu, TQ_SIGNAL(aboutToShow()), this, TQ_SLOT(slotAboutToShowMenu()));
+ connect(menu, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotActivateTool(int)));
+
+ TQString str, tmp;
+
+ SQ_Config::instance()->setGroup("External tools");
+
+ TQStringList names = SQ_Config::instance()->readListEntry("names");
+ TQStringList commands = SQ_Config::instance()->readListEntry("commands");
+ TQStringList icons = SQ_Config::instance()->readListEntry("icons");
+
+ for(TQStringList::iterator it_n = names.begin(),it_c = commands.begin(),it_i = icons.begin();
+ it_n != names.end() || it_c != commands.end() || it_i != icons.end();
+ ++it_n, ++it_c, ++it_i)
+ {
+ append(Tool(*it_i, *it_n, *it_c));
+ }
+}
+
+SQ_ExternalTool::~SQ_ExternalTool()
+{
+ delete menu;
+}
+
+TQString SQ_ExternalTool::toolPixmap(const int i)
+{
+ return (*this)[i].icon;
+}
+
+TQString SQ_ExternalTool::toolName(const int i)
+{
+ return (*this)[i].name;
+}
+
+TQString SQ_ExternalTool::toolCommand(const int i)
+{
+ return (*this)[i].command;
+}
+
+/*
+ * Recreate current popop menu.
+ */
+SQ_PopupMenu* SQ_ExternalTool::newPopupMenu()
+{
+ int id;
+
+ // clear menu
+ menu->clear();
+
+ menu->insertTitle(i18n("No file selected"));
+
+ // construct new menu
+ for(unsigned int i = 0;i < count();i++)
+ {
+ id = menu->insertItem(SQ_IconLoader::instance()->loadIcon(toolPixmap(i), TDEIcon::Desktop, TDEIcon::SizeSmall), toolName(i));
+ menu->setItemParameter(id, i);
+ }
+
+ return menu;
+}
+
+/*
+ * Get current popup menu.
+ */
+SQ_PopupMenu* SQ_ExternalTool::constPopupMenu() const
+{
+ return menu;
+}
+
+/*
+ * Write tools to config file
+ */
+void SQ_ExternalTool::writeEntries()
+{
+ // no tools ?
+ if(!count()) return;
+
+ TQString num;
+
+ // delete old group with old items
+ SQ_Config::instance()->deleteGroup("External tools");
+ SQ_Config::instance()->setGroup("External tools");
+ TQStringList names, icons, commands;
+
+ // write items in config file
+ for(TQValueVector<Tool>::iterator it = begin();it != end();++it)
+ {
+ names.append((*it).name);
+ icons.append((*it).icon);
+ commands.append((*it).command);
+ }
+
+ SQ_Config::instance()->writeEntry("names", names);
+ SQ_Config::instance()->writeEntry("commands", commands);
+ SQ_Config::instance()->writeEntry("icons", icons);
+}
+
+/*
+ * Invoked, when user executed popup menu with external tools.
+ * This slot will do some useful stuff.
+ */
+void SQ_ExternalTool::slotAboutToShowMenu()
+{
+ if(!items.count())
+ {
+ menu->changeTitle(i18n("No file selected"));
+ return;
+ }
+
+ KFileItem *item = items.first();
+
+ if(!item)
+ {
+ menu->changeTitle(i18n("No file selected"));
+ return;
+ }
+
+ // make title shorter
+ TQString file = KStringHandler::rsqueeze(item->name(), 30);
+
+ // finally, change title
+ TQString final = (items.count() == 1 || items.count() == 0) ? file : (file + TQString::fromLatin1(" (+%1)").arg(items.count()-1));
+ menu->changeTitle(final);
+}
+
+void SQ_ExternalTool::slotActivateTool(int id)
+{
+ KURL::List list;
+
+ if(items.isEmpty()) return;
+
+ int index = menu->itemParameter(id);
+
+ KFileItem *f = items.first();
+
+ while(f)
+ {
+ list.append(f->url());
+ f = items.next();
+ }
+
+ items.clear();
+
+ if(list.empty()) return;
+
+ KShellProcess proc;
+
+ // get appropriate tool
+ Tool *tool = &at(index);
+ TQString comm = tool->command;
+
+ int per_f = comm.contains("%f");
+ int per_F = comm.contains("%F");
+
+ // %f = single file
+ // %F = multiple files
+ if(per_f && per_F)
+ {
+ KMessageBox::error(0, i18n("Command cannot contain both \"%f\" and \"%F\""), i18n("Error processing command"));
+ return;
+ }
+ else if(!per_f && !per_F)
+ {
+ KMessageBox::error(0, i18n("Command should contain \"%f\" or \"%F\""), i18n("Error processing command"));
+ return;
+ }
+ else if(per_f)
+ {
+ KURL u = list.first();
+ comm.replace("%f", KShellProcess::quote(u.isLocalFile() ? u.path() : u.prettyURL()));
+ proc << comm;
+ }
+ else
+ {
+ TQString files;
+
+ KURL::List::iterator itEnd = list.end();
+
+ for(KURL::List::iterator it = list.begin();it != itEnd;++it)
+ {
+ files.append(KShellProcess::quote((*it).isLocalFile() ? (*it).path() : (*it).prettyURL()));
+ files.append(" ");
+ }
+
+ comm.replace("%F", files);
+ proc << comm;
+ }
+
+ // start process
+ proc.start(TDEProcess::DontCare);
+}
+
+#include "sq_externaltool.moc"
diff --git a/src/sq_externaltool.h b/src/sq_externaltool.h
new file mode 100644
index 0000000..12e6858
--- /dev/null
+++ b/src/sq_externaltool.h
@@ -0,0 +1,104 @@
+/***************************************************************************
+ sq_externaltool.h - description
+ -------------------
+ begin : ??? ??? 12 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_EXTERNALTOOL_H
+#define SQ_EXTERNALTOOL_H
+
+#include <tqstring.h>
+#include <tqobject.h>
+#include <tqvaluevector.h>
+
+#include <tdefileitem.h>
+
+class SQ_PopupMenu;
+
+struct Tool
+{
+ Tool();
+ Tool(const TQString &, const TQString &, const TQString &);
+
+ TQString name, command;
+ TQString icon;
+};
+
+/*
+ * Class which manages external tools. It store all available external tools
+ * in memory, and create popup menu where external tools been inserted.
+ */
+
+class SQ_ExternalTool : public TQObject, public TQValueVector<Tool>
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_ExternalTool(TQObject *parent = 0);
+ ~SQ_ExternalTool();
+
+ /*
+ * Get pixmap, name or command of external tool.
+ */
+ TQString toolPixmap(const int i);
+ TQString toolName(const int i);
+ TQString toolCommand(const int i);
+
+ void setItems(const KFileItemList &);
+
+ /*
+ * Recreate current popop menu.
+ */
+ SQ_PopupMenu* newPopupMenu();
+
+ /*
+ * Get current popup menu.
+ */
+ SQ_PopupMenu* constPopupMenu() const;
+
+ /*
+ * Write tools to config file as TQStringLists
+ */
+ void writeEntries();
+
+ static SQ_ExternalTool* instance() { return m_instance; }
+
+ private slots:
+
+ /*
+ * Invoked, when user executed popup menu with external tools.
+ * This slot will do some useful stuff.
+ */
+ void slotAboutToShowMenu();
+ void slotActivateTool(int);
+
+ private:
+ /*
+ * Popup menu with all tools.
+ */
+ SQ_PopupMenu *menu;
+
+ KFileItemList items;
+
+ static SQ_ExternalTool *m_instance;
+};
+
+inline
+void SQ_ExternalTool::setItems(const KFileItemList &itms)
+{
+ items = itms;
+}
+
+#endif
diff --git a/src/sq_externaltools.ui b/src/sq_externaltools.ui
new file mode 100644
index 0000000..fa28d1a
--- /dev/null
+++ b/src/sq_externaltools.ui
@@ -0,0 +1,463 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_ExternalTools</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_ExternalTools</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>562</width>
+ <height>419</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Adjust external tools</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>65</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton" row="3" column="2" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>pushCancel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="3" column="1">
+ <property name="name">
+ <cstring>pushOK</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="Line" row="2" column="0" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQListView" row="0" column="0" rowspan="2" colspan="3">
+ <column>
+ <property name="text">
+ <string>Pixmap</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Command</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>listTools</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="resizePolicy">
+ <enum>Manual</enum>
+ </property>
+ <property name="selectionMode">
+ <enum>Single</enum>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ <property name="defaultRenameAction">
+ <enum>Reject</enum>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>&lt;b&gt;Command&lt;/b&gt; can contain &lt;ul&gt;&lt;li&gt;%f: one file&lt;li&gt;%F: multiple files&lt;/ul&gt;</string>
+ </property>
+ </widget>
+ <spacer row="1" column="3">
+ <property name="name">
+ <cstring>spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>130</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLayoutWidget" row="0" column="3">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushNew</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>New tool</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pushDelete</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoRepeat">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Delete</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="2" column="0">
+ <property name="name">
+ <cstring>pushClearAll</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Clear All</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>groupBox4</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushToolUp</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoRepeat">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Move tool up</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pushToolDown</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoRepeat">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Move tool down</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>groupBox3_2</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushHelp</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushOK</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ExternalTools</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>pushCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ExternalTools</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>listTools</sender>
+ <signal>rightButtonClicked(TQListViewItem*,const TQPoint&amp;,int)</signal>
+ <receiver>SQ_ExternalTools</receiver>
+ <slot>slotToolRenameRequest(TQListViewItem*,const TQPoint&amp;,int)</slot>
+ </connection>
+ <connection>
+ <sender>pushToolUp</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ExternalTools</receiver>
+ <slot>slotToolUp()</slot>
+ </connection>
+ <connection>
+ <sender>pushToolDown</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ExternalTools</receiver>
+ <slot>slotToolDown()</slot>
+ </connection>
+ <connection>
+ <sender>pushNew</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ExternalTools</receiver>
+ <slot>slotNewTool()</slot>
+ </connection>
+ <connection>
+ <sender>pushClearAll</sender>
+ <signal>clicked()</signal>
+ <receiver>listTools</receiver>
+ <slot>clear()</slot>
+ </connection>
+ <connection>
+ <sender>pushDelete</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ExternalTools</receiver>
+ <slot>slotToolClear()</slot>
+ </connection>
+ <connection>
+ <sender>pushHelp</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ExternalTools</receiver>
+ <slot>slotHelp()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>listTools</tabstop>
+ <tabstop>pushNew</tabstop>
+ <tabstop>pushDelete</tabstop>
+ <tabstop>pushClearAll</tabstop>
+ <tabstop>pushToolUp</tabstop>
+ <tabstop>pushToolDown</tabstop>
+ <tabstop>pushHelp</tabstop>
+ <tabstop>pushOK</tabstop>
+ <tabstop>pushCancel</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">sq_externaltool.h</include>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="global" impldecl="in implementation">kicondialog.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="global" impldecl="in implementation">tqwhatsthis.h</include>
+ <include location="global" impldecl="in implementation">tdeglobal.h</include>
+ <include location="global" impldecl="in implementation">kiconloader.h</include>
+ <include location="local" impldecl="in implementation">sq_externaltools.ui.h</include>
+</includes>
+<slots>
+ <slot>slotNewTool()</slot>
+ <slot>slotToolClear()</slot>
+ <slot>slotToolUp()</slot>
+ <slot>slotToolDown()</slot>
+ <slot returnType="int">start()</slot>
+ <slot>slotToolRenameRequest( TQListViewItem * item, const TQPoint &amp;, int pos )</slot>
+ <slot>slotHelp()</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_externaltools.ui.h b/src/sq_externaltools.ui.h
new file mode 100644
index 0000000..c1a9f04
--- /dev/null
+++ b/src/sq_externaltools.ui.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+void SQ_ExternalTools::init()
+{
+ listTools->setSorting(-1);
+
+ TQListViewItem *itemafter = 0L, *item;
+
+ for(TQValueVector<Tool>::iterator it = SQ_ExternalTool::instance()->begin();it != SQ_ExternalTool::instance()->end();++it)
+ {
+ if(itemafter)
+ item = new TQListViewItem(listTools, itemafter, TQString(), (*it).name, (*it).command, (*it).icon);
+ else
+ item = new TQListViewItem(listTools, TQString(), (*it).name, (*it).command, (*it).icon);
+
+ item->setPixmap(0, SQ_IconLoader::instance()->loadIcon(item->text(3), TDEIcon::Desktop, 16));
+ itemafter = item;
+
+ item->setRenameEnabled(1, true);
+ item->setRenameEnabled(2, true);
+ item->setMultiLinesEnabled(false);
+
+ listTools->insertItem(item);
+ }
+
+ pushToolUp->setPixmap(SQ_IconLoader::instance()->loadIcon("move_task_up", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ pushToolDown->setPixmap(SQ_IconLoader::instance()->loadIcon("move_task_down", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ pushNew->setPixmap(SQ_IconLoader::instance()->loadIcon("document-new", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ pushDelete->setPixmap(SQ_IconLoader::instance()->loadIcon("edit-delete", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ pushClearAll->setPixmap(SQ_IconLoader::instance()->loadIcon("edittrash", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ pushHelp->setPixmap(SQ_IconLoader::instance()->loadIcon("help", TDEIcon::Desktop, TDEIcon::SizeSmall));
+
+ listTools->setCurrentItem(listTools->firstChild());
+ listTools->clearSelection();
+ listTools->setSelected(listTools->currentItem(), true);
+}
+
+void SQ_ExternalTools::slotNewTool()
+{
+ TQListViewItem *itemafter = listTools->lastItem(), *item;
+
+ if(itemafter)
+ item = new TQListViewItem(listTools, itemafter, "", "Tool name", "tool_executable %f", "");
+ else
+ item = new TQListViewItem(listTools, "", "Tool name", "tool_executable %f", "");
+
+ item->setRenameEnabled(1, true);
+ item->setRenameEnabled(2, true);
+ item->setMultiLinesEnabled(false);
+ listTools->insertItem(item);
+ item->startRename(1);
+}
+
+void SQ_ExternalTools::slotToolClear()
+{
+ TQListViewItem *item = listTools->currentItem();
+
+ if(!item) return;
+
+ listTools->takeItem(item);
+
+ item = listTools->currentItem();
+
+ if(item)
+ listTools->setSelected(item, true);
+}
+
+void SQ_ExternalTools::slotToolUp()
+{
+ TQListViewItem *item = listTools->currentItem();
+
+ if(!item) return;
+
+ TQListViewItem *itemafter = item->itemAbove();
+
+ if(!itemafter) return;
+
+ itemafter->moveItem(item);
+}
+
+void SQ_ExternalTools::slotToolDown()
+{
+ TQListViewItem *item = listTools->currentItem();
+
+ if(!item) return;
+
+ TQListViewItem *itemafter = item->itemBelow();
+
+ if(!itemafter) return;
+
+ item->moveItem(itemafter);
+
+}
+
+int SQ_ExternalTools::start()
+{
+ int result = exec();
+
+ if(result == TQDialog::Accepted)
+ {
+ TQListViewItem *cur = listTools->firstChild();
+
+ SQ_ExternalTool::instance()->clear();
+
+ for(;cur;cur = cur->itemBelow())
+ {
+ SQ_ExternalTool::instance()->append(Tool(cur->text(3), cur->text(1), cur->text(2)));
+ }
+ }
+
+ return result;
+}
+
+void SQ_ExternalTools::slotToolRenameRequest( TQListViewItem *item, const TQPoint &, int pos )
+{
+ if(!item || pos == -1)
+ return;
+
+ if(pos > 0)
+ item->startRename(pos);
+ else
+ {
+ TDEIconDialog dialog(TDEGlobal::iconLoader());
+ dialog.setup(TDEIcon::Desktop, TDEIcon::Application, true, 16);
+ TQString result = dialog.openDialog();
+
+ if(!result.isEmpty())
+ {
+ item->setPixmap(0, SQ_IconLoader::instance()->loadIcon(result, TDEIcon::Desktop, 16));
+ item->setText(3, result);
+ }
+ }
+}
+
+void SQ_ExternalTools::slotHelp()
+{
+ TQWhatsThis::display(tr2i18n("<b>Command</b> can contain <ul><li>%f: one file<li>%F: multiple files</ul>"));
+}
diff --git a/src/sq_filedetailview.cpp b/src/sq_filedetailview.cpp
new file mode 100644
index 0000000..932715d
--- /dev/null
+++ b/src/sq_filedetailview.cpp
@@ -0,0 +1,228 @@
+/***************************************************************************
+ sq_filedetailview.cpp - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqheader.h>
+#include <tqcursor.h>
+
+#include <tdepopupmenu.h>
+#include <tdefileitem.h>
+#include <tdeglobalsettings.h>
+#include <konq_filetip.h>
+
+#include "ksquirrel.h"
+#include "sq_config.h"
+#include "sq_iconloader.h"
+#include "sq_filedetailview.h"
+#include "sq_widgetstack.h"
+#include "sq_diroperator.h"
+#include "sq_dragprovider.h"
+
+SQ_FileListViewItem::SQ_FileListViewItem(TQListView *parent, KFileItem *fi) : KFileListViewItem(parent, fi)
+{}
+
+SQ_FileListViewItem::SQ_FileListViewItem(TQListView *parent, const TQString &text, const TQPixmap &icon, KFileItem *fi)
+ : KFileListViewItem(parent, text, icon, fi)
+{}
+
+SQ_FileListViewItem::~SQ_FileListViewItem()
+{}
+
+SQ_FileDetailView::SQ_FileDetailView(TQWidget* parent, const char* name)
+ : KFileDetailView(parent, name)
+{
+ // pixmap for directory item
+ dirPix = SQ_IconLoader::instance()->loadIcon("folder", TDEIcon::Desktop, TDEIcon::SizeSmall);
+
+ toolTip = new KonqFileTip(this);
+ slotResetToolTip();
+
+ disconnect(this, TQ_SIGNAL(onViewport()), this, 0);
+ disconnect(this, TQ_SIGNAL(onItem(TQListViewItem *)), this, 0);
+ connect(this, TQ_SIGNAL(onViewport()), this, TQ_SLOT(slotRemoveToolTip()));
+ connect(this, TQ_SIGNAL(onItem(TQListViewItem *)), this, TQ_SLOT(slotShowToolTip(TQListViewItem *)));
+}
+
+SQ_FileDetailView::~SQ_FileDetailView()
+{
+ slotRemoveToolTip();
+}
+
+void SQ_FileDetailView::slotResetToolTip()
+{
+ SQ_Config::instance()->setGroup("Fileview");
+
+ toolTip->setOptions(true,
+ SQ_Config::instance()->readBoolEntry("tooltips_preview", false),
+ SQ_Config::instance()->readNumEntry("tooltips_lines", 6));
+}
+
+// Show extended tooltip for item under mouse cursor
+void SQ_FileDetailView::slotShowToolTip(TQListViewItem *item)
+{
+ SQ_Config::instance()->setGroup("Fileview");
+
+ if(!SQ_Config::instance()->readBoolEntry("tooltips", false) ||
+ (!KSquirrel::app()->isActiveWindow() && SQ_Config::instance()->readBoolEntry("tooltips_inactive", true)))
+ return;
+
+ // remove previous tootip and stop timer
+ slotRemoveToolTip();
+
+ KFileListViewItem *fitem = dynamic_cast<KFileListViewItem *>(item);
+
+ if(!fitem) return;
+
+ KFileItem *f = fitem->fileInfo();
+
+ if(f) toolTip->setItem(f, fitem->rect(), fitem->pixmap(0));
+}
+
+bool SQ_FileDetailView::eventFilter(TQObject *o, TQEvent *e)
+{
+ if(o == viewport() || o == this)
+ {
+ int type = e->type();
+
+ if(type == TQEvent::Leave || type == TQEvent::FocusOut || type == TQEvent::Hide)
+ slotRemoveToolTip();
+ }
+
+ return KFileDetailView::eventFilter(o, e);
+}
+
+/*
+ * Remove tootip.
+ */
+void SQ_FileDetailView::slotRemoveToolTip()
+{
+ toolTip->setItem(0);
+}
+
+/*
+ * Reimplement insertItem() to enable/disable inserting
+ * directories (depends on current settings).
+ */
+void SQ_FileDetailView::insertItem(KFileItem *i)
+{
+ SQ_Config::instance()->setGroup("Fileview");
+
+ // directores disabled ?
+ if(i->isDir() && SQ_Config::instance()->readBoolEntry("disable_dirs", false))
+ return;
+
+ // add new item
+ setUpdatesEnabled(false);
+ SQ_FileListViewItem *item = new SQ_FileListViewItem(this, i);
+
+ initItem(item, i);
+ setUpdatesEnabled(true);
+
+ i->setExtraData(this, item);
+}
+
+/*
+ * Internal. Set item's sorting key.
+ */
+void SQ_FileDetailView::initItem(SQ_FileListViewItem *item, const KFileItem *i)
+{
+ // determine current sorting type
+ TQDir::SortSpec spec = KFileView::sorting();
+
+ if(spec & TQDir::Time)
+ item->setKey(sortingKey(i->time(TDEIO::UDS_MODIFICATION_TIME), i->isDir(), spec));
+ else if(spec & TQDir::Size)
+ item->setKey(sortingKey(i->size(), i->isDir(), spec));
+ else
+ item->setKey(sortingKey(i->text(), i->isDir(), spec));
+}
+
+/*
+ * On double click execute item or
+ * invoke default browser in current url.
+ */
+void SQ_FileDetailView::contentsMouseDoubleClickEvent(TQMouseEvent *e)
+{
+ TQPoint vp = contentsToViewport(e->pos());
+
+ TQListViewItem *item = itemAt(vp);
+
+ emit TQListView::doubleClicked(item);
+
+ int col = item ? header()->mapToLogical(header()->cellAt(vp.x())) : -1;
+
+ // double click on item
+ if(item)
+ emit doubleClicked(item, e->globalPos(), col);
+
+ // double click was in viewport, let's invoke browser
+ else
+ emit invokeBrowser();
+}
+
+// Accept dragging
+void SQ_FileDetailView::dragEnterEvent(TQDragEnterEvent *e)
+{
+ e->accept(true);
+}
+
+/*
+ * Insert ".." item.
+ */
+void SQ_FileDetailView::insertCdUpItem(const KURL &base)
+{
+ static const TQString &dirup = TDEGlobal::staticQString("..");
+
+ KFileItem *fi = new KFileItem(base.upURL(), "inode/directory", S_IFDIR);
+
+ SQ_FileListViewItem *item = new SQ_FileListViewItem(this, dirup, dirPix, fi);
+
+ item->setSelectable(false);
+ item->setKey(sortingKey("..", true, TQDir::Name|TQDir::DirsFirst));
+
+ fi->setExtraData(this, item);
+}
+
+/*
+ * Clear current view and insert "..".
+ */
+void SQ_FileDetailView::clearView()
+{
+ // call default clearing method
+ KFileDetailView::clearView();
+
+ // insert ".."
+ insertCdUpItem(SQ_WidgetStack::instance()->url());
+}
+
+void SQ_FileDetailView::startDrag()
+{
+ SQ_Config::instance()->setGroup("Fileview");
+
+ if(SQ_Config::instance()->readBoolEntry("drag", true))
+ {
+ SQ_DragProvider::instance()->setParams(this, *KFileView::selectedItems(), SQ_DragProvider::Icons);
+ SQ_DragProvider::instance()->start();
+ }
+ else
+ KFileDetailView::startDrag();
+}
+
+#include "sq_filedetailview.moc"
diff --git a/src/sq_filedetailview.h b/src/sq_filedetailview.h
new file mode 100644
index 0000000..44a500f
--- /dev/null
+++ b/src/sq_filedetailview.h
@@ -0,0 +1,119 @@
+/***************************************************************************
+ sq_filedetailview.h - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_FILEDETAILVIEW_H
+#define SQ_FILEDETAILVIEW_H
+
+#include <tdefiledetailview.h>
+
+class KonqFileTip;
+
+/*
+ * SQ_FileDetailView represents detailed view in filemanager.
+ */
+
+/*
+ * SQ_FileListViewItem represents one item in detaild view.
+ */
+class SQ_FileListViewItem : public KFileListViewItem
+{
+ public:
+ SQ_FileListViewItem(TQListView *parent, KFileItem *fi);
+ SQ_FileListViewItem(TQListView *parent, const TQString &text, const TQPixmap &icon, KFileItem *fi);
+ ~SQ_FileListViewItem();
+
+ protected:
+ /*
+ * Reimplement paintFocus() to ignore painting focus.
+ */
+ virtual void paintFocus(TQPainter *, const TQColorGroup &, const TQRect &)
+ {}
+};
+
+class SQ_FileDetailView : public KFileDetailView
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_FileDetailView(TQWidget* parent, const char* name);
+ ~SQ_FileDetailView();
+
+ /*
+ * Reimplement insertItem() to enable/disable inserting
+ * directories (depends on current settings).
+ */
+ virtual void insertItem(KFileItem *i);
+
+ /*
+ * Clear current view and insert "..".
+ */
+ virtual void clearView();
+
+ /*
+ * Insert ".." item.
+ */
+ void insertCdUpItem(const KURL &baseurl);
+
+ protected:
+ /*
+ * Internal. Set item's sorting key.
+ */
+ void initItem(SQ_FileListViewItem *item, const KFileItem *i);
+
+ virtual void startDrag();
+
+ virtual bool eventFilter(TQObject *o, TQEvent *e);
+
+ /*
+ * On double click execute item or
+ * invoke default browser in current url.
+ */
+ virtual void contentsMouseDoubleClickEvent(TQMouseEvent *e);
+
+ /*
+ * Accept dragging.
+ */
+ virtual void dragEnterEvent(TQDragEnterEvent *);
+
+ signals:
+ void invokeBrowser();
+
+ public slots:
+ void slotResetToolTip();
+
+ private slots:
+ /*
+ * Show extended tooltip for 'item'.
+ */
+ void slotShowToolTip(TQListViewItem *item);
+
+ /*
+ * Remove tootip and stop timer.
+ */
+ void slotRemoveToolTip();
+
+ private:
+ TQPixmap dirPix;
+
+ /*
+ * Tooltip for file item.
+ */
+ KonqFileTip *toolTip;
+};
+
+#endif
diff --git a/src/sq_filedialog.cpp b/src/sq_filedialog.cpp
new file mode 100644
index 0000000..5bfccdb
--- /dev/null
+++ b/src/sq_filedialog.cpp
@@ -0,0 +1,44 @@
+/***************************************************************************
+ sq_filedialog.cpp - description
+ -------------------
+ begin : Mon Mar 5 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tdefilefiltercombo.h>
+
+#include "sq_filedialog.h"
+
+SQ_FileDialog::SQ_FileDialog(const TQString &path, TQWidget *parent)
+ : KFileDialog(path, TQString(), parent, "select_a_file", true)
+{}
+
+SQ_FileDialog::~SQ_FileDialog()
+{}
+
+void SQ_FileDialog::updateCombo(bool enable)
+{
+ filterWidget->setEditable(enable);
+
+ slotFilterChanged();
+}
+
+TQString SQ_FileDialog::nameFilter() const
+{
+ return filterWidget->currentText();
+}
+
+void SQ_FileDialog::setCurrentFilter(const TQString &f)
+{
+ filterWidget->setCurrentFilter(f);
+}
diff --git a/src/sq_filedialog.h b/src/sq_filedialog.h
new file mode 100644
index 0000000..7fe79cb
--- /dev/null
+++ b/src/sq_filedialog.h
@@ -0,0 +1,39 @@
+/***************************************************************************
+ sq_filedialog.h - description
+ -------------------
+ begin : Mon Mar 5 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_FILEDIALOG_H
+#define SQ_FILEDIALOG_H
+
+#include <tdefiledialog.h>
+
+/**
+ *@author Baryshev Dmitry
+ */
+
+class SQ_FileDialog : public KFileDialog
+{
+ public:
+ SQ_FileDialog(const TQString &path, TQWidget *parent);
+ ~SQ_FileDialog();
+
+ TQString nameFilter() const;
+ void updateCombo(bool enable);
+
+ void setCurrentFilter(const TQString &);
+};
+
+#endif
diff --git a/src/sq_fileiconview.cpp b/src/sq_fileiconview.cpp
new file mode 100644
index 0000000..686f90b
--- /dev/null
+++ b/src/sq_fileiconview.cpp
@@ -0,0 +1,143 @@
+/***************************************************************************
+ sq_fileiconview.cpp - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqpoint.h>
+#include <tqdragobject.h>
+#include <tqfontmetrics.h>
+#include <tqpainter.h>
+
+#include "sq_config.h"
+#include "sq_iconloader.h"
+#include "sq_fileiconview.h"
+#include "sq_widgetstack.h"
+#include "sq_diroperator.h"
+#include "sq_dragprovider.h"
+
+SQ_FileIconViewItem::SQ_FileIconViewItem(TQIconView *parent, const TQString &text,
+ const TQPixmap &pixmap, KFileItem *fi)
+ : KFileIconViewItem(parent, text, pixmap, fi)
+{}
+
+SQ_FileIconViewItem::~SQ_FileIconViewItem()
+{}
+
+SQ_FileIconView::SQ_FileIconView(TQWidget *parent, const char *name) : SQ_FileIconViewBase(parent, name)
+{
+ TQString n = name;
+
+ setSorting(TQDir::IgnoreCase);
+
+ dirPix = SQ_IconLoader::instance()->loadIcon("folder", TDEIcon::Desktop, (n == "icon view")
+ ? TDEIcon::SizeMedium : TDEIcon::SizeSmall);
+}
+
+SQ_FileIconView::~SQ_FileIconView()
+{}
+
+void SQ_FileIconView::updateView(bool b)
+{
+ if(!b)
+ return;
+
+ SQ_FileIconViewItem *item = static_cast<SQ_FileIconViewItem*>(TQIconView::firstItem());
+
+ if(item)
+ {
+ do
+ {
+ item->setPixmap((item->fileInfo())->pixmap(iconSize()));
+ item = static_cast<SQ_FileIconViewItem*>(item->nextItem());
+ }while(item);
+ }
+}
+
+/*
+ * Reimplement insertItem() to enable/disable inserting
+ * directories (depends on current settings).
+ */
+void SQ_FileIconView::insertItem(KFileItem *i)
+{
+ SQ_Config::instance()->setGroup("Fileview");
+
+ // directores disabled ?
+ if(i->isDir() && SQ_Config::instance()->readBoolEntry("disable_dirs", false))
+ return;
+
+ SQ_FileIconViewItem *item;
+
+ // add new item
+ setUpdatesEnabled(false);
+ item = new SQ_FileIconViewItem((TQIconView*)this, i->text(), i->pixmap(iconSize()), i);
+
+ initItemMy(item, i);
+ setUpdatesEnabled(true);
+
+ i->setExtraData(this, item);
+}
+
+/*
+ * Insert ".." item.
+ */
+void SQ_FileIconView::insertCdUpItem(const KURL &base)
+{
+ static const TQString &dirup = TDEGlobal::staticQString("..");
+
+ KFileItem *fi = new KFileItem(base.upURL(), "inode/directory", S_IFDIR);
+
+ // create ".." item
+ SQ_FileIconViewItem *item = new SQ_FileIconViewItem(this, dirup, dirPix, fi);
+
+ item->setSelectable(false);
+
+ fi->setExtraData(this, item);
+}
+
+/*
+ * Clear current view and insert "..".
+ */
+void SQ_FileIconView::clearView()
+{
+ // call default clearing method
+ KFileIconView::clearView();
+
+ // insert ".."
+ insertCdUpItem(SQ_WidgetStack::instance()->url());
+}
+
+void SQ_FileIconView::listingCompleted()
+{
+ arrangeItemsInGrid();
+}
+
+void SQ_FileIconView::startDrag()
+{
+ SQ_Config::instance()->setGroup("Fileview");
+
+ if(SQ_Config::instance()->readBoolEntry("drag", true))
+ {
+ SQ_DragProvider::instance()->setParams(this, *KFileView::selectedItems(), SQ_DragProvider::Icons);
+ SQ_DragProvider::instance()->start();
+ }
+ else
+ KFileIconView::startDrag();
+}
+
+#include "sq_fileiconview.moc"
diff --git a/src/sq_fileiconview.h b/src/sq_fileiconview.h
new file mode 100644
index 0000000..6f45cac
--- /dev/null
+++ b/src/sq_fileiconview.h
@@ -0,0 +1,90 @@
+/***************************************************************************
+ sq_fileiconview.h - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_FILEICONVIEW_H
+#define SQ_FILEICONVIEW_H
+
+#include "sq_fileiconviewbase.h"
+
+#include <tqwidget.h>
+
+class TQPoint;
+
+/*
+ * SQ_FileIconView represents icon view and list view in filemanager.
+ */
+
+/*
+ * SQ_FileIconViewItem represents one item in icon/list view.
+ */
+class SQ_FileIconViewItem : public KFileIconViewItem
+{
+ public:
+ SQ_FileIconViewItem(TQIconView *parent, const TQString &text, const TQPixmap &pixmap, KFileItem *fi);
+ ~SQ_FileIconViewItem();
+
+ protected:
+ /*
+ * Reimplement paintFocus() to ignore painting focus.
+ */
+ virtual void paintFocus(TQPainter *, const TQColorGroup &)
+ {}
+};
+
+class SQ_FileIconView : public SQ_FileIconViewBase
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_FileIconView(TQWidget *parent = 0, const char *name = "");
+ ~SQ_FileIconView();
+
+ /*
+ * Internal.
+ */
+ virtual void updateView(bool b);
+
+ /*
+ * Reimplement insertItem() to enable/disable inserting
+ * directories (depends on current settings).
+ */
+ virtual void insertItem(KFileItem *i);
+
+ /*
+ * Clear current view and insert "..".
+ */
+ virtual void clearView();
+
+ /*
+ * All files are listed. Do something important.
+ */
+ virtual void listingCompleted();
+
+ /*
+ * Insert ".." item.
+ */
+ virtual void insertCdUpItem(const KURL &baseurl);
+
+ protected:
+ virtual void startDrag();
+
+ private:
+ TQPixmap dirPix;
+};
+
+#endif
diff --git a/src/sq_fileiconviewbase.cpp b/src/sq_fileiconviewbase.cpp
new file mode 100644
index 0000000..f0e2a78
--- /dev/null
+++ b/src/sq_fileiconviewbase.cpp
@@ -0,0 +1,156 @@
+/***************************************************************************
+ sq_fileiconviewbase.cpp - description
+ -------------------
+ begin : ??? Feb 22 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqdragobject.h>
+#include <tqcursor.h>
+
+#include <tdeglobalsettings.h>
+#include <tdeaction.h>
+#include <tdefileitem.h>
+#include <tdeio/job.h>
+#include <konq_filetip.h>
+
+#include "ksquirrel.h"
+#include "sq_fileiconviewbase.h"
+#include "sq_config.h"
+
+SQ_FileIconViewBase::SQ_FileIconViewBase(TQWidget *parent, const char *name)
+ : KFileIconView(parent, name)
+{
+ toolTip = new KonqFileTip(this);
+ slotResetToolTip();
+
+ disconnect(this, TQ_SIGNAL(onViewport()), this, 0);
+ disconnect(this, TQ_SIGNAL(onItem(TQIconViewItem *)), this, 0);
+ connect(this, TQ_SIGNAL(onViewport()), this, TQ_SLOT(slotRemoveToolTip()));
+ connect(this, TQ_SIGNAL(onItem(TQIconViewItem *)), this, TQ_SLOT(slotShowToolTip(TQIconViewItem *)));
+}
+
+SQ_FileIconViewBase::~SQ_FileIconViewBase()
+{
+ slotRemoveToolTip();
+}
+
+void SQ_FileIconViewBase::slotResetToolTip()
+{
+ SQ_Config::instance()->setGroup("Fileview");
+
+ toolTip->setOptions(true,
+ SQ_Config::instance()->readBoolEntry("tooltips_preview", false),
+ SQ_Config::instance()->readNumEntry("tooltips_lines", 6));
+}
+
+// Show extended tooltip for item under mouse cursor
+void SQ_FileIconViewBase::slotShowToolTip(TQIconViewItem *item)
+{
+ SQ_Config::instance()->setGroup("Fileview");
+
+ if(!SQ_Config::instance()->readBoolEntry("tooltips", false) ||
+ (!KSquirrel::app()->isActiveWindow() && SQ_Config::instance()->readBoolEntry("tooltips_inactive", true)))
+ return;
+
+ // remove previous tootip and stop timer
+ slotRemoveToolTip();
+
+ KFileIconViewItem *fitem = dynamic_cast<KFileIconViewItem *>(item);
+
+ if(!fitem) return;
+
+ KFileItem *f = fitem->fileInfo();
+
+ if(f) toolTip->setItem(f, fitem->rect(), fitem->pixmap());
+}
+
+bool SQ_FileIconViewBase::eventFilter(TQObject *o, TQEvent *e)
+{
+ if(o == viewport() || o == this)
+ {
+ int type = e->type();
+
+ if(type == TQEvent::Leave || type == TQEvent::FocusOut || type == TQEvent::Hide)
+ slotRemoveToolTip();
+ }
+
+ return KFileIconView::eventFilter(o, e);
+}
+
+/*
+ * Remove tootip.
+ */
+void SQ_FileIconViewBase::slotRemoveToolTip()
+{
+ toolTip->setItem(0);
+}
+
+// Accept drag
+void SQ_FileIconViewBase::dragEnterEvent(TQDragEnterEvent *e)
+{
+ e->accept(true);
+}
+
+/*
+ * Handle double clicks.
+ */
+void SQ_FileIconViewBase::contentsMouseDoubleClickEvent(TQMouseEvent *e)
+{
+ TQIconView::contentsMouseDoubleClickEvent(e);
+
+ TQIconViewItem *item = findItem(e->pos());
+
+ // double click on item
+ if(item)
+ emit doubleClicked(item, e->globalPos());
+
+ // double click in viewport, lets invoke browser
+ else
+ emit invokeBrowser();
+}
+
+void SQ_FileIconViewBase::updateView(const KFileItem *i)
+{
+ KFileIconViewItem *item = viewItem(i);
+
+ if(item)
+ initItemMy(item, i, true);
+}
+
+KFileIconViewItem* SQ_FileIconViewBase::viewItem(const KFileItem *item)
+{
+ return item ? reinterpret_cast<KFileIconViewItem *>((void *)item->extraData(this)) : 0;
+}
+
+void SQ_FileIconViewBase::initItemMy(KFileIconViewItem *item, const KFileItem *i, bool upd)
+{
+ if(upd)
+ item->setText(i->text(), true, true);
+
+ // determine current sorting type
+ TQDir::SortSpec spec = KFileView::sorting();
+
+ if(spec & TQDir::Time)
+ item->setKey(sortingKey((unsigned long)i->time(TDEIO::UDS_MODIFICATION_TIME), i->isDir(), spec));
+ else if(spec & TQDir::Size)
+ item->setKey(sortingKey(i->size(), i->isDir(), spec));
+ else
+ item->setKey(sortingKey(i->text(), i->isDir(), spec));
+}
+
+#include "sq_fileiconviewbase.moc"
diff --git a/src/sq_fileiconviewbase.h b/src/sq_fileiconviewbase.h
new file mode 100644
index 0000000..014110b
--- /dev/null
+++ b/src/sq_fileiconviewbase.h
@@ -0,0 +1,88 @@
+/***************************************************************************
+ sq_fileiconviewbase.h - description
+ -------------------
+ begin : ??? Feb 22 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_FILEICONVIEWBASE_H
+#define SQ_FILEICONVIEWBASE_H
+
+#include <tdefileiconview.h>
+
+class KonqFileTip;
+
+/*
+ * SQ_FileIconViewBase is a base class for icon view, list view and
+ * thumbnail view with drag-and-drop support.
+ */
+
+class SQ_FileIconViewBase : public KFileIconView
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_FileIconViewBase(TQWidget *parent = 0, const char *name = 0);
+ virtual ~SQ_FileIconViewBase();
+
+ virtual void insertCdUpItem(const KURL &base) = 0;
+ virtual void updateView(const KFileItem *i);
+
+ protected:
+
+ /*
+ * Get KFileIconViewItem by KFileItem. All KFileItems store
+ * a pointer to appropriate KFileIconViewItem as extra data.
+ * See also KFileItem::setExtraData() and insertItem().
+ */
+ KFileIconViewItem* viewItem(const KFileItem *item);
+ /*
+ * Accept dragging.
+ */
+ virtual void dragEnterEvent(TQDragEnterEvent *);
+
+ /*
+ * Handle double clicks.
+ */
+ virtual void contentsMouseDoubleClickEvent(TQMouseEvent *e);
+
+ virtual bool eventFilter(TQObject *o, TQEvent *e);
+
+ void initItemMy(KFileIconViewItem *item, const KFileItem *i, bool upd = false);
+
+ signals:
+ void invokeBrowser();
+
+ public slots:
+ void slotResetToolTip();
+
+ protected slots:
+ /*
+ * Show extended tooltip for 'item'.
+ */
+ void slotShowToolTip(TQIconViewItem *item);
+
+ /*
+ * Remove tootip and stop timer.
+ */
+ void slotRemoveToolTip();
+
+ private:
+ /*
+ * Tooltip for file item.
+ */
+ KonqFileTip *toolTip;
+};
+
+#endif
diff --git a/src/sq_filethumbview.cpp b/src/sq_filethumbview.cpp
new file mode 100644
index 0000000..80b693c
--- /dev/null
+++ b/src/sq_filethumbview.cpp
@@ -0,0 +1,549 @@
+/***************************************************************************
+ sq_fileiconview.cpp - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqpainter.h>
+#include <tqhbox.h>
+#include <tqtoolbar.h>
+#include <tqtoolbutton.h>
+#include <tqlabel.h>
+#include <tqtimer.h>
+#include <tqapplication.h>
+
+#include <kstandarddirs.h>
+#include <kstringhandler.h>
+#include <tdeglobalsettings.h>
+#include <tdelocale.h>
+#include <tdeapplication.h>
+#include <tdeglobal.h>
+
+#include "ksquirrel.h"
+#include "sq_iconloader.h"
+#include "sq_config.h"
+#include "sq_dir.h"
+#include "sq_filethumbview.h"
+#include "sq_libraryhandler.h"
+#include "sq_thumbnailloadjob.h"
+#include "sq_thumbnailsize.h"
+#include "sq_widgetstack.h"
+#include "sq_diroperator.h"
+#include "sq_progress.h"
+#include "sq_progressbox.h"
+#include "sq_filethumbviewitem.h"
+#include "sq_dragprovider.h"
+
+SQ_FileThumbView::SQ_FileThumbView(TQWidget *parent, const char *name) : SQ_FileIconViewBase(parent, name), isPending(false)
+{
+ // create progress bar
+ m_progressBox = new SQ_ProgressBox(this);
+
+ timerScroll = new TQTimer(this);
+ connect(timerScroll, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotDelayedContentsMoving()));
+
+ timerAdd = new TQTimer(this);
+ connect(timerAdd, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotDelayedAddItems()));
+
+ // setup cache limit
+ SQ_Config::instance()->setGroup("Thumbnails");
+ m_lazy = SQ_Config::instance()->readBoolEntry("lazy", true);
+ lazyDelay = SQ_Config::instance()->readNumEntry("lazy_delay", 500);
+ if(lazyDelay <= 0) lazyDelay = 500;
+ m_rows = SQ_Config::instance()->readNumEntry("rows", 2);
+ if(m_rows <= 0 || m_rows > 5) m_rows = 2;
+
+ setResizeMode(TQIconView::Adjust);
+
+ // load "pending" pixmaps
+ pending = SQ_IconLoader::instance()->loadIcon("clock", TDEIcon::Desktop, 32);
+
+ connect(this, TQ_SIGNAL(contentsMoving(int, int)), this, TQ_SLOT(slotContentsMoving(int, int)));
+
+ rebuildCachedPixmaps();
+}
+
+SQ_FileThumbView::~SQ_FileThumbView()
+{}
+
+/*
+ * Reimplement insertItem() to enable/disable inserting
+ * directories (depends on current settings) and inserting thumbnails.
+ */
+void SQ_FileThumbView::insertItem(KFileItem *i)
+{
+ SQ_Config::instance()->setGroup("Fileview");
+
+ // directores disabled ?
+ if(i->isDir() && SQ_Config::instance()->readBoolEntry("disable_dirs", false))
+ return;
+
+ SQ_Config::instance()->setGroup("Thumbnails");
+
+ SQ_FileThumbViewItem *item;
+
+ setUpdatesEnabled(false);
+ if(SQ_Config::instance()->readBoolEntry("mark", false) && SQ_LibraryHandler::instance()->libraryForFile(i->url().path()))
+ {
+ item = new SQ_FileThumbViewItem(this, i->text(), pendingCache, i);
+ }
+ else
+ {
+ TQPixmap mimeall = i->pixmap(SQ_ThumbnailSize::smallest());
+ TQPixmap thumbnail(pixelSize.width(), pixelSize.height());
+ TQPainter painter(&thumbnail);
+ painter.setBrush(colorGroup().base());
+ painter.setPen(colorGroup().highlight());
+ painter.drawRect(0, 0, pixelSize.width(), pixelSize.height());
+ painter.drawPixmap((pixelSize.width()-mimeall.width())/2, (pixelSize.height()-mimeall.height())/2, mimeall);
+ item = new SQ_FileThumbViewItem(this, i->text(), thumbnail, i);
+ }
+
+ initItemMy(item, i);
+
+ i->setExtraData(this, item);
+ setUpdatesEnabled(true);
+}
+
+/*
+ * One thumbnail is loaded. Let's update KFileItem's pixmap.
+ */
+void SQ_FileThumbView::setThumbnailPixmap(const KFileItem* fileItem, const SQ_Thumbnail &t)
+{
+ KFileIconViewItem *iconItem = viewItem(fileItem);
+
+ if(!iconItem) return;
+
+ SQ_FileThumbViewItem *item = static_cast<SQ_FileThumbViewItem*>(iconItem);
+
+ if(!item) return;
+
+ TQPixmap newpix;
+
+ // Extended thumbnail also have mime icon and dimensions
+ if(SQ_ThumbnailSize::instance()->extended())
+ {
+ TQSize sz = pixelSize;//SQ_ThumbnailSize::instance()->extendedSize();
+ int W = sz.width(), H = sz.height();
+
+ // erase original pixmap
+ newpix.resize(W, H);
+
+ TQPainter painter;
+ painter.begin(&newpix);
+
+ painter.setPen(colorGroup().highlight());
+ painter.setBrush(colorGroup().base());
+
+ // draw bounding rect
+ painter.drawRect(0, 0, W, H);
+
+ painter.drawImage((W - t.thumbnail.width())/2, (W - t.thumbnail.height())/2, t.thumbnail);
+ painter.drawPixmap(W-t.mime.width()-5, H-t.mime.height()-4, t.mime);
+ painter.drawLine(3, W-1, W-4, W-1);
+
+ TQFont f = painter.font();
+ f.setPixelSize(10);
+ painter.setFont(f);
+
+ int rest = H-W-2;
+
+ painter.setPen(colorGroup().text());
+
+ if(t.w && t.h) painter.drawText(4, W+rest/2-12, 100, 12, 0, TQString::fromLatin1("%1x%2").arg(t.w).arg(t.h));
+
+ painter.drawText(4, W+rest/2+1, 100, 12, 0, TDEIO::convertSize(fileItem->size()));
+ painter.end();
+ }
+ else
+ {
+ newpix.resize(pixelSize.width(), pixelSize.height());
+
+ TQPainter painter;
+ painter.begin(&newpix);
+
+ painter.setPen(colorGroup().highlight());
+ painter.setBrush(colorGroup().base());
+
+ // draw bounding rect
+ painter.drawRect(0, 0, pixelSize.width(), pixelSize.height());
+
+ // draw pixmap
+ painter.drawImage((pixelSize.width() - t.thumbnail.width())/2, (pixelSize.height() - t.thumbnail.height())/2, t.thumbnail);
+ painter.end();
+ }
+
+ item->setPixmap(newpix);
+ item->setListed(true);
+
+ // update item
+ item->repaint();
+}
+
+void SQ_FileThumbView::startThumbnailUpdate()
+{
+ stopThumbnailUpdate();
+ doStartThumbnailUpdate(itemsToUpdate());
+}
+
+KFileItemList SQ_FileThumbView::itemsToUpdate(bool fromAll)
+{
+ // non-lazy mode - simply return all items
+ if(!m_lazy)
+ return *items();
+
+ // hehe, lazy mode
+ KFileItemList list;
+
+ TQRect rect(contentsX(), contentsY(), viewport()->width(), viewport()->height());
+ TQIconViewItem *first = fromAll ? firstItem() : findFirstVisibleItem(rect);
+ TQIconViewItem *last = fromAll ? lastItem() : findLastVisibleItem(rect);
+
+ if(first && last)
+ {
+ SQ_FileThumbViewItem *tfi;
+
+ TQIconViewItem *f = first;
+ int yy;
+
+ if(m_rows)
+ {
+ // one row more up and down
+ for(int i = 0;i < m_rows;++i)
+ {
+ if(!last) break;
+
+ last = last->nextItem();
+
+ if(last)
+ {
+ yy = last->y();
+
+ while((last = last->nextItem()) && last->y() == yy)
+ {}
+ }
+ }
+
+ for(int i = 0;i < m_rows;++i)
+ {
+ f = first->prevItem();
+
+ if(f)
+ {
+ yy = f->y();
+
+ while((f = first->prevItem()) && f->y() == yy)
+ first = f;
+ }
+ }
+ }
+ else
+ last = last->nextItem();
+
+ for(TQIconViewItem *item = first;(item && item != last);item = item->nextItem())
+ {
+ tfi = dynamic_cast<SQ_FileThumbViewItem *>(item);
+
+ if(tfi && !tfi->listed())
+ list.append(tfi->fileInfo());
+ }
+ }
+
+ return list;
+}
+
+void SQ_FileThumbView::slotContentsMoving(int, int)
+{
+ if(isVisible())
+ timerScroll->start(lazyDelay, true);
+ else
+ waitForShowEvent();
+}
+
+void SQ_FileThumbView::slotDelayedContentsMoving()
+{
+ // restart generator in lazy mode
+ if(m_lazy)
+ {
+ stopThumbnailUpdate();
+ doStartThumbnailUpdate(itemsToUpdate());
+ }
+ // make visible items first items in the job
+ else
+ {
+ // force itemsToUpdate() return only visible items
+ // that need update
+ m_lazy = true;
+ KFileItemList visibleItems = itemsToUpdate();
+
+ if(updateRunning())
+ thumbJob->pop(visibleItems);
+
+ // restore lazy mode
+ m_lazy = false;
+ }
+}
+
+/*
+ * Create job, connect signals and start updating
+ */
+void SQ_FileThumbView::doStartThumbnailUpdate(const KFileItemList &list)
+{
+ if(list.isEmpty())
+ return;
+
+ // update progress bar
+ SQ_WidgetStack::instance()->thumbnailUpdateStart(list.count());
+
+ // create new job
+ thumbJob = new SQ_ThumbnailLoadJob(list, this);
+
+ connect(thumbJob, TQ_SIGNAL(thumbnailLoaded(const KFileItem*, const SQ_Thumbnail &)),
+ this, TQ_SLOT(setThumbnailPixmap(const KFileItem*, const SQ_Thumbnail&)));
+
+ connect(thumbJob, TQ_SIGNAL(done()), SQ_WidgetStack::instance(), TQ_SLOT(thumbnailsUpdateEnded()));
+
+ // start!
+ thumbJob->start();
+}
+
+// Stop thumbnail update: delete job, reset progress bar
+void SQ_FileThumbView::stopThumbnailUpdate()
+{
+ timerScroll->stop();
+ timerAdd->stop();
+ newItems.clear();
+
+ if(!thumbJob.isNull())
+ {
+ thumbJob->kill();
+ SQ_WidgetStack::instance()->thumbnailsUpdateEnded();
+ }
+}
+
+// Start/stop thumbnail job
+void SQ_FileThumbView::slotThumbnailUpdateToggle()
+{
+ if(!thumbJob.isNull())
+ stopThumbnailUpdate();
+ else
+ startThumbnailUpdate();
+}
+
+/*
+ * Append new items to thumbnail generating job.
+ */
+void SQ_FileThumbView::addItemsToJob(const KFileItemList &items, bool append)
+{
+ newItemsAppend = append;
+
+ KFileItemListIterator it(items);
+ KFileItem *fi;
+
+ while((fi = it.current()))
+ {
+ newItems.append(fi);
+ ++it;
+ }
+
+ // don't confuse user with multiple updates
+ timerAdd->start(500, true);
+}
+
+void SQ_FileThumbView::slotDelayedAddItems()
+{
+ KFileItemList _newItems = newItems;
+ newItems.clear();
+
+ if(m_lazy)
+ {
+ KFileItemList visItems = itemsToUpdate();
+ KFileItemListIterator it(_newItems);
+ KFileItem *fi;
+
+ while((fi = it.current()))
+ {
+ if(visItems.findRef(fi) == -1)
+ _newItems.removeRef(fi); // also does ++it
+ else
+ ++it;
+ }
+ }
+
+ // job is not running
+ if(thumbJob.isNull())
+ doStartThumbnailUpdate(_newItems);
+ // add new items to running job
+ else
+ {
+ m_progressBox->addSteps(_newItems.count());
+
+ if(newItemsAppend)
+ thumbJob->appendItems(_newItems);
+ else
+ thumbJob->prependItems(_newItems);
+ }
+}
+
+/*
+ * Clear current view and insert "..".
+ */
+void SQ_FileThumbView::clearView()
+{
+ // stop job
+ stopThumbnailUpdate();
+ slotRemoveToolTip();
+
+ pixelSize = SQ_ThumbnailSize::instance()->extended() ?
+ SQ_ThumbnailSize::instance()->extendedSize() : TQSize(SQ_ThumbnailSize::instance()->pixelSize()+2,SQ_ThumbnailSize::instance()->pixelSize()+2);
+
+ // clear
+ KFileIconView::clearView();
+
+ // insert ".."
+ insertCdUpItem(SQ_WidgetStack::instance()->url());
+}
+
+/*
+ * Is thumbnail job running ?
+ */
+bool SQ_FileThumbView::updateRunning() const
+{
+ return !thumbJob.isNull();
+}
+
+/*
+ * Insert ".." item.
+ */
+void SQ_FileThumbView::insertCdUpItem(const KURL &base)
+{
+ static const TQString &dirup = TDEGlobal::staticQString("..");
+
+ KFileItem *fi = new KFileItem(base.upURL(), "inode/directory", S_IFDIR);
+
+ // insert new item
+ SQ_FileThumbViewItem *item = new SQ_FileThumbViewItem(this, dirup, directoryCache, fi);
+
+ // item ".." won't be selectable
+ item->setSelectable(false);
+
+ fi->setExtraData(this, item);
+}
+
+/*
+ * All files are listed. Do something important.
+ */
+void SQ_FileThumbView::listingCompleted()
+{
+ arrangeItemsInGrid();
+}
+
+void SQ_FileThumbView::rebuildPendingPixmap(bool dir)
+{
+ TQPixmap pixmapDir;
+
+ if(dir)
+ pixmapDir = SQ_IconLoader::instance()->loadIcon("folder", TDEIcon::Desktop, 48);
+
+ TQPixmap *p = dir ? &directoryCache : &pendingCache;
+ TQPixmap *w = dir ? &pixmapDir : &pending;
+
+ p->resize(pixelSize.width(), pixelSize.height());
+
+ TQPainter painter(p);
+ painter.setBrush(colorGroup().base());
+ painter.setPen(colorGroup().highlight());
+ painter.drawRect(0, 0, pixelSize.width(), pixelSize.height());
+ painter.drawPixmap((pixelSize.width() - w->width())/2, (pixelSize.height() - w->height())/2, *w);
+}
+
+void SQ_FileThumbView::rebuildCachedPixmaps()
+{
+ pixelSize = SQ_ThumbnailSize::instance()->extended() ?
+ SQ_ThumbnailSize::instance()->extendedSize() : TQSize(SQ_ThumbnailSize::instance()->pixelSize()+2,SQ_ThumbnailSize::instance()->pixelSize()+2);
+
+ // rebuild "pending" thumbnail
+ rebuildPendingPixmap();
+
+ // rebuild directory pixmap
+ rebuildPendingPixmap(true);
+}
+
+void SQ_FileThumbView::itemRemoved(KFileItem *i)
+{
+ thumbJob->itemRemoved(i);
+}
+
+void SQ_FileThumbView::itemsRemoved(const KFileItemList &l)
+{
+ thumbJob->itemsRemoved(l);
+}
+
+void SQ_FileThumbView::showEvent(TQShowEvent *e)
+{
+ KFileIconView::showEvent(e);
+
+ if(isPending)
+ {
+ isPending = false;
+ startThumbnailUpdate();
+ }
+}
+
+void SQ_FileThumbView::startDrag()
+{
+ SQ_Config::instance()->setGroup("Fileview");
+
+ if(SQ_Config::instance()->readBoolEntry("drag", true))
+ {
+ SQ_DragProvider::instance()->setParams(this, *KFileView::selectedItems(), SQ_DragProvider::Thumbnails);
+ SQ_DragProvider::instance()->start();
+ }
+ else
+ KFileIconView::startDrag();
+}
+
+void SQ_FileThumbView::setLazy(bool l, int delay)
+{
+ m_lazy = l;
+ lazyDelay = delay <= 0 ? 500 : delay;
+
+ // non-lazy mode requires to update all thumbnails
+ if(!m_lazy)
+ {
+ m_lazy = true;
+
+ stopThumbnailUpdate();
+ doStartThumbnailUpdate(itemsToUpdate(true));
+
+ // restore lazy mode
+ m_lazy = false;
+ }
+}
+
+void SQ_FileThumbView::resizeEvent(TQResizeEvent *e)
+{
+ KFileIconView::resizeEvent(e);
+
+ if(isVisible())
+ timerScroll->start(lazyDelay, true);
+ else
+ waitForShowEvent();
+}
+
+#include "sq_filethumbview.moc"
diff --git a/src/sq_filethumbview.h b/src/sq_filethumbview.h
new file mode 100644
index 0000000..b6e8481
--- /dev/null
+++ b/src/sq_filethumbview.h
@@ -0,0 +1,215 @@
+/***************************************************************************
+ sq_fileiconview.h - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_FILETHUMBVIEW_H
+#define SQ_FILETHUMBVIEW_H
+
+#include <tqguardedptr.h>
+#include <tqsize.h>
+
+#include "sq_fileiconviewbase.h"
+#include "sq_thumbnailinfo.h"
+
+class TQHBox;
+class TQToolButton;
+class TQTimer;
+
+class SQ_ProgressBox;
+class SQ_ThumbnailLoadJob;
+class SQ_FileThumbViewItem;
+
+/*
+ * SQ_FileThumbView represents thumbnail view. Can also update thumbnails (with the help of
+ * SQ_ThumbnailLoadJob) and show extended tooltips.
+ */
+
+class SQ_FileThumbView : public SQ_FileIconViewBase
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_FileThumbView(TQWidget *parent = 0, const char *name = "");
+ ~SQ_FileThumbView();
+
+ bool lazy() const;
+
+ void setLazy(bool l, int delay);
+
+ void setAddRows(int rows);
+
+ void rebuildCachedPixmaps();
+
+ /*
+ * Reimplement insertItem() to enable/disable inserting
+ * directories (depends on current settings) and inserting thumbnails.
+ */
+ virtual void insertItem(KFileItem *i);
+
+ /*
+ * Append new items to thumbnail generating job.
+ */
+ void addItemsToJob(const KFileItemList &items, bool append = true);
+
+ /*
+ * Delete item from thumbnail generating job.
+ */
+ void itemRemoved(KFileItem *i);
+ void itemsRemoved(const KFileItemList &);
+
+ /*
+ * Internal.
+ */
+ virtual void updateView(bool)
+ {}
+
+ /*
+ * Clear current view and insert "..".
+ */
+ virtual void clearView();
+
+ /*
+ * All files are listed. Do something important.
+ */
+ virtual void listingCompleted();
+
+ /*
+ * Create job, connect signals and start updating
+ */
+ void doStartThumbnailUpdate(const KFileItemList &list);
+
+ /*
+ * Is thumbnail job running ?
+ */
+ bool updateRunning() const;
+
+ /*
+ * Insert ".." item.
+ */
+ virtual void insertCdUpItem(const KURL &base);
+
+ /*
+ * Don't start thumbnail job until thumbnail view is hidden.
+ */
+ void waitForShowEvent();
+
+ SQ_ProgressBox* progressBox() const;
+
+ protected:
+ virtual void resizeEvent(TQResizeEvent *);
+ virtual void startDrag();
+
+ /*
+ * Show event. Let's start thumbnail job, if needed.
+ */
+ virtual void showEvent(TQShowEvent *);
+
+ private:
+
+ /*
+ * rebuild "pending" thumbnail for supported items
+ */
+ void rebuildPendingPixmap(bool dir = false);
+
+ KFileItemList itemsToUpdate(bool fromAll = false);
+
+ public slots:
+ /*
+ * Start and stop thumbnail update job.
+ */
+ void startThumbnailUpdate();
+ void stopThumbnailUpdate();
+
+ /*
+ * One thumbnail is loaded. Let's update KFileItem's pixmap.
+ */
+ void setThumbnailPixmap(const KFileItem* fileItem, const SQ_Thumbnail&);
+
+ protected slots:
+ /*
+ * Start or stop thumbnail update.
+ */
+ void slotThumbnailUpdateToggle();
+
+ private slots:
+
+ void slotContentsMoving(int, int);
+ void slotDelayedContentsMoving();
+ void slotDelayedAddItems();
+
+ public:
+ /*
+ * Layout box with progress bar and "stop" button.
+ */
+ SQ_ProgressBox *m_progressBox;
+
+ /*
+ * "Stop" button.
+ */
+ TQToolButton *buttonStop;
+
+ private:
+ TQGuardedPtr<SQ_ThumbnailLoadJob> thumbJob;
+
+ /*
+ * "Pending" thumbnail.
+ */
+ TQPixmap pending;
+
+ TQTimer *timerScroll, *timerAdd;
+
+ TQPixmap directoryCache, pendingCache;
+ TQSize pixelSize;
+
+ KFileItemList newItems;
+ bool newItemsAppend;
+
+ /*
+ * Thumbnail job won't start until isPending
+ * is false. It means, that thumbnail view currently is hidden.
+ */
+ bool isPending;
+ bool m_lazy;
+ int lazyDelay;
+ int m_rows;
+};
+
+inline
+void SQ_FileThumbView::waitForShowEvent()
+{
+ isPending = true;
+}
+
+inline
+SQ_ProgressBox* SQ_FileThumbView::progressBox() const
+{
+ return m_progressBox;
+}
+
+inline
+bool SQ_FileThumbView::lazy() const
+{
+ return m_lazy;
+}
+
+inline
+void SQ_FileThumbView::setAddRows(int rows)
+{
+ m_rows = rows;
+}
+
+#endif
diff --git a/src/sq_filethumbviewitem.cpp b/src/sq_filethumbviewitem.cpp
new file mode 100644
index 0000000..d2be112
--- /dev/null
+++ b/src/sq_filethumbviewitem.cpp
@@ -0,0 +1,67 @@
+/***************************************************************************
+ sq_filethumbviewitem.cpp - description
+ -------------------
+ begin : ??? ??? 12 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqstring.h>
+#include <tqpainter.h>
+
+#include <kwordwrap.h>
+
+#include "sq_filethumbviewitem.h"
+
+SQ_FileThumbViewItem::SQ_FileThumbViewItem(TQIconView *parent, const TQString &text, const TQPixmap &pixmap, KFileItem *fi):
+ KFileIconViewItem(parent, text, pixmap, fi), m_listed(false)
+{}
+
+SQ_FileThumbViewItem::~SQ_FileThumbViewItem()
+{}
+
+void SQ_FileThumbViewItem::paintItem(TQPainter *p, const TQColorGroup &cg)
+{
+ TDEIconViewItem::paintPixmap(p, cg);
+ paintText(p, cg);
+}
+
+void SQ_FileThumbViewItem::paintText(TQPainter *p, const TQColorGroup &cg)
+{
+ TQRect rectText = textRect(false);
+ TQRect rc = pixmapRect(false);
+
+ rectText.setX(rc.x());
+ rectText.setWidth(rc.width()-2);
+
+ if(isSelected())
+ {
+ p->fillRect(rectText, cg.highlight());
+ p->setPen(TQPen(cg.highlightedText()));
+ }
+ else
+ {
+ if(iconView()->itemTextBackground() != TQt::NoBrush)
+ p->fillRect(rectText, iconView()->itemTextBackground());
+
+ p->setPen(cg.text());
+ }
+
+ wordWrap()->drawText(p, textRect(false).x(), textRect(false).y(), AlignCenter);
+}
+
+void SQ_FileThumbViewItem::paintFocus(TQPainter *, const TQColorGroup &)
+{}
diff --git a/src/sq_filethumbviewitem.h b/src/sq_filethumbviewitem.h
new file mode 100644
index 0000000..adddb67
--- /dev/null
+++ b/src/sq_filethumbviewitem.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+ sq_filethumbviewitem.h - description
+ -------------------
+ begin : ??? ??? 12 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_FILETHUMBVIEWITEM_H
+#define SQ_FILETHUMBVIEWITEM_H
+
+#include <tqpixmap.h>
+
+#include <tdefileiconview.h>
+
+/*
+ * SQ_FileThumbViewItem represents a thumbnail item in SQ_FileThumbView.
+ * Additianally it stores some useful info.
+ */
+
+class SQ_FileThumbViewItem : public KFileIconViewItem
+{
+ public:
+ SQ_FileThumbViewItem(TQIconView *parent, const TQString &text, const TQPixmap &pixmap, KFileItem *fi);
+ ~SQ_FileThumbViewItem();
+
+ bool listed() const;
+
+ void setListed(bool l);
+
+ protected:
+ /*
+ * Painting routines.
+ */
+ virtual void paintItem(TQPainter *p, const TQColorGroup &cg);
+ virtual void paintFocus(TQPainter *p, const TQColorGroup &cg);
+ void paintText(TQPainter *p, const TQColorGroup &c);
+
+ private:
+ bool m_listed;
+};
+
+inline
+bool SQ_FileThumbViewItem::listed() const
+{
+ return m_listed;
+}
+
+inline
+void SQ_FileThumbViewItem::setListed(bool l)
+{
+ m_listed = l;
+}
+
+#endif
diff --git a/src/sq_filters.ui b/src/sq_filters.ui
new file mode 100644
index 0000000..5e57146
--- /dev/null
+++ b/src/sq_filters.ui
@@ -0,0 +1,413 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_Filters</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_Filters</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>562</width>
+ <height>417</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Adjust filters</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQPushButton" row="3" column="1">
+ <property name="name">
+ <cstring>pushOK</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="3" column="2" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>pushCancel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>411</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="Line" row="2" column="0" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>line2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="0" column="3">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushNew</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>New filter</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pushDelete</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoRepeat">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Delete</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="2" column="0">
+ <property name="name">
+ <cstring>pushClearAll</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Clear All</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushFilterUp</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoRepeat">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Move filter up</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pushFilterDown</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoRepeat">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Move filter down</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer row="1" column="3">
+ <property name="name">
+ <cstring>spacer12</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>145</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLayoutWidget" row="0" column="0" rowspan="2" colspan="3">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQListView" row="0" column="0" rowspan="1" colspan="3">
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Extensions</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>listFilters</cstring>
+ </property>
+ <property name="acceptDrops">
+ <bool>true</bool>
+ </property>
+ <property name="resizePolicy">
+ <enum>Manual</enum>
+ </property>
+ <property name="selectionMode">
+ <enum>Single</enum>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="showSortIndicator">
+ <bool>false</bool>
+ </property>
+ <property name="itemMargin">
+ <number>1</number>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ <property name="defaultRenameAction">
+ <enum>Reject</enum>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>checkBoth</cstring>
+ </property>
+ <property name="text">
+ <string>Menu item contains both name and extension</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushFilterUp</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_Filters</receiver>
+ <slot>slotFilterUp()</slot>
+ </connection>
+ <connection>
+ <sender>pushFilterDown</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_Filters</receiver>
+ <slot>slotFilterDown()</slot>
+ </connection>
+ <connection>
+ <sender>listFilters</sender>
+ <signal>rightButtonClicked(TQListViewItem*,const TQPoint&amp;,int)</signal>
+ <receiver>SQ_Filters</receiver>
+ <slot>slotFilterRenameRequest(TQListViewItem*,const TQPoint&amp;,int)</slot>
+ </connection>
+ <connection>
+ <sender>pushOK</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_Filters</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>pushCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_Filters</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>pushNew</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_Filters</receiver>
+ <slot>slotNewFilter()</slot>
+ </connection>
+ <connection>
+ <sender>pushClearAll</sender>
+ <signal>clicked()</signal>
+ <receiver>listFilters</receiver>
+ <slot>clear()</slot>
+ </connection>
+ <connection>
+ <sender>pushDelete</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_Filters</receiver>
+ <slot>slotFilterClear()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>listFilters</tabstop>
+ <tabstop>checkBoth</tabstop>
+ <tabstop>pushNew</tabstop>
+ <tabstop>pushDelete</tabstop>
+ <tabstop>pushClearAll</tabstop>
+ <tabstop>pushFilterUp</tabstop>
+ <tabstop>pushFilterDown</tabstop>
+ <tabstop>pushOK</tabstop>
+ <tabstop>pushCancel</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="local" impldecl="in implementation">ksquirrel.h</include>
+ <include location="local" impldecl="in implementation">sq_filters.ui.h</include>
+</includes>
+<slots>
+ <slot>slotNewFilter()</slot>
+ <slot>slotFilterClear()</slot>
+ <slot>slotFilterUp()</slot>
+ <slot>slotFilterDown()</slot>
+ <slot returnType="int">start()</slot>
+ <slot>slotFilterRenameRequest( TQListViewItem * item, const TQPoint &amp;, int pos )</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_filters.ui.h b/src/sq_filters.ui.h
new file mode 100644
index 0000000..138b0dc
--- /dev/null
+++ b/src/sq_filters.ui.h
@@ -0,0 +1,138 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+void SQ_Filters::init()
+{
+ listFilters->setSorting(-1);
+
+ TQListViewItem *itemafter = 0L, *item;
+
+ TQValueList<TQString>::iterator nEND = KSquirrel::app()->filtersNames()->end();
+ TQValueList<TQString>::iterator it_name = KSquirrel::app()->filtersNames()->begin();
+ TQValueList<TQString>::iterator it_ext = KSquirrel::app()->filtersExtensions()->begin();
+
+ for(;it_name != nEND;++it_name,++it_ext)
+ {
+ if(itemafter)
+ item = new TQListViewItem(listFilters, itemafter, *it_name, *it_ext);
+ else
+ item = new TQListViewItem(listFilters, *it_name, *it_ext);
+
+ itemafter = item;
+
+ item->setRenameEnabled(0, true);
+ item->setRenameEnabled(1, true);
+ item->setMultiLinesEnabled(false);
+
+ listFilters->insertItem(item);
+ }
+
+ pushFilterUp->setPixmap(SQ_IconLoader::instance()->loadIcon("move_task_up", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ pushFilterDown->setPixmap(SQ_IconLoader::instance()->loadIcon("move_task_down", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ pushNew->setPixmap(SQ_IconLoader::instance()->loadIcon("document-new", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ pushDelete->setPixmap(SQ_IconLoader::instance()->loadIcon("edit-delete", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ pushClearAll->setPixmap(SQ_IconLoader::instance()->loadIcon("edittrash", TDEIcon::Desktop, TDEIcon::SizeSmall));
+
+ listFilters->setCurrentItem(listFilters->firstChild());
+ listFilters->clearSelection();
+ listFilters->setSelected(listFilters->currentItem(), true);
+
+ SQ_Config::instance()->setGroup("Filters");
+
+ checkBoth->setChecked(SQ_Config::instance()->readBoolEntry("menuitem both", true));
+}
+
+void SQ_Filters::slotNewFilter()
+{
+ TQListViewItem *itemafter = listFilters->lastItem(), *item;
+
+ if(itemafter)
+ item = new TQListViewItem(listFilters, itemafter, i18n("Name"), "*.");
+ else
+ item = new TQListViewItem(listFilters, i18n("Name"), "*.");
+
+ item->setRenameEnabled(0, true);
+ item->setRenameEnabled(1, true);
+ item->setMultiLinesEnabled(false);
+ listFilters->insertItem(item);
+ item->startRename(0);
+
+}
+
+void SQ_Filters::slotFilterClear()
+{
+ TQListViewItem *item = listFilters->currentItem();
+
+ if(!item) return;
+
+ listFilters->takeItem(item);
+
+ item = listFilters->currentItem();
+
+ if(item)
+ listFilters->setSelected(item, true);
+}
+
+void SQ_Filters::slotFilterUp()
+{
+ TQListViewItem *item = listFilters->currentItem();
+
+ if(!item) return;
+
+ TQListViewItem *itemafter = item->itemAbove();
+
+ if(!itemafter) return;
+
+ itemafter->moveItem(item);
+}
+
+void SQ_Filters::slotFilterDown()
+{
+ TQListViewItem *item = listFilters->currentItem();
+
+ if(!item) return;
+
+ TQListViewItem *itemafter = item->itemBelow();
+
+ if(!itemafter) return;
+
+ item->moveItem(itemafter);
+
+}
+
+int SQ_Filters::start()
+{
+ int result = exec();
+
+ if(result == TQDialog::Accepted)
+ {
+ TQListViewItem *cur = listFilters->firstChild();
+
+ KSquirrel::app()->filtersNames()->clear();
+ KSquirrel::app()->filtersExtensions()->clear();
+
+ for(;cur;cur = cur->itemBelow())
+ {
+ KSquirrel::app()->filtersNames()->append(cur->text(0));
+ KSquirrel::app()->filtersExtensions()->append(cur->text(1));
+ }
+
+ SQ_Config::instance()->setGroup("Filters");
+ SQ_Config::instance()->writeEntry("menuitem both", checkBoth->isChecked());
+ }
+
+ return result;
+}
+
+
+void SQ_Filters::slotFilterRenameRequest( TQListViewItem *item, const TQPoint &, int pos )
+{
+ if(item)
+ item->startRename(((pos>=0)?pos:0));
+}
diff --git a/src/sq_glinfo.ui b/src/sq_glinfo.ui
new file mode 100644
index 0000000..8aad68f
--- /dev/null
+++ b/src/sq_glinfo.ui
@@ -0,0 +1,165 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_GLInfo</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_GLInfo</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>542</width>
+ <height>233</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>OpenGL information</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQListView" row="0" column="0" rowspan="1" colspan="2">
+ <column>
+ <property name="text">
+ <string>Parameter</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <item>
+ <property name="text">
+ <string>GL_VENDOR</string>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>GL_RENDERER</string>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>GL_VERSION</string>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>listGL</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="itemMargin">
+ <number>2</number>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ </widget>
+ <widget class="Line" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>line8</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="2" column="1">
+ <property name="name">
+ <cstring>pushClose</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer15</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>431</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushClose</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_GLInfo</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>pushClose</tabstop>
+ <tabstop>listGL</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in implementation">GL/gl.h</include>
+ <include location="global" impldecl="in implementation">tqmap.h</include>
+ <include location="local" impldecl="in implementation">sq_glinfo.ui.h</include>
+</includes>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_glinfo.ui.h b/src/sq_glinfo.ui.h
new file mode 100644
index 0000000..878eeea
--- /dev/null
+++ b/src/sq_glinfo.ui.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** TQt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+void SQ_GLInfo::init()
+{
+ listGL->setSorting(-1);
+
+ TQListViewItem *item;
+ TQMap<TQString, GLenum> v;
+
+ v.insert("GL_VENDOR", GL_VENDOR);
+ v.insert("GL_RENDERER", GL_RENDERER);
+ v.insert("GL_VERSION", GL_VERSION);
+
+ for(TQMap<TQString, GLenum>::ConstIterator it = v.constBegin(); it != v.constEnd(); ++it)
+ {
+ item = listGL->findItem(it.key().latin1(), 0);
+
+ if(item)
+ {
+ const GLubyte *b = glGetString(it.data());
+
+ if(b)
+ {
+ item->setText(1, (const char*)b);
+ }
+ }
+ }
+}
diff --git a/src/sq_glparts.cpp b/src/sq_glparts.cpp
new file mode 100644
index 0000000..ec55d89
--- /dev/null
+++ b/src/sq_glparts.cpp
@@ -0,0 +1,219 @@
+/***************************************************************************
+ sq_glparts.cpp - description
+ -------------------
+ begin : ??? ??? 13 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "sq_glparts.h"
+#include "sq_library.h"
+
+#include <ksquirrel-libs/fmt_codec_base.h>
+
+/* ***************************************************************************************** */
+
+Parts::Parts() : w(0), h(0), realw(0), realh(0), m_parts(0), buffer(0)
+{}
+
+Part::Part() : x1(0), y1(0), x2(0), y2(0), tex(0), list(0)
+{}
+
+/* ***************************************************************************************** */
+
+memoryPart::memoryPart(const int sz) : m_size(sz), m_data(0)
+{}
+
+memoryPart::~memoryPart()
+{
+ del();
+}
+
+void memoryPart::create()
+{
+ m_data = new RGBA [m_size];
+
+// if(m_data)
+// memset(m_data, 0, m_size * sizeof(RGBA));
+}
+
+// Delete textures and display lists.
+void Parts::removeParts()
+{
+ if(!m_parts.empty())
+ {
+ int toy = tilesy.size();
+ int toxy = tilesx.size() * toy;
+
+ for(int z = 0;z < toxy;z++)
+ glDeleteTextures(1, &m_parts[z].tex);
+
+ glDeleteLists(m_parts[0].list, toy);
+
+ m_parts.clear();
+ }
+}
+
+// Create parts: generate textures and display lists.
+bool Parts::makeParts()
+{
+ int z;
+ int toy = tilesy.size();
+
+ GLuint base = glGenLists(toy);
+
+ if(!base)
+ return false;
+
+ Part pt;
+ int tox = tilesx.size();
+ int toxy = tox * toy;
+
+ for(z = 0;z < toxy;z++)
+ {
+ glGenTextures(1, &pt.tex);
+ m_parts.push_back(pt);
+ }
+
+ // calculate display list's id
+ for(z = 0;z < toy;z++)
+ m_parts[z * tox].list = base + z;
+
+ return true;
+}
+
+// Calculate coordinates for textures
+void Parts::computeCoords()
+{
+ Part *p;
+ int index = 0;
+ float X, Y;
+
+ Y = (float)h / 2.0;
+
+ int tlsy = tilesy.size();
+ int tlsx = tilesx.size();
+
+ for(int y = 0;y < tlsy;y++)
+ {
+ X = -(float)w / 2.0;
+
+ for(int x = 0;x < tlsx;x++)
+ {
+ p = &m_parts[index];
+
+ p->x1 = X;
+ p->y1 = Y;
+ p->x2 = X + tilesx[x];
+ p->y2 = Y - tilesy[y];
+
+ p->tx1 = 0.0;
+ p->tx2 = 1.0;
+ p->ty1 = 0.0;
+ p->ty2 = 1.0;
+
+ index++;
+ X += tilesx[x];
+ }
+
+ Y -= tilesy[y];
+ }
+}
+
+/* ***************************************************************************************** */
+
+Tab::Tab()
+{
+ empty();
+}
+
+Tab::~Tab()
+{}
+
+void Tab::clearParts()
+{
+ if(broken) return;
+
+ std::vector<Parts>::iterator itEnd = parts.end();
+
+ for(std::vector<Parts>::iterator it = parts.begin();it != itEnd;++it)
+ {
+ // delete textures and memory buffers
+ (*it).removeParts();
+ (*it).deleteBuffer();
+ }
+
+ parts.clear();
+
+ finfo.image.clear();
+ finfo.meta.clear();
+}
+
+void Tab::removeParts()
+{
+ if(broken) return;
+
+ std::vector<Parts>::iterator itEnd = parts.end();
+
+ for(std::vector<Parts>::iterator it = parts.begin();it != itEnd;++it)
+ (*it).removeParts();
+}
+
+void Tab::remakeParts()
+{
+ if(broken) return;
+
+ std::vector<Parts>::iterator itEnd = parts.end();
+
+ for(std::vector<Parts>::iterator it = parts.begin();it != itEnd;++it)
+ {
+ (*it).makeParts();
+ (*it).computeCoords();
+ }
+}
+
+void Tab::empty()
+{
+ nullMatrix();
+
+ orient = -1;
+ rotate = 0;
+ fmt_size = 0;
+ lib = 0;
+ codeK = 0;
+ current = 0;
+ curangle = 0;
+ total = 0;
+ sx = sy = sw = sh = 0;
+ elapsed = 0;
+
+ wm = TQWMatrix();
+
+ glselection = -1;
+ srect = TQRect();
+
+ manualBlocked = false;
+ isflippedV = isflippedH = false;
+ broken = false;
+
+ m_original = KURL();
+ File = TQString();
+ m_File = TQString();
+ quickImageInfo = TQString();
+ fmt_ext = TQString();
+}
+
+void Tab::nullMatrix()
+{
+ for(int i = 0;i < 12;i++)
+ matrix[i] = (GLfloat)(i % 5 == 0);
+}
diff --git a/src/sq_glparts.h b/src/sq_glparts.h
new file mode 100644
index 0000000..24c538c
--- /dev/null
+++ b/src/sq_glparts.h
@@ -0,0 +1,152 @@
+/***************************************************************************
+ sq_glparts.h - description
+ -------------------
+ begin : ??? Mar 13 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_GLPARTS_H
+#define SQ_GLPARTS_H
+
+#include <tqgl.h>
+
+#include <tqwmatrix.h>
+#include <tqrect.h>
+
+#include <kurl.h>
+
+#include <vector>
+
+#include <ksquirrel-libs/fmt_defs.h>
+
+struct SQ_LIBRARY;
+class fmt_codec_base;
+
+class memoryPart
+{
+ public:
+ memoryPart(const int sz);
+ ~memoryPart();
+
+ // create/delete memory buffer
+ void create();
+ void del();
+
+ bool valid() const;
+ RGBA *data();
+
+ private:
+ int m_size;
+ RGBA *m_data;
+};
+
+inline
+RGBA* memoryPart::data()
+{
+ return m_data;
+}
+
+inline
+void memoryPart::del()
+{
+ delete [] m_data;
+ m_data = 0;
+}
+
+inline
+bool memoryPart::valid() const
+{
+ return m_data != 0;
+}
+
+/* *************************************************************** */
+
+struct Part
+{
+ Part();
+
+ float x1, y1, x2, y2, tx1, tx2, ty1, ty2;
+ unsigned int tex;
+ GLuint list;
+};
+
+/* *************************************************************** */
+
+// one image page. All pages are stored in SQ_GLWidget::parts
+struct Parts
+{
+ Parts();
+
+ int w, h, realw, realh;
+
+ std::vector<Part> m_parts;
+ std::vector<int> tilesx, tilesy;
+ memoryPart *buffer;
+
+ bool makeParts();
+ void removeParts();
+ void computeCoords();
+ void deleteBuffer();
+};
+
+inline
+void Parts::deleteBuffer()
+{
+ delete buffer;
+ buffer = 0;
+}
+
+/* *************************************************************** */
+
+struct Tab
+{
+ Tab();
+ ~Tab();
+
+ void nullMatrix();
+ void empty();
+ void clearParts();
+ void removeParts();
+ void remakeParts();
+
+ GLfloat matrix[12];
+ GLfloat curangle;
+
+ KURL m_original;
+ TQString File, m_File, quickImageInfo;
+ TQString fmt_ext;
+
+ TQWMatrix wm;
+ TQRect srect;
+
+ int orient;
+ int current;
+ int fmt_size;
+ int total;
+ int glselection;
+ int sx, sy, sw, sh;
+ int elapsed;
+
+ bool rotate;
+ bool manualBlocked;
+ bool isflippedV, isflippedH;
+ bool broken;
+
+ std::vector<Parts> parts;
+ fmt_info finfo;
+
+ SQ_LIBRARY *lib;
+ fmt_codec_base *codeK;
+};
+
+#endif
diff --git a/src/sq_glselectionpainter.cpp b/src/sq_glselectionpainter.cpp
new file mode 100644
index 0000000..9594f28
--- /dev/null
+++ b/src/sq_glselectionpainter.cpp
@@ -0,0 +1,145 @@
+/***************************************************************************
+ sq_glselectionpainter.cpp - description
+ -------------------
+ begin : Apr 4 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tqbitmap.h>
+#include <tqpainter.h>
+
+#include <cmath>
+
+#include "sq_glwidget.h"
+#include "sq_glselectionpainter.h"
+
+static const int len = 4;
+static const int len2 = 10;
+static const int lenc = 2;
+static const int lenc2 = lenc / 2;
+static const double rad_const = 3.14159265358979323846 / 180.0;
+
+/* ******************************************************************* */
+
+SQ_GLSelectionPainter::SQ_GLSelectionPainter(SQ_GLWidget *widget)
+ : w(widget), sourcew(1), sourceh(1), sw(0), sh(0), sx(0), sy(0),
+ angle(0), m_valid(false), m_shown(false)
+{}
+
+SQ_GLSelectionPainter::~SQ_GLSelectionPainter()
+{}
+
+void SQ_GLSelectionPainter::begin(Type tp, int x, int y, bool U)
+{
+ // end previous drawing if any
+ end();
+
+ m_type = tp;
+
+ hackXY(x, y);
+
+ sx = xmoveold = x;
+ sy = ymoveold = y;
+ sw = 0;
+ sh = 0;
+
+ m_valid = true;
+ m_shown = true;
+
+ if(U) w->updateGLA();
+}
+
+void SQ_GLSelectionPainter::move(int x, int y)
+{
+ hackXY(x, y);
+
+ int X = TQMAX(x, xmoveold);
+ int Y = TQMIN(y, ymoveold);
+ int Xmin = TQMIN(x, xmoveold);
+ int Ymin = TQMAX(y, ymoveold);
+
+ sx = Xmin;
+ sy = Ymin;
+ sw = X - Xmin;
+ sh = Ymin - Y;
+
+ angle += 3;
+
+ if(angle > 360)
+ angle = 0;
+
+ // SQ_GLWidget::paintGL() will call draw()
+ w->updateGLA();
+}
+
+void SQ_GLSelectionPainter::end()
+{
+ m_valid = false;
+ m_shown = false;
+
+ w->updateGLA();
+}
+
+void SQ_GLSelectionPainter::drawEllipse(float xradius, float yradius)
+{
+ w->makeCurrent();
+
+ double degInRad;
+
+ glBegin(GL_LINE_LOOP);
+ glColor4f(1,0,1,1);
+
+ for(int i = 0; i < 360; i++)
+ {
+ degInRad = rad_const * i;
+ glVertex2f(cos(degInRad) * xradius, sin(degInRad) * yradius);
+ }
+
+ glColor4f(1,1,1,1);
+ glEnd();
+}
+
+void SQ_GLSelectionPainter::drawRect()
+{
+ w->makeCurrent();
+
+ glBegin(GL_LINE_LOOP);
+ glColor4f(1,0,1,1);
+
+ glVertex2f(-sw/2, sh/2);
+ glVertex2f(sw/2, sh/2);
+ glVertex2f(sw/2, -sh/2);
+ glVertex2f(-sw/2, -sh/2);
+
+ glColor4f(1,1,1,1);
+ glEnd();
+}
+
+void SQ_GLSelectionPainter::draw()
+{
+ if(!sw || !sh)
+ return;
+
+ if(m_type == Ellipse)
+ drawEllipse(sw/2, sh/2);
+ else
+ drawRect();
+
+ // center rectangle
+ if(sw > lenc && sh > lenc)
+ {
+ glColor4f(1,0,1,1);
+ glRectf(-lenc2, lenc2, lenc2, -lenc2);
+ glColor4f(1,1,1,1);
+ }
+}
diff --git a/src/sq_glselectionpainter.h b/src/sq_glselectionpainter.h
new file mode 100644
index 0000000..ea39286
--- /dev/null
+++ b/src/sq_glselectionpainter.h
@@ -0,0 +1,151 @@
+/***************************************************************************
+ sq_glselectionpainter.h - description
+ -------------------
+ begin : Apr 4 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_GLSELECTIONPAINTER_H
+#define SQ_GLSELECTIONPAINTER_H
+
+#include <tqrect.h>
+#include <tqpoint.h>
+
+class SQ_GLWidget;
+
+/*
+ * This is a selection painter for SQ_GLWidget.
+ *
+ * Selection can be shown as rectangle and ellipse.
+ *
+ * Ellipsis selection mainly used in redeye filter.
+ */
+
+class SQ_GLSelectionPainter
+{
+ public:
+ enum Type { Rectangle, Ellipse };
+
+ SQ_GLSelectionPainter(SQ_GLWidget *widget);
+ ~SQ_GLSelectionPainter();
+
+ void setSourceSize(int, int);
+
+ TQPoint center() const;
+
+ void draw();
+
+ /*
+ * Set selection type - rectangle or ellipse
+ */
+ int type() const;
+
+ /*
+ * when selection is drawn and visible, it's valid.
+ * After end() it becomes invalid.
+ */
+ bool valid() const;
+
+ void setVisible(bool vis);
+
+ void begin(Type tp, int x, int y, bool U = true);
+ void move(int x, int y);
+ void setGeometry(const TQRect &rc);
+ void end();
+
+ /*
+ * Selected rectangle geometry
+ */
+ TQPoint pos() const;
+ TQSize size() const;
+
+ private:
+ void drawEllipse(float xradius, float yradius);
+ void drawRect();
+ void hackXY(int &x, int &y);
+
+ private:
+ SQ_GLWidget *w;
+ int sourcew, sourceh;
+ int sw, sh, sx, sy;
+
+ int angle;
+ int xmoveold, ymoveold;
+ bool m_valid, m_shown;
+ Type m_type;
+};
+
+inline
+TQPoint SQ_GLSelectionPainter::pos() const
+{
+ return valid() ? TQPoint(sourcew/2 + sx, sourceh/2 - sy) : TQPoint();
+}
+
+inline
+TQSize SQ_GLSelectionPainter::size() const
+{
+ return valid() ? TQSize(sw, sh) : TQSize();
+}
+
+inline
+int SQ_GLSelectionPainter::type() const
+{
+ return m_type;
+}
+
+inline
+void SQ_GLSelectionPainter::setGeometry(const TQRect &rc)
+{
+ int X = rc.x(), Y = rc.y();
+
+ hackXY(X, Y);
+
+ sx = X;
+ sy = Y;
+ sw = rc.width();
+ sh = rc.height();
+}
+
+inline
+void SQ_GLSelectionPainter::setSourceSize(int w, int h)
+{
+ sourcew = w;
+ sourceh = h;
+}
+
+inline
+void SQ_GLSelectionPainter::setVisible(bool vis)
+{
+ if(m_valid) m_shown = vis;
+}
+
+inline
+bool SQ_GLSelectionPainter::valid() const
+{
+ return m_valid && m_shown;
+}
+
+inline
+TQPoint SQ_GLSelectionPainter::center() const
+{
+ return TQPoint(sx + sw/2, sy - sh/2);
+}
+
+inline
+void SQ_GLSelectionPainter::hackXY(int &x, int &y)
+{
+ x -= sourcew / 2;
+ y = sourceh / 2 - y;
+}
+
+#endif
diff --git a/src/sq_glu.cpp b/src/sq_glu.cpp
new file mode 100644
index 0000000..8e17e31
--- /dev/null
+++ b/src/sq_glu.cpp
@@ -0,0 +1,110 @@
+/***************************************************************************
+ sq_glu.cpp - description
+ -------------------
+ begin : ??? ??? 29 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ * Copyright (C) 1995-2001 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_glu.h"
+
+#include <cmath>
+
+/*
+ * Replacement for gluLookAt().
+ */
+void SQ_GLU::gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz)
+{
+ GLdouble m[16];
+ GLdouble x[3], y[3], z[3];
+ GLdouble mag;
+
+ z[0] = eyex - centerx;
+ z[1] = eyey - centery;
+ z[2] = eyez - centerz;
+
+ mag = sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
+
+ if(mag)
+ {
+ z[0] /= mag;
+ z[1] /= mag;
+ z[2] /= mag;
+ }
+
+ y[0] = upx;
+ y[1] = upy;
+ y[2] = upz;
+
+ x[0] = y[1] * z[2] - y[2] * z[1];
+ x[1] = -y[0] * z[2] + y[2] * z[0];
+ x[2] = y[0] * z[1] - y[1] * z[0];
+
+ y[0] = z[1] * x[2] - z[2] * x[1];
+ y[1] = -z[0] * x[2] + z[2] * x[0];
+ y[2] = z[0] * x[1] - z[1] * x[0];
+
+ mag = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
+
+ if(mag)
+ {
+ x[0] /= mag;
+ x[1] /= mag;
+ x[2] /= mag;
+ }
+
+ mag = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
+
+ if(mag)
+ {
+ y[0] /= mag;
+ y[1] /= mag;
+ y[2] /= mag;
+ }
+
+#define M(row,col) m[col*4+row]
+ M(0, 0) = x[0];
+ M(0, 1) = x[1];
+ M(0, 2) = x[2];
+ M(0, 3) = 0.0;
+ M(1, 0) = y[0];
+ M(1, 1) = y[1];
+ M(1, 2) = y[2];
+ M(1, 3) = 0.0;
+ M(2, 0) = z[0];
+ M(2, 1) = z[1];
+ M(2, 2) = z[2];
+ M(2, 3) = 0.0;
+ M(3, 0) = 0.0;
+ M(3, 1) = 0.0;
+ M(3, 2) = 0.0;
+ M(3, 3) = 1.0;
+#undef M
+
+ glMultMatrixd(m);
+ glTranslated(-eyex, -eyey, -eyez);
+}
diff --git a/src/sq_glu.h b/src/sq_glu.h
new file mode 100644
index 0000000..7da7a80
--- /dev/null
+++ b/src/sq_glu.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ sq_glu.h - description
+ -------------------
+ begin : ??? ??? 29 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ * Copyright (C) 1995-2001 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef SQ_GLU_H
+#define SQ_GLU_H
+
+#include <GL/gl.h>
+
+/*
+ * SQ_GLU is a replacement for libGLU. SQ_GLWidget uses only one method
+ * in original GLU library - gluLookAt(). It would be better to place it
+ * in standalone namespace, and remove -lGLU dependency at all.
+ *
+ * Note: Now KSquirrel doesn't use GLU, but TQt's TQGLWidget still
+ * depends on <GL/glu.h>
+ */
+
+namespace SQ_GLU
+{
+ /*
+ * Replacement for gluLookAt().
+ */
+ void gluLookAt(GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble);
+};
+
+#endif
diff --git a/src/sq_glview.cpp b/src/sq_glview.cpp
new file mode 100644
index 0000000..59498ca
--- /dev/null
+++ b/src/sq_glview.cpp
@@ -0,0 +1,360 @@
+/***************************************************************************
+ sq_glview.cpp - description
+ -------------------
+ begin : ??? ??? 5 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqlayout.h>
+#include <tqlabel.h>
+#include <tqtoolbutton.h>
+#include <tqtooltip.h>
+#include <tqhbox.h>
+
+#include <tdeaction.h>
+#include <kstatusbar.h>
+#include <tdetoolbar.h>
+#include <kstandarddirs.h>
+#include <tdeactioncollection.h>
+#include <tdelocale.h>
+#include <ksqueezedtextlabel.h>
+#include <ktabbar.h>
+#include <kiconloader.h>
+
+#include "sq_glview.h"
+#include "sq_glwidget.h"
+#include "sq_glwidget_helpers.h"
+#include "sq_config.h"
+#include "sq_iconloader.h"
+
+#include "ksquirrel.h"
+#include "sq_widgetstack.h"
+
+SQ_GLView * SQ_GLView::m_instance = 0;
+
+SQ_GLView::SQ_GLView(TQWidget *parent) : TQVBox(parent, "ksquirrel-image-window")
+{
+ m_instance = this;
+
+ createContent();
+
+ installEventFilter(this);
+}
+
+SQ_GLView::~SQ_GLView()
+{}
+
+void SQ_GLView::createContent()
+{
+ box = new TQVBox(this);
+
+ m_toolbar = new SQ_ToolBar(box);
+ m_toolbar->setMouseTracking(true);
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ // read settings
+ m_tabs = SQ_Config::instance()->readBoolEntry("tabs", false);
+ m_tabsclose = SQ_Config::instance()->readBoolEntry("tabs_close", true);
+
+ m_tabbar = new KTabBar(box);
+ m_tabbar->setHoverCloseButton(m_tabsclose);
+ m_tabbar->setHoverCloseButtonDelayed(false);
+ m_tabbar->setMouseTracking(true);
+ m_tabbar->setFocusPolicy(TQWidget::NoFocus);
+
+ box->setStretchFactor(m_toolbar, 1);
+
+ m_tabbar->setShown(false);
+
+ gl = new SQ_GLWidget(this, "ksquirrel-opengl-widget");
+ gl->glInitA();
+ gl->setFocus();
+
+ connect(m_tabbar, TQ_SIGNAL(selected(int)), gl, TQ_SLOT(slotChangeTab(int)));
+ connect(m_tabbar, TQ_SIGNAL(closeRequest(int)), gl, TQ_SLOT(slotCloseRequest(int)));
+ connect(m_tabbar, TQ_SIGNAL(mouseMiddleClick(int)), gl, TQ_SLOT(slotCloseRequest(int)));
+ connect(gl, TQ_SIGNAL(tabCountChanged()), this, TQ_SLOT(slotTabCountChanged()));
+
+ setStretchFactor(gl, 1);
+
+ sbar = new KStatusBar(this);
+ sbar->setMouseTracking(true);
+
+ // create TQLabels, fill 'names' with pointers
+ TQHBox *sqSBDecodedBox = new TQHBox;
+ sqSBDecodedBox->setSpacing(2);
+ TQLabel *sqSBDecodedI = new TQLabel(TQString(), sqSBDecodedBox, "SBDecodedI");
+ names.insert("SBDecodedI", sqSBDecodedI);
+ TQLabel *sqSBDecoded = new TQLabel(TQString(), sqSBDecodedBox, "SBDecoded");
+ names.insert("SBDecoded", sqSBDecoded);
+
+ TQLabel *sqSBGLZoom = new TQLabel(TQString(), 0, "SBGLZoom");
+ names.insert("SBGLZoom", sqSBGLZoom);
+ TQLabel *sqSBGLAngle = new TQLabel(TQString(), 0, "SBGLAngle");
+ names.insert("SBGLAngle", sqSBGLAngle);
+ TQLabel *sqSBLoaded = new TQLabel(TQString(), 0, "SBLoaded");
+ TQToolTip::add(sqSBLoaded, i18n("Loading time"));
+ names.insert("SBLoaded", sqSBLoaded);
+ TQLabel *sqSBFrame = new TQLabel(TQString(), 0, "SBFrame");
+ names.insert("SBFrame", sqSBFrame);
+ TQLabel *sqSBFile = new KSqueezedTextLabel(TQString(), 0, "SBFile");
+ names.insert("SBFile", sqSBFile);
+
+ sqSBFrame->setAlignment(TQt::AlignHCenter | TQt::AlignVCenter | TQt::ExpandTabs);
+ sqSBFile->setAlignment(TQt::AlignRight | TQt::AlignTop);
+ TQFont font = sqSBFile->font();
+ font.setBold(true);
+ sqSBFile->setFont(font);
+
+ // fill statusbar
+ sbar->addWidget(sqSBDecodedBox, 0, true);
+ sbar->addWidget(sqSBFrame, 0, true);
+ sbar->addWidget(sqSBLoaded, 0, true);
+ sbar->addWidget(sqSBGLZoom, 0, true);
+ sbar->addWidget(sqSBGLAngle, 0, true);
+ sbar->addWidget(sqSBFile, 1, true);
+
+ resetStatusBar();
+
+ sbar->setShown(SQ_Config::instance()->readBoolEntry("statusbar", true));
+
+ // restore geometry from config file
+ restoreGeometry();
+
+ gl->matrixChanged();
+}
+
+void SQ_GLView::closeEvent(TQCloseEvent *e)
+{
+ // ignore event
+ e->ignore();
+
+ // let KSquirrel close SQ_GLView, since it can be built-in
+ KSquirrel::app()->closeGLWidget();
+}
+
+bool SQ_GLView::eventFilter(TQObject *watched, TQEvent *e)
+{
+ if(watched == this)
+ {
+ // stop animation, if SQ_GLView is hidden (animation becomes useless)
+ if(/*e->type() == TQEvent::WindowDeactivate || */e->type() == TQEvent::Hide)
+ {
+ gl->stopAnimation();
+ return true;
+ }
+ // resume animation, if needed
+ else if(/*e->type() == TQEvent::WindowActivate || */e->type() == TQEvent::Show)
+ {
+ if(!gl->manualBlocked())
+ gl->startAnimation();
+
+ return true;
+ }
+ else // call to default eventFilter()
+ return TQVBox::eventFilter(watched, e);
+ }
+ else
+ return TQVBox::eventFilter(watched, e);
+}
+
+void SQ_GLView::saveGeometry()
+{
+ SQ_Config::instance()->writeEntry("pos", pos());
+ SQ_Config::instance()->writeEntry("size", size());
+}
+
+void SQ_GLView::restoreGeometry()
+{
+ TQPoint p_def(0,0);
+ TQSize sz_def(660, 480);
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ TQPoint p = SQ_Config::instance()->readPointEntry("pos", &p_def);
+ TQSize sz = SQ_Config::instance()->readSizeEntry("size", &sz_def);
+
+ move(p);
+ resize(sz);
+}
+
+/*
+ * Reset all statusbar's labels to default values.
+ */
+void SQ_GLView::resetStatusBar()
+{
+ TQString fl = TQString::fromLatin1("----");
+
+ names["SBGLZoom"]->setText(fl);
+ names["SBGLAngle"]->setText(fl);
+ names["SBLoaded"]->setText(fl);
+ names["SBDecodedI"]->setText(TQString::fromLatin1("--"));
+ names["SBFile"]->setText(TQString::fromLatin1("--------"));
+ names["SBDecoded"]->setText(fl);
+ names["SBFrame"]->setText(TQString::fromLatin1("0/0"));
+}
+
+SQ_ToolBar::SQ_ToolBar(TQWidget *parent) : TDEToolBar(parent)
+{
+ setFixedHeight(SQ_ToolButton::fixedWidth() + 5);
+ boxLayout()->setSpacing(0);
+ boxLayout()->setMargin(0);
+}
+
+SQ_ToolBar::~SQ_ToolBar()
+{}
+
+void SQ_ToolBar::mouseReleaseEvent(TQMouseEvent *e)
+{
+ e->accept();
+}
+
+void SQ_GLView::addPage(const TQString &label)
+{
+ TQTab *tab = new TQTab(label);
+
+ m_tabbar->addTab(tab);
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ if(m_tabsclose)
+ tab->setIconSet(SmallIcon("window-close"));
+}
+
+void SQ_GLView::removePage(int index)
+{
+ m_tabbar->removeTab(m_tabbar->tabAt(index));
+ m_tabbar->setHidden(m_tabbar->count() <= 1);
+}
+
+void SQ_GLView::removeTabs()
+{
+ blockSignals(true);
+ int cnt = m_tabbar->count();
+
+ while(cnt--)
+ m_tabbar->removeTab(m_tabbar->tabAt(0));
+
+ blockSignals(false);
+}
+
+void SQ_GLView::setupTabbar()
+{
+ SQ_Config::instance()->setGroup("GL view");
+
+ int cnt;
+
+ if(m_tabsclose != SQ_Config::instance()->readBoolEntry("tabs_close", true))
+ {
+ m_tabsclose = SQ_Config::instance()->readBoolEntry("tabs_close", true);
+
+ // change iconset
+ cnt = m_tabbar->count();
+
+ for(int i = 0;i < cnt;i++)
+ m_tabbar->tabAt(i)->setIconSet(m_tabsclose ? SmallIcon("window-close") : TQPixmap());
+
+ m_tabbar->setHoverCloseButton(m_tabsclose);
+ m_tabbar->layoutTabs();
+ }
+
+ if(m_tabs == SQ_Config::instance()->readBoolEntry("tabs", false))
+ return;
+
+ blockSignals(true);
+
+ m_tabs = SQ_Config::instance()->readBoolEntry("tabs", false);
+
+ m_tabbar->setHoverCloseButton(m_tabsclose);
+ m_tabbar->setShown(m_tabs);
+
+ int id = m_tabbar->currentTab();
+
+ if(id == -1)
+ {
+ if(m_tabs) m_tabbar->setHidden(m_tabbar->count() <= 1);
+ blockSignals(false);
+ return;
+ }
+
+ int index = m_tabbar->indexOf(id);
+
+ // remove other tabs if needed
+ if(!m_tabs)
+ {
+ int ind = 0;
+ cnt = m_tabbar->count();
+ cnt--;
+
+ while(cnt--)
+ {
+ if(m_tabbar->tabAt(ind)->identifier() == id)
+ {
+ ind++;
+ continue;
+ }
+
+ m_tabbar->removeTab(m_tabbar->tabAt(ind));
+ }
+ }
+ else
+ m_tabbar->setHidden(m_tabbar->count() <= 1);
+
+ blockSignals(false);
+
+ if(!m_tabs)
+ gl->removeNonCurrentTabs(index);
+}
+
+void SQ_GLView::slotTabCountChanged()
+{
+ if(m_tabs)
+ m_tabbar->setHidden(m_tabbar->count() <= 1);
+}
+
+void SQ_GLView::leftTab()
+{
+ int index = m_tabbar->indexOf(m_tabbar->currentTab());
+
+ // smth went wrong
+ if(index < 0) return;
+
+ index--;
+ if(index < 0)
+ index = m_tabbar->count() - 1;
+
+ if(index < 0) return;
+
+ m_tabbar->setCurrentTab(m_tabbar->tabAt(index));
+}
+
+void SQ_GLView::rightTab()
+{
+ int index = m_tabbar->indexOf(m_tabbar->currentTab());
+
+ // smth went wrong
+ if(index < 0) return;
+
+ index++;
+ if(index >= m_tabbar->count())
+ index = 0;
+
+ m_tabbar->setCurrentTab(m_tabbar->tabAt(index));
+}
+
+#include "sq_glview.moc"
diff --git a/src/sq_glview.h b/src/sq_glview.h
new file mode 100644
index 0000000..25b6fc2
--- /dev/null
+++ b/src/sq_glview.h
@@ -0,0 +1,202 @@
+/***************************************************************************
+ sq_glview.h - description
+ -------------------
+ begin : ??? ??? 5 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_GLVIEW_H
+#define SQ_GLVIEW_H
+
+#include <tqvbox.h>
+#include <tqmap.h>
+
+#include <tdetoolbar.h>
+
+class SQ_GLWidget;
+class SQ_LibraryListener;
+class SQ_LibraryHandler;
+class SQ_Config;
+
+class KStatusBar;
+class KTabBar;
+
+class TQLabel;
+
+class SQ_ToolBar : public TDEToolBar
+{
+ public:
+ SQ_ToolBar(TQWidget *parent);
+ ~SQ_ToolBar();
+
+ protected:
+ void mouseReleaseEvent(TQMouseEvent *);
+};
+
+/*
+ * SQ_GLView represents a widget containing SQ_GLWidget, toolbar and statusbar.
+ *
+ *
+ * + -------------------------------------------------+
+ * | | | | | | | | | | | | | | | | | | | <= toolbar with actions (SQ_ToolBar)
+ * |--------------------------------------------------|
+ * | |
+ * | |
+ * | |
+ * | |
+ * | |
+ * | | <= OpenGL widget (SQ_GLWidget)
+ * | |
+ * | |
+ * | |
+ * | |
+ * | |
+ * | |
+ * | |
+ * |--------------------------------------------------| <= statusbar (KStatusBar)
+ * +--------------------------------------------------+
+ *
+ *
+ */
+
+class SQ_GLView : public TQVBox
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_GLView(TQWidget *parent = 0);
+ ~SQ_GLView();
+
+ void leftTab();
+ void rightTab();
+
+ void addPage(const TQString &label);
+
+ void removePage(int);
+ void removeTabs();
+ void setupTabbar();
+
+ bool tabs() const;
+ bool tabsClose() const;
+
+
+ /*
+ * Save current position and size to config
+ */
+ void saveGeometry();
+ void restoreGeometry();
+
+ /*
+ * Reset all statusbar's labels to default values.
+ */
+ void resetStatusBar();
+
+ /*
+ * Get a pointer to statusbar.
+ */
+ KStatusBar* statusbar();
+
+
+ KTabBar* tabbar();
+
+ /*
+ * Get a poniter to toolbar with actions (next file, zoom, rotate...)
+ */
+ SQ_ToolBar* toolbar();
+
+ TQWidget* boxBar();
+
+ /*
+ * Get a pointer to a widget in statusbar by name.
+ */
+ TQLabel* sbarWidget(const TQString &name) const;
+
+ static SQ_GLView* window() { return m_instance; }
+
+ private slots:
+ void slotTabCountChanged();
+
+ protected:
+
+ /*
+ * We want to eat close events. If current version is not 'small',
+ * ignore close event. If current version is 'small', save all important
+ * parameters to config file and accept close event (exit).
+ */
+ void closeEvent(TQCloseEvent *e);
+
+ private:
+
+ /*
+ * Internal.
+ */
+ void createContent();
+
+ virtual bool eventFilter(TQObject *watched, TQEvent *e);
+
+ private:
+ SQ_GLWidget *gl;
+ KStatusBar *sbar;
+ TQMap<TQString, TQLabel* > names;
+ SQ_ToolBar *m_toolbar;
+ KTabBar *m_tabbar;
+ bool m_tabs, m_tabsclose;
+ TQVBox *box;
+
+ static SQ_GLView *m_instance;
+};
+
+inline
+SQ_ToolBar* SQ_GLView::toolbar()
+{
+ return m_toolbar;
+}
+
+inline
+KTabBar* SQ_GLView::tabbar()
+{
+ return m_tabbar;
+}
+
+inline
+KStatusBar* SQ_GLView::statusbar()
+{
+ return sbar;
+}
+
+inline
+TQLabel* SQ_GLView::sbarWidget(const TQString &name) const
+{
+ return names[name];
+}
+
+inline
+bool SQ_GLView::tabs() const
+{
+ return m_tabs;
+}
+
+inline
+bool SQ_GLView::tabsClose() const
+{
+ return m_tabsclose;
+}
+
+inline
+TQWidget* SQ_GLView::boxBar()
+{
+ return box;
+}
+
+#endif
diff --git a/src/sq_glwidget.cpp b/src/sq_glwidget.cpp
new file mode 100644
index 0000000..0380090
--- /dev/null
+++ b/src/sq_glwidget.cpp
@@ -0,0 +1,2006 @@
+/***************************************************************************
+ sq_glwidget.cpp - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqeventloop.h>
+#include <tqstringlist.h>
+#include <tqfileinfo.h>
+#include <tqdatetime.h>
+#include <tqlabel.h>
+#include <tqtimer.h>
+#include <tqdatetime.h>
+#include <tqslider.h>
+#include <tqlabel.h>
+
+#include <tdeapplication.h>
+#include <tdeaction.h>
+#include <kcursor.h>
+#include <kstandarddirs.h>
+#include <kstatusbar.h>
+#include <tdefiledialog.h>
+#include <tdeglobal.h>
+#include <tdelocale.h>
+#include <kstringhandler.h>
+#include <tdemessagebox.h>
+#include <kdebug.h>
+#include <tdeio/job.h>
+#include <tdetempfile.h>
+#include <twin.h>
+#include <ktabbar.h>
+
+#include <cmath>
+#include <cstdlib>
+
+#ifndef KSQUIRREL_PART
+#include "ksquirrel.h"
+#include "sq_widgetstack.h"
+#include "sq_glview.h"
+#include "sq_fileiconview.h"
+#include "sq_diroperator.h"
+#include "sq_hloptions.h"
+#include "sq_previewwidget.h"
+#include "sq_tabopendialog.h"
+#endif
+
+#include "sq_popupmenu.h"
+#include "sq_libraryhandler.h"
+#include "sq_config.h"
+#include "sq_glwidget_helpers.h"
+#include "sq_glwidget.h"
+#include "sq_glu.h"
+#include "sq_codecsettings.h"
+#include "sq_glselectionpainter.h"
+#include "sq_utils.h"
+#include "sq_errorstring.h"
+#include "fmt_filters.h"
+
+#include <ksquirrel-libs/fileio.h>
+#include <ksquirrel-libs/fmt_codec_base.h>
+#include <ksquirrel-libs/fmt_utils.h>
+#include <ksquirrel-libs/error.h>
+
+#ifdef SQ_HAVE_KEXIF
+#include <libkexif/kexifdata.h>
+#endif
+
+// is it enough ?
+#define SQ_FLOAT_SIGMA 1e-5
+
+#define ISFLOAT(a,b) (fabs(a - b) < SQ_FLOAT_SIGMA)
+#define ISFLOAT1(a) ISFLOAT(a, 1.0)
+#define ISFLOAT0(a) ISFLOAT(a, 0.0)
+
+#define SQ_TAB_TEXT_LENGTH 30
+
+/* ***************************************************************************************** */
+
+SQ_GLWidget * SQ_GLWidget::m_instance = 0;
+
+static const int timer_delay_file = 5;
+static const double rad_const = 3.14159265358979323846 / 180.0;
+
+static const float SQ_WINDOW_BACKGROUND_POS = -1000.0;
+static const float SQ_IMAGE_CHECKER_POS = -999.0;
+static const float SQ_FIRST_FRAME_POS = -998.0;
+static const float SQ_MARKS_POS = -997.0;
+static const float SQ_FIRST_TILE_LAYER = -995.0;
+static const float SQ_ONSCREEN_LAYER = 10000.0;
+
+/* ***************************************************************************************** */
+
+SQ_GLWidget::SQ_GLWidget(TQWidget *parent, const char *name) : TQGLWidget(parent, name)
+{
+ kdDebug() << "+SQ_GLWidget" << endl;
+
+ // init all variables...
+ m_instance = this;
+
+#ifdef KSQUIRREL_PART
+ connect(&t_glv, TQ_SIGNAL(message(const TQString &)), this, TQ_SIGNAL(message(const TQString &)));
+#endif
+
+ zoomMenu = 0;
+ selectionMenu = 0;
+ images = 0;
+ parts_broken = 0;
+
+ ac = new TDEActionCollection(this, this, "GLWidget actionCollection");
+ changed = blocked = decoded = reset_mode = false;
+ movetype = -1;
+ buffer = new RGBA [512 * 512];
+ zoomFactor = 1.0;
+ old_id = -1;
+ menu = new TQPopupMenu(this);
+ hackResizeGL = false;
+ lastCopy = KURL::fromPathOrURL("/");
+ oldZoom = -1;
+
+ percentsLabel = new TQLabel(this);
+ percentsLabel->move(4, 4);
+ percentsLabel->hide();
+
+ tabold = tab = &taborig;
+
+ tmp = new KTempFile;
+ tmp->setAutoDelete(true);
+ tmp->close();
+
+ SQ_Config::instance()->setGroup("GL view");
+ zoom_type = SQ_Config::instance()->readNumEntry("zoom type", 2);
+ linear = SQ_Config::instance()->readBoolEntry("zoom_nice", true);
+
+ // load background for transparent image
+ BGquads = TQImage(locate("data", "images/checker.png"));
+
+ if(BGquads.isNull())
+ {
+ BGquads = TQImage(32, 32, 32);
+ BGquads.setAlphaBuffer(true);
+ BGquads.fill(0);
+ }
+
+ bindChecker = true;
+
+ zoomfactor = SQ_Config::instance()->readNumEntry("zoom", 25);
+ movefactor = SQ_Config::instance()->readNumEntry("move", 5);
+ rotatefactor = SQ_Config::instance()->readNumEntry("angle", 90);
+
+ // load cursors
+ setCursor(KCursor::arrowCursor());
+
+ setFocusPolicy(TQWidget::WheelFocus);
+ setAcceptDrops(true);
+
+ // popup menu with image pages
+ images = new TDEPopupMenu;
+ images->setCheckable(true);
+
+ // create actions
+ createActions();
+
+ // create toolbars
+ createToolbar();
+
+ // create tickmarks
+ createMarks();
+
+ initAccelsAndMenu();
+
+ enableActions(false);
+
+ KCursor::setAutoHideCursor(this, true);
+ KCursor::setHideCursorDelay(2500);
+
+#ifndef KSQUIRREL_PART
+ timer_prev = new TQTimer(this);
+ timer_next = new TQTimer(this);
+
+ TQ_CHECK_PTR(timer_prev);
+ TQ_CHECK_PTR(timer_next);
+
+ connect(timer_prev, TQ_SIGNAL(timeout()), SQ_WidgetStack::instance(), TQ_SLOT(emitPreviousSelected()));
+ connect(timer_next, TQ_SIGNAL(timeout()), SQ_WidgetStack::instance(), TQ_SLOT(emitNextSelected()));
+#endif
+
+ timer_anim = new TQTimer(this);
+
+ TQ_CHECK_PTR(timer_anim);
+
+ connect(timer_anim, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotAnimateNext()));
+
+ connect(images, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotSetCurrentImage(int)));
+ connect(images, TQ_SIGNAL(aboutToHide()), this, TQ_SLOT(slotImagesHidden()));
+ connect(images, TQ_SIGNAL(aboutToShow()), this, TQ_SLOT(slotImagesShown()));
+
+ gls = new SQ_GLSelectionPainter(this);
+}
+
+SQ_GLWidget::~SQ_GLWidget()
+{
+ kdDebug() << "-SQ_GLWidget" << endl;
+
+ delete gls;
+
+ delete parts_broken;
+
+ removeCurrentTabs();
+
+ delete selectionMenu;
+ delete zoomMenu;
+ delete images;
+ delete [] buffer;
+ delete tmp;
+}
+
+// Initialize OpenGL context. Used internally by TQGLWidget.
+void SQ_GLWidget::initializeGL()
+{
+ setClearColor();
+ glClearDepth(1.0);
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_ALPHA_TEST);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glShadeModel(GL_FLAT);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+
+ // finally, clear
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ // create "broken" image
+ initBrokenImage();
+
+ initMarks();
+}
+
+// Resize OpenGL context. Used internally by TQGLWidget.
+void SQ_GLWidget::resizeGL(int width, int height)
+{
+ gls->setSourceSize(width, height);
+
+ // set new viewport
+ glViewport(0, 0, width, height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+
+ // O(0,0) will be in the center of the window
+ glOrtho(-width/2, width/2, -height/2, height/2, 0.1f, 10000.0);
+
+ // camera setup
+ SQ_GLU::gluLookAt(0,0,1, 0,0,0, 0,1,0);
+ glMatrixMode(GL_MODELVIEW);
+
+ if(decoded && !hackResizeGL)
+ slotZoomIfLess();
+
+ hackResizeGL = false;
+}
+
+/*
+ * Fill a w x h region with texture. Generate texture if needed.
+ */
+void SQ_GLWidget::draw_background(void *bits, unsigned int *tex, int dim, GLfloat w, GLfloat h, bool &bind, bool deleteOld)
+{
+ float half_w, half_h;
+
+ half_w = w / 2.0;
+ half_h = h / 2.0;
+
+ // bind texture ?
+ if(bind)
+ {
+ // delete old texture before binding ?
+ if(deleteOld)
+ glDeleteTextures(1, tex);
+
+ // generate and bind texture
+ glGenTextures(1, tex);
+ glBindTexture(GL_TEXTURE_2D, *tex);
+
+ // setup parameters
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+
+ // assign image to texture
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dim, dim, 0, GL_RGBA, GL_UNSIGNED_BYTE, bits);
+
+ bind = false;
+ }
+ else
+ glBindTexture(GL_TEXTURE_2D, *tex);
+
+ // draw
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0, 0.0); glVertex2f(-half_w, half_h);
+ glTexCoord2f(w/(GLfloat)dim, 0.0); glVertex2f(half_w, half_h);
+ glTexCoord2f(w/(GLfloat)dim, h/(GLfloat)dim); glVertex2f(half_w, -half_h);
+ glTexCoord2f(0.0, h/(GLfloat)dim); glVertex2f(-half_w, -half_h);
+ glEnd();
+}
+
+// Redraw OpenGL context. Used internally by TQGLWidget.
+void SQ_GLWidget::paintGL()
+{
+ int z;
+
+ // clear
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ if(gls->valid())
+ {
+ matrix_push();
+ matrix_pure_reset();
+ TQPoint p = gls->center();
+
+ // move to selection center
+ MATRIX_X = p.x();
+ MATRIX_Y = p.y();
+ write_gl_matrix();
+
+ gls->draw();
+
+ matrix_pop();
+ write_gl_matrix();
+ }
+
+ glEnable(GL_TEXTURE_2D);
+
+ // draw window background ?
+ SQ_Config::instance()->setGroup("GL view");
+ if(SQ_Config::instance()->readNumEntry("GL view background type", 1) == 2)
+ {
+ static bool del = false;
+ matrix_push();
+ matrix_pure_reset();
+ matrix_move_z(SQ_WINDOW_BACKGROUND_POS);
+ draw_background(BGpixmap.bits(), &texPixmap, BGpixmap.width(), width(), height(), changed, del);
+ del = true;
+ matrix_pop();
+ write_gl_matrix();
+ }
+
+ // draw image
+ if(!reset_mode && decoded)
+ {
+ SQ_Config::instance()->setGroup("GL view");
+
+ fmt_image *im = &tab->finfo.image[tab->current];
+
+ // if the image is transparent, and we should draw background for image
+ if(im->hasalpha && SQ_Config::instance()->readBoolEntry("alpha_bkgr", true))
+ {
+ GLfloat w = (float)im->w / 2.0, h = (float)im->h / 2.0;
+
+ static const GLdouble eq[4][4] =
+ {
+ {0.0, 1.0, 0.0, 0.0},
+ {1.0, 0.0, 0.0, 0.0},
+ {0.0, -1.0, 0.0, 0.0},
+ {-1.0, 0.0, 0.0, 0.0}
+ };
+
+ // we will draw background for transparent image (quads) within
+ // entire window, and cut off useless regions with clip planes
+ glPushMatrix();
+ glTranslatef(-w, -h, 0.0);
+ glClipPlane(GL_CLIP_PLANE0, eq[0]);
+ glClipPlane(GL_CLIP_PLANE1, eq[1]);
+ glEnable(GL_CLIP_PLANE0);
+ glEnable(GL_CLIP_PLANE1);
+ glPopMatrix();
+ glPushMatrix();
+ glTranslatef(w, h, 0.0);
+ glClipPlane(GL_CLIP_PLANE2, eq[2]);
+ glClipPlane(GL_CLIP_PLANE3, eq[3]);
+ glEnable(GL_CLIP_PLANE2);
+ glEnable(GL_CLIP_PLANE3);
+ glPopMatrix();
+
+ // draw background
+ matrix_push();
+ matrix_pure_reset();
+ matrix_move_z(SQ_IMAGE_CHECKER_POS);
+ draw_background(BGquads.bits(), &texQuads, 32, width(), height(), bindChecker, !bindChecker);
+ matrix_pop();
+ write_gl_matrix();
+
+ // don't need planes any more...
+ glDisable(GL_CLIP_PLANE3);
+ glDisable(GL_CLIP_PLANE2);
+ glDisable(GL_CLIP_PLANE1);
+ glDisable(GL_CLIP_PLANE0);
+ }
+
+ matrix_move_z(SQ_FIRST_FRAME_POS);
+
+ Parts *pt = tab->broken ? parts_broken : &tab->parts[tab->current];
+
+ // draw current image
+ int toy = pt->tilesy.size();
+ int tox = pt->tilesx.size();
+ for(z = 0;z < toy;z++)
+ if(glIsList(pt->m_parts[z * tox].list))
+ glCallList(pt->m_parts[z * tox].list);
+
+ // draw tickmarks ("broken" image won't have tickmarks)
+ if(!tab->broken && marks && SQ_Config::instance()->readBoolEntry("marks", true))
+ {
+ GLfloat zum = getZoom();
+ GLfloat x = fabsf(pt->m_parts[0].x1) * zum, y = pt->m_parts[0].y1 * zum;
+ GLfloat X = MATRIX_X, Y = MATRIX_Y;
+
+ if(x < 0.0)
+ x = -x;
+
+ const GLfloat ly = y+16, ry = -y-16;
+ const GLfloat lx = x+16, rx = -x-16;
+
+ matrix_push();
+ matrix_pure_reset();
+ MATRIX_X = X;
+ MATRIX_Y = Y;
+ matrix_rotate2(tab->curangle);
+ matrix_move_z(SQ_MARKS_POS);
+
+ GLfloat coords[4][8] =
+ {
+ {rx, ly, -x, ly, -x, y, rx, y},
+ {x, ly, lx, ly, lx, y, x, y},
+ {x, -y, lx, -y, lx, ry, x, ry},
+ {rx, -y, -x, -y, -x, ry, rx, ry}
+ };
+
+ for(z = 0;z < 4;z++)
+ {
+ glBindTexture(GL_TEXTURE_2D, mark[z]);
+
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0, 0.0); glVertex2f(coords[z][0], coords[z][1]);
+ glTexCoord2f(1.0, 0.0); glVertex2f(coords[z][2], coords[z][3]);
+ glTexCoord2f(1.0, 1.0); glVertex2f(coords[z][4], coords[z][5]);
+ glTexCoord2f(0.0, 1.0); glVertex2f(coords[z][6], coords[z][7]);
+ glEnd();
+ }
+
+ matrix_pop();
+ write_gl_matrix();
+ }
+ }
+
+ glDisable(GL_TEXTURE_2D);
+
+ matrixChanged();
+
+ if(!tab->broken && tab->total > 1)
+ frameChanged();
+}
+
+/*
+ * Change statusbar info according with
+ * current matrix (it shows current zoom & angle values).
+ */
+void SQ_GLWidget::matrixChanged()
+{
+ TQString str;
+
+ float m = getZoom();
+ float fzoom = m * 100.0;
+ float z = (m < 1.0) ? 1.0/m : m;
+
+ // construct zoom
+ str = TQString::fromLatin1("%1% [%2:%3]")
+ .arg(fzoom, 0, 'f', 1)
+ .arg((m < 1.0)?1.0:z, 0, 'f', 1)
+ .arg((m > 1.0)?1.0:z, 0, 'f', 1);
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBGLZoom")->setText(str);
+#else
+ t_glv.sbarWidget("SBGLZoom")->setText(str);
+#endif
+
+ // construct rotation angle
+ str = TQString::fromLatin1("%1%2 %3 deg")
+ .arg((tab->isflippedV)?"V":"")
+ .arg((tab->isflippedH)?"H":"")
+ .arg(tab->curangle, 0, 'f', 1);
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBGLAngle")->setText(str);
+#else
+ t_glv.sbarWidget("SBGLAngle")->setText(str);
+#endif
+}
+
+/*
+ * Mouse wheel event. Let's load next/previous image, or
+ * zoom in/zoom out (depends on settings).
+ */
+void SQ_GLWidget::wheelEvent(TQWheelEvent *e)
+{
+ if(e->delta() < 0 && e->state() == TQt::NoButton)
+ {
+#ifndef KSQUIRREL_PART
+ SQ_Config::instance()->setGroup("GL view");
+
+ // load next file in current directory
+ if(SQ_Config::instance()->readNumEntry("scroll", 0))
+ slotNext();
+ else
+#endif
+
+ slotZoomPlus();
+ }
+ else if(e->delta() > 0 && e->state() == TQt::NoButton)
+ {
+#ifndef KSQUIRREL_PART
+ SQ_Config::instance()->setGroup("GL view");
+
+ if(SQ_Config::instance()->readNumEntry("scroll", 0))
+ slotPrev();
+ else
+#endif
+
+ slotZoomMinus();
+ }
+ // some special bindings:
+ // if CTRL key is pressed, zoom 2x or 0.5x
+ else if(e->delta() < 0 && e->state() == TQt::ControlButton)
+ matrix_zoom(2.0);
+ else if(e->delta() > 0 && e->state() == TQt::ControlButton)
+ matrix_zoom(0.5f);
+ else if(e->delta() < 0 && e->state() == TQt::ShiftButton)
+ slotZoomPlus();
+ else if(e->delta() > 0 && e->state() == TQt::ShiftButton)
+ slotZoomMinus();
+}
+
+// User pressed mouse button down.
+void SQ_GLWidget::mousePressEvent(TQMouseEvent *e)
+{
+ setFocus();
+
+ // left button, update cursor
+ if(e->button() == TQt::LeftButton && e->state() == TQt::NoButton && tab->glselection == -1)
+ {
+#ifndef KSQUIRREL_PART
+ TQTime t = TQTime::currentTime();
+
+ SQ_Config::instance()->setGroup("GL view");
+ int dc = SQ_Config::instance()->readNumEntry("double_click", 0);
+
+ if(dc && clickTime.isValid() && clickTime.msecsTo(t) <= TDEApplication::doubleClickInterval())
+ {
+ if(dc == 1)
+ KSquirrel::app()->closeGLWidget();
+ else
+ toggleFullScreen();
+
+ return;
+ }
+ else
+ clickTime = t;
+
+#endif
+ setCursor(KCursor::sizeAllCursor());
+
+ xmoveold = e->x();
+ ymoveold = e->y();
+
+ movetype = 1;
+ }
+ // left button + SHIFT, let's start drawing zoom frame
+ else if(e->button() == TQt::LeftButton && (e->state() == TQt::ShiftButton || tab->glselection != -1))
+ {
+ // stop animation!
+ stopAnimation();
+
+ // update cursor to crosshair
+ setCursor(KCursor::crossCursor());
+
+ if(tab->glselection == SQ_GLSelectionPainter::Rectangle || tab->glselection == SQ_GLSelectionPainter::Ellipse)
+ gls->begin(static_cast<SQ_GLSelectionPainter::Type>(tab->glselection), e->x(), e->y());
+ else
+ gls->begin(SQ_GLSelectionPainter::Rectangle, e->x(), e->y());
+
+ movetype = 2;
+ }
+ // right button - show context menu
+ else if(e->button() == TQt::RightButton)
+ menu->popup(TQCursor::pos());
+ // middle button - toggle fullscreen state
+ else if(e->button() == TQt::MidButton)
+ toggleFullScreen();
+}
+
+// User moved mouse.
+void SQ_GLWidget::mouseMoveEvent(TQMouseEvent *e)
+{
+ // user didn't press any mouse button before ?
+ if(movetype == -1 && fullscreen())
+ {
+#if 0
+// bool tvis = SQ_GLView::window()->toolbar()->isShown();
+// bool svis = SQ_GLView::window()->statusbar()->isShown();
+
+ int h = SQ_GLView::window()->toolbar()->height() +
+ SQ_GLView::window()->tabbar()->height();
+
+#warning FIXME
+#ifndef KSQUIRREL_PART
+ hackResizeGL = true;
+ SQ_GLView::window()->boxBar()->setShown((/*tvis ? false:*/(e->y() < h)));
+ SQ_GLView::window()->statusbar()->setShown((/*svis ? false:*/(e->y() >
+ height()-SQ_GLView::window()->statusbar()->height())));
+#endif
+#endif
+ return;
+ }
+
+ // left mouse button, lets move image (or matrix :-) )
+ if(movetype == 1)
+ {
+ xmove = e->x();
+ ymove = e->y();
+
+ matrix_move(xmove-xmoveold, -ymove+ymoveold);
+
+ xmoveold = e->x();
+ ymoveold = e->y();
+ }
+ // left + SHIFT
+ else if(movetype == 2)
+ gls->move(e->x(), e->y());
+}
+
+// User released some mouse button.
+void SQ_GLWidget::mouseReleaseEvent(TQMouseEvent *)
+{
+ if(movetype == -1)
+ return;
+
+ // left button - restore cursor
+ if(movetype == 1 || (movetype == 2 && tab->glselection != -1)) // permanent selection
+ setCursor(KCursor::arrowCursor());
+ // left button + SHIFT - zoom to selected rectangle (if needed)
+ else if(movetype == 2 && tab->glselection == -1)
+ {
+ setCursor(KCursor::arrowCursor());
+
+ TQSize sz = gls->size();
+ TQPoint pt = gls->pos();
+ TQRect lastRect(pt.x(), pt.y(), sz.width(), sz.height());
+
+ gls->end();
+
+ TQPoint lastC = lastRect.center();
+ TQPoint O(width() / 2, height() / 2);
+
+ if(lastRect.width() > 2 && lastRect.height() > 2)
+ {
+ bool lastReset = reset_mode;
+ reset_mode = true;
+ float X = MATRIX_X, Y = MATRIX_Y;
+ matrix_move(O.x() - lastC.x(), lastC.y() - O.y());
+ reset_mode = lastReset;
+
+ // try to zoom
+ bool zoomed = tab->broken ? false : zoomRect(lastRect);
+
+ // not zoomed ? (zoom > maximum zoom)
+ if(!zoomed)
+ {
+ MATRIX_X = X;
+ MATRIX_Y = Y;
+ write_gl_matrix();
+ }
+ }
+
+ updateGL();
+
+ // start animation, if needed
+ if(!manualBlocked())
+ startAnimation();
+ }
+
+ movetype = -1;
+}
+
+/*
+ * Zoom to 'r'. Will be called after somebody used right mouse button
+ * to select zoom region.
+ */
+bool SQ_GLWidget::zoomRect(const TQRect &r)
+{
+ // calculate zoom factor
+ float factor = 1.0;
+ float w = (float)width(), h = (float)height();
+ float factorw = w / (float)r.width();
+ float factorh = h / (float)r.height();
+ float t = w / h;
+
+ if(t > (float)r.width() / (float)r.height())
+ factor = factorh;
+ else
+ factor = factorw;
+
+ // try to zoom
+ return matrix_zoom(factor);
+}
+
+// Fit width.
+void SQ_GLWidget::slotZoomW()
+{
+ zoom_type = 0;
+ pAZoomW->setChecked(true);
+
+ // no image decoded
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ // calculate zoom factor
+ float factor = (float)width() / (tab->rotate ? (float)tab->finfo.image[tab->current].h : (float)tab->finfo.image[tab->current].w);
+
+ // "Ignore, if the image is less than window" - restore zoom factor to 1.0
+ if(pAIfLess->isChecked() && (tab->finfo.image[tab->current].w < width() && tab->finfo.image[tab->current].h < height()))
+ factor = 1.0;
+
+ // zoom...
+ internalZoom(factor);
+}
+
+// Fit height.
+void SQ_GLWidget::slotZoomH()
+{
+ zoom_type = 1;
+ pAZoomH->setChecked(true);
+
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ float factor = (float)height() / (tab->rotate ? (float)tab->finfo.image[tab->current].w : (float)tab->finfo.image[tab->current].h);
+
+ if(pAIfLess->isChecked() && (tab->finfo.image[tab->current].w < width() && tab->finfo.image[tab->current].h < height()))
+ factor = 1.0;
+
+ internalZoom(factor);
+}
+
+// Fit image (e.g. width and height).
+void SQ_GLWidget::slotZoomWH()
+{
+ zoom_type = 2;
+ pAZoomWH->setChecked(true);
+
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ float factor = 1.0;
+ float w = (float)width(), h = (float)height();
+ float factorw = w / (tab->rotate ? (float)tab->finfo.image[tab->current].h : (float)tab->finfo.image[tab->current].w);
+ float factorh = h / (tab->rotate ? (float)tab->finfo.image[tab->current].w : (float)tab->finfo.image[tab->current].h);
+ float t = w / h;
+ float F = tab->rotate ? ((float)tab->finfo.image[tab->current].h / (float)tab->finfo.image[tab->current].w) : ((float)tab->finfo.image[tab->current].w / (float)tab->finfo.image[tab->current].h);
+
+ if(t > F)
+ factor = factorh;
+ else
+ factor = factorw;
+
+ if(pAIfLess->isChecked() && (tab->finfo.image[tab->current].w < width() && tab->finfo.image[tab->current].h < height()))
+ factor = 1.0;
+
+ internalZoom(factor);
+}
+
+// Previous zoom.
+void SQ_GLWidget::slotZoomLast()
+{
+ zoom_type = 4;
+ pAZoomLast->setChecked(true);
+
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ internalZoom(zoomFactor);
+}
+
+// Zoom 100%.
+void SQ_GLWidget::slotZoom100()
+{
+ zoom_type = 3;
+ pAZoom100->setChecked(true);
+
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ internalZoom(1.0);
+}
+
+// "Ignore, if the image is less than window"
+void SQ_GLWidget::slotZoomIfLess()
+{
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ switch(zoom_type)
+ {
+ case 0: slotZoomW(); break;
+ case 1: slotZoomH(); break;
+ case 2: slotZoomWH(); break;
+ case 3: break;
+
+ default:
+ slotZoomLast();
+ }
+}
+
+// Zoom+
+void SQ_GLWidget::slotZoomPlus()
+{
+ matrix_zoom(1.0+zoomfactor/100.0);
+}
+
+// Zoom-
+void SQ_GLWidget::slotZoomMinus()
+{
+ matrix_zoom(1.0/(1.0+zoomfactor/100.0));
+}
+
+// Rotate left.
+void SQ_GLWidget::slotRotateLeft()
+{
+ matrix_rotate(-rotatefactor);
+}
+
+// Rotate right.
+void SQ_GLWidget::slotRotateRight()
+{
+ matrix_rotate(rotatefactor);
+}
+
+/*
+ operations with matrices are taken from GLiv =)
+
+ thanks to Guillaume Chazarian.
+*/
+void SQ_GLWidget::flip(int id, bool U)
+{
+ GLfloat x = MATRIX_X, y = MATRIX_Y;
+ MATRIX_X = 0;
+ MATRIX_Y = 0;
+
+ tab->matrix[id] *= -1.0;
+ tab->matrix[id + 1] *= -1.0;
+ tab->matrix[id + 3] *= -1.0;
+
+ MATRIX_X = x;
+ MATRIX_Y = y;
+
+ write_gl_matrix();
+
+ if(!reset_mode && U)
+ updateGL();
+}
+
+void SQ_GLWidget::slotFlipH()
+{
+ if(!tab->broken)
+ {
+ tab->isflippedH = !tab->isflippedH;
+ flip(0);
+ }
+}
+
+void SQ_GLWidget::slotFlipV()
+{
+ if(!tab->broken)
+ {
+ tab->isflippedV = !tab->isflippedV;
+ flip(4);
+ }
+}
+
+void SQ_GLWidget::slotMatrixReset()
+{
+ if(!tab->broken)
+ {
+ oldZoom = getZoom();
+ matrix_reset(false);
+ matrix_zoom(1.0);
+ }
+}
+
+void SQ_GLWidget::write_gl_matrix()
+{
+ GLfloat transposed[16] =
+ {
+ 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0
+ };
+
+ transposed[0] = MATRIX_C1;
+ transposed[5] = MATRIX_C2;
+ transposed[4] = MATRIX_S1;
+ transposed[1] = MATRIX_S2;
+ transposed[12] = MATRIX_X;
+ transposed[13] = MATRIX_Y;
+ transposed[14] = MATRIX_Z;
+
+ glLoadMatrixf(transposed);
+}
+
+void SQ_GLWidget::matrix_move(GLfloat x, GLfloat y)
+{
+ if(tab->broken) return;
+
+ MATRIX_X += x;
+ MATRIX_Y += y;
+
+ write_gl_matrix();
+
+ if(!reset_mode)
+ updateGL();
+}
+
+void SQ_GLWidget::matrix_move_z(GLfloat z)
+{
+ MATRIX_Z = z;
+
+ write_gl_matrix();
+}
+
+void SQ_GLWidget::matrix_push()
+{
+ memcpy(saved, tab->matrix, sizeof(tab->matrix));
+}
+
+void SQ_GLWidget::matrix_pop()
+{
+ memcpy(tab->matrix, saved, sizeof(tab->matrix));
+}
+
+void SQ_GLWidget::matrix_reset(bool U)
+{
+ tab->nullMatrix();
+
+ tab->curangle = 0.0;
+ tab->isflippedH = tab->isflippedV = false;
+
+ if(decoded)
+ exifRotate(U);
+}
+
+void SQ_GLWidget::matrix_pure_reset()
+{
+ tab->nullMatrix();
+ write_gl_matrix();
+}
+
+bool SQ_GLWidget::matrix_zoom(GLfloat ratio)
+{
+ if(tab->broken) return false;
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ int zoom_lim = SQ_Config::instance()->readNumEntry("zoom limit", 1);
+ GLfloat zoom_min, zoom_max, zoom_tobe;
+
+ zoom_tobe = hypot(MATRIX_C1 * ratio, MATRIX_S1 * ratio) * 100.0;
+
+ switch(zoom_lim)
+ {
+ case 2:
+ zoom_min = (float)SQ_Config::instance()->readNumEntry("zoom_min", 1);
+ zoom_max = (float)SQ_Config::instance()->readNumEntry("zoom_max", 10000);
+ break;
+
+ default: // "case 1:" too
+ zoom_min = 1.0;
+ zoom_max = 10000.0;
+ }
+
+ if(zoom_lim)
+ {
+ float z = getZoomPercents();
+
+ // zoom limit exceeded - do nothing
+ if((z >= zoom_max && ratio > 1.0) || (z <= zoom_min && ratio < 1.0))
+ return false;
+
+ // if the new zoom will be greater (smaller) than maximum
+ // (minimum) zoom - scale it.
+ if(ratio < 1.0 && zoom_min >= zoom_tobe)
+ ratio = ratio * zoom_min / zoom_tobe;
+ else if(ratio > 1.0 && zoom_max <= zoom_tobe)
+ ratio = ratio * zoom_max / zoom_tobe;
+ }
+
+ GLfloat oldz = (oldZoom == -1 ? getZoom() : oldZoom);
+
+ MATRIX_C1 *= ratio;
+ MATRIX_S1 *= ratio;
+ MATRIX_X *= ratio;
+ MATRIX_S2 *= ratio;
+ MATRIX_C2 *= ratio;
+ MATRIX_Y *= ratio;
+
+ hackMatrix();
+
+ GLfloat z = getZoom();
+ int filter = -1;
+
+ if(ISFLOAT1(oldz) && !ISFLOAT1(z))
+ filter = linear ? GL_LINEAR : GL_NEAREST;
+ else if(ISFLOAT1(z))
+ filter = GL_NEAREST;
+
+ // update all textures
+ if(filter != -1)
+ {
+ for(int i = 0;i < tab->total;i++)
+ {
+ int toxy = tab->parts[i].m_parts.size();
+
+ for(int j = 0;j < toxy;j++)
+ {
+ glBindTexture(GL_TEXTURE_2D, tab->parts[i].m_parts[j].tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+ }
+ }
+ }
+
+ oldZoom = -1;
+ write_gl_matrix();
+
+ changeSlider(z);
+
+ if(!reset_mode)
+ updateGL();
+
+ return true;
+}
+
+/*
+ * Floating point operations are not 100% exact.
+ * We should correct matrix values.
+ */
+void SQ_GLWidget::hackMatrix()
+{
+ if(ISFLOAT1(MATRIX_C1)) MATRIX_C1 = MATRIX_C1 < 0 ? -1.0 : 1.0;
+ else if(ISFLOAT0(MATRIX_C1)) MATRIX_C1 = 0.0;
+
+ if(ISFLOAT1(MATRIX_C2)) MATRIX_C2 = MATRIX_C2 < 0 ? -1.0 : 1.0;
+ else if(ISFLOAT0(MATRIX_C2)) MATRIX_C2 = 0.0;
+
+ if(ISFLOAT1(MATRIX_S1)) MATRIX_S1 = MATRIX_S1 < 0 ? -1.0 : 1.0;
+ else if(ISFLOAT0(MATRIX_S1)) MATRIX_S1 = 0.0;
+
+ if(ISFLOAT1(MATRIX_S2)) MATRIX_S2 = MATRIX_S2 < 0 ? -1.0 : 1.0;
+ else if(ISFLOAT0(MATRIX_S2)) MATRIX_S2 = 0.0;
+
+ if(ISFLOAT0(MATRIX_X)) MATRIX_X = 0.0;
+ if(ISFLOAT0(MATRIX_Y)) MATRIX_Y = 0.0;
+}
+
+GLfloat SQ_GLWidget::getZoom() const
+{
+ return hypot(MATRIX_C1, MATRIX_S1);
+}
+
+GLfloat SQ_GLWidget::getZoomPercents() const
+{
+ return getZoom() * 100.0;
+}
+
+void SQ_GLWidget::matrix_rotate(GLfloat angle, bool U)
+{
+ if(tab->broken) return;
+
+ GLfloat c1 = MATRIX_C1, c2 = MATRIX_C2, s1 = MATRIX_S1, s2 = MATRIX_S2;
+
+ double rad = angle * rad_const;
+ double cosine = cos(rad);
+ double sine = sin(rad);
+
+ MATRIX_C1 = c1 * cosine + s2 * sine;
+ MATRIX_S1 = s1 * cosine + c2 * sine;
+ MATRIX_S2 = -c1 * sine + s2 * cosine;
+ MATRIX_C2 = -s1 * sine + c2 * cosine;
+
+ hackMatrix();
+
+ tab->curangle += angle;
+
+ if(tab->curangle == 360.0 || tab->curangle == -360.0)
+ tab->curangle = 0.0;
+ else if(tab->curangle > 360.0)
+ tab->curangle -= 360.0;
+ else if(tab->curangle < -360.0)
+ tab->curangle += 360.0;
+
+ write_gl_matrix();
+
+ if(U)
+ updateGL();
+}
+
+void SQ_GLWidget::matrix_rotate2(GLfloat angle)
+{
+ GLfloat c1 = MATRIX_C1, c2 = MATRIX_C2, s1 = MATRIX_S1, s2 = MATRIX_S2;
+
+ double rad = angle * rad_const;
+ double cosine = cos(rad);
+ double sine = sin(rad);
+
+ MATRIX_C1 = c1 * cosine + s2 * sine;
+ MATRIX_S1 = s1 * cosine + c2 * sine;
+ MATRIX_S2 = -c1 * sine + s2 * cosine;
+ MATRIX_C2 = -s1 * sine + c2 * cosine;
+
+ write_gl_matrix();
+}
+
+/*
+ * Bind textures, draw them and create GL lists.
+ * Also show textures by executing GL lists, if 'swap' = true.
+ */
+bool SQ_GLWidget::showFrames(int i, Parts *p, bool swap)
+{
+ int z, k = 0;
+ const int a = p->tilesx.size() * i, b = a + p->tilesx.size();
+ int filter = linear ? GL_LINEAR : GL_NEAREST;
+
+ // for safety...
+ makeCurrent();
+
+ glEnable(GL_TEXTURE_2D);
+
+ float zm = getZoom();
+
+ for(z = a;z < b;z++)
+ {
+ glBindTexture(GL_TEXTURE_2D, p->m_parts[z].tex);
+
+ // setup texture parameters
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, ISFLOAT1(zm) ? GL_NEAREST : filter);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, ISFLOAT1(zm) ? GL_NEAREST : filter);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ setupBits(p, buffer, i, k);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, p->tilesx[k], p->tilesy[i], 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+
+ k++;
+ }
+
+ // create new display list
+ glNewList(p->m_parts[a].list, swap ? GL_COMPILE_AND_EXECUTE : GL_COMPILE);
+
+ // bind & draw textures (if needed)
+ for(z = a;z < b;z++)
+ {
+ glBindTexture(GL_TEXTURE_2D, p->m_parts[z].tex);
+
+ glBegin(GL_QUADS);
+ glTexCoord2f(p->m_parts[z].tx1, p->m_parts[z].ty1); glVertex2f(p->m_parts[z].x1, p->m_parts[z].y1);
+ glTexCoord2f(p->m_parts[z].tx2, p->m_parts[z].ty1); glVertex2f(p->m_parts[z].x2, p->m_parts[z].y1);
+ glTexCoord2f(p->m_parts[z].tx2, p->m_parts[z].ty2); glVertex2f(p->m_parts[z].x2, p->m_parts[z].y2);
+ glTexCoord2f(p->m_parts[z].tx1, p->m_parts[z].ty2); glVertex2f(p->m_parts[z].x1, p->m_parts[z].y2);
+ glEnd();
+ }
+
+ glEndList();
+
+ glDisable(GL_TEXTURE_2D);
+
+ // swap buffers...
+ if(swap)
+ swapBuffers();
+
+ return GL_TRUE;
+}
+
+void SQ_GLWidget::setupBits(Parts *p, RGBA *_buffer, int y, int x)
+{
+ TQPair<int, int> pair = SQ_GLWidget::calcRealDimensions(*p, y, x);
+
+ int offs = p->realw * pair.second + pair.first;
+ RGBA *orig = p->buffer->data() + offs;
+
+ int toy = p->tilesy[y];
+ int tox = p->tilesx[x];
+
+ for(int j = 0;j < toy;j++)
+ memcpy(_buffer + tox*j, orig + p->realw*j, tox*sizeof(RGBA));
+}
+
+/*
+ * Start decoding given image. We can call it from anywhere.
+ */
+void SQ_GLWidget::startDecoding(const TQString &file)
+{
+#ifndef KSQUIRREL_PART
+ if(SQ_PreviewWidget::instance()->cancel())
+ SQ_WidgetStack::instance()->diroperator()->stopPreview();
+#endif
+
+ if(reset_mode)
+ return;
+
+ started.start();
+
+ tabold = tab;
+ tmptab.empty();
+ tab = &tmptab;
+ reset_mode = true;
+
+ timer_anim->stop();
+ images->clear();
+
+ tab->m_File = file; // original name
+ tab->File = TQFile::encodeName(tab->m_File); // translated name
+ tab->m_original = m_original;
+
+ TQFileInfo fm(file);
+ tab->fmt_ext = fm.extension(false);
+ tab->fmt_size = fm.size();
+
+#ifndef KSQUIRREL_PART
+ // show window with image
+ KSquirrel::app()->raiseGLWidget();
+#endif
+
+ if(m_expected.isEmpty())
+ TDEApplication::eventLoop()->processEvents(TQEventLoop::ExcludeUserInput | TQEventLoop::ExcludeSocketNotifiers);
+
+ decode();
+}
+
+/*
+ * Prepare decoding. It will find proper library for decoding,
+ * clear old memory buffers, etc.
+ */
+bool SQ_GLWidget::prepare()
+{
+ TQString status;
+
+ tab = &tmptab;
+
+ // get library from cache
+ SQ_LIBRARY *m_lib = SQ_LibraryHandler::instance()->libraryForFile(tab->m_File);
+
+ if(!m_lib)
+ {
+ KMessageBox::error(this, i18n("Codec for %1 format not found").arg(tab->fmt_ext));
+ reset_mode = false;
+ tab = tabold;
+ return false;
+ }
+ else
+ tmptab.lib = m_lib;
+
+ enableActions(true);
+
+ int already = -1, result = -1, i = 0;
+ SQ_Config::instance()->setGroup("GL view");
+
+#ifndef KSQUIRREL_PART
+ bool use_tabs = SQ_GLView::window()->tabs();
+#endif
+
+ bool useCurrent = false;
+
+#ifndef KSQUIRREL_PART
+ if(!use_tabs)
+ {
+ removeCurrentTabs();
+
+ SQ_GLView::window()->removeTabs();
+ }
+ else
+ {
+ if(m_expected != m_original)
+ {
+ std::vector<Tab>::iterator it = tabs.begin();
+ std::vector<Tab>::iterator itEnd = tabs.end();
+ for(;it != itEnd;++it, ++i)
+ {
+ if((*it).m_original == m_original)
+ {
+ already = i;
+ useCurrent = true;
+ break;
+ }
+ }
+ }
+
+ // 0 - new page
+ // 1 - replace current tab
+ // 2 - close all and open in a new tab
+ // -1 - ignore 'result' at all
+ if(already == -1
+ && decoded
+ && m_expected != m_original
+ && !useCurrent
+ && SQ_Config::instance()->readBoolEntry("tabs_ask", false))
+ {
+ SQ_TabOpenDialog tbo(this);
+ tbo.exec();
+ result = tbo.result();
+ }
+ }
+#else
+ removeCurrentTabs();
+#endif
+
+#ifndef KSQUIRREL_PART
+ int curtab = SQ_GLView::window()->tabbar()->indexOf(SQ_GLView::window()->tabbar()->currentTab());
+#else
+ int curtab = -1;
+#endif
+
+ int curindex = (already == -1) ? curtab : already;
+
+ if(curindex != -1 && (m_expected == m_original || result == 1 || useCurrent))
+ {
+ if(curtab != curindex)
+ tabs[curtab].removeParts();
+
+ tabs[curindex].clearParts();
+ tabs[curindex] = tmptab;
+ tab = &tabs[curindex];
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->tabbar()->blockSignals(true);
+ SQ_GLView::window()->tabbar()->setCurrentTab(SQ_GLView::window()->tabbar()->tabAt(curindex));
+ SQ_GLView::window()->tabbar()->tabAt(curindex)->setText(KStringHandler::csqueeze(tab->m_original.fileName(), SQ_TAB_TEXT_LENGTH));
+ SQ_GLView::window()->tabbar()->blockSignals(false);
+#endif
+ }
+ else
+ {
+ if(curindex != -1)
+ {
+ if(result == 2)
+ closeAllTabs();
+ else
+ tabs[curindex].removeParts();
+ }
+
+ tabs.push_back(tmptab);
+ int lastId = tabs.size() - 1;
+ tab = &tabs[lastId];
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->tabbar()->blockSignals(true);
+ SQ_GLView::window()->addPage(KStringHandler::csqueeze(tab->m_original.fileName(), SQ_TAB_TEXT_LENGTH));
+ SQ_GLView::window()->tabbar()->setCurrentTab(SQ_GLView::window()->tabbar()->tabAt(lastId));
+
+ // TQTabBar::show will emit selected(int),
+ // we don't want it
+ emit tabCountChanged();
+ SQ_GLView::window()->tabbar()->blockSignals(false);
+#endif
+ }
+
+ gls->setVisible(false);
+
+ SQ_CodecSettings::applySettings(tab->lib, SQ_CodecSettings::ImageViewer);
+
+ // determine codec
+ tab->codeK = tab->lib->codec;
+
+ // start decoding!
+ i = tab->codeK->read_init(tab->File.ascii());
+
+ // oops, error...
+ if(i != SQE_OK)
+ {
+ decodeFailedOn0(i);
+ m_expected = KURL();
+ return false;
+ }
+
+ return true;
+}
+
+void SQ_GLWidget::decode()
+{
+ // prepare decoding...
+ if(!prepare())
+ return;
+
+#ifndef KSQUIRREL_PART
+ KSquirrel::app()->setCaption(originalURL());
+#endif
+
+ zoomFactor = getZoom();
+ matrix_pure_reset();
+ matrixChanged();
+
+#ifdef SQ_HAVE_KEXIF
+ KExifData d;
+ d.readFromFile(tab->m_File);
+ tab->orient = d.getImageQt::Orientation();
+ tab->wm = SQ_Utils::exifGetMatrix(TQString(), tab->orient);
+
+ tab->rotate = (tab->orient == KExifData::ROT_90_HFLIP || tab->orient == KExifData::ROT_90
+ || tab->orient == KExifData::ROT_90_VFLIP || tab->orient == KExifData::ROT_270);
+#else
+ tab->orient = -1;
+ tab->rotate = false;
+#endif
+
+ errors = 0;
+
+/* *********************************************************** */
+
+ int i, j, id;
+ int line, res, first_id = 0;
+ fmt_image *im;
+ memoryPart *pt;
+ bool progr;
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ // in fullscreen mode progressive loading is disabled anyway
+ if(fullscreen())
+ progr = false;
+ else
+ progr = SQ_Config::instance()->readBoolEntry("progressiv", true);
+
+ int allpages = SQ_Config::instance()->readNumEntry("load_pages", 0);
+ int pages_num = SQ_Config::instance()->readNumEntry("load_pages_number", 1);
+
+ if(pages_num < 1) pages_num = 1;
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBFile")->setText(tab->m_original.fileName());
+#else
+ t_glv.sbarWidget("SBFile")->setText(tab->m_original.fileName());
+#endif
+
+ tab->current = 0;
+
+ bool notexpected = m_expected.isEmpty();
+ m_expected = KURL();
+
+ // start time counting
+ while(true)
+ {
+ if((allpages == 1 && tab->current) || (allpages == 2 && tab->current == pages_num))
+ break;
+
+ // absolute evil, but should do...
+ if(notexpected)
+ TDEApplication::eventLoop()->processEvents(TQEventLoop::ExcludeUserInput | TQEventLoop::ExcludeSocketNotifiers);
+
+ i = tab->codeK->read_next();
+
+ // something went wrong. SQE_NOTOK is a special type of error. It means
+ // that we decoded all pages.
+ if(i != SQE_OK)
+ {
+ if(i == SQE_NOTOK || tab->current)
+ break;
+ else
+ {
+ decodeFailedOn0(i);
+ return;
+ }
+ }
+
+ im = tab->codeK->image(tab->current);
+
+ Parts pp;
+
+ // find tile size
+ SQ_GLWidget::findCloserTiles(im->w, im->h, pp.tilesx, pp.tilesy);
+ TQPair<int, int> pair = SQ_GLWidget::calcRealDimensions(pp);
+ pp.realw = pair.first;
+ pp.realh = pair.second;
+
+ // setup current Part
+ pp.w = im->w;
+ pp.h = im->h;
+
+ // create textures and display lists
+ if(!pp.makeParts())
+ {
+ if(tab->current)
+ break;
+ else
+ {
+ KMessageBox::error(this,
+ i18n("Memory allocation failed for %1 of memory")
+ .arg(TDEIO::convertSize(pp.realw * pp.realh * sizeof(RGBA))));
+
+ decodeFailedOn0(SQE_R_NOMEMORY);
+ return;
+ }
+ }
+
+ pt = new memoryPart(pp.realw * pp.realh);
+ pt->create();
+
+ if(!pt->valid())
+ {
+ pp.removeParts();
+
+ if(tab->current)
+ break;
+ else
+ {
+ KMessageBox::error(this, i18n("Memory allocation failed"));
+ decodeFailedOn0(SQE_R_NOMEMORY);
+ return;
+ }
+ }
+
+ line = 0;
+
+ pp.computeCoords();
+ pp.buffer = pt;
+
+ tab->finfo = tab->codeK->information();
+
+ if(!tab->current)
+ {
+ tab->isflippedH = tab->isflippedV = false;
+ slotZoomIfLess();
+ matrixChanged();
+ updateCurrentFileInfo();
+ }
+
+ matrix_move_z(SQ_FIRST_TILE_LAYER+tab->current);
+
+ for(int pass = 0;pass < im->passes;pass++)
+ {
+ if(tab->codeK->read_next_pass() != SQE_OK)
+ break;
+
+ bool flip = tab->finfo.image[tab->current].needflip;
+ line = 0;
+ int tlsy = pp.tilesy.size();
+ int tlsyval, offs = 0, O, iA;
+
+ for(i = 0;i < tlsy;i++)
+ {
+ iA = flip ? (tlsy-i-1) : i;
+ tlsyval = pp.tilesy[iA];
+
+ for(j = 0;j < tlsyval;j++)
+ {
+ O = flip ? (pp.realw*(im->h - offs - j-1)) : (offs + j)*pp.realw;
+ res = tab->codeK->read_scanline(pp.buffer->data() + O);
+ errors += (int)(res != SQE_OK);
+
+ if(++line == im->h)
+ break;
+ }
+
+ offs += tlsyval;
+
+ // last pass
+ if(pass == im->passes-1)
+ {
+// if(!tab->current)
+ {
+ bool b = showFrames(iA, &pp, progr);
+
+ if(!b)
+ kdWarning() << "Showframes failed for image " << tab->current << ", tiley " << i << endl;
+ }
+ }
+
+ }
+ }
+
+ id = images->insertItem(TQString::fromLatin1("#%1 [%2x%3@%4]").arg(tab->current+1).arg(im->w).arg(im->h).arg(im->bpp));
+
+ images->setItemParameter(id, tab->current);
+
+ if(!tab->current)
+ {
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBDecodedI")->setPixmap(tab->lib->mime);
+#endif
+ old_id = first_id = id;
+ }
+
+ tab->parts.push_back(pp);
+
+ calcFrameLabelWidth();
+ frameChanged();
+ tab->current++;
+ }
+
+ tab->finfo = tab->codeK->information();
+ tab->codeK->read_close();
+ tab->total = tab->finfo.image.size();
+ tab->current = 0;
+ frameChanged();
+
+ enableSettingsButton(!tab->lib->config.isEmpty());
+
+ decoded = true;
+ reset_mode = false;
+ updateGL();
+
+ tab->quickImageInfo = tab->lib->quickinfo;
+ tab->elapsed = started.elapsed();
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBLoaded")->setText(TDEGlobal::locale()->formatLong(tab->elapsed) + i18n(" ms."));
+#else
+ t_glv.sbarWidget("SBLoaded")->setText(TDEGlobal::locale()->formatLong(tab->elapsed) + i18n(" ms."));
+#endif
+
+ images->setItemChecked(first_id, true);
+
+ if(tab->finfo.animated)
+ TQTimer::singleShot(tab->finfo.image[tab->current].delay, this, TQ_SLOT(slotAnimateNext()));
+}
+
+/*
+ * Palette changed. Let's update tickmarks and background color.
+ */
+void SQ_GLWidget::paletteChange(const TQPalette &oldPalette)
+{
+ TQGLWidget::paletteChange(oldPalette);
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ if(SQ_Config::instance()->readNumEntry("GL view background type", 1) == 0)
+ {
+ TQColor color = colorGroup().color(TQColorGroup::Base);
+ qglClearColor(color);
+ updateGL();
+ }
+}
+
+void SQ_GLWidget::slotFirst()
+{
+#ifndef KSQUIRREL_PART
+ if(!reset_mode)
+ SQ_WidgetStack::instance()->firstFile();
+#endif
+}
+
+void SQ_GLWidget::slotLast()
+{
+#ifndef KSQUIRREL_PART
+ if(!reset_mode)
+ SQ_WidgetStack::instance()->lastFile();
+#endif
+}
+
+void SQ_GLWidget::slotNext()
+{
+#ifndef KSQUIRREL_PART
+ timer_next->stop();
+ timer_prev->stop();
+
+ timer_next->start(timer_delay_file, true);
+#endif
+}
+
+void SQ_GLWidget::slotPrev()
+{
+#ifndef KSQUIRREL_PART
+ timer_prev->stop();
+ timer_next->stop();
+
+ timer_prev->start(timer_delay_file, true);
+#endif
+}
+
+void SQ_GLWidget::slotZoomMenu()
+{
+ zoomMenu->exec(TQCursor::pos());
+}
+
+void SQ_GLWidget::slotAnimateNext()
+{
+ // Some time ago we started to decode new image, but it is
+ // not guaranteed that animation stopped!
+ //
+ // We should return now to avoid segfaults...
+ if(reset_mode)
+ return;
+
+// tab->parts[tab->current].removeParts();
+
+ tab->current++;
+
+ if(tab->current >= (int)tab->finfo.image.size())
+ tab->current = 0;
+
+ updateCurrentFileInfo();
+ updateGL();
+
+ int delay = tab->finfo.image[tab->current].delay;
+
+ timer_anim->start(delay, true);
+}
+
+void SQ_GLWidget::startAnimation()
+{
+ if(!tab->finfo.animated) return;
+
+ timer_anim->start(tab->finfo.image[tab->current].delay, true);
+}
+
+void SQ_GLWidget::stopAnimation()
+{
+ timer_anim->stop();
+}
+
+void SQ_GLWidget::slotToggleAnimate()
+{
+ if(!tab->finfo.animated || gls->valid()) return;
+
+ if(!timer_anim->isActive())
+ {
+ tab->manualBlocked = false;
+ startAnimation();
+ }
+ else
+ {
+ tab->manualBlocked = true;
+ stopAnimation();
+ }
+}
+
+/*
+ * Next image in animated sequence. Called by user (with F3).
+ */
+void SQ_GLWidget::nextImage()
+{
+ // if the image has only one page - do nothing
+ if(tab->total == 1)
+ return;
+
+ tab->current++;
+
+ if(tab->current >= tab->total)
+ tab->current = 0;
+
+ updateGL();
+ updateCurrentFileInfo();
+}
+
+/*
+ * Previous image in animated sequence. Called by user (with F2).
+ */
+void SQ_GLWidget::prevImage()
+{
+ if(tab->total == 1)
+ return;
+
+ tab->current--;
+
+ if(tab->current < 0)
+ tab->current = tab->total - 1;
+
+ updateGL();
+ updateCurrentFileInfo();
+}
+
+/*
+ * Jump to first/last image page.
+ */
+void SQ_GLWidget::jumpToImage(bool last)
+{
+ // if the image has only one page - do nothing
+ if(tab->total == 1)
+ return;
+
+ tab->current = (last) ? tab->finfo.image.size() - 1 : 0;
+
+ updateGL();
+ updateCurrentFileInfo();
+}
+
+void SQ_GLWidget::initMarks()
+{
+ for(int i = 0;i < 4;i++)
+ {
+ glGenTextures(1, &mark[i]);
+
+ glBindTexture(GL_TEXTURE_2D, mark[i]);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, mm[i].bits());
+ }
+}
+
+void SQ_GLWidget::internalZoom(const GLfloat &zF)
+{
+ tab->curangle = 0.0;
+
+ oldZoom = getZoom();
+ matrix_pure_reset();
+
+ exifRotate(false);
+
+ matrix_zoom(zF);
+}
+
+void SQ_GLWidget::updateFilter(bool nice)
+{
+ if(nice == linear)
+ return;
+
+ // store
+ linear = nice;
+
+ int filter = nice ? GL_LINEAR : GL_NEAREST;
+ Parts *pt;
+
+ // update all textures
+ for(int i = 0;i < tab->total;i++)
+ {
+ pt = tab->broken ? parts_broken : &tab->parts[i];
+ int toxy = pt->m_parts.size();
+
+ for(int j = 0;j < toxy;j++)
+ {
+ glBindTexture(GL_TEXTURE_2D, pt->m_parts[j].tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+ }
+ }
+
+ updateGL();
+}
+
+/*
+ * Cleanup method.
+ */
+void SQ_GLWidget::decodeFailedOn0(const int err_code)
+{
+ tab->codeK->read_close();
+ tab->finfo.image.clear();
+ tab->finfo.meta.clear();
+ tab->total = 0;
+ decoded = (bool)tabs.size();
+ reset_mode = false;
+ tab->broken = true;
+ tab->lib = 0;
+
+ useBrokenImage(err_code);
+}
+
+/*
+ * Force using broken image + update context.
+ * Show appropriate error message in statusbar.
+ */
+void SQ_GLWidget::useBrokenImage(const int err_index)
+{
+ enableSettingsButton(false);
+ enableActions(false);
+
+ // save "broken" image information in 'tab->finfo'
+ tab->finfo.image.push_back(image_broken);
+
+ // reset statusbar widgets
+ SQ_GLView::window()->resetStatusBar();
+
+#ifndef KSQUIRREL_PART
+ // show error message instead of file name
+ SQ_GLView::window()->sbarWidget("SBFile")->setText(SQ_ErrorString::instance()->string(err_index));
+ KSquirrel::app()->setCaption(TQString());
+#else
+ t_glv.sbarWidget("SBFile")->setText(SQ_ErrorString::instance()->string(err_index));
+#endif
+
+ matrix_pure_reset();
+ tab->curangle = 0;
+ tab->isflippedH = tab->isflippedV = false;
+
+ changeSlider(1.0);
+
+ // update context and show "broken" image
+ updateGL();
+}
+
+/*
+ * Are we in fullscreen state ?
+ */
+bool SQ_GLWidget::fullscreen() const
+{
+#ifndef KSQUIRREL_PART
+ KWin::WindowInfo wi = KWin::windowInfo(SQ_GLView::window()->winId());
+
+ if(wi.valid())
+ pAFull->setChecked((wi.state() & NET::FullScreen));
+
+ return pAFull->isChecked();
+#else
+ return false;
+#endif
+}
+
+/*
+ * Toggle fullscreen state.
+ */
+void SQ_GLWidget::toggleFullScreen()
+{
+#ifndef KSQUIRREL_PART
+ bool fs = !fullscreen();
+
+ pAFull->setChecked(fs);
+ pAToolFull->setOn(fs);
+
+ KSquirrel::app()->slotFullScreen(fs);
+#endif
+}
+
+void SQ_GLWidget::slotSetZoomPercents(int perc)
+{
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ GLfloat z = (perc <= 20) ? (GLfloat)perc / 20 : ((GLfloat)perc - 20)/2 + 1.0;
+
+ internalZoom(z);
+}
+
+void SQ_GLWidget::updateFactors()
+{
+ zoomfactor = SQ_Config::instance()->readNumEntry("zoom", 25);
+ movefactor = SQ_Config::instance()->readNumEntry("move", 5);
+ rotatefactor = SQ_Config::instance()->readNumEntry("angle", 90);
+}
+
+void SQ_GLWidget::slotSelectionRect()
+{
+ stopAnimation();
+ tab->glselection = SQ_GLSelectionPainter::Rectangle;
+ gls->end();
+}
+
+void SQ_GLWidget::slotSelectionEllipse()
+{
+ stopAnimation();
+ tab->glselection = SQ_GLSelectionPainter::Ellipse;
+ gls->end();
+}
+
+void SQ_GLWidget::slotSelectionClear()
+{
+ tab->glselection = -1;
+ gls->end();
+
+ pASelectionEllipse->setChecked(false);
+ pASelectionRect->setChecked(false);
+
+ if(!manualBlocked())
+ startAnimation();
+}
+
+bool SQ_GLWidget::manualBlocked()
+{
+ // selection is also blocks animation
+ return tab->manualBlocked || gls->valid();
+}
+
+void SQ_GLWidget::setDownloadPercents(int p)
+{
+ if(p < 0)
+ percentsLabel->hide();
+ else
+ {
+ percentsLabel->setText(i18n("Downloading...") + ' ' + TDEIO::convertSize(p));
+ percentsLabel->adjustSize();
+ percentsLabel->show();
+ }
+}
+
+#include "sq_glwidget.moc"
diff --git a/src/sq_glwidget.h b/src/sq_glwidget.h
new file mode 100644
index 0000000..be4903f
--- /dev/null
+++ b/src/sq_glwidget.h
@@ -0,0 +1,620 @@
+/***************************************************************************
+ sq_glwidget.h - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef SQ_GLWIDGET_H
+#define SQ_GLWIDGET_H
+
+#include <tqimage.h>
+#include <tqrect.h>
+#include <tqpair.h>
+#include <tqdatetime.h>
+
+#include <kurl.h>
+
+#include <vector>
+
+#include "sq_glparts.h"
+
+#ifdef KSQUIRREL_PART
+#include "sq_glview.h"
+#endif
+
+class SQ_GLSelectionPainter;
+struct SQ_ImageFilterOptions;
+struct SQ_ImageBCGOptions;
+struct RGBA;
+
+// parameters in GL matrix
+#define MATRIX_C1 tab->matrix[0]
+#define MATRIX_S1 tab->matrix[1]
+#define MATRIX_X tab->matrix[3]
+#define MATRIX_S2 tab->matrix[4]
+#define MATRIX_C2 tab->matrix[5]
+#define MATRIX_Y tab->matrix[7]
+#define MATRIX_Z tab->matrix[11]
+
+class TDEAction;
+class TDEActionCollection;
+class TDEToggleAction;
+class TDEPopupMenu;
+class TDERadioAction;
+class KTempFile;
+
+namespace TDEIO { class Job; }
+
+class TQTimer;
+class TQPopupMenu;
+class TQSlider;
+class TQLabel;
+
+class SQ_ToolButtonPopup;
+class SQ_ToolButton;
+class SQ_ToolBar;
+
+/* *************************************************************** */
+
+/*
+ * SQ_GLWidget represents a widget, which loads, shows and manipulates
+ * an image.
+ *
+ * It contains complex decoding method. Since OpenGL can show textures
+ * only with dimensions of power of 2 (32x62, 512, 256 etc.), we should divide
+ * decoded image into quads and only then generate textures.
+ * It means, that the image you see consists of several parts:
+ *
+ * |----------------------------------
+ * | | |
+ * | tex N1 | tex N2 |
+ * | | |
+ * ----------------------------------- <= Entire image
+ * | | |
+ * | tex N3 | tex N4 |
+ * | | |
+ * -----------------------------------
+ *
+ *
+ * The main class member is 'parts'. It's an array of decoded images
+ * and appropriate memory buffers and textures. Here comes an explanation:
+ * [ use monotype fonts :) ]
+ *
+ * textures & coordinates Part
+ * +-----------------------------------+ ##################### ##################
+ * | parts[2] | # # #===> # #
+ * | +-------------------------------------+ # # # # texture id #
+ * | | parts[1] | |======> ##################### # texture coords #
+ * | | +-------------------------------------+ | # # # # ... #
+ * | | | m_parts parts[0] | | # # # ##################
+ * | | | ##### | | #####################
+ * | | | # # | |
+ * | | | # #===============================|
+ * | | | # # |
+ * | | | ##### |
+ * | | | | memory buffers
+ * | | | m32 | ###############################
+ * | | | ##### | #RGBA.#.....#.....#.....#.....#
+ * | | | # # | #RGBA.#.....#.....#.....#.....#
+ * | | | # #==================================> ###############################
+ * +-| | # # | #RGBA.#.....#.....#.....#.....#
+ * +-| ##### | #RGBA.#.....#.....#.....#.....#
+ * +-------------------------------------+ ###############################
+ * \ /
+ * \ /
+ * parts
+ *
+ *
+ ******************************************************************************
+ *
+ */
+
+class SQ_GLWidget : public TQGLWidget
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_GLWidget(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_GLWidget();
+
+ void setDownloadPercents(int);
+
+ void removeNonCurrentTabs(int);
+
+ void setExpectedURL(const KURL &u);
+
+ TQString originalURL() const;
+
+ /*
+ * Start decoding given image. We can call it from anywhere.
+ */
+ void startDecoding(const TQString &file);
+ void startDecoding(const KURL &url);
+
+ void zoom(GLfloat);
+
+ /*
+ * Set zoom, move and rotate factors from config.
+ */
+ void updateFactors();
+
+ /*
+ * Set clear color for context.
+ */
+ void setClearColor();
+
+ void setOriginalURL(const KURL &);
+
+ /*
+ * Get zoom value, e.g. 1.5, 2.2 ...
+ */
+ GLfloat getZoom() const;
+
+ /*
+ * Get zoom value in percents, e.g. 150, 220 ...
+ */
+ GLfloat getZoomPercents() const;
+
+ TDEActionCollection* actionCollection() const;
+
+ /*
+ * Are we in fullscreen state ?
+ */
+ bool fullscreen() const;
+
+ /*
+ * Toggle fullscreen state.
+ */
+ void toggleFullScreen();
+
+ /*
+ * Direct call to updateGL().
+ */
+ void updateGLA() { updateGL(); }
+
+ /*
+ * Type of zoom: fit width, fit height...
+ */
+ int zoomType();
+
+ /*
+ * Filter is GL_LINEAR ?
+ */
+ bool isnice();
+
+ /*
+ * Direct call to glInit();
+ */
+ void glInitA() { TQGLWidget::glInit(); }
+
+ /*
+ * Start animation, if loaded image is animated.
+ */
+ void startAnimation();
+
+ /*
+ * Stop animation, if loaded image is animated.
+ */
+ void stopAnimation();
+
+ /*
+ * Is animation stopped by user ?
+ */
+ bool manualBlocked();
+
+ /*
+ * Change statusbar info according with
+ * current matrix (it shows current zoom & angle values).
+ */
+ void matrixChanged();
+
+ /*
+ * Check or uncheck 'Slideshow' button in toolbar.
+ */
+ void updateSlideShowButton(bool toggled);
+
+ void closeAllTabsFull();
+
+ static SQ_GLWidget* window() { return m_instance; }
+
+ protected:
+
+ /*
+ * Next three methods should be reimplemented in
+ * every TQGLWidget's subclass.
+ */
+ void initializeGL();
+ void paintGL();
+ void resizeGL(int,int);
+
+ /*
+ * Mouse wheel event. Let's load next/previous image, or
+ * zoom in/zoom out (depends on settings).
+ */
+ void wheelEvent(TQWheelEvent *);
+
+ /*
+ * Palette changed. Let's update tickmarks and background color.
+ */
+ void paletteChange(const TQPalette &oldPalette);
+
+ /*
+ * Accept drag-and-drop events. We can drop some images
+ * on this widget, SQ_GLWidget will try to decode first file.
+ *
+ * TODO: find first supported image and decode it ?
+ */
+ void dragEnterEvent(TQDragEnterEvent *);
+ void dropEvent(TQDropEvent *);
+
+ /*
+ * Mouse events.
+ */
+ void mousePressEvent(TQMouseEvent *);
+ void mouseReleaseEvent(TQMouseEvent *);
+ void mouseMoveEvent(TQMouseEvent *);
+
+ private:
+ void copyURL();
+
+ TQImage generatePreview();
+
+ bool calcSelection();
+
+ void changeSlider(GLfloat z = -1.0);
+
+ void hackMatrix();
+
+ void enableActions(bool U);
+
+ void initAccelsAndMenu();
+
+ void crop();
+ void bcg();
+ void filter();
+ void editUpdate();
+
+ /*
+ * Save current image page to clipboard
+ */
+ void toClipboard();
+
+ /*
+ * Save current image page to file
+ */
+ void saveAs();
+
+ void enableSettingsButton(bool enab);
+
+ /*
+ * Remove currently loaded textures and memory buffers.
+ */
+ void removeCurrentParts();
+ void removeCurrentTabs();
+
+ void closeAllTabs();
+
+ /*
+ * Since 0.6.0-final KSquirrel doesn't show error messages,
+ * if the image is broken or not supported. It uses "broken" image
+ * instead. This method does all needed init.
+ */
+ void initBrokenImage();
+
+ /*
+ * Force using broken image + update context.
+ * Show appropriate error message in statusbar.
+ */
+ void useBrokenImage(const int err_index);
+
+ /*
+ * Update filter. If 'nice' is true, use GL_LINEAR
+ * and GL_NEAREST otherwise.
+ */
+ void updateFilter(bool nice);
+
+ /*
+ * Cleanup method.
+ */
+ void decodeFailedOn0(const int err_code);
+
+ /*
+ * Create TDEActions.
+ */
+ void createActions();
+
+ /*
+ * Create toolbars.
+ */
+ void createToolbar();
+
+ /*
+ * Fill a w x h region with texture. Generate texture if needed.
+ */
+ void draw_background(void *bits, unsigned int *tex, int dim, GLfloat w, GLfloat h, bool &bind, bool deleteOld);
+
+ void setupBits(Parts *p, RGBA *buffer, int y, int x);
+
+ /*
+ * Jump to first or last image in animated sequence.
+ */
+ void jumpToImage(bool);
+
+ /*
+ * Next image in animated sequence. Called by user (with F3).
+ */
+ void nextImage();
+
+ /*
+ * Previous image in animated sequence. Called by user (with F2).
+ */
+ void prevImage();
+
+ /*
+ * Draw (or not) image's background.
+ */
+ void toggleDrawingBackground();
+
+ /*
+ * Show popup menu with external tools.
+ */
+ void showExternalTools();
+
+ /*
+ * Generate textures for tickmarks and bind them.
+ */
+ void initMarks();
+
+ /*
+ * Load and check tickmarks from disk.
+ */
+ void createMarks();
+
+ /*
+ * Wrapper for 'delete' key. Called from keyPressEvent().
+ */
+ void deleteWrapper();
+
+ /*
+ * Show current image's width, height and bpp in statusbar.
+ */
+ void updateCurrentFileInfo();
+
+ /*
+ * Show/hide tickmarks.
+ */
+ void toogleTickmarks();
+
+ /*
+ * Show current page number in multipaged images.
+ *
+ * For example: "3/11" means that current page is the third in current image,
+ * which has 11 pages.
+ */
+ void frameChanged();
+ void calcFrameLabelWidth();
+
+ /*
+ * Set current zoom to 'z'.
+ */
+ void internalZoom(const GLfloat &z);
+
+ /*
+ * Find best tile's width and height for given width and height.
+ */
+ static void findCloserTiles(int w, int h, std::vector<int> &x, std::vector<int> &y);
+ static TQPair<int, int> calcRealDimensions(Parts &, int y = -1, int x = -1);
+
+ /*
+ * Prepare decoding. It will find proper library for decoding,
+ * clear old memory buffers, etc.
+ */
+ bool prepare();
+
+ /*
+ * Zoom to 'r'. Will be called after somebody used mouse button
+ * to select zoom region. Return true, if zoomed.
+ */
+ bool zoomRect(const TQRect &r);
+
+ /*
+ * Bind textures, draw them and create GL lists.
+ * If 'swap' it true, swap buffers.
+ */
+ bool showFrames(int y, Parts *, bool swap);
+
+ /*
+ * OpenGL-related methods, not interesting :-)
+ *
+ * Move, zoom, reset, flip and rotate current matrix.
+ */
+ void matrix_move(GLfloat x, GLfloat y);
+ void matrix_move_z(GLfloat z);
+ bool matrix_zoom(GLfloat ratio);
+ void matrix_reset(bool = true);
+ void matrix_pure_reset();
+ void matrix_push();
+ void matrix_pop();
+ void write_gl_matrix();
+ void matrix_rotate(GLfloat angle, bool = true);
+ void matrix_rotate2(GLfloat angle);
+ void flip(int, bool = true);
+ void flip_h();
+ void flip_v();
+ void exifRotate(bool);
+
+ signals:
+ void tabCountChanged();
+ void message(const TQString &);
+
+ public slots:
+ void slotPrint();
+
+ void slotSelectionEllipse();
+ void slotSelectionRect();
+ void slotSelectionClear();
+
+ private slots:
+ void decode();
+
+ void slotAccelActivated();
+
+ void slotChangeTab(int);
+ void slotCloseRequest(int);
+
+ void slotCopyJobResult(TDEIO::Job *job);
+
+ /*
+ * Slots for toolbar's actions:
+ * fit width, fit height, zoom+, zoom-, rotate, flip,
+ * first file, last file, reset...
+ */
+ void slotShowNav();
+ void slotSetZoomPercents(int);
+ void slotZoomW();
+ void slotZoomH();
+ void slotZoomWH();
+ void slotZoomPlus();
+ void slotZoom100();
+ void slotZoomLast();
+ void slotZoomMinus();
+ void slotZoomIfLess();
+ void slotRotateLeft();
+ void slotRotateRight();
+ void slotFlipV();
+ void slotFlipH();
+ void slotMatrixReset();
+ void slotProperties(); // show image properties
+ void slotFirst();
+ void slotLast();
+ void slotNext();
+ void slotPrev();
+ void slotZoomMenu();
+ void slotAnimateNext();
+ void slotToggleAnimate(); // start/stop animation
+ void slotSetCurrentImage(int);
+ void slotShowImages();
+ void slotImagesHidden();
+ void slotImagesShown();
+ void slotShowHelp();
+ void slotShowCodecSettings();
+ void slotApplyCodecSettings();
+
+ void slotBCG(SQ_ImageBCGOptions *);
+ void slotFilter(SQ_ImageFilterOptions *fltopt);
+
+ void slotCopyResult(TDEIO::Job *);
+
+ private:
+ TDEAction *pASelectionClear;
+ TDEToggleAction *pAFull, *pAIfLess, *pAZoomW,
+ *pAZoomH, *pAZoomWH, *pAZoom100,
+ *pAZoomLast,
+ *pASelectionEllipse, *pASelectionRect;
+
+ SQ_ToolButton *pAToolQuick, *pAToolFull, *pAToolProp, *pAToolPrint;
+ SQ_ToolButtonPopup *pAToolZoom, *pAToolImages;
+
+ TDEActionCollection *ac, *acMain;
+ TQPopupMenu *menu, *menuFile, *menuImage;
+ int id_saveas, id_settings,
+ id_f5, id_f6, id_f7, id_f8, id_del,
+ id_prop;
+
+ // popup menu with zoom types (fit width, fit height, zoom 100%...)
+ TDEPopupMenu *zoomMenu, *selectionMenu,
+
+ // popup menu with image pages
+ *images;
+
+ TQImage BGpixmap, BGquads;
+
+ TQTimer *timer_prev, *timer_next;
+ TQTimer *timer_anim;
+
+ TQImage mm[4];
+
+ fmt_image image_broken;
+ SQ_GLSelectionPainter *gls;
+
+ Parts *parts_broken;
+
+ GLfloat saved[12], zoomfactor, movefactor, rotatefactor;
+
+ unsigned int texQuads, texPixmap, mark[4];
+ int xmoveold, ymoveold, xmove, ymove,
+ zoom_type, old_id, total, errors, movetype;
+ bool reset_mode, decoded, blocked,
+ changed, marks, linear;
+ float zoomFactor, oldZoom;
+ RGBA *buffer;
+ TQSlider *slider_zoom;
+
+ KTempFile *tmp;
+ KURL lastCopy, m_expected, m_original;
+ TQTime clickTime, started;
+
+ std::vector<Tab> tabs;
+ Tab *tab, *tabold;
+ Tab tmptab, taborig;
+ bool hackResizeGL, bindChecker;
+
+ TQLabel *percentsLabel;
+
+#ifdef KSQUIRREL_PART
+ SQ_GLView t_glv;
+#endif
+
+ static SQ_GLWidget *m_instance;
+};
+
+inline
+int SQ_GLWidget::zoomType()
+{
+ return zoom_type;
+}
+
+inline
+bool SQ_GLWidget::isnice()
+{
+ return linear;
+}
+
+inline
+TDEActionCollection* SQ_GLWidget::actionCollection() const
+{
+ return ac;
+}
+
+inline
+void SQ_GLWidget::setOriginalURL(const KURL &u)
+{
+ m_original = u;
+}
+
+inline
+TQString SQ_GLWidget::originalURL() const
+{
+ return tab->m_original.isLocalFile() ? tab->m_original.path() : tab->m_original.prettyURL();
+}
+
+inline
+void SQ_GLWidget::setExpectedURL(const KURL &u)
+{
+ m_expected = u;
+}
+
+#endif
diff --git a/src/sq_glwidget_helpers.cpp b/src/sq_glwidget_helpers.cpp
new file mode 100644
index 0000000..0dd96c0
--- /dev/null
+++ b/src/sq_glwidget_helpers.cpp
@@ -0,0 +1,264 @@
+/***************************************************************************
+ sq_glwidget_helpers.cpp - description
+ -------------------
+ begin : ��� ��� 7 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqwmatrix.h>
+#include <tqrect.h>
+#include <tqpoint.h>
+#include <tqpointarray.h>
+
+#include <algorithm>
+#include <cstdlib>
+
+#include <tdetoolbar.h>
+
+#include <ksquirrel-libs/fmt_defs.h>
+
+#ifdef SQ_HAVE_KEXIF
+#include <libkexif/kexifdata.h>
+#endif
+
+#include "sq_glwidget_helpers.h"
+
+SQ_ToolButtonPopup::SQ_ToolButtonPopup(const TQPixmap &pix, const TQString &textLabel, TDEToolBar *parent)
+ : TDEToolBarButton(pix, -1, parent, 0, textLabel)
+{
+ setFixedWidth(SQ_ToolButton::fixedWidth());
+}
+
+SQ_ToolButtonPopup::~SQ_ToolButtonPopup()
+{}
+
+SQ_ToolButton::SQ_ToolButton(const TQIconSet &iconSet, const TQString &textLabel,
+ TQObject *receiver, const char *slot, TDEToolBar *parent, const char *name)
+ : TQToolButton(iconSet, textLabel, TQString(), receiver, slot, parent, name)
+{
+ setFixedWidth(SQ_ToolButton::fixedWidth());
+}
+
+SQ_ToolButton::~SQ_ToolButton()
+{}
+
+int SQ_GLHelpers::roundAngle(int curangle)
+{
+ int sign = (curangle < 0 ? -1 : 1);
+ curangle = std::abs(curangle);
+
+ if((curangle > 0 && curangle < 45) || (curangle >= 315 && curangle < 360))
+ curangle = 0;
+ else if(curangle >= 45 && curangle < 135)
+ curangle = 90;
+ else if(curangle >= 135 && curangle < 225)
+ curangle = 180;
+ else if(curangle >= 225 && curangle < 315)
+ curangle = 270;
+
+ curangle *= sign;
+
+ return curangle;
+}
+
+void SQ_GLHelpers::subRotation(TQWMatrix &wm, int curangle, int orient)
+{
+ curangle = SQ_GLHelpers::roundAngle(curangle);
+
+#ifdef SQ_HAVE_KEXIF
+ switch(orient)
+ {
+ case KExifData::ROT_180: curangle -= 180; break;
+ case KExifData::ROT_90_HFLIP:
+ case KExifData::ROT_90:
+ case KExifData::ROT_90_VFLIP: curangle -= 90; break;
+ case KExifData::ROT_270: curangle -= 270; break;
+
+ default: ;
+ }
+#endif
+
+ switch(curangle)
+ {
+ case -180:
+ case 180: wm.rotate(180); break;
+
+ case -270:
+ case 90: wm.rotate(90); break;
+
+ case -90:
+ case 270: wm.rotate(270); break;
+
+ default: ;
+ }
+}
+
+bool SQ_GLHelpers::normalizeSelection(int &sx, int &sy, int &sw, int &sh, int w, int h, const TQWMatrix &matr, int curangle, int orient)
+{
+ TQWMatrix wm = matr;
+
+ SQ_GLHelpers::subRotation(wm, curangle, orient);
+
+ if(!wm.isIdentity())
+ {
+ int ax = -w/2 + sx;
+ int ay = h/2 - sy;
+
+ TQPointArray pa(4), pb;
+
+ pa.setPoint(0, ax, ay-sh);
+ pa.setPoint(1, ax+sw, ay-sh);
+ pa.setPoint(2, ax+sw, ay);
+ pa.setPoint(3, ax, ay);
+
+ pb = wm.map(pa);
+
+ int fx, fy, fx2, fy2;
+ fx = std::min(std::min(pb.point(0).x(), pb.point(1).x()), std::min(pb.point(2).x(), pb.point(3).x()));
+ fy = std::max(std::max(pb.point(0).y(), pb.point(1).y()), std::max(pb.point(2).y(), pb.point(3).y()));
+
+ fx2 = std::max(std::max(pb.point(0).x(), pb.point(1).x()), std::max(pb.point(2).x(), pb.point(3).x()));
+ fy2 = std::min(std::min(pb.point(0).y(), pb.point(1).y()), std::min(pb.point(2).y(), pb.point(3).y()));
+
+ sx = fx;
+ sy = fy;
+ sw = fx2 - fx;
+ sh = fy - fy2;
+
+ sx += w/2;
+ sy = h/2-sy;
+ }
+
+ if(sx > w || sy > h || sx + sw < 0 || sy + sh < 0)
+ return false;
+
+ if(sx < 0) { sw = sw+sx; sx = 0; }
+ if(sy < 0) { sh = sh+sy; sy = 0; }
+
+ if(sx + sw > w) sw = w - sx;
+ if(sy + sh > h) sh = h - sy;
+
+ return (sw && sh);
+}
+
+void SQ_GLHelpers::scanLine0(RGBA *data, RGBA *scan, int rw, int w, int h, int y, int flip)
+{
+ if(flip == 1)
+ {
+ data = data + rw*y + w-1;
+
+ for(int i = 0;i < w;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data--;
+ }
+ }
+ else if(flip == 2)
+ {
+ data = data + rw*(h-1-y);
+
+ for(int i = 0;i < w;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data++;
+ }
+ }
+ else
+ memcpy(scan, data + rw*y, w * sizeof(RGBA));
+}
+
+void SQ_GLHelpers::scanLine90(RGBA *data, RGBA *scan, int rw, int w, int h, int y, int flip)
+{
+ if(flip == 2)
+ {
+ data = data + y;
+
+ for(int i = 0;i < h;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data += rw;
+ }
+ }
+ else
+ {
+ data = flip == 1 ? (data + rw*(h-1) + w-y-1) : (data + rw*(h-1) + y);
+
+ for(int i = 0;i < h;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data -= rw;
+ }
+ }
+}
+
+void SQ_GLHelpers::scanLine180(RGBA *data, RGBA *scan, int rw, int w, int h, int y, int flip)
+{
+ if(flip == 1)
+ {
+ data = data + rw*(h-1-y);
+
+ memcpy(scan, data, w * sizeof(RGBA));
+ }
+ else
+ {
+ data = flip == 2 ? (data + rw*y + w-1) : (data + rw*(h-1-y) + w-1);
+
+ for(int i = 0;i < w;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data--;
+ }
+ }
+}
+
+void SQ_GLHelpers::scanLine270(RGBA *data, RGBA *scan, int rw, int w, int h, int y, int flip)
+{
+ if(flip == 2)
+ {
+ data = data + rw*(h-1) + w-y-1;
+
+ for(int i = 0;i < h;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data -= rw;
+ }
+ }
+ else
+ {
+ data = flip == 1 ? (data + y) : (data + w-y-1);
+
+ for(int i = 0;i < h;i++)
+ {
+ *scan = *data;
+
+ scan++;
+ data += rw;
+ }
+ }
+}
diff --git a/src/sq_glwidget_helpers.h b/src/sq_glwidget_helpers.h
new file mode 100644
index 0000000..f8cfbd3
--- /dev/null
+++ b/src/sq_glwidget_helpers.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ sq_glwidget_helpers.h - description
+ -------------------
+ begin : May 31 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_GLWIDGET_HELPERS
+#define SQ_GLWIDGET_HELPERS
+
+#include <tdetoolbarbutton.h>
+
+class TQWMatrix;
+
+class TDEToolBar;
+
+struct RGBA;
+
+class SQ_ToolButtonPopup : public TDEToolBarButton
+{
+ public:
+ SQ_ToolButtonPopup(const TQPixmap &pix, const TQString &textLabel, TDEToolBar *parent);
+ ~SQ_ToolButtonPopup();
+};
+
+class SQ_ToolButton : public TQToolButton
+{
+ public:
+ SQ_ToolButton(const TQIconSet &iconSet, const TQString &textLabel, TQObject *receiver,
+ const char *slot, TDEToolBar *parent, const char *name = 0);
+ ~SQ_ToolButton();
+
+ static int fixedWidth();
+};
+
+inline
+int SQ_ToolButton::fixedWidth()
+{
+ return 26;
+}
+
+namespace SQ_GLHelpers
+{
+ // 0, 1, 2
+ typedef void (* scanLineGetter)(RGBA *data, RGBA *, int rw, int w, int h, int y, int flip);
+
+ void scanLine0(RGBA *, RGBA *, int, int, int, int, int);
+ void scanLine90(RGBA *, RGBA *, int, int, int, int, int);
+ void scanLine180(RGBA *, RGBA *, int, int, int, int, int);
+ void scanLine270(RGBA *, RGBA *, int, int, int, int, int);
+
+ int roundAngle(int ang);
+
+ void subRotation(TQWMatrix &wm, int curangle, int orient);
+
+ /*
+ * normalize selection rectangle
+ * sx,sy are X and Y coordinates
+ * sw x sh is a selection geometry
+ */
+ bool normalizeSelection(int &sx, int &sy, int &sw, int &sh, int w, int h, const TQWMatrix&, int curangle, int orient);
+}
+
+#endif
diff --git a/src/sq_glwidget_stuff.cpp b/src/sq_glwidget_stuff.cpp
new file mode 100644
index 0000000..bde87c4
--- /dev/null
+++ b/src/sq_glwidget_stuff.cpp
@@ -0,0 +1,1782 @@
+/***************************************************************************
+ sq_glwidget_stuff.cpp - description
+ -------------------
+ begin : Wed Oct 31 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqclipboard.h>
+#include <tqslider.h>
+#include <tqdragobject.h>
+#include <tqtimer.h>
+#include <tqlabel.h>
+#include <tqpainter.h>
+#include <tqpaintdevicemetrics.h>
+
+#include <tdeapplication.h>
+#include <tdeaction.h>
+#include <kstandarddirs.h>
+#include <tdelocale.h>
+#include <tdepopupmenu.h>
+#include <ktabbar.h>
+#include <kcursor.h>
+#include <tdetempfile.h>
+#include <tdemessagebox.h>
+#include <tdefileitem.h>
+#include <kprinter.h>
+
+#include <algorithm>
+
+#ifndef KSQUIRREL_PART
+#include "ksquirrel.h"
+#include "sq_widgetstack.h"
+#endif
+
+#include "sq_config.h"
+#include "sq_libraryhandler.h"
+#include "sq_glview.h"
+#include "sq_glwidget.h"
+#include "sq_glwidget_helpers.h"
+#include "sq_imageproperties.h"
+#include "sq_helpwidget.h"
+#include "sq_filedialog.h"
+#include "sq_iconloader.h"
+#include "sq_codecsettingsskeleton.h"
+#include "sq_externaltool.h"
+#include "sq_diroperator.h"
+#include "sq_popupmenu.h"
+#include "sq_glselectionpainter.h"
+#include "sq_utils.h"
+#include "sq_imagefilter.h"
+#include "sq_imagebcg.h"
+#include "fmt_filters.h"
+
+#ifdef SQ_HAVE_KEXIF
+#include <libkexif/kexifdata.h>
+#include <libexif/exif-data.h>
+#endif
+
+#include <ksquirrel-libs/fmt_codec_base.h>
+#include <ksquirrel-libs/error.h>
+
+#include "file_broken.xpm"
+
+// Create actions
+void SQ_GLWidget::createActions()
+{
+ pASelectionRect = new TDEToggleAction(i18n("Rectangle"), TQPixmap(locate("data", "images/actions/glselection_rect.png")), 0, this, TQ_SLOT(slotSelectionRect()), ac, "SQ Selection Rect");
+ pASelectionEllipse = new TDEToggleAction(i18n("Ellipse"), TQPixmap(locate("data", "images/actions/glselection_ellipse.png")), 0, this, TQ_SLOT(slotSelectionEllipse()), ac, "SQ Selection Ellipse");
+ pASelectionClear = new TDEAction(i18n("Clear"), 0, 0, this, TQ_SLOT(slotSelectionClear()), ac, "SQ Selection Clear");
+
+ pAZoomW = new TDEToggleAction(i18n("Fit width"), TQPixmap(locate("data", "images/actions/zoomW.png")), 0, this, TQ_SLOT(slotZoomW()), ac, "SQ ZoomW");
+ pAZoomH = new TDEToggleAction(i18n("Fit height"), TQPixmap(locate("data", "images/actions/zoomH.png")), 0, this, TQ_SLOT(slotZoomH()), ac, "SQ ZoomH");
+ pAZoomWH = new TDEToggleAction(i18n("Fit image"), TQPixmap(locate("data", "images/actions/zoomWH.png")), 0, this, TQ_SLOT(slotZoomWH()), ac, "SQ ZoomWH");
+ pAZoom100 = new TDEToggleAction(i18n("Zoom 100%"), TQPixmap(locate("data", "images/actions/zoom100.png")), 0, this, TQ_SLOT(slotZoom100()), ac, "SQ Zoom100");
+ pAZoomLast = new TDEToggleAction(i18n("Leave previous zoom"), TQPixmap(locate("data", "images/actions/zoomlast.png")), 0, this, TQ_SLOT(slotZoomLast()), ac, "SQ ZoomLast");
+ pAIfLess = new TDEToggleAction(i18n("Ignore, if image is smaller than window"), TQPixmap(locate("data", "images/actions/ifless.png")), 0, 0, 0, ac, "if less");
+
+ pAFull = new TDEToggleAction(TQString(), 0, 0, 0, ac, "SQ GL Full");
+
+ TQString squirrel_zoom_actions = TQString::fromLatin1("squirrel_zoom_actions");
+ pAZoomW->setExclusiveGroup(squirrel_zoom_actions);
+ pAZoomH->setExclusiveGroup(squirrel_zoom_actions);
+ pAZoomWH->setExclusiveGroup(squirrel_zoom_actions);
+ pAZoom100->setExclusiveGroup(squirrel_zoom_actions);
+ pAZoomLast->setExclusiveGroup(squirrel_zoom_actions);
+
+ TQString squirrel_selection_type = TQString::fromLatin1("squirrel_selection_type");
+ pASelectionEllipse->setExclusiveGroup(squirrel_selection_type);
+ pASelectionRect->setExclusiveGroup(squirrel_selection_type);
+
+ connect(pAIfLess, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotZoomIfLess()));
+
+#ifndef KSQUIRREL_PART
+ connect(pAFull, TQ_SIGNAL(toggled(bool)), KSquirrel::app(), TQ_SLOT(slotFullScreen(bool)));
+#endif
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ pAIfLess->setChecked(SQ_Config::instance()->readBoolEntry("ignore", true));
+}
+
+void SQ_GLWidget::createToolbar()
+{
+ zoomMenu = new TDEPopupMenu;
+
+#ifndef KSQUIRREL_PART
+ selectionMenu = new TDEPopupMenu;
+
+ SQ_ToolButton *pATool;
+
+ SQ_ToolBar *toolbar = SQ_GLView::window()->toolbar();
+
+ pASelectionRect->plug(selectionMenu);
+ pASelectionEllipse->plug(selectionMenu);
+ selectionMenu->insertSeparator();
+ pASelectionClear->plug(selectionMenu);
+
+ // hack to show accels
+ selectionMenu->changeItem(pASelectionRect->itemId(0), pASelectionRect->text() + "\tCtrl+R");
+ selectionMenu->changeItem(pASelectionEllipse->itemId(0), pASelectionEllipse->text() + "\tCtrl+E");
+ selectionMenu->changeItem(pASelectionClear->itemId(0), pASelectionClear->text() + "\tCtrl+C");
+
+ pAZoom100->plug(zoomMenu);
+ pAZoomLast->plug(zoomMenu);
+ zoomMenu->insertSeparator();
+ pAZoomW->plug(zoomMenu);
+ pAZoomH->plug(zoomMenu);
+ pAZoomWH->plug(zoomMenu);
+ zoomMenu->insertSeparator();
+ pAIfLess->plug(zoomMenu);
+
+ switch(zoom_type)
+ {
+ case 0: pAZoomW->setChecked(true); break;
+ case 1: pAZoomH->setChecked(true); break;
+ case 3: pAZoom100->setChecked(true); break;
+ case 4: pAZoomLast->setChecked(true); break;
+
+ // "case 2" too
+ default: pAZoomWH->setChecked(true);
+ }
+
+/*
+ * We will create TQToolButtons and put them in toolbar.
+ * Of course, we can just TDEAction::plug(), BUT plugged TDEActions
+ * will produce buttons, which cann't be clicked twise! I think
+ * plugged TDEActions will treat our attempt as double-click, not two single-clicks.
+ * On the other hand, we can click TQToolButton as frequently as we want.
+ *
+ * Plugged TDEActions also don't know about autorepeat :(
+ */
+ new SQ_ToolButton(TQPixmap(locate("data", "images/actions/file_first.png")), i18n("Go to first image"), this, TQ_SLOT(slotFirst()), toolbar);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/file_prev.png")), i18n("Previous image"), this, TQ_SLOT(slotPrev()), toolbar);
+ pATool->setAutoRepeat(true);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/file_next.png")), i18n("Next image"), this, TQ_SLOT(slotNext()), toolbar);
+ pATool->setAutoRepeat(true);
+ new SQ_ToolButton(TQPixmap(locate("data", "images/actions/file_last.png")), i18n("Go to last image"), this, TQ_SLOT(slotLast()), toolbar);
+
+ // some toolbuttons need autorepeat...
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/zoom+.png")), i18n("Zoom +"), this, TQ_SLOT(slotZoomPlus()), toolbar);
+ pATool->setAutoRepeat(true);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/zoom-.png")), i18n("Zoom -"), this, TQ_SLOT(slotZoomMinus()), toolbar);
+ pATool->setAutoRepeat(true);
+ pAToolZoom = new SQ_ToolButtonPopup(TQPixmap(locate("data", "images/actions/zoom_template.png")), i18n("Zoom"), toolbar);
+ pAToolZoom->setPopup(zoomMenu);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/rotateL.png")), i18n("Rotate left"), this, TQ_SLOT(slotRotateLeft()), toolbar);
+ pATool->setAutoRepeat(true);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/rotateR.png")), i18n("Rotate right"), this, TQ_SLOT(slotRotateRight()), toolbar);
+ pATool->setAutoRepeat(true);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/flipV.png")), i18n("Flip vertically"), this, TQ_SLOT(slotFlipV()), toolbar);
+ pATool->setAutoRepeat(true);
+ pATool = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/flipH.png")), i18n("Flip horizontally"), this, TQ_SLOT(slotFlipH()), toolbar);
+ pATool->setAutoRepeat(true);
+ new SQ_ToolButton(TQPixmap(locate("data", "images/actions/reload.png")), i18n("Normalize"), this, TQ_SLOT(slotMatrixReset()), toolbar);
+
+ pAToolFull = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/fullscreen.png")), i18n("Fullscreen"), pAFull, TQ_SLOT(activate()), toolbar);
+ pAToolFull->setToggleButton(true);
+ pAToolImages = new SQ_ToolButtonPopup(TQPixmap(locate("data", "images/actions/images.png")), i18n("Select image"), toolbar);
+ pAToolImages->setPopup(images);
+ SQ_ToolButtonPopup *pAToolSel = new SQ_ToolButtonPopup(TQPixmap(locate("data", "images/actions/glselection.png")), i18n("Selection"), toolbar);
+ pAToolSel->setPopup(selectionMenu);
+ pAToolQuick = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/configure.png")), i18n("Codec settings"), this, TQ_SLOT(slotShowCodecSettings()), toolbar);
+ pAToolQuick->setEnabled(false);
+ pAToolProp = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/prop.png")), i18n("Image Properties"), this, TQ_SLOT(slotProperties()), toolbar);
+ pAToolPrint = new SQ_ToolButton(TQPixmap(locate("data", "images/actions/print.png")), i18n("Print"), this, TQ_SLOT(slotPrint()), toolbar);
+ new SQ_ToolButton(TQPixmap(locate("data", "images/actions/shownav.png")), i18n("Show navigator"), this, TQ_SLOT(slotShowNav()), toolbar);
+
+ slider_zoom = new TQSlider(1, 38, 2, 19, TQt::Horizontal, toolbar);
+ slider_zoom->setTickmarks(TQSlider::Below);
+ slider_zoom->setTickInterval(19);
+ connect(slider_zoom, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(slotSetZoomPercents(int)));
+ toolbar->insertWidget(1000, 0, slider_zoom);
+ toolbar->setItemAutoSized(1000);
+ toolbar->alignItemRight(1000);
+
+ changeSlider(1.0);
+#endif
+}
+
+// Show image properties.
+void SQ_GLWidget::slotProperties()
+{
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ // Stop animation...
+ stopAnimation();
+
+ const int real_size = tab->finfo.image[tab->current].w * tab->finfo.image[tab->current].h * sizeof(RGBA);
+ TQString sz = TDEIO::convertSize(real_size);
+ TQStringList list;
+
+ TQValueVector<TQPair<TQString,TQString> > meta;
+
+ if(!tab->finfo.meta.empty())
+ {
+ for(std::vector<fmt_metaentry>::iterator it = tab->finfo.meta.begin();it != tab->finfo.meta.end();++it)
+ {
+ meta.append(TQPair<TQString,TQString>((*it).group, (*it).data));
+ }
+ }
+
+ // save tab->current image parameters and some additioanl information
+ // in list
+ list << tab->quickImageInfo
+ << TQString::fromLatin1("%1x%2").arg(tab->finfo.image[tab->current].w).arg(tab->finfo.image[tab->current].h)
+ << TQString::fromLatin1("%1").arg(tab->finfo.image[tab->current].bpp)
+ << tab->finfo.image[tab->current].colorspace
+ << tab->finfo.image[tab->current].compression
+ << sz
+ << TQString::fromLatin1("%1").arg((double)real_size / tab->fmt_size, 0, 'f', 2)
+ << ((tab->finfo.image[tab->current].interlaced) ? i18n("yes") : i18n("no"))
+ << TQString::fromLatin1("%1").arg(errors)
+ << TQString::fromLatin1("%1").arg(tab->finfo.image.size())
+ << TQString::fromLatin1("#%1").arg(tab->current+1)
+ << TQString::fromLatin1("%1").arg(tab->finfo.image[tab->current].delay);
+
+ // create dialog and setup it
+ SQ_ImageProperties prop(this);
+ prop.setFile(tab->m_File);
+ prop.setURL(tab->m_original);
+ prop.setParams(list);
+ prop.setMetaInfo(meta);
+
+ // show!
+ prop.exec();
+
+ // restore animation
+ if(!manualBlocked())
+ startAnimation();
+}
+
+void SQ_GLWidget::findCloserTiles(int w, int h, std::vector<int> &x, std::vector<int> &y)
+{
+ static int s = 9;
+ static int dims[10] = { 2, 4, 8, 16, 32, 64, 128, 256, 512 };
+
+ int *dd[2] = { &w, &h };
+ std::vector<int> *dv[2] = { &x, &y };
+ int del;
+
+ for(int ff = 0;ff < 2;ff++)
+ {
+ if(*dd[ff] == 1) *dd[ff]=2;
+ else if((*dd[ff])%2) (*dd[ff])++;
+
+ while((*dd[ff]) >= 512)
+ {
+ (*dv[ff]).push_back(512);
+ (*dd[ff]) -= 512;
+ }
+
+ for(int i = 0;i < s-1;i++)
+ if((*dd[ff]) >= dims[i] && (*dd[ff]) < dims[i+1])
+ {
+ del = dims[i] + (dims[i]>>1);
+
+ if((*dd[ff]) <= del)
+ {
+ (*dv[ff]).push_back(dims[i]);
+ (*dd[ff]) -= dims[i];
+ }
+ else
+ {
+ (*dv[ff]).push_back(dims[i+1]);
+ (*dd[ff]) -= dims[i+1];
+ }
+
+ i = -1;
+ }
+ }
+}
+
+TQPair<int, int> SQ_GLWidget::calcRealDimensions(Parts &p, int y, int x)
+{
+ int rw = 0, rh = 0;
+ int toy = y == -1 ? p.tilesy.size() : y;
+ int tox = x == -1 ? p.tilesx.size() : x;
+
+ std::vector<int>::iterator itEnd = p.tilesx.end();
+
+ for(std::vector<int>::iterator it = p.tilesx.begin();it != itEnd && tox--;++it)
+ rw += (*it);
+
+ itEnd = p.tilesy.end();
+
+ for(std::vector<int>::iterator it = p.tilesy.begin();it != itEnd && toy--;++it)
+ rh += (*it);
+
+ return TQPair<int, int>(rw, rh);
+}
+
+void SQ_GLWidget::slotShowCodecSettings()
+{
+ tab->lib = SQ_LibraryHandler::instance()->libraryForFile(tab->m_File);
+
+ if(!tab->lib || tab->lib->config.isEmpty()) // oops ?
+ {
+ enableSettingsButton(false);
+ return;
+ }
+
+ SQ_CodecSettingsSkeleton skel(this);
+
+ connect(&skel, TQ_SIGNAL(apply()), this, TQ_SLOT(slotApplyCodecSettings()));
+
+ skel.addSettingsWidget(tab->lib->config);
+ skel.setCodecInfo(tab->lib->mime, tab->lib->quickinfo);
+ skel.adjustSize();
+
+ if(skel.exec(tab->lib->settings) == TQDialog::Accepted)
+ tab->lib->codec->set_settings(tab->lib->settings);
+}
+
+void SQ_GLWidget::slotApplyCodecSettings()
+{
+ if(tab->lib)
+ {
+ // new settings are already set by SQ_CodecSettingsSkeleton
+ tab->lib->codec->set_settings(tab->lib->settings);
+ m_original = tab->m_original;
+ startDecoding(TQString(tab->m_File));
+ }
+}
+
+void SQ_GLWidget::slotSetCurrentImage(int id)
+{
+ if(tab->total == 1)
+ return;
+
+ images->setItemChecked(old_id, false);
+ tab->current = images->itemParameter(id);
+
+ images->setItemChecked(id, true);
+ old_id = id;
+
+ updateCurrentFileInfo();
+ updateGL();
+}
+
+void SQ_GLWidget::slotImagesShown()
+{
+ if(tab->finfo.animated)
+ {
+ if(!timer_anim->isActive())
+ blocked = false;
+ else
+ {
+ stopAnimation();
+ blocked = true;
+ }
+ }
+
+ images->setItemChecked(old_id, false);
+ int id = images->idAt(tab->current);
+ images->setItemChecked(id, true);
+ old_id = id;
+}
+
+void SQ_GLWidget::slotShowImages()
+{
+ images->exec(TQCursor::pos());
+}
+
+void SQ_GLWidget::slotImagesHidden()
+{
+ if(blocked && tab->finfo.animated)
+ startAnimation();
+}
+
+void SQ_GLWidget::slotShowHelp()
+{
+ SQ_HelpWidget help_w(this);
+
+ help_w.exec();
+}
+
+void SQ_GLWidget::showExternalTools()
+{
+ bool v_ogorogde_buzina_a_v_kieve_dzyadka = SQ_ExternalTool::instance()->constPopupMenu()->isEnabled();
+ SQ_ExternalTool::instance()->constPopupMenu()->setEnabled(true);
+
+ KFileItemList items;
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, tab->m_original);
+
+ if(!tab->m_original.isEmpty())
+ {
+ items.append(&fi);
+ SQ_ExternalTool::instance()->setItems(items);
+ }
+
+ SQ_ExternalTool::instance()->constPopupMenu()->exec(TQCursor::pos());
+ SQ_ExternalTool::instance()->constPopupMenu()->setEnabled(v_ogorogde_buzina_a_v_kieve_dzyadka);
+}
+
+// Delete current image (user pressed 'Delete' key).
+void SQ_GLWidget::deleteWrapper()
+{
+ if(tab->m_original.isEmpty())
+ return;
+
+#ifndef KSQUIRREL_PART
+ KFileItemList list;
+ KFileItem fi(KFileItem::Unknown, KFileItem::Unknown, tab->m_original);
+ list.append(&fi);
+ SQ_WidgetStack::instance()->diroperator()->del(list, this);
+#else
+ SQ_DirOperator::instance()->del(tab->m_original, this);
+#endif
+}
+
+void SQ_GLWidget::enableSettingsButton(bool enab)
+{
+#ifndef KSQUIRREL_PART
+ pAToolQuick->setEnabled(enab);
+#endif
+
+ menuImage->setItemEnabled(id_settings, enab);
+}
+
+void SQ_GLWidget::saveAs()
+{
+ if(!tab->lib || tab->finfo.image.empty()) // nothing to save
+ return;
+
+ SQ_Config::instance()->setGroup("GL view");
+ TQString lastPath = SQ_Config::instance()->readEntry("saveasPath");
+ TQString lastFilt = SQ_Config::instance()->readEntry("saveasFilter");
+
+ if(lastPath.isEmpty())
+ {
+ KURL u = tab->m_original;
+ u.cd("..");
+ lastPath = u.prettyURL();
+ }
+
+ SQ_FileDialog d(lastPath, this);
+
+ // set filter: writable codecs without *.*
+ d.setFilter(SQ_LibraryHandler::instance()->allFiltersFileDialogString(false, false));
+ d.setOperationMode(KFileDialog::Saving);
+ d.setSelection(tab->m_original.fileName());
+ d.setCurrentFilter(lastFilt);
+ d.updateCombo(false);
+
+ if(d.exec() == TQDialog::Rejected || d.selectedURL().isEmpty())
+ return;
+
+ KURL url = d.selectedURL();
+
+ // cut off file name
+ KURL u = url;
+ u.cd("..");
+ SQ_Config::instance()->writeEntry("saveasPath", u.prettyURL());
+ SQ_Config::instance()->writeEntry("saveasFilter", d.nameFilter());
+
+ TQString path = url.isLocalFile() ? url.path() : tmp->name();
+
+ SQ_LIBRARY *wlib = SQ_LibraryHandler::instance()->libraryByName(d.nameFilter());
+
+ if(!wlib || !wlib->writestatic)
+ {
+ KMessageBox::error(this, i18n("Sorry, could not perform write operation\nfor codec \"%1\"").arg(d.nameFilter()));
+ return;
+ }
+
+ SQ_GLHelpers::scanLineGetter scgetter;
+ int flp = 0;
+ int curangle = SQ_GLHelpers::roundAngle((int)tab->curangle);
+
+ fmt_image im = tab->finfo.image[tab->current];
+
+/*
+ * The easiest way to rotate image is to use TQImage + TQImage::xForm(),
+ * but this method is VERY memory inefficient. We will use our own tranformation
+ * routins... Yes, they will be a little bit slower, but they require only
+ * one scaline in stack.
+ */
+
+ int w = im.w, h = im.h;
+ int rw = tab->parts[tab->current].realw;
+
+#ifdef SQ_HAVE_KEXIF
+ switch(tab->orient)
+ {
+ case KExifData::HFLIP:
+ case KExifData::ROT_90_HFLIP:
+ flp = 1;
+ break;
+
+ case KExifData::VFLIP:
+ case KExifData::ROT_90_VFLIP:
+ flp = 2;
+ break;
+
+ default: ;
+ }
+#endif
+
+ switch(curangle)
+ {
+ case -270:
+ case 90: scgetter = SQ_GLHelpers::scanLine90; std::swap(w, h); break;
+
+ case -180:
+ case 180: scgetter = SQ_GLHelpers::scanLine180; break;
+
+ case -90:
+ case 270: scgetter = SQ_GLHelpers::scanLine270; std::swap(w, h); break;
+
+ default: scgetter = SQ_GLHelpers::scanLine0;
+ }
+
+ RGBA *scan = new RGBA[w];
+ RGBA *data = tab->parts[tab->current].buffer->data();
+
+ fmt_image im2 = im;
+ im2.w = w;
+ im2.h = h;
+
+ fmt_writeoptions opt;
+ opt.interlaced = false;
+ opt.alpha = im.hasalpha;
+ opt.bitdepth = im.bpp;
+ opt.compression_scheme = (wlib->opt.compression_scheme & CompressionNo) ? CompressionNo : CompressionInternal;
+ opt.compression_level = wlib->opt.compression_def;
+
+ int err = wlib->codec->write_init(TQString(TQFile::encodeName(path)).ascii(), im2, opt);
+
+ if(err != SQE_OK)
+ {
+ KMessageBox::error(this, i18n("Error writing image"));
+ delete [] scan;
+ return;
+ }
+
+ err = wlib->codec->write_next();
+
+ if(err != SQE_OK)
+ {
+ KMessageBox::error(this, i18n("Error writing image"));
+ delete [] scan;
+ return;
+ }
+
+ wlib->codec->write_next_pass();
+
+ int H = im2.h;
+ int Y0 = wlib->opt.needflip ? (-H+1):0;
+ int Y = wlib->opt.needflip ? 1:H;
+ int f;
+
+ for(int j = Y0;j < Y;j++)
+ {
+ f = (j < 0) ? -j : j;
+
+ scgetter(data, scan, rw, im.w, im.h, f, flp);
+
+ err = wlib->codec->write_scanline(scan);
+
+ if(err != SQE_OK)
+ {
+ wlib->codec->write_close();
+ KMessageBox::error(this, i18n("Error writing image"));
+ delete [] scan;
+ return;
+ }
+ }
+
+ wlib->codec->write_close();
+ delete [] scan;
+
+ // copy to non-local directory
+ if(!url.isLocalFile())
+ {
+ // src dst perm overwrite resume progress
+ TDEIO::Job *j = TDEIO::file_copy(path, url, -1, true, false, false);
+
+ connect(j, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotCopyResult(TDEIO::Job *)));
+ }
+}
+
+void SQ_GLWidget::slotCopyResult(TDEIO::Job *job)
+{
+ if(job->error())
+ {
+ if(KMessageBox::questionYesNoCancel(this, job->errorString() + '\n' + i18n("Try another location?")) == KMessageBox::Yes)
+ {
+ SQ_FileDialog d(TQString(), this);
+
+ // set filter: writable codecs without *.*
+ d.setFilter(SQ_LibraryHandler::instance()->allFiltersFileDialogString(false, false));
+ d.setOperationMode(KFileDialog::Saving);
+ d.updateCombo(false);
+
+ int result = d.exec();
+
+ if(result == TQDialog::Rejected || d.selectedURL().isEmpty())
+ return;
+
+ TDEIO::Job *j = TDEIO::file_copy(tmp->name(), d.selectedURL(), -1, true, false, false);
+ connect(j, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotCopyResult(TDEIO::Job *)));
+ }
+ }
+}
+
+void SQ_GLWidget::toClipboard()
+{
+ if(!decoded || tab->broken)
+ return;
+
+ TQImage im((uchar *)tab->parts[tab->current].buffer->data(), tab->parts[tab->current].realw, tab->parts[tab->current].realh, 32, 0, 0, TQImage::LittleEndian);
+
+ im = im.swapRGB();
+
+ // image doesn't have extra regions
+ if(tab->parts[tab->current].realw == tab->parts[tab->current].w && tab->parts[tab->current].realh == tab->parts[tab->current].h)
+ TDEApplication::clipboard()->setImage(im, TQClipboard::Clipboard);
+ else
+ TDEApplication::clipboard()->setImage(im.copy(0, 0, tab->parts[tab->current].w, tab->parts[tab->current].h), TQClipboard::Clipboard);
+}
+
+void SQ_GLWidget::bcg()
+{
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ SQ_ImageBCG _bcg(this);
+
+ stopAnimation();
+
+ _bcg.setPreviewImage(generatePreview());
+
+ connect(&_bcg, TQ_SIGNAL(bcg(SQ_ImageBCGOptions *)), this, TQ_SLOT(slotBCG(SQ_ImageBCGOptions *)));
+
+ _bcg.exec();
+
+ if(!manualBlocked())
+ startAnimation();
+}
+
+void SQ_GLWidget::filter()
+{
+ if(tab->broken || tab->finfo.image.empty()) return;
+
+ SQ_ImageFilter flt(this);
+
+ stopAnimation();
+
+ flt.setPreviewImage(generatePreview());
+
+ connect(&flt, TQ_SIGNAL(filter(SQ_ImageFilterOptions *)), this, TQ_SLOT(slotFilter(SQ_ImageFilterOptions *)));
+
+ flt.exec();
+
+ if(!manualBlocked())
+ startAnimation();
+}
+
+void SQ_GLWidget::slotFilter(SQ_ImageFilterOptions *filtopt)
+{
+ TQImage im((uchar *)tab->parts[tab->current].buffer->data(), tab->parts[tab->current].realw, tab->parts[tab->current].realh, 32, 0, 0, TQImage::LittleEndian);
+ TQImage img = gls->valid() ? im.copy(tab->sx, tab->sy, tab->sw, tab->sh) : im;
+
+ fmt_filters::image image =
+ gls->valid() ? fmt_filters::image((unsigned char *)img.bits(), img.width(), img.height())
+ : fmt_filters::image((unsigned char *)img.bits(), tab->parts[tab->current].w, tab->parts[tab->current].h, img.width(), img.height());
+
+ fmt_filters::rgba c = fmt_filters::white;
+
+ switch(filtopt->type)
+ {
+ case F::fblend: fmt_filters::blend(image, filtopt->rgb1, filtopt->_float); break;
+ case F::fblur: fmt_filters::blur(image, filtopt->_double1, filtopt->_double2);break;
+ case F::fdesaturate: fmt_filters::desaturate(image, filtopt->_float); break;
+ case F::fdespeckle: fmt_filters::despeckle(image); break;
+ case F::fedge: fmt_filters::edge(image, filtopt->_double1); break;
+ case F::femboss: fmt_filters::emboss(image, filtopt->_double1, filtopt->_double2); break;
+ case F::fequalize: fmt_filters::equalize(image); break;
+ case F::ffade: fmt_filters::fade(image, filtopt->rgb1, filtopt->_float); break;
+ case F::fflatten: fmt_filters::flatten(image, filtopt->rgb1, filtopt->rgb2); break;
+ case F::fimplode: fmt_filters::implode(image, filtopt->_double1, c); break;
+ case F::fnegative: fmt_filters::negative(image); break;
+ case F::fnoise: fmt_filters::noise(image, (fmt_filters::NoiseType)filtopt->_uint); break;
+ case F::foil: fmt_filters::oil(image, filtopt->_double1); break;
+ case F::fshade: fmt_filters::shade(image, filtopt->_bool, filtopt->_double1, filtopt->_double2); break;
+ case F::fsharpen: fmt_filters::sharpen(image, filtopt->_double1, filtopt->_double2); break;
+ case F::fsolarize: fmt_filters::solarize(image, filtopt->_double1); break;
+ case F::fspread: fmt_filters::spread(image, filtopt->_uint); break;
+ case F::fswapRGB: fmt_filters::swapRGB(image, filtopt->_uint); break;
+ case F::fswirl: fmt_filters::swirl(image, filtopt->_double1, c); break;
+ case F::fthreshold: fmt_filters::threshold(image, filtopt->_uint); break;
+ case F::fgray: fmt_filters::gray(image); break;
+ case F::fredeye: fmt_filters::redeye(image, image.w, image.h, 0, 0, filtopt->_uint); break;
+ }
+
+ if(gls->valid()) bitBlt(&im, tab->sx, tab->sy, &img, 0, 0, img.width(), img.height());
+
+ editUpdate();
+
+ SQ_ImageFilter::instance()->setPreviewImage(generatePreview());
+}
+
+void SQ_GLWidget::slotBCG(SQ_ImageBCGOptions *bcgopt)
+{
+ TQImage im((uchar *)tab->parts[tab->current].buffer->data(), tab->parts[tab->current].realw, tab->parts[tab->current].realh, 32, 0, 0, TQImage::LittleEndian);
+ TQImage img = gls->valid() ? im.copy(tab->sx, tab->sy, tab->sw, tab->sh) : im;
+
+ fmt_filters::image image =
+ gls->valid() ? fmt_filters::image((unsigned char *)img.bits(), img.width(), img.height())
+ : fmt_filters::image((unsigned char *)img.bits(), tab->parts[tab->current].w, tab->parts[tab->current].h, img.width(), img.height());
+ if(bcgopt->b)
+ fmt_filters::brightness(image, bcgopt->b);
+
+ if(bcgopt->c)
+ fmt_filters::contrast(image, bcgopt->c);
+
+ if(bcgopt->g != 100)
+ fmt_filters::gamma(image, (double)bcgopt->g / 100.0);
+
+ if(bcgopt->red || bcgopt->green || bcgopt->blue)
+ fmt_filters::colorize(image, bcgopt->red, bcgopt->green, bcgopt->blue);
+
+ if(gls->valid()) bitBlt(&im, tab->sx, tab->sy, &img, 0, 0, img.width(), img.height());
+
+ editUpdate();
+
+ SQ_ImageBCG::instance()->setPreviewImage(generatePreview());
+}
+
+bool SQ_GLWidget::calcSelection()
+{
+ TQSize sz = gls->size();
+ TQPoint pt = gls->pos();
+
+ float z = getZoom();
+ float x = pt.x(), y = pt.y(), w = sz.width(), h = sz.height();
+ x = x - (float)width()/2 - MATRIX_X + (float)tab->parts[tab->current].w/2 * z;
+ y = y - (float)height()/2 + MATRIX_Y + (float)tab->parts[tab->current].h/2 * z;
+
+ int sx = (int)(x/z + 0.5);
+ int sy = (int)(y/z + 0.5);
+ int sw = (int)(w/z + 0.5);
+ int sh = (int)(h/z + 0.5);
+
+ if(!sw || !sh)
+ {
+ gls->end();
+ return false;
+ }
+ else
+ {
+ if(SQ_GLHelpers::normalizeSelection(sx,
+ sy,
+ sw,
+ sh,
+ tab->parts[tab->current].w,
+ tab->parts[tab->current].h,
+ tab->wm,
+ (int)tab->curangle,
+ tab->orient))
+ {
+ tab->srect = TQRect(pt, sz);
+ tab->sx = sx;
+ tab->sy = sy;
+ tab->sw = sw;
+ tab->sh = sh;
+ }
+ else
+ return false;
+ }
+
+ return true;
+}
+
+TQImage SQ_GLWidget::generatePreview()
+{
+ TQImage im((uchar *)tab->parts[tab->current].buffer->data(), tab->parts[tab->current].realw, tab->parts[tab->current].realh, 32, 0, 0, TQImage::LittleEndian);
+ TQImage img, ret;
+
+ if(gls->valid() && calcSelection())
+ img = im.copy(tab->sx, tab->sy, tab->sw, tab->sh);
+ else
+ {
+ if(tab->parts[tab->current].realw == tab->parts[tab->current].w && tab->parts[tab->current].realh == tab->parts[tab->current].h)
+ img = im;
+ else
+ img = im.copy(0, 0, tab->parts[tab->current].w, tab->parts[tab->current].h);
+ }
+
+ ret = SQ_Utils::scaleImage((unsigned char *)img.bits(), img.width(), img.height(), 160).swapRGB();
+
+ SQ_Utils::exifRotate(TQString(), ret, tab->orient);
+
+ return ret;
+}
+
+void SQ_GLWidget::editUpdate()
+{
+ int tlsy = tab->parts[tab->current].tilesy.size();
+
+ glDeleteLists(tab->parts[tab->current].m_parts[0].list, tlsy);
+
+ for(int i = 0;i < tlsy;i++)
+ showFrames(i, &tab->parts[tab->current], false);
+
+ updateGL();
+}
+
+void SQ_GLWidget::slotShowNav()
+{
+#ifndef KSQUIRREL_PART
+ KSquirrel::app()->activate();
+#endif
+}
+
+void SQ_GLWidget::initAccelsAndMenu()
+{
+ TQPopupMenu *menuRotate = new TQPopupMenu(menu);
+ TQPopupMenu *menuZoom = new TQPopupMenu(menu);
+ TQPopupMenu *menuMove = new TQPopupMenu(menu);
+
+#ifndef KSQUIRREL_PART
+ TQPopupMenu *menuWindow = new TQPopupMenu(menu);
+#endif
+
+ menuImage = new TQPopupMenu(menu);
+ menuFile = new TQPopupMenu(menu);
+
+ menu->insertItem(SQ_IconLoader::instance()->loadIcon("icons", TDEIcon::Desktop, TDEIcon::SizeSmall), i18n("File"), menuFile);
+ menu->insertItem(SQ_IconLoader::instance()->loadIcon("view_orientation", TDEIcon::Desktop, TDEIcon::SizeSmall), i18n("Rotate"), menuRotate);
+ menu->insertItem(SQ_IconLoader::instance()->loadIcon("viewmag", TDEIcon::Desktop, TDEIcon::SizeSmall), i18n("Zoom"), menuZoom);
+ menu->insertItem(i18n("Move"), menuMove);
+
+#ifndef KSQUIRREL_PART
+ menu->insertItem(i18n("Window"), menuWindow);
+#endif
+
+ menu->insertItem(i18n("Image"), menuImage);
+
+#define SQ_ADD_KACTION(b) \
+ (new TDEAction(TQString(), b, this, TQ_SLOT(slotAccelActivated()), ac, TQString::fromLatin1("action_%1").arg(b)))
+
+ id_saveas = menuFile->insertItem(SQ_IconLoader::instance()->loadIcon("document-save-as", TDEIcon::Desktop, TDEIcon::SizeSmall), i18n("Save As...") + "\tS", SQ_ADD_KACTION(TQt::Key_S), TQ_SLOT(activate()));
+
+#ifndef KSQUIRREL_PART
+ menuFile->insertSeparator();
+ menuFile->insertItem(TQPixmap(locate("data", "images/menu/next16.png")), i18n("Next") + "\tPageDown", SQ_ADD_KACTION(TQt::Key_PageDown), TQ_SLOT(activate()));
+ menuFile->insertItem(TQPixmap(locate("data", "images/menu/prev16.png")), i18n("Previous") + "\tPageUp", SQ_ADD_KACTION(TQt::Key_PageUp), TQ_SLOT(activate()));
+ menuFile->insertItem(TQPixmap(locate("data", "images/menu/first16.png")), i18n("First") + "\tHome", SQ_ADD_KACTION(TQt::Key_Home), TQ_SLOT(activate()));
+ menuFile->insertItem(TQPixmap(locate("data", "images/menu/last16.png")), i18n("Last") + "\tEnd", SQ_ADD_KACTION(TQt::Key_End), TQ_SLOT(activate()));
+#endif
+
+ menuFile->insertSeparator();
+ id_f5 = menuFile->insertItem(i18n("Copy to...") + "\tF5", SQ_ADD_KACTION(TQt::Key_F5), TQ_SLOT(activate()));
+ id_f6 = menuFile->insertItem(i18n("Move to...") + "\tF6", SQ_ADD_KACTION(TQt::Key_F7), TQ_SLOT(activate()));
+ id_f7 = menuFile->insertItem(i18n("Copy to last folder") + "\tF7", SQ_ADD_KACTION(TQt::Key_F6), TQ_SLOT(activate()));
+ id_f8 = menuFile->insertItem(i18n("Move to last folder") + "\tF8", SQ_ADD_KACTION(TQt::Key_F8), TQ_SLOT(activate()));
+ menuFile->insertSeparator();
+ id_del = menuFile->insertItem(i18n("Delete") + "\tDelete", SQ_ADD_KACTION(TQt::Key_Delete), TQ_SLOT(activate()));
+
+ menuRotate->insertItem(TQPixmap(locate("data", "images/menu/rotateLeft16.png")), i18n("Rotate left") + "\tCtrl+Left", SQ_ADD_KACTION(TQt::Key_Left+CTRL), TQ_SLOT(activate()));
+ menuRotate->insertItem(TQPixmap(locate("data", "images/menu/rotateRight16.png")), i18n("Rotate right") + "\tCtrl+Right", SQ_ADD_KACTION(TQt::Key_Right+CTRL), TQ_SLOT(activate()));
+ menuRotate->insertSeparator();
+ menuRotate->insertItem(TQPixmap(locate("data", "images/menu/18016.png")), i18n("Rotate 180'") + "\tCtrl+Up", SQ_ADD_KACTION(TQt::Key_Up+CTRL), TQ_SLOT(activate()));
+ menuRotate->insertSeparator();
+ menuRotate->insertItem(i18n("Rotate 1' left") + "\tAlt+Left", SQ_ADD_KACTION(TQt::Key_Left+ALT), TQ_SLOT(activate()));
+ menuRotate->insertItem(i18n("Rotate 1' right") + "\tAlt+Right", SQ_ADD_KACTION(TQt::Key_Right+ALT), TQ_SLOT(activate()));
+
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom+16.png")), i18n("Zoom +") + "\t+", SQ_ADD_KACTION(TQt::Key_Plus), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom-16.png")), i18n("Zoom -") + "\t-", SQ_ADD_KACTION(TQt::Key_Minus), TQ_SLOT(activate()));
+ menuZoom->insertItem(i18n("Zoom 2x") + "\tCtrl++", SQ_ADD_KACTION(TQt::Key_Plus+CTRL), TQ_SLOT(activate()));
+ menuZoom->insertItem(i18n("Zoom 1/2x") + "\tCtrl+-", SQ_ADD_KACTION(TQt::Key_Minus+CTRL), TQ_SLOT(activate()));
+ menuZoom->insertSeparator();
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom10016.png")), TQString::fromLatin1("100%") + "\t1", SQ_ADD_KACTION(TQt::Key_1), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom20016.png")), TQString::fromLatin1("200%") + "\t2", SQ_ADD_KACTION(TQt::Key_2), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom30016.png")), TQString::fromLatin1("300%") + "\t3", SQ_ADD_KACTION(TQt::Key_3), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom50016.png")), TQString::fromLatin1("500%") + "\t5", SQ_ADD_KACTION(TQt::Key_5), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom70016.png")), TQString::fromLatin1("700%") + "\t7", SQ_ADD_KACTION(TQt::Key_7), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom90016.png")), TQString::fromLatin1("900%") + "\t9", SQ_ADD_KACTION(TQt::Key_9), TQ_SLOT(activate()));
+ menuZoom->insertItem(TQPixmap(locate("data", "images/menu/zoom100016.png")), TQString::fromLatin1("1000%") + "\t0", SQ_ADD_KACTION(TQt::Key_0), TQ_SLOT(activate()));
+
+ menuMove->insertItem(TQPixmap(locate("data", "images/menu/moveLeft16.png")), i18n("Move left") + "\tRight", SQ_ADD_KACTION(TQt::Key_Right), TQ_SLOT(activate()));
+ menuMove->insertItem(TQPixmap(locate("data", "images/menu/moveRight16.png")), i18n("Move right") + "\tLeft", SQ_ADD_KACTION(TQt::Key_Left), TQ_SLOT(activate()));
+ menuMove->insertItem(TQPixmap(locate("data", "images/menu/moveUp16.png")), i18n("Move up") + "\tDown", SQ_ADD_KACTION(TQt::Key_Down), TQ_SLOT(activate()));
+ menuMove->insertItem(TQPixmap(locate("data", "images/menu/moveDown16.png")), i18n("Move down") + "\tUp", SQ_ADD_KACTION(TQt::Key_Up), TQ_SLOT(activate()));
+
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/animate16.png")), i18n("Start/stop animation") + "\tA", SQ_ADD_KACTION(TQt::Key_A), TQ_SLOT(activate()));
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/background16.png")), i18n("Hide/show background") + "\tB", SQ_ADD_KACTION(TQt::Key_B), TQ_SLOT(activate()));
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/tickmarks16.png")), i18n("Hide/show tickmarks") + "\tK", SQ_ADD_KACTION(TQt::Key_K), TQ_SLOT(activate()));
+ menuImage->insertSeparator();
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/flipV16.png")), i18n("Flip vertically") + "\tV", SQ_ADD_KACTION(TQt::Key_V), TQ_SLOT(activate()));
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/flipH16.png")), i18n("Flip horizontally") + "\tH", SQ_ADD_KACTION(TQt::Key_H), TQ_SLOT(activate()));
+ menuImage->insertSeparator();
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/page116.png")), i18n("First page") + "\tF1", SQ_ADD_KACTION(TQt::Key_F1), TQ_SLOT(activate()));
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/page216.png")), i18n("Previous page") + "\tF2", SQ_ADD_KACTION(TQt::Key_F2), TQ_SLOT(activate()));
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/page316.png")), i18n("Next page") + "\tF3", SQ_ADD_KACTION(TQt::Key_F3), TQ_SLOT(activate()));
+ menuImage->insertItem(TQPixmap(locate("data", "images/menu/page416.png")), i18n("Last page") + "\tF4", SQ_ADD_KACTION(TQt::Key_F4), TQ_SLOT(activate()));
+ menuImage->insertSeparator();
+ menuImage->insertItem(i18n("Copy file url") + "\tF9", SQ_ADD_KACTION(TQt::Key_F9), TQ_SLOT(activate()));
+ menuImage->insertItem(i18n("To clipboard") + "\tQ", SQ_ADD_KACTION(TQt::Key_Q), TQ_SLOT(activate()));
+ menuImage->insertItem(i18n("Print") + "\tCtrl+P", SQ_ADD_KACTION(TQt::Key_P+CTRL), TQ_SLOT(activate()));
+ menuImage->insertSeparator();
+ id_settings = menuImage->insertItem(SQ_IconLoader::instance()->loadIcon("configure", TDEIcon::Desktop, TDEIcon::SizeSmall), i18n("Codec settings") + "\tC", SQ_ADD_KACTION(TQt::Key_C), TQ_SLOT(activate()));
+ menuImage->setItemEnabled(id_settings, false);
+ menuImage->insertSeparator();
+ menuImage->insertItem(i18n("Color balance...") + "\tD", SQ_ADD_KACTION(TQt::Key_D), TQ_SLOT(activate()));
+ menuImage->insertItem(i18n("Apply filter...") + "\tU", SQ_ADD_KACTION(TQt::Key_U), TQ_SLOT(activate()));
+
+ menuImage->insertItem(i18n("Crop") + "\tY", SQ_ADD_KACTION(TQt::Key_Y), TQ_SLOT(activate()));
+
+#ifndef KSQUIRREL_PART
+ menuWindow->insertItem(TQPixmap(locate("data", "images/menu/fullscreen16.png")), i18n("Fullscreen") + "\tF", SQ_ADD_KACTION(TQt::Key_F), TQ_SLOT(activate()));
+ menuWindow->insertSeparator();
+ menuWindow->insertItem(i18n("Previous tab") + "\tShift+Left", SQ_ADD_KACTION(TQt::Key_Left+SHIFT), TQ_SLOT(activate()));
+ menuWindow->insertItem(i18n("Next tab") + "\tShift+Right", SQ_ADD_KACTION(TQt::Key_Right+SHIFT), TQ_SLOT(activate()));
+ menuWindow->insertSeparator();
+ menuWindow->insertItem(i18n("Close tab") + "\tW", SQ_ADD_KACTION(TQt::Key_W), TQ_SLOT(activate()));
+
+ menuWindow->insertItem(i18n("Close all tabs") + "\tCtrl+W", SQ_ADD_KACTION(TQt::Key_W+CTRL), TQ_SLOT(activate()));
+#endif
+
+ menu->insertSeparator();
+ menu->insertItem(TQPixmap(locate("data", "images/menu/reset16.png")), i18n("Reset") + "\tR", SQ_ADD_KACTION(TQt::Key_R), TQ_SLOT(activate()));
+ id_prop = menu->insertItem(TQPixmap(locate("data", "images/menu/prop16.png")), i18n("Properties") + "\tP", SQ_ADD_KACTION(TQt::Key_P), TQ_SLOT(activate()));
+ menu->insertSeparator();
+ menu->insertItem(i18n("Hotkeys") + "\t/", SQ_ADD_KACTION(TQt::Key_Slash), TQ_SLOT(activate()));
+
+#ifndef KSQUIRREL_PART
+ menu->insertSeparator();
+ menu->insertItem(TQPixmap(locate("data", "images/menu/close16.png")), i18n("Close") + "\tX", SQ_ADD_KACTION(TQt::Key_X), TQ_SLOT(activate()));
+#endif
+
+ SQ_ADD_KACTION(TQt::Key_Down+CTRL);
+ SQ_ADD_KACTION(TQt::Key_Equal);
+ SQ_ADD_KACTION(TQt::Key_Equal+CTRL);
+ SQ_ADD_KACTION(TQt::Key_N);
+ SQ_ADD_KACTION(TQt::Key_Space);
+ SQ_ADD_KACTION(TQt::Key_BackSpace);
+ SQ_ADD_KACTION(TQt::Key_Escape);
+ SQ_ADD_KACTION(TQt::Key_Return);
+ SQ_ADD_KACTION(TQt::Key_Enter);
+ SQ_ADD_KACTION(TQt::Key_Z);
+ SQ_ADD_KACTION(TQt::Key_I);
+ SQ_ADD_KACTION(TQt::Key_E);
+
+#ifndef KSQUIRREL_PART
+ SQ_ADD_KACTION(TQt::Key_R+CTRL);
+ SQ_ADD_KACTION(TQt::Key_E+CTRL);
+ SQ_ADD_KACTION(TQt::Key_C+CTRL);
+#endif
+
+ SQ_ADD_KACTION(TQt::Key_Menu);
+ SQ_ADD_KACTION(TQt::Key_M);
+ SQ_ADD_KACTION(TQt::Key_4);
+ SQ_ADD_KACTION(TQt::Key_6);
+ SQ_ADD_KACTION(TQt::Key_8);
+ SQ_ADD_KACTION(TQt::Key_Comma);
+ SQ_ADD_KACTION(TQt::Key_Period);
+ SQ_ADD_KACTION(TQt::Key_Asterisk);
+ SQ_ADD_KACTION(TQt::Key_L);
+}
+
+
+void SQ_GLWidget::slotAccelActivated()
+{
+ TDEAction *accel = static_cast<TDEAction *>(const_cast<TQObject *>(sender()));
+
+ TDEShortcut ks = accel->shortcut();
+
+ if(!ks.compare(TQt::Key_Left)) matrix_move(movefactor, 0);
+ else if(!ks.compare(TQt::Key_Right)) matrix_move(-movefactor, 0);
+ else if(!ks.compare(TQt::Key_Up)) matrix_move(0, -movefactor);
+ else if(!ks.compare(TQt::Key_Down)) matrix_move(0, movefactor);
+ else if(!ks.compare(TQt::Key_Equal) ||
+ !ks.compare(TQt::Key_Plus)) slotZoomPlus();
+ else if(!ks.compare(TQt::Key_Minus)) slotZoomMinus();
+ else if(!ks.compare(TQt::Key_Equal+CTRL) ||
+ !ks.compare(TQt::Key_Plus+CTRL)) matrix_zoom(2.0f);
+ else if(!ks.compare(TQt::Key_Minus+CTRL)) matrix_zoom(0.5f);
+ else if(!ks.compare(TQt::Key_Q)) toClipboard();
+ else if(!ks.compare(TQt::Key_V)) slotFlipV();
+ else if(!ks.compare(TQt::Key_H)) slotFlipH();
+ else if(!ks.compare(TQt::Key_Left+CTRL)) slotRotateLeft();
+ else if(!ks.compare(TQt::Key_Right+CTRL)) slotRotateRight();
+ else if(!ks.compare(TQt::Key_R)) slotMatrixReset();
+ else if(!ks.compare(TQt::Key_Up+CTRL)) matrix_rotate(180.0f);
+ else if(!ks.compare(TQt::Key_Down+CTRL)) matrix_rotate(-180.0f);
+ else if(!ks.compare(TQt::Key_Left+ALT)) matrix_rotate(-1.0f);
+ else if(!ks.compare(TQt::Key_Right+ALT)) matrix_rotate(1.0f);
+
+#ifndef KSQUIRREL_PART
+ else if(!ks.compare(TQt::Key_Left+SHIFT)) SQ_GLView::window()->leftTab();
+ else if(!ks.compare(TQt::Key_Right+SHIFT)) SQ_GLView::window()->rightTab();
+ else if(!ks.compare(TQt::Key_W)) slotCloseRequest(SQ_GLView::window()->tabbar()->indexOf(SQ_GLView::window()->tabbar()->currentTab()));
+ else if(!ks.compare(TQt::Key_W+CTRL)) closeAllTabsFull();
+#else
+ else if(!ks.compare(TQt::Key_W)) closeAllTabsFull();
+#endif
+
+ else if(!ks.compare(TQt::Key_N)) updateFilter(!linear);
+ else if(!ks.compare(TQt::Key_P)) slotProperties();
+ else if(!ks.compare(TQt::Key_C)) slotShowCodecSettings();
+
+#ifndef KSQUIRREL_PART
+ else if(!ks.compare(TQt::Key_PageDown) ||
+ !ks.compare(TQt::Key_Space)) slotNext();
+ else if(!ks.compare(TQt::Key_PageUp) ||
+ !ks.compare(TQt::Key_BackSpace)) slotPrev();
+ else if(!ks.compare(TQt::Key_X) ||
+ !ks.compare(TQt::Key_Escape) ||
+ !ks.compare(TQt::Key_Return) ||
+ !ks.compare(TQt::Key_Enter)) KSquirrel::app()->closeGLWidget();
+ else if(!ks.compare(TQt::Key_Home)) slotFirst();
+ else if(!ks.compare(TQt::Key_End)) slotLast();
+ else if(!ks.compare(TQt::Key_F)) toggleFullScreen();
+#endif
+
+ else if(!ks.compare(TQt::Key_Z)) slotZoomMenu();
+ else if(!ks.compare(TQt::Key_S)) saveAs();
+ else if(!ks.compare(TQt::Key_A)) slotToggleAnimate();
+ else if(!ks.compare(TQt::Key_I)) slotShowImages();
+ else if(!ks.compare(TQt::Key_F1)) jumpToImage(false);
+ else if(!ks.compare(TQt::Key_F2)) prevImage();
+ else if(!ks.compare(TQt::Key_F3)) nextImage();
+ else if(!ks.compare(TQt::Key_F4)) jumpToImage(true);
+ else if(!ks.compare(TQt::Key_F5) || !ks.compare(TQt::Key_F6))
+ {
+ // select a directory
+ KURL url = KFileDialog::getExistingURL(lastCopy.prettyURL(), this);
+
+ if(url.isEmpty())
+ return;
+
+ lastCopy = url;
+ TDEIO::Job *job;
+
+ if(!ks.compare(TQt::Key_F5))
+ job = TDEIO::copy(tab->m_original, url);
+ else
+ job = TDEIO::move(tab->m_original, url);
+
+ job->setWindow(this);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotCopyJobResult(TDEIO::Job *)));
+ }
+ else if(!ks.compare(TQt::Key_F7) || !ks.compare(TQt::Key_F8))
+ {
+ TDEIO::Job *job;
+
+ if(!ks.compare(TQt::Key_F6))
+ job = TDEIO::copy(tab->m_original, lastCopy);
+ else
+ job = TDEIO::move(tab->m_original, lastCopy);
+
+ job->setWindow(this);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotCopyJobResult(TDEIO::Job *)));
+ }
+ else if(!ks.compare(TQt::Key_F9)) copyURL();
+ else if(!ks.compare(TQt::Key_Slash)) slotShowHelp();
+ else if(!ks.compare(TQt::Key_B)) toggleDrawingBackground();
+ else if(!ks.compare(TQt::Key_K)) toogleTickmarks();
+ else if(!ks.compare(TQt::Key_E)) showExternalTools();
+ else if(!ks.compare(TQt::Key_Delete)) deleteWrapper();
+ else if(!ks.compare(TQt::Key_D)) bcg();
+ else if(!ks.compare(TQt::Key_U)) filter();
+ else if(!ks.compare(TQt::Key_Y)) crop();
+
+#ifndef KSQUIRREL_PART
+ else if(!ks.compare(TQt::Key_R+CTRL)) slotSelectionRect();
+ else if(!ks.compare(TQt::Key_E+CTRL)) slotSelectionEllipse();
+ else if(!ks.compare(TQt::Key_C+CTRL)) slotSelectionClear();
+#endif
+
+ else if(!ks.compare(TQt::Key_P+CTRL)) slotPrint();
+ else if(!ks.compare(TQt::Key_Menu) ||
+ !ks.compare(TQt::Key_M)) menu->exec(TQCursor::pos());
+ else if(!ks.compare(TQt::Key_Comma)) slotZoomW();
+ else if(!ks.compare(TQt::Key_Period)) slotZoomH();
+ else if(!ks.compare(TQt::Key_Asterisk)) slotZoomWH();
+ else if(!ks.compare(TQt::Key_L))
+ {
+ bool b = pAIfLess->isChecked();
+ pAIfLess->setChecked(!b);
+ slotZoomIfLess();
+ }
+ else
+ {
+ int val = -1;
+
+ if(!ks.compare(TQt::Key_1)) val = 1;
+ else if(!ks.compare(TQt::Key_2)) val = 2;
+ else if(!ks.compare(TQt::Key_3)) val = 3;
+ else if(!ks.compare(TQt::Key_4)) val = 4;
+ else if(!ks.compare(TQt::Key_5)) val = 5;
+ else if(!ks.compare(TQt::Key_6)) val = 6;
+ else if(!ks.compare(TQt::Key_7)) val = 7;
+ else if(!ks.compare(TQt::Key_8)) val = 8;
+ else if(!ks.compare(TQt::Key_9)) val = 9;
+ else if(!ks.compare(TQt::Key_0)) val = 10;
+
+ if(val != -1)
+ {
+ if(tab->broken || tab->finfo.image.empty())
+ return;
+
+ zoom(val);
+ }
+ }
+}
+
+void SQ_GLWidget::zoom(GLfloat val)
+{
+ oldZoom = getZoom();
+ matrix_reset(false);
+ matrix_zoom(val);
+}
+
+void SQ_GLWidget::slotCopyJobResult(TDEIO::Job *job)
+{
+ if(job->error())
+ job->showErrorDialog(this);
+}
+
+void SQ_GLWidget::exifRotate(bool U)
+{
+#ifdef SQ_HAVE_KEXIF
+ switch(tab->orient)
+ {
+ // flipping
+ case KExifData::HFLIP: tab->isflippedH = !tab->isflippedH; flip(0, U); break;
+ case KExifData::VFLIP: tab->isflippedV = !tab->isflippedV; flip(4, U); break;
+
+ // rotating
+ case KExifData::ROT_90: matrix_rotate(90, U); break;
+ case KExifData::ROT_180: matrix_rotate(180, U); break;
+ case KExifData::ROT_270: matrix_rotate(270, U); break;
+
+ // flipping & rotating
+ case KExifData::ROT_90_HFLIP: tab->isflippedH = !tab->isflippedH; flip(0, false); matrix_rotate(90, U); break;
+ case KExifData::ROT_90_VFLIP: tab->isflippedV = !tab->isflippedV; flip(4, false); matrix_rotate(90, U); break;
+
+ // normal rotation or unspecified
+ default: if(U) updateGL();
+ }
+#else
+ if(U)
+ updateGL();
+#endif
+}
+
+void SQ_GLWidget::enableActions(bool U)
+{
+#ifndef KSQUIRREL_PART
+ pASelectionRect->setEnabled(U);
+ pASelectionEllipse->setEnabled(U);
+ pASelectionClear->setEnabled(U);
+ pAToolProp->setEnabled(U);
+ pAToolPrint->setEnabled(U);
+#endif
+
+ menuFile->setItemEnabled(id_f5, U);
+ menuFile->setItemEnabled(id_f6, U);
+ menuFile->setItemEnabled(id_f7, U);
+ menuFile->setItemEnabled(id_f8, U);
+ menuFile->setItemEnabled(id_del, U);
+ menuFile->setItemEnabled(id_saveas, U);
+
+ menu->setItemEnabled(id_prop, U);
+
+ menuImage->setEnabled(U);
+}
+
+void SQ_GLWidget::crop()
+{
+ if(tab->broken
+ || tab->finfo.image.empty()
+ || !gls->valid()
+ || !calcSelection()
+ || (tab->sw == tab->parts[tab->current].w && tab->sh == tab->parts[tab->current].h))
+ return;
+
+ const int RW = tab->parts[tab->current].realw;
+ RGBA *img = tab->parts[tab->current].buffer->data() + tab->sy * RW + tab->sx;
+
+ Parts pp;
+ memoryPart *pt;
+
+ SQ_GLWidget::findCloserTiles(tab->sw, tab->sh, pp.tilesx, pp.tilesy);
+ TQPair<int, int> pair = SQ_GLWidget::calcRealDimensions(pp);
+ pp.realw = pair.first;
+ pp.realh = pair.second;
+ pp.w = tab->sw;
+ pp.h = tab->sh;
+
+ if(!pp.makeParts())
+ {
+ KMessageBox::error(this,
+ i18n("Memory allocation failed for %1 of memory")
+ .arg(TDEIO::convertSize(pp.realw * pp.realh * sizeof(RGBA))));
+ return;
+ }
+
+ pt = new memoryPart(pp.realw * pp.realh);
+ pt->create();
+
+ if(!pt->valid())
+ {
+ pp.removeParts();
+ return;
+ }
+
+ memset(pt->data(), 0, pp.realw * pp.realh * sizeof(RGBA));
+
+ for(int i = 0;i < tab->sh;i++)
+ memcpy(pt->data()+i*pp.realw, img + i*RW, tab->sw * sizeof(RGBA));
+
+ pp.computeCoords();
+ pp.buffer = pt;
+
+ tab->parts[tab->current].removeParts();
+ tab->parts[tab->current].deleteBuffer();
+ tab->finfo.image[tab->current].w = tab->sw;
+ tab->finfo.image[tab->current].h = tab->sh;
+
+ int tlsy = pp.tilesy.size();
+ for(int i = 0;i < tlsy;i++)
+ showFrames(i, &pp, false);
+
+ tab->parts[tab->current] = pp;
+
+ slotSelectionClear();
+ updateCurrentFileInfo();
+ tab->isflippedH = tab->isflippedV = false;
+ slotZoomIfLess();
+ matrixChanged();
+}
+
+void SQ_GLWidget::slotChangeTab(int id)
+{
+#ifndef KSQUIRREL_PART
+ id = SQ_GLView::window()->tabbar()->indexOf(id);
+
+ Tab *newtab = (id == -1) ? &taborig : &tabs[id];
+
+ if(tab == newtab)
+ return;
+
+ if(tab)
+ {
+ tab->removeParts();
+ gls->setVisible(false);
+ }
+
+ tab = newtab;
+
+ images->clear();
+ old_id = -1;
+ stopAnimation();
+
+ enableSettingsButton(id != -1 && tab->lib && !tab->lib->config.isEmpty());
+ enableActions(!tab->broken && id != -1);
+
+ if(id == -1)
+ {
+ SQ_GLView::window()->resetStatusBar();
+ KSquirrel::app()->setCaption(TQString());
+ decoded = false;
+ changeSlider(1.0);
+ }
+ else
+ {
+ changeSlider();
+ KSquirrel::app()->setCaption(originalURL());
+ enableActions(!tab->broken);
+
+ if(!tab->broken)
+ {
+ SQ_GLView::window()->sbarWidget("SBDecodedI")->setPixmap(tab->lib->mime);
+
+ // fill menu
+ std::vector<fmt_image>::iterator itEnd = tab->finfo.image.end();
+ std::vector<fmt_image>::iterator it = tab->finfo.image.begin();
+ int mid, i = 0, first_id = 0;
+
+ for(;it != itEnd;++it, ++i)
+ {
+ mid = images->insertItem(TQString::fromLatin1("#%1 [%2x%3@%4]").arg(i+1).arg((*it).w).arg((*it).h).arg((*it).bpp));
+ images->setItemParameter(mid, i);
+
+ if(i == tab->current)
+ old_id = first_id = mid;
+ }
+
+ images->setItemChecked(first_id, true);
+ updateCurrentFileInfo();
+ frameChanged();
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBFile")->setText(tab->m_original.fileName(false));
+ SQ_GLView::window()->sbarWidget("SBLoaded")->setText(TDEGlobal::locale()->formatLong(tab->elapsed) + i18n(" ms."));
+#else
+ t_glv.sbarWidget("SBFile")->setText(tab->m_original.fileName(false));
+ t_glv.sbarWidget("SBLoaded")->setText(TDEGlobal::locale()->formatLong(tab->elapsed) + i18n(" ms."));
+#endif
+ }
+ else
+ SQ_GLView::window()->resetStatusBar();
+
+ std::vector<Parts>::iterator itp = tab->parts.begin();
+ std::vector<Parts>::iterator itpEnd = tab->parts.end();
+ int tlsy;
+
+ tab->remakeParts();
+
+ if(tab->glselection != -1)
+ {
+ if(!gls->valid())
+ gls->begin(static_cast<SQ_GLSelectionPainter::Type>(tab->glselection), 0, 0, false);
+
+ gls->setGeometry(tab->srect);
+ }
+ else
+ gls->end();
+
+ gls->setVisible(tab->glselection != -1);
+
+ for(;itp != itpEnd;++itp)
+ {
+ tlsy = (*itp).tilesy.size();
+
+ for(int i = 0;i < tlsy;i++)
+ showFrames(i, &(*itp), false);
+ }
+
+ if(!manualBlocked())
+ startAnimation();
+ }
+
+ matrixChanged();
+ updateGL();
+#endif
+}
+
+void SQ_GLWidget::slotCloseRequest(int index)
+{
+#ifndef KSQUIRREL_PART
+ if(index < 0)
+ return;
+
+ SQ_GLView::window()->tabbar()->blockSignals(true);
+
+ // prevent matrix from changing. When tab count == 1,
+ // SQ_GLView will hide tabbar and SQ_GLWIdget will be resized.
+ // We don't want it.
+ if(SQ_GLView::window()->tabbar()->count() == 2)
+ hackResizeGL = true;
+
+ SQ_GLView::window()->removePage(index);
+ emit tabCountChanged();
+ SQ_GLView::window()->tabbar()->blockSignals(false);
+
+ // workaround bug in KTabBar
+ TQMouseEvent ev(TQEvent::MouseMove,
+ TQCursor::pos(),
+ SQ_GLView::window()->tabbar()->mapFromGlobal(TQCursor::pos()),
+ TQt::NoButton,
+ TQt::NoButton);
+
+ TDEApplication::sendEvent(SQ_GLView::window()->tabbar(), &ev);
+
+ std::vector<Tab>::iterator itEnd = tabs.end();
+ std::vector<Tab>::iterator it = tabs.begin();
+ int i = 0;
+
+ for(;(it != itEnd && i != index);++it, ++i)
+ ;
+
+ (*it).clearParts();
+ tabs.erase(it);
+ tab = 0;
+
+ gls->setVisible(false);
+
+ slotChangeTab(SQ_GLView::window()->tabbar()->currentTab());
+#endif
+}
+
+void SQ_GLWidget::initBrokenImage()
+{
+ memoryPart *pt;
+ TQImage broken = TQPixmap(file_broken_xpm).convertToImage().swapRGB();
+ broken.setAlphaBuffer(true);
+
+ parts_broken = new Parts;
+
+ // setup parts_broken. It will have only one 64x64 tile
+ parts_broken->tilesx.push_back(broken.width());
+ parts_broken->tilesy.push_back(broken.height());
+ parts_broken->realw = broken.width();
+ parts_broken->realh = broken.height();
+ parts_broken->w = broken.width();
+ parts_broken->h = broken.height();
+ parts_broken->makeParts();
+ parts_broken->computeCoords();
+
+ pt = new memoryPart(broken.width() * broken.width());
+ pt->create();
+
+ memcpy(pt->data(), broken.bits(), broken.numBytes());
+
+ parts_broken->buffer = pt;
+
+ showFrames(0, parts_broken, false);
+
+ image_broken.w = parts_broken->w;
+ image_broken.h = parts_broken->h;
+ image_broken.bpp = broken.depth();
+ image_broken.compression = "-";
+ image_broken.colorspace = "RGBA";
+ image_broken.hasalpha = false;
+
+ // we don't need memory buffer any more...
+ parts_broken->deleteBuffer();
+}
+
+// Accept drop events.
+void SQ_GLWidget::dropEvent(TQDropEvent *e)
+{
+ TQStringList files;
+
+ if(TQUriDrag::decodeLocalFiles(e, files))
+ {
+ // go through array and find first supported image format
+ for(TQStringList::iterator it = files.begin();it != files.end();++it)
+ {
+ if(SQ_LibraryHandler::instance()->libraryForFile(*it))
+ {
+ KURL u = KURL::fromPathOrURL(*it);
+ m_expected = u;
+ m_original = u;
+ startDecoding(u);
+ break;
+ }
+ }
+ }
+}
+
+// Accept drag events.
+void SQ_GLWidget::dragEnterEvent(TQDragEnterEvent *e)
+{
+ e->accept(TQUriDrag::canDecode(e));
+}
+
+/*
+ * Set clear color for context.
+ */
+void SQ_GLWidget::setClearColor()
+{
+ TQColor color;
+ TQString path;
+
+ SQ_Config::instance()->setGroup("GL view");
+
+ switch(SQ_Config::instance()->readNumEntry("GL view background type", 1))
+ {
+ // system color
+ case 0:
+ color = colorGroup().color(TQColorGroup::Base);
+ break;
+
+ // custom color
+ case 1:
+ color.setNamedColor(SQ_Config::instance()->readEntry("GL view background", "#4e4e4e"));
+ break;
+
+ // repeated texture
+ case 2:
+ path = SQ_Config::instance()->readEntry("GL view custom texture", "");
+ BGpixmap.load(path);
+
+ if(BGpixmap.isNull())
+ {
+ SQ_Config::instance()->writeEntry("GL view background type", 0);
+ setClearColor();
+ return;
+ }
+
+ BGpixmap.convertDepth(32);
+ BGpixmap = BGpixmap.swapRGB();
+
+ changed = true;
+ break;
+
+ default: ;
+ }
+
+ // update clear color
+ qglClearColor(color);
+
+ if(decoded)
+ updateGL();
+}
+
+void SQ_GLWidget::removeCurrentParts()
+{
+ // if tab->broken, 'tab->parts' has no members
+ if(decoded && !tab->broken)
+ {
+ std::vector<Parts>::iterator itEnd = tab->parts.end();
+
+ for(std::vector<Parts>::iterator it = tab->parts.begin();it != itEnd;++it)
+ {
+ // delete textures and memory buffers
+ (*it).removeParts();
+ (*it).deleteBuffer();
+ }
+
+ tab->parts.clear();
+ }
+}
+
+void SQ_GLWidget::removeCurrentTabs()
+{
+ std::vector<Tab>::iterator itEnd = tabs.end();
+
+ for(std::vector<Tab>::iterator it = tabs.begin();it != itEnd;++it)
+ (*it).clearParts();
+
+ tabs.clear();
+ tab = &taborig;
+}
+
+void SQ_GLWidget::removeNonCurrentTabs(int index)
+{
+ std::vector<Tab>::iterator itEnd = tabs.end();
+ Tab tm;
+ int i = 0;
+
+ for(std::vector<Tab>::iterator it = tabs.begin();it != itEnd;++it, ++i)
+ {
+ if(i == index)
+ {
+ tm = *it;
+ continue;
+ }
+
+ (*it).clearParts();
+ }
+
+ tabs.clear();
+ tabs.push_back(tm);
+ tab = &tabs[0];
+}
+
+void SQ_GLWidget::startDecoding(const KURL &url)
+{
+ startDecoding(url.path());
+}
+
+// Show/hide background for transparent image.
+void SQ_GLWidget::toggleDrawingBackground()
+{
+ SQ_Config::instance()->setGroup("GL view");
+
+ bool b = SQ_Config::instance()->readBoolEntry("alpha_bkgr", true);
+
+ b = !b;
+
+ SQ_Config::instance()->writeEntry("alpha_bkgr", b);
+
+ updateGL();
+}
+
+void SQ_GLWidget::createMarks()
+{
+ mm[0] = TQImage(locate("data", "images/marks/mark_1.png"));
+ mm[1] = TQImage(locate("data", "images/marks/mark_2.png"));
+ mm[2] = TQImage(locate("data", "images/marks/mark_3.png"));
+ mm[3] = TQImage(locate("data", "images/marks/mark_4.png"));
+
+ marks = (mm[0].isNull() || mm[1].isNull() || mm[2].isNull() || mm[3].isNull()) ? false : true;
+
+ if(!marks)
+ return;
+
+ for(int i = 0;i < 4;i++)
+ {
+ mm[i] = mm[i].convertDepth(32);
+ mm[i].setAlphaBuffer(true);
+ }
+}
+
+/*
+ * Show current image's width, height and bpp in statusbar.
+ */
+void SQ_GLWidget::updateCurrentFileInfo()
+{
+ TQString status = TQString::fromLatin1("%1x%2@%3")
+ .arg(tab->finfo.image[tab->current].w)
+ .arg(tab->finfo.image[tab->current].h)
+ .arg(tab->finfo.image[tab->current].bpp);
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBDecoded")->setText(status);
+#else
+ t_glv.sbarWidget("SBDecoded")->setText(status);
+#endif
+}
+
+// Show/hide tickmarks around the image.
+void SQ_GLWidget::toogleTickmarks()
+{
+ SQ_Config::instance()->setGroup("GL view");
+
+ bool b = SQ_Config::instance()->readBoolEntry("marks", true);
+
+ b = !b;
+
+ SQ_Config::instance()->writeEntry("marks", b);
+
+ updateGL();
+}
+
+void SQ_GLWidget::changeSlider(GLfloat z1)
+{
+#ifndef KSQUIRREL_PART
+ GLfloat z = z1 < 0 ? getZoom() : z1;
+
+ int i_zoom = (int)(z * 100);
+
+ slider_zoom->blockSignals(true);
+ slider_zoom->setValue((i_zoom <= 100) ? i_zoom/5 : (19+i_zoom/50));
+ slider_zoom->blockSignals(false);
+#endif
+}
+
+void SQ_GLWidget::calcFrameLabelWidth()
+{
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBFrame")->setFixedWidth(
+ SQ_GLView::window()->sbarWidget("SBFrame")->fontMetrics()
+ .boundingRect(TQString::fromLatin1("0%1/0%2").arg(tab->total).arg(tab->total)).width());
+#endif
+}
+
+/*
+ * Show current page number in multipaged images.
+ *
+ * For example: "3/11" means that current page is the third in current image,
+ * which has 11 pages.
+ */
+void SQ_GLWidget::frameChanged()
+{
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->sbarWidget("SBFrame")->setText(TQString::fromLatin1("%1/%2").arg(tab->current+1).arg(tab->total));
+#else
+ t_glv.sbarWidget("SBFrame")->setText(TQString::fromLatin1("%1/%2").arg(tab->current+1).arg(tab->total));
+#endif
+}
+
+void SQ_GLWidget::closeAllTabs()
+{
+ removeCurrentTabs();
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->removeTabs();
+#endif
+}
+
+void SQ_GLWidget::closeAllTabsFull()
+{
+ stopAnimation();
+
+ closeAllTabs();
+
+#ifndef KSQUIRREL_PART
+ SQ_GLView::window()->resetStatusBar();
+ SQ_GLView::window()->tabbar()->hide();
+
+ KSquirrel::app()->setCaption(TQString());
+#endif
+
+ decoded = false;
+ m_original = KURL();
+ m_expected = KURL();
+
+ images->clear();
+ old_id = -1;
+
+ enableSettingsButton(false);
+ enableActions(false);
+ changeSlider(1.0);
+
+ updateGL();
+}
+
+void SQ_GLWidget::slotPrint()
+{
+ if(!decoded || tab->broken)
+ return;
+
+ TQImage im((uchar *)tab->parts[tab->current].buffer->data(), tab->parts[tab->current].realw, tab->parts[tab->current].realh, 32, 0, 0, TQImage::LittleEndian);
+ TQImage img;
+
+ if(gls->valid() && calcSelection())
+ img = TQImage(im.copy(tab->sx, tab->sy, tab->sw, tab->sh)).swapRGB();
+ else
+ {
+ if(tab->parts[tab->current].realw == tab->parts[tab->current].w && tab->parts[tab->current].realh == tab->parts[tab->current].h)
+ img = im.swapRGB();
+ else
+ img = TQImage(im.copy(0, 0, tab->parts[tab->current].w, tab->parts[tab->current].h)).swapRGB();
+ }
+
+ img.setAlphaBuffer(true);
+
+ KPrinter printer;
+
+ printer.setCreator("KSquirrel");
+
+ if(printer.setup(this))
+ {
+ TQPainter p(&printer);
+
+ TQPaintDeviceMetrics mt(&printer);
+
+ TQSize sz(img.width(), img.height());
+
+ if(img.width() > mt.width() || img.height() > mt.height())
+ sz.scale(mt.width(), mt.height(), TQSize::ScaleMin);
+
+ int cp = printer.numCopies();
+
+ for(int i = 0;i < cp;i++)
+ {
+ p.drawImage(TQRect((mt.width()-sz.width())/2, (mt.height()-sz.height())/2, sz.width(), sz.height()), img);
+
+ if(i < cp-1)
+ printer.newPage();
+ }
+ }
+}
+
+void SQ_GLWidget::copyURL()
+{
+ if(!decoded || tab->broken)
+ return;
+
+ TQApplication::clipboard()->setText(tab->m_original.prettyURL());
+}
diff --git a/src/sq_helpwidget.ui b/src/sq_helpwidget.ui
new file mode 100644
index 0000000..cb2a4bc
--- /dev/null
+++ b/src/sq_helpwidget.ui
@@ -0,0 +1,334 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_HelpWidget</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_HelpWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>512</width>
+ <height>430</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Hotkeys</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>false</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQWidgetStack" row="1" column="0">
+ <property name="name">
+ <cstring>widgetStack1</cstring>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p align=center&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Esc,X,Return&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;close&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Middle click, F&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;fullscreen&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Z&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;show 'Zoom' menu&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;/&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;show this help&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Right click, M, ContextMenu&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;show context menu&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;N&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;toggle filter&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Shift + Left button&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;select a region&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Shift + Left&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;previous tab&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Shift + Right&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;next tab&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;W&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;close tab&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p align=center&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Space, Page Down&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;next image&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Backspace, Page Up&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;previous image&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Home&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;first image&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;End&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;last image&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>2</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p align=center&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Left, Right, Up, Down&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;move the image&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Ctrl + Left&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;rotate left&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Ctrl + Right&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;rotate right&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Ctrl + Up/Down&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;rotate for 180 degrees up/down&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Alt + Left/Right&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;rotate for 1 degree left/right&lt;/td&gt;&lt;/tr&gt;&lt;/table&lt;/p&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>3</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel6</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p align=center&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;+/-&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;zoom Nx&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Ctrl + +/-&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;zoom 2x/0.5x&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Scroll&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;load next/prev file OR zoom+/zoom-&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Shift + Scroll&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;zoom+/zoom-&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;Ctrl + Scroll&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;zoom+ 2x/zoom- 2x&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;1..9&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;zoom 1..9x&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;0&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;zoom 10x&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;comma&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;fit width&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;period&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;fit height&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;p align=right&gt;*&lt;/p&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;fit image&lt;/td&gt;&lt;/tr&gt;&lt;/table&lt;/p&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>4</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel5</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;p align=center&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;S&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;save as&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;V&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;flip vertically&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;H&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;flip horizontally&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;R&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;reset&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;P&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;image properties&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;C&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;codec settings&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;L&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;ignore zoom if image is smaller than window&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;I&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;menu with images&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;A&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;stop/start animation&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;B&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;toggle drawing background for transparent images&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;K&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;toggle drawing tickmarks&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;E&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;show menu with external tools&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;Y&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;crop&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;F1&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;first image in multi-paged image&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;F2&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;previous&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;F3&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;next&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p align=right&gt;&lt;b&gt;F4&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;last&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ <widget class="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>buttonGroup</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <property name="exclusive">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushButton3</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>General</string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="on">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="buttonGroupId">
+ <number>0</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>pushButton3_2</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Filing</string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="buttonGroupId">
+ <number>1</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="2">
+ <property name="name">
+ <cstring>pushButton3_3</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Moving</string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="buttonGroupId">
+ <number>2</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="4">
+ <property name="name">
+ <cstring>pushButton3_5</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Current image</string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="buttonGroupId">
+ <number>4</number>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="3">
+ <property name="name">
+ <cstring>pushButton3_4</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Zoom</string>
+ </property>
+ <property name="toggleButton">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="buttonGroupId">
+ <number>3</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>buttonGroup</sender>
+ <signal>clicked(int)</signal>
+ <receiver>widgetStack1</receiver>
+ <slot>raiseWidget(int)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>pushButton3</tabstop>
+ <tabstop>pushButton3_2</tabstop>
+ <tabstop>pushButton3_3</tabstop>
+ <tabstop>pushButton3_5</tabstop>
+ <tabstop>pushButton3_4</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in implementation">tqtooltip.h</include>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="local" impldecl="in implementation">sq_helpwidget.ui.h</include>
+</includes>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function access="private" specifier="non virtual">destroy()</function>
+ <function returnType="bool">event( TQEvent * e )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_helpwidget.ui.h b/src/sq_helpwidget.ui.h
new file mode 100644
index 0000000..c0f2673
--- /dev/null
+++ b/src/sq_helpwidget.ui.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** TQt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+/*
+ * SQ_HelpWidget is a helper widget. It shows hotkeys, which
+ * are accepted by SQ_GLWidget. Called from SQ_GLWidget.
+ */
+
+void SQ_HelpWidget::init()
+{
+ setPalette(TQToolTip::palette());
+ SQ_Config::instance()->setGroup("GL view");
+
+ int pg = SQ_Config::instance()->readNumEntry("help_id", 0);
+
+ buttonGroup->setButton(pg);
+ widgetStack1->raiseWidget(pg);
+}
+
+void SQ_HelpWidget::destroy()
+{
+ SQ_Config::instance()->setGroup("GL view");
+ SQ_Config::instance()->writeEntry("help_id", buttonGroup->selectedId());
+}
+
+bool SQ_HelpWidget::event(TQEvent *e)
+{
+ if(e->type() == TQEvent::WindowDeactivate
+ || e->type() == TQEvent::MouseButtonPress
+ || e->type() == TQEvent::KeyPress)
+ {
+ reject();
+ }
+
+ return TQDialog::event(e);
+}
diff --git a/src/sq_hloptions.cpp b/src/sq_hloptions.cpp
new file mode 100644
index 0000000..d7d8fe2
--- /dev/null
+++ b/src/sq_hloptions.cpp
@@ -0,0 +1,37 @@
+/***************************************************************************
+ sq_hloptions.cpp - description
+ -------------------
+ begin : ??? ??? 30 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_hloptions.h"
+
+SQ_HLOptions * SQ_HLOptions::m_instance = 0;
+
+SQ_HLOptions::SQ_HLOptions()
+ : showLibsAndExit(false),
+ have_directorybasket(true),
+ have_categories(true),
+ have_imagebasket(true),
+ have_mountview(true)
+{
+ m_instance = this;
+}
+
+SQ_HLOptions::~SQ_HLOptions()
+{}
diff --git a/src/sq_hloptions.h b/src/sq_hloptions.h
new file mode 100644
index 0000000..4b13134
--- /dev/null
+++ b/src/sq_hloptions.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+ sq_hloptions.h - description
+ -------------------
+ begin : ??? ??? 30 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_HLOPTIONS_H
+#define SQ_HLOPTIONS_H
+
+#include <kurl.h>
+
+/*
+ * SQ_HLOptions stores command line options.
+ */
+
+struct SQ_HLOptions
+{
+ SQ_HLOptions();
+ ~SQ_HLOptions();
+
+ static SQ_HLOptions* instance() { return m_instance; }
+
+ TQString param;
+ KURL file, dir;
+
+ /*
+ * Just show found libraries and exit ?
+ */
+ bool showLibsAndExit;
+
+ bool have_directorybasket, have_categories, have_imagebasket, have_mountview;
+
+ static SQ_HLOptions *m_instance;
+};
+
+#endif
diff --git a/src/sq_iconlistbox.cpp b/src/sq_iconlistbox.cpp
new file mode 100644
index 0000000..dd6cc35
--- /dev/null
+++ b/src/sq_iconlistbox.cpp
@@ -0,0 +1,77 @@
+/***************************************************************************
+ sq_iconlistbox.cpp - description
+ -------------------
+ begin : ??? ??? 19 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_iconlistbox.h"
+#include "sq_iconlistitem.h"
+
+SQ_IconListBox::SQ_IconListBox(TQWidget *parent, const char *name, WFlags f) : TDEListBox(parent, name, f),
+ mHeightValid(false), mWidthValid(false)
+{
+ setHScrollBarMode(TQScrollView::AlwaysOff);
+}
+
+void SQ_IconListBox::updateWidth()
+{
+ if(!mWidthValid)
+ {
+ int maxWidth = 10, w;
+
+ for(TQListBoxItem *i = item(0); i != 0; i = i->next())
+ {
+ w = ((SQ_IconListItem *)i)->width(this);
+ maxWidth = TQMAX(w, maxWidth);
+ }
+
+ for(TQListBoxItem *i = item(0); i != 0; i = i->next())
+ ((SQ_IconListItem *)i)->expandMinimumWidth(maxWidth + 30);
+
+ if(verticalScrollBar()->isVisible())
+ maxWidth += verticalScrollBar()->sizeHint().width();
+
+ setFixedWidth(maxWidth + frameWidth()*2 + 30);
+ mWidthValid = true;
+ }
+}
+
+void SQ_IconListBox::invalidateHeight()
+{
+ mHeightValid = false;
+}
+
+void SQ_IconListBox::invalidateWidth()
+{
+ mWidthValid = false;
+}
+
+void SQ_IconListBox::updateAndInstall(TQObject *o)
+{
+ invalidateHeight();
+ invalidateWidth();
+ updateWidth();
+
+ TQFont listFont(font());
+
+ listFont.setBold(true);
+ setFont(listFont);
+ verticalScrollBar()->installEventFilter(o);
+ setCurrentItem(0);
+ setSelected(0, true);
+}
diff --git a/src/sq_iconlistbox.h b/src/sq_iconlistbox.h
new file mode 100644
index 0000000..3fc7b68
--- /dev/null
+++ b/src/sq_iconlistbox.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ sq_iconlistbox.h - description
+ -------------------
+ begin : ??? ??? 19 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_ICONLISTBOX_H
+#define SQ_ICONLISTBOX_H
+
+#include <tdelistbox.h>
+
+/*
+ * SQ_IconListBox represents a listbox with fixed width.
+ *
+ * SQ_IconListBox and SQ_IconListItem are used in SQ_Options.
+ */
+
+class SQ_IconListBox : public TDEListBox
+{
+ public:
+ SQ_IconListBox(TQWidget * = 0, const char * = 0, WFlags = 0);
+
+ void updateAndInstall(TQObject *);
+
+ private:
+ void updateWidth();
+ void invalidateHeight();
+ void invalidateWidth();
+
+ private:
+ bool mHeightValid;
+ bool mWidthValid;
+};
+
+#endif
diff --git a/src/sq_iconlistitem.cpp b/src/sq_iconlistitem.cpp
new file mode 100644
index 0000000..7bf06b3
--- /dev/null
+++ b/src/sq_iconlistitem.cpp
@@ -0,0 +1,105 @@
+/***************************************************************************
+ sq_iconlistitem.cpp - description
+ -------------------
+ begin : ??? ??? 19 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqlistbox.h>
+#include <tqpainter.h>
+#include <tqbitmap.h>
+#include <tqpixmap.h>
+
+#include "sq_iconlistitem.h"
+
+SQ_IconListItem::SQ_IconListItem(TQListBox *listbox, const TQPixmap &pixmap, const TQString &text)
+ : TQListBoxItem(listbox)
+{
+ mPixmap = pixmap;
+
+ if(mPixmap.isNull())
+ mPixmap = defaultPixmap();
+
+ setText(text);
+ mMinimumWidth = 0;
+}
+
+int SQ_IconListItem::expandMinimumWidth( int width )
+{
+ mMinimumWidth = TQMAX(mMinimumWidth, width);
+
+ return mMinimumWidth;
+}
+
+const TQPixmap& SQ_IconListItem::defaultPixmap()
+{
+ static TQPixmap *pix=0;
+
+ if(pix == 0)
+ {
+ pix = new TQPixmap( 32, 32 );
+ TQPainter p(pix);
+ p.eraseRect(0, 0, pix->width(), pix->height());
+ p.setPen(TQt::red);
+ p.drawRect(0, 0, pix->width(), pix->height());
+ p.end();
+
+ TQBitmap mask(pix->width(), pix->height(), true);
+ mask.fill(TQt::black);
+ p.begin(&mask);
+ p.setPen(TQt::white);
+ p.drawRect(0, 0, pix->width(), pix->height());
+ p.end();
+
+ pix->setMask(mask);
+ }
+
+ return *pix;
+}
+
+void SQ_IconListItem::paint(TQPainter *painter)
+{
+ TQFontMetrics fm = painter->fontMetrics();
+ int ht = fm.boundingRect(0, 0, 0, 0, TQt::AlignCenter, text()).height();
+ int wp = mPixmap.width();
+ int hp = mPixmap.height();
+
+ painter->drawPixmap((mMinimumWidth-wp)/2, 5, mPixmap);
+
+ if(text().isEmpty() == false)
+ painter->drawText(0, hp+7, mMinimumWidth, ht, TQt::AlignCenter, text());
+}
+
+int SQ_IconListItem::height( const TQListBox *lb ) const
+{
+ if(text().isEmpty() == true)
+ return mPixmap.height();
+ else
+ {
+ int ht = lb->fontMetrics().boundingRect(0, 0, 0, 0, TQt::AlignCenter, text()).height();
+ return (mPixmap.height() + ht + 10);
+ }
+}
+
+int SQ_IconListItem::width( const TQListBox *lb ) const
+{
+ int wt = lb->fontMetrics().boundingRect(0, 0, 0, 0, TQt::AlignCenter, text()).width() + 10;
+ int wp = mPixmap.width() + 10;
+ int w = TQMAX(wt, wp);
+
+ return TQMAX(w, mMinimumWidth);
+}
diff --git a/src/sq_iconlistitem.h b/src/sq_iconlistitem.h
new file mode 100644
index 0000000..6e7597d
--- /dev/null
+++ b/src/sq_iconlistitem.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ sq_iconlistitem.h - description
+ -------------------
+ begin : ??? ??? 19 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_ICONLISTITEM_H
+#define SQ_ICONLISTITEM_H
+
+#include <tqlistbox.h>
+
+class TQListBox;
+class TQPainter;
+class TQPixmap;
+
+/*
+ * SQ_IconListItem represents a listbox item.
+ *
+ * With SQ_IconListBox it is used in SQ_Options.
+ *
+ * Taken from tdelibs.
+ */
+
+class SQ_IconListItem : public TQListBoxItem
+{
+ public:
+ SQ_IconListItem(TQListBox *listbox, const TQPixmap &pixmap, const TQString &text);
+
+ virtual int height(const TQListBox *lb) const;
+ virtual int width(const TQListBox *lb) const;
+ int expandMinimumWidth(int width);
+
+ protected:
+ const TQPixmap& defaultPixmap();
+ void paint(TQPainter *painter);
+
+ private:
+ TQPixmap mPixmap;
+ int mMinimumWidth;
+};
+
+#endif
diff --git a/src/sq_iconloader.cpp b/src/sq_iconloader.cpp
new file mode 100644
index 0000000..c8c9ec8
--- /dev/null
+++ b/src/sq_iconloader.cpp
@@ -0,0 +1,82 @@
+/***************************************************************************
+ sq_iconloader.cpp - description
+ -------------------
+ begin : ??? Aug 20 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tdeglobal.h>
+#include <kiconloader.h>
+
+#include "sq_iconloader.h"
+#include "sq_iconloader_pixmaps.h"
+
+SQ_IconLoader * SQ_IconLoader::m_instance = 0;
+
+SQ_IconLoader::SQ_IconLoader(TQObject *parent) : TQObject(parent)
+{
+ m_instance = this;
+
+ fillPixmaps();
+}
+
+SQ_IconLoader::~SQ_IconLoader()
+{}
+
+TQPixmap SQ_IconLoader::loadIcon(const TQString& name, TDEIcon::Group group, int size) const
+{
+ // try to load from installed icon theme
+ TQPixmap p = TDEGlobal::iconLoader()->loadIcon(name, group, size, TDEIcon::DefaultState, 0, true);
+
+ // requested pixmap not found, let's
+ // try to find it in our pixmaps
+ if(p.isNull())
+ {
+ if(name == "move_task_up")
+ p = pixmap_up;
+ else if(name == "move_task_down")
+ p = pixmap_down;
+ else if(name == "display" && size == 32)
+ p = pixmap_display;
+ else if(name == "folder" && size == 32)
+ p = pixmap_folder;
+ else if(name == "images" && size == 32)
+ p = pixmap_images;
+ else if(name == "binary" && size == 32)
+ p = pixmap_binary;
+ else if(name == "edit" && size == 32)
+ p = pixmap_edit;
+ else
+ p = TDEGlobal::iconLoader()->loadIcon("unknown", group, size);
+ }
+
+ return p;
+}
+
+/*
+ * Internal. Load all pixmaps.
+ */
+void SQ_IconLoader::fillPixmaps()
+{
+ pixmap_up = TQPixmap(xpm_up);
+ pixmap_down = TQPixmap(xpm_down);
+ pixmap_display = TQPixmap(xpm_display);
+ pixmap_folder = TQPixmap(xpm_folder);
+ pixmap_images = TQPixmap(xpm_images);
+ pixmap_binary = TQPixmap(xpm_binary);
+ pixmap_edit = TQPixmap(xpm_edit);
+}
diff --git a/src/sq_iconloader.h b/src/sq_iconloader.h
new file mode 100644
index 0000000..dec6a6e
--- /dev/null
+++ b/src/sq_iconloader.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ sq_iconloader.h - description
+ -------------------
+ begin : ??? Aug 20 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_ICONLOADER_H
+#define SQ_ICONLOADER_H
+
+#include <tqobject.h>
+#include <tqpixmap.h>
+
+#include <kicontheme.h>
+
+/*
+ * SQ_IconLoader represents an icon loader. It tries to load pixmap from
+ * installed icon theme. If icon was not found, it uses internal pixmaps
+ * instead.
+ */
+
+class SQ_IconLoader : public TQObject
+{
+ public:
+ SQ_IconLoader(TQObject *parent = 0);
+ ~SQ_IconLoader();
+
+ TQPixmap loadIcon(const TQString &name, TDEIcon::Group group = TDEIcon::Desktop, int size = 16) const;
+
+ private:
+ static SQ_IconLoader *m_instance;
+
+ /*
+ * Internal. Load all pixmaps.
+ */
+ void fillPixmaps();
+
+ public:
+ static SQ_IconLoader* instance() { return m_instance; }
+
+ private:
+ TQPixmap pixmap_up, pixmap_down,
+ pixmap_display, pixmap_folder,
+ pixmap_images, pixmap_binary,
+ pixmap_edit;
+};
+
+#endif
diff --git a/src/sq_iconloader_pixmaps.h b/src/sq_iconloader_pixmaps.h
new file mode 100644
index 0000000..0bc6183
--- /dev/null
+++ b/src/sq_iconloader_pixmaps.h
@@ -0,0 +1,2557 @@
+/***************************************************************************
+ sq_iconloader_pixmaps.h - description
+ -------------------
+ begin : ��� ��� 3 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_ICONLOADER_PIXMAPS
+#define SQ_ICONLOADER_PIXMAPS
+
+static const char * xpm_up[] = {
+"22 22 139 2",
+" c None",
+". c #AE5300",
+"+ c #AD5204",
+"@ c #B35E10",
+"# c #EBD4BF",
+"$ c #C78851",
+"% c #AD5203",
+"& c #F0DDBF",
+"* c #FFED80",
+"= c #FAEDBF",
+"- c #BD7331",
+"; c #FFE330",
+"> c #FFD900",
+", c #FFD710",
+"' c #FAECBF",
+") c #F0D99F",
+"! c #FFE420",
+"~ c #FFDC00",
+"{ c #FFD700",
+"] c #FFD300",
+"^ c #FFD210",
+"/ c #FAEBBF",
+"( c #BD7330",
+"_ c #F0DA9F",
+": c #FFE410",
+"< c #FFDE00",
+"[ c #FFDA00",
+"} c #FFD600",
+"| c #FFD100",
+"1 c #FFCD00",
+"2 c #FFCC10",
+"3 c #FAE9BF",
+"4 c #BD7332",
+"5 c #FAF0BF",
+"6 c #FFE710",
+"7 c #FFE100",
+"8 c #FFDD00",
+"9 c #FFD800",
+"0 c #FFD400",
+"a c #FFD000",
+"b c #FFCB00",
+"c c #FFC700",
+"d c #FFC710",
+"e c #FAE8BF",
+"f c #B25D12",
+"g c #AE5302",
+"h c #FFE910",
+"i c #FFE400",
+"j c #FFDF00",
+"k c #FFDB00",
+"l c #FFD200",
+"m c #FFCE00",
+"n c #FFCA00",
+"o c #FFC500",
+"p c #FFC100",
+"q c #FFC110",
+"r c #F0D29F",
+"s c #AD5202",
+"t c #FAEE8F",
+"u c #FFEC10",
+"v c #FFE600",
+"w c #FFE200",
+"x c #FFD500",
+"y c #FFCC00",
+"z c #FFC800",
+"A c #FFC400",
+"B c #FFBF00",
+"C c #FFBB00",
+"D c #FFBB10",
+"E c #F0D19F",
+"F c #FAEF8F",
+"G c #FFED00",
+"H c #FFE900",
+"I c #FFE500",
+"J c #FFE000",
+"K c #FFCF00",
+"L c #FFC600",
+"M c #FFC200",
+"N c #FFBE00",
+"O c #FFB900",
+"P c #FFB500",
+"Q c #FFB610",
+"R c #F0CF9F",
+"S c #B25C15",
+"T c #F5E78E",
+"U c #FBE802",
+"V c #FBE402",
+"W c #FBDF02",
+"X c #FBDB02",
+"Y c #FDDB01",
+"Z c #FFC900",
+"` c #FFC000",
+" . c #F6B104",
+".. c #F6AD04",
+"+. c #F6A904",
+"@. c #F6A504",
+"#. c #F5A514",
+"$. c #D9A36E",
+"%. c #B46107",
+"&. c #BC7008",
+"*. c #BC6F08",
+"=. c #BC6E08",
+"-. c #DEA404",
+";. c #FFC300",
+">. c #D58508",
+",. c #BD6506",
+"'. c #BD6406",
+"). c #BD6306",
+"!. c #B95E06",
+"~. c #AE5301",
+"{. c #D79700",
+"]. c #FFBD00",
+"^. c #CD7A08",
+"/. c #D79600",
+"(. c #FFBC00",
+"_. c #D79500",
+":. c #FFBA00",
+"<. c #CD7908",
+"[. c #D79400",
+"}. c #FFB800",
+"|. c #CD7808",
+"1. c #D79300",
+"2. c #FFB700",
+"3. c #CD7708",
+"4. c #D79200",
+"5. c #FFB300",
+"6. c #CD7608",
+"7. c #D79100",
+"8. c #FFB600",
+"9. c #F9AB03",
+"0. c #C07008",
+"a. c #EDB008",
+"b. c #EDAD08",
+"c. c #EDA908",
+"d. c #EDA608",
+"e. c #EDA208",
+"f. c #ED9F08",
+"g. c #ED9B08",
+"h. c #C16807",
+" . . + ",
+" . @ # $ % ",
+" . @ & * = - % ",
+" . @ & ; > , ' - % ",
+" . @ ) ! ~ { ] ^ / - % ",
+" . ( _ : < [ } | 1 2 3 4 + ",
+" . ( 5 6 7 8 9 0 a b c d e f g ",
+" . ( 5 h i j k { l m n o p q r f s ",
+" . ( t u v w < > x | y z A B C D E f s ",
+". ( F G H I J ~ 9 ] K b L M N O P Q R S g ",
+"g T U V W X Y [ } l 1 Z o ` ...+.@.#.$.+ ",
+"% %.&.*.*.=.-.> 0 a y c ;.B >.,.,.'.).!.~. ",
+" . . . . . {.{ ] m n L p ].^.. . . . . ",
+" . /.x | 1 z A ` (.^.. ",
+" . _.0 K b c ;.N :.<.. ",
+" . [.l m Z o p ].}.|.. ",
+" . 1.a y z A B C 2.|.. ",
+" . 1.K n L M N O P 3.. ",
+" . 4.1 Z o ` (.}.5.6.. ",
+" . 7.y c ;.B :.8.9.6.. ",
+" ~.0.a.b.c.d.e.f.g.h.. ",
+" ~.g g g g g g g ~. "};
+
+static const char * xpm_down[] = {
+"22 22 138 2",
+" c None",
+". c #AE5300",
+"+ c #C78950",
+"@ c #FFFABF",
+"# c #FFF9BF",
+"$ c #FFF8BF",
+"% c #FFF7BF",
+"& c #FFF6BF",
+"* c #FFF4BF",
+"= c #FFF3BF",
+"- c #D7A000",
+"; c #FFEA00",
+"> c #FFE600",
+", c #FFE100",
+"' c #FFDD00",
+") c #FFD800",
+"! c #FFD400",
+"~ c #FFCF00",
+"{ c #D79000",
+"] c #D79F00",
+"^ c #FFE800",
+"/ c #FFE400",
+"( c #FFDF00",
+"_ c #FFDB00",
+": c #FFD700",
+"< c #FFD200",
+"[ c #FFCE00",
+"} c #D78F00",
+"| c #FFE700",
+"1 c #FFE200",
+"2 c #FFDE00",
+"3 c #FFD900",
+"4 c #FFD500",
+"5 c #FFD000",
+"6 c #FFCC00",
+"7 c #D78E00",
+"8 c #D79E00",
+"9 c #FFE500",
+"0 c #FFDC00",
+"a c #FFD300",
+"b c #FFCA00",
+"c c #D78D00",
+"d c #D79D00",
+"e c #FFE300",
+"f c #FFDA00",
+"g c #FFD600",
+"h c #FFCD00",
+"i c #FFC900",
+"j c #D78C00",
+"k c #D79C00",
+"l c #FFCB00",
+"m c #FFC700",
+"n c #D78B00",
+"o c #D79B00",
+"p c #FFE000",
+"q c #FFC500",
+"r c #D78A00",
+"s c #D79A00",
+"t c #FFD100",
+"u c #FFC800",
+"v c #FFC300",
+"w c #BB6F2A",
+"x c #C27E40",
+"y c #E1AD10",
+"z c #FFC600",
+"A c #FFC200",
+"B c #E19A10",
+"C c #B86920",
+"D c #D9AF6C",
+"E c #F8E843",
+"F c #FFF140",
+"G c #FFEE40",
+"H c #FFEA40",
+"I c #FFE110",
+"J c #FFC000",
+"K c #FFC010",
+"L c #FFC940",
+"M c #FFC640",
+"N c #FFC240",
+"O c #FCBB41",
+"P c #EAC7A3",
+"Q c #B25B01",
+"R c #E1B707",
+"S c #FBE302",
+"T c #FFBE00",
+"U c #FFBA00",
+"V c #FFB500",
+"W c #FFB100",
+"X c #FCA902",
+"Y c #EA9207",
+"Z c #BA5F02",
+"` c #E2B506",
+" . c #FCDF02",
+".. c #FFC100",
+"+. c #FFBD00",
+"@. c #FFB800",
+"#. c #FFB400",
+"$. c #FCAC02",
+"%. c #EA9407",
+"&. c #B25A01",
+"*. c #E2B106",
+"=. c #FCD902",
+"-. c #FFC400",
+";. c #FFBF00",
+">. c #FFBB00",
+",. c #FFB700",
+"'. c #FCAE02",
+"). c #EA9707",
+"!. c #BA6002",
+"~. c #EABA07",
+"{. c #FCD302",
+"]. c #FFB900",
+"^. c #FCB102",
+"/. c #EA9907",
+"(. c #BA6702",
+"_. c #EAB607",
+":. c #FCCD02",
+"<. c #FFBC00",
+"[. c #FCB302",
+"}. c #E29206",
+"|. c #BA6102",
+"1. c #BA6602",
+"2. c #EAB107",
+"3. c #FECA01",
+"4. c #FBB502",
+"5. c #E29306",
+"6. c #B25801",
+"7. c #BA6502",
+"8. c #ECB006",
+"9. c #FEC401",
+"0. c #F8B403",
+"a. c #E19407",
+"b. c #BA6402",
+"c. c #ECAB06",
+"d. c #F5B305",
+"e. c #E19507",
+"f. c #C26E03",
+"g. c #DD9206",
+" . . . . . . . . . ",
+" . + @ # $ % & * = + . ",
+" . - ; > , ' ) ! ~ { . ",
+" . ] ^ / ( _ : < [ } . ",
+" . ] | 1 2 3 4 5 6 7 . ",
+" . 8 9 , 0 ) a ~ b c . ",
+" . d e ( f g < h i j . ",
+" . k 1 ' 3 ! 5 l m n . ",
+" . o p _ : a [ b q r . ",
+" . . . . . s 2 f 4 t 6 u v r . . . . . ",
+". w x x x x y ' ) ! ~ l z A B x x x x C . ",
+". D E F G H I _ g < h i q J K L M N O P . ",
+". Q R S > 1 2 3 4 5 6 m v T U V W X Y Z . ",
+" . Q ` .p 0 : a [ b z ..+.@.#.$.%.Z . ",
+" . &.*.=.f g t h u -.;.>.,.'.).!.. ",
+" . &.~.{.! 5 l m A T ].^./.!.. ",
+" . (._.:.[ i q ..<.[.}.|.. ",
+" . 1.2.3.u v ;.4.5.6.. ",
+" . 7.8.9.A 0.a.6.. ",
+" . b.c.d.e.6.. ",
+" . f.g.6.. ",
+" . . . "};
+
+static const char * xpm_binary[] = {
+"32 32 246 2",
+" c None",
+". c #6E6E6E",
+"+ c #8E8F8F",
+"@ c #898A8B",
+"# c #88898B",
+"$ c #88898A",
+"% c #87888A",
+"& c #86878A",
+"* c #868789",
+"= c #878889",
+"- c #878789",
+"; c #868788",
+"> c #858688",
+", c #858687",
+"' c #848687",
+") c #848587",
+"! c #858586",
+"~ c #6A6A6A",
+"{ c #706F6F",
+"] c #F6FAFF",
+"^ c #E7EFFF",
+"/ c #F0F5FF",
+"( c #E9F0FE",
+"_ c #E8F0FE",
+": c #E3ECFD",
+"< c #E4EDFD",
+"[ c #DFEAFB",
+"} c #E8F0FD",
+"| c #E6EFFC",
+"1 c #E2ECFB",
+"2 c #E1EBFB",
+"3 c #D5E3F8",
+"4 c #D3E1F8",
+"5 c #D1E1F7",
+"6 c #D0DFF6",
+"7 c #CEDFF6",
+"8 c #CDDEF5",
+"9 c #CBDDF5",
+"0 c #CADCF5",
+"a c #C9DBF4",
+"b c #C7DAF3",
+"c c #C6D9F3",
+"d c #C4D8F2",
+"e c #C2D7F2",
+"f c #C1D6F2",
+"g c #E7EEF6",
+"h c #696968",
+"i c #6F6F6F",
+"j c #F3F7FF",
+"k c #A0BDF9",
+"l c #E1EAFC",
+"m c #C8D9F9",
+"n c #BBD1F6",
+"o c #D7E4FA",
+"p c #B6CDF4",
+"q c #D0DFF8",
+"r c #AEC7F1",
+"s c #CBDBF6",
+"t c #BAD0F3",
+"u c #A7C3EF",
+"v c #9ABBEC",
+"w c #4E87DC",
+"x c #4F86DC",
+"y c #4983D9",
+"z c #437FD6",
+"A c #3D7CD5",
+"B c #3878D2",
+"C c #3374D1",
+"D c #2E72D0",
+"E c #296ECE",
+"F c #236ACC",
+"G c #1C67C9",
+"H c #1762C6",
+"I c #105EC4",
+"J c #0A5AC5",
+"K c #E3EAF4",
+"L c #F4F8FF",
+"M c #9DBCF8",
+"N c #C2D4F9",
+"O c #ACC6F5",
+"P c #A3C0F3",
+"Q c #A4C0F1",
+"R c #9FBDF0",
+"S c #97B9EE",
+"T c #99B9ED",
+"U c #8FB3EB",
+"V c #7EA7E7",
+"W c #709EE3",
+"X c #578DDE",
+"Y c #548BDD",
+"Z c #4E87DA",
+"` c #4983D7",
+" . c #4380D6",
+".. c #3E7CD3",
+"+. c #3978D2",
+"@. c #3476D1",
+"#. c #2D72CF",
+"$. c #296ECD",
+"%. c #236BCB",
+"&. c #1E67C9",
+"*. c #1763C6",
+"=. c #1160C7",
+"-. c #E4EBF5",
+";. c #6F6F6E",
+">. c #FEFFFF",
+",. c #E7EFFE",
+"'. c #E2EAFC",
+"). c #E1EBFC",
+"!. c #DEE9FA",
+"~. c #DDE8FA",
+"{. c #DBE6F9",
+"]. c #DEE9FC",
+"^. c #DAE6FA",
+"/. c #D8E4F8",
+"(. c #D8E5F7",
+"_. c #D6E3F7",
+":. c #D6E2F5",
+"<. c #D3E0F3",
+"[. c #D1DFF2",
+"}. c #D0DEF1",
+"|. c #CDDBF0",
+"1. c #CCDBEF",
+"2. c #CBDAEE",
+"3. c #C8D8ED",
+"4. c #C7D7ED",
+"5. c #C7D8ED",
+"6. c #C4D4EB",
+"7. c #C0D1E9",
+"8. c #C1D3EC",
+"9. c #F4F6F8",
+"0. c #686868",
+"a. c #FFFFFF",
+"b. c #FEFEFE",
+"c. c #EDECE9",
+"d. c #F5F5F3",
+"e. c #FEFDFB",
+"f. c #FFFEFC",
+"g. c #FFFFFC",
+"h. c #FFFFFB",
+"i. c #FFFEFB",
+"j. c #FFFDFA",
+"k. c #FFFDF9",
+"l. c #FEFCF8",
+"m. c #FFFCF8",
+"n. c #FCFAF6",
+"o. c #EBE8E5",
+"p. c #FBF8F4",
+"q. c #FCF9F5",
+"r. c #FEFAF6",
+"s. c #F9F9F8",
+"t. c #E1E1E1",
+"u. c #BDBDBD",
+"v. c #C1C1C1",
+"w. c #FAFAFA",
+"x. c #F6F6F6",
+"y. c #B4B4B4",
+"z. c #F2F2F2",
+"A. c #FCFCFC",
+"B. c #F9F9F9",
+"C. c #F7F7F7",
+"D. c #F8F8F8",
+"E. c #CFCFCF",
+"F. c #B6B6B6",
+"G. c #D2D2D2",
+"H. c #F5F5F5",
+"I. c #CACACA",
+"J. c #E2E2E2",
+"K. c #BEBEBE",
+"L. c #EFEFEF",
+"M. c #FBFBFB",
+"N. c #ECECEC",
+"O. c #BCBCBC",
+"P. c #D3D3D3",
+"Q. c #C2C2C2",
+"R. c #F4F4F4",
+"S. c #B1B1B1",
+"T. c #DEDEDE",
+"U. c #BABABA",
+"V. c #E3E3E3",
+"W. c #F1F1F1",
+"X. c #EEEEEE",
+"Y. c #FDFDFD",
+"Z. c #F0F0F0",
+"`. c #F3F3F3",
+" + c #EDEDED",
+".+ c #E7E7E7",
+"++ c #E6E6E6",
+"@+ c #C0C0C0",
+"#+ c #D8D8D8",
+"$+ c #DADADA",
+"%+ c #D1D1D1",
+"&+ c #E0E0E0",
+"*+ c #DFDFDF",
+"=+ c #C6C6C6",
+"-+ c #A6A6A6",
+";+ c #E8E8E8",
+">+ c #B5B5B5",
+",+ c #EAEAEA",
+"'+ c #D4D4D4",
+")+ c #DCDCDC",
+"!+ c #D5D5D5",
+"~+ c #B2B2B2",
+"{+ c #CDCDCD",
+"]+ c #C3C3C3",
+"^+ c #DDDDDD",
+"/+ c #D0D0D0",
+"(+ c #EBEBEB",
+"_+ c #B3B3B3",
+":+ c #A7A7A7",
+"<+ c #A4A4A4",
+"[+ c #D9D9D9",
+"}+ c #C7C7C7",
+"|+ c #BFBFBF",
+"1+ c #DBDBDB",
+"2+ c #979797",
+"3+ c #909090",
+"4+ c #6D6D6D",
+"5+ c #ACACAC",
+"6+ c #939393",
+"7+ c #A9A9A9",
+"8+ c #949494",
+"9+ c #E4E4E4",
+"0+ c #929292",
+"a+ c #8E8E8E",
+"b+ c #8D8D8D",
+"c+ c #8F8F8F",
+"d+ c #8C8C8C",
+"e+ c #676767",
+"f+ c #A2A2A2",
+"g+ c #D6D6D6",
+"h+ c #9C9C9C",
+"i+ c #BBBBBB",
+"j+ c #C5C5C5",
+"k+ c #717171",
+"l+ c #E9E9E9",
+"m+ c #CBCBCB",
+"n+ c #AFAFAF",
+"o+ c #ABABAB",
+"p+ c #CECECE",
+"q+ c #707070",
+"r+ c #B9B9B9",
+"s+ c #B0B0B0",
+"t+ c #E5E5E5",
+"u+ c #6C6C6C",
+"v+ c #959595",
+"w+ c #8A8A8A",
+" . + @ # # # $ $ % % & * * * = - * * ; ; ; > > , , ' ) > ! ~ ",
+" { ] ^ / ( _ _ : < [ } | 1 2 3 4 5 6 7 8 9 0 a b c d e f g h ",
+" i j k l m n o p q r s t u v w x y z A B C D E F G H I J K h ",
+" i L M N O P P Q R S T U V W X Y Z ` ...+.@.#.$.%.&.*.=.-.h ",
+" ;.>.,.'.).2 !.~.{.].^./.(._.(.:.<.[.}.|.1.2.3.4.5.6.7.8.9.0. ",
+" . a.a.a.a.a.a.a.b.c.d.a.a.a.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.0. ",
+" . a.a.a.a.a.a.a.t.u.v.w.a.x.y.z.A.B.B.C.C.x.D.E.F.G.H.z.D.0. ",
+" . a.a.a.a.a.a.a.I.J.K.L.a.M.y.N.A.B.D.C.C.x.D.O.P.Q.R.L.D.0. ",
+" . a.a.a.a.a.a.a.R.u.G.a.b.H.S.T.b.D.D.D.x.x.C.J.U.V.W.X.D.0. ",
+" . a.a.a.Y.b.a.a.a.a.a.Y.A.A.R.B.w.D.B.Z.B.x.R.x.`.`. +Z.B.0. ",
+" . a.a.a.U..+a.a.a.b.b.Y.b.++@+#+w.w.$+u.%+R.C.&+U.Z. +W.B.0. ",
+" . a.a.a.O.*+a.a.b.Y.Y.A.a.=+P.@+H.w.v.#+-+Z.C.;+>+,+X.W.B.0. ",
+" . a.a.a.Q.'+a.b.b.Y.A.A.b.V.O.P.B.B.)+O.!+R.x.V.~+J.Z.z.B.0. ",
+" . a.a.a.B.M.a.b.Y.Y.A.M.w.Y.C.B.D.x.B.`.C.R.z.L.L.L.L.`.B.0. ",
+" . a.a.H.Q.{+A.b.Y.A.M.M.M.R.]+W.D.D.++Q.`.`.Z.Z.W.W.Z.R.B.0. ",
+" . a.a.^+/+v.(+a.Y.M.M.M.w.C.~+N.D.D.;+_+z.z.W.W.W.W.W.H.B.0. ",
+" . a.a.`.Q.I.w.Y.A.A.M.B.w.`.:+$+w.D.V.<+[+x.z.z.`.z.z.x.B.0. ",
+" . a.B.Y.C.w.b.Y.Y.b.w.B.B.x.X.Z.H.`.z.,+Z.`.z.R.x.z.z.x.B.0. ",
+" . a.R.`.x.D.D.w.z.}+`.D.D.L.|+X.R.H.^+_+1+H.C.&+U.R.H.D.B.0. ",
+" . a.x.H.R.R.R.H.Z.>+ +x.x.L.2+;+D.C.~+{+3+Z.w.t.<+H.x.B.B.0. ",
+" 4+a.x.H.H.H.H.x.Z.5+/+D.C.W.6+'+M.D.=+7+F.`.B.&+8+9+D.B.B.0. ",
+" 4+a.C.x.M.D.x.x.H.z.L.x.C.z.)+(+D.C.R.$+C.D.C.`.N.R.B.A.w.0. ",
+" 4+a.C.D.@+9+B.C.Z.Q.W.C.x.C.M.D.x.x.D.M.0+a+a+a+b+b+b+c+d+e+ ",
+" 4+a.w.A.f+g+Y.w.z.f+X.w.D.D.D.D.D.D.D.B.c+(+D.x.H.H.M.H.i ",
+" 4+a.w.M.h+i+Y.w.Z.0+j+A.D.D.D.D.D.D.D.B.c+L.A.A.b.a.M.k+ ",
+" 4+a.w.B.++l+w.w.x.J.l+w.B.w.b.M.B.B.B.w.c+,+H.H.M.B.k+ ",
+" 4+a.A.D.m+[+A.A.R.K.g+Y.M.B.g+L.A.w.w.M.c+++L.R.`.k+ ",
+" 4+a.a.!+i+n+.+a.|+{+o+(+a.p+7+i+w.M.w.M.a+V.L. +q+ ",
+" 4+a.a.*+~+n+X.a.I.r+o+W.a.r+@+s+C.A.M.A.a+9+.+q+ ",
+" 4+a.a.a.)+.+a.a.Y.E.t+a.a.x.@+t+a.a.a.a.3+&+i ",
+" u+v+6+0+8+6+0+0+6+8+8+0+0+6+v+6+0+0+0+6+w+. ",
+" "};
+static const char * xpm_display[] = {
+"32 32 488 2",
+" c None",
+". c #868686",
+"+ c #9E9E9E",
+"@ c #9D9D9D",
+"# c #9C9C9C",
+"$ c #9B9B9B",
+"% c #9A9A9A",
+"& c #666666",
+"* c #949494",
+"= c #FDFDFD",
+"- c #FFFFFF",
+"; c #F1F1F1",
+"> c #717171",
+", c #EAEAEA",
+"' c #FFFFFD",
+") c #FFFFFC",
+"! c #FFFFFA",
+"~ c #FFFEFA",
+"{ c #FFFEF9",
+"] c #FFFDF9",
+"^ c #FFFCF9",
+"/ c #FFFCF8",
+"( c #FEFEFE",
+"_ c #C8C8C8",
+": c #F5F5F5",
+"< c #D7D8DB",
+"[ c #7087AE",
+"} c #7D98BE",
+"| c #8AA7CA",
+"1 c #8CA9CB",
+"2 c #8FACCD",
+"3 c #92B0D0",
+"4 c #95B3D2",
+"5 c #98B6D4",
+"6 c #9BB9D6",
+"7 c #9EBCD7",
+"8 c #A0BED8",
+"9 c #A0BFD8",
+"0 c #9BB9D4",
+"a c #98B6D3",
+"b c #95B3D1",
+"c c #92AFCF",
+"d c #8EACCD",
+"e c #8BA8CA",
+"f c #87A5C9",
+"g c #85A2C7",
+"h c #758FB7",
+"i c #899CC0",
+"j c #F8F9FA",
+"k c #D3D3D3",
+"l c #F4F4F4",
+"m c #C6C9D0",
+"n c #083FA5",
+"o c #2A6ECA",
+"p c #3B80D5",
+"q c #4287D9",
+"r c #488EDD",
+"s c #4F95E2",
+"t c #579DE6",
+"u c #5EA4EB",
+"v c #64ABEF",
+"w c #6AB1F3",
+"x c #6EB5F5",
+"y c #6EB6F6",
+"z c #6DB4F5",
+"A c #69B1F2",
+"B c #63AAEF",
+"C c #5DA3EA",
+"D c #559CE6",
+"E c #4F94E1",
+"F c #478DDC",
+"G c #4084D7",
+"H c #397ED3",
+"I c #3478D0",
+"J c #1A5DBF",
+"K c #2C5CB7",
+"L c #F3F5F8",
+"M c #D2D2D2",
+"N c #F6F6F6",
+"O c #C8CCD3",
+"P c #225DB7",
+"Q c #397BD1",
+"R c #4081D3",
+"S c #4788D8",
+"T c #4D8FDB",
+"U c #5395DF",
+"V c #599BE3",
+"W c #5EA2E7",
+"X c #64A7EA",
+"Y c #68ABED",
+"Z c #6AAEEF",
+"` c #6BAFEF",
+" . c #6AAEEE",
+".. c #63A7EA",
+"+. c #5FA1E6",
+"@. c #5294DF",
+"#. c #4B8DDB",
+"$. c #4586D6",
+"%. c #3F80D2",
+"&. c #3879CE",
+"*. c #2C6EC8",
+"=. c #3F73C5",
+"-. c #F0F2F6",
+";. c #FFFEFD",
+">. c #CDD0D7",
+",. c #2B66BC",
+"'. c #3576CE",
+"). c #3D7DD1",
+"!. c #4384D5",
+"~. c #498AD8",
+"{. c #4E90DC",
+"]. c #5395E0",
+"^. c #5D9FE5",
+"/. c #60A3E8",
+"(. c #62A5E9",
+"_. c #62A4E9",
+":. c #60A3E7",
+"<. c #5C9FE6",
+"[. c #589AE2",
+"}. c #4E8FDC",
+"|. c #4182D3",
+"1. c #3B7CD0",
+"2. c #3575CC",
+"3. c #296BC7",
+"4. c #467AC9",
+"5. c #EAEBEF",
+"6. c #F1F0EF",
+"7. c #CECECE",
+"8. c #F8F8F8",
+"9. c #CED1D8",
+"0. c #2560B9",
+"a. c #3072CB",
+"b. c #3F7FD2",
+"c. c #488AD8",
+"d. c #4D8FDC",
+"e. c #5294DE",
+"f. c #5597E0",
+"g. c #589BE2",
+"h. c #5A9CE3",
+"i. c #599CE3",
+"j. c #5597E1",
+"k. c #5193DE",
+"l. c #4D8EDB",
+"m. c #4889D8",
+"n. c #4283D4",
+"o. c #3C7CD1",
+"p. c #3777CD",
+"q. c #3271C9",
+"r. c #2667C4",
+"s. c #4276C6",
+"t. c #E1E3E7",
+"u. c #E4E3E1",
+"v. c #CACACA",
+"w. c #F9F9F9",
+"x. c #CED2D9",
+"y. c #1550AF",
+"z. c #2C6CC7",
+"A. c #3474CB",
+"B. c #3979CE",
+"C. c #3D7ED1",
+"D. c #4282D4",
+"E. c #4788D7",
+"F. c #4B8CDA",
+"G. c #5092DD",
+"H. c #4A8BD9",
+"I. c #4687D7",
+"J. c #4182D4",
+"K. c #3C7DD1",
+"L. c #3272CA",
+"M. c #2E6DC7",
+"N. c #1F5FBF",
+"O. c #3467BE",
+"P. c #E1E3E6",
+"Q. c #E3E2E1",
+"R. c #CCCCCC",
+"S. c #FBFBFB",
+"T. c #D2D6DC",
+"U. c #0740A5",
+"V. c #1656B9",
+"W. c #2F6FC8",
+"X. c #3373CB",
+"Y. c #3F80D3",
+"Z. c #4889D7",
+"`. c #4587D6",
+" + c #4283D5",
+".+ c #3B7BD0",
+"++ c #3676CD",
+"@+ c #3171C9",
+"#+ c #2968C3",
+"$+ c #0949B1",
+"%+ c #2C5EB7",
+"&+ c #E1E0DF",
+"*+ c #FCFCFC",
+"=+ c #D4D7DE",
+"-+ c #0841A5",
+";+ c #003BA8",
+">+ c #1654B7",
+",+ c #2B6BC5",
+"'+ c #3171CA",
+")+ c #3878CE",
+"!+ c #3E7FD1",
+"~+ c #3A7BD0",
+"{+ c #3878CD",
+"]+ c #3070C9",
+"^+ c #2C6BC6",
+"/+ c #2362C0",
+"(+ c #0F4DB2",
+"_+ c #0037A6",
+":+ c #2D60B9",
+"<+ c #E0E2E5",
+"[+ c #DFDEDC",
+"}+ c #D6D9E0",
+"|+ c #0942A6",
+"1+ c #003CA9",
+"2+ c #0341AB",
+"3+ c #0F4DB4",
+"4+ c #1E5DBD",
+"5+ c #2A69C5",
+"6+ c #3374CB",
+"7+ c #3676CC",
+"8+ c #3778CD",
+"9+ c #3576CC",
+"0+ c #2C6CC6",
+"a+ c #2463C0",
+"b+ c #1552B7",
+"c+ c #0642AD",
+"d+ c #003CA8",
+"e+ c #0038A6",
+"f+ c #DFE1E4",
+"g+ c #DCDBDA",
+"h+ c #D7DBE2",
+"i+ c #0B44A9",
+"j+ c #0443AE",
+"k+ c #0C4AB1",
+"l+ c #0F4DB3",
+"m+ c #1250B5",
+"n+ c #1857B9",
+"o+ c #205FBE",
+"p+ c #2766C2",
+"q+ c #2A6AC5",
+"r+ c #2E6EC7",
+"s+ c #2E6EC8",
+"t+ c #2D6DC7",
+"u+ c #2767C3",
+"v+ c #2161BF",
+"w+ c #1A59BA",
+"x+ c #114FB4",
+"y+ c #0A48B0",
+"z+ c #0744AD",
+"A+ c #0441AB",
+"B+ c #0038A7",
+"C+ c #DEDFE2",
+"D+ c #D9D8D7",
+"E+ c #D9DDE4",
+"F+ c #114BAD",
+"G+ c #0B4AB2",
+"H+ c #1452B6",
+"I+ c #1B5ABB",
+"J+ c #1F5EBD",
+"K+ c #2261C0",
+"L+ c #2464C1",
+"M+ c #2767C2",
+"N+ c #2968C4",
+"O+ c #2969C4",
+"P+ c #2665C1",
+"Q+ c #2262C0",
+"R+ c #1756B8",
+"S+ c #1351B5",
+"T+ c #0A47B0",
+"U+ c #003BA9",
+"V+ c #DBDDE0",
+"W+ c #D6D5D4",
+"X+ c #DCE0E6",
+"Y+ c #1852B2",
+"Z+ c #1250B6",
+"`+ c #1B59BB",
+" @ c #205EBD",
+".@ c #2766C3",
+"+@ c #2B6AC6",
+"@@ c #2D6EC7",
+"#@ c #3070C8",
+"$@ c #3272C9",
+"%@ c #2867C3",
+"&@ c #1A58BA",
+"*@ c #1653B7",
+"=@ c #114EB4",
+"-@ c #0242AE",
+";@ c #3063BB",
+">@ c #DADCDF",
+",@ c #D4D3D2",
+"'@ c #DDE1E8",
+")@ c #1E58B6",
+"!@ c #1857BA",
+"~@ c #2160BF",
+"{@ c #2665C2",
+"]@ c #2F6EC8",
+"^@ c #3372CA",
+"/@ c #3A7BCF",
+"(@ c #3B7BCF",
+"_@ c #3677CD",
+":@ c #2B6BC6",
+"<@ c #215FBE",
+"[@ c #1C5ABB",
+"}@ c #1654B8",
+"|@ c #0848B2",
+"1@ c #3567BF",
+"2@ c #D9DBDE",
+"3@ c #D1D1CF",
+"4@ c #DEE2E8",
+"5@ c #235DB9",
+"6@ c #1D5EBF",
+"7@ c #3E7FD2",
+"8@ c #4284D4",
+"9@ c #4484D5",
+"0@ c #0E4EB5",
+"a@ c #396CC1",
+"b@ c #D8D9DC",
+"c@ c #CFCECD",
+"d@ c #CDCDCD",
+"e@ c #DEE1E7",
+"f@ c #2763BC",
+"g@ c #2364C2",
+"h@ c #3372CB",
+"i@ c #4B8DDA",
+"j@ c #4C8EDB",
+"k@ c #4C8EDA",
+"l@ c #498BD9",
+"m@ c #3D7ED2",
+"n@ c #3373CA",
+"o@ c #1353B8",
+"p@ c #3C70C3",
+"q@ c #D6D8DB",
+"r@ c #CDCCCA",
+"s@ c #DBDFE5",
+"t@ c #1F5EBC",
+"u@ c #1C60C2",
+"v@ c #266AC7",
+"w@ c #2D71CB",
+"x@ c #3377CF",
+"y@ c #397DD3",
+"z@ c #3E83D7",
+"A@ c #4389DA",
+"B@ c #478DDD",
+"C@ c #4A90DE",
+"D@ c #4C92DF",
+"E@ c #4489DB",
+"F@ c #3F85D7",
+"G@ c #3A7FD4",
+"H@ c #3379D0",
+"I@ c #2D71CC",
+"J@ c #2063C3",
+"K@ c #195CBF",
+"L@ c #0A4FB7",
+"M@ c #356CC3",
+"N@ c #D5D7DA",
+"O@ c #CAC9C8",
+"P@ c #E9ECEF",
+"Q@ c #88AADC",
+"R@ c #86ABDF",
+"S@ c #8CB1E2",
+"T@ c #90B5E4",
+"U@ c #93B8E6",
+"V@ c #96BBE8",
+"W@ c #99BFEA",
+"X@ c #9DC2EB",
+"Y@ c #9FC4EE",
+"Z@ c #A0C6EE",
+"`@ c #A1C6EF",
+" # c #A0C5EE",
+".# c #9EC4ED",
+"+# c #9CC2EC",
+"@# c #92B7E5",
+"## c #8EB3E3",
+"$# c #8AAFE0",
+"%# c #87ABDD",
+"&# c #83A7DC",
+"*# c #7BA0D7",
+"=# c #92AFDD",
+"-# c #D6D7D9",
+";# c #C6C6C5",
+"># c #CBCBCB",
+",# c #FDFDFC",
+"'# c #F4F6F8",
+")# c #F6F7F8",
+"!# c #F4F3F3",
+"~# c #F1F2F2",
+"{# c #F0F0F0",
+"]# c #EFEEEF",
+"^# c #EDEDEC",
+"/# c #EBEBEB",
+"(# c #E9EAEA",
+"_# c #E8E8E8",
+":# c #E6E6E6",
+"<# c #E3E3E3",
+"[# c #E2E2E2",
+"}# c #E1E1E1",
+"|# c #DFDFDF",
+"1# c #DCDCDC",
+"2# c #DBDBDB",
+"3# c #D9D9D9",
+"4# c #D7D8D7",
+"5# c #D5D6D6",
+"6# c #D4D3D3",
+"7# c #D0D0D1",
+"8# c #CFCFCF",
+"9# c #C4C4C4",
+"0# c #FBFAFA",
+"a# c #F9F7F7",
+"b# c #F6F6F4",
+"c# c #F4F4F3",
+"d# c #ECEBEA",
+"e# c #E9E9E8",
+"f# c #E8E7E7",
+"g# c #E6E5E5",
+"h# c #E4E2E3",
+"i# c #E2E1E0",
+"j# c #E0DFDD",
+"k# c #DEDDDC",
+"l# c #DBDBDA",
+"m# c #D8D9D8",
+"n# c #D6D6D5",
+"o# c #D4D4D3",
+"p# c #D2D2D1",
+"q# c #D0CFCF",
+"r# c #CECCCC",
+"s# c #CBCAC9",
+"t# c #A5A5A5",
+"u# c #ACACAC",
+"v# c #C9C9C9",
+"w# c #C7C7C7",
+"x# c #D5D5D5",
+"y# c #D1D1D1",
+"z# c #C1C1C1",
+"A# c #B4B4B4",
+"B# c #B9B9B9",
+"C# c #BBBBBB",
+"D# c #BABABA",
+"E# c #B8B8B8",
+"F# c #BCBCBC",
+"G# c #595959",
+"H# c #D0D0D0",
+"I# c #C3C3C3",
+"J# c #C2C2C2",
+"K# c #BFBFBF",
+"L# c #BEBEBE",
+"M# c #878787",
+"N# c #3A3A3A",
+"O# c #8B8B8B",
+"P# c #C6C6C6",
+"Q# c #E7E7E7",
+"R# c #F3F3F3",
+"S# c #5E5E5E",
+"T# c #FAFAFA",
+"U# c #F2F2F2",
+"V# c #DADADA",
+"W# c #A8A8A8",
+"X# c #787878",
+"Y# c #ECECEC",
+"Z# c #DDDDDD",
+"`# c #E5E5E5",
+" $ c #E4E4E4",
+".$ c #DEDEDE",
+"+$ c #4C4C4C",
+"@$ c #F7F7F7",
+"#$ c #EDEDED",
+"$$ c #D8D8D8",
+"%$ c #D7D7D7",
+"&$ c #393939",
+"*$ c #808080",
+"=$ c #EFEFEF",
+"-$ c #EEEEEE",
+";$ c #D6D6D6",
+">$ c #686868",
+",$ c #414141",
+"'$ c #898989",
+")$ c #D4D4D4",
+"!$ c #B5B5B5",
+"~$ c #757575",
+"{$ c #2D2D2D",
+"]$ c #454545",
+"^$ c #848484",
+"/$ c #A4A4A4",
+"($ c #A6A6A6",
+"_$ c #A3A3A3",
+":$ c #979797",
+"<$ c #7E7E7E",
+"[$ c #606060",
+"}$ c #3C3C3C",
+" . + @ @ @ @ @ @ @ @ @ # # # # # # # # # $ $ $ % % % $ & ",
+" * = - - - - - - - - - - - - - - - - - - - - - - - - - - ; > ",
+" , - - ' ) ! ! ! ~ { ] ] ^ / / / ] ] ] ] { { { { { ! ) ( - _ ",
+" : - < [ } | 1 2 3 4 5 6 7 8 9 8 7 0 a b c d e f g h i j - k ",
+" l - m n o p q r s t u v w x y z A B C D E F G H I J K L - M ",
+" N - O P Q R S T U V W X Y Z ` .Y ..+.V @.#.$.%.&.*.=.-.;.M ",
+" N - >.,.'.).!.~.{.].V ^./.(.(._.:.<.[.U }.S |.1.2.3.4.5.6.7. ",
+" 8.- 9.0.a.&.b.!.c.d.e.f.g.h.h.i.[.j.k.l.m.n.o.p.q.r.s.t.u.v. ",
+" w.- x.y.z.A.B.C.D.E.F.d.G.k.k.k.G.T H.I.J.K.p.L.M.N.O.P.Q.R. ",
+" S.- T.U.V.W.X.p.1.Y.!.$.S ~.~.~.Z.`. +%..+++@+M.#+$+%+P.&+R. ",
+" *+- =+-+;+>+,+'+2.)+1.!+%.R R R %.C.~+{+A.]+^+/+(+_+:+<+[+R. ",
+" *+- }+|+1+2+3+4+5+]+6+7+8+)+)+{+p.9+X.]+0+a+b+c+d+e+:+f+g+R. ",
+" = - h+i+j+k+l+m+n+o+p+q+M.r+s+s+t+,+u+v+w+x+y+z+A+B+:+C+D+R. ",
+" ( - E+F+G+H+n+I+J+K+L+M+N+O+O+N+u+P+Q+J+I+R+S+l+T+U+:+V+W+R. ",
+" - - X+Y+Z+`+ @/+.@+@@@#@@+$@$@@+#@M.,+%@a+J+&@*@=@-@;@>@,@R. ",
+" - - '@)@!@~@{@q+]@^@7+B./@(@(@/@[email protected].:@{@<@[@}@|@1@2@3@R. ",
+" - - 4@5@6@u+t+@+++/@7@R 8@9@9@[email protected]@.+p.'+0+.@v+[@0@a@b@c@d@ ",
+" - - e@f@[email protected]@{+).n.I.c.i@j@[email protected]@I.n.m@&.n@0+.@~@o@p@q@r@R. ",
+" - - s@t@u@v@w@x@y@z@A@B@C@D@D@C@r E@F@G@H@I@v@J@K@L@M@N@O@R. ",
+" - - P@Q@R@S@T@U@V@W@X@Y@Z@`@`@ #.#+#W@V@@###$#%#&#*#=#-#;#># ",
+" - ,#'#)#N !#~#{#]#^#/#(#_#:#<#[#}#|#1#2#3#4#5#6#M 7#8#_ 9#R. ",
+" 7.- ( ,#0#a#b#c#6.d#e#f#g#h#i#j#k#l#m#n#W+W+o#p#q#r#s#_ 2#t# ",
+" u#M d@R.>#v#9#w#x#k M y#8#7.d@R.>#v.v.z#A#B#C#D#B#E#F#* ",
+" G#w#H#>#v#w#9#I#J#K#L#L#M#N# ",
+" O#P#/#H#:#/#_#_#_#Q#Q#_#/#x#:#R#A#S# ",
+" y#- - - ; 2#/#: w.w.T#8.U#V#k w.- - - W# ",
+" X#- = S.w.N Y#Z#|#`#:# $1#7.v#R..$*+S.- - +$ ",
+" S#@$@$U#U#; #$, <#1#2#$$%$2#|#Q#; U#U#T#Y#&$ ",
+" *$[#=$=$Y#, , , , , , , /#Y#Y##$=$-$;$>$ ",
+" ,$'$C#%$[#<#<# $ $ $ $<#<#[#)$!$~${$ ",
+" ]$& ^$% /$($($_$:$<$[$}$ ",
+" "};
+static const char * xpm_edit[] = {
+"32 32 281 2",
+" c None",
+". c #C4D0E5",
+"+ c #9DAAC1",
+"@ c #FBFFFF",
+"# c #FFFFFF",
+"$ c #FEFFFF",
+"% c #F5FAFF",
+"& c #EDF3FE",
+"* c #E4EBF9",
+"= c #D8E1F2",
+"- c #C2D0E9",
+"; c #A7B2C4",
+"> c #FCFFFF",
+", c #F8FDFF",
+"' c #F2F7FF",
+") c #EAF1FD",
+"! c #E1E9F7",
+"~ c #D5DFF0",
+"{ c #DBAC55",
+"] c #F2C584",
+"^ c #E6AE84",
+"/ c #DD9A6F",
+"( c #EDF4FE",
+"_ c #E6EDFA",
+": c #DBD6D4",
+"< c #F5BC00",
+"[ c #FEE43E",
+"} c #FEE8C3",
+"| c #FEECD3",
+"1 c #EEC5A3",
+"2 c #F8FCFF",
+"3 c #F1F7FF",
+"4 c #E9EFFC",
+"5 c #E6B76B",
+"6 c #FEE600",
+"7 c #FECA00",
+"8 c #FEB610",
+"9 c #FEC451",
+"0 c #FECB93",
+"a c #C15B1D",
+"b c #FAFEFF",
+"c c #F3F9FF",
+"d c #EBEAED",
+"e c #F5C40F",
+"f c #FEB600",
+"g c #FEAF00",
+"h c #FE9610",
+"i c #F98219",
+"j c #AF725E",
+"k c #F5F9FF",
+"l c #EDC07F",
+"m c #FDDE00",
+"n c #FED201",
+"o c #FEB001",
+"p c #FEAC01",
+"q c #FE871C",
+"r c #E1701E",
+"s c #CED1E2",
+"t c #9EABC1",
+"u c #F7FBFF",
+"v c #F5C120",
+"w c #FEBB07",
+"x c #FEB306",
+"y c #FE9C0E",
+"z c #AF684C",
+"A c #98A9C5",
+"B c #FDFFFF",
+"C c #F3CF9F",
+"D c #FDE005",
+"E c #FEDB06",
+"F c #FEB70D",
+"G c #FEB30C",
+"H c #FE8C1C",
+"I c #E06510",
+"J c #B5B1C1",
+"K c #B4C3DC",
+"L c #AEBEDB",
+"M c #8495B1",
+"N c #F5B824",
+"O c #FEE80D",
+"P c #FEC613",
+"Q c #FEB913",
+"R c #FEA918",
+"S c #FE8E23",
+"T c #C7805B",
+"U c #BBC9E0",
+"V c #B9C6DF",
+"W c #B5C5E0",
+"X c #FBE1BF",
+"Y c #FCDC15",
+"Z c #FEE117",
+"` c #FEBE1C",
+" . c #FEBD19",
+".. c #FE9929",
+"+. c #E9781D",
+"@. c #BFA9AC",
+"#. c #C2CFE5",
+"$. c #C1CDE4",
+"%. c #BDCBE5",
+"&. c #F8C449",
+"*. c #FEEB22",
+"=. c #FED123",
+"-. c #FEC023",
+";. c #FEB128",
+">. c #FE9A34",
+",. c #CD7947",
+"'. c #C9D4E9",
+"). c #C7D2E7",
+"!. c #C6D2E6",
+"~. c #C3D0E8",
+"{. c #FDEACF",
+"]. c #F9D121",
+"^. c #FEE72C",
+"/. c #FEC42E",
+"(. c #FEC32A",
+"_. c #FEA938",
+":. c #F59031",
+"<. c #C5A5A3",
+"[. c #CED9EC",
+"}. c #CCD7EA",
+"|. c #CBD7EA",
+"1. c #C8D5EC",
+"2. c #F8CE6C",
+"3. c #FEED39",
+"4. c #FED837",
+"5. c #FEC835",
+"6. c #FEBE37",
+"7. c #FEA645",
+"8. c #D06F31",
+"9. c #D2DCEF",
+"0. c #D0DBED",
+"a. c #CEDAF0",
+"b. c #FEF1DF",
+"c. c #F9C828",
+"d. c #FEEC44",
+"e. c #FECE3F",
+"f. c #FECA3C",
+"g. c #FEB649",
+"h. c #F9A247",
+"i. c #C9A098",
+"j. c #D9E2F3",
+"k. c #D7E1F2",
+"l. c #D4DEF0",
+"m. c #D4DDEF",
+"n. c #D2DEF2",
+"o. c #F3CD87",
+"p. c #FEF054",
+"q. c #FEE04D",
+"r. c #FECE48",
+"s. c #FECA47",
+"t. c #FEB258",
+"u. c #D87833",
+"v. c #DEE6F5",
+"w. c #DDE5F4",
+"x. c #DBE4F3",
+"y. c #D8E1F1",
+"z. c #D5E0F4",
+"A. c #F2F1EF",
+"B. c #FAD148",
+"C. c #FEF15F",
+"D. c #FED654",
+"E. c #FED150",
+"F. c #FEC35B",
+"G. c #F9AF58",
+"H. c #CC947F",
+"I. c #E1E9F8",
+"J. c #DDE6F4",
+"K. c #DCE5F4",
+"L. c #DAE4F3",
+"M. c #D9E3F6",
+"N. c #F6FBFF",
+"O. c #F5D193",
+"P. c #FDEC66",
+"Q. c #FEE766",
+"R. c #FED55C",
+"S. c #FED259",
+"T. c #FEBF6B",
+"U. c #E2914A",
+"V. c #E0DFE9",
+"W. c #E4EBF8",
+"X. c #E2EAF8",
+"Y. c #DFE7F7",
+"Z. c #7C8CA8",
+"`. c #F9FEFF",
+" + c #F8C74E",
+".+ c #FEF37A",
+"++ c #FEDC69",
+"@+ c #FED864",
+"#+ c #FECF6B",
+"$+ c #FEC573",
+"%+ c #CD8968",
+"&+ c #E7EEFB",
+"*+ c #E5ECF9",
+"=+ c #E3EBF9",
+"-+ c #DBE3F1",
+";+ c #D2D9E9",
+">+ c #CBD2E3",
+",+ c #C6CFE3",
+"'+ c #7786A3",
+")+ c #F9FDFF",
+"!+ c #F5B651",
+"~+ c #FEEE86",
+"{+ c #FEDC70",
+"]+ c #FEDA6E",
+"^+ c #FECE7D",
+"/+ c #E4964E",
+"(+ c #E2D8DC",
+"_+ c #E3E9F6",
+":+ c #D8DEED",
+"<+ c #CFD7E5",
+"[+ c #CCD2E2",
+"}+ c #CAD1E2",
+"|+ c #CAD1E1",
+"1+ c #C8D1E5",
+"2+ c #EEAB59",
+"3+ c #FEEBCE",
+"4+ c #FEE4A4",
+"5+ c #FEDD8D",
+"6+ c #FBD08B",
+"7+ c #CB9373",
+"8+ c #D7DCEA",
+"9+ c #D2D8E6",
+"0+ c #CFD6E5",
+"a+ c #CED5E4",
+"b+ c #CDD4E4",
+"c+ c #C9D0E2",
+"d+ c #C9D2E5",
+"e+ c #E7A259",
+"f+ c #F8E7D0",
+"g+ c #C0856A",
+"h+ c #D0D0DA",
+"i+ c #D4DAE7",
+"j+ c #D0D7E5",
+"k+ c #CDD4E3",
+"l+ c #CCD3E3",
+"m+ c #F7FDFF",
+"n+ c #C6966D",
+"o+ c #F5DBC0",
+"p+ c #B67252",
+"q+ c #D3D2DB",
+"r+ c #D8DDE9",
+"s+ c #D5DAE8",
+"t+ c #D1D8E6",
+"u+ c #CBD2E2",
+"v+ c #CAD2E5",
+"w+ c #936D5C",
+"x+ c #978585",
+"y+ c #B88571",
+"z+ c #D9DFE9",
+"A+ c #D8DEE9",
+"B+ c #D7DCE9",
+"C+ c #D5DAE7",
+"D+ c #CDD3E4",
+"E+ c #CCD4E7",
+"F+ c #8D6050",
+"G+ c #AA7A69",
+"H+ c #DBE0E9",
+"I+ c #D3D9E7",
+"J+ c #CFD5E4",
+"K+ c #D4DBEA",
+"L+ c #DFE9FA",
+"M+ c #F4F9FC",
+"N+ c #BF968A",
+"O+ c #E2E6EE",
+"P+ c #DADFE9",
+"Q+ c #D6DBE8",
+"R+ c #D9DFEC",
+"S+ c #DFE6F3",
+"T+ c #E3EBF8",
+"U+ c #E0E9FB",
+"V+ c #F7FCFF",
+"W+ c #F4F9FF",
+"X+ c #F2F8FF",
+"Y+ c #F0F6FF",
+"Z+ c #EBF1FC",
+"`+ c #E7EEFA",
+" @ c #E4ECF9",
+".@ c #E1E8F7",
+"+@ c #E0EAFC",
+"@@ c #E9F0FC",
+"#@ c #F4FDFF",
+". . . . . . . . . . . . . . . + ",
+". @ # # # # # # # # $ % & * = - ; ",
+". > # # # # # # # # , ' ) ! ~ { ] ^ / ",
+". > # # # # # # # # @ % ( _ : < [ } | 1 ",
+". > # # # # # # # # $ 2 3 4 5 6 7 8 9 0 a ",
+". > # # # # # # # # # b c d e 6 f g h i j ",
+". > # # # # # # # # # > k l m n o p q r s t ",
+". > # # # # # # # # # > u v 6 w x y q z A A A ",
+". > # # # # # # # # # B C D E F G H I J K L M ",
+". > # # # # # # # # # # N O P Q R S T U V W M ",
+". > # # # # # # # # # X Y Z ` ...+.@.#.$.%.M ",
+". > # # # # # # # # # &.*.=.-.;.>.,.'.).!.~.M ",
+". > # # # # # # # # {.].^./.(._.:.<.[.}.|.1.M ",
+". > # # # # # # # # 2.3.4.5.6.7.8.~ 9.0.0.a.M ",
+". > # # # # # # # b.c.d.e.f.g.h.i.j.k.l.m.n.M ",
+". > # # # # # # B o.p.q.r.s.t.u.v.w.x.= y.z.M ",
+". > # # # # # > A.B.C.D.E.F.G.H.I.v.J.K.L.M.M ",
+". > # # # # # N.O.P.Q.R.S.T.U.V.W.X.Y.v.J.l.Z. ",
+". > # # # # `., +.+++@+#+$+%+&+*+=+-+;+>+,+'+ ",
+". > # # # # )+, !+~+{+]+^+/+(+_+:+<+[+}+|+1+'+ ",
+". > # # # > `.`.2+3+4+5+6+7+8+9+0+a+b+}+c+d+'+ ",
+". > # # # > `., e+| | f+g+h+i+9+j+0+k+l+>+d+'+ ",
+". > # # # @ `.m+n+| o+p+q+r+s+9+t+0+a+u+l+v+'+ ",
+". > # # $ b `., w+x+y+z+A+B+C+9+j+0+D+u+l+E+Z. ",
+". > # # $ b `., F+G+H+z+A+r+i+I+j+0+J+K+-+L+M ",
+". > # # > b , M+N+O+P+z+A+Q+i+9+R+S+T+X.! U+M ",
+". > # # `.`., V+W+W+X+3 Y+Z+W.`+_ @X.X..@+@M ",
+". > # # `.`., V+W+W+X+3 Y+& ) @@_ @X.X..@+@M ",
+". #@# # `.`., V+W+W+X+3 Y+& ) @@_ @X.X..@+@M ",
+". M M M M M M M M M M M M M M M M M M M M M M ",
+" ",
+" "};
+static const char * xpm_folder[] = {
+"32 32 465 2",
+" c None",
+". c #2F69EF",
+"+ c #1650E9",
+"@ c #3D76F2",
+"# c #5E91FD",
+"$ c #104AEB",
+"% c #3F7AF4",
+"& c #5E93FD",
+"* c #0043FF",
+"= c #0541F5",
+"- c #1243E3",
+"; c #3776F5",
+"> c #95B9FE",
+", c #0047FF",
+"' c #003BFF",
+") c #0D3DE5",
+"! c #B0B0D3",
+"~ c #D6D6E9",
+"{ c #C6C6E0",
+"] c #AEAED1",
+"^ c #2C6FF7",
+"/ c #85AFFC",
+"( c #0651FF",
+"_ c #0046FF",
+": c #0042FF",
+"< c #0039FF",
+"[ c #0434F3",
+"} c #0D38DB",
+"| c #CECEE4",
+"1 c #FEFEFF",
+"2 c #F9F9FC",
+"3 c #E0E0EE",
+"4 c #CBCBE3",
+"5 c #A7AED8",
+"6 c #2E74F9",
+"7 c #8EB5FA",
+"8 c #135FFF",
+"9 c #054FFF",
+"0 c #0041FF",
+"a c #002DFF",
+"b c #082FE3",
+"c c #B8B8D8",
+"d c #F0F6FF",
+"e c #4687FB",
+"f c #B9D3FD",
+"g c #6797F2",
+"h c #4E80EE",
+"i c #2E68F0",
+"j c #1255F7",
+"k c #0040FF",
+"l c #0037FF",
+"m c #002BFF",
+"n c #0020FB",
+"o c #082BD6",
+"p c #D8D8EA",
+"q c #488CFD",
+"r c #91BBFD",
+"s c #91BCFF",
+"t c #7AABFF",
+"u c #6CA0FF",
+"v c #5C90FB",
+"w c #4C7FF3",
+"x c #4172EE",
+"y c #2B5AEF",
+"z c #1740F5",
+"A c #001CFF",
+"B c #021EEB",
+"C c #0524CE",
+"D c #BFBFDC",
+"E c #629FFF",
+"F c #95BFFE",
+"G c #9FC8FF",
+"H c #88B6FF",
+"I c #78A9FF",
+"J c #6A9FFF",
+"K c #6196FF",
+"L c #5E92FF",
+"M c #5E8EFF",
+"N c #5A84FC",
+"O c #5070F5",
+"P c #445BEE",
+"Q c #1B34F3",
+"R c #031FD6",
+"S c #B6B6D6",
+"T c #E2E2EF",
+"U c #498EFE",
+"V c #C0DDFF",
+"W c #97C2FF",
+"X c #85B3FF",
+"Y c #76A7FF",
+"Z c #699CFF",
+"` c #6095FF",
+" . c #5E91FF",
+".. c #5E8DFF",
+"+. c #5E86FF",
+"@. c #5E7FFF",
+"#. c #4A60F1",
+"$. c #0822FA",
+"%. c #0018F9",
+"&. c #0119CB",
+"*. c #C5C5DF",
+"=. c #FBFBFD",
+"-. c #5495FD",
+";. c #B9D8FE",
+">. c #92BEFE",
+",. c #82B1FE",
+"'. c #73A4FE",
+"). c #669AFE",
+"!. c #5E92FE",
+"~. c #5D90FE",
+"{. c #5D8BFE",
+"]. c #5E85FF",
+"^. c #5A78FC",
+"/. c #3249EC",
+"(. c #0017FE",
+"_. c #0017FF",
+":. c #0017EE",
+"<. c #0013C4",
+"[. c #ECECF5",
+"}. c #F8F8FB",
+"|. c #4689FC",
+"1. c #B6D6FD",
+"2. c #8FBCFD",
+"3. c #7FAEFD",
+"4. c #6FA2FD",
+"5. c #6498FD",
+"6. c #5C91FD",
+"7. c #5C8EFD",
+"8. c #5C89FD",
+"9. c #5E84FF",
+"0. c #4B67F2",
+"a. c #1129EF",
+"b. c #0016FA",
+"c. c #0014DF",
+"d. c #0011C0",
+"e. c #CFCFE5",
+"f. c #FDFDFE",
+"g. c #F6F6FA",
+"h. c #E7EDFA",
+"i. c #4587FB",
+"j. c #B3D3FD",
+"k. c #8CB8FD",
+"l. c #7BABFD",
+"m. c #6D9FFD",
+"n. c #6196FD",
+"o. c #5B90FD",
+"p. c #5B8DFD",
+"q. c #5A80FC",
+"r. c #304FEB",
+"s. c #0017E3",
+"t. c #0017F1",
+"u. c #0019FF",
+"v. c #4157DE",
+"w. c #BBBBD9",
+"x. c #F3F3F9",
+"y. c #E4EBF9",
+"z. c #98BFFC",
+"A. c #9AC4FC",
+"B. c #88B6FC",
+"C. c #78A8FC",
+"D. c #6A9CFC",
+"E. c #5F93FC",
+"F. c #5A8EFC",
+"G. c #5A8CFC",
+"H. c #5E89FF",
+"I. c #4F72F5",
+"J. c #1E46F4",
+"K. c #1139F9",
+"L. c #0828F1",
+"M. c #0017E7",
+"N. c #0019EF",
+"O. c #A6B8FE",
+"P. c #4A5DD8",
+"Q. c #F1F1F7",
+"R. c #E2E8F7",
+"S. c #468BFD",
+"T. c #97C0FD",
+"U. c #AED2FB",
+"V. c #96C0FB",
+"W. c #85B2FB",
+"X. c #75A6FB",
+"Y. c #679AFB",
+"Z. c #5D91FB",
+"`. c #598DFB",
+" + c #5C8CFD",
+".+ c #5C87FD",
+"++ c #395FEE",
+"@+ c #153FF8",
+"#+ c #1640FF",
+"$+ c #133DFF",
+"%+ c #0B39FD",
+"&+ c #8EA6FA",
+"*+ c #FCFCFE",
+"=+ c #1F34CC",
+"-+ c #C2C2DD",
+";+ c #F0F0F7",
+">+ c #EEEEF6",
+",+ c #E0E6F6",
+"'+ c #478CFD",
+")+ c #9BC4FD",
+"!+ c #BDDEFB",
+"~+ c #A6CCFB",
+"{+ c #92BDFB",
+"]+ c #81AFFB",
+"^+ c #72A2FB",
+"/+ c #6598FB",
+"(+ c #5B8FFB",
+"_+ c #588CFB",
+":+ c #5D8DFE",
+"<+ c #5078F5",
+"[+ c #2551F3",
+"}+ c #1541FB",
+"|+ c #113FFF",
+"1+ c #0B3CFF",
+"2+ c #557CFE",
+"3+ c #FCFCFD",
+"4+ c #E8EBFA",
+"5+ c #1328C8",
+"6+ c #EBEBF4",
+"7+ c #468CFD",
+"8+ c #A1C8FE",
+"9+ c #D1ECFB",
+"0+ c #B5D8FA",
+"a+ c #A1C9FA",
+"b+ c #8FB9FA",
+"c+ c #7DABFA",
+"d+ c #6EA0FA",
+"e+ c #6295FA",
+"f+ c #588DFA",
+"g+ c #5A8DFC",
+"h+ c #5B8BFE",
+"i+ c #3964F0",
+"j+ c #1146F9",
+"k+ c #0D40FE",
+"l+ c #0B3DFF",
+"m+ c #F9F9FD",
+"n+ c #CFD0F1",
+"o+ c #091CC2",
+"p+ c #C8C8E1",
+"q+ c #E9E9F3",
+"r+ c #E8E8F3",
+"s+ c #3D87FF",
+"t+ c #EDF9FD",
+"u+ c #D5EBFB",
+"v+ c #BDD8FB",
+"w+ c #A3C6FB",
+"x+ c #8EB6FB",
+"y+ c #7BA7FB",
+"z+ c #6999FB",
+"A+ c #5A8DFB",
+"B+ c #4E83FB",
+"C+ c #4980FE",
+"D+ c #396DFA",
+"E+ c #1C53F7",
+"F+ c #0F46FD",
+"G+ c #0C3FFF",
+"H+ c #4872FE",
+"I+ c #F8F8FC",
+"J+ c #F8F8FD",
+"K+ c #D8DBF5",
+"L+ c #1528C6",
+"M+ c #F7F7FB",
+"N+ c #E7E7F2",
+"O+ c #E6E6F1",
+"P+ c #73A6F9",
+"Q+ c #A1C6FD",
+"R+ c #D1E7FB",
+"S+ c #B8D5FB",
+"T+ c #A1C3FB",
+"U+ c #8CB2FB",
+"V+ c #78A3FB",
+"W+ c #6695FB",
+"X+ c #5688FB",
+"Y+ c #4B81FD",
+"Z+ c #477CFF",
+"`+ c #2F63F5",
+" @ c #134DFA",
+".@ c #1046FF",
+"+@ c #2E5DFE",
+"@@ c #E4E9FB",
+"#@ c #F6F6FB",
+"$@ c #F7F7FC",
+"%@ c #E8E8F7",
+"&@ c #283ACB",
+"*@ c #EDEDF5",
+"=@ c #E3E3F0",
+"-@ c #D5DCF1",
+";@ c #4586FB",
+">@ c #CEE2FC",
+",@ c #B3D1FB",
+"'@ c #9EC0FB",
+")@ c #88B0FB",
+"!@ c #75A1FB",
+"~@ c #6392FB",
+"{@ c #5386FB",
+"]@ c #4C82FE",
+"^@ c #3F75FB",
+"/@ c #225BF7",
+"(@ c #134DFC",
+"_@ c #3163FE",
+":@ c #E3E7FB",
+"<@ c #F5F5FB",
+"[@ c #F3F3FB",
+"}@ c #394BD0",
+"|@ c #C3C3DE",
+"1@ c #C0C0DC",
+"2@ c #D7D7E9",
+"3@ c #7DA9F7",
+"4@ c #82ACFA",
+"5@ c #B5D1FA",
+"6@ c #99BDFA",
+"7@ c #84ACFA",
+"8@ c #729EFA",
+"9@ c #6090FA",
+"0@ c #5286FB",
+"a@ c #4C82FF",
+"b@ c #366AF6",
+"c@ c #1954F9",
+"d@ c #1D57FE",
+"e@ c #E1E6FA",
+"f@ c #F2F2F9",
+"g@ c #F2F2FA",
+"h@ c #F3F3FA",
+"i@ c #3F52D3",
+"j@ c #3572E7",
+"k@ c #B3BFE6",
+"l@ c #C3C5E2",
+"m@ c #D2D2E7",
+"n@ c #417CF5",
+"o@ c #B9D2FB",
+"p@ c #98BDFB",
+"q@ c #81AAFA",
+"r@ c #6D9BFA",
+"s@ c #5D8EFA",
+"t@ c #5387FD",
+"u@ c #457AFB",
+"v@ c #2862F7",
+"w@ c #225DFB",
+"x@ c #BFCFF9",
+"y@ c #F0F0F9",
+"z@ c #F1F1F9",
+"A@ c #7884E0",
+"B@ c #2470FA",
+"C@ c #CADBF8",
+"D@ c #D0DBF3",
+"E@ c #BCCBED",
+"F@ c #B5C3E9",
+"G@ c #B5BEE3",
+"H@ c #C8CAE3",
+"I@ c #A0B3E9",
+"J@ c #4A7FF3",
+"K@ c #B1CFFF",
+"L@ c #86B0FF",
+"M@ c #709FFD",
+"N@ c #5F90FD",
+"O@ c #5388FF",
+"P@ c #3C72F7",
+"Q@ c #2864F9",
+"R@ c #BFCEF8",
+"S@ c #EDEDF7",
+"T@ c #EDEDF8",
+"U@ c #EEEEF8",
+"V@ c #818DE3",
+"W@ c #2776FF",
+"X@ c #A2C6FE",
+"Y@ c #F0F7FF",
+"Z@ c #E2EEFF",
+"`@ c #D5E7FF",
+" # c #C0D7F9",
+".# c #AEC8F4",
+"+# c #9CBBF0",
+"@# c #9AB5E9",
+"## c #4A7BEB",
+"$# c #80A4F5",
+"%# c #81A9F9",
+"&# c #6B9AFB",
+"*# c #6092FF",
+"=# c #4E83FC",
+"-# c #2E68F7",
+";# c #A2BBF7",
+"># c #E9E9F7",
+",# c #EBEBF7",
+"'# c #ECECF7",
+")# c #959FE7",
+"!# c #327FFE",
+"~# c #86B3FD",
+"{# c #E1EDFE",
+"]# c #C9E0FF",
+"^# c #BCD8FF",
+"/# c #AFD1FF",
+"(# c #9FC5FB",
+"_# c #85B0F6",
+":# c #275EEB",
+"<# c #90B0F7",
+"[# c #5387F8",
+"}# c #497DF6",
+"|# c #4377F6",
+"1# c #99B5F6",
+"2# c #E7E7F5",
+"3# c #E8E8F6",
+"4# c #B9BFEF",
+"5# c #081CC3",
+"6# c #2D70F7",
+"7# c #7AA6F9",
+"8# c #CADEFE",
+"9# c #A2CAFF",
+"0# c #96C2FF",
+"a# c #72A4FA",
+"b# c #2F5EE7",
+"c# c #76A2FB",
+"d# c #3875FB",
+"e# c #8DACF7",
+"f# c #E3E3F4",
+"g# c #E4E4F4",
+"h# c #E4E4F5",
+"i# c #E6E6F5",
+"j# c #BEC4F1",
+"k# c #081CC4",
+"l# c #2763EF",
+"m# c #6D99F5",
+"n# c #B3D1FD",
+"o# c #89BBFF",
+"p# c #5286F3",
+"q# c #345FE5",
+"r# c #8CB0FB",
+"s# c #E1E1F3",
+"t# c #E2E2F3",
+"u# c #E2E4F7",
+"v# c #081DC4",
+"w# c #2156E8",
+"x# c #618CF1",
+"y# c #9CC3FD",
+"z# c #7FB3FF",
+"A# c #3567EB",
+"B# c #5675E5",
+"C# c #DEDEF2",
+"D# c #E0E0F2",
+"E# c #E3E6F8",
+"F# c #1E34CC",
+"G# c #1B49E1",
+"H# c #5580EE",
+"I# c #87B5FC",
+"J# c #73ACFF",
+"K# c #2958E5",
+"L# c #7D93E9",
+"M# c #DEDEF1",
+"N# c #E4E7F9",
+"O# c #1F35CD",
+"P# c #163CDA",
+"Q# c #4973E9",
+"R# c #73A8FC",
+"S# c #6CA7FF",
+"T# c #143AD9",
+"U# c #8C9CE9",
+"V# c #3C52D6",
+"W# c #0012C0",
+"X# c #1130D2",
+"Y# c #4067E5",
+"Z# c #6095F8",
+"`# c #1032D4",
+" $ c #2F48D5",
+".$ c #0014C2",
+"+$ c #0C25CA",
+"@$ c #0D2CD0",
+"#$ c #0117C5",
+" . + ",
+" @ # $ ",
+" % & * = - ",
+" ; > , * ' ) ",
+" ! ~ { ] ^ / ( _ : < [ } ",
+" | 1 1 2 3 4 5 6 7 8 9 _ 0 < a b ",
+" c 2 1 1 1 1 d e f g h i j k l m n o ",
+" p 1 1 1 1 d q r s t u v w x y z A B C ",
+" D 2 1 1 1 1 E F G H I J K L M N O P Q R ",
+" S T 1 1 1 1 1 U V W X Y Z ` ...+.@.#.$.%.&. ",
+" *.1 =.=.=.=.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<. ",
+" c [.=.}.}.}.}.}.|.1.2.3.4.5.6.7.8.9.0.a.b._._.c.d. ",
+" e.f.g.g.g.g.g.h.i.j.k.l.m.n.o.p.8.q.r.s.t._._.u.v.d. ",
+" w.g.g.x.x.x.x.y.i.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.f.P. ",
+" p =.Q.Q.Q.Q.R.S.T.U.V.W.X.Y.Z.`. +.+++@+#+$+%+&+*+f.f.=+ ",
+" -+=.;+>+>+>+,+'+)+!+~+{+]+^+/+(+_+:+<+[+}+|+1+2+=.3+3+3+4+5+",
+" T g.6+6+6+6+7+8+9+0+a+b+c+d+e+f+g+h+i+j+k+l+2+m+m+=.=.=.n+o+",
+" p+f.q+r+r+r+r+s+t+u+v+w+x+y+z+A+B+C+D+E+F+G+H+I+I+J+J+m+K+L+ ",
+"-+6+M+N+O+O+O+O+P+Q+R+S+T+U+V+W+X+Y+Z+`+ @.@+@@@#@M+$@$@%@&@ ",
+"{ ;+1 1 g.*@O+=@-@;@>@,@'@)@!@~@{@]@^@/@(@_@:@<@<@<@#@[@}@d. ",
+" |@1@2@6+=.1 2 ;+3@4@5@6@7@8@9@0@a@b@c@d@e@f@g@g@h@g@i@d. ",
+" j@k@l@m@T g.1 n@o@p@q@r@s@t@u@v@w@x@y@y@z@z@z@A@d. ",
+" B@C@D@E@F@G@H@I@J@K@L@M@N@O@P@Q@R@S@T@T@U@f@V@d. ",
+" W@X@Y@Z@`@ #.#+#@###$#%#&#*#=#-#;#>#,#,#'#U@)#d. ",
+" !#~#{#Z@`@]#^#/#(#_#:#<#[#}#|#1#2#2#3#3#'#4#5# ",
+" 6#7#8#]#^#/#9#0#a#b#c#d#e#f#g#h#i#>#j#k# ",
+" l#m#n#/#9#0#o#p#q#r#s#s#t#t#g#u#v# ",
+" w#x#y#0#o#z#A#B#t#C#D#t#E#F# ",
+" G#H#I#z#J#K#L#M#C#N#O# ",
+" P#Q#R#S#T#U#z@V#W# ",
+" X#Y#Z#`# $.$ ",
+" +$@$#$ "};
+
+static const char * xpm_images[] = {
+"32 32 557 2",
+" c None",
+". c #C4D0E5",
+"+ c #9DAAC1",
+"@ c #FBFFFF",
+"# c #FFFFFF",
+"$ c #FEFFFF",
+"% c #F5FAFF",
+"& c #EDF3FE",
+"* c #E4EBF9",
+"= c #D8E1F2",
+"- c #C2D0E9",
+"; c #ACB7CA",
+"> c #FCFFFF",
+", c #F8FDFF",
+"' c #F2F7FF",
+") c #EAF1FD",
+"! c #E1E9F7",
+"~ c #D5DFF0",
+"{ c #BFCCE3",
+"] c #EBF4FF",
+"^ c #A6B2C6",
+"/ c #EDF4FE",
+"( c #E6EDFA",
+"_ c #D9E2F2",
+": c #C2CEE5",
+"< c #F0F6FF",
+"[ c #DCE7F9",
+"} c #A6B2C8",
+"| c #F8FCFF",
+"1 c #F1F7FF",
+"2 c #E9EFFC",
+"3 c #DCE5F4",
+"4 c #C4D0E6",
+"5 c #E8EEFB",
+"6 c #DBE5F9",
+"7 c #A7B3C9",
+"8 c #FAFEFF",
+"9 c #F3F9FF",
+"0 c #EBF1FD",
+"a c #DFE7F6",
+"b c #C6D1E5",
+"c c #FDFFFF",
+"d c #ECF2FD",
+"e c #DEE9FB",
+"f c #A9B5CA",
+"g c #C3C4CD",
+"h c #F3EADD",
+"i c #EFD9C2",
+"j c #E4C09A",
+"k c #E4C29E",
+"l c #E5C6A4",
+"m c #F0DECC",
+"n c #F5EADF",
+"o c #F7EFE7",
+"p c #FBF7F3",
+"q c #F5F9FF",
+"r c #E3EBF9",
+"s c #BECBE1",
+"t c #F3F5FB",
+"u c #ECF2F9",
+"v c #E4EBF7",
+"w c #D8E1F0",
+"x c #D0DCF1",
+"y c #A1AEC5",
+"z c #BF6300",
+"A c #C1721B",
+"B c #C26F14",
+"C c #BD6F19",
+"D c #B76B1A",
+"E c #BD701D",
+"F c #C0731F",
+"G c #BB6E18",
+"H c #B6660F",
+"I c #BC7529",
+"J c #D1A273",
+"K c #EDDBC9",
+"L c #F6F3ED",
+"M c #F7FBFF",
+"N c #E8EFFC",
+"O c #C8D4E7",
+"P c #98A9C5",
+"Q c #C16601",
+"R c #C6751D",
+"S c #CF8C41",
+"T c #D9AB7A",
+"U c #CAB8A7",
+"V c #B6B8C3",
+"W c #B2B7CB",
+"X c #C4C2CD",
+"Y c #EEE6DE",
+"Z c #F2E0C8",
+"` c #E1C19B",
+" . c #CB9355",
+".. c #BC772E",
+"+. c #AE600C",
+"@. c #C38D57",
+"#. c #E4D4C3",
+"$. c #EFF3FA",
+"%. c #EBF1FE",
+"&. c #E5EDFA",
+"*. c #D7E0F1",
+"=. c #C1CEE4",
+"-. c #B6C4DD",
+";. c #B4C3DC",
+">. c #AEBEDB",
+",. c #8495B1",
+"'. c #C16400",
+"). c #C77416",
+"!. c #D69C59",
+"~. c #EFD9BB",
+"{. c #E2F2FF",
+"]. c #81AFEB",
+"^. c #97BFF1",
+"/. c #BDD8FA",
+"(. c #8CABE2",
+"_. c #A3B2DE",
+":. c #F3F6FD",
+"<. c #ECEBDB",
+"[. c #D2AC7A",
+"}. c #B8732C",
+"|. c #A25200",
+"1. c #CFB191",
+"2. c #E9EDF4",
+"3. c #CCD6EA",
+"4. c #BECAE2",
+"5. c #BBC9E0",
+"6. c #B9C6DF",
+"7. c #B5C5E0",
+"8. c #C26400",
+"9. c #CF8A37",
+"0. c #ECD1A7",
+"a. c #FFFFFC",
+"b. c #FCFAEB",
+"c. c #AFC8E2",
+"d. c #57A0EE",
+"e. c #8DCDFF",
+"f. c #80C4FF",
+"g. c #70C4FF",
+"h. c #4877C8",
+"i. c #C0BBD1",
+"j. c #EFF3E2",
+"k. c #CCDDC3",
+"l. c #B7D3B6",
+"m. c #C5E6D6",
+"n. c #D5CDAE",
+"o. c #C28A4B",
+"p. c #9E5103",
+"q. c #C5A280",
+"r. c #E6ECF8",
+"s. c #D5DFEF",
+"t. c #C7D3E8",
+"u. c #C5D1E6",
+"v. c #C2CFE5",
+"w. c #C1CDE4",
+"x. c #BDCBE5",
+"y. c #D18C3A",
+"z. c #EED3A5",
+"A. c #F3E2C1",
+"B. c #F1DBB3",
+"C. c #FBF1D0",
+"D. c #F9F7DF",
+"E. c #8EB2D8",
+"F. c #137DF3",
+"G. c #2296FF",
+"H. c #178EFF",
+"I. c #0089FF",
+"J. c #0A5BCC",
+"K. c #BCB5C4",
+"L. c #A5C889",
+"M. c #80BE7F",
+"N. c #ABD9AD",
+"O. c #9ACE9C",
+"P. c #8CC38E",
+"Q. c #EAEBD3",
+"R. c #C38D51",
+"S. c #9A4F01",
+"T. c #C1A996",
+"U. c #D0DAED",
+"V. c #CCD7EA",
+"W. c #C9D4E9",
+"X. c #C7D2E7",
+"Y. c #C6D2E6",
+"Z. c #C3D0E8",
+"`. c #CB7F25",
+" + c #E0B373",
+".+ c #D08E40",
+"++ c #BE6807",
+"@+ c #C17117",
+"#+ c #D49C55",
+"$+ c #F6E3AC",
+"%+ c #C2C9CD",
+"&+ c #0F58CD",
+"*+ c #007AFC",
+"=+ c #0C8DFF",
+"-+ c #0061E8",
+";+ c #4C67B4",
+">+ c #C7B6A1",
+",+ c #75C765",
+"'+ c #6CDC70",
+")+ c #7DE47D",
+"!+ c #75E574",
+"~+ c #34B638",
+"{+ c #B6CC94",
+"]+ c #FFEAC5",
+"^+ c #B57329",
+"/+ c #954E07",
+"(+ c #CBCCD2",
+"_+ c #D0DBED",
+":+ c #CED9EC",
+"<+ c #CBD7EA",
+"[+ c #C8D5EC",
+"}+ c #C06500",
+"|+ c #C16907",
+"1+ c #EBCA8C",
+"2+ c #BE6809",
+"3+ c #D49648",
+"4+ c #F4EFCA",
+"5+ c #9A9EAE",
+"6+ c #4F7CC4",
+"7+ c #467DCC",
+"8+ c #4D61A6",
+"9+ c #C7B0A7",
+"0+ c #F5D9A6",
+"a+ c #4DBC3D",
+"b+ c #15CB18",
+"c+ c #17CD17",
+"d+ c #06CC05",
+"e+ c #009F00",
+"f+ c #9DB66A",
+"g+ c #FEE3B4",
+"h+ c #EABE7D",
+"i+ c #974E03",
+"j+ c #AD8763",
+"k+ c #D2DCEF",
+"l+ c #CEDAF0",
+"m+ c #BF6401",
+"n+ c #CF8C34",
+"o+ c #FFF6BF",
+"p+ c #C77C22",
+"q+ c #B15C04",
+"r+ c #DBA75B",
+"s+ c #FFF7B9",
+"t+ c #FFE7A6",
+"u+ c #D9BB94",
+"v+ c #BA9987",
+"w+ c #E4C294",
+"x+ c #FFE7A3",
+"y+ c #FEDEA1",
+"z+ c #609B38",
+"A+ c #00A502",
+"B+ c #07CC10",
+"C+ c #00C009",
+"D+ c #118A0C",
+"E+ c #CBBF75",
+"F+ c #FDD493",
+"G+ c #FFDF9B",
+"H+ c #B06714",
+"I+ c #93500E",
+"J+ c #D8E0F0",
+"K+ c #D7E1F2",
+"L+ c #D4DEF0",
+"M+ c #D4DDEF",
+"N+ c #D2DEF2",
+"O+ c #BD6402",
+"P+ c #E6BC6F",
+"Q+ c #FFF4B0",
+"R+ c #F2D48A",
+"S+ c #D9A14C",
+"T+ c #CD8A33",
+"U+ c #CF903A",
+"V+ c #E1B160",
+"W+ c #FBDA8F",
+"X+ c #FFE197",
+"Y+ c #FFDF92",
+"Z+ c #FFE391",
+"`+ c #FFE58F",
+" @ c #FFDE8B",
+".@ c #FFD687",
+"+@ c #FFD98B",
+"@@ c #D7BC6E",
+"#@ c #87A946",
+"$@ c #5AAC38",
+"%@ c #64A938",
+"&@ c #A9AD4E",
+"*@ c #FED078",
+"=@ c #FFCE78",
+"-@ c #FFCD7C",
+";@ c #D28B30",
+">@ c #8B4500",
+",@ c #CFCBCC",
+"'@ c #DBE4F3",
+")@ c #D8E1F1",
+"!@ c #D5E0F4",
+"~@ c #BA6202",
+"{@ c #E4B763",
+"]@ c #FFF4A4",
+"^@ c #FFED9C",
+"/@ c #FFEC9C",
+"(@ c #FAD983",
+"_@ c #FEDC86",
+":@ c #FFE791",
+"<@ c #FFDB83",
+"[@ c #FFD67C",
+"}@ c #FFD47A",
+"|@ c #FFD277",
+"1@ c #FFD074",
+"2@ c #FFCE70",
+"3@ c #FFCB6D",
+"4@ c #FFC869",
+"5@ c #FFCC6D",
+"6@ c #FFC367",
+"7@ c #DDB654",
+"8@ c #E89F49",
+"9@ c #F99056",
+"0@ c #EA8752",
+"a@ c #F29E4A",
+"b@ c #FFBF58",
+"c@ c #E49832",
+"d@ c #894300",
+"e@ c #C7BBB4",
+"f@ c #DDE6F4",
+"g@ c #DAE4F3",
+"h@ c #D9E3F6",
+"i@ c #B76001",
+"j@ c #C37A1D",
+"k@ c #F3D27A",
+"l@ c #FFF197",
+"m@ c #FFE68A",
+"n@ c #FFDF82",
+"o@ c #FFDA7B",
+"p@ c #FFD473",
+"q@ c #FFD16E",
+"r@ c #FFCF69",
+"s@ c #FFCB64",
+"t@ c #FFC860",
+"u@ c #FFC55B",
+"v@ c #FFC356",
+"w@ c #FFC052",
+"x@ c #FFBD4E",
+"y@ c #FFBA4A",
+"z@ c #FFBD49",
+"A@ c #FE9D39",
+"B@ c #F6916A",
+"C@ c #F3A19A",
+"D@ c #EFA6A2",
+"E@ c #EB9C88",
+"F@ c #F59B3D",
+"G@ c #E58F1E",
+"H@ c #864300",
+"I@ c #CBC0BA",
+"J@ c #DFE7F7",
+"K@ c #DEE6F5",
+"L@ c #DBE5F7",
+"M@ c #B15B00",
+"N@ c #C0771B",
+"O@ c #D1953A",
+"P@ c #E7B559",
+"Q@ c #FFD979",
+"R@ c #FFDC79",
+"S@ c #FFCF6A",
+"T@ c #FFCC64",
+"U@ c #FFC95F",
+"V@ c #FFC559",
+"W@ c #FFC253",
+"X@ c #FFBF4E",
+"Y@ c #FFBD48",
+"Z@ c #FFB942",
+"`@ c #FFB53E",
+" # c #FFB238",
+".# c #FFB832",
+"+# c #EE6924",
+"@# c #F77471",
+"## c #FF9498",
+"$# c #FF9698",
+"%# c #F96971",
+"&# c #D7471C",
+"*# c #E1820A",
+"=# c #844100",
+"-# c #C9BDB6",
+";# c #E2EAF8",
+"># c #E0E7F6",
+",# c #DCE6F8",
+"'# c #AB5600",
+")# c #B4670F",
+"!# c #C47E25",
+"~# c #E5AC4C",
+"{# c #FFD76D",
+"]# c #FFCA60",
+"^# c #FFBF4D",
+"/# c #FFBC48",
+"(# c #FFB842",
+"_# c #FFB43C",
+":# c #FFB036",
+"<# c #FFAD30",
+"[# c #FFB72B",
+"}# c #E9541C",
+"|# c #FB2725",
+"1# c #FE2526",
+"2# c #F91B1B",
+"3# c #FF0D0D",
+"4# c #C41803",
+"5# c #C86C01",
+"6# c #823F00",
+"7# c #D7D6D9",
+"8# c #E2E9F7",
+"9# c #E0E8F7",
+"0# c #E0E8F6",
+"a# c #DEE8FA",
+"b# c #A35100",
+"c# c #AC5F0A",
+"d# c #CF8C2D",
+"e# c #FFC959",
+"f# c #FFC252",
+"g# c #FFBD4B",
+"h# c #FFBA45",
+"i# c #FFB740",
+"j# c #FFB43A",
+"k# c #FFB034",
+"l# c #FFAC2F",
+"m# c #FFA929",
+"n# c #FFB125",
+"o# c #E05F11",
+"p# c #E50C0B",
+"q# c #FF0E14",
+"r# c #FF1014",
+"s# c #E4000A",
+"t# c #D14301",
+"u# c #A45600",
+"v# c #8C531C",
+"w# c #E3EBF7",
+"x# c #DFE9FA",
+"y# c #A25403",
+"z# c #D58F2C",
+"A# c #FFC650",
+"B# c #FFB844",
+"C# c #FFB63E",
+"D# c #FFB339",
+"E# c #FFB033",
+"F# c #FFAB2D",
+"G# c #FFA828",
+"H# c #FFA522",
+"I# c #FFA31C",
+"J# c #F89A15",
+"K# c #D84A08",
+"L# c #D22814",
+"M# c #D02518",
+"N# c #C02D06",
+"O# c #E77A01",
+"P# c #874400",
+"Q# c #A47B55",
+"R# c #E3EBF8",
+"S# c #E1E9F8",
+"T# c #AA5F0A",
+"U# c #E69F32",
+"V# c #FFBC41",
+"W# c #FFB237",
+"X# c #FFAE32",
+"Y# c #FFAA2C",
+"Z# c #FFA726",
+"`# c #FFA421",
+" $ c #FFA11B",
+".$ c #FF9D15",
+"+$ c #FF9D0F",
+"@$ c #F88E07",
+"#$ c #F48105",
+"$$ c #F38005",
+"%$ c #F68A02",
+"&$ c #B96400",
+"*$ c #D2C9C6",
+"=$ c #E4ECF9",
+"-$ c #E0E9FB",
+";$ c #954A00",
+">$ c #BA6E13",
+",$ c #FEB036",
+"'$ c #FFAF31",
+")$ c #FFAA2B",
+"!$ c #FFA625",
+"~$ c #FFA31F",
+"{$ c #FFA01A",
+"]$ c #FF9D14",
+"^$ c #FF990E",
+"/$ c #FF9607",
+"($ c #FF9404",
+"_$ c #FF9402",
+":$ c #FF9802",
+"<$ c #EA8501",
+"[$ c #8C4600",
+"}$ c #A0744C",
+"|$ c #E6ECF7",
+"1$ c #E3EAF9",
+"2$ c #9A5309",
+"3$ c #D1821A",
+"4$ c #FFB22C",
+"5$ c #FFA723",
+"6$ c #FFA21D",
+"7$ c #FF9F17",
+"8$ c #FF9C12",
+"9$ c #FF980C",
+"0$ c #FF9506",
+"a$ c #FF9202",
+"b$ c #FF9602",
+"c$ c #ED8701",
+"d$ c #934B00",
+"e$ c #884C12",
+"f$ c #DCD9DA",
+"g$ c #E7EEFA",
+"h$ c #E3EAF8",
+"i$ c #AD9480",
+"j$ c #974F03",
+"k$ c #C67610",
+"l$ c #FDA01A",
+"m$ c #FFA316",
+"n$ c #FF9D10",
+"o$ c #FF990A",
+"p$ c #FF9505",
+"q$ c #FF9302",
+"r$ c #FF9502",
+"s$ c #FF9601",
+"t$ c #D77901",
+"u$ c #904900",
+"v$ c #803F00",
+"w$ c #C9B9AD",
+"x$ c #E8EFFA",
+"y$ c #C2CADB",
+"z$ c #C6A583",
+"A$ c #8D4803",
+"B$ c #924B02",
+"C$ c #B06005",
+"D$ c #CA7205",
+"E$ c #DE7E02",
+"F$ c #E78301",
+"G$ c #E38001",
+"H$ c #CB7000",
+"I$ c #994F00",
+"J$ c #854100",
+"K$ c #8E551E",
+"L$ c #D9D2CF",
+"M$ c #E9EFFA",
+"N$ c #E9F0FC",
+"O$ c #E1E8F7",
+"P$ c #E0EAFC",
+"Q$ c #FBFDFC",
+"R$ c #F0E6DD",
+"S$ c #C3A07E",
+"T$ c #A2703E",
+"U$ c #8A490B",
+"V$ c #834000",
+"W$ c #834100",
+"X$ c #945F2C",
+"Y$ c #C9B5A3",
+"Z$ c #EBEDF3",
+"`$ c #EDF2FD",
+" % c #F4FDFF",
+".% c #F9FEFF",
+"+% c #F7FCFF",
+"@% c #F4F9FF",
+"#% c #F2F8FF",
+" ",
+" . . . . . . . . . . . . . . . + ",
+" . @ # # # # # # # # $ % & * = - ; ",
+" . > # # # # # # # # , ' ) ! ~ { ] ^ ",
+" . > # # # # # # # # @ % / ( _ : < [ } ",
+" . > # # # # # # # # $ | 1 2 3 4 # 5 6 7 ",
+" . > # # # # # # # # # 8 9 0 a b # c d e f ",
+" g h i j k l m n o p # > q & r s t u v w x y ",
+" z A B C D E F G H I J K L M < N O P P P P P P P ",
+" Q R S T U V W X Y Z ` ...+.@.#.$.%.&.! *.=.-.;.>.,.",
+" '.).!.~.# {.].^./.(._.:.# # <.[.}.|.1.2.&.a 3.4.5.6.7.,.",
+" 8.9.0.# a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.,.",
+" '.y.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.,.",
+" Q `. +.+++@+#+$+%+&+*+=+-+;+>+,+'+)+!+~+{+]+^+/+(+_+:+V.<+[+,.",
+"}+|+1+2+ 3+4+5+6+7+8+9+0+a+b+c+d+e+f+g+h+i+j+~ k+_+_+l+,.",
+"m+n+o+p+ q+r+s+t+u+v+w+x+y+z+A+B+C+D+E+F+G+H+I+J+K+L+M+N+,.",
+"O+P+Q+R+S+T+U+V+W+X+Y+Z+`+ @.@+@@@#@$@%@&@*@=@-@;@>@,@'@= )@!@,.",
+"~@{@]@^@/@(@_@:@<@[@}@|@1@2@3@4@5@6@7@8@9@0@a@b@c@d@e@f@3 g@h@,.",
+"i@j@k@l@m@n@o@p@q@r@s@t@u@v@w@x@y@z@A@B@C@D@E@F@G@H@I@J@K@f@L@,.",
+" M@N@O@P@Q@R@S@T@U@V@W@X@Y@Z@`@ #.#+#@###$#%#&#*#=#-#;#>#a ,#,.",
+" '#)#!#~#{#]#V@W@^#/#(#_#:#<#[#}#|#1#2#3#4#5#6#7#8#9#0#a#,.",
+" b#c#d#e#f#g#h#i#j#k#l#m#n#o#p#q#r#s#t#u#v#w#r 9#J@x#,.",
+" y#z#A#B#C#D#E#F#G#H#I#J#K#L#M#N#O#P#Q#( R#;#S#x#,.",
+" T#U#V#W#X#Y#Z#`# $.$+$@$#$$$%$&$6#*$( =$! ;#-$,.",
+" ;$>$,$'$)$!$~${$]$^$/$($_$:$<$[$}$|$( 1$! ;#-$,.",
+" 2$3$4$5$6$7$8$9$0$a$a$b$c$d$e$f$g$( h$;#;#x#,.",
+" i$j$k$l$m$n$o$p$q$r$s$t$u$v$w$x$g$( R#;#! -$,.",
+" y$z$A$B$C$D$E$F$G$H$I$J$K$L$M$N$( =$;#;#O$P$,.",
+" . Q$R$S$T$U$V$W$V$V$X$Y$Z$`$) N$( =$;#;#O$P$,.",
+" . %# # .%.%, +%@%@%#%1 < & ) N$( =$;#;#O$P$,.",
+" . ,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.",
+" "};
+
+#endif
diff --git a/src/sq_imageloader.cpp b/src/sq_imageloader.cpp
new file mode 100644
index 0000000..f818db7
--- /dev/null
+++ b/src/sq_imageloader.cpp
@@ -0,0 +1,261 @@
+/***************************************************************************
+ sq_imageloader.cpp - description
+ -------------------
+ begin : Tue Sep 20 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqfile.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "sq_imageloader.h"
+#include "sq_libraryhandler.h"
+
+#include <ksquirrel-libs/fileio.h>
+#include <ksquirrel-libs/fmt_utils.h>
+#include <ksquirrel-libs/fmt_codec_base.h>
+#include <ksquirrel-libs/error.h>
+
+SQ_ImageLoader * SQ_ImageLoader::m_instance = 0;
+
+SQ_ImageLoader::SQ_ImageLoader(TQObject *parent) : TQObject(parent), m_errors(0)
+{
+ m_instance = this;
+
+ m_image = 0;
+ dumbscan = 0;
+ finfo = new fmt_info;
+}
+
+SQ_ImageLoader::~SQ_ImageLoader()
+{
+ delete finfo;
+
+ if(dumbscan) free(dumbscan);
+ if(m_image) free(m_image);
+}
+
+/*
+ * Try to determine image dimensions.
+ */
+bool SQ_ImageLoader::tasteImage(const TQString &path, int *w, int *h, SQ_LIBRARY *_lib)
+{
+ SQ_LIBRARY *lib;
+ int res;
+ fmt_codec_base *codeK;
+
+ // determine library for file
+ lib = _lib ? _lib : SQ_LibraryHandler::instance()->libraryForFile(path);
+
+ if(!lib)
+ return false;
+
+ // determine codec
+ codeK = lib->codec_il;
+
+ if(!codeK)
+ return false;
+
+ // init...
+ res = codeK->read_init(TQString(TQFile::encodeName(path)).ascii());
+
+ // error in init()!
+ if(res != SQE_OK)
+ {
+ codeK->read_close();
+ return false;
+ }
+
+ // advance to next page
+ res = codeK->read_next();
+
+ if(res != SQE_OK)
+ {
+ codeK->read_close();
+ return false;
+ }
+ else
+ {
+ fmt_image *image;
+
+ image = codeK->image(0);
+ *w = image->w;
+ *h = image->h;
+ codeK->read_close();
+
+ return true;
+ }
+}
+
+/*
+ * Try to load image and store a pointer to decoded image data in m_image. Aslo
+ * store information about the image in finfo.
+ */
+bool SQ_ImageLoader::loadImage(const TQString &pixPath, const SQ_CodecSettings::settings &sett, bool multi, int nomorethan)
+{
+ SQ_LIBRARY *lib;
+ int res, current = 0, i, j;
+ RGBA *scan;
+ fmt_codec_base *codeK;
+ fmt_image *image;
+
+ finfo->image.clear();
+ finfo->meta.clear();
+
+#define SQ_SAVE_INF \
+ *finfo = codeK->information(); \
+ codeK->read_close();
+
+ // reset error count
+ m_errors = 0;
+
+ // determine library for file
+ lib = SQ_LibraryHandler::instance()->libraryForFile(pixPath);
+
+ if(!lib)
+ return false;
+
+ // determine codec
+ codeK = lib->codec_il;
+
+ if(!codeK)
+ return false;
+
+ if(sett != SQ_CodecSettings::None)
+ SQ_CodecSettings::applySettings(lib, sett);
+
+ // init...
+ res = codeK->read_init(TQString(TQFile::encodeName(pixPath)).ascii());
+
+ // error in init()!
+ if(res != SQE_OK)
+ {
+ codeK->read_close();
+ return false;
+ }
+
+ // read all pages in image...
+ while(true)
+ {
+ if(m_errors || (!multi && current) || (multi && current == nomorethan))
+ break;
+
+ // advance to next page
+ i = codeK->read_next();
+
+ // error occured while decoding first page
+ if(i != SQE_OK && i != SQE_NOTOK && !current)
+ {
+ codeK->read_close();
+ return false;
+ }
+ else if((i != SQE_OK && i != SQE_NOTOK && current) || (i == SQE_NOTOK && current))
+ break;
+
+ image = codeK->image(current);
+
+ // realloc memory
+ if(!current)
+ {
+ const int S = image->w * image->h * sizeof(RGBA);
+
+ m_image = (RGBA *)realloc(m_image, S);
+
+ if(!m_image)
+ {
+ codeK->read_close();
+ return false;
+ }
+
+ memset(m_image, 255, S);
+ }
+ else
+ {
+ dumbscan = (RGBA *)realloc(dumbscan, image->w * image->h * sizeof(RGBA));
+
+ if(!dumbscan)
+ {
+ SQ_SAVE_INF
+ return false;
+ }
+ }
+
+ // read all passes
+ for(int pass = 0;pass < image->passes;pass++)
+ {
+ codeK->read_next_pass();
+
+ if(!current)
+ {
+ for(j = 0;j < image->h;j++)
+ {
+ scan = m_image + j * image->w;
+ i = codeK->read_scanline(scan);
+ m_errors += (i != SQE_OK);
+ }
+ }
+ else
+ {
+ for(j = 0;j < image->h;j++)
+ {
+ i = codeK->read_scanline(dumbscan);
+
+ SQ_SAVE_INF
+
+ return (i == SQE_OK);
+ }
+ }
+ }
+
+ // flip decoded image, if needed
+ if(image->needflip && !current)
+ fmt_utils::flipv((char *)m_image, image->w * sizeof(RGBA), image->h);
+
+ current++;
+ }
+
+ SQ_SAVE_INF
+
+ // all done!
+ return true;
+}
+
+// Delete buffers...
+void SQ_ImageLoader::cleanup(bool del)
+{
+ if(dumbscan) free(dumbscan);
+ if(del && m_image) free(m_image);
+
+ dumbscan = 0;
+ m_image = 0;
+}
+
+/*
+ * Return decoded image as TQImage.
+ */
+TQImage SQ_ImageLoader::image() const
+{
+ TQImage image((unsigned char*)bits(), finfo->image[0].w, finfo->image[0].h, 32, 0, 0, TQImage::LittleEndian);
+
+ // if the image has alpha channel, let TQImage know it
+ if(finfo->image[0].hasalpha)
+ image.setAlphaBuffer(true);
+
+ return image.swapRGB();
+}
diff --git a/src/sq_imageloader.h b/src/sq_imageloader.h
new file mode 100644
index 0000000..409b293
--- /dev/null
+++ b/src/sq_imageloader.h
@@ -0,0 +1,108 @@
+/***************************************************************************
+ sq_imageloader.h - description
+ -------------------
+ begin : Tue Sep 20 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_IMAGELOADER_H
+#define SQ_IMAGELOADER_H
+
+#include <tqstring.h>
+#include <tqimage.h>
+#include <tqobject.h>
+
+#include "sq_codecsettings.h"
+
+struct fmt_info;
+struct RGBA;
+
+struct SQ_LIBRARY;
+
+/*
+ * SQ_ImageLoader namespace represents functions to decode images. Uses
+ * SQ_LibraryHandler. Used by SQ_EditBase (preview image) and SQ_ThumbnailLoadJob
+ * (for generating thumbnails).
+ */
+
+class SQ_ImageLoader : public TQObject
+{
+ public:
+ SQ_ImageLoader(TQObject *parent);
+ ~SQ_ImageLoader();
+
+ /*
+ * Try to load image and store a pointer to decoded image data in m_image. Aslo
+ * store information about the image in finfo.
+ *
+ * If 'multi' is true, read all image pages from file.
+ */
+ bool loadImage(const TQString &path, const SQ_CodecSettings::settings &sett, bool multi = false, int nomorethan = -1);
+
+ /*
+ * Try to determine image dimensions.
+ */
+ bool tasteImage(const TQString &path, int *w, int *h, SQ_LIBRARY *_lib = 0);
+
+ /*
+ * Remove any previously saved data.
+ */
+ void cleanup(bool del = true);
+
+ /*
+ * Direct access to image bits...
+ */
+ RGBA* bits() const;
+
+ /*
+ * Return decoded image as TQImage.
+ */
+ TQImage image() const;
+
+ /*
+ * Get a pointer to structure with information
+ * on decoded image (number of pages, width, height...)
+ */
+ fmt_info* info() const;
+
+ int errors() const;
+
+ static SQ_ImageLoader* instance() { return m_instance; }
+
+ private:
+ RGBA *m_image, *dumbscan;
+ fmt_info *finfo;
+ int m_errors;
+
+ static SQ_ImageLoader *m_instance;
+};
+
+inline
+RGBA* SQ_ImageLoader::bits() const
+{
+ return m_image;
+}
+
+inline
+fmt_info* SQ_ImageLoader::info() const
+{
+ return finfo;
+}
+
+inline
+int SQ_ImageLoader::errors() const
+{
+ return m_errors;
+}
+
+#endif
diff --git a/src/sq_imageproperties.ui b/src/sq_imageproperties.ui
new file mode 100644
index 0000000..a85d9c2
--- /dev/null
+++ b/src/sq_imageproperties.ui
@@ -0,0 +1,969 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_ImageProperties</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_ImageProperties</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>495</width>
+ <height>384</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Image properties</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>pushButton1</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ <property name="toggleButton">
+ <bool>false</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>470</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQTabWidget" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>tabWidget</cstring>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>File</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer12</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Attributes</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel4_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Owner:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel5_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Group:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textOwner</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel27_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Permissions:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="1">
+ <property name="name">
+ <cstring>textPermissions</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="1">
+ <property name="name">
+ <cstring>textGroup</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQGroupBox" row="1" column="1">
+ <property name="name">
+ <cstring>groupBox2</cstring>
+ </property>
+ <property name="title">
+ <string>Time</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Created:</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2_2_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Last read:</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel3_2_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Last modified:</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignTop</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textCreated</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="1">
+ <property name="name">
+ <cstring>textLastRead</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="1">
+ <property name="name">
+ <cstring>textLastMod</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQGroupBox" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>General</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2_3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>File:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="1">
+ <property name="name">
+ <cstring>textSize</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_4</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Directory:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel3_3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Size:</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>lineDirectory</cstring>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>lineFile</cstring>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Image</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel6_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel11_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Number of frames:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel23_2_2_2_2_3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Current frame</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel23_2_2_2_2_4</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Delay:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel7_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Dimensions:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel8_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Bits per pixel:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel9_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Color space:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel10_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Compression:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel21_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Uncompressed size:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel23_2_2_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Compression ratio:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel23_2_2_2_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Interlaced:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel23_2_2_2_2_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Status:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop|AlignRight</set>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer10</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>210</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textType</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textFrames</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textFrame</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textDelay</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textDimensions</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textBpp</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textColorModel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textCompression</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textUncompressed</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textRatio</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textInterlaced</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textStatusIcon</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textStatus</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer11</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>205</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>Metadata</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQListView" row="0" column="0">
+ <column>
+ <property name="text">
+ <string>Group</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>listMeta</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushButton1</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ImageProperties</receiver>
+ <slot>close()</slot>
+ </connection>
+ <connection>
+ <sender>listMeta</sender>
+ <signal>contextMenuRequested(TQListViewItem*,const TQPoint&amp;,int)</signal>
+ <receiver>SQ_ImageProperties</receiver>
+ <slot>slotContextMenu(TQListViewItem*,const TQPoint&amp;,int)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>tabWidget</tabstop>
+ <tabstop>lineDirectory</tabstop>
+ <tabstop>lineFile</tabstop>
+ <tabstop>listMeta</tabstop>
+ <tabstop>pushButton1</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in declaration">tqvaluevector.h</include>
+ <include location="global" impldecl="in declaration">tqvariant.h</include>
+ <include location="global" impldecl="in declaration">tqpair.h</include>
+ <include location="global" impldecl="in declaration">tqpixmap.h</include>
+ <include location="global" impldecl="in declaration">kurl.h</include>
+ <include location="global" impldecl="in declaration">tdeio/job.h</include>
+ <include location="global" impldecl="in declaration">tdefileitem.h</include>
+ <include location="global" impldecl="in implementation">tqstringlist.h</include>
+ <include location="global" impldecl="in implementation">tqfileinfo.h</include>
+ <include location="global" impldecl="in implementation">tdeio/global.h</include>
+ <include location="global" impldecl="in implementation">tdepopupmenu.h</include>
+ <include location="global" impldecl="in implementation">kstdaction.h</include>
+ <include location="global" impldecl="in implementation">tdeaction.h</include>
+ <include location="global" impldecl="in implementation">tqapplication.h</include>
+ <include location="global" impldecl="in implementation">tqclipboard.h</include>
+ <include location="global" impldecl="in implementation">tqdir.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="global" impldecl="in implementation">tqbuttongroup.h</include>
+ <include location="global" impldecl="in implementation">tdelocale.h</include>
+ <include location="local" impldecl="in implementation">sq_imageproperties.ui.h</include>
+</includes>
+<forwards>
+ <forward>class TDEPopupMenu;</forward>
+ <forward>class TDEAction;</forward>
+ <forward>namespace TDEIO { class Job; }</forward>
+</forwards>
+<variables>
+ <variable access="private">KURL url;</variable>
+ <variable access="private">TQWidget *kew;</variable>
+ <variable access="private">TQPixmap ok, error;</variable>
+ <variable access="private">TDEPopupMenu *menu;</variable>
+ <variable access="private">TQListViewItem *data;</variable>
+ <variable access="private">int z, exifMode;</variable>
+ <variable access="private">TDEAction *copy, *copyentry, *copyall;</variable>
+ <variable access="private">TQString file;</variable>
+</variables>
+<slots>
+ <slot access="private">slotContextMenu( TQListViewItem * item, const TQPoint &amp; p, int z1 )</slot>
+ <slot access="private">slotCopyString()</slot>
+ <slot access="private">slotCopyAll()</slot>
+ <slot access="private">slotCopyEntry()</slot>
+ <slot access="private" specifier="non virtual">slotModeClicked( int id )</slot>
+ <slot access="private">slotStatResult( TDEIO::Job * job )</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function access="private" specifier="non virtual">destroy()</function>
+ <function>setParams( TQStringList &amp; l )</function>
+ <function specifier="non virtual">setURL( const KURL &amp; _url )</function>
+ <function access="private">setFileParams()</function>
+ <function>setMetaInfo( TQValueVector&lt;TQPair&lt;TQString, TQString&gt; &gt; meta )</function>
+ <function specifier="non virtual">setFile( const TQString &amp; _file )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_imageproperties.ui.h b/src/sq_imageproperties.ui.h
new file mode 100644
index 0000000..5265d46
--- /dev/null
+++ b/src/sq_imageproperties.ui.h
@@ -0,0 +1,264 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+/*
+ * SQ_ImageProperties shows image properties.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef SQ_HAVE_KEXIF
+#include <libkexif/kexifwidget.h>
+#include <libkexif/kexifdata.h>
+#include <tqobjectlist.h>
+#include "sq_config.h"
+#endif
+
+void SQ_ImageProperties::init()
+{
+ menu = new TDEPopupMenu;
+ copy = KStdAction::copy(this, TQ_SLOT(slotCopyString()), 0);
+ copyentry = new TDEAction(i18n("Copy entry"), 0, this, TQ_SLOT(slotCopyEntry()), 0);
+ copyall = new TDEAction(i18n("Copy all entries"), 0, this, TQ_SLOT(slotCopyAll()), 0);
+
+ copyentry->setIcon(copy->icon());
+ copyall->setIcon(copy->icon());
+
+ copy->plug(menu);
+ copyentry->plug(menu);
+ copyall->plug(menu);
+
+ ok = SQ_IconLoader::instance()->loadIcon("ok", TDEIcon::Desktop, 16);
+ error = SQ_IconLoader::instance()->loadIcon("error", TDEIcon::Desktop, 16);
+}
+
+void SQ_ImageProperties::destroy()
+{
+#ifdef SQ_HAVE_KEXIF
+ SQ_Config::instance()->setGroup("GL view");
+ SQ_Config::instance()->writeEntry("exifmode", exifMode);
+#endif
+
+ delete copyall;
+ delete copyentry;
+ delete copy;
+ delete menu;
+}
+
+void SQ_ImageProperties::setParams(TQStringList &l)
+{
+ setFileParams();
+
+ TQStringList::Iterator it = l.begin();
+ textType->setText(*it); ++it;
+ textDimensions->setText(*it); ++it;
+ textBpp->setText(*it); ++it;
+ textColorModel->setText(*it); ++it;
+ textCompression->setText(*it); ++it;
+ textUncompressed->setText(*it); ++it;
+ textRatio->setText(*it); ++it;
+ textInterlaced->setText(*it); ++it;
+ int errors = (*it).toInt(); ++it;
+ textFrames->setText(*it); ++it;
+ textFrame->setText(*it); ++it;
+ TQString s = TQString::fromLatin1("%1").arg(i18n("1 error", "%n errors", errors));
+ textStatus->setText((errors)?s:TQString());
+ textStatusIcon->setPixmap((errors)?error:ok);
+
+ s = TQString::fromLatin1("%1%2").arg(*it).arg(i18n(" ms."));
+ textDelay->setText(s);
+}
+
+void SQ_ImageProperties::setURL(const KURL &_url)
+{
+ url = _url;
+}
+
+void SQ_ImageProperties::setFileParams()
+{
+ TDEIO::Job *stjob = TDEIO::stat(url, false);
+ connect(stjob, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotStatResult(TDEIO::Job *)));
+
+#ifdef SQ_HAVE_KEXIF
+ SQ_Config::instance()->setGroup("GL view");
+ exifMode = SQ_Config::instance()->readNumEntry("exifmode", 0);
+
+ TQWidget *tabWidgetEXIF = new TQWidget(tabWidget, "tabWidgetEXIF");
+ tabWidget->addTab(tabWidgetEXIF, i18n("EXIF"));
+ TQGridLayout *pageLayout6 = new TQGridLayout(tabWidgetEXIF, 2, 1, 11, 6, "tabWidgetEXIFLayout");
+
+ TQButtonGroup *gr = new TQButtonGroup(tabWidgetEXIF, "EXIF mode");
+ gr->setFrameShape(TQFrame::NoFrame);
+ gr->setExclusive(true);
+ connect(gr, TQ_SIGNAL(clicked(int)), this, TQ_SLOT(slotModeClicked(int)));
+
+ TQGridLayout *pageLayoutGR = new TQGridLayout(gr, 1, 3, 0, -1, "tabWidgetEXIFGRLayout");
+
+ TQPushButton *mode1 = new TQPushButton(i18n("Simple"), gr, "mode1");
+ mode1->setToggleButton(true);
+
+ TQPushButton *mode2 = new TQPushButton(i18n("Full"), gr, "mode2");
+ mode2->setToggleButton(true);
+
+ TQSpacerItem *spacer = new TQSpacerItem(15, 1, TQSizePolicy::Expanding, TQSizePolicy::Minimum);
+
+ // create KEXIF widget and load metadata from file
+ KExifWidget *kew1 = new KExifWidget(tabWidgetEXIF);
+ kew1->loadFile(file);
+
+ // hack to workaround poor libkexif API
+ TQObjectList *ch = const_cast<TQObjectList *>(kew1->children());
+ for(TQObjectList::iterator it = ch->begin();it != ch->end();++it)
+ {
+ if((*it)->inherits("TQListView"))
+ {
+ TQListView *l = dynamic_cast<TQListView *>(*it);
+ TQWidget *w = tabWidget->page(3);
+
+ if(l && w && !l->childCount())
+ tabWidget->changeTab(w, i18n("EXIF (no)"));
+
+ break;
+ }
+ }
+
+ // set proper button on
+ if(exifMode)
+ {
+ mode2->setOn(true);
+ kew1->setMode(KExifWidget::FULL);
+ }
+ else
+ {
+ mode1->setOn(true);
+ kew1->setMode(KExifWidget::SIMPLE);
+ }
+
+ // finally, add all widgets to layouts
+ pageLayoutGR->addWidget(mode1, 0, 0);
+ pageLayoutGR->addWidget(mode2, 0, 1);
+ pageLayoutGR->addItem(spacer, 0, 2);
+
+ pageLayout6->addWidget(gr, 0, 0);
+ pageLayout6->addWidget(kew1, 1, 0);
+ kew = kew1;
+#endif
+}
+
+void SQ_ImageProperties::setMetaInfo(TQValueVector<TQPair<TQString,TQString> > meta )
+{
+ TQListViewItem *after = 0, *item;
+
+ TQValueVector<TQPair<TQString,TQString> >::iterator itEnd = meta.end();
+
+ for(TQValueVector<TQPair<TQString,TQString> >::iterator it = meta.begin();it != itEnd;++it)
+ {
+ if(after)
+ item = new TQListViewItem(listMeta, after, (*it).first+TQString::fromLatin1(" "), (*it).second.replace(TQChar('\n'), TQChar(' ')));
+ else
+ after = item = new TQListViewItem(listMeta, (*it).first+TQString::fromLatin1(" "), (*it).second.replace(TQChar('\n'), TQChar(' ')));
+
+ listMeta->insertItem(item);
+ }
+
+ if(!listMeta->childCount())
+ {
+ listMeta->header()->hide();
+
+ TQWidget *w = tabWidget->page(2);
+
+ if(w)
+ tabWidget->changeTab(w, i18n("Metadata (no)"));
+ }
+}
+
+void SQ_ImageProperties::slotContextMenu( TQListViewItem *item, const TQPoint &p, int z1 )
+{
+ if(item)
+ {
+ data = item;
+ z = z1;
+ menu->exec(p);
+ }
+}
+
+void SQ_ImageProperties::slotCopyString()
+{
+ TQApplication::clipboard()->setText(data->text(z), TQClipboard::Clipboard);
+}
+
+void SQ_ImageProperties::slotCopyAll()
+{
+ if(!data)
+ return;
+
+ TQString app;
+ TQListViewItem *item = listMeta->firstChild();
+
+ for(;item;item = item->itemBelow())
+ {
+ app.append(item->text(0) + "\n" + item->text(1) + "\n");
+ }
+
+ TQApplication::clipboard()->setText(app, TQClipboard::Clipboard);
+}
+
+void SQ_ImageProperties::slotCopyEntry()
+{
+ if(!data)
+ return;
+
+ TQString app = data->text(0) + "\n" + data->text(1) + "\n";
+
+ TQApplication::clipboard()->setText(app, TQClipboard::Clipboard);
+}
+
+void SQ_ImageProperties::slotModeClicked(int id)
+{
+// change mode: simple or full
+#ifdef SQ_HAVE_KEXIF
+ exifMode = id;
+ static_cast<KExifWidget *>(kew)->setMode(id ? KExifWidget::FULL : KExifWidget::SIMPLE);
+#endif
+}
+
+void SQ_ImageProperties::slotStatResult(TDEIO::Job *job)
+{
+ if(!job->error())
+ {
+ TDEIO::UDSEntry entry = static_cast<TDEIO::StatJob*>(job)->statResult();
+ KFileItem fi(entry, url);
+
+ KURL t = url;
+ t.cd("..");
+ lineDirectory->setText(t.isLocalFile() ? t.path() : t.prettyURL());
+ lineFile->setText(fi.name());
+
+ textSize->setText(TDEIO::convertSize(fi.size()));
+ textOwner->setText(TQString("%1").arg(fi.user()));
+ textGroup->setText(TQString("%1").arg(fi.group()));
+ textPermissions->setText(fi.permissionsString());
+
+ TQDateTime abs;
+ abs.setTime_t(fi.time(TDEIO::UDS_CREATION_TIME));
+ textCreated->setText(abs.toString("dd/MM/yyyy hh:mm:ss"));
+ abs.setTime_t(fi.time(TDEIO::UDS_ACCESS_TIME));
+ textLastRead->setText(abs.toString("dd/MM/yyyy hh:mm:ss"));
+ abs.setTime_t(fi.time(TDEIO::UDS_MODIFICATION_TIME));
+ textLastMod->setText(abs.toString("dd/MM/yyyy hh:mm:ss"));
+ }
+}
+
+// set local file for KEXIF
+void SQ_ImageProperties::setFile(const TQString &_file)
+{
+ file = _file;
+}
diff --git a/src/sq_kipiinterface.cpp b/src/sq_kipiinterface.cpp
new file mode 100644
index 0000000..474ab46
--- /dev/null
+++ b/src/sq_kipiinterface.cpp
@@ -0,0 +1,209 @@
+/***************************************************************************
+ sq_kipiinterface.cpp - description
+ -------------------
+ begin : Feb 5 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "sq_kipiinterface.h"
+
+#ifdef SQ_HAVE_KIPI
+
+#include <tdefileitem.h>
+#include <tdelocale.h>
+#include <kurl.h>
+#include <tdefileview.h>
+#include <tdefileiconview.h>
+#include <kdirlister.h>
+
+#include <libkipi/imagecollectionshared.h>
+#include <libkipi/imageinfoshared.h>
+
+#include "sq_widgetstack.h"
+#include "sq_diroperator.h"
+#include "sq_imagebasket.h"
+#include "sq_hloptions.h"
+
+class SQ_KIPIImageCollection : public KIPI::ImageCollectionShared
+{
+ public:
+ SQ_KIPIImageCollection(const TQString& name, const KURL::List& images)
+ : KIPI::ImageCollectionShared(), mName(name), mImages(images)
+ {}
+
+ TQString name()
+ {
+ return mName;
+ }
+
+ TQString comment()
+ {
+ return TQString();
+ }
+
+ KURL::List images()
+ {
+ return mImages;
+ }
+
+ // FIXME: Return current URL instead
+ KURL uploadPath()
+ {
+ KURL url;
+ url.setPath("/");
+ return url;
+ }
+
+ TQString uploadRootName()
+ {
+ return i18n("Root directory");
+ }
+
+ private:
+ TQString mName;
+ KURL::List mImages;
+};
+
+/***************************************************************/
+
+class SQ_KIPIImageInfo : public KIPI::ImageInfoShared
+{
+ public:
+ SQ_KIPIImageInfo(KIPI::Interface *interface, const KURL &url)
+ : KIPI::ImageInfoShared(interface, url)
+ {}
+
+ TQString title()
+ {
+ return _url.fileName();
+ }
+
+ TQString description()
+ {
+ return TQString();
+ }
+
+ void setDescription(const TQString&)
+ {}
+
+ TQStringVariantMap attributes()
+ {
+ return TQStringVariantMap();
+ }
+
+ void clearAttributes()
+ {}
+
+ void addAttributes(const TQStringVariantMap&)
+ {}
+};
+
+
+/***************************************************************/
+
+SQ_KIPIInterface::SQ_KIPIInterface(TQWidget *parent)
+ : KIPI::Interface(parent, "KSquirrel KIPI Interface")
+{
+ connect(SQ_WidgetStack::instance()->diroperator(), TQ_SIGNAL(fileHighlighted(const KFileItem *)),
+ this, TQ_SLOT(slotSelectionChanged()));
+
+ connect(SQ_WidgetStack::instance()->diroperator()->dirLister(), TQ_SIGNAL(completed(const KURL&)),
+ this, TQ_SLOT(slotDirectoryChanged()));
+}
+
+SQ_KIPIInterface::~SQ_KIPIInterface()
+{}
+
+KIPI::ImageCollection SQ_KIPIInterface::currentAlbum()
+{
+ KURL::List list;
+
+ const KFileItemList *l = SQ_WidgetStack::instance()->diroperator()->view()->items();
+
+ if(l)
+ {
+ KFileItemListIterator it(*l);
+
+ for( ; it.current(); ++it)
+ list.append(it.current()->url());
+ }
+
+ return KIPI::ImageCollection(new SQ_KIPIImageCollection(i18n("Folder content"), list));
+}
+
+KIPI::ImageCollection SQ_KIPIInterface::currentSelection()
+{
+ KURL::List list;
+
+ const KFileItemList *l = SQ_WidgetStack::instance()->diroperator()->selectedItems();
+
+ if(l)
+ {
+ KFileItemListIterator it(*l);
+
+ for( ; it.current(); ++it)
+ list.append(it.current()->url());
+ }
+
+ return KIPI::ImageCollection(new SQ_KIPIImageCollection(i18n("Selected images"), list));
+}
+
+KIPI::ImageCollection SQ_KIPIInterface::currentBasket()
+{
+ KURL::List list;
+
+ KFileItemList l = SQ_ImageBasket::instance()->realItems();
+
+ KFileItemListIterator it(l);
+
+ for( ; it.current(); ++it)
+ list.append(it.current()->url());
+
+ return KIPI::ImageCollection(new SQ_KIPIImageCollection(i18n("Image basket"), list));
+}
+
+TQValueList<KIPI::ImageCollection> SQ_KIPIInterface::allAlbums()
+{
+ TQValueList<KIPI::ImageCollection> list;
+
+ list << currentAlbum() << currentSelection();
+
+ if(SQ_HLOptions::instance()->have_imagebasket)
+ list << currentBasket();
+
+ return list;
+}
+
+KIPI::ImageInfo SQ_KIPIInterface::info(const KURL& url)
+{
+ return KIPI::ImageInfo(new SQ_KIPIImageInfo(this, url));
+}
+
+int SQ_KIPIInterface::features() const
+{
+ return KIPI::AcceptNewImages;
+}
+
+void SQ_KIPIInterface::slotSelectionChanged()
+{
+ emit selectionChanged(SQ_WidgetStack::instance()->diroperator()->selectedItems()->count() > 0);
+}
+
+void SQ_KIPIInterface::slotDirectoryChanged()
+{
+ emit currentAlbumChanged(SQ_WidgetStack::instance()->diroperator()->numFiles() > 0);
+}
+
+#include "sq_kipiinterface.moc"
+
+#endif
diff --git a/src/sq_kipiinterface.h b/src/sq_kipiinterface.h
new file mode 100644
index 0000000..c1b9712
--- /dev/null
+++ b/src/sq_kipiinterface.h
@@ -0,0 +1,66 @@
+/***************************************************************************
+ sq_kipiinterface.h - description
+ -------------------
+ begin : Feb 5 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_KIPIINTERFACE_H
+#define SQ_KIPIINTERFACE_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef Q_MOC_RUN
+#define SQ_HAVE_KIPI
+#endif // Q_MOC_RUN
+
+#ifdef SQ_HAVE_KIPI
+
+#include <libkipi/interface.h>
+
+class SQ_KIPIInterfacePrivate;
+
+class SQ_KIPIInterface : public KIPI::Interface
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_KIPIInterface(TQWidget *parent);
+ ~SQ_KIPIInterface();
+
+ KIPI::ImageCollection currentAlbum();
+ KIPI::ImageCollection currentSelection();
+ KIPI::ImageCollection currentBasket();
+
+ TQValueList<KIPI::ImageCollection> allAlbums();
+ KIPI::ImageInfo info(const KURL &);
+ int features() const;
+ bool addImage(const KURL &, TQString &);
+
+ private slots:
+ void slotSelectionChanged();
+ void slotDirectoryChanged();
+};
+
+inline
+bool SQ_KIPIInterface::addImage(const KURL &, TQString &)
+{
+ return true;
+}
+
+#endif
+
+#endif
diff --git a/src/sq_kipimanager.cpp b/src/sq_kipimanager.cpp
new file mode 100644
index 0000000..23c7bb0
--- /dev/null
+++ b/src/sq_kipimanager.cpp
@@ -0,0 +1,189 @@
+/***************************************************************************
+ sq_kipimanager.cpp - description
+ -------------------
+ begin : Feb 5 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "sq_kipimanager.h"
+
+#ifdef SQ_HAVE_KIPI
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqwidget.h>
+
+#include <tdeactioncollection.h>
+#include <tdepopupmenu.h>
+#include <tdelocale.h>
+#include <kdebug.h>
+
+#include <libkipi/pluginloader.h>
+#include <libkipi/interface.h>
+
+#include "sq_kipiinterface.h"
+
+SQ_ActionMenu::SQ_ActionMenu(const TQString &text, TQObject *parent, const char *name)
+ : TDEActionMenu(text, parent, name)
+{}
+
+SQ_ActionMenu::SQ_ActionMenu(const TQString &text, const TQString &icon, TQObject *parent, const char *name)
+ : TDEActionMenu(text, icon, parent, name)
+{}
+
+SQ_ActionMenu::~SQ_ActionMenu()
+{
+ TQValueVector<TDEAction *>::iterator itEnd = plugged.end();
+
+ for(TQValueVector<TDEAction *>::iterator it = plugged.begin();it != itEnd;++it)
+ remove(*it);
+}
+
+void SQ_ActionMenu::insert(TDEAction *ka, int index)
+{
+ TDEActionMenu::insert(ka, index);
+
+ plugged.append(ka);
+}
+
+/***********************************************************************/
+
+SQ_KIPIManager::SQ_KIPIManager(TQWidget *_parent, const char *name) : TQObject(_parent, name), parent(_parent)
+{
+ kdDebug() << "+SQ_KIPIManager" << endl;
+
+ // Create a dummy "no plugin" action
+ noPlugin = new TDEAction(i18n("No Plugins"), 0, 0, 0, (TDEActionCollection *)0/*actionCollection()*/, "no_plugin");
+ noPlugin->setShortcutConfigurable(false);
+ noPlugin->setEnabled(false);
+
+ loaded = false;
+ p = new TDEPopupMenu;
+
+ connect(p, TQ_SIGNAL(aboutToShow()), this, TQ_SLOT(slotAboutToShow()));
+
+ SQ_KIPIInterface *interface = new SQ_KIPIInterface(_parent);
+ mPluginLoader = new KIPI::PluginLoader(TQStringList(), interface);
+ connect(mPluginLoader, TQ_SIGNAL(replug()), this, TQ_SLOT(slotReplug()));
+}
+
+SQ_KIPIManager::~SQ_KIPIManager()
+{
+ kdDebug() << "-SQ_KIPIManager" << endl;
+
+ delete mPluginLoader;
+
+ //unplug all & delete popup menu
+ clearMap();
+ delete p;
+
+ delete noPlugin;
+}
+
+void SQ_KIPIManager::loadPlugins()
+{
+ kdDebug() << "Loading KIPI plugins..." << endl;
+
+ loaded = true;
+ mPluginLoader->loadPlugins();
+
+ kdDebug() << "Done" << endl;
+}
+
+void SQ_KIPIManager::clearMap()
+{
+ // delete menus
+ for(CategoryMap::iterator it = cmenus.begin();it != cmenus.end();++it)
+ delete it.data(); // destructor will do all things for us
+
+ cmenus.clear();
+}
+
+void SQ_KIPIManager::slotReplug()
+{
+ // Fill the mActions
+ KIPI::PluginLoader::PluginList pluginList = mPluginLoader->pluginList();
+ KIPI::PluginLoader::PluginList::ConstIterator it(pluginList.begin());
+ KIPI::PluginLoader::PluginList::ConstIterator itEnd(pluginList.end());
+ KIPI::Plugin *plugin;
+ CategoryMap::iterator fnd;
+
+ clearMap();
+
+ SQ_ActionMenu *menuImages = new SQ_ActionMenu(i18n("Image actions"));
+ SQ_ActionMenu *menuEffects = new SQ_ActionMenu(i18n("Effects"));
+ SQ_ActionMenu *menuTools = new SQ_ActionMenu(i18n("Tools"));
+ SQ_ActionMenu *menuImport = new SQ_ActionMenu(i18n("Import"));
+ SQ_ActionMenu *menuExport = new SQ_ActionMenu(i18n("Export"));
+ SQ_ActionMenu *menuBatch = new SQ_ActionMenu(i18n("Batch processing"));
+ SQ_ActionMenu *menuColl = new SQ_ActionMenu(i18n("Collections"));
+
+ cmenus[KIPI::IMAGESPLUGIN] = menuImages;
+ cmenus[KIPI::EFFECTSPLUGIN] = menuEffects;
+ cmenus[KIPI::TOOLSPLUGIN] = menuTools;
+ cmenus[KIPI::IMPORTPLUGIN] = menuImport;
+ cmenus[KIPI::EXPORTPLUGIN] = menuExport;
+ cmenus[KIPI::BATCHPLUGIN] = menuBatch;
+ cmenus[KIPI::COLLECTIONSPLUGIN] = menuColl;
+
+ for( ;it != itEnd;++it)
+ {
+ if(!(*it)->shouldLoad())
+ continue;
+
+ plugin = (*it)->plugin();
+
+ if (!plugin) continue;
+
+ plugin->setup(parent);
+
+ TDEActionPtrList actions = plugin->actions();
+ TDEActionPtrList::ConstIterator actionIt = actions.begin(), end = actions.end();
+ KIPI::Category category;
+
+ for ( ;actionIt != end;++actionIt)
+ {
+ category = plugin->category(*actionIt);
+
+ fnd = cmenus.find(category);
+
+ if(fnd == cmenus.end())
+ continue;
+
+ fnd.data()->insert(*actionIt);
+ }
+
+ plugin->actionCollection()->readShortcutSettings();
+ }
+
+ // plug
+ for(CategoryMap::iterator it = cmenus.begin();it != cmenus.end();++it)
+ {
+ if(!it.data()->count())
+ it.data()->insert(noPlugin);
+
+ it.data()->plug(p);
+ }
+}
+
+void SQ_KIPIManager::slotAboutToShow()
+{
+ // load KIPI plugins on demand
+ if(!loaded) loadPlugins();
+}
+
+#include "sq_kipimanager.moc"
+
+#endif
diff --git a/src/sq_kipimanager.h b/src/sq_kipimanager.h
new file mode 100644
index 0000000..5a47a0c
--- /dev/null
+++ b/src/sq_kipimanager.h
@@ -0,0 +1,121 @@
+/***************************************************************************
+ sq_kipimanager.h - description
+ -------------------
+ begin : Feb 5 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef SQ_KIPIMANAGER_H
+#define SQ_KIPIMANAGER_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef Q_MOC_RUN
+#define SQ_HAVE_KIPI
+#endif // Q_MOC_RUN
+
+#ifdef SQ_HAVE_KIPI
+
+#include <tqmap.h>
+#include <tqvaluevector.h>
+
+#include <tdeaction.h>
+
+#include <libkipi/plugin.h>
+
+namespace KIPI { class PluginLoader; }
+
+class TQWidget;
+
+class TDEPopupMenu;
+
+/*
+ * This subclass of TDEActionMenu should know which TDEActions
+ * are currently plugged in it.
+ */
+class SQ_ActionMenu : public TDEActionMenu
+{
+ public:
+ SQ_ActionMenu(const TQString &text, TQObject *parent = 0, const char *name = 0);
+ SQ_ActionMenu(const TQString &text, const TQString &icon, TQObject *parent = 0, const char *name = 0);
+
+ /*
+ * remove() all TDEActions currently plugged.
+ */
+ ~SQ_ActionMenu();
+
+ /*
+ * Reimplement insert() to let us remember "ka"
+ */
+ void insert(TDEAction *ka, int index = -1);
+
+ int count() const;
+
+ private:
+ // Currently plugged TDEActions
+ TQValueVector<TDEAction *> plugged;
+};
+
+inline
+int SQ_ActionMenu::count() const
+{
+ return plugged.count();
+}
+
+/*
+ * KIPI plugins manager. It loads KIPI plugins and creates popup
+ * menu with all available actions.
+ */
+class SQ_KIPIManager : public TQObject
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_KIPIManager(TQWidget *_parent, const char *name = 0);
+ ~SQ_KIPIManager();
+
+ TDEPopupMenu* popup() const;
+
+ void loadPlugins();
+
+ private:
+ void clearMap();
+
+ private slots:
+ void slotReplug();
+ void slotAboutToShow();
+
+ private:
+ typedef TQMap<KIPI::Category, SQ_ActionMenu*> CategoryMap;
+
+ KIPI::PluginLoader *mPluginLoader;
+ CategoryMap cmenus;
+ TDEAction *noPlugin;
+ TQWidget *parent;
+ TDEPopupMenu *p;
+ bool loaded;
+};
+
+inline
+TDEPopupMenu* SQ_KIPIManager::popup() const
+{
+ return p;
+}
+
+#endif
+
+#endif
diff --git a/src/sq_library.h b/src/sq_library.h
new file mode 100644
index 0000000..cf350d6
--- /dev/null
+++ b/src/sq_library.h
@@ -0,0 +1,97 @@
+/***************************************************************************
+ sq_library.h - description
+ -------------------
+ begin : ��� ��� 27 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_LIBRARY_H
+#define SQ_LIBRARY_H
+
+#include <tqstring.h>
+#include <tqregexp.h>
+#include <tqpixmap.h>
+
+#include <ksquirrel-libs/fmt_defs.h>
+#include <ksquirrel-libs/settings.h>
+
+class TQLibrary;
+
+class KTempFile;
+
+class fmt_codec_base;
+
+/*
+ * SQ_LIBRARY represents a library. It contains all information
+ * needed by other classes, e.g. pointer to codec, mime image,
+ * version string, filter string, etc.
+ *
+ * Used by SQ_LibraryHandler.
+ */
+
+struct SQ_LIBRARY
+{
+ SQ_LIBRARY() : lib(0), codec(0), codec_il(0), tmp(0), tmp_il(0)
+ {}
+
+ // pointer to library
+ TQLibrary *lib;
+
+ // path to a library on disk
+ TQString libpath;
+
+ // converted regular expression
+ TQRegExp regexp;
+
+ // filter for a filemanager
+ TQString filter;
+
+ // path to config file (.ui)
+ TQString config;
+
+ fmt_settings settings;
+
+ // regular expression as string
+ TQString regexp_str;
+
+ TQString mimetype;
+
+ bool mime_multi;
+
+ // information on codec
+ TQString quickinfo;
+
+ // codec's version
+ TQString version;
+
+ // pointer to a codec
+ fmt_codec_base *codec, *codec_il;
+
+ // 'create' and 'destroy' functions.
+ // should exist in library!
+ fmt_codec_base* (*codec_create)();
+ void (*codec_destroy)(fmt_codec_base*);
+
+ TQPixmap mime;
+
+ // options for writers.
+ fmt_writeoptionsabs opt;
+
+ bool writestatic, writeanimated;
+ bool readable;
+ bool canbemultiple, needtempfile;
+
+ KTempFile *tmp, *tmp_il;
+};
+
+#endif
diff --git a/src/sq_libraryhandler.cpp b/src/sq_libraryhandler.cpp
new file mode 100644
index 0000000..3b6cf2c
--- /dev/null
+++ b/src/sq_libraryhandler.cpp
@@ -0,0 +1,582 @@
+/***************************************************************************
+ sq_libraryhandler.cpp - description
+ -------------------
+ begin : Mar 5 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqlibrary.h>
+#include <tqfileinfo.h>
+#include <tqstringlist.h>
+#include <tqfile.h>
+#include <tqdir.h>
+
+#include <kstringhandler.h>
+#include <tdetempfile.h>
+#include <tdeconfig.h>
+#include <tdelocale.h>
+#include <kdebug.h>
+#include <kurl.h>
+#include <kmimetype.h>
+
+#include "sq_libraryhandler.h"
+#include "sq_config.h"
+
+#include <ksquirrel-libs/fmt_codec_base.h>
+
+#include <iostream>
+#include <iomanip>
+
+#if !defined(QT_STRINGIFY)
+# define QT_STRINGIFY2(x) #x
+# define QT_STRINGIFY(x) QT_STRINGIFY2(x)
+#endif
+
+static const int buffer_size = 10;
+
+SQ_LibraryHandler * SQ_LibraryHandler::m_instance = 0;
+
+// SQ_LibraryHandler
+SQ_LibraryHandler::SQ_LibraryHandler(TQObject *parent)
+ : TQObject(parent), TQValueVector<SQ_LIBRARY>()
+{
+ m_instance = this;
+
+ kdDebug() << "+SQ_LibraryHandler" << endl;
+
+ tdeconf = new TDEConfig("ksquirrel-codec-settings");
+
+ load();
+}
+
+SQ_LibraryHandler::~SQ_LibraryHandler()
+{
+ clear();
+
+ delete tdeconf;
+
+ kdDebug() << "-SQ_LibraryHandler" << endl;
+}
+
+/*
+ * Find appropriate SQ_LIBRARY by filename. If
+ * not found, return NULL.
+ */
+SQ_LIBRARY* SQ_LibraryHandler::libraryForFile(const KURL &url)
+{
+ KMimeType::Ptr mime = KMimeType::findByURL(url);
+
+ iterator itEnd = end();
+
+ SQ_LIBRARY *l = 0;
+
+ // go through array and compare names
+ for(iterator it = begin();it != itEnd;++it)
+ {
+ if((*it).mime_multi)
+ {
+ if((*it).mimetype.find(mime->name()) != -1)
+ {
+ l = &(*it);
+ break;
+ }
+ }
+ else if((*it).mimetype == mime->name())
+ {
+ l = &(*it);
+ break;
+ }
+ }
+
+#if 0
+ if(l)
+ kdDebug() << KStringHandler::lsqueeze(url.prettyURL())
+ << "\" => "
+ << l->quickinfo
+ << endl;
+#endif
+
+ return l;
+}
+
+SQ_LIBRARY* SQ_LibraryHandler::libraryForFile(const TQString &path)
+{
+ KURL u;
+ u.setPath(path);
+
+ return libraryForFile(u);
+}
+
+/*
+ * Get all filters as one string.
+ */
+TQString SQ_LibraryHandler::allFiltersString() const
+{
+ TQString ret;
+
+ const_iterator itEnd = end();
+
+ // construct string
+ for(const_iterator it = begin();it != itEnd;++it)
+ {
+ if(!(*it).filter.isEmpty())
+ ret = ret + (*it).filter + ' ';
+ }
+
+ return ret;
+}
+
+TQString SQ_LibraryHandler::allFiltersFileDialogString(bool r, bool allfiles) const
+{
+ TQString ret;
+
+ const_iterator itEnd = end();
+
+ // construct string
+ for(const_iterator it = begin();it != itEnd;++it)
+ {
+ if(!r)
+ if((*it).writestatic)
+ ret = ret + (*it).filter + '|' + (*it).quickinfo + '\n';
+ else;
+ else if((*it).readable)
+ ret = ret + (*it).filter + '|' + (*it).quickinfo + '\n';
+ }
+
+ return allfiles ? (ret + "*.*|" + i18n("All files")) : ret.left(ret.length() - 1);
+}
+
+/*
+ * Fill 'filters' with all found filters, and
+ * 'quick' with appropriate information.
+ */
+void SQ_LibraryHandler::allFilters(TQStringList &filters, TQStringList &quick) const
+{
+ // clear rubbish
+ filters.clear();
+ quick.clear();
+
+ // no found libraries ?
+ if(empty())
+ return;
+
+ const_iterator itEnd = end();
+
+ // go through array and fill TQStringLists
+ for(const_iterator it = begin();it != itEnd;++it)
+ if(!(*it).filter.isEmpty())
+ {
+ filters.append((*it).filter);
+ quick.append((*it).quickinfo);
+ }
+}
+
+void SQ_LibraryHandler::allWritableFilters(TQStringList &filters, TQStringList &quick) const
+{
+ // clear rubbish
+ filters.clear();
+ quick.clear();
+
+ // no libraries ?
+ if(empty())
+ return;
+
+ const_iterator itEnd = end();
+
+ // go through array and fill TQStringLists
+ for(const_iterator it = begin();it != itEnd;++it)
+ if((*it).writestatic && !(*it).filter.isEmpty())
+ {
+ filters.append((*it).filter);
+ quick.append((*it).quickinfo);
+ }
+}
+
+/*
+ * Remove and unload all libraries.
+ */
+void SQ_LibraryHandler::clear()
+{
+ kdDebug() << "SQ_LibraryHandler::clear()" << endl;
+
+ iterator itEnd = end();
+
+ // unload libraries on clear()
+ for(iterator it = begin();it != itEnd;++it)
+ {
+ writeSettings(&(*it));
+
+ // delete temp file
+ if((*it).needtempfile)
+ {
+ delete (*it).tmp_il;
+ delete (*it).tmp;
+ }
+
+ (*it).codec_destroy((*it).codec_il);
+ (*it).codec_destroy((*it).codec);
+ delete (*it).lib;
+ (*it).lib = 0;
+ }
+
+ TQValueVector<SQ_LIBRARY>::clear();
+}
+
+/*
+ * Add new libraries.
+ */
+void SQ_LibraryHandler::add(TQStringList &foundLibraries)
+{
+ codec_options o;
+
+ TQStringList::iterator itEnd = foundLibraries.end();
+
+ for(TQStringList::iterator it = foundLibraries.begin();it != itEnd;++it)
+ {
+ TQFileInfo ff(*it);
+
+ SQ_LIBRARY libtmp;
+
+ // create TQLibrary object
+ libtmp.lib = new TQLibrary(*it);
+ libtmp.libpath = *it;
+ libtmp.lib->load();
+
+ // resolve create() and destroy() functions
+ libtmp.codec_create = (fmt_codec_base*(*)())(libtmp.lib)->resolve(TQString::fromLatin1("codec_create"));
+ libtmp.codec_destroy = (void (*)(fmt_codec_base*))(libtmp.lib)->resolve(TQString::fromLatin1("codec_destroy"));
+
+ // couldn't resolve - corrupted library ?
+ if(!libtmp.codec_create || !libtmp.codec_destroy)
+ {
+ libtmp.lib->unload();
+ delete libtmp.lib;
+ }
+ else
+ {
+ // create codec !
+ fmt_codec_base *codeK = libtmp.codec_create();
+
+ // read options
+ codeK->options(&o);
+
+ TQString q = o.name;
+
+ // Yet unknown library ?
+ if(!alreadyInMap(q))
+ {
+ libtmp.mime = TQPixmap(reinterpret_cast<const char **>(o.pixmap));
+ libtmp.mimetype = o.mimetype;
+ libtmp.mime_multi = libtmp.mimetype.find(';') != -1;
+ libtmp.quickinfo = q;
+ libtmp.filter = o.filter;
+ libtmp.version = o.version;
+ libtmp.regexp_str = o.mime;
+ libtmp.config = o.config;
+ libtmp.regexp.setPattern(libtmp.regexp_str);
+ libtmp.regexp.setCaseSensitive(true);
+ libtmp.writestatic = o.writestatic;
+ libtmp.writeanimated = o.writeanimated;
+ libtmp.readable = o.readable;
+ libtmp.canbemultiple = o.canbemultiple;
+ libtmp.needtempfile = o.needtempfile;
+ libtmp.tmp = 0;
+
+ libtmp.codec_il = libtmp.codec_create();
+
+ if(libtmp.needtempfile)
+ {
+ libtmp.tmp = new KTempFile;
+ libtmp.tmp->setAutoDelete(true);
+ libtmp.tmp->close();
+ codeK->settempfile(libtmp.tmp->name().ascii());
+
+ libtmp.tmp_il = new KTempFile;
+ libtmp.tmp_il->setAutoDelete(true);
+ libtmp.tmp_il->close();
+ libtmp.codec_il->settempfile(libtmp.tmp_il->name().ascii());
+ }
+
+ if(libtmp.writestatic)
+ codeK->getwriteoptions(&libtmp.opt);
+
+ libtmp.codec = codeK;
+
+ readSettings(&libtmp);
+
+ append(libtmp);
+ }
+ else // already known library
+ {
+ // destroy codec
+ libtmp.codec_destroy(codeK);
+
+ // unload library
+ libtmp.lib->unload();
+
+ delete libtmp.lib;
+ }
+ }
+ }
+
+ // print some information
+ dump();
+}
+
+/*
+ * Is library named 'quick' already been handled ?
+ */
+bool SQ_LibraryHandler::alreadyInMap(const TQString &quick) const
+{
+ const_iterator itEnd = end();
+
+ // go through array and find 'quick'
+ for(const_iterator it = begin();it != itEnd;++it)
+ if((*it).quickinfo == quick)
+ return true;
+
+ return false;
+}
+
+/*
+ * Print some information on found libraries.
+ */
+void SQ_LibraryHandler::dump() const
+{
+ std::cerr << "SQ_LibraryHandler: memory dump (total " << count() << ")" << endl;
+
+ const_iterator itEnd = end();
+
+ std::cerr.setf(ios::left);
+
+ for(const_iterator it = begin();it != itEnd;++it)
+ {
+ std::cerr << std::setw(30)
+ << KStringHandler::csqueeze(TQFileInfo((*it).libpath).fileName(), 30)
+ << std::setw(0)
+ << " ["
+ << KStringHandler::rsqueeze((*it).quickinfo, 45)
+ << "]"
+ << endl;
+ }
+}
+
+/*
+ * Does any of found libraries handle given extension ?
+ */
+bool SQ_LibraryHandler::knownExtension(const TQString &ext)
+{
+ iterator itEnd = end();
+
+ // go through array and compare extensions
+ for(iterator it = begin();it != itEnd;++it)
+ {
+ if((*it).filter.contains(ext, false))
+ return true;
+ }
+
+ return false;
+}
+
+/*
+ * Find appropriate SQ_LIBRARY by its name. If
+ * not found, return NULL.
+ *
+ * Name is a string, returned by fmt_quickinfo()
+ */
+SQ_LIBRARY* SQ_LibraryHandler::libraryByName(const TQString &name)
+{
+ SQ_LIBRARY *l;
+
+ iterator itEnd = end();
+
+ // go through array and compare names
+ for(iterator it = begin();it != itEnd;++it)
+ {
+ l = &(*it);
+
+ if(l->quickinfo == name)
+ return l;
+ }
+
+ return 0;
+}
+
+void SQ_LibraryHandler::writeSettings(SQ_LIBRARY *lib)
+{
+ // no config - no settings
+ if(lib->config.isEmpty())
+ return;
+
+ tdeconf->setGroup(lib->quickinfo);
+
+ fmt_settings::iterator itEnd = lib->settings.end();
+
+ TQString k;
+
+ for(fmt_settings::iterator it = lib->settings.begin();it != itEnd;++it)
+ {
+ k = (*it).first;
+
+ if((*it).second.type == settings_value::v_bool) // boolean
+ {
+ k.prepend("b");
+ tdeconf->writeEntry(k, (*it).second.bVal);
+ }
+ else if((*it).second.type == settings_value::v_int) // integer
+ {
+ k.prepend("i");
+ tdeconf->writeEntry(k, (*it).second.iVal);
+ }
+ else if((*it).second.type == settings_value::v_double) // double
+ {
+ k.prepend("d");
+ tdeconf->writeEntry(k, (*it).second.dVal);
+ }
+ else // string
+ {
+ k.prepend("s");
+ tdeconf->writeEntry(k, (*it).second.sVal);
+ }
+ }
+}
+
+void SQ_LibraryHandler::readSettings(SQ_LIBRARY *lib)
+{
+ // no config - no settings
+ if(lib->config.isEmpty())
+ return;
+
+ TQMap<TQString, TQString> map = tdeconf->entryMap(lib->quickinfo);
+
+ if(!map.size())
+ {
+ lib->codec->fill_default_settings();
+ lib->settings = lib->codec->settings();
+ return;
+ }
+
+ TQMap<TQString, TQString>::iterator mapEnd = map.end();
+ fmt_settings &sett = lib->settings;
+ TQString d, k;
+ settings_value val;
+
+ for(TQMap<TQString, TQString>::iterator mapIt = map.begin();mapIt != mapEnd;++mapIt)
+ {
+ k = mapIt.key();
+ d = mapIt.data();
+
+ if(k.startsWith(TQChar('i')))
+ {
+ val.type = settings_value::v_int;
+ val.iVal = d.toInt();
+ }
+ else if(k.startsWith(TQChar('d')))
+ {
+ val.type = settings_value::v_double;
+ val.dVal = d.toDouble();
+ }
+ else if(k.startsWith(TQChar('b')))
+ {
+ val.type = settings_value::v_bool;
+ val.bVal = (d == "true");
+ }
+ else // all other values are treated as strings
+ {
+ val.type = settings_value::v_string;
+ val.sVal = d.ascii();
+ }
+
+ k = k.right(k.length() - 1);
+ sett[k.ascii()] = val;
+ }
+
+ lib->codec->set_settings(sett);
+}
+
+void SQ_LibraryHandler::reload()
+{
+ clear();
+ load();
+}
+
+void SQ_LibraryHandler::load()
+{
+ TQStringList libs;
+
+ TQDir dir(QT_STRINGIFY(SQ_KLIBS), TQString(), TQDir::Unsorted, TQDir::Files);
+
+ const TQFileInfoList *list = dir.entryInfoList();
+
+ if(list)
+ {
+ TQFileInfoListIterator it(*list);
+ TQFileInfo *fi;
+
+ while((fi = it.current()) != 0)
+ {
+ libs.append(fi->absFilePath());
+ ++it;
+ }
+ }
+
+ // just show dump, if no libs were found
+ add(libs);
+}
+
+SQ_LibraryHandler::Support SQ_LibraryHandler::maybeSupported(const KURL &u, const TQString &mime) const
+{
+ const_iterator itEnd = constEnd();
+
+ SQ_Config::instance()->setGroup("Main");
+ bool treat = SQ_Config::instance()->readBoolEntry("treat", true);
+
+ // we can determine mimetype by hand or use "mime"
+ TQString mimeDet = mime.isEmpty() ? KMimeType::findByURL(u)->name() : mime;
+
+ // mimetype by magic is not determined automatically
+ // for non-local urls - we may support this file type or may not
+ // (we don't know exactly at this moment)
+ if(!u.isLocalFile() && mimeDet == KMimeType::defaultMimeType())
+ return (treat ? SQ_LibraryHandler::No : SQ_LibraryHandler::Maybe);
+
+ // go through array and compare mimetype names
+ for(const_iterator it = constBegin();it != itEnd;++it)
+ {
+ if((*it).mime_multi)
+ {
+ if((*it).mimetype.find(mimeDet, 0, false) != -1)
+ return SQ_LibraryHandler::Yes;
+ }
+ else if((*it).mimetype == mimeDet) // don't waste CPU time with find()
+ return SQ_LibraryHandler::Yes;
+ }
+
+ // we don't know about given mimetype
+ return SQ_LibraryHandler::No;
+}
+
+void SQ_LibraryHandler::sync()
+{
+ iterator itEnd = end();
+
+ // unload libraries on clear()
+ for(iterator it = begin();it != itEnd;++it)
+ writeSettings(&(*it));
+
+ tdeconf->sync();
+}
diff --git a/src/sq_libraryhandler.h b/src/sq_libraryhandler.h
new file mode 100644
index 0000000..8a3b25d
--- /dev/null
+++ b/src/sq_libraryhandler.h
@@ -0,0 +1,128 @@
+/***************************************************************************
+ sq_libraryhandler.h - description
+ -------------------
+ begin : Mar 5 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_LIBRARY_HANDLER_H
+#define SQ_LIBRARY_HANDLER_H
+
+#include <tqvaluevector.h>
+#include <tqdatetime.h>
+#include <tqobject.h>
+
+#include "sq_library.h"
+
+class TQStringList;
+
+class TDEConfig;
+class KURL;
+
+/*
+ * SQ_LibraryHandler is a library manager. It's the main class
+ * in library loading mechanizm.
+ */
+
+class SQ_LibraryHandler : public TQObject, public TQValueVector<SQ_LIBRARY>
+{
+ public:
+ SQ_LibraryHandler(TQObject *parent = 0);
+ ~SQ_LibraryHandler();
+
+ enum Support { Maybe = 0, Yes, No };
+
+ /*
+ * Reload libraries from disk
+ */
+ void reload();
+
+ void sync();
+
+ Support maybeSupported(const KURL &, const TQString& = TQString()) const;
+
+ /*
+ * Find appropriate SQ_LIBRARY by filename. If
+ * not found, return NULL.
+ */
+ SQ_LIBRARY* libraryForFile(const KURL &);
+ SQ_LIBRARY* libraryForFile(const TQString &);
+
+ /*
+ * Find appropriate SQ_LIBRARY by its name. If
+ * not found, return NULL.
+ *
+ * Name is a string, returned by fmt_quickinfo()
+ */
+ SQ_LIBRARY* libraryByName(const TQString &name);
+
+ /*
+ * Does any of found libraries handle given extension ?
+ */
+ bool knownExtension(const TQString &ext);
+
+ /*
+ * Fill 'filters' with all found filters, and
+ * 'quick' with appropriate information.
+ */
+ void allFilters(TQStringList &filters, TQStringList &quick) const;
+
+ void allWritableFilters(TQStringList &filters, TQStringList &quick) const;
+
+ /*
+ * Get all filters as one string.
+ */
+ TQString allFiltersString() const;
+
+ /*
+ * Filters as one string suitable for KFileDialogs.
+ * If r == true, return readable codecs
+ * If allfiles == true, append *.* to result
+ */
+ TQString allFiltersFileDialogString(bool r, bool allfiles = true) const;
+
+ /*
+ * Remove and unload all libraries.
+ */
+ void clear();
+
+ /*
+ * Print some information on found libraries.
+ */
+ void dump() const;
+
+ static SQ_LibraryHandler* instance() { return m_instance; }
+
+ private:
+
+ void add(TQStringList &foundLibraries);
+
+ /*
+ * Load libraries from disk.
+ */
+ void load();
+ /*
+ * Is library with name 'quick' already been handled ?
+ */
+ bool alreadyInMap(const TQString &quick) const;
+
+ void writeSettings(SQ_LIBRARY *lib);
+ void readSettings(SQ_LIBRARY *lib);
+
+ private:
+ TDEConfig *tdeconf;
+
+ static SQ_LibraryHandler *m_instance;
+};
+
+#endif
diff --git a/src/sq_navigatordropmenu.cpp b/src/sq_navigatordropmenu.cpp
new file mode 100644
index 0000000..efd629b
--- /dev/null
+++ b/src/sq_navigatordropmenu.cpp
@@ -0,0 +1,117 @@
+/***************************************************************************
+ sq_navigatordropmenu.cpp - description
+ -------------------
+ begin : ??? Feb 23 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tdelocale.h>
+#include <tdeaction.h>
+#include <tdeio/job.h>
+#include <kstringhandler.h>
+
+#include "ksquirrel.h"
+#include "sq_popupmenu.h"
+#include "sq_navigatordropmenu.h"
+
+SQ_NavigatorDropMenu * SQ_NavigatorDropMenu::m_instance= 0;
+
+SQ_NavigatorDropMenu::SQ_NavigatorDropMenu(TQObject *parent) : TQObject(parent)
+{
+ m_instance = this;
+
+ TDEActionCollection *ac = new TDEActionCollection(0, this, "Actions for drop menu");
+
+ dropmenu = new SQ_PopupMenu(0);
+
+ // "copy" action
+ TDEAction *pACopy = new TDEAction(i18n("Copy here"), "edit-paste", 0, this, TQ_SLOT(slotCopy()), ac, "sq_copy");
+
+ // "move" action
+ TDEAction *pAMove = new TDEAction(i18n("Move here"), 0, 0, this, TQ_SLOT(slotMove()), ac, "sq_move");
+
+ // "link" action
+ TDEAction *pALink = new TDEAction(i18n("Link here"), "www", 0, this, TQ_SLOT(slotLink()), ac, "sq_link");
+
+ // "cancel" action, this action will do nothing - just close popup menu
+ TDEAction *pACancel = new TDEAction(i18n("Cancel"), 0, 0, 0, 0, ac, "sq_cancel");
+
+ // plug all actions to popup menu
+ dropmenu->insertTitle(TQString());
+ pACopy->plug(dropmenu);
+ pAMove->plug(dropmenu);
+ pALink->plug(dropmenu);
+ dropmenu->insertSeparator();
+ pACancel->plug(dropmenu);
+}
+
+SQ_NavigatorDropMenu::~SQ_NavigatorDropMenu()
+{
+ delete dropmenu;
+}
+
+void SQ_NavigatorDropMenu::slotCopy()
+{
+ if(also) emit done(url, SQ_NavigatorDropMenu::Copy);
+
+ TDEIO::Job *job = TDEIO::copy(list, url);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotJobResult(TDEIO::Job *)));
+}
+
+void SQ_NavigatorDropMenu::slotMove()
+{
+ if(also) emit done(url, SQ_NavigatorDropMenu::Move);
+
+ TDEIO::Job *job = TDEIO::move(list, url);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotJobResult(TDEIO::Job *)));
+}
+
+void SQ_NavigatorDropMenu::slotLink()
+{
+ if(also) emit done(url, SQ_NavigatorDropMenu::Link);
+
+ TDEIO::Job *job = TDEIO::link(list, url);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotJobResult(TDEIO::Job *)));
+}
+
+void SQ_NavigatorDropMenu::slotJobResult(TDEIO::Job *job)
+{
+ if(job && job->error())
+ job->showErrorDialog(KSquirrel::app());
+}
+
+/*
+ * Save destination url and urls of dropped files.
+ */
+void SQ_NavigatorDropMenu::setupFiles(const KURL::List &l, const KURL &u)
+{
+ list = l;
+ url = u;
+
+ dropmenu->changeTitle(KStringHandler::lsqueeze(u.isLocalFile() ? u.path() : u.prettyURL(), 20));
+}
+
+/*
+ * Show popup menu with available actions.
+ */
+void SQ_NavigatorDropMenu::exec(const TQPoint &pos, bool _also)
+{
+ also = _also;
+ dropmenu->exec(pos);
+}
+
+#include "sq_navigatordropmenu.moc"
diff --git a/src/sq_navigatordropmenu.h b/src/sq_navigatordropmenu.h
new file mode 100644
index 0000000..11bef69
--- /dev/null
+++ b/src/sq_navigatordropmenu.h
@@ -0,0 +1,91 @@
+/***************************************************************************
+ sq_navigatordropmenu.h - description
+ -------------------
+ begin : ??? Feb 23 2005
+ copyright : (C) 2005 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_NAVIGATORDROPMENU_H
+#define SQ_NAVIGATORDROPMENU_H
+
+#include <tqobject.h>
+#include <tqpoint.h>
+
+#include <kurl.h>
+
+namespace TDEIO { class Job; }
+
+class SQ_PopupMenu;
+
+/*
+ * SQ_NavigatorDropMenu will help in drag-and-drop
+ * things. It creates popup menu with available actions
+ * (copy, move, ...), which will be executed by SQ_FileIconViewBase,
+ * when user dropped some files:
+ *
+ * void SQ_FileIconViewBase::slotDropped(TQDropEvent *, const KURL::List &urls, const KURL &_url)
+ * {
+ * KURL url = (_url.isEmpty()) ? SQ_WidgetStack::instance()->url() : _url;
+ *
+ * SQ_NavigatorDropMenu::instance()->setupFiles(urls, url);
+ * SQ_NavigatorDropMenu::instance()->exec(TQCursor::pos());
+ * }
+ *
+ */
+
+class SQ_NavigatorDropMenu : public TQObject
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_NavigatorDropMenu(TQObject *parent = 0);
+ ~SQ_NavigatorDropMenu();
+
+ static SQ_NavigatorDropMenu* instance() { return m_instance; }
+
+ enum FileAction { Copy = 0, Move, Link };
+
+ /*
+ * Save destination url and urls of dropped files.
+ */
+ void setupFiles(const KURL::List &l, const KURL &u);
+
+ /*
+ * Show popup menu with available actions.
+ */
+ void exec(const TQPoint &pos, bool = false);
+
+ private slots:
+ /*
+ * These slots will use TDEIO to
+ * copy, move or link files.
+ */
+ void slotCopy();
+ void slotMove();
+ void slotLink();
+ void slotJobResult(TDEIO::Job *);
+
+ signals:
+ void done(const KURL &, int);
+
+ private:
+ SQ_PopupMenu *dropmenu;
+ KURL::List list;
+ KURL url;
+ bool also;
+
+ static SQ_NavigatorDropMenu *m_instance;
+};
+
+#endif
diff --git a/src/sq_options.ui b/src/sq_options.ui
new file mode 100644
index 0000000..3efe19f
--- /dev/null
+++ b/src/sq_options.ui
@@ -0,0 +1,2108 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_Options</class>
+<author>Krasu</author>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_Options</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>437</width>
+ <height>468</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>10000</width>
+ <height>10000</height>
+ </size>
+ </property>
+ <property name="caption">
+ <string>Options</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="SQ_IconListBox" row="0" column="0">
+ <property name="name">
+ <cstring>listMain</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>400</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQWidgetStack" row="0" column="1">
+ <property name="name">
+ <cstring>widgetStack</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>pageMain</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer10</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_4</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;The main options&lt;/b&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox5</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>checkSync</cstring>
+ </property>
+ <property name="text">
+ <string>Write configuration file to disk, when I press "OK"</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>checkMinimize</cstring>
+ </property>
+ <property name="text">
+ <string>Minimize to tray after closing</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>checkSplash</cstring>
+ </property>
+ <property name="text">
+ <string>Show splash screen at startup</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="3" column="0">
+ <property name="name">
+ <cstring>checkAnime</cstring>
+ </property>
+ <property name="text">
+ <string>Don't show animated logo in toolbar</string>
+ </property>
+ </widget>
+ <widget class="TQButtonGroup" row="6" column="0">
+ <property name="name">
+ <cstring>buttonGroupCS</cstring>
+ </property>
+ <property name="title">
+ <string>Apply codec settings to</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>1</number>
+ </property>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioButton22</cstring>
+ </property>
+ <property name="text">
+ <string>Thumbnail loader</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioButton23</cstring>
+ </property>
+ <property name="text">
+ <string>Image viewer (also preview window)</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>radioButton24_2</cstring>
+ </property>
+ <property name="text">
+ <string>Both</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="3" column="0">
+ <property name="name">
+ <cstring>radioButton25_2</cstring>
+ </property>
+ <property name="text">
+ <string>RunTime</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQCheckBox" row="4" column="0">
+ <property name="name">
+ <cstring>checkTreat</cstring>
+ </property>
+ <property name="text">
+ <string>Treat unknown mime types as unsupported</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="5" column="0">
+ <property name="name">
+ <cstring>checkKIPIDemand</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Load KIPI plugins on demand (for slow machines)</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>pageFileview</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_4_3</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;Disk navigator&lt;/b&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQTabWidget" row="1" column="0">
+ <property name="name">
+ <cstring>tabNav</cstring>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Main</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>buttonGroupSetPath</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>GroupBoxPanel</enum>
+ </property>
+ <property name="title">
+ <string>On starting open...</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>1</number>
+ </property>
+ <widget class="TQRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>radioSetThis</cstring>
+ </property>
+ <property name="text">
+ <string>Custom directory:</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>2</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioSetLast</cstring>
+ </property>
+ <property name="text">
+ <string>Last visited directory</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>0</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioSetCurrent</cstring>
+ </property>
+ <property name="text">
+ <string>Current directory, where KSquirrel starts</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>1</number>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="3" column="0">
+ <property name="name">
+ <cstring>kURLReqOpenCustom</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>checkRunUnknown</cstring>
+ </property>
+ <property name="text">
+ <string>Run unknown file formats separately (with default application)</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>checkSaveHistory</cstring>
+ </property>
+ <property name="text">
+ <string>Save history</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="3" column="0">
+ <property name="name">
+ <cstring>checkSupportAr</cstring>
+ </property>
+ <property name="text">
+ <string>Jump into archives</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="4" column="0">
+ <property name="name">
+ <cstring>checkJumpFirst</cstring>
+ </property>
+ <property name="text">
+ <string>Jump to first image</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="6" column="0">
+ <property name="name">
+ <cstring>checkCalc</cstring>
+ </property>
+ <property name="text">
+ <string>Calculate directory size</string>
+ </property>
+ </widget>
+ <spacer row="8" column="0">
+ <property name="name">
+ <cstring>spacer16</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>Interface</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="4" column="0">
+ <property name="name">
+ <cstring>spacer14</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>26</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>checkTooltips</cstring>
+ </property>
+ <property name="text">
+ <string>Show tooltips with file information</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>checkDisableDirs</cstring>
+ </property>
+ <property name="text">
+ <string>Don't show directories</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>checkDrag</cstring>
+ </property>
+ <property name="text">
+ <string>Visualize drag operation</string>
+ </property>
+ </widget>
+ <widget class="TQGroupBox" row="3" column="0">
+ <property name="name">
+ <cstring>groupTooltip</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>checkInactive</cstring>
+ </property>
+ <property name="text">
+ <string>Don't show tooltips when the main window is inactive</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>checkTooltipPreview</cstring>
+ </property>
+ <property name="text">
+ <string>Show file preview</string>
+ </property>
+ </widget>
+ <widget class="KIntNumInput" row="2" column="0">
+ <property name="name">
+ <cstring>spinLines</cstring>
+ </property>
+ <property name="label">
+ <string>Number of text lines</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Clicking</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer18</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>buttonGroupSync</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="title">
+ <string>Synchronization</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>1</number>
+ </property>
+ <widget class="TQRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>radioSyncBoth</cstring>
+ </property>
+ <property name="text">
+ <string>Both</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioSyncWStackTree</cstring>
+ </property>
+ <property name="text">
+ <string>Tree &lt;- Navigator</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioSyncTreeWStack</cstring>
+ </property>
+ <property name="text">
+ <string>Tree -&gt; Navigator</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>pageThumbnails</cstring>
+ </property>
+ <attribute name="id">
+ <number>2</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_4_qqqq4</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;Thumbnails&lt;/b&gt;</string>
+ </property>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer17_3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox4</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Plain</enum>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>checkNoWriteThumbs</cstring>
+ </property>
+ <property name="text">
+ <string>Do not write thumbnails on disk</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>checkMark</cstring>
+ </property>
+ <property name="text">
+ <string>Mark supported image formats with clock icon (slow)</string>
+ </property>
+ </widget>
+ <widget class="KIntNumInput" row="3" column="0">
+ <property name="name">
+ <cstring>spinLazy</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="label">
+ <string>Delay</string>
+ </property>
+ <property name="suffix">
+ <string> ms.</string>
+ </property>
+ </widget>
+ <widget class="KIntNumInput" row="4" column="0">
+ <property name="name">
+ <cstring>spinMargin</cstring>
+ </property>
+ <property name="label">
+ <string>Margin between thumbnails</string>
+ </property>
+ <property name="suffix">
+ <string> pixels</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>checkLazy</cstring>
+ </property>
+ <property name="text">
+ <string>Lazy thumbnail generation</string>
+ </property>
+ </widget>
+ <widget class="KIntNumInput" row="6" column="0">
+ <property name="name">
+ <cstring>spinCacheSize</cstring>
+ </property>
+ <property name="label">
+ <string>Maximum cache size (in memory)</string>
+ </property>
+ <property name="suffix">
+ <string> Kb</string>
+ </property>
+ <property name="specialValueText">
+ <string>No cache</string>
+ </property>
+ </widget>
+ <widget class="KIntNumInput" row="5" column="0">
+ <property name="name">
+ <cstring>spinRows</cstring>
+ </property>
+ <property name="label">
+ <string>Number of additionally generated rows</string>
+ </property>
+ <property name="specialValueText">
+ <string>No</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>pageGL</cstring>
+ </property>
+ <attribute name="id">
+ <number>3</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQTabWidget" row="1" column="0">
+ <property name="name">
+ <cstring>tabGL</cstring>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Window</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>buttonGroupScrolling</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>On scroll event</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>1</number>
+ </property>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioSCRZoom_2</cstring>
+ </property>
+ <property name="text">
+ <string>Zoom the scene</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioSRCNext_2</cstring>
+ </property>
+ <property name="text">
+ <string>Load next/previous file</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQCheckBox" row="3" column="0">
+ <property name="name">
+ <cstring>checkProgress</cstring>
+ </property>
+ <property name="text">
+ <string>Show images progressively</string>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQButtonGroup">
+ <property name="name">
+ <cstring>buttonGroupColor</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Background</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>1</number>
+ </property>
+ <widget class="TQRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>radioColorCustomTexture</cstring>
+ </property>
+ <property name="text">
+ <string>Custom texture</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>2</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioColorCustom</cstring>
+ </property>
+ <property name="text">
+ <string>Custom color</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>1</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioColorSystem</cstring>
+ </property>
+ <property name="text">
+ <string>System color</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>0</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidgetStack">
+ <property name="name">
+ <cstring>widgetStack4</cstring>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KColorButton" row="0" column="0">
+ <property name="name">
+ <cstring>kColorSystem</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KColorButton" row="0" column="0">
+ <property name="name">
+ <cstring>kColorGLbackground</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>95</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>2</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KURLRequester" row="0" column="0">
+ <property name="name">
+ <cstring>kURLReqCustomTexture</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="TQGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox3</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>5</number>
+ </property>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushCustomValidate</cstring>
+ </property>
+ <property name="text">
+ <string>Validate</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textCustomValidate</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer16_5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>2</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQButtonGroup" row="1" column="0">
+ <property name="name">
+ <cstring>buttonGroupDC</cstring>
+ </property>
+ <property name="title">
+ <string>Double click</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>1</number>
+ </property>
+ <widget class="TQRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>radioButton27_2</cstring>
+ </property>
+ <property name="text">
+ <string>Fullscreen</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>2</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioButton28_2</cstring>
+ </property>
+ <property name="text">
+ <string>Do nothing</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>0</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioButton26_3</cstring>
+ </property>
+ <property name="text">
+ <string>Close window</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>1</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="5" column="0">
+ <property name="name">
+ <cstring>spacer16_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>2</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQCheckBox" row="4" column="0">
+ <property name="name">
+ <cstring>checkCloseAll</cstring>
+ </property>
+ <property name="text">
+ <string>Close all opened images when closing window</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>Loader</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>buttonGroupPages</cstring>
+ </property>
+ <property name="title">
+ <string>Image pages</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>1</number>
+ </property>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioButton18_2</cstring>
+ </property>
+ <property name="text">
+ <string>Load all pages</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioButton19</cstring>
+ </property>
+ <property name="text">
+ <string>Load only first page</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>radioButtonPagesNoMore</cstring>
+ </property>
+ <property name="text">
+ <string>Load no more than</string>
+ </property>
+ </widget>
+ <widget class="KIntNumInput" row="3" column="0">
+ <property name="name">
+ <cstring>pagesNumber</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="suffix">
+ <string> pages</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer13</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>50</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Image</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="4" column="0">
+ <property name="name">
+ <cstring>spacer16_4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQCheckBox" row="3" column="0">
+ <property name="name">
+ <cstring>checkMarks</cstring>
+ </property>
+ <property name="text">
+ <string>Draw tickmarks around the image</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>checkDrawQuads</cstring>
+ </property>
+ <property name="text">
+ <string>Draw background for transparent images</string>
+ </property>
+ </widget>
+ <widget class="KIntNumInput" row="0" column="0">
+ <property name="name">
+ <cstring>sliderAngle</cstring>
+ </property>
+ <property name="label">
+ <string>Rotating</string>
+ </property>
+ <property name="suffix">
+ <string> degrees</string>
+ </property>
+ </widget>
+ <widget class="KIntNumInput" row="1" column="0">
+ <property name="name">
+ <cstring>sliderMove</cstring>
+ </property>
+ <property name="label">
+ <string>Moving</string>
+ </property>
+ <property name="suffix">
+ <string> pixels</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>Zoom</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>buttonGroupZoomLimit</cstring>
+ </property>
+ <property name="title">
+ <string>Zoom limit</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>1</number>
+ </property>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioButton27</cstring>
+ </property>
+ <property name="text">
+ <string>Minimum: 1%, maximum: 10,000%</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>1</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>radioButton28</cstring>
+ </property>
+ <property name="text">
+ <string>Custom</string>
+ </property>
+ </widget>
+ <widget class="TQGroupBox" row="3" column="0">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="frameShape">
+ <enum>NoFrame</enum>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>minimum</string>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="1" column="0">
+ <property name="name">
+ <cstring>spinZoomMin</cstring>
+ </property>
+ <property name="suffix">
+ <string> %</string>
+ </property>
+ <property name="maxValue">
+ <number>100</number>
+ </property>
+ <property name="minValue">
+ <number>1</number>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>maximum</string>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="1" column="1">
+ <property name="name">
+ <cstring>spinZoomMax</cstring>
+ </property>
+ <property name="suffix">
+ <string> %</string>
+ </property>
+ <property name="maxValue">
+ <number>100000</number>
+ </property>
+ <property name="minValue">
+ <number>101</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioButton26</cstring>
+ </property>
+ <property name="text">
+ <string>No limit</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>0</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="KIntNumInput" row="1" column="0">
+ <property name="name">
+ <cstring>spinZoomFactor</cstring>
+ </property>
+ <property name="label">
+ <string>Zoom coefficient</string>
+ </property>
+ <property name="suffix">
+ <string>%</string>
+ </property>
+ <property name="specialValueText">
+ <string>None</string>
+ </property>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer19</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>Tabs</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>checkTabs</cstring>
+ </property>
+ <property name="text">
+ <string>Enable tabs</string>
+ </property>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer15_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>46</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupTabs</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>checkTabAsk</cstring>
+ </property>
+ <property name="text">
+ <string>Ask what to do when opening new image</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>checkTabClose</cstring>
+ </property>
+ <property name="text">
+ <string>Show close buttons</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_4_4</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;Customize OpenGL widget&lt;/b&gt;</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>4</number>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQTabWidget" row="1" column="0">
+ <property name="name">
+ <cstring>tabSidebar</cstring>
+ </property>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Treeview</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>buttonGroupRecurs</cstring>
+ </property>
+ <property name="title">
+ <string>Recursion</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
+ <number>1</number>
+ </property>
+ <widget class="TQRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>radioButton24</cstring>
+ </property>
+ <property name="text">
+ <string>No recursion</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>radioButton25</cstring>
+ </property>
+ <property name="text">
+ <string>Show number of files</string>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="3" column="0">
+ <property name="name">
+ <cstring>radioButton26_2</cstring>
+ </property>
+ <property name="text">
+ <string>Show number of subfolders and files</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>3</number>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>radioButton26_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Show number of subfolders</string>
+ </property>
+ <property name="buttonGroupId">
+ <number>2</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer14_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>135</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>Mount view</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>checkDevice</cstring>
+ </property>
+ <property name="text">
+ <string>Show device path</string>
+ </property>
+ </widget>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer16_6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>90</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>checkMountOptions</cstring>
+ </property>
+ <property name="text">
+ <string>Show mount options</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="1" column="0">
+ <property name="name">
+ <cstring>checkMountFS</cstring>
+ </property>
+ <property name="text">
+ <string>Show filesystem type</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>Image preview</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>preview</cstring>
+ </property>
+ <property name="text">
+ <string>Enable preview window</string>
+ </property>
+ </widget>
+ <spacer row="2" column="0">
+ <property name="name">
+ <cstring>spacer15</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBoxPreview</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KIntNumInput" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>previewDelay</cstring>
+ </property>
+ <property name="label">
+ <string>Delay before image loading</string>
+ </property>
+ <property name="suffix">
+ <string> ms</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Background color for preview widget:</string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="1" column="1">
+ <property name="name">
+ <cstring>previewColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="4" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>previewDont</cstring>
+ </property>
+ <property name="text">
+ <string>Don't load preview image on file execution</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Disables loading preview image when user launches image with mouse</string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="3" column="1">
+ <property name="name">
+ <cstring>previewTextColor</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textPreviewText</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Text color:</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>checkPreviewText</cstring>
+ </property>
+ <property name="text">
+ <string>Show image dimensions</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_4_5_2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;Sidebar settings&lt;/b&gt;</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQWidget">
+ <property name="name">
+ <cstring>WStackPage</cstring>
+ </property>
+ <attribute name="id">
+ <number>5</number>
+ </attribute>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabelKIPI</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>5</x>
+ <y>5</y>
+ <width>406</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;KIPI Configuration&lt;/b&gt;</string>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ <widget class="Line" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>line10</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>SQ_IconListBox</class>
+ <header location="local">sq_iconlistbox.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="PNG" length="1002">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154388dad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a190172af6a9690000000049454e44ae426082</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_Options</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>kURLReqCustomTexture</sender>
+ <signal>urlSelected(const TQString&amp;)</signal>
+ <receiver>SQ_Options</receiver>
+ <slot>slotNewCustomTexture(const TQString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>radioButton28</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>groupBox1</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>radioColorCustom</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>kColorGLbackground</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>radioColorCustomTexture</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>SQ_Options</receiver>
+ <slot>slotCustomTextureToggled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>radioSetThis</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>kURLReqOpenCustom</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>pushCustomValidate</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_Options</receiver>
+ <slot>slotValidateCustomTexture()</slot>
+ </connection>
+ <connection>
+ <sender>kURLReqCustomTexture</sender>
+ <signal>returnPressed(const TQString&amp;)</signal>
+ <receiver>SQ_Options</receiver>
+ <slot>slotNewCustomTexture(const TQString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>buttonGroupColor</sender>
+ <signal>clicked(int)</signal>
+ <receiver>widgetStack4</receiver>
+ <slot>raiseWidget(int)</slot>
+ </connection>
+ <connection>
+ <sender>kColorSystem</sender>
+ <signal>changed(const TQColor&amp;)</signal>
+ <receiver>SQ_Options</receiver>
+ <slot>slotSetSystemBack(const TQColor&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>radioButtonPagesNoMore</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>pagesNumber</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_Options</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>preview</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>groupBoxPreview</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>checkLazy</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>spinLazy</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>checkTooltips</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>groupTooltip</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>checkPreviewText</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>textPreviewText</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>checkPreviewText</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>previewTextColor</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>checkTabs</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>groupTabs</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>checkMinimize</tabstop>
+ <tabstop>checkSync</tabstop>
+ <tabstop>tabNav</tabstop>
+ <tabstop>radioSetLast</tabstop>
+ <tabstop>radioSetCurrent</tabstop>
+ <tabstop>radioSetThis</tabstop>
+ <tabstop>kURLReqOpenCustom</tabstop>
+ <tabstop>checkRunUnknown</tabstop>
+ <tabstop>checkSaveHistory</tabstop>
+ <tabstop>checkSupportAr</tabstop>
+ <tabstop>checkJumpFirst</tabstop>
+ <tabstop>radioSyncBoth</tabstop>
+ <tabstop>radioSyncTreeWStack</tabstop>
+ <tabstop>radioSyncWStackTree</tabstop>
+ <tabstop>checkNoWriteThumbs</tabstop>
+ <tabstop>tabGL</tabstop>
+ <tabstop>radioSCRZoom_2</tabstop>
+ <tabstop>radioSRCNext_2</tabstop>
+ <tabstop>radioColorSystem</tabstop>
+ <tabstop>radioColorCustom</tabstop>
+ <tabstop>radioColorCustomTexture</tabstop>
+ <tabstop>kURLReqCustomTexture</tabstop>
+ <tabstop>pushCustomValidate</tabstop>
+ <tabstop>checkDrawQuads</tabstop>
+ <tabstop>checkMarks</tabstop>
+ <tabstop>radioButton26</tabstop>
+ <tabstop>radioButton27</tabstop>
+ <tabstop>radioButton28</tabstop>
+ <tabstop>spinZoomMin</tabstop>
+ <tabstop>spinZoomMax</tabstop>
+ <tabstop>buttonCancel</tabstop>
+ <tabstop>kColorSystem</tabstop>
+ <tabstop>kColorGLbackground</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in declaration">tqpixmap.h</include>
+ <include location="global" impldecl="in implementation">kcolorbutton.h</include>
+ <include location="global" impldecl="in implementation">klineedit.h</include>
+ <include location="global" impldecl="in implementation">knuminput.h</include>
+ <include location="global" impldecl="in implementation">kpushbutton.h</include>
+ <include location="global" impldecl="in implementation">kstandarddirs.h</include>
+ <include location="global" impldecl="in implementation">kurlrequester.h</include>
+ <include location="local" impldecl="in implementation">sq_codecsettings.h</include>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="local" impldecl="in implementation">sq_hloptions.h</include>
+ <include location="global" impldecl="in implementation">sq_iconlistbox.h</include>
+ <include location="local" impldecl="in implementation">sq_iconlistitem.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="local" impldecl="in implementation">sq_libraryhandler.h</include>
+ <include location="local" impldecl="in implementation">sq_options.ui.h</include>
+ <include location="local" impldecl="in implementation">sq_pixmapcache.h</include>
+ <include location="local" impldecl="in implementation">sq_viewcache.h</include>
+ <include location="global" impldecl="in implementation">tqdir.h</include>
+ <include location="global" impldecl="in implementation">tqfileinfo.h</include>
+ <include location="global" impldecl="in implementation">tqimage.h</include>
+ <include location="global" impldecl="in implementation">tqmessagebox.h</include>
+</includes>
+<variables>
+ <variable>TQString custpixmap;</variable>
+ <variable>bool showlinks;</variable>
+ <variable>TQString favpixmap;</variable>
+ <variable>TQWidget *kipi;</variable>
+</variables>
+<slots>
+ <slot>slotNewCustomTexture( const TQString &amp; path )</slot>
+ <slot>slotShowPage()</slot>
+ <slot>slotCustomTextureToggled( bool en )</slot>
+ <slot>slotValidateCustomTexture()</slot>
+ <slot>paletteChange( const TQPalette &amp; oldPalette )</slot>
+ <slot>slotSetSystemBack( const TQColor &amp; )</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function returnType="int">start()</function>
+ <function returnType="bool">validPixmap( TQPixmap pix )</function>
+ <function access="private" returnType="bool">isPowerOf2( int tested )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_options.ui.h b/src/sq_options.ui.h
new file mode 100644
index 0000000..df07794
--- /dev/null
+++ b/src/sq_options.ui.h
@@ -0,0 +1,333 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+/*
+ * SQ_Options is a configuration dialog for KSquirrel.
+ */
+
+// for KIPI defs
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef SQ_HAVE_KIPI
+#include <libkipi/pluginloader.h>
+#endif
+
+void SQ_Options::init()
+{
+ buttonOk->setIconSet(SQ_IconLoader::instance()->loadIcon("ok", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ int tp;
+ SQ_Config *tdeconf = SQ_Config::instance();
+ TQColor color;
+
+ pagesNumber->setRange(1, 1000, 1, true);
+
+ tdeconf->setGroup("Main");
+
+ checkKIPIDemand->setChecked(tdeconf->readBoolEntry("kipi_ondemand", true));
+ tp = tdeconf->readNumEntry("applyto", SQ_CodecSettings::Both);
+ buttonGroupCS->setButton(tp);
+ checkMinimize->setChecked(tdeconf->readBoolEntry("minimize to tray", false));
+ checkSync->setChecked(tdeconf->readBoolEntry("sync", false));
+ checkSplash->setChecked(tdeconf->readBoolEntry("splash", true));
+ checkAnime->setChecked(tdeconf->readBoolEntry("anime_dont", false));
+ checkTreat->setChecked(tdeconf->readBoolEntry("treat", true));
+
+ KFile::Mode mode = static_cast<KFile::Mode>(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly);
+
+ tdeconf->setGroup("Fileview");
+
+ tp = tdeconf->readNumEntry("sync type", 0);
+ buttonGroupSync->setButton(tp);
+ tp = tdeconf->readNumEntry("set path", 0);
+ buttonGroupSetPath->setButton(tp);
+ kURLReqOpenCustom->setURL(tdeconf->readEntry("custom directory", "/"));
+
+ spinLines->setRange(1, 20, 1, true);
+ spinLines->setValue(tdeconf->readNumEntry("tooltips_lines", 6));
+ checkTooltipPreview->setChecked(tdeconf->readBoolEntry("tooltips_preview", false));
+ checkTooltips->setChecked(tdeconf->readBoolEntry("tooltips", false));
+ checkInactive->setChecked(tdeconf->readBoolEntry("tooltips_inactive", true));
+ checkSaveHistory->setChecked(tdeconf->readBoolEntry("history", true));
+ checkRunUnknown->setChecked(tdeconf->readBoolEntry("run unknown", false));
+ checkSupportAr->setChecked(tdeconf->readBoolEntry("archives", true));
+ checkJumpFirst->setChecked(tdeconf->readBoolEntry("tofirst", true));
+ checkDisableDirs->setChecked(tdeconf->readBoolEntry("disable_dirs", false));
+ checkCalc->setChecked(tdeconf->readBoolEntry("calculate", true));
+ checkDrag->setChecked(tdeconf->readBoolEntry("drag", true));
+
+// Init GLView page
+ tdeconf->setGroup("GL view");
+
+ TQPixmap p1;
+ checkProgress->setChecked(tdeconf->readBoolEntry("progressiv", true));
+ checkDrawQuads->setChecked(tdeconf->readBoolEntry("alpha_bkgr", true));
+ checkMarks->setChecked(tdeconf->readBoolEntry("marks", true));
+
+ // tabs
+ checkTabs->setChecked(tdeconf->readBoolEntry("tabs", false));
+ checkTabAsk->setChecked(tdeconf->readBoolEntry("tabs_ask", false));
+ checkTabClose->setChecked(tdeconf->readBoolEntry("tabs_close", true));
+ checkCloseAll->setChecked(tdeconf->readBoolEntry("closeall", false));
+
+ tp = tdeconf->readNumEntry("double_click", 0);
+ buttonGroupDC->setButton(tp);
+ tp = tdeconf->readNumEntry("load_pages", 0);
+ buttonGroupPages->setButton(tp);
+ pagesNumber->setEnabled(tp == 2);
+ tp = tdeconf->readNumEntry("load_pages_number", 1);
+ pagesNumber->setValue(tp);
+
+ tp = tdeconf->readNumEntry("GL view background type", 1);
+ buttonGroupColor->setButton(tp);
+ widgetStack4->raiseWidget(tp);
+
+ kColorSystem->setColor(colorGroup().color(TQColorGroup::Base));
+
+ tp = tdeconf->readNumEntry("zoom limit", 1);
+ buttonGroupZoomLimit->setButton(tp);
+ spinZoomMin->setValue(tdeconf->readNumEntry("zoom_min", 1));
+ spinZoomMax->setValue(tdeconf->readNumEntry("zoom_max", 10000));
+
+ custpixmap = tdeconf->readEntry("GL view custom texture", "");
+ kURLReqCustomTexture->setURL(custpixmap);
+
+ if(!custpixmap.isEmpty())
+ slotValidateCustomTexture();
+
+ tp = tdeconf->readNumEntry("scroll", 0);
+ buttonGroupScrolling->setButton(tp);
+ sliderAngle->setRange(0, 180, 1, true);
+ sliderAngle->setValue(tdeconf->readNumEntry("angle", 90));
+ spinZoomFactor->setRange(0, 300, 1, true);
+ spinZoomFactor->setValue(tdeconf->readNumEntry("zoom", 25));
+ sliderMove->setRange(1, 50, 1, true);
+ sliderMove->setValue(tdeconf->readNumEntry("move", 5));
+
+ color.setNamedColor(tdeconf->readEntry("GL view background", "#4e4e4e"));
+ kColorGLbackground->setColor(color);
+
+ tdeconf->setGroup("Sidebar");
+
+ tp = tdeconf->readNumEntry("recursion_type", 0);
+ buttonGroupRecurs->setButton(tp);
+ checkDevice->setChecked(tdeconf->readBoolEntry("mount_device", false));
+ checkMountOptions->setChecked(tdeconf->readBoolEntry("mount_options", false));
+ checkMountFS->setChecked(tdeconf->readBoolEntry("mount_fstype", true));
+ color.setNamedColor(tdeconf->readEntry("preview_background", "#4e4e4e"));
+ previewColor->setColor(color);
+ color.setNamedColor(tdeconf->readEntry("preview_text", "#ffffff"));
+ previewTextColor->setColor(color);
+ preview->setChecked(tdeconf->readBoolEntry("preview", true));
+ checkPreviewText->setChecked(tdeconf->readBoolEntry("preview_text_enable", true));
+ previewDont->setChecked(tdeconf->readBoolEntry("preview_dont", true));
+ previewDelay->setRange(50, 2000, 50, true);
+ previewDelay->setValue(tdeconf->readNumEntry("preview_delay", 400));
+
+ tdeconf->setGroup("Thumbnails");
+
+ spinCacheSize->setRange(0, 104857, 10, true);
+ spinMargin->setRange(0, 20, 1, true);
+ spinMargin->setValue(tdeconf->readNumEntry("margin", 2));
+ spinCacheSize->setValue(tdeconf->readNumEntry("cache", 1024*5));
+ checkNoWriteThumbs->setChecked(tdeconf->readBoolEntry("dont write", false));
+ checkMark->setChecked(tdeconf->readBoolEntry("mark", false));
+ checkLazy->setChecked(tdeconf->readBoolEntry("lazy", true));
+ spinLazy->setRange(10, 5000, 100, true);
+ spinLazy->setValue(tdeconf->readNumEntry("lazy_delay", 500));
+ spinRows->setRange(0, 5, 1, true);
+ spinRows->setValue(tdeconf->readNumEntry("rows", 2));
+
+ new SQ_IconListItem(listMain, SQ_IconLoader::instance()->loadIcon("display", TDEIcon::Desktop, TDEIcon::SizeMedium), i18n("General"));
+ new SQ_IconListItem(listMain, SQ_IconLoader::instance()->loadIcon("folder", TDEIcon::Desktop, TDEIcon::SizeMedium), i18n("Filing"));
+ new SQ_IconListItem(listMain, SQ_IconLoader::instance()->loadIcon("images", TDEIcon::Desktop, TDEIcon::SizeMedium), i18n("Thumbnails"));
+ new SQ_IconListItem(listMain, TQPixmap::fromMimeSource(locate("data", "images/listbox/image_win.png")), i18n("Image window"));
+ new SQ_IconListItem(listMain, SQ_IconLoader::instance()->loadIcon("penguin", TDEIcon::Desktop, TDEIcon::SizeMedium), i18n("Sidebar"));
+
+#ifdef SQ_HAVE_KIPI
+ new SQ_IconListItem(listMain, SQ_IconLoader::instance()->loadIcon("kipi", TDEIcon::Desktop, TDEIcon::SizeMedium), i18n("KIPI"));
+
+ TQWidget *pg6 = widgetStack->widget(5);
+ TQGridLayout *pageLayout6 = new TQGridLayout(pg6, 2, 1, 0, -1, "pageLayout_6");
+ kipi = new KIPI::ConfigWidget(pg6);
+ pageLayout6->addWidget(textLabelKIPI, 0, 0);
+ pageLayout6->addWidget(kipi, 1, 0);
+ checkKIPIDemand->setEnabled(true);
+#endif
+
+ listMain->updateAndInstall(this);
+
+ connect(listMain, TQ_SIGNAL(selectionChanged()), TQ_SLOT(slotShowPage()));
+
+ kURLReqOpenCustom->setMode(mode);
+
+ // restore selection page
+ tdeconf->setGroup("Main");
+ listMain->setCurrentItem(tdeconf->readNumEntry("options_last", 0));
+ tabNav->setCurrentPage(tdeconf->readNumEntry("options_last_tabNav", 0));
+ tabGL->setCurrentPage(tdeconf->readNumEntry("options_last_tabGL", 0));
+ tabSidebar->setCurrentPage(tdeconf->readNumEntry("options_last_tabSidebar", 0));
+
+ if(!SQ_HLOptions::instance()->have_mountview)
+ tabSidebar->setTabEnabled(tabSidebar->page(1), false);
+}
+
+int SQ_Options::start()
+{
+ int result = TQDialog::exec();
+
+ if(result == TQDialog::Accepted)
+ {
+#ifdef SQ_HAVE_KIPI
+ static_cast<KIPI::ConfigWidget *>(kipi)->apply();
+#endif
+
+ SQ_Config *tdeconf = SQ_Config::instance();
+
+ tdeconf->setGroup("Fileview");
+ tdeconf->writeEntry("set path", buttonGroupSetPath->selectedId());
+ tdeconf->writeEntry("custom directory", kURLReqOpenCustom->url());
+ tdeconf->writeEntry("sync type", buttonGroupSync->selectedId());
+ tdeconf->writeEntry("history", checkSaveHistory->isChecked());
+ tdeconf->writeEntry("run unknown", checkRunUnknown->isChecked());
+ tdeconf->writeEntry("archives", checkSupportAr->isChecked());
+ tdeconf->writeEntry("tofirst", checkJumpFirst->isChecked());
+ tdeconf->writeEntry("disable_dirs", checkDisableDirs->isChecked());
+ tdeconf->writeEntry("calculate", checkCalc->isChecked());
+ tdeconf->writeEntry("drag", checkDrag->isChecked());
+ tdeconf->writeEntry("tooltips", checkTooltips->isChecked());
+ tdeconf->writeEntry("tooltips_inactive", checkInactive->isChecked());
+ tdeconf->writeEntry("tooltips_lines", spinLines->value());
+ tdeconf->writeEntry("tooltips_preview", checkTooltipPreview->isChecked());
+
+ tdeconf->setGroup("Main");
+ tdeconf->writeEntry("applyto", buttonGroupCS->selectedId());
+ tdeconf->writeEntry("minimize to tray", checkMinimize->isChecked());
+ tdeconf->writeEntry("sync", checkSync->isChecked());
+ tdeconf->writeEntry("splash", checkSplash->isChecked());
+ tdeconf->writeEntry("anime_dont", checkAnime->isChecked());
+ tdeconf->writeEntry("kipi_ondemand", checkKIPIDemand->isChecked());
+ tdeconf->writeEntry("treat", checkTreat->isChecked());
+ tdeconf->writeEntry("options_last", listMain->currentItem());
+ tdeconf->writeEntry("options_last_tabGL", tabGL->currentPageIndex());
+ tdeconf->writeEntry("options_last_tabNav", tabNav->currentPageIndex());
+ tdeconf->writeEntry("options_last_tabSidebar", tabSidebar->currentPageIndex());
+
+ tdeconf->setGroup("Thumbnails");
+ tdeconf->writeEntry("margin", spinMargin->value());
+ tdeconf->writeEntry("cache", spinCacheSize->value());
+ tdeconf->writeEntry("dont write", checkNoWriteThumbs->isChecked());
+ tdeconf->writeEntry("mark", checkMark->isChecked());
+ tdeconf->writeEntry("lazy", checkLazy->isChecked());
+ tdeconf->writeEntry("lazy_delay", spinLazy->value());
+ tdeconf->writeEntry("rows", spinRows->value());
+
+ tdeconf->setGroup("GL view");
+ tdeconf->writeEntry("double_click", buttonGroupDC->selectedId());
+ tdeconf->writeEntry("load_pages", buttonGroupPages->selectedId());
+ tdeconf->writeEntry("load_pages_number", pagesNumber->value());
+ tdeconf->writeEntry("GL view background", kColorGLbackground->color().name());
+ tdeconf->writeEntry("GL view custom texture", custpixmap);
+ tdeconf->writeEntry("GL view background type", buttonGroupColor->selectedId());
+ tdeconf->writeEntry("zoom limit", buttonGroupZoomLimit->selectedId());
+ tdeconf->writeEntry("alpha_bkgr", checkDrawQuads->isChecked());
+ tdeconf->writeEntry("marks", checkMarks->isChecked());
+ tdeconf->writeEntry("progressiv", checkProgress->isChecked());
+ tdeconf->writeEntry("scroll", buttonGroupScrolling->selectedId());
+ tdeconf->writeEntry("angle", sliderAngle->value());
+ tdeconf->writeEntry("zoom", spinZoomFactor->value());
+ tdeconf->writeEntry("zoom_min", spinZoomMin->value());
+ tdeconf->writeEntry("zoom_max", spinZoomMax->value());
+ tdeconf->writeEntry("move", sliderMove->value());
+ tdeconf->writeEntry("tabs", checkTabs->isChecked());
+ tdeconf->writeEntry("tabs_ask", checkTabAsk->isChecked());
+ tdeconf->writeEntry("tabs_close", checkTabClose->isChecked());
+ tdeconf->writeEntry("closeall", checkCloseAll->isChecked());
+
+ tdeconf->setGroup("Sidebar");
+ tdeconf->writeEntry("recursion_type", buttonGroupRecurs->selectedId());
+ tdeconf->writeEntry("mount_device", checkDevice->isChecked());
+ tdeconf->writeEntry("mount_options", checkMountOptions->isChecked());
+ tdeconf->writeEntry("mount_fstype", checkMountFS->isChecked());
+ tdeconf->writeEntry("preview_background", previewColor->color().name());
+ tdeconf->writeEntry("preview_text", previewTextColor->color().name());
+ tdeconf->writeEntry("preview_text_enable", checkPreviewText->isChecked());
+ tdeconf->writeEntry("preview_delay", previewDelay->value());
+ tdeconf->writeEntry("preview_dont", previewDont->isChecked());
+ tdeconf->writeEntry("preview", preview->isChecked());
+ }
+
+ return result;
+}
+
+bool SQ_Options::validPixmap(TQPixmap pix)
+{
+ return (isPowerOf2(pix.width()) && isPowerOf2(pix.height()) && pix.width() <= 256 && pix.width() == pix.height() && !pix.isNull());
+}
+
+bool SQ_Options::isPowerOf2( int tested )
+{
+ int i = 1;
+
+ if(tested == 1)
+ return true;
+
+ for(;tested > i;i <<= 1)
+ ;
+
+ return i == tested;
+}
+
+void SQ_Options::slotNewCustomTexture( const TQString & path)
+{
+ TQPixmap p1(path);
+
+ if(validPixmap(p1))
+ {
+ custpixmap = path;
+ textCustomValidate->setText(TQString::fromLatin1("%1x%2: OK")
+ .arg(p1.width())
+ .arg(p1.height()));
+ }
+ else
+ textCustomValidate->setText(i18n("Wrong dimensions: %1x%2.")
+ .arg(p1.width())
+ .arg(p1.height()));
+}
+
+void SQ_Options::slotShowPage()
+{
+ int id = listMain->currentItem();
+
+ widgetStack->raiseWidget(id);
+}
+
+void SQ_Options::slotCustomTextureToggled( bool en)
+{
+ kURLReqCustomTexture->setEnabled(en);
+ groupBox3->setEnabled(en);
+}
+
+void SQ_Options::slotValidateCustomTexture()
+{
+ slotNewCustomTexture(kURLReqCustomTexture->url());
+}
+
+void SQ_Options::paletteChange( const TQPalette &oldPalette )
+{
+ TQDialog::paletteChange(oldPalette);
+
+ kColorSystem->setColor(colorGroup().color(TQColorGroup::Base));
+}
+
+void SQ_Options::slotSetSystemBack( const TQColor & )
+{
+ kColorSystem->setColor(colorGroup().color(TQColorGroup::Base));
+}
diff --git a/src/sq_pixmapcache.cpp b/src/sq_pixmapcache.cpp
new file mode 100644
index 0000000..6710420
--- /dev/null
+++ b/src/sq_pixmapcache.cpp
@@ -0,0 +1,167 @@
+/***************************************************************************
+ sq_pixmapcache.cpp - description
+ -------------------
+ begin : Sep 28 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_pixmapcache.h"
+#include "sq_thumbnailsize.h"
+#include "sq_dirthumbs.h"
+
+SQ_PixmapCache * SQ_PixmapCache::m_instance = 0;
+
+SQ_PixmapCache::SQ_PixmapCache(TQObject *parent, int limit)
+ : TQObject(parent), TQMap<KURL, SQ_Thumbnail>()
+{
+ m_instance = this;
+ cache_limit = limit << 10;
+
+ dir = new SQ_DirThumbs;
+
+ valid_full = false;
+}
+
+SQ_PixmapCache::~SQ_PixmapCache()
+{
+ delete dir;
+}
+
+/*
+ * Write all entries to disk and clear cache.
+ */
+void SQ_PixmapCache::sync()
+{
+ // nothing to sync
+ if(empty())
+ return;
+
+ iterator itEnd = end();
+
+ // go through array and sync each entry
+ for(iterator it = begin();it != itEnd;++it)
+ syncEntry(it.key(), it.data());
+
+ // remove all entries from cache
+ clear();
+}
+
+/*
+ * Write one entry to disk and remove it from cache.
+ */
+void SQ_PixmapCache::syncEntry(const KURL &key, SQ_Thumbnail &thumb)
+{
+ // let SQ_DirThumbs save thumbnail
+ dir->saveThumbnail(key, thumb);
+}
+
+/*
+ * Insert new entry to cache
+ */
+void SQ_PixmapCache::insert(const KURL &key, const SQ_Thumbnail &thumb)
+{
+ // thumbnail is null ?
+ if(thumb.thumbnail.isNull())
+ return;
+
+ // calc new cache size
+ last_full += entrySize(thumb);
+
+ // add new entry
+ TQMap<KURL, SQ_Thumbnail>::insert(key, thumb);
+}
+
+/*
+ * Remove entry from cache.
+ */
+void SQ_PixmapCache::removeEntry(const KURL &key)
+{
+ iterator it = find(key);
+
+ // no item to remove ?
+ if(it == end())
+ return;
+
+ last_full -= entrySize(it.data());
+
+ TQMap<KURL, SQ_Thumbnail>::remove(key);
+}
+
+/*
+ * Remove entry from cache and from disk.
+ */
+void SQ_PixmapCache::removeEntryFull(const KURL &key)
+{
+ // remove from memory
+ removeEntry(key);
+
+ // remove from disk
+ dir->removeFile(key);
+}
+
+/*
+ * Check if pixmap, represented by 'key', is already in cache.
+ */
+bool SQ_PixmapCache::contains2(const KURL &key, SQ_Thumbnail &th)
+{
+ iterator it = find(key);
+
+ // item found
+ if(it != end())
+ {
+ th = it.data();
+ return true;
+ }
+
+ // not found
+ return false;
+}
+
+/*
+ * Calculate total size used by cache (not exact!)
+ */
+int SQ_PixmapCache::totalSize()
+{
+ if(valid_full)
+ return last_full;
+
+ int total = 0;
+
+ iterator itEnd = end();
+
+ for(iterator it = begin();it != itEnd;++it)
+ {
+ total += entrySize(it.data());
+ }
+
+ last_full = total;
+ valid_full = true;
+
+ return total;
+}
+
+void SQ_PixmapCache::clear()
+{
+ valid_full = false;
+
+ TQMap<KURL, SQ_Thumbnail>::clear();
+}
+
+int SQ_PixmapCache::entrySize(const SQ_Thumbnail &th) const
+{
+ return th.thumbnail.width() * th.thumbnail.height() * 4;
+}
diff --git a/src/sq_pixmapcache.h b/src/sq_pixmapcache.h
new file mode 100644
index 0000000..3572715
--- /dev/null
+++ b/src/sq_pixmapcache.h
@@ -0,0 +1,133 @@
+/***************************************************************************
+ sq_pixmapcache.h - description
+ -------------------
+ begin : Sep 28 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_PIXMAPCACHE_H
+#define SQ_PIXMAPCACHE_H
+
+#include <tqmap.h>
+#include <tqobject.h>
+
+#include <kurl.h>
+
+#include "sq_thumbnailinfo.h"
+
+class SQ_DirThumbs;
+
+/*
+ * SQ_PixmapCache represents a simple memory cache, which
+ * stores pixmaps. It doesn't use neither TQPixmapCache nor TQCache.
+ *
+ * Uses SQ_Dir(Thumbnails) to store thumbnails on disk.
+ */
+
+class SQ_PixmapCache : public TQObject, public TQMap<KURL, SQ_Thumbnail>
+{
+ public:
+ SQ_PixmapCache(TQObject *parent, int limit = 20*1024);
+ ~SQ_PixmapCache();
+
+ /*
+ * Get maximum cache limit.
+ */
+ int cacheLimit();
+
+ /*
+ * Set cache limit, in kilobytes.
+ *
+ * 200 means ~200 Kb, 1024 - 1Mb
+ */
+ void setCacheLimit(int);
+
+ /*
+ * Write all entries to disk and clear cache.
+ */
+ void sync();
+
+ /*
+ * Write one entry to disk and remove it from cache.
+ */
+ void syncEntry(const KURL &key, SQ_Thumbnail &thumb);
+
+ /*
+ * Insert new entry to cache
+ */
+ void insert(const KURL &key, const SQ_Thumbnail &thumb);
+
+ /*
+ * Check if pixmap, represented by 'key', is already in cache.
+ */
+ bool contains2(const KURL &key, SQ_Thumbnail &th);
+
+ /*
+ * Calculate total size used by cache (not exact!)
+ */
+ int totalSize();
+
+ /*
+ * Is cache full ?
+ */
+ bool full();
+
+ /*
+ * Clear cache.
+ */
+ void clear();
+
+ /*
+ * Remove entry from cache.
+ */
+ void removeEntry(const KURL &key);
+
+ /*
+ * Remove entry from cache and from disk.
+ */
+ void removeEntryFull(const KURL &key);
+
+ static SQ_PixmapCache* instance() { return m_instance; }
+
+ private:
+ int entrySize(const SQ_Thumbnail &th) const;
+
+ private:
+ int cache_limit;
+ int last_full;
+ bool valid_full;
+ SQ_DirThumbs *dir;
+
+ static SQ_PixmapCache *m_instance;
+};
+
+inline
+int SQ_PixmapCache::cacheLimit()
+{
+ return cache_limit;
+}
+
+inline
+void SQ_PixmapCache::setCacheLimit(int n)
+{
+ cache_limit = n << 10;
+}
+
+inline
+bool SQ_PixmapCache::full()
+{
+ // when 'cache_limit' is 0, pixmap cache is always full
+ return cache_limit ? (cache_limit <= totalSize()) : true;
+}
+
+#endif
diff --git a/src/sq_pluginsinfo.ui b/src/sq_pluginsinfo.ui
new file mode 100644
index 0000000..2234d1d
--- /dev/null
+++ b/src/sq_pluginsinfo.ui
@@ -0,0 +1,272 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_PluginsInfo</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_PluginsInfo</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>604</width>
+ <height>474</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Codec information and settings</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="Line" row="2" column="0">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQListView" row="1" column="0">
+ <column>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Icon</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Library</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Version</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>MIME</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>tableLib</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="1" column="1">
+ <property name="name">
+ <cstring>textCount</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLibs1</cstring>
+ </property>
+ <property name="text">
+ <string>Directory:</string>
+ </property>
+ </widget>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>70</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Total found:</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textLibs</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQLayoutWidget" row="3" column="0">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>445</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushClose</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushClose</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_PluginsInfo</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>tableLib</sender>
+ <signal>doubleClicked(TQListViewItem*)</signal>
+ <receiver>SQ_PluginsInfo</receiver>
+ <slot>slotDoubleClicked(TQListViewItem*)</slot>
+ </connection>
+ <connection>
+ <sender>tableLib</sender>
+ <signal>mouseButtonClicked(int,TQListViewItem*,const TQPoint&amp;,int)</signal>
+ <receiver>SQ_PluginsInfo</receiver>
+ <slot>slotMouseButtonClicked(int,TQListViewItem*,const TQPoint&amp;,int)</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in implementation">sq_libraryhandler.h</include>
+ <include location="global" impldecl="in implementation">kstandarddirs.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="local" impldecl="in implementation">sq_codecsettingsskeleton.h</include>
+ <include location="global" impldecl="in implementation">ksquirrel-libs/fileio.h</include>
+ <include location="global" impldecl="in implementation">ksquirrel-libs/fmt_codec_base.h</include>
+ <include location="global" impldecl="in implementation">kstringhandler.h</include>
+ <include location="local" impldecl="in implementation">sq_pluginsinfo.ui.h</include>
+</includes>
+<slots>
+ <slot>slotDoubleClicked( TQListViewItem * i )</slot>
+ <slot>slotMouseButtonClicked( int button, TQListViewItem * i, const TQPoint &amp;, int c )</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function access="private">showLibs()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_pluginsinfo.ui.h b/src/sq_pluginsinfo.ui.h
new file mode 100644
index 0000000..bc8f05a
--- /dev/null
+++ b/src/sq_pluginsinfo.ui.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+#if !defined(QT_STRINGIFY)
+# define QT_STRINGIFY2(x) #x
+# define QT_STRINGIFY(x) QT_STRINGIFY2(x)
+#endif
+
+/*
+ * SQ_PluginsInfo shows all found by SQ_LibraryListener libraries.
+ */
+
+void SQ_PluginsInfo::init()
+{
+ tableLib->setColumnText (5, SQ_IconLoader::instance()->loadIcon("document-open", TDEIcon::Desktop, TDEIcon::SizeSmall), "");
+ tableLib->setColumnText (6, SQ_IconLoader::instance()->loadIcon("document-save", TDEIcon::Desktop, TDEIcon::SizeSmall), "");
+
+ showLibs();
+}
+
+void SQ_PluginsInfo::showLibs()
+{
+ int cnt = SQ_LibraryHandler::instance()->count();
+
+ textLibs->setText(QT_STRINGIFY(SQ_KLIBS));
+ textCount->setNum(cnt);
+
+ if(!cnt) return;
+
+ TQPixmap ok = SQ_IconLoader::instance()->loadIcon("ok", TDEIcon::Desktop, TDEIcon::SizeSmall);
+ TQPixmap configure = SQ_IconLoader::instance()->loadIcon("configure", TDEIcon::Desktop, TDEIcon::SizeSmall);
+
+ SQ_LibraryHandler::iterator itEnd = SQ_LibraryHandler::instance()->end();
+ TQListViewItem *item;
+
+ for(SQ_LibraryHandler::iterator it = SQ_LibraryHandler::instance()->begin();it != itEnd;++it)
+ {
+ item = new TQListViewItem(tableLib, TQString(), TQString(),
+ (*it).quickinfo, (*it).version,
+ KStringHandler::rsqueeze((*it).mimetype, 20));
+
+ if(!(*it).config.isEmpty())
+ item->setPixmap(0, configure);
+
+ if((*it).readable)
+ item->setPixmap(5, ok);
+
+ if((*it).writestatic)
+ item->setPixmap(6, ok);
+
+ item->setPixmap(1, (*it).mime);
+
+ tableLib->insertItem(item);
+ }
+
+ item = tableLib->firstChild();
+ tableLib->setCurrentItem(item);
+ tableLib->setSelected(item, true);
+}
+
+void SQ_PluginsInfo::slotDoubleClicked(TQListViewItem *i)
+{
+ if(!i)
+ return;
+
+ SQ_LIBRARY *lib = SQ_LibraryHandler::instance()->libraryByName(i->text(2));
+
+ if(!lib || lib->config.isEmpty())
+ return;
+
+ SQ_CodecSettingsSkeleton skel(this);
+ skel.addSettingsWidget(lib->config);
+ skel.setCodecInfo(*i->pixmap(1), i->text(2));
+ skel.adjustSize();
+ skel.exec(lib->settings);
+}
+
+void SQ_PluginsInfo::slotMouseButtonClicked(int button, TQListViewItem *i, const TQPoint &, int c)
+{
+ if(button == TQt::LeftButton && i && !c)
+ slotDoubleClicked(i);
+}
diff --git a/src/sq_popupmenu.cpp b/src/sq_popupmenu.cpp
new file mode 100644
index 0000000..553d9ef
--- /dev/null
+++ b/src/sq_popupmenu.cpp
@@ -0,0 +1,39 @@
+/***************************************************************************
+ sq_popupmenu.cpp - description
+ -------------------
+ begin : ??? June 3 2006
+ copyright : (C) 2006 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_popupmenu.h"
+
+SQ_PopupMenu::SQ_PopupMenu(TQWidget *parent, const char *name)
+ : TDEPopupMenu(parent, name), title(0)
+{}
+
+SQ_PopupMenu::~SQ_PopupMenu()
+{}
+
+void SQ_PopupMenu::insertTitle(const TQString &t)
+{
+ title = TDEPopupMenu::insertTitle(t);
+}
+
+void SQ_PopupMenu::changeTitle(const TQString &t)
+{
+ TDEPopupMenu::changeTitle(title, t);
+}
diff --git a/src/sq_popupmenu.h b/src/sq_popupmenu.h
new file mode 100644
index 0000000..efc12f2
--- /dev/null
+++ b/src/sq_popupmenu.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ sq_popupmenu.h - description
+ -------------------
+ begin : ??? June 3 2006
+ copyright : (C) 2006 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_POPUPMENU_H
+#define SQ_POPUPMENU_H
+
+#include <tdepopupmenu.h>
+
+/**
+ *@author Baryshev Dmitry
+ */
+
+class SQ_PopupMenu : public TDEPopupMenu
+{
+ public:
+ SQ_PopupMenu(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_PopupMenu();
+
+ void insertTitle(const TQString &t);
+ void changeTitle(const TQString &t);
+
+ private:
+ int title;
+};
+
+#endif
diff --git a/src/sq_progress.cpp b/src/sq_progress.cpp
new file mode 100644
index 0000000..e22455c
--- /dev/null
+++ b/src/sq_progress.cpp
@@ -0,0 +1,137 @@
+/***************************************************************************
+ sq_progress.cpp - description
+ -------------------
+ begin : ??? ??? 29 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <limits.h>
+
+#include <tqpainter.h>
+#include <tqbrush.h>
+#include <tqpen.h>
+
+#include <tdeglobalsettings.h>
+
+#include "sq_progress.h"
+
+SQ_Progress::SQ_Progress(TQWidget *parent, const char *name)
+ : TQLabel(parent, name, TQt::WNoAutoErase), m_text(true), painter(0)
+{}
+
+SQ_Progress::~SQ_Progress()
+{
+ delete painter;
+}
+
+void SQ_Progress::setTotalSteps(int totalSteps)
+{
+ total_steps = totalSteps;
+ step = 0;
+ percentage = 0;
+
+ if(!color.isValid())
+ color = TDEGlobalSettings::highlightColor();
+
+ painter = new TQPainter(this);
+ painter->setBrush(color);
+ painter->setPen(color);
+
+ TQFont f = font();
+ f.setBold(true);
+ painter->setFont(f);
+
+ painter->setPen(color);
+ painter->setBrush(TDEGlobalSettings::baseColor());
+ painter->drawRect(rect());
+}
+
+/*
+ * Internal. Set current progress to 'progress'.
+ */
+void SQ_Progress::setIndicator(int progress)
+{
+ int totalSteps = total_steps;
+
+ // scale down...
+ if(totalSteps > INT_MAX/1000)
+ {
+ progress /= 1000;
+ totalSteps /= 1000;
+ }
+
+ int np = progress * 100 / totalSteps;
+
+ // draw progress if needed
+ if(np != percentage)
+ {
+ percentage = np;
+ drawProgress();
+ }
+
+ step = progress;
+}
+
+/*
+ * Add 'step_new' to current step.
+ */
+void SQ_Progress::advance(int step_new)
+{
+ setIndicator(step + step_new);
+}
+
+/*
+ * Clear drawing.
+ */
+void SQ_Progress::flush()
+{
+ delete painter;
+ painter = 0;
+}
+
+void SQ_Progress::paintEvent(TQPaintEvent *)
+{
+ if(painter)
+ {
+ drawProgress();
+ }
+}
+
+void SQ_Progress::drawProgress()
+{
+ int np = width() * percentage / 100;
+
+ // reset clip rectangle
+ painter->setClipRect(0, 0, width(), height());
+ painter->setPen(color);
+ painter->setBrush(TDEGlobalSettings::baseColor());
+ painter->drawRect(rect());
+
+ // draw rectangle
+ painter->fillRect(2, 2, np-4, height()-4, color);
+
+ if(m_text)
+ {
+ // draw percentage value
+ painter->setPen(TDEGlobalSettings::highlightedTextColor());
+ painter->setClipRect(0, 0, np, height());
+ painter->drawText(rect(), TQt::AlignCenter | TQt::SingleLine, TQString::number(percentage) + '%');
+ painter->setPen(TDEGlobalSettings::textColor());
+ painter->setClipRect(np, 0, width()-np, height());
+ painter->drawText(rect(), TQt::AlignCenter | TQt::SingleLine, TQString::number(percentage) + '%');
+ }
+}
diff --git a/src/sq_progress.h b/src/sq_progress.h
new file mode 100644
index 0000000..b6f884a
--- /dev/null
+++ b/src/sq_progress.h
@@ -0,0 +1,99 @@
+/***************************************************************************
+ sq_progress.h - description
+ -------------------
+ begin : ??? ??? 29 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_PROGRESS_H
+#define SQ_PROGRESS_H
+
+#include <tqlabel.h>
+#include <tqcolor.h>
+
+class TQPainter;
+
+/*
+ * SQ_Progress is a simple replacement for TQProgressBar
+ */
+
+class SQ_Progress : public TQLabel
+{
+ public:
+ SQ_Progress(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_Progress();
+
+ void setTotalSteps(int totalSteps);
+ void addSteps(int steps);
+
+ void setColor(const TQColor &c); // alternative progress color
+
+ /*
+ * Set current progress to 'progress'.
+ */
+ void setIndicator(int progress);
+
+ /*
+ * Add 'step_new' to current step.
+ */
+ void advance(int step_new = 1);
+
+ /*
+ * Clear drawing.
+ */
+ void flush();
+
+ bool showText() const;
+
+ void setShowText(bool sh);
+
+ protected:
+ virtual void paintEvent(TQPaintEvent *);
+
+ private:
+ void drawProgress();
+
+ private:
+ int percentage, total_steps, step;
+ bool m_text;
+ TQColor color;
+
+ TQPainter *painter;
+};
+
+inline
+bool SQ_Progress::showText() const
+{
+ return m_text;
+}
+
+inline
+void SQ_Progress::setShowText(bool sh)
+{
+ m_text = sh;
+}
+
+inline
+void SQ_Progress::setColor(const TQColor &c)
+{
+ color = c;
+}
+
+inline
+void SQ_Progress::addSteps(int steps)
+{
+ total_steps += steps;
+ setIndicator(step);
+}
+
+#endif
diff --git a/src/sq_progressbox.cpp b/src/sq_progressbox.cpp
new file mode 100644
index 0000000..34516a3
--- /dev/null
+++ b/src/sq_progressbox.cpp
@@ -0,0 +1,59 @@
+/***************************************************************************
+ sq_progressbox.cpp - description
+ -------------------
+ begin : ??? Jan 21 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqpushbutton.h>
+
+#include "sq_iconloader.h"
+#include "sq_progressbox.h"
+
+SQ_ProgressBox::SQ_ProgressBox(TQWidget *parent, const char *name) : TQHBox(parent, name)
+{
+// TQToolBar *progressBoxBar = new TQToolBar(TQString(), NULL, this);
+ buttonStop = new TQPushButton(this);
+ buttonStop->setFlat(true);
+ buttonStop->setPixmap(SQ_IconLoader::instance()->loadIcon("media-playback-stop", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ connect(buttonStop, TQ_SIGNAL(clicked()), parent, TQ_SLOT(slotThumbnailUpdateToggle()));
+
+ // create progress bar
+ p = new SQ_Progress(this);
+
+ // setup progress bar
+ setFrameShape(TQFrame::NoFrame);
+ setSpacing(0);
+ setMargin(0);
+ setStretchFactor(p, 1);
+ setGeometry(5, 5, 160, 22);
+
+ hide();
+}
+
+SQ_ProgressBox::~SQ_ProgressBox()
+{}
+
+void SQ_ProgressBox::startButtonPixmap()
+{
+ buttonStop->setPixmap(SQ_IconLoader::instance()->loadIcon("media-playback-start", TDEIcon::Desktop, TDEIcon::SizeSmall));
+}
+
+void SQ_ProgressBox::stopButtonPixmap()
+{
+ buttonStop->setPixmap(SQ_IconLoader::instance()->loadIcon("media-playback-stop", TDEIcon::Desktop, TDEIcon::SizeSmall));
+}
diff --git a/src/sq_progressbox.h b/src/sq_progressbox.h
new file mode 100644
index 0000000..35075df
--- /dev/null
+++ b/src/sq_progressbox.h
@@ -0,0 +1,87 @@
+/***************************************************************************
+ sq_progressbox.h - description
+ -------------------
+ begin : ??? Jan 21 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_PROGRESSBOX_H
+#define SQ_PROGRESSBOX_H
+
+#include <tqhbox.h>
+
+#include "sq_progress.h"
+
+class TQPushButton;
+
+class SQ_ProgressBox : public TQHBox
+{
+ public:
+ SQ_ProgressBox(TQWidget * parent = 0, const char * name = 0);
+ ~SQ_ProgressBox();
+
+ SQ_Progress* progressBar() const;
+
+ TQPushButton* button() const;
+
+ void stopButtonPixmap();
+ void startButtonPixmap();
+
+ // redirect to SQ_Progress
+ void flush();
+ void advance(int step = 1);
+ void setTotalSteps(int steps);
+ void addSteps(int steps);
+
+ private:
+ SQ_Progress *p;
+ TQPushButton *buttonStop;
+};
+
+inline
+TQPushButton* SQ_ProgressBox::button() const
+{
+ return buttonStop;
+}
+
+inline
+SQ_Progress* SQ_ProgressBox::progressBar() const
+{
+ return p;
+}
+
+inline
+void SQ_ProgressBox::flush()
+{
+ p->flush();
+}
+
+inline
+void SQ_ProgressBox::advance(int step)
+{
+ p->advance(step);
+}
+
+inline
+void SQ_ProgressBox::setTotalSteps(int steps)
+{
+ p->setTotalSteps(steps);
+}
+
+inline
+void SQ_ProgressBox::addSteps(int steps)
+{
+ p->addSteps(steps);
+}
+
+#endif
diff --git a/src/sq_selectdeselectgroup.ui b/src/sq_selectdeselectgroup.ui
new file mode 100644
index 0000000..ba51e31
--- /dev/null
+++ b/src/sq_selectdeselectgroup.ui
@@ -0,0 +1,106 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_SelectDeselectGroup</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_SelectDeselectGroup</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>470</width>
+ <height>47</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>SQ_SelectDeselectGroup</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Filename or mask:</string>
+ </property>
+ </widget>
+ <widget class="TQComboBox" row="0" column="1">
+ <property name="name">
+ <cstring>comboMask</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="insertionPolicy">
+ <enum>AtTop</enum>
+ </property>
+ <property name="autoCompletion">
+ <bool>true</bool>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="3">
+ <property name="name">
+ <cstring>pushMask</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="2">
+ <property name="name">
+ <cstring>pushEdit</cstring>
+ </property>
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushMask</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_SelectDeselectGroup</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>pushEdit</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_SelectDeselectGroup</receiver>
+ <slot>slotEdit()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>comboMask</tabstop>
+ <tabstop>pushMask</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="local" impldecl="in implementation">sq_selectdeselectgroup.ui.h</include>
+</includes>
+<slots>
+ <slot access="private" specifier="non virtual">slotEdit()</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function returnType="int">exec( TQString &amp; mask )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_selectdeselectgroup.ui.h b/src/sq_selectdeselectgroup.ui.h
new file mode 100644
index 0000000..d67a39b
--- /dev/null
+++ b/src/sq_selectdeselectgroup.ui.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef SQ_HAVE_KREGEXP
+#include <kregexpeditorinterface.h>
+#include <tdeparts/componentfactory.h>
+#include <ktrader.h>
+#endif
+
+void SQ_SelectDeselectGroup::init()
+{
+ SQ_Config::instance()->setGroup("Fileview");
+ comboMask->insertStringList(SQ_Config::instance()->readListEntry("selectdeselecthistory"));
+
+#ifdef SQ_HAVE_KREGEXP
+ // not installed
+ if(TDETrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty())
+ pushEdit->setEnabled(false);
+#else
+ pushEdit->setEnabled(false);
+#endif
+}
+
+int SQ_SelectDeselectGroup::exec(TQString &mask)
+{
+ int result = TQDialog::exec();
+
+ if(result == TQDialog::Accepted)
+ {
+ TQStringList list;
+ int cc = comboMask->count();
+
+ for(int i = 0;i < cc;i++)
+ list.append(comboMask->text(i));
+
+ // save history
+ SQ_Config::instance()->setGroup("Fileview");
+ SQ_Config::instance()->writeEntry("selectdeselecthistory", list);
+
+ // save mask
+ mask = comboMask->currentText();
+ }
+
+ return mask.isEmpty() ? TQDialog::Rejected : result;
+}
+
+void SQ_SelectDeselectGroup::slotEdit()
+{
+#ifdef SQ_HAVE_KREGEXP
+ TQDialog *editorDialog = KParts::ComponentFactory::createInstanceFromQuery<TQDialog>("KRegExpEditor/KRegExpEditor");
+
+ if(editorDialog)
+ {
+ KRegExpEditorInterface *editor = static_cast<KRegExpEditorInterface *>(editorDialog->tqt_cast("KRegExpEditorInterface"));
+
+ Q_ASSERT(editor);
+ editor->setRegExp(comboMask->currentText());
+
+ if(editorDialog->exec())
+ {
+ comboMask->insertItem(editor->regExp());
+ comboMask->setCurrentText(editor->regExp());
+ }
+ }
+#endif
+}
diff --git a/src/sq_slideshow.ui b/src/sq_slideshow.ui
new file mode 100644
index 0000000..b3053b4
--- /dev/null
+++ b/src/sq_slideshow.ui
@@ -0,0 +1,450 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_SlideShow</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_SlideShow</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>425</width>
+ <height>350</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Slideshow options</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>220</width>
+ <height>26</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushStart</cstring>
+ </property>
+ <property name="text">
+ <string>Start</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushClose</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Directory:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <spacer row="2" column="2">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>175</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KIntSpinBox" row="3" column="1">
+ <property name="name">
+ <cstring>spinCycle</cstring>
+ </property>
+ <property name="specialValueText">
+ <string>No</string>
+ </property>
+ <property name="maxValue">
+ <number>1000</number>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="2" column="1">
+ <property name="name">
+ <cstring>spinDelay</cstring>
+ </property>
+ <property name="suffix">
+ <string> ms</string>
+ </property>
+ <property name="maxValue">
+ <number>100000</number>
+ </property>
+ <property name="minValue">
+ <number>500</number>
+ </property>
+ <property name="lineStep">
+ <number>100</number>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Delay:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textLabel1_4</cstring>
+ </property>
+ <property name="text">
+ <string>Repeats:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel1_6</cstring>
+ </property>
+ <property name="text">
+ <string>Recursively</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="1" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>checkRecurs</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="8" column="0">
+ <property name="name">
+ <cstring>textSize</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Show file size</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="6" column="0">
+ <property name="name">
+ <cstring>textPos</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Show current index</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="8" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>checkSize</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="7" column="0">
+ <property name="name">
+ <cstring>textName</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Show file name</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="6" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>checkPos</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="7" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>checkName</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="4" column="0">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Background color:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="4" column="1">
+ <property name="name">
+ <cstring>bcolor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer row="4" column="2">
+ <property name="name">
+ <cstring>spacer3_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>186</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLabel" row="5" column="0">
+ <property name="name">
+ <cstring>textLabel1_5</cstring>
+ </property>
+ <property name="text">
+ <string>Onscreen messages</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="5" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>checkMessages</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer row="9" column="2">
+ <property name="name">
+ <cstring>spacer3_2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>145</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KColorButton" row="9" column="1">
+ <property name="name">
+ <cstring>tcolor</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="9" column="0">
+ <property name="name">
+ <cstring>textColor</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Message text color:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KURLRequester">
+ <property name="name">
+ <cstring>kurl</cstring>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushCurrent</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushHistory</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>pushClose</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_SlideShow</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>pushStart</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_SlideShow</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>kurl</sender>
+ <signal>urlSelected(const TQString&amp;)</signal>
+ <receiver>SQ_SlideShow</receiver>
+ <slot>slotDirectory(const TQString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>checkMessages</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>SQ_SlideShow</receiver>
+ <slot>slotMessages(bool)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>kurl</tabstop>
+ <tabstop>spinDelay</tabstop>
+ <tabstop>spinCycle</tabstop>
+ <tabstop>pushStart</tabstop>
+ <tabstop>pushClose</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in declaration">tqstringlist.h</include>
+ <include location="global" impldecl="in implementation">kcolorbutton.h</include>
+ <include location="global" impldecl="in implementation">klineedit.h</include>
+ <include location="global" impldecl="in implementation">knuminput.h</include>
+ <include location="global" impldecl="in implementation">kpushbutton.h</include>
+ <include location="global" impldecl="in implementation">kurlrequester.h</include>
+ <include location="local" impldecl="in implementation">sq_config.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="local" impldecl="in implementation">sq_slideshow.ui.h</include>
+ <include location="local" impldecl="in implementation">sq_widgetstack.h</include>
+ <include location="global" impldecl="in implementation">tqpopupmenu.h</include>
+</includes>
+<variables>
+ <variable access="private">TQStringList items;</variable>
+</variables>
+<slots>
+ <slot access="private">slotDirectory( const TQString &amp; dir )</slot>
+ <slot access="private">slotActivated( int id )</slot>
+ <slot access="private">slotCurrent()</slot>
+ <slot access="private">slotMessages( bool b )</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function returnType="int">exec( TQString &amp; path )</function>
+ <function access="private">setPath( const TQString &amp; path )</function>
+ <function access="private">appendPath( const TQString &amp; path )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_slideshow.ui.h b/src/sq_slideshow.ui.h
new file mode 100644
index 0000000..72e8ee3
--- /dev/null
+++ b/src/sq_slideshow.ui.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+#define SQ_HIST_NUMBER 25
+
+void SQ_SlideShow::init()
+{
+ KFile::Mode mode = static_cast<KFile::Mode>(KFile::Directory | KFile::ExistingOnly);
+ kurl->setMode(mode);
+
+ SQ_Config::instance()->setGroup("Slideshow");
+
+ checkRecurs->setChecked(SQ_Config::instance()->readBoolEntry("recurs", false));
+ spinDelay->setValue(SQ_Config::instance()->readNumEntry("delay", 1000));
+ spinCycle->setValue(SQ_Config::instance()->readNumEntry("repeat", 0));
+ pushCurrent->setPixmap(SQ_IconLoader::instance()->loadIcon("folder_green", TDEIcon::Desktop, 16));
+ pushHistory->setPixmap(SQ_IconLoader::instance()->loadIcon("history", TDEIcon::Desktop, 16));
+ checkMessages->setChecked(SQ_Config::instance()->readBoolEntry("messages", true));
+ checkName->setChecked(SQ_Config::instance()->readBoolEntry("messages_name", true));
+ checkSize->setChecked(SQ_Config::instance()->readBoolEntry("messages_size", false));
+ checkPos->setChecked(SQ_Config::instance()->readBoolEntry("messages_pos", true));
+
+ TQColor col;
+ col.setNamedColor(SQ_Config::instance()->readEntry("background", "#4e4e4e"));
+ bcolor->setColor(col);
+ col.setNamedColor(SQ_Config::instance()->readEntry("message_text", "#ffffff"));
+ tcolor->setColor(col);
+
+ TQPopupMenu *hist = new TQPopupMenu;
+ items = SQ_Config::instance()->readListEntry("history");
+ int i = 0;
+
+ setPath(items.last());
+
+ for(TQStringList::iterator it = items.begin();it != items.end();++it)
+ {
+ if(i++ < SQ_HIST_NUMBER)
+ hist->insertItem(*it);
+ else
+ break;
+ }
+
+ connect(hist, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotActivated(int)));
+
+ pushHistory->setPopup(hist);
+}
+
+int SQ_SlideShow::exec(TQString &path)
+{
+ int result = TQDialog::exec();
+
+ if(result == TQDialog::Accepted)
+ {
+ // save parameters
+ SQ_Config::instance()->setGroup("Slideshow");
+ SQ_Config::instance()->writeEntry("delay", spinDelay->value());
+ SQ_Config::instance()->writeEntry("repeat", spinCycle->value());
+ SQ_Config::instance()->writeEntry("background", bcolor->color().name());
+ SQ_Config::instance()->writeEntry("message_text", tcolor->color().name());
+ SQ_Config::instance()->writeEntry("messages", checkMessages->isChecked());
+ SQ_Config::instance()->writeEntry("messages_name", checkName->isChecked());
+ SQ_Config::instance()->writeEntry("messages_size", checkSize->isChecked());
+ SQ_Config::instance()->writeEntry("messages_pos", checkPos->isChecked());
+ SQ_Config::instance()->writeEntry("history", items);
+ SQ_Config::instance()->writeEntry("recurs", checkRecurs->isChecked());
+ path = kurl->url();
+ }
+
+ return result;
+}
+
+void SQ_SlideShow::slotDirectory(const TQString &dir)
+{
+ if(!dir.isEmpty())
+ appendPath(dir);
+}
+
+void SQ_SlideShow::setPath(const TQString &path)
+{
+ kurl->setURL(path);
+}
+
+void SQ_SlideShow::slotActivated(int id)
+{
+ TQString dir = pushHistory->popup()->text(id);
+
+ if(!dir.isEmpty())
+ setPath(dir);
+}
+
+void SQ_SlideShow::appendPath(const TQString &path)
+{
+ if(items.findIndex(path) == -1)
+ {
+ items.append(path);
+ pushHistory->popup()->insertItem(path);
+
+ if(items.count() > SQ_HIST_NUMBER)
+ items.pop_front();
+ }
+}
+
+void SQ_SlideShow::slotCurrent()
+{
+ TQString path = SQ_WidgetStack::instance()->url().prettyURL();
+
+ setPath(path);
+ appendPath(path);
+}
+
+void SQ_SlideShow::slotMessages( bool b)
+{
+ checkName->setEnabled(b);
+ checkPos->setEnabled(b);
+ checkSize->setEnabled(b);
+ textName->setEnabled(b);
+ textSize->setEnabled(b);
+ textPos->setEnabled(b);
+ textColor->setEnabled(b);
+ tcolor->setEnabled(b);
+}
diff --git a/src/sq_slideshowlisting.ui b/src/sq_slideshowlisting.ui
new file mode 100644
index 0000000..7e8c5f4
--- /dev/null
+++ b/src/sq_slideshowlisting.ui
@@ -0,0 +1,111 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_SlideShowListing</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_SlideShowListing</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>490</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Form1</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="TQFrame" row="0" column="0">
+ <property name="name">
+ <cstring>frame3</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Listing</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="3">
+ <property name="name">
+ <cstring>pushCancel</cstring>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ <widget class="KSqueezedTextLabel" row="0" column="2">
+ <property name="name">
+ <cstring>textFile</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="textFormat">
+ <enum>RichText</enum>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textCount</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<includes>
+ <include location="global" impldecl="in implementation">ksqueezedtextlabel.h</include>
+ <include location="local" impldecl="in implementation">sq_slideshowlisting.ui.h</include>
+</includes>
+<signals>
+ <signal>kill();</signal>
+</signals>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function specifier="non virtual">setFile( int count, const TQString &amp; f )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_slideshowlisting.ui.h b/src/sq_slideshowlisting.ui.h
new file mode 100644
index 0000000..f0dd0e5
--- /dev/null
+++ b/src/sq_slideshowlisting.ui.h
@@ -0,0 +1,22 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** TQt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+void SQ_SlideShowListing::init()
+{
+ connect(pushCancel, TQ_SIGNAL(clicked()), this, TQ_SIGNAL(kill()));
+}
+
+void SQ_SlideShowListing::setFile(int count, const TQString &f)
+{
+ textCount->setText(TQString::fromLatin1("[%1]").arg(count));
+ textFile->setText(f);
+}
diff --git a/src/sq_slideshowwidget.cpp b/src/sq_slideshowwidget.cpp
new file mode 100644
index 0000000..167fb44
--- /dev/null
+++ b/src/sq_slideshowwidget.cpp
@@ -0,0 +1,366 @@
+/***************************************************************************
+ sq_slideshowwidget.cpp - description
+ -------------------
+ begin : ??? Mar 30 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqimage.h>
+#include <tqpainter.h>
+#include <tqtimer.h>
+#include <tqtoolbutton.h>
+#include <tqhbox.h>
+#include <tqfileinfo.h>
+#include <tqfont.h>
+#include <tqlabel.h>
+#include <tqwhatsthis.h>
+
+#include <kcursor.h>
+#include <tdelocale.h>
+#include <tdeio/global.h>
+#include <tdeglobalsettings.h>
+
+#include <ksquirrel-libs/fmt_defs.h>
+
+#include "ksquirrel.h"
+#include "sq_slideshowwidget.h"
+#include "sq_imageloader.h"
+#include "sq_iconloader.h"
+#include "sq_config.h"
+#include "sq_utils.h"
+
+#ifdef SQ_HAVE_KEXIF
+#include <libkexif/kexifdata.h>
+#include <algorithm>
+#endif
+
+SQ_SlideShowWidget * SQ_SlideShowWidget::m_inst = 0;
+
+SQ_SlideShowWidget::SQ_SlideShowWidget(TQWidget *parent, const char *name)
+ : TQWidget(parent,name, TQt::WStyle_Customize | TQt::WStyle_NoBorder | TQt::WStyle_StaysOnTop | TQt::WNoAutoErase)
+{
+ m_inst = this;
+
+ timerHide = new TQTimer(this);
+
+ message = new TQLabel(this);
+
+ TQFont f = message->font();
+ f.setPointSize(12);
+ f.setBold(true);
+ message->setFont(f);
+ message->setMargin(4);
+ message->setFrameShape(TQFrame::NoFrame);
+
+ connect(timerHide, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotHide()));
+
+ options = new TQHBox(this, "tde toolbar widget");
+ options->setSpacing(0);
+ options->setMargin(1);
+ options->move(0, 0);
+ options->hide();
+ message->hide();
+
+ int is = TDEIcon::SizeMedium;
+
+ TQToolButton *b = new TQToolButton(options);
+ b->setIconSet(SQ_IconLoader::instance()->loadIcon("go-previous", TDEIcon::Desktop, is));
+ connect(b, TQ_SIGNAL(clicked()), this, TQ_SIGNAL(previous()));
+ connect(b, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotResetPause()));
+
+ b = new TQToolButton(options);
+ b->setIconSet(SQ_IconLoader::instance()->loadIcon("go-next", TDEIcon::Desktop, is));
+ connect(b, TQ_SIGNAL(clicked()), this, TQ_SIGNAL(next()));
+ connect(b, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotResetPause()));
+
+ buttonPause = new TQToolButton(options);
+ buttonPause->setToggleButton(true);
+ buttonPause->setIconSet(SQ_IconLoader::instance()->loadIcon("media-playback-pause", TDEIcon::Desktop, is));
+ connect(buttonPause, TQ_SIGNAL(clicked()), this, TQ_SIGNAL(pause()));
+
+ b = new TQToolButton(options);
+ b->setIconSet(SQ_IconLoader::instance()->loadIcon("help", TDEIcon::Desktop, is));
+ connect(b, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotShowHelp()));
+
+ b = new TQToolButton(options);
+ b->setIconSet(SQ_IconLoader::instance()->loadIcon("cancel", TDEIcon::Desktop, is));
+ connect(b, TQ_SIGNAL(clicked()), this, TQ_SIGNAL(stopSlideShow()));
+
+ options->adjustSize();
+ message->setFixedHeight(options->height());
+
+ options->installEventFilter(this);
+
+ KCursor::setAutoHideCursor(this, true);
+ KCursor::setHideCursorDelay(2500);
+}
+
+SQ_SlideShowWidget::~SQ_SlideShowWidget()
+{}
+
+void SQ_SlideShowWidget::beginSlideShow(int totl)
+{
+ total = totl;
+
+ SQ_Config::instance()->setGroup("Slideshow");
+
+ bgcolor.setNamedColor(SQ_Config::instance()->readEntry("background", "#4e4e4e"));
+
+ messages = SQ_Config::instance()->readBoolEntry("messages", true);
+ mes_pos = SQ_Config::instance()->readBoolEntry("messages_pos", true);
+ mes_name = SQ_Config::instance()->readBoolEntry("messages_name", true);
+ mes_size = SQ_Config::instance()->readBoolEntry("messages_size", false);
+ tcolor.setNamedColor(SQ_Config::instance()->readEntry("message_text", "#ffffff"));
+
+ // fake transparency
+ message->setPaletteForegroundColor(tcolor);
+ message->setPaletteBackgroundColor(bgcolor);
+
+ show();
+ setGeometry(TDEGlobalSettings::desktopGeometry(KSquirrel::app()));
+
+ message->hide();
+ options->hide();
+
+ if(messages)
+ {
+ message->move(0, 0);
+ message->show();
+ }
+
+ path = "";
+ current = 0;
+ buttonPause->setOn(false);
+
+ setFocus();
+}
+
+void SQ_SlideShowWidget::endSlideShow()
+{
+ options->hide();
+ message->hide();
+ hide();
+
+ pixmap = TQPixmap();
+}
+
+void SQ_SlideShowWidget::loadImage(const TQString &_path, int _current)
+{
+ fmt_info *finfo;
+ RGBA *bits;
+
+ // load first page
+ bool b = SQ_ImageLoader::instance()->loadImage(_path, SQ_CodecSettings::ImageViewer);
+
+ finfo = SQ_ImageLoader::instance()->info();
+ bits = SQ_ImageLoader::instance()->bits();
+
+ // memory allocation failed in SQ_ImageLoader::loadImage()
+ if(!b || !bits || !finfo->image.size())
+ return;
+
+ path = _path;
+ current = _current;
+
+ constructMessage();
+
+ pixmap = TQPixmap();
+
+ int w = finfo->image[0].w;
+ int h = finfo->image[0].h;
+ TQImage *all = 0, *small = 0;
+
+ all = new TQImage((uchar *)bits, w, h, 32, 0, 0, TQImage::LittleEndian);
+ all->setAlphaBuffer(true);
+
+ // scale down to fit into window
+ if(w > width() || h > height())
+ {
+ small = new TQImage();
+ *small = SQ_Utils::scale(*all, width(), height(), SQ_Utils::SMOOTH_FAST, TQImage::ScaleMin);
+
+ delete all;
+ all = 0;
+
+ if(small->isNull())
+ {
+ SQ_ImageLoader::instance()->cleanup();
+ return;
+ }
+ }
+ else
+ small = all;
+
+ const int wh = small->width() * small->height();
+ unsigned char t;
+ RGBA *sk = reinterpret_cast<RGBA *>(small->bits());
+
+ // swap R and B components - TQPixmap need it
+ for(int i = 0;i < wh;i++)
+ {
+ t = (sk+i)->r;
+ (sk+i)->r = (sk+i)->b;
+ (sk+i)->b = t;
+ }
+
+#ifdef SQ_HAVE_KEXIF
+ KExifData data;
+ data.readFromFile(_path);
+ int O = data.getImageQt::Orientation();
+
+ if(O != KExifData::UNSPECIFIED && O != KExifData::NORMAL)
+ {
+ // copy original image
+ TQImage img = *small;
+
+ // rotate image
+ SQ_Utils::exifRotate(TQString(), img, O);
+
+ // transfer back
+ *small = img;
+ }
+#endif
+
+ pixmap.convertFromImage(*small);
+
+ // finally clean all memory buffers
+ SQ_ImageLoader::instance()->cleanup();
+
+ delete small;
+
+ // show loaded image
+ update();
+}
+
+void SQ_SlideShowWidget::paintEvent(TQPaintEvent *e)
+{
+ TQPainter p(this);
+
+ p.setClipRect(e->rect());
+ p.fillRect(e->rect(), bgcolor);
+
+ if(!pixmap.isNull())
+ p.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap);
+}
+
+void SQ_SlideShowWidget::closeEvent(TQCloseEvent *e)
+{
+ emit stopSlideShow();
+
+ e->ignore();
+}
+
+void SQ_SlideShowWidget::keyPressEvent(TQKeyEvent *e)
+{
+ if(e->key() == TQt::Key_Enter || e->key() == TQt::Key_Escape || e->key() == TQt::Key_Return)
+ close();
+ else if(e->key() == TQt::Key_Pause || e->key() == TQt::Key_Space)
+ {
+ buttonPause->toggle();
+ emit pause();
+ }
+ else if(e->key() == TQt::Key_PageUp)
+ emit previous();
+ else if(e->key() == TQt::Key_PageDown)
+ emit next();
+ else if(e->key() == TQt::Key_M)
+ {
+ SQ_Config::instance()->setGroup("Slideshow");
+
+ messages = SQ_Config::instance()->readBoolEntry("messages", true);
+ messages = !messages;
+ SQ_Config::instance()->writeEntry("messages", messages);
+
+ if(options->isVisible() && messages)
+ message->move(options->width()+1, 0);
+
+ constructMessage();
+
+ message->setShown(messages);
+ }
+
+ e->accept();
+}
+
+void SQ_SlideShowWidget::mouseMoveEvent(TQMouseEvent *)
+{
+ if(!options->isVisible())
+ {
+ options->show();
+ if(messages) message->move(options->width()+1, 0);
+ }
+
+ timerHide->start(1500, true);
+}
+
+void SQ_SlideShowWidget::slotHide()
+{
+ options->hide();
+
+ if(messages) message->move(0, 0);
+}
+
+bool SQ_SlideShowWidget::eventFilter(TQObject *, TQEvent *e)
+{
+ if(e->type() == TQEvent::Enter)
+ {
+ timerHide->stop();
+ return true;
+ }
+
+ return false;
+}
+
+void SQ_SlideShowWidget::slotShowHelp()
+{
+ TQWhatsThis::display(i18n(
+ "<table cellspacing=0>"
+ "<tr><td><b>Enter, Escape, Return</b></td><td>stop slideshow</td></tr>"
+ "<tr><td><b>Pause, Space</b></td><td>pause/unpause slideshow</td></tr>"
+ "<tr><td><b>Page Up</b></td><td>previous image</td></tr>"
+ "<tr><td><b>Page Down</b></td><td>next image</td></tr>"
+ "<tr><td><b>M</b></td><td>show/hide onscreen messages</td></tr>"
+ "</table>"
+ ));
+}
+
+void SQ_SlideShowWidget::constructMessage()
+{
+ // construct onscreen message
+ if(messages)
+ {
+ TQFileInfo fm(path);
+ TQString s_message;
+
+ if(mes_pos) s_message = TQString::fromLatin1("[%1/%2] ").arg(current+1).arg(total);
+
+ if(mes_name) s_message += fm.fileName();
+
+ if(mes_size)
+ s_message = (mes_name || mes_pos) ? (s_message + " (" + TDEIO::convertSize(fm.size()) + ')') : TDEIO::convertSize(fm.size());
+
+ message->setText(s_message);
+ message->adjustSize();
+ }
+}
+
+void SQ_SlideShowWidget::slotResetPause()
+{
+ buttonPause->setOn(false);
+}
+
+#include "sq_slideshowwidget.moc"
diff --git a/src/sq_slideshowwidget.h b/src/sq_slideshowwidget.h
new file mode 100644
index 0000000..d708964
--- /dev/null
+++ b/src/sq_slideshowwidget.h
@@ -0,0 +1,108 @@
+/***************************************************************************
+ sq_slideshowwidget.h - description
+ -------------------
+ begin : ??? Mar 30 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_SLIDESHOWWIDGET_H
+#define SQ_SLIDESHOWWIDGET_H
+
+#include <tqwidget.h>
+#include <tqpixmap.h>
+
+class TQTimer;
+class TQHBox;
+class TQLabel;
+class TQToolButton;
+
+/**
+ *@author Baryshev Dmitry
+ *
+ * A widget to show slideshow. It contains toolbar
+ * with some useful actions like "pause", "close", "next image" etc.
+ * It also can show onscreen message, which format is configured through
+ * "Action -> Slideshow advanced".
+ */
+
+class SQ_SlideShowWidget : public TQWidget
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_SlideShowWidget(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_SlideShowWidget();
+
+ void beginSlideShow(int totl);
+ void endSlideShow();
+ void loadImage(const TQString &path, int);
+
+ virtual bool eventFilter(TQObject * watched, TQEvent *e);
+
+ static SQ_SlideShowWidget* instance() { return m_inst; }
+
+ protected:
+ /*
+ * Draw decoded image
+ */
+ virtual void paintEvent(TQPaintEvent *);
+
+ /*
+ * Ignore close event and tell KSquirrel to stop slideshow
+ */
+ virtual void closeEvent(TQCloseEvent *);
+
+ /*
+ * Return, Escape = stop slideshow
+ * Pause, Space = pause/unpause slideshow
+ * Page Up = previous image
+ * Page Down = next image
+ */
+ virtual void keyPressEvent(TQKeyEvent *);
+
+ /*
+ * show toolbar with actions
+ */
+ virtual void mouseMoveEvent(TQMouseEvent *);
+
+ private:
+ void constructMessage();
+
+ signals:
+ void stopSlideShow();
+ void pause();
+ void next();
+ void previous();
+
+ private slots:
+ void slotHide();
+ void slotShowHelp();
+ void slotResetPause();
+
+ private:
+ TQString path;
+ int current;
+ TQPixmap pixmap;
+ TQColor bgcolor, tcolor;
+ TQTimer *timerHide;
+ TQLabel *message;
+ TQHBox *options;
+ bool messages, mes_name, mes_size, mes_pos;
+ int total;
+ TQToolButton *buttonPause;
+
+ static SQ_SlideShowWidget *m_inst;
+};
+
+#endif
diff --git a/src/sq_splashscreen.cpp b/src/sq_splashscreen.cpp
new file mode 100644
index 0000000..95ce99e
--- /dev/null
+++ b/src/sq_splashscreen.cpp
@@ -0,0 +1,107 @@
+/*
+ * (C) 2006 Baryshev Dmitry, KSquirrel project.
+ * Originally based on kstartuplogo.cpp from KDEvelop project
+ */
+
+/***************************************************************************
+ kstartuplogo.cpp - description
+ -------------------
+ artwork : KDevelop Project / Ralf Nolden <[email protected]>
+ begin : Mon Oct 1 2001
+ copyright : (C) 2001 by Kai Heitkamp
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *
+ * USA. *
+ * *
+ * For license exceptions see LICENSE.EXC file, attached with the source *
+ * code. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tdeglobalsettings.h>
+#include <kstandarddirs.h>
+#include <kprogress.h>
+#include <kdebug.h>
+
+#include "sq_splashscreen.h"
+#include "sq_progress.h"
+
+SQ_SplashScreen * SQ_SplashScreen::m_inst = 0;
+
+SQ_SplashScreen::SQ_SplashScreen(TQWidget * parent, const char *name)
+ : TQWidget(parent, name,
+ TQt::WStyle_Customize |
+ TQt::WStyle_NoBorder |
+ TQt::WStyle_StaysOnTop |
+ TQt::WDestructiveClose |
+ TQt::WX11BypassWM)
+{
+ kdDebug() << "+SQ_SplashScreen" << endl;
+
+ m_inst = this;
+
+ TQPixmap pix = TQPixmap(locate("data", "images/splash.png"));
+
+ setPaletteBackgroundPixmap(pix);
+
+ TQRect rc = TDEGlobalSettings::splashScreenDesktopGeometry();
+
+ move(rc.center().x() - pix.width()/2, rc.center().y() - pix.height()/2);
+ setFixedWidth(pix.width());
+ setFixedHeight(pix.height());
+
+ pr = new SQ_Progress(this);
+ pr->setGeometry(201, 255, 162, 14);
+ pr->setShowText(false);
+ pr->setColor(TQColor(170,100,110));
+ pr->setTotalSteps(10);
+}
+
+SQ_SplashScreen::~SQ_SplashScreen()
+{
+ kdDebug() << "-SQ_SplashScreen" << endl;
+
+ m_inst = 0;
+}
+
+void SQ_SplashScreen::finish()
+{
+ if(SQ_SplashScreen::instance())
+ {
+ SQ_SplashScreen::instance()->progress()->flush();
+ SQ_SplashScreen::instance()->close();
+ }
+}
+
+void SQ_SplashScreen::mousePressEvent(TQMouseEvent *e)
+{
+ e->accept();
+
+ hide();
+}
+
+void SQ_SplashScreen::advance()
+{
+ if(SQ_SplashScreen::instance())
+ SQ_SplashScreen::instance()->progress()->advance();
+}
diff --git a/src/sq_splashscreen.h b/src/sq_splashscreen.h
new file mode 100644
index 0000000..9473c71
--- /dev/null
+++ b/src/sq_splashscreen.h
@@ -0,0 +1,72 @@
+/*
+ * (C) Baryshev Dmitry, KSquirrel project.
+ * Originally based on kstartuplogo.h from KDevelop project
+ */
+
+/***************************************************************************
+ kstartuplogo.h - description
+ -------------------
+ artwork : KDevelop Project / Ralf Nolden <[email protected]>
+ begin : Mon Oct 1 2001
+ copyright : (C) 2001 by Kai Heitkamp
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *
+ * USA. *
+ * *
+ * For license exceptions see LICENSE.EXC file, attached with the source *
+ * code. *
+ * *
+ ***************************************************************************/
+
+#ifndef KSTARTUPLOGO_H
+#define KSTARTUPLOGO_H
+
+#include <tqwidget.h>
+
+class SQ_Progress;
+
+class SQ_SplashScreen : public TQWidget
+{
+ public:
+ SQ_SplashScreen(TQWidget *parent = 0, const char *name = 0);
+ ~SQ_SplashScreen();
+
+ static void advance();
+ static void finish();
+
+ SQ_Progress *progress();
+
+ static SQ_SplashScreen* instance() { return m_inst; }
+
+ protected:
+ virtual void mousePressEvent(TQMouseEvent *);
+
+ private:
+ SQ_Progress *pr;
+
+ static SQ_SplashScreen *m_inst;
+};
+
+inline
+SQ_Progress* SQ_SplashScreen::progress()
+{
+ return pr;
+}
+
+#endif
diff --git a/src/sq_tabopendialog.ui b/src/sq_tabopendialog.ui
new file mode 100644
index 0000000..652fe05
--- /dev/null
+++ b/src/sq_tabopendialog.ui
@@ -0,0 +1,104 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_TabOpenDialog</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_TabOpenDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>341</width>
+ <height>85</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Opening...</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushButton1</cstring>
+ </property>
+ <property name="text">
+ <string>Open in a new tab</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>pushButton2</cstring>
+ </property>
+ <property name="text">
+ <string>Replace current tab</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>pushButton3</cstring>
+ </property>
+ <property name="text">
+ <string>Close all and open in a new tab</string>
+ </property>
+ </widget>
+ <spacer row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>10</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushButton1</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_TabOpenDialog</receiver>
+ <slot>slotPush1()</slot>
+ </connection>
+ <connection>
+ <sender>pushButton2</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_TabOpenDialog</receiver>
+ <slot>slotPush2()</slot>
+ </connection>
+ <connection>
+ <sender>pushButton3</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_TabOpenDialog</receiver>
+ <slot>slotPush3()</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in implementation">sq_tabopendialog.ui.h</include>
+</includes>
+<variables>
+ <variable access="private">int res;</variable>
+</variables>
+<slots>
+ <slot access="private" specifier="non virtual">slotPush1()</slot>
+ <slot access="private" specifier="non virtual">slotPush2()</slot>
+ <slot access="private" specifier="non virtual">slotPush3()</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function specifier="non virtual" returnType="int">result()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_tabopendialog.ui.h b/src/sq_tabopendialog.ui.h
new file mode 100644
index 0000000..5d80dfa
--- /dev/null
+++ b/src/sq_tabopendialog.ui.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** TQt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+void SQ_TabOpenDialog::init()
+{
+ res = -1;
+}
+
+void SQ_TabOpenDialog::slotPush1()
+{
+ res = 0;
+ accept();
+}
+
+
+void SQ_TabOpenDialog::slotPush2()
+{
+ res = 1;
+ accept();
+}
+
+void SQ_TabOpenDialog::slotPush3()
+{
+ res = 2;
+ accept();
+}
+
+int SQ_TabOpenDialog::result()
+{
+ return res;
+}
diff --git a/src/sq_thumbnailcachemaster.ui b/src/sq_thumbnailcachemaster.ui
new file mode 100644
index 0000000..dcf7f5c
--- /dev/null
+++ b/src/sq_thumbnailcachemaster.ui
@@ -0,0 +1,257 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_ThumbnailCacheMaster</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_ThumbnailCacheMaster</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>331</width>
+ <height>244</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Thumbnail cache</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>pushCache</cstring>
+ </property>
+ <property name="text">
+ <string>Calculate cache size on disk</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textThumbSize</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="margin">
+ <number>1</number>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="1" column="0">
+ <property name="name">
+ <cstring>pushClearCache</cstring>
+ </property>
+ <property name="text">
+ <string>Clear cache on disk</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="3" column="0">
+ <property name="name">
+ <cstring>pushShowCache</cstring>
+ </property>
+ <property name="text">
+ <string>View memory cache</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="4" column="0">
+ <property name="name">
+ <cstring>pushClearCacheMemory</cstring>
+ </property>
+ <property name="text">
+ <string>Clear cache in memory</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="1">
+ <property name="name">
+ <cstring>textCacheMemSize</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="margin">
+ <number>1</number>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="5" column="0">
+ <property name="name">
+ <cstring>pushSyncCache</cstring>
+ </property>
+ <property name="text">
+ <string>Sync cache to disk</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="KPushButton" row="2" column="0">
+ <property name="name">
+ <cstring>pushCacheMemory</cstring>
+ </property>
+ <property name="text">
+ <string>Calculate cache size in memory</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="Line" row="6" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="7" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>195</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushClose</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<connections>
+ <connection>
+ <sender>pushSyncCache</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ThumbnailCacheMaster</receiver>
+ <slot>slotSyncCache()</slot>
+ </connection>
+ <connection>
+ <sender>pushShowCache</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ThumbnailCacheMaster</receiver>
+ <slot>slotShowDiskCache()</slot>
+ </connection>
+ <connection>
+ <sender>pushClearCacheMemory</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ThumbnailCacheMaster</receiver>
+ <slot>slotClearMemoryCache()</slot>
+ </connection>
+ <connection>
+ <sender>pushClearCache</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ThumbnailCacheMaster</receiver>
+ <slot>slotClearCache()</slot>
+ </connection>
+ <connection>
+ <sender>pushCacheMemory</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ThumbnailCacheMaster</receiver>
+ <slot>slotCalcCacheMemory()</slot>
+ </connection>
+ <connection>
+ <sender>pushCache</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ThumbnailCacheMaster</receiver>
+ <slot>slotCalcCache()</slot>
+ </connection>
+ <connection>
+ <sender>pushClose</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ThumbnailCacheMaster</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>pushCache</tabstop>
+ <tabstop>pushClearCache</tabstop>
+ <tabstop>pushCacheMemory</tabstop>
+ <tabstop>pushShowCache</tabstop>
+ <tabstop>pushClearCacheMemory</tabstop>
+ <tabstop>pushSyncCache</tabstop>
+ <tabstop>pushClose</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in declaration">tdeio/job.h</include>
+ <include location="global" impldecl="in implementation">kdirsize.h</include>
+ <include location="global" impldecl="in implementation">kpushbutton.h</include>
+ <include location="local" impldecl="in implementation">sq_dirthumbs.h</include>
+ <include location="local" impldecl="in implementation">sq_iconloader.h</include>
+ <include location="local" impldecl="in implementation">sq_pixmapcache.h</include>
+ <include location="local" impldecl="in implementation">sq_thumbnailcachemaster.ui.h</include>
+ <include location="local" impldecl="in implementation">sq_viewcache.h</include>
+ <include location="global" impldecl="in implementation">tdeio/global.h</include>
+ <include location="global" impldecl="in implementation">tdeio/job.h</include>
+ <include location="global" impldecl="in implementation">tqapplication.h</include>
+</includes>
+<slots>
+ <slot access="private">slotCalcCache()</slot>
+ <slot access="private">slotClearCache()</slot>
+ <slot access="private">slotClearFinished( TDEIO::Job * )</slot>
+ <slot access="private">slotClearMemoryCache()</slot>
+ <slot access="private">slotCalcCacheMemory()</slot>
+ <slot access="private">slotShowDiskCache()</slot>
+ <slot access="private">slotSyncCache()</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_thumbnailcachemaster.ui.h b/src/sq_thumbnailcachemaster.ui.h
new file mode 100644
index 0000000..2659ae8
--- /dev/null
+++ b/src/sq_thumbnailcachemaster.ui.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+/*
+ * SQ_ThumbnailCacheMaster manipulates thumbnail cache
+ * in memory and on disk. It can show current cache size,
+ * delete cache on disk, clear cache etc.
+ */
+
+void SQ_ThumbnailCacheMaster::init()
+{
+ pushCache->setIconSet(SQ_IconLoader::instance()->loadIcon("kcalc", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ pushCacheMemory->setIconSet(SQ_IconLoader::instance()->loadIcon("kcalc", TDEIcon::Desktop, TDEIcon::SizeSmall));
+ pushShowCache->setIconSet(SQ_IconLoader::instance()->loadIcon("memory", TDEIcon::Desktop, TDEIcon::SizeSmall));
+
+ slotCalcCacheMemory();
+}
+
+void SQ_ThumbnailCacheMaster::slotCalcCache()
+{
+ SQ_DirThumbs tmp;
+
+ KURL url = tmp.root();
+
+ int size = KDirSize::dirSize(url);
+
+ TQString s = TDEIO::convertSize(size);
+
+ textThumbSize->setText(s);
+}
+
+void SQ_ThumbnailCacheMaster::slotClearCache()
+{
+ TQApplication::setOverrideCursor(TQCursor(TQt::WaitCursor));
+
+ SQ_DirThumbs tmp;
+
+ KURL url = tmp.root();
+
+ TDEIO::DeleteJob *job = TDEIO::del(url);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job*)), this, TQ_SLOT(slotClearFinished(TDEIO::Job*)));
+}
+
+void SQ_ThumbnailCacheMaster::slotClearFinished( TDEIO::Job * )
+{
+ TQApplication::restoreOverrideCursor();
+ slotCalcCache();
+}
+
+void SQ_ThumbnailCacheMaster::slotClearMemoryCache()
+{
+ TQApplication::setOverrideCursor(TQCursor(TQt::WaitCursor));
+
+ SQ_PixmapCache::instance()->clear();
+ slotCalcCacheMemory();
+
+ TQApplication::restoreOverrideCursor();
+}
+
+void SQ_ThumbnailCacheMaster::slotCalcCacheMemory()
+{
+ textCacheMemSize->setText(TQString::fromLatin1("%1/%2")
+ .arg(TDEIO::convertSize(SQ_PixmapCache::instance()->totalSize()))
+ .arg(TDEIO::convertSize(SQ_PixmapCache::instance()->cacheLimit())));
+}
+
+void SQ_ThumbnailCacheMaster::slotShowDiskCache()
+{
+ SQ_ViewCache m_view(this);
+ m_view.exec();
+}
+
+void SQ_ThumbnailCacheMaster::slotSyncCache()
+{
+ TQApplication::setOverrideCursor(TQCursor(TQt::WaitCursor));
+
+ SQ_PixmapCache::instance()->sync();
+
+ slotCalcCacheMemory();
+ slotCalcCache();
+
+ TQApplication::restoreOverrideCursor();
+}
diff --git a/src/sq_thumbnailinfo.h b/src/sq_thumbnailinfo.h
new file mode 100644
index 0000000..6abff2d
--- /dev/null
+++ b/src/sq_thumbnailinfo.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ sq_thumbnailinfo.h - description
+ -------------------
+ begin : ��� ��� 11 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_THUMBNAILINFO_H
+#define SQ_THUMBNAILINFO_H
+
+#include <tqstring.h>
+#include <tqpixmap.h>
+#include <tqimage.h>
+
+#include <ctime>
+
+// default thumbnail format
+#define sqdirThumbFormat "PNG"
+
+// default quality
+#define sqdirThumbQuality 85
+
+#define sqdirMimeFormat "XPM"
+
+/*
+ * Represents thumbnail.
+ */
+struct SQ_Thumbnail
+{
+ // mime icon from image codec
+ TQPixmap mime;
+
+ // 'last modifiled' time of original file.
+ // we should store it for non-local urls
+ time_t originalTime;
+
+ int w, h;
+
+ TQImage thumbnail;
+};
+
+#endif
diff --git a/src/sq_thumbnailloadjob.cpp b/src/sq_thumbnailloadjob.cpp
new file mode 100644
index 0000000..e75dcf4
--- /dev/null
+++ b/src/sq_thumbnailloadjob.cpp
@@ -0,0 +1,480 @@
+/*
+ copyright : (C) 2004 by Baryshev Dmitry
+ KSquirrel - image viewer for KDE
+*/
+
+/* This file is part of the KDE project
+ Copyright (C) 2000 David Faure <[email protected]>
+ 2000 Carsten Pfeiffer <[email protected]>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqdir.h>
+#include <tqimage.h>
+#include <tqpainter.h>
+#include <tqlabel.h>
+#include <tqdatetime.h>
+
+#include <tdefileitem.h>
+#include <kiconloader.h>
+#include <kstandarddirs.h>
+#include <tdetempfile.h>
+#include <kdebug.h>
+
+#include "sq_config.h"
+#include "sq_widgetstack.h"
+#include "sq_pixmapcache.h"
+#include "sq_dirthumbs.h"
+#include "sq_thumbnailloadjob.h"
+#include "sq_libraryhandler.h"
+#include "sq_thumbnailsize.h"
+#include "sq_thumbnailsunused.h"
+#include "sq_utils.h"
+#include "sq_filethumbview.h"
+#include "sq_filethumbviewitem.h"
+#include "sq_imageloader.h"
+
+#include <ksquirrel-libs/fmt_defs.h>
+
+#include <string>
+
+#define SQ_PREDOWNLOAD_SIZE 20
+
+SQ_ThumbnailLoadJob::SQ_ThumbnailLoadJob(const KFileItemList &items, SQ_FileThumbView *parnt)
+ : TDEIO::Job(false), parent(parnt)
+{
+ mBrokenThumbnail.thumbnail = TDEGlobal::iconLoader()->loadIcon("file_broken", TDEIcon::Desktop, SQ_ThumbnailSize::smallest());
+ mItems = items;
+
+ donothing = false;
+
+ dir = new SQ_DirThumbs;
+}
+
+SQ_ThumbnailLoadJob::~SQ_ThumbnailLoadJob()
+{
+ delete dir;
+}
+
+void SQ_ThumbnailLoadJob::start()
+{
+ if(mItems.isEmpty())
+ {
+ emit done();
+ delete this;
+ return;
+ }
+
+ determineNextIcon();
+}
+
+void SQ_ThumbnailLoadJob::appendItem(const KFileItem* item)
+{
+ mItems.append(item);
+}
+
+void SQ_ThumbnailLoadJob::itemRemoved(const KFileItem* item)
+{
+ mItems.removeRef(item);
+
+ nextFile(item == mCurrentItem);
+}
+
+void SQ_ThumbnailLoadJob::itemsRemoved(const KFileItemList &items)
+{
+ KFileItem *item;
+ bool next = false;
+ KFileItemList *m_items = const_cast<KFileItemList *>(&items);
+
+ if(!mItems.isEmpty() && !items.isEmpty())
+ {
+ for(item = m_items->first();item;item = m_items->next())
+ {
+ mItems.removeRef(item);
+
+ if(item == mCurrentItem)
+ next = true;
+ }
+ }
+
+ nextFile(next);
+}
+
+void SQ_ThumbnailLoadJob::pop(const KFileItemList &items)
+{
+ KFileItem *item;
+ bool next = false;
+ KFileItemList *m_items = const_cast<KFileItemList *>(&items);
+
+ if(!mItems.isEmpty() && !items.isEmpty())
+ {
+ for(item = m_items->first();item;item = m_items->next())
+ {
+ mItems.removeRef(item);
+
+ if(item == mCurrentItem)
+ next = true;
+ }
+
+ for(item = m_items->last();item;item = m_items->prev())
+ mItems.prepend(item);
+ }
+
+ nextFile(next);
+}
+
+void SQ_ThumbnailLoadJob::nextFile(bool b)
+{
+ if(b)
+ {
+ TDEIO::Job *j = subjobs.first();
+
+ if(j)
+ {
+ j->kill();
+ subjobs.removeFirst();
+ }
+
+ determineNextIcon();
+ }
+}
+
+void SQ_ThumbnailLoadJob::determineNextIcon()
+{
+ if(donothing)
+ return;
+
+ KFileItem *item = 0;
+ SQ_FileThumbViewItem *tfi;
+
+ while(true)
+ {
+ item = mItems.first();
+
+ if(!item)
+ {
+ emit done();
+ delete this;
+ return;
+ }
+
+ SQ_WidgetStack::instance()->thumbnailProcess();
+
+ tfi = reinterpret_cast<SQ_FileThumbViewItem *>(item->extraData(parent));
+
+ // 1) local urls that are 100% supported, or
+ // 2) remote urls that are 100% supported or _maybe_ supported (application/octet-stream)
+ if(item->isReadable() && SQ_LibraryHandler::instance()->maybeSupported(item->url(), item->mimetype()) != SQ_LibraryHandler::No)
+ break;
+ else
+ {
+ mItems.removeFirst();
+ tfi->setListed(true);
+ }
+ }
+
+ if(mItems.isEmpty() || !item)
+ {
+ emit done();
+ delete this;
+ return;
+ }
+ else
+ {
+ mState = STATE_STATORIG;
+ mCurrentItem = mItems.first();
+ mCurrentURL = mCurrentItem->url();
+ mItems.removeFirst();
+
+ TDEIO::StatJob *job = TDEIO::stat(mCurrentURL, false);
+ job->setSide(true);
+ job->setDetails(0);
+ addSubjob(job);
+ }
+}
+
+void SQ_ThumbnailLoadJob::slotResult(TDEIO::Job *job)
+{
+ subjobs.remove(job);
+// Q_ASSERT(subjobs.isEmpty());
+
+ switch(mState)
+ {
+ case STATE_STATORIG:
+ {
+ TDEIO::UDSEntry entry = mCurrentItem->entry();
+ TDEIO::UDSEntry::ConstIterator it = entry.begin();
+ mOriginalTime = 0;
+ size = totalSize = 0;
+ TQString suff;
+
+ for(; it != entry.end(); ++it)
+ {
+ if((*it).m_uds == TDEIO::UDS_MODIFICATION_TIME)
+ {
+ mOriginalTime = (time_t)((*it).m_long);
+ }
+ else if((*it).m_uds == TDEIO::UDS_SIZE)
+ {
+ totalSize = (TDEIO::filesize_t)((*it).m_long);
+ }
+ else if((*it).m_uds == TDEIO::UDS_NAME)
+ {
+ suff = (*it).m_str;
+ }
+ }
+
+ mThumbURL.setPath(dir->absPath(mCurrentURL));
+
+ if(mCurrentURL.isLocalFile())
+ {
+ if(!statResultThumbnail())
+ createThumbnail(mCurrentURL);
+
+ determineNextIcon();
+ }
+ else if(statResultThumbnail())
+ determineNextIcon();
+ else if(SQ_ThumbnailsUnused::instance()->needUpdate(mCurrentURL, mOriginalTime))
+ {
+ mState = STATE_PREDOWNLOAD;
+ continueDownload = false;
+
+ tmp = new KTempFile(TQString(), TQString::fromLatin1(".%1").arg(suff), 0600);
+ tmp->setAutoDelete(true);
+ tmp->close();
+
+ mTempURL.setPath(tmp->name());
+
+ TDEIO::Job *cpjob = TDEIO::get(mCurrentURL, false, false);
+
+ connect(cpjob, TQ_SIGNAL(data(TDEIO::Job *, const TQByteArray &)),
+ this, TQ_SLOT(slotData(TDEIO::Job *, const TQByteArray &)));
+
+ addSubjob(cpjob);
+ }
+ else
+ determineNextIcon();
+ }
+ break;
+
+ case STATE_PREDOWNLOAD:
+ {
+ // error
+ if(job->error() && job->error() != TDEIO::ERR_USER_CANCELED)
+ emitThumbnailLoadingFailed();
+
+ // no errors, or canceled
+ delete tmp;
+ determineNextIcon();
+ }
+ break;
+
+ case STATE_DOWNLOAD:
+ {
+ if(job->error())
+ emitThumbnailLoadingFailed();
+ else if(SQ_LibraryHandler::instance()->libraryForFile(mTempURL.path()))
+ createThumbnail(mTempURL);
+ else
+ SQ_ThumbnailsUnused::instance()->insert(mCurrentURL, mOriginalTime);
+
+ delete tmp;
+ determineNextIcon();
+ }
+ break;
+ }
+}
+
+void SQ_ThumbnailLoadJob::slotData(TDEIO::Job *job, const TQByteArray &data)
+{
+ if(!data.size())
+ return;
+
+ size += data.size();
+
+ TQFile f(mTempURL.path());
+
+ if(f.open(IO_WriteOnly | IO_Append))
+ {
+ f.writeBlock(data);
+ f.close();
+ }
+
+ // 20 bytes are enough to determine file type
+ if(size >= SQ_PREDOWNLOAD_SIZE && !continueDownload)
+ {
+ // cancel download (file type is not supported)
+ if(totalSize != size
+ && !SQ_LibraryHandler::instance()->libraryForFile(mTempURL.path()))
+ {
+ SQ_ThumbnailsUnused::instance()->insert(mCurrentURL, mOriginalTime);
+ job->kill(false); // kill job & emit result
+ }
+ else if(!statResultThumbnail())
+ {
+ // nice, we can open this image -
+ // go to 'STATE_DOWNLOAD' stage and continue download
+ continueDownload = true;
+ mState = STATE_DOWNLOAD;
+ }
+ else if(size != totalSize)
+ {
+ job->kill(true); // kill job
+ subjobs.remove(job);
+ determineNextIcon();
+ }
+ }
+}
+
+bool SQ_ThumbnailLoadJob::statResultThumbnail()
+{
+ SQ_Thumbnail th;
+
+ if(SQ_PixmapCache::instance()->contains2(mCurrentURL, th))
+ {
+ emitThumbnailLoaded(th);
+ return true;
+ }
+
+ if(dir->needUpdate(mThumbURL.path(), mOriginalTime))
+ {
+// kdDebug() << "STAT **** thumbnailTime < mOriginalTime ****" << endl;
+ return false;
+ }
+
+ if(!th.thumbnail.load(mThumbURL.path(), sqdirThumbFormat))
+ return false;
+
+ SQ_LIBRARY *lib = SQ_LibraryHandler::instance()->libraryForFile(mCurrentURL);
+
+ th.w = th.thumbnail.text("Thumb::Image::Width").toInt();
+ th.h = th.thumbnail.text("Thumb::Image::Height").toInt();
+
+ if((!th.w || !th.h) && mCurrentURL.isLocalFile())
+ SQ_ImageLoader::instance()->tasteImage(mCurrentURL.path(), &th.w, &th.h, lib);
+
+ th.mime = lib->mime;
+ th.originalTime = mOriginalTime;
+ th.mime.load(dir->absPath(mCurrentURL), sqdirMimeFormat);
+
+ insertOrSync(mCurrentURL, th);
+
+ emitThumbnailLoaded(th);
+
+ return true;
+}
+
+void SQ_ThumbnailLoadJob::createThumbnail(const KURL &pixPath)
+{
+ SQ_Thumbnail th;
+ bool loaded = false;
+
+ if(SQ_PixmapCache::instance()->contains2(pixPath, th))
+ {
+ emitThumbnailLoaded(th);
+// kdDebug() << "CREATE found in cache \"" << pixPath << "\"" << endl;
+ return;
+ }
+
+ loaded = SQ_Utils::loadThumbnail(pixPath, th);
+
+ if(loaded)
+ {
+ th.originalTime = mOriginalTime;
+ th.thumbnail = th.thumbnail.swapRGB();
+ insertOrSync(mCurrentURL, th);
+ emitThumbnailLoaded(th);
+ }
+ else
+ emitThumbnailLoadingFailed();
+}
+
+void SQ_ThumbnailLoadJob::insertOrSync(const KURL &url, SQ_Thumbnail &th)
+{
+ if(!SQ_PixmapCache::instance()->full())
+ {
+ SQ_PixmapCache::instance()->insert(url, th);
+// kdDebug() << "IOSYNC inserting \"" << url.url() << "\"" << endl;
+ }
+ else
+ {
+// kdDebug() << "IOSYNC SQ_PixmapCache is full! Cache is ignored!" << endl;
+ SQ_PixmapCache::instance()->syncEntry(url, th);
+ }
+}
+
+void SQ_ThumbnailLoadJob::emitThumbnailLoaded(SQ_Thumbnail &t)
+{
+ int biggestDimension = TQMAX(t.thumbnail.width(), t.thumbnail.height());
+ int thumbPixelSize = SQ_ThumbnailSize::instance()->pixelSize();
+
+ if(biggestDimension <= thumbPixelSize)
+ {
+ emit thumbnailLoaded(mCurrentItem, t);
+ return;
+ }
+
+ t.thumbnail = SQ_Utils::scaleImage(
+ t.thumbnail.bits(),
+ t.thumbnail.width(),
+ t.thumbnail.height(),
+ thumbPixelSize);
+
+ emit thumbnailLoaded(mCurrentItem, t);
+}
+
+void SQ_ThumbnailLoadJob::emitThumbnailLoadingFailed()
+{
+ emit thumbnailLoaded(mCurrentItem, mBrokenThumbnail);
+}
+
+void SQ_ThumbnailLoadJob::appendItems(const KFileItemList &items)
+{
+ KFileItem *item;
+ KFileItemList *m_items = const_cast<KFileItemList *>(&items);
+
+ if(!mItems.isEmpty() && !items.isEmpty())
+ {
+ for(item = m_items->first();item;item = m_items->next())
+ mItems.append(item);
+ }
+}
+
+void SQ_ThumbnailLoadJob::prependItems(const KFileItemList &items)
+{
+ KFileItem *item;
+ KFileItemList *m_items = const_cast<KFileItemList *>(&items);
+
+ if(!mItems.isEmpty() && !items.isEmpty())
+ {
+ for(item = m_items->last();item;item = m_items->prev())
+ mItems.prepend(item);
+ }
+}
+
+void SQ_ThumbnailLoadJob::kill(bool q)
+{
+ donothing = true;
+
+ TDEIO::Job::kill(q);
+}
+
+#include "sq_thumbnailloadjob.moc"
diff --git a/src/sq_thumbnailloadjob.h b/src/sq_thumbnailloadjob.h
new file mode 100644
index 0000000..5e9d9bb
--- /dev/null
+++ b/src/sq_thumbnailloadjob.h
@@ -0,0 +1,102 @@
+/*
+ copyright : (C) 2004 by Baryshev Dmitry
+ KSquirrel - image viewer for KDE
+*/
+
+/* This file is part of the KDE project
+ Copyright (C) 2000 David Faure <[email protected]>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SQ_THUMBNAILLOADJOB_H
+#define SQ_THUMBNAILLOADJOB_H
+
+#include <tqimage.h>
+
+#include <tdeio/job.h>
+
+#include "sq_thumbnailinfo.h"
+
+class KFileItem;
+class KTempFile;
+
+class SQ_DirThumbs;
+class SQ_FileThumbView;
+
+typedef TQPtrList<KFileItem> KFileItemList;
+
+/*
+ * SQ_ThumbnailLoadJob is a job for loading thumbnails
+ * in given directory.
+ */
+
+class SQ_ThumbnailLoadJob : public TDEIO::Job
+{
+ TQ_OBJECT
+
+
+ public:
+ SQ_ThumbnailLoadJob(const KFileItemList &itemList, SQ_FileThumbView *parnt);
+ ~SQ_ThumbnailLoadJob();
+
+ virtual void kill(bool q = true);
+
+ void start();
+ void itemRemoved(const KFileItem* item);
+ void itemsRemoved(const KFileItemList &list);
+ void appendItem(const KFileItem* item);
+ void appendItems(const KFileItemList &items);
+ void prependItems(const KFileItemList &items);
+
+ void pop(const KFileItemList &items);
+
+ private:
+ void determineNextIcon();
+ bool statResultThumbnail();
+ void createThumbnail(const KURL &);
+ void emitThumbnailLoaded(SQ_Thumbnail &);
+ void emitThumbnailLoadingFailed();
+ void insertOrSync(const KURL &, SQ_Thumbnail &th);
+ void nextFile(bool b);
+
+ signals:
+ void thumbnailLoaded(const KFileItem* item, const SQ_Thumbnail &t);
+ void done();
+
+ private slots:
+ void slotResult(TDEIO::Job *job);
+ void slotData(TDEIO::Job *job, const TQByteArray &data);
+
+ private:
+ enum { STATE_STATORIG, STATE_PREDOWNLOAD, STATE_DOWNLOAD } mState;
+
+ KFileItemList mItems;
+ KFileItem *mCurrentItem;
+ KURL mCurrentURL;
+ KURL mThumbURL;
+ KURL mTempURL;
+ TDEIO::filesize_t totalSize, size;
+ KTempFile *tmp;
+ time_t mOriginalTime;
+ TQString mime;
+ bool continueDownload, donothing;
+
+ SQ_DirThumbs *dir;
+ SQ_Thumbnail mBrokenThumbnail;
+ SQ_FileThumbView *parent;
+};
+
+#endif
diff --git a/src/sq_thumbnailsize.cpp b/src/sq_thumbnailsize.cpp
new file mode 100644
index 0000000..ff15fcd
--- /dev/null
+++ b/src/sq_thumbnailsize.cpp
@@ -0,0 +1,70 @@
+/*
+ copyright : (C) 2004 by Baryshev Dmitry
+ KSquirrel - image viewer for KDE
+*/
+
+/*
+Gwenview - A simple image viewer for KDE
+Copyright 2000-2003 Aur?lien G?teau
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "sq_thumbnailsize.h"
+
+SQ_ThumbnailSize * SQ_ThumbnailSize::m_instance = 0;
+
+SQ_ThumbnailSize::SQ_ThumbnailSize(TQObject *parent, Size value)
+ : TQObject(parent), mValue(value), m_extended(false), m_margin(16)
+{
+ m_instance = this;
+}
+
+SQ_ThumbnailSize::SQ_ThumbnailSize(TQObject *parent, const TQString& str)
+ : TQObject(parent), m_extended(false), m_margin(16)
+{
+ TQString low = str.lower();
+
+ if(low == "medium")
+ mValue = Medium;
+ else if(low == "large")
+ mValue = Large;
+ else
+ mValue = Huge;
+}
+
+void SQ_ThumbnailSize::setPixelSize(const TQString &size)
+{
+ TQString low = size.lower();
+
+ if(low == "medium")
+ mValue = Medium;
+ else if(low == "large")
+ mValue = Large;
+ else
+ mValue = Huge;
+}
+
+TQString SQ_ThumbnailSize::stringValue() const
+{
+ static TQString sizeStr[3] = {"64","96","128"};
+
+ return sizeStr[int(mValue)];
+}
diff --git a/src/sq_thumbnailsize.h b/src/sq_thumbnailsize.h
new file mode 100644
index 0000000..587ae39
--- /dev/null
+++ b/src/sq_thumbnailsize.h
@@ -0,0 +1,145 @@
+/*
+ copyright : (C) 2004 by Baryshev Dmitry
+ KSquirrel - image viewer for KDE
+*/
+
+/*
+Gwenview - A simple image viewer for KDE
+Copyright (c) 2000-2003 Aur?lien G?teau
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+#ifndef SQ_THUMBNAILSIZE_H
+#define SQ_THUMBNAILSIZE_H
+
+#include <tqstring.h>
+#include <tqobject.h>
+#include <tqsize.h>
+
+/**
+ * This is an "enum-like" class : an enum with cast operators to convert
+ * from/to string and a few other methods
+ */
+class SQ_ThumbnailSize : public TQObject
+{
+ public:
+ enum Size { Medium, Large, Huge };
+
+ SQ_ThumbnailSize(TQObject *parent, Size value);
+ SQ_ThumbnailSize(TQObject *parent, const TQString& str);
+
+ void setExtended(bool);
+ bool extended() const;
+
+ void setMargin(int);
+ int margin() const;
+
+ void setPixelSize(const TQString &size);
+
+ TQString pixelSizeString() const;
+ int pixelSize() const;
+
+ TQSize extendedSize() const;
+
+ int value() const;
+ TQString stringValue() const;
+
+ static int biggest() { return 128; }
+ static int smallest() { return 48; }
+
+ static SQ_ThumbnailSize* instance() { return m_instance; }
+
+ private:
+ Size mValue;
+ bool m_extended;
+ int m_margin;
+
+ static SQ_ThumbnailSize *m_instance;
+};
+
+inline
+int SQ_ThumbnailSize::value() const
+{
+ return (int)mValue;
+}
+
+inline
+void SQ_ThumbnailSize::setExtended(bool ex)
+{
+ m_extended = ex;
+}
+
+inline
+bool SQ_ThumbnailSize::extended() const
+{
+ return m_extended;
+}
+
+inline
+void SQ_ThumbnailSize::setMargin(int m)
+{
+ m_margin = m;
+}
+
+inline
+int SQ_ThumbnailSize::margin() const
+{
+ return m_margin;
+}
+
+inline
+int SQ_ThumbnailSize::pixelSize() const
+{
+ switch (mValue)
+ {
+ case Medium:
+ return 64;
+ case Large:
+ return 96;
+ default:
+ return 128;
+ }
+}
+
+inline
+TQSize SQ_ThumbnailSize::extendedSize() const
+{
+ switch (mValue)
+ {
+ case Medium:
+ return TQSize(76, 108);
+ case Large:
+ return TQSize(108, 139);
+ default:
+ return TQSize(140, 170);
+ }
+}
+
+inline
+TQString SQ_ThumbnailSize::pixelSizeString() const
+{
+ switch (mValue)
+ {
+ case Medium:
+ return "medium";
+ case Large:
+ return "large";
+ default:
+ return "huge";
+ }
+}
+
+#endif
diff --git a/src/sq_thumbnailsunused.cpp b/src/sq_thumbnailsunused.cpp
new file mode 100644
index 0000000..59957bb
--- /dev/null
+++ b/src/sq_thumbnailsunused.cpp
@@ -0,0 +1,97 @@
+/***************************************************************************
+ sq_thumbnailsunused.cpp - description
+ -------------------
+ begin : Fri Jul 20 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <tdeconfig.h>
+
+#include "sq_thumbnailsunused.h"
+
+SQ_ThumbnailsUnused * SQ_ThumbnailsUnused::m_instance = 0;
+
+SQ_ThumbnailsUnused::SQ_ThumbnailsUnused(TQObject *parent) : TQObject(parent), TQMap<KURL, time_t>()
+{
+ m_instance = this;
+
+ cache = new TDEConfig("ksquirrel-unused-cache");
+
+ load();
+}
+
+SQ_ThumbnailsUnused::~SQ_ThumbnailsUnused()
+{
+ save();
+ delete cache;
+}
+
+bool SQ_ThumbnailsUnused::needUpdate(const KURL &u, time_t t)
+{
+ iterator it = find(u);
+
+ if(it == end())
+ return true;
+
+ return it.data() != t;
+}
+
+void SQ_ThumbnailsUnused::load()
+{
+ cache->setGroup("General");
+ int count = cache->readNumEntry("count");
+
+ if(count <= 0)
+ return;
+
+ TQString is, s;
+ time_t t;
+
+ for(int i = 0;i < count;i++)
+ {
+ cache->setGroup("URL");
+
+ is = TQString::number(i);
+ s = cache->readEntry(is);
+
+ cache->setGroup("Time");
+ t = cache->readNumEntry(is);
+
+ insert(KURL::fromPathOrURL(s), t);
+ }
+}
+
+void SQ_ThumbnailsUnused::save()
+{
+ cache->deleteGroup("URL");
+ cache->deleteGroup("Time");
+
+ cache->setGroup("General");
+ cache->writeEntry("count", size());
+
+ iterator itEnd = end();
+ TQString is;
+ int i = 0;
+
+ for(iterator it = begin();it != itEnd;++it)
+ {
+ is = TQString::number(i);
+ cache->setGroup("URL");
+ cache->writeEntry(is, it.key().prettyURL());
+
+ cache->setGroup("Time");
+ cache->writeEntry(is, it.data());
+
+ i++;
+ }
+}
diff --git a/src/sq_thumbnailsunused.h b/src/sq_thumbnailsunused.h
new file mode 100644
index 0000000..7c2da3e
--- /dev/null
+++ b/src/sq_thumbnailsunused.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ sq_thumbnailsunused.h - description
+ -------------------
+ begin : Fri Jul 20 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_THUMBNAILSUNUSED_H
+#define SQ_THUMBNAILSUNUSED_H
+
+#include <tqmap.h>
+#include <tqobject.h>
+
+#include <kurl.h>
+
+#include <ctime>
+
+class TDEConfig;
+
+/*
+ * This is small helper class for thumbnail loader. It is used only on
+ * non-local filesystems to cache information on unsupported file
+ * types to avoid downloading them from [possibly] slow tdeio-slave
+ * (for example, smb:/ on slow network).
+ */
+
+class SQ_ThumbnailsUnused : public TQObject, public TQMap<KURL, time_t>
+{
+ public:
+ SQ_ThumbnailsUnused(TQObject *parent = 0);
+ ~SQ_ThumbnailsUnused();
+
+ bool needUpdate(const KURL &u, time_t t);
+
+ static SQ_ThumbnailsUnused* instance() { return m_instance; };
+
+ private:
+ void load();
+ void save();
+
+ private:
+ static SQ_ThumbnailsUnused *m_instance;
+ TDEConfig *cache;
+};
+
+#endif
diff --git a/src/sq_utils.cpp b/src/sq_utils.cpp
new file mode 100644
index 0000000..20eea42
--- /dev/null
+++ b/src/sq_utils.cpp
@@ -0,0 +1,188 @@
+/***************************************************************************
+ sq_utils.cpp - description
+ -------------------
+ begin : Thu Aug 2 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqstring.h>
+
+#include <ksquirrel-libs/fmt_defs.h>
+
+#include "sq_libraryhandler.h"
+#include "sq_utils.h"
+
+#ifndef KSQUIRREL_PART
+#include <kurl.h>
+#include "sq_imageloader.h"
+#include "sq_thumbnailinfo.h"
+#include "sq_thumbnailsize.h"
+#endif
+
+#ifdef SQ_HAVE_KEXIF
+#include <libkexif/kexifdata.h>
+#endif
+
+void SQ_Utils::exifRotate(const TQString &file, TQImage &im, int o)
+{
+#ifdef SQ_HAVE_KEXIF
+ im = im.xForm(SQ_Utils::exifGetMatrix(file, o));
+#endif
+}
+
+TQWMatrix SQ_Utils::exifGetMatrix(const TQString &file, int o)
+{
+ TQWMatrix matrix;
+
+#ifdef SQ_HAVE_KEXIF
+ int O;
+
+ if(o == -1)
+ {
+ KExifData data;
+ data.readFromFile(file);
+ O = data.getImageQt::Orientation();
+ }
+ else
+ O = o;
+
+ switch(O)
+ {
+ case KExifData::HFLIP: matrix.scale(-1,1); break;
+ case KExifData::ROT_180: matrix.rotate(180); break;
+ case KExifData::VFLIP: matrix.scale(1,-1); break;
+ case KExifData::ROT_90_HFLIP: matrix.scale(-1,1); matrix.rotate(90); break;
+ case KExifData::ROT_90: matrix.rotate(90); break;
+ case KExifData::ROT_90_VFLIP: matrix.scale(1,-1); matrix.rotate(90); break;
+ case KExifData::ROT_270: matrix.rotate(270); break;
+
+ // normal rotation or unspecified
+ default: ;
+ }
+
+#endif
+
+ return matrix;
+}
+
+TQImage SQ_Utils::scaleImage(unsigned char *im, int w, int h, int fitwithin)
+{
+ if(w <= fitwithin && h <= fitwithin)
+ {
+ TQImage scaled(im, w, h, 32, 0, 0, TQImage::LittleEndian);
+ scaled.setAlphaBuffer(true);
+ return scaled.copy();
+ }
+
+ TQImage orig(im, w, h, 32, 0, 0, TQImage::LittleEndian);
+ orig.setAlphaBuffer(true);
+
+ // return scaled image
+ return SQ_Utils::scale(orig, fitwithin, fitwithin, SQ_Utils::SMOOTH_FAST, TQImage::ScaleMin);
+}
+
+#ifndef KSQUIRREL_PART
+bool SQ_Utils::loadThumbnail(const KURL &pixPath, SQ_Thumbnail &t)
+{
+ SQ_LIBRARY *lib = 0;
+
+#ifdef SQ_HAVE_KEXIF
+ lib = SQ_LibraryHandler::instance()->libraryForFile(pixPath.path());
+ bool th = false;
+
+ if(lib)
+ {
+ KExifData data;
+ data.readFromFile(pixPath.path());
+ TQImage im = data.getThumbnail();
+
+ if(!im.isNull())
+ {
+ SQ_Utils::exifRotate(TQString(), im, data.getImageQt::Orientation());
+
+ th = true;
+ t.w = 0;
+ t.h = 0;
+ t.mime = lib->mime;
+
+ TQString w, h;
+ w = im.text("Thumb::Image::Width");
+ h = im.text("Thumb::Image::Height");
+ t.w = w.toInt();
+ t.h = h.toInt();
+
+ if(!t.w || !t.h)
+ SQ_ImageLoader::instance()->tasteImage(pixPath.path(), &t.w, &t.h, lib);
+
+ t.thumbnail = SQ_Utils::scaleImage((unsigned char *)im.bits(), im.width(),
+ im.height(), SQ_ThumbnailSize::biggest());
+ t.thumbnail = t.thumbnail.swapRGB();
+ }
+ }
+ else
+ return false;
+
+ // thumbnail loaded - nothing to do,
+ // or load thumbnail by hands otherwise.
+ if(th)
+ return true;
+#endif
+
+ fmt_info *finfo;
+
+ RGBA *all;
+
+ bool b = SQ_ImageLoader::instance()->loadImage(pixPath.path(), SQ_CodecSettings::ThumbnailLoader);
+
+ finfo = SQ_ImageLoader::instance()->info();
+ all = SQ_ImageLoader::instance()->bits();
+
+ // memory allocation failed in SQ_ImageLoader::loadImage()
+ if(!all)
+ return false;
+
+ // another error occured...
+ if(!b)
+ {
+ // if our image is partially corrupted - show it. The image
+ // is partially corrupted, if number of errors < number of scanlines
+ // and at least one page was loaded.
+ if(!finfo->image.size()
+ || (SQ_ImageLoader::instance()->errors() == finfo->image[0].h && finfo->image.size() == 1))
+ {
+ SQ_ImageLoader::instance()->cleanup();
+ return false;
+ }
+ }
+
+ if(!lib) lib = SQ_LibraryHandler::instance()->libraryForFile(pixPath.path());
+
+ t.w = finfo->image[0].w;
+ t.h = finfo->image[0].h;
+ t.mime = lib->mime;
+
+ t.thumbnail = SQ_Utils::scaleImage((unsigned char *)all, finfo->image[0].w,
+ finfo->image[0].h, SQ_ThumbnailSize::biggest());
+
+ SQ_ImageLoader::instance()->cleanup();
+
+ // finally, rotate thumbnail using EXIF
+ SQ_Utils::exifRotate(pixPath.path(), t.thumbnail);
+
+ return true;
+}
+#endif
diff --git a/src/sq_utils.h b/src/sq_utils.h
new file mode 100644
index 0000000..6d92104
--- /dev/null
+++ b/src/sq_utils.h
@@ -0,0 +1,63 @@
+/***************************************************************************
+ sq_utils.h - description
+ -------------------
+ begin : Thu Aug 2 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_UTILS_H
+#define SQ_UTILS_H
+
+#include <tqimage.h>
+#include <tqwmatrix.h>
+
+class KURL;
+
+class TQString;
+
+class SQ_Thumbnail;
+
+/*
+ * Helper class for SQ_GLWidget and SQ_ThumbnailLoadJob:
+ *
+ * thumbnail loader, rotater, mmx scaler
+ */
+
+namespace SQ_Utils
+{
+ enum SmoothAlgorithm { SMOOTH_NONE, SMOOTH_FAST, SMOOTH_NORMAL, SMOOTH_BEST };
+
+ TQImage scale(const TQImage& image, int width, int height,
+ SmoothAlgorithm alg, TQImage::ScaleMode mode = TQImage::ScaleFree, double blur = 1.0);
+
+ /*
+ * Scale given image to fit it within 'fitwithin'
+ */
+ TQImage scaleImage(unsigned char *im, int w, int h, int fitwithin);
+
+#ifndef KSQUIRREL_PART
+ /*
+ * Create and save thumbnail for 'pixPath'
+ */
+ bool loadThumbnail(const KURL &pixPath, SQ_Thumbnail&);
+#endif
+
+ /*
+ * determine EXIF rotation and rotate image if needed
+ */
+ void exifRotate(const TQString &file, TQImage &i, int o = -1);
+
+ TQWMatrix exifGetMatrix(const TQString &file, int o = -1);
+};
+
+#endif
diff --git a/src/sq_utils_asm_scale.S b/src/sq_utils_asm_scale.S
new file mode 100644
index 0000000..08b43da
--- /dev/null
+++ b/src/sq_utils_asm_scale.S
@@ -0,0 +1,810 @@
+#ifdef HAVE_X86_MMX
+
+#ifdef __EMX__
+/* Due to strange behaviour of as.exe we use this macros */
+/* For all OS/2 coders - please use PGCC to compile this code */
+#define PR_(foo) ___##foo
+#define PT_(foo,func) ___##foo,func
+#define SIZE(sym) \
+ .___end_##sym:; \
+ .size ___##sym,.___end_##sym-___##sym; \
+ .align 8;
+#else
+#define PR_(foo) __##foo
+#define PT_(foo,func) __##foo,func
+#define SIZE(sym) \
+ .__end_##sym:; \
+ .size __##sym,.__end_##sym-__##sym; \
+ .align 8;
+#endif
+
+/*\
+|*| MMX assembly scaling routine for Imlib2
+|*| Written by Willem Monsuwe <[email protected]>
+\*/
+
+.text
+ .align 8
+.globl PR_(mimageScale_mmx_AARGBA)
+/* .type PT_(mimageScale_mmx_AARGBA,@function) */
+
+
+/*\ Prototype: __mimageScale_mmx_AARGBA(ImlibScaleInfo *isi, DATA32 *dest,
+|*| int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow)
+\*/
+
+#define isi 8(%ebp)
+#define dest 12(%ebp)
+#define dxx 16(%ebp)
+#define dyy 20(%ebp)
+#define dx 24(%ebp)
+#define dy 28(%ebp)
+#define dw 32(%ebp)
+#define dh 36(%ebp)
+#define dow 40(%ebp)
+#define sow 44(%ebp)
+
+/*\ Local variables that didn't fit in registers \*/
+#define y -4(%ebp)
+#define yp -8(%ebp)
+#define yap -12(%ebp)
+#define xp -16(%ebp)
+#define xap -20(%ebp)
+#define Cx -24(%ebp)
+#define Mx -28(%ebp)
+#define Cy -32(%ebp)
+#define My -36(%ebp)
+#define sow_4 -40(%ebp)
+
+/*\ When %edx points to ImlibScaleInfo, these are the members \*/
+#define xpoints (%edx)
+#define ypoints 4(%edx)
+#define xapoints 8(%edx)
+#define yapoints 12(%edx)
+#define xup_yup 16(%edx)
+
+PR_(mimageScale_mmx_AARGBA):
+ pushl %ebp
+ movl %esp, %ebp
+ subl $40, %esp
+ pushl %ebx
+ pushl %ecx
+ pushl %edx
+ pushl %edi
+ pushl %esi
+ movl isi, %edx
+
+ /*\ Check (dw > 0) && (dh > 0) \*/
+ cmpl $0, dw
+ jle .scale_leave
+ cmpl $0, dh
+ jle .scale_leave
+
+ /*\ X-based array pointers point to the end; we're looping up to 0 \*/
+ /*\ %edi = dest + dow * dy + dx + dw \*/
+ movl dow, %eax
+ imull dy, %eax
+ addl dx, %eax
+ addl dw, %eax
+ movl dest, %edi
+ leal (%edi, %eax, 4), %edi
+ /*\ xp = xpoints + dxx + dw \*/
+ movl dxx, %ebx
+ addl dw, %ebx
+ movl xpoints, %eax
+ leal (%eax, %ebx, 4), %eax
+ movl %eax, xp
+ /*\ xap = xapoints + dxx + dw \*/
+ movl xapoints, %eax
+ leal (%eax, %ebx, 4), %eax
+ movl %eax, xap
+ /*\ y = dh \*/
+ movl dh, %eax
+ movl %eax, y
+ /*\ yp = ypoints + dyy \*/
+ movl dyy, %ebx
+ movl ypoints, %eax
+ leal (%eax, %ebx, 4), %eax
+ movl %eax, yp
+ /*\ yap = yapoints + dyy \*/
+ movl yapoints, %eax
+ leal (%eax, %ebx, 4), %eax
+ movl %eax, yap
+
+ pxor %mm7, %mm7
+
+ /*\ Test xup bit \*/
+ movl xup_yup, %eax
+ sarl $1, %eax
+ jnc .scale_x_down
+
+.scale_x_up:
+ /*\ Test yup bit \*/
+ sarl $1, %eax
+ jnc .scale_x_up_y_down
+
+
+/*\ Scaling up both ways \*/
+
+.scale_x_up_y_up:
+ movl sow, %ebx
+
+.up_up_loop_y:
+
+ /*\ x = -dw \*/
+ movl dw, %ecx
+ negl %ecx
+
+ /*\ %eax = *yap << 4 \*/
+ movl yap, %eax
+ movl (%eax), %eax
+ sall $4, %eax
+ jz .up_up_yap_0
+ movd %eax, %mm1
+ punpcklwd %mm1, %mm1
+ punpckldq %mm1, %mm1
+
+.up_up_loop1_x:
+ /*\ %esi = *yp + xp[x] \*/
+ movl yp, %eax
+ movl (%eax), %esi
+ movl xp, %eax
+ movl (%eax, %ecx, 4), %eax
+ leal (%esi, %eax, 4), %esi
+
+ /*\ %eax = xap[x] << 4 \*/
+ movl xap, %eax
+ movl (%eax, %ecx, 4), %eax
+ sall $4, %eax
+ jz .up_up_xap_0
+
+ /*\ %mm0 = xap[x] << 4 \*/
+ movd %eax, %mm0
+ punpcklwd %mm0, %mm0
+ punpckldq %mm0, %mm0
+
+ /*\ Load and unpack four pixels in parralel
+ |*| %mm2 = ptr[0], %mm3 = ptr[1]
+ |*| %mm4 = ptr[sow], %mm5 = ptr[sow + 1]
+ \*/
+ movq (%esi), %mm2
+ movq (%esi, %ebx, 4), %mm4
+ movq %mm2, %mm3
+ movq %mm4, %mm5
+ punpcklbw %mm7, %mm2
+ punpcklbw %mm7, %mm4
+ punpckhbw %mm7, %mm3
+ punpckhbw %mm7, %mm5
+
+ /*\ X interpolation: r = l + (r - l) * xap \*/
+ psubw %mm2, %mm3
+ psubw %mm4, %mm5
+ psllw $4, %mm3
+ psllw $4, %mm5
+ pmulhw %mm0, %mm3
+ pmulhw %mm0, %mm5
+ paddw %mm2, %mm3
+ paddw %mm4, %mm5
+ /*\ Now %mm3 = I(ptr[0], ptr[1]), %mm5 = I(ptr[sow], ptr[sow + 1]) \*/
+ jmp .up_up_common
+.up_up_xap_0:
+ /*\ Load and unpack two pixels
+ |*| %mm3 = ptr[0], %mm5 = ptr[sow]
+ \*/
+ movd (%esi), %mm3
+ movd (%esi, %ebx, 4), %mm5
+ punpcklbw %mm7, %mm3
+ punpcklbw %mm7, %mm5
+.up_up_common:
+ /*\ Y interpolation: d = u + (d - u) * yap \*/
+ psubw %mm3, %mm5
+ psllw $4, %mm5
+ pmulhw %mm1, %mm5
+ paddw %mm3, %mm5
+ packuswb %mm5, %mm5
+ movd %mm5, (%edi, %ecx, 4)
+
+ /*\ while (++x) \*/
+ incl %ecx
+ jnz .up_up_loop1_x
+ jmp .up_up_yap_end
+.up_up_yap_0:
+
+.up_up_loop2_x:
+ /*\ %esi = *yp + xp[x] \*/
+ movl yp, %eax
+ movl (%eax), %esi
+ movl xp, %eax
+ movl (%eax, %ecx, 4), %eax
+ leal (%esi, %eax, 4), %esi
+
+ /*\ %eax = xap[x] << 4 \*/
+ movl xap, %eax
+ movl (%eax, %ecx, 4), %eax
+ sall $4, %eax
+ jz .up_up_0
+
+ /*\ %mm0 = xap[x] << 4 \*/
+ movd %eax, %mm0
+ punpcklwd %mm0, %mm0
+ punpckldq %mm0, %mm0
+
+ /*\ Load and unpack two pixels in parralel
+ |*| %mm2 = ptr[0], %mm3 = ptr[1]
+ \*/
+ movq (%esi), %mm2
+ movq %mm2, %mm3
+ punpcklbw %mm7, %mm2
+ punpckhbw %mm7, %mm3
+
+ /*\ X interpolation: r = l + (r - l) * xap \*/
+ psubw %mm2, %mm3
+ psllw $4, %mm3
+ pmulhw %mm0, %mm3
+ paddw %mm2, %mm3
+ packuswb %mm3, %mm3
+ movd %mm3, (%edi, %ecx, 4)
+ jmp .up_up_1
+.up_up_0:
+ /*\ dptr[x] = *sptr \*/
+ movl (%esi), %eax
+ movl %eax, (%edi, %ecx, 4)
+.up_up_1:
+ incl %ecx
+ jnz .up_up_loop2_x
+
+.up_up_yap_end:
+ /*\ dptr += dow \*/
+ movl dow, %eax
+ leal (%edi, %eax, 4), %edi
+ /*\ yap++; yp++ \*/
+ addl $4, yap
+ addl $4, yp
+ /*\ while (y--) \*/
+ decl y
+ jnz .up_up_loop_y
+
+ jmp .scale_leave
+
+
+/*\ Scaling down vertically \*/
+
+.scale_x_up_y_down:
+ /*\ sow_4 = sow * 4 \*/
+ movl sow, %eax
+ sall $2, %eax
+ movl %eax, sow_4
+
+.up_down_loop_y:
+
+ /*\ Setup My and Cy \*/
+ movl yap, %eax
+ movzwl (%eax), %ebx
+ movl %ebx, My
+ movzwl 2(%eax), %eax
+ movl %eax, Cy
+
+ /*\ mm4 = Cy \*/
+ movd %eax, %mm4
+ punpcklwd %mm4, %mm4
+ punpckldq %mm4, %mm4
+ /*\ mm5 = My \*/
+ movd %ebx, %mm5
+ punpcklwd %mm5, %mm5
+ punpckldq %mm5, %mm5
+
+ /*\ x = -dw \*/
+ movl dw, %ecx
+ negl %ecx
+.up_down_loop_x:
+ /*\ %esi = *yp + xp[x] \*/
+ movl yp, %eax
+ movl (%eax), %esi
+ movl xp, %eax
+ movl (%eax, %ecx, 4), %eax
+ leal (%esi, %eax, 4), %esi
+
+ movl %esi, %eax
+ /*\ v = (*p * My) >> 10 \*/
+ movd (%eax), %mm0
+ punpcklbw %mm7, %mm0
+ psllw $6, %mm0
+ pmulhw %mm5, %mm0
+
+ /*\ i = 0x4000 - My \*/
+ movl $0x4000, %ebx
+ subl My, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ p += sow; v += (*p * Cy) >> 10 \*/
+ addl sow_4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm4, %mm1
+ paddw %mm1, %mm0
+
+ /*\ i -= Cy; while (i > Cy) \*/
+ subl Cy, %ebx
+2:
+ cmpl Cy, %ebx
+ jg 1b
+
+ /*\ mm6 = i \*/
+ movd %ebx, %mm6
+ punpcklwd %mm6, %mm6
+ punpckldq %mm6, %mm6
+
+ /*\ p += sow; v += (*p * i) >> 10 \*/
+ addl sow_4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm6, %mm1
+ paddw %mm1, %mm0
+5:
+ /*\ %eax = xap[x] << 5 \*/
+ movl xap, %eax
+ movl (%eax, %ecx, 4), %eax
+ sall $5, %eax
+ jz 6f
+ /*\ mm3 = xap[x] << 5 \*/
+ movd %eax, %mm3
+ punpcklwd %mm3, %mm3
+ punpckldq %mm3, %mm3
+
+ /*\ p + 1 \*/
+ movl %esi, %eax
+ addl $4, %eax
+ /*\ vv = (*p * My) >> 10 \*/
+ movd (%eax), %mm2
+ punpcklbw %mm7, %mm2
+ psllw $6, %mm2
+ pmulhw %mm5, %mm2
+
+ /*\ i = 0x4000 - My \*/
+ movl $0x4000, %ebx
+ subl My, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ p += sow; vv += (*p * Cy) >> 10 \*/
+ addl sow_4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm4, %mm1
+ paddw %mm1, %mm2
+
+ /*\ i -= Cy; while (i > Cy) \*/
+ subl Cy, %ebx
+2:
+ cmpl Cy, %ebx
+ jg 1b
+
+ /*\ p += sow; v += (*p * i) >> 10 \*/
+ addl sow_4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm6, %mm1
+ paddw %mm1, %mm2
+5:
+ /*\ v = v + (vv - v) * xap \*/
+ psubw %mm0, %mm2
+ psllw $3, %mm2
+ pmulhw %mm3, %mm2
+ paddw %mm2, %mm0
+6:
+ /*\ dest[x] = v >> 4 \*/
+ psrlw $4, %mm0
+ packuswb %mm0, %mm0
+ movd %mm0, (%edi, %ecx, 4)
+
+ /*\ while (++x) \*/
+ incl %ecx
+ jnz .up_down_loop_x
+
+ /*\ dptr += dow \*/
+ movl dow, %eax
+ leal (%edi, %eax, 4), %edi
+ /*\ yap++; yp++ \*/
+ addl $4, yap
+ addl $4, yp
+ /*\ while (y--) \*/
+ decl y
+ jnz .up_down_loop_y
+
+ jmp .scale_leave
+
+.scale_x_down:
+ /*\ Test yup bit \*/
+ sarl $1, %eax
+ jnc .scale_x_down_y_down
+
+
+/*\ Scaling down horizontally \*/
+
+.scale_x_down_y_up:
+ /*\ sow_4 = sow * 4 \*/
+ movl sow, %eax
+ sall $2, %eax
+ movl %eax, sow_4
+
+.down_up_loop_y:
+
+ /*\ %eax = *yap << 5 \*/
+ movl yap, %eax
+ movl (%eax), %eax
+ sall $5, %eax
+ /*\ mm3 = *yap << 5 \*/
+ movd %eax, %mm3
+ punpcklwd %mm3, %mm3
+ punpckldq %mm3, %mm3
+
+ /*\ x = -dw \*/
+ movl dw, %ecx
+ negl %ecx
+.down_up_loop_x:
+ /*\ %esi = *yp + xp[x] \*/
+ movl yp, %eax
+ movl (%eax), %esi
+ movl xp, %eax
+ movl (%eax, %ecx, 4), %eax
+ leal (%esi, %eax, 4), %esi
+
+ /*\ Setup Mx and Cx \*/
+ movl xap, %eax
+ movzwl (%eax, %ecx, 4), %ebx
+ movl %ebx, Mx
+ movzwl 2(%eax, %ecx, 4), %eax
+ movl %eax, Cx
+
+ /*\ mm4 = Cx \*/
+ movd %eax, %mm4
+ punpcklwd %mm4, %mm4
+ punpckldq %mm4, %mm4
+ /*\ mm5 = Mx \*/
+ movd %ebx, %mm5
+ punpcklwd %mm5, %mm5
+ punpckldq %mm5, %mm5
+
+ movl %esi, %eax
+ /*\ v = (*p * Mx) >> 10 \*/
+ movd (%eax), %mm0
+ punpcklbw %mm7, %mm0
+ psllw $6, %mm0
+ pmulhw %mm5, %mm0
+
+ /*\ i = 0x4000 - Mx \*/
+ movl $0x4000, %ebx
+ subl Mx, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ p += sow; v += (*p * Cx) >> 10 \*/
+ addl $4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm4, %mm1
+ paddw %mm1, %mm0
+
+ /*\ i -= Cx; while (i > Cx) \*/
+ subl Cx, %ebx
+2:
+ cmpl Cx, %ebx
+ jg 1b
+
+ /*\ mm6 = i \*/
+ movd %ebx, %mm6
+ punpcklwd %mm6, %mm6
+ punpckldq %mm6, %mm6
+
+ /*\ p += sow; v += (*p * i) >> 10 \*/
+ addl $4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm6, %mm1
+ paddw %mm1, %mm0
+5:
+ movd %mm3, %eax
+ testl %eax, %eax
+ jz 6f
+ /*\ p + sow \*/
+ movl %esi, %eax
+ addl sow_4, %eax
+ /*\ vv = (*p * Mx) >> 10 \*/
+ movd (%eax), %mm2
+ punpcklbw %mm7, %mm2
+ psllw $6, %mm2
+ pmulhw %mm5, %mm2
+
+ /*\ i = 0x4000 - Mx \*/
+ movl $0x4000, %ebx
+ subl Mx, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ p += sow; vv += (*p * Cx) >> 10 \*/
+ addl $4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm4, %mm1
+ paddw %mm1, %mm2
+
+ /*\ i -= Cx; while (i > Cx) \*/
+ subl Cx, %ebx
+2:
+ cmpl Cx, %ebx
+ jg 1b
+
+ /*\ p += sow; v += (*p * i) >> 10 \*/
+ addl $4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $6, %mm1
+ pmulhw %mm6, %mm1
+ paddw %mm1, %mm2
+5:
+ /*\ v = v + (vv - v) * yap \*/
+ psubw %mm0, %mm2
+ psllw $3, %mm2
+ pmulhw %mm3, %mm2
+ paddw %mm2, %mm0
+6:
+ /*\ dest[x] = v >> 4 \*/
+ psrlw $4, %mm0
+ packuswb %mm0, %mm0
+ movd %mm0, (%edi, %ecx, 4)
+
+ /*\ while (++x) \*/
+ incl %ecx
+ jnz .down_up_loop_x
+
+ /*\ dptr += dow \*/
+ movl dow, %eax
+ leal (%edi, %eax, 4), %edi
+ /*\ yap++; yp++ \*/
+ addl $4, yap
+ addl $4, yp
+ /*\ while (y--) \*/
+ decl y
+ jnz .down_up_loop_y
+
+ jmp .scale_leave
+
+
+/*\ Scaling down both ways \*/
+
+.scale_x_down_y_down:
+ /*\ sow_4 = sow * 4 \*/
+ movl sow, %eax
+ sall $2, %eax
+ movl %eax, sow_4
+
+.down_down_loop_y:
+
+ /*\ Setup My and Cy \*/
+ movl yap, %eax
+ movzwl (%eax), %ebx
+ movl %ebx, My
+ movzwl 2(%eax), %eax
+ movl %eax, Cy
+
+ /*\ x = -dw \*/
+ movl dw, %ecx
+ negl %ecx
+.down_down_loop_x:
+ /*\ %esi = *yp + xp[x] \*/
+ movl yp, %eax
+ movl (%eax), %esi
+ movl xp, %eax
+ movl (%eax, %ecx, 4), %eax
+ leal (%esi, %eax, 4), %esi
+
+ /*\ Setup Mx and Cx \*/
+ movl xap, %eax
+ movzwl (%eax, %ecx, 4), %ebx
+ movl %ebx, Mx
+ movzwl 2(%eax, %ecx, 4), %eax
+ movl %eax, Cx
+
+ /*\ mm3 = Cx \*/
+ movd %eax, %mm3
+ punpcklwd %mm3, %mm3
+ punpckldq %mm3, %mm3
+ /*\ mm5 = Mx \*/
+ movd %ebx, %mm5
+ punpcklwd %mm5, %mm5
+ punpckldq %mm5, %mm5
+
+ /*\ p = sptr; v = (*p * Mx) >> 9 \*/
+ movl %esi, %eax
+ movd (%eax), %mm0
+ punpcklbw %mm7, %mm0
+ psllw $7, %mm0
+ pmulhw %mm5, %mm0
+
+ /*\ i = 0x4000 - Mx \*/
+ movl $0x4000, %ebx
+ subl Mx, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ v += (*++p * Cx) >> 9 \*/
+ addl $4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $7, %mm1
+ pmulhw %mm3, %mm1
+ paddw %mm1, %mm0
+
+ /*\ i -= Cx; while (i > Cx) \*/
+ subl Cx, %ebx
+2:
+ cmpl Cx, %ebx
+ jg 1b
+
+ /*\ mm6 = i \*/
+ movd %ebx, %mm6
+ punpcklwd %mm6, %mm6
+ punpckldq %mm6, %mm6
+
+ /*\ v += (*++p * i) >> 9 \*/
+ addl $4, %eax
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $7, %mm1
+ pmulhw %mm6, %mm1
+ paddw %mm1, %mm0
+5:
+ /*\ v *= My \*/
+ movd My, %mm4
+ punpcklwd %mm4, %mm4
+ punpckldq %mm4, %mm4
+ psllw $2, %mm0
+ pmulhw %mm4, %mm0
+
+ /*\ j = 0x4000 - My \*/
+ movl $0x4000, %edx
+ subl My, %edx
+ jbe 6f
+ jmp 4f
+3:
+ /*\ sptr += sow; p = sptr \*/
+ addl sow_4, %esi
+ movl %esi, %eax
+ /*\ vx = (*p * Mx) >> 9 \*/
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $7, %mm1
+ pmulhw %mm5, %mm1
+
+ /*\ i = 0x4000 - Mx \*/
+ movl $0x4000, %ebx
+ subl Mx, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ vx += (*++p * Cx) >> 9 \*/
+ addl $4, %eax
+ movd (%eax), %mm2
+ punpcklbw %mm7, %mm2
+ psllw $7, %mm2
+ pmulhw %mm3, %mm2
+ paddw %mm2, %mm1
+
+ /*\ i -= Cx; while (i > Cx) \*/
+ subl Cx, %ebx
+2:
+ cmpl Cx, %ebx
+ jg 1b
+
+ /*\ vx += (*++p * i) >> 9 \*/
+ addl $4, %eax
+ movd (%eax), %mm2
+ punpcklbw %mm7, %mm2
+ psllw $7, %mm2
+ pmulhw %mm6, %mm2
+ paddw %mm2, %mm1
+5:
+ /*\ v += (vx * Cy) >> 14 \*/
+ movd Cy, %mm4
+ punpcklwd %mm4, %mm4
+ punpckldq %mm4, %mm4
+ psllw $2, %mm1
+ pmulhw %mm4, %mm1
+ paddw %mm1, %mm0
+
+ /*\ j -= Cy; while (j > Cy) \*/
+ subl Cy, %edx
+4:
+ cmpl Cy, %edx
+ jg 3b
+
+ /*\ sptr += sow; p = sptr \*/
+ addl sow_4, %esi
+ movl %esi, %eax
+ /*\ vx = (*p * Mx) >> 9 \*/
+ movd (%eax), %mm1
+ punpcklbw %mm7, %mm1
+ psllw $7, %mm1
+ pmulhw %mm5, %mm1
+
+ /*\ i = 0x4000 - Mx \*/
+ movl $0x4000, %ebx
+ subl Mx, %ebx
+ jbe 5f
+ jmp 2f
+1:
+ /*\ vx += (*++p * Cx) >> 9 \*/
+ addl $4, %eax
+ movd (%eax), %mm2
+ punpcklbw %mm7, %mm2
+ psllw $7, %mm2
+ pmulhw %mm3, %mm2
+ paddw %mm2, %mm1
+
+ /*\ i -= Cx; while (i > Cx) \*/
+ subl Cx, %ebx
+2:
+ cmpl Cx, %ebx
+ jg 1b
+
+ /*\ vx += (*++p * i) >> 9 \*/
+ addl $4, %eax
+ movd (%eax), %mm2
+ punpcklbw %mm7, %mm2
+ psllw $7, %mm2
+ pmulhw %mm6, %mm2
+ paddw %mm2, %mm1
+5:
+ /*\ v += (vx * j) >> 14 \*/
+ movd %edx, %mm4
+ punpcklwd %mm4, %mm4
+ punpckldq %mm4, %mm4
+ psllw $2, %mm1
+ pmulhw %mm4, %mm1
+ paddw %mm1, %mm0
+6:
+ /*\ dptr[x] = mm0 >> 5 \*/
+ psrlw $5, %mm0
+ packuswb %mm0, %mm0
+ movd %mm0, (%edi, %ecx, 4)
+
+ /*\ while (++x) \*/
+ incl %ecx
+ jnz .down_down_loop_x
+
+ /*\ dptr += dow \*/
+ movl dow, %eax
+ leal (%edi, %eax, 4), %edi
+ /*\ yap++; yp++ \*/
+ addl $4, yap
+ addl $4, yp
+ /*\ while (y--) \*/
+ decl y
+ jnz .down_down_loop_y
+
+ jmp .scale_leave
+
+.scale_leave:
+ emms
+ popl %esi
+ popl %edi
+ popl %edx
+ popl %ecx
+ popl %ebx
+ movl %ebp, %esp
+ popl %ebp
+ ret
+
+SIZE(mimageScale_mmx_AARGBA)
+
+#endif
+
+.section .note.GNU-stack,"",%progbits
diff --git a/src/sq_utils_scale.cpp b/src/sq_utils_scale.cpp
new file mode 100644
index 0000000..39ba93e
--- /dev/null
+++ b/src/sq_utils_scale.cpp
@@ -0,0 +1,1933 @@
+// This file includes code for scaling images, in two versions.
+// One ported from ImageMagick (slower, but can achieve better quality),
+// and from Imlib2 ported by Mosfet (very fast).
+
+
+// ImageMagick code begin
+// ----------------------
+
+// This code is ImageMagick's resize code, adapted for TQImage, with
+// fastfloat class added as an optimization.
+// The original license text follows.
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% RRRR EEEEE SSSSS IIIII ZZZZZ EEEEE %
+% R R E SS I ZZ E %
+% RRRR EEE SSS I ZZZ EEE %
+% R R E SS I ZZ E %
+% R R EEEEE SSSSS IIIII ZZZZZ EEEEE %
+% %
+% ImageMagick Image Resize Methods %
+% %
+% %
+% Software Design %
+% John Cristy %
+% July 1992 %
+% %
+% %
+% Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated %
+% to making software imaging solutions freely available. %
+% %
+% Permission is hereby granted, free of charge, to any person obtaining a %
+% copy of this software and associated documentation files ("ImageMagick"), %
+% to deal in ImageMagick without restriction, including without limitation %
+% the rights to use, copy, modify, merge, publish, distribute, sublicense, %
+% and/or sell copies of ImageMagick, and to permit persons to whom the %
+% ImageMagick is furnished to do so, subject to the following conditions: %
+% %
+% The above copyright notice and this permission notice shall be included in %
+% all copies or substantial portions of ImageMagick. %
+% %
+% The software is provided "as is", without warranty of any kind, express or %
+% implied, including but not limited to the warranties of merchantability, %
+% fitness for a particular purpose and noninfringement. In no event shall %
+% ImageMagick Studio be liable for any claim, damages or other liability, %
+% whether in an action of contract, tort or otherwise, arising from, out of %
+% or in connection with ImageMagick or the use or other dealings in %
+% ImageMagick. %
+% %
+% Except as contained in this notice, the name of the ImageMagick Studio %
+% shall not be used in advertising or otherwise to promote the sale, use or %
+% other dealings in ImageMagick without prior written authorization from the %
+% ImageMagick Studio. %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%
+*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+// System
+#ifdef HAVE_ENDIAN_H
+#include <endian.h>
+#else
+#ifdef HAVE_SYS_ENDIAN_H
+#include <sys/endian.h>
+#endif
+#endif
+
+#include <tqimage.h>
+#include <tqcolor.h>
+
+#include <tdeversion.h>
+#include <kcpuinfo.h>
+
+#include <cstring>
+#include <cstdlib>
+
+#include "sq_utils.h"
+
+// everything in namespace
+namespace SQ_Utils {
+
+#define Max TQMAX
+#define Min TQMIN
+
+// mustn't be less than used precision (i.e. 1/fastfloat::RATIO)
+#define MagickEpsilon 0.0002
+
+// fastfloat begin
+// this class stores floating point numbers as integers, with BITS shift,
+// i.e. value XYZ is stored as XYZ * RATIO
+struct fastfloat
+ {
+ private:
+ enum { BITS = 12, RATIO = 4096 };
+ public:
+ fastfloat() {}
+ fastfloat( long v ) : value( v << BITS ) {}
+ fastfloat( int v ) : value( v << BITS ) {}
+ fastfloat( double v ) : value( static_cast< long >( v * RATIO + 0.5 )) {}
+ double toDouble() const { return static_cast< double >( value ) / RATIO; }
+ long toLong() const { return value >> BITS; }
+ fastfloat& operator += ( fastfloat r ) { value += r.value; return *this; }
+ fastfloat& operator -= ( fastfloat r ) { value -= r.value; return *this; }
+ fastfloat& operator *= ( fastfloat r ) { value = static_cast< long long >( value ) * r.value >> BITS; return *this; }
+ fastfloat& operator /= ( fastfloat r ) { value = ( static_cast< long long >( value ) << BITS ) / r.value; return *this; }
+ bool operator< ( fastfloat r ) const { return value < r.value; }
+ bool operator<= ( fastfloat r ) const { return value <= r.value; }
+ bool operator> ( fastfloat r ) const { return value > r.value; }
+ bool operator>= ( fastfloat r ) const { return value >= r.value; }
+ bool operator== ( fastfloat r ) const { return value == r.value; }
+ bool operator!= ( fastfloat r ) const { return value != r.value; }
+ fastfloat operator-() const { return fastfloat( -value, false ); }
+ private:
+ fastfloat( long v, bool ) : value( v ) {} // for operator-()
+ long value;
+ };
+
+inline fastfloat operator+ ( fastfloat l, fastfloat r ) { return fastfloat( l ) += r; }
+inline fastfloat operator- ( fastfloat l, fastfloat r ) { return fastfloat( l ) -= r; }
+inline fastfloat operator* ( fastfloat l, fastfloat r ) { return fastfloat( l ) *= r; }
+inline fastfloat operator/ ( fastfloat l, fastfloat r ) { return fastfloat( l ) /= r; }
+
+inline bool operator< ( fastfloat l, double r ) { return l < fastfloat( r ); }
+inline bool operator<= ( fastfloat l, double r ) { return l <= fastfloat( r ); }
+inline bool operator> ( fastfloat l, double r ) { return l > fastfloat( r ); }
+inline bool operator>= ( fastfloat l, double r ) { return l >= fastfloat( r ); }
+inline bool operator== ( fastfloat l, double r ) { return l == fastfloat( r ); }
+inline bool operator!= ( fastfloat l, double r ) { return l != fastfloat( r ); }
+
+inline bool operator< ( double l, fastfloat r ) { return fastfloat( l ) < r ; }
+inline bool operator<= ( double l, fastfloat r ) { return fastfloat( l ) <= r ; }
+inline bool operator> ( double l, fastfloat r ) { return fastfloat( l ) > r ; }
+inline bool operator>= ( double l, fastfloat r ) { return fastfloat( l ) >= r ; }
+inline bool operator== ( double l, fastfloat r ) { return fastfloat( l ) == r ; }
+inline bool operator!= ( double l, fastfloat r ) { return fastfloat( l ) != r ; }
+
+inline double fasttodouble( fastfloat v ) { return v.toDouble(); }
+inline long fasttolong( fastfloat v ) { return v.toLong(); }
+
+#if 1 // change to 0 to turn fastfloat usage off
+#else
+#define fastfloat double
+#define fasttodouble( v ) double( v )
+#define fasttolong( v ) long( v )
+#endif
+
+//fastfloat end
+
+
+typedef fastfloat (*Filter)(const fastfloat, const fastfloat);
+
+typedef struct _ContributionInfo
+{
+ fastfloat
+ weight;
+
+ long
+ pixel;
+} ContributionInfo;
+
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% R e s i z e I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% ResizeImage() scales an image to the desired dimensions with one of these
+% filters:
+%
+% Bessel Blackman Box
+% Catrom Cubic Gaussian
+% Hanning Hermite Lanczos
+% Mitchell Point Quandratic
+% Sinc Triangle
+%
+% Most of the filters are FIR (finite impulse response), however, Bessel,
+% Gaussian, and Sinc are IIR (infinite impulse response). Bessel and Sinc
+% are windowed (brought down to zero) with the Blackman filter.
+%
+% ResizeImage() was inspired by Paul Heckbert's zoom program.
+%
+% The format of the ResizeImage method is:
+%
+% Image *ResizeImage(Image *image,const unsigned long columns,
+% const unsigned long rows,const FilterTypes filter,const double blur,
+% ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o image: The image.
+%
+% o columns: The number of columns in the scaled image.
+%
+% o rows: The number of rows in the scaled image.
+%
+% o filter: Image filter to use.
+%
+% o blur: The blur factor where > 1 is blurry, < 1 is sharp.
+%
+% o exception: Return any errors or warnings in this structure.
+%
+%
+*/
+
+#if 0
+static fastfloat Bessel(const fastfloat x,const fastfloat)
+{
+ if (x == 0.0)
+ return(MagickPI/4.0);
+ return(BesselOrderOne(MagickPI*x)/(2.0*x));
+}
+
+static fastfloat Sinc(const fastfloat x,const fastfloat)
+{
+ if (x == 0.0)
+ return(1.0);
+ return(sin(MagickPI*x)/(MagickPI*x));
+}
+
+static fastfloat Blackman(const fastfloat x,const fastfloat)
+{
+ return(0.42+0.5*cos(MagickPI*x)+0.08*cos(2*MagickPI*x));
+}
+
+static fastfloat BlackmanBessel(const fastfloat x,const fastfloat)
+{
+ return(Blackman(x/support,support)*Bessel(x,support));
+}
+
+static fastfloat BlackmanSinc(const fastfloat x,const fastfloat)
+{
+ return(Blackman(x/support,support)*Sinc(x,support));
+}
+#endif
+
+static fastfloat Box(const fastfloat x,const fastfloat)
+{
+ if (x < -0.5)
+ return(0.0);
+ if (x < 0.5)
+ return(1.0);
+ return(0.0);
+}
+
+#if 0
+static fastfloat Catrom(const fastfloat x,const fastfloat)
+{
+ if (x < -2.0)
+ return(0.0);
+ if (x < -1.0)
+ return(0.5*(4.0+x*(8.0+x*(5.0+x))));
+ if (x < 0.0)
+ return(0.5*(2.0+x*x*(-5.0-3.0*x)));
+ if (x < 1.0)
+ return(0.5*(2.0+x*x*(-5.0+3.0*x)));
+ if (x < 2.0)
+ return(0.5*(4.0+x*(-8.0+x*(5.0-x))));
+ return(0.0);
+}
+
+static fastfloat Cubic(const fastfloat x,const fastfloat)
+{
+ if (x < -2.0)
+ return(0.0);
+ if (x < -1.0)
+ return((2.0+x)*(2.0+x)*(2.0+x)/6.0);
+ if (x < 0.0)
+ return((4.0+x*x*(-6.0-3.0*x))/6.0);
+ if (x < 1.0)
+ return((4.0+x*x*(-6.0+3.0*x))/6.0);
+ if (x < 2.0)
+ return((2.0-x)*(2.0-x)*(2.0-x)/6.0);
+ return(0.0);
+}
+
+static fastfloat Gaussian(const fastfloat x,const fastfloat)
+{
+ return(exp(-2.0*x*x)*sqrt(2.0/MagickPI));
+}
+
+static fastfloat Hanning(const fastfloat x,const fastfloat)
+{
+ return(0.5+0.5*cos(MagickPI*x));
+}
+
+static fastfloat Hamming(const fastfloat x,const fastfloat)
+{
+ return(0.54+0.46*cos(MagickPI*x));
+}
+
+static fastfloat Hermite(const fastfloat x,const fastfloat)
+{
+ if (x < -1.0)
+ return(0.0);
+ if (x < 0.0)
+ return((2.0*(-x)-3.0)*(-x)*(-x)+1.0);
+ if (x < 1.0)
+ return((2.0*x-3.0)*x*x+1.0);
+ return(0.0);
+}
+
+static fastfloat Lanczos(const fastfloat x,const fastfloat support)
+{
+ if (x < -3.0)
+ return(0.0);
+ if (x < 0.0)
+ return(Sinc(-x,support)*Sinc(-x/3.0,support));
+ if (x < 3.0)
+ return(Sinc(x,support)*Sinc(x/3.0,support));
+ return(0.0);
+}
+
+static fastfloat Mitchell(const fastfloat x,const fastfloat)
+{
+#define B (1.0/3.0)
+#define C (1.0/3.0)
+#define P0 (( 6.0- 2.0*B )/6.0)
+#define P2 ((-18.0+12.0*B+ 6.0*C)/6.0)
+#define P3 (( 12.0- 9.0*B- 6.0*C)/6.0)
+#define Q0 (( 8.0*B+24.0*C)/6.0)
+#define Q1 (( -12.0*B-48.0*C)/6.0)
+#define Q2 (( 6.0*B+30.0*C)/6.0)
+#define Q3 (( - 1.0*B- 6.0*C)/6.0)
+
+ if (x < -2.0)
+ return(0.0);
+ if (x < -1.0)
+ return(Q0-x*(Q1-x*(Q2-x*Q3)));
+ if (x < 0.0)
+ return(P0+x*x*(P2-x*P3));
+ if (x < 1.0)
+ return(P0+x*x*(P2+x*P3));
+ if (x < 2.0)
+ return(Q0+x*(Q1+x*(Q2+x*Q3)));
+ return(0.0);
+
+#undef B
+#undef C
+#undef P0
+#undef P2
+#undef P3
+#undef Q0
+#undef Q1
+#undef Q2
+#undef Q3
+}
+#endif
+
+// this is the same like Mitchell, but it has different values
+// for B and C, resulting in sharper images
+// http://sourceforge.net/mailarchive/forum.php?thread_id=7445822&forum_id=1210
+static fastfloat Bicubic(const fastfloat x,const fastfloat)
+{
+#define B (0.0/3.0)
+#define C (2.0/3.0)
+#define P0 (( 6.0- 2.0*B )/6.0)
+#define P2 ((-18.0+12.0*B+ 6.0*C)/6.0)
+#define P3 (( 12.0- 9.0*B- 6.0*C)/6.0)
+#define Q0 (( 8.0*B+24.0*C)/6.0)
+#define Q1 (( -12.0*B-48.0*C)/6.0)
+#define Q2 (( 6.0*B+30.0*C)/6.0)
+#define Q3 (( - 1.0*B- 6.0*C)/6.0)
+
+ if (x < -2.0)
+ return(0.0);
+ if (x < -1.0)
+ return(Q0-x*(Q1-x*(Q2-x*Q3)));
+ if (x < 0.0)
+ return(P0+x*x*(P2-x*P3));
+ if (x < 1.0)
+ return(P0+x*x*(P2+x*P3));
+ if (x < 2.0)
+ return(Q0+x*(Q1+x*(Q2+x*Q3)));
+ return(0.0);
+
+#undef B
+#undef C
+#undef P0
+#undef P2
+#undef P3
+#undef Q0
+#undef Q1
+#undef Q2
+#undef Q3
+}
+
+#if 0
+static fastfloat Quadratic(const fastfloat x,const fastfloat)
+{
+ if (x < -1.5)
+ return(0.0);
+ if (x < -0.5)
+ return(0.5*(x+1.5)*(x+1.5));
+ if (x < 0.5)
+ return(0.75-x*x);
+ if (x < 1.5)
+ return(0.5*(x-1.5)*(x-1.5));
+ return(0.0);
+}
+#endif
+
+static fastfloat Triangle(const fastfloat x,const fastfloat)
+{
+ if (x < -1.0)
+ return(0.0);
+ if (x < 0.0)
+ return(1.0+x);
+ if (x < 1.0)
+ return(1.0-x);
+ return(0.0);
+}
+
+static void HorizontalFilter(const TQImage& source,TQImage& destination,
+ const fastfloat x_factor,const fastfloat blur,
+ ContributionInfo *contribution, Filter filter, fastfloat filtersupport)
+{
+ fastfloat
+ center,
+ density,
+ scale,
+ support;
+
+ long
+ n,
+ start,
+ stop,
+ y;
+
+ long
+ i,
+ x;
+
+ /*
+ Apply filter to resize horizontally from source to destination.
+ */
+ scale=blur*Max(1.0/x_factor,1.0);
+ support=scale* filtersupport;
+ if (support <= 0.5)
+ {
+ /*
+ Reduce to point sampling.
+ */
+ support=0.5+MagickEpsilon;
+ scale=1.0;
+ }
+ scale=1.0/scale;
+ for (x=0; x < (long) destination.width(); x++)
+ {
+ center=(fastfloat) (x+0.5)/x_factor;
+ start= fasttolong(Max(center-support+0.5,0));
+ stop= fasttolong(Min(center+support+0.5,source.width()));
+ density=0.0;
+ for (n=0; n < (stop-start); n++)
+ {
+ contribution[n].pixel=start+n;
+ contribution[n].weight=
+ filter (scale*(start+n-center+0.5), filtersupport );
+ density+=contribution[n].weight;
+ }
+ if ((density != 0.0) && (density != 1.0))
+ {
+ /*
+ Normalize.
+ */
+ density=1.0/density;
+ for (i=0; i < n; i++)
+ contribution[i].weight*=density;
+ }
+// p=AcquireImagePixels(source,contribution[0].pixel,0,contribution[n-1].pixel-
+// contribution[0].pixel+1,source->rows,exception);
+// q=SetImagePixels(destination,x,0,1,destination->rows);
+ for (y=0; y < (long) destination.height(); y++)
+ {
+ fastfloat red = 0;
+ fastfloat green = 0;
+ fastfloat blue = 0;
+ fastfloat alpha = 0;
+ for (i=0; i < n; i++)
+ {
+ int px = contribution[i].pixel;
+ int py = y;
+ TQRgb p = reinterpret_cast< TQRgb* >( const_cast<TQImage&>(source).jumpTable()[ py ])[ px ];
+ red+=contribution[i].weight*tqRed(p);
+ green+=contribution[i].weight*tqGreen(p);
+ blue+=contribution[i].weight*tqBlue(p);
+ alpha+=contribution[i].weight*tqAlpha(p);
+ }
+ TQRgb pix = tqRgba(
+ fasttolong( red < 0 ? 0 : red > 255 ? 255 : red + 0.5 ),
+ fasttolong( green < 0 ? 0 : green > 255 ? 255 : green + 0.5 ),
+ fasttolong( blue < 0 ? 0 : blue > 255 ? 255 : blue + 0.5 ),
+ fasttolong( alpha < 0 ? 0 : alpha > 255 ? 255 : alpha + 0.5 ));
+ reinterpret_cast< TQRgb* >( const_cast<TQImage&>(destination).jumpTable()[ y ])[ x ] = pix;
+ }
+ }
+}
+
+static void VerticalFilter(const TQImage& source,TQImage& destination,
+ const fastfloat y_factor,const fastfloat blur,
+ ContributionInfo *contribution, Filter filter, fastfloat filtersupport )
+{
+ fastfloat
+ center,
+ density,
+ scale,
+ support;
+
+ long
+ n,
+ start,
+ stop,
+ x;
+
+ long
+ i,
+ y;
+
+ /*
+ Apply filter to resize vertically from source to destination.
+ */
+ scale=blur*Max(1.0/y_factor,1.0);
+ support=scale* filtersupport;
+ if (support <= 0.5)
+ {
+ /*
+ Reduce to point sampling.
+ */
+ support=0.5+MagickEpsilon;
+ scale=1.0;
+ }
+ scale=1.0/scale;
+ for (y=0; y < (long) destination.height(); y++)
+ {
+ center=(fastfloat) (y+0.5)/y_factor;
+ start= fasttolong(Max(center-support+0.5,0));
+ stop= fasttolong(Min(center+support+0.5,source.height()));
+ density=0.0;
+ for (n=0; n < (stop-start); n++)
+ {
+ contribution[n].pixel=start+n;
+ contribution[n].weight=
+ filter (scale*(start+n-center+0.5), filtersupport);
+ density+=contribution[n].weight;
+ }
+ if ((density != 0.0) && (density != 1.0))
+ {
+ /*
+ Normalize.
+ */
+ density=1.0/density;
+ for (i=0; i < n; i++)
+ contribution[i].weight*=density;
+ }
+// p=AcquireImagePixels(source,0,contribution[0].pixel,source->columns,
+// contribution[n-1].pixel-contribution[0].pixel+1,exception);
+// q=SetImagePixels(destination,0,y,destination->columns,1);
+ for (x=0; x < (long) destination.width(); x++)
+ {
+ fastfloat red = 0;
+ fastfloat green = 0;
+ fastfloat blue = 0;
+ fastfloat alpha = 0;
+ for (i=0; i < n; i++)
+ {
+ int px = x;
+ int py = contribution[i].pixel;
+ TQRgb p = reinterpret_cast< TQRgb* >( const_cast<TQImage&>(source).jumpTable()[ py ])[ px ];
+ red+=contribution[i].weight*tqRed(p);
+ green+=contribution[i].weight*tqGreen(p);
+ blue+=contribution[i].weight*tqBlue(p);
+ alpha+=contribution[i].weight*tqAlpha(p);
+ }
+ TQRgb pix = tqRgba(
+ fasttolong( red < 0 ? 0 : red > 255 ? 255 : red + 0.5 ),
+ fasttolong( green < 0 ? 0 : green > 255 ? 255 : green + 0.5 ),
+ fasttolong( blue < 0 ? 0 : blue > 255 ? 255 : blue + 0.5 ),
+ fasttolong( alpha < 0 ? 0 : alpha > 255 ? 255 : alpha + 0.5 ));
+ reinterpret_cast< TQRgb* >( const_cast<TQImage&>(destination).jumpTable()[ y ])[ x ] = pix;
+ }
+ }
+}
+
+static TQImage ResizeImage(const TQImage& image,const int columns,
+ const int rows, Filter filter, fastfloat filtersupport, double blur)
+{
+ ContributionInfo
+ *contribution;
+
+ fastfloat
+ support,
+ x_factor,
+ x_support,
+ y_factor,
+ y_support;
+
+ /*
+ Initialize resize image attributes.
+ */
+ if ((columns == image.width()) && (rows == image.height()) && (blur == 1.0))
+ return image.copy();
+ TQImage resize_image( columns, rows, 32 );
+ resize_image.setAlphaBuffer( image.hasAlphaBuffer());
+ /*
+ Allocate filter contribution info.
+ */
+ x_factor=(fastfloat) resize_image.width()/image.width();
+ y_factor=(fastfloat) resize_image.height()/image.height();
+// i=(long) LanczosFilter;
+// if (image->filter != UndefinedFilter)
+// i=(long) image->filter;
+// else
+// if ((image->storage_class == PseudoClass) || image->matte ||
+// ((x_factor*y_factor) > 1.0))
+// i=(long) MitchellFilter;
+ x_support=blur*Max(1.0/x_factor,1.0)*filtersupport;
+ y_support=blur*Max(1.0/y_factor,1.0)*filtersupport;
+ support=Max(x_support,y_support);
+ if (support < filtersupport)
+ support=filtersupport;
+ contribution=new ContributionInfo[ fasttolong( 2.0*Max(support,0.5)+3 ) ];
+ TQ_CHECK_PTR( contribution );
+ /*
+ Resize image.
+ */
+ if (((fastfloat) columns*(image.height()+rows)) >
+ ((fastfloat) rows*(image.width()+columns)))
+ {
+ TQImage source_image( columns, image.height(), 32 );
+ source_image.setAlphaBuffer( image.hasAlphaBuffer());
+ HorizontalFilter(image,source_image,x_factor,blur,
+ contribution,filter,filtersupport);
+ VerticalFilter(source_image,resize_image,y_factor,
+ blur,contribution,filter,filtersupport);
+ }
+ else
+ {
+ TQImage source_image( image.width(), rows, 32 );
+ source_image.setAlphaBuffer( image.hasAlphaBuffer());
+ VerticalFilter(image,source_image,y_factor,blur,
+ contribution,filter,filtersupport);
+ HorizontalFilter(source_image,resize_image,x_factor,
+ blur,contribution,filter,filtersupport);
+ }
+ /*
+ Free allocated memory.
+ */
+ delete[] contribution;
+ return(resize_image);
+}
+
+
+#undef Max
+#undef Min
+#undef MagickEpsilon
+
+
+// filters and their matching support values
+#if 0
+ static const FilterInfo
+ filters[SincFilter+1] =
+ {
+ { Box, 0.0 },
+ { Box, 0.0 },
+ { Box, 0.5 },
+ { Triangle, 1.0 },
+ { Hermite, 1.0 },
+ { Hanning, 1.0 },
+ { Hamming, 1.0 },
+ { Blackman, 1.0 },
+ { Gaussian, 1.25 },
+ { Quadratic, 1.5 },
+ { Cubic, 2.0 },
+ { Catrom, 2.0 },
+ { Mitchell, 2.0 },
+ { Lanczos, 3.0 },
+ { BlackmanBessel, 3.2383 },
+ { BlackmanSinc, 4.0 }
+ };
+#endif
+
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% S a m p l e I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% SampleImage() scales an image to the desired dimensions with pixel
+% sampling. Unlike other scaling methods, this method does not introduce
+% any additional color into the scaled image.
+%
+% The format of the SampleImage method is:
+%
+% Image *SampleImage(const Image *image,const unsigned long columns,
+% const unsigned long rows,ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o image: The image.
+%
+% o columns: The number of columns in the sampled image.
+%
+% o rows: The number of rows in the sampled image.
+%
+% o exception: Return any errors or warnings in this structure.
+%
+%
+*/
+TQImage SampleImage(const TQImage& image,const int columns,
+ const int rows)
+{
+ int
+ *x_offset,
+ *y_offset;
+
+ long
+ j,
+ y;
+
+ uchar
+ *pixels;
+
+ const uchar
+ *p;
+
+ long
+ x;
+
+ uchar
+ *q;
+
+ /*
+ Initialize sampled image attributes.
+ */
+ if ((columns == image.width()) && (rows == image.height()))
+ return image;
+ // This function is modified to handle any image depth, not only
+ // 32bit like the ImageMagick original. This avoids the relatively
+ // expensive conversion.
+ const int d = image.depth() / 8;
+ TQImage sample_image( columns, rows, image.depth());
+ sample_image.setAlphaBuffer( image.hasAlphaBuffer());
+ /*
+ Allocate scan line buffer and column offset buffers.
+ */
+ pixels= new uchar[ image.width() * d ];
+ x_offset= new int[ sample_image.width() ];
+ y_offset= new int[ sample_image.height() ];
+ /*
+ Initialize pixel offsets.
+ */
+// In the following several code 0.5 needs to be added, otherwise the image
+// would be moved by half a pixel to bottom-right, just like
+// with TQt's TQImage::scale()
+ for (x=0; x < (long) sample_image.width(); x++)
+ {
+ x_offset[x]=int((x+0.5)*image.width()/sample_image.width());
+ }
+ for (y=0; y < (long) sample_image.height(); y++)
+ {
+ y_offset[y]=int((y+0.5)*image.height()/sample_image.height());
+ }
+ /*
+ Sample each row.
+ */
+ j=(-1);
+ for (y=0; y < (long) sample_image.height(); y++)
+ {
+ q= sample_image.scanLine( y );
+ if (j != y_offset[y] )
+ {
+ /*
+ Read a scan line.
+ */
+ j= y_offset[y];
+ p= image.scanLine( j );
+ (void) memcpy(pixels,p,image.width()*d);
+ }
+ /*
+ Sample each column.
+ */
+ switch( d )
+ {
+ case 1: // 8bit
+ for (x=0; x < (long) sample_image.width(); x++)
+ {
+ *q++=pixels[ x_offset[x] ];
+ }
+ break;
+ case 4: // 32bit
+ for (x=0; x < (long) sample_image.width(); x++)
+ {
+ *(TQRgb*)q=((TQRgb*)pixels)[ x_offset[x] ];
+ q += d;
+ }
+ break;
+ default:
+ for (x=0; x < (long) sample_image.width(); x++)
+ {
+ memcpy( q, pixels + x_offset[x] * d, d );
+ q += d;
+ }
+ break;
+ }
+ }
+ if( d != 4 ) // != 32bit
+ {
+ sample_image.setNumColors( image.numColors());
+ for( int i = 0; i < image.numColors(); ++i )
+ sample_image.setColor( i, image.color( i ));
+ }
+ delete[] y_offset;
+ delete[] x_offset;
+ delete[] pixels;
+ return sample_image;
+}
+
+
+// ImageMagick code end
+
+
+// Imlib2/Mosfet code begin
+// ------------------------
+
+// This code is Imlib2 code, additionally modified by Mosfet, and with few small
+// modifications for Gwenview. The MMX scaling code also belongs to it.
+
+// The original license texts follow.
+
+/**
+ * This is the normal smoothscale method, based on Imlib2's smoothscale.
+ *
+ * Originally I took the algorithm used in NetPBM and TQt and added MMX/3dnow
+ * optimizations. It ran in about 1/2 the time as TQt. Then I ported Imlib's
+ * C algorithm and it ran at about the same speed as my MMX optimized one...
+ * Finally I ported Imlib's MMX version and it ran in less than half the
+ * time as my MMX algorithm, (taking only a quarter of the time TQt does).
+ *
+ * Changes include formatting, namespaces and other C++'ings, removal of old
+ * #ifdef'ed code, and removal of unneeded border calculation code.
+ *
+ * Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code
+ * is by Willem Monsuwe <[email protected]>. All other modifications are
+ * (C) Daniel M. Duley.
+ */
+
+/*
+ Copyright (C) 2004 Daniel M. Duley <[email protected]>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+/*
+Copyright (C) 2000 Carsten Haitzler and various contributors (see AUTHORS)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies of the Software and its Copyright notices. In addition publicly
+documented acknowledgment must be given that this software has been used if no
+source code of this software is made available publicly. This includes
+acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
+documents or any documentation provided with any product containing this
+software. This License does not apply to any software that links to the
+libraries provided by this software (statically or dynamically), but only to
+the software provided.
+
+Please see the COPYING.PLAIN for a plain-english explanation of this notice
+and it's intent.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+namespace MImageScale{
+ typedef struct __mimage_scale_info
+ {
+ int *xpoints;
+ unsigned int **ypoints;
+ int *xapoints, *yapoints;
+ int xup_yup;
+ } MImageScaleInfo;
+
+ unsigned int** mimageCalcYPoints(unsigned int *src, int sow, int sh,
+ int dh);
+ int* mimageCalcXPoints(int sw, int dw);
+ int* mimageCalcApoints(int s, int d, int up);
+ MImageScaleInfo* mimageFreeScaleInfo(MImageScaleInfo *isi);
+ MImageScaleInfo *mimageCalcScaleInfo(TQImage &img, int sw, int sh,
+ int dw, int dh, char aa, int sow);
+ void mimageSampleRGBA(MImageScaleInfo *isi, unsigned int *dest, int dxx,
+ int dyy, int dx, int dy, int dw, int dh, int dow);
+ void mimageScaleAARGBA(MImageScaleInfo *isi, unsigned int *dest, int dxx,
+ int dyy, int dx, int dy, int dw, int dh, int dow,
+ int sow);
+ void mimageScaleAARGB(MImageScaleInfo *isi, unsigned int *dest, int dxx,
+ int dyy, int dx, int dy, int dw, int dh, int dow, int
+ sow);
+ TQImage smoothScale(const TQImage& img, int dw, int dh);
+}
+
+#ifdef HAVE_X86_MMX
+extern "C" {
+ void __mimageScale_mmx_AARGBA(MImageScale::MImageScaleInfo *isi,
+ unsigned int *dest, int dxx, int dyy,
+ int dx, int dy, int dw, int dh,
+ int dow, int sow);
+}
+#endif
+
+using namespace MImageScale;
+
+TQImage MImageScale::smoothScale(const TQImage& image, int dw, int dh)
+{
+ TQImage img = image.depth() < 32 ? image.convertDepth( 32 ) : image;
+ int w = img.width();
+ int h = img.height();
+
+ int sow = img.bytesPerLine();
+ // handle CroppedTQImage
+ if( img.height() > 1 && sow != img.scanLine( 1 ) - img.scanLine( 0 ))
+ sow = img.scanLine( 1 ) - img.scanLine( 0 );
+ sow = sow / ( img.depth() / 8 );
+
+ MImageScaleInfo *scaleinfo =
+ mimageCalcScaleInfo(img, w, h, dw, dh, true, sow);
+ if(!scaleinfo)
+ return TQImage();
+
+ TQImage buffer(dw, dh, 32);
+ buffer.setAlphaBuffer(img.hasAlphaBuffer());
+
+#ifdef HAVE_X86_MMX
+//#warning Using MMX Smoothscale
+ bool haveMMX = KCPUInfo::haveExtension( KCPUInfo::IntelMMX );
+ if(haveMMX){
+ __mimageScale_mmx_AARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0),
+ 0, 0, 0, 0, dw, dh, dw, sow);
+ }
+ else
+#endif
+ {
+ if(img.hasAlphaBuffer())
+ mimageScaleAARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0), 0, 0,
+ 0, 0, dw, dh, dw, sow);
+ else
+ mimageScaleAARGB(scaleinfo, (unsigned int *)buffer.scanLine(0), 0, 0,
+ 0, 0, dw, dh, dw, sow);
+ }
+ mimageFreeScaleInfo(scaleinfo);
+ return(buffer);
+}
+
+//
+// Code ported from Imlib...
+//
+
+// FIXME: replace with mRed, etc... These work on pointers to pixels, not
+// pixel values
+#if BYTE_ORDER == BIG_ENDIAN
+#define A_VAL(p) ((unsigned char *)(p))[0]
+#define R_VAL(p) ((unsigned char *)(p))[1]
+#define G_VAL(p) ((unsigned char *)(p))[2]
+#define B_VAL(p) ((unsigned char *)(p))[3]
+#elif BYTE_ORDER == LITTLE_ENDIAN
+#define A_VAL(p) ((unsigned char *)(p))[3]
+#define R_VAL(p) ((unsigned char *)(p))[2]
+#define G_VAL(p) ((unsigned char *)(p))[1]
+#define B_VAL(p) ((unsigned char *)(p))[0]
+#else
+#error "BYTE_ORDER is not defined"
+#endif
+
+#define INV_XAP (256 - xapoints[x])
+#define XAP (xapoints[x])
+#define INV_YAP (256 - yapoints[dyy + y])
+#define YAP (yapoints[dyy + y])
+
+unsigned int** MImageScale::mimageCalcYPoints(unsigned int *src,
+ int sow, int sh, int dh)
+{
+ unsigned int **p;
+ int i, j = 0;
+ int val, inc, rv = 0;
+
+ if(dh < 0){
+ dh = -dh;
+ rv = 1;
+ }
+ p = new unsigned int* [dh+1];
+
+ val = 0;
+ inc = (sh << 16) / dh;
+ for(i = 0; i < dh; i++){
+ p[j++] = src + ((val >> 16) * sow);
+ val += inc;
+ }
+ if(rv){
+ for(i = dh / 2; --i >= 0; ){
+ unsigned int *tmp = p[i];
+ p[i] = p[dh - i - 1];
+ p[dh - i - 1] = tmp;
+ }
+ }
+ return(p);
+}
+
+int* MImageScale::mimageCalcXPoints(int sw, int dw)
+{
+ int *p, i, j = 0;
+ int val, inc, rv = 0;
+
+ if(dw < 0){
+ dw = -dw;
+ rv = 1;
+ }
+ p = new int[dw+1];
+
+ val = 0;
+ inc = (sw << 16) / dw;
+ for(i = 0; i < dw; i++){
+ p[j++] = (val >> 16);
+ val += inc;
+ }
+
+ if(rv){
+ for(i = dw / 2; --i >= 0; ){
+ int tmp = p[i];
+ p[i] = p[dw - i - 1];
+ p[dw - i - 1] = tmp;
+ }
+ }
+ return(p);
+}
+
+int* MImageScale::mimageCalcApoints(int s, int d, int up)
+{
+ int *p, i, j = 0, rv = 0;
+
+ if(d < 0){
+ rv = 1;
+ d = -d;
+ }
+ p = new int[d];
+
+ /* scaling up */
+ if(up){
+ int val, inc;
+
+ val = 0;
+ inc = (s << 16) / d;
+ for(i = 0; i < d; i++){
+ p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00);
+ if((val >> 16) >= (s - 1))
+ p[j - 1] = 0;
+ val += inc;
+ }
+ }
+ /* scaling down */
+ else{
+ int val, inc, ap, Cp;
+ val = 0;
+ inc = (s << 16) / d;
+ Cp = ((d << 14) / s) + 1;
+ for(i = 0; i < d; i++){
+ ap = ((0x100 - ((val >> 8) & 0xff)) * Cp) >> 8;
+ p[j] = ap | (Cp << 16);
+ j++;
+ val += inc;
+ }
+ }
+ if(rv){
+ int tmp;
+ for(i = d / 2; --i >= 0; ){
+ tmp = p[i];
+ p[i] = p[d - i - 1];
+ p[d - i - 1] = tmp;
+ }
+ }
+ return(p);
+}
+
+MImageScaleInfo* MImageScale::mimageFreeScaleInfo(MImageScaleInfo *isi)
+{
+ if(isi){
+ delete[] isi->xpoints;
+ delete[] isi->ypoints;
+ delete[] isi->xapoints;
+ delete[] isi->yapoints;
+ delete isi;
+ }
+ return(NULL);
+}
+
+MImageScaleInfo* MImageScale::mimageCalcScaleInfo(TQImage &img, int sw, int sh,
+ int dw, int dh, char aa, int sow)
+{
+ MImageScaleInfo *isi;
+ int scw, sch;
+
+ scw = dw * img.width() / sw;
+ sch = dh * img.height() / sh;
+
+ isi = new MImageScaleInfo;
+ if(!isi)
+ return(NULL);
+ memset(isi, 0, sizeof(MImageScaleInfo));
+
+ isi->xup_yup = (abs(dw) >= sw) + ((abs(dh) >= sh) << 1);
+
+ isi->xpoints = mimageCalcXPoints(img.width(), scw);
+ if(!isi->xpoints)
+ return(mimageFreeScaleInfo(isi));
+ isi->ypoints = mimageCalcYPoints((unsigned int *)img.scanLine(0),
+ sow, img.height(), sch );
+ if (!isi->ypoints)
+ return(mimageFreeScaleInfo(isi));
+ if(aa){
+ isi->xapoints = mimageCalcApoints(img.width(), scw, isi->xup_yup & 1);
+ if(!isi->xapoints)
+ return(mimageFreeScaleInfo(isi));
+ isi->yapoints = mimageCalcApoints(img.height(), sch, isi->xup_yup & 2);
+ if(!isi->yapoints)
+ return(mimageFreeScaleInfo(isi));
+ }
+ return(isi);
+}
+
+/* scale by pixel sampling only */
+void MImageScale::mimageSampleRGBA(MImageScaleInfo *isi, unsigned int *dest,
+ int dxx, int dyy, int dx, int dy, int dw,
+ int dh, int dow)
+{
+ unsigned int *sptr, *dptr;
+ int x, y, end;
+ unsigned int **ypoints = isi->ypoints;
+ int *xpoints = isi->xpoints;
+
+ /* whats the last pixel ont he line so we stop there */
+ end = dxx + dw;
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ /* get the pointer to the start of the destination scanline */
+ dptr = dest + dx + ((y + dy) * dow);
+ /* calculate the source line we'll scan from */
+ sptr = ypoints[dyy + y];
+ /* go thru the scanline and copy across */
+ for(x = dxx; x < end; x++)
+ *dptr++ = sptr[xpoints[x]];
+ }
+}
+
+/* FIXME: NEED to optimise ScaleAARGBA - currently its "ok" but needs work*/
+
+/* scale by area sampling */
+void MImageScale::mimageScaleAARGBA(MImageScaleInfo *isi, unsigned int *dest,
+ int dxx, int dyy, int dx, int dy, int dw,
+ int dh, int dow, int sow)
+{
+ unsigned int *sptr, *dptr;
+ int x, y, end;
+ unsigned int **ypoints = isi->ypoints;
+ int *xpoints = isi->xpoints;
+ int *xapoints = isi->xapoints;
+ int *yapoints = isi->yapoints;
+
+ end = dxx + dw;
+ /* scaling up both ways */
+ if(isi->xup_yup == 3){
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ /* calculate the source line we'll scan from */
+ dptr = dest + dx + ((y + dy) * dow);
+ sptr = ypoints[dyy + y];
+ if(YAP > 0){
+ for(x = dxx; x < end; x++){
+ int r, g, b, a;
+ int rr, gg, bb, aa;
+ unsigned int *pix;
+
+ if(XAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ a = A_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ a += A_VAL(pix) * XAP;
+ pix += sow;
+ rr = R_VAL(pix) * XAP;
+ gg = G_VAL(pix) * XAP;
+ bb = B_VAL(pix) * XAP;
+ aa = A_VAL(pix) * XAP;
+ pix--;
+ rr += R_VAL(pix) * INV_XAP;
+ gg += G_VAL(pix) * INV_XAP;
+ bb += B_VAL(pix) * INV_XAP;
+ aa += A_VAL(pix) * INV_XAP;
+ r = ((rr * YAP) + (r * INV_YAP)) >> 16;
+ g = ((gg * YAP) + (g * INV_YAP)) >> 16;
+ b = ((bb * YAP) + (b * INV_YAP)) >> 16;
+ a = ((aa * YAP) + (a * INV_YAP)) >> 16;
+ *dptr++ = tqRgba(r, g, b, a);
+ }
+ else{
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_YAP;
+ g = G_VAL(pix) * INV_YAP;
+ b = B_VAL(pix) * INV_YAP;
+ a = A_VAL(pix) * INV_YAP;
+ pix += sow;
+ r += R_VAL(pix) * YAP;
+ g += G_VAL(pix) * YAP;
+ b += B_VAL(pix) * YAP;
+ a += A_VAL(pix) * YAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ a >>= 8;
+ *dptr++ = tqRgba(r, g, b, a);
+ }
+ }
+ }
+ else{
+ for(x = dxx; x < end; x++){
+ int r, g, b, a;
+ unsigned int *pix;
+
+ if(XAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ a = A_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ a += A_VAL(pix) * XAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ a >>= 8;
+ *dptr++ = tqRgba(r, g, b, a);
+ }
+ else
+ *dptr++ = sptr[xpoints[x] ];
+ }
+ }
+ }
+ }
+ /* if we're scaling down vertically */
+ else if(isi->xup_yup == 1){
+ /*\ 'Correct' version, with math units prepared for MMXification \*/
+ int Cy, j;
+ unsigned int *pix;
+ int r, g, b, a, rr, gg, bb, aa;
+ int yap;
+
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ Cy = YAP >> 16;
+ yap = YAP & 0xffff;
+
+ dptr = dest + dx + ((y + dy) * dow);
+ for(x = dxx; x < end; x++){
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = (R_VAL(pix) * yap) >> 10;
+ g = (G_VAL(pix) * yap) >> 10;
+ b = (B_VAL(pix) * yap) >> 10;
+ a = (A_VAL(pix) * yap) >> 10;
+ for(j = (1 << 14) - yap; j > Cy; j -= Cy){
+ pix += sow;
+ r += (R_VAL(pix) * Cy) >> 10;
+ g += (G_VAL(pix) * Cy) >> 10;
+ b += (B_VAL(pix) * Cy) >> 10;
+ a += (A_VAL(pix) * Cy) >> 10;
+ }
+ if(j > 0){
+ pix += sow;
+ r += (R_VAL(pix) * j) >> 10;
+ g += (G_VAL(pix) * j) >> 10;
+ b += (B_VAL(pix) * j) >> 10;
+ a += (A_VAL(pix) * j) >> 10;
+ }
+ if(XAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x] + 1;
+ rr = (R_VAL(pix) * yap) >> 10;
+ gg = (G_VAL(pix) * yap) >> 10;
+ bb = (B_VAL(pix) * yap) >> 10;
+ aa = (A_VAL(pix) * yap) >> 10;
+ for(j = (1 << 14) - yap; j > Cy; j -= Cy){
+ pix += sow;
+ rr += (R_VAL(pix) * Cy) >> 10;
+ gg += (G_VAL(pix) * Cy) >> 10;
+ bb += (B_VAL(pix) * Cy) >> 10;
+ aa += (A_VAL(pix) * Cy) >> 10;
+ }
+ if(j > 0){
+ pix += sow;
+ rr += (R_VAL(pix) * j) >> 10;
+ gg += (G_VAL(pix) * j) >> 10;
+ bb += (B_VAL(pix) * j) >> 10;
+ aa += (A_VAL(pix) * j) >> 10;
+ }
+ r = r * INV_XAP;
+ g = g * INV_XAP;
+ b = b * INV_XAP;
+ a = a * INV_XAP;
+ r = (r + ((rr * XAP))) >> 12;
+ g = (g + ((gg * XAP))) >> 12;
+ b = (b + ((bb * XAP))) >> 12;
+ a = (a + ((aa * XAP))) >> 12;
+ }
+ else{
+ r >>= 4;
+ g >>= 4;
+ b >>= 4;
+ a >>= 4;
+ }
+ *dptr = tqRgba(r, g, b, a);
+ dptr++;
+ }
+ }
+ }
+ /* if we're scaling down horizontally */
+ else if(isi->xup_yup == 2){
+ /*\ 'Correct' version, with math units prepared for MMXification \*/
+ int Cx, j;
+ unsigned int *pix;
+ int r, g, b, a, rr, gg, bb, aa;
+ int xap;
+
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ dptr = dest + dx + ((y + dy) * dow);
+ for(x = dxx; x < end; x++){
+ Cx = XAP >> 16;
+ xap = XAP & 0xffff;
+
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = (R_VAL(pix) * xap) >> 10;
+ g = (G_VAL(pix) * xap) >> 10;
+ b = (B_VAL(pix) * xap) >> 10;
+ a = (A_VAL(pix) * xap) >> 10;
+ for(j = (1 << 14) - xap; j > Cx; j -= Cx){
+ pix++;
+ r += (R_VAL(pix) * Cx) >> 10;
+ g += (G_VAL(pix) * Cx) >> 10;
+ b += (B_VAL(pix) * Cx) >> 10;
+ a += (A_VAL(pix) * Cx) >> 10;
+ }
+ if(j > 0){
+ pix++;
+ r += (R_VAL(pix) * j) >> 10;
+ g += (G_VAL(pix) * j) >> 10;
+ b += (B_VAL(pix) * j) >> 10;
+ a += (A_VAL(pix) * j) >> 10;
+ }
+ if(YAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x] + sow;
+ rr = (R_VAL(pix) * xap) >> 10;
+ gg = (G_VAL(pix) * xap) >> 10;
+ bb = (B_VAL(pix) * xap) >> 10;
+ aa = (A_VAL(pix) * xap) >> 10;
+ for(j = (1 << 14) - xap; j > Cx; j -= Cx){
+ pix++;
+ rr += (R_VAL(pix) * Cx) >> 10;
+ gg += (G_VAL(pix) * Cx) >> 10;
+ bb += (B_VAL(pix) * Cx) >> 10;
+ aa += (A_VAL(pix) * Cx) >> 10;
+ }
+ if(j > 0){
+ pix++;
+ rr += (R_VAL(pix) * j) >> 10;
+ gg += (G_VAL(pix) * j) >> 10;
+ bb += (B_VAL(pix) * j) >> 10;
+ aa += (A_VAL(pix) * j) >> 10;
+ }
+ r = r * INV_YAP;
+ g = g * INV_YAP;
+ b = b * INV_YAP;
+ a = a * INV_YAP;
+ r = (r + ((rr * YAP))) >> 12;
+ g = (g + ((gg * YAP))) >> 12;
+ b = (b + ((bb * YAP))) >> 12;
+ a = (a + ((aa * YAP))) >> 12;
+ }
+ else{
+ r >>= 4;
+ g >>= 4;
+ b >>= 4;
+ a >>= 4;
+ }
+ *dptr = tqRgba(r, g, b, a);
+ dptr++;
+ }
+ }
+ }
+ /* if we're scaling down horizontally & vertically */
+ else{
+ /*\ 'Correct' version, with math units prepared for MMXification:
+ |*| The operation 'b = (b * c) >> 16' translates to pmulhw,
+ |*| so the operation 'b = (b * c) >> d' would translate to
+ |*| psllw (16 - d), %mmb; pmulh %mmc, %mmb
+ \*/
+ int Cx, Cy, i, j;
+ unsigned int *pix;
+ int a, r, g, b, ax, rx, gx, bx;
+ int xap, yap;
+
+ for(y = 0; y < dh; y++){
+ Cy = YAP >> 16;
+ yap = YAP & 0xffff;
+
+ dptr = dest + dx + ((y + dy) * dow);
+ for(x = dxx; x < end; x++){
+ Cx = XAP >> 16;
+ xap = XAP & 0xffff;
+
+ sptr = ypoints[dyy + y] + xpoints[x];
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ ax = (A_VAL(pix) * xap) >> 9;
+ pix++;
+ for(i = (1 << 14) - xap; i > Cx; i -= Cx){
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ ax += (A_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if(i > 0){
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ ax += (A_VAL(pix) * i) >> 9;
+ }
+
+ r = (rx * yap) >> 14;
+ g = (gx * yap) >> 14;
+ b = (bx * yap) >> 14;
+ a = (ax * yap) >> 14;
+
+ for(j = (1 << 14) - yap; j > Cy; j -= Cy){
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ ax = (A_VAL(pix) * xap) >> 9;
+ pix++;
+ for(i = (1 << 14) - xap; i > Cx; i -= Cx){
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ ax += (A_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if(i > 0){
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ ax += (A_VAL(pix) * i) >> 9;
+ }
+
+ r += (rx * Cy) >> 14;
+ g += (gx * Cy) >> 14;
+ b += (bx * Cy) >> 14;
+ a += (ax * Cy) >> 14;
+ }
+ if(j > 0){
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ ax = (A_VAL(pix) * xap) >> 9;
+ pix++;
+ for(i = (1 << 14) - xap; i > Cx; i -= Cx){
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ ax += (A_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if(i > 0){
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ ax += (A_VAL(pix) * i) >> 9;
+ }
+
+ r += (rx * j) >> 14;
+ g += (gx * j) >> 14;
+ b += (bx * j) >> 14;
+ a += (ax * j) >> 14;
+ }
+
+ R_VAL(dptr) = r >> 5;
+ G_VAL(dptr) = g >> 5;
+ B_VAL(dptr) = b >> 5;
+ A_VAL(dptr) = a >> 5;
+ dptr++;
+ }
+ }
+ }
+}
+
+/* scale by area sampling - IGNORE the ALPHA byte*/
+void MImageScale::mimageScaleAARGB(MImageScaleInfo *isi, unsigned int *dest,
+ int dxx, int dyy, int dx, int dy, int dw,
+ int dh, int dow, int sow)
+{
+ unsigned int *sptr, *dptr;
+ int x, y, end;
+ unsigned int **ypoints = isi->ypoints;
+ int *xpoints = isi->xpoints;
+ int *xapoints = isi->xapoints;
+ int *yapoints = isi->yapoints;
+
+ end = dxx + dw;
+ /* scaling up both ways */
+ if(isi->xup_yup == 3){
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ /* calculate the source line we'll scan from */
+ dptr = dest + dx + ((y + dy) * dow);
+ sptr = ypoints[dyy + y];
+ if(YAP > 0){
+ for(x = dxx; x < end; x++){
+ int r = 0, g = 0, b = 0;
+ int rr = 0, gg = 0, bb = 0;
+ unsigned int *pix;
+
+ if(XAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ pix += sow;
+ rr = R_VAL(pix) * XAP;
+ gg = G_VAL(pix) * XAP;
+ bb = B_VAL(pix) * XAP;
+ pix --;
+ rr += R_VAL(pix) * INV_XAP;
+ gg += G_VAL(pix) * INV_XAP;
+ bb += B_VAL(pix) * INV_XAP;
+ r = ((rr * YAP) + (r * INV_YAP)) >> 16;
+ g = ((gg * YAP) + (g * INV_YAP)) >> 16;
+ b = ((bb * YAP) + (b * INV_YAP)) >> 16;
+ *dptr++ = tqRgba(r, g, b, 0xff);
+ }
+ else{
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_YAP;
+ g = G_VAL(pix) * INV_YAP;
+ b = B_VAL(pix) * INV_YAP;
+ pix += sow;
+ r += R_VAL(pix) * YAP;
+ g += G_VAL(pix) * YAP;
+ b += B_VAL(pix) * YAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ *dptr++ = tqRgba(r, g, b, 0xff);
+ }
+ }
+ }
+ else{
+ for(x = dxx; x < end; x++){
+ int r = 0, g = 0, b = 0;
+ unsigned int *pix;
+
+ if(XAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = R_VAL(pix) * INV_XAP;
+ g = G_VAL(pix) * INV_XAP;
+ b = B_VAL(pix) * INV_XAP;
+ pix++;
+ r += R_VAL(pix) * XAP;
+ g += G_VAL(pix) * XAP;
+ b += B_VAL(pix) * XAP;
+ r >>= 8;
+ g >>= 8;
+ b >>= 8;
+ *dptr++ = tqRgba(r, g, b, 0xff);
+ }
+ else
+ *dptr++ = sptr[xpoints[x] ];
+ }
+ }
+ }
+ }
+ /* if we're scaling down vertically */
+ else if(isi->xup_yup == 1){
+ /*\ 'Correct' version, with math units prepared for MMXification \*/
+ int Cy, j;
+ unsigned int *pix;
+ int r, g, b, rr, gg, bb;
+ int yap;
+
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ Cy = YAP >> 16;
+ yap = YAP & 0xffff;
+
+ dptr = dest + dx + ((y + dy) * dow);
+ for(x = dxx; x < end; x++){
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = (R_VAL(pix) * yap) >> 10;
+ g = (G_VAL(pix) * yap) >> 10;
+ b = (B_VAL(pix) * yap) >> 10;
+ pix += sow;
+ for(j = (1 << 14) - yap; j > Cy; j -= Cy){
+ r += (R_VAL(pix) * Cy) >> 10;
+ g += (G_VAL(pix) * Cy) >> 10;
+ b += (B_VAL(pix) * Cy) >> 10;
+ pix += sow;
+ }
+ if(j > 0){
+ r += (R_VAL(pix) * j) >> 10;
+ g += (G_VAL(pix) * j) >> 10;
+ b += (B_VAL(pix) * j) >> 10;
+ }
+ if(XAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x] + 1;
+ rr = (R_VAL(pix) * yap) >> 10;
+ gg = (G_VAL(pix) * yap) >> 10;
+ bb = (B_VAL(pix) * yap) >> 10;
+ pix += sow;
+ for(j = (1 << 14) - yap; j > Cy; j -= Cy){
+ rr += (R_VAL(pix) * Cy) >> 10;
+ gg += (G_VAL(pix) * Cy) >> 10;
+ bb += (B_VAL(pix) * Cy) >> 10;
+ pix += sow;
+ }
+ if(j > 0){
+ rr += (R_VAL(pix) * j) >> 10;
+ gg += (G_VAL(pix) * j) >> 10;
+ bb += (B_VAL(pix) * j) >> 10;
+ }
+ r = r * INV_XAP;
+ g = g * INV_XAP;
+ b = b * INV_XAP;
+ r = (r + ((rr * XAP))) >> 12;
+ g = (g + ((gg * XAP))) >> 12;
+ b = (b + ((bb * XAP))) >> 12;
+ }
+ else{
+ r >>= 4;
+ g >>= 4;
+ b >>= 4;
+ }
+ *dptr = tqRgba(r, g, b, 0xff);
+ dptr++;
+ }
+ }
+ }
+ /* if we're scaling down horizontally */
+ else if(isi->xup_yup == 2){
+ /*\ 'Correct' version, with math units prepared for MMXification \*/
+ int Cx, j;
+ unsigned int *pix;
+ int r, g, b, rr, gg, bb;
+ int xap;
+
+ /* go through every scanline in the output buffer */
+ for(y = 0; y < dh; y++){
+ dptr = dest + dx + ((y + dy) * dow);
+ for(x = dxx; x < end; x++){
+ Cx = XAP >> 16;
+ xap = XAP & 0xffff;
+
+ pix = ypoints[dyy + y] + xpoints[x];
+ r = (R_VAL(pix) * xap) >> 10;
+ g = (G_VAL(pix) * xap) >> 10;
+ b = (B_VAL(pix) * xap) >> 10;
+ pix++;
+ for(j = (1 << 14) - xap; j > Cx; j -= Cx){
+ r += (R_VAL(pix) * Cx) >> 10;
+ g += (G_VAL(pix) * Cx) >> 10;
+ b += (B_VAL(pix) * Cx) >> 10;
+ pix++;
+ }
+ if(j > 0){
+ r += (R_VAL(pix) * j) >> 10;
+ g += (G_VAL(pix) * j) >> 10;
+ b += (B_VAL(pix) * j) >> 10;
+ }
+ if(YAP > 0){
+ pix = ypoints[dyy + y] + xpoints[x] + sow;
+ rr = (R_VAL(pix) * xap) >> 10;
+ gg = (G_VAL(pix) * xap) >> 10;
+ bb = (B_VAL(pix) * xap) >> 10;
+ pix++;
+ for(j = (1 << 14) - xap; j > Cx; j -= Cx){
+ rr += (R_VAL(pix) * Cx) >> 10;
+ gg += (G_VAL(pix) * Cx) >> 10;
+ bb += (B_VAL(pix) * Cx) >> 10;
+ pix++;
+ }
+ if(j > 0){
+ rr += (R_VAL(pix) * j) >> 10;
+ gg += (G_VAL(pix) * j) >> 10;
+ bb += (B_VAL(pix) * j) >> 10;
+ }
+ r = r * INV_YAP;
+ g = g * INV_YAP;
+ b = b * INV_YAP;
+ r = (r + ((rr * YAP))) >> 12;
+ g = (g + ((gg * YAP))) >> 12;
+ b = (b + ((bb * YAP))) >> 12;
+ }
+ else{
+ r >>= 4;
+ g >>= 4;
+ b >>= 4;
+ }
+ *dptr = tqRgba(r, g, b, 0xff);
+ dptr++;
+ }
+ }
+ }
+ /* fully optimized (i think) - onyl change of algorithm can help */
+ /* if we're scaling down horizontally & vertically */
+ else{
+ /*\ 'Correct' version, with math units prepared for MMXification \*/
+ int Cx, Cy, i, j;
+ unsigned int *pix;
+ int r, g, b, rx, gx, bx;
+ int xap, yap;
+
+ for(y = 0; y < dh; y++){
+ Cy = YAP >> 16;
+ yap = YAP & 0xffff;
+
+ dptr = dest + dx + ((y + dy) * dow);
+ for(x = dxx; x < end; x++){
+ Cx = XAP >> 16;
+ xap = XAP & 0xffff;
+
+ sptr = ypoints[dyy + y] + xpoints[x];
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ pix++;
+ for(i = (1 << 14) - xap; i > Cx; i -= Cx){
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if(i > 0){
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ }
+
+ r = (rx * yap) >> 14;
+ g = (gx * yap) >> 14;
+ b = (bx * yap) >> 14;
+
+ for(j = (1 << 14) - yap; j > Cy; j -= Cy){
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ pix++;
+ for(i = (1 << 14) - xap; i > Cx; i -= Cx){
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if(i > 0){
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ }
+
+ r += (rx * Cy) >> 14;
+ g += (gx * Cy) >> 14;
+ b += (bx * Cy) >> 14;
+ }
+ if(j > 0){
+ pix = sptr;
+ sptr += sow;
+ rx = (R_VAL(pix) * xap) >> 9;
+ gx = (G_VAL(pix) * xap) >> 9;
+ bx = (B_VAL(pix) * xap) >> 9;
+ pix++;
+ for(i = (1 << 14) - xap; i > Cx; i -= Cx){
+ rx += (R_VAL(pix) * Cx) >> 9;
+ gx += (G_VAL(pix) * Cx) >> 9;
+ bx += (B_VAL(pix) * Cx) >> 9;
+ pix++;
+ }
+ if(i > 0){
+ rx += (R_VAL(pix) * i) >> 9;
+ gx += (G_VAL(pix) * i) >> 9;
+ bx += (B_VAL(pix) * i) >> 9;
+ }
+
+ r += (rx * j) >> 14;
+ g += (gx * j) >> 14;
+ b += (bx * j) >> 14;
+ }
+
+ R_VAL(dptr) = r >> 5;
+ G_VAL(dptr) = g >> 5;
+ B_VAL(dptr) = b >> 5;
+ dptr++;
+ }
+ }
+ }
+}
+
+// Imlib2/Mosfet code end
+
+TQImage scale(const TQImage& image, int width, int height,
+ SmoothAlgorithm alg, TQImage::ScaleMode mode, double blur )
+{
+ if( image.isNull()) return image.copy();
+
+ TQSize newSize( image.size() );
+ newSize.scale( TQSize( width, height ), (TQSize::ScaleMode)mode ); // ### remove cast in TQt 4.0
+ newSize = newSize.expandedTo( TQSize( 1, 1 )); // make sure it doesn't become null
+
+ if ( newSize == image.size() ) return image.copy();
+
+ width = newSize.width();
+ height = newSize.height();
+ Filter filter = NULL;
+ fastfloat filtersupport;
+
+ switch( alg ) {
+ case SMOOTH_NONE:
+ filter = NULL;
+ filtersupport = 0.0;
+ break;
+ case SMOOTH_FAST:
+ filter = Box;
+ filtersupport = 0.5;
+ break;
+ case SMOOTH_NORMAL:
+ default:
+ filter = Triangle;
+ filtersupport = 1.0;
+ break;
+ case SMOOTH_BEST:
+// filter = Mitchell;
+ filter = Bicubic;
+ filtersupport = 2.0;
+ break;
+ }
+
+ if( filter == Box && blur == 1.0 )
+ return MImageScale::smoothScale( image, width, height );
+
+ if( filter == Box && width > image.width() && height > image.height() && blur == 1.0 ) {
+ filter = NULL; // Box doesn't really smooth when enlarging
+ }
+
+ if( filter == NULL ) {
+ return SampleImage( image, width, height ); // doesn't need 32bit
+ }
+
+ return ResizeImage( image.convertDepth( 32 ), width, height, filter, filtersupport, blur );
+ // unlike TQt's smoothScale() this function introduces new colors to grayscale images ... oh well
+}
+
+
+} // namespace
diff --git a/src/sq_version b/src/sq_version
new file mode 100644
index 0000000..c3670dc
--- /dev/null
+++ b/src/sq_version
@@ -0,0 +1 @@
+15521
diff --git a/src/sq_viewcache.ui b/src/sq_viewcache.ui
new file mode 100644
index 0000000..b82ceb7
--- /dev/null
+++ b/src/sq_viewcache.ui
@@ -0,0 +1,168 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SQ_ViewCache</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>SQ_ViewCache</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>523</width>
+ <height>410</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Memory cache</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="modal">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQPushButton" row="3" column="2">
+ <property name="name">
+ <cstring>pushButton1</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ <widget class="TQListView" row="0" column="0" rowspan="1" colspan="3">
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>MIME</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Parameters</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>listCache</cstring>
+ </property>
+ <property name="resizePolicy">
+ <enum>AutoOneFit</enum>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>NoColumn</enum>
+ </property>
+ </widget>
+ <widget class="Line" row="1" column="0" rowspan="2" colspan="3">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget" row="3" column="0">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;Total:&lt;/b&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>textTotal</cstring>
+ </property>
+ <property name="textFormat">
+ <enum>RichText</enum>
+ </property>
+ <property name="alignment">
+ <set>AlignCenter</set>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushButton1</sender>
+ <signal>clicked()</signal>
+ <receiver>SQ_ViewCache</receiver>
+ <slot>accept()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>listCache</tabstop>
+ <tabstop>pushButton1</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">sq_pixmapcache.h</include>
+ <include location="local" impldecl="in implementation">sq_viewcache.ui.h</include>
+</includes>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/sq_viewcache.ui.h b/src/sq_viewcache.ui.h
new file mode 100644
index 0000000..7e2ece9
--- /dev/null
+++ b/src/sq_viewcache.ui.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** TQt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+void SQ_ViewCache::init()
+{
+ textTotal->setText(TQString("<b>%1</b>").arg((int)SQ_PixmapCache::instance()->count()));
+
+ if(SQ_PixmapCache::instance()->isEmpty())
+ return;
+
+ listCache->setSorting(-1);
+
+ TQListViewItem *itemafter = 0, *item;
+
+ SQ_PixmapCache::iterator itEnd = SQ_PixmapCache::instance()->end();
+ SQ_Thumbnail th;
+ KURL url;
+ TQString s;
+
+ for(SQ_PixmapCache::iterator it = SQ_PixmapCache::instance()->begin();it != itEnd;++it)
+ {
+ th = it.data();
+ url = it.key();
+ s = url.isLocalFile() ? url.path() : url.prettyURL();
+
+ if(itemafter)
+ item = new TQListViewItem(listCache, itemafter, s,
+ TQString(), TQString::fromLatin1("%1x%2").arg(th.w).arg(th.h));
+ else
+ item = new TQListViewItem(listCache, s,
+ TQString(), TQString::fromLatin1("%1x%2").arg(th.w).arg(th.h));
+
+ item->setPixmap(1, it.data().mime);
+
+ itemafter = item;
+
+ listCache->insertItem(item);
+ }
+}
diff --git a/src/sq_widgetstack.cpp b/src/sq_widgetstack.cpp
new file mode 100644
index 0000000..aec29e1
--- /dev/null
+++ b/src/sq_widgetstack.cpp
@@ -0,0 +1,781 @@
+/***************************************************************************
+ sq_widgetstack.cpp - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tqlabel.h>
+#include <tqbuttongroup.h>
+#include <tqpushbutton.h>
+#include <tqtoolbutton.h>
+#include <tqtimer.h>
+#include <tqapplication.h>
+
+#include <tdeaction.h>
+#include <kcombobox.h>
+#include <kstandarddirs.h>
+#include <tdestdaccel.h>
+#include <tdelocale.h>
+#include <tdeio/job.h>
+#include <tdefiledialog.h>
+#include <tdemessagebox.h>
+#include <kstringhandler.h>
+
+#include "ksquirrel.h"
+#include "sq_config.h"
+#include "sq_fileiconview.h"
+#include "sq_filethumbview.h"
+#include "sq_filedetailview.h"
+#include "sq_widgetstack.h"
+#include "sq_externaltool.h"
+#include "sq_treeview.h"
+#include "sq_hloptions.h"
+#include "sq_archivehandler.h"
+#include "sq_glview.h"
+#include "sq_glwidget.h"
+#include "sq_libraryhandler.h"
+#include "sq_diroperator.h"
+#include "sq_bookmarkowner.h"
+#include "sq_thumbnailsize.h"
+#include "sq_progressbox.h"
+#include "sq_thumbnailloadjob.h"
+#include "sq_pixmapcache.h"
+#include "sq_selectdeselectgroup.h"
+#include "sq_navigatordropmenu.h"
+
+SQ_WidgetStack * SQ_WidgetStack::m_instance = 0;
+
+SQ_WidgetStack::SQ_WidgetStack(TQWidget *parent, const int id) : TQObject(parent)
+{
+ m_instance = this;
+
+ SQ_DirOperator::ViewT m_type = static_cast<SQ_DirOperator::ViewT>(id);
+
+ KURL url;
+
+ // Check Options for path
+ SQ_Config::instance()->setGroup("Fileview");
+
+ if(SQ_HLOptions::instance()->dir.isEmpty())
+ {
+ switch(SQ_Config::instance()->readNumEntry("set path", 0))
+ {
+ case 0: url = KURL::fromPathOrURL(SQ_Config::instance()->readEntry("last visited", "/")); break;
+ case 1: url = KURL::fromPathOrURL(TQDir::current().path()); break;
+ case 2: url = KURL::fromPathOrURL(SQ_Config::instance()->readEntry("custom directory", "/")); break;
+
+ default: url = KURL::fromPathOrURL("/");
+ }
+ }
+ else // path from command line
+ url = SQ_HLOptions::instance()->dir;
+
+ dirop = new SQ_DirOperator(url, static_cast<SQ_DirOperator::ViewT>(id), parent);
+
+ raiseWidget(m_type, false);
+
+ connect(KSquirrel::app(), TQ_SIGNAL(thumbSizeChanged(const TQString&)), dirop, TQ_SLOT(slotSetThumbSize(const TQString&)));
+ connect(dirop, TQ_SIGNAL(runSeparately(KFileItem *)), this, TQ_SLOT(slotRunSeparately()));
+
+ KSquirrel::app()->historyCombo()->setEditText(url.isLocalFile() ? url.path() : url.prettyURL());
+
+ timerShowProgress = new TQTimer(this);
+ connect(timerShowProgress, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotDelayedShowProgress()));
+}
+
+SQ_WidgetStack::~SQ_WidgetStack()
+{}
+
+/*
+ * Get current url of visible diroperator.
+ */
+KURL SQ_WidgetStack::url() const
+{
+ return dirop->url();
+}
+
+void SQ_WidgetStack::init()
+{
+ SQ_Config::instance()->setGroup("Fileview");
+
+ fileaction = static_cast<SQ_WidgetStack::FileAction>(SQ_Config::instance()->readNumEntry("last_action", SQ_WidgetStack::Unknown));
+ KURL uu = KURL::fromPathOrURL(SQ_Config::instance()->readEntry("last_url"));
+
+ connect(SQ_NavigatorDropMenu::instance(), TQ_SIGNAL(done(const KURL &, int)),
+ this, TQ_SLOT(slotTreeMenuDone(const KURL &, int)));
+
+ emitNewLastURL(uu);
+}
+
+void SQ_WidgetStack::slotTreeMenuDone(const KURL &url, int a)
+{
+ if(a == SQ_NavigatorDropMenu::Copy)
+ fileaction = SQ_WidgetStack::Copy;
+ else if(a == SQ_NavigatorDropMenu::Move)
+ fileaction = SQ_WidgetStack::Cut;
+ else if(a == SQ_NavigatorDropMenu::Link)
+ fileaction = SQ_WidgetStack::Link;
+
+ lastURL = url;
+
+ emitNewLastURL(lastURL);
+}
+
+void SQ_WidgetStack::setURL(const KURL &newurl, bool parseTree)
+{
+ KURL url = newurl;
+ url.adjustPath(+1);
+
+ // update bookmarks' url
+ if(SQ_BookmarkOwner::instance())
+ SQ_BookmarkOwner::instance()->setURL(url);
+
+ // update history combobox
+ KSquirrel::app()->historyCombo()->setEditText(url.isLocalFile() ? url.path() : url.prettyURL());
+ KSquirrel::app()->historyCombo()->addToHistory(url.isLocalFile() ? url.path() : url.prettyURL());
+
+ // set url for file tree
+ if(SQ_TreeView::instance() && parseTree)
+ {
+ SQ_Config::instance()->setGroup("Fileview");
+ int sync_type = SQ_Config::instance()->readNumEntry("sync type", 0);
+
+ if(sync_type != 2)
+ SQ_TreeView::instance()->emitNewURL(url);
+ }
+}
+
+/*
+ * Select next/prevous supported image in filemanager.
+ * Do nothing, if no more supported images found in given
+ * direction.
+ */
+int SQ_WidgetStack::moveTo(Direction direction, KFileItem *it, bool useSupported)
+{
+ KFileView *local;
+ KFileItem *item;
+
+ // current fileview
+ local = dirop->view();
+
+ if(it)
+ item = it;
+ else
+ item = (direction == SQ_WidgetStack::Next)?
+ local->nextItem(local->currentFileItem()):
+ local->prevItem(local->currentFileItem());
+
+ if(!item)
+ return moveFailed;
+
+ if(useSupported)
+ {
+ while(true)
+ {
+ if(item->isFile())
+ // supported image type ?
+// if(SQ_LibraryHandler::instance()->libraryForFile(item->url().path()))
+ if(SQ_LibraryHandler::instance()->maybeSupported(item->url()) != SQ_LibraryHandler::No)
+ break;
+
+ item = (direction == SQ_WidgetStack::Next)?
+ (local->nextItem(item)):
+ (local->prevItem(item));
+
+ if(!item)
+ return moveFailed;
+ }
+ }
+
+ // set current file, select it
+ dirop->setCurrentItem(item);
+
+ return moveSuccess;
+}
+
+/*
+ * Set filter.
+ */
+void SQ_WidgetStack::setNameFilter(const TQString &f)
+{
+ dirop->setNameFilter(f);
+ dirop->actionCollection()->action("reload")->activate();
+}
+
+/*
+ * Get current filter.
+ */
+TQString SQ_WidgetStack::nameFilter() const
+{
+ return dirop->nameFilter();
+}
+
+/*
+ * Change view type. See SQ_DirOperator::ViewT for more.
+ */
+void SQ_WidgetStack::raiseWidget(SQ_DirOperator::ViewT id, bool doUpdate)
+{
+ if(doUpdate) dirop->stopThumbnailUpdate();
+
+ dirop->removeCdUpItem();
+ dirop->prepareView(id);
+
+ switch(id)
+ {
+ case SQ_DirOperator::TypeList:
+ case SQ_DirOperator::TypeIcons:
+ {
+ SQ_FileIconView *iv = dynamic_cast<SQ_FileIconView *>(dirop->preparedView());
+
+ dirop->setPreparedView();
+ iv->setSelectionMode(KFile::Extended);
+ action("short view")->activate();
+
+ if(id == SQ_DirOperator::TypeList)
+ iv->actionCollection()->action("small columns")->activate();
+ else
+ iv->actionCollection()->action("large rows")->activate();
+ }
+ break;
+
+ case SQ_DirOperator::TypeDetailed:
+ {
+ SQ_FileDetailView *dv = dynamic_cast<SQ_FileDetailView *>(dirop->preparedView());
+
+ dirop->setPreparedView();
+ dv->setSelectionMode(KFile::Extended);
+ }
+ break;
+
+ case SQ_DirOperator::TypeThumbs:
+ {
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->preparedView());
+ tv->actionCollection()->action("large rows")->activate();
+ dirop->setPreparedView();
+ action("short view")->activate();
+ tv->setSelectionMode(KFile::Extended);
+ updateGrid(true);
+ if(doUpdate) dirop->startOrNotThumbnailUpdate();
+ }
+ break;
+ }
+
+ // enable/disable menu with thumbnail sizes
+ KSquirrel::app()->enableThumbsMenu(id == SQ_DirOperator::TypeThumbs);
+ dirop->enableThumbnailActions(id == SQ_DirOperator::TypeThumbs);
+ dirop->selectOld();
+}
+
+/*
+ * Selected items in currently visible diroperator.
+ */
+const KFileItemList* SQ_WidgetStack::selectedItems() const
+{
+ return dirop->view()->selectedItems();
+}
+
+/*
+ * All items in currently visible diroperator.
+ */
+const KFileItemList* SQ_WidgetStack::items() const
+{
+ return dirop->view()->items();
+}
+
+void SQ_WidgetStack::emitNextSelected()
+{
+ if(moveTo(SQ_WidgetStack::Next) == SQ_WidgetStack::moveSuccess)
+ {
+ KFileItem *fi = dirop->view()->currentFileItem();
+ SQ_GLWidget::window()->setExpectedURL(fi->url());
+ dirop->execute(fi);
+ }
+}
+
+void SQ_WidgetStack::emitPreviousSelected()
+{
+ if(moveTo(SQ_WidgetStack::Previous) == SQ_WidgetStack::moveSuccess)
+ {
+ KFileItem *fi = dirop->view()->currentFileItem();
+ SQ_GLWidget::window()->setExpectedURL(fi->url());
+ dirop->execute(fi);
+ }
+}
+
+void SQ_WidgetStack::slotSelectFirstFile()
+{
+ moveToFirstLast(SQ_WidgetStack::Next, false);
+}
+
+void SQ_WidgetStack::slotSelectLastFile()
+{
+ moveToFirstLast(SQ_WidgetStack::Previous, false);
+}
+
+// Go to first file
+void SQ_WidgetStack::firstFile()
+{
+ moveToFirstLast(SQ_WidgetStack::Next);
+}
+
+// Go to last file
+void SQ_WidgetStack::lastFile()
+{
+ moveToFirstLast(SQ_WidgetStack::Previous);
+}
+
+void SQ_WidgetStack::moveToFirstLast(Direction direct, bool exec)
+{
+ KFileView *local_view = dirop->view();
+ KFileItemList *list = const_cast<KFileItemList*>(local_view->items());
+
+ if(list)
+ {
+ KFileItem *item = (direct == SQ_WidgetStack::Next) ? list->first() : list->last();
+
+ if(!item || moveTo(direct, item) == moveFailed)
+ return;
+
+ item = local_view->currentFileItem();
+
+ if(item)
+ {
+ dirop->setCurrentItem(item);
+ SQ_GLWidget::window()->setExpectedURL(item->url());
+ if(exec) dirop->execute(item);
+ }
+ }
+}
+
+/*
+ * Update grid for thumbnail view. New grid is calcalated from item
+ * margins (from Options).
+ */
+void SQ_WidgetStack::updateGrid(bool arrange)
+{
+ if(dirop->viewType() != SQ_DirOperator::TypeThumbs)
+ return;
+
+ SQ_Config::instance()->setGroup("Thumbnails");
+ int newgrid = SQ_ThumbnailSize::instance()->extended() ?
+ SQ_ThumbnailSize::instance()->extendedSize().width()
+ : SQ_ThumbnailSize::instance()->pixelSize();
+
+ newgrid += (SQ_Config::instance()->readNumEntry("margin", 2) + 2);
+
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());
+
+ // different grid ?
+ if(tv->gridX() != newgrid)
+ {
+ tv->setGridX(newgrid);
+
+ if(arrange)
+ tv->arrangeItemsInGrid();
+ }
+}
+
+void SQ_WidgetStack::thumbnailsUpdateEnded()
+{
+ if(dirop->viewType() != SQ_DirOperator::TypeThumbs)
+ return;
+
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());
+
+ if(!tv) return;
+
+ timerShowProgress->stop();
+ tv->progressBox()->hide();
+ tv->progressBox()->flush();
+ tv->progressBox()->startButtonPixmap();
+}
+
+void SQ_WidgetStack::thumbnailUpdateStart(int count)
+{
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());
+
+ if(!tv) return;
+
+ tv->progressBox()->setTotalSteps(count);
+ tv->progressBox()->stopButtonPixmap();
+
+ timerShowProgress->start(1000, true);
+}
+
+void SQ_WidgetStack::slotDelayedShowProgress()
+{
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());
+
+ if(tv)
+ tv->progressBox()->show();
+}
+
+void SQ_WidgetStack::thumbnailProcess()
+{
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());
+
+ if(tv)
+ tv->progressBox()->advance();
+}
+
+void SQ_WidgetStack::setURLForCurrent(const TQString &path, bool parseTree)
+{
+ KURL url = KURL::fromPathOrURL(path);
+
+ setURLForCurrent(url, parseTree);
+}
+
+void SQ_WidgetStack::setURLForCurrent(const KURL &url, bool parseTree)
+{
+ setURL(url, parseTree);
+ dirop->setURL(url, true);
+}
+
+void SQ_WidgetStack::updateView()
+{
+ dirop->actionCollection()->action("reload")->activate();
+}
+
+void SQ_WidgetStack::slotRunSeparately()
+{
+ const KFileItemList *selected = selectedItems();
+ KFileItemListIterator it(*selected);
+
+ KFileItem *item;
+
+ while((item = it.current()))
+ {
+ if(item)
+ item->run();
+
+ ++it;
+ }
+}
+
+// recreate selected thumbnails
+void SQ_WidgetStack::slotRecreateThumbnail()
+{
+ // oops, not a thumbnail view
+ if(dirop->viewType() != SQ_DirOperator::TypeThumbs)
+ return;
+
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());
+
+ if(tv->updateRunning())
+ return;
+
+ tv->progressBox()->show();
+
+ TQTimer::singleShot(1, this, TQ_SLOT(slotDelayedRecreateThumbnail()));
+}
+
+void SQ_WidgetStack::slotDelayedRecreateThumbnail()
+{
+ SQ_Thumbnail thumb;
+
+ KFileItemList *list = const_cast<KFileItemList *>(selectedItems());
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());
+
+ if(!list || !tv)
+ return;
+
+ KFileItemListIterator it(*list);
+ KFileItem *item;
+
+ while((item = it.current()))
+ {
+ SQ_PixmapCache::instance()->removeEntryFull(item->url());
+ ++it;
+ }
+
+ tv->doStartThumbnailUpdate(*list);
+}
+
+/*
+ * Save currently selected items' paths, if any.
+ *
+ * Return true, if at least one url was saved.
+ */
+bool SQ_WidgetStack::prepare()
+{
+ // clear old files
+ files.clear();
+
+ KFileItemList *items = const_cast<KFileItemList *>(selectedItems());
+ KFileItem *i;
+
+ if(!items || items->isEmpty())
+ {
+ KMessageBox::information(dirop, i18n("No files to copy or move"));
+ return false;
+ }
+
+ i = items->first();
+
+ while(i)
+ {
+ files.append(i->url());
+ i = items->next();
+ }
+
+ return true;
+}
+
+/*
+ * Slots for file actions: copy, move, cut...
+ */
+void SQ_WidgetStack::slotFileCopy()
+{
+ fileaction = (prepare()) ? SQ_WidgetStack::Copy : SQ_WidgetStack::Unknown;
+}
+
+void SQ_WidgetStack::slotFileCut()
+{
+ fileaction = (prepare()) ? SQ_WidgetStack::Cut : SQ_WidgetStack::Unknown;
+}
+
+// Paste files
+void SQ_WidgetStack::slotFilePaste()
+{
+ // No files to copy ?
+ if(files.isEmpty() || fileaction == SQ_WidgetStack::Unknown)
+ {
+ KMessageBox::information(dirop, i18n("No files to copy or move"));
+ return;
+ }
+
+ // get current url
+ KURL _url = url();
+ emitNewLastURL(_url);
+ TDEIO::Job *job;
+
+ // now copy or move files to current url
+ job = (fileaction == SQ_WidgetStack::Copy) ? TDEIO::copy(files, _url) : TDEIO::move(files, _url);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotJobResult(TDEIO::Job *)));
+}
+
+void SQ_WidgetStack::slotJobResult(TDEIO::Job *job)
+{
+ if(job && job->error())
+ job->showErrorDialog(KSquirrel::app());
+}
+
+void SQ_WidgetStack::emitNewLastURL(const KURL &u)
+{
+ lastURL = u;
+ TQString text;
+
+ TQString targ = KStringHandler::csqueeze(u.isLocalFile() ? u.path() : u.prettyURL(), 25);
+
+ if(fileaction == SQ_WidgetStack::Copy)
+ text = i18n("Repeat (copy to %1)").arg(targ);
+ else if(fileaction == SQ_WidgetStack::Cut)
+ text = i18n("Repeat (move to %1)").arg(targ);
+ else if(fileaction == SQ_WidgetStack::Link)
+ text = i18n("Repeat (link to %1)").arg(targ);
+
+ if(!text.isEmpty())
+ emit newLastURL(text);
+}
+
+void SQ_WidgetStack::repeat()
+{
+ if(fileaction == SQ_WidgetStack::Copy || fileaction == SQ_WidgetStack::Cut)
+ prepare();
+ else
+ return;
+
+ // No files to copy ?
+ if(lastURL.isEmpty() || files.isEmpty())
+ return;
+
+ TDEIO::Job *job = (fileaction == SQ_WidgetStack::Copy) ? TDEIO::copy(files, lastURL) : TDEIO::move(files, lastURL);
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotJobResult(TDEIO::Job *)));
+}
+
+// Create links
+void SQ_WidgetStack::slotFileLinkTo()
+{
+ if(!prepare())
+ return;
+
+ // select a directory
+ KURL url = KFileDialog::getExistingURL(lastURL.url(), dirop);
+
+ if(url.isEmpty())
+ return;
+
+ fileaction = SQ_WidgetStack::Link;
+ emitNewLastURL(url);
+
+ // create symlinks
+ TDEIO::link(files, url);
+}
+
+// Copy to...
+void SQ_WidgetStack::slotFileCopyTo()
+{
+ if(!prepare())
+ return;
+
+ // select a directory
+ KURL url = KFileDialog::getExistingURL(lastURL.url(), dirop);
+
+ if(url.isEmpty())
+ return;
+
+ fileaction = SQ_WidgetStack::Copy;
+ emitNewLastURL(url);
+
+ // copy files to selected directory
+ TDEIO::copy(files, url);
+}
+
+// Move to...
+void SQ_WidgetStack::slotFileMoveTo()
+{
+ if(!prepare())
+ return;
+
+ // select a directory
+ KURL url = KFileDialog::getExistingURL(lastURL.url(), dirop);
+
+ if(url.isEmpty())
+ return;
+
+ fileaction = SQ_WidgetStack::Cut;
+ emitNewLastURL(url);
+
+ // move files to selected directory
+ TDEIO::move(files, url);
+}
+
+/*
+ * User wants to select to deselect some files.
+ */
+void SQ_WidgetStack::slotSelectGroup()
+{
+ selectDeselectGroup(true);
+}
+
+void SQ_WidgetStack::slotDeselectGroup()
+{
+ selectDeselectGroup(false);
+}
+
+/*
+ * Execute SQ_SelectDeselectGroup dialog, and select or
+ * deselect files after it has been closed.
+ */
+void SQ_WidgetStack::selectDeselectGroup(bool select)
+{
+ TQString mask;
+
+ KFileView *local = dirop->view();
+
+ SQ_SelectDeselectGroup sd(KSquirrel::app());
+
+ sd.setCaption(select ? i18n("Select a group of files") : i18n("Deselect a group of files"));
+ sd.pushMask->setText(select ? i18n("Select !") : i18n("Deselect !"));
+
+ if(sd.exec(mask) == TQDialog::Accepted)
+ {
+ if(select)
+ local->clearSelection();
+
+ KFileItemList *sd_files = const_cast<KFileItemList *>(items());
+ KFileItem *i;
+ TQRegExp exp(mask);
+ exp.setWildcard(true);
+
+ if(!sd_files)
+ return;
+
+ i = sd_files->first();
+
+ // go through all files
+ while(i)
+ {
+ // name matched
+ if(exp.exactMatch(i->name()))
+ local->setSelected(i, select);
+
+ // next file
+ i = sd_files->next();
+ }
+ }
+}
+
+/*
+ * Deselect all files.
+ */
+void SQ_WidgetStack::slotDeselectAll()
+{
+ dirop->view()->clearSelection();
+}
+
+/*
+ * Select all files.
+ */
+void SQ_WidgetStack::slotSelectAll()
+{
+ KFileItemList *sd_files = const_cast<KFileItemList *>(items());
+ KFileView *local = dirop->view();
+ KFileItem *i;
+
+ if(!sd_files)
+ return;
+
+ i = sd_files->first();
+
+ // go through files and select them all
+ while(i)
+ {
+ local->setSelected(i, true);
+ i = sd_files->next();
+ }
+}
+
+TDEAction* SQ_WidgetStack::action(const TQString &name)
+{
+ return dirop->actionCollection()->action(name);
+}
+
+bool SQ_WidgetStack::updateRunning() const
+{
+ if(dirop->viewType() != SQ_DirOperator::TypeThumbs)
+ return false;
+
+ SQ_FileThumbView *tv = dynamic_cast<SQ_FileThumbView *>(dirop->view());
+
+ if(!tv)
+ return false;
+
+ return tv->updateRunning();
+}
+
+void SQ_WidgetStack::saveState()
+{
+ SQ_Config::instance()->writeEntry("last visited", dirop->url().prettyURL());
+ SQ_Config::instance()->writeEntry("last_action", static_cast<int>(fileaction));
+ SQ_Config::instance()->writeEntry("last_url", lastURL.prettyURL());
+
+ dirop->saveConfig();
+}
+
+#include "sq_widgetstack.moc"
diff --git a/src/sq_widgetstack.h b/src/sq_widgetstack.h
new file mode 100644
index 0000000..410e20d
--- /dev/null
+++ b/src/sq_widgetstack.h
@@ -0,0 +1,251 @@
+/***************************************************************************
+ sq_widgetstack.h - description
+ -------------------
+ begin : Mon Mar 15 2004
+ copyright : (C) 2004 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef SQ_WIDGETSTACK_H
+#define SQ_WIDGETSTACK_H
+
+#include <tqobject.h>
+#include <tqstring.h>
+
+#include <kurl.h>
+#include <tdefileitem.h>
+
+#include "sq_diroperator.h"
+
+namespace TDEIO { class Job; }
+
+class TQTimer;
+
+class TDEAction;
+class TDEToggleAction;
+class KFileView;
+
+/*
+ * SQ_WidgetStack is a simple wrapper for file manager (navigator).
+ *
+ * It serves all file actions (Copy, Move, Link to...), thumbnail
+ * updates, selecting/deselecting files with +/- etc.
+ */
+
+class SQ_WidgetStack : public TQObject
+{
+ TQ_OBJECT
+
+
+ public:
+ /*
+ * Create navigator.
+ * id ::=
+ * 0 = List view
+ * 1 = Icon view
+ * 2 = Detail view
+ * 3 = Thumbnail view
+ */
+ SQ_WidgetStack(TQWidget *parent, const int id);
+
+ ~SQ_WidgetStack();
+
+ /*
+ * Direction for moveTo().
+ */
+ enum Direction { Next = 0, Previous };
+
+ enum FileAction { Copy = 0, Cut, Link, Unknown };
+
+ enum moveToError { moveSuccess = 0, moveFailed } ;
+
+ SQ_DirOperator* diroperator() const;
+
+ bool updateRunning() const;
+
+ void repeat();
+
+ void init();
+
+ void saveState();
+
+ /*
+ * Get current url. Just calls SQ_DirOperator::url().
+ */
+ KURL url() const;
+
+ /*
+ * Selected items in currently visible diroperator.
+ */
+ const KFileItemList* selectedItems() const;
+
+ /*
+ * All items in currently visible diroperator.
+ */
+ const KFileItemList* items() const;
+
+ /*
+ * Update grid for thumbnail view. New grid is calcalated from item
+ * margins (from Options).
+ */
+ void updateGrid(bool arrange);
+
+ /*
+ * Reread current directory.
+ */
+ void updateView();
+
+ /*
+ * Quick access to SQ_DirOperator::actionCollection::action()
+ */
+ TDEAction *action(const TQString &name);
+
+ /*
+ * Select first supported image in current directory.
+ * Used by SQ_GLWidget.
+ */
+ void firstFile();
+
+ /*
+ * Select last supported image in current directory.
+ * Used by SQ_GLWidget.
+ */
+ void lastFile();
+
+ static SQ_WidgetStack* instance() { return m_instance; }
+
+ private:
+
+ void emitNewLastURL(const KURL &u);
+
+ void moveToFirstLast(Direction d, bool exec = true);
+ /*
+ * Save currently selected items' paths, if any.
+ *
+ * Return true, if at least one url was saved.
+ */
+ bool prepare();
+
+ /*
+ * Execute SQ_SelectDeselectGroup dialog, and select or
+ * deselect files after it has been closed.
+ */
+ void selectDeselectGroup(bool select);
+
+ /*
+ * Set current url for all _other_ widgets and objects (bookmarks,
+ * tree, SQ_QuickOperator etc.)
+ */
+ void setURL(const KURL &, bool = true);
+
+ signals:
+ void newLastURL(const TQString &);
+
+ public slots:
+ /*
+ * Change view type. See SQ_DirOperator::ViewT for more.
+ */
+ void raiseWidget(SQ_DirOperator::ViewT, bool doUpdate = true);
+
+ void slotSelectFirstFile();
+ void slotSelectLastFile();
+
+ void emitNextSelected();
+ void emitPreviousSelected();
+
+ /*
+ * Set filter.
+ */
+ void setNameFilter(const TQString&);
+
+ /*
+ * Used by SQ_FileThumbView to manipulate thumbnail progress.
+ */
+ void thumbnailsUpdateEnded();
+ void thumbnailUpdateStart(int);
+ void thumbnailProcess();
+ void slotDelayedShowProgress();
+
+ /*
+ * Set url
+ */
+ void setURLForCurrent(const TQString &, bool parseTree = true);
+ void setURLForCurrent(const KURL &, bool parseTree = true);
+ void slotRunSeparately();
+
+ /*
+ * Select next/prevous supported image in filemanager.
+ * Do nothing, if no more supported images found in given
+ * direction.
+ */
+ int moveTo(Direction direction, KFileItem *it = 0, bool useSupported = true);
+
+ /*
+ * Get current filter.
+ */
+ TQString nameFilter() const;
+
+ /*
+ * Slots for file actions: copy, move, cut...
+ */
+ void slotFileCopy();
+ void slotFileCut();
+ void slotFilePaste();
+ void slotFileCopyTo();
+ void slotFileMoveTo();
+ void slotFileLinkTo();
+
+ private slots:
+ void slotRecreateThumbnail();
+ void slotDelayedRecreateThumbnail();
+
+ void slotTreeMenuDone(const KURL &, int);
+
+ void slotJobResult(TDEIO::Job *job);
+
+ /*
+ * User wants to select to deselect some files.
+ */
+ void slotSelectGroup();
+ void slotDeselectGroup();
+
+ /*
+ * Deselect all files.
+ */
+ void slotDeselectAll();
+
+ /*
+ * Select all files.
+ */
+ void slotSelectAll();
+
+ private:
+ /*
+ * File manager itself
+ */
+ SQ_DirOperator *dirop;
+
+ TQTimer *timerShowProgress;
+ KURL::List files; // files to copy, move or link
+ KURL lastURL;
+ FileAction fileaction;
+
+ static SQ_WidgetStack *m_instance;
+};
+
+inline
+SQ_DirOperator* SQ_WidgetStack::diroperator() const
+{
+ return dirop;
+}
+
+#endif