Skip to content
Open
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
11 changes: 11 additions & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@
<file>src/gui/ResolveConflictsDialog.qml</file>
<file>src/gui/ConflictDelegate.qml</file>
<file>src/gui/ConflictItemFileInfo.qml</file>
<file>src/gui/wizard/qml/AccountWizardWindow.qml</file>
<file>src/gui/wizard/qml/AdvancedOptionsDialog.qml</file>
<file>src/gui/wizard/qml/BasicAuthPage.qml</file>
<file>src/gui/wizard/qml/BrowserAuthPage.qml</file>
<file>src/gui/wizard/qml/OptionRow.qml</file>
<file>src/gui/wizard/qml/ProxySettingsDialog.qml</file>
<file>src/gui/wizard/qml/ServerPage.qml</file>
<file>src/gui/wizard/qml/SyncOptionsPage.qml</file>
<file>src/gui/wizard/qml/WizardButton.qml</file>
<file>src/gui/wizard/qml/WizardDialogFrame.qml</file>
<file>src/gui/wizard/qml/WizardTextField.qml</file>
<file>src/gui/macOS/ui/FileProviderSettings.qml</file>
<file>src/gui/macOS/ui/FileProviderFileDelegate.qml</file>
<file>src/gui/integration/FileActionsWindow.qml</file>
Expand Down
37 changes: 2 additions & 35 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@ set(client_UI_SRCS
mnemonicdialog.ui
vfsdownloaderrordialog.ui
wizard/flow2authwidget.ui
wizard/owncloudadvancedsetuppage.ui
wizard/owncloudconnectionmethoddialog.ui
wizard/owncloudhttpcredspage.ui
wizard/owncloudsetupnocredspage.ui
wizard/termsofservicecheckwidget.ui
wizard/webview.ui
wizard/welcomepage.ui
wizard/proxysettings.ui
)

qt_add_resources(client_UI_SRCS ../../resources.qrc ${CMAKE_SOURCE_DIR}/theme.qrc)
Expand Down Expand Up @@ -225,36 +218,12 @@ set(client_SRCS
creds/webflowcredentials.cpp
creds/webflowcredentialsdialog.h
creds/webflowcredentialsdialog.cpp
wizard/abstractcredswizardpage.h
wizard/abstractcredswizardpage.cpp
wizard/owncloudadvancedsetuppage.h
wizard/owncloudadvancedsetuppage.cpp
wizard/owncloudconnectionmethoddialog.h
wizard/owncloudconnectionmethoddialog.cpp
wizard/owncloudhttpcredspage.h
wizard/owncloudhttpcredspage.cpp
wizard/flow2authcredspage.h
wizard/flow2authcredspage.cpp
wizard/accountwizardcontroller.h
wizard/accountwizardcontroller.cpp
wizard/flow2authwidget.h
wizard/flow2authwidget.cpp
wizard/owncloudsetuppage.h
wizard/owncloudsetuppage.cpp
wizard/termsofservicecheckwidget.h
wizard/termsofservicecheckwidget.cpp
wizard/termsofservicewizardpage.h
wizard/termsofservicewizardpage.cpp
wizard/owncloudwizardcommon.h
wizard/owncloudwizardcommon.cpp
wizard/owncloudwizard.h
wizard/owncloudwizard.cpp
wizard/slideshow.h
wizard/slideshow.cpp
wizard/welcomepage.h
wizard/welcomepage.cpp
wizard/linklabel.h
wizard/linklabel.cpp
wizard/wizardproxysettingsdialog.h
wizard/wizardproxysettingsdialog.cpp
integration/fileactionsmodel.h
integration/fileactionsmodel.cpp
)
Expand All @@ -268,8 +237,6 @@ endif()

if (WITH_WEBENGINE)
list(APPEND client_SRCS
wizard/webviewpage.h
wizard/webviewpage.cpp
wizard/webview.h
wizard/webview.cpp
)
Expand Down
3 changes: 1 addition & 2 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "encryptfolderjob.h"
#include "syncresult.h"
#include "ignorelisttablewidget.h"
#include "wizard/owncloudwizard.h"
#include "networksettings.h"
#include "ui_mnemonicdialog.h"

Expand Down Expand Up @@ -1031,7 +1030,7 @@ void AccountSettings::slotEnableVfsCurrentFolder()
return;
}

