ShareDialog: Some GUI rework requested by Jan.
authorKlaas Freitag <freitag@owncloud.com>
Thu, 26 Mar 2015 15:51:31 +0000 (16:51 +0100)
committerKlaas Freitag <freitag@owncloud.com>
Tue, 7 Apr 2015 11:38:01 +0000 (13:38 +0200)
src/gui/sharedialog.cpp
src/gui/sharedialog.ui

index b57f36a446fc56d5cec2eaf26b469c9e77da7d94..bbcf05b1c2cc5c18e1e56513d09b0ee69f3ccfd1 100644 (file)
@@ -84,24 +84,20 @@ ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QSt
     QIcon icon = icon_provider.icon(f_info);
     _ui->label_icon->setPixmap(icon.pixmap(40,40));
 
-    QString name;
-    if( f_info.isDir() ) {
-        name = tr("Share Directory");
-    } else {
-        name = tr("Share File");
-    }
-    _ui->groupBox->setTitle(name);
-
-    QString lPath(_localPath);
-    if( lPath.length() > 50) {
-        lPath = QLatin1String("...")+lPath.right(50);
-    }
-    _ui->label_name->setText(tr("Local path: %1").arg(lPath));
+    QFileInfo lPath(_localPath);
+    QString fileName = lPath.fileName();
+    _ui->label_name->setText(tr("%1").arg(fileName));
+    QFont f( _ui->label_name->font());
+    f.setPointSize( f.pointSize() * 1.4 );
+    _ui->label_name->setFont( f );
 
     _ui->label_sharePath->setWordWrap(true);
-    _ui->label_sharePath->setText(tr("%1 path: %2").arg(Theme::instance()->appNameGUI()).arg(_sharePath));
+    QString ocDir(_sharePath);
+    ocDir.truncate(ocDir.length()-fileName.length());
+
+    _ui->label_sharePath->setText(tr("%1 path: %2").arg(Theme::instance()->appNameGUI()).arg(ocDir));
     this->setWindowTitle(tr("%1 Sharing").arg(Theme::instance()->appNameGUI()));
