7#include "customtoolswidgetng.h"
10#include "customtoolsplugin.h"
11#include "customtoolsviewinterface.h"
13#include <KToggleAction>
16#include <QStackedWidget>
20class PimCommon::CustomToolsWidgetNgPrivate
23 CustomToolsWidgetNgPrivate() =
default;
25 QStackedWidget *mStackedWidget =
nullptr;
26 QList<PimCommon::CustomToolsViewInterface *> mListInterfaceView;
29CustomToolsWidgetNg::CustomToolsWidgetNg(
QWidget *parent)
31 , d(new
PimCommon::CustomToolsWidgetNgPrivate)
34 lay->setContentsMargins({});
37 lay->addWidget(d->mStackedWidget);
41CustomToolsWidgetNg::~CustomToolsWidgetNg() =
default;
45 d->mListInterfaceView.append(plugin);
46 d->mStackedWidget->addWidget(plugin);
49void CustomToolsWidgetNg::initializeView(KActionCollection *ac,
const QList<CustomToolsPlugin *> &localPluginsList)
51 for (CustomToolsPlugin *plugin : localPluginsList) {
52 PimCommon::CustomToolsViewInterface *localCreateView = plugin->createView(ac,
this);
53 d->mListInterfaceView.append(localCreateView);
54 d->mStackedWidget->addWidget(localCreateView);
58void CustomToolsWidgetNg::slotToolsWasClosed()
60 for (PimCommon::CustomToolsViewInterface *interface : std::as_const(d->mListInterfaceView)) {
61 interface->action()->setChecked(
false);
66void CustomToolsWidgetNg::slotActivateView(QWidget *w)
69 d->mStackedWidget->setCurrentWidget(w);
71 for (PimCommon::CustomToolsViewInterface *interface : std::as_const(d->mListInterfaceView)) {
73 interface->action()->setChecked(
false);
83QList<KToggleAction *> CustomToolsWidgetNg::actionList()
const
85 QList<KToggleAction *> lstActions;
86 lstActions.
reserve(d->mListInterfaceView.count());
87 for (PimCommon::CustomToolsViewInterface *interface : std::as_const(d->mListInterfaceView)) {
88 lstActions << interface->action();
93void CustomToolsWidgetNg::setText(
const QString &text)
96 auto currentWidget = d->mStackedWidget->currentWidget();
97 auto it = std::find_if(d->mListInterfaceView.cbegin(), d->mListInterfaceView.cend(), [currentWidget](
auto interface) {
98 return interface == currentWidget;
100 if (it != d->mListInterfaceView.cend()) {
101 (*it)->setText(text);
106#include "moc_customtoolswidgetng.cpp"
void reserve(qsizetype size)
void setObjectName(QAnyStringView name)