OwncloudWizard::askExperimentalVirtualFilesFeature(this, [folder, this](bool enable) {
Utility::askExperimentalVirtualFilesFeature(this, [folder, this](bool enable) {
if (!enable || !folder) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/creds/webflowcredentialsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include "theme.h"
#include "application.h"
#include "guiutility.h"
#include "owncloudgui.h"
#include "wizard/owncloudwizardcommon.h"

#ifdef WITH_WEBENGINE
#include "wizard/webview.h"
Expand Down Expand Up @@ -74,7 +74,7 @@
_errorLabel->hide();
_containerLayout->addWidget(_errorLabel);

WizardCommon::initErrorLabel(_errorLabel);
Utility::initErrorLabel(_errorLabel);

Check warning on line 77 in src/gui/creds/webflowcredentialsdialog.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/creds/webflowcredentialsdialog.cpp:77:29 [cppcoreguidelines-init-variables]

variable '_errorLabel' is not initialized

_layout->addLayout(_containerLayout);
setLayout(_layout);
Expand Down
11 changes: 7 additions & 4 deletions src/gui/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "selectivesyncdialog.h"
#include "accountstate.h"
#include "creds/abstractcredentials.h"
#include "wizard/owncloudwizard.h"
#include "guiutility.h"
#include "common/asserts.h"

#ifdef Q_OS_MACOS
Expand All @@ -26,6 +26,7 @@
#include <QFileInfo>
#include <QFileIconProvider>
#include <QInputDialog>
#include <QLoggingCategory>
#include <QUrl>
#include <QValidator>
#include <QWizardPage>
Expand Down Expand Up @@ -55,6 +56,8 @@

namespace OCC {

Q_LOGGING_CATEGORY(lcFolderWizard, "nextcloud.gui.folderwizard", QtInfoMsg)

Check warning on line 59 in src/gui/folderwizard.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/folderwizard.cpp:59:1 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'Q_LOGGING_CATEGORY' is non-const and globally accessible, consider making it const

QString FormatWarningsWizardPage::formatWarnings(const QStringList &warnings) const
{
QString formattedWarning;
Expand Down Expand Up @@ -256,7 +259,7 @@

void FolderWizardRemotePath::slotCreateRemoteFolderFinished()
{
qCDebug(lcWizard) << "webdav mkdir request finished";
qCDebug(lcFolderWizard) << "webdav mkdir request finished";
showWarn(tr("Folder was successfully created on %1.").arg(Theme::instance()->appNameGUI()));
slotRefreshFolders();
_ui.folderEntry->setText(dynamic_cast<MkColJob *>(sender())->path());
Expand All @@ -265,7 +268,7 @@

void FolderWizardRemotePath::slotHandleMkdirNetworkError(QNetworkReply *reply)
{
qCWarning(lcWizard) << "webdav mkdir request failed:" << reply->error();
qCWarning(lcFolderWizard) << "webdav mkdir request failed:" << reply->error();
if (!_account->credentials()->stillValid(reply)) {
showWarn(tr("Authentication failed accessing %1").arg(Theme::instance()->appNameGUI()));
} else {
Expand Down Expand Up @@ -668,7 +671,7 @@
// The click has already had an effect on the box, so if it's
// checked it was newly activated.
if (_virtualFilesCheckBox->isChecked()) {
OwncloudWizard::askExperimentalVirtualFilesFeature(this, [this](bool enable) {
Utility::askExperimentalVirtualFilesFeature(this, [this](bool enable) {
if (!enable)
_virtualFilesCheckBox->setChecked(false);
});
Expand Down
82 changes: 82 additions & 0 deletions src/gui/guiutility.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2017 ownCloud GmbH
Expand All @@ -6,14 +6,22 @@

#include "guiutility.h"

#include "config.h"

#include <QClipboard>
#include <QApplication>
#include <QCoreApplication>
#include <QDesktopServices>
#include <QLabel>
#include <QLoggingCategory>
#include <QMessageBox>
#include <QObject>
#include <QPalette>
#include <QPushButton>
#include <QUrlQuery>

#include "common/asserts.h"
#include "common/vfs.h"
using namespace OCC;

Q_LOGGING_CATEGORY(lcUtility, "nextcloud.gui.utility", QtInfoMsg)
Expand Down Expand Up @@ -101,3 +109,77 @@
{
return QCoreApplication::translate("utility", "Free up local space");
}

void Utility::askExperimentalVirtualFilesFeature(QWidget *receiver, const std::function<void(bool enable)> &callback)
{
#ifdef BUILD_FILE_PROVIDER_MODULE
callback(true);
return;
#endif

const auto bestVfsMode = bestAvailableVfsMode();
QMessageBox *msgBox = nullptr;

Check warning on line 121 in src/gui/guiutility.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/guiutility.cpp:121:18 [cppcoreguidelines-init-variables]

variable 'msgBox' is not initialized
QPushButton *acceptButton = nullptr;

Check warning on line 122 in src/gui/guiutility.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/guiutility.cpp:122:18 [cppcoreguidelines-init-variables]

variable 'acceptButton' is not initialized
switch (bestVfsMode) {
case Vfs::WindowsCfApi:
callback(true);
return;
case Vfs::WithSuffix:
msgBox = new QMessageBox(
QMessageBox::Warning,
QCoreApplication::translate("utility", "Enable experimental feature?"),
QCoreApplication::translate("utility",
"When the \"virtual files\" mode is enabled no files will be downloaded initially. "
"Instead, a tiny \"%1\" file will be created for each file that exists on the server. "
"The contents can be downloaded by running these files or by using their context menu."
"\n\n"
"The virtual files mode is mutually exclusive with selective sync. "
"Currently unselected folders will be translated to online-only folders "
"and your selective sync settings will be reset."
"\n\n"
"Switching to this mode will abort any currently running synchronization."
"\n\n"
"This is a new, experimental mode. If you decide to use it, please report any "
"issues that come up.")
.arg(APPLICATION_DOTVIRTUALFILE_SUFFIX),
QMessageBox::NoButton, receiver);
acceptButton = msgBox->addButton(QCoreApplication::translate("utility", "Enable experimental placeholder mode"), QMessageBox::AcceptRole);
msgBox->addButton(QCoreApplication::translate("utility", "Stay safe"), QMessageBox::RejectRole);
break;
case Vfs::XAttr:
case Vfs::Off:
Q_UNREACHABLE();
}

QObject::connect(msgBox, &QMessageBox::accepted, receiver, [callback, msgBox, acceptButton] {
callback(msgBox->clickedButton() == acceptButton);
msgBox->deleteLater();
});
QObject::connect(msgBox, &QMessageBox::rejected, receiver, [callback, msgBox] {
callback(false);
msgBox->deleteLater();
});
msgBox->open();
}

void Utility::initErrorLabel(QLabel *errorLabel)
{
const auto style = QLatin1String("border: 1px solid #eed3d7; border-radius: 5px; padding: 3px;"
"background-color: #f2dede; color: #b94a48;");

errorLabel->setStyleSheet(style);
errorLabel->setWordWrap(true);
auto sizePolicy = errorLabel->sizePolicy();
sizePolicy.setRetainSizeWhenHidden(true);
errorLabel->setSizePolicy(sizePolicy);
errorLabel->setVisible(false);
}

void Utility::customizeHintLabel(QLabel *label)
{
auto palette = label->palette();
auto textColor = palette.color(QPalette::Text);
textColor.setAlpha(128);
palette.setColor(QPalette::Text, textColor);
label->setPalette(palette);
}
13 changes: 13 additions & 0 deletions src/gui/guiutility.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
#ifndef GUIUTILITY_H
#define GUIUTILITY_H

#include <QString>

Check failure on line 10 in src/gui/guiutility.h

View workflow job for this annotation

GitHub Actions / build

src/gui/guiutility.h:10:10 [clang-diagnostic-error]

'QString' file not found
#include <QUrl>
#include <QWidget>

#include <functional>

#include "common/pinstate.h"

class QLabel;

Check warning on line 18 in src/gui/guiutility.h

View workflow job for this annotation

GitHub Actions / build

src/gui/guiutility.h:18:7 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'QLabel' is non-const and globally accessible, consider making it const

namespace OCC {
namespace Utility {

Expand Down Expand Up @@ -41,6 +45,15 @@
/** Translated text for "free up local space" (and unpinning the item) */
QString vfsFreeSpaceActionText();

/** Ask before enabling an experimental virtual files mode. */
void askExperimentalVirtualFilesFeature(QWidget *receiver, const std::function<void(bool enable)> &callback);

/** Apply the standard inline error label styling used by setup dialogs. */
void initErrorLabel(QLabel *errorLabel);

/** Dim a hint label while preserving its current palette. */
void customizeHintLabel(QLabel *label);

} // namespace Utility
} // namespace OCC

Expand Down
2 changes: 2 additions & 0 deletions src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "wheelhandler.h"
#include "syncconflictsmodel.h"
#include "syncengine.h"
#include "wizard/accountwizardcontroller.h"
#include "filedetails/datefieldbackend.h"
#include "filedetails/filedetails.h"
#include "filedetails/shareemodel.h"
Expand Down Expand Up @@ -148,6 +149,7 @@ ownCloudGui::ownCloudGui(Application *parent)
qmlRegisterType<SortedShareModel>("com.nextcloud.desktopclient", 1, 0, "SortedShareModel");
qmlRegisterType<SyncConflictsModel>("com.nextcloud.desktopclient", 1, 0, "SyncConflictsModel");
qmlRegisterType<FileActionsModel>("com.nextcloud.desktopclient", 1, 0, "FileActionsModel");
qmlRegisterType<AccountWizardController>("com.nextcloud.desktopclient", 1, 0, "AccountWizardController");

qmlRegisterUncreatableType<QAbstractItemModel>("com.nextcloud.desktopclient", 1, 0, "QAbstractItemModel", "QAbstractItemModel");
qmlRegisterUncreatableType<Activity>("com.nextcloud.desktopclient", 1, 0, "activity", "Activity");
Expand Down
Loading
Loading