Diffstat (limited to 'noncore/apps/opie-console/profileeditorplugins.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/profileeditorplugins.cpp | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/profileeditorplugins.cpp b/noncore/apps/opie-console/profileeditorplugins.cpp new file mode 100644 index 0000000..54eee3f --- a/dev/null +++ b/noncore/apps/opie-console/profileeditorplugins.cpp | |||
@@ -0,0 +1,164 @@ | |||
1 | |||
2 | #include "profileeditorplugins.h" | ||
3 | #include "profile.h" | ||
4 | |||
5 | #include "qframe.h" | ||
6 | #include "qlabel.h" | ||
7 | #include "qlineedit.h" | ||
8 | #include "qlayout.h" | ||
9 | |||
10 | ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile p) | ||
11 | { | ||
12 | m_parent = parent; | ||
13 | m_profile = p; | ||
14 | m_widget = NULL; | ||
15 | } | ||
16 | |||
17 | ProfileEditorPlugin::~ProfileEditorPlugin() | ||
18 | { | ||
19 | if(m_widget) delete m_widget; | ||
20 | } | ||
21 | |||
22 | class ProfileEditorPluginSerial : public ProfileEditorPlugin | ||
23 | { | ||
24 | public: | ||
25 | |||
26 | ProfileEditorPluginSerial(QWidget *parent, Profile p) | ||
27 | : ProfileEditorPlugin(parent, p) | ||
28 | { | ||
29 | } | ||
30 | |||
31 | ~ProfileEditorPluginSerial() | ||
32 | { | ||
33 | } | ||
34 | |||
35 | QWidget *widget() | ||
36 | { | ||
37 | if(!m_widget) | ||
38 | { | ||
39 | QFrame *device_frame = new QFrame(m_parent); | ||
40 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); | ||
41 | |||
42 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | ||
43 | |||
44 | QLineEdit *frame_device_line = new QLineEdit("/dev/ttyS0", device_frame); | ||
45 | |||
46 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | ||
47 | vbox_frame->add(frame_device); | ||
48 | vbox_frame->add(frame_device_line); | ||
49 | |||
50 | m_widget = device_frame; | ||
51 | } | ||
52 | |||
53 | return m_widget; | ||
54 | } | ||
55 | |||
56 | void save() | ||
57 | { | ||
58 | } | ||
59 | }; | ||
60 | |||
61 | class ProfileEditorPluginIrda : public ProfileEditorPlugin | ||
62 | { | ||
63 | public: | ||
64 | |||
65 | ProfileEditorPluginIrda(QWidget *parent, Profile p) | ||
66 | : ProfileEditorPlugin(parent, p) | ||
67 | { | ||
68 | } | ||
69 | |||
70 | ~ProfileEditorPluginIrda() | ||
71 | { | ||
72 | } | ||
73 | |||
74 | QWidget *widget() | ||
75 | { | ||
76 | if(!m_widget) | ||
77 | { | ||
78 | QFrame *device_frame = new QFrame(m_parent); | ||
79 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); | ||
80 | |||
81 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | ||
82 | |||
83 | QLineEdit *frame_device_line = new QLineEdit("/dev/ircomm0", device_frame); | ||
84 | |||
85 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | ||
86 | vbox_frame->add(frame_device); | ||
87 | vbox_frame->add(frame_device_line); | ||
88 | |||
89 | m_widget = device_frame; | ||
90 | } | ||
91 | |||
92 | return m_widget; | ||
93 | } | ||
94 | |||
95 | void save() | ||
96 | { | ||
97 | } | ||
98 | }; | ||
99 | |||
100 | class ProfileEditorPluginModem : public ProfileEditorPlugin | ||
101 | { | ||
102 | public: | ||
103 | |||
104 | ProfileEditorPluginModem(QWidget *parent, Profile p) | ||
105 | : ProfileEditorPlugin(parent, p) | ||
106 | { | ||
107 | } | ||
108 | |||
109 | ~ProfileEditorPluginModem() | ||
110 | { | ||
111 | } | ||
112 | |||
113 | QWidget *widget() | ||
114 | { | ||
115 | if(!m_widget) | ||
116 | { | ||
117 | QFrame *device_frame = new QFrame(m_parent); | ||
118 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); | ||
119 | |||
120 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | ||
121 | QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame); | ||
122 | |||
123 | device_line = new QLineEdit("/dev/ttyS0", device_frame); | ||
124 | number_line = new QLineEdit(device_frame); | ||
125 | |||
126 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | ||
127 | vbox_frame->add(frame_device); | ||
128 | vbox_frame->add(device_line); | ||
129 | vbox_frame->add(frame_number); | ||
130 | vbox_frame->add(number_line); | ||
131 | |||
132 | m_widget = device_frame; | ||
133 | } | ||
134 | |||
135 | return m_widget; | ||
136 | } | ||
137 | |||
138 | void save() | ||
139 | { | ||
140 | // special settings | ||
141 | Profile p = m_profile; | ||
142 | p.writeEntry("Device", device_line->text()); | ||
143 | p.writeEntry("Number", number_line->text()); | ||
144 | } | ||
145 | |||
146 | private: | ||
147 | QLineEdit *device_line, *number_line; | ||
148 | }; | ||
149 | |||
150 | ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p) | ||
151 | { | ||
152 | return new ProfileEditorPluginSerial(parent, p); | ||
153 | } | ||
154 | |||
155 | ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p) | ||
156 | { | ||
157 | return new ProfileEditorPluginIrda(parent, p); | ||
158 | } | ||
159 | |||
160 | ProfileEditorPlugin *factory_modem(QWidget *parent, const Profile& p) | ||
161 | { | ||
162 | return new ProfileEditorPluginModem(parent, p); | ||
163 | } | ||
164 | |||