diff --git a/CMakeLists.txt b/CMakeLists.txt index 27102a6f0e7cd..2434776e7b040 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") @@ -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) diff --git a/nmctheme_v1.rcc b/nmctheme_v1.rcc new file mode 100644 index 0000000000000..1e673f886e4f5 Binary files /dev/null and b/nmctheme_v1.rcc differ diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 9660bfb7ee7f2..0402a9c1a26c2 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -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() @@ -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 @@ -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 diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 6446876cd0f19..0b31ba4345277 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -1143,7 +1143,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()); } void AccountSettings::slotEnableCurrentFolder(bool terminate) @@ -1239,9 +1239,11 @@ void AccountSettings::slotUpdateQuota(qint64 total, qint64 used) const auto totalStr = Utility::octetsToString(total); const auto percentStr = Utility::compactFormatDouble(percent, 1); const auto toolTip = tr("%1 (%3%) of %2 in use. Some folders, including network mounted or shared folders, might have different limits.").arg(usedStr, totalStr, percentStr); - _ui->quotaInfoLabel->setText(tr("%1 of %2 in use").arg(usedStr, totalStr)); + //_ui->quotaInfoLabel->setText(tr("%1 of %2 in use").arg(usedStr, totalStr)); + _ui->quotaInfoLabel->setText(QCoreApplication::translate("", "%1_OF_%2").arg(usedStr, totalStr)); _ui->quotaInfoLabel->setToolTip(toolTip); _ui->quotaProgressBar->setToolTip(toolTip); + _ui->quotaInfoText->setText(QCoreApplication::translate("", "USED_STORAGE_%1").arg(percentStr)); } else { _ui->quotaProgressBar->setVisible(false); _ui->quotaInfoLabel->setToolTip({}); @@ -1253,6 +1255,8 @@ void AccountSettings::slotUpdateQuota(qint64 total, qint64 used) const auto usedStr = Utility::octetsToString(used); _ui->quotaInfoLabel->setText(tr("%1 in use").arg(usedStr)); } + + _ui->quotaInfoText->setText(QCoreApplication::translate("", "USED_STORAGE_%1").arg(QString::number(0))); } } diff --git a/src/gui/accountsettings.h b/src/gui/accountsettings.h index 8981f1dffe6f8..e3ccf4f1334a3 100644 --- a/src/gui/accountsettings.h +++ b/src/gui/accountsettings.h @@ -115,6 +115,7 @@ protected slots: void slotSelectiveSyncChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles); void slotPossiblyUnblacklistE2EeFoldersAndRestartSync(); + void checkClientSideEncryptionState(); //NMC customization, we need to access it private slots: void updateBlackListAndScheduleFolderSync(const QStringList &blackList, OCC::Folder *folder, const QStringList &foldersToRemoveFromBlacklist) const; @@ -129,9 +130,14 @@ private slots: void initializeE2eEncryption(); void resetE2eEncryption(); - 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); diff --git a/src/gui/accountsettings.ui b/src/gui/accountsettings.ui index 2db413221b169..68e3881cdd2a9 100644 --- a/src/gui/accountsettings.ui +++ b/src/gui/accountsettings.ui @@ -14,7 +14,7 @@ Form - + @@ -66,6 +66,25 @@ + + + + + 0 + 0 + + + + 0% of memory used + + + Qt::PlainText + + + false + + + diff --git a/src/gui/main.cpp b/src/gui/main.cpp index e91fb3be9a1f4..f9a92fda2d1be 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -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); diff --git a/src/gui/nmcgui/nmcaccountsettings.cpp b/src/gui/nmcgui/nmcaccountsettings.cpp new file mode 100644 index 0000000000000..38e697b53aeb0 --- /dev/null +++ b/src/gui/nmcgui/nmcaccountsettings.cpp @@ -0,0 +1,147 @@ +/* + * 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 "../common/utility.h" +#include "guiutility.h" +#include "qdesktopservices.h" + + +namespace OCC { + +NMCAccountSettings::NMCAccountSettings(AccountState *accountState, QWidget *parent) + : AccountSettings(accountState, parent) + , m_liveAccountButton(new CustomButton(QCoreApplication::translate("", "ADD_LIVE_BACKUP"), QIcon(QLatin1String(":/client/theme/NMCIcons/action-add.svg")).pixmap(24,24))) + , m_liveTitle(new QLabel(QCoreApplication::translate("", "LIVE_BACKUPS"))) + , m_liveDescription(new QLabel(QCoreApplication::translate("", "LIVE_DESCRIPTION"))) + , m_folderSync(new QLabel(QCoreApplication::translate("", "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()->storageGroupBox->removeWidget(getUi()->quotaInfoText); + + 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(QCoreApplication::translate("", "LIVE_BACKUPS_DESCRIPTION")); + 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); + + quotaVLayout->addSpacerItem(new QSpacerItem(1,12, QSizePolicy::Fixed, QSizePolicy::Fixed)); + quotaVLayout->addWidget(getUi()->quotaInfoLabel); + getUi()->quotaInfoLabel->setStyleSheet("QLabel{font-size: 18px; padding: 8px; font-weight: 500;}"); + 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(getUi()->quotaInfoText); + getUi()->quotaInfoText->setStyleSheet("QLabel{font-size: 13px; padding: 8px;}"); + + quotaVLayout->addSpacerItem(new QSpacerItem(1,20, QSizePolicy::Fixed, QSizePolicy::Fixed)); + + magentaHLayout->addLayout(quotaVLayout); + + auto *storageLinkButton = new QPushButton(QCoreApplication::translate("", "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); + + //We need these, because our widget becomes visibe, when we add it to our layout (due to parent), but in accountsettings its forced to be invisible at first. + //We do here the same and check if the visibility is needed or not. + getUi()->encryptionMessage->hide(); + checkClientSideEncryptionState(); +} + +} // namespace OCC \ No newline at end of file diff --git a/src/gui/nmcgui/nmcaccountsettings.h b/src/gui/nmcgui/nmcaccountsettings.h new file mode 100644 index 0000000000000..ef90ae4de0fdb --- /dev/null +++ b/src/gui/nmcgui/nmcaccountsettings.h @@ -0,0 +1,112 @@ +/* + * 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 +#include +#include +#include + +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); + + //Its an icon within the button, but we disable it for now, because the text occupies to much space, and the button shod be increased in size to fir the size, + //but we dont want to change the button size for cosmetic reasons. + + // 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 \ No newline at end of file diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index a59314a15ce73..ea898dfb20f6b 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -20,6 +20,7 @@ #include "generalsettings.h" #include "networksettings.h" #include "accountsettings.h" +#include "nmcgui/nmcaccountsettings.h" #include "configfile.h" #include "progressdispatcher.h" #include "owncloudgui.h" @@ -243,7 +244,8 @@ void SettingsDialog::accountAdded(AccountState *s) } _toolBar->insertAction(_toolBar->actions().at(0), accountAction); - auto accountSettings = new AccountSettings(s, this); + // auto accountSettings = new AccountSettings(s, this); + auto accountSettings = new NMCAccountSettings(s, this); QString objectName = QLatin1String("accountSettings_"); objectName += s->account()->displayName(); accountSettings->setObjectName(objectName); @@ -305,7 +307,8 @@ void SettingsDialog::slotAccountDisplayNameChanged() void SettingsDialog::accountRemoved(AccountState *s) { for (auto it = _actionGroupWidgets.begin(); it != _actionGroupWidgets.end(); ++it) { - auto as = qobject_cast(*it); + // auto as = qobject_cast(*it); + auto as = qobject_cast(*it); if (!as) { continue; }