From 86202df40876e7af8b3f251816f6376c999aab11 Mon Sep 17 00:00:00 2001 From: Elsie Hupp <9206310+elsiehupp@users.noreply.github.com> Date: Fri, 12 Mar 2021 18:05:25 -0500 Subject: [PATCH] Squash and remove extra files Signed-off-by: Elsie Hupp <9206310+elsiehupp@users.noreply.github.com> --- src/gui/CMakeLists.txt | 6 ++++ src/gui/foregroundbackground_cocoa.h | 42 ++++++++++++++++++++++++ src/gui/foregroundbackground_cocoa.mm | 34 +++++++++++++++++++ src/gui/foregroundbackground_interface.h | 35 ++++++++++++++++++++ src/gui/foregroundbackground_linux.cpp | 27 +++++++++++++++ src/gui/foregroundbackground_mac.mm | 26 +++++++++++++++ src/gui/foregroundbackground_windows.cpp | 27 +++++++++++++++ src/gui/settingsdialog.cpp | 17 ++++++++-- src/gui/settingsdialog.h | 2 ++ 9 files changed, 214 insertions(+), 2 deletions(-) create mode 100644 src/gui/foregroundbackground_cocoa.h create mode 100644 src/gui/foregroundbackground_cocoa.mm create mode 100644 src/gui/foregroundbackground_interface.h create mode 100644 src/gui/foregroundbackground_linux.cpp create mode 100644 src/gui/foregroundbackground_mac.mm create mode 100644 src/gui/foregroundbackground_windows.cpp diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 13cde2ff9b86f..861f265f7bd31 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -149,6 +149,8 @@ endif() IF( APPLE ) list(APPEND client_SRCS cocoainitializer_mac.mm) + list(APPEND client_SRCS foregroundbackground_mac.mm) + list(APPEND client_SRCS foregroundbackground_cocoa.mm) list(APPEND client_SRCS socketapisocket_mac.mm) list(APPEND client_SRCS systray.mm) @@ -164,6 +166,10 @@ IF( APPLE ) DESTINATION "${OWNCLOUD_OSX_BUNDLE}/Contents/Frameworks" USE_SOURCE_PERMISSIONS) endif() +ELSEIF( WIN32 ) + list(APPEND client_SRCS foregroundbackground_windows.cpp) +ELSEIF( LINUX ) + list(APPEND client_SRCS foregroundbackground_linux.cpp) ENDIF() IF( NOT WIN32 AND NOT APPLE ) diff --git a/src/gui/foregroundbackground_cocoa.h b/src/gui/foregroundbackground_cocoa.h new file mode 100644 index 0000000000000..c21dbb75f6484 --- /dev/null +++ b/src/gui/foregroundbackground_cocoa.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) by Elsie Hupp + * + * 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. + */ + +#import + +/** +* @brief CocoaProcessType provides methods for moving the application between +* the background and foreground. +* @ingroup gui +*/ + +#ifndef COCOAPROCESSTYPE_H +#define COCOAPROCESSTYPE_H + +@interface CocoaProcessType : NSApplication + +/** + * @brief CocoaProcessTypeToForeground() enables the macOS menubar and dock icon, which are necessary for a maximized window to be able to exit full screen. + * @ingroup gui + */ ++ (void)ToForeground; + +/** + * @brief CocoaProcessTypeToBackground() disables the macOS menubar and dock icon, so that the application will only be present as a menubar icon. + * @ingroup gui + */ ++ (void)ToBackground; + +@end + +#endif \ No newline at end of file diff --git a/src/gui/foregroundbackground_cocoa.mm b/src/gui/foregroundbackground_cocoa.mm new file mode 100644 index 0000000000000..be790d1b9b8c6 --- /dev/null +++ b/src/gui/foregroundbackground_cocoa.mm @@ -0,0 +1,34 @@ +/* + * Copyright (C) by Elsie Hupp + * + * 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 "foregroundbackground_cocoa.h" +#include "common/utility.h" + +@implementation CocoaProcessType + ++ (void)ToForeground +{ + NSApplicationLoad(); + ProcessSerialNumber processSerialNumber = { 0, kCurrentProcess }; + TransformProcessType(&processSerialNumber, kProcessTransformToForegroundApplication); +} + ++ (void)ToBackground +{ + NSApplicationLoad(); + ProcessSerialNumber processSerialNumber = { 0, kCurrentProcess }; + TransformProcessType(&processSerialNumber, kProcessTransformToUIElementApplication); +} + +@end \ No newline at end of file diff --git a/src/gui/foregroundbackground_interface.h b/src/gui/foregroundbackground_interface.h new file mode 100644 index 0000000000000..bf7492273af02 --- /dev/null +++ b/src/gui/foregroundbackground_interface.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) by Elsie Hupp + * + * 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. + */ + +/** +* @brief ForegroundBackgroundInterface allows ForegroundBackground to be implemented differently per platform +* @ingroup gui +*/ + +#ifndef FOREGROUNDBACKGROUND_INTERFACE_H +#define FOREGROUNDBACKGROUND_INTERFACE_H + + /** + * @brief ToForeground() enables the macOS menubar and dock icon, which are necessary for a maximized window to be able to exit full screen. + * @ingroup gui + */ + void ToForeground(); + + /** + * @brief TypeToBackground() disables the macOS menubar and dock icon, so that the application will only be present as a menubar icon. + * @ingroup gui + */ + void ToBackground(); + +#endif \ No newline at end of file diff --git a/src/gui/foregroundbackground_linux.cpp b/src/gui/foregroundbackground_linux.cpp new file mode 100644 index 0000000000000..736727fcdf75a --- /dev/null +++ b/src/gui/foregroundbackground_linux.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (C) by Elsie Hupp + * + * 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 "foregroundbackground_interface.h" + +void ToForeground() +{ + // To be implemented + return; +} + +void ToBackground() +{ + // To be implemented + return; +} diff --git a/src/gui/foregroundbackground_mac.mm b/src/gui/foregroundbackground_mac.mm new file mode 100644 index 0000000000000..f866e701d0cab --- /dev/null +++ b/src/gui/foregroundbackground_mac.mm @@ -0,0 +1,26 @@ +/* + * Copyright (C) by Elsie Hupp + * + * 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 "foregroundbackground_interface.h" +#include "foregroundbackground_cocoa.h" + +void ToForeground() +{ + [CocoaProcessType ToForeground]; +} + +void ToBackground() +{ + [CocoaProcessType ToBackground]; +} diff --git a/src/gui/foregroundbackground_windows.cpp b/src/gui/foregroundbackground_windows.cpp new file mode 100644 index 0000000000000..736727fcdf75a --- /dev/null +++ b/src/gui/foregroundbackground_windows.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (C) by Elsie Hupp + * + * 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 "foregroundbackground_interface.h" + +void ToForeground() +{ + // To be implemented + return; +} + +void ToBackground() +{ + // To be implemented + return; +} diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index cb503ef14eb48..c45861af6b7a1 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -14,6 +14,7 @@ #include "settingsdialog.h" #include "ui_settingsdialog.h" +#include "foregroundbackground_interface.h" #include "folderman.h" #include "theme.h" @@ -26,6 +27,7 @@ #include "accountmanager.h" #include +#include #include #include #include @@ -85,13 +87,20 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) , _ui(new Ui::SettingsDialog) , _gui(gui) { + + ToForeground(); + ConfigFile cfg; _ui->setupUi(this); + + _menuBar = new QMenuBar(parent); + _toolBar = new QToolBar; _toolBar->setIconSize(QSize(32, 32)); _toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - layout()->setMenuBar(_toolBar); + // layout()->addWidget(_toolBar); + layout()->setMenuBar(_menuBar); // People perceive this as a Window, so also make Ctrl+W work auto *closeWindowAction = new QAction(this); @@ -158,12 +167,14 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) customizeStyle(); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint & Qt::Window); + cfg.restoreGeometry(this); } SettingsDialog::~SettingsDialog() { + ToBackground(); delete _ui; } @@ -178,6 +189,7 @@ void SettingsDialog::reject() ConfigFile cfg; cfg.saveGeometry(this); QDialog::reject(); + ToBackground(); } void SettingsDialog::accept() @@ -185,6 +197,7 @@ void SettingsDialog::accept() ConfigFile cfg; cfg.saveGeometry(this); QDialog::accept(); + ToBackground(); } void SettingsDialog::changeEvent(QEvent *e) diff --git a/src/gui/settingsdialog.h b/src/gui/settingsdialog.h index f46208d533a73..b4e3f4732934d 100644 --- a/src/gui/settingsdialog.h +++ b/src/gui/settingsdialog.h @@ -23,6 +23,7 @@ class QAction; class QActionGroup; +class QMenuBar; class QToolBar; class QStandardItemModel; @@ -89,6 +90,7 @@ private slots: // case the account avatar changes QHash _actionForAccount; + QMenuBar *_menuBar; QToolBar *_toolBar; ownCloudGui *_gui;