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
a0ba5835
Commit
a0ba5835
authored
Jun 29, 2012
by
Sven Langkamp
Committed by
Halla Rempt
Aug 17, 2012
Browse files
restore last used palette in the palette docker after start
CCBUG:299033 Conflicts: krita/ui/kis_config.cc krita/ui/kis_config.h
parent
6249b7b0
Changes
6
Hide whitespace changes
Inline
Side-by-side
krita/plugins/extensions/dockers/defaultdockers/kis_palette_docker.cc
View file @
a0ba5835
...
...
@@ -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 @
a0ba5835
...
...
@@ -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 @
a0ba5835
...
...
@@ -837,3 +837,23 @@ void KisConfig::setExportConfiguration(const QString &filterId, const KisPropert
m_cfg
.
writeEntry
(
"ExportConfiguration-"
+
filterId
,
exportConfig
);
}
QString
KisConfig
::
defaultPalette
()
{
return
m_cfg
.
readEntry
(
"defaultPalette"
,
QString
());
}
void
KisConfig
::
setDefaultPalette
(
const
QString
&
name
)
{
m_cfg
.
writeEntry
(
"defaultPalette"
,
name
);
}
bool
KisConfig
::
useSystemMonitorProfile
()
const
{
return
m_cfg
.
readEntry
(
"ColorManagement/UseSystemMonitorProfile"
,
false
);
}
void
KisConfig
::
setUseSystemMonitorProfile
(
bool
_useSystemMonitorProfile
)
{
m_cfg
.
writeEntry
(
"ColorManagement/UseSystemMonitorProfile"
,
_useSystemMonitorProfile
);
}
krita/ui/kis_config.h
View file @
a0ba5835
...
...
@@ -265,6 +265,12 @@ public:
QString
exportConfiguration
(
const
QString
&
filterId
)
const
;
void
setExportConfiguration
(
const
QString
&
filterId
,
const
KisPropertiesConfiguration
&
properties
);
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 @
a0ba5835
...
...
@@ -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 @
a0ba5835
...
...
@@ -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