1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-09 20:42:47 +01:00

Merge branch 'dev' into 37-support-system-wide-dark-mode

This commit is contained in:
Elias Steurer 2020-03-19 12:50:38 +01:00
commit bdc4b4ced6
12 changed files with 191 additions and 77 deletions

View File

@ -70,18 +70,22 @@ INCLUDEPATH += \
$$PWD/src/\ $$PWD/src/\
CONFIG(debug, debug|release) {
install_assets.path = $${OUT_PWD}/assets/fonts
} else {
install_assets.path = $${OUT_PWD}/assets/fonts
}
install_assets.files += $$PWD/assets/fonts/NotoSansCJKkr-Regular.otf
win32 { win32 {
RC_ICONS += favicon.ico RC_ICONS += favicon.ico
CONFIG(debug, debug|release) { CONFIG(debug, debug|release) {
install_it.path = $${OUT_PWD}/debug/ install_it.path = $${OUT_PWD}/debug/
} else { } else {
install_it.path = $${OUT_PWD}/release/ install_it.path = $${OUT_PWD}/release/
} }
INCLUDEPATH += $$PWD/../Common/vcpkg/installed/x64-windows/include INCLUDEPATH += $$PWD/../Common/vcpkg/installed/x64-windows/include
DEPENDPATH += $$PWD/../Common/vcpkg/installed/x64-windows/include DEPENDPATH += $$PWD/../Common/vcpkg/installed/x64-windows/include
@ -154,5 +158,5 @@ unix {
} }
INSTALLS += install_it INSTALLS += install_it install_assets

View File

@ -49,7 +49,7 @@ App::App()
QGuiApplication::setOrganizationName("ScreenPlay"); QGuiApplication::setOrganizationName("ScreenPlay");
QGuiApplication::setOrganizationDomain("screen-play.app"); QGuiApplication::setOrganizationDomain("screen-play.app");
QGuiApplication::setApplicationName("ScreenPlay"); QGuiApplication::setApplicationName("ScreenPlay");
QGuiApplication::setApplicationVersion("0.9.0"); QGuiApplication::setApplicationVersion("0.10.0");
QGuiApplication::setQuitOnLastWindowClosed(false); QGuiApplication::setQuitOnLastWindowClosed(false);
QtBreakpad::init(QDir::current().absolutePath()); QtBreakpad::init(QDir::current().absolutePath());

View File

@ -30,7 +30,7 @@ ApplicationWindow {
visible: false visible: false
width: 1400 width: 1400
height: 788 height: 788
title: "ScreenPlay Alpha - V0.9.0" title: "ScreenPlay Alpha - V0.10.0"
minimumHeight: 450 minimumHeight: 450
minimumWidth: 1050 minimumWidth: 1050

View File

@ -4,6 +4,7 @@ import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import ScreenPlay 1.0 import ScreenPlay 1.0
import Settings 1.0
import "../../../Common" import "../../../Common"
@ -159,7 +160,6 @@ Item {
TagSelector { TagSelector {
id: tagSelector id: tagSelector
Layout.fillWidth: true Layout.fillWidth: true
font.family: ScreenPlay.settings.font
} }
Item { Item {

View File

@ -222,6 +222,9 @@ Item {
right: parent.right right: parent.right
left: parent.left left: parent.left
} }
MouseArea {
anchors.fill: parent
}
TabBar { TabBar {
height: parent.height height: parent.height
background: Item {} background: Item {}

View File

@ -177,6 +177,7 @@ Item {
} }
} }
GridView { GridView {
id: customPropertiesGridView id: customPropertiesGridView
boundsBehavior: Flickable.DragOverBounds boundsBehavior: Flickable.DragOverBounds
@ -191,18 +192,21 @@ Item {
top: parent.top top: parent.top
topMargin: 60 topMargin: 60
right: parent.right right: parent.right
rightMargin: 40
bottom: parent.bottom bottom: parent.bottom
margins: 30 bottomMargin: 30
left: itmLeftWrapper.right left: itmLeftWrapper.right
} }
delegate: MonitorsProjectSettingItem { delegate: MonitorsProjectSettingItem {
id: delegate id: delegate
width: parent.width - 40
selectedMonitor: monitors.activeMonitorIndex selectedMonitor: monitors.activeMonitorIndex
} }
ScrollBar.vertical: ScrollBar { ScrollBar.vertical: ScrollBar {
snapMode: ScrollBar.SnapOnRelease snapMode: ScrollBar.SnapOnRelease
policy: ScrollBar.AlwaysOn
} }
states: [ states: [
@ -337,3 +341,9 @@ Item {
} }
] ]
} }
/*##^##
Designer {
D{i:0;autoSize:true;height:768;width:1366}
}
##^##*/

View File

@ -1,34 +1,32 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.3 import QtQuick.Controls 2.3
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import QtQuick.Dialogs 1.2
import QtQuick.Controls.Material 2.2 import QtQuick.Controls.Material 2.2
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import Settings 1.0
import ScreenPlay 1.0 import ScreenPlay 1.0
Item { Rectangle {
id: delegate id: delegate
focus: true focus: true
height: isHeadline ? 50 : 30 height: isHeadline ? 50 : 30
width: 300
property int selectedMonitor property int selectedMonitor
anchors {
left: parent.left
leftMargin: isHeadline ? 0 : 25
}
Text { Text {
id: txtDescription id: txtDescription
text: name text: name
width: 100 width: 100
font.pointSize: isHeadline ? 21 : 14 font.pointSize: isHeadline ? 18 : 12
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
font.family: ScreenPlay.settings.font font.family: ScreenPlay.settings.font
font.weight: Font.Normal font.weight: Font.Normal
color: isHeadline ? Qt.darker(Material.foreground) : Material.foreground
anchors { anchors {
left: parent.left left: parent.left
leftMargin: isHeadline ? 0 : 25
} }
} }
@ -48,14 +46,97 @@ Item {
var obj = JSON.parse(value.toString()) var obj = JSON.parse(value.toString())
if (obj["type"] === "slider") { if (obj["text"]) {
txtDescription.text = obj["text"]
}
switch (obj["type"]) {
case "slider":
loader.sourceComponent = compSlider loader.sourceComponent = compSlider
loader.item.from = obj["from"] loader.item.from = obj["from"]
loader.item.to = obj["to"] loader.item.to = obj["to"]
loader.item.value = obj["value"] loader.item.value = obj["value"]
loader.item.stepSize = obj["stepSize"] loader.item.stepSize = obj["stepSize"]
break
case "bool":
loader.sourceComponent = compCheckbox
loader.item.value = obj["value"]
break
case "color":
loader.sourceComponent = compColorpicker
loader.item.value = obj["value"]
break
} }
} }
Component {
id: compCheckbox
Item {
id: root
anchors.fill: parent
property bool value
CheckBox {
id: checkbox
checkable: true
checked: root.value
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
}
onCheckedChanged: {
ScreenPlay.screenPlayManager.setWallpaperValue(
selectedMonitor, name, checkbox.checked)
}
}
}
}
Component {
id: compColorpicker
Item {
id: root
anchors.fill: parent
property color value
Button {
id: btnSetColor
text: qsTr("Set color")
onClicked: colorDialog.open()
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
}
}
Rectangle {
id: rctPreviewColor
radius: 3
color: root.value
border.width: 1
border.color: "gray"
width: parent.height
height: parent.height
anchors {
right: btnSetColor.left
rightMargin: 20
verticalCenter: parent.verticalCenter
}
}
ColorDialog {
id: colorDialog
title: qsTr("Please choose a color")
onAccepted: {
rctPreviewColor.color = colorDialog.color
let tmpColor = "'" + colorDialog.color.toString() + "'"
ScreenPlay.screenPlayManager.setWallpaperValue(
selectedMonitor, name, tmpColor)
}
}
}
}
Component { Component {
id: compSlider id: compSlider
@ -74,16 +155,27 @@ Item {
value: root.value value: root.value
stepSize: root.stepSize stepSize: root.stepSize
live: false live: false
width: parent.width
anchors {
verticalCenter: parent.verticalCenter
right:txtSliderValue.left
rightMargin: 20
left:parent.left
leftMargin: 20
}
onValueChanged: { onValueChanged: {
var value = Math.round(slider.value * 100) / 100; var value = Math.round(slider.value * 100) / 100
txtSliderValue.text = value; txtSliderValue.text = value
ScreenPlay.screenPlayManager.setWallpaperValue(selectedMonitor,txtDescription.text,value) ScreenPlay.screenPlayManager.setWallpaperValue(
selectedMonitor, name, value)
} }
} }
Text { Text {
id: txtSliderValue id: txtSliderValue
color: Material.foreground
horizontalAlignment: Text.AlignRight
font.family: ScreenPlay.settings.font
anchors { anchors {
right: parent.right right: parent.right
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
@ -95,6 +187,14 @@ Item {
Loader { Loader {
id: loader id: loader
anchors.fill: parent anchors.fill: parent
anchors.rightMargin: 10
} }
} }
} }
/*##^##
Designer {
D{i:0;height:50;width:400}
}
##^##*/

View File

@ -15,6 +15,10 @@ Rectangle {
width: 1366 width: 1366
color: Material.background color: Material.background
MouseArea {
anchors.fill: parent
}
signal changePage(string name) signal changePage(string name)
property var navArray: [navCreate, navWorkshop, navInstalled, navSettings, navCommunity] property var navArray: [navCreate, navWorkshop, navInstalled, navSettings, navCommunity]

View File

@ -101,7 +101,18 @@ void ScreenPlayManager::createWallpaper(
settings.insert("absolutePath", path); settings.insert("absolutePath", path);
saveWallpaperProfile("default", settings); saveWallpaperProfile("default", settings);
return;
} }
if (saveToProfilesConfigFile && type == "qmlWallpaper") {
QJsonObject settings;
settings.insert("monitors", monitors);
settings.insert("type", type);
settings.insert("previewImage", previewImage);
settings.insert("absolutePath", path);
saveWallpaperProfile("default", settings);
}
} }
/*! /*!
@ -138,7 +149,7 @@ void ScreenPlayManager::removeAllWallpapers()
m_screenPlayWallpapers.clear(); m_screenPlayWallpapers.clear();
m_monitorListModel->clearActiveWallpaper(); m_monitorListModel->clearActiveWallpaper();
QString absoluteProfilesFilePath = m_globalVariables->localSettingsPath().toLocalFile() + "/profiles.json"; QString absoluteProfilesFilePath = m_globalVariables->localSettingsPath().toString() + "/profiles.json";
auto configOptional = Util::openJsonFileToObject(absoluteProfilesFilePath); auto configOptional = Util::openJsonFileToObject(absoluteProfilesFilePath);
if (!configOptional) { if (!configOptional) {
@ -164,6 +175,8 @@ void ScreenPlayManager::removeAllWallpapers()
Util::writeJsonObjectToFile(absoluteProfilesFilePath, newConfig); Util::writeJsonObjectToFile(absoluteProfilesFilePath, newConfig);
setActiveWallpaperCounter(0); setActiveWallpaperCounter(0);
} else {
qWarning() << "Trying to remove all wallpapers while m_screenPlayWallpapers is not empty. Count: "<< m_screenPlayWallpapers.size();
} }
} }
@ -261,7 +274,7 @@ bool ScreenPlayManager::saveWallpaperProfile(const QString& profileName, const Q
// Remove when implementing profiles // Remove when implementing profiles
Q_UNUSED(profileName) Q_UNUSED(profileName)
QString absoluteProfilesFilePath = m_globalVariables->localSettingsPath().toLocalFile() + "/profiles.json"; QString absoluteProfilesFilePath = m_globalVariables->localSettingsPath().toString() + "/profiles.json";
auto configOptional = Util::openJsonFileToObject(absoluteProfilesFilePath); auto configOptional = Util::openJsonFileToObject(absoluteProfilesFilePath);
if (!configOptional) { if (!configOptional) {
@ -313,10 +326,10 @@ bool ScreenPlayManager::saveWallpaperProfile(const QString& profileName, const Q
void ScreenPlayManager::loadWallpaperProfiles() void ScreenPlayManager::loadWallpaperProfiles()
{ {
auto configObj = Util::openJsonFileToObject(m_globalVariables->localSettingsPath().toLocalFile() + "/profiles.json"); auto configObj = Util::openJsonFileToObject(m_globalVariables->localSettingsPath().toString() + "/profiles.json");
if (!configObj) { if (!configObj) {
qWarning() << "Could not load active profiles at path: " << m_globalVariables->localSettingsPath().toLocalFile() + "/profiles.json"; qWarning() << "Could not load active profiles at path: " << m_globalVariables->localSettingsPath().toString() + "/profiles.json";
return; return;
} }

View File

@ -77,7 +77,7 @@ Settings::Settings(const shared_ptr<GlobalVariables>& globalVariables,
setAnonymousTelemetry(m_qSettings.value("AnonymousTelemetry", true).toBool()); setAnonymousTelemetry(m_qSettings.value("AnonymousTelemetry", true).toBool());
// Wallpaper and Widgets config // Wallpaper and Widgets config
QFile profilesFile(m_globalVariables->localSettingsPath().toLocalFile() + "/profiles.json"); QFile profilesFile(m_globalVariables->localSettingsPath().toString() + "/profiles.json");
if (!profilesFile.exists()) { if (!profilesFile.exists()) {
qInfo("No profiles.json found, creating default profiles.json"); qInfo("No profiles.json found, creating default profiles.json");
qDebug() << profilesFile; qDebug() << profilesFile;
@ -130,7 +130,7 @@ Settings::Settings(const shared_ptr<GlobalVariables>& globalVariables,
*/ */
void Settings::writeJsonFileFromResource(const QString& filename) void Settings::writeJsonFileFromResource(const QString& filename)
{ {
QFile file(m_globalVariables->localSettingsPath().toLocalFile() + "/" + filename + ".json"); QFile file(m_globalVariables->localSettingsPath().toString() + "/" + filename + ".json");
QFile defaultSettings(":/" + filename + ".json"); QFile defaultSettings(":/" + filename + ".json");
file.open(QIODevice::WriteOnly | QIODevice::Text); file.open(QIODevice::WriteOnly | QIODevice::Text);

View File

@ -121,7 +121,7 @@ Item {
onVisualsPausedChanged:{ onVisualsPausedChanged:{
if(window.checkWallpaperVisible){ if(window.checkWallpaperVisible){
webView.visible = visualsPaused webView.visible = !visualsPaused
} }
} }

View File

@ -17,7 +17,6 @@ HHOOK mouseHook;
QQuickView* winGlobalHook = nullptr; QQuickView* winGlobalHook = nullptr;
LRESULT __stdcall MouseHookCallback(int nCode, WPARAM wParam, LPARAM lParam) LRESULT __stdcall MouseHookCallback(int nCode, WPARAM wParam, LPARAM lParam)
{ {
Qt::MouseButton mouseButton {}; Qt::MouseButton mouseButton {};
@ -68,8 +67,6 @@ LRESULT __stdcall MouseHookCallback(int nCode, WPARAM wParam, LPARAM lParam)
auto* app = QApplication::instance(); auto* app = QApplication::instance();
app->sendEvent(winGlobalHook, &eventRelease); app->sendEvent(winGlobalHook, &eventRelease);
qDebug() << mouseButton << mouseButtons;
}); });
} }
@ -144,7 +141,9 @@ WinWindow::WinWindow(
m_checkForFullScreenWindowTimer.start(10); m_checkForFullScreenWindowTimer.start(10);
} }
QTimer::singleShot(1000, [this]() {
setupWindowMouseHook(); setupWindowMouseHook();
});
} }
void WinWindow::setVisible(bool show) void WinWindow::setVisible(bool show)
@ -303,50 +302,31 @@ int GetMonitorIndex(HMONITOR hMonitor)
void WinWindow::checkForFullScreenWindow() void WinWindow::checkForFullScreenWindow()
{ {
// If one screen:
{
auto hWnd = GetForegroundWindow();
DWORD dwStyle = (DWORD)GetWindowLong(hWnd, GWL_STYLE);
int screensCount = QGuiApplication::screens().length();
if (screensCount == 1) {
if ((dwStyle & WS_MAXIMIZE) != 0) {
// do stuff
setVisualsPaused(false);
} else {
setVisualsPaused(true);
}
return;
}
}
// If multiple screens:
{
HWND hFoundWnd = nullptr; HWND hFoundWnd = nullptr;
EnumWindows(&FindTheDesiredWnd, reinterpret_cast<LPARAM>(&hFoundWnd)); EnumWindows(&FindTheDesiredWnd, reinterpret_cast<LPARAM>(&hFoundWnd));
// True if one window has WS_MAXIMIZE // True if one window has WS_MAXIMIZE
if (hFoundWnd != nullptr) { if (hFoundWnd != nullptr) {
DWORD dwFlags = 0; DWORD dwFlags = 0;
HMONITOR monitor = MonitorFromWindow(hFoundWnd, dwFlags); HMONITOR monitor = MonitorFromWindow(hFoundWnd, dwFlags);
HMONITOR wallpaper = MonitorFromWindow(m_windowHandle, dwFlags);
int monitorIndex = GetMonitorIndex(monitor); int monitorIndex = GetMonitorIndex(monitor);
// qDebug() << "Window found " << printWindowNameByhWnd(hFoundWnd) << monitorIndex << activeScreensList().at(0); int wallpaperIndex = GetMonitorIndex(wallpaper);
// qDebug() << "Window found " << printWindowNameByhWnd(hFoundWnd) << monitorIndex << activeScreensList().at(0) << wallpaperIndex;
// We do not support autopause for multi monitor wallpaper // We do not support autopause for multi monitor wallpaper
if (activeScreensList().length() == 1) { if (activeScreensList().length() == 1) {
// If the window that has WS_MAXIMIZE is at the same monitor as this wallpaper // If the window that has WS_MAXIMIZE is at the same monitor as this wallpaper
if (monitorIndex == activeScreensList().at(0)) { if (monitorIndex == wallpaperIndex) {
//qDebug() << "monitorIndex" << monitorIndex; //qDebug() << "monitorIndex" << monitorIndex;
setVisualsPaused(false);
} else {
setVisualsPaused(true); setVisualsPaused(true);
} else {
setVisualsPaused(false);
} }
} }
} else { } else {
setVisualsPaused(true); setVisualsPaused(false);
}
} }
} }