improve semantics for layout class

pull/2/head
Michail Vourlakos 7 years ago
parent e3d1001861
commit 92127577d1

@ -16,7 +16,7 @@ set(lattedock-app_SRCS
globalshortcuts.cpp
universalsettings.cpp
layoutmanager.cpp
layoutsettings.cpp
layout.cpp
layoutconfigdialog.cpp
importer.cpp
layoutsDelegates/checkboxdelegate.cpp

@ -21,7 +21,7 @@
#include "importer.h"
#include "layoutmanager.h"
#include "layoutsettings.h"
#include "layout.h"
#include "screenpool.h"
#include "../liblattedock/dock.h"
@ -164,7 +164,7 @@ bool Importer::importOldLayout(QString oldAppletsPath, QString newName, bool alt
}
//! update also the layout settings correctly
LayoutSettings newLayout(this, newLayoutPath, newName);
Layout newLayout(this, newLayoutPath, newName);
newLayout.setVersion(2);
newLayout.setLaunchers(layoutLaunchers);
@ -458,7 +458,7 @@ QString Importer::importLayoutHelper(QString fileName)
return QString();
}
QString newLayoutName = LayoutSettings::layoutName(fileName);
QString newLayoutName = Layout::layoutName(fileName);
newLayoutName = uniqueLayoutName(newLayoutName);
QFile(fileName).copy(QDir::homePath() + "/.config/latte/" + newLayoutName + ".layout.latte");
@ -477,7 +477,7 @@ QStringList Importer::availableLayouts()
QStringList layoutNames;
foreach (auto file, files) {
layoutNames.append(LayoutSettings::layoutName(file));
layoutNames.append(Layout::layoutName(file));
}
return layoutNames;

