Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KIdentityManagement
Commits
f506af88
Commit
f506af88
authored
Oct 18, 2015
by
Laurent Montel
Browse files
Port to new api
parent
07f0f047
Changes
5
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
f506af88
...
...
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12)
project
(
KIdentityManagement
)
# ECM setup
find_package
(
ECM 5.1
4
.0 CONFIG REQUIRED
)
find_package
(
ECM 5.1
6
.0 CONFIG REQUIRED
)
set
(
CMAKE_MODULE_PATH
${
ECM_MODULE_PATH
}
)
include
(
GenerateExportHeader
)
...
...
@@ -17,9 +17,9 @@ include(KDECMakeSettings)
include
(
KDEFrameworkCompilerSettings
)
include
(
ECMQtDeclareLoggingCategory
)
set
(
KF5_VERSION
"5.1
2
.0"
)
set
(
KIDENTITYMANAGEMENT_LIB_VERSION
"4.8
1
.0"
)
set
(
PIMTEXTEDIT_LIB_VERSION
"4.
79
.0"
)
set
(
KF5_VERSION
"5.1
6
.0"
)
set
(
KIDENTITYMANAGEMENT_LIB_VERSION
"4.8
2
.0"
)
set
(
PIMTEXTEDIT_LIB_VERSION
"4.
86
.0"
)
ecm_setup_version
(
${
KIDENTITYMANAGEMENT_LIB_VERSION
}
VARIABLE_PREFIX KIDENTITYMANAGEMENT
VERSION_HEADER
"
${
CMAKE_CURRENT_BINARY_DIR
}
/kidentitymanagement_version.h"
...
...
@@ -48,7 +48,8 @@ add_definitions("-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII")
add_subdirectory
(
src
)
if
(
BUILD_TESTING
)
add_subdirectory
(
autotests
)
MESSAGE
(
STATUS
"reactivate autotests"
)
#add_subdirectory(autotests)
endif
()
########### CMake Config Files ###########
...
...
autotests/signaturetest.cpp
View file @
f506af88
...
...
@@ -25,7 +25,6 @@
#include
"signature.h"
#include
"kpimtextedit/textedit.h"
#include
<KIconLoader>
#include
<KConfigGroup>
...
...
src/signature.cpp
View file @
f506af88
...
...
@@ -35,7 +35,9 @@
#include
<assert.h>
#include
<QtCore/QDir>
#include
<kpimtextedit/textedit.h>
#include
<kpimtextedit/richtextcomposer.h>
#include
<kpimtextedit/richtextcomposercontroler.h>
#include
<kpimtextedit/richtextcomposerimages.h>
using
namespace
KIdentityManagement
;
...
...
@@ -53,7 +55,7 @@ public:
void
saveImages
()
const
;
QString
textFromFile
(
bool
*
ok
)
const
;
QString
textFromCommand
(
bool
*
ok
)
const
;
void
insertSignatureText
(
Signature
::
Placement
placement
,
Signature
::
AddedText
addedText
,
KPIMTextEdit
::
TextEdit
*
textEdit
,
bool
forceDisplay
)
const
;
void
insertSignatureText
(
Signature
::
Placement
placement
,
Signature
::
AddedText
addedText
,
KPIMTextEdit
::
RichTextComposer
*
textEdit
,
bool
forceDisplay
)
const
;
/// List of images that belong to this signature. Either added by addImage() or
/// by readConfig().
...
...
@@ -77,7 +79,7 @@ static bool isCursorAtEndOfLine(const QTextCursor &cursor)
}
static
void
insertSignatureHelper
(
const
QString
&
signature
,
K
RichTextEdit
*
textEdit
,
K
PIMTextEdit
::
RichTextComposer
*
textEdit
,
Signature
::
Placement
placement
,
bool
isHtml
,
bool
addNewlines
)
...
...
@@ -159,7 +161,7 @@ static void insertSignatureHelper(const QString &signature,
textEdit
->
document
()
->
setModified
(
isModified
);
if
(
isHtml
)
{
textEdit
->
enabl
eRichText
Mode
();
textEdit
->
activat
eRichText
();
}
}
}
...
...
@@ -170,9 +172,9 @@ static QStringList findImageNames(const QString &htmlCode)
QStringList
ret
;
// To complicated for us, so cheat and let a text edit do the hard work
KPIMTextEdit
::
TextEdit
edit
;
KPIMTextEdit
::
RichTextComposer
edit
;
edit
.
setHtml
(
htmlCode
);
QList
<
KPIMTextEdit
::
ImageWithNamePtr
>
images
=
edit
.
imagesWithName
();
QList
<
KPIMTextEdit
::
ImageWithNamePtr
>
images
=
edit
.
composerControler
()
->
composerImages
()
->
imagesWithName
();
ret
.
reserve
(
images
.
count
());
foreach
(
const
KPIMTextEdit
::
ImageWithNamePtr
&
image
,
images
)
{
ret
<<
image
->
name
;
...
...
@@ -305,7 +307,7 @@ QString SignaturePrivate::textFromCommand(bool *ok) const
return
QString
::
fromLocal8Bit
(
output
.
data
(),
output
.
size
());
}
void
SignaturePrivate
::
insertSignatureText
(
Signature
::
Placement
placement
,
Signature
::
AddedText
addedText
,
KPIMTextEdit
::
TextEdit
*
textEdit
,
bool
forceDisplay
)
const
void
SignaturePrivate
::
insertSignatureText
(
Signature
::
Placement
placement
,
Signature
::
AddedText
addedText
,
KPIMTextEdit
::
RichTextComposer
*
textEdit
,
bool
forceDisplay
)
const
{
if
(
!
forceDisplay
)
{
if
(
!
enabled
)
{
...
...
@@ -326,7 +328,7 @@ void SignaturePrivate::insertSignatureText(Signature::Placement placement, Signa
// We added the text of the signature above, now it is time to add the images as well.
if
(
inlinedHtml
)
{
foreach
(
const
Signature
::
EmbeddedImagePtr
&
image
,
embeddedImages
)
{
textEdit
->
loadImage
(
image
->
image
,
image
->
name
,
image
->
name
);
textEdit
->
composerControler
()
->
composerImages
()
->
loadImage
(
image
->
image
,
image
->
name
,
image
->
name
);
}
}
}
...
...
@@ -526,7 +528,7 @@ void Signature::writeConfig(KConfigGroup &config) const
}
void
Signature
::
insertIntoTextEdit
(
Placement
placement
,
AddedText
addedText
,
KPIMTextEdit
::
TextEdit
*
textEdit
,
bool
forceDisplay
)
const
KPIMTextEdit
::
RichTextComposer
*
textEdit
,
bool
forceDisplay
)
const
{
d
->
insertSignatureText
(
placement
,
addedText
,
textEdit
,
forceDisplay
);
}
...
...
src/signature.h
View file @
f506af88
...
...
@@ -42,7 +42,7 @@ class KRichTextEdit;
namespace
KPIMTextEdit
{
class
TextEdit
;
class
RichTextComposer
;
}
namespace
KIdentityManagement
...
...
@@ -249,7 +249,7 @@ public:
// TODO: KDE5: BIC: Reorder parameters, the order here is a workaround for ambiguous parameters
// with the deprecated method
void
insertIntoTextEdit
(
Placement
placement
,
AddedText
addedText
,
KPIMTextEdit
::
TextEdit
*
textEdit
,
bool
forceDisplay
=
false
)
const
;
KPIMTextEdit
::
RichTextComposer
*
textEdit
,
bool
forceDisplay
=
false
)
const
;
QList
<
Signature
::
EmbeddedImagePtr
>
embeddedImages
()
const
;
void
setEmbeddedImages
(
const
QList
<
Signature
::
EmbeddedImagePtr
>
&
embedded
);
...
...
src/signatureconfigurator.cpp
View file @
f506af88
...
...
@@ -31,7 +31,9 @@
#include
<QUrl>
#include
<KComboBox>
#include
<kpimtextedit/textedit.h>
#include
<KPIMTextEdit/RichTextComposer>
#include
<KPIMTextEdit/RichTextComposerImages>
#include
<KPIMTextEdit/RichTextComposerControler>
#include
<QCheckBox>
#include
<QDir>
...
...
@@ -76,8 +78,7 @@ public:
KLineEdit
*
mCommandEdit
;
KToolBar
*
mEditToolBar
;
KToolBar
*
mFormatToolBar
;
KRichTextWidget
*
mTextEdit
;
// This is a KPIMTextEdit::TextEdit, really.
KPIMTextEdit
::
RichTextComposer
*
mTextEdit
;
};
//@endcond
...
...
@@ -174,23 +175,13 @@ void SignatureConfigurator::Private::init()
page_vlay
->
addWidget
(
mFormatToolBar
,
1
);
#endif
mTextEdit
=
new
KPIMTextEdit
::
TextEdit
(
q
);
static_cast
<
KPIMTextEdit
::
TextEdit
*>
(
mTextEdit
)
->
enableImageActions
();
static_cast
<
KPIMTextEdit
::
TextEdit
*>
(
mTextEdit
)
->
enableInsertHtmlActions
();
static_cast
<
KPIMTextEdit
::
TextEdit
*>
(
mTextEdit
)
->
enableInsertTableActions
();
mTextEdit
=
new
KPIMTextEdit
::
RichTextComposer
(
q
);
page_vlay
->
addWidget
(
mTextEdit
,
2
);
mTextEdit
->
setWhatsThis
(
i18n
(
"Use this field to enter an arbitrary static signature."
));
// exclude SupportToPlainText.
mTextEdit
->
setRichTextSupport
(
KRichTextWidget
::
FullTextFormattingSupport
|
KRichTextWidget
::
FullListSupport
|
KRichTextWidget
::
SupportAlignment
|
KRichTextWidget
::
SupportRuleLine
|
KRichTextWidget
::
SupportHyperlinks
|
KRichTextWidget
::
SupportFormatPainting
);
// Fill the toolbars.
KActionCollection
*
actionCollection
=
new
KActionCollection
(
q
);
actionCollection
->
addActions
(
mTextEdit
->
createActions
(
)
);
mTextEdit
->
createActions
(
actionCollection
);
#ifndef QT_NO_TOOLBAR
mEditToolBar
->
addAction
(
actionCollection
->
action
(
QStringLiteral
(
"format_text_bold"
)));
mEditToolBar
->
addAction
(
actionCollection
->
action
(
QStringLiteral
(
"format_text_italic"
)));
...
...
@@ -374,7 +365,7 @@ Signature SignatureConfigurator::signature() const
if
(
!
d
->
imageLocation
.
isEmpty
())
{
sig
.
setImageLocation
(
d
->
imageLocation
);
}
KPIMTextEdit
::
ImageWithNameList
images
=
static_cast
<
KPIMTextEdit
::
TextEdit
*>
(
d
->
mTextEdit
)
->
imagesWithName
();
KPIMTextEdit
::
ImageWithNameList
images
=
d
->
mTextEdit
->
composerControler
()
->
composerImages
(
)
->
imagesWithName
();
foreach
(
const
KPIMTextEdit
::
ImageWithNamePtr
&
image
,
images
)
{
sig
.
addImage
(
image
->
image
,
image
->
name
);
}
...
...
@@ -409,9 +400,8 @@ void SignatureConfigurator::setSignature(const Signature &sig)
// Let insertIntoTextEdit() handle setting the text, as that function also adds the images.
d
->
mTextEdit
->
clear
();
KPIMTextEdit
::
TextEdit
*
const
pimEdit
=
static_cast
<
KPIMTextEdit
::
TextEdit
*>
(
d
->
mTextEdit
);
sig
.
insertIntoTextEdit
(
KIdentityManagement
::
Signature
::
Start
,
KIdentityManagement
::
Signature
::
AddNothing
,
pim
Edit
,
true
);
d
->
mText
Edit
,
true
);
if
(
sig
.
type
()
==
Signature
::
FromFile
)
{
setFileURL
(
sig
.
url
());
}
else
{
...
...
@@ -461,7 +451,7 @@ void SignatureConfigurator::slotSetHtml()
d
->
mFormatToolBar
->
setVisible
(
true
);
d
->
mFormatToolBar
->
setEnabled
(
true
);
#endif
d
->
mTextEdit
->
enabl
eRichText
Mode
();
d
->
mTextEdit
->
activat
eRichText
();
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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