now mobile ppp widget has been completed

This commit is contained in:
arcan1s 2014-02-21 21:26:44 +04:00
parent d85e5560fa
commit f3b6457a9b
14 changed files with 256 additions and 83 deletions

View File

@ -24,6 +24,7 @@ BridgeWidget::BridgeWidget(QWidget *parent)
ui(new Ui::BridgeWidget) ui(new Ui::BridgeWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
clear();
} }
@ -31,3 +32,30 @@ BridgeWidget::~BridgeWidget()
{ {
delete ui; delete ui;
} }
void BridgeWidget::clear()
{
ui->checkBox_skip->setCheckState(Qt::Unchecked);
}
QHash<QString, QString> BridgeWidget::getSettings()
{
QHash<QString, QString> bridgeSettings;
if (isOk() == 0) {
if (ui->checkBox_skip->checkState() == Qt::Checked)
bridgeSettings[QString("SkipForwardingDelay")] = QString("yes");
}
clear();
return bridgeSettings;
}
int BridgeWidget::isOk()
{
// all fine
return 0;
}

View File

@ -32,6 +32,11 @@ class BridgeWidget : public QWidget
public: public:
explicit BridgeWidget(QWidget *parent = 0); explicit BridgeWidget(QWidget *parent = 0);
~BridgeWidget(); ~BridgeWidget();
QHash<QString, QString> getSettings();
int isOk();
public slots:
void clear();
private: private:
Ui::BridgeWidget *ui; Ui::BridgeWidget *ui;

View File

@ -18,6 +18,8 @@
#include "ethernetwidget.h" #include "ethernetwidget.h"
#include "ui_ethernetwidget.h" #include "ui_ethernetwidget.h"
#include <QDir>
#include <QFileDialog>
#include <QFile> #include <QFile>
@ -28,7 +30,6 @@ EthernetWidget::EthernetWidget(QWidget *parent)
ui->setupUi(this); ui->setupUi(this);
createActions(); createActions();
clear(); clear();
showAdvanced();
} }
@ -46,16 +47,32 @@ void EthernetWidget::clear()
ui->comboBox_driver->setCurrentIndex(0); ui->comboBox_driver->setCurrentIndex(0);
ui->spinBox_timeoutCarrier->setValue(5); ui->spinBox_timeoutCarrier->setValue(5);
ui->spinBox_timeoutWpa->setValue(15); ui->spinBox_timeoutWpa->setValue(15);
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
showAdvanced();
} }
void EthernetWidget::createActions() void EthernetWidget::createActions()
{ {
connect(ui->pushButton_ethernetAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced())); connect(ui->pushButton_ethernetAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->pushButton_wpaConfig, SIGNAL(clicked(bool)), this, SLOT(selectWpaConfig()));
connect(ui->checkBox_8021x, SIGNAL(stateChanged(int)), this, SLOT(showWpa(int))); connect(ui->checkBox_8021x, SIGNAL(stateChanged(int)), this, SLOT(showWpa(int)));
} }
void EthernetWidget::selectWpaConfig()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("EthernetWidget", "Select wpa configuration file"),
QDir::currentPath(),
QApplication::translate("EthernetWidget", "Configuration files (*.conf)"));
if (!filename.isEmpty())
ui->lineEdit_wpaConfig->setText(filename);
}
void EthernetWidget::showAdvanced() void EthernetWidget::showAdvanced()
{ {
if (ui->pushButton_ethernetAdvanced->text().indexOf(QString("Show")) > -1) { if (ui->pushButton_ethernetAdvanced->text().indexOf(QString("Show")) > -1) {
@ -104,6 +121,7 @@ QHash<QString, QString> EthernetWidget::getSettings()
int EthernetWidget::isOk() int EthernetWidget::isOk()
{ {
// file wpa_supplicant doesn't exists // file wpa_supplicant doesn't exists
if (!ui->lineEdit_wpaConfig->text().isEmpty())
if (!QFile(ui->lineEdit_wpaConfig->text()).exists()) if (!QFile(ui->lineEdit_wpaConfig->text()).exists())
return 1; return 1;
// all fine // all fine

View File

@ -40,6 +40,7 @@ public slots:
void clear(); void clear();
private slots: private slots:
void selectWpaConfig();
void showAdvanced(); void showAdvanced();
void showWpa(int state); void showWpa(int state);

View File

@ -99,6 +99,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="pushButton_wpaConfig">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -217,6 +224,7 @@
<tabstop>checkBox_skip</tabstop> <tabstop>checkBox_skip</tabstop>
<tabstop>checkBox_8021x</tabstop> <tabstop>checkBox_8021x</tabstop>
<tabstop>lineEdit_wpaConfig</tabstop> <tabstop>lineEdit_wpaConfig</tabstop>
<tabstop>pushButton_wpaConfig</tabstop>
<tabstop>comboBox_driver</tabstop> <tabstop>comboBox_driver</tabstop>
<tabstop>spinBox_timeoutCarrier</tabstop> <tabstop>spinBox_timeoutCarrier</tabstop>
<tabstop>spinBox_timeoutWpa</tabstop> <tabstop>spinBox_timeoutWpa</tabstop>

View File

@ -30,7 +30,6 @@ GeneralWidget::GeneralWidget(QWidget *parent, QString ifaceDir, QString profileD
ui->setupUi(this); ui->setupUi(this);
createActions(); createActions();
clear(); clear();
showAdvanced();
} }
@ -57,6 +56,9 @@ void GeneralWidget::clear()
ui->lineEdit_execUpPost->clear(); ui->lineEdit_execUpPost->clear();
ui->lineEdit_execDownPre->clear(); ui->lineEdit_execDownPre->clear();
ui->checkBox_forceConnect->setCheckState(Qt::Unchecked); ui->checkBox_forceConnect->setCheckState(Qt::Unchecked);
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
showAdvanced();
} }

View File

@ -29,7 +29,6 @@ IpWidget::IpWidget(QWidget *parent)
createActions(); createActions();
createFilter(); createFilter();
clear(); clear();
showAdvanced();
} }
@ -76,6 +75,9 @@ void IpWidget::clear()
ui->lineEdit_dnsSearch->clear(); ui->lineEdit_dnsSearch->clear();
ui->lineEdit_dnsOptions->clear(); ui->lineEdit_dnsOptions->clear();
ui->listWidget_dnsOptions->clear(); ui->listWidget_dnsOptions->clear();
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
showAdvanced();
} }

