diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index 25640dd63a4..d8466a9975e 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -98,7 +98,8 @@ SOURCES += mainwindow.cpp \ textdocument.cpp \ documentmanager.cpp \ removefiledialog.cpp \ - iversioncontrol.cpp + iversioncontrol.cpp \ + dialogs/addtovcsdialog.cpp HEADERS += mainwindow.h \ editmode.h \ @@ -194,7 +195,8 @@ HEADERS += mainwindow.h \ idocumentfactory.h \ textdocument.h \ documentmanager.h \ - removefiledialog.h + removefiledialog.h \ + dialogs/addtovcsdialog.h FORMS += dialogs/newdialog.ui \ actionmanager/commandmappings.ui \ @@ -206,7 +208,8 @@ FORMS += dialogs/newdialog.ui \ variablechooser.ui \ mimetypesettingspage.ui \ mimetypemagicdialog.ui \ - removefiledialog.ui + removefiledialog.ui \ + dialogs/addtovcsdialog.ui RESOURCES += core.qrc \ fancyactionbar.qrc diff --git a/src/plugins/coreplugin/coreplugin.qbs b/src/plugins/coreplugin/coreplugin.qbs index 7b4abefae00..5edc0d519dc 100644 --- a/src/plugins/coreplugin/coreplugin.qbs +++ b/src/plugins/coreplugin/coreplugin.qbs @@ -171,6 +171,9 @@ QtcPlugin { "actionmanager/commandmappings.ui", "actionmanager/commandsfile.cpp", "actionmanager/commandsfile.h", + "dialogs/addtovcsdialog.cpp", + "dialogs/addtovcsdialog.h", + "dialogs/addtovcsdialog.ui", "dialogs/externaltoolconfig.cpp", "dialogs/externaltoolconfig.h", "dialogs/externaltoolconfig.ui", diff --git a/src/plugins/coreplugin/dialogs/addtovcsdialog.cpp b/src/plugins/coreplugin/dialogs/addtovcsdialog.cpp new file mode 100644 index 00000000000..c1e3758dba1 --- /dev/null +++ b/src/plugins/coreplugin/dialogs/addtovcsdialog.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#include "addtovcsdialog.h" +#include "ui_addtovcsdialog.h" + +#include + +namespace Core { +namespace Internal { + +AddToVcsDialog::AddToVcsDialog(QWidget *parent, const QString &title, + const QStringList &files, const QString &vcsDisplayName) : + QDialog(parent), + ui(new Ui::AddToVcsDialog) +{ + ui->setupUi(this); + QString addTo = files.size() == 1 + ? tr("Add the file to version control (%1)").arg(vcsDisplayName) + : tr("Add the files to version control (%1)").arg(vcsDisplayName); + + ui->addFilesLabel->setText(addTo); + setWindowTitle(title); + + foreach (const QString &file, files) { + QListWidgetItem *item = new QListWidgetItem(file); + ui->filesListWidget->addItem(item); + } +} + +AddToVcsDialog::~AddToVcsDialog() +{ + delete ui; +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/dialogs/addtovcsdialog.h b/src/plugins/coreplugin/dialogs/addtovcsdialog.h new file mode 100644 index 00000000000..67928099f08 --- /dev/null +++ b/src/plugins/coreplugin/dialogs/addtovcsdialog.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef ADDTOVCSDIALOG_H +#define ADDTOVCSDIALOG_H + +#include + +namespace Core { +namespace Internal { + +namespace Ui { +class AddToVcsDialog; +} + +class AddToVcsDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AddToVcsDialog(QWidget *parent, const QString &title, + const QStringList &files, const QString &vcsDisplayName); + ~AddToVcsDialog(); + +private: + Ui::AddToVcsDialog *ui; +}; + + +} // namespace Internal +} // namespace Core +#endif // ADDTOVCSDIALOG_H diff --git a/src/plugins/coreplugin/dialogs/addtovcsdialog.ui b/src/plugins/coreplugin/dialogs/addtovcsdialog.ui new file mode 100644 index 00000000000..17493a3f69e --- /dev/null +++ b/src/plugins/coreplugin/dialogs/addtovcsdialog.ui @@ -0,0 +1,93 @@ + + + Core::Internal::AddToVcsDialog + + + + 0 + 0 + 363 + 433 + + + + + 200 + 200 + + + + + 300 + 500 + + + + Dialog + + + + + + + + + + + + + QAbstractItemView::NoSelection + + + QAbstractItemView::SelectRows + + + + + + + Qt::Horizontal + + + QDialogButtonBox::No|QDialogButtonBox::Yes + + + + + + + + + buttonBox + accepted() + Core::Internal::AddToVcsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Core::Internal::AddToVcsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp index 00a5334d8aa..0fe9543f4b7 100644 --- a/src/plugins/coreplugin/vcsmanager.cpp +++ b/src/plugins/coreplugin/vcsmanager.cpp @@ -36,8 +36,9 @@ #include "idocument.h" #include "infobar.h" -#include +#include "addtovcsdialog.h" +#include #include #include @@ -403,11 +404,9 @@ void VcsManager::promptToAdd(const QString &directory, const QStringList &fileNa if (!vc || !vc->supportsOperation(Core::IVersionControl::AddOperation)) return; - QMessageBox::StandardButton button = - QMessageBox::question(Core::ICore::mainWindow(), VcsManager::msgAddToVcsTitle(), - VcsManager::msgPromptToAddToVcs(fileNames, vc), - QMessageBox::Yes | QMessageBox::No); - if (button == QMessageBox::Yes) { + Internal::AddToVcsDialog dlg(Core::ICore::mainWindow(), VcsManager::msgAddToVcsTitle(), + fileNames, vc->displayName()); + if (dlg.exec() == QDialog::Accepted) { QStringList notAddedToVc; foreach (const QString &file, fileNames) { if (!vc->vcsAdd(file))