Beispiel #1
0
void OverwriteQuery::execute()
{
    // If we are being called from the KPart, the cursor is probably Qt::WaitCursor
    // at the moment (#231974)
    QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));

    KIO::RenameDialog_Options options = KIO::RenameDialog_Overwrite | KIO::RenameDialog_Skip;
    if (m_noRenameMode) {
        options = options | KIO::RenameDialog_NoRename;
    }
    if (m_multiMode) {
        options = options | KIO::RenameDialog_MultipleItems;
    }

    QUrl sourceUrl = QUrl::fromLocalFile(QDir::cleanPath(m_data.value(QStringLiteral("filename")).toString()));
    QUrl destUrl = QUrl::fromLocalFile(QDir::cleanPath(m_data.value(QStringLiteral("filename")).toString()));

    QPointer<KIO::RenameDialog> dialog = new KIO::RenameDialog(
        Q_NULLPTR,
        i18nc("@title:window", "File Already Exists"),
        sourceUrl,
        destUrl,
        options);
    dialog.data()->exec();

    m_data[QStringLiteral("newFilename")] = dialog.data()->newDestUrl().toDisplayString(QUrl::PreferLocalFile);

    setResponse(dialog.data()->result());

    delete dialog.data();

    QApplication::restoreOverrideCursor();
}
Beispiel #2
0
void PasswordNeededQuery::execute()
{
    qCDebug(ARK) << "Executing password prompt";

    // If we are being called from the KPart, the cursor is probably Qt::WaitCursor
    // at the moment (#231974)
    QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));

    QPointer<KPasswordDialog> dlg = new KPasswordDialog;
    dlg.data()->setPrompt(xi18nc("@info", "The archive <filename>%1</filename> is password protected. Please enter the password.",
                                 m_data.value(QStringLiteral("archiveFilename")).toString()));

    if (m_data.value(QStringLiteral("incorrectTryAgain")).toBool()) {
        dlg.data()->showErrorMessage(i18n("Incorrect password, please try again."), KPasswordDialog::PasswordError);
    }

    const bool notCancelled = dlg.data()->exec();
    const QString password = dlg.data()->password();

    m_data[QStringLiteral("password")] = password;
    setResponse(notCancelled && !password.isEmpty());

    QApplication::restoreOverrideCursor();

    delete dlg.data();
}
Beispiel #3
0
QString AssociatedFilesUI::associateUrl(const QUrl &url, const QString &entryId, const File *bibTeXfile, QWidget *parent) {
    QPointer<QDialog> dlg = new QDialog(parent);
    QBoxLayout *layout = new QVBoxLayout(dlg);
    QPointer<AssociatedFilesUI> ui = new AssociatedFilesUI(entryId, bibTeXfile, dlg);
    layout->addWidget(ui);
    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, dlg);
    layout->addWidget(buttonBox);
    dlg->setLayout(layout);

    connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, dlg.data(), &QDialog::accept);
    connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, dlg.data(), &QDialog::reject);

    if (AssociatedFiles::urlIsLocal(url))
        ui->setupForLocalFile(url, entryId);
    else
        ui->setupForRemoteUrl(url, entryId);

    const bool accepted = dlg->exec() == QDialog::Accepted;
    bool success = true;
    QString referenceString;
    if (accepted) {
        const QUrl newUrl = AssociatedFiles::copyDocument(url, entryId, bibTeXfile, ui->renameOperation(), ui->moveCopyOperation(), dlg, ui->userDefinedFilename());
        success &= !newUrl.isEmpty();
        if (success) {
            referenceString = AssociatedFiles::associateDocumentURL(newUrl, bibTeXfile, ui->pathType());
            success &= !referenceString.isEmpty();
        }
    }

    delete dlg;
    return accepted && success ? referenceString : QString();
}
Beispiel #4
0
void L2tpWidget::showPpp()
{
    QPointer<L2tpPPPWidget> adv;
    if (m_tmpPppSetting.isNull()) {
        adv = new L2tpPPPWidget(m_setting, this);
    } else {
        adv = new L2tpPPPWidget(m_tmpPppSetting, this);
    }
    connect(adv.data(), &L2tpPPPWidget::accepted,
            [adv, this] () {
                NMStringMap advData = adv->setting();
                if (!advData.isEmpty()) {
                    if (m_tmpPppSetting.isNull()) {
                        m_tmpPppSetting = NetworkManager::VpnSetting::Ptr(new NetworkManager::VpnSetting);
                    }
                    m_tmpPppSetting->setData(advData);
                }
            });
    connect(adv.data(), &L2tpPPPWidget::finished,
            [adv] () {
                if (adv) {
                    adv->deleteLater();
                }
            });
    adv->setModal(true);
    adv->show();
}
 void cleanupConnections()
 {
     if (_reply) {
         QObject::disconnect(_replyFinished);
         QObject::disconnect(_enginioDestroyed);
         QObject::connect(_reply.data(), &QNetworkReply::finished, _reply.data(), &QNetworkReply::deleteLater);
     }
 }
