Git/VCS: Use spinning progress indicator for log view

Show a spinning progress indicator instead of the "Waiting for data"
text for e.g. the git log view and other commands that use
VcsBaseEditor.

Change-Id: Ie4c73f85397f8809bda6bb276140eb695d96174f
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Eike Ziller
2015-01-16 16:06:16 +01:00
parent 8c3e68832e
commit 4c63deae5c
4 changed files with 30 additions and 6 deletions

View File

@@ -727,7 +727,6 @@ const char *GitClient::stashNamePrefix = "stash@{";
GitClient::GitClient(GitSettings *settings) : GitClient::GitClient(GitSettings *settings) :
m_cachedGitVersion(0), m_cachedGitVersion(0),
m_msgWait(tr("Waiting for data...")),
m_settings(settings), m_settings(settings),
m_disableEditor(false) m_disableEditor(false)
{ {
@@ -797,7 +796,7 @@ VcsBaseEditorWidget *GitClient::findExistingVCSEditor(const char *registerDynami
// Exists already // Exists already
EditorManager::activateEditor(outputEditor); EditorManager::activateEditor(outputEditor);
outputEditor->document()->setContents(m_msgWait.toUtf8()); outputEditor->document()->setContents(QByteArray()); // clear
rc = VcsBaseEditor::getVcsBaseEditor(outputEditor); rc = VcsBaseEditor::getVcsBaseEditor(outputEditor);
return rc; return rc;
@@ -926,8 +925,7 @@ VcsBaseEditorWidget *GitClient::createVcsEditor(
QTC_CHECK(!findExistingVCSEditor(registerDynamicProperty, dynamicPropertyValue)); QTC_CHECK(!findExistingVCSEditor(registerDynamicProperty, dynamicPropertyValue));
// Create new, set wait message, set up with source and codec // Create new, set wait message, set up with source and codec
IEditor *outputEditor = EditorManager::openEditorWithContents(id, &title, IEditor *outputEditor = EditorManager::openEditorWithContents(id, &title);
m_msgWait.toUtf8());
outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue); outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue);
rc = VcsBaseEditor::getVcsBaseEditor(outputEditor); rc = VcsBaseEditor::getVcsBaseEditor(outputEditor);
connect(rc, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)), connect(rc, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),

View File

@@ -435,7 +435,6 @@ private:
mutable Utils::FileName m_gitVersionForBinary; mutable Utils::FileName m_gitVersionForBinary;
mutable unsigned m_cachedGitVersion; mutable unsigned m_cachedGitVersion;
const QString m_msgWait;
GitSettings *m_settings; GitSettings *m_settings;
QString m_gitQtcEditor; QString m_gitQtcEditor;
QMap<QString, StashInfo> m_stashInfo; QMap<QString, StashInfo> m_stashInfo;

View File

@@ -46,6 +46,7 @@
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <texteditor/textdocument.h> #include <texteditor/textdocument.h>
#include <texteditor/textdocumentlayout.h> #include <texteditor/textdocumentlayout.h>
#include <utils/progressindicator.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QDebug> #include <QDebug>
@@ -573,6 +574,7 @@ public:
QPointer<VcsCommand> m_command; QPointer<VcsCommand> m_command;
QObject *m_describeReceiver; QObject *m_describeReceiver;
const char *m_describeSlot; const char *m_describeSlot;
Utils::ProgressIndicator *m_progressIndicator;
private: private:
QComboBox *m_entriesComboBox; QComboBox *m_entriesComboBox;
@@ -589,6 +591,7 @@ VcsBaseEditorWidgetPrivate::VcsBaseEditorWidgetPrivate(VcsBaseEditorWidget *edit
m_mouseDragging(false), m_mouseDragging(false),
m_describeReceiver(0), m_describeReceiver(0),
m_describeSlot(0), m_describeSlot(0),
m_progressIndicator(0),
m_entriesComboBox(0) m_entriesComboBox(0)
{ {
m_textCursorHandlers.append(new ChangeTextCursorHandler(editorWidget)); m_textCursorHandlers.append(new ChangeTextCursorHandler(editorWidget));
@@ -1352,9 +1355,18 @@ VcsBaseEditorParameterWidget *VcsBaseEditorWidget::configurationWidget() const
void VcsBaseEditorWidget::setCommand(VcsCommand *command) void VcsBaseEditorWidget::setCommand(VcsCommand *command)
{ {
if (d->m_command) if (d->m_command) {
d->m_command->abort(); d->m_command->abort();
hideProgressIndicator();
}
d->m_command = command; d->m_command = command;
if (d->m_command) {
d->m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicator::Large);
d->m_progressIndicator->attachToWidget(this);
connect(d->m_command, &VcsCommand::finished,
this, &VcsBaseEditorWidget::hideProgressIndicator);
QTimer::singleShot(100, this, SLOT(showProgressIndicator()));
}
} }
// Find the complete file from a diff relative specification. // Find the complete file from a diff relative specification.
@@ -1439,6 +1451,19 @@ void VcsBaseEditorWidget::slotPaste()
} }
} }
void VcsBaseEditorWidget::showProgressIndicator()
{
if (!d->m_progressIndicator) // already stopped and deleted
return;
d->m_progressIndicator->show();
}
void VcsBaseEditorWidget::hideProgressIndicator()
{
delete d->m_progressIndicator;
d->m_progressIndicator = 0;
}
bool VcsBaseEditorWidget::canApplyDiffChunk(const DiffChunk &dc) const bool VcsBaseEditorWidget::canApplyDiffChunk(const DiffChunk &dc) const
{ {
if (!dc.isValid()) if (!dc.isValid())

View File

@@ -242,6 +242,8 @@ private slots:
void slotAnnotateRevision(); void slotAnnotateRevision();
void slotApplyDiffChunk(); void slotApplyDiffChunk();
void slotPaste(); void slotPaste();
void showProgressIndicator();
void hideProgressIndicator();
protected: protected:
/* A helper that can be used to locate a file in a diff in case it /* A helper that can be used to locate a file in a diff in case it