1 /*
2 
3  Copyright (c) 2003-2013 uim Project https://github.com/uim/uim
4 
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without
8  modification, are permitted provided that the following conditions
9  are met:
10 
11  1. Redistributions of source code must retain the above copyright
12     notice, this list of conditions and the following disclaimer.
13  2. Redistributions in binary form must reproduce the above copyright
14     notice, this list of conditions and the following disclaimer in the
15     documentation and/or other materials provided with the distribution.
16  3. Neither the name of authors nor the names of its contributors
17     may be used to endorse or promote products derived from this software
18     without specific prior written permission.
19 
20  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
21  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
24  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  SUCH DAMAGE.
31 
32 */
33 #ifndef UIM_QT_PREF_QT_H
34 #define UIM_QT_PREF_QT_H
35 
36 #include <qdialog.h>
37 #include <qdict.h>
38 #include <qlistview.h>
39 #include <qwidgetstack.h>
40 #include <qlayout.h>
41 #include <qlabel.h>
42 #include <qpushbutton.h>
43 #include <qvbox.h>
44 #include <qhbox.h>
45 #include <qvgroupbox.h>
46 #include <qmap.h>
47 #include <qptrlist.h>
48 #include <qsplitter.h>
49 
50 #include <uim/uim.h>
51 #include <uim/uim-custom.h>
52 
53 
54 class UimCustomItemIface;
55 
56 class UimPrefDialog : public QDialog
57 {
58     Q_OBJECT
59 
60 public:
61     UimPrefDialog( QWidget *parent = 0, const char *name = 0 );
62     ~UimPrefDialog();
63 
64 protected:
65     void checkDotUimFile();
66 
67     void setupWidgets();
68     void createMainWidgets();
69     void createGroupWidgets();
70 
71     void confirmChange();
72     void confirmQuit();
73 
74 protected slots:
75     void slotSetDefault();
76     void slotApply();
77     void slotOK();
78     void slotCancel();
79 
80     void slotSelectionChanged( QListViewItem * );
81     void slotCustomValueChanged();
82 
83 private:
84     bool m_isValueChanged;
85 
86     QDict<QWidget>  m_groupWidgetsDict;
87     QString m_currentPageName;
88 
89     QListView *m_groupListView;
90     QWidgetStack *m_groupWidgetStack;
91 
92     QPushButton *m_applyButton;
93 };
94 
95 //---------------------------------------------------------------------------------
96 class QConfirmDialog : public QDialog {
97     Q_OBJECT
98 
99 public:
100     QConfirmDialog( const QString &msg, const QString &confname, QWidget *parent, const char *name = 0 );
101 
102 protected:
103     void setupWidgets( const QString& msg );
104 
105 protected slots:
106     void showOnStart( bool isShowOnStart );
107 
108 protected:
109     QString m_confname;
110 };
111 
112 //---------------------------------------------------------------------------------
113 class GroupPageWidget : public QWidget {
114     Q_OBJECT
115 
116 public:
117     GroupPageWidget( QWidget *parent, const char *group_name );
118 
119     void setDefault();
120     void setupWidgets();
121 
122 protected:
123 
124     UimCustomItemIface *addCustom( QVGroupBox *vbox, const char *custom_sym );
125     UimCustomItemIface *addCustomTypeBool( QVGroupBox *vbox, struct uim_custom *custom );
126     UimCustomItemIface *addCustomTypeInteger( QVGroupBox *vbox, struct uim_custom *custom );
127     UimCustomItemIface *addCustomTypeString( QVGroupBox *vbox, struct uim_custom *custom );
128     UimCustomItemIface *addCustomTypePathname( QVGroupBox *vbox, struct uim_custom *custom );
129     UimCustomItemIface *addCustomTypeChoice( QVGroupBox *vbox, struct uim_custom *custom );
130     UimCustomItemIface *addCustomTypeOrderedList( QVGroupBox *vbox, struct uim_custom *custom );
131     UimCustomItemIface *addCustomTypeKey( QVGroupBox *vbox, struct uim_custom *custom );
132 
133 protected slots:
slotCustomValueChanged()134     void slotCustomValueChanged(){ emit customValueChanged(); }
135 signals:
136     void customValueChanged();
137 
138 protected:
139     QPtrList<UimCustomItemIface> m_customIfaceList;
140     QString m_group_sym;
141     bool m_widget_created;
142 };
143 
144 #endif /* Not def: UIM_QT_PREF_QT_H */
145