KRename – powerful batch renamer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pictureplugin.cpp 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /***************************************************************************
  2. pictureplugin.cpp - description
  3. -------------------
  4. begin : Son Apr 14 2002
  5. copyright : (C) 2002 by Dominik Seichter
  6. email : domseichter@web.de
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************/
  16. #include "pictureplugin.h"
  17. // QT includes
  18. #include <tqimage.h>
  19. // KDE includes
  20. #include <tdeapplication.h>
  21. #include <tdelocale.h>
  22. PicturePlugin::PicturePlugin()
  23. : FilePlugin( 0 )
  24. {
  25. keys.append( "resolution" );
  26. keys.append( "xres" );
  27. keys.append( "yres" );
  28. keys.append( "bitdepth" );
  29. setupKeys();
  30. m_icon = "image-x-generic";
  31. }
  32. const TQString PicturePlugin::getName() const
  33. {
  34. return i18n("Picture Plugin");
  35. }
  36. const TQString PicturePlugin::getAccelName() const
  37. {
  38. return i18n("P&icture Plugin");
  39. }
  40. const TQString PicturePlugin::getPattern() const
  41. {
  42. return "pic";
  43. }
  44. TQString PicturePlugin::processFile( BatchRenamer* b, int i, TQString token, int )
  45. {
  46. TQString resolution;
  47. TQString xres;
  48. TQString yres;
  49. TQString bitdepth;
  50. TQString filename = BatchRenamer::buildFilename( &b->files()[i].src );
  51. token = token.lower();
  52. /*
  53. * Check if we have something cached for this file
  54. */
  55. if( cache.contains( filename + "::" + token ) )
  56. return cache[filename + "::" + token ];
  57. TQImage img( filename );
  58. if( img.isNull() )
  59. return TQString();
  60. resolution = TQString( "%1x%2" ).arg(img.width()).arg(img.height());
  61. xres = TQString::number( img.width() );
  62. yres = TQString::number( img.height() );
  63. bitdepth = TQString::number( img.depth() );
  64. if( cache.count() >= CACHE_MAX )
  65. cache.remove( cache.begin() );
  66. TQString ret = TQString();
  67. if( token == getPattern() + "resolution" )
  68. ret = resolution;
  69. else if( token == getPattern() + "xres" )
  70. ret = xres;
  71. else if( token == getPattern() + "yres" )
  72. ret = yres;
  73. else if( token == getPattern() + "bitdepth" )
  74. ret = bitdepth;
  75. cache.insert( filename + "::" + token, ret );
  76. return ret;
  77. }
  78. #include "pictureplugin.moc"