2013-07-04 21:59:40 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
|
|
|
|
*
|
|
|
|
* 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; version 2 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "generalsettings.h"
|
|
|
|
#include "ui_generalsettings.h"
|
|
|
|
|
|
|
|
#include "mirall/theme.h"
|
|
|
|
#include "mirall/mirallconfigfile.h"
|
|
|
|
#include "mirall/application.h"
|
2013-07-05 02:25:19 +04:00
|
|
|
#include "mirall/utility.h"
|
2013-07-05 03:01:23 +04:00
|
|
|
#include "mirall/mirallconfigfile.h"
|
2013-07-04 21:59:40 +04:00
|
|
|
|
|
|
|
#include <QNetworkProxy>
|
2013-08-14 18:35:36 +04:00
|
|
|
#include <QDir>
|
2013-07-04 21:59:40 +04:00
|
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
|
|
|
GeneralSettings::GeneralSettings(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
_ui(new Ui::GeneralSettings)
|
|
|
|
{
|
|
|
|
_ui->setupUi(this);
|
|
|
|
|
2013-07-05 03:01:23 +04:00
|
|
|
connect(_ui->desktopNotificationsCheckBox, SIGNAL(toggled(bool)),
|
|
|
|
SLOT(slotToggleOptionalDesktopNotifications(bool)));
|
|
|
|
|
2013-07-07 00:38:33 +04:00
|
|
|
_ui->autostartCheckBox->setChecked(Utility::hasLaunchOnStartup(Theme::instance()->appName()));
|
2013-07-05 02:25:19 +04:00
|
|
|
connect(_ui->autostartCheckBox, SIGNAL(toggled(bool)), SLOT(slotToggleLaunchOnStartup(bool)));
|
2013-07-04 21:59:40 +04:00
|
|
|
|
|
|
|
// setup about section
|
|
|
|
QString about = Theme::instance()->about();
|
|
|
|
if (about.isEmpty()) {
|
|
|
|
_ui->aboutGroupBox->hide();
|
|
|
|
} else {
|
|
|
|
_ui->aboutLabel->setText(about);
|
|
|
|
_ui->aboutLabel->setOpenExternalLinks(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
loadMiscSettings();
|
|
|
|
|
|
|
|
// misc
|
|
|
|
connect(_ui->monoIconsCheckBox, SIGNAL(toggled(bool)), SLOT(saveMiscSettings()));
|
2013-08-14 18:35:36 +04:00
|
|
|
|
|
|
|
// OEM themes are not obliged to ship mono icons, so there
|
|
|
|
// is no point in offering an option
|
2013-08-31 16:13:25 +04:00
|
|
|
QString themeDir = QString::fromLatin1(":/mirall/theme/%1/")
|
2013-08-14 18:35:36 +04:00
|
|
|
.arg(Theme::instance()->systrayIconFlavor(true));
|
2013-08-31 16:13:25 +04:00
|
|
|
_ui->monoIconsCheckBox->setVisible(QDir(themeDir).exists());
|
2013-08-14 18:35:36 +04:00
|
|
|
|
2013-07-04 21:59:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GeneralSettings::~GeneralSettings()
|
|
|
|
{
|
|
|
|
delete _ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralSettings::loadMiscSettings()
|
|
|
|
{
|
|
|
|
MirallConfigFile cfgFile;
|
|
|
|
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
|
2013-07-24 21:53:05 +04:00
|
|
|
_ui->desktopNotificationsCheckBox->setChecked(cfgFile.optionalDesktopNotifications());
|
2013-07-04 21:59:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeneralSettings::saveMiscSettings()
|
|
|
|
{
|
|
|
|
MirallConfigFile cfgFile;
|
|
|
|
bool isChecked = _ui->monoIconsCheckBox->isChecked();
|
|
|
|
cfgFile.setMonoIcons(isChecked);
|
|
|
|
Theme::instance()->setSystrayUseMonoIcons(isChecked);
|
|
|
|
}
|
|
|
|
|
2013-07-05 02:25:19 +04:00
|
|
|
void GeneralSettings::slotToggleLaunchOnStartup(bool enable)
|
|
|
|
{
|
2013-07-07 00:38:33 +04:00
|
|
|
Theme *theme = Theme::instance();
|
|
|
|
Utility::setLaunchOnStartup(theme->appName(), theme->appNameGUI(), enable);
|
2013-07-05 02:25:19 +04:00
|
|
|
}
|
|
|
|
|
2013-07-05 03:01:23 +04:00
|
|
|
void GeneralSettings::slotToggleOptionalDesktopNotifications(bool enable)
|
|
|
|
{
|
|
|
|
MirallConfigFile cfgFile;
|
|
|
|
cfgFile.setOptionalDesktopNotifications(enable);
|
|
|
|
}
|
|
|
|
|
2013-07-04 21:59:40 +04:00
|
|
|
} // namespace Mirall
|