1 /*************************************************************************** 2 * Copyright (C) 2003 by Sébastien Laoût * 3 * slaout@linux62.org * 4 * * 5 * This program is free software; you can redistribute it and/or modify * 6 * it under the terms of the GNU General Public License as published by * 7 * the Free Software Foundation; either version 2 of the License, or * 8 * (at your option) any later version. * 9 * * 10 * This program is distributed in the hope that it will be useful, * 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 * GNU General Public License for more details. * 14 * * 15 * You should have received a copy of the GNU General Public License * 16 * along with this program; if not, write to the * 17 * Free Software Foundation, Inc., * 18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 19 ***************************************************************************/ 20 21 #ifndef VARIOUSWIDGETS_H 22 #define VARIOUSWIDGETS_H 23 24 #include <QWidget> 25 #include <QDialog> 26 #include <QDialog> 27 28 #include <KComboBox> 29 #include <KUrlLabel> 30 31 class QLineEdit; 32 class QListWidgetItem; 33 class QResizeEvent; 34 class QString; 35 class QKeyEvent; 36 37 /** A widget to select a command to run, 38 * with a QLineEdit and a QPushButton. 39 * @author Sébastien Laoût 40 */ 41 class RunCommandRequester : public QWidget 42 { 43 Q_OBJECT 44 public: 45 RunCommandRequester(const QString &runCommand, const QString &message, QWidget *parent = 0); 46 ~RunCommandRequester(); 47 QString runCommand(); 48 void setRunCommand(const QString &runCommand); lineEdit()49 QLineEdit *lineEdit() { 50 return m_runCommand; 51 } 52 private slots: 53 void slotSelCommand(); 54 private: 55 QLineEdit *m_runCommand; 56 QString m_message; 57 }; 58 59 /** KComboBox to ask icon size 60 * @author Sébastien Laoût 61 */ 62 class IconSizeCombo : public KComboBox 63 { 64 Q_OBJECT 65 public: 66 IconSizeCombo(QWidget *parent = 0); 67 ~IconSizeCombo(); 68 int iconSize(); 69 void setSize(int size); 70 }; 71 72 /** A window that the user resize to graphically choose a new image size 73 * TODO: Create a SizePushButton or even SizeWidget 74 * @author Sébastien Laoût 75 */ 76 class ViewSizeDialog : public QDialog 77 { 78 Q_OBJECT 79 public: 80 ViewSizeDialog(QWidget *parent, int w, int h); 81 ~ViewSizeDialog(); 82 private: 83 virtual void resizeEvent(QResizeEvent *); 84 QWidget *m_sizeGrip; 85 }; 86 87 /** A label displaying a link that, once clicked, offer a What's This messageBox to help users. 88 * @author Sébastien Laoût 89 */ 90 class HelpLabel : public KUrlLabel 91 { 92 Q_OBJECT 93 public: 94 HelpLabel(const QString &text, const QString &message, QWidget *parent); 95 ~HelpLabel(); message()96 QString message() { 97 return m_message; 98 } 99 public slots: setMessage(const QString & message)100 void setMessage(const QString &message) { 101 m_message = message; 102 } 103 void display(); 104 private: 105 QString m_message; 106 }; 107 108 /** A dialog to choose the size of an icon. 109 * @author Sébastien Laoût 110 */ 111 class IconSizeDialog : public QDialog 112 { 113 Q_OBJECT 114 public: 115 IconSizeDialog(const QString &caption, const QString &message, const QString &icon, int iconSize, QWidget *parent); 116 ~IconSizeDialog(); iconSize()117 int iconSize() { 118 return m_iconSize; 119 } /// << @return the chozen icon size (16, 32, ...) or -1 if canceled! 120 protected slots: 121 void slotCancel(); 122 void slotSelectionChanged(); 123 void choose(QListWidgetItem*); 124 private: 125 QListWidgetItem *m_size16; 126 QListWidgetItem *m_size22; 127 QListWidgetItem *m_size32; 128 QListWidgetItem *m_size48; 129 QListWidgetItem *m_size64; 130 QListWidgetItem *m_size128; 131 int m_iconSize; 132 QPushButton* okButton; 133 }; 134 135 /** 136 * A missing class from Frameworks (and Qt): a combobox to select a font size! 137 */ 138 class FontSizeCombo : public KComboBox 139 { 140 Q_OBJECT 141 public: 142 FontSizeCombo(bool rw, bool withDefault, QWidget *parent = 0); 143 ~FontSizeCombo(); 144 void setFontSize(qreal size); 145 qreal fontSize(); 146 protected: 147 void keyPressEvent(QKeyEvent *event); 148 signals: 149 void sizeChanged(qreal size); 150 void escapePressed(); 151 void returnPressed2(); 152 private slots: 153 void textChangedInCombo(const QString &text); 154 private: 155 bool m_withDefault; 156 }; 157 158 #endif // VARIOUSWIDGETS_H 159