~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to libs/widgets/common/thumbbardock.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
namespace Digikam
31
31
{
32
32
 
33
 
DragHandle::DragHandle(QDockWidget *parent)
 
33
DragHandle::DragHandle(QDockWidget* parent)
34
34
    : QWidget(),
35
35
      m_currentArea(Qt::LeftDockWidgetArea)
36
36
{
51
51
void DragHandle::paintEvent(QPaintEvent*)
52
52
{
53
53
    QPainter p(this);
54
 
    QStyle *style = m_parent->style();
 
54
    QStyle* style = m_parent->style();
55
55
 
56
56
    // The QStyleOptionToolBar contains every parameter needed to draw the
57
57
    // handle.
82
82
void DragHandle::dockLocationChanged(Qt::DockWidgetArea area)
83
83
{
84
84
    m_currentArea = area;
 
85
 
85
86
    // When the dock widget that contains this handle changes to a different
86
87
    // orientation, the DockWidgetVerticalTitleBar feature needs to be adjusted:
87
88
    // present when the thumbbar orientation is horizontal, absent when it is
99
100
QSize DragHandle::sizeHint() const
100
101
{
101
102
    // Size is the sum of the margin, frame width and the handle itself.
102
 
    QStyle *style = m_parent->style();
 
103
    QStyle* style = m_parent->style();
103
104
    int handleWidth = style->pixelMetric(QStyle::PM_ToolBarHandleExtent);
104
105
    int margin      = style->pixelMetric(QStyle::PM_ToolBarItemMargin) +
105
106
                      style->pixelMetric(QStyle::PM_ToolBarFrameWidth);
 
107
 
106
108
    if (m_currentArea == Qt::LeftDockWidgetArea || m_currentArea == Qt::RightDockWidgetArea)
107
109
    {
108
110
        return QSize(m_parent->width(), handleWidth + 2*margin);
120
122
 
121
123
// ----------------------------------------------------------------------------
122
124
 
123
 
ThumbBarDock::ThumbBarDock(QWidget *parent, Qt::WindowFlags flags)
124
 
            : QDockWidget(parent, flags), m_visible(SHOULD_BE_SHOWN)
 
125
ThumbBarDock::ThumbBarDock(QWidget* parent, Qt::WindowFlags flags)
 
126
    : QDockWidget(parent, flags), m_visible(SHOULD_BE_SHOWN)
125
127
{
126
128
    // Use a DragHandle as title bar widget.
127
129
    setTitleBarWidget(new DragHandle(this));
139
141
{
140
142
    // Measure orientation of the widget and adjust the child thumbbar to this
141
143
    // orientation and size.
142
 
    QMainWindow *parent = qobject_cast<QMainWindow*>(parentWidget());
 
144
    QMainWindow* parent = qobject_cast<QMainWindow*>(parentWidget());
143
145
    emit dockLocationChanged(parent->dockWidgetArea(this));
144
146
    //ThumbBarView *child = qobject_cast<ThumbBarView *>(widget());
145
147
    widget()->resize(size());
146
148
    update();
147
149
}
148
150
 
149
 
KToggleAction *ThumbBarDock::getToggleAction(QObject *parent, QString caption)
 
151
KToggleAction* ThumbBarDock::getToggleAction(QObject* parent, QString caption)
150
152
{
151
 
    KToggleAction *action = new KToggleAction(KIcon("view-choose"), caption, parent);
 
153
    KToggleAction* action = new KToggleAction(KIcon("view-choose"), caption, parent);
152
154
 
153
155
    // Default shortcut is Ctrl+T.
154
156
    action->setShortcut(KShortcut(Qt::CTRL+Qt::Key_T));
170
172
    // Set the visibility to what it should be or to what it was. Reset
171
173
    // SHOULD_BE_ values to their WAS_ values, to implement correct behavior
172
174
    // on subsequent calls.
173
 
    if      (m_visible == SHOULD_BE_SHOWN)  m_visible = WAS_SHOWN;
174
 
    else if (m_visible == SHOULD_BE_HIDDEN) m_visible = WAS_HIDDEN;
 
175
    if      (m_visible == SHOULD_BE_SHOWN)
 
176
    {
 
177
        m_visible = WAS_SHOWN;
 
178
    }
 
179
    else if (m_visible == SHOULD_BE_HIDDEN)
 
180
    {
 
181
        m_visible = WAS_HIDDEN;
 
182
    }
 
183
 
175
184
    setVisible(m_visible == WAS_SHOWN);
176
185
}
177
186
 
178
187
bool ThumbBarDock::shouldBeVisible()
179
188
{
180
189
    if ((m_visible == WAS_SHOWN) || (m_visible == SHOULD_BE_SHOWN))
 
190
    {
181
191
        return true;
 
192
    }
 
193
 
182
194
    return false;
183
195
}
184
196
 
185
197
void ThumbBarDock::setShouldBeVisible(bool status)
186
198
{
187
 
    if (status) m_visible = SHOULD_BE_SHOWN;
188
 
    else        m_visible = SHOULD_BE_HIDDEN;
 
199
    if (status)
 
200
    {
 
201
        m_visible = SHOULD_BE_SHOWN;
 
202
    }
 
203
    else
 
204
    {
 
205
        m_visible = SHOULD_BE_HIDDEN;
 
206
    }
189
207
}
190
208
 
191
209
void ThumbBarDock::slotDockLocationChanged(Qt::DockWidgetArea area)
192
210
{
193
211
    // Change orientation of child thumbbar when location has changed.
194
 
    ThumbBarView *child = qobject_cast<ThumbBarView *>(widget());
 
212
    ThumbBarView* child = qobject_cast<ThumbBarView*>(widget());
 
213
 
195
214
    if (!child)
 
215
    {
196
216
        return;
 
217
    }
 
218
 
197
219
    if ((area == Qt::LeftDockWidgetArea) || (area == Qt::RightDockWidgetArea))
198
220
    {
199
221
        child->setOrientation(Qt::Vertical);
206
228
 
207
229
void ThumbBarDock::showThumbBar(bool status)
208
230
{
209
 
    if (status) m_visible = WAS_SHOWN;
210
 
    else        m_visible = WAS_HIDDEN;
 
231
    if (status)
 
232
    {
 
233
        m_visible = WAS_SHOWN;
 
234
    }
 
235
    else
 
236
    {
 
237
        m_visible = WAS_HIDDEN;
 
238
    }
 
239
 
211
240
    setVisible(status);
212
241
}
213
242