Skip to content
Draft
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
1 change: 1 addition & 0 deletions NEXTCLOUD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ set( APPLICATION_NAME "Nextcloud" )
set( APPLICATION_SHORTNAME "Nextcloud" )
set( APPLICATION_EXECUTABLE "nextcloud" )
set( APPLICATION_CONFIG_NAME "${APPLICATION_EXECUTABLE}" )
set( APPLICATION_SYNC_FOLDER_NAME "Nextcloud Folder" )
set( APPLICATION_DOMAIN "nextcloud.com" )
set( APPLICATION_VENDOR "Nextcloud GmbH" )
set( APPLICATION_UPDATE_URL "https://updates.nextcloud.org/client/" CACHE STRING "URL for updater" )
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#cmakedefine APPLICATION_DOMAIN "@APPLICATION_DOMAIN@"
#cmakedefine APPLICATION_REV_DOMAIN "@APPLICATION_REV_DOMAIN@"
#cmakedefine APPLICATION_SHORTNAME "@APPLICATION_SHORTNAME@"
#cmakedefine APPLICATION_SYNC_FOLDER_NAME "@APPLICATION_SYNC_FOLDER_NAME@"
#cmakedefine APPLICATION_EXECUTABLE "@APPLICATION_EXECUTABLE@"
#cmakedefine APPLICATION_CONFIG_NAME "@APPLICATION_CONFIG_NAME@"
#cmakedefine APPLICATION_UPDATE_URL "@APPLICATION_UPDATE_URL@"
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ QString Folder::shortGuiRemotePathOrAppName() const
}
return a;
} else {
return Theme::instance()->appNameGUI();
return Theme::instance()->defaultClientFolder();
}
}

Expand Down
79 changes: 37 additions & 42 deletions src/gui/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ FolderWizardLocalPath::FolderWizardLocalPath(const AccountPtr &account)
connect(_ui.localFolderChooseBtn, &QAbstractButton::clicked, this, &FolderWizardLocalPath::slotChooseLocalFolder);
_ui.localFolderChooseBtn->setToolTip(tr("Click to select a local folder to sync."));

QUrl serverUrl = _account->url();
auto serverUrl = _account->url();
serverUrl.setUserName(_account->credentials()->user());
QString defaultPath = QDir::homePath() + QLatin1Char('/') + Theme::instance()->appName();
defaultPath = FolderMan::instance()->findGoodPathForNewSyncFolder(defaultPath, serverUrl, FolderMan::GoodPathStrategy::AllowOnlyNewPath);
QString defaultPath = QDir::homePath() + QLatin1Char('/') + Theme::instance()->defaultClientFolder();
defaultPath = FolderMan::instance()->findGoodPathForNewSyncFolder(defaultPath,
serverUrl,
FolderMan::GoodPathStrategy::AllowOnlyNewPath);
_ui.localFolderLineEdit->setText(QDir::toNativeSeparators(defaultPath));
_ui.localFolderLineEdit->setToolTip(tr("Enter the path to the local folder."));

Expand All @@ -95,51 +97,47 @@ void FolderWizardLocalPath::cleanupPage()

bool FolderWizardLocalPath::isComplete() const
{
QUrl serverUrl = _account->url();
auto serverUrl = _account->url();
serverUrl.setUserName(_account->credentials()->user());

const auto errorStr = FolderMan::instance()->checkPathValidityForNewFolder(
QDir::fromNativeSeparators(_ui.localFolderLineEdit->text()), serverUrl).second;


bool isOk = errorStr.isEmpty();
QStringList warnStrings;
if (!isOk) {
warnStrings << errorStr;
}

const auto errorMessage = FolderMan::instance()->checkPathValidityForNewFolder(QDir::fromNativeSeparators(
_ui.localFolderLineEdit->text()),
serverUrl).second;
const auto noErrorMessage = errorMessage.isEmpty();
_ui.warnLabel->setWordWrap(true);
if (isOk) {
if (noErrorMessage) {
_ui.warnLabel->hide();
_ui.warnLabel->clear();
} else {
_ui.warnLabel->show();
QString warnings = formatWarnings(warnStrings);
_ui.warnLabel->setText(warnings);
_ui.warnLabel->setText(formatWarnings({errorMessage}));
}
return isOk;

return noErrorMessage;
}

void FolderWizardLocalPath::slotChooseLocalFolder()
{
QString sf = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
QDir d(sf);
auto homeDirectoryName = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);

// open the first entry of the home dir, otherwise the dir picker comes up with the closed home dir icon
const auto homeDirectoryList = QDir(homeDirectoryName).entryList(QDir::Dirs |
QDir::NoDotAndDotDot |
QDir::NoSymLinks,
QDir::DirsFirst | QDir::Name);

// open the first entry of the home dir. Otherwise the dir picker comes
// up with the closed home dir icon, stupid Qt default...
QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks,
QDir::DirsFirst | QDir::Name);
if (homeDirectoryList.count() > 0) {
homeDirectoryName += "/" + homeDirectoryList.at(0); // Take the first dir in home dir.
}

if (dirs.count() > 0)
sf += "/" + dirs.at(0); // Take the first dir in home dir.
const auto userSelectedDirectory = QFileDialog::getExistingDirectory(this,
tr("Select the source folder"),
homeDirectoryName);

QString dir = QFileDialog::getExistingDirectory(this,
tr("Select the source folder"),
sf);
if (!dir.isEmpty()) {
// set the last directory component name as alias
_ui.localFolderLineEdit->setText(QDir::toNativeSeparators(dir));
if (!userSelectedDirectory.isEmpty()) {
_ui.localFolderLineEdit->setText(QDir::toNativeSeparators(userSelectedDirectory));
}

emit completeChanged();
}

Expand Down Expand Up @@ -196,18 +194,14 @@ FolderWizardRemotePath::FolderWizardRemotePath(const AccountPtr &account)

void FolderWizardRemotePath::slotAddRemoteFolder()
{
QTreeWidgetItem *current = _ui.folderTreeWidget->currentItem();

QString parent('/');
if (current) {
parent = current->data(0, Qt::UserRole).toString();
}

const auto *currentItem = _ui.folderTreeWidget->currentItem();
auto *dlg = new QInputDialog(this);

dlg->setWindowTitle(tr("Create Remote Folder"));
dlg->setLabelText(tr("Enter the name of the new folder to be created below \"%1\":")
.arg(parent));
.arg(currentItem?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.arg(currentItem?
.arg(currentItem ?

currentItem->data(0, Qt::UserRole).toString() :
QStringLiteral("/")));
dlg->open(this, SLOT(slotCreateRemoteFolder(QString)));
dlg->setAttribute(Qt::WA_DeleteOnClose);
}
Expand Down Expand Up @@ -552,8 +546,9 @@ void FolderWizardSelectiveSync::initializePage()
targetPath = targetPath.mid(1);
}
QString alias = QFileInfo(targetPath).fileName();
if (alias.isEmpty())
alias = Theme::instance()->appName();
if (alias.isEmpty()) {
alias = Theme::instance()->defaultClientFolder();
}
QStringList initialBlacklist;
if (Theme::instance()->wizardSelectiveSyncDefaultNothing()) {
initialBlacklist = QStringList("/");
Expand Down
7 changes: 6 additions & 1 deletion src/libsync/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ QString Theme::appName() const
return APPLICATION_SHORTNAME;
}

QString Theme::appSyncFolderName() const
{
return APPLICATION_SYNC_FOLDER_NAME;
}

Comment on lines +132 to +136
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this new method necessary?

QUrl Theme::stateOnlineImageSource() const
{
return imagePathToUrl(themeImagePath("state-ok"));
Expand Down Expand Up @@ -471,7 +476,7 @@ QString Theme::forceConfigAuthType() const

QString Theme::defaultClientFolder() const
{
return appName();
return appSyncFolderName();
}

QString Theme::systrayIconFlavor(bool mono) const
Expand Down
6 changes: 6 additions & 0 deletions src/libsync/theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject
*/
[[nodiscard]] QString appName() const;

/**
* @brief appSyncFolderName - Default sync folder name
* @return QString with sync folder name.
*/
[[nodiscard]] QString appSyncFolderName() const;

/**
* @brief Returns full path to an online state icon
* @return QUrl full path to an icon
Expand Down