Warning, file /plasma/latte-dock/app/view/settings/viewsettingsfactory.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "viewsettingsfactory.h"
0007 
0008 // local
0009 #include "primaryconfigview.h"
0010 #include "widgetexplorerview.h"
0011 #include "../view.h"
0012 
0013 // Plasma
0014 #include <Plasma/Containment>
0015 
0016 namespace Latte {
0017 
0018 ViewSettingsFactory::ViewSettingsFactory(QObject *parent)
0019     : QObject(parent)
0020 {
0021 }
0022 
0023 ViewSettingsFactory::~ViewSettingsFactory()
0024 {
0025     if (m_primaryConfigView) {
0026         delete m_primaryConfigView;
0027     }
0028 }
0029 
0030 bool ViewSettingsFactory::hasOrphanSettings() const
0031 {
0032     return m_primaryConfigView && !m_primaryConfigView->parentView();
0033 }
0034 
0035 bool ViewSettingsFactory::hasVisibleSettings() const
0036 {
0037     return m_primaryConfigView && m_primaryConfigView->isVisible();
0038 }
0039 
0040 
0041 Plasma::Containment *ViewSettingsFactory::lastContainment()
0042 {
0043     return m_lastContainment;
0044 }
0045 
0046 ViewPart::PrimaryConfigView *ViewSettingsFactory::primaryConfigView()
0047 {
0048     return m_primaryConfigView;
0049 }
0050 
0051 ViewPart::PrimaryConfigView *ViewSettingsFactory::primaryConfigView(Latte::View *view)
0052 {
0053     if (!m_primaryConfigView) {
0054         //!set user configuring early enough in order to give config windows time to be created properly
0055         view->containment()->setUserConfiguring(true);
0056 
0057         m_primaryConfigView = new ViewPart::PrimaryConfigView(view);
0058     } else {
0059         auto previousView = m_primaryConfigView->parentView();
0060 
0061         if (previousView) {
0062             previousView->releaseConfigView();
0063         }
0064 
0065         m_primaryConfigView->setParentView(view);
0066     }
0067 
0068     if (view) {
0069         m_lastContainment = view->containment();
0070     }
0071 
0072     return m_primaryConfigView;
0073 }
0074 
0075 ViewPart::WidgetExplorerView *ViewSettingsFactory::widgetExplorerView(Latte::View *view)
0076 {
0077     //! it is deleted on hiding
0078     auto widgetExplorerView = new ViewPart::WidgetExplorerView(view);
0079     return widgetExplorerView;
0080 }
0081 
0082 
0083 }