Get rid of DiffShowEditor.

Made DiffEditor customizable instead

Change-Id: If92799d47c7e731febb45197384c082eb3af55df
Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com>
This commit is contained in:
Jarek Kobus
2014-01-30 17:04:54 +01:00
committed by Jarek Kobus
parent 3798552beb
commit edac8f082d
13 changed files with 221 additions and 393 deletions

View File

@@ -34,6 +34,11 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/minisplitter.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/displaysettings.h>
#include <QToolButton> #include <QToolButton>
#include <QSpinBox> #include <QSpinBox>
@@ -44,23 +49,110 @@
#include <QComboBox> #include <QComboBox>
#include <QFileInfo> #include <QFileInfo>
using namespace TextEditor;
namespace DiffEditor { namespace DiffEditor {
namespace Internal {
class DescriptionEditor : public BaseTextEditor
{
Q_OBJECT
public:
DescriptionEditor(BaseTextEditorWidget *editorWidget) : BaseTextEditor(editorWidget) {}
Core::Id id() const { return "DescriptionEditor"; }
};
class DescriptionEditorWidget : public BaseTextEditorWidget
{
Q_OBJECT
public:
DescriptionEditorWidget(QWidget *parent = 0);
virtual QSize sizeHint() const;
public slots:
void setDisplaySettings(const DisplaySettings &ds);
protected:
BaseTextEditor *createEditor() { return new DescriptionEditor(this); }
private:
};
DescriptionEditorWidget::DescriptionEditorWidget(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 DescriptionEditorWidget::sizeHint() const
{
QSize size = BaseTextEditorWidget::sizeHint();
size.setHeight(size.height() / 5);
return size;
}
void DescriptionEditorWidget::setDisplaySettings(const DisplaySettings &ds)
{
DisplaySettings settings = displaySettings();
settings.m_visualizeWhitespace = ds.m_visualizeWhitespace;
BaseTextEditorWidget::setDisplaySettings(settings);
}
} // namespace Internal
///////////////////////////////// DiffEditor ////////////////////////////////// ///////////////////////////////// DiffEditor //////////////////////////////////
DiffEditor::DiffEditor(SideBySideDiffEditorWidget *editorWidget) DiffEditor::DiffEditor(SideBySideDiffEditorWidget *editorWidget)
: IEditor(0) : IEditor(0)
, m_toolWidget(0) , m_toolWidget(0)
, m_document(new Internal::DiffEditorDocument(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE), this)) , m_document(new Internal::DiffEditorDocument(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE), this))
, m_editorWidget(editorWidget) , m_diffWidget(editorWidget)
, m_diffEditorController(0) , m_diffEditorController(0)
, m_entriesComboBox(0) , m_entriesComboBox(0)
, m_toggleDescriptionAction(0)
{ {
setWidget(editorWidget); QSplitter *splitter = new Core::MiniSplitter(Qt::Vertical);
m_descriptionWidget = new Internal::DescriptionEditorWidget(splitter);
m_descriptionWidget->setReadOnly(true);
splitter->addWidget(m_descriptionWidget);
splitter->addWidget(editorWidget);
setWidget(splitter);
connect(TextEditorSettings::instance(), SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
m_descriptionWidget, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
connect(TextEditorSettings::instance(), SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
m_descriptionWidget->baseTextDocument(), SLOT(setFontSettings(TextEditor::FontSettings)));
m_descriptionWidget->setDisplaySettings(TextEditorSettings::displaySettings());
m_descriptionWidget->setCodeStyle(TextEditorSettings::codeStyle());
m_descriptionWidget->baseTextDocument()->setFontSettings(TextEditorSettings::fontSettings());
m_diffEditorController = editorWidget ? editorWidget->diffEditorController() : 0; m_diffEditorController = editorWidget ? editorWidget->diffEditorController() : 0;
if (m_diffEditorController) { if (m_diffEditorController) {
connect(m_diffEditorController, SIGNAL(currentDiffFileIndexChanged(int)), connect(m_diffEditorController, SIGNAL(currentDiffFileIndexChanged(int)),
this, SLOT(activateEntry(int))); this, SLOT(activateEntry(int)));
connect(m_diffEditorController, SIGNAL(descriptionChanged(QString)),
this, SLOT(slotDescriptionChanged(QString)));
connect(m_diffEditorController, SIGNAL(descriptionEnablementChanged(bool)),
this, SLOT(slotDescriptionVisibilityChanged()));
connect(m_diffEditorController, SIGNAL(descriptionVisibilityChanged(bool)),
this, SLOT(slotDescriptionVisibilityChanged()));
slotDescriptionChanged(m_diffEditorController->description());
slotDescriptionVisibilityChanged();
} }
} }
@@ -91,7 +183,7 @@ Core::Id DiffEditor::id() const
QTextCodec *DiffEditor::codec() const QTextCodec *DiffEditor::codec() const
{ {
return m_editorWidget->codec(); return m_diffWidget->codec();
} }
static QToolBar *createToolBar(const QWidget *someWidget) static QToolBar *createToolBar(const QWidget *someWidget)
@@ -111,7 +203,7 @@ QWidget *DiffEditor::toolBar()
return m_toolWidget; return m_toolWidget;
// Create // Create
m_toolWidget = createToolBar(m_editorWidget); m_toolWidget = createToolBar(m_diffWidget);
m_entriesComboBox = new QComboBox; m_entriesComboBox = new QComboBox;
m_entriesComboBox->setMinimumContentsLength(20); m_entriesComboBox->setMinimumContentsLength(20);
@@ -148,6 +240,13 @@ QWidget *DiffEditor::toolBar()
toggleSync->setToolTip(tr("Synchronize Horizontal Scroll Bars")); toggleSync->setToolTip(tr("Synchronize Horizontal Scroll Bars"));
m_toolWidget->addWidget(toggleSync); m_toolWidget->addWidget(toggleSync);
QToolButton *toggleDescription = new QToolButton(m_toolWidget);
toggleDescription->setIcon(QIcon(QLatin1String(Core::Constants::ICON_TOGGLE_TOPBAR)));
toggleDescription->setCheckable(true);
toggleDescription->setChecked(true);
m_toggleDescriptionAction = m_toolWidget->addWidget(toggleDescription);
slotDescriptionVisibilityChanged();
if (m_diffEditorController) { if (m_diffEditorController) {
connect(whitespaceButton, SIGNAL(clicked(bool)), connect(whitespaceButton, SIGNAL(clicked(bool)),
m_diffEditorController, SLOT(setIgnoreWhitespaces(bool))); m_diffEditorController, SLOT(setIgnoreWhitespaces(bool)));
@@ -155,6 +254,8 @@ QWidget *DiffEditor::toolBar()
m_diffEditorController, SLOT(setContextLinesNumber(int))); m_diffEditorController, SLOT(setContextLinesNumber(int)));
connect(toggleSync, SIGNAL(clicked(bool)), connect(toggleSync, SIGNAL(clicked(bool)),
m_diffEditorController, SLOT(setHorizontalScrollBarSynchronization(bool))); m_diffEditorController, SLOT(setHorizontalScrollBarSynchronization(bool)));
connect(toggleDescription, SIGNAL(clicked(bool)),
m_diffEditorController, SLOT(setDescriptionVisible(bool)));
// TODO: synchronize in opposite direction too // TODO: synchronize in opposite direction too
} }
@@ -206,6 +307,18 @@ void DiffEditor::setDiff(const QList<DiffEditorController::DiffFilesContents> &d
m_diffEditorController->setDiffContents(diffFileList, workingDirectory); m_diffEditorController->setDiffContents(diffFileList, workingDirectory);
} }
void DiffEditor::setDescription(const QString &description)
{
if (m_diffEditorController)
m_diffEditorController->setDescription(description);
}
void DiffEditor::setDescriptionEnabled(bool on)
{
if (m_diffEditorController)
m_diffEditorController->setDescriptionEnabled(on);
}
void DiffEditor::clear(const QString &message) void DiffEditor::clear(const QString &message)
{ {
m_entriesComboBox->clear(); m_entriesComboBox->clear();
@@ -236,4 +349,34 @@ void DiffEditor::activateEntry(int index)
updateEntryToolTip(); updateEntryToolTip();
} }
void DiffEditor::slotDescriptionChanged(const QString &description)
{
m_descriptionWidget->setPlainText(description);
}
void DiffEditor::slotDescriptionVisibilityChanged()
{
if (!m_diffEditorController)
return;
const bool visible = m_diffEditorController->isDescriptionVisible();
const bool enabled = m_diffEditorController->isDescriptionEnabled();
m_descriptionWidget->setVisible(visible && enabled);
if (!m_toggleDescriptionAction)
return;
QWidget *toggle = m_toolWidget->widgetForAction(m_toggleDescriptionAction);
if (visible)
toggle->setToolTip(tr("Hide Change Description"));
else
toggle->setToolTip(tr("Show Change Description"));
m_toggleDescriptionAction->setVisible(enabled);
}
} // namespace DiffEditor } // namespace DiffEditor
#include "diffeditor.moc"

View File

@@ -39,14 +39,15 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QToolBar; class QToolBar;
class QComboBox; class QComboBox;
class QToolButton;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace TextEditor { class BaseTextEditorWidget; }
namespace DiffEditor { namespace DiffEditor {
class SideBySideDiffEditorWidget; class SideBySideDiffEditorWidget;
namespace Internal { namespace Internal { class DiffEditorDocument; }
class DiffEditorDocument;
}
class DIFFEDITOR_EXPORT DiffEditor : public Core::IEditor class DIFFEDITOR_EXPORT DiffEditor : public Core::IEditor
{ {
@@ -58,6 +59,8 @@ public:
public: public:
void setDiff(const QList<DiffEditorController::DiffFilesContents> &diffFileList, void setDiff(const QList<DiffEditorController::DiffFilesContents> &diffFileList,
const QString &workingDirectory = QString()); const QString &workingDirectory = QString());
void setDescription(const QString &description);
void setDescriptionEnabled(bool on);
void clear(const QString &message); void clear(const QString &message);
// Core::IEditor // Core::IEditor
@@ -73,6 +76,8 @@ public slots:
private slots: private slots:
void entryActivated(int index); void entryActivated(int index);
void slotDescriptionChanged(const QString &description);
void slotDescriptionVisibilityChanged();
protected: protected:
QToolBar *m_toolWidget; QToolBar *m_toolWidget;
@@ -81,9 +86,11 @@ private:
void updateEntryToolTip(); void updateEntryToolTip();
Internal::DiffEditorDocument *m_document; Internal::DiffEditorDocument *m_document;
SideBySideDiffEditorWidget *m_editorWidget; TextEditor::BaseTextEditorWidget *m_descriptionWidget;
SideBySideDiffEditorWidget *m_diffWidget;
DiffEditorController *m_diffEditorController; DiffEditorController *m_diffEditorController;
QComboBox *m_entriesComboBox; QComboBox *m_entriesComboBox;
QAction *m_toggleDescriptionAction;
}; };
} // namespace DiffEditor } // namespace DiffEditor

View File

@@ -9,8 +9,6 @@ HEADERS += diffeditor_global.h \
diffeditorfactory.h \ diffeditorfactory.h \
diffeditorplugin.h \ diffeditorplugin.h \
differ.h \ differ.h \
diffshoweditor.h \
diffshoweditorfactory.h \
sidebysidediffeditorwidget.h sidebysidediffeditorwidget.h
SOURCES += diffeditor.cpp \ SOURCES += diffeditor.cpp \
@@ -19,8 +17,6 @@ SOURCES += diffeditor.cpp \
diffeditorfactory.cpp \ diffeditorfactory.cpp \
diffeditorplugin.cpp \ diffeditorplugin.cpp \
differ.cpp \ differ.cpp \
diffshoweditor.cpp \
diffshoweditorfactory.cpp \
sidebysidediffeditorwidget.cpp sidebysidediffeditorwidget.cpp
RESOURCES += RESOURCES +=

View File

@@ -25,10 +25,6 @@ QtcPlugin {
"diffeditorplugin.h", "diffeditorplugin.h",
"differ.cpp", "differ.cpp",
"differ.h", "differ.h",
"diffshoweditor.cpp",
"diffshoweditor.h",
"diffshoweditorfactory.cpp",
"diffshoweditorfactory.h",
"sidebysidediffeditorwidget.cpp", "sidebysidediffeditorwidget.cpp",
"sidebysidediffeditorwidget.h", "sidebysidediffeditorwidget.h",
] ]

View File

@@ -38,8 +38,6 @@ namespace Constants {
const char DIFF_EDITOR_ID[] = "Diff Editor"; const char DIFF_EDITOR_ID[] = "Diff Editor";
const char DIFF_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("DiffEditor", "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_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"; const char G_TOOLS_DIFF[] = "QtCreator.Group.Tools.Options";
} // namespace Constants } // namespace Constants

View File

@@ -33,9 +33,12 @@ namespace DiffEditor {
DiffEditorController::DiffEditorController(QObject *parent) DiffEditorController::DiffEditorController(QObject *parent)
: QObject(parent), : QObject(parent),
m_descriptionEnabled(false),
m_descriptionVisible(true),
m_contextLinesNumber(3), m_contextLinesNumber(3),
m_ignoreWhitespaces(true), m_ignoreWhitespaces(true),
m_syncScrollBars(true) m_syncScrollBars(true),
m_currentDiffFileIndex(-1)
{ {
clear(); clear();
} }
@@ -60,6 +63,21 @@ QString DiffEditorController::workingDirectory() const
return m_workingDirectory; return m_workingDirectory;
} }
QString DiffEditorController::description() const
{
return m_description;
}
bool DiffEditorController::isDescriptionEnabled() const
{
return m_descriptionEnabled;
}
bool DiffEditorController::isDescriptionVisible() const
{
return m_descriptionVisible;
}
int DiffEditorController::contextLinesNumber() const int DiffEditorController::contextLinesNumber() const
{ {
return m_contextLinesNumber; return m_contextLinesNumber;
@@ -100,6 +118,33 @@ void DiffEditorController::setDiffContents(const QList<DiffFilesContents> &diffF
emit diffContentsChanged(diffFileList, workingDirectory); emit diffContentsChanged(diffFileList, workingDirectory);
} }
void DiffEditorController::setDescription(const QString &description)
{
if (m_description == description)
return;
m_description = description;
emit descriptionChanged(description);
}
void DiffEditorController::setDescriptionEnabled(bool on)
{
if (m_descriptionEnabled == on)
return;
m_descriptionEnabled = on;
emit descriptionEnablementChanged(on);
}
void DiffEditorController::setDescriptionVisible(bool on)
{
if (m_descriptionVisible == on)
return;
m_descriptionVisible = on;
emit descriptionVisibilityChanged(on);
}
void DiffEditorController::setContextLinesNumber(int lines) void DiffEditorController::setContextLinesNumber(int lines)
{ {
const int l = qMax(lines, -1); const int l = qMax(lines, -1);

View File

@@ -70,7 +70,10 @@ public:
QList<DiffFilesContents> diffContents() const; QList<DiffFilesContents> diffContents() const;
QString workingDirectory() const; QString workingDirectory() const;
QString description() const;
bool isDescriptionEnabled() const;
bool isDescriptionVisible() const;
int contextLinesNumber() const; int contextLinesNumber() const;
bool isIgnoreWhitespaces() const; bool isIgnoreWhitespaces() const;
bool horizontalScrollBarSynchronization() const; bool horizontalScrollBarSynchronization() const;
@@ -80,7 +83,10 @@ public slots:
void clear(); void clear();
void clear(const QString &message); void clear(const QString &message);
void setDiffContents(const QList<DiffEditorController::DiffFilesContents> &diffFileList, const QString &workingDirectory = QString()); void setDiffContents(const QList<DiffEditorController::DiffFilesContents> &diffFileList, const QString &workingDirectory = QString());
void setDescription(const QString &description);
void setDescriptionEnabled(bool on);
void setDescriptionVisible(bool on);
void setContextLinesNumber(int lines); void setContextLinesNumber(int lines);
void setIgnoreWhitespaces(bool ignore); void setIgnoreWhitespaces(bool ignore);
void setHorizontalScrollBarSynchronization(bool on); void setHorizontalScrollBarSynchronization(bool on);
@@ -91,7 +97,10 @@ signals:
void cleared(const QString message); void cleared(const QString message);
// This sets the current diff file index to 0 (unless diffFileList is empty) // This sets the current diff file index to 0 (unless diffFileList is empty)
void diffContentsChanged(const QList<DiffEditorController::DiffFilesContents> &diffFileList, const QString &workingDirectory); void diffContentsChanged(const QList<DiffEditorController::DiffFilesContents> &diffFileList, const QString &workingDirectory);
void descriptionChanged(const QString &description);
void descriptionEnablementChanged(bool on);
void descriptionVisibilityChanged(bool on);
void contextLinesNumberChanged(int lines); void contextLinesNumberChanged(int lines);
void ignoreWhitespacesChanged(bool ignore); void ignoreWhitespacesChanged(bool ignore);
void horizontalScrollBarSynchronizationChanged(bool on); void horizontalScrollBarSynchronizationChanged(bool on);
@@ -102,7 +111,10 @@ private:
QList<DiffFilesContents> m_diffFileList; QList<DiffFilesContents> m_diffFileList;
QString m_workingDirectory; QString m_workingDirectory;
QString m_description;
bool m_descriptionEnabled;
bool m_descriptionVisible;
int m_contextLinesNumber; int m_contextLinesNumber;
bool m_ignoreWhitespaces; bool m_ignoreWhitespaces;
bool m_syncScrollBars; bool m_syncScrollBars;

View File

@@ -31,8 +31,6 @@
#include "diffeditor.h" #include "diffeditor.h"
#include "diffeditorconstants.h" #include "diffeditorconstants.h"
#include "diffeditorfactory.h" #include "diffeditorfactory.h"
#include "diffshoweditor.h"
#include "diffshoweditorfactory.h"
#include "sidebysidediffeditorwidget.h" #include "sidebysidediffeditorwidget.h"
#include <QFileDialog> #include <QFileDialog>
@@ -74,7 +72,6 @@ bool DiffEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
toolsContainer->addAction(diffCommand, Constants::G_TOOLS_DIFF); toolsContainer->addAction(diffCommand, Constants::G_TOOLS_DIFF);
addAutoReleasedObject(new DiffEditorFactory(this)); addAutoReleasedObject(new DiffEditorFactory(this));
addAutoReleasedObject(new DiffShowEditorFactory(this));
return true; return true;
} }

View File

@@ -1,176 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 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 "sidebysidediffeditorwidget.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"; }
};
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(SideBySideDiffEditorWidget *editorWidget)
: DiffEditor(editorWidget)
{
document()->setDisplayName(QCoreApplication::translate("DiffShowEditor",
Constants::DIFF_SHOW_EDITOR_DISPLAY_NAME));
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);
connect(TextEditorSettings::instance(), SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
m_diffShowWidget, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
connect(TextEditorSettings::instance(), SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
m_diffShowWidget->baseTextDocument(), SLOT(setFontSettings(TextEditor::FontSettings)));
m_diffShowWidget->setDisplaySettings(TextEditorSettings::displaySettings());
m_diffShowWidget->setCodeStyle(TextEditorSettings::codeStyle());
m_diffShowWidget->baseTextDocument()->setFontSettings(TextEditorSettings::fontSettings());
}
DiffShowEditor::~DiffShowEditor()
{
}
void DiffShowEditor::setDescription(const QString &description)
{
m_diffShowWidget->setPlainText(description);
}
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"

View File

@@ -1,73 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 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 TextEditor { class BaseTextEditorWidget; }
namespace DiffEditor {
class DIFFEDITOR_EXPORT DiffShowEditor : public DiffEditor
{
Q_OBJECT
public:
explicit DiffShowEditor(SideBySideDiffEditorWidget *editorWidget);
virtual ~DiffShowEditor();
public:
void setDescription(const QString &description);
// Core::IEditor
Core::Id id() const;
QWidget *toolBar();
private slots:
void setDescriptionVisible(bool visible);
private:
void updateEntryToolTip();
TextEditor::BaseTextEditorWidget *m_diffShowWidget;
QToolButton *m_toggleDescriptionButton;
};
} // namespace DiffEditor
#endif // DIFFEDITOR_H

View File

@@ -1,59 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 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 "diffeditorconstants.h"
#include "diffshoweditorfactory.h"
#include "diffshoweditor.h"
#include "sidebysidediffeditorwidget.h"
#include <QCoreApplication>
namespace DiffEditor {
namespace Internal {
DiffShowEditorFactory::DiffShowEditorFactory(QObject *parent)
: IEditorFactory(parent)
{
setId(Constants::DIFF_SHOW_EDITOR_ID);
setDisplayName(qApp->translate("DiffEditorFactory", Constants::DIFF_SHOW_EDITOR_DISPLAY_NAME));
setMimeTypes(QStringList() << QLatin1String(Constants::DIFF_EDITOR_MIMETYPE));
}
Core::IEditor *DiffShowEditorFactory::createEditor()
{
SideBySideDiffEditorWidget *editorWidget = new SideBySideDiffEditorWidget();
DiffEditorController *editorController = new DiffEditorController(editorWidget);
editorWidget->setDiffEditorController(editorController);
DiffShowEditor *editor = new DiffShowEditor(editorWidget);
return editor;
}
} // namespace Internal
} // namespace DiffEditor

