introduce ViewData and FIRSTSCREENID

work/spdx
Michail Vourlakos 4 years ago
parent f2cbbba0f6
commit e7eeb4f9fd

@ -11,5 +11,6 @@ set(lattedock-app_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/preferencesdata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/screendata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/uniqueidinfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/viewdata.cpp
PARENT_SCOPE
)

@ -0,0 +1,74 @@
/*
* Copyright 2021 Michail Vourlakos <mvourlakos@gmail.com>
*
* This file is part of Latte-Dock
*
* Latte-Dock is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Latte-Dock is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "viewdata.h"
namespace Latte {
namespace Data {
View::View()
: Generic()
{
}
View::View(View &&o)
: Generic(o),
onPrimary(o.onPrimary),
screen(o.screen),
maxLength(o.maxLength),
alignment(o.alignment)
{
}
View::View(const View &o)
: Generic(o),
onPrimary(o.onPrimary),
screen(o.screen),
maxLength(o.maxLength),
alignment(o.alignment)
{
}
View &View::operator=(const View &rhs)
{
id = rhs.id;
name = rhs.name;
onPrimary = rhs.onPrimary;
screen = rhs.screen;
maxLength = rhs.maxLength;
alignment = rhs.alignment;
return (*this);
}
View &View::operator=(View &&rhs)
{
id = rhs.id;
name = rhs.name;
onPrimary = rhs.onPrimary;
screen = rhs.screen;
maxLength = rhs.maxLength;
alignment = rhs.alignment;
return (*this);
}
}
}

@ -0,0 +1,61 @@
/*
* Copyright 2021 Michail Vourlakos <mvourlakos@gmail.com>
*
* This file is part of Latte-Dock
*
* Latte-Dock is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Latte-Dock is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef VIEWDATA_H
#define VIEWDATA_H
// local
#include <coretypes.h>
#include "genericdata.h"
#include "../screenpool.h"
//! Qt
#include <QMetaType>
#include <QString>
namespace Latte {
namespace Data {
class View : public Generic
{
public:
View();
View(View &&o);
View(const View &o);
//! View data
bool onPrimary{true};
int screen{Latte::ScreenPool::FIRSTSCREENID};
float maxLength{1.0};
Latte::Types::Alignment alignment{Latte::Types::Center};
//! Operators
View &operator=(const View &rhs);
View &operator=(View &&rhs);
};
}
}
Q_DECLARE_METATYPE(Latte::Data::View)
#endif

@ -41,6 +41,8 @@
namespace Latte {
const int ScreenPool::FIRSTSCREENID;
ScreenPool::ScreenPool(KSharedConfig::Ptr config, QObject *parent)
: QObject(parent),
m_configGroup(KConfigGroup(config, QStringLiteral("ScreenConnectors")))
@ -230,7 +232,7 @@ void ScreenPool::save()
for (int i=0; i<m_screensTable.rowCount(); ++i) {
Data::Screen screenRecord = m_screensTable[i];
if (screenRecord.id.toInt() >= 10) {
if (screenRecord.id.toInt() >= FIRSTSCREENID) {
m_configGroup.writeEntry(screenRecord.id, screenRecord.serialize());
}
}
@ -282,7 +284,7 @@ QString ScreenPool::connector(int id) const
int ScreenPool::firstAvailableId() const
{
//start counting from 10, first numbers will be used for special cases e.g. primaryScreen, id=0
int availableId = 10;
int availableId = FIRSTSCREENID;
for (int row=0; row<m_screensTable.rowCount(); ++row) {
if (!m_screensTable.containsId(QString::number(availableId))) {

@ -42,6 +42,8 @@ class ScreenPool : public QObject, public QAbstractNativeEventFilter
Q_OBJECT
public:
static const int FIRSTSCREENID = 10;
ScreenPool(KSharedConfig::Ptr config, QObject *parent = nullptr);
void load();
~ScreenPool() override;

Loading…
Cancel
Save