Port Folder Properties dialog to QFormLayout

This allows to use a consistent form layout with other KDE applications
by following the KDE Human Interface Guidelines.
wilder-portage
Carl Schwan 5 years ago
parent c8d5a1d681
commit 1a92909f24
No known key found for this signature in database
GPG Key ID: 6B35D38387B67BE
  1. 117
      src/collectionpage/collectionexpirywidget.cpp
  2. 3
      src/collectionpage/collectionexpirywidget.h
  3. 35
      src/collectionpage/collectiongeneralpage.cpp
  4. 46
      src/collectionpage/collectiongeneralwidget.cpp
  5. 3
      src/collectionpage/collectiongeneralwidget.h
  6. 59
      src/collectionpage/collectionviewwidget.cpp

@ -18,55 +18,68 @@
#include <KMessageBox> #include <KMessageBox>
#include <KPluralHandlingSpinBox> #include <KPluralHandlingSpinBox>
#include <QCheckBox> #include <QCheckBox>
#include <QFormLayout>
#include <QGroupBox> #include <QGroupBox>
#include <QHBoxLayout>
#include <QPushButton> #include <QPushButton>
#include <QRadioButton> #include <QRadioButton>
#include <QVBoxLayout>
using namespace MailCommon; using namespace MailCommon;
CollectionExpiryWidget::CollectionExpiryWidget(QWidget *parent) class DaysSpinBox : public KPluralHandlingSpinBox
: QWidget(parent)
{ {
auto globalVBox = new QVBoxLayout(this); public:
globalVBox->setContentsMargins({}); DaysSpinBox(QWidget *parent)
: KPluralHandlingSpinBox(parent)
{
setMaximum(999999);
setSuffix(ki18ncp("Expire messages after %1", " day", " days"));
setSpecialValueText(i18n("Never"));
}
QString textFromValue(int value) const override
{
if (value == 0) {
return i18n("Never");
}
return KPluralHandlingSpinBox::textFromValue(value);
}
auto daysBox = new QGridLayout; int valueFromText(const QString &text) const override
{
return KPluralHandlingSpinBox::valueFromText(text);
}
mExpireReadMailCB = new QCheckBox(i18n("Expire read messages after"), this); QValidator::State validate(QString &text, int &pos) const override
connect(mExpireReadMailCB, &QCheckBox::toggled, this, &CollectionExpiryWidget::slotUpdateControls); {
daysBox->addWidget(mExpireReadMailCB, 0, 0); if (text == i18n("Never")) {
return QValidator::Acceptable;
}
return KPluralHandlingSpinBox::validate(text, pos);
}
};
mExpireReadMailSB = new KPluralHandlingSpinBox(this); CollectionExpiryWidget::CollectionExpiryWidget(QWidget *parent)
mExpireReadMailSB->setMaximum(999999); : QWidget(parent)
mExpireReadMailSB->setValue(30); {
mExpireReadMailSB->setSuffix(ki18ncp("Expire messages after %1", " day", " days")); auto formLayout = new QFormLayout(this);
daysBox->addWidget(mExpireReadMailSB, 0, 1); formLayout->setContentsMargins({});
connect(mExpireReadMailSB, QOverload<int>::of(&KPluralHandlingSpinBox::valueChanged), this, &CollectionExpiryWidget::slotChanged);
mExpireUnreadMailCB = new QCheckBox(i18n("Expire unread messages after"), this); mExpireReadMailSB = new DaysSpinBox(this);
connect(mExpireUnreadMailCB, &QCheckBox::toggled, this, &CollectionExpiryWidget::slotUpdateControls); connect(mExpireReadMailSB, qOverload<int>(&KPluralHandlingSpinBox::valueChanged), this, &CollectionExpiryWidget::slotChanged);
daysBox->addWidget(mExpireUnreadMailCB, 1, 0); formLayout->addRow(i18n("Expire read messages after:"), mExpireReadMailSB);
mExpireUnreadMailSB = new KPluralHandlingSpinBox(this); mExpireUnreadMailSB = new DaysSpinBox(this);
mExpireUnreadMailSB->setMaximum(99999); connect(mExpireUnreadMailSB, qOverload<int>(&KPluralHandlingSpinBox::valueChanged), this, &CollectionExpiryWidget::slotChanged);
mExpireUnreadMailSB->setValue(30); formLayout->addRow(i18n("Expire unread messages after:"), mExpireUnreadMailSB);
mExpireUnreadMailSB->setSuffix(ki18ncp("Expire messages after %1", " day", " days"));
daysBox->addWidget(mExpireUnreadMailSB, 1, 1);
connect(mExpireUnreadMailSB, QOverload<int>::of(&KPluralHandlingSpinBox::valueChanged), this, &CollectionExpiryWidget::slotChanged);
mExpireMailWithInvalidDateCB = new QCheckBox(i18n("Expire messages with invalid date"), this); mExpireMailWithInvalidDateCB = new QCheckBox(i18n("Expire messages with invalid date"), this);
connect(mExpireMailWithInvalidDateCB, &QCheckBox::toggled, this, &CollectionExpiryWidget::slotChanged); connect(mExpireMailWithInvalidDateCB, &QCheckBox::toggled, this, &CollectionExpiryWidget::slotChanged);
daysBox->addWidget(mExpireMailWithInvalidDateCB, 2, 0); formLayout->addRow(QString(), mExpireMailWithInvalidDateCB);
daysBox->setColumnStretch(3, 1);
globalVBox->addLayout(daysBox);
globalVBox->addSpacing(30);
auto actionsGroup = new QGroupBox(this); auto actionsGroup = new QGroupBox(this);
actionsGroup->setFlat(true); // for mutual exclusion of the radio buttons actionsGroup->setFlat(true); // for mutual exclusion of the radio buttons
globalVBox->addWidget(actionsGroup); formLayout->addRow(actionsGroup);
auto moveToHBox = new QHBoxLayout(); auto moveToHBox = new QHBoxLayout();
moveToHBox->setContentsMargins(0, 0, 0, 0); moveToHBox->setContentsMargins(0, 0, 0, 0);
@ -74,31 +87,28 @@ CollectionExpiryWidget::CollectionExpiryWidget(QWidget *parent)
mMoveToRB = new QRadioButton(actionsGroup); mMoveToRB = new QRadioButton(actionsGroup);
mMoveToRB->setText(i18n("Move expired messages to:")); mMoveToRB->setText(i18n("Move expired messages to:"));
connect(mMoveToRB, &QRadioButton::toggled, this, &CollectionExpiryWidget::slotUpdateControls); connect(mMoveToRB, &QRadioButton::toggled, this, &CollectionExpiryWidget::slotChanged);
moveToHBox->addWidget(mMoveToRB); moveToHBox->addWidget(mMoveToRB);
mFolderSelector = new FolderRequester(this); mFolderSelector = new FolderRequester(this);
mFolderSelector->setMustBeReadWrite(true); mFolderSelector->setMustBeReadWrite(true);
mFolderSelector->setShowOutbox(false); mFolderSelector->setShowOutbox(false);
moveToHBox->addWidget(mFolderSelector); moveToHBox->addWidget(mFolderSelector);
globalVBox->addLayout(moveToHBox); formLayout->addRow(QString(), moveToHBox);
connect(mFolderSelector, &FolderRequester::folderChanged, this, &CollectionExpiryWidget::slotChanged); connect(mFolderSelector, &FolderRequester::folderChanged, this, &CollectionExpiryWidget::slotChanged);
mDeletePermanentlyRB = new QRadioButton(actionsGroup); mDeletePermanentlyRB = new QRadioButton(actionsGroup);
mDeletePermanentlyRB->setText(i18n("Delete expired messages permanently")); mDeletePermanentlyRB->setText(i18n("Delete expired messages permanently"));
connect(mDeletePermanentlyRB, &QRadioButton::toggled, this, &CollectionExpiryWidget::slotUpdateControls); connect(mDeletePermanentlyRB, &QRadioButton::toggled, this, &CollectionExpiryWidget::slotChanged);
globalVBox->addWidget(mDeletePermanentlyRB);
globalVBox->addSpacing(30); formLayout->addRow(QString(), mDeletePermanentlyRB);
mExpireNowPB = new QPushButton(i18n("Save Settings and Expire Now"), this); mExpireNowPB = new QPushButton(i18n("Save Settings and Expire Now"), this);
connect(mExpireNowPB, &QPushButton::clicked, this, &CollectionExpiryWidget::saveAndExpireRequested); connect(mExpireNowPB, &QPushButton::clicked, this, &CollectionExpiryWidget::saveAndExpireRequested);
globalVBox->addWidget(mExpireNowPB, 0, Qt::AlignRight); formLayout->addRow(QString(), mExpireNowPB);
globalVBox->addStretch(100); // eat all superfluous space
mDeletePermanentlyRB->setChecked(true); mDeletePermanentlyRB->setChecked(true);
slotUpdateControls(); slotChanged();
} }
CollectionExpiryWidget::~CollectionExpiryWidget() CollectionExpiryWidget::~CollectionExpiryWidget()
@ -112,19 +122,10 @@ void CollectionExpiryWidget::hideExpireNowButton()
void CollectionExpiryWidget::slotChanged() void CollectionExpiryWidget::slotChanged()
{ {
Q_EMIT configChanged(); const bool showExpiryActions = mExpireReadMailSB->value() != 0 || mExpireUnreadMailSB->value() != 0;
}
void CollectionExpiryWidget::slotUpdateControls()
{
const bool showExpiryActions = mExpireReadMailCB->isChecked() || mExpireUnreadMailCB->isChecked();
mMoveToRB->setEnabled(showExpiryActions); mMoveToRB->setEnabled(showExpiryActions);
mFolderSelector->setEnabled(showExpiryActions && mMoveToRB->isChecked()); mFolderSelector->setEnabled(showExpiryActions && mMoveToRB->isChecked());
mDeletePermanentlyRB->setEnabled(showExpiryActions); mDeletePermanentlyRB->setEnabled(showExpiryActions);
mExpireReadMailSB->setEnabled(mExpireReadMailCB->isChecked());
mExpireUnreadMailSB->setEnabled(mExpireUnreadMailCB->isChecked());
mExpireNowPB->setEnabled(showExpiryActions); mExpireNowPB->setEnabled(showExpiryActions);
Q_EMIT configChanged(); Q_EMIT configChanged();
@ -135,12 +136,14 @@ void CollectionExpiryWidget::load(const MailCommon::CollectionExpirySettings &se
if (settings.isValid()) { if (settings.isValid()) {
bool expiryGloballyOn = settings.expiryGloballyOn; bool expiryGloballyOn = settings.expiryGloballyOn;
if (expiryGloballyOn && settings.mReadExpireUnits != ExpireCollectionAttribute::ExpireNever && settings.daysToExpireRead >= 0) { if (expiryGloballyOn && settings.mReadExpireUnits != ExpireCollectionAttribute::ExpireNever && settings.daysToExpireRead >= 0) {
mExpireReadMailCB->setChecked(true);
mExpireReadMailSB->setValue(settings.daysToExpireRead); mExpireReadMailSB->setValue(settings.daysToExpireRead);
} else {
mExpireReadMailSB->setValue(0);
} }
if (expiryGloballyOn && settings.mUnreadExpireUnits != ExpireCollectionAttribute::ExpireNever && settings.daysToExpireUnread >= 0) { if (expiryGloballyOn && settings.mUnreadExpireUnits != ExpireCollectionAttribute::ExpireNever && settings.daysToExpireUnread >= 0) {
mExpireUnreadMailCB->setChecked(true);
mExpireUnreadMailSB->setValue(settings.daysToExpireUnread); mExpireUnreadMailSB->setValue(settings.daysToExpireUnread);
} else {
mExpireUnreadMailSB->setValue(0);
} }
if (settings.mExpireAction == ExpireCollectionAttribute::ExpireDelete) { if (settings.mExpireAction == ExpireCollectionAttribute::ExpireDelete) {
@ -160,12 +163,12 @@ void CollectionExpiryWidget::load(const MailCommon::CollectionExpirySettings &se
} else { } else {
mDeletePermanentlyRB->setChecked(true); mDeletePermanentlyRB->setChecked(true);
} }
slotUpdateControls(); slotChanged();
} }
bool CollectionExpiryWidget::validateExpireFolder(bool expireNow) bool CollectionExpiryWidget::validateExpireFolder(bool expireNow)
{ {
const bool enableGlobally = mExpireReadMailCB->isChecked() || mExpireUnreadMailCB->isChecked(); const bool enableGlobally = mExpireReadMailSB->value() != 0 || mExpireUnreadMailSB->value() != 0;
const Akonadi::Collection expireToFolder = mFolderSelector->collection(); const Akonadi::Collection expireToFolder = mFolderSelector->collection();
if (enableGlobally && mMoveToRB->isChecked() && !expireToFolder.isValid()) { if (enableGlobally && mMoveToRB->isChecked() && !expireToFolder.isValid()) {
KMessageBox::error(this, KMessageBox::error(this,
@ -203,15 +206,15 @@ MailCommon::ExpireCollectionAttribute *CollectionExpiryWidget::assignFolderAttri
CollectionExpirySettings CollectionExpiryWidget::settings() const CollectionExpirySettings CollectionExpiryWidget::settings() const
{ {
CollectionExpirySettings settings; CollectionExpirySettings settings;
settings.expiryGloballyOn = mExpireReadMailCB->isChecked() || mExpireUnreadMailCB->isChecked(); settings.expiryGloballyOn = mExpireReadMailSB->value() != 0 || mExpireUnreadMailSB->value() != 0;
settings.expiryMessagesWithInvalidDate = mExpireMailWithInvalidDateCB->isChecked(); settings.expiryMessagesWithInvalidDate = mExpireMailWithInvalidDateCB->isChecked();
// we always write out days now // we always write out days now
settings.daysToExpireRead = mExpireReadMailSB->value(); settings.daysToExpireRead = mExpireReadMailSB->value();
settings.daysToExpireUnread = mExpireUnreadMailSB->value(); settings.daysToExpireUnread = mExpireUnreadMailSB->value();
settings.mReadExpireUnits = settings.mReadExpireUnits =
mExpireReadMailCB->isChecked() ? MailCommon::ExpireCollectionAttribute::ExpireDays : MailCommon::ExpireCollectionAttribute::ExpireNever; mExpireReadMailSB->value() != 0 ? MailCommon::ExpireCollectionAttribute::ExpireDays : MailCommon::ExpireCollectionAttribute::ExpireNever;
settings.mUnreadExpireUnits = settings.mUnreadExpireUnits =
mExpireUnreadMailCB->isChecked() ? MailCommon::ExpireCollectionAttribute::ExpireDays : MailCommon::ExpireCollectionAttribute::ExpireNever; mExpireUnreadMailSB->value() != 0 ? MailCommon::ExpireCollectionAttribute::ExpireDays : MailCommon::ExpireCollectionAttribute::ExpireNever;
if (mDeletePermanentlyRB->isChecked()) { if (mDeletePermanentlyRB->isChecked()) {
settings.mExpireAction = ExpireCollectionAttribute::ExpireDelete; settings.mExpireAction = ExpireCollectionAttribute::ExpireDelete;

@ -57,10 +57,7 @@ private:
Q_REQUIRED_RESULT bool validateExpireFolder(bool expireNow); Q_REQUIRED_RESULT bool validateExpireFolder(bool expireNow);
Q_REQUIRED_RESULT MailCommon::ExpireCollectionAttribute *assignFolderAttribute(Akonadi::Collection &collection, bool &expireNow); Q_REQUIRED_RESULT MailCommon::ExpireCollectionAttribute *assignFolderAttribute(Akonadi::Collection &collection, bool &expireNow);
void slotChanged(); void slotChanged();
void slotUpdateControls();
QCheckBox *mExpireReadMailCB = nullptr;
KPluralHandlingSpinBox *mExpireReadMailSB = nullptr; KPluralHandlingSpinBox *mExpireReadMailSB = nullptr;
QCheckBox *mExpireUnreadMailCB = nullptr;
KPluralHandlingSpinBox *mExpireUnreadMailSB = nullptr; KPluralHandlingSpinBox *mExpireUnreadMailSB = nullptr;
QRadioButton *mMoveToRB = nullptr; QRadioButton *mMoveToRB = nullptr;
FolderRequester *mFolderSelector = nullptr; FolderRequester *mFolderSelector = nullptr;

@ -31,6 +31,8 @@
#include <KMessageBox> #include <KMessageBox>
#include <QCheckBox> #include <QCheckBox>
#include <QFontDatabase>
#include <QFormLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
@ -59,23 +61,18 @@ void CollectionGeneralPage::init(const Akonadi::Collection &collection)
auto topLayout = new QVBoxLayout(this); auto topLayout = new QVBoxLayout(this);
mCollectionGeneralWidget = new CollectionGeneralWidget(this);
topLayout->addWidget(mCollectionGeneralWidget);
auto innerLayout = qobject_cast<QFormLayout *>(mCollectionGeneralWidget->layout());
// Mustn't be able to edit details for a non-resource, system folder. // Mustn't be able to edit details for a non-resource, system folder.
if ((!mIsLocalSystemFolder || mIsResourceFolder) && !mFolderCollection->isReadOnly()) { if ((!mIsLocalSystemFolder || mIsResourceFolder) && !mFolderCollection->isReadOnly()) {
auto hl = new QHBoxLayout();
topLayout->addItem(hl);
label = new QLabel(i18nc("@label:textbox Name of the folder.", "&Name:"), this);
hl->addWidget(label);
mNameEdit = new QLineEdit(this); mNameEdit = new QLineEdit(this);
new KPIM::LineEditCatchReturnKey(mNameEdit, this); new KPIM::LineEditCatchReturnKey(mNameEdit, this);
connect(mNameEdit, &QLineEdit::textChanged, this, &CollectionGeneralPage::slotNameChanged); connect(mNameEdit, &QLineEdit::textChanged, this, &CollectionGeneralPage::slotNameChanged);
label->setBuddy(mNameEdit); innerLayout->insertRow(0, i18nc("@label:textbox Name of the folder.", "Folder &Name:"), mNameEdit);
hl->addWidget(mNameEdit);
} }
mCollectionGeneralWidget = new CollectionGeneralWidget(this);
topLayout->addWidget(mCollectionGeneralWidget);
// Only do make this settable, if the IMAP resource is enabled // Only do make this settable, if the IMAP resource is enabled
// and it's not the personal folders (those must not be changed) // and it's not the personal folders (those must not be changed)
const QString collectionResource = collection.resource(); const QString collectionResource = collection.resource();
@ -95,11 +92,8 @@ void CollectionGeneralPage::init(const Akonadi::Collection &collection)
const PimCommon::CollectionTypeUtil::FolderContentsType folderType = const PimCommon::CollectionTypeUtil::FolderContentsType folderType =
collectionUtil.typeFromKolabName(annotations.value(PimCommon::CollectionTypeUtil::kolabFolderType())); collectionUtil.typeFromKolabName(annotations.value(PimCommon::CollectionTypeUtil::kolabFolderType()));
int row = 0;
auto gl = new QGridLayout();
topLayout->addItem(gl);
mContentsComboBox = new PimCommon::ContentTypeWidget(this); mContentsComboBox = new PimCommon::ContentTypeWidget(this);
gl->addWidget(mContentsComboBox, row, 0, 1, 2); innerLayout->addRow(PimCommon::ContentTypeWidget::labelName(), mContentsComboBox);
mContentsComboBox->setCurrentIndex(contentsType); mContentsComboBox->setCurrentIndex(contentsType);
connect(mContentsComboBox, &PimCommon::ContentTypeWidget::activated, this, &CollectionGeneralPage::slotFolderContentsSelectionChanged); connect(mContentsComboBox, &PimCommon::ContentTypeWidget::activated, this, &CollectionGeneralPage::slotFolderContentsSelectionChanged);
@ -113,23 +107,22 @@ void CollectionGeneralPage::init(const Akonadi::Collection &collection)
// or if it's set to calendar or task (existing folder) // or if it's set to calendar or task (existing folder)
const bool folderTypeComboboxEnabled = const bool folderTypeComboboxEnabled =
(folderType == PimCommon::CollectionTypeUtil::ContentsTypeCalendar || folderType == PimCommon::CollectionTypeUtil::ContentsTypeTask); (folderType == PimCommon::CollectionTypeUtil::ContentsTypeCalendar || folderType == PimCommon::CollectionTypeUtil::ContentsTypeTask);
++row; if (folderTypeComboboxEnabled) {
mIncidencesForComboBox = new PimCommon::IncidencesForWidget(this); mIncidencesForComboBox = new PimCommon::IncidencesForWidget(this);
gl->addWidget(mIncidencesForComboBox, row, 0, 1, 2); innerLayout->addRow(PimCommon::IncidencesForWidget::labelName(), mIncidencesForComboBox);
mIncidencesForComboBox->setCurrentIndex(incidencesFor); mIncidencesForComboBox->setCurrentIndex(incidencesFor);
mIncidencesForComboBox->setEnabled(folderTypeComboboxEnabled); }
mSharedSeenFlagsCheckBox = new QCheckBox(this); mSharedSeenFlagsCheckBox = new QCheckBox(this);
mSharedSeenFlagsCheckBox->setText(i18n("Share unread state with all users")); mSharedSeenFlagsCheckBox->setText(i18n("Share unread state with all users"));
mSharedSeenFlagsCheckBox->setChecked(sharedSeen); mSharedSeenFlagsCheckBox->setChecked(sharedSeen);
++row;
gl->addWidget(mSharedSeenFlagsCheckBox, row, 0, 1, 1);
mSharedSeenFlagsCheckBox->setWhatsThis( mSharedSeenFlagsCheckBox->setWhatsThis(
i18n("If enabled, the unread state of messages in this folder will be " i18n("If enabled, the unread state of messages in this folder will be "
"the same for all users having access to this folder. If disabled " "the same for all users having access to this folder. If disabled "
"(the default), every user with access to this folder has their " "(the default), every user with access to this folder has their "
"own unread state.")); "own unread state."));
innerLayout->addRow(QString(), mSharedSeenFlagsCheckBox);
} }
topLayout->addStretch(100); // eat all superfluous space topLayout->addStretch(100); // eat all superfluous space

@ -12,20 +12,18 @@
#include <KIdentityManagement/IdentityCombo> #include <KIdentityManagement/IdentityCombo>
#include <KLocalizedString> #include <KLocalizedString>
#include <QCheckBox> #include <QCheckBox>
#include <QFormLayout>
#include <QFrame> #include <QFrame>
#include <QLabel> #include <QLabel>
#include <QVBoxLayout>
using namespace MailCommon; using namespace MailCommon;
CollectionGeneralWidget::CollectionGeneralWidget(QWidget *parent) CollectionGeneralWidget::CollectionGeneralWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
auto topLayout = new QVBoxLayout(this); auto topLayout = new QFormLayout(this);
topLayout->setObjectName(QStringLiteral("topLayout")); topLayout->setObjectName(QStringLiteral("topLayout"));
topLayout->setContentsMargins({}); topLayout->setContentsMargins({});
// should new mail in this folder be ignored? // should new mail in this folder be ignored?
auto hbl = new QHBoxLayout();
topLayout->addItem(hbl);
mNotifyOnNewMailCheckBox = new QCheckBox(i18n("Act on new/unread mail in this folder"), this); mNotifyOnNewMailCheckBox = new QCheckBox(i18n("Act on new/unread mail in this folder"), this);
mNotifyOnNewMailCheckBox->setWhatsThis( mNotifyOnNewMailCheckBox->setWhatsThis(
i18n("<qt><p>If this option is enabled then you will be notified about " i18n("<qt><p>If this option is enabled then you will be notified about "
@ -37,46 +35,29 @@ CollectionGeneralWidget::CollectionGeneralWidget(QWidget *parent)
"be skipped when going to the next/previous folder with unread " "be skipped when going to the next/previous folder with unread "
"messages. This is useful for ignoring any new/unread mail in " "messages. This is useful for ignoring any new/unread mail in "
"your trash and spam folder.</p></qt>")); "your trash and spam folder.</p></qt>"));
hbl->addWidget(mNotifyOnNewMailCheckBox); topLayout->addRow(QString(), mNotifyOnNewMailCheckBox);
// should replies to mails in this folder be kept in this same folder? // should replies to mails in this folder be kept in this same folder?
hbl = new QHBoxLayout();
topLayout->addItem(hbl);
mKeepRepliesInSameFolderCheckBox = new QCheckBox(i18n("Keep replies in this folder"), this); mKeepRepliesInSameFolderCheckBox = new QCheckBox(i18n("Keep replies in this folder"), this);
mKeepRepliesInSameFolderCheckBox->setWhatsThis( mKeepRepliesInSameFolderCheckBox->setWhatsThis(
i18n("Check this option if you want replies you write " i18n("Check this option if you want replies you write "
"to mails in this folder to be put in this same folder " "to mails in this folder to be put in this same folder "
"after sending, instead of in the configured sent-mail folder.")); "after sending, instead of in the configured sent-mail folder."));
hbl->addWidget(mKeepRepliesInSameFolderCheckBox); topLayout->addRow(QString(), mKeepRepliesInSameFolderCheckBox);
hbl->addStretch(1);
// should this folder be shown in the folder selection dialog? // should this folder be shown in the folder selection dialog?
hbl = new QHBoxLayout();
topLayout->addItem(hbl);
mHideInSelectionDialogCheckBox = new QCheckBox(i18n("Hide this folder in the folder selection dialog"), this); mHideInSelectionDialogCheckBox = new QCheckBox(i18n("Hide this folder in the folder selection dialog"), this);
mHideInSelectionDialogCheckBox->setWhatsThis(xi18nc("@info:whatsthis", mHideInSelectionDialogCheckBox->setWhatsThis(xi18nc("@info:whatsthis",
"Check this option if you do not want this folder " "Check this option if you do not want this folder "
"to be shown in folder selection dialogs, such as the <interface>" "to be shown in folder selection dialogs, such as the <interface>"
"Jump to Folder</interface> dialog.")); "Jump to Folder</interface> dialog."));
hbl->addWidget(mHideInSelectionDialogCheckBox); topLayout->addRow(QString(), mHideInSelectionDialogCheckBox);
hbl->addStretch(1);
addLine(this, topLayout);
// use grid layout for the following combobox settings
auto gl = new QGridLayout();
topLayout->addItem(gl);
gl->setColumnStretch(1, 100); // make the second column use all available space
int row = -1;
// sender identity // sender identity
++row;
mUseDefaultIdentityCheckBox = new QCheckBox(i18n("Use &default identity"), this); mUseDefaultIdentityCheckBox = new QCheckBox(i18n("Use &default identity"), this);
gl->addWidget(mUseDefaultIdentityCheckBox); topLayout->addRow(QString(), mUseDefaultIdentityCheckBox);
connect(mUseDefaultIdentityCheckBox, &QCheckBox::stateChanged, this, &CollectionGeneralWidget::slotIdentityCheckboxChanged); connect(mUseDefaultIdentityCheckBox, &QCheckBox::stateChanged, this, &CollectionGeneralWidget::slotIdentityCheckboxChanged);
++row;
auto label = new QLabel(i18n("&Sender identity:"), this);
gl->addWidget(label, row, 0);
mIdentityComboBox = new KIdentityManagement::IdentityCombo(KernelIf->identityManager(), this); mIdentityComboBox = new KIdentityManagement::IdentityCombo(KernelIf->identityManager(), this);
label->setBuddy(mIdentityComboBox);
gl->addWidget(mIdentityComboBox, row, 1);
mIdentityComboBox->setWhatsThis( mIdentityComboBox->setWhatsThis(
i18n("Select the sender identity to be used when writing new mail " i18n("Select the sender identity to be used when writing new mail "
"or replying to mail in this folder. This means that if you are in " "or replying to mail in this folder. This means that if you are in "
@ -84,22 +65,13 @@ CollectionGeneralWidget::CollectionGeneralWidget(QWidget *parent)
"sender email address, signature and signing or encryption keys " "sender email address, signature and signing or encryption keys "
"automatically. Identities can be set up in the main configuration " "automatically. Identities can be set up in the main configuration "
"dialog. (Settings -> Configure KMail)")); "dialog. (Settings -> Configure KMail)"));
topLayout->addRow(i18n("&Sender identity:"), mIdentityComboBox);
} }
CollectionGeneralWidget::~CollectionGeneralWidget() CollectionGeneralWidget::~CollectionGeneralWidget()
{ {
} }
void CollectionGeneralWidget::addLine(QWidget *parent, QVBoxLayout *layout)
{
auto line = new QFrame(parent);
line->setGeometry(QRect(80, 150, 250, 20));
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
line->setFrameShape(QFrame::HLine);
layout->addWidget(line);
}
void CollectionGeneralWidget::slotIdentityCheckboxChanged() void CollectionGeneralWidget::slotIdentityCheckboxChanged()
{ {
mIdentityComboBox->setEnabled(!mUseDefaultIdentityCheckBox->isChecked()); mIdentityComboBox->setEnabled(!mUseDefaultIdentityCheckBox->isChecked());

@ -11,7 +11,7 @@
#include <AkonadiCore/Collection> #include <AkonadiCore/Collection>
#include <QWidget> #include <QWidget>
class QCheckBox; class QCheckBox;
class QVBoxLayout; class QFormLayout;
namespace KIdentityManagement namespace KIdentityManagement
{ {
class IdentityCombo; class IdentityCombo;
@ -29,7 +29,6 @@ public:
void load(const Akonadi::Collection &col); void load(const Akonadi::Collection &col);
private: private:
void addLine(QWidget *parent, QVBoxLayout *layout);
void slotIdentityCheckboxChanged(); void slotIdentityCheckboxChanged();
QCheckBox *mNotifyOnNewMailCheckBox = nullptr; QCheckBox *mNotifyOnNewMailCheckBox = nullptr;
QCheckBox *mKeepRepliesInSameFolderCheckBox = nullptr; QCheckBox *mKeepRepliesInSameFolderCheckBox = nullptr;

@ -7,6 +7,7 @@
#include "collectionviewwidget.h" #include "collectionviewwidget.h"
#include "mailcommon_debug.h" #include "mailcommon_debug.h"
#include <KLocalizedString> #include <KLocalizedString>
#include <QFormLayout>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <Akonadi/KMime/MessageFolderAttribute> #include <Akonadi/KMime/MessageFolderAttribute>
@ -26,86 +27,62 @@ using namespace MailCommon;
CollectionViewWidget::CollectionViewWidget(QWidget *parent) CollectionViewWidget::CollectionViewWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
auto topLayout = new QVBoxLayout(this); auto topLayout = new QFormLayout(this);
topLayout->setObjectName(QStringLiteral("topLayout")); topLayout->setObjectName(QStringLiteral("topLayout"));
topLayout->setContentsMargins({}); topLayout->setContentsMargins({});
// sender or receiver column // sender or receiver column
const QString senderReceiverColumnTip = i18n("Show Sender/Receiver Column in List of Messages"); const QString senderReceiverColumnTip = i18n("Show Sender/Receiver Column in List of Messages");
auto senderReceiverColumnLabel = new QLabel(i18n("Sho&w column:"), this);
mShowSenderReceiverComboBox = new QComboBox(this); mShowSenderReceiverComboBox = new QComboBox(this);
mShowSenderReceiverComboBox->setToolTip(senderReceiverColumnTip); mShowSenderReceiverComboBox->setToolTip(senderReceiverColumnTip);
senderReceiverColumnLabel->setBuddy(mShowSenderReceiverComboBox);
mShowSenderReceiverComboBox->insertItem(0, i18nc("@item:inlistbox Show default value.", "Default")); mShowSenderReceiverComboBox->insertItem(0, i18nc("@item:inlistbox Show default value.", "Default"));
mShowSenderReceiverComboBox->insertItem(1, i18nc("@item:inlistbox Show sender.", "Sender")); mShowSenderReceiverComboBox->insertItem(1, i18nc("@item:inlistbox Show sender.", "Sender"));
mShowSenderReceiverComboBox->insertItem(2, i18nc("@item:inlistbox Show receiver.", "Receiver")); mShowSenderReceiverComboBox->insertItem(2, i18nc("@item:inlistbox Show receiver.", "Receiver"));
topLayout->addRow(i18n("Sho&w column:"), mShowSenderReceiverComboBox);
auto senderReceiverColumnHLayout = new QHBoxLayout();
senderReceiverColumnHLayout->addWidget(senderReceiverColumnLabel);
senderReceiverColumnHLayout->addWidget(mShowSenderReceiverComboBox);
topLayout->addLayout(senderReceiverColumnHLayout);
// message list
auto messageListGroup = new QGroupBox(i18n("Message List"), this);
auto messageListGroupLayout = new QVBoxLayout(messageListGroup);
topLayout->addWidget(messageListGroup);
// message list aggregation // message list aggregation
mUseDefaultAggregationCheckBox = new QCheckBox(i18n("Use default aggregation"), messageListGroup); mUseDefaultAggregationCheckBox = new QCheckBox(i18n("Use default message list aggregation:"), this);
messageListGroupLayout->addWidget(mUseDefaultAggregationCheckBox);
connect(mUseDefaultAggregationCheckBox, &QCheckBox::stateChanged, this, &CollectionViewWidget::slotAggregationCheckboxChanged); connect(mUseDefaultAggregationCheckBox, &QCheckBox::stateChanged, this, &CollectionViewWidget::slotAggregationCheckboxChanged);
topLayout->addRow(QString(), mUseDefaultAggregationCheckBox);
mAggregationComboBox = new MessageList::Utils::AggregationComboBox(messageListGroup); mAggregationComboBox = new MessageList::Utils::AggregationComboBox(this);
auto aggregationLabel = new QLabel(i18n("Aggregation"), messageListGroup);
aggregationLabel->setBuddy(mAggregationComboBox);
using MessageList::Utils::AggregationConfigButton; using MessageList::Utils::AggregationConfigButton;
auto aggregationConfigButton = new AggregationConfigButton(messageListGroup, mAggregationComboBox); auto aggregationConfigButton = new AggregationConfigButton(this, mAggregationComboBox);
// Make sure any changes made in the aggregations configure dialog are reflected in the combo. // Make sure any changes made in the aggregations configure dialog are reflected in the combo.
connect(aggregationConfigButton, &AggregationConfigButton::configureDialogCompleted, this, &CollectionViewWidget::slotSelectFolderAggregation); connect(aggregationConfigButton, &AggregationConfigButton::configureDialogCompleted, this, &CollectionViewWidget::slotSelectFolderAggregation);
auto aggregationLayout = new QHBoxLayout(); auto aggregationLayout = new QHBoxLayout;
aggregationLayout->addWidget(aggregationLabel, 1);
aggregationLayout->addWidget(mAggregationComboBox, 1); aggregationLayout->addWidget(mAggregationComboBox, 1);
aggregationLayout->addWidget(aggregationConfigButton, 0); aggregationLayout->addWidget(aggregationConfigButton, 0);
messageListGroupLayout->addLayout(aggregationLayout); topLayout->addRow(QString(), aggregationLayout);
// message list theme // message list theme
mUseDefaultThemeCheckBox = new QCheckBox(i18n("Use default theme"), messageListGroup); mUseDefaultThemeCheckBox = new QCheckBox(i18n("Use default message list theme"), this);
messageListGroupLayout->addWidget(mUseDefaultThemeCheckBox);
connect(mUseDefaultThemeCheckBox, &QCheckBox::stateChanged, this, &CollectionViewWidget::slotThemeCheckboxChanged); connect(mUseDefaultThemeCheckBox, &QCheckBox::stateChanged, this, &CollectionViewWidget::slotThemeCheckboxChanged);
topLayout->addRow(QString(), mUseDefaultThemeCheckBox);
mThemeComboBox = new MessageList::Utils::ThemeComboBox(messageListGroup); mThemeComboBox = new MessageList::Utils::ThemeComboBox(this);
auto themeLabel = new QLabel(i18n("Theme"), messageListGroup);
themeLabel->setBuddy(mThemeComboBox);
using MessageList::Utils::ThemeConfigButton; using MessageList::Utils::ThemeConfigButton;
auto themeConfigButton = new ThemeConfigButton(messageListGroup, mThemeComboBox); auto themeConfigButton = new ThemeConfigButton(this, mThemeComboBox);
// Make sure any changes made in the themes configure dialog are reflected in the combo. // Make sure any changes made in the themes configure dialog are reflected in the combo.
connect(themeConfigButton, &ThemeConfigButton::configureDialogCompleted, this, &CollectionViewWidget::slotSelectFolderTheme); connect(themeConfigButton, &ThemeConfigButton::configureDialogCompleted, this, &CollectionViewWidget::slotSelectFolderTheme);
auto themeLayout = new QHBoxLayout(); auto themeLayout = new QHBoxLayout;
themeLayout->addWidget(themeLabel, 1);
themeLayout->addWidget(mThemeComboBox, 1); themeLayout->addWidget(mThemeComboBox, 1);
themeLayout->addWidget(themeConfigButton, 0); themeLayout->addWidget(themeConfigButton, 0);
messageListGroupLayout->addLayout(themeLayout); topLayout->addRow(QString(), themeLayout);
// Message Default Format // Message Default Format
auto messageFormatGroup = new QGroupBox(i18n("Message Default Format"), this);
auto messageFormatGroupLayout = new QVBoxLayout(messageFormatGroup);
mPreferHtmlToText = new QRadioButton(i18n("Prefer HTML to text"), this); mPreferHtmlToText = new QRadioButton(i18n("Prefer HTML to text"), this);
messageFormatGroupLayout->addWidget(mPreferHtmlToText); topLayout->addRow(i18n("Message format:"), mPreferHtmlToText);
mPreferTextToHtml = new QRadioButton(i18n("Prefer text to HTML"), this); mPreferTextToHtml = new QRadioButton(i18n("Prefer text to HTML"), this);
messageFormatGroupLayout->addWidget(mPreferTextToHtml); topLayout->addRow(QString(), mPreferTextToHtml);
mUseGlobalSettings = new QRadioButton(i18n("Use Global Settings"), this); mUseGlobalSettings = new QRadioButton(i18n("Use Global Settings"), this);
messageFormatGroupLayout->addWidget(mUseGlobalSettings); topLayout->addRow(QString(), mUseGlobalSettings);
topLayout->addWidget(messageFormatGroup);
topLayout->addStretch(100);
} }
CollectionViewWidget::~CollectionViewWidget() CollectionViewWidget::~CollectionViewWidget()

Loading…
Cancel
Save