@ -18,14 +18,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "layoutsettings.h"
#include "layout.h"
#include <QFile>
#include <KSharedConfig>
namespace Latte {
LayoutSettings::LayoutSettings(QObject *parent, QString layoutFile, QString assignedName)
Layout::Layout(QObject *parent, QString layoutFile, QString assignedName)
: QObject(parent)
{
qDebug() << "Layout file to create object: " << layoutFile << " with name: " << assignedName;
@ -45,7 +45,7 @@ LayoutSettings::LayoutSettings(QObject *parent, QString layoutFile, QString assi
}
}
LayoutSettings::~LayoutSettings()
Layout::~Layout()
{
if (!m_layoutFile.isEmpty()) {
//saveConfig();
@ -53,21 +53,21 @@ LayoutSettings::~LayoutSettings()
}
}
void LayoutSettings::init()
void Layout::init()
{
connect(this, &LayoutSettings::activitiesChanged, this, &LayoutSettings::saveConfig);
connect(this, &LayoutSettings::versionChanged, this, &LayoutSettings::saveConfig);
connect(this, &LayoutSettings::colorChanged, this, &LayoutSettings::saveConfig);
connect(this, &LayoutSettings::showInMenuChanged, this, &LayoutSettings::saveConfig);
connect(this, &LayoutSettings::launchersChanged, this, &LayoutSettings::saveConfig);
connect(this, &Layout::activitiesChanged, this, &Layout::saveConfig);
connect(this, &Layout::versionChanged, this, &Layout::saveConfig);
connect(this, &Layout::colorChanged, this, &Layout::saveConfig);
connect(this, &Layout::showInMenuChanged, this, &Layout::saveConfig);
connect(this, &Layout::launchersChanged, this, &Layout::saveConfig);
}
int LayoutSettings::version() const
int Layout::version() const
{
return m_version;
}
void LayoutSettings::setVersion(int ver)
void Layout::setVersion(int ver)
{
if (m_version == ver) {
return;
@ -78,12 +78,12 @@ void LayoutSettings::setVersion(int ver)
emit versionChanged();
}
bool LayoutSettings::showInMenu() const
bool Layout::showInMenu() const
{
return m_showInMenu;
}
void LayoutSettings::setShowInMenu(bool show)
void Layout::setShowInMenu(bool show)
{
if (m_showInMenu == show) {
return;
@ -93,12 +93,12 @@ void LayoutSettings::setShowInMenu(bool show)
emit showInMenuChanged();
}
QString LayoutSettings::name() const
QString Layout::name() const
{
return m_layoutName;
}
void LayoutSettings::setName(QString name)
void Layout::setName(QString name)
{
if (m_layoutName == name) {
return;
@ -111,12 +111,12 @@ void LayoutSettings::setName(QString name)
emit nameChanged();
}
QString LayoutSettings::color() const
QString Layout::color() const
{
return m_color;
}
void LayoutSettings::setColor(QString color)
void Layout::setColor(QString color)
{
if (m_color == color) {
return;
@ -127,12 +127,12 @@ void LayoutSettings::setColor(QString color)
}
QString LayoutSettings::file() const
QString Layout::file() const
{
return m_layoutFile;
}
void LayoutSettings::setFile(QString file)
void Layout::setFile(QString file)
{
if (m_layoutFile == file) {
return;
@ -144,12 +144,12 @@ void LayoutSettings::setFile(QString file)
emit fileChanged();
}
QStringList LayoutSettings::launchers() const
QStringList Layout::launchers() const
{
return m_launchers;
}
void LayoutSettings::setLaunchers(QStringList launcherList)
void Layout::setLaunchers(QStringList launcherList)
{
if (m_launchers == launcherList)
return;
@ -159,12 +159,12 @@ void LayoutSettings::setLaunchers(QStringList launcherList)
emit launchersChanged();
}
QStringList LayoutSettings::activities() const
QStringList Layout::activities() const
{
return m_activities;
}
void LayoutSettings::setActivities(QStringList activities)
void Layout::setActivities(QStringList activities)
{
if (m_activities == activities) {
return;
@ -175,7 +175,7 @@ void LayoutSettings::setActivities(QStringList activities)
emit activitiesChanged();
}
bool LayoutSettings::fileIsBroken() const
bool Layout::fileIsBroken() const
{
if (m_layoutFile.isEmpty() || !QFile(m_layoutFile).exists()) {
return false;
@ -230,7 +230,7 @@ bool LayoutSettings::fileIsBroken() const
}
QString LayoutSettings::layoutName(const QString &fileName)
QString Layout::layoutName(const QString &fileName)
{
int lastSlash = fileName.lastIndexOf("/");
QString tempLayoutFile = fileName;
@ -242,7 +242,7 @@ QString LayoutSettings::layoutName(const QString &fileName)
return layoutName;
}
void LayoutSettings::loadConfig()
void Layout::loadConfig()
{
m_version = m_layoutGroup.readEntry("version", 2);
m_color = m_layoutGroup.readEntry("color", QString("blue"));
@ -251,7 +251,7 @@ void LayoutSettings::loadConfig()
m_launchers = m_layoutGroup.readEntry("launchers", QStringList());
}
void LayoutSettings::saveConfig()
void Layout::saveConfig()
{
qDebug() << "layout is saving... for layout:" << m_layoutName;
m_layoutGroup.writeEntry("version", m_version);

@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LAYOUTSETTINGS_H
#define LAYOUTSETTINGS_H
#ifndef LAYOUT_H
#define LAYOUT_H
#include <QObject>
@ -35,7 +35,7 @@ namespace Latte {
//! This class is responsible to hold the settings for a specific layout.
//! It also updates always the relevant layout configuration concerning
//! its general settings (no the containments)
class LayoutSettings : public QObject {
class Layout : public QObject {
Q_OBJECT
Q_PROPERTY(bool showInMenu READ showInMenu WRITE setShowInMenu NOTIFY showInMenuChanged)
Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
@ -44,8 +44,8 @@ class LayoutSettings : public QObject {
Q_PROPERTY(QStringList activities READ activities WRITE setActivities NOTIFY activitiesChanged)
public:
LayoutSettings(QObject *parent, QString layoutFile, QString layoutName = QString());
~LayoutSettings() override;
Layout(QObject *parent, QString layoutFile, QString layoutName = QString());
~Layout() override;
bool showInMenu() const;
void setShowInMenu(bool show);
@ -104,4 +104,4 @@ private:
}
#endif // LAYOUTSETTINGS_H
#endif // LAYOUT_H

@ -21,7 +21,7 @@
#include "ui_layoutconfigdialog.h"
#include "layoutconfigdialog.h"
#include "layoutsettings.h"
#include "layout.h"
#include "layoutsDelegates/checkboxdelegate.h"
#include "layoutsDelegates/colorcmbboxdelegate.h"
#include "layoutsDelegates/activitycmbboxdelegate.h"
@ -154,7 +154,7 @@ void LayoutConfigDialog::on_newButton_clicked()
//! find Default preset path
foreach (auto preset, m_manager->presetsPaths()) {
QString presetName = LayoutSettings::layoutName(preset);
QString presetName = Layout::layoutName(preset);
if (presetName == "Default") {
QByteArray presetNameChars = presetName.toUtf8();
@ -187,7 +187,7 @@ void LayoutConfigDialog::on_copyButton_clicked()
QString copiedId = tempDir + "/" + layoutName + ".layout.latte";
QFile(id).copy(copiedId);
LayoutSettings *settings = new LayoutSettings(this, copiedId);
Layout *settings = new Layout(this, copiedId);
m_layouts[copiedId] = settings;
insertLayoutInfoAtRow(row + 1, copiedId, color, layoutName, menu, QStringList());
@ -427,7 +427,7 @@ void LayoutConfigDialog::on_exportButton_clicked()
return;
}
LayoutSettings layoutS(this, file);
Layout layoutS(this, file);
layoutS.setActivities(QStringList());
//NOTE: The pointer is automatically deleted when the event is closed
@ -499,7 +499,7 @@ void LayoutConfigDialog::restoreDefaults()
qDebug() << Q_FUNC_INFO;
foreach (auto preset, m_manager->presetsPaths()) {
QString presetName = LayoutSettings::layoutName(preset);
QString presetName = Layout::layoutName(preset);
QByteArray presetNameChars = presetName.toUtf8();
const char *prset_str = presetNameChars.data();
presetName = i18n(prset_str);
@ -513,7 +513,7 @@ void LayoutConfigDialog::restoreDefaults()
void LayoutConfigDialog::addLayoutForFile(QString file, QString layoutName, bool newTempDirectory, bool showNotification)
{
if (layoutName.isEmpty()) {
layoutName = LayoutSettings::layoutName(file);
layoutName = Layout::layoutName(file);
}
QString copiedId;
@ -526,7 +526,7 @@ void LayoutConfigDialog::addLayoutForFile(QString file, QString layoutName, bool
copiedId = file;
}
LayoutSettings *settings = new LayoutSettings(this, copiedId);
Layout *settings = new Layout(this, copiedId);
m_layouts[copiedId] = settings;
QString id = copiedId;
@ -560,7 +560,7 @@ void LayoutConfigDialog::loadLayouts()
QString layoutPath = QDir::homePath() + "/.config/latte/" + layout + ".layout.latte";
m_initLayoutPaths.append(layoutPath);
LayoutSettings *layoutSets = new LayoutSettings(this, layoutPath);
Layout *layoutSets = new Layout(this, layoutPath);
m_layouts[layoutPath] = layoutSets;
insertLayoutInfoAtRow(i, layoutPath, layoutSets->color(), layoutSets->name(),
@ -820,7 +820,7 @@ bool LayoutConfigDialog::saveAllChanges()
//qDebug() << i << ". " << id << " - " << color << " - " << name << " - " << menu << " - " << lActivities;
LayoutSettings *layout = name == m_manager->currentLayoutName() ? m_manager->currentLayout() : m_layouts[id];
Layout *layout = name == m_manager->currentLayoutName() ? m_manager->currentLayout() : m_layouts[id];
if (layout->color() != color) {
layout->setColor(color);
@ -862,7 +862,7 @@ bool LayoutConfigDialog::saveAllChanges()
QString newFile = QDir::homePath() + "/.config/latte/" + toRenameNames[i] + ".layout.latte";
QFile(toRenamePaths[i]).rename(newFile);
LayoutSettings *nLayout = new LayoutSettings(this, newFile);
Layout *nLayout = new Layout(this, newFile);
m_layouts[newFile] = nLayout;
for (int j = 0; j < m_model->rowCount(); ++j) {

@ -23,7 +23,7 @@
#define LAYOUTCONFIGDIALOG_H
#include "layoutmanager.h"
#include "layoutsettings.h"
#include "layout.h"
#include <QObject>
#include <QDialog>
@ -36,7 +36,7 @@ class LayoutConfigDialog;
namespace Latte {
class LayoutManager;
class LayoutSettings;
class Layout;
}
namespace Latte {
@ -96,7 +96,7 @@ private:
QStandardItemModel *m_model{nullptr};
Ui::LayoutConfigDialog *ui;
QHash<const QString, LayoutSettings *> m_layouts;
QHash<const QString, Layout *> m_layouts;
};
}

@ -111,7 +111,7 @@ QAction *LayoutManager::addWidgetsAction()
return m_addWidgetsAction;
}
LayoutSettings *LayoutManager::currentLayout()
Layout *LayoutManager::currentLayout()
{
return m_currentLayout;
}
@ -134,7 +134,7 @@ QString LayoutManager::defaultLayoutName() const
{
QByteArray presetNameOrig = QString("preset" + QString::number(1)).toUtf8();
QString presetPath = m_corona->kPackage().filePath(presetNameOrig);
QString presetName = LayoutSettings::layoutName(presetPath);
QString presetName = Layout::layoutName(presetPath);
QByteArray presetNameChars = presetName.toUtf8();
presetName = i18n(presetNameChars);
@ -264,7 +264,7 @@ void LayoutManager::loadLayouts()
QStringList files = layoutDir.entryList(filter, QDir::Files | QDir::NoSymLinks);
foreach (auto layout, files) {
LayoutSettings layoutSets(this, layoutDir.absolutePath() + "/" + layout);
Layout layoutSets(this, layoutDir.absolutePath() + "/" + layout);
QStringList validActivityIds = validActivities(layoutSets.activities());
layoutSets.setActivities(validActivityIds);
@ -323,7 +323,7 @@ bool LayoutManager::switchToLayout(QString layoutName)
m_currentLayout->deleteLater();
}
m_currentLayout = new LayoutSettings(this, lPath, layoutName);
m_currentLayout = new Layout(this, lPath, layoutName);
emit currentLayoutChanged();
});
@ -384,7 +384,7 @@ void LayoutManager::importPreset(int presetNo, bool newInstanceIfPresent)
{
QByteArray presetNameOrig = QString("preset" + QString::number(presetNo)).toUtf8();
QString presetPath = m_corona->kPackage().filePath(presetNameOrig);
QString presetName = LayoutSettings::layoutName(presetPath);
QString presetName = Layout::layoutName(presetPath);
QByteArray presetNameChars = presetName.toUtf8();
presetName = i18n(presetNameChars);

@ -23,7 +23,7 @@
#include "dockcorona.h"
#include "importer.h"
#include "layoutsettings.h"
#include "layout.h"
#include "layoutconfigdialog.h"
#include "launcherssignals.h"
@ -33,7 +33,7 @@
#include <KLocalizedString>
class Importer;
class LayoutSettings;
class Layout;
class LayoutConfigDialog;
class LaunchersSignals;
@ -51,7 +51,7 @@ class LayoutManager : public QObject {
Q_PROPERTY(QAction *addWidgetsAction READ addWidgetsAction NOTIFY addWidgetsActionChanged)
Q_PROPERTY(LayoutSettings *currentLayout READ currentLayout NOTIFY currentLayoutChanged)
Q_PROPERTY(Layout *currentLayout READ currentLayout NOTIFY currentLayoutChanged)
Q_PROPERTY(LaunchersSignals *launchersSignals READ launchersSignals NOTIFY launchersSignalsChanged)
public:
@ -76,7 +76,7 @@ public:
QAction *addWidgetsAction();
LayoutSettings *currentLayout();
Layout *currentLayout();
LaunchersSignals *launchersSignals();
QStringList activities();
@ -121,7 +121,7 @@ private:
DockCorona *m_corona{nullptr};
Importer *m_importer{nullptr};
LayoutSettings *m_currentLayout{nullptr};
Layout *m_currentLayout{nullptr};
LaunchersSignals *m_launchersSignals{nullptr};
QString m_shouldSwitchToLayout;

@ -26,7 +26,7 @@
#include <KConfigGroup>
#include <KSharedConfig>
#include "layoutsettings.h"
#include "layout.h"
namespace Latte {

Loading…
Cancel
Save