forked from qt-creator/qt-creator
Editor: Added Dialog for read only files.
Task-number: QTCREATORBUG-2851 Change-Id: Ic47a5a1833650e31b4e27d0a01259d6b398a6415 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Christian Stenger <christian.stenger@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -30,13 +30,18 @@
|
||||
#include "refactoringchanges.h"
|
||||
#include "basetexteditor.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/dialogs/readonlyfilesdialog.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QTextBlock>
|
||||
#include <QTextCursor>
|
||||
#include <QTextDocument>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
@@ -319,6 +324,17 @@ void RefactoringFile::setOpenEditor(bool activate, int pos)
|
||||
|
||||
void RefactoringFile::apply()
|
||||
{
|
||||
// test file permissions
|
||||
if (!QFileInfo(fileName()).isWritable()) {
|
||||
const QString &path = fileName();
|
||||
Core::Internal::ReadOnlyFilesDialog roDialog(path, Core::ICore::mainWindow());
|
||||
const QString &failDetailText = QApplication::translate("RefactoringFile::apply",
|
||||
"Refactoring cannot be applied.");
|
||||
roDialog.setShowFailWarning(true, failDetailText);
|
||||
if (roDialog.exec() == Core::Internal::ReadOnlyFilesDialog::RO_Cancel)
|
||||
return;
|
||||
}
|
||||
|
||||
// open / activate / goto position
|
||||
if (m_openEditor && !m_fileName.isEmpty()) {
|
||||
unsigned line = unsigned(-1), column = unsigned(-1);
|
||||
|
||||
Reference in New Issue
Block a user