Commit 6795d4f1 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add shortcut to switch between the current and the previous preset

BUG:311352

The default shortcut is / (slash).
parent e3826a2c
......@@ -216,6 +216,11 @@ KisPaintopBox::KisPaintopBox(KisView2 * view, QWidget *parent, const char * name
action->setShortcut(KShortcut(Qt::Key_Left));
connect(action, SIGNAL(triggered()), this, SLOT(slotPreviousFavoritePreset()));
action = new KAction(i18n("Switch to Previous Preset"), this);
view->actionCollection()->addAction("previous_preset", action);
action->setShortcut(KShortcut(Qt::Key_Slash));
connect(action, SIGNAL(triggered()), this, SLOT(slotSwitchToPreviousPreset()));
QWidget* mirrorActions = new QWidget(this);
QHBoxLayout* mirrorLayout = new QHBoxLayout(mirrorActions);
mirrorLayout->addWidget(hMirrorButton);
......@@ -334,8 +339,11 @@ KoID KisPaintopBox::currentPaintop()
void KisPaintopBox::setCurrentPaintop(const KoID& paintop, KisPaintOpPresetSP preset)
{
if(m_activePreset) {
if(m_optionWidget) {
if (m_activePreset) {
m_previousPreset = m_activePreset->clone();
if (m_optionWidget) {
m_optionWidget->writeConfiguration(const_cast<KisPaintOpSettings*>(m_activePreset->settings().data()));
m_optionWidget->disconnect(this);
m_optionWidget->hide();
......@@ -380,7 +388,6 @@ void KisPaintopBox::setCurrentPaintop(const KoID& paintop, KisPaintOpPresetSP pr
}
m_activePreset = preset;
emit signalPaintopChanged(preset);
}
KoID KisPaintopBox::defaultPaintOp()
......@@ -782,3 +789,10 @@ void KisPaintopBox::slotNextFavoritePreset()
i++;
}
}
void KisPaintopBox::slotSwitchToPreviousPreset()
{
if (m_previousPreset) {
setCurrentPaintop(m_previousPreset->paintOp(), m_previousPreset);
}
}
......@@ -91,9 +91,6 @@ public:
QPixmap paintopPixmap(const KoID& paintop);
~KisPaintopBox();
signals:
void signalPaintopChanged(KisPaintOpPresetSP paintop);
public slots:
void slotColorSpaceChanged(const KoColorSpace* colorSpace);
void slotInputDeviceChanged(const KoInputDevice & inputDevice);
......@@ -128,6 +125,7 @@ private slots:
void slotOpacityChanged(qreal);
void slotPreviousFavoritePreset();
void slotNextFavoritePreset();
void slotSwitchToPreviousPreset();
private:
KisCanvasResourceProvider* m_resourceProvider;
......@@ -148,6 +146,7 @@ private:
QMap<KoID,KisPaintOpSettingsWidget*> m_paintopOptionWidgets;
KisPaintOpPresetSP m_activePreset;
KisPaintOpPresetSP m_previousPreset;
QString m_prevCompositeOpID;
QString m_currCompositeOpID;
KisNodeSP m_previousNode;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment