1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-11 13:18:13 +03:00

support new layouts data for settings

This commit is contained in:
Michail Vourlakos 2020-03-10 20:37:01 +02:00
parent 1ee24adbbd
commit 7bb01f150a
6 changed files with 290 additions and 0 deletions

View File

@ -14,6 +14,7 @@ add_subdirectory(layouts)
add_subdirectory(package)
add_subdirectory(plasma/extended)
add_subdirectory(settings)
add_subdirectory(settings/data)
add_subdirectory(settings/delegates)
add_subdirectory(settings/tools)
add_subdirectory(shortcuts)

View File

@ -0,0 +1,6 @@
set(lattedock-app_SRCS
${lattedock-app_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/layout.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layoutstable.cpp
PARENT_SCOPE
)

View File

@ -0,0 +1,89 @@
/*
* Copyright 2020 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 "layout.h"
namespace Latte {
namespace Settings {
namespace Data {
Layout::Layout()
{
}
Layout::~Layout()
{
}
Layout::Layout(const Layout &o)
: id(o.id),
name(o.name),
background(o.background),
backgroundTextColor(o.backgroundTextColor),
isLocked(o.isLocked),
isShownInMenu(o.isShownInMenu),
hasDisabledBorders(o.hasDisabledBorders),
activities(o.activities),
shares(o.shares)
{
}
Layout &Layout::operator=(const Layout &rhs)
{
id = rhs.id;
name = rhs.name;
background = rhs.background;
backgroundTextColor = rhs.backgroundTextColor;
isLocked = rhs.isLocked;
isShownInMenu = rhs.isShownInMenu;
hasDisabledBorders = rhs.hasDisabledBorders;
activities = rhs.activities;
shares = rhs.shares;
return *this;
}
bool Layout::operator==(const Layout &rhs) const
{
return (id == rhs.id)
&& (name == rhs.name)
&& (background == rhs.background)
&& (backgroundTextColor == rhs.backgroundTextColor)
&& (isLocked == rhs.isLocked)
&& (isShownInMenu == rhs.isShownInMenu)
&& (hasDisabledBorders == rhs.hasDisabledBorders)
&& (activities == rhs.activities)
&& (shares == rhs.shares);
}
bool Layout::operator!=(const Layout &rhs) const
{
return !(*this == rhs);
}
bool Layout::isShared() const
{
return !shares.isEmpty();
}
}
}
}

View File

@ -0,0 +1,64 @@
/*
* Copyright 2020 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 SETTINGSDATALAYOUT_H
#define SETTINGSDATALAYOUT_H
#include <QString>
#include <QStringList>
namespace Latte {
namespace Settings {
namespace Data {
class Layout
{
public:
Layout();
~Layout();
Layout(const Layout &o);
//! Layout data
QString id;
QString name;
QString background;
QString backgroundTextColor;
bool isLocked{false};
bool isShownInMenu{false};
bool hasDisabledBorders{false};
QStringList activities;
QStringList shares;
//! Functionality
bool isShared() const;
//! Operators
Layout &operator=(const Layout &rhs);
bool operator==(const Layout &rhs) const;
bool operator!=(const Layout &rhs) const;
};
}
}
}
#endif

View File

@ -0,0 +1,75 @@
/*
* Copyright 2020 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 "layoutstable.h"
namespace Latte {
namespace Settings {
namespace Data {
LayoutsTable::LayoutsTable()
{
}
LayoutsTable::~LayoutsTable()
{
}
//! Operators
LayoutsTable &LayoutsTable::operator=(const LayoutsTable &rhs)
{
m_layouts = rhs.m_layouts;
return (*this);
}
LayoutsTable &LayoutsTable::operator<<(const Layout &rhs)
{
if (!rhs.id.isEmpty()) {
m_layouts[rhs.id] = rhs;
}
return (*this);
}
bool LayoutsTable::operator==(const LayoutsTable &rhs) const
{
if (m_layouts.keys().count() != rhs.m_layouts.keys().count()) {
return false;
}
for(const QString &id : m_layouts.keys()) {
if (!rhs.m_layouts.contains(id) || (m_layouts[id] != rhs.m_layouts[id])) {
return false;
}
}
return true;
}
bool LayoutsTable::operator!=(const LayoutsTable &rhs) const
{
return !(*this == rhs);
}
}
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright 2020 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 SETTINGSDATALAYOUTSTABLE_H
#define SETTINGSDATALAYOUTSTABLE_H
#include "layout.h"
#include <QHash>
namespace Latte {
namespace Settings {
namespace Data {
class LayoutsTable
{
public:
LayoutsTable();
~LayoutsTable();
//! Operators
LayoutsTable &operator=(const LayoutsTable &rhs);
LayoutsTable &operator<<(const Layout &rhs);
bool operator==(const LayoutsTable &rhs) const;
bool operator!=(const LayoutsTable &rhs) const;
protected:
//! #id, layout_record
QHash<QString, Layout> m_layouts;
};
}
}
}
#endif