Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/gui/folderwizard/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,20 @@ QString FolderWizardPrivate::defaultSyncRoot() const
FolderWizardPrivate::FolderWizardPrivate(FolderWizard *q, const AccountStatePtr &account)
: q_ptr(q)
, _account(account)
, _folderWizardSourcePage(new FolderWizardLocalPath(this))
, _folderWizardSelectiveSyncPage(new FolderWizardSelectiveSync(this))
, _spacesPage(new SpacesPage(account->account(), q))
{
q->setPage(FolderWizard::Page_Space, _spacesPage);
q->setPage(FolderWizard::Page_Source, _folderWizardSourcePage);

if (!_account->account()->hasDefaultSyncRoot()) {
_folderWizardSourcePage = new FolderWizardLocalPath(this);
q->setPage(FolderWizard::Page_Source, _folderWizardSourcePage);
}

q->setPage(FolderWizard::Page_SelectiveSync, _folderWizardSelectiveSyncPage);
}

QString FolderWizardPrivate::initialLocalPath() const
QString FolderWizardPrivate::localPath() const
{
return FolderMan::findGoodPathForNewSyncFolder(
defaultSyncRoot(), _spacesPage->currentSpace()->displayName(), FolderMan::NewFolderType::SpacesSyncRoot, _account->account()->uuid());
Expand Down Expand Up @@ -121,7 +124,7 @@ bool FolderWizardPrivate::useVirtualFiles() const
const auto mode = VfsPluginManager::instance().bestAvailableVfsMode();
const bool useVirtualFiles = (Theme::instance()->forceVirtualFilesOption() && mode == Vfs::WindowsCfApi) || (_folderWizardSelectiveSyncPage->useVirtualFiles());
if (useVirtualFiles) {
const auto availability = Vfs::checkAvailability(initialLocalPath(), mode);
const auto availability = Vfs::checkAvailability(localPath(), mode);
if (!availability) {
auto msg = new QMessageBox(QMessageBox::Warning, FolderWizard::tr("Virtual files are not available for the selected folder"), availability.error(), QMessageBox::Ok, ocApp()->gui()->settingsDialog());
msg->setAttribute(Qt::WA_DeleteOnClose);
Expand Down Expand Up @@ -149,16 +152,13 @@ FolderWizard::~FolderWizard()
FolderMan::SyncConnectionDescription FolderWizard::result()
{
Q_D(FolderWizard);
const QString localPath = d->localPath();

const QString localPath = d->_folderWizardSourcePage->localPath();
if (!d->_account->account()->hasDefaultSyncRoot()) {
if (FileSystem::isChildPathOf(localPath, d->defaultSyncRoot())) {
d->_account->account()->setDefaultSyncRoot(d->defaultSyncRoot());
if (!QFileInfo::exists(d->defaultSyncRoot())) {
OC_ASSERT(QDir().mkpath(d->defaultSyncRoot()));
}
}
if (d->_folderWizardSourcePage) {
d->_account->account()->setDefaultSyncRoot(d->_folderWizardSourcePage->localPath());
}
// the local path must be a child of defaultSyncRoot
Q_ASSERT(FileSystem::isChildPathOf(localPath, d->defaultSyncRoot()));

return {
d->davUrl(), //
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderwizard/folderwizard_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FolderWizardPrivate
FolderWizardPrivate(FolderWizard *q, const AccountStatePtr &account);
static QString formatWarnings(const QStringList &warnings, bool isError = false);

QString initialLocalPath() const;
QString localPath() const;

QString remotePath() const;

Expand Down
10 changes: 2 additions & 8 deletions src/gui/folderwizard/folderwizardlocalpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ FolderWizardLocalPath::FolderWizardLocalPath(FolderWizardPrivate *parent)
, _ui(new Ui_FolderWizardSourcePage)
{
_ui->setupUi(this);
registerField(QStringLiteral("sourceFolder*"), _ui->localFolderLineEdit);
connect(_ui->localFolderChooseBtn, &QAbstractButton::clicked, this, &FolderWizardLocalPath::slotChooseLocalFolder);
_ui->localFolderChooseBtn->setToolTip(tr("Click to select a local folder to sync."));

_ui->localFolderLineEdit->setToolTip(tr("Enter the path to the local folder."));

_ui->warnLabel->setTextFormat(Qt::RichText);
_ui->warnLabel->hide();
Expand All @@ -53,7 +49,7 @@ FolderWizardLocalPath::~FolderWizardLocalPath()
void FolderWizardLocalPath::initializePage()
{
_ui->warnLabel->hide();
_ui->localFolderLineEdit->setText(QDir::toNativeSeparators(folderWizardPrivate()->initialLocalPath()));
_ui->localFolderLineEdit->setText(QDir::toNativeSeparators(folderWizardPrivate()->defaultSyncRoot()));
}

QString FolderWizardLocalPath::localPath() const
Expand Down Expand Up @@ -97,9 +93,7 @@ void FolderWizardLocalPath::slotChooseLocalFolder()
if (dirs.count() > 0)
sf += QLatin1Char('/') + dirs.at(0); // Take the first dir in home dir.

QString dir = QFileDialog::getExistingDirectory(this,
tr("Select the local folder"),
sf);
QString dir = QFileDialog::getExistingDirectory(this, tr("Select the Spaces root folder"), sf);
if (!dir.isEmpty()) {
// set the last directory component name as alias
_ui->localFolderLineEdit->setText(QDir::toNativeSeparators(dir));
Expand Down
18 changes: 14 additions & 4 deletions src/gui/folderwizard/folderwizardsourcepage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,27 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Pick a local folder on your computer to sync</string>
<string>Select a local folder to synchronize your Spaces to:</string>
</property>
<property name="buddy">
<cstring>localFolderLineEdit</cstring>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="localFolderLineEdit"/>
<widget class="QLineEdit" name="localFolderLineEdit">
<property name="toolTip">
<string>Enter the path to the Spaces root folder. This folder will contain all your synchronized Spaces.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="localFolderChooseBtn">
<property name="toolTip">
<string>Click to select a the Spaces root folder.</string>
</property>
<property name="text">
<string>&amp;Choose...</string>
</property>
Expand All @@ -41,14 +51,14 @@
<string/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
<enum>Qt::TextFormat::RichText</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down
Loading