Commit f5a2c146 authored by jkobus's avatar jkobus Committed by Jarek Kobus

Add a DiffShowEditor showing an additional info

Task-number: QTCREATORBUG-9489

Change-Id: I3ae2e59ccaf397f4236505f21e027a42e2798784
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: default avatarPetar Perisin <petar.perisin@gmail.com>
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@digia.com>
parent a304fb45
......@@ -36,6 +36,7 @@
<file>images/replace.png</file>
<file>images/reset.png</file>
<file>images/sidebaricon.png</file>
<file>images/topbaricon.png</file>
<file>images/splitbutton_horizontal.png</file>
<file>images/statusbar.png</file>
<file>images/undo.png</file>
......
......@@ -194,6 +194,7 @@ const char ICON_CLEAR[] = ":/core/images/clear.png";
const char ICON_RESET[] = ":/core/images/reset.png";
const char ICON_MAGNIFIER[] = ":/core/images/magnifier.png";
const char ICON_TOGGLE_SIDEBAR[] = ":/core/images/sidebaricon.png";
const char ICON_TOGGLE_TOPBAR[] = ":/core/images/topbaricon.png";
const char ICON_CLOSE_DOCUMENT[] = ":/core/images/button_close.png";
const char ICON_CLOSE[] = ":/core/images/closebutton.png";
const char ICON_CLOSE_DARK[] = ":/core/images/darkclosebutton.png";
......
......@@ -27,8 +27,8 @@
**
****************************************************************************/
#ifndef DIFFEDITOREDITABLE_H
#define DIFFEDITOREDITABLE_H
#ifndef DIFFEDITOR_H
#define DIFFEDITOR_H
#include "diffeditor_global.h"
#include "diffeditorwidget.h"
......@@ -77,16 +77,18 @@ public slots:
private slots:
void entryActivated(int index);
protected:
QToolBar *m_toolWidget;
private:
void updateEntryToolTip();
Internal::DiffEditorFile *m_file;
DiffEditorWidget *m_editorWidget;
QToolBar *m_toolWidget;
QComboBox *m_entriesComboBox;
mutable QString m_displayName;
};
} // namespace DiffEditor
#endif // DIFFEDITOREDITABLE_H
#endif // DIFFEDITOR_H
......@@ -4,15 +4,21 @@ include(../../qtcreatorplugin.pri)
HEADERS += diffeditor_global.h \
diffeditorconstants.h \
diffeditor.h \
diffeditorfactory.h \
diffeditorfile.h \
diffeditorplugin.h \
diffeditorwidget.h \
differ.h
differ.h \
diffshoweditor.h \
diffshoweditorfactory.h
SOURCES += diffeditor.cpp \
diffeditorfactory.cpp \
diffeditorfile.cpp \
diffeditorplugin.cpp \
diffeditorwidget.cpp \
differ.cpp
differ.cpp \
diffshoweditor.cpp \
diffshoweditorfactory.cpp
RESOURCES +=
......@@ -16,6 +16,8 @@ QtcPlugin {
"diffeditor.h",
"diffeditor_global.h",
"diffeditorconstants.h",
"diffeditorfactory.cpp",
"diffeditorfactory.h",
"diffeditorfile.cpp",
"diffeditorfile.h",
"diffeditorplugin.cpp",
......@@ -24,6 +26,10 @@ QtcPlugin {
"diffeditorwidget.h",
"differ.cpp",
"differ.h",
"diffshoweditor.cpp",
"diffshoweditor.h",
"diffshoweditorfactory.cpp",
"diffshoweditorfactory.h",
]
}
......@@ -36,6 +36,8 @@ namespace Constants {
const char DIFF_EDITOR_ID[] = "Diff Editor";
const char DIFF_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("DiffEditor", "Diff Editor");
const char DIFF_EDITOR_MIMETYPE[] = "text/x-patch";
const char DIFF_SHOW_EDITOR_ID[] = "Show Editor";
const char DIFF_SHOW_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("ShowEditor", "Show Editor");
const char G_TOOLS_DIFF[] = "QtCreator.Group.Tools.Options";
} // namespace Constants
......
/****************************************************************************
**
** 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 "diffeditorfactory.h"
#include "diffeditor.h"
#include "diffeditorwidget.h"
#include "diffeditorconstants.h"
#include <QCoreApplication>
namespace DiffEditor {
namespace Internal {
DiffEditorFactory::DiffEditorFactory(QObject *parent)
: IEditorFactory(parent),
m_mimeTypes(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE))
{
}
Core::Id DiffEditorFactory::id() const
{
return Constants::DIFF_EDITOR_ID;
}
QString DiffEditorFactory::displayName() const
{
return qApp->translate("DiffEditorFactory", Constants::DIFF_EDITOR_DISPLAY_NAME);
}
Core::IEditor *DiffEditorFactory::createEditor(QWidget *parent)
{
DiffEditorWidget *editorWidget = new DiffEditorWidget(parent);
DiffEditor *editor = new DiffEditor(editorWidget);
return editor;
}
QStringList DiffEditorFactory::mimeTypes() const
{
return m_mimeTypes;
}
} // namespace Internal
} // namespace DiffEditor
/****************************************************************************
**
** 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 DIFFEDITORFACTORY_H
#define DIFFEDITORFACTORY_H
#include "diffeditor_global.h"
#include <QStringList>
#include <coreplugin/editormanager/ieditorfactory.h>
namespace DiffEditor {
namespace Internal {
class DiffEditorFactory : public Core::IEditorFactory
{
Q_OBJECT
public:
explicit DiffEditorFactory(QObject *parent);
QStringList mimeTypes() const;
Core::IEditor *createEditor(QWidget *parent);
Core::Id id() const;
QString displayName() const;
private:
const QStringList m_mimeTypes;
};
} // namespace Internal
} // namespace DiffEditor
#endif // DIFFEDITORFACTORY_H
......@@ -29,10 +29,12 @@
#include "diffeditorplugin.h"
#include "diffeditor.h"
#include "diffeditorwidget.h"
#include "diffeditorconstants.h"
#include "diffeditorfactory.h"
#include "diffeditorwidget.h"
#include "diffshoweditor.h"
#include "diffshoweditorfactory.h"
#include <QCoreApplication>
#include <QFileDialog>
#include <QTextCodec>
#include <QtPlugin>
......@@ -44,40 +46,8 @@
namespace DiffEditor {
///////////////////////////////// DiffEditorFactory //////////////////////////////////
namespace Internal {
DiffEditorFactory::DiffEditorFactory(DiffEditorPlugin *owner)
: m_mimeTypes(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE)),
m_owner(owner)
{
}
Core::Id DiffEditorFactory::id() const
{
return Constants::DIFF_EDITOR_ID;
}
QString DiffEditorFactory::displayName() const
{
return qApp->translate("DiffEditorFactory", Constants::DIFF_EDITOR_DISPLAY_NAME);
}
Core::IEditor *DiffEditorFactory::createEditor(QWidget *parent)
{
DiffEditorWidget *editorWidget = new DiffEditorWidget(parent);
DiffEditor *editor = new DiffEditor(editorWidget);
return editor;
}
QStringList DiffEditorFactory::mimeTypes() const
{
return m_mimeTypes;
}
///////////////////////////////// DiffEditorPlugin //////////////////////////////////
DiffEditorPlugin::DiffEditorPlugin()
{
}
......@@ -86,11 +56,6 @@ DiffEditorPlugin::~DiffEditorPlugin()
{
}
void DiffEditorPlugin::initializeEditor(DiffEditorWidget *editor)
{
Q_UNUSED(editor)
}
bool DiffEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments)
......@@ -110,6 +75,7 @@ bool DiffEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
toolsContainer->addAction(diffCommand, Constants::G_TOOLS_DIFF);
addAutoReleasedObject(new DiffEditorFactory(this));
addAutoReleasedObject(new DiffShowEditorFactory(this));
return true;
}
......
......@@ -33,18 +33,9 @@
#include "diffeditor_global.h"
#include <extensionsystem/iplugin.h>
#include <coreplugin/editormanager/ieditorfactory.h>
#include <coreplugin/icontext.h>
#include <coreplugin/idocument.h>
#include <QStringList>
namespace Core { class IEditor; }
namespace DiffEditor {
class DiffEditorWidget;
namespace Internal {
class DiffEditorPlugin : public ExtensionSystem::IPlugin
......@@ -59,9 +50,6 @@ public:
bool initialize(const QStringList &arguments, QString *errorMessage = 0);
void extensionsInitialized();
// Connect editor to settings changed signals.
void initializeEditor(DiffEditorWidget *editor);
private slots:
void diff();
......@@ -74,23 +62,6 @@ private:
};
class DiffEditorFactory : public Core::IEditorFactory
{
Q_OBJECT
public:
explicit DiffEditorFactory(DiffEditorPlugin *owner);
QStringList mimeTypes() const;
Core::IEditor *createEditor(QWidget *parent);
Core::Id id() const;
QString displayName() const;
private:
const QStringList m_mimeTypes;
DiffEditorPlugin *m_owner;
};
} // namespace Internal
} // namespace DiffEditor
......
/****************************************************************************
**
** 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 "diffshoweditor.h"
#include "diffeditorconstants.h"
#include <QToolBar>
#include <QToolButton>
#include <QCoreApplication>
#include <coreplugin/coreconstants.h>
#include <coreplugin/minisplitter.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/displaysettings.h>
using namespace TextEditor;
namespace DiffEditor {
namespace Internal {
class DiffShowEditorWidgetEditable : public BaseTextEditor
{
Q_OBJECT
public:
DiffShowEditorWidgetEditable(BaseTextEditorWidget *editorWidget) : BaseTextEditor(editorWidget) {}
Core::Id id() const { return "DiffShowViewEditor"; }
bool isTemporary() const { return false; }
};
class DiffShowEditorWidget : public BaseTextEditorWidget
{
Q_OBJECT
public:
DiffShowEditorWidget(QWidget *parent = 0);
virtual QSize sizeHint() const;
public slots:
void setDisplaySettings(const DisplaySettings &ds);
protected:
BaseTextEditor *createEditor() { return new DiffShowEditorWidgetEditable(this); }
private:
};
DiffShowEditorWidget::DiffShowEditorWidget(QWidget *parent)
: BaseTextEditorWidget(parent)
{
DisplaySettings settings = displaySettings();
settings.m_textWrapping = false;
settings.m_displayLineNumbers = false;
settings.m_highlightCurrentLine = false;
settings.m_displayFoldingMarkers = false;
settings.m_markTextChanges = false;
settings.m_highlightBlocks = false;
BaseTextEditorWidget::setDisplaySettings(settings);
setCodeFoldingSupported(true);
setFrameStyle(QFrame::NoFrame);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
}
QSize DiffShowEditorWidget::sizeHint() const
{
QSize size = BaseTextEditorWidget::sizeHint();
size.setHeight(size.height() / 5);
return size;
}
void DiffShowEditorWidget::setDisplaySettings(const DisplaySettings &ds)
{
DisplaySettings settings = displaySettings();
settings.m_visualizeWhitespace = ds.m_visualizeWhitespace;
BaseTextEditorWidget::setDisplaySettings(settings);
}
} // namespace Internal
DiffShowEditor::DiffShowEditor(DiffEditorWidget *editorWidget)
: DiffEditor(editorWidget)
{
QSplitter *splitter = new Core::MiniSplitter(Qt::Vertical);
m_diffShowWidget = new Internal::DiffShowEditorWidget(splitter);
m_diffShowWidget->setReadOnly(true);
splitter->addWidget(m_diffShowWidget);
splitter->addWidget(editorWidget);
setWidget(splitter);
TextEditorSettings *settings = TextEditorSettings::instance();
connect(settings, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
m_diffShowWidget, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
m_diffShowWidget, SLOT(setFontSettings(TextEditor::FontSettings)));
m_diffShowWidget->setDisplaySettings(settings->displaySettings());
m_diffShowWidget->setCodeStyle(settings->codeStyle());
m_diffShowWidget->setFontSettings(settings->fontSettings());
}
DiffShowEditor::~DiffShowEditor()
{
}
void DiffShowEditor::setDescription(const QString &description)
{
m_diffShowWidget->setPlainText(description);
}
QString DiffShowEditor::displayName() const
{
if (m_displayName.isEmpty())
m_displayName = QCoreApplication::translate("DiffShowEditor", Constants::DIFF_SHOW_EDITOR_DISPLAY_NAME);
return m_displayName;
}
void DiffShowEditor::setDisplayName(const QString &title)
{
m_displayName = title;
emit changed();
}
Core::Id DiffShowEditor::id() const
{
return Constants::DIFF_SHOW_EDITOR_ID;
}
QWidget *DiffShowEditor::toolBar()
{
if (m_toolWidget)
return m_toolWidget;
// Create
DiffEditor::toolBar();
m_toggleDescriptionButton = new QToolButton(m_toolWidget);
m_toggleDescriptionButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_TOGGLE_TOPBAR)));
m_toggleDescriptionButton->setCheckable(true);
m_toggleDescriptionButton->setChecked(true);
connect(m_toggleDescriptionButton, SIGNAL(clicked(bool)),
this, SLOT(setDescriptionVisible(bool)));
m_toolWidget->addWidget(m_toggleDescriptionButton);
setDescriptionVisible(true);
return m_toolWidget;
}
void DiffShowEditor::setDescriptionVisible(bool visible)
{
if (visible) {
m_toggleDescriptionButton->setToolTip(tr("Hide Change Description"));
} else {
m_toggleDescriptionButton->setToolTip(tr("Show Change Description"));
}
m_diffShowWidget->setVisible(visible);
}
} // namespace DiffEditor
#include "diffshoweditor.moc"
/****************************************************************************
**
** 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 DIFFSHOWEDITOR_H
#define DIFFSHOWEDITOR_H
#include "diffeditor_global.h"
#include "diffeditor.h"
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/idocument.h>
QT_BEGIN_NAMESPACE
class QToolButton;
QT_END_NAMESPACE
namespace DiffEditor {
namespace Internal {
class DiffEditorFile;
}
class DIFFEDITOR_EXPORT DiffShowEditor : public DiffEditor
{
Q_OBJECT
public:
explicit DiffShowEditor(DiffEditorWidget *editorWidget);
virtual ~DiffShowEditor();
public:
void setDescription(const QString &description);
// Core::IEditor
QString displayName() const;
void setDisplayName(const QString &title);
Core::Id id() const;
QWidget *toolBar();
private slots:
void setDescriptionVisible(bool visible);
private:
void updateEntryToolTip();
TextEditor::BaseTextEditorWidget *m_diffShowWidget;
mutable QString m_displayName;
QToolButton *m_toggleDescriptionButton;
};
} // namespace DiffEditor
#endif // DIFFEDITOR_H
/****************************************************************************
**
** 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 "diffshoweditorfactory.h"
#include "diffshoweditor.h"
#include "diffeditorwidget.h"
#include "diffeditorconstants.h"
#include <QCoreApplication>
namespace DiffEditor {
namespace Internal {
DiffShowEditorFactory::DiffShowEditorFactory(QObject *parent)
: IEditorFactory(parent),
m_mimeTypes(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE))
{
}
Core::Id DiffShowEditorFactory::id() const
{
return Constants::DIFF_SHOW_EDITOR_ID;
}
QString DiffShowEditorFactory::displayName() const
{
return qApp->translate("DiffEditorFactory", Constants::DIFF_SHOW_EDITOR_DISPLAY_NAME);
}
Core::IEditor *DiffShowEditorFactory::createEditor(QWidget *parent)
{
DiffEditorWidget *editorWidget = new DiffEditorWidget(parent);
DiffShowEditor *editor = new DiffShowEditor(editorWidget);
return editor;
}
QStringList DiffShowEditorFactory::mimeTypes() const
{
return m_mimeTypes;
}
} // namespace Internal
} // namespace DiffEditor
/****************************************************************************
**
** 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