1 /* This file is part of the KDE Project -*- mode:c++; -*- 2 Copyright (C) 2010 Jonathan Marten <jjm@keelhaul.me.uk> 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this library; see the file COPYING.LIB. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef SCANPARAMS_P_H 21 #define SCANPARAMS_P_H 22 23 #include <qwidget.h> 24 #include <qlabel.h> 25 #include <qgridlayout.h> 26 27 // Limits for the scan option and label, to keep them to reasonable sizes 28 #define MAX_CONTROL_WIDTH 300 29 #define MAX_LABEL_WIDTH 150 30 #define MIN_LABEL_WIDTH 50 31 32 /** 33 * This class represents a single options page (Basic, Other or Advanced) 34 * within the scan parameter GUI. 35 * 36 * @author Jonathan Marten 37 */ 38 39 class ScanParamsPage : public QWidget 40 { 41 Q_OBJECT 42 43 public: 44 /** 45 * Create a new options page. 46 * 47 * @param parent The parent widget 48 * @param name Qt object name 49 */ 50 explicit ScanParamsPage(QWidget *parent, const char *name = nullptr); 51 52 /** 53 * Destructor. 54 */ 55 virtual ~ScanParamsPage(); 56 57 /** 58 * Add a standard parameter row to the page. 59 * 60 * @param lab Label for the parameter, normally from KScanOption::getlabel() 61 * or @c nullptr for no label. 62 * @param wid Scan control widget, normally from KScanOption::widget(). 63 * @param unit SANE unit label, normally from KScanOption::getUnit() or 64 * @c nullptr for no unit label. 65 * @param align Special alignment flags for layout row. 66 67 * @note The layout coloumns are used as follows: the @p lab label goes in 68 * column 0, left aligned. Column 1 is a spacer. If the @p unit label is 69 * present then it goes in column 3 and the @p wid widget in column 2. If 70 * there is no @p unit label then the @p wid widget spans columns 2 and 3. 71 */ 72 void addRow(QLabel *lab, QWidget *wid, QLabel *unit = nullptr, Qt::Alignment align = Qt::Alignment()); 73 74 /** 75 * Add a full width widget to the page. 76 * 77 * @param wid The widget to add. 78 */ 79 void addRow(QWidget *wid); 80 81 /** 82 * Finish off the layout by adding a stretch widget (so that all the created 83 * parameters are aligned to the top), and check whether any widgets have 84 * been added. 85 * 86 * @return @c true if any parameter widgets are present 87 */ 88 bool lastRow(); 89 90 /** 91 * Add a group separator to the layout. Because of the widget sorting there 92 * may be nothing following, or another group, so the group is retained as 93 * "pending" and added just before the next row. 94 * 95 * @param wid The widget to add. 96 */ 97 void addGroup(QWidget *wid); 98 99 private: 100 void checkPendingGroup(); 101 102 QGridLayout *mLayout; 103 int mNextRow; 104 QWidget *mPendingGroup; 105 }; 106 107 #endif // SCANPARAMS_P_H 108