2 * ** Copyright (C) 2002 Net Integration Technologies
4 * ** This program is free software; you can redistribute it and/or modify
5 * ** it under the terms of the GNU Lesser General Public License as published by
6 * ** the Free Software Foundation; either version 2 of the License, or
7 * ** (at your option) any later version.
9 * ** This program 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
12 * ** GNU General Public License for more details.
14 * ** You should have received a copy of the GNU Lesser General Public License
15 * ** along with this program; if not, write to the Free Software
16 * ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "ukconfig.moc"
22 #include "kapplication.h"
24 // little helper borrowed from the KMail Sources: - thanks guys ;)
25 static inline QPixmap
loadIcon( const char * name
)
27 return KGlobal::instance()->iconLoader()->loadIcon( QString::fromLatin1(name
), KIcon::NoGroup
, KIcon::SizeMedium
);
30 /**************************************************************************/
32 /* UniKonfAddMount Starts Here */
34 UniKonfAddMount::UniKonfAddMount(QWidget
*parent
, const char *name
, KSimpleConfig
*_config
)
35 : KDialog(parent
, name
, true),
36 config(_config
)//, mp_modified(false)
38 aslayout
= new QGridLayout(this,5,4,3,-1);
41 ok
= new KPushButton(i18n("Ok"),this,"prefs_ok");
46 close
= new KPushButton(i18n("Close"),this,"prefs_close");
49 help
= new KPushButton(i18n("Help"),this,"prefs_help");
52 monikerl
= new QLabel(NULL
, i18n("Moniker:"), this);
53 moniker
= new KLineEdit(this);
54 mountpointl
= new QLabel(NULL
, i18n("Mount Point:"), this);
55 mountpoint
= new KLineEdit(this);
56 mountpoint
->setText("/");
58 aslayout
->addWidget(monikerl
, 0, 0);
59 aslayout
->addMultiCellWidget(moniker
, 0, 0, 1, 3);
60 aslayout
->addWidget(mountpointl
, 2, 0);
61 aslayout
->addMultiCellWidget(mountpoint
, 2, 2, 1, 3);
62 aslayout
->addWidget(ok
,5,1);
63 aslayout
->addWidget(close
,5,2);
64 aslayout
->addWidget(help
,5,3);
66 connect( ok
, SIGNAL(clicked()), SLOT(createnew()));
67 connect( close
, SIGNAL(clicked()), SLOT(reject()));
72 UniKonfAddMount::UniKonfAddMount(QString
*_mountpoint
, QWidget
*parent
,
73 const char *name
, KSimpleConfig
*_config
)
74 : KDialog(parent
,name
,TRUE
),
76 old_mount(*_mountpoint
)
78 config
->setGroup(_mountpoint
->latin1());
79 aslayout
= new QGridLayout(this,5,4,3,-1);
82 ok
= new KPushButton(i18n("Ok"),this,"prefs_ok");
87 close
= new KPushButton(i18n("Close"),this,"prefs_close");
90 help
= new KPushButton(i18n("Help"),this,"prefs_help");
93 monikerl
= new QLabel(NULL
, i18n("Moniker:"), this);
94 moniker
= new KLineEdit(this);
95 moniker
->setText(config
->readEntry("moniker"));
97 mountpointl
= new QLabel(NULL
, i18n("Mount Point:"), this);
98 mountpoint
= new KLineEdit(this);
99 mountpoint
->setText(_mountpoint
->latin1());
101 aslayout
->addWidget(monikerl
, 0, 0);
102 aslayout
->addMultiCellWidget(moniker
, 0, 0, 1, 3);
103 aslayout
->addWidget(mountpointl
, 2, 0);
104 aslayout
->addMultiCellWidget(mountpoint
, 2, 2, 1, 3);
106 aslayout
->addWidget(ok
,4,1);
107 aslayout
->addWidget(close
,4,2);
108 aslayout
->addWidget(help
,4,3);
110 connect( ok
, SIGNAL(clicked()), SLOT(modify()));
111 connect( close
, SIGNAL(clicked()), SLOT(reject()));
115 UniKonfAddMount::~UniKonfAddMount()
120 void UniKonfAddMount::createnew()
122 config
->setGroup(mountpoint
->text());
123 config
->writeEntry("moniker", moniker
->text());
128 void UniKonfAddMount::modify()
130 config
->setGroup(mountpoint
->text());
131 config
->deleteGroup(old_mount
, true);
132 config
->writeEntry("moniker", moniker
->text());
137 /**************************************************************************/
139 /* UniKonfCfgConn Starts Here */
140 /* - Configurationof mountpoints */
142 UniKonfCfgConn::UniKonfCfgConn(QWidget
*parent
, const char *name
, KSimpleConfig
*_config
)
143 : UniKonfCfgPage(parent
,name
),
146 servername
= new QString(QString::null
);
147 CHECK_PTR(servername
);
149 connectlayout
= new QGridLayout(this,5,3,3,-1);
150 CHECK_PTR(connectlayout
);
151 connectwindow
= new KListBox(this,"connectwindow");
152 CHECK_PTR(connectwindow
);
153 connect_add
= new KPushButton(i18n("Add"),this,"connect_add");
154 CHECK_PTR(connect_add
);
155 connect_mod
= new KPushButton(i18n("Modify"),this,"connect_mod");
156 CHECK_PTR(connect_mod
);
157 connect_del
= new KPushButton(i18n("Delete"),this,"connect_del");
158 CHECK_PTR(connect_del
);
160 connectlayout
->addMultiCellWidget(connectwindow
,0,4,0,1);
161 connectlayout
->addWidget(connect_add
,0,2);
162 connectlayout
->addWidget(connect_mod
,1,2);
163 connectlayout
->addWidget(connect_del
,2,2);
164 connectlayout
->addRowSpacing(3,50);
165 connectlayout
->addRowSpacing(4,50);
167 connect(connect_add
,SIGNAL(clicked()),SLOT(addMountPoint()));
168 connect(connect_mod
,SIGNAL(clicked()),SLOT(modMountPoint()));
169 connect(connect_del
,SIGNAL(clicked()),SLOT(delMountPoint()));
170 connect(connectwindow
,SIGNAL(highlighted(const QString
&)), SLOT(setMountPoint(const QString
&)));
174 UniKonfCfgConn::~UniKonfCfgConn()
179 QString
UniKonfCfgConn::helpAnchor() {
180 return QString::fromLatin1("configure-connections");
183 void UniKonfCfgConn::fillwindow()
185 connectwindow
->clear();
186 QStringList
sectlist(config
->groupList());
188 for ( QStringList::Iterator it
= sectlist
.begin(); it
!= sectlist
.end(); ++it
)
190 if (((*it
).contains("KFile") == 0) &&
191 ((*it
).contains("Global") == 0 ) &&
192 ((*it
).contains("Cert") == 0 ) &&
193 ((*it
).contains("<default>") == 0) )
194 connectwindow
->insertItem((*it
).latin1(), count
++);
198 void UniKonfCfgConn::addMountPoint()
200 UniKonfAddMount
dlg(this,"kdiradm",config
);
201 dlg
.setCaption("Add Server");
206 void UniKonfCfgConn::modMountPoint()
208 if (!servername
->isNull())
210 UniKonfAddMount
dlg(servername
, this,"kdiradm",config
);
211 dlg
.setCaption(i18n("Modify Server"));
215 KMessageBox::sorry(this,i18n("You Must Select a Server from the list!"));
219 void UniKonfCfgConn::delMountPoint()
221 if (!servername
->isNull())
223 config
->deleteGroup(servername
->latin1());
226 KMessageBox::sorry(this,i18n("You Must Select a Server from the list!"));
231 void UniKonfCfgConn::setMountPoint(const QString
&_selected
)
233 servername
= new QString(_selected
);
236 void UniKonfCfgConn::apply()
238 // For this page, apply doesn't really make sense, so this is just an empty
242 /**************************************************************************/
244 /* UniKonfPrefs Starts Here */
246 UniKonfCfg::UniKonfCfg(QWidget
*parent
, const char *name
, KSimpleConfig
*_config
)
247 : KDialogBase(IconList
, i18n("Configure"), Help
|Apply
|Ok
|Cancel
, Ok
, parent
, name
, true, true )
249 setIconListAllVisible( true );
254 // Connections to UniKonf mountpoints.
255 // -> Client, IniFile, etc.
256 page
= addPage( i18n("Mountpoints"), i18n("Mountpoints"), loadIcon("network"));
259 vlay
= new QVBoxLayout( page
, 0, spacingHint() );
262 connwidget
= new UniKonfCfgConn( page
, "connections", _config
);
263 CHECK_PTR(connwidget
);
265 vlay
->addWidget(connwidget
);
267 connwidget
->setPageIndex( pageIndex( page
) );
270 UniKonfCfg::~UniKonfCfg()
275 void UniKonfCfg::slotHelp()
277 int activePage
= activePageIndex();
279 if ( activePage
== connwidget
->pageIndex() )
280 kapp
->invokeHelp( connwidget
->helpAnchor() );
283 void UniKonfCfg::slotApply()
288 void UniKonfCfg::slotOk()
294 void UniKonfCfg::apply(bool AboutToClose
)
296 int activePage
= activePageIndex();
298 if ( AboutToClose
|| activePage
== connwidget
->pageIndex() )