diff --git a/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp b/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp index ab146498..5a5b670f 100644 --- a/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp +++ b/kmail/editorsendcheckplugins/automaticaddcontacts/automaticaddcontactsjob.cpp @@ -1,262 +1,265 @@ /* Copyright (C) 2016-2017 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "automaticaddcontactsjob.h" #include "automaticaddcontactsplugin_debug.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include AutomaticAddContactsJob::AutomaticAddContactsJob(QObject *parent) : QObject(parent) , mCurrentIndex(-1) { } AutomaticAddContactsJob::~AutomaticAddContactsJob() { } void AutomaticAddContactsJob::start() { if (mEmails.isEmpty()) { deleteLaterAndEmitSignal(); return; } else { if (!mCollection.isValid()) { qCDebug(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Invalid collection"; deleteLaterAndEmitSignal(); return; } } mCurrentIndex = -1; fetchCollection(); } void AutomaticAddContactsJob::fetchCollection() { Akonadi::CollectionFetchJob *const addressBookJob = new Akonadi::CollectionFetchJob(mCollection, Akonadi::CollectionFetchJob::Base); const QStringList mimeTypes(KContacts::Addressee::mimeType()); addressBookJob->fetchScope().setContentMimeTypes(mimeTypes); connect(addressBookJob, &KJob::result, this, &AutomaticAddContactsJob::slotSelectedCollectionFetched); } void AutomaticAddContactsJob::slotSelectedCollectionFetched(KJob *job) { if (job->error()) { //Collection not found. //fetch all collection const QStringList mimeTypes(KContacts::Addressee::mimeType()); Akonadi::CollectionFetchJob *const addressBookJob = new Akonadi::CollectionFetchJob(Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive); addressBookJob->fetchScope().setContentMimeTypes(mimeTypes); connect(addressBookJob, &KJob::result, this, &AutomaticAddContactsJob::slotFetchAllCollections); return; } const Akonadi::CollectionFetchJob *addressBookJob = qobject_cast(job); mCollection = addressBookJob->collections().at(0); addNextContact(); } void AutomaticAddContactsJob::slotFetchAllCollections(KJob *job) { if (job->error()) { qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Error during AutomaticAddContactsJob::slotFetchAllCollections : " << job->errorString(); deleteLaterAndEmitSignal(); return; } const Akonadi::CollectionFetchJob *addressBookJob = qobject_cast(job); Akonadi::Collection::List canCreateItemCollections; const Akonadi::Collection::List addressBookCollections = addressBookJob->collections(); for (const Akonadi::Collection &collection : addressBookCollections) { if (Akonadi::Collection::CanCreateItem & collection.rights()) { canCreateItemCollections.append(collection); } } Akonadi::Collection addressBook; const int nbItemCollection(canCreateItemCollections.size()); if (nbItemCollection == 0) { if (KMessageBox::questionYesNo( nullptr, i18nc("@info", "You must create an address book before adding a contact. Do you want to create an address book?"), i18nc("@title:window", "No Address Book Available")) == KMessageBox::Yes) { - Akonadi::AgentTypeDialog dlg(nullptr); - dlg.setWindowTitle(i18n("Add Address Book")); - dlg.agentFilterProxyModel()->addMimeTypeFilter(KContacts::Addressee::mimeType()); - dlg.agentFilterProxyModel()->addMimeTypeFilter(KContacts::ContactGroup::mimeType()); - dlg.agentFilterProxyModel()->addCapabilityFilter(QStringLiteral("Resource")); + QPointer dlg = new Akonadi::AgentTypeDialog(nullptr); + dlg->setWindowTitle(i18n("Add Address Book")); + dlg->agentFilterProxyModel()->addMimeTypeFilter(KContacts::Addressee::mimeType()); + dlg->agentFilterProxyModel()->addMimeTypeFilter(KContacts::ContactGroup::mimeType()); + dlg->agentFilterProxyModel()->addCapabilityFilter(QStringLiteral("Resource")); - if (dlg.exec()) { - const Akonadi::AgentType agentType = dlg.agentType(); + if (dlg->exec()) { + const Akonadi::AgentType agentType = dlg->agentType(); if (agentType.isValid()) { Akonadi::AgentInstanceCreateJob *job = new Akonadi::AgentInstanceCreateJob(agentType, this); connect(job, &KJob::result, this, &AutomaticAddContactsJob::slotResourceCreationDone); job->configure(); job->start(); + delete dlg; return; } else { //if agent is not valid => return error and finish job deleteLaterAndEmitSignal(); + delete dlg; return; } } else { //Canceled create agent => return error and finish job deleteLaterAndEmitSignal(); + delete dlg; return; } } else { deleteLaterAndEmitSignal(); return; } } else if (nbItemCollection == 1) { addressBook = canCreateItemCollections[0]; } else { // ask user in which address book the new contact shall be stored QPointer dlg = new Akonadi::SelectAddressBookDialog(0); bool gotIt = true; if (dlg->exec()) { addressBook = dlg->selectedCollection(); } else { gotIt = false; } delete dlg; if (!gotIt) { qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Unable to selected Addressbook selected not valid"; deleteLaterAndEmitSignal(); return; } } if (!addressBook.isValid()) { qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Addressbook selected not valid"; deleteLaterAndEmitSignal(); return; } addNextContact(); } void AutomaticAddContactsJob::slotResourceCreationDone(KJob *job) { if (job->error()) { qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Unable to create resource:" << job->errorText(); deleteLaterAndEmitSignal(); return; } addNextContact(); } void AutomaticAddContactsJob::verifyContactExist() { const QString email = mEmails.at(mCurrentIndex); QString tname, temail; KEmailAddress::extractEmailAddressAndName(email, temail, tname); if (temail.isEmpty()) { addNextContact(); } else { if (mProcessedEmails.contains(email)) { addNextContact(); } else { mProcessEmail = email; mName = tname; mProcessedEmails.append(email); Akonadi::ContactSearchJob *searchJob = new Akonadi::ContactSearchJob(this); searchJob->setLimit(1); searchJob->setQuery(Akonadi::ContactSearchJob::Email, mProcessEmail.toLower(), Akonadi::ContactSearchJob::ExactMatch); connect(searchJob, &KJob::result, this, &AutomaticAddContactsJob::slotSearchDone); } } } void AutomaticAddContactsJob::slotSearchDone(KJob *job) { Akonadi::ContactSearchJob *searchJob = static_cast(job); if (searchJob->error()) { qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Unable to fetch contact:" << searchJob->errorText(); } else if (searchJob->contacts().isEmpty()) { KContacts::Addressee contact; contact.setNameFromString(mName); contact.insertEmail(mProcessEmail, true); // create the new item Akonadi::Item item; item.setMimeType(KContacts::Addressee::mimeType()); item.setPayload(contact); // save the new item in akonadi storage Akonadi::ItemCreateJob *createJob = new Akonadi::ItemCreateJob(item, mCollection, this); connect(createJob, &KJob::result, this, &AutomaticAddContactsJob::slotAddContactDone); return; } addNextContact(); } void AutomaticAddContactsJob::slotAddContactDone(KJob *job) { if (job->error()) { qCWarning(KMAIL_EDITOR_AUTOMATICADDCONTACTS_PLUGIN_LOG) << "Error when add contact to addressbook:" << job->errorText(); } addNextContact(); } void AutomaticAddContactsJob::addNextContact() { mCurrentIndex++; if (mCurrentIndex < mEmails.count()) { verifyContactExist(); } else { deleteLaterAndEmitSignal(); } } void AutomaticAddContactsJob::setEmails(const QStringList &list) { mEmails = PimCommon::Util::generateEmailList(list); } void AutomaticAddContactsJob::setCollection(const Akonadi::Collection &collection) { mCollection = collection; } void AutomaticAddContactsJob::deleteLaterAndEmitSignal() { Q_EMIT finished(); deleteLater(); } diff --git a/korganizer/plugins/picoftheday/picoftheday.cpp b/korganizer/plugins/picoftheday/picoftheday.cpp index 662ed6e0..a073eac2 100644 --- a/korganizer/plugins/picoftheday/picoftheday.cpp +++ b/korganizer/plugins/picoftheday/picoftheday.cpp @@ -1,356 +1,358 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher Copyright (c) 2007 Loïc Corbasson 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 "picoftheday.h" #include "configdialog.h" #include #include #include "korganizer_picoftheday_plugin_debug.h" #include #include #include +#include Picoftheday::Picoftheday() { KConfig _config(QStringLiteral("korganizerrc")); KConfigGroup config(&_config, "Picture of the Day Plugin"); mThumbSize = config.readEntry("InitialThumbnailSize", QSize(120, 60)); } Picoftheday::~Picoftheday() { } void Picoftheday::configure(QWidget *parent) { - ConfigDialog dlg(parent); - dlg.exec(); + QPointer dlg = new ConfigDialog(parent); + dlg->exec(); + delete dlg; } QString Picoftheday::info() const { return i18n("This plugin provides the Wikipedia " "Picture of the Day."); } Element::List Picoftheday::createDayElements(const QDate &date) { Element::List elements; POTDElement *element = new POTDElement(QStringLiteral("main element"), date, mThumbSize); elements.append(element); return elements; } //////////////////////////////////////////////////////////////////////////////// POTDElement::POTDElement(const QString &id, const QDate &date, const QSize &initialThumbSize) : StoredElement(id) , mDate(date) , mThumbSize(initialThumbSize) , mFirstStepCompleted(false) , mSecondStepCompleted(false) , mFirstStepJob(nullptr) , mSecondStepJob(nullptr) , mThirdStepJob(nullptr) { setShortText(i18n("Loading...")); setLongText(i18n("Loading Picture of the Day...")); mTimer = new QTimer(this); mTimer->setSingleShot(true); step1StartDownload(); } /** First step of three in the download process */ void POTDElement::step1StartDownload() { // Start downloading the picture if (!mFirstStepCompleted && !mFirstStepJob) { QUrl url = QUrl(QStringLiteral("http://en.wikipedia.org/w/index.php?title=Template:POTD/") +mDate.toString(Qt::ISODate) + QStringLiteral("&action=raw")); // The file at that URL contains the file name for the POTD mFirstStepJob = KIO::storedGet(url, KIO::NoReload, KIO::HideProgressInfo); KIO::Scheduler::setJobPriority(mFirstStepJob, 1); connect(mFirstStepJob, &KIO::SimpleJob::result, this, &POTDElement::step1Result); connect(this, &POTDElement::step1Success, this, &POTDElement::step2GetImagePage); } } /** Give it a job which fetched the raw page, and it'll give you the image file name hiding in it. */ void POTDElement::step1Result(KJob *job) { if (job->error()) { qCWarning(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": could not get POTD file name:" << job->errorString(); qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": file name:" << mFileName; qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": full-size image:" << mFullSizeImageUrl; qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": thumbnail:" << mThumbUrl; mFirstStepCompleted = false; return; } // First step completed: we now know the POTD's file name KIO::StoredTransferJob *const transferJob = static_cast(job); const QStringList lines = QString::fromUtf8(transferJob->data().data(), transferJob->data().size()).split(QLatin1Char('\n')); for (const QString &line : lines) { if (line.startsWith(QStringLiteral("|image="))) { mFileName = line; break; } } mFileName = mFileName.remove(QStringLiteral("|image=")).replace(QLatin1Char(' '), QLatin1Char('_')); for (const QString &line : lines) { if (line.startsWith(QStringLiteral("|texttitle="))) { mDescription = line; break; } } mDescription = mDescription.remove(QStringLiteral("|texttitle=")); if (!mDescription.isEmpty()) { mLongText = mDescription; } else { mLongText = mFileName; } mLongText = i18n("Wikipedia POTD: %1", mLongText); Q_EMIT gotNewLongText(mLongText); qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "FILENAME=" << mFileName; qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "DESCRIPTION=" << mDescription; mFirstStepCompleted = true; mFirstStepJob = nullptr; Q_EMIT step1Success(); } /** Second step of three in the download process */ void POTDElement::step2GetImagePage() { if (!mSecondStepCompleted && !mSecondStepJob) { mUrl = QUrl(QStringLiteral("http://en.wikipedia.org/wiki/File:") + mFileName); // We'll find the info to get the thumbnail we want on the POTD's image page Q_EMIT gotNewUrl(mUrl); mShortText = i18n("Picture Page"); Q_EMIT gotNewShortText(mShortText); mSecondStepJob = KIO::storedGet(mUrl, KIO::NoReload, KIO::HideProgressInfo); KIO::Scheduler::setJobPriority(mSecondStepJob, 1); connect(mSecondStepJob, &KIO::SimpleJob::result, this, &POTDElement::step2Result); connect(this, &POTDElement::step2Success, this, &POTDElement::step3GetThumbnail); } } /** Give it a job which fetched the image page, and it'll give you the appropriate thumbnail URL. */ void POTDElement::step2Result(KJob *job) { if (job->error()) { qCWarning(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": could not get POTD image page:" << job->errorString(); qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": file name:" << mFileName; qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": full-size image:" << mFullSizeImageUrl; qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": thumbnail:" << mThumbUrl; mSecondStepCompleted = false; return; } // Get the image URL from the image page's source code // and transform it to get an appropriate thumbnail size KIO::StoredTransferJob *const transferJob = static_cast(job); QDomDocument imgPage; if (!imgPage.setContent(QString::fromUtf8(transferJob->data().data(), transferJob->data().size()))) { qCWarning(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": Wikipedia returned an invalid XML page for image" << mFileName; return; } // We go through all links and stop at the first right-looking candidate QDomNodeList links = imgPage.elementsByTagName(QStringLiteral("a")); for (int i = 0; i < links.length(); ++i) { QString href = links.item(i).attributes().namedItem(QStringLiteral("href")).nodeValue(); if (href.startsWith( QStringLiteral("//upload.wikimedia.org/wikipedia/commons/"))) { mFullSizeImageUrl = QUrl(href); mFullSizeImageUrl.setScheme(QStringLiteral("https")); break; } } // We get the image's width/height ratio mHWRatio = 1.0; QDomNodeList images = imgPage.elementsByTagName(QStringLiteral("img")); for (int i = 0; i < links.length(); ++i) { QDomNamedNodeMap attr = images.item(i).attributes(); QString src = attr.namedItem(QStringLiteral("src")).nodeValue(); if (src.startsWith(thumbnailUrl(mFullSizeImageUrl).url())) { if ((attr.namedItem(QStringLiteral("height")).nodeValue().toInt() != 0) && (attr.namedItem(QStringLiteral("width")).nodeValue().toInt() != 0)) { mHWRatio = attr.namedItem(QStringLiteral("height")).nodeValue().toFloat() /attr.namedItem(QStringLiteral("width")).nodeValue().toFloat(); } break; } } qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": h/w ratio:" << mHWRatio; qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": got POTD image page source:" << mFullSizeImageUrl; if (!mFullSizeImageUrl.isEmpty()) { mSecondStepCompleted = true; mSecondStepJob = nullptr; Q_EMIT step2Success(); } } QUrl POTDElement::thumbnailUrl(const QUrl &fullSizeUrl, const int width) const { QString thumbUrl = fullSizeUrl.url(); if (width != 0) { thumbUrl.replace(QRegExp(QLatin1String("//upload.wikimedia.org/wikipedia/commons/(.*)/([^/]*)")), QStringLiteral("//upload.wikimedia.org/wikipedia/commons/thumb/\\1/\\2/") +QString::number(width) + QStringLiteral("px-\\2")); } else { // This will not return a valid thumbnail URL, but will at least // give some info (the beginning of the URL) thumbUrl.replace(QRegExp(QLatin1String("//upload.wikimedia.org/wikipedia/commons/(.*)/([^/]*)")), QStringLiteral("//upload.wikimedia.org/wikipedia/commons/thumb/\\1/\\2")); } thumbUrl.replace(QRegExp(QLatin1String("^file:////")), QStringLiteral("http://")); return QUrl(thumbUrl); } /** Third step of three in the downloading process */ void POTDElement::step3GetThumbnail() { if (mThirdStepJob) { mThirdStepJob->kill(); } mThirdStepJob = nullptr; int thumbWidth = mThumbSize.width(); int thumbHeight = static_cast(thumbWidth * mHWRatio); if (mThumbSize.height() < thumbHeight) { /* if the requested height is less than the requested width * ratio we would download too much, as the downloaded picture would be taller than requested, so we adjust the width of the picture to be downloaded in consequence */ thumbWidth /= (thumbHeight / mThumbSize.height()); thumbHeight = static_cast(thumbWidth * mHWRatio); } mDlThumbSize = QSize(thumbWidth, thumbHeight); qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": will download thumbnail of size" << mDlThumbSize; mThumbUrl = thumbnailUrl(mFullSizeImageUrl, thumbWidth); qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": got POTD thumbnail URL:" << mThumbUrl; mThirdStepJob = KIO::storedGet(mThumbUrl, KIO::NoReload, KIO::HideProgressInfo); KIO::Scheduler::setJobPriority(mThirdStepJob, 1); connect(mThirdStepJob, &KIO::SimpleJob::result, this, &POTDElement::step3Result); } /** Give it a job which fetched the thumbnail, and it'll give the corresponding pixmap to you. */ void POTDElement::step3Result(KJob *job) { if (job != mThirdStepJob) { return; } mThirdStepJob = nullptr; if (job->error()) { qCWarning(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": could not get POTD:" << job->errorString(); qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": file name:" << mFileName; qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": full-size image:" << mFullSizeImageUrl; qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": thumbnail:" << mThumbUrl; return; } // Last step completed: we get the pixmap from the transfer job's data KIO::StoredTransferJob *const transferJob = static_cast(job); if (mPixmap.loadFromData(transferJob->data())) { qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": got POTD."; Q_EMIT gotNewPixmap(mPixmap.scaled(mThumbSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); } } QPixmap POTDElement::newPixmap(const QSize &size) { if ((mThumbSize.width() < size.width()) || (mThumbSize.height() < size.height())) { qCDebug(KORGANIZERPICOFTHEDAYPLUGIN_LOG) << "POTD:" << mDate << ": called for a new pixmap size (" << size << "instead of" << mThumbSize << ", stored pixmap:" << mPixmap.size() << ")"; setThumbnailSize(size); if (!mFirstStepCompleted) { step1StartDownload(); // First run, start from the beginning } else if ((mDlThumbSize.width() < size.width()) && (mDlThumbSize.height() < size.height())) { if (mThirdStepJob) { // Another download (for the old size) is already running; // we'll run after that disconnect(this, &POTDElement::step3Success, this, &POTDElement::step3GetThumbnail); connect(this, &POTDElement::step3Success, this, &POTDElement::step3GetThumbnail); } else if (mFirstStepJob || mSecondStepJob) { // The download process did not get to step 3 yet, and will download // the correct size automagically } else { // We start a new thumbnail download a little later; the following code // is to avoid too frequent transfers e.g. when resizing mTimer->stop(); disconnect(mTimer, &QTimer::timeout, this, &POTDElement::step3GetThumbnail); connect(mTimer, &QTimer::timeout, this, &POTDElement::step3GetThumbnail); mTimer->setSingleShot(true); mTimer->start(1000); } } } /* else, either we already got a sufficiently big pixmap (stored in mPixmap), or we will get one anytime soon (we are downloading it already) and we will actualize what we return here later via gotNewPixmap */ if (mPixmap.isNull()) { return QPixmap(); } return mPixmap.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation); } void POTDElement::setThumbnailSize(const QSize &size) { mThumbSize = size; } diff --git a/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscript.cpp b/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscript.cpp index 111c4b11..bcd5581d 100644 --- a/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscript.cpp +++ b/plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscript.cpp @@ -1,59 +1,61 @@ /* Copyright (C) 2015-2017 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "viewerpluginexternalscript.h" #include "viewerpluginexternalscriptinterface.h" #include "configuredialog/viewerpluginexternalconfiguredialog.h" #include +#include #include using namespace MessageViewer; K_PLUGIN_FACTORY_WITH_JSON(ViewerPluginExternalscriptFactory, "messageviewer_externalscriptplugin.json", registerPlugin(); ) ViewerPluginExternalscript::ViewerPluginExternalscript(QObject *parent, const QList &) : MessageViewer::ViewerPlugin(parent) { } ViewerPluginInterface *ViewerPluginExternalscript::createView(QWidget *parent, KActionCollection *ac) { MessageViewer::ViewerPluginInterface *view = new MessageViewer::ViewerPluginExternalscriptInterface(ac, parent); return view; } QString ViewerPluginExternalscript::viewerPluginName() const { return QStringLiteral("external script"); } void MessageViewer::ViewerPluginExternalscript::showConfigureDialog(QWidget *parent) { - ViewerPluginExternalConfigureDialog dlg(parent); - if (dlg.exec()) { + QPointer dlg = new ViewerPluginExternalConfigureDialog(parent); + if (dlg->exec()) { Q_EMIT configChanged(); } + delete dlg; } bool MessageViewer::ViewerPluginExternalscript::hasConfigureDialog() const { return true; } #include "viewerpluginexternalscript.moc" diff --git a/plugins/webengineurlinterceptor/adblock/adblockpluginurlinterceptor.cpp b/plugins/webengineurlinterceptor/adblock/adblockpluginurlinterceptor.cpp index 01aab2d3..8f6ab6d7 100644 --- a/plugins/webengineurlinterceptor/adblock/adblockpluginurlinterceptor.cpp +++ b/plugins/webengineurlinterceptor/adblock/adblockpluginurlinterceptor.cpp @@ -1,58 +1,59 @@ /* Copyright (C) 2016-2017 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "adblockpluginurlinterceptor.h" #include "adblockinterceptorinterface.h" #include "../lib/widgets/adblockpluginurlinterceptorconfigurewidget.h" #include "lib/adblockmanager.h" #include "../lib/widgets/adblockpluginurlinterceptorconfiguredialog.h" #include #include #include K_PLUGIN_FACTORY_WITH_JSON(AdblockPluginUrlInterceptorFactory, "messageviewer_adblockurlinterceptor.json", registerPlugin(); ) AdblockPluginUrlInterceptor::AdblockPluginUrlInterceptor(QObject *parent, const QList &) : WebEngineViewer::NetworkPluginUrlInterceptor(parent) { } AdblockPluginUrlInterceptor::~AdblockPluginUrlInterceptor() { } WebEngineViewer::NetworkPluginUrlInterceptorInterface *AdblockPluginUrlInterceptor::createInterface(QWebEngineView *webEngine, QObject *parent) { AdblockInterceptorInterface *adblockInterface = new AdblockInterceptorInterface(parent); adblockInterface->setWebEngineView(webEngine); return adblockInterface; } bool AdblockPluginUrlInterceptor::hasConfigureDialog() const { return true; } void AdblockPluginUrlInterceptor::showConfigureDialog(QWidget *parent) { - AdBlock::AdblockPluginUrlInterceptorConfigureDialog dlg(parent); - dlg.exec(); + QPointer dlg = new AdBlock::AdblockPluginUrlInterceptorConfigureDialog (parent); + dlg->exec(); + delete dlg; } #include "adblockpluginurlinterceptor.moc"