void GetCredentialsJob::Private::getCredentials()
{
    Accounts::Account *acc = manager->account(id);
    if (!acc) {
        qWarning() << "Unable to find account for id" << id;
        if (repeatedTries < 3) {
            qDebug() << "Retrying in 2s";
            QTimer::singleShot(2000, q, SLOT(getCredentials()));
            repeatedTries++;
        } else {
            qDebug() << repeatedTries << "ending with error";
            q->setError(KJob::UserDefinedError);
            q->setErrorText(QLatin1String("Could not find account"));
            q->emitResult();
        }
        return;
    }

    Accounts::AccountService *service = new Accounts::AccountService(acc, manager->service(serviceType), q);

    Accounts::AuthData serviceAuthData = service->authData();
    authData = serviceAuthData.parameters();
    SignOn::Identity *identity = SignOn::Identity::existingIdentity(acc->credentialsId(), q);

    if (!identity) {
        qWarning() << "Unable to find identity for account id" << id;
        q->setError(KJob::UserDefinedError);
        q->setErrorText(QLatin1String("Could not find credentials"));
        q->emitResult();
        return;
    }

    authData["AccountUsername"] = acc->value(QLatin1String("username")).toString();
    QPointer<SignOn::AuthSession> authSession = identity->createSession(authMethod.isEmpty() ? serviceAuthData.method() : authMethod);
    if (!authSession) {
        qWarning() << "Unable to create auth session for" << authMethod << serviceAuthData.method();
        q->setError(KJob::UserDefinedError);
        q->setErrorText(QLatin1String("Could not create auth session"));
        q->emitResult();
        return;
    }

    QObject::connect(authSession.data(), &SignOn::AuthSession::response,
    [this, identity](const SignOn::SessionData &data) {
        sessionData = data;
        q->emitResult();
    });

    QObject::connect(authSession.data(), &SignOn::AuthSession::error,
    [this](const SignOn::Error &error) {
        qDebug() << error.message();
        q->setError(KJob::UserDefinedError);
        q->setErrorText(error.message());
        q->emitResult();
    });

    authSession->process(serviceAuthData.parameters(), authMechanism.isEmpty() ? serviceAuthData.mechanism() : authMechanism);
}
Beispiel #7
0
void FoldersPanel::slotViewContextMenuRequested(const QPointF& pos)
{
    Q_UNUSED(pos);

    QPointer<TreeViewContextMenu> contextMenu = new TreeViewContextMenu(this, KFileItem());
    contextMenu.data()->open();
    if (contextMenu.data()) {
        delete contextMenu.data();
    }
}
Beispiel #8
0
void FoldersPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
{
    Q_UNUSED(pos);

    const KFileItem fileItem = m_model->fileItem(index);

    QPointer<TreeViewContextMenu> contextMenu = new TreeViewContextMenu(this, fileItem);
    contextMenu.data()->open();
    if (contextMenu.data()) {
        delete contextMenu.data();
    }
}
Beispiel #9
0
	void updateVisible()
	{
		bool newVisible = false;
		if (visibleProperty.isValid()) {
			Q_ASSERT(dialog.data());
			newVisible = visibleProperty.read(dialog.data()).toBool();
		}

		if (newVisible != visible) {
			visible = newVisible;
			emit q_ptr->visibleChanged(visible);
		}
	}
