File indexing completed on 2024-12-22 04:14:54
0001 /* 0002 * SPDX-FileCopyrightText: 2009 Cyrille Berger <cberger@cberger.net> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "patterndocker_dock.h" 0008 0009 #include <QHBoxLayout> 0010 #include <QPushButton> 0011 0012 #include <klocalizedstring.h> 0013 0014 #include <kis_canvas_resource_provider.h> 0015 #include <kis_pattern_chooser.h> 0016 #include <KisViewManager.h> 0017 #include <resources/KoPattern.h> 0018 0019 PatternDockerDock::PatternDockerDock( ) 0020 : QDockWidget(i18n("Patterns")) 0021 { 0022 m_patternChooser = new KisPatternChooser(this); 0023 m_patternChooser->setPreviewOrientation(Qt::Vertical); 0024 m_patternChooser->setCurrentItem(0); 0025 m_patternChooser->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 0026 m_patternChooser->setMinimumHeight(160); 0027 0028 setWidget(m_patternChooser); 0029 } 0030 0031 void PatternDockerDock::setViewManager(KisViewManager* kisview) 0032 { 0033 KisCanvasResourceProvider* resourceProvider = kisview->canvasResourceProvider(); 0034 connect(resourceProvider, &KisCanvasResourceProvider::sigPatternChanged, this, &PatternDockerDock::patternChanged); 0035 0036 connect(m_patternChooser, SIGNAL(resourceSelected(KoResourceSP )), 0037 resourceProvider, SLOT(slotPatternActivated(KoResourceSP ))); 0038 } 0039 0040 0041 void PatternDockerDock::setCanvas(KoCanvasBase *canvas) 0042 { 0043 setEnabled(canvas != 0); 0044 } 0045 0046 0047 void PatternDockerDock::unsetCanvas() 0048 { 0049 setEnabled(false); 0050 } 0051 0052 0053 void PatternDockerDock::patternChanged(KoPatternSP pattern) 0054 { 0055 m_patternChooser->setCurrentPattern(pattern); 0056 } 0057