File indexing completed on 2024-06-23 05:49:18
0001 /* 0002 This file is part of the Kasten Framework, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <kossebau@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #include "toollistmenucontroller.hpp" 0010 0011 // Kasten gui 0012 #include <Kasten/WidgetsDockable> 0013 #include <Kasten/ToolViewDockWidget> 0014 // KF 0015 #include <KXMLGUIClient> 0016 #include <KXMLGUIFactory> 0017 // Qt 0018 #include <QAction> 0019 0020 namespace Kasten { 0021 0022 static constexpr char ToolListActionListId[] = "tools_list"; 0023 0024 ToolListMenuController::ToolListMenuController(If::WidgetsDockable* widgetsDockable, 0025 KXMLGUIClient* guiClient) 0026 : mWidgetsDockable(widgetsDockable) 0027 , mGuiClient(guiClient) 0028 { 0029 // TODO: for now this is only called on start, so first create all tools/views before this controller 0030 updateActions(); 0031 } 0032 0033 void ToolListMenuController::setTargetModel(AbstractModel* model) 0034 { 0035 Q_UNUSED(model) 0036 } 0037 0038 void ToolListMenuController::updateActions() 0039 { 0040 mGuiClient->unplugActionList(QLatin1String(ToolListActionListId)); 0041 0042 qDeleteAll(mToolActionList); 0043 mToolActionList.clear(); 0044 0045 const QVector<ToolViewDockWidget*> dockWidgets = mWidgetsDockable->dockWidgets(); 0046 0047 mToolActionList.reserve(dockWidgets.size()); 0048 for (const ToolViewDockWidget* dockWidget : dockWidgets) { 0049 QAction* action = dockWidget->toggleViewAction(); 0050 action->setText(dockWidget->windowTitle()); 0051 // action->setText( mToolView->title() ); 0052 mToolActionList.append(action); 0053 } 0054 0055 mGuiClient->plugActionList(QLatin1String(ToolListActionListId), mToolActionList); 0056 } 0057 0058 } 0059 0060 #include "moc_toollistmenucontroller.cpp"