Beispiel #10
0
void
CollectionViewPage::setFlatModel( PlayableModel* model )
{
    QPointer<PlayableModel> oldModel = m_flatModel;

    m_flatModel = model;
    m_trackView->setPlayableModel( model );

    if ( oldModel )
    {
        disconnect( oldModel.data(), SIGNAL( changed() ), this, SLOT( onModelChanged() ) );
        delete oldModel.data();
    }
}
Beispiel #11
0
void ProxyEditWindow::removeButtonClicked()
{
    QModelIndexList selection = ProxyView->selectionModel()->selectedIndexes();
    if (1 != selection.size())
        return;

    NetworkProxy proxy = selection.at(0).data(NetworkProxyRole).value<NetworkProxy>();

    QPointer<QMessageBox> messageBox = new QMessageBox(this);
    messageBox.data()->setWindowTitle(tr("Confirm proxy removal"));
    messageBox.data()->setText(tr("Are you sure do you want to remove this proxy?"));

    QPushButton *removeButton = messageBox.data()->addButton(tr("Remove proxy"), QMessageBox::AcceptRole);
    messageBox.data()->addButton(QMessageBox::Cancel);
    messageBox.data()->setDefaultButton(QMessageBox::Cancel);
    messageBox.data()->exec();

    if (messageBox.isNull())
        return;

    if (messageBox.data()->clickedButton() == removeButton)
        m_networkProxyManager->removeItem(proxy);

    delete messageBox.data();
}
Beispiel #12
0
void Submission::slotMessageDataAvailable()
{
    m_rawMessageData.clear();
    QBuffer buf(&m_rawMessageData);
    buf.open(QIODevice::WriteOnly);
    QString errorMessage;
    QList<Imap::Mailbox::CatenatePair> catenateable;

    if (shouldBuildMessageLocally() && !m_composer->asRawMessage(&buf, &errorMessage)) {
        gotError(tr("Cannot send right now -- saving failed:\n %1").arg(errorMessage));
        return;
    }
    if (m_model->isCatenateSupported() && !m_composer->asCatenateData(catenateable, &errorMessage)) {
        gotError(tr("Cannot send right now -- saving (CATENATE) failed:\n %1").arg(errorMessage));
        return;
    }

    if (m_saveToSentFolder) {
        Q_ASSERT(m_model);
        m_appendUidReceived = false;
        m_genUrlAuthReceived = false;

        changeConnectionState(STATE_SAVING);
        QPointer<Imap::Mailbox::AppendTask> appendTask = 0;

        if (m_model->isCatenateSupported()) {
            // FIXME: without UIDPLUS, there isn't much point in $SubmitPending...
            appendTask = QPointer<Imap::Mailbox::AppendTask>(
                        m_model->appendIntoMailbox(
                            m_sentFolderName,
                            catenateable,
                            QStringList() << QLatin1String("$SubmitPending") << QLatin1String("\\Seen"),
                            m_composer->timestamp()));
        } else {
            // FIXME: without UIDPLUS, there isn't much point in $SubmitPending...
            appendTask = QPointer<Imap::Mailbox::AppendTask>(
                        m_model->appendIntoMailbox(
                            m_sentFolderName,
                            m_rawMessageData,
                            QStringList() << QLatin1String("$SubmitPending") << QLatin1String("\\Seen"),
                            m_composer->timestamp()));
        }

        Q_ASSERT(appendTask);
        connect(appendTask.data(), SIGNAL(appendUid(uint,uint)), this, SLOT(slotAppendUidKnown(uint,uint)));
        connect(appendTask.data(), SIGNAL(completed(Imap::Mailbox::ImapTask*)), this, SLOT(slotAppendSucceeded()));
        connect(appendTask.data(), SIGNAL(failed(QString)), this, SLOT(slotAppendFailed(QString)));
    } else {
Beispiel #13
0
void
CollectionViewPage::setTreeModel( TreeModel* model )
{
    QPointer<PlayableModel> oldModel = m_model;
    m_model = model;
    m_columnView->setTreeModel( model );

    connect( model, SIGNAL( changed() ), SLOT( onModelChanged() ), Qt::UniqueConnection );
    onModelChanged();

    if ( oldModel )
    {
        disconnect( oldModel.data(), SIGNAL( changed() ), this, SLOT( onModelChanged() ) );
        delete oldModel.data();
    }
}
Beispiel #14
0
void
PartitionPage::onNewPartitionTableClicked()
{
    QModelIndex index = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
    Q_ASSERT( index.isValid() );
    Device* device = m_core->deviceModel()->deviceForIndex( index );

    QPointer<QDialog> dlg = new QDialog( this );
    Ui_CreatePartitionTableDialog ui;
    ui.setupUi( dlg.data() );
    QString areYouSure = tr( "Are you sure you want to create a new partition table on %1?" ).arg( device->name() );
    if ( PartUtils::isEfiSystem() )
        ui.gptRadioButton->setChecked( true );
    else
        ui.mbrRadioButton->setChecked( true );

    ui.areYouSureLabel->setText( areYouSure );
    if ( dlg->exec() == QDialog::Accepted )
    {
        PartitionTable::TableType type = ui.mbrRadioButton->isChecked() ? PartitionTable::msdos : PartitionTable::gpt;
        m_core->createPartitionTable( device, type );
    }
    delete dlg;
    // PartionModelReset isn't emitted after createPartitionTable, so we have to manually update
    // the bootLoader index after the reset.
    updateBootLoaderIndex();
}
Beispiel #15
0
 foreach (QPointer<ZParameter> param, m_paramArray) {
   if (param) {
     if (param->parent() == NULL) { //not owned by any parent
       delete param.data();
     }
   }
 }
Beispiel #16
0
void
CollectionViewPage::setFlatModel( PlayableModel* model )
{
    QPointer<PlayableModel> oldModel = m_flatModel;

    m_flatModel = model;
    m_trackView->setPlayableModel( model );
    m_trackView->setSortingEnabled( true );
    m_trackView->sortByColumn( 0, Qt::AscendingOrder );

    if ( oldModel )
    {
        disconnect( oldModel.data(), SIGNAL( changed() ), this, SLOT( onModelChanged() ) );
        delete oldModel.data();
    }
}
bool BlackBerryRunControlFactory::canRun(ProjectExplorer::RunConfiguration *runConfiguration,
                                  ProjectExplorer::RunMode mode) const
{
    Q_UNUSED(mode);

    BlackBerryRunConfiguration *rc = qobject_cast<BlackBerryRunConfiguration *>(runConfiguration);
    if (!rc)
        return false;

    BlackBerryDeviceConfiguration::ConstPtr device = BlackBerryDeviceConfiguration::device(rc->target()->kit());
    if (!device)
        return false;

    // The device can only run the same application once, any subsequent runs will
    // not launch a second instance. Disable the Run button if the application is already
    // running on the device.
    if (m_activeRunControls.contains(rc->key())) {
        QPointer<ProjectExplorer::RunControl> activeRunControl = m_activeRunControls[rc->key()];
        if (activeRunControl && activeRunControl.data()->isRunning())
            return false;
        else
            m_activeRunControls.remove(rc->key());
    }

    BlackBerryDeployConfiguration *activeDeployConf = qobject_cast<BlackBerryDeployConfiguration *>(
                rc->target()->activeDeployConfiguration());
    return activeDeployConf != 0;
}
Beispiel #18
0
uint qHash(const QPointer<Thing>& qpt)
{
	if (qpt)
	{
		return qHash(*(qpt.data()));
	}
	return 0;
}
void
CollectionViewPage::setAlbumModel( PlayableModel* model )
{
    QPointer<PlayableModel> oldModel = m_albumModel;

    if ( m_albumModel )
        delete m_albumModel;

    m_albumModel = model;
    m_albumView->setPlayableModel( model );
    m_albumView->proxyModel()->sort( PlayableModel::Artist, Qt::AscendingOrder );

    if ( oldModel )
    {
        disconnect( oldModel.data(), SIGNAL( changed() ), this, SLOT( onModelChanged() ) );
        delete oldModel.data();
    }
}
Beispiel #20
0
void tst_QWebView::reusePage()
{
    if (!QDir(TESTS_SOURCE_DIR).exists())
        W_QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll);

    QDir::setCurrent(TESTS_SOURCE_DIR);

    QFETCH(QString, html);
    QWebView* view1 = new QWebView;
    QPointer<QWebPage> page = new QWebPage;
    view1->setPage(page.data());
    page.data()->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
    QWebFrame* mainFrame = page.data()->mainFrame();
    mainFrame->setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR));
    if (html.contains("</embed>")) {
        // some reasonable time for the PluginStream to feed test.swf to flash and start painting
        waitForSignal(view1, SIGNAL(loadFinished(bool)), 2000);
    }
QObject* TasPointerCache::getObject(const QString& pointerId)
{    
    QPointer<QObject> pointer = mPointers.value(pointerId, 0);    
    if(pointer.isNull()){
        mPointers.remove(pointerId);        
        return 0;
    }
    return pointer.data();
}
Beispiel #22
0
QObject *quetzal_request_guard_value(void *data)
{
    if (!data)
        return 0;
    QPointer<QObject> *pointer = reinterpret_cast<QPointer<QObject>*>(data);
    QObject *value = pointer->data();
    delete pointer;
    return value;
}
Beispiel #23
0
void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
{
#if !defined(Q_OS_OSX) && !defined(Q_OS_IOS) // Cocoa tracks popups
    // Ignore all enter/leave events from QPA if we are not on the first-level context menu.
    // This prevents duplicated events on most platforms. Fake events will be delivered in
    // QWidgetWindow::handleMouseEvent(QMouseEvent *). Make an exception whether the widget
    // is already under mouse - let the mouse leave.
    if (QApplicationPrivate::inPopupMode() && m_widget != QApplication::activePopupWidget() && !m_widget->underMouse())
        return;
#endif
    if (event->type() == QEvent::Leave) {
        QWidget *enter = 0;
        // Check from window system event queue if the next queued enter targets a window
        // in the same window hierarchy (e.g. enter a child of this window). If so,
        // remove the enter event from queue and handle both in single dispatch.
        QWindowSystemInterfacePrivate::EnterEvent *systemEvent =
            static_cast<QWindowSystemInterfacePrivate::EnterEvent *>
            (QWindowSystemInterfacePrivate::peekWindowSystemEvent(QWindowSystemInterfacePrivate::Enter));
        const QPointF globalPosF = systemEvent ? systemEvent->globalPos : QGuiApplicationPrivate::lastCursorPosition;
        if (systemEvent) {
            if (QWidgetWindow *enterWindow = qobject_cast<QWidgetWindow *>(systemEvent->enter))
            {
                QWindow *thisParent = this;
                QWindow *enterParent = enterWindow;
                while (thisParent->parent())
                    thisParent = thisParent->parent();
                while (enterParent->parent())
                    enterParent = enterParent->parent();
                if (thisParent == enterParent) {
                    QGuiApplicationPrivate::currentMouseWindow = enterWindow;
                    enter = enterWindow->widget();
                    QWindowSystemInterfacePrivate::removeWindowSystemEvent(systemEvent);
                }
            }
        }
        // Enter-leave between sibling widgets is ignored when there is a mousegrabber - this makes
        // both native and non-native widgets work similarly.
        // When mousegrabbing, leaves are only generated if leaving the parent window.
        if (!enter || !QWidget::mouseGrabber()) {
            // Preferred leave target is the last mouse receiver, unless it has native window,
            // in which case it is assumed to receive it's own leave event when relevant.
            QWidget *leave = m_widget;
            if (qt_last_mouse_receiver && !qt_last_mouse_receiver->internalWinId())
                leave = qt_last_mouse_receiver.data();
            QApplicationPrivate::dispatchEnterLeave(enter, leave, globalPosF);
            qt_last_mouse_receiver = enter;
        }
    } else {
        const QEnterEvent *ee = static_cast<QEnterEvent *>(event);
        QWidget *child = m_widget->childAt(ee->pos());
        QWidget *receiver = child ? child : m_widget.data();
        QApplicationPrivate::dispatchEnterLeave(receiver, 0, ee->screenPos());
        qt_last_mouse_receiver = receiver;
    }
}
    void prepareSessionToken(EnginioClientPrivate *enginio)
    {
        cleanupConnections();

        QJsonObject data;
        data[EnginioString::username] = _user;
        data[EnginioString::password] = _pass;
        _reply = enginio->identify(data);
        _replyFinished = QObject::connect(_reply.data(), &QNetworkReply::finished, SessionSetterFunctor(enginio, _reply.data()));
        _enginioDestroyed = QObject::connect(enginio->q_ptr, &EnginioClient::destroyed, DisconnectConnection(_replyFinished));
    }
CReporterUtils *CReporterUtils::instance()
{
    /* Will be set to zero when someone outside calls delete on the object. This
     * happens when qmlRegisterSingletonType() is used with the instance. */
    static QPointer<CReporterUtils> instance;
    if (!instance) {
        instance = new CReporterUtils;
    }

    return instance.data();
}
Beispiel #26
0
void  Scraper::findMovieInfo(QNetworkAccessManager *manager, MediaMovieSearchPtr mediaMovieSearchPtr, const SearchFor &searchFor, const QString& language)  {

    QPointer<InProgressDialog> waitDialog = JaqetMainWindow::getInstance()->showWaitDialog();
    if (!waitDialog.isNull()){
        connect(waitDialog.data(), SIGNAL(canceled()), this,
                SIGNAL(canceled()), Qt::UniqueConnection);

    }

    internalFindMovieInfo(manager,  mediaMovieSearchPtr, searchFor, language);
}
void Ut_MApplicationPage::testCentralWidget()
{
    QPointer<MWidget> widget = new MWidget;
    m_subject->setCentralWidget(widget);
    QCOMPARE(m_subject->centralWidget(), widget.data());

    // remove the current central widget and verify that it has been deleted
    m_subject->setCentralWidget(0);
    QCOMPARE(m_subject->centralWidget(), (MWidget *) 0);
    QVERIFY(widget.isNull());

    widget = new MWidget;
    m_subject->setCentralWidget(widget);
    QCOMPARE(m_subject->centralWidget(), widget.data());

    // delete the page to see if the central widget is deleted
    delete m_subject;
    m_subject = 0;
    QVERIFY(widget.isNull());
}
Beispiel #28
0
void
JobStatusView::addJob( const QPointer<JobStatusItem>& item )
{
    if ( s_instance == 0 || s_instance->model() == 0 )
    {
        s_jobItems.append( item );
    }
    else
    {
        s_instance->model()->addJob( item.data() );
    }
}
 static void mouseUp(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y)
 {
     QPoint globalPos(x,y);
     QWindow *tlw = m_mouseGrabber.data();
     if (!tlw)
         tlw = topLevelWindowAt(globalPos);
     QPoint localPos = tlw ? (globalPos -tlw->position()) : globalPos;
     QWindowSystemInterface::handleMouseEvent(tlw, localPos, globalPos
                                             , Qt::MouseButtons(Qt::NoButton));
     m_ignoreMouseEvents = false;
     m_mouseGrabber = 0;
 }
void StorageServiceManagerMainWindow::slotConfigure()
{
    QPointer<StorageServiceConfigureDialog> dlg = new StorageServiceConfigureDialog(this);
    connect(dlg.data(), &StorageServiceConfigureDialog::serviceRemoved, this, &StorageServiceManagerMainWindow::slotServiceRemoved);
    dlg->setListService(mStorageManager->listService());
    if (dlg->exec()) {
        mStorageManager->setListService(dlg->listService());
        mStorageServiceMainWidget->storageServiceTabWidget()->updateListService(dlg->listService());
        dlg->writeSettings();
    }
    delete dlg;
}