File indexing completed on 2024-05-05 04:21:24
0001 0002 /* 0003 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org> 0004 All rights reserved. 0005 0006 Redistribution and use in source and binary forms, with or without 0007 modification, are permitted provided that the following conditions 0008 are met: 0009 0010 1. Redistributions of source code must retain the above copyright 0011 notice, this list of conditions and the following disclaimer. 0012 2. Redistributions in binary form must reproduce the above copyright 0013 notice, this list of conditions and the following disclaimer in the 0014 documentation and/or other materials provided with the distribution. 0015 0016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0017 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0018 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0019 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0020 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0021 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0022 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0023 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0025 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0026 */ 0027 0028 0029 #ifndef kpDocumentSaveOptionsWidget_H 0030 #define kpDocumentSaveOptionsWidget_H 0031 0032 0033 #include <QRect> 0034 #include <QWidget> 0035 0036 #include "imagelib/kpDocumentMetaInfo.h" 0037 #include "document/kpDocumentSaveOptions.h" 0038 0039 0040 class QComboBox; 0041 class QImage; 0042 class QLabel; 0043 class QTimer; 0044 class QSpinBox; 0045 class QPushButton; 0046 0047 class kpDocumentSaveOptionsPreviewDialog; 0048 0049 0050 class kpDocumentSaveOptionsWidget : public QWidget 0051 { 0052 Q_OBJECT 0053 0054 public: 0055 kpDocumentSaveOptionsWidget (const QImage &docPixmap, 0056 const kpDocumentSaveOptions &saveOptions, 0057 const kpDocumentMetaInfo &metaInfo, 0058 QWidget *parent); 0059 kpDocumentSaveOptionsWidget (QWidget *parent); 0060 private: 0061 void init (); 0062 public: 0063 ~kpDocumentSaveOptionsWidget () override; 0064 0065 0066 // <visualParent> is usually the filedialog 0067 void setVisualParent (QWidget *visualParent); 0068 0069 0070 protected: 0071 bool mimeTypeHasConfigurableColorDepth () const; 0072 bool mimeTypeHasConfigurableQuality () const; 0073 0074 public: 0075 QString mimeType () const; 0076 public Q_SLOTS: 0077 void setMimeType (const QString &string); 0078 0079 public: 0080 int colorDepth () const; 0081 bool dither () const; 0082 protected: 0083 static int colorDepthComboItemFromColorDepthAndDither (int depth, bool dither); 0084 public Q_SLOTS: 0085 void setColorDepthDither (int depth, 0086 bool dither = kpDocumentSaveOptions::initialDither ()); 0087 protected Q_SLOTS: 0088 void slotColorDepthSelected (); 0089 0090 public: 0091 int quality () const; 0092 public Q_SLOTS: 0093 void setQuality (int newQuality); 0094 0095 public: 0096 kpDocumentSaveOptions documentSaveOptions () const; 0097 public Q_SLOTS: 0098 void setDocumentSaveOptions (const kpDocumentSaveOptions &saveOptions); 0099 0100 0101 public: 0102 void setDocumentPixmap (const QImage &documentPixmap); 0103 void setDocumentMetaInfo (const kpDocumentMetaInfo &metaInfo); 0104 0105 0106 protected: 0107 enum Mode 0108 { 0109 // (mutually exclusive) 0110 None, ColorDepth, Quality 0111 }; 0112 0113 Mode mode () const; 0114 void setMode (Mode mode); 0115 0116 protected Q_SLOTS: 0117 void repaintLabels (); 0118 0119 0120 protected Q_SLOTS: 0121 void showPreview (bool yes = true); 0122 void hidePreview (); 0123 void updatePreviewDelayed (); 0124 void updatePreview (); 0125 void updatePreviewDialogLastRelativeGeometry (); 0126 0127 0128 protected: 0129 QWidget *m_visualParent; 0130 0131 Mode m_mode; 0132 0133 QImage *m_documentPixmap; 0134 0135 kpDocumentSaveOptions m_baseDocumentSaveOptions; 0136 kpDocumentMetaInfo m_documentMetaInfo; 0137 0138 QLabel *m_colorDepthLabel; 0139 QComboBox *m_colorDepthCombo; 0140 int m_colorDepthComboLastSelectedItem; 0141 QWidget *m_colorDepthSpaceWidget; 0142 0143 QLabel *m_qualityLabel; 0144 QSpinBox *m_qualityInput; 0145 0146 QPushButton *m_previewButton; 0147 kpDocumentSaveOptionsPreviewDialog *m_previewDialog; 0148 QRect m_previewDialogLastRelativeGeometry; 0149 QTimer *m_updatePreviewTimer; 0150 int m_updatePreviewDelay; 0151 QTimer *m_updatePreviewDialogLastRelativeGeometryTimer; 0152 }; 0153 0154 0155 #endif // kpDocumentSaveOptionsWidget_H