Commit f7d3a26f authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

allow to have an Elisa icon in system tray and to close main window

BUG: 416170
parent 7c176e13
......@@ -13,5 +13,7 @@
<group name="PlayerSettings">
<entry key="ShowProgressOnTaskBar" type="Bool" >
</entry>
<entry key="ShowSystemTrayIcon" type="Bool" >
</entry>
</group>
</kcfg>
......@@ -311,6 +311,7 @@ void ElisaApplication::configChanged()
currentConfiguration->read();
Q_EMIT showProgressOnTaskBarChanged();
Q_EMIT showSystemTrayIconChanged();
}
ElisaUtils::EntryDataList ElisaApplication::checkFileListAndMakeAbsolute(const ElisaUtils::EntryDataList &filesList,
......@@ -550,4 +551,11 @@ bool ElisaApplication::showProgressOnTaskBar() const
return currentConfiguration->showProgressOnTaskBar();
}
bool ElisaApplication::showSystemTrayIcon() const
{
auto currentConfiguration = Elisa::ElisaConfiguration::self();
return currentConfiguration->showSystemTrayIcon();
}
#include "moc_elisaapplication.cpp"
......@@ -85,6 +85,10 @@ class ELISALIB_EXPORT ElisaApplication : public QObject
READ showProgressOnTaskBar
NOTIFY showProgressOnTaskBarChanged)
Q_PROPERTY(bool showSystemTrayIcon
READ showSystemTrayIcon
NOTIFY showSystemTrayIconChanged)
public:
explicit ElisaApplication(QObject *parent = nullptr);
......@@ -116,6 +120,8 @@ public:
bool showProgressOnTaskBar() const;
bool showSystemTrayIcon() const;
Q_SIGNALS:
void argumentsChanged();
......@@ -143,6 +149,8 @@ Q_SIGNALS:
void showProgressOnTaskBarChanged();
void showSystemTrayIconChanged();
public Q_SLOTS:
void appHelpActivated();
......
......@@ -36,6 +36,7 @@ ElisaConfigurationDialog::ElisaConfigurationDialog(QObject* parent)
setRootPath(Elisa::ElisaConfiguration::rootPath());
setShowProgressInTaskBar(Elisa::ElisaConfiguration::showProgressOnTaskBar());
setShowSystemTrayIcon(Elisa::ElisaConfiguration::showSystemTrayIcon());
setForceUsageOfFastFileSearch(Elisa::ElisaConfiguration::forceUsageOfFastFileSearch());
save();
......@@ -87,6 +88,7 @@ void ElisaConfigurationDialog::save()
{
Elisa::ElisaConfiguration::setRootPath(mRootPath);
Elisa::ElisaConfiguration::setShowProgressOnTaskBar(mShowProgressInTaskBar);
Elisa::ElisaConfiguration::setShowSystemTrayIcon(mShowSystemTrayIcon);
Elisa::ElisaConfiguration::setForceUsageOfFastFileSearch(mForceUsageOfFastFileSearch);
Elisa::ElisaConfiguration::self()->save();
......@@ -106,6 +108,18 @@ void ElisaConfigurationDialog::setShowProgressInTaskBar(bool showProgressInTaskB
setDirty();
}
void ElisaConfigurationDialog::setShowSystemTrayIcon(bool showSystemTrayIcon)
{
if (mShowSystemTrayIcon == showSystemTrayIcon) {
return;
}
mShowSystemTrayIcon = showSystemTrayIcon;
Q_EMIT showSystemTrayIconChanged();
setDirty();
}
void ElisaConfigurationDialog::setForceUsageOfFastFileSearch(bool forceUsageOfFastFileSearch)
{
if (mForceUsageOfFastFileSearch == forceUsageOfFastFileSearch) {
......
......@@ -43,6 +43,11 @@ class ELISALIB_EXPORT ElisaConfigurationDialog : public QObject
WRITE setShowProgressInTaskBar
NOTIFY showProgressInTaskBarChanged)
Q_PROPERTY(bool showSystemTrayIcon
READ showSystemTrayIcon
WRITE setShowSystemTrayIcon
NOTIFY showSystemTrayIconChanged)
Q_PROPERTY(bool isDirty
READ isDirty
NOTIFY isDirtyChanged)
......@@ -65,6 +70,11 @@ public:
return mShowProgressInTaskBar;
}
bool showSystemTrayIcon() const
{
return mShowSystemTrayIcon;
}
bool forceUsageOfFastFileSearch() const
{
return mForceUsageOfFastFileSearch;
......@@ -78,6 +88,8 @@ Q_SIGNALS:
void showProgressInTaskBarChanged();
void showSystemTrayIconChanged();
void forceUsageOfFastFileSearchChanged();
public Q_SLOTS:
......@@ -88,6 +100,8 @@ public Q_SLOTS:
void setShowProgressInTaskBar(bool showProgressInTaskBar);
void setShowSystemTrayIcon(bool showSystemTrayIcon);
void setForceUsageOfFastFileSearch(bool forceUsageOfFastFileSearch);
private Q_SLOTS:
......@@ -105,7 +119,10 @@ private:
bool mIsDirty = false;
bool mShowProgressInTaskBar = true;
bool mForceUsageOfFastFileSearch;
bool mShowSystemTrayIcon = true;
bool mForceUsageOfFastFileSearch = true;
};
#endif
......@@ -223,6 +223,7 @@ auto MusicListenersManager::initializeRootPath()
Elisa::ElisaConfiguration::setRootPath(initialRootPath);
Elisa::ElisaConfiguration::setShowProgressOnTaskBar(true);
Elisa::ElisaConfiguration::setShowSystemTrayIcon(true);
Elisa::ElisaConfiguration::setForceUsageOfFastFileSearch(true);
Elisa::ElisaConfiguration::self()->save();
......
......@@ -22,6 +22,7 @@ import QtQuick.Window 2.2
import org.kde.kirigami 2.5 as Kirigami
import org.kde.elisa 1.0
import Qt.labs.settings 1.0
import Qt.labs.platform 1.1
ApplicationWindow {
id: mainWindow
......@@ -155,9 +156,11 @@ ApplicationWindow {
headerBarManager: elisa.manageHeaderBar
manageMediaPlayerControl: elisa.playerControl
showProgressOnTaskBar: elisa.showProgressOnTaskBar
showSystemTrayIcon: elisa.showSystemTrayIcon
elisaMainWindow: mainWindow
onRaisePlayer: {
mainWindow.show()
mainWindow.visible = true
mainWindow.raise()
mainWindow.requestActivate()
}
......
......@@ -34,4 +34,12 @@ ColumnLayout {
onCheckedChanged: config.showProgressInTaskBar = checked
}
CheckBox {
checked: config.showSystemTrayIcon
text: i18n("Show System Tray Icon")
onCheckedChanged: config.showSystemTrayIcon = checked
}
}
......@@ -16,7 +16,7 @@
*/
import QtQuick 2.7
import Qt.labs.platform 1.0 as NativeMenu
import Qt.labs.platform 1.1 as NativeMenu
import org.kde.elisa 1.0
Item {
......@@ -28,11 +28,25 @@ Item {
property alias headerBarManager: mpris2Interface.headerBarManager
property alias manageMediaPlayerControl: mpris2Interface.manageMediaPlayerControl
property alias showProgressOnTaskBar: mpris2Interface.showProgressOnTaskBar
property bool showSystemTrayIcon
property var elisaMainWindow
signal raisePlayer()
Connections {
target: elisaMainWindow
onClosing: {
if (systemTrayIcon.visible) {
close.accepted = false
elisaMainWindow.hide()
}
}
}
NativeMenu.MenuBar {
NativeApplicationMenu {
id: globalMenu
}
}
......@@ -46,4 +60,22 @@ Item {
rootItem.raisePlayer()
}
}
NativeMenu.SystemTrayIcon {
id: systemTrayIcon
icon.name: 'elisa'
tooltip: mainWindow.title
visible: available && showSystemTrayIcon
menu: globalMenu
onActivated: {
if (reason === NativeMenu.SystemTrayIcon.Trigger && !elisaMainWindow.visible) {
elisaMainWindow.visible = true
} else if (reason === NativeMenu.SystemTrayIcon.Trigger && elisaMainWindow.visible) {
raisePlayer()
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment