forked from qt-creator/qt-creator
EditorManager: Refactor read-only message
Change-Id: Iceeb5ed0ecafa6593095bbeeab5819be6b8a28de Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -90,6 +90,7 @@ static const char kCurrentDocumentFilePath[] = "CurrentDocument:FilePath";
|
|||||||
static const char kCurrentDocumentPath[] = "CurrentDocument:Path";
|
static const char kCurrentDocumentPath[] = "CurrentDocument:Path";
|
||||||
static const char kCurrentDocumentXPos[] = "CurrentDocument:XPos";
|
static const char kCurrentDocumentXPos[] = "CurrentDocument:XPos";
|
||||||
static const char kCurrentDocumentYPos[] = "CurrentDocument:YPos";
|
static const char kCurrentDocumentYPos[] = "CurrentDocument:YPos";
|
||||||
|
static const char kMakeWritableWarning[] = "Core.EditorManager.MakeWritable";
|
||||||
|
|
||||||
//===================EditorClosingCoreListener======================
|
//===================EditorClosingCoreListener======================
|
||||||
|
|
||||||
@@ -1686,23 +1687,9 @@ void EditorManager::handleEditorStateChange()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::updateActions()
|
void EditorManager::updateMakeWritableWarning()
|
||||||
{
|
{
|
||||||
QString fName;
|
|
||||||
IEditor *curEditor = currentEditor();
|
IEditor *curEditor = currentEditor();
|
||||||
int openedCount = openedEditors().count() + d->m_editorModel->restoredEditors().count();
|
|
||||||
|
|
||||||
if (curEditor) {
|
|
||||||
|
|
||||||
if (!curEditor->document()->fileName().isEmpty()) {
|
|
||||||
QFileInfo fi(curEditor->document()->fileName());
|
|
||||||
fName = fi.fileName();
|
|
||||||
} else {
|
|
||||||
fName = curEditor->displayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HostOsInfo::isMacHost())
|
|
||||||
window()->setWindowModified(curEditor->document()->isModified());
|
|
||||||
bool ww = curEditor->document()->isModified() && curEditor->document()->isFileReadOnly();
|
bool ww = curEditor->document()->isModified() && curEditor->document()->isFileReadOnly();
|
||||||
if (ww != curEditor->document()->hasWriteWarning()) {
|
if (ww != curEditor->document()->hasWriteWarning()) {
|
||||||
curEditor->document()->setWriteWarning(ww);
|
curEditor->document()->setWriteWarning(ww);
|
||||||
@@ -1724,21 +1711,41 @@ void EditorManager::updateActions()
|
|||||||
if (ww) {
|
if (ww) {
|
||||||
// we are about to change a read-only file, warn user
|
// we are about to change a read-only file, warn user
|
||||||
if (promptVCS) {
|
if (promptVCS) {
|
||||||
InfoBarEntry info(QLatin1String("Core.EditorManager.MakeWritable"),
|
InfoBarEntry info(QLatin1String(kMakeWritableWarning),
|
||||||
tr("<b>Warning:</b> This file was not opened in %1 yet.")
|
tr("<b>Warning:</b> This file was not opened in %1 yet.")
|
||||||
.arg(versionControl->displayName()));
|
.arg(versionControl->displayName()));
|
||||||
info.setCustomButtonInfo(tr("Open"), this, SLOT(vcsOpenCurrentEditor()));
|
info.setCustomButtonInfo(tr("Open"), this, SLOT(vcsOpenCurrentEditor()));
|
||||||
curEditor->document()->infoBar()->addInfo(info);
|
curEditor->document()->infoBar()->addInfo(info);
|
||||||
} else {
|
} else {
|
||||||
InfoBarEntry info(QLatin1String("Core.EditorManager.MakeWritable"),
|
InfoBarEntry info(QLatin1String(kMakeWritableWarning),
|
||||||
tr("<b>Warning:</b> You are changing a read-only file."));
|
tr("<b>Warning:</b> You are changing a read-only file."));
|
||||||
info.setCustomButtonInfo(tr("Make Writable"), this, SLOT(makeCurrentEditorWritable()));
|
info.setCustomButtonInfo(tr("Make Writable"), this, SLOT(makeCurrentEditorWritable()));
|
||||||
curEditor->document()->infoBar()->addInfo(info);
|
curEditor->document()->infoBar()->addInfo(info);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
curEditor->document()->infoBar()->removeInfo(QLatin1String("Core.EditorManager.MakeWritable"));
|
curEditor->document()->infoBar()->removeInfo(QLatin1String(kMakeWritableWarning));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorManager::updateActions()
|
||||||
|
{
|
||||||
|
QString fName;
|
||||||
|
IEditor *curEditor = currentEditor();
|
||||||
|
int openedCount = openedEditors().count() + d->m_editorModel->restoredEditors().count();
|
||||||
|
|
||||||
|
if (curEditor) {
|
||||||
|
|
||||||
|
if (!curEditor->document()->fileName().isEmpty()) {
|
||||||
|
QFileInfo fi(curEditor->document()->fileName());
|
||||||
|
fName = fi.fileName();
|
||||||
|
} else {
|
||||||
|
fName = curEditor->displayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HostOsInfo::isMacHost())
|
||||||
|
window()->setWindowModified(curEditor->document()->isModified());
|
||||||
|
updateMakeWritableWarning();
|
||||||
} else /* curEditor */ if (HostOsInfo::isMacHost()) {
|
} else /* curEditor */ if (HostOsInfo::isMacHost()) {
|
||||||
window()->setWindowModified(false);
|
window()->setWindowModified(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,6 +263,7 @@ private:
|
|||||||
void switchToPreferedMode();
|
void switchToPreferedMode();
|
||||||
void updateAutoSave();
|
void updateAutoSave();
|
||||||
void setCloseSplitEnabled(Internal::SplitterOrView *splitterOrView, bool enable);
|
void setCloseSplitEnabled(Internal::SplitterOrView *splitterOrView, bool enable);
|
||||||
|
void updateMakeWritableWarning();
|
||||||
|
|
||||||
EditorManagerPrivate *d;
|
EditorManagerPrivate *d;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user