tdegraphics
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.

kpdocumentsaveoptionswidget.h 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. Copyright (c) 2003,2004,2005 Clarence Dang <dang@kde.org>
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions
  6. are met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  13. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  17. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  18. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  21. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. */
  23. #ifndef KP_DOCUMENT_SAVE_OPTIONS_WIDGET_H
  24. #define KP_DOCUMENT_SAVE_OPTIONS_WIDGET_H
  25. #include <tqsize.h>
  26. #include <tqwidget.h>
  27. class TQPixmap;
  28. class TQLabel;
  29. class kpResizeSignallingLabel;
  30. class kpDocumentSaveOptionsPreviewDialog : public TQWidget
  31. {
  32. Q_OBJECT
  33. public:
  34. kpDocumentSaveOptionsPreviewDialog (TQWidget *parent, const char *name = 0);
  35. virtual ~kpDocumentSaveOptionsPreviewDialog ();
  36. TQSize preferredMinimumSize () const;
  37. protected:
  38. static const TQSize s_pixmapLabelMinimumSize;
  39. signals:
  40. void moved ();
  41. void resized ();
  42. void finished ();
  43. public slots:
  44. void setFilePixmapAndSize (const TQPixmap &filePixmap, int fileSize);
  45. void updatePixmapPreview ();
  46. protected:
  47. virtual void closeEvent (TQCloseEvent *e);
  48. virtual void moveEvent (TQMoveEvent *e);
  49. virtual void resizeEvent (TQResizeEvent *e);
  50. protected:
  51. TQPixmap *m_filePixmap;
  52. int m_fileSize;
  53. kpResizeSignallingLabel *m_filePixmapLabel;
  54. TQLabel *m_fileSizeLabel;
  55. };
  56. #include <tqrect.h>
  57. #include <tqwidget.h>
  58. #include <kpdocumentmetainfo.h>
  59. #include <kpdocumentsaveoptions.h>
  60. class TQLabel;
  61. class TQTimer;
  62. class KComboBox;
  63. class KIntNumInput;
  64. class KPushButton;
  65. class kpDocumentSaveOptionsWidget : public TQWidget
  66. {
  67. Q_OBJECT
  68. public:
  69. kpDocumentSaveOptionsWidget (const TQPixmap &docPixmap,
  70. const kpDocumentSaveOptions &saveOptions,
  71. const kpDocumentMetaInfo &metaInfo,
  72. TQWidget *parent, const char *name = 0);
  73. kpDocumentSaveOptionsWidget (TQWidget *parent, const char *name = 0);
  74. private:
  75. void init ();
  76. public:
  77. virtual ~kpDocumentSaveOptionsWidget ();
  78. // <visualParent> is usually the filedialog
  79. void setVisualParent (TQWidget *visualParent);
  80. protected:
  81. bool mimeTypeHasConfigurableColorDepth () const;
  82. bool mimeTypeHasConfigurableQuality () const;
  83. public:
  84. TQString mimeType () const;
  85. public slots:
  86. void setMimeType (const TQString &string);
  87. public:
  88. int colorDepth () const;
  89. bool dither () const;
  90. protected:
  91. static int colorDepthComboItemFromColorDepthAndDither (int depth, bool dither);
  92. public slots:
  93. void setColorDepthDither (int depth,
  94. bool dither = kpDocumentSaveOptions::initialDither ());
  95. protected slots:
  96. void slotColorDepthSelected ();
  97. public:
  98. int quality () const;
  99. public slots:
  100. void setQuality (int newQuality);
  101. public:
  102. kpDocumentSaveOptions documentSaveOptions () const;
  103. public slots:
  104. void setDocumentSaveOptions (const kpDocumentSaveOptions &saveOptions);
  105. public:
  106. void setDocumentPixmap (const TQPixmap &documentPixmap);
  107. void setDocumentMetaInfo (const kpDocumentMetaInfo &metaInfo);
  108. protected:
  109. enum Mode
  110. {
  111. // (mutually exclusive)
  112. None, ColorDepth, Quality
  113. };
  114. Mode mode () const;
  115. void setMode (Mode mode);
  116. protected slots:
  117. void repaintLabels ();
  118. protected slots:
  119. void showPreview (bool yes = true);
  120. void hidePreview ();
  121. void updatePreviewDelayed ();
  122. void updatePreview ();
  123. void updatePreviewDialogLastRelativeGeometry ();
  124. protected:
  125. TQWidget *m_visualParent;
  126. Mode m_mode;
  127. TQPixmap *m_documentPixmap;
  128. kpDocumentSaveOptions m_baseDocumentSaveOptions;
  129. kpDocumentMetaInfo m_documentMetaInfo;
  130. TQLabel *m_colorDepthLabel;
  131. KComboBox *m_colorDepthCombo;
  132. int m_colorDepthComboLastSelectedItem;
  133. TQWidget *m_colorDepthSpaceWidget;
  134. TQLabel *m_qualityLabel;
  135. KIntNumInput *m_qualityInput;
  136. KPushButton *m_previewButton;
  137. kpDocumentSaveOptionsPreviewDialog *m_previewDialog;
  138. TQRect m_previewDialogLastRelativeGeometry;
  139. TQTimer *m_updatePreviewTimer;
  140. int m_updatePreviewDelay;
  141. TQTimer *m_updatePreviewDialogLastRelativeGeometryTimer;
  142. };
  143. #endif // KP_DOCUMENT_SAVE_OPTIONS_WIDGET_H