1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-16 07:22:34 +02:00

Move more functions into dedicated ScreenPlayWallpaper class

This commit is contained in:
Elias Steurer 2020-07-18 20:22:47 +02:00
parent 7df52a12b3
commit 0d7cb55643
5 changed files with 20 additions and 41 deletions

View File

@ -350,17 +350,6 @@ void ScreenPlayManager::newConnection()
m_clients.append(connection);
}
/*!
\brief Closes all m_clients connections and clears the QVector.
*/
void ScreenPlayManager::closeAllConnections()
{
for (auto& client : m_clients) {
client->close();
}
m_clients.clear();
m_clients.squeeze();
}
/*!
\brief Closes all wallpaper connection with the following type:
@ -422,30 +411,13 @@ bool ScreenPlayManager::closeWallpaper(const QString& appID)
*/
void ScreenPlayManager::setWallpaperValue(QString appID, QString key, QString value)
{
for (int i = 0; i < m_clients.count(); ++i) {
if (m_clients.at(i)->appID() == appID) {
QJsonObject obj;
obj.insert(key, QJsonValue(value));
QByteArray send = QJsonDocument(obj).toJson();
m_clients.at(i)->socket()->write(send);
m_clients.at(i)->socket()->waitForBytesWritten();
for (const auto& wallpaper : m_screenPlayWallpapers) {
if (wallpaper->appID() == appID) {
wallpaper->setWallpaperValue(key, value);
}
}
}
void ScreenPlayManager::replace(const QString& appID, const QJsonObject& obj)
{
for (int i = 0; i < m_clients.count(); ++i) {
if (m_clients.at(i)->appID() == appID) {
QByteArray send = QJsonDocument(obj).toJson();
m_clients.at(i)->socket()->write(send);
m_clients.at(i)->socket()->waitForBytesWritten();
}
}
}
/*!
\brief Saves a given wallpaper \a newProfileObject to a \a profileName. We ignore the profileName argument
@ -482,7 +454,7 @@ void ScreenPlayManager::saveProfiles()
bool ScreenPlayManager::removeWallpaperByAppID(const QString& appID)
{
for (auto wallpaper : m_screenPlayWallpapers) {
for (auto& wallpaper : m_screenPlayWallpapers) {
if (wallpaper->appID() == appID) {
qInfo() << "Remove wallpaper " << wallpaper->file() << "at monitor " << wallpaper->screenNumber();
decreaseActiveWallpaperCounter();

View File

@ -124,13 +124,11 @@ public slots:
void saveProfiles();
void newConnection();
void closeAllConnections();
void closeAllWallpapers();
void closeAllWidgets();
void closeConntectionByType(const QStringList& list);
bool closeWallpaper(const QString& appID);
void setWallpaperValue(QString appID, QString key, QString value);
void replace(const QString& appID, const QJsonObject& obj);
void setActiveWallpaperCounter(int activeWallpaperCounter)
{

View File

@ -109,6 +109,14 @@ void ScreenPlayWallpaper::processError(QProcess::ProcessError error)
qDebug() << "EX: " << error;
}
void ScreenPlayWallpaper::setWallpaperValue(const QString& key, const QString& value)
{
QJsonObject obj;
obj.insert(key, value);
m_connection->sendMessage(QJsonDocument(obj).toJson(QJsonDocument::Compact));
}
ProjectSettingsListModel* ScreenPlayWallpaper::getProjectSettingsListModel()
{
return &m_projectSettingsListModel;
@ -147,7 +155,9 @@ void ScreenPlayWallpaper::replace(
obj.insert("file", file);
obj.insert("checkWallpaperVisible", checkWallpaperVisible);
m_connection->sendMessage(QJsonDocument(obj).toJson());
m_connection->sendMessage(QJsonDocument(obj).toJson(QJsonDocument::Compact));
}
}

View File

@ -155,6 +155,7 @@ signals:
public slots:
void processExit(int exitCode, QProcess::ExitStatus exitStatus);
void processError(QProcess::ProcessError error);
void setWallpaperValue(const QString &key, const QString &value);
void setScreenNumber(QVector<int> screenNumber)
{
@ -241,14 +242,12 @@ public slots:
}
private:
QProcess m_process;
ProjectSettingsListModel m_projectSettingsListModel;
const std::shared_ptr<GlobalVariables>& m_globalVariables;
std::shared_ptr<SDKConnection> m_connection;
ProjectSettingsListModel m_projectSettingsListModel;
QVector<int> m_screenNumber;
QProcess m_process;
QString m_previewImage;
InstalledType::InstalledType m_type;
FillMode::FillMode m_fillMode;

View File

@ -152,14 +152,14 @@ signals:
void requestSave();
private:
QProcess m_process;
const std::shared_ptr<GlobalVariables>& m_globalVariables;
std::shared_ptr<SDKConnection> m_connection;
QProcess m_process;
QString m_previewImage;
QString m_appID;
QPoint m_position;
InstalledType::InstalledType m_type;
QString m_absolutePath;
std::shared_ptr<SDKConnection> m_connection;
};
}