Krita Source Code Documentation
Loading...
Searching...
No Matches
KisWindowLayoutManager Class Reference

#include <KisWindowLayoutManager.h>

+ Inheritance diagram for KisWindowLayoutManager:

Classes

struct  Display
 
struct  DisplayLayout
 
struct  Private
 

Public Member Functions

void activeDocumentChanged (KisDocument *document)
 
bool isShowImageInAllWindowsEnabled () const
 
 KisWindowLayoutManager ()
 
QUuid primaryWindowId () const
 
bool primaryWorkspaceFollowsFocus () const
 
void setLastUsedLayout (KisWindowLayoutResource *layout)
 
void setPrimaryWorkspaceFollowsFocus (bool enabled, QUuid primaryWindow)
 
void setShowImageInAllWindowsEnabled (bool showInAll)
 
 ~KisWindowLayoutManager ()
 

Static Public Member Functions

static KisWindowLayoutManagerinstance ()
 

Private Slots

void slotFocusChanged (QWidget *, QWidget *)
 
void slotScreensChanged ()
 

Private Attributes

QScopedPointer< Privated
 

Detailed Description

Definition at line 20 of file KisWindowLayoutManager.h.

Constructor & Destructor Documentation

◆ KisWindowLayoutManager()

KisWindowLayoutManager::KisWindowLayoutManager ( )
explicit

Definition at line 114 of file KisWindowLayoutManager.cpp.

115 : d(new Private)
116{
117 d->loadDisplayLayouts();
118
119 connect(qobject_cast<KisApplication*>(KisApplication::instance()),
120 SIGNAL(focusChanged(QWidget*,QWidget*)),
121 this, SLOT(slotFocusChanged(QWidget*,QWidget*)));
122
123 connect(qGuiApp, SIGNAL(screenAdded(QScreen*)), this, SLOT(slotScreensChanged()));
124 connect(qGuiApp, SIGNAL(screenRemoved(QScreen*)), this, SLOT(slotScreensChanged()));
125}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void slotFocusChanged(QWidget *, QWidget *)
QScopedPointer< Private > d

References connect(), d, slotFocusChanged(), and slotScreensChanged().

◆ ~KisWindowLayoutManager()

KisWindowLayoutManager::~KisWindowLayoutManager ( )

Definition at line 127 of file KisWindowLayoutManager.cpp.

127 {
128 Q_FOREACH(DisplayLayout *layout, d->displayLayouts) {
129 delete layout;
130 }
131}

References d.

Member Function Documentation

◆ activeDocumentChanged()

void KisWindowLayoutManager::activeDocumentChanged ( KisDocument * document)

Definition at line 174 of file KisWindowLayoutManager.cpp.

175{
176 if (d->showImageInAllWindows) {
177 Q_FOREACH(QPointer<KisMainWindow> window, KisPart::instance()->mainWindows()) {
178 if (window->isHidden()) continue;
179
180 const auto view = window->activeView();
181 if (!view || view->document() != document) {
182 window->showDocument(document);
183 }
184 }
185 }
186}
static KisPart * instance()
Definition KisPart.cpp:131

References d, and KisPart::instance().

◆ instance()

KisWindowLayoutManager * KisWindowLayoutManager::instance ( )
static

Definition at line 109 of file KisWindowLayoutManager.cpp.

110{
111 return s_instance;
112}

◆ isShowImageInAllWindowsEnabled()

bool KisWindowLayoutManager::isShowImageInAllWindowsEnabled ( ) const

When enabled, main windows will synchronize to keep the same document active

Definition at line 153 of file KisWindowLayoutManager.cpp.

154{
155 return d->showImageInAllWindows;
156}

References d.

◆ primaryWindowId()

QUuid KisWindowLayoutManager::primaryWindowId ( ) const

Definition at line 169 of file KisWindowLayoutManager.cpp.

170{
171 return d->primaryWindow;
172}

References d.

◆ primaryWorkspaceFollowsFocus()

bool KisWindowLayoutManager::primaryWorkspaceFollowsFocus ( ) const

When enabled, a workspace dedicated as primary is used for any main window which receives focus. Meanwhile, the workspace of that window is used for the window which originally had the primary workspace.

Definition at line 158 of file KisWindowLayoutManager.cpp.

159{
160 return d->primaryWorkspaceFollowsFocus;
161}

References d.

◆ setLastUsedLayout()

void KisWindowLayoutManager::setLastUsedLayout ( KisWindowLayoutResource * layout)

Definition at line 199 of file KisWindowLayoutManager.cpp.

200{
201 // For automatic switching, only allow a window layout proper
202 KisSessionResource *session = dynamic_cast<KisSessionResource*>(layout);
203 if (session) return;
204
205 QList<QScreen*> screens = QGuiApplication::screens();
206 Q_FOREACH(DisplayLayout *displayLayout, d->displayLayouts) {
207 if (displayLayout->matches(screens)) {
208 displayLayout->preferredWindowLayout = layout->name();
209 d->saveDisplayLayout(*displayLayout);
210 break;
211 }
212 }
213}

References d, KisWindowLayoutManager::DisplayLayout::matches(), and KisWindowLayoutManager::DisplayLayout::preferredWindowLayout.

◆ setPrimaryWorkspaceFollowsFocus()

void KisWindowLayoutManager::setPrimaryWorkspaceFollowsFocus ( bool enabled,
QUuid primaryWindow )

Definition at line 163 of file KisWindowLayoutManager.cpp.

164{
165 d->primaryWorkspaceFollowsFocus = enabled;
166 d->primaryWindow = primaryWindow;
167}

References d.

◆ setShowImageInAllWindowsEnabled()

void KisWindowLayoutManager::setShowImageInAllWindowsEnabled ( bool showInAll)

Definition at line 133 of file KisWindowLayoutManager.cpp.

134{
135 bool wasEnabled = d->showImageInAllWindows;
136
137 d->showImageInAllWindows = showInAll;
138
139 if (!wasEnabled && showInAll) {
140 KisMainWindow *currentMainWindow = KisPart::instance()->currentMainwindow();
141 if (currentMainWindow) {
142 KisView *activeView = currentMainWindow->activeView();
143 if (activeView) {
144 KisDocument *document = activeView->document();
145 if (document) {
146 activeDocumentChanged(document);
147 }
148 }
149 }
150 }
151}
Main window for Krita.
QPointer< KisView > activeView
KisMainWindow * currentMainwindow() const
Definition KisPart.cpp:483
QPointer< KisDocument > document
Definition KisView.cpp:121
void activeDocumentChanged(KisDocument *document)

References activeDocumentChanged(), KisMainWindow::activeView, KisPart::currentMainwindow(), d, KisView::document, and KisPart::instance().

◆ slotFocusChanged

void KisWindowLayoutManager::slotFocusChanged ( QWidget * old,
QWidget * now )
privateslot

Definition at line 188 of file KisWindowLayoutManager.cpp.

189{
190 Q_UNUSED(old);
191
192 if (!now) return;
193 KisMainWindow *newMainWindow = qobject_cast<KisMainWindow*>(now->window());
194 if (!newMainWindow) return;
195
196 newMainWindow->windowFocused();
197}

References KisMainWindow::windowFocused().

◆ slotScreensChanged

void KisWindowLayoutManager::slotScreensChanged ( )
privateslot

Definition at line 215 of file KisWindowLayoutManager.cpp.

216{
217 QList<QScreen*> screens = QGuiApplication::screens();
218
219 Q_FOREACH(const DisplayLayout *displayLayout, d->displayLayouts) {
220 if (displayLayout->matches(screens)) {
222 KisWindowLayoutResourceSP layout = windowLayoutServer->resource("", "", displayLayout->preferredWindowLayout);
223
224 if (layout) {
226 layout->applyLayout();
227 return;
228 }
229 }
230 }
231
232 Q_FOREACH(QScreen *screen, screens) {
233 connect(screen, SIGNAL(geometryChanged(QRect)), this, SLOT(slotScreensChanged()), Qt::UniqueConnection);
234 }
235
236}
static KisResourceServerProvider * instance()
KoResourceServer< KisWindowLayoutResource > * windowLayoutServer()
void setLastUsedLayout(KisWindowLayoutResource *layout)
QSharedPointer< T > resource(const QString &md5, const QString &fileName, const QString &name)
resource retrieves a resource. If the md5sum is not empty, the resource will only be retrieved if a r...

References connect(), d, KisResourceServerProvider::instance(), KisWindowLayoutManager::DisplayLayout::matches(), KisWindowLayoutManager::DisplayLayout::preferredWindowLayout, KoResourceServer< T >::resource(), setLastUsedLayout(), slotScreensChanged(), and KisResourceServerProvider::windowLayoutServer().

Member Data Documentation

◆ d

QScopedPointer<Private> KisWindowLayoutManager::d
private

Definition at line 71 of file KisWindowLayoutManager.h.


The documentation for this class was generated from the following files: