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.13] nmc/2003-Main_Settings_Dialog #286

Open
wants to merge 3 commits into
base: stable-3.13
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
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/
6 changes: 5 additions & 1 deletion 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)

# CfAPI Shell Extensions
Expand Down Expand Up @@ -303,9 +306,10 @@ 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)
endif()

feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES INCLUDE_QUIET_PACKAGES)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES INCLUDE_QUIET_PACKAGES)
Binary file added nmctheme_v1.rcc
Binary file not shown.
10 changes: 9 additions & 1 deletion src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ find_package(Qt5 REQUIRED COMPONENTS Widgets Svg Qml Quick QuickControls2 QuickW
find_package(KF5Archive REQUIRED)
find_package(KF5GuiAddons)

#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 @@ -261,6 +264,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 Expand Up @@ -623,6 +630,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 Expand Up @@ -785,4 +793,4 @@ if(NOT BUILD_OWNCLOUD_OSX_BUNDLE AND NOT WIN32)
endif(SharedMimeInfo_FOUND)
endif()

configure_file(configgui.h.in ${CMAKE_CURRENT_BINARY_DIR}/configgui.h)
configure_file(configgui.h.in ${CMAKE_CURRENT_BINARY_DIR}/configgui.h)
11 changes: 10 additions & 1 deletion src/gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ int main(int argc, char **argv)
#ifdef Q_OS_WIN
SetDllDirectory(L"");
#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 Expand Up @@ -188,4 +197,4 @@ int main(int argc, char **argv)
}

return app.exec();
}
}
89 changes: 89 additions & 0 deletions src/gui/nmcgui/nmcsettingsdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* 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 "QtWidgets/qboxlayout.h"
#include "QtWidgets/qlabel.h"
#include "QtWidgets/qtoolbar.h"
#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(750,760);

getToolBar()->setFixedHeight(91); ///75px button height + 8 + 8 margin top and bottom
getToolBar()->setStyleSheet("QToolBar{background: #f3f3f3; background-color: #f3f3f3; border-width: 0px; border-color: none;}");
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","Network") || action->text() == QCoreApplication::tr("Network")) ||
(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(75, 75);
widget->setStyleSheet(
"QToolButton { border: none; background-color: #f3f3f3; border-radius: 4px; font-size: 13px; padding: 8px;}"
"QToolButton:hover { background-color: #e5e5e5; }"
);
}
}
}

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

void NMCSettingsDialog::fixAccountButton() const
{
auto action = getToolBar()->actions().at(0);
auto *widget = getToolBar()->widgetForAction(action);
if(widget)
{
widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
widget->setFixedSize(128, 75);
widget->setStyleSheet(
"QToolButton { border: none; background-color: #f3f3f3; border-radius: 4px; font-size: 13px; padding: 8px;}"
"QToolButton:hover { background-color: #e5e5e5; }"
);
}
}

} // 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();

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

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 @@ -25,6 +25,7 @@
#include "guiutility.h"
#include "logbrowser.h"
#include "logger.h"
#include "nmcgui/nmcsettingsdialog.h"
#include "openfilemanager.h"
#include "owncloudsetupwizard.h"
#include "progressdispatcher.h"
Expand Down Expand Up @@ -577,7 +578,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);
_settingsDialog->show();
}
Expand Down
32 changes: 21 additions & 11 deletions src/gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

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

#include "folderman.h"
Expand Down Expand Up @@ -71,7 +72,7 @@ QString shortDisplayNameForSettings(OCC::Account *account, int width)
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 @@ -124,6 +125,13 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
auto *generalSettings = new GeneralSettings;
_ui->stack->addWidget(generalSettings);

//NMC customization
//Adds space between general and network actions
auto *spacer2 = new QWidget();
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 @@ -237,7 +245,7 @@ void SettingsDialog::accountAdded(AccountState *s)
const auto accountAction = createColorAwareAction(QLatin1String(":/client/theme/account.svg"), actionText);

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 @@ -297,6 +305,7 @@ void SettingsDialog::slotAccountDisplayNameChanged()
action->setText(displayName);
auto height = _toolBar->sizeHint().height();
action->setIconText(shortDisplayNameForSettings(account, static_cast<int>(height * buttonSizeRatio)));
action->setToolTip(shortDisplayNameForSettings(account, static_cast<int>(height * buttonSizeRatio)));
}
}
}
Expand Down Expand Up @@ -342,13 +351,13 @@ void SettingsDialog::customizeStyle()
QString background(palette().base().color().name());
_toolBar->setStyleSheet(TOOLBAR_CSS().arg(background, dark, highlightColor, highlightTextColor));

Q_FOREACH (QAction *a, _actionGroup->actions()) {
QIcon icon = Theme::createColorAwareIcon(a->property("iconPath").toString(), palette());
a->setIcon(icon);
auto *btn = qobject_cast<QToolButton *>(_toolBar->widgetForAction(a));
if (btn)
btn->setIcon(icon);
}
//Q_FOREACH (QAction *a, _actionGroup->actions()) {
// QIcon icon = Theme::createColorAwareIcon(a->property("iconPath").toString(), palette());
// a->setIcon(icon);
// auto *btn = qobject_cast<QToolButton *>(_toolBar->widgetForAction(a));
// if (btn)
// btn->setIcon(icon);
//}
}

class ToolButtonAction : public QWidgetAction
Expand Down Expand Up @@ -395,8 +404,9 @@ QAction *SettingsDialog::createActionWithIcon(const QIcon &icon, const QString &
QAction *SettingsDialog::createColorAwareAction(const QString &iconPath, const QString &text)
{
// all buttons must have the same size in order to keep a good layout
QIcon coloredIcon = Theme::createColorAwareIcon(iconPath, palette());
return createActionWithIcon(coloredIcon, text, iconPath);
//QIcon coloredIcon = Theme::createColorAwareIcon(iconPath, palette());
//return createActionWithIcon(coloredIcon, text, iconPath);
return createActionWithIcon(QIcon(iconPath), text, iconPath);
}

} // namespace OCC
10 changes: 8 additions & 2 deletions src/gui/settingsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,16 @@ class SettingsDialog : public QDialog

QWidget* currentPage();

QToolBar *getToolBar() const
{
return _toolBar;
}

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

signals:
Expand All @@ -74,9 +79,10 @@ private slots:
void accountAdded(OCC::AccountState *);
void accountRemoved(OCC::AccountState *);

private:
protected:
void customizeStyle();

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

Expand Down
Loading