Commit 61e8987e authored by Laurent Montel's avatar Laurent Montel 😁

Move settings in own class. Add storage service support

parent b6ba5691
......@@ -24,6 +24,7 @@ set(blogilo_SRCS
uploadmediadialog.cpp
syncuploader.cpp
poststabwidget.cpp
configuredialog.cpp
composer/htmleditor.cpp
composer/stylegetter.cpp
......@@ -31,6 +32,7 @@ set(blogilo_SRCS
composer/blogilocomposereditor.cpp
composer/bilbobrowser.cpp
composer/blogilocomposerwidget.cpp
storageservice/storageservicemanagersettingsjob.cpp
)
......
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "configuredialog.h"
ConfigureDialog::ConfigureDialog()
#include "ui_advancedsettingsbase.h"
#include "ui_settingsbase.h"
#include "ui_editorsettingsbase.h"
#include "settings.h"
#include "blogsettings.h"
#include <KLocalizedString>
ConfigureDialog::ConfigureDialog(QWidget *parent, const QString& name, KConfigSkeleton *config)
: KConfigDialog(parent, name, config)
{
QWidget *generalSettingsDlg = new QWidget;
generalSettingsDlg->setAttribute( Qt::WA_DeleteOnClose );
Ui::SettingsBase ui_prefs_base;
Ui::EditorSettingsBase ui_editorsettings_base;
ui_prefs_base.setupUi( generalSettingsDlg );
BlogSettings *blogSettingsDlg = new BlogSettings;
blogSettingsDlg->setAttribute( Qt::WA_DeleteOnClose );
connect( blogSettingsDlg, SIGNAL(blogAdded(BilboBlog)),
this, SIGNAL(blogAdded(BilboBlog)) );
connect( blogSettingsDlg, SIGNAL(blogEdited(BilboBlog)),
this, SIGNAL(blogEdited(BilboBlog)) );
connect( blogSettingsDlg, SIGNAL(blogRemoved(int)), this, SIGNAL(blogRemoved(int)) );
QWidget *editorSettingsDlg = new QWidget;
editorSettingsDlg->setAttribute( Qt::WA_DeleteOnClose );
ui_editorsettings_base.setupUi( editorSettingsDlg );
QWidget *advancedSettingsDlg = new QWidget;
advancedSettingsDlg->setAttribute( Qt::WA_DeleteOnClose );
Ui::AdvancedSettingsBase ui_advancedsettings_base;
ui_advancedsettings_base.setupUi( advancedSettingsDlg );
addPage( generalSettingsDlg, i18nc( "Configure Page", "General" ), QLatin1String("configure") );
addPage( blogSettingsDlg, i18nc( "Configure Page", "Blogs" ), QLatin1String("document-properties"));
addPage( editorSettingsDlg, i18nc( "Configure Page", "Editor" ), QLatin1String("accessories-text-editor"));
addPage( advancedSettingsDlg, i18nc( "Configure Page", "Advanced" ), QLatin1String("applications-utilities"));
connect( this, SIGNAL(settingsChanged(QString)), this, SIGNAL(settingsChanged()) );
connect( this, SIGNAL(destroyed(QObject*)), this, SIGNAL(dialogDestroyed(QObject*)));
setAttribute( Qt::WA_DeleteOnClose );
resize( Settings::configWindowSize() );
show();
}
ConfigureDialog::~ConfigureDialog()
{
}
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef CONFIGUREDIALOG_H
#define CONFIGUREDIALOG_H
class ConfigureDialog
#include <KConfigDialog>
#include "bilboblog.h"
class ConfigureDialog : public KConfigDialog
{
Q_OBJECT
public:
ConfigureDialog();
explicit ConfigureDialog( QWidget *parent, const QString& name, KConfigSkeleton *config );
~ConfigureDialog();
Q_SIGNALS:
void blogRemoved(int);
void blogAdded(const BilboBlog &);
void blogEdited(const BilboBlog &);
void dialogDestroyed(QObject*);
void settingsChanged();
};
#endif // CONFIGUREDIALOG_H
......@@ -36,11 +36,17 @@
#include "blogsettings.h"
#include "poststabwidget.h"
#include "uploadmediadialog.h"
#include "configuredialog.h"
#include "storageservice/storageservicemanagersettingsjob.h"
#include "ui_advancedsettingsbase.h"
#include "ui_settingsbase.h"
#include "ui_editorsettingsbase.h"
#include "pimcommon/storageservice/storageservicemanager.h"
#include "pimcommon/storageservice/storageservicejobconfig.h"
#include "pimcommon/storageservice/storageserviceabstract.h"
#include <ktabwidget.h>
#include <KStatusNotifierItem>
#include <kstatusbar.h>
......@@ -124,12 +130,22 @@ MainWindow::MainWindow()
}
connect( blogs, SIGNAL(triggered(QAction*)), this, SLOT(currentBlogChanged(QAction*)) );
QTimer::singleShot( 0, this, SLOT(loadTempPosts()) );
initStorageService();
}
MainWindow::~MainWindow()
{
}
void MainWindow::initStorageService()
{
StorageServiceManagerSettingsJob *settingsJob = new StorageServiceManagerSettingsJob(this);
PimCommon::StorageServiceJobConfig *configJob = PimCommon::StorageServiceJobConfig::self();
configJob->registerConfigIf(settingsJob);
mStorageManager = new PimCommon::StorageServiceManager(this);
}
void MainWindow::slotCloseTabClicked()
{
const int currentIndex = tabPosts->currentIndex();
......@@ -287,36 +303,15 @@ void MainWindow::optionsPreferences()
if ( KConfigDialog::showDialog( QLatin1String("settings") ) ) {
return;
}
KConfigDialog *dialog = new KConfigDialog( this, QLatin1String("settings"), Settings::self() );
QWidget *generalSettingsDlg = new QWidget;
generalSettingsDlg->setAttribute( Qt::WA_DeleteOnClose );
Ui::SettingsBase ui_prefs_base;
Ui::EditorSettingsBase ui_editorsettings_base;
ui_prefs_base.setupUi( generalSettingsDlg );
BlogSettings *blogSettingsDlg = new BlogSettings;
blogSettingsDlg->setAttribute( Qt::WA_DeleteOnClose );
connect( blogSettingsDlg, SIGNAL(blogAdded(BilboBlog)),
ConfigureDialog *dialog = new ConfigureDialog( this, QLatin1String("settings"), Settings::self() );
connect( dialog, SIGNAL(blogAdded(BilboBlog)),
this, SLOT(slotBlogAdded(BilboBlog)) );
connect( blogSettingsDlg, SIGNAL(blogEdited(BilboBlog)),
connect( dialog, SIGNAL(blogEdited(BilboBlog)),
this, SLOT(slotBlogEdited(BilboBlog)) );
connect( blogSettingsDlg, SIGNAL(blogRemoved(int)), this, SLOT(slotBlogRemoved(int)) );
QWidget *editorSettingsDlg = new QWidget;
editorSettingsDlg->setAttribute( Qt::WA_DeleteOnClose );
ui_editorsettings_base.setupUi( editorSettingsDlg );
QWidget *advancedSettingsDlg = new QWidget;
advancedSettingsDlg->setAttribute( Qt::WA_DeleteOnClose );
Ui::AdvancedSettingsBase ui_advancedsettings_base;
ui_advancedsettings_base.setupUi( advancedSettingsDlg );
dialog->addPage( generalSettingsDlg, i18nc( "Configure Page", "General" ), QLatin1String("configure") );
dialog->addPage( blogSettingsDlg, i18nc( "Configure Page", "Blogs" ), QLatin1String("document-properties"));
dialog->addPage( editorSettingsDlg, i18nc( "Configure Page", "Editor" ), QLatin1String("accessories-text-editor"));
dialog->addPage( advancedSettingsDlg, i18nc( "Configure Page", "Advanced" ), QLatin1String("applications-utilities"));
connect( dialog, SIGNAL(blogRemoved(int)), this, SLOT(slotBlogRemoved(int)) );
connect( dialog, SIGNAL(settingsChanged(QString)), this, SIGNAL(settingsChanged()) );
connect( dialog, SIGNAL(settingsChanged(QString)), this, SLOT(slotSettingsChanged()) );
connect( dialog, SIGNAL(destroyed(QObject*)), this, SLOT(slotDialogDestroyed(QObject*)));
dialog->setAttribute( Qt::WA_DeleteOnClose );
dialog->resize( Settings::configWindowSize() );
connect( dialog, SIGNAL(dialogDestroyed(QObject*)), this, SLOT(slotDialogDestroyed(QObject*)));
dialog->show();
}
......
......@@ -46,6 +46,11 @@ Main window of blogilo...
@author Mehrdad Momeny <mehrdad.momeny@gmail.com>
@author Golnaz Nilieh <g382nilieh@gmail.com>
*/
namespace PimCommon {
class StorageServiceManager;
}
class MainWindow : public KXmlGuiWindow
{
Q_OBJECT
......@@ -111,6 +116,7 @@ private:
void setupActions();
void setupSystemTray();
void writeConfigs();
void initStorageService();
/**
Create a new post entry,
and return pointer to it's widget (Actually return value is a PostEntry instance)
......@@ -132,5 +138,6 @@ private:
int &mCurrentBlogId;
QToolButton *mCloseTabButton;
QToolButton *mNewTabButton;
PimCommon::StorageServiceManager *mStorageManager;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment