1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-19 00:42:33 +02: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/\
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 {
RC_ICONS += favicon.ico
CONFIG(debug, debug|release) {
install_it.path = $${OUT_PWD}/debug/
} else {
install_it.path = $${OUT_PWD}/release/
}
INCLUDEPATH += $$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::setOrganizationDomain("screen-play.app");
QGuiApplication::setApplicationName("ScreenPlay");
QGuiApplication::setApplicationVersion("0.9.0");
QGuiApplication::setApplicationVersion("0.10.0");
QGuiApplication::setQuitOnLastWindowClosed(false);
QtBreakpad::init(QDir::current().absolutePath());

View File

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

View File

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

View File

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

View File

@ -177,6 +177,7 @@ Item {
}
}
GridView {
id: customPropertiesGridView
boundsBehavior: Flickable.DragOverBounds
@ -191,18 +192,21 @@ Item {
top: parent.top
topMargin: 60
right: parent.right
rightMargin: 40
bottom: parent.bottom
margins: 30
bottomMargin: 30
left: itmLeftWrapper.right
}
delegate: MonitorsProjectSettingItem {
id: delegate
width: parent.width - 40
selectedMonitor: monitors.activeMonitorIndex
}
ScrollBar.vertical: ScrollBar {
snapMode: ScrollBar.SnapOnRelease
policy: ScrollBar.AlwaysOn
}
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.Controls 2.3
import QtGraphicalEffects 1.0
import QtQuick.Dialogs 1.2
import QtQuick.Controls.Material 2.2
import QtQuick.Layouts 1.3
import Settings 1.0
import ScreenPlay 1.0
Item {
Rectangle {
id: delegate
focus: true
height: isHeadline ? 50 : 30
width: 300
property int selectedMonitor
anchors {
left: parent.left
leftMargin: isHeadline ? 0 : 25
}
Text {
id: txtDescription
text: name
width: 100
font.pointSize: isHeadline ? 21 : 14
font.pointSize: isHeadline ? 18 : 12
anchors.verticalCenter: parent.verticalCenter
font.family: ScreenPlay.settings.font
font.weight: Font.Normal
color: isHeadline ? Qt.darker(Material.foreground) : Material.foreground
anchors {
left: parent.left
leftMargin: isHeadline ? 0 : 25
}
}
@ -48,19 +46,102 @@ Item {
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.item.from = obj["from"]
loader.item.to = obj["to"]
loader.item.value = obj["value"]
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 {
id: compSlider
Item {
id:root
id: root
anchors.fill: parent
property int from
property int to
@ -68,24 +149,35 @@ Item {
property int stepSize
Slider {
id:slider
id: slider
from: root.from
to: root.to
value: root.value
stepSize: root.stepSize
live: false
width: parent.width
anchors {
verticalCenter: parent.verticalCenter
right:txtSliderValue.left
rightMargin: 20
left:parent.left
leftMargin: 20
}
onValueChanged: {
var value = Math.round(slider.value * 100) / 100;
txtSliderValue.text = value;
ScreenPlay.screenPlayManager.setWallpaperValue(selectedMonitor,txtDescription.text,value)
var value = Math.round(slider.value * 100) / 100
txtSliderValue.text = value
ScreenPlay.screenPlayManager.setWallpaperValue(
selectedMonitor, name, value)
}
}
Text {
id: txtSliderValue
anchors{
right:parent.right
color: Material.foreground
horizontalAlignment: Text.AlignRight
font.family: ScreenPlay.settings.font
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
}
}
@ -95,6 +187,14 @@ Item {
Loader {
id: loader
anchors.fill: parent
anchors.rightMargin: 10
}
}
}
/*##^##
Designer {
D{i:0;height:50;width:400}
}
##^##*/

View File

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

View File

@ -101,7 +101,18 @@ void ScreenPlayManager::createWallpaper(
settings.insert("absolutePath", path);
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_monitorListModel->clearActiveWallpaper();
QString absoluteProfilesFilePath = m_globalVariables->localSettingsPath().toLocalFile() + "/profiles.json";
QString absoluteProfilesFilePath = m_globalVariables->localSettingsPath().toString() + "/profiles.json";
auto configOptional = Util::openJsonFileToObject(absoluteProfilesFilePath);
if (!configOptional) {
@ -164,6 +175,8 @@ void ScreenPlayManager::removeAllWallpapers()
Util::writeJsonObjectToFile(absoluteProfilesFilePath, newConfig);
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
Q_UNUSED(profileName)
QString absoluteProfilesFilePath = m_globalVariables->localSettingsPath().toLocalFile() + "/profiles.json";
QString absoluteProfilesFilePath = m_globalVariables->localSettingsPath().toString() + "/profiles.json";
auto configOptional = Util::openJsonFileToObject(absoluteProfilesFilePath);
if (!configOptional) {
@ -313,10 +326,10 @@ bool ScreenPlayManager::saveWallpaperProfile(const QString& profileName, const Q
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) {
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;
}

View File

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

View File

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

View File

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