2014-01-14 21:39:27 +00:00
|
|
|
/**
|
2014-01-22 21:58:53 +00:00
|
|
|
* Copyright 2014 Samoilenko Yuri<kinnalru@gmail.com>
|
2014-01-14 21:39:27 +00:00
|
|
|
*
|
|
|
|
* This program 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 2 of
|
|
|
|
* the License or (at your option) version 3 or any later version
|
|
|
|
* accepted by the membership of KDE e.V. (or its successor approved
|
|
|
|
* by the membership of KDE e.V.), which shall act as a proxy
|
|
|
|
* defined in Section 14 of version 3 of the license.
|
|
|
|
*
|
|
|
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sftp_config.h"
|
|
|
|
|
|
|
|
#include <KConfigGroup>
|
|
|
|
#include <KPluginFactory>
|
|
|
|
#include <KSharedConfig>
|
2014-09-22 00:24:42 +01:00
|
|
|
#include <QStandardPaths>
|
2014-06-16 19:02:07 +01:00
|
|
|
#include <KAboutData>
|
|
|
|
#include <KIconLoader>
|
2014-01-14 21:39:27 +00:00
|
|
|
|
2014-01-15 22:07:58 +00:00
|
|
|
#include "sftpplugin.h"
|
2014-01-14 21:39:27 +00:00
|
|
|
|
|
|
|
#include "ui_sftp_config.h"
|
|
|
|
|
|
|
|
K_PLUGIN_FACTORY(SftpConfigFactory, registerPlugin<SftpConfig>();)
|
|
|
|
|
|
|
|
SftpConfig::SftpConfig(QWidget *parent, const QVariantList& )
|
2014-06-16 19:02:07 +01:00
|
|
|
: KCModule(KAboutData::pluginData("kdeconnect_sftp_config"), parent)
|
2014-01-15 22:07:58 +00:00
|
|
|
, m_ui(new Ui::SftpConfigUi())
|
|
|
|
, m_cfg(SftpConfig::config())
|
2014-01-14 21:39:27 +00:00
|
|
|
{
|
2014-01-15 22:07:58 +00:00
|
|
|
m_ui->setupUi(this);
|
2014-01-14 21:39:27 +00:00
|
|
|
|
2014-01-15 22:07:58 +00:00
|
|
|
m_ui->refresh->setIcon(KIconLoader::global()->loadIcon("view-refresh", KIconLoader::Dialog));
|
|
|
|
m_ui->pixmap->setPixmap(KIconLoader::global()->loadIcon("dialog-error", KIconLoader::Dialog));
|
2014-09-22 00:26:08 +01:00
|
|
|
|
2014-01-15 22:07:58 +00:00
|
|
|
connect(m_ui->refresh, SIGNAL(clicked(bool)), this, SLOT(checkSshfs()));
|
2014-09-22 00:26:08 +01:00
|
|
|
|
2014-01-15 22:07:58 +00:00
|
|
|
connect(m_ui->idle, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
|
|
|
connect(m_ui->timeout, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
2014-01-14 21:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SftpConfig::~SftpConfig()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-15 22:07:58 +00:00
|
|
|
void SftpConfig::checkSshfs()
|
2014-01-14 21:39:27 +00:00
|
|
|
{
|
2014-09-22 00:24:42 +01:00
|
|
|
m_ui->error->setVisible(QStandardPaths::findExecutable(QStringLiteral("sshfs")).isEmpty());
|
2014-01-14 21:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SftpConfig::defaults()
|
|
|
|
{
|
|
|
|
KCModule::defaults();
|
2014-09-22 00:26:08 +01:00
|
|
|
|
2014-01-15 22:07:58 +00:00
|
|
|
checkSshfs();
|
|
|
|
m_ui->idle->setChecked(m_cfg->group("main").readEntry("idle", true));
|
|
|
|
m_ui->timeout->setValue(m_cfg->group("main").readEntry("idletimeout", 10));
|
2014-09-22 00:26:08 +01:00
|
|
|
|
2014-01-15 22:07:58 +00:00
|
|
|
Q_EMIT changed(true);
|
2014-01-14 21:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SftpConfig::load()
|
|
|
|
{
|
|
|
|
KCModule::load();
|
2014-09-22 00:26:08 +01:00
|
|
|
|
2014-01-15 22:07:58 +00:00
|
|
|
checkSshfs();
|
|
|
|
m_ui->idle->setChecked(m_cfg->group("main").readEntry("idle", true));
|
|
|
|
m_ui->timeout->setValue(m_cfg->group("main").readEntry("idletimeout", 10));
|
2014-09-22 00:26:08 +01:00
|
|
|
|
|
|
|
Q_EMIT changed(false);
|
2014-01-14 21:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SftpConfig::save()
|
|
|
|
{
|
2014-01-15 22:07:58 +00:00
|
|
|
checkSshfs();
|
|
|
|
m_cfg->group("main").writeEntry("idle", m_ui->idle->isChecked());
|
|
|
|
m_cfg->group("main").writeEntry("idletimeout", m_ui->timeout->value());
|
2014-06-07 17:27:08 +01:00
|
|
|
|
2014-01-14 21:39:27 +00:00
|
|
|
KCModule::save();
|
2014-01-15 22:07:58 +00:00
|
|
|
Q_EMIT changed(false);
|
2014-01-14 21:39:27 +00:00
|
|
|
}
|
|
|
|
|
2014-06-16 19:02:07 +01:00
|
|
|
#include "sftp_config.moc"
|