Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Office
Calligra
Commits
60faa2a9
Commit
60faa2a9
authored
Jun 29, 2012
by
Sven Langkamp
Browse files
restore last used palette in the palette docker after start
CCBUG:299033
parent
37a47e71
Changes
6
Hide whitespace changes
Inline
Side-by-side
krita/plugins/extensions/dockers/defaultdockers/kis_palette_docker.cc
View file @
60faa2a9
...
...
@@ -20,6 +20,7 @@
#include <QComboBox>
#include <QVBoxLayout>
#include <QTimer>
#include <KoCanvasBase.h>
#include <KoResource.h>
...
...
@@ -27,6 +28,8 @@
#include <KoColorSetWidget.h>
#include <KoCanvasResourceManager.h>
#include <KoColorSpaceRegistry.h>
#include <KoResourceServerProvider.h>
#include <kis_config.h>
KisPaletteDocker
::
KisPaletteDocker
()
:
QDockWidget
(
i18n
(
"Palettes"
))
...
...
@@ -39,15 +42,29 @@ KisPaletteDocker::KisPaletteDocker()
QVBoxLayout
*
layout
=
new
QVBoxLayout
(
mainWidget
);
KoColorSetWidget
*
chooser
=
new
KoColorSetWidget
(
this
);
layout
->
addWidget
(
chooser
);
m_
chooser
=
new
KoColorSetWidget
(
this
);
layout
->
addWidget
(
m_
chooser
);
mainWidget
->
setLayout
(
layout
);
connect
(
chooser
,
SIGNAL
(
colorChanged
(
const
KoColor
&
,
bool
)),
SLOT
(
colorSelected
(
const
KoColor
&
,
bool
)));
connect
(
m_chooser
,
SIGNAL
(
colorChanged
(
const
KoColor
&
,
bool
)),
SLOT
(
colorSelected
(
const
KoColor
&
,
bool
)));
KisConfig
cfg
;
m_defaultPalette
=
cfg
.
defaultPalette
();
KoResourceServer
<
KoColorSet
>*
rServer
=
KoResourceServerProvider
::
instance
()
->
paletteServer
();
m_serverAdapter
=
new
KoResourceServerAdapter
<
KoColorSet
>
(
rServer
,
this
);
connect
(
m_serverAdapter
,
SIGNAL
(
resourceAdded
(
KoResource
*
)),
this
,
SLOT
(
resourceAddedToServer
(
KoResource
*
)));
m_serverAdapter
->
connectToResourceServer
();
checkForDefaultResource
();
}
KisPaletteDocker
::~
KisPaletteDocker
()
{
KoColorSet
*
colorSet
=
m_chooser
->
colorSet
();
if
(
colorSet
)
{
KisConfig
cfg
;
cfg
.
setDefaultPalette
(
colorSet
->
name
());
}
}
void
KisPaletteDocker
::
setCanvas
(
KoCanvasBase
*
canvas
)
...
...
@@ -75,6 +92,21 @@ QDockWidget* KisPaletteDockerFactory::createDockWidget()
return
dockWidget
;
}
void
KisPaletteDocker
::
resourceAddedToServer
(
KoResource
*
resource
)
{
// Avoiding resource mutex deadlock
QTimer
::
singleShot
(
0
,
this
,
SLOT
(
checkForDefaultResource
()
)
);
}
void
KisPaletteDocker
::
checkForDefaultResource
()
{
foreach
(
KoResource
*
resource
,
m_serverAdapter
->
resources
())
{
if
(
resource
->
name
()
==
m_defaultPalette
)
{
KoColorSet
*
colorSet
=
static_cast
<
KoColorSet
*>
(
resource
);
m_chooser
->
setColorSet
(
colorSet
);
}
}
}
#include "kis_palette_docker.moc"
krita/plugins/extensions/dockers/defaultdockers/kis_palette_docker.h
View file @
60faa2a9
...
...
@@ -25,7 +25,9 @@
#include <KoDockFactoryBase.h>
#include <KoColorSet.h>
#include <KoCanvasObserverBase.h>
#include <KoResourceServerAdapter.h>
class
KoColorSetWidget
;
class
KoColor
;
class
KisView2
;
...
...
@@ -52,6 +54,8 @@ public:
private
slots
:
void
colorSelected
(
const
KoColor
&
color
,
bool
final
);
void
resourceAddedToServer
(
KoResource
*
resource
);
void
checkForDefaultResource
();
private:
void
readNamedColor
(
void
);
...
...
@@ -59,6 +63,9 @@ private:
protected:
KoColorSet
*
m_currentPalette
;
KoCanvasBase
*
m_canvas
;
KoColorSetWidget
*
m_chooser
;
KoResourceServerAdapter
<
KoColorSet
>*
m_serverAdapter
;
QString
m_defaultPalette
;
};
class
KisPaletteDockerFactory
:
public
KoDockFactoryBase
...
...
krita/ui/kis_config.cc
View file @
60faa2a9
...
...
@@ -841,6 +841,15 @@ void KisConfig::setExportConfiguration(const QString &filterId, const KisPropert
}
QString
KisConfig
::
defaultPalette
()
{
return
m_cfg
.
readEntry
(
"defaultPalette"
,
QString
());
}
void
KisConfig
::
setDefaultPalette
(
const
QString
&
name
)
{
m_cfg
.
writeEntry
(
"defaultPalette"
,
name
);
}
bool
KisConfig
::
useSystemMonitorProfile
()
const
{
...
...
krita/ui/kis_config.h
View file @
60faa2a9
...
...
@@ -268,6 +268,9 @@ public:
bool
useSystemMonitorProfile
()
const
;
void
setUseSystemMonitorProfile
(
bool
_useSystemMonitorProfile
);
QString
defaultPalette
();
void
setDefaultPalette
(
const
QString
&
name
);
template
<
class
T
>
void
writeEntry
(
const
QString
&
name
,
const
T
&
value
)
{
m_cfg
.
writeEntry
(
name
,
value
);
...
...
libs/widgets/KoColorSetWidget.cpp
View file @
60faa2a9
...
...
@@ -247,6 +247,11 @@ void KoColorSetWidget::setColorSet(KoColorSet *colorSet)
d
->
fillColors
();
}
KoColorSet
*
KoColorSetWidget
::
colorSet
()
{
return
d
->
colorSet
;
}
void
KoColorSetWidget
::
resizeEvent
(
QResizeEvent
*
event
)
{
emit
widgetSizeChanged
(
event
->
size
());
...
...
libs/widgets/KoColorSetWidget.h
View file @
60faa2a9
...
...
@@ -59,6 +59,12 @@ public:
* @param colorSet pointer to the color set
*/
void
setColorSet
(
KoColorSet
*
colorSet
);
/**
* Gets the current color set
* @returns current color set,, 0 if none set
*/
KoColorSet
*
colorSet
();
protected:
virtual
void
resizeEvent
(
QResizeEvent
*
event
);
///< reimplemented from QFrame
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment