mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-10-06 09:17:07 +02:00
ScreenPlay::removeWallpaperAt(int at) does remove walls now(not done)
This commit is contained in:
parent
e5504e2c14
commit
d23cd0ffd3
@ -9,6 +9,15 @@ ScreenPlay::ScreenPlay(InstalledListModel* ilm, Settings* set, MonitorListModel*
|
||||
m_sdkc{sdkc}
|
||||
{}
|
||||
|
||||
ScreenPlay::~ScreenPlay()
|
||||
{
|
||||
if(m_ilm) delete m_ilm;
|
||||
if(m_settings) delete m_settings;
|
||||
if(m_mlm) delete m_mlm;
|
||||
if(m_qGuiApplication) delete m_qGuiApplication;
|
||||
if(m_sdkc) delete m_sdkc;
|
||||
}
|
||||
|
||||
const InstalledListModel* ScreenPlay::listModelInstalled() const noexcept { return m_ilm; }
|
||||
const Settings* ScreenPlay::settings() const noexcept { return m_settings; }
|
||||
const MonitorListModel* ScreenPlay::monitorListModel() const noexcept { return m_mlm; }
|
||||
@ -30,11 +39,13 @@ void ScreenPlay::createWallpaper(
|
||||
//this->removeAllWallpaper();
|
||||
this->removeWallpaperAt(0);
|
||||
m_settings->increaseActiveWallpaperCounter();
|
||||
|
||||
m_screenPlayWallpaperList.emplace_back(
|
||||
RefSPWall::create(
|
||||
QVector<int>{monitorIndex}, absoluteStoragePath.toLocalFile(),
|
||||
std::vector<int>{monitorIndex}, absoluteStoragePath.toLocalFile(),
|
||||
previewImage, volume, fillMode, type, this)
|
||||
);
|
||||
|
||||
m_mlm->setWallpaperActiveMonitor(m_qGuiApplication->screens().at(monitorIndex),
|
||||
QString{absoluteStoragePath.toLocalFile() + "/" + previewImage});
|
||||
}
|
||||
@ -98,31 +109,39 @@ void ScreenPlay::setAllWallpaperValue(const QString &key, const QString &value)
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenPlay::removeWallpaperAt(int at)
|
||||
void ScreenPlay::removeWallpaperAt(const int at)
|
||||
{
|
||||
//Q_ASSERT(m_screenPlayWallpaperList.size() < at);
|
||||
// Q_ASSERT(at < m_screenPlayWallpaperList.size() && m_sdkc);
|
||||
qDebug() << "No of walls in list: " << m_screenPlayWallpaperList.size();
|
||||
if(m_screenPlayWallpaperList.empty()) return; // done here;
|
||||
|
||||
if (m_screenPlayWallpaperList.isEmpty())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < m_screenPlayWallpaperList.length(); ++i) {
|
||||
|
||||
if (m_screenPlayWallpaperList.at(i).data()->screenNumber().at(0) == at) {
|
||||
qDebug() << i << m_screenPlayWallpaperList.at(i).data()->screenNumber().at(0);
|
||||
m_sdkc->closeWallpapersAt(at);
|
||||
m_screenPlayWallpaperList.removeAt(i);
|
||||
}
|
||||
const auto toRemove = std::remove_if(
|
||||
m_screenPlayWallpaperList.begin(), m_screenPlayWallpaperList.end(),
|
||||
[&](const RefSPWall& refSPWallpaper) noexcept ->bool {
|
||||
const std::vector<int>& screenNumber = refSPWallpaper->screenNumber();
|
||||
qDebug() << "Screen No. :" << screenNumber.size();
|
||||
const bool isFound = !screenNumber.empty();// && screenNumber[0] == at;
|
||||
if(isFound) {
|
||||
// m_mlm
|
||||
m_sdkc->closeWallpapersAt(at); // for waht ???
|
||||
m_settings->decreaseActiveWallpaperCounter();
|
||||
qDebug() << "current wall count... " << m_settings->activeWallpaperCounter();
|
||||
}
|
||||
return isFound;
|
||||
});
|
||||
m_screenPlayWallpaperList.erase(toRemove, m_screenPlayWallpaperList.end());
|
||||
qDebug() << "After removing: No of walls in list: " << m_screenPlayWallpaperList.size();
|
||||
|
||||
}
|
||||
|
||||
QVector<int> ScreenPlay::getMonitorByAppID(const QString &appID) const
|
||||
std::vector<int> ScreenPlay::getMonitorByAppID(const QString& appID) const
|
||||
{
|
||||
for (const RefSPWall& refSPWallpaper: m_screenPlayWallpaperList) {
|
||||
if (refSPWallpaper.data()->appID() == appID) {
|
||||
return refSPWallpaper.data()->screenNumber();
|
||||
}
|
||||
}
|
||||
return QVector<int>{};
|
||||
return std::vector<int>{};
|
||||
}
|
||||
|
||||
QString ScreenPlay::generateID() const
|
||||
@ -141,6 +160,7 @@ QString ScreenPlay::generateID() const
|
||||
return randomString;
|
||||
}
|
||||
|
||||
|
||||
ScreenPlayWallpaper::ScreenPlayWallpaper(const std::vector<int>& screenNumber, const QString& projectPath,
|
||||
const QString& previewImage, const float volume,
|
||||
const QString& fillMode, const QString& type, ScreenPlay *parent)
|
||||
|
@ -23,11 +23,11 @@
|
||||
class ScreenPlayWallpaper;
|
||||
class ScreenPlayWidget;
|
||||
|
||||
// conveniences types
|
||||
// convenience types
|
||||
using RefSPWall = QSharedPointer<ScreenPlayWallpaper>;
|
||||
using RefSPWidget = QSharedPointer<ScreenPlayWidget>;
|
||||
|
||||
class ScreenPlay : public QObject {
|
||||
class ScreenPlay final: public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
InstalledListModel *const m_ilm{nullptr};
|
||||
@ -48,6 +48,9 @@ public:
|
||||
// copy and move disable(for now) : remember rule of 1/3/5
|
||||
Q_DISABLE_COPY_MOVE(ScreenPlay)
|
||||
|
||||
// destructor
|
||||
~ScreenPlay();
|
||||
|
||||
// getters
|
||||
const InstalledListModel* listModelInstalled() const noexcept;
|
||||
const Settings* settings() const noexcept;
|
||||
@ -57,15 +60,12 @@ public:
|
||||
const std::vector<RefSPWall>& spWallList() const noexcept;
|
||||
const std::vector<RefSPWidget>& spWidgetList() const noexcept;
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
void allWallpaperRemoved() const;
|
||||
void projectSettingsListModelFound(ProjectSettingsListModel* li, const QString& type) const;
|
||||
void projectSettingsListModelNotFound() const;
|
||||
|
||||
public slots:
|
||||
void removeWallpaperAt(int at);
|
||||
void createWallpaper(
|
||||
const int monitorIndex, QUrl absoluteStoragePath,
|
||||
const QString& previewImage, const float volume,
|
||||
@ -75,8 +75,8 @@ public slots:
|
||||
void requestProjectSettingsListModelAt(const int index) const noexcept;
|
||||
void setWallpaperValue(const int at, const QString& key, const QString& value) noexcept;
|
||||
void setAllWallpaperValue(const QString& key, const QString& value) noexcept;
|
||||
void removeWallpaperAt(const int at);
|
||||
QVector<int> getMonitorByAppID(const QString &appID) const;
|
||||
void removeWallpaperAt(const int at = 0);
|
||||
std::vector<int> getMonitorByAppID(const QString& appID) const;
|
||||
QString generateID() const;
|
||||
};
|
||||
|
||||
|
@ -34,10 +34,15 @@ void SDKConnector::closeAllWallpapers()
|
||||
|
||||
void SDKConnector::closeWallpapersAt(int at)
|
||||
{
|
||||
for (int i = 0; i < m_clients.size(); ++i) {
|
||||
if (m_clients.at(i).data()->monitor().size() > 0) {
|
||||
if (m_clients.at(i).data()->monitor().at(0) == at) {
|
||||
m_clients.at(i).data()->close();
|
||||
for (const QSharedPointer<SDKConnection>& refSDKConnection : m_clients) {
|
||||
refSDKConnection->close();
|
||||
if (!refSDKConnection->monitor().empty()) {
|
||||
// problem here !!
|
||||
if (refSDKConnection->monitor().at(0) == at) {
|
||||
refSDKConnection->close();
|
||||
qDebug() << "Wall Closed...!";
|
||||
} else {
|
||||
qDebug() << "COULD NOT CLOSE!";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "no wp window ";
|
||||
|
Loading…
Reference in New Issue
Block a user