Commit 794790e2 authored by Halla Rempt's avatar Halla Rempt
Browse files

History docker: Replace the menu popup with a dialog

This is both easier to find, and will work on Windows.
parent be6738b3
......@@ -7,6 +7,7 @@ set(kritahistorydocker_SOURCES
KisUndoView.h
KisUndoModel.h
KisUndoModel.cpp
DlgConfigureHistoryDock.cpp
)
add_library(kritahistorydocker MODULE ${kritahistorydocker_SOURCES})
......
/*
* Copyright (C) 2016 Boudewijn Rempt <boud@valdyas.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "DlgConfigureHistoryDock.h"
#include <QFormLayout>
#include <QCheckBox>
#include <QLabel>
#include <kis_double_parse_spin_box.h>
#include <kis_int_parse_spin_box.h>
DlgConfigureHistoryDock::DlgConfigureHistoryDock(KUndo2QStack *stack, QWidget *parent)
: KoDialog(parent)
, m_stack(stack)
{
setButtons(KoDialog::Close);
QWidget *page = new QWidget(this);
QFormLayout *form = new QFormLayout(page);
QCheckBox *chkCumulative = new QCheckBox(i18n("Enable Cumulative Undo"), page);
chkCumulative->setChecked(stack->useCumulativeUndoRedo());
connect(chkCumulative, SIGNAL(toggled(bool)), m_stack, SLOT(toggleCumulativeUndoRedo()));
form->addRow(chkCumulative, new QWidget(page));
QLabel *l = new QLabel(i18n("Start merging time"), page);
QDoubleSpinBox *s = new KisDoubleParseSpinBox(page);
s->setToolTip(i18nc("@info:tooltip", "The amount of time after a merged stroke before merging again"));
s->setRange(3,10);
s->setValue(m_stack->timeT1());
form->addRow(l, s);
s->setEnabled(chkCumulative->isChecked());
connect(chkCumulative, SIGNAL(toggled(bool)), s, SLOT(setEnabled(bool)));
connect(s, SIGNAL(valueChanged(double)), m_stack, SLOT(setStackT1(double)));
QLabel *l1 = new QLabel(i18n("Group time"));
QDoubleSpinBox *s1 = new KisDoubleParseSpinBox();
s1->setToolTip(i18nc("@info:tooltip", "The amount of time every stroke should be apart from its previous stroke to be classified in one group"));
s1->setRange(0.3,s->value());
s1->setValue(m_stack->timeT2());
form->addRow(l1, s1);
s1->setEnabled(chkCumulative->isChecked());
connect(chkCumulative, SIGNAL(toggled(bool)), s1, SLOT(setEnabled(bool)));
connect(s1, SIGNAL(valueChanged(double)), m_stack, SLOT(setStackT2(double)));
QLabel *l2 = new QLabel(i18n("Split Strokes"));
QSpinBox *s2 = new KisIntParseSpinBox();
s2->setToolTip(i18nc("@info:tooltip", "The number of last strokes which Krita should store separately"));
s2->setRange(1,m_stack->undoLimit());
s2->setValue(m_stack->strokesN());
form->addRow(l2, s2);
s2->setEnabled(chkCumulative->isChecked());
connect(chkCumulative, SIGNAL(toggled(bool)), s2, SLOT(setEnabled(bool)));
connect(s2,SIGNAL(valueChanged(int)),SLOT(setStackN(int)));
setMainWidget(page);
}
/*
* Copyright (C) 2016 Boudewijn Rempt <boud@valdyas.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef DLGCONFIGUREHISTORYDOCK_H
#define DLGCONFIGUREHISTORYDOCK_H
#include <KoDialog.h>
#include <QObject>
#include <QWidget>
#include <kundo2stack.h>
class DlgConfigureHistoryDock : public KoDialog
{
Q_OBJECT
public:
DlgConfigureHistoryDock(KUndo2QStack *stack, QWidget *parent = 0);
private:
KUndo2QStack *m_stack;
};
#endif // DLGCONFIGUREHISTORYDOCK_H
......@@ -20,13 +20,33 @@
#include "HistoryDock.h"
#include <KoDocumentResourceManager.h>
#include <kis_config.h>
#include <kis_icon_utils.h>
#include <QDebug>
#include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QSpacerItem>
#include <DlgConfigureHistoryDock.h>
HistoryDock::HistoryDock()
: QDockWidget()
, m_historyCanvas(0)
{
QWidget *page = new QWidget(this);
QVBoxLayout *vl = new QVBoxLayout(page);
m_undoView = new KisUndoView(this);
setWidget(m_undoView);
vl->addWidget(m_undoView);
QHBoxLayout *hl = new QHBoxLayout(page);
hl->addSpacerItem(new QSpacerItem(10, 1, QSizePolicy::Expanding, QSizePolicy::Fixed));
m_bnConfigure = new QToolButton(page);
m_bnConfigure->setIcon(KisIconUtils::loadIcon("configure"));
connect(m_bnConfigure, SIGNAL(clicked(bool)), SLOT(configure()));
hl->addWidget(m_bnConfigure);
vl->addItem(hl);
setWidget(page);
setWindowTitle(i18n("Undo History"));
}
......@@ -48,3 +68,8 @@ void HistoryDock::setCanvas(KoCanvasBase *canvas) {
m_undoView->setCanvas( myCanvas );
}
void HistoryDock::configure()
{
DlgConfigureHistoryDock dlg(m_undoView->stack(), this);
dlg.exec();
}
......@@ -20,6 +20,8 @@
#define _HISTORY_DOCK_H_
#include <QDockWidget>
#include <QToolButton>
#include "KisUndoView.h"
#include <KoCanvasObserverBase.h>
......@@ -42,9 +44,13 @@ public:
QString observerName() { return "HistoryDock"; }
virtual void setCanvas(KoCanvasBase *canvas);
virtual void unsetCanvas() { m_historyCanvas = 0; setEnabled(false); m_undoView->setStack(0); }
private Q_SLOTS:
void configure();
private:
KisUndoView* m_undoView;
KoCanvasBase* m_historyCanvas;
KisUndoView *m_undoView;
QToolButton *m_bnConfigure;
KoCanvasBase *m_historyCanvas;
};
......
......@@ -300,87 +300,29 @@ QIcon KisUndoView::cleanIcon() const
void KisUndoView::setCanvas(KisCanvas2 *canvas) {
d->model->setCanvas(canvas);
}
void KisUndoView::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::RightButton)
{
QMenu menu(this);
QAction* action1 = menu.addAction(KisIconUtils::loadIcon("link"),stack()->useCumulativeUndoRedo()?i18n("Disable Cumulative Undo"):i18n("Enable Cumulative Undo"));
connect(action1, SIGNAL(triggered()), this, SLOT(toggleCumulativeUndoRedo()));
QLabel *l = new QLabel(i18n("Start merging time"));
QDoubleSpinBox *s = new KisDoubleParseSpinBox();
s->setToolTip(i18nc("@info:tooltip", "The amount of time after a merged stroke before merging again"));
s->setRange(3,10);
s->setValue(stack()->timeT1());
QGridLayout *g = new QGridLayout();
g->addWidget(l);
g->addWidget(s);
QWidget *w = new QWidget();
w->setLayout(g);
w->setVisible(stack()->useCumulativeUndoRedo());
QWidgetAction* action2 = new QWidgetAction(s);
action2->setDefaultWidget(w);
connect(s,SIGNAL(valueChanged(double)),SLOT(setStackT1(double)));
QLabel *l1 = new QLabel(i18n("Group time"));
QDoubleSpinBox *s1 = new KisDoubleParseSpinBox();
s1->setToolTip(i18nc("@info:tooltip", "The amount of time every stroke should be apart from its previous stroke to be classified in one group"));
s1->setRange(0.3,s->value());
s1->setValue(stack()->timeT2());
QGridLayout *g1 = new QGridLayout();
g1->addWidget(l1);
g1->addWidget(s1);
QWidget *w1 = new QWidget();
w1->setLayout(g1);
w1->setVisible(stack()->useCumulativeUndoRedo());
QWidgetAction* action3 = new QWidgetAction(s1);
action3->setDefaultWidget(w1);
connect(s1,SIGNAL(valueChanged(double)),SLOT(setStackT2(double)));
QLabel *l2 = new QLabel(i18n("Split Strokes"));
QSpinBox *s2 = new KisIntParseSpinBox();
s2->setToolTip(i18nc("@info:tooltip", "The number of last strokes which Krita should store separately"));
s2->setRange(1,stack()->undoLimit());
s2->setValue(stack()->strokesN());
QGridLayout *g2 = new QGridLayout();
g1->addWidget(l2);
g1->addWidget(s2);
QWidget *w2 = new QWidget();
w2->setLayout(g2);
w2->setVisible(stack()->useCumulativeUndoRedo());
QWidgetAction* action4 = new QWidgetAction(s2);
action4->setDefaultWidget(w2);
connect(s2,SIGNAL(valueChanged(int)),SLOT(setStackN(int)));
menu.addAction(action2);
menu.addAction(action3);
menu.addAction(action4);
menu.exec(event->globalPos());
}
else{
QListView::mousePressEvent(event);
}
}
void KisUndoView::toggleCumulativeUndoRedo()
{
stack()->setUseCumulativeUndoRedo(!stack()->useCumulativeUndoRedo() );
KisConfig cfg;
cfg.setCumulativeUndoRedo(stack()->useCumulativeUndoRedo());
}
void KisUndoView::setStackT1(double value)
{
stack()->setTimeT1(value);
KisConfig cfg;
cfg.setStackT1(value);
}
void KisUndoView::setStackT2(double value)
{
stack()->setTimeT2(value);
KisConfig cfg;
cfg.setStackT2(value);
}
void KisUndoView::setStackN(int value)
{
stack()->setStrokesN(value);
......
......@@ -99,10 +99,7 @@ public:
void setCleanIcon(const QIcon &icon);
QIcon cleanIcon() const;
void mousePressEvent(QMouseEvent *event);
//my new imba function
void setCanvas(KisCanvas2* canvas);
public Q_SLOTS:
......
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