mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-05 18:42:29 +01:00
Add quick settings to tray icon
Fix navigation and multi loading of installed content Fix installed reloading on content change and fix reload timer no limit the triggering, but always trigger 500ms later Fix settings checkbox triggering always when entering settings page Fix create wizard change page to installed
This commit is contained in:
parent
0e6079fe9f
commit
99e427b6cb
@ -96,6 +96,7 @@ private:
|
||||
QFileSystemWatcher m_fileSystemWatcher;
|
||||
QVector<ProjectFile> m_screenPlayFiles;
|
||||
int m_count { 0 };
|
||||
QTimer m_reloadLimiter;
|
||||
std::atomic_bool m_isLoading { false };
|
||||
|
||||
const std::shared_ptr<GlobalVariables>& m_globalVariables;
|
||||
|
@ -23,40 +23,45 @@ ApplicationWindow {
|
||||
function setTheme(theme) {
|
||||
switch (theme) {
|
||||
case Settings.System:
|
||||
root.Material.theme = Material.System;
|
||||
break;
|
||||
root.Material.theme = Material.System
|
||||
break
|
||||
case Settings.Dark:
|
||||
root.Material.theme = Material.Dark;
|
||||
break;
|
||||
root.Material.theme = Material.Dark
|
||||
break
|
||||
case Settings.Light:
|
||||
root.Material.theme = Material.Light;
|
||||
break;
|
||||
root.Material.theme = Material.Light
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
function switchPage(name) {
|
||||
if (nav.currentNavigationName === name) {
|
||||
if (name === "Installed")
|
||||
App.installedListModel.reset();
|
||||
App.installedListModel.reset()
|
||||
}
|
||||
if (name === "Installed") {
|
||||
stackView.replace("qrc:/qml/ScreenPlayApp/qml/Installed/Installed.qml", {
|
||||
"sidebar": sidebar
|
||||
});
|
||||
return;
|
||||
stackView.replace(
|
||||
"qrc:/qml/ScreenPlayApp/qml/Installed/Installed.qml", {
|
||||
"sidebar": sidebar
|
||||
})
|
||||
return
|
||||
}
|
||||
stackView.replace("qrc:/qml/ScreenPlayApp/qml/" + name + "/" + name + ".qml", {
|
||||
"modalSource": content
|
||||
});
|
||||
sidebar.state = "inactive";
|
||||
stackView.replace(
|
||||
"qrc:/qml/ScreenPlayApp/qml/" + name + "/" + name + ".qml",
|
||||
{
|
||||
"modalSource": content
|
||||
})
|
||||
nav.setNavigation(name)
|
||||
sidebar.state = "inactive"
|
||||
}
|
||||
|
||||
color: Material.theme === Material.Dark ? Qt.darker(Material.background) : Material.background
|
||||
color: Material.theme === Material.Dark ? Qt.darker(
|
||||
Material.background) : Material.background
|
||||
// Set visible if the -silent parameter was not set (see app.cpp end of constructor).
|
||||
visible: false
|
||||
width: 1400
|
||||
height: 810
|
||||
title: "ScreenPlay Alpha - V" + App.version()
|
||||
title: "ScreenPlay Alpha - v" + App.version()
|
||||
minimumHeight: 450
|
||||
minimumWidth: 1050
|
||||
|
||||
@ -72,25 +77,29 @@ ApplicationWindow {
|
||||
// https://bugreports.qt.io/browse/QTBUG-86047
|
||||
Material.accent: Material.color(Material.Orange)
|
||||
onVisibilityChanged: {
|
||||
if (root.visibility === 2)
|
||||
App.installedListModel.reset();
|
||||
if (root.visibility !== 2)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
onClosing: close => {
|
||||
close.accepted = false;
|
||||
if (App.screenPlayManager.activeWallpaperCounter === 0 && App.screenPlayManager.activeWidgetsCounter === 0) {
|
||||
App.exit();
|
||||
}
|
||||
const alwaysMinimize = settings.value("alwaysMinimize", null);
|
||||
if (alwaysMinimize === null) {
|
||||
console.error("Unable to retreive alwaysMinimize setting");
|
||||
}
|
||||
if (alwaysMinimize === "true") {
|
||||
root.hide();
|
||||
App.showDockIcon(false);
|
||||
return;
|
||||
}
|
||||
exitDialog.open();
|
||||
}
|
||||
close.accepted = false
|
||||
if (App.screenPlayManager.activeWallpaperCounter === 0
|
||||
&& App.screenPlayManager.activeWidgetsCounter === 0) {
|
||||
App.exit()
|
||||
}
|
||||
const alwaysMinimize = settings.value("alwaysMinimize", null)
|
||||
if (alwaysMinimize === null) {
|
||||
console.error(
|
||||
"Unable to retreive alwaysMinimize setting")
|
||||
}
|
||||
if (alwaysMinimize === "true") {
|
||||
root.hide()
|
||||
App.showDockIcon(false)
|
||||
return
|
||||
}
|
||||
exitDialog.open()
|
||||
}
|
||||
|
||||
QCore.Settings {
|
||||
id: settings
|
||||
@ -103,14 +112,15 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
setTheme(App.settings.theme);
|
||||
setTheme(App.settings.theme)
|
||||
stackView.push("qrc:/qml/ScreenPlayApp/qml/Installed/Installed.qml", {
|
||||
"sidebar": sidebar
|
||||
});
|
||||
"sidebar": sidebar
|
||||
})
|
||||
if (!App.settings.silentStart) {
|
||||
App.showDockIcon(true);
|
||||
root.show();
|
||||
App.showDockIcon(true)
|
||||
root.show()
|
||||
}
|
||||
App.installedListModel.reset();
|
||||
}
|
||||
|
||||
Item {
|
||||
@ -140,7 +150,7 @@ ApplicationWindow {
|
||||
|
||||
Connections {
|
||||
function onThemeChanged(theme) {
|
||||
setTheme(theme);
|
||||
setTheme(theme)
|
||||
}
|
||||
|
||||
target: App.settings
|
||||
@ -148,7 +158,7 @@ ApplicationWindow {
|
||||
|
||||
Connections {
|
||||
function onRequestNavigation(nav) {
|
||||
switchPage(nav);
|
||||
switchPage(nav)
|
||||
}
|
||||
|
||||
target: App.util
|
||||
@ -156,16 +166,18 @@ ApplicationWindow {
|
||||
|
||||
Connections {
|
||||
function onRequestRaise() {
|
||||
App.showDockIcon(true);
|
||||
root.show();
|
||||
App.showDockIcon(true)
|
||||
root.show()
|
||||
}
|
||||
|
||||
function onActiveWidgetsCounterChanged() {
|
||||
plausible.pageView("widget/count/" + App.screenPlayManager.activeWidgetsCounter);
|
||||
plausible.pageView(
|
||||
"widget/count/" + App.screenPlayManager.activeWidgetsCounter)
|
||||
}
|
||||
|
||||
function onActiveWallpaperCounterChanged() {
|
||||
plausible.pageView("wallpaper/count/" + App.screenPlayManager.activeWallpaperCounter);
|
||||
plausible.pageView(
|
||||
"wallpaper/count/" + App.screenPlayManager.activeWallpaperCounter)
|
||||
}
|
||||
|
||||
target: App.screenPlayManager
|
||||
@ -223,16 +235,16 @@ ApplicationWindow {
|
||||
Connections {
|
||||
function onSetSidebarActive(active) {
|
||||
if (active)
|
||||
sidebar.state = "active";
|
||||
sidebar.state = "active"
|
||||
else
|
||||
sidebar.state = "inactive";
|
||||
sidebar.state = "inactive"
|
||||
}
|
||||
|
||||
function onSetNavigationItem(pos) {
|
||||
if (pos === 0)
|
||||
nav.onPageChanged("Create");
|
||||
nav.onPageChanged("Create")
|
||||
else
|
||||
nav.onPageChanged("Workshop");
|
||||
nav.onPageChanged("Workshop")
|
||||
}
|
||||
|
||||
target: stackView.currentItem
|
||||
@ -261,8 +273,8 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
onChangePage: function (name) {
|
||||
monitors.close();
|
||||
switchPage(name);
|
||||
monitors.close()
|
||||
switchPage(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,7 @@ Rectangle {
|
||||
|
||||
function onWizardExited() {
|
||||
root.expanded = true;
|
||||
stackView.clear(StackView.PushTransition);
|
||||
stackView.push("qrc:/qml/ScreenPlayApp/qml/Create/StartInfo.qml");
|
||||
listView.currentIndex = 0;
|
||||
App.util.setNavigation("Installed");
|
||||
App.util.setNavigationActive(true);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,6 @@ Item {
|
||||
|
||||
StackView.onActivated: {
|
||||
navWrapper.state = "in";
|
||||
App.installedListFilter.sortBySearchType(SearchType.All);
|
||||
checkIsContentInstalled();
|
||||
}
|
||||
|
||||
@ -257,7 +256,7 @@ Item {
|
||||
Menu {
|
||||
id: contextMenu
|
||||
objectName: "installedItemContextMenu"
|
||||
|
||||
// Must be var to support 64-bit size!
|
||||
property var publishedFileID: 0
|
||||
property url absoluteStoragePath
|
||||
property string fileName
|
||||
|
@ -13,7 +13,7 @@ Rectangle {
|
||||
id: root
|
||||
|
||||
property string currentNavigationName: "Installed"
|
||||
property var navArray: [navCreate, navWorkshop, navInstalled, navSettings, navCommunity]
|
||||
property var navArray: [navCreate, navWorkshop, navInstalled,navCommunity, navSettings]
|
||||
property bool navActive: true
|
||||
property Item modalSource
|
||||
property int iconWidth: 16
|
||||
@ -28,13 +28,13 @@ Rectangle {
|
||||
else
|
||||
root.state = "disabled";
|
||||
}
|
||||
|
||||
function setNavigation(name) {
|
||||
var i = 0;
|
||||
for (; i < navArray.length; i++) {
|
||||
if (navArray[i].name === name) {
|
||||
for (var i = 0; i < navArray.length; i++) {
|
||||
print(navArray[i].objectName)
|
||||
if (navArray[i].objectName === name) {
|
||||
navArray[i].state = "active";
|
||||
root.currentNavigationName = name;
|
||||
tabBar.currentIndex = navArray[i].index
|
||||
} else {
|
||||
navArray[i].state = "inactive";
|
||||
}
|
||||
@ -70,7 +70,7 @@ Rectangle {
|
||||
}
|
||||
|
||||
TabBar {
|
||||
id: row
|
||||
id: tabBar
|
||||
height: 50
|
||||
currentIndex: 2
|
||||
|
||||
@ -84,55 +84,60 @@ Rectangle {
|
||||
|
||||
CustomTabButton {
|
||||
id: navCreate
|
||||
index: 0
|
||||
icon.height: 22
|
||||
icon.width: 22
|
||||
text: qsTr("Create")
|
||||
objectName: "Create"
|
||||
icon.source: "qrc:/qml/ScreenPlayApp/assets/icons/icon_plus.svg"
|
||||
onClicked: {
|
||||
root.onPageChanged("Create");
|
||||
}
|
||||
objectName: "createTab"
|
||||
}
|
||||
|
||||
CustomTabButton {
|
||||
id: navWorkshop
|
||||
index: 1
|
||||
enabled: App.settings.steamVersion
|
||||
text: qsTr("Workshop")
|
||||
objectName: "Workshop"
|
||||
icon.source: "qrc:/qml/ScreenPlayApp/assets/icons/icon_steam.svg"
|
||||
onClicked: {
|
||||
root.onPageChanged("Workshop");
|
||||
}
|
||||
objectName: "workshopTab"
|
||||
}
|
||||
|
||||
CustomTabButton {
|
||||
id: navInstalled
|
||||
index: 2
|
||||
text: qsTr("Installed") + " " + App.installedListModel.count
|
||||
objectName: "Installed"
|
||||
icon.source: "qrc:/qml/ScreenPlayApp/assets/icons/icon_installed.svg"
|
||||
onClicked: {
|
||||
root.onPageChanged("Installed");
|
||||
}
|
||||
objectName: "installedTab"
|
||||
}
|
||||
|
||||
CustomTabButton {
|
||||
id: navCommunity
|
||||
index: 3
|
||||
text: qsTr("Community")
|
||||
objectName: "Community"
|
||||
icon.source: "qrc:/qml/ScreenPlayApp/assets/icons/icon_community.svg"
|
||||
onClicked: {
|
||||
root.onPageChanged("Community");
|
||||
}
|
||||
objectName: "communityTab"
|
||||
}
|
||||
|
||||
CustomTabButton {
|
||||
id: navSettings
|
||||
index: 4
|
||||
text: qsTr("Settings")
|
||||
objectName: "Settings"
|
||||
icon.source: "qrc:/qml/ScreenPlayApp/assets/icons/icon_settings.svg"
|
||||
onClicked: {
|
||||
root.onPageChanged("Settings");
|
||||
}
|
||||
objectName: "settingsTab"
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,6 +147,7 @@ Rectangle {
|
||||
font.pointSize: 12
|
||||
height: parent.height
|
||||
width: implicitWidth
|
||||
property int index: 0
|
||||
background: Item {
|
||||
}
|
||||
font.capitalization: Font.MixedCase
|
||||
@ -278,7 +284,7 @@ Rectangle {
|
||||
name: "disabled"
|
||||
|
||||
PropertyChanges {
|
||||
target: row
|
||||
target: tabBar
|
||||
opacity: 0.3
|
||||
}
|
||||
}
|
||||
@ -289,7 +295,7 @@ Rectangle {
|
||||
to: "*"
|
||||
|
||||
PropertyAnimation {
|
||||
target: row
|
||||
target: tabBar
|
||||
duration: 300
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ Item {
|
||||
id: radioButton
|
||||
|
||||
checked: settingsBool.isChecked
|
||||
onCheckedChanged: {
|
||||
onClicked: {
|
||||
if (radioButton.checkState === Qt.Checked)
|
||||
checkboxChanged(true);
|
||||
else
|
||||
|
@ -14,28 +14,90 @@ SystemTrayIcon {
|
||||
onActivated: function (reason) {
|
||||
switch (reason) {
|
||||
case SystemTrayIcon.Unknown:
|
||||
break;
|
||||
break
|
||||
case SystemTrayIcon.Context:
|
||||
break;
|
||||
break
|
||||
case SystemTrayIcon.DoubleClick:
|
||||
window.show();
|
||||
break;
|
||||
window.show()
|
||||
break
|
||||
case SystemTrayIcon.Trigger:
|
||||
break;
|
||||
break
|
||||
case SystemTrayIcon.MiddleClick:
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
function open(){
|
||||
App.showDockIcon(true)
|
||||
window.show()
|
||||
|
||||
}
|
||||
|
||||
menu: Menu {
|
||||
MenuItem {
|
||||
id: miOpenScreenPlay
|
||||
text: qsTr("Open ScreenPlay")
|
||||
onTriggered: {
|
||||
App.showDockIcon(true);
|
||||
window.show();
|
||||
root.open()
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
id: miChangeWallpaperSettings
|
||||
text: qsTr("Change Wallpaper settings")
|
||||
onTriggered: {
|
||||
root.open()
|
||||
App.util.setNavigation("Installed");
|
||||
App.util.setToggleWallpaperConfiguration()
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
separator: true
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("Browse Workshop")
|
||||
onTriggered: {
|
||||
root.open()
|
||||
App.util.setNavigation("Workshop");
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
id: miCreate
|
||||
text: qsTr("Create new Wallpaper or Widgets")
|
||||
onTriggered: {
|
||||
root.open()
|
||||
App.util.setNavigation("Create");
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
id: miSettings
|
||||
text: qsTr("Settings")
|
||||
onTriggered: {
|
||||
root.open()
|
||||
App.util.setNavigation("Settings");
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
separator: true
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Forums")
|
||||
onTriggered: {
|
||||
Qt.openUrlExternally("https://forum.screen-play.app/")
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Frequently Asked Questions (FAQ)")
|
||||
onTriggered: {
|
||||
Qt.openUrlExternally(
|
||||
"https://kelteseth.gitlab.io/ScreenPlayDocs/Frequently%20Asked%20Questions/")
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
separator: true
|
||||
}
|
||||
MenuItem {
|
||||
id: miMuteAll
|
||||
|
||||
@ -44,13 +106,13 @@ SystemTrayIcon {
|
||||
text: qsTr("Mute all")
|
||||
onTriggered: {
|
||||
if (miMuteAll.isMuted) {
|
||||
isMuted = false;
|
||||
miMuteAll.text = qsTr("Mute all");
|
||||
App.screenPlayManager.setAllWallpaperValue("muted", "true");
|
||||
isMuted = false
|
||||
miMuteAll.text = qsTr("Mute all")
|
||||
App.screenPlayManager.setAllWallpaperValue("muted", "true")
|
||||
} else {
|
||||
isMuted = true;
|
||||
miMuteAll.text = qsTr("Unmute all");
|
||||
App.screenPlayManager.setAllWallpaperValue("muted", "false");
|
||||
isMuted = true
|
||||
miMuteAll.text = qsTr("Unmute all")
|
||||
App.screenPlayManager.setAllWallpaperValue("muted", "false")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -63,13 +125,15 @@ SystemTrayIcon {
|
||||
text: qsTr("Pause all")
|
||||
onTriggered: {
|
||||
if (miStopAll.isPlaying) {
|
||||
isPlaying = false;
|
||||
miStopAll.text = qsTr("Pause all");
|
||||
App.screenPlayManager.setAllWallpaperValue("isPlaying", "true");
|
||||
isPlaying = false
|
||||
miStopAll.text = qsTr("Pause all")
|
||||
App.screenPlayManager.setAllWallpaperValue("isPlaying",
|
||||
"true")
|
||||
} else {
|
||||
isPlaying = true;
|
||||
miStopAll.text = qsTr("Play all");
|
||||
App.screenPlayManager.setAllWallpaperValue("isPlaying", "false");
|
||||
isPlaying = true
|
||||
miStopAll.text = qsTr("Play all")
|
||||
App.screenPlayManager.setAllWallpaperValue("isPlaying",
|
||||
"false")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,18 +35,23 @@ InstalledListModel::InstalledListModel(
|
||||
*/
|
||||
void InstalledListModel::init()
|
||||
{
|
||||
if (!m_fileSystemWatcher.addPath(m_globalVariables->localStoragePath().toLocalFile())) {
|
||||
qWarning() << "Could not setup file system watcher for changed files with path: " << m_globalVariables->localStoragePath().toLocalFile();
|
||||
QString projectsPath = m_globalVariables->localStoragePath().toLocalFile();
|
||||
QDirIterator projectFilesIter(projectsPath, { "*.qml", "*.html", "*.css", "*.js", "*.png", "project.json" }, QDir::Files | QDir::NoSymLinks, QDirIterator::Subdirectories);
|
||||
while (projectFilesIter.hasNext()) {
|
||||
m_fileSystemWatcher.addPath(projectFilesIter.next());
|
||||
}
|
||||
m_reloadLimiter.setInterval(500);
|
||||
m_reloadLimiter.setSingleShot(true);
|
||||
QObject::connect(&m_reloadLimiter, &QTimer::timeout, this, [this]() {
|
||||
reset();
|
||||
});
|
||||
|
||||
auto reloadLambda = [this]() {
|
||||
QTimer::singleShot(500, this, [this]() {
|
||||
reset();
|
||||
});
|
||||
auto restartTimer = [this]() {
|
||||
m_reloadLimiter.start();
|
||||
};
|
||||
|
||||
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, reloadLambda);
|
||||
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, reloadLambda);
|
||||
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, restartTimer);
|
||||
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, restartTimer);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -288,6 +293,10 @@ QVariantMap InstalledListModel::get(const QString& folderName) const
|
||||
*/
|
||||
void InstalledListModel::reset()
|
||||
{
|
||||
if (m_isLoading) {
|
||||
qInfo() << "loadInstalledContent is already running. Skip.";
|
||||
return;
|
||||
}
|
||||
beginResetModel();
|
||||
m_screenPlayFiles.clear();
|
||||
m_screenPlayFiles.squeeze();
|
||||
|
@ -105,13 +105,13 @@ bool ProjectFile::init()
|
||||
qWarning("Invalid videoCodec was specified inside the json object!");
|
||||
}
|
||||
} else if (type == ScreenPlay::InstalledType::InstalledType::VideoWallpaper) {
|
||||
qWarning("No videoCodec was specified inside the json object!");
|
||||
// qWarning("No videoCodec was specified inside the json object!");
|
||||
if (file.endsWith(".mp4")) {
|
||||
videoCodec = ScreenPlay::VideoCodec::VideoCodec::H264;
|
||||
qWarning("Eyeball to h264 because of .mp4");
|
||||
// qWarning("Eyeball to h264 because of .mp4");
|
||||
} else if (file.endsWith(".webm")) {
|
||||
videoCodec = ScreenPlay::VideoCodec::VideoCodec::VP8;
|
||||
qWarning("Eyeball to VP8 because of .webm");
|
||||
// qWarning("Eyeball to VP8 because of .webm");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user