View File

@ -26,7 +26,7 @@
#include "ethernetwidget.h" #include "ethernetwidget.h"
#include "generalwidget.h" #include "generalwidget.h"
#include "ipwidget.h" #include "ipwidget.h"
#include "mobileppp.h" #include "mobilewidget.h"
#include "netctlinteract.h" #include "netctlinteract.h"
#include "netctlprofile.h" #include "netctlprofile.h"
#include "passwdwidget.h" #include "passwdwidget.h"
@ -73,7 +73,7 @@ MainWindow::MainWindow(QWidget *parent)
ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid); ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid);
ethernetWid = new EthernetWidget(this); ethernetWid = new EthernetWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid); ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid);
mobileWid = new MobilePpp(this); mobileWid = new MobileWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid); ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
pppoeWid = new PppoeWidget(this); pppoeWid = new PppoeWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid); ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);

View File

@ -29,7 +29,7 @@ class ErrorWindow;
class EthernetWidget; class EthernetWidget;
class GeneralWidget; class GeneralWidget;
class IpWidget; class IpWidget;
class MobilePpp; class MobileWidget;
class Netctl; class Netctl;
class NetctlProfile; class NetctlProfile;
class PasswdWidget; class PasswdWidget;
@ -89,7 +89,7 @@ private:
EthernetWidget *ethernetWid; EthernetWidget *ethernetWid;
GeneralWidget *generalWid; GeneralWidget *generalWid;
IpWidget *ipWid; IpWidget *ipWid;
MobilePpp *mobileWid; MobileWidget *mobileWid;
PppoeWidget *pppoeWid; PppoeWidget *pppoeWid;
TunnelWidget *tunnelWid; TunnelWidget *tunnelWid;
TuntapWidget *tuntapWid; TuntapWidget *tuntapWid;

View File

@ -204,6 +204,37 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="layout_newProfileButtons">
<item>
<widget class="QPushButton" name="pushButton_profileClear">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer_newProfileButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_profileSave">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_wifi"> <widget class="QWidget" name="tab_wifi">
@ -310,37 +341,6 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="layout_newProfileButtons">
<item>
<widget class="QPushButton" name="pushButton_profileClear">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer_newProfileButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_profileSave">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QMenuBar" name="menuBar"> <widget class="QMenuBar" name="menuBar">

View File

@ -1,33 +0,0 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "mobileppp.h"
#include "ui_mobileppp.h"
MobilePpp::MobilePpp(QWidget *parent)
: QWidget(parent),
ui(new Ui::MobilePpp)
{
ui->setupUi(this);
}
MobilePpp::~MobilePpp()
{
delete ui;
}

View File

@ -0,0 +1,132 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "mobilewidget.h"
#include "ui_mobilewidget.h"
#include <QDir>
#include <QFileDialog>
#include <QFile>
MobileWidget::MobileWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::MobileWidget)
{
ui->setupUi(this);
createActions();
clear();
}
MobileWidget::~MobileWidget()
{
delete ui;
}
void MobileWidget::clear()
{
ui->lineEdit_username->clear();
ui->lineEdit_password->clear();
ui->lineEdit_apn->clear();
ui->lineEdit_pin->clear();
ui->comboBox_mode->setCurrentIndex(0);
ui->spinBox_fail->setValue(5);
ui->checkBox_route->setCheckState(Qt::Checked);
ui->checkBox_dns->setCheckState(Qt::Checked);
ui->lineEdit_options->clear();
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
showAdvanced();
}
void MobileWidget::createActions()
{
connect(ui->pushButton_mobileAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->pushButton_options, SIGNAL(clicked(bool)), this, SLOT(selectOptionsFile()));
}
void MobileWidget::selectOptionsFile()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("MobileWidget", "Select options file"),
QDir::currentPath(),
QApplication::translate("MobileWidget", "Configuration files (*.conf)"));
if (!filename.isEmpty())
ui->lineEdit_options->setText(filename);
}
void MobileWidget::showAdvanced()
{
if (ui->pushButton_mobileAdvanced->text().indexOf(QString("Show")) > -1) {
ui->widget_mobileAdvanced->setShown(true);
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
}
else {
ui->widget_mobileAdvanced->setHidden(true);
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Show advanced"));
}
}
QHash<QString, QString> MobileWidget::getSettings()
{
QHash<QString, QString> mobileSettings;
if (isOk() == 0) {
if (!ui->lineEdit_username->text().isEmpty())
mobileSettings[QString("User")] = QString("'") + ui->lineEdit_username->text() + QString("'");
if (!ui->lineEdit_password->text().isEmpty())
mobileSettings[QString("Password")] = QString("'") + ui->lineEdit_password->text() + QString("'");
mobileSettings[QString("AccessPointName")] = ui->lineEdit_apn->text();
if (!ui->lineEdit_pin->text().isEmpty())
mobileSettings[QString("PIN")] = QString("'") + ui->lineEdit_pin->text() + QString("'");
else
mobileSettings[QString("PIN")] = QString("None");
mobileSettings[QString("Mode")] = ui->comboBox_mode->currentText();
if (ui->spinBox_fail->value() != 5)
mobileSettings[QString("MaxFail")] = QString(ui->spinBox_fail->value());
if (ui->checkBox_route->checkState() == Qt::Unchecked)
mobileSettings[QString("DefaultRoute")] = QString("false");
if (ui->checkBox_dns->checkState() == Qt::Unchecked)
mobileSettings[QString("UsePeerDNS")] = QString("false");
if (!ui->lineEdit_options->text().isEmpty())
mobileSettings[QString("OptionsFile")] = ui->lineEdit_options->text();
}
clear();
return mobileSettings;
}
int MobileWidget::isOk()
{
// APN is not set
if (ui->lineEdit_apn->text().isEmpty())
return 1;
// config file doesn't exist
if (!ui->lineEdit_options->text().isEmpty())
if (!QFile(ui->lineEdit_options->text()).exists())
return 2;
// all fine
return 0;
}

View File

@ -15,27 +15,37 @@
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ * * along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/ ***************************************************************************/
#ifndef MOBILEPPP_H #ifndef MOBILEWIDGET_H
#define MOBILEPPP_H #define MOBILEWIDGET_H
#include <QWidget> #include <QWidget>
namespace Ui { namespace Ui {
class MobilePpp; class MobileWidget;
} }
class MobilePpp : public QWidget class MobileWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MobilePpp(QWidget *parent = 0); explicit MobileWidget(QWidget *parent = 0);
~MobilePpp(); ~MobileWidget();
QHash<QString, QString> getSettings();
int isOk();
public slots:
void clear();
private slots:
void selectOptionsFile();
void showAdvanced();
private: private:
Ui::MobilePpp *ui; Ui::MobileWidget *ui;
void createActions();
}; };
#endif /* MOBILEPPP_H */ #endif /* MOBILEWIDGET_H */

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>MobilePpp</class> <class>MobileWidget</class>
<widget class="QWidget" name="MobilePpp"> <widget class="QWidget" name="MobileWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>