Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.14] nmc/2003-Folderwizard_Settings_Dialog_New #315

Open
wants to merge 4 commits into
base: stable-3.14
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES)

set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

set(NMC_RCC_FILE "nmctheme_v1.rcc")
configure_file(${CMAKE_SOURCE_DIR}/${NMC_RCC_FILE} "${BIN_OUTPUT_DIRECTORY}/${NMC_RCC_FILE}" COPYONLY)

include(${CMAKE_SOURCE_DIR}/NEXTCLOUD.cmake)

set(QT_VERSION_MAJOR "6")
Expand Down Expand Up @@ -341,6 +344,7 @@ configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
if(BUILD_OWNCLOUD_OSX_BUNDLE)
install(FILES sync-exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
configure_file(sync-exclude.lst bin/${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/sync-exclude.lst COPYONLY)
install(FILES nmctheme_v1.rcc DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
elseif(BUILD_CLIENT)
install( FILES sync-exclude.lst DESTINATION ${SYSCONFDIR}/${APPLICATION_SHORTNAME} )
configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY)
Expand Down
Binary file added nmctheme_v1.rcc
Binary file not shown.
8 changes: 8 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS Widgets Svg Qml Quick Qui
find_package(KF6Archive REQUIRED)
find_package(KF6GuiAddons)

#NMC change, its needed to find the ui file in a different location than the header file
set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_SOURCE_DIR}/src/gui")

if (NOT TARGET Qt::GuiPrivate)
message(FATAL_ERROR "Could not find GuiPrivate component of Qt. It might be shipped as a separate package, please check that.")
endif()
Expand Down Expand Up @@ -251,6 +254,10 @@ set(client_SRCS
wizard/linklabel.cpp
)

file(GLOB NMC_FILES "nmcgui/*")
set(NMC_SRCS ${NMC_FILES})
list(APPEND client_SRCS ${NMC_SRCS})

if (WITH_WEBENGINE)
list(APPEND client_SRCS
wizard/webviewpage.h
Expand Down Expand Up @@ -618,6 +625,7 @@ if(NOT BUILD_OWNCLOUD_OSX_BUNDLE)
install(FILES ${VISUAL_ELEMENTS} DESTINATION bin/visualelements)
install(FILES "${theme_dir}/${APPLICATION_EXECUTABLE}.VisualElementsManifest.xml" DESTINATION bin)
install(FILES ${client_I18N} DESTINATION i18n)
install(FILES ${CMAKE_SOURCE_DIR}/nmctheme_v1.rcc DESTINATION bin)
endif()

# we may not add MACOSX_BUNDLE here, if not building one
Expand Down
9 changes: 6 additions & 3 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#include "theme.h"
#include "foldercreationdialog.h"
#include "folderman.h"
#include "folderwizard.h"
// #include "folderwizard.h"
#include "nmcgui/nmcfolderwizard.h"
#include "folderstatusmodel.h"
#include "folderstatusdelegate.h"
#include "common/utility.h"
Expand Down Expand Up @@ -774,7 +775,8 @@ void AccountSettings::slotAddFolder()
const auto folderMan = FolderMan::instance();
folderMan->setSyncEnabled(false); // do not start more syncs.

const auto folderWizard = new FolderWizard(_accountState->account(), this);
// const auto folderWizard = new FolderWizard(_accountState->account(), this);
const auto folderWizard = new NMCFolderWizard(_accountState->account(), this);
folderWizard->setAttribute(Qt::WA_DeleteOnClose);

connect(folderWizard, &QDialog::accepted, this, &AccountSettings::slotFolderWizardAccepted);
Expand All @@ -785,7 +787,8 @@ void AccountSettings::slotAddFolder()

void AccountSettings::slotFolderWizardAccepted()
{
const auto folderWizard = qobject_cast<FolderWizard *>(sender());
// const auto folderWizard = qobject_cast<FolderWizard *>(sender());
const auto folderWizard = qobject_cast<NMCFolderWizard *>(sender());
const auto folderMan = FolderMan::instance();

qCInfo(lcAccountSettings) << "Folder wizard completed";
Expand Down
14 changes: 10 additions & 4 deletions src/gui/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,10 @@ bool FolderWizardRemotePath::isComplete() const
if (QDir::cleanPath(dir) == QDir::cleanPath(curDir)) {
warnStrings.append(tr("This folder is already being synced."));
} else if (dir.startsWith(curDir)) {
warnStrings.append(tr("You are already syncing <i>%1</i>, which is a parent folder of <i>%2</i>.").arg(Utility::escape(curDir), Utility::escape(dir)));
// warnStrings.append(tr("You are already syncing <i>%1</i>, which is a parent folder of <i>%2</i>.").arg(Utility::escape(curDir), Utility::escape(dir)));
} else if (curDir.startsWith(dir)) {
warnStrings.append(tr("You are already syncing <i>%1</i>, which is a subfolder of <i>%2</i>.").arg(Utility::escape(curDir), Utility::escape(dir)));
// warnStrings.append(tr("You are already syncing <i>%1</i>, which is a subfolder of <i>%2</i>.").arg(Utility::escape(curDir), Utility::escape(dir)));
warnStrings.append(QCoreApplication::translate("", "FOLDER_WIZARD_FOLDER_WARNING")); //NMC customization
}
}

Expand Down Expand Up @@ -564,7 +565,8 @@ void FolderWizardRemotePath::changeStyle()
FolderWizardSelectiveSync::FolderWizardSelectiveSync(const AccountPtr &account)
{
auto *layout = new QVBoxLayout(this);
_selectiveSync = new SelectiveSyncWidget(account, this);
// _selectiveSync = new SelectiveSyncWidget(account, this);
_selectiveSync = new NMCSelectiveSyncWidget(account, this);
layout->addWidget(_selectiveSync);

if (Theme::instance()->showVirtualFilesOption() && bestAvailableVfsMode() != Vfs::Off) {
Expand Down Expand Up @@ -679,7 +681,11 @@ FolderWizard::FolderWizard(AccountPtr account, QWidget *parent)
setPage(Page_Target, _folderWizardTargetPage);
_folderWizardTargetPage->installEventFilter(this);
}
setPage(Page_SelectiveSync, _folderWizardSelectiveSyncPage);
// setPage(Page_SelectiveSync, _folderWizardSelectiveSyncPage);
if(Utility::isMac())
{
setPage(Page_SelectiveSync, _folderWizardSelectiveSyncPage);
}

setWindowTitle(tr("Add Folder Sync Connection"));
setOptions(QWizard::CancelButtonOnLeft);
Expand Down
25 changes: 18 additions & 7 deletions src/gui/folderwizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
#include "folder.h"
#include "accountfwd.h"

#include "ui_folderwizardsourcepage.h"
#include "ui_folderwizardtargetpage.h"
#include "nmcgui/nmcfolderwizardsourcepage.h"
#include "nmcgui/nmcfolderwizardtargetpage.h"
#include "nmcgui/nmcselectivesyncdialog.h"

class QCheckBox;

namespace OCC {

class SelectiveSyncWidget;
class NMCSelectiveSyncWidget;

class ownCloudInfo;

Expand Down Expand Up @@ -61,6 +62,11 @@ class FolderWizardLocalPath : public FormatWarningsWizardPage

void setFolderMap(const Folder::Map &fm) { _folderMap = fm; }

NMCFolderWizardSourcePage getUi()
{
return _ui;
}

protected:
void changeEvent(QEvent *) override;

Expand All @@ -70,7 +76,7 @@ protected slots:
private:
void changeStyle();

Ui_FolderWizardSourcePage _ui{};
NMCFolderWizardSourcePage _ui{};
Folder::Map _folderMap;
AccountPtr _account;
};
Expand All @@ -93,6 +99,11 @@ class FolderWizardRemotePath : public FormatWarningsWizardPage
void initializePage() override;
void cleanupPage() override;

NMCFolderWizardTargetPage getUi()
{
return _ui;
};

protected slots:
void showWarn(const QString & = QString()) const;
void slotAddRemoteFolder();
Expand All @@ -119,7 +130,7 @@ private slots:
LsColJob *runLsColJob(const QString &path);
void recursiveInsert(QTreeWidgetItem *parent, QStringList pathTrail, QString path);
bool selectByPath(QString path);
Ui_FolderWizardTargetPage _ui{};
NMCFolderWizardTargetPage _ui{};
bool _warnWasVisible = false;
AccountPtr _account;
QTimer _lscolTimer;
Expand All @@ -146,7 +157,7 @@ private slots:
void virtualFilesCheckboxClicked();

private:
SelectiveSyncWidget *_selectiveSync;
NMCSelectiveSyncWidget *_selectiveSync;
QCheckBox *_virtualFilesCheckBox = nullptr;
};

Expand All @@ -170,7 +181,7 @@ class FolderWizard : public QWizard
bool eventFilter(QObject *watched, QEvent *event) override;
void resizeEvent(QResizeEvent *event) override;

private:
protected:
FolderWizardLocalPath *_folderWizardSourcePage;
FolderWizardRemotePath *_folderWizardTargetPage = nullptr;
FolderWizardSelectiveSync *_folderWizardSelectiveSyncPage;
Expand Down
8 changes: 8 additions & 0 deletions src/gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ int main(int argc, char **argv)
qputenv("QML_IMPORT_PATH", (QDir::currentPath() + QStringLiteral("/qml")).toLatin1());
#endif

bool resourceLoaded = false;
const QString currentPath = QDir::currentPath();
if(Utility::isMac()) {
resourceLoaded = QResource::registerResource(QDir::toNativeSeparators("/Applications/MagentaCLOUD.app/Contents/Resources/nmctheme_v1.rcc"));
} else if(Utility::isWindows() || !resourceLoaded) {
resourceLoaded = QResource::registerResource(QDir::toNativeSeparators(currentPath + "/nmctheme_v1.rcc"));
}

Q_INIT_RESOURCE(resources);
Q_INIT_RESOURCE(theme);

Expand Down
41 changes: 41 additions & 0 deletions src/gui/nmcgui/nmcfolderwizard.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) by Eugen Fischer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "nmcfolderwizard.h"

/**
* Folder wizard itself
*/

namespace OCC {

NMCFolderWizard::NMCFolderWizard(AccountPtr account, QWidget *parent)
:FolderWizard(account, parent)
{
setWizardStyle(QWizard::ClassicStyle);
setButtonText(QWizard::FinishButton, QCoreApplication::translate("", "ADD_SYNCHRONIZATION"));

//Source page
auto sourceUi = _folderWizardSourcePage->getUi();
sourceUi.localFolderLineEdit->clear();
sourceUi.localFolderLineEdit->setPlaceholderText(QCoreApplication::translate("", "ADD_LIVE_BACKUP_PLACEHOLDER_TEXT"));
sourceUi.setDefaultSettings();
sourceUi.changeLayout();

//Target page
auto targetUi = _folderWizardTargetPage->getUi();
targetUi.setDefaultSettings();
targetUi.setLayout();
}

} // end namespace
50 changes: 50 additions & 0 deletions src/gui/nmcgui/nmcfolderwizard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) by Eugen Fischer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

