mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-18 16:32:33 +02:00
Remove Qt Smartpointer with std
Add separate widget counter
This commit is contained in:
parent
1a68f411cf
commit
7fb7b65e2b
@ -116,11 +116,11 @@ Item {
|
||||
|
||||
Button {
|
||||
id: btnRemoveAllWallpaper
|
||||
text: qsTr("Remove all wallpaper")
|
||||
text: qsTr("Remove all wallpaper and Widgets")
|
||||
Material.background: Material.Orange
|
||||
Material.foreground: "white"
|
||||
onClicked: {
|
||||
screenPlay.removeAllWallpaper()
|
||||
screenPlay.closeAllConnections()
|
||||
monitors.state = "inactive"
|
||||
}
|
||||
|
||||
@ -254,25 +254,25 @@ Item {
|
||||
to: "inactive"
|
||||
reversible: true
|
||||
|
||||
NumberAnimation {
|
||||
PropertyAnimation {
|
||||
target: background
|
||||
property: "opacity"
|
||||
duration: 200
|
||||
easing.type: Easing.OutQuart
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
PropertyAnimation {
|
||||
target: monitorsSettingsWrapper
|
||||
property: "anchors.topMargin"
|
||||
duration: 200
|
||||
easing.type: Easing.OutQuart
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
target: monitors
|
||||
property: "opacity"
|
||||
duration: 200
|
||||
easing.type: Easing.OutQuart
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -40,7 +40,7 @@ Item {
|
||||
|
||||
Text {
|
||||
id: txtAmountActiveWallpapers
|
||||
text: screenPlaySettings.activeWallpaperCounter
|
||||
text: screenPlaySettings.activeWallpaperCounter + screenPlaySettings.activeWidgetsCounter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
color: "orange"
|
||||
|
@ -58,6 +58,8 @@ void ScreenPlayManager::createWidget(QUrl absoluteStoragePath, const QString& pr
|
||||
return;
|
||||
}
|
||||
|
||||
m_settings->increaseActiveWidgetsCounter();
|
||||
|
||||
m_screenPlayWidgets.emplace_back(
|
||||
make_unique<ScreenPlayWidget>(
|
||||
generateID(),
|
||||
@ -68,12 +70,14 @@ void ScreenPlayManager::createWidget(QUrl absoluteStoragePath, const QString& pr
|
||||
this));
|
||||
}
|
||||
|
||||
void ScreenPlayManager::removeAllWallpaper()
|
||||
void ScreenPlayManager::closeAllConnections()
|
||||
{
|
||||
if (m_settings && !m_screenPlayWallpapers.empty()) {
|
||||
m_sdkconnector->closeAllWallpapers();
|
||||
if (!m_screenPlayWidgets.empty() || !m_screenPlayWallpapers.empty()) {
|
||||
m_sdkconnector->closeAllConnections();
|
||||
m_settings->setActiveWallpaperCounter(0);
|
||||
m_settings->setActiveWidgetsCounter(0);
|
||||
m_screenPlayWallpapers.clear();
|
||||
m_screenPlayWidgets.clear();
|
||||
emit allWallpaperRemoved();
|
||||
}
|
||||
return;
|
||||
@ -84,7 +88,7 @@ void ScreenPlayManager::requestProjectSettingsListModelAt(const int index)
|
||||
for (const unique_ptr<ScreenPlayWallpaper>& uPtrWallpaper : m_screenPlayWallpapers) {
|
||||
if (!uPtrWallpaper->screenNumber().empty() && uPtrWallpaper->screenNumber()[0] == index) { // ??? only at index == 0
|
||||
emit projectSettingsListModelFound(
|
||||
uPtrWallpaper->projectSettingsListModel().data(),
|
||||
uPtrWallpaper->projectSettingsListModel().get(),
|
||||
uPtrWallpaper->type());
|
||||
return;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public slots:
|
||||
const QString& previewImage, const float volume,
|
||||
const QString& fillMode, const QString& type);
|
||||
void createWidget(QUrl absoluteStoragePath, const QString& previewImage);
|
||||
void removeAllWallpaper();
|
||||
void closeAllConnections();
|
||||
void requestProjectSettingsListModelAt(const int index);
|
||||
void setWallpaperValue(const int at, const QString& key, const QString& value);
|
||||
void setAllWallpaperValue(const QString& key, const QString& value);
|
||||
|
@ -16,7 +16,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const vector<int>& screenNumber,
|
||||
const QString& type,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_projectSettingsListModel { QSharedPointer<ProjectSettingsListModel>::create(projectPath + "/project.json") }
|
||||
, m_projectSettingsListModel { make_shared<ProjectSettingsListModel>(projectPath + "/project.json") }
|
||||
, m_screenNumber { move(screenNumber) }
|
||||
, m_projectPath { projectPath }
|
||||
, m_previewImage { previewImage }
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "projectsettingslistmodel.h"
|
||||
#include "settings.h"
|
||||
|
||||
namespace ScreenPlay {
|
||||
using std::shared_ptr,
|
||||
std::make_shared,
|
||||
@ -35,7 +36,7 @@ public:
|
||||
|
||||
~ScreenPlayWallpaper() {}
|
||||
|
||||
const QSharedPointer<ProjectSettingsListModel>& projectSettingsListModel() const noexcept
|
||||
const shared_ptr<ProjectSettingsListModel>& projectSettingsListModel() const
|
||||
{
|
||||
return m_projectSettingsListModel;
|
||||
}
|
||||
@ -120,7 +121,7 @@ public slots:
|
||||
|
||||
private:
|
||||
QProcess m_process;
|
||||
QSharedPointer<ProjectSettingsListModel> m_projectSettingsListModel;
|
||||
shared_ptr<ProjectSettingsListModel> m_projectSettingsListModel;
|
||||
vector<int> m_screenNumber;
|
||||
QString m_projectPath;
|
||||
QString m_previewImage;
|
||||
|
@ -5,12 +5,12 @@
|
||||
namespace ScreenPlay {
|
||||
SDKConnector::SDKConnector(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_server { make_unique<QLocalServer>() }
|
||||
{
|
||||
|
||||
m_server = QSharedPointer<QLocalServer>(new QLocalServer(this));
|
||||
connect(m_server.data(), &QLocalServer::newConnection, this, &SDKConnector::newConnection);
|
||||
if (!m_server.data()->listen("ScreenPlay")) {
|
||||
//TODO what to do if no ScreenPlay local socket can be open
|
||||
connect(m_server.get(), &QLocalServer::newConnection, this, &SDKConnector::newConnection);
|
||||
if (!m_server->listen("ScreenPlay")) {
|
||||
qErrnoWarning("Could not open Local Socket with the name ScreenPlay. Usually this means another ScreenPlay instance is running!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,10 +20,10 @@ void SDKConnector::readyRead()
|
||||
|
||||
void SDKConnector::newConnection()
|
||||
{
|
||||
m_clients.append(QSharedPointer<SDKConnection>(new SDKConnection(m_server.data()->nextPendingConnection())));
|
||||
m_clients.append(make_shared<SDKConnection>(m_server->nextPendingConnection()));
|
||||
}
|
||||
|
||||
void SDKConnector::closeAllWallpapers()
|
||||
void SDKConnector::closeAllConnections()
|
||||
{
|
||||
for (int i = 0; i < m_clients.size(); ++i) {
|
||||
m_clients.at(i)->close();
|
||||
@ -34,7 +34,7 @@ void SDKConnector::closeAllWallpapers()
|
||||
|
||||
void SDKConnector::closeWallpapersAt(int at)
|
||||
{
|
||||
for (const QSharedPointer<SDKConnection>& refSDKConnection : m_clients) {
|
||||
for (const shared_ptr<SDKConnection>& refSDKConnection : m_clients) {
|
||||
refSDKConnection->close();
|
||||
if (!refSDKConnection->monitor().empty()) {
|
||||
// problem here !!
|
||||
@ -54,13 +54,13 @@ void SDKConnector::setWallpaperValue(QString appID, QString key, QString value)
|
||||
{
|
||||
|
||||
for (int i = 0; i < m_clients.count(); ++i) {
|
||||
if (m_clients.at(i).data()->appID() == appID) {
|
||||
if (m_clients.at(i)->appID() == appID) {
|
||||
QJsonObject obj;
|
||||
obj.insert(key, QJsonValue(value));
|
||||
|
||||
QByteArray send = QJsonDocument(obj).toJson();
|
||||
m_clients.at(i).data()->socket()->write(send);
|
||||
m_clients.at(i).data()->socket()->waitForBytesWritten();
|
||||
m_clients.at(i)->socket()->write(send);
|
||||
m_clients.at(i)->socket()->waitForBytesWritten();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,14 +68,14 @@ void SDKConnector::setWallpaperValue(QString appID, QString key, QString value)
|
||||
void SDKConnector::setSceneValue(QString appID, QString key, QString value)
|
||||
{
|
||||
for (int i = 0; i < m_clients.count(); ++i) {
|
||||
if (m_clients.at(i).data()->appID() == appID) {
|
||||
if (m_clients.at(i)->appID() == appID) {
|
||||
QJsonObject obj;
|
||||
obj.insert("type", QJsonValue("qmlScene"));
|
||||
obj.insert(key, QJsonValue(value));
|
||||
|
||||
QByteArray send = QJsonDocument(obj).toJson();
|
||||
m_clients.at(i).data()->socket()->write(send);
|
||||
m_clients.at(i).data()->socket()->waitForBytesWritten();
|
||||
m_clients.at(i)->socket()->write(send);
|
||||
m_clients.at(i)->socket()->waitForBytesWritten();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,11 @@
|
||||
#include <QLocalServer>
|
||||
#include <QLocalSocket>
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QTimer>
|
||||
#include <QVector>
|
||||
|
||||
#include <memory>
|
||||
|
||||
/*!
|
||||
\class SDKConnector
|
||||
\brief Used for every Wallpaper, Scene or Widget communication via Windows pipes/QLocalSocket
|
||||
@ -17,6 +18,11 @@
|
||||
namespace ScreenPlay {
|
||||
class SDKConnection;
|
||||
|
||||
using std::make_unique,
|
||||
std::unique_ptr,
|
||||
std::shared_ptr,
|
||||
std::make_shared;
|
||||
|
||||
class SDKConnector : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -25,14 +31,15 @@ public:
|
||||
public slots:
|
||||
void readyRead();
|
||||
void newConnection();
|
||||
void closeAllWallpapers();
|
||||
void closeAllConnections();
|
||||
|
||||
void closeWallpapersAt(int at);
|
||||
void setWallpaperValue(QString appID, QString key, QString value);
|
||||
void setSceneValue(QString appID, QString key, QString value);
|
||||
|
||||
private:
|
||||
QSharedPointer<QLocalServer> m_server;
|
||||
QVector<QSharedPointer<SDKConnection>> m_clients;
|
||||
unique_ptr<QLocalServer> m_server;
|
||||
QVector<shared_ptr<SDKConnection>> m_clients;
|
||||
};
|
||||
|
||||
class SDKConnection : public QObject {
|
||||
|
@ -18,11 +18,11 @@ Settings::Settings(const shared_ptr<InstalledListModel>& ilm,
|
||||
const shared_ptr<SDKConnector>& sdkc,
|
||||
QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_version(QVersionNumber(0, 0, 1))
|
||||
, m_profileListModel(plm)
|
||||
, m_installedListModel(ilm)
|
||||
, m_monitorListModel(mlm)
|
||||
, m_sdkconnector(sdkc)
|
||||
, m_version { QVersionNumber(0, 0, 1) }
|
||||
, m_profileListModel { plm }
|
||||
, m_installedListModel { ilm }
|
||||
, m_monitorListModel { mlm }
|
||||
, m_sdkconnector { sdkc }
|
||||
{
|
||||
auto* app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <QProcessEnvironment>
|
||||
#include <QQmlPropertyMap>
|
||||
#include <QSettings>
|
||||
#include <QSharedPointer>
|
||||
#include <QStandardPaths>
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
@ -47,7 +46,7 @@ using std::shared_ptr,
|
||||
class Settings : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QVersionNumber version READ version )
|
||||
Q_PROPERTY(QVersionNumber version READ version)
|
||||
Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
|
||||
Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged)
|
||||
Q_PROPERTY(bool sendStatistics READ sendStatistics WRITE setSendStatistics NOTIFY sendStatisticsChanged)
|
||||
@ -55,7 +54,9 @@ class Settings : public QObject {
|
||||
Q_PROPERTY(bool offlineMode READ offlineMode WRITE setOfflineMode NOTIFY offlineModeChanged)
|
||||
Q_PROPERTY(QUrl localStoragePath READ localStoragePath WRITE setLocalStoragePath NOTIFY localStoragePathChanged)
|
||||
Q_PROPERTY(QString decoder READ decoder WRITE setDecoder NOTIFY decoderChanged)
|
||||
|
||||
Q_PROPERTY(int activeWallpaperCounter READ activeWallpaperCounter WRITE setActiveWallpaperCounter NOTIFY activeWallpaperCounterChanged)
|
||||
Q_PROPERTY(int activeWidgetsCounter READ activeWidgetsCounter WRITE setActiveWidgetsCounter NOTIFY activeWidgetsCounterChanged)
|
||||
|
||||
public:
|
||||
explicit Settings(
|
||||
@ -131,7 +132,6 @@ public:
|
||||
return m_offlineMode;
|
||||
}
|
||||
|
||||
|
||||
bool autostart() const
|
||||
{
|
||||
return m_autostart;
|
||||
@ -152,6 +152,10 @@ public:
|
||||
return m_decoder;
|
||||
}
|
||||
|
||||
int activeWidgetsCounter() const
|
||||
{
|
||||
return m_activeWidgetsCounter;
|
||||
}
|
||||
|
||||
signals:
|
||||
void autostartChanged(bool autostart);
|
||||
@ -165,6 +169,8 @@ signals:
|
||||
void pauseWallpaperWhenIngameChanged(bool pauseWallpaperWhenIngame);
|
||||
void offlineModeChanged(bool offlineMode);
|
||||
|
||||
void activeWidgetsCounterChanged(int activeWidgetsCounter);
|
||||
|
||||
public slots:
|
||||
void writeSingleSettingConfig(QString name, QVariant value);
|
||||
void saveWallpaperToConfig(const int monitorIndex, const QUrl& absoluteStoragePath, const QString& type);
|
||||
@ -252,6 +258,18 @@ public slots:
|
||||
emit activeWallpaperCounterChanged(m_activeWallpaperCounter);
|
||||
}
|
||||
|
||||
void increaseActiveWidgetsCounter()
|
||||
{
|
||||
m_activeWidgetsCounter++;
|
||||
emit activeWidgetsCounterChanged(m_activeWidgetsCounter);
|
||||
}
|
||||
|
||||
void decreaseActivewidgetsCounter()
|
||||
{
|
||||
m_activeWidgetsCounter--;
|
||||
emit activeWidgetsCounterChanged(m_activeWidgetsCounter);
|
||||
}
|
||||
|
||||
void increaseActiveWallpaperCounter()
|
||||
{
|
||||
m_activeWallpaperCounter++;
|
||||
@ -287,6 +305,15 @@ public slots:
|
||||
|
||||
void loadActiveProfiles();
|
||||
|
||||
void setActiveWidgetsCounter(int activeWidgetsCounter)
|
||||
{
|
||||
if (m_activeWidgetsCounter == activeWidgetsCounter)
|
||||
return;
|
||||
|
||||
m_activeWidgetsCounter = activeWidgetsCounter;
|
||||
emit activeWidgetsCounterChanged(m_activeWidgetsCounter);
|
||||
}
|
||||
|
||||
private:
|
||||
void createDefaultConfig();
|
||||
void setupWidgetAndWindowPaths();
|
||||
@ -306,13 +333,14 @@ private:
|
||||
QUrl m_screenPlayWidgetPath;
|
||||
QUrl m_screenPlayBasePath;
|
||||
|
||||
bool m_pauseWallpaperWhenIngame = true;
|
||||
bool m_autostart = true;
|
||||
bool m_highPriorityStart = true;
|
||||
bool m_sendStatistics = false;
|
||||
bool m_offlineMode = true;
|
||||
bool m_pauseWallpaperWhenIngame { true };
|
||||
bool m_autostart { true };
|
||||
bool m_highPriorityStart { true };
|
||||
bool m_sendStatistics { false };
|
||||
bool m_offlineMode { true };
|
||||
|
||||
QString m_decoder = "";
|
||||
int m_activeWallpaperCounter = 0;
|
||||
QString m_decoder { "" };
|
||||
int m_activeWallpaperCounter { 0 };
|
||||
int m_activeWidgetsCounter { 0 };
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user