mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-21 14:03:39 +03:00
actionsdialog: introduce handler
This commit is contained in:
parent
f830fb3165
commit
549779a3e2
@ -272,12 +272,24 @@ QString GenericTable<T>::idForName(const QString &name) const
|
||||
return QString();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
QStringList GenericTable<T>::ids() const
|
||||
{
|
||||
QStringList idlist;
|
||||
|
||||
for(int i=0; i<m_list.count(); ++i) {
|
||||
idlist << m_list[i].id;
|
||||
}
|
||||
|
||||
return idlist;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
QStringList GenericTable<T>::names() const
|
||||
{
|
||||
QStringList nms;
|
||||
|
||||
for(int i=0; i<m_list.count(); ++i) {
|
||||
for(int i=0; i<m_list.count(); ++i) {
|
||||
nms << m_list[i].name;
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
|
||||
QString idForName(const QString &name) const;
|
||||
|
||||
QStringList ids() const;
|
||||
QStringList names() const;
|
||||
|
||||
void clear();
|
||||
|
@ -1,7 +1,8 @@
|
||||
set(lattedock-app_SRCS
|
||||
${lattedock-app_SRCS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/actionlistwidgetitem.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/actionsdialog.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/actionsdialog.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/actionshandler.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
|
81
app/settings/actionsdialog/actionshandler.cpp
Normal file
81
app/settings/actionsdialog/actionshandler.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2021 Michail Vourlakos <mvourlakos@gmail.com>
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "actionshandler.h"
|
||||
|
||||
// local
|
||||
#include "ui_actionsdialog.h"
|
||||
#include "actionsdialog.h"
|
||||
#include "../../data/contextmenudata.h"
|
||||
|
||||
// KDE
|
||||
#include <KLocalizedString>
|
||||
|
||||
namespace Latte {
|
||||
namespace Settings {
|
||||
namespace Handler {
|
||||
|
||||
ActionsHandler::ActionsHandler(Dialog::ActionsDialog *dialog, const QStringList ¤tActions)
|
||||
: Generic(dialog),
|
||||
m_dialog(dialog),
|
||||
m_ui(m_dialog->ui())
|
||||
{
|
||||
init();
|
||||
c_alwaysActions = table(currentActions);
|
||||
}
|
||||
|
||||
ActionsHandler::~ActionsHandler()
|
||||
{
|
||||
}
|
||||
|
||||
void ActionsHandler::init()
|
||||
{
|
||||
def_alwaysActions = table(Data::ContextMenu::ACTIONSALWAYSVISIBLE);
|
||||
}
|
||||
|
||||
bool ActionsHandler::hasChangedData() const
|
||||
{
|
||||
return c_alwaysActions != c_alwaysActions;
|
||||
}
|
||||
|
||||
bool ActionsHandler::inDefaultValues() const
|
||||
{
|
||||
return c_alwaysActions == def_alwaysActions;
|
||||
}
|
||||
|
||||
Data::GenericTable<Data::Generic> ActionsHandler::table(const QStringList &ids)
|
||||
{
|
||||
Data::GenericTable<Data::Generic> bastable;
|
||||
|
||||
for(int i=0; i<ids.count(); ++i) {
|
||||
bastable << Data::Generic(ids[i], "");
|
||||
}
|
||||
|
||||
return bastable;
|
||||
}
|
||||
|
||||
QStringList ActionsHandler::currentData() const
|
||||
{
|
||||
return c_alwaysActions.ids();
|
||||
}
|
||||
|
||||
void ActionsHandler::reset()
|
||||
{
|
||||
c_alwaysActions = o_alwaysActions;
|
||||
}
|
||||
|
||||
void ActionsHandler::resetDefaults()
|
||||
{
|
||||
c_alwaysActions = def_alwaysActions;
|
||||
}
|
||||
|
||||
void ActionsHandler::save()
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
74
app/settings/actionsdialog/actionshandler.h
Normal file
74
app/settings/actionsdialog/actionshandler.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2021 Michail Vourlakos <mvourlakos@gmail.com>
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef ACTIONSHANDLER_H
|
||||
#define ACTIONSHANDLER_H
|
||||
|
||||
// local
|
||||
#include "../generic/generichandler.h"
|
||||
#include "../../data/generictable.h"
|
||||
|
||||
// Qt
|
||||
#include <QObject>
|
||||
|
||||
namespace Ui {
|
||||
class ActionsDialog;
|
||||
}
|
||||
|
||||
namespace Latte{
|
||||
namespace Settings{
|
||||
namespace Dialog{
|
||||
class ActionsDialog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace Latte {
|
||||
namespace Settings {
|
||||
namespace Handler {
|
||||
|
||||
//! Handlers are objects to handle the UI elements that semantically associate with specific
|
||||
//! ui::tabs or different windows. They are responsible also to handle the user interaction
|
||||
//! between controllers and views
|
||||
|
||||
class ActionsHandler : public Generic
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ActionsHandler(Dialog::ActionsDialog *dialog, const QStringList ¤tActions);
|
||||
~ActionsHandler();
|
||||
|
||||
bool hasChangedData() const override;
|
||||
bool inDefaultValues() const override;
|
||||
|
||||
QStringList currentData() const;
|
||||
|
||||
public slots:
|
||||
void reset() override;
|
||||
void resetDefaults() override;
|
||||
void save() override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
void initDefaults();
|
||||
|
||||
Data::GenericTable<Data::Generic> table(const QStringList &ids);
|
||||
|
||||
private:
|
||||
Data::GenericTable<Data::Generic> def_alwaysActions;
|
||||
|
||||
Data::GenericTable<Data::Generic> c_alwaysActions;
|
||||
Data::GenericTable<Data::Generic> o_alwaysActions;
|
||||
|
||||
Dialog::ActionsDialog *m_dialog{nullptr};
|
||||
Ui::ActionsDialog *m_ui{nullptr};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user