You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
153 lines
4.2 KiB
C++
153 lines
4.2 KiB
C++
4 years ago
|
/*
|
||
|
* Copyright 2021 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 "exporttemplatehandler.h"
|
||
|
|
||
|
// local
|
||
|
#include "ui_exporttemplatedialog.h"
|
||
4 years ago
|
#include "exporttemplatedialog.h"
|
||
|
#include "appletsmodel.h"
|
||
|
#include "delegates/normalcheckboxdelegate.h"
|
||
|
#include "../settingsdialog/layoutscontroller.h"
|
||
4 years ago
|
#include "../../data/appletdata.h"
|
||
4 years ago
|
#include "../../layout/genericlayout.h"
|
||
4 years ago
|
#include "../../layouts/storage.h"
|
||
4 years ago
|
#include "../../view/view.h"
|
||
4 years ago
|
|
||
4 years ago
|
//! KDE
|
||
|
#include <KLocalizedString>
|
||
|
|
||
4 years ago
|
//! Plasma
|
||
|
#include <Plasma/Containment>
|
||
|
|
||
4 years ago
|
namespace Latte {
|
||
|
namespace Settings {
|
||
|
namespace Handler {
|
||
|
|
||
|
ExportTemplateHandler::ExportTemplateHandler(Dialog::ExportTemplateDialog *parentDialog)
|
||
|
: Generic(parentDialog),
|
||
|
m_parentDialog(parentDialog),
|
||
|
m_ui(m_parentDialog->ui()),
|
||
4 years ago
|
m_appletsModel(new Model::Applets(this))
|
||
|
{
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
ExportTemplateHandler::ExportTemplateHandler(Dialog::ExportTemplateDialog *parentDialog, const QString &layoutName, const QString &layoutId)
|
||
|
: ExportTemplateHandler(parentDialog)
|
||
|
{
|
||
|
loadLayoutApplets(layoutName, layoutId);
|
||
|
}
|
||
|
|
||
|
ExportTemplateHandler::ExportTemplateHandler(Dialog::ExportTemplateDialog *parentDialog, Latte::View *view)
|
||
|
: ExportTemplateHandler(parentDialog)
|
||
4 years ago
|
{
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
ExportTemplateHandler::~ExportTemplateHandler()
|
||
|
{
|
||
|
}
|
||
|
|
||
4 years ago
|
|
||
4 years ago
|
void ExportTemplateHandler::init()
|
||
|
{
|
||
4 years ago
|
m_ui->appletsTable->horizontalHeader()->setStretchLastSection(true);
|
||
4 years ago
|
m_ui->appletsTable->horizontalHeader()->setSectionsClickable(false);
|
||
|
|
||
4 years ago
|
m_ui->appletsTable->verticalHeader()->setVisible(false);
|
||
|
|
||
4 years ago
|
m_ui->appletsTable->setItemDelegateForColumn(Model::Applets::NAMECOLUMN, new Settings::Applets::Delegate::NormalCheckBox(this));
|
||
|
|
||
4 years ago
|
//! Applets Model
|
||
4 years ago
|
m_appletsProxyModel = new QSortFilterProxyModel(this);
|
||
|
m_appletsProxyModel->setSourceModel(m_appletsModel);
|
||
|
m_appletsProxyModel->setSortRole(Model::Applets::SORTINGROLE);
|
||
|
m_appletsProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||
4 years ago
|
// m_appletsProxyModel->sort(Model::Applets::NAMECOLUMN, Qt::AscendingOrder);
|
||
4 years ago
|
|
||
|
m_ui->appletsTable->setModel(m_appletsProxyModel);
|
||
4 years ago
|
|
||
4 years ago
|
//! Buttons
|
||
|
connect(m_ui->deselectAllBtn, &QPushButton::clicked, this, &ExportTemplateHandler::onDeselectAll);
|
||
|
connect(m_ui->selectAllBtn, &QPushButton::clicked, this, &ExportTemplateHandler::onSelectAll);
|
||
|
connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked, this, &ExportTemplateHandler::onReset);
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
void ExportTemplateHandler::loadLayoutApplets(const QString &layoutName, const QString &layoutId)
|
||
4 years ago
|
{
|
||
4 years ago
|
Data::AppletsTable c_data = Latte::Layouts::Storage::self()->plugins(layoutId);
|
||
4 years ago
|
m_appletsModel->setData(c_data);
|
||
|
m_parentDialog->setWindowTitle(i18n("Export Layout Template"));
|
||
|
}
|
||
|
|
||
|
void ExportTemplateHandler::loadViewApplets(Latte::View *view)
|
||
|
{
|
||
4 years ago
|
Data::AppletsTable c_data = Latte::Layouts::Storage::self()->plugins(view->layout(), view->containment()->id());
|
||
4 years ago
|
m_appletsModel->setData(c_data);
|
||
4 years ago
|
m_parentDialog->setWindowTitle(i18n("Export View Template"));
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
void ExportTemplateHandler::onReset()
|
||
|
{
|
||
4 years ago
|
m_appletsModel->reset();
|
||
|
}
|
||
|
|
||
|
void ExportTemplateHandler::onSelectAll()
|
||
|
{
|
||
|
m_appletsModel->selectAll();
|
||
|
|
||
|
}
|
||
|
|
||
|
void ExportTemplateHandler::onDeselectAll()
|
||
|
{
|
||
|
m_appletsModel->deselectAll();
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
bool ExportTemplateHandler::dataAreChanged() const
|
||
|
{
|
||
4 years ago
|
return m_appletsModel->dataAreChanged();
|
||
4 years ago
|
}
|
||
|
|
||
|
bool ExportTemplateHandler::inDefaultValues() const
|
||
|
{
|
||
4 years ago
|
return !dataAreChanged();
|
||
4 years ago
|
}
|
||
|
|
||
|
|
||
|
void ExportTemplateHandler::reset()
|
||
|
{
|
||
4 years ago
|
m_appletsModel->reset();
|
||
4 years ago
|
}
|
||
|
|
||
|
void ExportTemplateHandler::resetDefaults()
|
||
|
{
|
||
4 years ago
|
reset();
|
||
4 years ago
|
}
|
||
|
|
||
|
void ExportTemplateHandler::save()
|
||
|
{
|
||
|
//do nothing
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|