Klaas Freitag 14 лет назад
Родитель
Сommit
95eadf2cb9

+ 15 - 1
src/mirall/application.cpp

@@ -97,8 +97,10 @@ QString Application::folderConfigPath() const
 
 void Application::setupActions()
 {
-    _actionAddFolder = new QAction(tr("Add folder"), this);
+    _actionAddFolder = new QAction(tr("Add folder..."), this);
     QObject::connect(_actionAddFolder, SIGNAL(triggered(bool)), SLOT(slotAddFolder()));
+    _actionConfigure = new QAction(tr("Configure..."), this);
+    QObject::connect(_actionConfigure, SIGNAL(triggered(bool)), SLOT(slotConfigure()));
     _actionQuit = new QAction(tr("Quit"), this);
     QObject::connect(_actionQuit, SIGNAL(triggered(bool)), SLOT(quit()));
 }
@@ -118,12 +120,16 @@ void Application::slotTrayClicked( QSystemTrayIcon::ActivationReason reason )
 {
   if( reason == QSystemTrayIcon::Trigger ) {
     // check if there is a mirall.cfg already.
+    if( _owncloudSetup->wizard()->isVisible() ) {
+      _owncloudSetup->wizard()->show();
+    }
     QFile fi( QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/mirall.cfg" );
     if( !fi.exists() ) {
       qDebug() << "No configured folders yet, start the Owncloud integration dialog.";
       _owncloudSetup->startWizard();
     } else {
       _statusDialog->setFolderList( _folderMap );
+
       _statusDialog->exec();
     }
   }
@@ -133,7 +139,10 @@ void Application::setupContextMenu()
 {
     delete _contextMenu;
     _contextMenu = new QMenu();
+    _contextMenu->setTitle(tr( "Mirall" ));
+    _contextMenu->addAction(_actionConfigure);
     _contextMenu->addAction(_actionAddFolder);
+    _contextMenu->addSeparator();
 
     // here all folders should be added
     foreach (Folder *folder, _folderMap) {
@@ -234,6 +243,11 @@ void Application::slotRemoveFolder( const QString& alias )
   }
 }
 
+void Application::slotConfigure()
+{
+  _owncloudSetup->startWizard();
+}
+
 void Application::setupKnownFolders()
 {
   qDebug() << "* Setup folders from " << folderConfigPath();

+ 3 - 0
src/mirall/application.h

@@ -46,6 +46,7 @@ protected slots:
     void slotReparseConfiguration();
     void slotAddFolder();
     void slotRemoveFolder( const QString& );
+    void slotConfigure();
 
     void slotFolderSyncStarted();
     void slotFolderSyncFinished(const SyncResult &);
@@ -75,6 +76,8 @@ private:
     QSystemTrayIcon *_tray;
     QAction *_actionQuit;
     QAction *_actionAddFolder;
+    QAction *_actionConfigure;
+
     QNetworkConfigurationManager *_networkMgr;
     QString _folderConfigPath;
 

+ 22 - 4
src/mirall/owncloudsetup.cpp

@@ -58,6 +58,9 @@ OwncloudSetup::OwncloudSetup( QObject *parent ) :
     connect( _ocWizard, SIGNAL(installOCLocalhost()),
              this, SLOT(slotCreateOCLocalhost()));
 
+    // in case of cancel, terminate the owncloud-admin script.
+    connect( _ocWizard, SIGNAL(rejected()), _process, SLOT(terminate()));
+
 }
 
 void OwncloudSetup::slotConnectToOCUrl( const QString& url )
@@ -73,6 +76,11 @@ bool OwncloudSetup::isBusy()
   return _process->state() > 0;
 }
 
+ OwncloudWizard *OwncloudSetup::wizard()
+ {
+   return _ocWizard;
+ }
+
 void OwncloudSetup::slotCreateOCLocalhost()
 {
   if( isBusy() ) {
@@ -125,8 +133,13 @@ void OwncloudSetup::slotInstallOCServer()
 void OwncloudSetup::runOwncloudAdmin( const QStringList& args )
 {
   const QString bin("/usr/bin/owncloud-admin");
-
+  qDebug() << "starting " << bin << " with args. " << args;
+  if( _process->state() != QProcess::NotRunning	) {
+    qDebug() << "Owncloud admin is still running, skip!";
+    return;
+  }
   if( checkOwncloudAdmin( bin )) {
+    _ocWizard->appendToResultWidget( tr("Starting script owncloud-admin...") );
     _process->start( bin, args );
   } else {
     slotFinished( 1, QProcess::NormalExit );
@@ -162,19 +175,24 @@ void OwncloudSetup::slotError( QProcess::ProcessError )
 void OwncloudSetup::slotStarted()
 {
   _ocWizard->button( QWizard::FinishButton )->setEnabled( false );
+  _ocWizard->button( QWizard::BackButton )->setEnabled( false );
+   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 }
 
 void OwncloudSetup::slotFinished( int res, QProcess::ExitStatus )
 {
   _ocWizard->button( QWizard::FinishButton )->setEnabled( true );
+  _ocWizard->button( QWizard::BackButton)->setEnabled( true );
+  QApplication::restoreOverrideCursor();
 
   if( res ) {
     _ocWizard->appendToResultWidget( tr("<font color=\"red\">Installation of ownCloud failed!</font>") );
-    emit ownCloudSetupFinished( true );
+    _ocWizard->showOCUrlLabel( false );
+    emit ownCloudSetupFinished( false );
   } else {
     // Successful installation. Write the config.
     _ocWizard->appendToResultWidget( tr("<font color=\"green\">Installation of ownCloud succeeded!</font>") );
-
+    _ocWizard->showOCUrlLabel( true );
     writeOwncloudConfig();
 
     emit ownCloudSetupFinished( true );
@@ -185,7 +203,7 @@ void OwncloudSetup::slotFinished( int res, QProcess::ExitStatus )
 void OwncloudSetup::startWizard()
 {
   _ocWizard->setOCUrl( ownCloudUrl() );
-  _ocWizard->exec();
+  _ocWizard->show();
 }
 
 QString OwncloudSetup::mirallConfigFile() const

+ 3 - 0
src/mirall/owncloudsetup.h

@@ -53,6 +53,9 @@ public:
   QString ownCloudPasswd() const ;
 
   void    setupLocalSyncFolder();
+
+  OwncloudWizard *wizard();
+
 signals:
   void    ownCloudSetupFinished( bool );
 

+ 24 - 5
src/mirall/owncloudwizard.cpp

@@ -201,6 +201,7 @@ OwncloudWizardResultPage::OwncloudWizardResultPage()
     _ui.setupUi(this);
     // no fields to register.
     _ui.resultTextEdit->setAcceptRichText(true);
+    _ui.ocLinkLabel->setVisible( false );
 }
 
 OwncloudWizardResultPage::~OwncloudWizardResultPage()
@@ -226,6 +227,18 @@ void OwncloudWizardResultPage::appendResultText( const QString& msg )
   }
 }
 
+void OwncloudWizardResultPage::showOCUrlLabel( const QString& url, bool show )
+{
+  _ui.ocLinkLabel->setText( tr("Congratulations! Your <a href=\"%1\">new ownCloud</a> is now up and running!").arg(url) );
+  _ui.ocLinkLabel->setOpenExternalLinks( true );
+
+  if( show ) {
+    _ui.ocLinkLabel->setVisible( true );
+  } else {
+    _ui.ocLinkLabel->setVisible( false );
+  }
+}
+
 // ======================================================================
 
 /**
@@ -262,13 +275,14 @@ void OwncloudWizard::slotCurrentPageChanged( int id )
     if( domain.startsWith( "https://" )) {
       domain = domain.right( domain.length()-8 );
     }
-    field("myOCUrl").setValue( domain );
+
     QString host = "ftp." +domain;
     OwncloudFTPAccessPage *p1 = static_cast<OwncloudFTPAccessPage*> (page( Page_FTP ));
     p1->setFTPUrl( host );
   }
   if( id == Page_Install ) {
     appendToResultWidget( QString() );
+    showOCUrlLabel( false );
     if( field("connectMyOC").toBool() ) {
       // check the url and connect.
       QString url = field("OCUrl").toString();
@@ -285,6 +299,12 @@ void OwncloudWizard::slotCurrentPageChanged( int id )
   }
 }
 
+void OwncloudWizard::showOCUrlLabel( bool show )
+{
+  OwncloudWizardResultPage *p = static_cast<OwncloudWizardResultPage*> (page( Page_Install ));
+  p->showOCUrlLabel( _oCUrl, show );
+}
+
 void OwncloudWizard::appendToResultWidget( const QString& msg )
 {
   OwncloudWizardResultPage *p = static_cast<OwncloudWizardResultPage*> (page( Page_Install ));
@@ -293,10 +313,9 @@ void OwncloudWizard::appendToResultWidget( const QString& msg )
 
 void OwncloudWizard::setOCUrl( const QString& url )
 {
-  if( !url.isEmpty() ) {
-    OwncloudWizardSelectTypePage *p = static_cast<OwncloudWizardSelectTypePage*>(page( Page_SelectType ));
-    p->setOCUrl( url );
-  }
+  _oCUrl = url;
+  OwncloudWizardSelectTypePage *p = static_cast<OwncloudWizardSelectTypePage*>(page( Page_SelectType ));
+  p->setOCUrl( url );
 }
 
 } // end namespace

+ 6 - 0
src/mirall/owncloudwizard.h

@@ -41,6 +41,8 @@ public:
   virtual void initializePage();
   int nextId() const;
   void setOCUrl( const QString& );
+  void showOCUrlLabel( const QString& );
+
 private:
   Ui_OwncloudWizardSelectTypePage _ui;
 
@@ -114,6 +116,7 @@ public:
 
 public slots:
   void appendResultText( const QString& );
+  void showOCUrlLabel( const QString&, bool );
 
 private:
   Ui_OwncloudWizardResultPage _ui;
@@ -145,6 +148,8 @@ public:
 public slots:
     void appendToResultWidget( const QString& );
     void slotCurrentPageChanged( int );
+    void showOCUrlLabel( bool );
+
 
 signals:
     void connectToOCUrl( const QString& );
@@ -153,6 +158,7 @@ signals:
 
 private:
     QString _configFile;
+    QString _oCUrl;
 };
 
 

+ 8 - 1
src/mirall/owncloudwizardresultpage.ui

@@ -26,7 +26,7 @@
         </font>
        </property>
        <property name="text">
-        <string>Result:</string>
+        <string>Result</string>
        </property>
       </widget>
      </item>
@@ -72,6 +72,13 @@ p, li { white-space: pre-wrap; }
      </property>
     </widget>
    </item>
+   <item row="3" column="0">
+    <widget class="QLabel" name="ocLinkLabel">
+     <property name="text">
+      <string>TextLabel</string>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <resources/>