예제 #1
0
void BazaarPlugin::showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusItem> &status)
{
    VcsBase::VcsBaseOutputWindow *outputWindow = VcsBase::VcsBaseOutputWindow::instance();
    //Once we receive our data release the connection so it can be reused elsewhere
    disconnect(m_client, SIGNAL(parsedStatus(QList<VcsBase::VcsBaseClient::StatusItem>)),
               this, SLOT(showCommitWidget(QList<VcsBase::VcsBaseClient::StatusItem>)));

    if (status.isEmpty()) {
        outputWindow->appendError(tr("There are no changes to commit."));
        return;
    }

    // Start new temp file
    Utils::TempFileSaver saver;
    // Keep the file alive, else it removes self and forgets its name
    saver.setAutoRemove(false);
    if (!saver.finalize()) {
        VcsBase::VcsBaseOutputWindow::instance()->append(saver.errorString());
        return;
    }

    Core::IEditor *editor = Core::EditorManager::openEditor(saver.fileName(),
                                                            Constants::COMMIT_ID,
                                                            Core::EditorManager::ModeSwitch);
    if (!editor) {
        outputWindow->appendError(tr("Unable to create an editor for the commit."));
        return;
    }

    CommitEditor *commitEditor = qobject_cast<CommitEditor *>(editor);

    if (!commitEditor) {
        outputWindow->appendError(tr("Unable to create a commit editor."));
        return;
    }

    commitEditor->registerActions(m_editorUndo, m_editorRedo, m_editorCommit, m_editorDiff);
    connect(commitEditor, SIGNAL(diffSelectedFiles(QStringList)),
            this, SLOT(diffFromEditorSelected(QStringList)));
    commitEditor->setCheckScriptWorkingDirectory(m_submitRepository);

    const QString msg = tr("Commit changes for \"%1\".").
            arg(QDir::toNativeSeparators(m_submitRepository));
    commitEditor->setDisplayName(msg);

    const BranchInfo branch = m_client->synchronousBranchQuery(m_submitRepository);
    commitEditor->setFields(m_submitRepository, branch,
                            m_bazaarSettings.stringValue(BazaarSettings::userNameKey),
                            m_bazaarSettings.stringValue(BazaarSettings::userEmailKey), status);
}
예제 #2
0
void MobileAppWizardMaemoOptionsPage::setPngIcon(const QString &icon)
{
    QString error;
    QPixmap iconPixmap(icon);
    if (iconPixmap.isNull()) {
        QMessageBox::critical(this, tr("Invalid Icon"),
            tr("The file is not a valid image."));
        return;
    }

    QString actualIconPath;
    if (iconPixmap.size() == m_d->iconSize) {
        actualIconPath = icon;
    } else {
        const QMessageBox::StandardButton button = QMessageBox::warning(this,
            tr("Wrong Icon Size"), tr("The icon needs to be %1x%2 pixels big, "
                "but is not. Do you want Creator to scale it?")
                .arg(m_d->iconSize.width()).arg(m_d->iconSize.height()),
            QMessageBox::Ok | QMessageBox::Cancel);
        if (button != QMessageBox::Ok)
            return;
        iconPixmap = iconPixmap.scaled(m_d->iconSize);
        Utils::TempFileSaver saver;
        saver.setAutoRemove(false);
        if (!saver.hasError())
            saver.setResult(iconPixmap.save(
                    saver.file(), QFileInfo(icon).suffix().toAscii().constData()));
        if (!saver.finalize()) {
            QMessageBox::critical(this, tr("File Error"),
                tr("Could not copy icon file: %1").arg(saver.errorString()));
            return;
        }
        actualIconPath = saver.fileName();
    }

    m_d->ui.pngIconButton->setIcon(iconPixmap);
    m_d->pngIcon = actualIconPath;
}