1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-08 01:18:21 +03:00
latte-dock/app/data/layoutdata.cpp

189 lines
5.0 KiB
C++
Raw Normal View History

2020-03-10 21:37:01 +03:00
/*
2021-05-27 18:01:00 +03:00
SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
2020-03-10 21:37:01 +03:00
2020-03-12 12:53:37 +03:00
#include "layoutdata.h"
2020-03-10 21:37:01 +03:00
// Qt
#include <QDir>
2020-03-10 21:37:01 +03:00
namespace Latte {
namespace Data {
Layout::Layout()
: Generic()
2020-03-10 21:37:01 +03:00
{
}
2020-03-14 17:14:28 +03:00
Layout::Layout(Layout &&o)
: Generic(o),
2020-07-30 18:52:29 +03:00
icon(o.icon),
2020-03-14 17:14:28 +03:00
color(o.color),
background(o.background),
textColor(o.textColor),
lastUsedActivity(o.lastUsedActivity),
2020-03-14 17:14:28 +03:00
isActive(o.isActive),
isConsideredActive(o.isConsideredActive),
2020-03-14 17:14:28 +03:00
isLocked(o.isLocked),
isShownInMenu(o.isShownInMenu),
2020-08-09 13:53:43 +03:00
isTemplate(o.isTemplate),
2020-03-14 17:14:28 +03:00
hasDisabledBorders(o.hasDisabledBorders),
2021-05-03 02:50:23 +03:00
popUpMargin(o.popUpMargin),
2021-06-16 10:07:34 +03:00
schemeFile(o.schemeFile),
2020-03-14 17:14:28 +03:00
activities(o.activities),
2021-03-21 01:13:16 +03:00
backgroundStyle(o.backgroundStyle),
errors(o.errors),
warnings(o.warnings),
2021-03-21 01:13:16 +03:00
views(o.views)
2020-03-10 21:37:01 +03:00
{
}
Layout::Layout(const Layout &o)
: Generic(o),
2020-07-30 18:52:29 +03:00
icon(o.icon),
2020-03-12 16:12:13 +03:00
color(o.color),
2020-03-10 21:37:01 +03:00
background(o.background),
2020-03-12 16:12:13 +03:00
textColor(o.textColor),
lastUsedActivity(o.lastUsedActivity),
isActive(o.isActive),
isConsideredActive(o.isConsideredActive),
2020-03-10 21:37:01 +03:00
isLocked(o.isLocked),
isShownInMenu(o.isShownInMenu),
2020-08-09 13:53:43 +03:00
isTemplate(o.isTemplate),
2020-03-10 21:37:01 +03:00
hasDisabledBorders(o.hasDisabledBorders),
2021-05-03 02:50:23 +03:00
popUpMargin(o.popUpMargin),
2021-06-16 10:07:34 +03:00
schemeFile(o.schemeFile),
2020-03-10 21:37:01 +03:00
activities(o.activities),
2021-03-21 01:13:16 +03:00
backgroundStyle(o.backgroundStyle),
errors(o.errors),
warnings(o.warnings),
2021-03-21 01:13:16 +03:00
views(o.views)
2020-03-10 21:37:01 +03:00
{
}
2020-03-14 17:14:28 +03:00
Layout &Layout::operator=(Layout &&rhs)
{
id = rhs.id;
name = rhs.name;
2020-07-30 18:52:29 +03:00
icon = rhs.icon;
2020-03-14 17:14:28 +03:00
color = rhs.color;
background = rhs.background;
textColor = rhs.textColor;
lastUsedActivity = rhs.lastUsedActivity;
2020-03-14 17:14:28 +03:00
isActive = rhs.isActive;
isConsideredActive = rhs.isConsideredActive;
2020-03-14 17:14:28 +03:00
isLocked = rhs.isLocked;
isShownInMenu = rhs.isShownInMenu;
2020-08-09 13:53:43 +03:00
isTemplate = rhs.isTemplate;
2020-03-14 17:14:28 +03:00
hasDisabledBorders = rhs.hasDisabledBorders;
2021-05-03 02:50:23 +03:00
popUpMargin = rhs.popUpMargin;
2021-06-16 10:07:34 +03:00
schemeFile = rhs.schemeFile;
2020-03-14 17:14:28 +03:00
activities = rhs.activities;
2020-04-15 17:34:58 +03:00
backgroundStyle = rhs.backgroundStyle;
errors = rhs.errors;
warnings = rhs.warnings;
2021-03-21 01:13:16 +03:00
views = rhs.views;
2020-03-14 17:14:28 +03:00
return (*this);
}
2020-03-10 21:37:01 +03:00
Layout &Layout::operator=(const Layout &rhs)
{
id = rhs.id;
name = rhs.name;
2020-07-30 18:52:29 +03:00
icon = rhs.icon;
2020-03-12 16:12:13 +03:00
color = rhs.color;
2020-03-10 21:37:01 +03:00
background = rhs.background;
2020-03-12 16:12:13 +03:00
textColor = rhs.textColor;
lastUsedActivity = rhs.lastUsedActivity;
isActive = rhs.isActive;
isConsideredActive = rhs.isConsideredActive;
2020-03-10 21:37:01 +03:00
isLocked = rhs.isLocked;
isShownInMenu = rhs.isShownInMenu;
2020-08-09 13:53:43 +03:00
isTemplate = rhs.isTemplate;
2020-03-10 21:37:01 +03:00
hasDisabledBorders = rhs.hasDisabledBorders;
2021-05-03 02:50:23 +03:00
popUpMargin = rhs.popUpMargin;
2021-06-16 10:07:34 +03:00
schemeFile = rhs.schemeFile;
2020-03-10 21:37:01 +03:00
activities = rhs.activities;
2020-04-15 17:34:58 +03:00
backgroundStyle = rhs.backgroundStyle;
errors = rhs.errors;
warnings = rhs.warnings;
2021-03-21 01:13:16 +03:00
views = rhs.views;
2020-03-10 21:37:01 +03:00
2020-03-14 17:14:28 +03:00
return (*this);
2020-03-10 21:37:01 +03:00
}
bool Layout::operator==(const Layout &rhs) const
{
return (id == rhs.id)
&& (name == rhs.name)
2020-07-30 18:52:29 +03:00
&& (icon == rhs.icon)
2020-03-12 16:12:13 +03:00
&& (color == rhs.color)
2020-03-10 21:37:01 +03:00
&& (background == rhs.background)
2020-03-12 16:12:13 +03:00
&& (textColor == rhs.textColor)
//&& (lastUsedActivity == rhs.lastUsedActivity) /*Disabled because this is not needed in order to track layout changes for saving*/
//&& (isActive == rhs.isActive) /*Disabled because this is not needed in order to track layout changes for saving*/
//&& (isConsideredActive == rhs.isConsideredActive) /*Disabled because this is not needed in order to track layout changes for saving*/
2020-03-10 21:37:01 +03:00
&& (isLocked == rhs.isLocked)
&& (isShownInMenu == rhs.isShownInMenu)
2020-08-09 13:53:43 +03:00
&& (isTemplate == rhs.isTemplate)
2020-03-10 21:37:01 +03:00
&& (hasDisabledBorders == rhs.hasDisabledBorders)
2021-05-03 02:50:23 +03:00
&& (popUpMargin == rhs.popUpMargin)
2021-06-16 10:07:34 +03:00
&& (schemeFile == rhs.schemeFile)
2020-03-10 21:37:01 +03:00
&& (activities == rhs.activities)
2021-03-21 01:13:16 +03:00
&& (backgroundStyle == rhs.backgroundStyle)
//&& (errors == rhs.errors) /*Disabled because this is not needed in order to track layout changes for saving*/
//&& (warnings == rhs.warnings) /*Disabled because this is not needed in order to track layout changes for saving*/
2021-03-21 01:13:16 +03:00
&& (views == rhs.views);
2020-03-10 21:37:01 +03:00
}
bool Layout::operator!=(const Layout &rhs) const
{
return !(*this == rhs);
}
bool Layout::isOnAllActivities() const
{
return ((activities.count() == 1) && (activities[0] == ALLACTIVITIESID));
}
bool Layout::isForFreeActivities() const
{
return ((activities.count() == 1) && (activities[0] == FREEACTIVITIESID));
}
bool Layout::isTemporary() const
{
return id.startsWith("/tmp");
}
bool Layout::isEmpty() const
2020-03-10 21:37:01 +03:00
{
return isNull();
2020-03-10 21:37:01 +03:00
}
bool Layout::isNull() const
{
return (id.isEmpty() && name.isEmpty());
}
bool Layout::isSystemTemplate() const
2020-08-09 13:53:43 +03:00
{
return isTemplate && !id.startsWith(QDir::tempPath()) && !id.startsWith(QDir::homePath());
2020-08-09 13:53:43 +03:00
}
bool Layout::hasErrors() const
{
return errors > 0;
}
bool Layout::hasWarnings() const
{
return warnings > 0;
}
2020-03-10 21:37:01 +03:00
}
}