Commit 1306400d authored by Laurent Montel's avatar Laurent Montel 😁

Add storage service to blogilo

parent a26aaadb
......@@ -33,6 +33,7 @@ set(blogilo_SRCS
composer/bilbobrowser.cpp
composer/blogilocomposerwidget.cpp
storageservice/storageservicemanagersettingsjob.cpp
configurestorageservicewidget.cpp
)
......
<?xml version="1.0"?>
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="blogilo" version="10">
<kpartgui name="blogilo" version="11">
<MenuBar>
<Menu name="blog"><text>Blog</text>
<Action name="add_blog" />
......@@ -11,6 +11,10 @@
<Action name="save_locally" />
<Action name="publish_post" />
</Menu>
<Menu name="storageservice"><text>Import Export File</text>
<Action name="upload_file" />
<Action name="download_file" />
</Menu>
<Menu name="settings"><text>Settings</text>
<Action name="toggle_toolbox" />
</Menu>
......
......@@ -21,6 +21,8 @@
#include "ui_settingsbase.h"
#include "ui_editorsettingsbase.h"
#include "configurestorageservicewidget.h"
#include "settings.h"
#include "blogsettings.h"
......@@ -53,10 +55,15 @@ ConfigureDialog::ConfigureDialog(QWidget *parent, const QString& name, KConfigSk
Ui::AdvancedSettingsBase ui_advancedsettings_base;
ui_advancedsettings_base.setupUi( advancedSettingsDlg );
mConfigStorageService = new ConfigureStorageServiceWidget;
mConfigStorageService->setAttribute( Qt::WA_DeleteOnClose );
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"));
addPage( mConfigStorageService, i18nc( "Configure Page", "Storage Service" ), QLatin1String("applications-utilities"));
connect( this, SIGNAL(settingsChanged(QString)), this, SIGNAL(settingsChanged()) );
connect( this, SIGNAL(destroyed(QObject*)), this, SIGNAL(dialogDestroyed(QObject*)));
setAttribute( Qt::WA_DeleteOnClose );
......
......@@ -20,7 +20,7 @@
#include <KConfigDialog>
#include "bilboblog.h"
class ConfigureStorageServiceWidget;
class ConfigureDialog : public KConfigDialog
{
Q_OBJECT
......@@ -34,6 +34,9 @@ Q_SIGNALS:
void blogEdited(const BilboBlog &);
void dialogDestroyed(QObject*);
void settingsChanged();
private:
ConfigureStorageServiceWidget *mConfigStorageService;
};
#endif // CONFIGUREDIALOG_H
/*
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 "configurestorageservicewidget.h"
#include "pimcommon/storageservice/settings/storageservicesettingswidget.h"
#include <KLocalizedString>
#include <KStandardDirs>
#include <KMessageBox>
#include <QVBoxLayout>
#include <QProcess>
#include <QPushButton>
ConfigureStorageServiceWidget::ConfigureStorageServiceWidget(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *lay = new QVBoxLayout;
mStorageServiceWidget = new PimCommon::StorageServiceSettingsWidget;
connect(mStorageServiceWidget, SIGNAL(changed()), this, SIGNAL(changed()));
lay->addWidget(mStorageServiceWidget);
QHBoxLayout *hbox = new QHBoxLayout;
mManageStorageService = new QPushButton(i18n("Manage Storage Service"));
hbox->addWidget(mManageStorageService);
hbox->addStretch();
lay->addLayout(hbox);
if (KStandardDirs::findExe(QLatin1String("storageservicemanager")).isEmpty()) {
mManageStorageService->setEnabled(false);
} else {
connect(mManageStorageService, SIGNAL(clicked(bool)), this, SLOT(slotManageStorageService()));
}
setLayout(lay);
}
ConfigureStorageServiceWidget::~ConfigureStorageServiceWidget()
{
}
void ConfigureStorageServiceWidget::slotManageStorageService()
{
if ( !QProcess::startDetached(QLatin1String("storageservicemanager") ) )
KMessageBox::error( this, i18n( "Could not start storage service manager; "
"please check your installation." ),
i18n( "KMail Error" ) );
}
void ConfigureStorageServiceWidget::save()
{
//storageServiceManager()->setListService(mStorageServiceWidget->listService());
}
void ConfigureStorageServiceWidget::doLoadFromGlobalSettings()
{
//mStorageServiceWidget->setListService(KMKernel::self()->storageServiceManager()->listService(), PimCommon::StorageServiceAbstract::ShareLinkCapability);
}
#include "moc_configurestorageservicewidget.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
*/
#ifndef CONFIGURESTORAGESERVICEWIDGET_H
#define CONFIGURESTORAGESERVICEWIDGET_H
#include <QWidget>
class QPushButton;
namespace PimCommon {
class StorageServiceSettingsWidget;
}
class ConfigureStorageServiceWidget : public QWidget
{
Q_OBJECT
public:
explicit ConfigureStorageServiceWidget(QWidget *parent=0);
~ConfigureStorageServiceWidget();
void save();
void doLoadFromGlobalSettings();
Q_SIGNALS:
void changed();
private slots:
void slotManageStorageService();
private:
PimCommon::StorageServiceSettingsWidget *mStorageServiceWidget;
QPushButton *mManageStorageService;
};
#endif // CONFIGURESTORAGESERVICEWIDGET_H
......@@ -52,10 +52,11 @@
#include <kstatusbar.h>
#include <KToggleAction>
#include <kactioncollection.h>
#include <KActionMenu>
#include <kconfigdialog.h>
#include <kdebug.h>
#include <kmessagebox.h>
#include <KDE/KLocale>
#include <KLocale>
#include <KSelectAction>
#include <kimagefilepreview.h>
#include <KToolInvocation>
......@@ -78,6 +79,7 @@ MainWindow::MainWindow()
mCurrentBlogId(__currentBlogId)
{
setWindowTitle( i18n("Blogilo") );
initStorageService();
tabPosts = new PostsTabWidget(this);
setCentralWidget( tabPosts );
......@@ -130,7 +132,6 @@ MainWindow::MainWindow()
}
connect( blogs, SIGNAL(triggered(QAction*)), this, SLOT(currentBlogChanged(QAction*)) );
QTimer::singleShot( 0, this, SLOT(loadTempPosts()) );
initStorageService();
}
MainWindow::~MainWindow()
......@@ -144,6 +145,22 @@ void MainWindow::initStorageService()
configJob->registerConfigIf(settingsJob);
mStorageManager = new PimCommon::StorageServiceManager(this);
connect(mStorageManager, SIGNAL(uploadFileDone(QString,QString)), this, SLOT(slotUploadFileDone(QString,QString)));
connect(mStorageManager, SIGNAL(shareLinkDone(QString,QString)), this, SLOT(slotUploadFileDone(QString,QString)));
connect(mStorageManager, SIGNAL(uploadFileFailed(QString,QString)), this, SLOT(slotUploadFileFailed(QString,QString)));
}
void MainWindow::slotUploadFileDone(const QString &serviceName, const QString &link)
{
Q_UNUSED(serviceName);
KMessageBox::information(this, i18n("File uploaded. You can access to it at this url %1", link), i18n("Upload File"));
}
void MainWindow::slotUploadFileFailed(const QString &serviceName, const QString &filename)
{
Q_UNUSED(serviceName);
Q_UNUSED(filename);
KMessageBox::error(this, i18n("Error during upload."), i18n("Upload File"));
}
void MainWindow::slotCloseTabClicked()
......@@ -214,6 +231,9 @@ void MainWindow::setupActions()
actionCollection()->addAction( QLatin1String("open_blog_in_browser"), actOpenBlog);
actOpenBlog->setToolTip(i18n("Open current blog in browser"));
connect( actOpenBlog, SIGNAL(triggered(bool)), this, SLOT(slotOpenCurrentBlogInBrowser()) );
actionCollection()->addAction( QLatin1String("upload_file"), mStorageManager->menuUploadServices(this) );
actionCollection()->addAction( QLatin1String("download_file"), mStorageManager->menuDownloadServices(this) );
}
void MainWindow::loadTempPosts()
......
......@@ -107,6 +107,9 @@ private slots:
void slotCloseTabClicked();
void slotRemoveAllExclude(int);
void slotUploadFileDone(const QString &serviceName, const QString &filename);
void slotUploadFileFailed(const QString &serviceName, const QString &filename);
protected:
void keyPressEvent( QKeyEvent * event );
virtual bool queryExit();
......
......@@ -117,6 +117,7 @@ void StorageServiceDownloadDialog::slotDownloadFile()
}
const QString fileId = mStorage->fileIdentifier(mTreeWidget->itemInformationSelected());
mTreeWidget->setEnabled(false);
enableButton(User1, false);
mStorage->downloadFile(filename, fileId, destination);
}
}
......@@ -127,6 +128,7 @@ void StorageServiceDownloadDialog::slotDownfileDone(const QString &serviceName,
Q_UNUSED(filename);
KMessageBox::information(this, i18n("File was correctly downloaded."), i18n("Download file"));
mTreeWidget->setEnabled(true);
enableButton(User1, true);
}
void StorageServiceDownloadDialog::slotDownfileFailed(const QString &serviceName, const QString &filename)
......@@ -135,6 +137,7 @@ void StorageServiceDownloadDialog::slotDownfileFailed(const QString &serviceName
Q_UNUSED(filename);
KMessageBox::information(this, i18n("Error during download file."), i18n("Download file"));
mTreeWidget->setEnabled(true);
enableButton(User1, true);
}
#include "moc_storageservicedownloaddialog.cpp"
......@@ -19,6 +19,8 @@
#include "settings/pimcommonsettings.h"
#include "storageservice/dialog/storageservicedownloaddialog.h"
#include "dropbox/dropboxstorageservice.h"
#include "hubic/hubicstorageservice.h"
#include "ubuntuone/ubuntuonestorageservice.h"
......@@ -102,8 +104,6 @@ KActionMenu *StorageServiceManager::menuWithCapability(PimCommon::StorageService
act->setIcon(icon);
switch(capability) {
case PimCommon::StorageServiceAbstract::NoCapability:
case PimCommon::StorageServiceAbstract::UploadFileCapability:
case PimCommon::StorageServiceAbstract::DownloadFileCapability:
case PimCommon::StorageServiceAbstract::CreateFolderCapability:
case PimCommon::StorageServiceAbstract::DeleteFolderCapability:
case PimCommon::StorageServiceAbstract::ListFolderCapability:
......@@ -115,13 +115,24 @@ KActionMenu *StorageServiceManager::menuWithCapability(PimCommon::StorageService
case PimCommon::StorageServiceAbstract::CopyFolderCapability:
qDebug()<<" not implemented ";
break;
case PimCommon::StorageServiceAbstract::DownloadFileCapability:
menuService->setText(i18n("Download File..."));
connect(act, SIGNAL(triggered()), this, SLOT(slotDownloadFile()));
break;
case PimCommon::StorageServiceAbstract::UploadFileCapability:
menuService->setText(i18n("Upload File..."));
connect(act, SIGNAL(triggered()), this, SLOT(slotShareFile()));
break;
case PimCommon::StorageServiceAbstract::ShareLinkCapability:
menuService->setText(i18n("Share File..."));
connect(act, SIGNAL(triggered()), this, SLOT(slotShareFile()));
break;
case PimCommon::StorageServiceAbstract::DeleteFileCapability:
menuService->setText(i18n("Delete File..."));
connect(act, SIGNAL(triggered()), this, SLOT(slotDeleteFile()));
break;
case PimCommon::StorageServiceAbstract::AccountInfoCapability:
menuService->setText(i18n("Account Info..."));
connect(act, SIGNAL(triggered()), this, SLOT(slotAccountInfo()));
break;
}
......@@ -157,6 +168,22 @@ void StorageServiceManager::slotShareFile()
}
}
void StorageServiceManager::slotDownloadFile()
{
QAction *act = qobject_cast< QAction* >( sender() );
if ( act ) {
const QString type = act->data().toString();
if (mListService.contains(type)) {
StorageServiceAbstract *service = mListService.value(type);
QPointer<PimCommon::StorageServiceDownloadDialog> dlg = new PimCommon::StorageServiceDownloadDialog(service, 0);
if (dlg->exec()) {
//TODO ?
}
delete dlg;
}
}
}
void StorageServiceManager::defaultConnect(StorageServiceAbstract *service)
{
connect(service,SIGNAL(actionFailed(QString,QString)), this, SIGNAL(actionFailed(QString,QString)), Qt::UniqueConnection);
......
......@@ -61,7 +61,7 @@ public:
static QString serviceToI18n(ServiceType type);
static QString serviceName(ServiceType type);
static QString description(ServiceType type);
static QUrl serviceUrl(ServiceType type);
static QUrl serviceUrl(ServiceType type);
static QString icon(ServiceType type);
static StorageServiceAbstract::Capabilities capabilities(ServiceType type);
static QString kconfigName();
......@@ -82,7 +82,7 @@ private Q_SLOTS:
void slotAccountInfo();
void slotShareFile();
void slotDeleteFile();
void slotDownloadFile();
private:
void defaultConnect(StorageServiceAbstract *service);
void readConfig();
......
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