forked from qt-creator/qt-creator
Git: add reload button for 'git blame' and 'git log' windows
Change-Id: I64685e779bed91d41e38bdc1454571dbbcd7f177 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
#include <diffeditor/diffeditorconstants.h>
|
||||
#include <diffeditor/diffeditorcontroller.h>
|
||||
#include <diffeditor/diffutils.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QCoreApplication>
|
||||
@@ -372,6 +373,8 @@ public:
|
||||
mapSetting(addToggleButton("-w", tr("Ignore Whitespace"),
|
||||
tr("Ignore whitespace only changes.")),
|
||||
settings.boolPointer(GitSettings::ignoreSpaceChangesInBlameKey));
|
||||
|
||||
addButton(tr("Reload"), Utils::Icons::RELOAD.icon());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -402,6 +405,8 @@ public:
|
||||
QAction *graphButton = addToggleButton(graphArguments, tr("Graph"),
|
||||
tr("Show textual graph log."));
|
||||
mapSetting(graphButton, settings.boolPointer(GitSettings::graphLogKey));
|
||||
|
||||
addButton(tr("Reload"), Utils::Icons::RELOAD.icon());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -132,6 +132,14 @@ void VcsBaseEditorConfig::setBaseArguments(const QStringList &b)
|
||||
d->m_baseArguments = b;
|
||||
}
|
||||
|
||||
QAction *VcsBaseEditorConfig::addButton(const QString &label, const QIcon &icon)
|
||||
{
|
||||
auto action = new QAction(icon, label, d->m_toolBar);
|
||||
connect(action, &QAction::triggered, this, &VcsBaseEditorConfig::argumentsChanged);
|
||||
addAction(action);
|
||||
return action;
|
||||
}
|
||||
|
||||
QStringList VcsBaseEditorConfig::arguments() const
|
||||
{
|
||||
// Compile effective arguments
|
||||
@@ -156,9 +164,7 @@ QAction *VcsBaseEditorConfig::addToggleButton(const QStringList &options,
|
||||
action->setToolTip(tooltip);
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::toggled, this, &VcsBaseEditorConfig::argumentsChanged);
|
||||
const QList<QAction *> actions = d->m_toolBar->actions();
|
||||
// Insert the action before line/column and split actions.
|
||||
d->m_toolBar->insertAction(actions.at(qMax(actions.count() - 2, 0)), action);
|
||||
addAction(action);
|
||||
d->m_optionMappings.append(OptionMapping(options, action));
|
||||
return action;
|
||||
}
|
||||
@@ -293,4 +299,11 @@ void VcsBaseEditorConfig::updateMappedSettings()
|
||||
}
|
||||
}
|
||||
|
||||
void VcsBaseEditorConfig::addAction(QAction *action)
|
||||
{
|
||||
const QList<QAction *> actions = d->m_toolBar->actions();
|
||||
// Insert the action before line/column and split actions.
|
||||
d->m_toolBar->insertAction(actions.at(qMax(actions.count() - 2, 0)), action);
|
||||
}
|
||||
|
||||
} // namespace VcsBase
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
QStringList baseArguments() const;
|
||||
void setBaseArguments(const QStringList &);
|
||||
|
||||
QAction *addButton(const QString &label, const QIcon &icon);
|
||||
QAction *addToggleButton(const QString &option, const QString &label,
|
||||
const QString &tooltip = QString());
|
||||
QAction *addToggleButton(const QStringList &options, const QString &label,
|
||||
@@ -102,6 +103,8 @@ protected:
|
||||
void updateMappedSettings();
|
||||
|
||||
private:
|
||||
void addAction(QAction *action);
|
||||
|
||||
friend class Internal::VcsBaseEditorConfigPrivate;
|
||||
Internal::VcsBaseEditorConfigPrivate *const d;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user