#ifndef MIRALL_NMCFolderWizard_H
#define MIRALL_NMCFolderWizard_H

#include "folderwizard.h"

/**
* @brief The NMCFolderWizard class represents a specific folder wizard for the NMC application.
* @ingroup gui
*
* The NMCFolderWizard class is derived from the FolderWizard class and provides additional functionality
* specific to the NMC (replace with the actual application name) application.
*/

namespace OCC {

class NMCFolderWizard : public FolderWizard
{
Q_OBJECT
public:
/**
* @brief Constructs an instance of NMCFolderWizard.
* @param account The account associated with the wizard.
* @param parent The parent widget (default is nullptr).
*/
explicit NMCFolderWizard(OCC::AccountPtr account, QWidget *parent = nullptr);

/**
* @brief Destroys the NMCFolderWizard instance.
*/
~NMCFolderWizard() = default;
};

} // namespace OCC

#endif

81 changes: 81 additions & 0 deletions src/gui/nmcgui/nmcfolderwizardsourcepage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (C) by Eugen Fischer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

#include "nmcfolderwizardsourcepage.h"
#include "theme.h"

namespace OCC {

NMCFolderWizardSourcePage::NMCFolderWizardSourcePage()
:FolderWizardSourcePage()
{

}

void NMCFolderWizardSourcePage::setDefaultSettings()
{
groupBox->setVisible(false);
}

void NMCFolderWizardSourcePage::changeLayout()
{
gridLayout_2->setContentsMargins(0, 0, 0, 0);

QLabel *stepLabel = new QLabel();
stepLabel->setText(QCoreApplication::translate("", "ADD_LIVE_BACKUP_HEADLINE"));
stepLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
stepLabel->setStyleSheet("QLabel{color: black; font-size: 13px; font-weight: bold;}");

gridLayout_2->addWidget(stepLabel, 0, 0, Qt::AlignTop | Qt::AlignLeft);

QWidget *mainLayoutWidget = new QWidget();
mainLayoutWidget->setStyleSheet("");

auto *whiteLayout = new QGridLayout;
mainLayoutWidget->setObjectName("mainLayoutWidget");
mainLayoutWidget->setStyleSheet("QWidget#mainLayoutWidget { background-color: white; border-radius: 4px;}");
mainLayoutWidget->setLayout(whiteLayout);

QLabel *textLabel = new QLabel();
textLabel->setText(QCoreApplication::translate("", "ADD_LIVE_BACKUP_PAGE1_DESCRIPTION"));
textLabel->setWordWrap(true);
textLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

whiteLayout->addWidget(textLabel, 0, 0);

gridLayout_2->removeWidget(localFolderLineEdit);
localFolderLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
whiteLayout->addWidget(localFolderLineEdit, 1, 0);

localFolderChooseBtn->setAutoDefault(true);
localFolderChooseBtn->setDefault(true);
localFolderChooseBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
//localFolderChooseBtn->setFixedHeight(10);
whiteLayout->addWidget(localFolderChooseBtn, 1, 1);

gridLayout_2->addWidget(mainLayoutWidget, 1, 0, 1, 3);

gridLayout_2->removeWidget(warnLabel);
gridLayout_2->addWidget(warnLabel, 2, 0, 1, 3);

warnLabel->setStyleSheet("border: 0px; border-radius: 4px; background-color: #fee2d0");

gridLayout_2->removeItem(verticalSpacer);
gridLayout_2->addItem(verticalSpacer, 3, 0, 1, 3);
}

} // end namespace



Loading