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
7 changes: 7 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ endif()
configure_file(${CMAKE_SOURCE_DIR}/theme.qrc.in ${CMAKE_SOURCE_DIR}/theme.qrc)
set(theme_dir ${CMAKE_SOURCE_DIR}/theme)

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

set(client_UI_SRCS
accountsettings.ui
conflictdialog.ui
Expand Down Expand Up @@ -259,6 +262,10 @@ set(client_SRCS
integration/fileactionsmodel.cpp
)

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

if (NOT DISABLE_ACCOUNT_MIGRATION)
list(APPEND client_SRCS
legacyaccountselectiondialog.h
Expand Down
108 changes: 108 additions & 0 deletions src/gui/nmcgui/nmcsettingsdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* 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 "nmcsettingsdialog.h"
#include <QBoxLayout>
#include <QLabel>
#include <QToolBar>
#include "settingsdialog.h"

namespace OCC {

NMCSettingsDialog::NMCSettingsDialog(ownCloudGui *gui, QWidget *parent)
: SettingsDialog(gui, parent)
{
setLayout();

// The window has no background widget, use palette
// QPalette palette;
// palette.setColor(QPalette::Window, QColor("#F3f3f3"));
// setPalette(palette);

setFixedSize(760,760);

getToolBar()->setFixedHeight(92); // 76px button height + 8 + 8 margin top and bottom
getToolBar()->setContentsMargins(8, 0, 8, 0); // Left margin not accepted, Qt bug?
}

void NMCSettingsDialog::slotAccountAvatarChanged()
{
//Intercept the base class slot, so the round avatar is not set. (dont pass to base class)
//Fix Account button size, for ech new created account
fixAccountButton();
}

void OCC::NMCSettingsDialog::setLayout() const
{
//Fix network and general settings button size
const auto actions = getToolBar()->actions();
for(auto *action : actions)
{
if((action->text() == QCoreApplication::translate("OCC::SettingsDialog","General") || action->text() == QCoreApplication::tr("General")) ||
(action->text() == QCoreApplication::translate("OCC::SettingsDialog","Account") || action->text() == QCoreApplication::tr("Account")))
{
auto *widget = getToolBar()->widgetForAction(action);
if(widget)
{
widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
widget->setFixedSize(76, 76);
}
}
}

//Fix initial account button size and stylesheet
fixAccountButton();
}

void NMCSettingsDialog::fixAccountButton() const
{
auto *toolbar = getToolBar();
if (!toolbar) {
return;
}

const auto actions = toolbar->actions();
if (actions.isEmpty()) {
return;
}

bool hasLeftSpacer = false;
for (auto *action : actions) {
auto *widget = toolbar->widgetForAction(action);

Check warning on line 82 in src/gui/nmcgui/nmcsettingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this variable a pointer-to-const. The current type of "widget" is "class QWidget *".

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ5kibKfZRembQO_yQYq&open=AZ5kibKfZRembQO_yQYq&pullRequest=434
if (widget && widget->objectName() == QLatin1String("spacer_left")) {
hasLeftSpacer = true;
break;
}
}

if (!hasLeftSpacer) {
auto *spacer = new QWidget(toolbar);
spacer->setFixedWidth(16);
spacer->setObjectName(QStringLiteral("spacer_left"));
spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
toolbar->insertWidget(actions.first(), spacer);
}

for (auto *action : toolbar->actions()) {
if (action->text() == QCoreApplication::translate("OCC::SettingsDialog", "Account")
|| action->text() == QCoreApplication::tr("Account")) {
if (auto *widget = toolbar->widgetForAction(action)) {
widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
widget->setFixedSize(152, 76);
}
}
}
}

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

#include <settingsdialog.h>

namespace OCC {

/**
* @brief The NMCSettingsDialog class
*
* This class represents the settings dialog specific to the Magenta theme.
* It inherits from SettingsDialog and provides additional functionalities
* or customizations related to the Magenta theme.
*
* @ingroup gui
*/
class NMCSettingsDialog : public SettingsDialog
{
Q_OBJECT

public:
/**
* @brief Constructor for NMCSettingsDialog
*
* @param gui Pointer to the ownCloudGui instance.
* @param parent Pointer to the parent QWidget (default is nullptr).
*/
explicit NMCSettingsDialog(ownCloudGui *gui, QWidget *parent = nullptr);

/**
* @brief Destructor for NMCSettingsDialog
*/
~NMCSettingsDialog() = default;

public slots:
/**
* @brief Slot for handling changes in the account avatar
*/
void slotAccountAvatarChanged();

Check warning on line 53 in src/gui/nmcgui/nmcsettingsdialog.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Annotate this function with "override" or "final".

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ5kibNDZRembQO_yQYs&open=AZ5kibNDZRembQO_yQYs&pullRequest=434

// NMCGuiInterface interface
protected:
/**
* @brief Sets the layout for the NMCSettingsDialog
*/
void setLayout() const;

Check failure on line 60 in src/gui/nmcgui/nmcsettingsdialog.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this member function so that it doesn't hide an inherited non-virtual function, or make it virtual in the base class "QWidget".

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ5kibNDZRembQO_yQYr&open=AZ5kibNDZRembQO_yQYr&pullRequest=434

private:
/**
* @brief Fixes the appearance of the account button
*/
void fixAccountButton() const;
};

} // namespace OCC
#endif // MIRALL_SETTINGSDIALOGMAGENTA_H
3 changes: 2 additions & 1 deletion src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "owncloudsetupwizard.h"
#include "progressdispatcher.h"
#include "settingsdialog.h"
#include "nmcgui/nmcsettingsdialog.h"
#include "theme.h"
#include "wheelhandler.h"
#include "syncconflictsmodel.h"
Expand Down Expand Up @@ -621,7 +622,7 @@ void ownCloudGui::slotShowGuiMessage(const QString &title, const QString &messag
void ownCloudGui::slotShowSettings()
{
if (_settingsDialog.isNull()) {
_settingsDialog = new SettingsDialog(this);
_settingsDialog = new NMCSettingsDialog(this);
_settingsDialog->setAttribute(Qt::WA_DeleteOnClose, true);

#ifdef Q_OS_MACOS
Expand Down
12 changes: 10 additions & 2 deletions src/gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include "settingsdialog.h"
#include "QtWidgets/qmainwindow.h"

#include "folderman.h"
#include "theme.h"
Expand Down Expand Up @@ -119,7 +120,7 @@
host = fm.elidedText(host, Qt::ElideMiddle, width);
user = fm.elidedText(user, Qt::ElideRight, width);
}
return QStringLiteral("%1\n%2").arg(user, host);
return QStringLiteral("%1").arg(user);
}
}

Expand Down Expand Up @@ -191,6 +192,12 @@
_stack->addWidget(generalSettings);
_stack->setStyleSheet(QStringLiteral("QStackedWidget { background: transparent; }"));

// Adds space between general and network actions
auto *spacer2 = new QWidget();

Check failure on line 196 in src/gui/settingsdialog.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ5kibNoZRembQO_yQYt&open=AZ5kibNoZRembQO_yQYt&pullRequest=434
spacer2->setFixedWidth(8);
spacer2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
_toolBar->addWidget(spacer2);

// Connect styleChanged events to our widgets, so they can adapt (Dark-/Light-Mode switching)
connect(this, &SettingsDialog::styleChanged, generalSettings, &GeneralSettings::slotStyleChanged);

Expand Down Expand Up @@ -339,7 +346,7 @@
updateAccountAvatar(s->account().data());

if (!brandingSingleAccount) {
accountAction->setToolTip(s->account()->displayName());
accountAction->setToolTip(shortDisplayNameForSettings(s->account().data(), static_cast<int>(height * buttonSizeRatio)));
accountAction->setIconText(shortDisplayNameForSettings(s->account().data(), static_cast<int>(height * buttonSizeRatio)));
}

Expand Down Expand Up @@ -410,6 +417,7 @@
QString displayName = account->displayName();
action->setText(displayName);
auto height = _toolBar->sizeHint().height();
action->setToolTip(shortDisplayNameForSettings(account, static_cast<int>(height * buttonSizeRatio)));
action->setIconText(shortDisplayNameForSettings(account, static_cast<int>(height * buttonSizeRatio)));
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/gui/settingsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ class SettingsDialog : public QDialog

QWidget* currentPage();

QToolBar *getToolBar() const
{
return _toolBar;
}

public slots:
void showFirstPage();
void showAccount(OCC::AccountState *account);
void setInitialAccount(OCC::AccountState *account);
void showIssuesList(OCC::AccountState *account);
void slotSwitchPage(QAction *action);
void slotAccountAvatarChanged();
virtual void slotAccountAvatarChanged();
void slotAccountDisplayNameChanged();

signals:
Expand All @@ -67,11 +72,12 @@ private slots:
void accountAdded(OCC::AccountState *);
void accountRemoved(OCC::AccountState *);

private:
protected:
void customizeStyle();
void requestStyleUpdate();
void updateAccountAvatar(const Account *account);

private:
QAction *createColorAwareAction(const QString &iconName, const QString &fileName);
QAction *createActionWithIcon(const QIcon &icon, const QString &text, const QString &iconPath = QString());

Expand Down
12 changes: 6 additions & 6 deletions theme/account.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion theme/network.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading