mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Hide app icon from dock on macOS
This commit is contained in:
parent
16557eb286
commit
d2fc2bbc6d
@ -117,6 +117,7 @@ signals:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QString version() const;
|
QString version() const;
|
||||||
|
void showDockIcon(const bool show);
|
||||||
void exit();
|
void exit();
|
||||||
|
|
||||||
QPointF cursorPos() { return QCursor::pos(); }
|
QPointF cursorPos() { return QCursor::pos(); }
|
||||||
|
@ -84,6 +84,7 @@ ApplicationWindow {
|
|||||||
|
|
||||||
if(alwaysMinimize === "true"){
|
if(alwaysMinimize === "true"){
|
||||||
root.hide()
|
root.hide()
|
||||||
|
App.showDockIcon(false);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,9 +106,11 @@ ApplicationWindow {
|
|||||||
stackView.push("qrc:/qml/ScreenPlayApp/qml/Installed/Installed.qml", {
|
stackView.push("qrc:/qml/ScreenPlayApp/qml/Installed/Installed.qml", {
|
||||||
"sidebar": sidebar
|
"sidebar": sidebar
|
||||||
})
|
})
|
||||||
if (!App.settings.silentStart)
|
if (!App.settings.silentStart){
|
||||||
|
App.showDockIcon(true)
|
||||||
root.show()
|
root.show()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: noneContentItems
|
id: noneContentItems
|
||||||
@ -152,6 +155,7 @@ ApplicationWindow {
|
|||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
function onRequestRaise() {
|
function onRequestRaise() {
|
||||||
|
App.showDockIcon(true)
|
||||||
root.show()
|
root.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ Util.Popup {
|
|||||||
text: qsTr("Minimize ScreenPlay")
|
text: qsTr("Minimize ScreenPlay")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
applicationWindow.hide()
|
applicationWindow.hide()
|
||||||
|
App.showDockIcon(false)
|
||||||
root.close()
|
root.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,6 +86,7 @@ Util.Popup {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
settings.setValue("alwaysMinimize", true)
|
settings.setValue("alwaysMinimize", true)
|
||||||
settings.sync()
|
settings.sync()
|
||||||
|
App.showDockIcon(false)
|
||||||
applicationWindow.hide()
|
applicationWindow.hide()
|
||||||
root.close()
|
root.close()
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
#include "ScreenPlay/app.h"
|
#include "ScreenPlay/app.h"
|
||||||
|
#if defined(Q_OS_OSX)
|
||||||
|
#include "ScreenPlayUtil/macutils.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "steam/steam_qt_enums_generated.h"
|
#include "steam/steam_qt_enums_generated.h"
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
@ -332,4 +335,11 @@ bool App::setupKDE()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void App::showDockIcon(const bool show)
|
||||||
|
{
|
||||||
|
#if defined(Q_OS_OSX)
|
||||||
|
MacUtils::instance()->showDockIcon(show);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ set(QML
|
|||||||
qml/TrayIcon.qml)
|
qml/TrayIcon.qml)
|
||||||
|
|
||||||
set(SOURCES # cmake-format: sort
|
set(SOURCES # cmake-format: sort
|
||||||
inc/public/ScreenPlayUtil/httpfileserver.cpp src/contenttypes.cpp src/util.cpp)
|
inc/public/ScreenPlayUtil/httpfileserver.cpp src/contenttypes.cpp src/util.cpp src/macutils.mm)
|
||||||
|
|
||||||
set(HEADER
|
set(HEADER
|
||||||
# cmake-format: sort
|
# cmake-format: sort
|
||||||
@ -54,6 +54,7 @@ set(HEADER
|
|||||||
inc/public/ScreenPlayUtil/PropertyHelpers.h
|
inc/public/ScreenPlayUtil/PropertyHelpers.h
|
||||||
inc/public/ScreenPlayUtil/PtrPropertyHelpers.h
|
inc/public/ScreenPlayUtil/PtrPropertyHelpers.h
|
||||||
inc/public/ScreenPlayUtil/SingletonHelper.h
|
inc/public/ScreenPlayUtil/SingletonHelper.h
|
||||||
|
inc/public/ScreenPlayUtil/macutils.h
|
||||||
inc/public/ScreenPlayUtil/util.h)
|
inc/public/ScreenPlayUtil/util.h)
|
||||||
|
|
||||||
set(RESOURCES # cmake-format: sort
|
set(RESOURCES # cmake-format: sort
|
||||||
|
49
ScreenPlayUtil/inc/public/ScreenPlayUtil/macutils.h
Normal file
49
ScreenPlayUtil/inc/public/ScreenPlayUtil/macutils.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2020 Elias Steurer (Kelteseth)
|
||||||
|
** Contact: https://screen-play.app
|
||||||
|
**
|
||||||
|
** This file is part of ScreenPlay. ScreenPlay is licensed under a dual license in
|
||||||
|
** order to ensure its sustainability. When you contribute to ScreenPlay
|
||||||
|
** you accept that your work will be available under the two following licenses:
|
||||||
|
**
|
||||||
|
** $SCREENPLAY_BEGIN_LICENSE$
|
||||||
|
**
|
||||||
|
** #### Affero General Public License Usage (AGPLv3)
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Affero
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file "ScreenPlay License.md" included in the
|
||||||
|
** packaging of this App. Please review the following information to
|
||||||
|
** ensure the GNU Affero Lesser General Public License version 3 requirements
|
||||||
|
** will be met: https://www.gnu.org/licenses/agpl-3.0.en.html.
|
||||||
|
**
|
||||||
|
** #### Commercial License
|
||||||
|
** This code is owned by Elias Steurer. By changing/adding to the code you agree to the
|
||||||
|
** terms written in:
|
||||||
|
** * Legal/corporate_contributor_license_agreement.md - For corporate contributors
|
||||||
|
** * Legal/individual_contributor_license_agreement.md - For individual contributors
|
||||||
|
**
|
||||||
|
** #### Additional Limitations to the AGPLv3 and Commercial Lincese
|
||||||
|
** This License does not grant any rights in the trademarks,
|
||||||
|
** service marks, or logos.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** $SCREENPLAY_END_LICENSE
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class MacUtils : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
static MacUtils* macUtils;
|
||||||
|
MacUtils();
|
||||||
|
|
||||||
|
public:
|
||||||
|
static MacUtils* instance();
|
||||||
|
static void showDockIcon(const bool show);
|
||||||
|
};
|
@ -31,6 +31,7 @@ SystemTrayIcon {
|
|||||||
MenuItem {
|
MenuItem {
|
||||||
text: qsTr("Open ScreenPlay")
|
text: qsTr("Open ScreenPlay")
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
App.showDockIcon(true);
|
||||||
window.show()
|
window.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
62
ScreenPlayUtil/src/macutils.mm
Normal file
62
ScreenPlayUtil/src/macutils.mm
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2020 Elias Steurer (Kelteseth)
|
||||||
|
** Contact: https://screen-play.app
|
||||||
|
**
|
||||||
|
** This file is part of ScreenPlay. ScreenPlay is licensed under a dual license in
|
||||||
|
** order to ensure its sustainability. When you contribute to ScreenPlay
|
||||||
|
** you accept that your work will be available under the two following licenses:
|
||||||
|
**
|
||||||
|
** $SCREENPLAY_BEGIN_LICENSE$
|
||||||
|
**
|
||||||
|
** #### Affero General Public License Usage (AGPLv3)
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Affero
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file "ScreenPlay License.md" included in the
|
||||||
|
** packaging of this App. Please review the following information to
|
||||||
|
** ensure the GNU Affero Lesser General Public License version 3 requirements
|
||||||
|
** will be met: https://www.gnu.org/licenses/agpl-3.0.en.html.
|
||||||
|
**
|
||||||
|
** #### Commercial License
|
||||||
|
** This code is owned by Elias Steurer. By changing/adding to the code you agree to the
|
||||||
|
** terms written in:
|
||||||
|
** * Legal/corporate_contributor_license_agreement.md - For corporate contributors
|
||||||
|
** * Legal/individual_contributor_license_agreement.md - For individual contributors
|
||||||
|
**
|
||||||
|
** #### Additional Limitations to the AGPLv3 and Commercial Lincese
|
||||||
|
** This License does not grant any rights in the trademarks,
|
||||||
|
** service marks, or logos.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** $SCREENPLAY_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "ScreenPlayUtil/macutils.h"
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import <MacTypes.h>
|
||||||
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
|
MacUtils* MacUtils::macUtils = nullptr;
|
||||||
|
|
||||||
|
MacUtils::MacUtils()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MacUtils* MacUtils::instance()
|
||||||
|
{
|
||||||
|
if (!macUtils)
|
||||||
|
macUtils = new MacUtils;
|
||||||
|
return macUtils;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacUtils::showDockIcon(const bool show)
|
||||||
|
{
|
||||||
|
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||||
|
|
||||||
|
if (show) {
|
||||||
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||||
|
} else {
|
||||||
|
TransformProcessType(&psn, kProcessTransformToUIElementApplication);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user