Commit 865cedb0 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use astyle-kdelibs

parent a387836f
......@@ -18,7 +18,6 @@
*/
#include "kdepim-version.h"
#include "sieveeditormainwindow.h"
#include <kaboutdata.h>
......@@ -29,22 +28,22 @@
#include <QCommandLineParser>
#include "pimcommon/util/kdelibs4configmigrater.h"
int main( int argc, char **argv )
int main(int argc, char **argv)
{
PimCommon::Kdelibs4ConfigMigrater migrate(QLatin1String("sieveeditor"));
migrate.setConfigFiles(QStringList()<<QLatin1String("sieveeditorrc"));
migrate.setUiFiles(QStringList()<<QLatin1String("sieveeditorui.rc"));
migrate.setConfigFiles(QStringList() << QLatin1String("sieveeditorrc"));
migrate.setUiFiles(QStringList() << QLatin1String("sieveeditorui.rc"));
migrate.migrate();
KLocalizedString::setApplicationDomain("sieveeditor");
QApplication app(argc, argv);
KAboutData aboutData(QStringLiteral("sieveeditor"),
i18n("KSieve Editor"),
QStringLiteral(KDEPIM_VERSION),
i18n("Sieve Editor"),
KAboutLicense::GPL_V2,
i18n("Copyright © 2013, 2014 sieveeditor authors"));
i18n("KSieve Editor"),
QStringLiteral(KDEPIM_VERSION),
i18n("Sieve Editor"),
KAboutLicense::GPL_V2,
i18n("Copyright © 2013, 2014 sieveeditor authors"));
aboutData.addAuthor(i18n("Laurent Montel"), i18n("Maintainer"), QLatin1String("montel@kde.org"));
aboutData.setProgramIconName(QLatin1String("kmail"));
......@@ -57,10 +56,8 @@ int main( int argc, char **argv )
parser.process(app);
aboutData.processCommandLine(&parser);
KDBusService service(KDBusService::Unique);
SieveEditorMainWindow *mw = new SieveEditorMainWindow();
mw->show();
return app.exec();
......
......@@ -50,8 +50,8 @@ void ServerSieveListWidget::readConfig()
void ServerSieveListWidget::writeConfig()
{
QList<SieveEditorUtil::SieveServerConfig> lstServerConfig;
for (int i=0; i <count(); ++i) {
ServerSieveListWidgetItem *serverSieveItem = static_cast<ServerSieveListWidgetItem*>(item(i));
for (int i = 0; i < count(); ++i) {
ServerSieveListWidgetItem *serverSieveItem = static_cast<ServerSieveListWidgetItem *>(item(i));
if (serverSieveItem) {
lstServerConfig.append(serverSieveItem->serverConfig());
}
......@@ -59,12 +59,12 @@ void ServerSieveListWidget::writeConfig()
SieveEditorUtil::writeServerSieveConfig(lstServerConfig);
}
void ServerSieveListWidget::modifyServerConfig()
{
QListWidgetItem *item = currentItem();
if (!item)
if (!item) {
return;
}
ServerSieveListWidgetItem *serverSieveListItem = static_cast<ServerSieveListWidgetItem *>(item);
......
......@@ -27,7 +27,7 @@
class ServerSieveListWidgetItem : public QListWidgetItem
{
public:
ServerSieveListWidgetItem(QListWidget *parent=0);
ServerSieveListWidgetItem(QListWidget *parent = 0);
~ServerSieveListWidgetItem();
SieveEditorUtil::SieveServerConfig serverConfig() const;
......@@ -41,7 +41,7 @@ class ServerSieveListWidget : public QListWidget
{
Q_OBJECT
public:
explicit ServerSieveListWidget(QWidget *parent=0);
explicit ServerSieveListWidget(QWidget *parent = 0);
~ServerSieveListWidget();
void readConfig();
......
......@@ -26,9 +26,9 @@
#include <QDebug>
/** static helper functions **/
static QString authenticationModeString( MailTransport::Transport::EnumAuthenticationType::type mode )
static QString authenticationModeString(MailTransport::Transport::EnumAuthenticationType::type mode)
{
switch ( mode ) {
switch (mode) {
case MailTransport::Transport::EnumAuthenticationType::LOGIN:
return QLatin1String("LOGIN");
case MailTransport::Transport::EnumAuthenticationType::PLAIN:
......@@ -42,40 +42,40 @@ static QString authenticationModeString( MailTransport::Transport::EnumAuthentic
case MailTransport::Transport::EnumAuthenticationType::NTLM:
return QLatin1String("NTLM");
case MailTransport::Transport::EnumAuthenticationType::CLEAR:
return i18nc( "Authentication method", "Clear text" );
return i18nc("Authentication method", "Clear text");
case MailTransport::Transport::EnumAuthenticationType::ANONYMOUS:
return i18nc( "Authentication method", "Anonymous" );
return i18nc("Authentication method", "Anonymous");
default:
break;
}
return QString();
}
static void addAuthenticationItem( QComboBox* authCombo, MailTransport::Transport::EnumAuthenticationType::type authtype )
static void addAuthenticationItem(QComboBox *authCombo, MailTransport::Transport::EnumAuthenticationType::type authtype)
{
//qDebug() << "adding auth item " << authenticationModeString( authtype );
authCombo->addItem( authenticationModeString( authtype ), QVariant( authtype ) );
authCombo->addItem(authenticationModeString(authtype), QVariant(authtype));
}
static MailTransport::Transport::EnumAuthenticationType::type getCurrentAuthMode( QComboBox* authCombo )
static MailTransport::Transport::EnumAuthenticationType::type getCurrentAuthMode(QComboBox *authCombo)
{
MailTransport::Transport::EnumAuthenticationType::type authtype = (MailTransport::Transport::EnumAuthenticationType::type) authCombo->itemData( authCombo->currentIndex() ).toInt();
MailTransport::Transport::EnumAuthenticationType::type authtype = (MailTransport::Transport::EnumAuthenticationType::type) authCombo->itemData(authCombo->currentIndex()).toInt();
//qDebug() << "current auth mode: " << authenticationModeString( authtype );
return authtype;
}
static void setCurrentAuthMode( QComboBox* authCombo, MailTransport::Transport::EnumAuthenticationType::type authtype )
static void setCurrentAuthMode(QComboBox *authCombo, MailTransport::Transport::EnumAuthenticationType::type authtype)
{
//qDebug() << "setting authcombo: " << authenticationModeString( authtype );
int index = authCombo->findData( authtype );
if ( index == -1 )
int index = authCombo->findData(authtype);
if (index == -1) {
qWarning() << "desired authmode not in the combo";
}
//qDebug() << "found corresponding index: " << index << "with data" << authenticationModeString( (MailTransport::Transport::EnumAuthenticationType::type) authCombo->itemData( index ).toInt() );
authCombo->setCurrentIndex( index );
MailTransport::Transport::EnumAuthenticationType::type t = (MailTransport::Transport::EnumAuthenticationType::type) authCombo->itemData( authCombo->currentIndex() ).toInt();
authCombo->setCurrentIndex(index);
MailTransport::Transport::EnumAuthenticationType::type t = (MailTransport::Transport::EnumAuthenticationType::type) authCombo->itemData(authCombo->currentIndex()).toInt();
//qDebug() << "selected auth mode:" << authenticationModeString( t );
Q_ASSERT( t == authtype );
Q_ASSERT(t == authtype);
}
ServerSieveSettings::ServerSieveSettings(QWidget *parent) :
......@@ -96,14 +96,14 @@ ServerSieveSettings::~ServerSieveSettings()
void ServerSieveSettings::populateDefaultAuthenticationOptions()
{
ui->authenticationCombo->clear();
addAuthenticationItem( ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::CLEAR);
addAuthenticationItem( ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::LOGIN );
addAuthenticationItem( ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::PLAIN );
addAuthenticationItem( ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::CRAM_MD5 );
addAuthenticationItem( ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::DIGEST_MD5 );
addAuthenticationItem( ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::NTLM );
addAuthenticationItem( ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::GSSAPI );
addAuthenticationItem( ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::ANONYMOUS );
addAuthenticationItem(ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::CLEAR);
addAuthenticationItem(ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::LOGIN);
addAuthenticationItem(ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::PLAIN);
addAuthenticationItem(ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::CRAM_MD5);
addAuthenticationItem(ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::DIGEST_MD5);
addAuthenticationItem(ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::NTLM);
addAuthenticationItem(ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::GSSAPI);
addAuthenticationItem(ui->authenticationCombo, MailTransport::Transport::EnumAuthenticationType::ANONYMOUS);
}
void ServerSieveSettings::slotUserServerNameChanged()
......@@ -157,7 +157,7 @@ void ServerSieveSettings::setServerSieveConfig(const SieveEditorUtil::SieveServe
setPort(conf.port);
setServerName(conf.serverName);
setUserName(conf.userName);
setCurrentAuthMode( ui->authenticationCombo, conf.authenticationType );
setCurrentAuthMode(ui->authenticationCombo, conf.authenticationType);
}
SieveEditorUtil::SieveServerConfig ServerSieveSettings::serverSieveConfig() const
......@@ -167,7 +167,7 @@ SieveEditorUtil::SieveServerConfig ServerSieveSettings::serverSieveConfig() cons
conf.port = port();
conf.serverName = serverName();
conf.userName = userName();
const MailTransport::Transport::EnumAuthenticationType::type authtype = getCurrentAuthMode( ui->authenticationCombo );
const MailTransport::Transport::EnumAuthenticationType::type authtype = getCurrentAuthMode(ui->authenticationCombo);
conf.authenticationType = authtype;
return conf;
}
......@@ -24,7 +24,8 @@
#include <QWidget>
#include "sieveeditorutil.h"
namespace Ui {
namespace Ui
{
class ServerSieveSettings;
}
......
......@@ -30,7 +30,7 @@
ServerSieveSettingsDialog::ServerSieveSettingsDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle( i18n( "Add Server Sieve" ) );
setWindowTitle(i18n("Add Server Sieve"));
QWidget *w = new QWidget;
QVBoxLayout *lay = new QVBoxLayout;
......@@ -42,8 +42,8 @@ ServerSieveSettingsDialog::ServerSieveSettingsDialog(QWidget *parent)
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mainLayout->addWidget(w);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
mOkButton = buttonBox->button(QDialogButtonBox::Ok);
mOkButton->setDefault(true);
mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
......@@ -51,7 +51,7 @@ ServerSieveSettingsDialog::ServerSieveSettingsDialog(QWidget *parent)
connect(buttonBox, &QDialogButtonBox::rejected, this, &ServerSieveSettingsDialog::reject);
mainLayout->addWidget(buttonBox);
resize(400,300);
resize(400, 300);
mOkButton->setEnabled(false);
}
......@@ -62,7 +62,7 @@ ServerSieveSettingsDialog::~ServerSieveSettingsDialog()
void ServerSieveSettingsDialog::slotEnableButtonOk(bool b)
{
mOkButton->setEnabled(b);
mOkButton->setEnabled(b);
}
QString ServerSieveSettingsDialog::serverName() const
......
......@@ -29,7 +29,7 @@ class ServerSieveSettingsDialog : public QDialog
{
Q_OBJECT
public:
explicit ServerSieveSettingsDialog(QWidget *parent=0);
explicit ServerSieveSettingsDialog(QWidget *parent = 0);
~ServerSieveSettingsDialog();
QString serverName() const;
......
......@@ -15,7 +15,6 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "sieveeditorcentralwidget.h"
#include "sieveeditormainwidget.h"
#include "sieveeditorconfigureserverpage.h"
......@@ -39,10 +38,11 @@ SieveEditorCentralWidget::~SieveEditorCentralWidget()
void SieveEditorCentralWidget::slotServerSieveFound(bool hasServer)
{
if (hasServer)
if (hasServer) {
setCurrentWidget(mSieveEditorMainWidget);
else
} else {
setCurrentWidget(mConfigureWidget);
}
}
SieveEditorMainWidget *SieveEditorCentralWidget::sieveEditorMainWidget() const
......
......@@ -15,7 +15,6 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SIEVEEDITORCENTRALWIDGET_H
#define SIEVEEDITORCENTRALWIDGET_H
......@@ -26,7 +25,7 @@ class SieveEditorCentralWidget : public QStackedWidget
{
Q_OBJECT
public:
explicit SieveEditorCentralWidget(QWidget *parent=0);
explicit SieveEditorCentralWidget(QWidget *parent = 0);
~SieveEditorCentralWidget();
SieveEditorMainWidget *sieveEditorMainWidget() const;
......
......@@ -27,7 +27,6 @@
#include <KLocalizedString>
#include <KSharedConfig>
#include <QTabWidget>
#include <QVBoxLayout>
#include <QCheckBox>
......@@ -38,8 +37,8 @@
SieveEditorConfigureDialog::SieveEditorConfigureDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle( i18n( "Configure" ) );
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
setWindowTitle(i18n("Configure"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
......@@ -88,16 +87,16 @@ void SieveEditorConfigureDialog::saveServerSieveConfig()
void SieveEditorConfigureDialog::readConfig()
{
KConfigGroup group( KSharedConfig::openConfig(), "SieveEditorConfigureDialog" );
const QSize size = group.readEntry( "Size", QSize(600, 400) );
if ( size.isValid() ) {
resize( size );
KConfigGroup group(KSharedConfig::openConfig(), "SieveEditorConfigureDialog");
const QSize size = group.readEntry("Size", QSize(600, 400));
if (size.isValid()) {
resize(size);
}
}
void SieveEditorConfigureDialog::writeConfig()
{
KConfigGroup group( KSharedConfig::openConfig(), "SieveEditorConfigureDialog" );
group.writeEntry( "Size", size() );
KConfigGroup group(KSharedConfig::openConfig(), "SieveEditorConfigureDialog");
group.writeEntry("Size", size());
group.sync();
}
......@@ -30,7 +30,7 @@ class SieveEditorConfigureDialog : public QDialog
{
Q_OBJECT
public:
explicit SieveEditorConfigureDialog(QWidget *parent=0);
explicit SieveEditorConfigureDialog(QWidget *parent = 0);
~SieveEditorConfigureDialog();
void saveServerSieveConfig();
......
......@@ -33,7 +33,6 @@ SieveEditorConfigureServerPage::SieveEditorConfigureServerPage(QWidget *parent)
setLayout(hbox);
}
SieveEditorConfigureServerPage::~SieveEditorConfigureServerPage()
{
......
......@@ -24,7 +24,7 @@ class SieveEditorConfigureServerPage : public QWidget
{
Q_OBJECT
public:
explicit SieveEditorConfigureServerPage(QWidget *parent=0);
explicit SieveEditorConfigureServerPage(QWidget *parent = 0);
~SieveEditorConfigureServerPage();
Q_SIGNALS:
......
......@@ -25,7 +25,6 @@
#include <KLocalizedString>
#include <KMessageBox>
SieveEditorConfigureServerWidget::SieveEditorConfigureServerWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::SieveEditorConfigureServerWidget)
......@@ -66,8 +65,9 @@ void SieveEditorConfigureServerWidget::slotAddServer()
void SieveEditorConfigureServerWidget::slotDeleteServer()
{
QListWidgetItem *item = ui->serverSieveListWidget->currentItem();
if (!item)
if (!item) {
return;
}
if (KMessageBox::Yes == KMessageBox::questionYesNo(this, i18n("Do you want to remove this server \'%1\'?", item->text()), i18n("Remove Server Sieve"))) {
delete item;
slotItemSelectionChanged();
......
......@@ -23,7 +23,8 @@
#include <QWidget>
namespace Ui {
namespace Ui
{
class SieveEditorConfigureServerWidget;
}
......
......@@ -32,7 +32,6 @@
#include <KColorScheme>
#include <KMessageBox>
#include <QSplitter>
#include <QTabBar>
......@@ -44,8 +43,8 @@ SieveEditorMainWidget::SieveEditorMainWidget(QWidget *parent)
connect(mTabWidget, &SieveEditorTabWidget::tabRemoveAllExclude, this, &SieveEditorMainWidget::slotTabRemoveAllExclude);
addWidget(mTabWidget);
mScriptManagerWidget = new SieveEditorScriptManagerWidget;
connect(mScriptManagerWidget, SIGNAL(createScriptPage(QUrl,QStringList,bool)), this, SLOT(slotCreateScriptPage(QUrl,QStringList,bool)));
connect(mScriptManagerWidget, SIGNAL(updateButtons(bool,bool,bool,bool)), SIGNAL(updateButtons(bool,bool,bool,bool)));
connect(mScriptManagerWidget, SIGNAL(createScriptPage(QUrl, QStringList, bool)), this, SLOT(slotCreateScriptPage(QUrl, QStringList, bool)));
connect(mScriptManagerWidget, SIGNAL(updateButtons(bool, bool, bool, bool)), SIGNAL(updateButtons(bool, bool, bool, bool)));
connect(mScriptManagerWidget, &SieveEditorScriptManagerWidget::scriptDeleted, this, &SieveEditorMainWidget::slotScriptDeleted);
connect(mScriptManagerWidget, SIGNAL(serverSieveFound(bool)), this, SIGNAL(serverSieveFound(bool)));
connect(this, &SieveEditorMainWidget::updateScriptList, mScriptManagerWidget, &SieveEditorScriptManagerWidget::slotRefreshList);
......@@ -53,21 +52,21 @@ SieveEditorMainWidget::SieveEditorMainWidget(QWidget *parent)
setChildrenCollapsible(false);
QList<int> splitterSizes;
splitterSizes << 80 << 20;
KConfigGroup myGroup( KSharedConfig::openConfig(), "SieveEditorMainWidget" );
setSizes(myGroup.readEntry( "mainSplitter", splitterSizes));
KConfigGroup myGroup(KSharedConfig::openConfig(), "SieveEditorMainWidget");
setSizes(myGroup.readEntry("mainSplitter", splitterSizes));
connect(KGlobalSettings::self(), &KGlobalSettings::kdisplayPaletteChanged, this, &SieveEditorMainWidget::slotGeneralPaletteChanged);
}
SieveEditorMainWidget::~SieveEditorMainWidget()
{
KConfigGroup myGroup( KSharedConfig::openConfig(), "SieveEditorMainWidget" );
myGroup.writeEntry( "mainSplitter", sizes());
KConfigGroup myGroup(KSharedConfig::openConfig(), "SieveEditorMainWidget");
myGroup.writeEntry("mainSplitter", sizes());
myGroup.sync();
}
QWidget *SieveEditorMainWidget::hasExistingPage(const QUrl &url)
{
for (int i=0; i < mTabWidget->count(); ++i) {
for (int i = 0; i < mTabWidget->count(); ++i) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(mTabWidget->widget(i));
if (page) {
if (page->currentUrl() == url) {
......@@ -95,14 +94,15 @@ void SieveEditorMainWidget::slotCreateScriptPage(const QUrl &url, const QStringL
} else {
SieveEditorPageWidget *editor = new SieveEditorPageWidget;
connect(editor, SIGNAL(refreshList()), this, SIGNAL(updateScriptList()));
connect(editor, SIGNAL(scriptModified(bool,SieveEditorPageWidget*)), this, SLOT(slotScriptModified(bool,SieveEditorPageWidget*)));
connect(editor, SIGNAL(scriptModified(bool, SieveEditorPageWidget *)), this, SLOT(slotScriptModified(bool, SieveEditorPageWidget *)));
connect(editor, SIGNAL(modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode)), SIGNAL(modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode)));
editor->setIsNewScript(isNewScript);
editor->loadScript(url, capabilities);
mTabWidget->addTab(editor, url.fileName());
mTabWidget->setCurrentWidget(editor);
if (isNewScript)
if (isNewScript) {
editor->saveScript(false, true);
}
}
}
......@@ -150,12 +150,13 @@ void SieveEditorMainWidget::saveScript()
bool SieveEditorMainWidget::needToSaveScript()
{
bool scriptSaved = false;
for (int i=0; i < mTabWidget->count(); ++i) {
for (int i = 0; i < mTabWidget->count(); ++i) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(mTabWidget->widget(i));
if (page) {
const bool result = page->needToSaveScript();
if (result)
if (result) {
scriptSaved = true;
}
}
}
return scriptSaved;
......@@ -177,7 +178,7 @@ void SieveEditorMainWidget::slotGoToLine()
}
}
void SieveEditorMainWidget::slotScriptModified(bool modified,SieveEditorPageWidget *page)
void SieveEditorMainWidget::slotScriptModified(bool modified, SieveEditorPageWidget *page)
{
const int index = mTabWidget->indexOf(page);
if (index >= 0) {
......@@ -194,8 +195,8 @@ void SieveEditorMainWidget::slotGeneralPaletteChanged()
mScriptColor = pal.text().color();
mModifiedScriptColor = pal.text().color();
const KColorScheme scheme( QPalette::Active, KColorScheme::View );
mModifiedScriptColor = scheme.foreground( KColorScheme::NegativeText ).color();
const KColorScheme scheme(QPalette::Active, KColorScheme::View);
mModifiedScriptColor = scheme.foreground(KColorScheme::NegativeText).color();
}
void SieveEditorMainWidget::slotTabCloseRequested(int index)
......@@ -217,7 +218,7 @@ void SieveEditorMainWidget::slotTabCloseRequested(int index)
void SieveEditorMainWidget::slotTabRemoveAllExclude(int index)
{
for(int i = mTabWidget->count()-1; i >=0; --i) {
for (int i = mTabWidget->count() - 1; i >= 0; --i) {
if (i == index) {
continue;
}
......
......@@ -32,7 +32,7 @@ class SieveEditorMainWidget : public QSplitter
{
Q_OBJECT
public:
explicit SieveEditorMainWidget(QWidget *parent=0);
explicit SieveEditorMainWidget(QWidget *parent = 0);
~SieveEditorMainWidget();
void createNewScript();
......
......@@ -43,17 +43,17 @@
SieveEditorMainWindow::SieveEditorMainWindow()
: KXmlGuiWindow(),
mNetworkIsDown(false)
{
{
mMainWidget = new SieveEditorCentralWidget;
connect(mMainWidget, &SieveEditorCentralWidget::configureClicked, this, &SieveEditorMainWindow::slotConfigure);
connect(mMainWidget->sieveEditorMainWidget(), SIGNAL(updateButtons(bool,bool,bool,bool)), this, SLOT(slotUpdateButtons(bool,bool,bool,bool)));
connect(mMainWidget->sieveEditorMainWidget(), SIGNAL(updateButtons(bool, bool, bool, bool)), this, SLOT(slotUpdateButtons(bool, bool, bool, bool)));
setCentralWidget(mMainWidget);
setupActions();
setupGUI();
readConfig();
initStatusBar();
connect( Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)),
this, SLOT(slotSystemNetworkStatusChanged(Solid::Networking::Status)) );
connect(Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)),
this, SLOT(slotSystemNetworkStatusChanged(Solid::Networking::Status)));
connect(mMainWidget->sieveEditorMainWidget()->tabWidget(), SIGNAL(currentChanged(int)), SLOT(slotUpdateActions()));
connect(mMainWidget->sieveEditorMainWidget(), SIGNAL(modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode)), SLOT(slotUpdateActions()));
const Solid::Networking::Status status = Solid::Networking::status();
......@@ -65,10 +65,11 @@ SieveEditorMainWindow::~SieveEditorMainWindow()
{
KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup group = config->group( QLatin1String("SieveEditorMainWindow") );
group.writeEntry( "Size", size() );
if (SieveEditorGlobalConfig::self()->closeWallet())
KConfigGroup group = config->group(QLatin1String("SieveEditorMainWindow"));
group.writeEntry("Size", size());
if (SieveEditorGlobalConfig::self()->closeWallet()) {
SieveServerSettings::self()->closeWallet();
}
}
void SieveEditorMainWindow::initStatusBar()
......@@ -79,7 +80,7 @@ void SieveEditorMainWindow::initStatusBar()
void SieveEditorMainWindow::slotSystemNetworkStatusChanged(Solid::Networking::Status status)
{
if ( status == Solid::Networking::Connected || status == Solid::Networking::Unknown) {
if (status == Solid::Networking::Connected || status == Solid::Networking::Unknown) {
mNetworkIsDown = false;
mStatusBarInfo->setText(i18n("Network is Up."));
} else {
......@@ -101,20 +102,20 @@ void SieveEditorMainWindow::slotUpdateButtons(bool newScriptAction, bool editScr
void SieveEditorMainWindow::readConfig()
{
KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup group = KConfigGroup( config, "SieveEditorMainWindow" );
const QSize sizeDialog = group.readEntry( "Size", QSize(800,600) );
if ( sizeDialog.isValid() ) {
resize( sizeDialog );
KConfigGroup group = KConfigGroup(config, "SieveEditorMainWindow");
const QSize sizeDialog = group.readEntry("Size", QSize(800, 600));
if (sizeDialog.isValid()) {
resize(sizeDialog);
}
}
void SieveEditorMainWindow::setupActions()
{
KActionCollection* ac=actionCollection();
KActionCollection *ac = actionCollection();
KStandardAction::quit(this, SLOT(close()), ac );
KStandardAction::preferences( this, SLOT(slotConfigure()), ac );
mSaveScript = KStandardAction::save( this, SLOT(slotSaveScript()), ac );
KStandardAction::quit(this, SLOT(close()), ac);
KStandardAction::preferences(this, SLOT(slotConfigure()), ac);
mSaveScript = KStandardAction::save(this, SLOT(slotSaveScript()), ac);
mSaveScript->setEnabled(false);
QAction *act = ac->addAction(QLatin1String("add_server_sieve"), this, SLOT(slotAddServerSieve()));
......@@ -122,11 +123,11 @@ void SieveEditorMainWindow::setupActions()
mDeleteScript = ac->addAction(QLatin1String("delete_script"), this, SLOT(slotDeleteScript()));
mDeleteScript->setText(i18n("Delete Script"));
ac->setDefaultShortcut(mDeleteScript, QKeySequence( Qt::Key_Delete ));
ac->setDefaultShortcut(mDeleteScript, QKeySequence(Qt::Key_Delete));
mDeleteScript->setEnabled(false);
mNewScript = ac->addAction(QLatin1String("create_new_script"), this, SLOT(slotCreateNewScript()));
ac->setDefaultShortcut(mNewScript,QKeySequence( Qt::CTRL + Qt::Key_N ));
ac->setDefaultShortcut(mNewScript, QKeySequence(Qt::CTRL + Qt::Key_N));
mNewScript->setText(i18n("Create New Script..."));
mNewScript->setEnabled(false);
......@@ -141,19 +142,20 @@ void SieveEditorMainWindow::setupActions()
mRefreshList = ac->addAction(QLatin1String("refresh_list"), this, SLOT(slotRefreshList()));