- added ocInfo check on startup to prevent folder syncing without

valid ownCloud connection
- fixed folder remove
This commit is contained in:
Klaas Freitag 2012-03-29 09:41:30 +02:00
parent 3d114f5b91
commit d938c531c8
4 changed files with 70 additions and 14 deletions

View file

@ -29,6 +29,7 @@
#include "mirall/owncloudfolder.h"
#include "mirall/statusdialog.h"
#include "mirall/owncloudsetupwizard.h"
#include "mirall/owncloudinfo.h"
#include "mirall/theme.h"
#include "mirall/mirallconfigfile.h"
@ -44,8 +45,10 @@ namespace Mirall {
Application::Application(int argc, char **argv) :
QApplication(argc, argv),
_tray(0),
_networkMgr(new QNetworkConfigurationManager(this)),
_contextMenu(0)
_contextMenu(0),
_ocInfo(0)
{
#ifdef OWNCLOUD_CLIENT
_theme = new ownCloudTheme();
@ -107,17 +110,11 @@ Application::Application(int argc, char **argv) :
//qDebug() << "Network:" << netCfg.identifier();
}
/* setup the folder list */
int cnt = _folderMan->setupFolders();
setupActions();
setupSystemTray();
if( cnt ) {
_tray->setIcon(_theme->folderIcon("owncloud", 24));
}
QTimer::singleShot( 5000, this, SLOT(slotHideSplash()) );
QTimer::singleShot( 0, this, SLOT( slotStartFolderSetup() ));
qDebug() << "Network Location: " << NetworkLocation::currentLocation().encoded();
}
@ -129,6 +126,44 @@ Application::~Application()
delete _networkMgr;
delete _folderMan;
delete _tray;
delete _ocInfo;
}
void Application::slotStartFolderSetup()
{
_ocInfo = new ownCloudInfo( QString(), this );
if( _ocInfo->isConfigured() ) {
connect( _ocInfo,SIGNAL(ownCloudInfoFound(QString,QString)),
SLOT(slotOwnCloudFound(QString,QString)));
connect( _ocInfo,SIGNAL(noOwncloudFound(QNetworkReply::NetworkError)),
SLOT(slotNoOwnCloudFound(QNetworkReply::NetworkError)));
_ocInfo->checkInstallation();
} else {
slotNoOwnCloudFound( QNetworkReply::UnknownNetworkError );
}
}
void Application::slotOwnCloudFound( const QString& url , const QString& version )
{
qDebug() << "** Application: ownCloud found: " << url << " with version " << version;
int cnt = _folderMan->setupFolders();
if( cnt ) {
_tray->setIcon(_theme->folderIcon("owncloud", 24));
_tray->show();
if( _tray )
_tray->showMessage(tr("ownCloud Sync Started"), tr("Sync started for %1 configured sync folder(s).").arg(cnt));
}
setupContextMenu();
}
void Application::slotNoOwnCloudFound( QNetworkReply::NetworkError err )
{
qDebug() << "** Application: NO ownCloud found!";
QMessageBox::warning(0, tr("No ownCloud Connection"),
tr("There is no ownCloud connection available. Please configure one by clicking on the tray icon!"));
}
void Application::slotHideSplash()
@ -156,14 +191,14 @@ void Application::setupSystemTray()
connect(_tray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
SLOT(slotTrayClicked(QSystemTrayIcon::ActivationReason)));
setupContextMenu();
// setupContextMenu();
_tray->show();
}
void Application::setupContextMenu()
{
delete _contextMenu;
if( _contextMenu ) delete _contextMenu;
_contextMenu = new QMenu();
_contextMenu->setTitle(_theme->appName() );
_contextMenu->addAction(_actionConfigure);
@ -285,7 +320,7 @@ void Application::slotRemoveFolder( const QString& alias )
}
_folderMan->slotRemoveFolder( alias );
_statusDialog->slotRemoveSelectedFolder( );
}
#ifdef HAVE_FETCH_AND_PUSH

View file

@ -17,6 +17,7 @@
#include <QApplication>
#include <QSystemTrayIcon>
#include <QNetworkReply>
#include "mirall/syncresult.h"
#include "mirall/folder.h"
@ -29,6 +30,7 @@ class QSystemTrayIcon;
class QNetworkConfigurationManager;
class QSignalMapper;
class QSplashScreen;
class QNetworkReply;
namespace Mirall {
class Theme;
@ -36,6 +38,7 @@ class FolderWatcher;
class FolderWizard;
class StatusDialog;
class OwncloudSetupWizard;
class ownCloudInfo;
class Application : public QApplication
{
@ -72,6 +75,9 @@ protected slots:
void slotFolderOpenAction(const QString & );
void slotHideSplash();
void slotStartFolderSetup();
void slotOwnCloudFound( const QString&, const QString& );
void slotNoOwnCloudFound( QNetworkReply::NetworkError );
private:
// configuration file -> folder
QSystemTrayIcon *_tray;
@ -92,6 +98,7 @@ private:
Theme *_theme;
QSignalMapper *_folderOpenActionMapper;
QSplashScreen *_splash;
ownCloudInfo *_ocInfo;
};
} // namespace Mirall

View file

@ -179,8 +179,6 @@ StatusDialog::StatusDialog( Theme *theme, QWidget *parent) :
_folderList->setMinimumWidth( 300 );
_folderList->setEditTriggers( QAbstractItemView::NoEditTriggers );
connect( _folderList,SIGNAL(doubleClicked(QModelIndex)),SLOT(slotDoubleClicked(QModelIndex)));
connect(_ButtonClose, SIGNAL(clicked()), this, SLOT(accept()));
connect(_ButtonRemove, SIGNAL(clicked()), this, SLOT(slotRemoveFolder()));
#ifdef HAVE_FETCH_AND_PUSH
@ -201,7 +199,14 @@ StatusDialog::StatusDialog( Theme *theme, QWidget *parent) :
_ButtonInfo->setEnabled(false);
_ButtonAdd->setEnabled(true);
#ifdef Q_WS_X11
connect(_folderList, SIGNAL(activated(QModelIndex)), SLOT(slotFolderActivated(QModelIndex)));
connect( _folderList,SIGNAL(doubleClicked(QModelIndex)),SLOT(slotDoubleClicked(QModelIndex)));
#endif
#ifdef Q_WS_WIN
connect(_folderList, SIGNAL(clicked(QModelIndex)), SLOT(slotFolderActivated(QModelIndex)));
connect( _folderList,SIGNAL(doubleClicked(QModelIndex)),SLOT(slotDoubleClicked(QModelIndex)));
#endif
}
void StatusDialog::slotFolderActivated( const QModelIndex& indx )
@ -308,11 +313,19 @@ void StatusDialog::slotRemoveFolder()
if( !alias.isEmpty() ) {
// remove from file system through folder man
emit(removeFolderAlias( alias ));
_model->removeRow( selected.row() );
// _model->removeRow( selected.row() );
}
}
}
void StatusDialog::slotRemoveSelectedFolder()
{
QModelIndex selected = _folderList->selectionModel()->currentIndex();
if( selected.isValid() ) {
_model->removeRow( selected.row() );
}
}
void StatusDialog::slotFetchFolder()
{
QModelIndex selected = _folderList->selectionModel()->currentIndex();

View file

@ -81,6 +81,7 @@ signals:
public slots:
void slotRemoveFolder();
void slotRemoveSelectedFolder();
void slotFetchFolder();
void slotPushFolder();
void slotFolderActivated( const QModelIndex& );