Sfoglia il codice sorgente

Show a warning text in folder wizard

Klaas Freitag 14 anni fa
parent
commit
91b12c7eb3
2 ha cambiato i file con 122 aggiunte e 14 eliminazioni
  1. 36 14
      src/mirall/folderwizard.cpp
  2. 86 0
      src/mirall/folderwizardsourcepage.ui

+ 36 - 14
src/mirall/folderwizard.cpp

@@ -39,18 +39,25 @@ FolderWizardSourcePage::FolderWizardSourcePage()
     _ui.localFolderLineEdit->setText( QString( "%1/%2").arg( QDir::homePath() ).arg("ownCloud" ) );
     registerField("alias*", _ui.aliasLineEdit);
     _ui.aliasLineEdit->setText( QString::fromLatin1("ownCloud") );
+
+    _ui.warnLabel->hide();
 }
 
 FolderWizardSourcePage::~FolderWizardSourcePage()
 {
+
 }
 
 bool FolderWizardSourcePage::isComplete() const
 {
   QFileInfo selFile( _ui.localFolderLineEdit->text() );
+  QString warnString;
 
   bool isOk = selFile.isDir();
-
+  if( !isOk ) {
+    _ui.warnLabel->show();
+    _ui.warnLabel->setText(tr("HEHHHAH"));
+  }
   // check if the local directory isn't used yet in another ownCloud sync
   Folder::Map *map = _folderMap;
   if( ! map ) return false;
@@ -58,9 +65,11 @@ bool FolderWizardSourcePage::isComplete() const
   if( isOk ) {
     Folder::Map::const_iterator i = map->begin();
     while( isOk && i != map->constEnd() ) {
-      qDebug() << "Checking local path: " << i.key();
-      if( QFileInfo( i.key() ) == selFile ) {
+      Folder *f = static_cast<Folder*>(i.value());
+      qDebug() << "Checking local path: " << f->path() << " <-> " << selFile.absoluteFilePath();
+      if( QFileInfo( f->path() ) == selFile ) {
         isOk = false;
+        warnString = tr("The local path %1 is already a upload folder.<br/>Please pick another one!").arg(selFile.absoluteFilePath());
       }
       i++;
     }
@@ -68,19 +77,32 @@ bool FolderWizardSourcePage::isComplete() const
 
   // check if the alias is unique.
   QString alias = _ui.aliasLineEdit->text();
-  if( alias.isEmpty() ) isOk = false;
-  if( isOk ) {
-    Folder::Map::const_iterator i = map->begin();
-    while( isOk && i != map->constEnd() ) {
-      Folder *f = static_cast<Folder*>(i.value());
-      qDebug() << "Checking local alias: " << f->alias();
-      if( f ) {
-        if( f->alias() == alias ) {
-          isOk = false;
-        }
+  if( alias.isEmpty() ) {
+    warnString.append( tr("The alias can not be empty. Please provide a descriptive alias word.") );
+    isOk = false;
+  }
+
+  Folder::Map::const_iterator i = map->begin();
+  bool goon = true;
+  while( goon && i != map->constEnd() ) {
+    Folder *f = static_cast<Folder*>(i.value());
+    qDebug() << "Checking local alias: " << f->alias();
+    if( f ) {
+      if( f->alias() == alias ) {
+        warnString.append( tr("<br/>The alias %1 is already in use. Please change it to something different.").arg(alias) );
+        isOk = false;
+        goon = false;
       }
-      i++;
     }
+    i++;
+  }
+
+  if( isOk ) {
+    _ui.warnLabel->hide();
+    _ui.warnLabel->setText( QString() );
+  } else {
+    _ui.warnLabel->show();
+    _ui.warnLabel->setText( warnString );
   }
   return isOk;
 }

+ 86 - 0
src/mirall/folderwizardsourcepage.ui

@@ -72,6 +72,92 @@
     </widget>
    </item>
    <item row="2" column="0">
+    <widget class="QLabel" name="warnLabel">
+     <property name="palette">
+      <palette>
+       <active>
+        <colorrole role="Base">
+         <brush brushstyle="SolidPattern">
+          <color alpha="255">
+           <red>255</red>
+           <green>255</green>
+           <blue>255</blue>
+          </color>
+         </brush>
+        </colorrole>
+        <colorrole role="Window">
+         <brush brushstyle="SolidPattern">
+          <color alpha="255">
+           <red>255</red>
+           <green>255</green>
+           <blue>192</blue>
+          </color>
+         </brush>
+        </colorrole>
+       </active>
+       <inactive>
+        <colorrole role="Base">
+         <brush brushstyle="SolidPattern">
+          <color alpha="255">
+           <red>255</red>
+           <green>255</green>
+           <blue>255</blue>
+          </color>
+         </brush>
+        </colorrole>
+        <colorrole role="Window">
+         <brush brushstyle="SolidPattern">
+          <color alpha="255">
+           <red>255</red>
+           <green>255</green>
+           <blue>192</blue>
+          </color>
+         </brush>
+        </colorrole>
+       </inactive>
+       <disabled>
+        <colorrole role="Base">
+         <brush brushstyle="SolidPattern">
+          <color alpha="255">
+           <red>255</red>
+           <green>255</green>
+           <blue>192</blue>
+          </color>
+         </brush>
+        </colorrole>
+        <colorrole role="Window">
+         <brush brushstyle="SolidPattern">
+          <color alpha="255">
+           <red>255</red>
+           <green>255</green>
+           <blue>192</blue>
+          </color>
+         </brush>
+        </colorrole>
+       </disabled>
+      </palette>
+     </property>
+     <property name="autoFillBackground">
+      <bool>true</bool>
+     </property>
+     <property name="frameShape">
+      <enum>QFrame::StyledPanel</enum>
+     </property>
+     <property name="text">
+      <string>TextLabel</string>
+     </property>
+     <property name="textFormat">
+      <enum>Qt::AutoText</enum>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+     <property name="margin">
+      <number>3</number>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0">
     <spacer name="verticalSpacer">
      <property name="orientation">
       <enum>Qt::Vertical</enum>