#include <QFileDialog>
#include <QUrl>
#include <QTimer>
+#include <QStorageInfo>
#include "QProgressIndicator.h"
_ui.resolutionWidget->setVisible(false);
}
+ QString lfreeSpaceStr = Utility::octetsToString(availableLocalSpace());
+ _ui.lFreeSpace->setText(QString(tr("Free space: %1")).arg(lfreeSpaceStr));
+
_ui.syncModeLabel->setText(t);
_ui.syncModeLabel->setFixedHeight(_ui.syncModeLabel->sizeHint().height());
wizard()->resize(wizard()->sizeHint());
+
+ qint64 rSpace = _ui.rSyncEverything->isChecked() ? _rSize : _rSelectedSize;
+
+ QString spaceError = checkLocalSpace(rSpace);
+ if (!spaceError.isEmpty()) {
+ errorStr = spaceError;
+ }
setErrorString(errorStr);
+
emit completeChanged();
}
wizard()->setProperty("localFolder", dir);
updateStatus();
}
+
+ qint64 rSpace = _ui.rSyncEverything->isChecked() ? _rSize : _rSelectedSize;
+ QString errorStr = checkLocalSpace(rSpace);
+ setErrorString(errorStr);
}
void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()
auto s = dlg->estimatedSize();
if (s > 0) {
_ui.lSelectiveSyncSizeLabel->setText(tr("(%1)").arg(Utility::octetsToString(s)));
+
+ _rSelectedSize = s;
+ QString errorStr = checkLocalSpace(_rSelectedSize);
+ setErrorString(errorStr);
+
} else {
_ui.lSelectiveSyncSizeLabel->setText(QString());
}
_ui.lSelectiveSyncSizeLabel->setText(QString());
_ui.rSyncEverything->setChecked(true);
_selectiveSyncBlacklist.clear();
+
+ QString errorStr = checkLocalSpace(_rSize);
+ setErrorString(errorStr);
}
void OwncloudAdvancedSetupPage::slotQuotaRetrieved(const QVariantMap &result)
{
- _ui.lSyncEverythingSizeLabel->setText(tr("(%1)").arg(Utility::octetsToString(result["size"].toDouble())));
+ _rSize = result["size"].toDouble();
+ _ui.lSyncEverythingSizeLabel->setText(tr("(%1)").arg(Utility::octetsToString(_rSize)));
+}
+
+qint64 OwncloudAdvancedSetupPage::availableLocalSpace() const
+{
+ QString localDir = localFolder();
+ QString path = !QDir(localDir).exists() && localDir.contains(QDir::homePath()) ?
+ QDir::homePath() : localDir;
+ QStorageInfo storage(QDir::toNativeSeparators(path));
+
+ return storage.bytesAvailable();
+}
+
+QString OwncloudAdvancedSetupPage::checkLocalSpace(qint64 remoteSize) const
+{
+ return (availableLocalSpace()>remoteSize) ? QString() : tr("There is no enough free space in the local folder!");
}
} // namespace OCC
</property>
</spacer>
</item>
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QLabel" name="lServerIcon">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="lServer">
- <property name="text">
- <string>Server</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item row="1" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::MinimumExpanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0" rowspan="3">
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <widget class="QLabel" name="lLocalIcon">
- <property name="text">
- <string>TextLabel</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="lLocal">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>&Local Folder</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- <property name="buddy">
- <cstring>pbSelectLocalFolder</cstring>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_4">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item row="4" column="1" colspan="2">
- <widget class="QWidget" name="resolutionWidget" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <layout class="QFormLayout" name="formLayout_2">
- <property name="sizeConstraint">
- <enum>QLayout::SetMinimumSize</enum>
- </property>
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="1" column="0" colspan="2">
- <widget class="QRadioButton" name="radioButton">
- <property name="text">
- <string>&Keep local data</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QRadioButton" name="cbSyncFromScratch">
- <property name="toolTip">
- <string><html><head/><body><p>If this box is checked, existing content in the local folder will be erased to start a clean sync from the server.</p><p>Do not check this if the local content should be uploaded to the servers folder.</p></body></html></string>
- </property>
- <property name="text">
- <string>Start a &clean sync (Erases the local folder!)</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="2" column="1" rowspan="2">
- <widget class="QPushButton" name="pbSelectLocalFolder">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>pbSelectLocalFolder</string>
- </property>
- </widget>
- </item>
<item row="0" column="1" colspan="2">
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
</layout>
</widget>
</item>
+ <item row="2" column="0" rowspan="4">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QLabel" name="lLocalIcon">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="lLocal">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&Local Folder</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="buddy">
+ <cstring>pbSelectLocalFolder</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="1" rowspan="2">
+ <widget class="QPushButton" name="pbSelectLocalFolder">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>pbSelectLocalFolder</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="lServerIcon">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="lServer">
+ <property name="text">
+ <string>Server</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="5" column="1" colspan="2">
+ <widget class="QWidget" name="resolutionWidget" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <layout class="QFormLayout" name="formLayout_2">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMinimumSize</enum>
+ </property>
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::ExpandingFieldsGrow</enum>
+ </property>
+ <item row="1" column="0" colspan="2">
+ <widget class="QRadioButton" name="radioButton">
+ <property name="text">
+ <string>&Keep local data</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QRadioButton" name="cbSyncFromScratch">
+ <property name="toolTip">
+ <string><html><head/><body><p>If this box is checked, existing content in the local folder will be erased to start a clean sync from the server.</p><p>Do not check this if the local content should be uploaded to the servers folder.</p></body></html></string>
+ </property>
+ <property name="text">
+ <string>Start a &clean sync (Erases the local folder!)</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="lFreeSpace">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item>