blob: f666bbf2edf6bdd752892bf3e7984a0d06900057 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2008-08-20
* Description : Image editor interface used by editor tools.
*
* Copyright (C) 2008-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program 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 General Public License for more details.
*
* ============================================================ */
// TQt includes.
#include <tqwidget.h>
// Local includes.
#include "sidebar.h"
#include "canvas.h"
#include "statusprogressbar.h"
#include "editortool.h"
#include "editortoolsettings.h"
#include "editorstackview.h"
#include "editorwindow.h"
#include "editortooliface.h"
#include "editortooliface.moc"
namespace Digikam
{
class EditorToolIfacePriv
{
public:
EditorToolIfacePriv()
{
prevTab = 0;
editor = 0;
tool = 0;
}
TQWidget *prevTab;
EditorTool *tool;
EditorWindow *editor;
};
EditorToolIface* EditorToolIface::m_iface = 0;
EditorToolIface* EditorToolIface::editorToolIface()
{
return m_iface;
}
EditorToolIface::EditorToolIface(EditorWindow *editor)
: TQObject()
{
d = new EditorToolIfacePriv;
d->editor = editor;
m_iface = this;
}
EditorToolIface::~EditorToolIface()
{
delete d;
if (m_iface == this)
m_iface = 0;
}
EditorTool* EditorToolIface::currentTool() const
{
return d->tool;
}
void EditorToolIface::loadTool(EditorTool* tool)
{
if (d->tool) unLoadTool();
d->tool = tool;
d->editor->editorStackView()->setToolView(d->tool->toolView());
d->editor->editorStackView()->setViewMode(EditorStackView::ToolViewMode);
d->prevTab = d->editor->rightSideBar()->getActiveTab();
d->editor->rightSideBar()->appendTab(d->tool->toolSettings(), d->tool->toolIcon(), d->tool->toolName());
d->editor->rightSideBar()->setActiveTab(d->tool->toolSettings());
d->editor->toggleActions(false);
// If editor tool has zoomable preview, switch on zoom actions.
if (d->editor->editorStackView()->previewWidget())
d->editor->toggleZoomActions(true);
}
void EditorToolIface::unLoadTool()
{
if (!d->tool) return;
d->editor->editorStackView()->setViewMode(EditorStackView::CanvasMode);
d->editor->editorStackView()->setToolView(0);
d->editor->rightSideBar()->deleteTab(d->tool->toolSettings());
d->editor->rightSideBar()->setActiveTab(d->prevTab);
d->editor->toggleActions(true);
// To restore canvas zoom level in zoom combobox.
if (!d->editor->editorStackView()->canvas()->fitToWindow())
d->editor->editorStackView()->setZoomFactor(d->editor->editorStackView()->canvas()->zoomFactor());
delete d->tool;
d->tool = 0;
}
void EditorToolIface::setToolStartProgress(const TQString& toolName)
{
d->editor->setToolStartProgress(toolName);
if (d->editor->editorStackView()->previewWidget())
d->editor->toggleZoomActions(false);
}
void EditorToolIface::setToolProgress(int progress)
{
d->editor->setToolProgress(progress);
}
void EditorToolIface::setToolStopProgress()
{
d->editor->setToolStopProgress();
if (d->editor->editorStackView()->previewWidget())
d->editor->toggleZoomActions(true);
}
void EditorToolIface::slotToolAborted()
{
EditorToolThreaded *tool = dynamic_cast<EditorToolThreaded*>(d->tool);
if (tool) tool->slotAbort();
}
} // namespace Digikam
|