Skip to content

Commit

Permalink
Merge #93 nmc/2003-Account_Settings_Dialog - Master
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenMCloud committed Feb 5, 2024
2 parents 615d592 + 7976c4f commit 4a03598
Show file tree
Hide file tree
Showing 10 changed files with 277 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,6 @@ convert.exe
*-w10startmenu.png
*state-*.png
theme.qrc

# Ignore specific folders
shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,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)

# CfAPI Shell Extensions
Expand Down
Binary file added nmctheme_v1.rcc
Binary file not shown.
7 changes: 7 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ project(gui)
find_package(Qt5 REQUIRED COMPONENTS Widgets Svg Qml Quick QuickControls2 Xml Network)
find_package(KF5Archive REQUIRED)

#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(QUICK_COMPILER)
find_package(Qt5QuickCompiler)
set_package_properties(Qt5QuickCompiler PROPERTIES
Expand Down Expand Up @@ -260,6 +263,10 @@ set(client_SRCS
wizard/linklabel.cpp
)

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

if (Qt5WebEngine_FOUND AND Qt5WebEngineWidgets_FOUND)
list(APPEND client_SRCS
wizard/webviewpage.h
Expand Down
4 changes: 3 additions & 1 deletion src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ QString AccountSettings::selectedFolderAlias() const
return _model->data(selected, FolderStatusDelegate::FolderAliasRole).toString();
}



void AccountSettings::slotToggleSignInState()
{
if (_accountState->isSignedOut()) {
Expand Down Expand Up @@ -1111,7 +1113,7 @@ void AccountSettings::showConnectionLabel(const QString &message, QStringList er
_ui->connectLabel->setToolTip({});
_ui->connectLabel->setStyleSheet(errStyle);
}
_ui->accountStatus->setVisible(!message.isEmpty());
//_ui->accountStatus->setVisible(!message.isEmpty()); //NMC Customization
}

void AccountSettings::slotEnableCurrentFolder(bool terminate)
Expand Down
6 changes: 6 additions & 0 deletions src/gui/accountsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ private slots:
void checkClientSideEncryptionState();
void removeActionFromEncryptionMessage(const QString &actionId);

protected:
Ui::AccountSettings *getUi() const
{
return _ui;
}

private:
bool event(QEvent *) override;
QAction *addActionToEncryptionMessage(const QString &actionTitle, const QString &actionId);
Expand Down
1 change: 1 addition & 0 deletions src/gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ int main(int argc, char **argv)
#ifdef Q_OS_WIN
SetDllDirectory(L"");
#endif
QResource::registerResource(QDir::toNativeSeparators(QDir::currentPath() + "/nmctheme_v1.rcc"));
Q_INIT_RESOURCE(resources);
Q_INIT_RESOURCE(theme);

Expand Down
142 changes: 142 additions & 0 deletions src/gui/nmcgui/nmcaccountsettings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* 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 "nmcgui/nmcaccountsettings.h"
#include "ui_accountsettings.h"
#include "qdesktopservices.h"


namespace OCC {

NMCAccountSettings::NMCAccountSettings(AccountState *accountState, QWidget *parent)
: AccountSettings(accountState, parent)
, m_liveAccountButton(new CustomButton(tr("ADD_LIVE_BACKUP"), QIcon(QLatin1String(":/client/theme/NMCIcons/action-add.svg")).pixmap(24,24)))
, m_liveTitle(new QLabel(tr("LIVE_BACKUPS")))
, m_liveDescription(new QLabel(tr("LIVE_DESCRIPTION")))
, m_folderSync(new QLabel(tr("YOUR_FOLDER_SYNC")))
{
setDefaultSettings();
setLayout();
connect(m_liveAccountButton, &CustomButton::clicked, this, &NMCAccountSettings::slotAddFolder);
}

void NMCAccountSettings::setDefaultSettings()
{
//Set default settings
getUi()->encryptionMessage->setCloseButtonVisible(true);
getUi()->selectiveSyncStatus->setVisible(false);
getUi()->selectiveSyncNotification->setVisible(false);
getUi()->accountStatus->setVisible(false);
getUi()->bigFolderUi->setVisible(false);

getUi()->gridLayout->setSpacing(8);
}

void NMCAccountSettings::setLayout()
{
//Fix layout
getUi()->storageGroupBox->removeWidget(getUi()->quotaInfoLabel);
getUi()->storageGroupBox->removeWidget(getUi()->quotaProgressBar);

getUi()->gridLayout->removeWidget(getUi()->encryptionMessage);
getUi()->gridLayout->addWidget(getUi()->encryptionMessage, 0, 0);

//getUi()->gridLayout->addWidget(new QLabel(""), 1, 0); //Spacer

//Title
m_folderSync->setStyleSheet("font-size: 15px; font-weight: 600; padding: 8px;"); //Semi-bold
m_folderSync->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
getUi()->gridLayout->addWidget(m_folderSync, 1, 0);

//Live backup area encryptionMessage
auto *liveHLayout = new QHBoxLayout(this);
liveHLayout->setContentsMargins(8,8,8,8);
auto *liveVLayout = new QVBoxLayout(this);
auto *liveWidget = new QWidget(this);

liveWidget->setStyleSheet("QWidget {background-color: white;border-radius: 4px;}");
liveWidget->setLayout(liveHLayout);
liveHLayout->addLayout(liveVLayout);

liveHLayout->addSpacerItem(new QSpacerItem(1,1, QSizePolicy::Expanding, QSizePolicy::Fixed));

const QString styleSheet("QPushButton{ font-size: %5px; border: %1px solid; border-color: black; border-radius: 4px; background-color: %2; color: %3;} QPushButton:hover { background-color: %4; }" );
m_liveAccountButton->setStyleSheet(styleSheet.arg("0","#E20074","white", "#c00063", "13"));
m_liveAccountButton->setFixedSize(180, 32);
m_liveAccountButton->setLeftIconMargin(4);
liveHLayout->addWidget(m_liveAccountButton);

liveVLayout->addWidget(m_liveTitle);
m_liveTitle->setStyleSheet("font-size: 15px; font-weight: 600;"); //Semi-bold
liveVLayout->addWidget(m_liveDescription);
m_liveDescription->setStyleSheet("font-size: 13px;");
m_liveDescription->setText("Synchronisieren Sie weitere beliebiege lokale Ordner in ihre MagentaCLOUD und schützen Sie damit ihre Onhalte kontienuierlich.");
m_liveDescription->setWordWrap(true);
m_liveDescription->setFixedWidth(450);

getUi()->gridLayout->addWidget(liveWidget, 4, 0);


//Storage area
auto *magentaHLayout = new QHBoxLayout(this);
magentaHLayout->setSpacing(32);

auto *quotaVLayout = new QVBoxLayout(this);
quotaVLayout->setSpacing(4);
auto *quota = new QLabel(this);
quota->setText(tr("USED_STORAGE_%1").arg(QString::number(getUi()->quotaProgressBar->value() > 0 ? getUi()->quotaProgressBar->value() : 0)));

quotaVLayout->addSpacerItem(new QSpacerItem(1,12, QSizePolicy::Fixed, QSizePolicy::Fixed));
quotaVLayout->addWidget(getUi()->quotaInfoLabel);
getUi()->quotaInfoLabel->setStyleSheet("QLabel{font-size: 18px; padding: 8px;}");
quotaVLayout->addWidget(getUi()->quotaProgressBar);
getUi()->quotaProgressBar->setStyleSheet("QProgressBar {"
" background-color: #e5e5e5;"
" color: black;"
" border-width: 1px;"
" border-color: black;"
" border-radius: 4px;"
"}"

"QProgressBar::chunk {"
" background-color: #ea0a8e; }");
getUi()->quotaProgressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
quotaVLayout->addWidget(quota);
quota->setStyleSheet("font-size: 13px; padding: 8px;");
quotaVLayout->addSpacerItem(new QSpacerItem(1,20, QSizePolicy::Fixed, QSizePolicy::Fixed));

magentaHLayout->addLayout(quotaVLayout);

auto *storageLinkButton = new QPushButton(tr("STORAGE_EXTENSION"), this);
storageLinkButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
storageLinkButton->setStyleSheet("QPushButton {"
" height: 32px;"
" width: 180px;"
" border: 1px solid black;"
" background-color: #ededed;"
" font-size: 13px;"
" border-radius: 4px;"
"} QPushButton::hover {"
" background-color: white;"
"}");
connect(storageLinkButton, &QPushButton::clicked, this, [](){
QDesktopServices::openUrl(QUrl("https://cloud.telekom-dienste.de/tarife"));
});
magentaHLayout->addWidget(storageLinkButton);
magentaHLayout->addSpacerItem(new QSpacerItem(8,1, QSizePolicy::Fixed, QSizePolicy::Fixed));

getUi()->gridLayout->addLayout(magentaHLayout, 5, 0);
}

} // namespace OCC
109 changes: 109 additions & 0 deletions src/gui/nmcgui/nmcaccountsettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* 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_ACCOUNTSETTINGSMAGENTA_H
#define MIRALL_ACCOUNTSETTINGSMAGENTA_H

#include "QtWidgets/qpushbutton.h"
#include <accountsettings.h>
#include <QPushButton>
#include <QIcon>
#include <QPainter>

namespace OCC {

/**
* @brief The CustomButton class is a QPushButton with an additional left icon.
* @ingroup gui
*/
class CustomButton : public QPushButton {
public:
/**
* @brief Constructs a CustomButton.
* @param text The button text.
* @param icon The button icon.
* @param parent The parent widget.
*/
explicit CustomButton(const QString &text, const QIcon &icon, QWidget *parent = nullptr)
: QPushButton(text, parent)
, icon_(icon)
{
setIconSize(QSize(24, 24));
}

/**
* @brief Sets the left margin for the icon.
* @param margin The left margin for the icon.
*/
void setLeftIconMargin(int margin){
m_leftMargin = margin;
}

protected:
void paintEvent(QPaintEvent *event) override {
QPushButton::paintEvent(event);

if (!icon_.isNull()) {
QRect iconRect = QRect(m_leftMargin, // left margin
(height() - iconSize().height()) / 2, // vertical center
iconSize().width(),
iconSize().height());

QPainter painter(this);
painter.drawPixmap(iconRect, icon_.pixmap(iconSize()));
}
}

private:
QIcon icon_;
int m_leftMargin = 4;
};

/**
* @brief The NMCAccountSettings class represents the account settings for a specific type.
* @ingroup gui
*/
class NMCAccountSettings : public AccountSettings
{
Q_OBJECT

public:
/**
* @brief Constructs NMCAccountSettings.
* @param accountState The account state associated with the settings.
* @param parent The parent widget.
*/
explicit NMCAccountSettings(AccountState *accountState, QWidget *parent = nullptr);
~NMCAccountSettings() = default;

private:
/**
* @brief Sets default settings for NMCAccountSettings.
*/
void setDefaultSettings();

/**
* @brief Sets the layout for NMCAccountSettings.
*/
void setLayout();

private:
CustomButton *m_liveAccountButton = nullptr;
QLabel *m_liveTitle = nullptr;
QLabel *m_liveDescription = nullptr;
QLabel *m_folderSync = nullptr;
};

} // namespace OCC
#endif // MIRALL_ACCOUNTSETTINGSMAGENTA_H
6 changes: 3 additions & 3 deletions src/gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "theme.h"
#include "generalsettings.h"
#include "networksettings.h"
#include "accountsettings.h"
#include "nmcgui/nmcaccountsettings.h"
#include "configfile.h"
#include "progressdispatcher.h"
#include "owncloudgui.h"
Expand Down Expand Up @@ -243,7 +243,7 @@ void SettingsDialog::accountAdded(AccountState *s)
}

_toolBar->insertAction(_toolBar->actions().at(0), accountAction);
auto accountSettings = new AccountSettings(s, this);
auto accountSettings = new NMCAccountSettings(s, this);
QString objectName = QLatin1String("accountSettings_");
objectName += s->account()->displayName();
accountSettings->setObjectName(objectName);
Expand Down Expand Up @@ -305,7 +305,7 @@ void SettingsDialog::slotAccountDisplayNameChanged()
void SettingsDialog::accountRemoved(AccountState *s)
{
for (auto it = _actionGroupWidgets.begin(); it != _actionGroupWidgets.end(); ++it) {
auto as = qobject_cast<AccountSettings *>(*it);
auto as = qobject_cast<NMCAccountSettings *>(*it);
if (!as) {
continue;
}
Expand Down

0 comments on commit 4a03598

Please sign in to comment.