Commit b0dd4778 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Make an onion skins dialog a docker actually

parent 0bb88756
......@@ -27,7 +27,6 @@
#include "kis_action_manager.h"
#include "kis_image_animation_interface.h"
#include "kis_animation_player.h"
#include "kis_onion_skin_dialog.h"
#include "kis_time_range.h"
#include "kundo2command.h"
#include "kis_post_execution_undo_adapter.h"
......@@ -43,7 +42,7 @@ AnimationDocker::AnimationDocker()
: QDockWidget(i18n("Animation"))
, m_canvas(0)
, m_animationWidget(new Ui_WdgAnimation)
, m_onionSkinOptions(new KisOnionSkinDialog())
, m_mainWindow(0)
{
QWidget* mainWidget = new QWidget(this);
setWidget(mainWidget);
......@@ -194,6 +193,8 @@ void AnimationDocker::setMainWindow(KisViewManager *view)
actionManager->addAction("delete_keyframe", m_deleteKeyframeAction);
connect(view->mainWindow(), SIGNAL(themeChanged()), this, SLOT(slotUpdateIcons()));
m_mainWindow = view->mainWindow();
}
void AnimationDocker::slotAddBlankFrame()
......@@ -248,7 +249,12 @@ void AnimationDocker::slotUIFramerateChanged()
void AnimationDocker::slotOnionSkinOptions()
{
m_onionSkinOptions->show();
if (m_mainWindow) {
QDockWidget *docker = m_mainWindow->dockWidget("OnionSkinsDocker");
if (docker) {
docker->setVisible(!docker->isVisible());
}
}
}
void AnimationDocker::slotGlobalTimeChanged()
......
......@@ -28,7 +28,7 @@
class KisCanvas2;
class Ui_WdgAnimation;
class KisOnionSkinDialog;
class KisMainWindow;
class AnimationDocker : public QDockWidget, public KisMainwindowObserver {
Q_OBJECT
......@@ -75,8 +75,6 @@ private:
KisCanvas2 *m_canvas;
Ui_WdgAnimation *m_animationWidget;
KisOnionSkinDialog *m_onionSkinOptions;
KisAction *m_previousFrameAction;
KisAction *m_nextFrameAction;
......@@ -93,6 +91,7 @@ private:
KisAction *m_deleteKeyframeAction;
KisAction *m_lazyFrameAction;
KisMainWindow *m_mainWindow;
};
......
......@@ -19,6 +19,7 @@
#include "animation_dockers.h"
#include "animation_docker.h"
#include "timeline_docker.h"
#include "kis_onion_skin_dialog.h"
#include <kpluginfactory.h>
......@@ -91,11 +92,43 @@ public:
private:
};
class OnionSkinsDockerFactory : public KoDockFactoryBase {
public:
OnionSkinsDockerFactory()
{
}
virtual QString id() const
{
return QString( "OnionSkinsDocker" );
}
virtual Qt::DockWidgetArea defaultDockWidgetArea() const
{
return Qt::RightDockWidgetArea;
}
virtual QDockWidget *createDockWidget()
{
KisOnionSkinDialog *dockWidget = new KisOnionSkinDialog();
dockWidget->setObjectName(id());
return dockWidget;
}
DockPosition defaultDockPosition() const
{
return DockMinimized;
}
private:
};
AnimationDockersPlugin::AnimationDockersPlugin(QObject *parent, const QVariantList &)
: QObject(parent)
{
KoDockRegistry::instance()->add(new AnimationDockerFactory());
KoDockRegistry::instance()->add(new TimelineDockerFactory());
KoDockRegistry::instance()->add(new OnionSkinsDockerFactory());
}
AnimationDockersPlugin::~AnimationDockersPlugin()
......
......@@ -34,12 +34,15 @@
static const int MAX_SKIN_COUNT = 10;
KisOnionSkinDialog::KisOnionSkinDialog(QWidget *parent) :
QDialog(parent),
QDockWidget(i18n("Onion Skins"), parent),
ui(new Ui::KisOnionSkinDialog),
m_updatesCompressor(300, KisSignalCompressor::FIRST_ACTIVE)
{
QWidget* mainWidget = new QWidget(this);
setWidget(mainWidget);
KisImageConfig config;
ui->setupUi(this);
ui->setupUi(mainWidget);
ui->doubleTintFactor->setMinimum(0);
ui->doubleTintFactor->setMaximum(100);
......@@ -82,6 +85,20 @@ KisOnionSkinDialog::~KisOnionSkinDialog()
delete ui;
}
void KisOnionSkinDialog::setCanvas(KoCanvasBase *canvas)
{
Q_UNUSED(canvas);
}
void KisOnionSkinDialog::unsetCanvas()
{
}
void KisOnionSkinDialog::setMainWindow(KisViewManager *kisview)
{
Q_UNUSED(kisview);
}
void KisOnionSkinDialog::slotShowAdditionalSettings(bool value)
{
ui->lblPrevColor->setVisible(value);
......
......@@ -19,9 +19,9 @@
#ifndef KIS_ONION_SKIN_DIALOG_H
#define KIS_ONION_SKIN_DIALOG_H
#include <QDialog>
#include <QSlider>
#include <QDockWidget>
#include <kis_mainwindow_observer.h>
#include "kis_signal_compressor.h"
namespace Ui {
......@@ -30,7 +30,7 @@ class KisOnionSkinDialog;
class KisEqualizerWidget;
class KisOnionSkinDialog : public QDialog
class KisOnionSkinDialog : public QDockWidget, public KisMainwindowObserver
{
Q_OBJECT
......@@ -38,6 +38,11 @@ public:
explicit KisOnionSkinDialog(QWidget *parent = 0);
~KisOnionSkinDialog();
QString observerName() { return "OnionSkinsDocker"; }
virtual void setCanvas(KoCanvasBase *canvas);
virtual void unsetCanvas();
void setMainWindow(KisViewManager *kisview);
private:
Ui::KisOnionSkinDialog *ui;
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KisOnionSkinDialog</class>
<widget class="QDialog" name="KisOnionSkinDialog">
<widget class="QWidget" name="KisOnionSkinDialog">
<property name="geometry">
<rect>
<x>0</x>
......
......@@ -1758,6 +1758,12 @@ QList<QDockWidget*> KisMainWindow::dockWidgets() const
return d->dockWidgetsMap.values();
}
QDockWidget* KisMainWindow::dockWidget(const QString &id)
{
if (!d->dockWidgetsMap.contains(id)) return 0;
return d->dockWidgetsMap[id];
}
QList<KoCanvasObserverBase*> KisMainWindow::canvasObservers() const
{
QList<KoCanvasObserverBase*> observers;
......
......@@ -124,6 +124,8 @@ public:
/// Return the list of dock widgets belonging to this main window.
QList<QDockWidget*> dockWidgets() const;
QDockWidget* dockWidget(const QString &id);
QList<KoCanvasObserverBase*> canvasObservers() const;
/**
......
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