00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#include "cupsdserveridentitypage.h"
00021
00022
#include <qlineedit.h>
00023
#include <klocale.h>
00024
#include <qlayout.h>
00025
#include <qlabel.h>
00026
#include <qwhatsthis.h>
00027
00028
#include "cupsdconf.h"
00029
#include "cupsdoption.h"
00030
00031 CupsdServerIdentityPage::CupsdServerIdentityPage(
QWidget *parent,
const char *name)
00032 : CupsdPage(parent, name)
00033 {
00034 path_.append(i18n(
"Server"));
00035
00036 header_ = i18n(
"Server General Configuration");
00037
00038
for (
int i=0;i<5;i++)
00039 opt_[i] =
new CupsdOption(
this);
00040
00041 servername_ =
new QLineEdit(opt_[0]);
00042 serveradmin_ =
new QLineEdit(opt_[1]);
00043 user_ =
new QLineEdit(opt_[2]);
00044 group_ =
new QLineEdit(opt_[3]);
00045 remroot_ =
new QLineEdit(opt_[4]);
00046
00047
QLabel *l1 =
new QLabel(i18n(
"Server name:"),
this);
00048 QLabel *l2 =
new QLabel(i18n(
"Administrator's email:"),
this);
00049 QLabel *l3 =
new QLabel(i18n(
"Server user:"),
this);
00050 QLabel *l4 =
new QLabel(i18n(
"Server group:"),
this);
00051 QLabel *l5 =
new QLabel(i18n(
"Remote user name:"),
this);
00052
00053
QGridLayout *main_ =
new QGridLayout(
this, 9, 2, 10, 10);
00054 main_->
addWidget(deflabel_, 0, 1, Qt::AlignRight|Qt::AlignVCenter);
00055 main_->
addWidget(opt_[0], 1, 1);
00056 main_->
addWidget(opt_[1], 2, 1);
00057 main_->
addWidget(opt_[2], 4, 1);
00058 main_->
addWidget(opt_[3], 5, 1);
00059 main_->
addWidget(opt_[4], 7, 1);
00060 main_->
addWidget(l1, 1, 0);
00061 main_->
addWidget(l2, 2, 0);
00062 main_->
addWidget(l3, 4, 0);
00063 main_->
addWidget(l4, 5, 0);
00064 main_->
addWidget(l5, 7, 0);
00065 main_->
setRowStretch(8, 1);
00066 main_->addRowSpacing(3, 20);
00067 main_->addRowSpacing(6, 20);
00068 }
00069
00070 CupsdServerIdentityPage::~CupsdServerIdentityPage()
00071 {
00072 }
00073
00074
bool CupsdServerIdentityPage::loadConfig(CupsdConf *conf,
QString&)
00075 {
00076 conf_ = conf;
00077
if (!conf->servername_.isNull())
00078 {
00079 opt_[0]->setDefault(
false);
00080 servername_->setText(conf->servername_);
00081 }
00082
if (!conf->serveradmin_.isNull())
00083 {
00084 opt_[1]->setDefault(
false);
00085 serveradmin_->setText(conf->serveradmin_);
00086 }
00087
if (!conf->user_.isNull())
00088 {
00089 opt_[2]->setDefault(
false);
00090 user_->setText(conf->user_);
00091 }
00092
if (!conf->group_.isNull())
00093 {
00094 opt_[3]->setDefault(
false);
00095 group_->setText(conf->group_);
00096 }
00097
if (!conf->remroot_.isNull())
00098 {
00099 opt_[4]->setDefault(
false);
00100 remroot_->setText(conf->remroot_);
00101 }
00102
return true;
00103 }
00104
00105
bool CupsdServerIdentityPage::saveConfig(CupsdConf *conf,
QString&)
00106 {
00107
if (!opt_[0]->isDefault() && !servername_->text().isNull()) conf->servername_ = servername_->text();
00108
if (!opt_[1]->isDefault() && !serveradmin_->text().isNull()) conf->serveradmin_ = serveradmin_->text();
00109
if (!opt_[2]->isDefault() && !user_->text().isNull()) conf->user_ = user_->text();
00110
if (!opt_[3]->isDefault() && !group_->text().isNull()) conf->group_ = group_->text();
00111
if (!opt_[4]->isDefault() && !remroot_->text().isNull()) conf->remroot_ = remroot_->text();
00112
return true;
00113 }
00114
00115
void CupsdServerIdentityPage::setDefaults()
00116 {
00117 servername_->setText(
"localhost");
00118 serveradmin_->setText(
"root@localhost");
00119 user_->setText(
"lp");
00120 group_->setText(
"sys");
00121 remroot_->setText(
"remroot");
00122 }
00123
00124
void CupsdServerIdentityPage::setInfos(CupsdConf *conf)
00125 {
00126
QWhatsThis::add(servername_, conf->comments_.toolTip(SERVERNAME_COMM));
00127
QWhatsThis::add(serveradmin_, conf->comments_.toolTip(SERVERADMIN_COMM));
00128
QWhatsThis::add(user_, conf->comments_.toolTip(USER_COMM));
00129
QWhatsThis::add(group_, conf->comments_.toolTip(GROUP_COMM));
00130
QWhatsThis::add(remroot_, conf->comments_.toolTip(REMOTEROOT_COMM));
00131 }