ctkIconEnginePlugin.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010 Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkIconEnginePlugin_h
  15. #define __ctkIconEnginePlugin_h
  16. // Qt includes
  17. #include <QIconEngineV2>
  18. #include <QIconEnginePluginV2>
  19. // CTK includes
  20. #include "ctkPimpl.h"
  21. #include "ctkPixmapIconEngine.h"
  22. #include "CTKWidgetsExport.h"
  23. class ctkIconEnginePluginPrivate;
  24. class ctkIconEnginePrivate;
  25. /// if you want to use it in your application, don't forget to declare
  26. /// Q_EXPORT_PLUGIN2(yourplugin, ctkIconEnginePlugin)
  27. /// Currently
  28. class CTK_WIDGETS_EXPORT ctkIconEnginePlugin: public QIconEnginePluginV2
  29. {
  30. Q_OBJECT;
  31. public:
  32. ctkIconEnginePlugin(QObject* parent = 0);
  33. virtual QIconEngineV2* create(const QString& filename=QString());
  34. /// Support all the Qt image formats by default
  35. virtual QStringList keys()const;
  36. /// Directory list given to the created icon engines
  37. /// Subdirectories where the icons should be searched, typically:
  38. /// "Small", "Medium", "Large", "XLarge" or
  39. /// "16x16", "32x32", "64x64", "128x128" or
  40. /// "LowDef", "HighDef"
  41. /// \sa ctkIconEnginePlugin::setSizeDirectories
  42. void setSizeDirectories(const QStringList& sizeDirectories);
  43. QStringList sizeDirectories()const;
  44. private:
  45. CTK_DECLARE_PRIVATE(ctkIconEnginePlugin);
  46. };
  47. //------------------------------------------------------------------------------
  48. /// Only support files in ressources.
  49. /// TODO: support any files (not just files in resources)
  50. class CTK_WIDGETS_EXPORT ctkIconEngine: public ctkPixmapIconEngine
  51. {
  52. public:
  53. typedef ctkPixmapIconEngine Superclass;
  54. ctkIconEngine();
  55. virtual void addFile(const QString& fileName, const QSize& size,
  56. QIcon::Mode mode, QIcon::State state);
  57. /// Subdirectories where the icons should be searched, typically:
  58. /// "Small", "Medium", "Large", "XLarge" or
  59. /// "16x16", "32x32", "64x64", "128x128" or
  60. /// "LowDef", "HighDef"
  61. void setSizeDirectories(const QStringList& sizeDirectories);
  62. QStringList sizeDirectories()const;
  63. private:
  64. CTK_DECLARE_PRIVATE(ctkIconEngine);
  65. };
  66. #endif