-    _ui->label_password->setText(tr("Set p&assword"));
+    _ui->checkBox_password->setText(tr("Set p&assword"));
     // check if the file is already inside of a synced folder
     if( sharePath.isEmpty() ) {
         // The file is not yet in an ownCloud synced folder. We could automatically
@@ -336,7 +332,12 @@ void ShareDialog::setShareLink( const QString& url )
     // FIXME: shorten the url for output.
     const QUrl realUrl(url);
     if( realUrl.isValid() ) {
-        const QString u = QString("<a href=\"%1\">%2</a>").arg(realUrl.toString(QUrl::None)).arg(url);
+        QFontMetrics fm( _ui->_labelShareLink->font() );
+        int linkLengthPixel = _ui->_labelShareLink->width();
+
+        QString elidedUrl = fm.elidedText(url, Qt::ElideRight, linkLengthPixel);
+
+        const QString u = QString("<a href=\"%1\">%2</a>").arg(realUrl.toString(QUrl::None)).arg(elidedUrl);
         _ui->_labelShareLink->setText(u);
         _shareUrl = url;
         _ui->pushButton_copy->setEnabled(true);
@@ -407,7 +408,7 @@ void ShareDialog::slotCreateShareFetched(const QString &reply)
         // there needs to be a password
         _ui->checkBox_password->setChecked(true);
         _ui->checkBox_password->setVisible(false);
-        _ui->label_password->setText(tr("Public sh&aring requires a password:"));
+        _ui->checkBox_password->setText(tr("Public sh&aring requires a password:"));
         _ui->lineEdit_password->setFocus();
         _ui->widget_shareLink->show();
 
index c3194b0e2ce236714263b3d7f91bce3af66efd54..820bb97f6af1e88e0fc0e17e68c7a1f038e6c99d 100644 (file)
@@ -6,20 +6,65 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>403</width>
-    <height>296</height>
+    <width>372</width>
+    <height>241</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Share NewDocument.odt</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout_4">
-   <item row="4" column="0">
-    <widget class="QLabel" name="errorLabel">
-     <property name="text">
-      <string>TextLabel</string>
-     </property>
-    </widget>
+  <layout class="QGridLayout" name="gridLayout_3">
+   <item row="0" column="0" colspan="2">
+    <layout class="QGridLayout" name="gridLayout">
+     <item row="0" column="0" rowspan="2">
+      <widget class="QLabel" name="label_icon">
+       <property name="text">
+        <string>TextLabel</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1">
+      <widget class="QLabel" name="label_name">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="font">
+        <font>
+         <weight>75</weight>
+         <bold>true</bold>
+        </font>
+       </property>
+       <property name="text">
+        <string>share label</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="2" rowspan="2">
+      <widget class="QProgressIndicator" name="pi_share" native="true"/>
+     </item>
+     <item row="1" column="1">
+      <widget class="QLabel" name="label_sharePath">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="font">
+        <font>
+         <weight>50</weight>
+         <bold>false</bold>
+        </font>
+       </property>
+       <property name="text">
+        <string>ownCloud Path:</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
    </item>
    <item row="1" column="0">
     <layout class="QHBoxLayout" name="horizontalLayout_shareLink">
    </item>
    <item row="2" column="0" colspan="2">
     <widget class="QWidget" name="widget_shareLink" native="true">
-     <layout class="QGridLayout" name="gridLayout_3">
+     <layout class="QGridLayout" name="gridLayout_2">
+      <property name="leftMargin">
+       <number>20</number>
+      </property>
       <property name="topMargin">
-       <number>0</number>
+       <number>1</number>
       </property>
       <item row="0" column="0">
        <layout class="QHBoxLayout" name="horizontalLayout_3">
         <item>
          <widget class="QCheckBox" name="checkBox_password">
           <property name="sizePolicy">
-           <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+           <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
             <horstretch>0</horstretch>
             <verstretch>0</verstretch>
            </sizepolicy>
           </property>
           <property name="text">
-           <string/>
+           <string>Set password</string>
           </property>
          </widget>
         </item>
         <item>
-         <widget class="QLabel" name="label_password">
-          <property name="text">
-           <string>Set p&amp;assword</string>
+         <spacer name="horizontalSpacer_3">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
           </property>
-          <property name="buddy">
-           <cstring>checkBox_password</cstring>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
           </property>
-         </widget>
+         </spacer>
         </item>
        </layout>
       </item>
       <item row="2" column="0">
-       <layout class="QHBoxLayout" name="horizontalLayout_14">
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <property name="leftMargin">
+         <number>20</number>
+        </property>
         <item>
          <widget class="QLineEdit" name="lineEdit_password">
           <property name="echoMode">
         </item>
         <item>
          <widget class="QPushButton" name="pushButton_setPassword">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
           <property name="text">
            <string>Set &amp;Password</string>
           </property>
        </layout>
       </item>
       <item row="3" column="0">
-       <layout class="QHBoxLayout" name="horizontalLayout">
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
         <item>
          <widget class="QCheckBox" name="checkBox_expire">
           <property name="text">
      </layout>
     </widget>
    </item>
-   <item row="5" column="0">
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Close</set>
-     </property>
-    </widget>
-   </item>
-   <item row="0" column="0" colspan="2">
-    <widget class="QGroupBox" name="groupBox">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="title">
-      <string>Share Info</string>
-     </property>
-     <layout class="QGridLayout" name="gridLayout_2">
-      <item row="0" column="0">
-       <layout class="QGridLayout" name="gridLayout">
-        <item row="0" column="0" rowspan="2">
-         <widget class="QLabel" name="label_icon">
-          <property name="text">
-           <string>TextLabel</string>
-          </property>
-         </widget>
-        </item>
-        <item row="0" column="1">
-         <widget class="QLabel" name="label_name">
-          <property name="sizePolicy">
-           <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
-            <horstretch>0</horstretch>
-            <verstretch>0</verstretch>
-           </sizepolicy>
-          </property>
-          <property name="font">
-           <font>
-            <weight>75</weight>
-            <bold>true</bold>
-           </font>
-          </property>
-          <property name="text">
-           <string>share label</string>
-          </property>
-         </widget>
-        </item>
-        <item row="0" column="2" rowspan="2">
-         <widget class="QProgressIndicator" name="pi_share" native="true"/>
-        </item>
-        <item row="1" column="1">
-         <widget class="QLabel" name="label_sharePath">
-          <property name="sizePolicy">
-           <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
-            <horstretch>0</horstretch>
-            <verstretch>0</verstretch>
-           </sizepolicy>
-          </property>
-          <property name="font">
-           <font>
-            <weight>50</weight>
-            <bold>false</bold>
-           </font>
-          </property>
-          <property name="text">
-           <string>ownCloud Path:</string>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
-     </layout>
-    </widget>
-   </item>
    <item row="3" column="1">
     <spacer name="verticalSpacer">
      <property name="orientation">
      </property>
     </spacer>
    </item>
+   <item row="4" column="0">
+    <widget class="QLabel" name="errorLabel">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="text">
+      <string>TextLabel</string>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="0" colspan="2">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Close</set>
+     </property>
+    </widget>
+   </item>
   </layout>
+  <zorder>errorLabel</zorder>
+  <zorder>widget_shareLink</zorder>
+  <zorder>buttonBox</zorder>
+  <zorder>checkBox_password</zorder>
+  <zorder>layoutWidget</zorder>
+  <zorder>verticalSpacer</zorder>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>