summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/profileeditorplugins.cpp
blob: a11d6b0dde165fdbd29ec15c5d9bbca246429dda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176

#include "profileeditorplugins.h"
#include "profile.h"

#include "qframe.h"
#include "qlabel.h"
#include "qlineedit.h"
#include "qlayout.h"

ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile p)
{
	m_parent = parent;
	m_profile = p;
	m_widget = NULL;
}

ProfileEditorPlugin::~ProfileEditorPlugin()
{
	if(m_widget) delete m_widget;
}

class ProfileEditorPluginSerial : public ProfileEditorPlugin
{
	public:
	
	ProfileEditorPluginSerial(QWidget *parent, Profile p)
	: ProfileEditorPlugin(parent, p)
	{
	}

	~ProfileEditorPluginSerial()
	{
	}

	QWidget *widget()
	{
		if(!m_widget)
		{
			QFrame *device_frame = new QFrame(m_parent);
			device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);

			QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);

			device_line = new QLineEdit("/dev/ttyS0", device_frame);

			QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
			vbox_frame->add(frame_device);
			vbox_frame->add(device_line);

			m_widget = device_frame;
		}

		return m_widget;
	}

	void save()
	{
		// special settings
		Profile p = m_profile;
		p.writeEntry("Device", device_line->text());
	}

	private:
		QLineEdit *device_line;
};

class ProfileEditorPluginIrda : public ProfileEditorPlugin
{
	public:

	ProfileEditorPluginIrda(QWidget *parent, Profile p)
	: ProfileEditorPlugin(parent, p)
	{
	}

	~ProfileEditorPluginIrda()
	{
	}

	QWidget *widget()
	{
		if(!m_widget)
		{
			QFrame *device_frame = new QFrame(m_parent);
			device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);

			QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);

			device_line = new QLineEdit("/dev/ircomm0", device_frame);

			QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
			vbox_frame->add(frame_device);
			vbox_frame->add(device_line);

			m_widget = device_frame;
		}

		return m_widget;
	}

	void save()
	{
		// special settings
		Profile p = m_profile;
		p.writeEntry("Device", device_line->text());
	}

	private:
		QLineEdit *device_line;
};

class ProfileEditorPluginModem : public ProfileEditorPlugin
{
	public:

	ProfileEditorPluginModem(QWidget *parent, Profile p)
	: ProfileEditorPlugin(parent, p)
	{
	}

	~ProfileEditorPluginModem()
	{
	}

	QWidget *widget()
	{
		if(!m_widget)
		{
			QFrame *device_frame = new QFrame(m_parent);
			device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);

			QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
			QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame);

			device_line = new QLineEdit("/dev/ttyS0", device_frame);
			number_line = new QLineEdit(device_frame);

			QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
			vbox_frame->add(frame_device);
			vbox_frame->add(device_line);
			vbox_frame->add(frame_number);
			vbox_frame->add(number_line);

			m_widget = device_frame;
		}

		return m_widget;
	}

	void save()
	{
		// special settings
		Profile p = m_profile;
		p.writeEntry("Device", device_line->text());
		p.writeEntry("Number", number_line->text());
	}

	private:
		QLineEdit *device_line, *number_line;
};

ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p)
{
	return new ProfileEditorPluginSerial(parent, p);
}

ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p)
{
	return new ProfileEditorPluginIrda(parent, p);
}

ProfileEditorPlugin *factory_modem(QWidget *parent, const Profile& p)
{
	return new ProfileEditorPluginModem(parent, p);
}