diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 0c1af4f6d..6b15ba5aa 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/controllers) add_subdirectory(settings/data) add_subdirectory(settings/delegates) add_subdirectory(settings/models) diff --git a/app/settings/controllers/CMakeLists.txt b/app/settings/controllers/CMakeLists.txt new file mode 100644 index 000000000..024a65b36 --- /dev/null +++ b/app/settings/controllers/CMakeLists.txt @@ -0,0 +1,5 @@ +set(lattedock-app_SRCS + ${lattedock-app_SRCS} + ${CMAKE_CURRENT_SOURCE_DIR}/layoutscontroller.cpp + PARENT_SCOPE +) diff --git a/app/settings/controllers/layoutscontroller.cpp b/app/settings/controllers/layoutscontroller.cpp new file mode 100644 index 000000000..a2826e0b7 --- /dev/null +++ b/app/settings/controllers/layoutscontroller.cpp @@ -0,0 +1,42 @@ +/* + * 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 "layoutscontroller.h" + + +namespace Latte { +namespace Settings { +namespace Controller { + +Layouts::Layouts(QObject *parent, Latte::Corona *corona) + : QObject(parent), + m_corona(corona), + m_model(new Model::Layouts(this, corona)) +{ +} + +Model::Layouts *Layouts::model() const +{ + return m_model; +} + +} +} +} diff --git a/app/settings/controllers/layoutscontroller.h b/app/settings/controllers/layoutscontroller.h new file mode 100644 index 000000000..aaf3bf1d9 --- /dev/null +++ b/app/settings/controllers/layoutscontroller.h @@ -0,0 +1,51 @@ +/* + * 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 SETTINGSLAYOUTSCONTROLLER_H +#define SETTINGSLAYOUTSCONTROLLER_H + +// local +#include "../models/layoutsmodel.h" +#include "../../lattecorona.h" + +namespace Latte { +namespace Settings { +namespace Controller { + +class Layouts : public QObject +{ + Q_OBJECT + +public: + explicit Layouts(QObject *parent, Latte::Corona *corona); + + Model::Layouts *model() const; + +private: + Latte::Corona *m_corona{nullptr}; + Model::Layouts *m_model{nullptr}; + +}; + +} +} +} + +#endif diff --git a/app/settings/settingsdialog.cpp b/app/settings/settingsdialog.cpp index eded3e75f..a1965c78a 100644 --- a/app/settings/settingsdialog.cpp +++ b/app/settings/settingsdialog.cpp @@ -101,9 +101,10 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona) connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked , this, &SettingsDialog::restoreDefaults); - m_model = new Settings::Model::Layouts(this, m_corona); + m_layoutsController = new Settings::Controller::Layouts(this, m_corona); + m_model = m_layoutsController->model(); - ui->layoutsView->setModel(m_model); + ui->layoutsView->setModel(m_layoutsController->model()); ui->layoutsView->horizontalHeader()->setStretchLastSection(true); ui->layoutsView->verticalHeader()->setVisible(false); diff --git a/app/settings/settingsdialog.h b/app/settings/settingsdialog.h index 56684cb14..dc8ed8a71 100644 --- a/app/settings/settingsdialog.h +++ b/app/settings/settingsdialog.h @@ -26,6 +26,7 @@ #include "../liblatte2/types.h" #include "data/layoutstable.h" #include "models/layoutsmodel.h" +#include "controllers/layoutscontroller.h" // Qt #include @@ -158,6 +159,7 @@ private: //QStandardItemModel *m_model{nullptr}; Settings::Model::Layouts *m_model{nullptr}; + Settings::Controller::Layouts *m_layoutsController{nullptr}; Ui::SettingsDialog *ui; //! SharedLayout #settingsid, Shares #settingsid