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
PIM
KMail
Commits
b8845db0
Commit
b8845db0
authored
Sep 21, 2020
by
Laurent Montel
😁
Browse files
Use new collectionviewwidget
parent
51e0158f
Pipeline
#35137
passed with stage
in 51 minutes and 18 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/CMakeLists.txt
View file @
b8845db0
...
...
@@ -48,6 +48,7 @@ set(kmailprivate_collectionpage_LIB_SRCS
collectionpage/collectionquotawidget.cpp
collectionpage/collectionmailinglistpage.cpp
collectionpage/collectionshortcutpage.cpp
collectionpage/collectionviewwidget.cpp
)
set
(
kmailprivate_configuredialog_LIB_SRCS
configuredialog/configagentdelegate.cpp
...
...
src/collectionpage/collectionviewpage.cpp
View file @
b8845db0
...
...
@@ -19,6 +19,7 @@
#include <KLocalizedString>
#include <KIconButton>
#include <QRadioButton>
#include "collectionviewwidget.h"
#include "kmail_debug.h"
#include <MessageList/AggregationComboBox>
...
...
@@ -43,7 +44,6 @@ CollectionViewPage::~CollectionViewPage()
void
CollectionViewPage
::
init
(
const
Akonadi
::
Collection
&
col
)
{
mCurrentCollection
=
col
;
mFolderCollection
=
FolderSettings
::
forCollection
(
col
);
mIsLocalSystemFolder
=
CommonKernel
->
isSystemFolderCollection
(
col
)
||
mFolderCollection
->
isStructural
()
||
Kernel
::
folderIsInbox
(
col
);
...
...
@@ -98,80 +98,8 @@ void CollectionViewPage::init(const Akonadi::Collection &col)
connect
(
mNormalIconButton
,
&
KIconButton
::
iconChanged
,
this
,
&
CollectionViewPage
::
slotChangeIcon
);
}
// sender or receiver column
const
QString
senderReceiverColumnTip
=
i18n
(
"Show Sender/Receiver Column in List of Messages"
);
QLabel
*
senderReceiverColumnLabel
=
new
QLabel
(
i18n
(
"Sho&w column:"
),
this
);
mShowSenderReceiverComboBox
=
new
QComboBox
(
this
);
mShowSenderReceiverComboBox
->
setToolTip
(
senderReceiverColumnTip
);
senderReceiverColumnLabel
->
setBuddy
(
mShowSenderReceiverComboBox
);
mShowSenderReceiverComboBox
->
insertItem
(
0
,
i18nc
(
"@item:inlistbox Show default value."
,
"Default"
));
mShowSenderReceiverComboBox
->
insertItem
(
1
,
i18nc
(
"@item:inlistbox Show sender."
,
"Sender"
));
mShowSenderReceiverComboBox
->
insertItem
(
2
,
i18nc
(
"@item:inlistbox Show receiver."
,
"Receiver"
));
QHBoxLayout
*
senderReceiverColumnHLayout
=
new
QHBoxLayout
();
senderReceiverColumnHLayout
->
addWidget
(
senderReceiverColumnLabel
);
senderReceiverColumnHLayout
->
addWidget
(
mShowSenderReceiverComboBox
);
topLayout
->
addLayout
(
senderReceiverColumnHLayout
);
// message list
QGroupBox
*
messageListGroup
=
new
QGroupBox
(
i18n
(
"Message List"
),
this
);
QVBoxLayout
*
messageListGroupLayout
=
new
QVBoxLayout
(
messageListGroup
);
topLayout
->
addWidget
(
messageListGroup
);
// message list aggregation
mUseDefaultAggregationCheckBox
=
new
QCheckBox
(
i18n
(
"Use default aggregation"
),
messageListGroup
);
messageListGroupLayout
->
addWidget
(
mUseDefaultAggregationCheckBox
);
connect
(
mUseDefaultAggregationCheckBox
,
&
QCheckBox
::
stateChanged
,
this
,
&
CollectionViewPage
::
slotAggregationCheckboxChanged
);
mAggregationComboBox
=
new
MessageList
::
Utils
::
AggregationComboBox
(
messageListGroup
);
QLabel
*
aggregationLabel
=
new
QLabel
(
i18n
(
"Aggregation"
),
messageListGroup
);
aggregationLabel
->
setBuddy
(
mAggregationComboBox
);
using
MessageList
::
Utils
::
AggregationConfigButton
;
AggregationConfigButton
*
aggregationConfigButton
=
new
AggregationConfigButton
(
messageListGroup
,
mAggregationComboBox
);
// Make sure any changes made in the aggregations configure dialog are reflected in the combo.
connect
(
aggregationConfigButton
,
&
AggregationConfigButton
::
configureDialogCompleted
,
this
,
&
CollectionViewPage
::
slotSelectFolderAggregation
);
QHBoxLayout
*
aggregationLayout
=
new
QHBoxLayout
();
aggregationLayout
->
addWidget
(
aggregationLabel
,
1
);
aggregationLayout
->
addWidget
(
mAggregationComboBox
,
1
);
aggregationLayout
->
addWidget
(
aggregationConfigButton
,
0
);
messageListGroupLayout
->
addLayout
(
aggregationLayout
);
// message list theme
mUseDefaultThemeCheckBox
=
new
QCheckBox
(
i18n
(
"Use default theme"
),
messageListGroup
);
messageListGroupLayout
->
addWidget
(
mUseDefaultThemeCheckBox
);
connect
(
mUseDefaultThemeCheckBox
,
&
QCheckBox
::
stateChanged
,
this
,
&
CollectionViewPage
::
slotThemeCheckboxChanged
);
mThemeComboBox
=
new
MessageList
::
Utils
::
ThemeComboBox
(
messageListGroup
);
QLabel
*
themeLabel
=
new
QLabel
(
i18n
(
"Theme"
),
messageListGroup
);
themeLabel
->
setBuddy
(
mThemeComboBox
);
using
MessageList
::
Utils
::
ThemeConfigButton
;
ThemeConfigButton
*
themeConfigButton
=
new
ThemeConfigButton
(
messageListGroup
,
mThemeComboBox
);
// Make sure any changes made in the themes configure dialog are reflected in the combo.
connect
(
themeConfigButton
,
&
ThemeConfigButton
::
configureDialogCompleted
,
this
,
&
CollectionViewPage
::
slotSelectFolderTheme
);
QHBoxLayout
*
themeLayout
=
new
QHBoxLayout
();
themeLayout
->
addWidget
(
themeLabel
,
1
);
themeLayout
->
addWidget
(
mThemeComboBox
,
1
);
themeLayout
->
addWidget
(
themeConfigButton
,
0
);
messageListGroupLayout
->
addLayout
(
themeLayout
);
// Message Default Format
QGroupBox
*
messageFormatGroup
=
new
QGroupBox
(
i18n
(
"Message Default Format"
),
this
);
QVBoxLayout
*
messageFormatGroupLayout
=
new
QVBoxLayout
(
messageFormatGroup
);
mPreferHtmlToText
=
new
QRadioButton
(
i18n
(
"Prefer HTML to text"
),
this
);
messageFormatGroupLayout
->
addWidget
(
mPreferHtmlToText
);
mPreferTextToHtml
=
new
QRadioButton
(
i18n
(
"Prefer text to HTML"
),
this
);
messageFormatGroupLayout
->
addWidget
(
mPreferTextToHtml
);
mUseGlobalSettings
=
new
QRadioButton
(
i18n
(
"Use Global Settings"
),
this
);
messageFormatGroupLayout
->
addWidget
(
mUseGlobalSettings
);
topLayout
->
addWidget
(
messageFormatGroup
);
mCollectionViewWidget
=
new
CollectionViewWidget
(
this
);
topLayout
->
addWidget
(
mCollectionViewWidget
);
topLayout
->
addStretch
(
100
);
}
...
...
@@ -181,29 +109,6 @@ void CollectionViewPage::slotChangeIcon(const QString &icon)
mUnreadIconButton
->
setIcon
(
icon
);
}
void
CollectionViewPage
::
slotAggregationCheckboxChanged
()
{
mAggregationComboBox
->
setEnabled
(
!
mUseDefaultAggregationCheckBox
->
isChecked
());
}
void
CollectionViewPage
::
slotThemeCheckboxChanged
()
{
mThemeComboBox
->
setEnabled
(
!
mUseDefaultThemeCheckBox
->
isChecked
());
}
void
CollectionViewPage
::
slotSelectFolderAggregation
()
{
bool
usesPrivateAggregation
=
false
;
mAggregationComboBox
->
readStorageModelConfig
(
mCurrentCollection
,
usesPrivateAggregation
);
mUseDefaultAggregationCheckBox
->
setChecked
(
!
usesPrivateAggregation
);
}
void
CollectionViewPage
::
slotSelectFolderTheme
()
{
bool
usesPrivateTheme
=
false
;
mThemeComboBox
->
readStorageModelConfig
(
mCurrentCollection
,
usesPrivateTheme
);
mUseDefaultThemeCheckBox
->
setChecked
(
!
usesPrivateTheme
);
}
void
CollectionViewPage
::
load
(
const
Akonadi
::
Collection
&
col
)
{
...
...
@@ -231,40 +136,7 @@ void CollectionViewPage::load(const Akonadi::Collection &col)
mIconsCheckBox
->
setChecked
(
!
iconWasEmpty
);
}
if
(
col
.
hasAttribute
<
Akonadi
::
MessageFolderAttribute
>
())
{
const
bool
outboundFolder
=
col
.
attribute
<
Akonadi
::
MessageFolderAttribute
>
()
->
isOutboundFolder
();
if
(
outboundFolder
)
{
mShowSenderReceiverComboBox
->
setCurrentIndex
(
2
);
}
else
{
mShowSenderReceiverComboBox
->
setCurrentIndex
(
1
);
}
}
else
{
mShowSenderReceiverComboBox
->
setCurrentIndex
(
0
);
}
mShowSenderReceiverValue
=
mShowSenderReceiverComboBox
->
currentIndex
();
// message list aggregation
slotSelectFolderAggregation
();
// message list theme
slotSelectFolderTheme
();
const
MessageViewer
::
Viewer
::
DisplayFormatMessage
formatMessage
=
mFolderCollection
->
formatMessage
();
switch
(
formatMessage
)
{
case
MessageViewer
::
Viewer
::
Html
:
mPreferHtmlToText
->
setChecked
(
true
);
break
;
case
MessageViewer
::
Viewer
::
Text
:
mPreferTextToHtml
->
setChecked
(
true
);
break
;
case
MessageViewer
::
Viewer
::
UseGlobalSetting
:
mUseGlobalSettings
->
setChecked
(
true
);
break
;
default:
qCDebug
(
KMAIL_LOG
)
<<
"No settings defined"
;
break
;
}
mCollectionViewWidget
->
load
(
col
);
}
void
CollectionViewPage
::
save
(
Akonadi
::
Collection
&
col
)
...
...
@@ -278,36 +150,5 @@ void CollectionViewPage::save(Akonadi::Collection &col)
col
.
attribute
<
Akonadi
::
EntityDisplayAttribute
>
()
->
setActiveIconName
(
QString
());
}
}
const
int
currentIndex
=
mShowSenderReceiverComboBox
->
currentIndex
();
if
(
mShowSenderReceiverValue
!=
currentIndex
)
{
if
(
currentIndex
==
1
)
{
Akonadi
::
MessageFolderAttribute
*
messageFolder
=
col
.
attribute
<
Akonadi
::
MessageFolderAttribute
>
(
Akonadi
::
Collection
::
AddIfMissing
);
messageFolder
->
setOutboundFolder
(
false
);
}
else
if
(
currentIndex
==
2
)
{
Akonadi
::
MessageFolderAttribute
*
messageFolder
=
col
.
attribute
<
Akonadi
::
MessageFolderAttribute
>
(
Akonadi
::
Collection
::
AddIfMissing
);
messageFolder
->
setOutboundFolder
(
true
);
}
else
{
col
.
removeAttribute
<
Akonadi
::
MessageFolderAttribute
>
();
}
}
// message list theme
const
bool
usePrivateTheme
=
!
mUseDefaultThemeCheckBox
->
isChecked
();
mThemeComboBox
->
writeStorageModelConfig
(
QString
::
number
(
mCurrentCollection
.
id
()),
usePrivateTheme
);
// message list aggregation
const
bool
usePrivateAggregation
=
!
mUseDefaultAggregationCheckBox
->
isChecked
();
mAggregationComboBox
->
writeStorageModelConfig
(
QString
::
number
(
mCurrentCollection
.
id
()),
usePrivateAggregation
);
MessageViewer
::
Viewer
::
DisplayFormatMessage
formatMessage
=
MessageViewer
::
Viewer
::
Unknown
;
if
(
mPreferHtmlToText
->
isChecked
())
{
formatMessage
=
MessageViewer
::
Viewer
::
Html
;
}
else
if
(
mPreferTextToHtml
->
isChecked
())
{
formatMessage
=
MessageViewer
::
Viewer
::
Text
;
}
else
if
(
mUseGlobalSettings
->
isChecked
())
{
formatMessage
=
MessageViewer
::
Viewer
::
UseGlobalSetting
;
}
else
{
qCDebug
(
KMAIL_LOG
)
<<
"No settings defined"
;
}
mFolderCollection
->
setFormatMessage
(
formatMessage
);
mFolderCollection
->
writeConfig
();
mCollectionViewWidget
->
save
(
col
);
}
src/collectionpage/collectionviewpage.h
View file @
b8845db0
...
...
@@ -15,6 +15,7 @@ class QLabel;
class
QComboBox
;
class
KIconButton
;
class
QRadioButton
;
class
CollectionViewWidget
;
template
<
typename
T
>
class
QSharedPointer
;
namespace
MessageList
{
...
...
@@ -36,28 +37,15 @@ public:
private:
void
slotChangeIcon
(
const
QString
&
icon
);
void
slotAggregationCheckboxChanged
();
void
slotThemeCheckboxChanged
();
void
slotSelectFolderAggregation
();
void
slotSelectFolderTheme
();
void
init
(
const
Akonadi
::
Collection
&
);
CollectionViewWidget
*
mCollectionViewWidget
=
nullptr
;
QSharedPointer
<
MailCommon
::
FolderSettings
>
mFolderCollection
;
QCheckBox
*
mIconsCheckBox
=
nullptr
;
QLabel
*
mNormalIconLabel
=
nullptr
;
KIconButton
*
mNormalIconButton
=
nullptr
;
QLabel
*
mUnreadIconLabel
=
nullptr
;
KIconButton
*
mUnreadIconButton
=
nullptr
;
QComboBox
*
mShowSenderReceiverComboBox
=
nullptr
;
QCheckBox
*
mUseDefaultAggregationCheckBox
=
nullptr
;
MessageList
::
Utils
::
AggregationComboBox
*
mAggregationComboBox
=
nullptr
;
QCheckBox
*
mUseDefaultThemeCheckBox
=
nullptr
;
MessageList
::
Utils
::
ThemeComboBox
*
mThemeComboBox
=
nullptr
;
QRadioButton
*
mPreferHtmlToText
=
nullptr
;
QRadioButton
*
mPreferTextToHtml
=
nullptr
;
QRadioButton
*
mUseGlobalSettings
=
nullptr
;
Akonadi
::
Collection
mCurrentCollection
;
int
mShowSenderReceiverValue
=
-
1
;
bool
mIsLocalSystemFolder
=
false
;
};
...
...
src/collectionpage/collectionviewwidget.cpp
View file @
b8845db0
...
...
@@ -5,12 +5,23 @@
*/
#include "collectionviewwidget.h"
#include "kmail_debug.h"
#include <QVBoxLayout>
#include <KLocalizedString>
#include <MessageList/AggregationComboBox>
#include <MessageList/AggregationConfigButton>
#include <MessageList/ThemeComboBox>
#include <MessageList/ThemeConfigButton>
#include <Akonadi/KMime/MessageFolderAttribute>
#include <MessageViewer/Viewer>
#include <QLabel>
#include <QComboBox>
#include <QGroupBox>
#include <QCheckBox>
#include <QRadioButton>
CollectionViewWidget
::
CollectionViewWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
)
...
...
@@ -43,7 +54,7 @@ CollectionViewWidget::CollectionViewWidget(QWidget *parent)
// message list aggregation
mUseDefaultAggregationCheckBox
=
new
QCheckBox
(
i18n
(
"Use default aggregation"
),
messageListGroup
);
messageListGroupLayout
->
addWidget
(
mUseDefaultAggregationCheckBox
);
connect
(
mUseDefaultAggregationCheckBox
,
&
QCheckBox
::
stateChanged
,
this
,
&
CollectionView
Pa
ge
::
slotAggregationCheckboxChanged
);
connect
(
mUseDefaultAggregationCheckBox
,
&
QCheckBox
::
stateChanged
,
this
,
&
CollectionView
Wid
ge
t
::
slotAggregationCheckboxChanged
);
mAggregationComboBox
=
new
MessageList
::
Utils
::
AggregationComboBox
(
messageListGroup
);
...
...
@@ -53,7 +64,7 @@ CollectionViewWidget::CollectionViewWidget(QWidget *parent)
using
MessageList
::
Utils
::
AggregationConfigButton
;
AggregationConfigButton
*
aggregationConfigButton
=
new
AggregationConfigButton
(
messageListGroup
,
mAggregationComboBox
);
// Make sure any changes made in the aggregations configure dialog are reflected in the combo.
connect
(
aggregationConfigButton
,
&
AggregationConfigButton
::
configureDialogCompleted
,
this
,
&
CollectionView
Pa
ge
::
slotSelectFolderAggregation
);
connect
(
aggregationConfigButton
,
&
AggregationConfigButton
::
configureDialogCompleted
,
this
,
&
CollectionView
Wid
ge
t
::
slotSelectFolderAggregation
);
QHBoxLayout
*
aggregationLayout
=
new
QHBoxLayout
();
aggregationLayout
->
addWidget
(
aggregationLabel
,
1
);
...
...
@@ -64,7 +75,7 @@ CollectionViewWidget::CollectionViewWidget(QWidget *parent)
// message list theme
mUseDefaultThemeCheckBox
=
new
QCheckBox
(
i18n
(
"Use default theme"
),
messageListGroup
);
messageListGroupLayout
->
addWidget
(
mUseDefaultThemeCheckBox
);
connect
(
mUseDefaultThemeCheckBox
,
&
QCheckBox
::
stateChanged
,
this
,
&
CollectionView
Pa
ge
::
slotThemeCheckboxChanged
);
connect
(
mUseDefaultThemeCheckBox
,
&
QCheckBox
::
stateChanged
,
this
,
&
CollectionView
Wid
ge
t
::
slotThemeCheckboxChanged
);
mThemeComboBox
=
new
MessageList
::
Utils
::
ThemeComboBox
(
messageListGroup
);
...
...
@@ -74,7 +85,7 @@ CollectionViewWidget::CollectionViewWidget(QWidget *parent)
using
MessageList
::
Utils
::
ThemeConfigButton
;
ThemeConfigButton
*
themeConfigButton
=
new
ThemeConfigButton
(
messageListGroup
,
mThemeComboBox
);
// Make sure any changes made in the themes configure dialog are reflected in the combo.
connect
(
themeConfigButton
,
&
ThemeConfigButton
::
configureDialogCompleted
,
this
,
&
CollectionView
Pa
ge
::
slotSelectFolderTheme
);
connect
(
themeConfigButton
,
&
ThemeConfigButton
::
configureDialogCompleted
,
this
,
&
CollectionView
Wid
ge
t
::
slotSelectFolderTheme
);
QHBoxLayout
*
themeLayout
=
new
QHBoxLayout
();
themeLayout
->
addWidget
(
themeLabel
,
1
);
...
...
@@ -95,8 +106,6 @@ CollectionViewWidget::CollectionViewWidget(QWidget *parent)
topLayout
->
addWidget
(
messageFormatGroup
);
topLayout
->
addStretch
(
100
);
//TODO
}
CollectionViewWidget
::~
CollectionViewWidget
()
...
...
@@ -106,6 +115,7 @@ CollectionViewWidget::~CollectionViewWidget()
void
CollectionViewWidget
::
load
(
const
Akonadi
::
Collection
&
col
)
{
mFolderCollection
=
MailCommon
::
FolderSettings
::
forCollection
(
col
);
if
(
col
.
hasAttribute
<
Akonadi
::
MessageFolderAttribute
>
())
{
const
bool
outboundFolder
=
col
.
attribute
<
Akonadi
::
MessageFolderAttribute
>
()
->
isOutboundFolder
();
if
(
outboundFolder
)
{
...
...
@@ -175,3 +185,27 @@ void CollectionViewWidget::save(Akonadi::Collection &col)
mFolderCollection
->
setFormatMessage
(
formatMessage
);
mFolderCollection
->
writeConfig
();
}
void
CollectionViewWidget
::
slotSelectFolderAggregation
()
{
bool
usesPrivateAggregation
=
false
;
mAggregationComboBox
->
readStorageModelConfig
(
mCurrentCollection
,
usesPrivateAggregation
);
mUseDefaultAggregationCheckBox
->
setChecked
(
!
usesPrivateAggregation
);
}
void
CollectionViewWidget
::
slotSelectFolderTheme
()
{
bool
usesPrivateTheme
=
false
;
mThemeComboBox
->
readStorageModelConfig
(
mCurrentCollection
,
usesPrivateTheme
);
mUseDefaultThemeCheckBox
->
setChecked
(
!
usesPrivateTheme
);
}
void
CollectionViewWidget
::
slotAggregationCheckboxChanged
()
{
mAggregationComboBox
->
setEnabled
(
!
mUseDefaultAggregationCheckBox
->
isChecked
());
}
void
CollectionViewWidget
::
slotThemeCheckboxChanged
()
{
mThemeComboBox
->
setEnabled
(
!
mUseDefaultThemeCheckBox
->
isChecked
());
}
src/collectionpage/collectionviewwidget.h
View file @
b8845db0
...
...
@@ -7,14 +7,43 @@
#ifndef COLLECTIONVIEWWIDGET_H
#define COLLECTIONVIEWWIDGET_H
#include <QSharedPointer>
#include <QWidget>
#include <MailCommon/FolderSettings>
class
QCheckBox
;
class
QComboBox
;
class
QRadioButton
;
namespace
MessageList
{
namespace
Utils
{
class
AggregationComboBox
;
class
ThemeComboBox
;
}
}
class
CollectionViewWidget
:
public
QWidget
{
Q_OBJECT
public:
explicit
CollectionViewWidget
(
QWidget
*
parent
=
nullptr
);
~
CollectionViewWidget
();
void
load
(
const
Akonadi
::
Collection
&
col
);
void
save
(
Akonadi
::
Collection
&
col
);
private:
void
slotSelectFolderAggregation
();
void
slotSelectFolderTheme
();
void
slotThemeCheckboxChanged
();
void
slotAggregationCheckboxChanged
();
QSharedPointer
<
MailCommon
::
FolderSettings
>
mFolderCollection
;
QCheckBox
*
mIconsCheckBox
=
nullptr
;
QComboBox
*
mShowSenderReceiverComboBox
=
nullptr
;
QCheckBox
*
mUseDefaultAggregationCheckBox
=
nullptr
;
MessageList
::
Utils
::
AggregationComboBox
*
mAggregationComboBox
=
nullptr
;
QCheckBox
*
mUseDefaultThemeCheckBox
=
nullptr
;
MessageList
::
Utils
::
ThemeComboBox
*
mThemeComboBox
=
nullptr
;
QRadioButton
*
mPreferHtmlToText
=
nullptr
;
QRadioButton
*
mPreferTextToHtml
=
nullptr
;
QRadioButton
*
mUseGlobalSettings
=
nullptr
;
Akonadi
::
Collection
mCurrentCollection
;
int
mShowSenderReceiverValue
=
-
1
;
};
#endif // COLLECTIONVIEWWIDGET_H
Write
Preview
Supports
Markdown
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