- Improved palette document spec
[dashstudio.git] / src / shell / connectdialog.cpp
bloba7f9f861b970ca0dcd191961169957785c87291f
1 /***************************************************************************
2 * Copyright (C) 2007 by David Cuadrado *
3 * krawek@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
22 #include "connectdialog.h"
24 #include <dcore/config.h>
25 #include <dgui/iconloader.h>
27 #include <QDialogButtonBox>
29 #include "ui_connect.h"
31 ConnectDialog::ConnectDialog(QWidget *parent)
32 : QDialog(parent)
34 QVBoxLayout *layout = new QVBoxLayout(this);
36 QWidget *container = new QWidget;
37 ui = new Ui::Connect;
38 ui->setupUi(container);
40 ui->imageNetwork->setPixmap(DGui::IconLoader::self()->load("applications-internet.svg").pixmap(100, 100));
41 ui->port->setValue(6821);
43 layout->addWidget(container);
45 QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
47 layout->addWidget(box);
49 restoreSettings();
51 connect(box, SIGNAL(accepted()), this, SLOT(accept()));
52 connect(box, SIGNAL(rejected()), this, SLOT(reject()));
56 ConnectDialog::~ConnectDialog()
58 saveSettings();
59 delete ui;
62 QString ConnectDialog::login() const
64 return ui->user->text();
67 QString ConnectDialog::password() const
69 return ui->password->text();
72 QString ConnectDialog::server() const
74 return ui->server->text();
77 int ConnectDialog::port() const
79 return ui->port->value();
82 void ConnectDialog::saveSettings()
84 DCore::Config *config = DCore::Config::self();
85 config->beginGroup("Network");
87 config->setValue("login", login());
89 if( ui->storePassword->isChecked() )
91 config->setValue("password", password());
93 else
95 config->remove("password");
98 config->setValue("server", server());
99 config->setValue("port", port());
101 config->endGroup();
104 void ConnectDialog::restoreSettings()
106 DCore::Config *config = DCore::Config::self();
107 config->beginGroup("Network");
109 ui->user->setText(config->value("login").toString());
111 if( config->contains("password") )
113 ui->password->setText(config->value("password").toString());
114 ui->storePassword->setChecked(true);
117 ui->server->setText(config->value("server").toString());
118 ui->port->setValue(config->value("port").toInt());
120 config->endGroup();