Commit 18edaddf authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Port mailing list and view tab in collection dialog to QFormLayout

Part of mailcommon!5
parent 7b75e4f7
Pipeline #71751 passed with stage
in 22 minutes and 32 seconds
......@@ -17,12 +17,13 @@
#include <AkonadiCore/itemfetchscope.h>
#include <QCheckBox>
#include <QFormLayout>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QSpacerItem>
#include <QVBoxLayout>
#include "kmail_debug.h"
#include <KEditListWidget>
......@@ -58,60 +59,54 @@ void CollectionMailingListPage::init(const Akonadi::Collection &col)
mCurrentCollection = col;
mFolder = FolderSettings::forCollection(col, false);
auto topLayout = new QVBoxLayout(this);
auto topLayout = new QFormLayout(this);
mHoldsMailingList = new QCheckBox(i18n("Folder holds a mailing list"), this);
connect(mHoldsMailingList, &QCheckBox::toggled, this, &CollectionMailingListPage::slotHoldsML);
connect(mHoldsMailingList, &QCheckBox::toggled, this, &CollectionMailingListPage::slotConfigChanged);
topLayout->addWidget(mHoldsMailingList);
topLayout->addRow(QString(), mHoldsMailingList);
mGroupWidget = new QWidget(this);
auto groupLayout = new QGridLayout(mGroupWidget);
mDetectButton = new QPushButton(i18n("Detect Automatically"), mGroupWidget);
mDetectButton = new QPushButton(i18n("Detect Automatically"), this);
connect(mDetectButton, &QPushButton::pressed, this, &CollectionMailingListPage::slotDetectMailingList);
groupLayout->addWidget(mDetectButton, 2, 1);
groupLayout->addItem(new QSpacerItem(0, 10), 3, 0);
topLayout->addRow(QString(), mDetectButton);
auto label = new QLabel(i18n("Mailing list description:"), mGroupWidget);
groupLayout->addWidget(label, 4, 0);
mMLId = new KSqueezedTextLabel(QString(), mGroupWidget);
mMLId = new KSqueezedTextLabel(QString(), this);
mMLId->setTextElideMode(Qt::ElideRight);
groupLayout->addWidget(mMLId, 4, 1, 1, 2);
topLayout->addRow(i18n("Mailing list description:"), mMLId);
// FIXME: add QWhatsThis
label = new QLabel(i18n("Preferred handler:"), mGroupWidget);
groupLayout->addWidget(label, 5, 0);
mMLHandlerCombo = new QComboBox(mGroupWidget);
mMLHandlerCombo = new QComboBox(this);
mMLHandlerCombo->addItem(i18n("KMail"), MailingList::KMail);
mMLHandlerCombo->addItem(i18n("Browser"), MailingList::Browser);
groupLayout->addWidget(mMLHandlerCombo, 5, 1, 1, 2);
connect(mMLHandlerCombo, qOverload<int>(&QComboBox::activated), this, &CollectionMailingListPage::slotMLHandling);
label->setBuddy(mMLHandlerCombo);
label = new QLabel(i18n("Address type:"), mGroupWidget);
groupLayout->addWidget(label, 6, 0);
mAddressCombo = new QComboBox(mGroupWidget);
label->setBuddy(mAddressCombo);
groupLayout->addWidget(mAddressCombo, 6, 1);
topLayout->addRow(i18n("Preferred handler:"), mMLHandlerCombo);
auto addressWidget = new QWidget(this);
addressWidget->setContentsMargins({});
auto addressTypeLayout = new QHBoxLayout(addressWidget);
addressTypeLayout->setContentsMargins({});
mAddressCombo = new QComboBox(this);
addressTypeLayout->addWidget(mAddressCombo);
// FIXME: if the mailing list actions have either QAction's or toolbar buttons
// associated with them - remove this button since it's really silly
// here
auto handleButton = new QPushButton(i18n("Invoke Handler"), mGroupWidget);
mHandleButton = new QPushButton(i18n("Invoke Handler"), this);
if (mFolder) {
connect(handleButton, &QPushButton::clicked, this, &CollectionMailingListPage::slotInvokeHandler);
connect(mHandleButton, &QPushButton::clicked, this, &CollectionMailingListPage::slotInvokeHandler);
} else {
handleButton->setEnabled(false);
mHandleButton->setEnabled(false);
}
addressTypeLayout->addWidget(mHandleButton);
topLayout->addRow(i18n("Address type:"), addressWidget);
groupLayout->addWidget(handleButton, 6, 2);
topLayout->addRow(new QLabel(i18n("URL for mailing list posting:"), this));
mEditList = new KEditListWidget(mGroupWidget);
mEditList = new KEditListWidget(this);
mEditList->lineEdit()->setClearButtonEnabled(true);
connect(mEditList, &KEditListWidget::changed, this, &CollectionMailingListPage::slotConfigChanged);
groupLayout->addWidget(mEditList, 7, 0, 1, 4);
topLayout->addRow(mEditList);
// Order is important because the activate handler and fillMLFromWidgets
// depend on it
......@@ -119,8 +114,11 @@ void CollectionMailingListPage::init(const Akonadi::Collection &col)
mAddressCombo->addItems(el);
connect(mAddressCombo, qOverload<int>(&QComboBox::activated), this, &CollectionMailingListPage::slotAddressChanged);
topLayout->addWidget(mGroupWidget);
mGroupWidget->setEnabled(false);
mMLId->setEnabled(false);
mMLHandlerCombo->setEnabled(false);
mAddressCombo->setEnabled(false);
mHandleButton->setEnabled(false);
mEditList->setEnabled(false);
}
void CollectionMailingListPage::load(const Akonadi::Collection &col)
......@@ -157,7 +155,13 @@ void CollectionMailingListPage::save(Akonadi::Collection &col)
//----------------------------------------------------------------------------
void CollectionMailingListPage::slotHoldsML(bool holdsML)
{
mGroupWidget->setEnabled(holdsML);
mMLId->setEnabled(holdsML);
mMLHandlerCombo->setEnabled(holdsML);
mAddressCombo->setEnabled(holdsML);
if (mFolder) {
mHandleButton->setEnabled(holdsML);
}
mEditList->setEnabled(holdsML);
mDetectButton->setEnabled(mFolder && mFolder->count() != 0);
}
......
......@@ -21,6 +21,7 @@ class QPushButton;
template<typename T> class QSharedPointer;
class QComboBox;
class QPushButton;
class KJob;
class KEditListWidget;
class KSqueezedTextLabel;
......@@ -62,7 +63,7 @@ private:
QComboBox *mAddressCombo = nullptr;
KEditListWidget *mEditList = nullptr;
KSqueezedTextLabel *mMLId = nullptr;
QWidget *mGroupWidget = nullptr;
QPushButton *mHandleButton = nullptr;
int mLastItem = 0;
bool changed = false;
};
......
......@@ -14,6 +14,7 @@
#include <KIconButton>
#include <KLocalizedString>
#include <QCheckBox>
#include <QFormLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QVBoxLayout>
......@@ -24,6 +25,7 @@
#include <MessageList/ThemeConfigButton>
#include <MailCommon/CollectionViewWidget>
#include <QDebug>
using namespace MailCommon;
......@@ -42,11 +44,19 @@ void CollectionViewPage::init(const Akonadi::Collection &col)
mIsLocalSystemFolder = CommonKernel->isSystemFolderCollection(col) || mFolderCollection->isStructural() || Kernel::folderIsInbox(col);
auto topLayout = new QVBoxLayout(this);
mCollectionViewWidget = new MailCommon::CollectionViewWidget(this);
topLayout->addWidget(mCollectionViewWidget);
// Musn't be able to edit details for non-resource, system folder.
if (!mIsLocalSystemFolder) {
auto innerLayout = qobject_cast<QFormLayout *>(mCollectionViewWidget->layout());
Q_ASSERT(innerLayout != nullptr);
// icons
mIconsCheckBox = new QCheckBox(i18n("Use custom &icons"), this);
mIconsCheckBox->setChecked(false);
innerLayout->insertRow(0, QString(), mIconsCheckBox);
mNormalIconLabel = new QLabel(i18nc("Icon used for folders with no unread messages.", "&Normal:"), this);
mNormalIconLabel->setEnabled(false);
......@@ -75,14 +85,12 @@ void CollectionViewPage::init(const Akonadi::Collection &col)
mUnreadIconButton->setEnabled(false);
auto iconHLayout = new QHBoxLayout();
iconHLayout->addWidget(mIconsCheckBox);
iconHLayout->addStretch(2);
iconHLayout->addWidget(mNormalIconLabel);
iconHLayout->addWidget(mNormalIconButton);
iconHLayout->addWidget(mUnreadIconLabel);
iconHLayout->addWidget(mUnreadIconButton);
iconHLayout->addStretch(1);
topLayout->addLayout(iconHLayout);
innerLayout->insertRow(1, QString(), iconHLayout);
connect(mIconsCheckBox, &QCheckBox::toggled, mNormalIconLabel, &QLabel::setEnabled);
connect(mIconsCheckBox, &QCheckBox::toggled, mNormalIconButton, &KIconButton::setEnabled);
......@@ -92,9 +100,6 @@ void CollectionViewPage::init(const Akonadi::Collection &col)
connect(mNormalIconButton, &KIconButton::iconChanged, this, &CollectionViewPage::slotChangeIcon);
}
mCollectionViewWidget = new MailCommon::CollectionViewWidget(this);
topLayout->addWidget(mCollectionViewWidget);
topLayout->addStretch(100);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment