From 7bb01f150ab986d3e6d2cf6095b2881d66a6acb7 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 10 Mar 2020 20:37:01 +0200 Subject: [PATCH] support new layouts data for settings --- app/CMakeLists.txt | 1 + app/settings/data/CMakeLists.txt | 6 ++ app/settings/data/layout.cpp | 89 ++++++++++++++++++++++++++++++ app/settings/data/layout.h | 64 +++++++++++++++++++++ app/settings/data/layoutstable.cpp | 75 +++++++++++++++++++++++++ app/settings/data/layoutstable.h | 55 ++++++++++++++++++ 6 files changed, 290 insertions(+) create mode 100644 app/settings/data/CMakeLists.txt create mode 100644 app/settings/data/layout.cpp create mode 100644 app/settings/data/layout.h create mode 100644 app/settings/data/layoutstable.cpp create mode 100644 app/settings/data/layoutstable.h diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index a83bfcb23..275e04e4d 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -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) diff --git a/app/settings/data/CMakeLists.txt b/app/settings/data/CMakeLists.txt new file mode 100644 index 000000000..480c90d73 --- /dev/null +++ b/app/settings/data/CMakeLists.txt @@ -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 +) diff --git a/app/settings/data/layout.cpp b/app/settings/data/layout.cpp new file mode 100644 index 000000000..68460c140 --- /dev/null +++ b/app/settings/data/layout.cpp @@ -0,0 +1,89 @@ +/* + * Copyright 2020 Michail Vourlakos + * + * 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 . + * + */ + +#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(); +} + +} +} +} diff --git a/app/settings/data/layout.h b/app/settings/data/layout.h new file mode 100644 index 000000000..6f05171ef --- /dev/null +++ b/app/settings/data/layout.h @@ -0,0 +1,64 @@ +/* + * Copyright 2020 Michail Vourlakos + * + * 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 . + * + */ + +#ifndef SETTINGSDATALAYOUT_H +#define SETTINGSDATALAYOUT_H + +#include +#include + +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 diff --git a/app/settings/data/layoutstable.cpp b/app/settings/data/layoutstable.cpp new file mode 100644 index 000000000..1076cd3a4 --- /dev/null +++ b/app/settings/data/layoutstable.cpp @@ -0,0 +1,75 @@ +/* + * Copyright 2020 Michail Vourlakos + * + * 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 . + * + */ + +#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); +} + +} +} +} diff --git a/app/settings/data/layoutstable.h b/app/settings/data/layoutstable.h new file mode 100644 index 000000000..5fabd7a8c --- /dev/null +++ b/app/settings/data/layoutstable.h @@ -0,0 +1,55 @@ +/* + * Copyright 2020 Michail Vourlakos + * + * 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 . + * + */ + +#ifndef SETTINGSDATALAYOUTSTABLE_H +#define SETTINGSDATALAYOUTSTABLE_H + +#include "layout.h" + +#include + +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 m_layouts; + +}; + +} +} +} + +#endif