View File

@@ -1,56 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 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 DIFFSHOWEDITORFACTORY_H
#define DIFFSHOWEDITORFACTORY_H
#include "diffeditor_global.h"
#include <QStringList>
#include <coreplugin/editormanager/ieditorfactory.h>
namespace DiffEditor {
namespace Internal {
class DiffShowEditorFactory : public Core::IEditorFactory
{
Q_OBJECT
public:
explicit DiffShowEditorFactory(QObject *parent);
Core::IEditor *createEditor();
};
} // namespace Internal
} // namespace DiffEditor
#endif // DIFFSHOWEDITORFACTORY_H

View File

@@ -60,7 +60,6 @@
#include <vcsbase/vcsbaseplugin.h> #include <vcsbase/vcsbaseplugin.h>
#include <diffeditor/diffeditor.h> #include <diffeditor/diffeditor.h>
#include <diffeditor/diffshoweditor.h>
#include <diffeditor/diffeditorconstants.h> #include <diffeditor/diffeditorconstants.h>
#include <QCoreApplication> #include <QCoreApplication>
@@ -375,11 +374,9 @@ void GitDiffHandler::slotShowDescriptionReceived(const QString &description)
{ {
if (m_editor.isNull()) if (m_editor.isNull())
return; return;
DiffEditor::DiffShowEditor *editor = qobject_cast<DiffEditor::DiffShowEditor *>(m_editor);
if (editor) { m_editor->setDescription(GitPlugin::instance()->gitClient()->
editor->setDescription(GitPlugin::instance()->gitClient()-> extendedShowDescription(m_workingDirectory, description));
extendedShowDescription(m_workingDirectory, description));
}
collectFilesList(QStringList() collectFilesList(QStringList()
<< m_requestedRevisionRange.begin.id << m_requestedRevisionRange.begin.id
@@ -1446,7 +1443,8 @@ void GitClient::show(const QString &source, const QString &id,
id, id,
source, source,
title, title,
DiffEditor::Constants::DIFF_SHOW_EDITOR_ID); DiffEditor::Constants::DIFF_EDITOR_ID);
diffEditor->setDescriptionEnabled(true);
} }
GitDiffHandler *handler = new GitDiffHandler(diffEditor, GitDiffHandler *handler = new GitDiffHandler(diffEditor,