diff --git a/src/pimcommon/configureplugins/configurepluginslistwidget.h b/src/pimcommon/configureplugins/configurepluginslistwidget.h index 58c0d0f..6c1bc72 100644 --- a/src/pimcommon/configureplugins/configurepluginslistwidget.h +++ b/src/pimcommon/configureplugins/configurepluginslistwidget.h @@ -1,80 +1,81 @@ /* Copyright (c) 2016-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CONFIGUREPLUGINSLISTWIDGET_H #define CONFIGUREPLUGINSLISTWIDGET_H #include #include "pimcommon_export.h" #include #include class QTreeWidget; class QAction; namespace PimCommon { class PIMCOMMON_EXPORT ConfigurePluginsListWidget : public QWidget { Q_OBJECT public: explicit ConfigurePluginsListWidget(QWidget *parent = nullptr); ~ConfigurePluginsListWidget(); virtual void save(); virtual void doLoadFromGlobalSettings(); virtual void doResetToDefaultsOther(); virtual void defaults(); virtual void initialize(); Q_SIGNALS: void descriptionChanged(const QString &description); void changed(); void configureClicked(const QString &configureGroupName, const QString &identifier); private: void slotItemSelectionChanged(); void slotItemChanged(QTreeWidgetItem *item, int column); protected: class PluginItem : public QTreeWidgetItem { public: PluginItem(QTreeWidgetItem *parent) : QTreeWidgetItem(parent) , mEnableByDefault(false) , mHasConfigureSupport(false) , mEnableFromUserSettings(false) { } + QString mIdentifier; QString mDescription; bool mEnableByDefault; bool mHasConfigureSupport; bool mEnableFromUserSettings; }; void savePlugins(const QString &groupName, const QString &prefixSettingKey, const QList &listItems); void fillTopItems(const QVector &lst, const QString &topLevelItemName, const QString &groupName, const QString &prefixKey, QList &itemsList, const QString &configureGroupName = QString()); void resetToUserSettings(const QList &items); void changeState(const QList &items); QTreeWidget *mListWidget = nullptr; private: void slotConfigureClicked(QAction *act); }; } #endif // CONFIGUREPLUGINSLISTWIDGET_H diff --git a/src/pimcommon/logactivities/logactivitiesdialog.cpp b/src/pimcommon/logactivities/logactivitiesdialog.cpp index 20ed713..41d4cf0 100644 --- a/src/pimcommon/logactivities/logactivitiesdialog.cpp +++ b/src/pimcommon/logactivities/logactivitiesdialog.cpp @@ -1,147 +1,146 @@ /* Copyright (C) 2017-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "logactivitiesdialog.h" #include "logactivitieswidget.h" #include "logactivitiesmanager.h" #include "logactivitiespurposemenuwidget.h" #include #include #include #include #include #include #include #include #include using namespace PimCommon; LogActivitiesDialog::LogActivitiesDialog(QWidget *parent) : QDialog(parent) { setWindowTitle(i18n("Log activities")); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setObjectName(QStringLiteral("mainLayout")); mLogWidget = new LogActivitiesWidget(this); mLogWidget->setObjectName(QStringLiteral("logwidget")); mainLayout->addWidget(mLogWidget); mEnableLogActivities = new QCheckBox(i18n("Log activities"), this); mEnableLogActivities->setObjectName(QStringLiteral("enablelogactivities")); mainLayout->addWidget(mEnableLogActivities); connect(mEnableLogActivities, &QCheckBox::toggled, this, &LogActivitiesDialog::slotEnableLogActivities); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close | QDialogButtonBox::Save, this); buttonBox->setObjectName(QStringLiteral("buttonbox")); mClearButton = new QPushButton(i18n("Clear"), this); mClearButton->setObjectName(QStringLiteral("clearbutton")); buttonBox->addButton(mClearButton, QDialogButtonBox::ActionRole); connect(mClearButton, &QPushButton::clicked, this, &LogActivitiesDialog::slotClear); mSaveButton = buttonBox->button(QDialogButtonBox::Save); mSaveButton->setObjectName(QStringLiteral("savebutton")); mSaveButton->setEnabled(false); LogactivitiesPurposeMenuWidget *purposeMenu = new LogactivitiesPurposeMenuWidget(this, this); if (purposeMenu->menu()) { mShareButton = new QPushButton(i18n("Share..."), this); mShareButton->setMenu(purposeMenu->menu()); mShareButton->setIcon(QIcon::fromTheme(QStringLiteral("document-share"))); purposeMenu->setEditorWidget(mLogWidget->editor()); buttonBox->addButton(mShareButton, QDialogButtonBox::ActionRole); mShareButton->setEnabled(false); } else { delete purposeMenu; } - connect(mSaveButton, &QPushButton::clicked, this, &LogActivitiesDialog::slotSave); mainLayout->addWidget(buttonBox); connect(buttonBox, &QDialogButtonBox::rejected, this, &LogActivitiesDialog::reject); readConfig(); connect(PimCommon::LogActivitiesManager::self(), &LogActivitiesManager::logEntryAdded, this, &LogActivitiesDialog::slotLogEntryAdded); connect(PimCommon::LogActivitiesManager::self(), &LogActivitiesManager::logEntryCleared, this, &LogActivitiesDialog::slotLogEntryCleared); connect(mLogWidget, &LogActivitiesWidget::textChanged, this, &LogActivitiesDialog::slotActivityTextChanged); mEnableLogActivities->setChecked(PimCommon::LogActivitiesManager::self()->enableLogActivities()); } LogActivitiesDialog::~LogActivitiesDialog() { disconnect(mLogWidget, &LogActivitiesWidget::textChanged, this, &LogActivitiesDialog::slotActivityTextChanged); writeConfig(); } void LogActivitiesDialog::slotActivityTextChanged(bool changed) { mSaveButton->setEnabled(changed); if (mShareButton) { mShareButton->setEnabled(changed); } } void LogActivitiesDialog::slotSave() { const QString filter = i18n("All Files (*)"); PimCommon::Util::saveTextAs(PimCommon::LogActivitiesManager::self()->log(), filter, this, QUrl(), i18nc("@title:window", "Save Log")); } void LogActivitiesDialog::slotEnableLogActivities(bool state) { PimCommon::LogActivitiesManager::self()->setEnableLogActivities(state); } void LogActivitiesDialog::setLog(const QString &str) { mLogWidget->setLog(str); } void LogActivitiesDialog::slotLogEntryAdded(const QString &entry) { mLogWidget->addLogEntry(entry); } void LogActivitiesDialog::slotLogEntryCleared() { mLogWidget->clear(); } void LogActivitiesDialog::slotClear() { mLogWidget->clear(); Q_EMIT logCleared(); } void LogActivitiesDialog::readConfig() { KConfigGroup group(KSharedConfig::openConfig(), "LogActivitiesDialog"); const QSize sizeDialog = group.readEntry("Size", QSize(800, 600)); if (sizeDialog.isValid()) { resize(sizeDialog); } } void LogActivitiesDialog::writeConfig() { KConfigGroup group(KSharedConfig::openConfig(), "LogActivitiesDialog"); group.writeEntry("Size", size()); } diff --git a/src/pimcommon/widgets/autotests/purposemenuwidgettest.cpp b/src/pimcommon/widgets/autotests/purposemenuwidgettest.cpp index 5ccd136..f31e67a 100644 --- a/src/pimcommon/widgets/autotests/purposemenuwidgettest.cpp +++ b/src/pimcommon/widgets/autotests/purposemenuwidgettest.cpp @@ -1,41 +1,39 @@ /* Copyright (c) 2018-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "purposemenuwidgettest.h" #include #include QTEST_MAIN(PurposeMenuWidgetTest) - PurposeMenuWidgetTest::PurposeMenuWidgetTest(QObject *parent) : QObject(parent) { - } void PurposeMenuWidgetTest::shouldHaveDefaultValues() { TestMenu w(nullptr); #ifdef KF5_USE_PURPOSE QVERIFY(w.menu()); QCOMPARE(w.menu()->objectName(), QStringLiteral("purposesharemenu")); #else QVERIFY(!w.menu()); #endif } diff --git a/src/pimcommon/widgets/autotests/purposemenuwidgettest.h b/src/pimcommon/widgets/autotests/purposemenuwidgettest.h index f6c9f6b..aec0f19 100644 --- a/src/pimcommon/widgets/autotests/purposemenuwidgettest.h +++ b/src/pimcommon/widgets/autotests/purposemenuwidgettest.h @@ -1,50 +1,48 @@ /* Copyright (c) 2018-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PURPOSEMENUWIDGETTEST_H #define PURPOSEMENUWIDGETTEST_H #include #include "widgets/purposemenuwidget.h" class TestMenu : public PimCommon::PurposeMenuWidget { Q_OBJECT public: TestMenu(QWidget *parentWidget, QObject *parent = nullptr) : PimCommon::PurposeMenuWidget(parentWidget, parent) { - } QByteArray text() override { return ""; } }; - class PurposeMenuWidgetTest : public QObject { Q_OBJECT public: explicit PurposeMenuWidgetTest(QObject *parent = nullptr); ~PurposeMenuWidgetTest() = default; private Q_SLOTS: void shouldHaveDefaultValues(); }; #endif // PURPOSEMENUWIDGETTEST_H diff --git a/src/pimcommon/widgets/purposemenuwidget.cpp b/src/pimcommon/widgets/purposemenuwidget.cpp index 43760d0..b0d14e7 100644 --- a/src/pimcommon/widgets/purposemenuwidget.cpp +++ b/src/pimcommon/widgets/purposemenuwidget.cpp @@ -1,95 +1,93 @@ /* Copyright (c) 2018-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - #include "purposemenuwidget.h" #ifdef KF5_USE_PURPOSE #include #include #include #include #include #include #include #endif - using namespace PimCommon; PurposeMenuWidget::PurposeMenuWidget(QWidget *parentWidget, QObject *parent) - : QObject(parent), - mParentWidget(parentWidget) + : QObject(parent) + , mParentWidget(parentWidget) { #ifdef KF5_USE_PURPOSE mShareMenu = new Purpose::Menu(mParentWidget); mShareMenu->setObjectName(QStringLiteral("purposesharemenu")); mShareMenu->model()->setPluginType(QStringLiteral("Export")); connect(mShareMenu, &Purpose::Menu::aboutToShow, this, &PurposeMenuWidget::slotInitializeShareMenu); connect(mShareMenu, &Purpose::Menu::finished, this, &PurposeMenuWidget::slotShareActionFinished); #endif } PurposeMenuWidget::~PurposeMenuWidget() { #ifdef KF5_USE_PURPOSE delete mTemporaryShareFile; #endif } QMenu *PurposeMenuWidget::menu() const { #ifdef KF5_USE_PURPOSE return mShareMenu; #else return nullptr; #endif } void PurposeMenuWidget::slotInitializeShareMenu() { #ifdef KF5_USE_PURPOSE delete mTemporaryShareFile; mTemporaryShareFile = new QTemporaryFile(); mTemporaryShareFile->open(); mTemporaryShareFile->setPermissions(QFile::ReadUser); mTemporaryShareFile->write(text()); mTemporaryShareFile->close(); mShareMenu->model()->setInputData(QJsonObject { { QStringLiteral("urls"), QJsonArray { {QUrl::fromLocalFile(mTemporaryShareFile->fileName()).toString()} } }, { QStringLiteral("mimeType"), { QStringLiteral("text/plain") } } }); mShareMenu->reload(); #endif } void PurposeMenuWidget::slotShareActionFinished(const QJsonObject &output, int error, const QString &message) { #ifdef KF5_USE_PURPOSE if (error) { KMessageBox::error(mParentWidget, i18n("There was a problem sharing the document: %1", message), i18n("Share")); } else { const QString url = output[QLatin1String("url")].toString(); if (url.isEmpty()) { KMessageBox::information(mParentWidget, i18n("File was shared.")); } else { KMessageBox::information(mParentWidget, i18n("You can find the new request at:
%1
", url), - QString(), QString(), KMessageBox::AllowLink); + QString(), QString(), KMessageBox::AllowLink); } } #endif } diff --git a/src/pimcommon/widgets/purposemenuwidget.h b/src/pimcommon/widgets/purposemenuwidget.h index f5e8983..d403904 100644 --- a/src/pimcommon/widgets/purposemenuwidget.h +++ b/src/pimcommon/widgets/purposemenuwidget.h @@ -1,54 +1,53 @@ /* Copyright (c) 2018-2019 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef PURPOSEMENUWIDGET_H #define PURPOSEMENUWIDGET_H #include #include "pimcommon_export.h" #include #ifdef KF5_USE_PURPOSE namespace Purpose { class Menu; } #endif class QMenu; class QTemporaryFile; -namespace PimCommon -{ +namespace PimCommon { class PIMCOMMON_EXPORT PurposeMenuWidget : public QObject { Q_OBJECT public: explicit PurposeMenuWidget(QWidget *parentWidget, QObject *parent = nullptr); ~PurposeMenuWidget() override; virtual QByteArray text() = 0; QMenu *menu() const; private: void slotInitializeShareMenu(); void slotShareActionFinished(const QJsonObject &output, int error, const QString &message); #ifdef KF5_USE_PURPOSE Purpose::Menu *mShareMenu = nullptr; QTemporaryFile *mTemporaryShareFile = nullptr; #endif QWidget *mParentWidget = nullptr; }; } #endif // PURPOSEMENUWIDGET_H diff --git a/src/pimcommonakonadi/acl/aclentrydialog.cpp b/src/pimcommonakonadi/acl/aclentrydialog.cpp index ec23f88..34e6432 100644 --- a/src/pimcommonakonadi/acl/aclentrydialog.cpp +++ b/src/pimcommonakonadi/acl/aclentrydialog.cpp @@ -1,201 +1,201 @@ /* * Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com * Copyright (c) 2010 Tobias Koenig * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "aclentrydialog_p.h" #include "aclutils_p.h" #include #include #include #include #include #include #include #include #include #include #include using namespace PimCommon; class AclEntryDialog::Private { public: Private(AclEntryDialog *qq) : q(qq) , mButtonGroup(nullptr) , mUserIdLineEdit(nullptr) , mButtonLayout(nullptr) , mOkButton(nullptr) { } void slotChanged(); void slotSelectAddresses(); AclEntryDialog *q = nullptr; QButtonGroup *mButtonGroup = nullptr; KPIM::AddresseeLineEdit *mUserIdLineEdit = nullptr; QVBoxLayout *mButtonLayout = nullptr; KIMAP::Acl::Rights mCustomPermissions; QPushButton *mOkButton = nullptr; }; void AclEntryDialog::Private::slotChanged() { mOkButton->setEnabled(!mUserIdLineEdit->text().trimmed().isEmpty() && mButtonGroup->checkedButton() != nullptr); } void AclEntryDialog::Private::slotSelectAddresses() { Akonadi::EmailAddressSelectionDialog dlg; if (!dlg.exec()) { return; } const QString text = !dlg.selectedAddresses().isEmpty() ? dlg.selectedAddresses().at(0).quotedEmail() : QString(); mUserIdLineEdit->setText(text); } AclEntryDialog::AclEntryDialog(QWidget *parent) : QDialog(parent) , d(new Private(this)) { QVBoxLayout *mainLayout = new QVBoxLayout(this); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); d->mOkButton = buttonBox->button(QDialogButtonBox::Ok); d->mOkButton->setDefault(true); d->mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return); connect(buttonBox, &QDialogButtonBox::accepted, this, &AclEntryDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &AclEntryDialog::reject); QWidget *page = new QWidget(this); mainLayout->addWidget(page); mainLayout->addWidget(buttonBox); QGridLayout *layout = new QGridLayout(page); layout->setMargin(0); QLabel *label = new QLabel(i18n("&User identifier:"), page); layout->addWidget(label, 0, 0); d->mUserIdLineEdit = new KPIM::AddresseeLineEdit(page); layout->addWidget(d->mUserIdLineEdit, 0, 1); label->setBuddy(d->mUserIdLineEdit); d->mUserIdLineEdit->setWhatsThis( i18nc("@info:whatsthis", "The User Identifier is the login of the user on the IMAP server. " "This can be a simple user name or the full email address of the user; " "the login for your own account on the server will tell you which one it is.")); QPushButton *button = new QPushButton(i18nc("select an email address", "Se&lect..."), page); layout->addWidget(button, 0, 2); QGroupBox *groupBox = new QGroupBox(i18n("Permissions"), page); d->mButtonLayout = new QVBoxLayout(groupBox); d->mButtonGroup = new QButtonGroup(groupBox); for (unsigned int i = 0; i < AclUtils::standardPermissionsCount(); ++i) { const KIMAP::Acl::Rights permissions = AclUtils::permissionsForIndex(i); QRadioButton *radioButton = new QRadioButton(AclUtils::permissionsToUserString(permissions), groupBox); d->mButtonLayout->addWidget(radioButton); d->mButtonGroup->addButton(radioButton, permissions); } d->mButtonLayout->addStretch(1); layout->addWidget(groupBox, 1, 0, 1, 3); label = new QLabel( - i18n("Note: Renaming requires write permissions on the parent folder."), page); + i18n("Note: Renaming requires write permissions on the parent folder."), page); layout->addWidget(label, 2, 0, 1, 3); layout->setRowStretch(2, 10); connect(d->mUserIdLineEdit, &KPIM::AddresseeLineEdit::textChanged, this, [this]() { d->slotChanged(); }); connect(button, &QPushButton::clicked, this, [this]() { d->slotSelectAddresses(); }); connect(d->mButtonGroup, QOverload::of(&QButtonGroup::buttonClicked), this, [this]() { d->slotChanged(); }); d->mOkButton->setEnabled(false); d->mUserIdLineEdit->setFocus(); } AclEntryDialog::~AclEntryDialog() { delete d; } void AclEntryDialog::setUserId(const QString &userId) { d->mUserIdLineEdit->setText(userId); d->mOkButton->setEnabled(!userId.isEmpty()); } QString AclEntryDialog::userId() const { return d->mUserIdLineEdit->text(); } void AclEntryDialog::setPermissions(KIMAP::Acl::Rights permissions) { QAbstractButton *button = d->mButtonGroup->button(KIMAP::Acl::normalizedRights(permissions)); if (button) { button->setChecked(true); } else { QRadioButton *radioButton = new QRadioButton(AclUtils::permissionsToUserString(permissions)); d->mButtonLayout->addWidget(radioButton); d->mButtonGroup->addButton(radioButton, permissions); } d->mCustomPermissions = permissions; } KIMAP::Acl::Rights AclEntryDialog::permissions() const { QAbstractButton *button = d->mButtonGroup->checkedButton(); if (!button) { return d->mCustomPermissions; } return KIMAP::Acl::denormalizedRights( static_cast(d->mButtonGroup->id(button))); } #include "moc_aclentrydialog_p.cpp"