mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Add closing of a single wallpaper
This commit is contained in:
parent
f06c720ed3
commit
eb2ca12633
@ -13,6 +13,7 @@ Item {
|
||||
|
||||
property string activeMonitorName: ""
|
||||
property int activeMonitorIndex
|
||||
onActiveMonitorIndexChanged: print(activeMonitorIndex)
|
||||
|
||||
onStateChanged: {
|
||||
bgMouseArea.focus = monitors.state == "active" ? true : false
|
||||
@ -114,20 +115,35 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
id: btnRemoveAllWallpaper
|
||||
text: qsTr("Remove all wallpaper and Widgets")
|
||||
Material.background: Material.Orange
|
||||
Material.foreground: "white"
|
||||
onClicked: {
|
||||
screenPlay.closeAllConnections()
|
||||
monitors.state = "inactive"
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
top: monitorSelection.bottom
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
bottomMargin: 30
|
||||
left: parent.left
|
||||
margins: 20
|
||||
}
|
||||
spacing: 20
|
||||
Button {
|
||||
id: btnRemoveSelectedWallpaper
|
||||
text: qsTr("Remove selected")
|
||||
Material.background: Material.Orange
|
||||
Material.foreground: "white"
|
||||
enabled: monitorSelection.activeMonitors.length == 1
|
||||
onClicked: {
|
||||
screenPlay.removeWallpaperAt(monitorSelection.activeMonitors[0])
|
||||
monitorSelection.deselectAll()
|
||||
}
|
||||
}
|
||||
Button {
|
||||
id: btnRemoveAllWallpaper
|
||||
text: qsTr("Remove all wallpaper and Widgets")
|
||||
Material.background: Material.Orange
|
||||
Material.foreground: "white"
|
||||
onClicked: {
|
||||
screenPlay.closeAllConnections()
|
||||
monitors.state = "inactive"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,7 +158,6 @@ Item {
|
||||
left: itmLeftWrapper.right
|
||||
}
|
||||
|
||||
|
||||
SP.Slider {
|
||||
headline: qsTr("Volume")
|
||||
onValueChanged: screenPlay.setWallpaperValue(
|
||||
|
@ -132,7 +132,7 @@ void MonitorListModel::loadMonitors()
|
||||
|
||||
void MonitorListModel::clearActiveWallpaper()
|
||||
{
|
||||
int i {0};
|
||||
int i { 0 };
|
||||
for (Monitor& monitor : m_monitorList) {
|
||||
monitor.m_activeWallpaper = nullptr;
|
||||
emit dataChanged(
|
||||
@ -145,6 +145,25 @@ void MonitorListModel::clearActiveWallpaper()
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorListModel::closeWallpaper(const QString& appID)
|
||||
{
|
||||
int i {};
|
||||
for (auto& item : m_monitorList) {
|
||||
if (item.m_activeWallpaper) {
|
||||
if (item.m_activeWallpaper->appID() == appID) {
|
||||
item.m_activeWallpaper = nullptr;
|
||||
emit dataChanged(
|
||||
index(i, 0),
|
||||
index(i, 0),
|
||||
QVector<int> {
|
||||
static_cast<int>(MonitorRole::PreviewImage),
|
||||
static_cast<int>(MonitorRole::AppID) });
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorListModel::setWallpaperActiveMonitor(const std::shared_ptr<ScreenPlayWallpaper>& wallpaper, const QVector<int> monitors)
|
||||
{
|
||||
|
||||
|
@ -88,6 +88,7 @@ signals:
|
||||
public slots:
|
||||
void reset();
|
||||
void clearActiveWallpaper();
|
||||
void closeWallpaper(const QString& appID);
|
||||
|
||||
void screenAdded(QScreen* screen)
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ ScreenPlayManager::ScreenPlayManager(const shared_ptr<GlobalVariables>& globalVa
|
||||
, m_monitorListModel { mlm }
|
||||
, m_sdkconnector { sdkc }
|
||||
{
|
||||
//loadActiveProfiles();
|
||||
loadActiveProfiles();
|
||||
QObject::connect(m_monitorListModel.get(), &MonitorListModel::monitorListChanged, this, &ScreenPlayManager::monitorListChanged);
|
||||
}
|
||||
|
||||
@ -70,14 +70,6 @@ void ScreenPlayManager::createWidget(const QUrl& absoluteStoragePath, const QStr
|
||||
this));
|
||||
}
|
||||
|
||||
void ScreenPlayManager::closeWallpaper(const QVector<int> screenNumber)
|
||||
{
|
||||
for (shared_ptr<ScreenPlayWallpaper>& wallpaper : m_screenPlayWallpapers) {
|
||||
if (wallpaper->screenNumber() == screenNumber) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenPlayManager::closeAllConnections()
|
||||
{
|
||||
if (!m_screenPlayWidgets.empty() || !m_screenPlayWallpapers.empty()) {
|
||||
@ -106,7 +98,7 @@ void ScreenPlayManager::requestProjectSettingsListModelAt(const int index)
|
||||
|
||||
void ScreenPlayManager::setWallpaperValue(const int index, const QString& key, const QString& value)
|
||||
{
|
||||
if(auto appID = m_monitorListModel->getAppIDByMonitorIndex(index)){
|
||||
if (auto appID = m_monitorListModel->getAppIDByMonitorIndex(index)) {
|
||||
m_sdkconnector->setWallpaperValue(appID.value(), key, value);
|
||||
}
|
||||
}
|
||||
@ -120,22 +112,11 @@ void ScreenPlayManager::setAllWallpaperValue(const QString& key, const QString&
|
||||
|
||||
void ScreenPlayManager::removeWallpaperAt(int at)
|
||||
{
|
||||
if (m_screenPlayWallpapers.empty())
|
||||
return;
|
||||
|
||||
const auto wallsToRemove = remove_if(
|
||||
m_screenPlayWallpapers.begin(), m_screenPlayWallpapers.end(),
|
||||
[&](const shared_ptr<ScreenPlayWallpaper>& uPtrWallpaper) -> bool {
|
||||
const QVector<int>& screenNumber = uPtrWallpaper->screenNumber();
|
||||
const bool isFound = !screenNumber.empty() && screenNumber[0] == at;
|
||||
if (isFound) {
|
||||
m_sdkconnector->closeWallpapersAt(at);
|
||||
decreaseActiveWallpaperCounter();
|
||||
}
|
||||
return isFound;
|
||||
});
|
||||
|
||||
m_screenPlayWallpapers.erase(wallsToRemove, m_screenPlayWallpapers.end());
|
||||
if (auto appID = m_monitorListModel->getAppIDByMonitorIndex(at)) {
|
||||
m_sdkconnector->closeWallpaper(appID.value());
|
||||
m_monitorListModel->closeWallpaper(appID.value());
|
||||
decreaseActiveWallpaperCounter();
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenPlayManager::monitorListChanged()
|
||||
|
@ -101,12 +101,12 @@ public slots:
|
||||
void createWidget(const QUrl& absoluteStoragePath, const QString& previewImage);
|
||||
|
||||
void closeAllConnections();
|
||||
void removeWallpaperAt(const int at = 0);
|
||||
|
||||
void requestProjectSettingsListModelAt(const int index);
|
||||
void setWallpaperValue(const int index, const QString& key, const QString& value);
|
||||
void setAllWallpaperValue(const QString& key, const QString& value);
|
||||
void removeWallpaperAt(const int at = 0);
|
||||
void monitorListChanged();
|
||||
void closeWallpaper(const QVector<int> screenNumber);
|
||||
|
||||
void setActiveWallpaperCounter(int activeWallpaperCounter)
|
||||
{
|
||||
|
@ -50,6 +50,16 @@ void SDKConnector::closeWallpapersAt(int at)
|
||||
}
|
||||
}
|
||||
|
||||
void SDKConnector::closeWallpaper(const QString& appID)
|
||||
{
|
||||
for (auto& item : m_clients) {
|
||||
if (item->appID() == appID) {
|
||||
item->close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SDKConnector::setWallpaperValue(QString appID, QString key, QString value)
|
||||
{
|
||||
|
||||
|
@ -34,6 +34,7 @@ public slots:
|
||||
void closeAllConnections();
|
||||
|
||||
void closeWallpapersAt(int at);
|
||||
void closeWallpaper(const QString& appID);
|
||||
void setWallpaperValue(QString appID, QString key, QString value);
|
||||
void setSceneValue(QString appID, QString key, QString value);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user