cyrille / braindump

Braindump is a tool to dump and organize the content of your brain (ideas, drawings, images, texts...) to your computer.

Clone this repository (size: 742.8 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/cyrille/braindump/
commit 458: 478d373c7d75
parent 457: 0ba7a9ddf219
branch: flake-2.1
update the ToolBox
Cyrille Berger
3 months ago

Changed (Δ109 bytes):

raw changeset »

src/import/ToolBox.cpp (18 lines added, 19 lines removed)

src/import/ToolBoxFactory.cpp (1 lines added, 1 lines removed)

src/import/ToolBox_p.h (4 lines added, 7 lines removed)

Up to file-list src/import/ToolBox.cpp:

1
1
/*
2
 * Copyright (c) 2005-2008 Thomas Zander <zander@kde.org>
2
 * Copyright (c) 2005-2009 Thomas Zander <zander@kde.org>
3
3
 *
4
4
 * This library is free software; you can redistribute it and/or
5
5
 * modify it under the terms of the GNU Library General Public
34
34
#include <QRect>
35
35
36
36
#include "math.h"
37
namespace {
37
38
38
class SectionLayout : public QLayout
39
39
{
40
40
public:
@@ -153,13 +153,14 @@ private:
153
153
    QString m_name;
154
154
};
155
155
156
// Priorities for a specific columnwidth of a child depending on the width of the parent.
157
static const int rowPriorities[][5] = {
158
    { 1, 1, 1, 1, 1 },
159
    { 2, 1, 1, 1, 1 },
160
    { 3, 2, 1, 1, 1 },
161
    { 2, 4, 1, 1, 1 },
162
    { 3, 2, 4, 5, 1 }
156
// Priorities for a specific columnwidth for section depending on the width of the docker.
157
static const int rowPriorities[][6] = {
158
    { 1, 1, 1, 1, 1 }, // values used when the docker has 1 column
159
    { 2, 1, 1, 1, 1 }, // values used when the docker has 2 columns
160
    { 3, 2, 1, 1, 1 }, // 3
161
    { 2, 4, 1, 1, 1 }, // 4
162
    { 5, 3, 2, 4, 1 }, // 5
163
    { 6, 3, 2, 4, 1 }  // 6
163
164
};
164
165
165
166
class ToolBoxLayout : public QLayout
@@ -235,7 +236,7 @@ public:
235
236
            return 0;
236
237
        QSize iconSize = static_cast<Section*> (m_sections[0]->widget())->iconSize();
237
238
        const int maxColumns = qMax(1, width / iconSize.width());
238
        const int prioIndex = qMin(5, maxColumns) - 1;
239
        const int prioIndex = qMin(6, maxColumns) - 1;
239
240
        // kDebug() << "tryPlaceItems w:" << width << "prioIndex:" << prioIndex << "max:" << maxColumns;
240
241
241
242
        int x = 0;
@@ -277,8 +278,6 @@ public:
277
278
                }
278
279
279
280
                preferredColumnWidth = suggestedColumnWidth;
280
                if (rows > 2 && rows < colsLeft) // then its pretty wide, wait for something better...
281
                    continue;
282
281
                break;
283
282
            }
284
283
            // kDebug() << " + preferredColumnWidth" << preferredColumnWidth;
@@ -308,7 +307,7 @@ public:
308
307
private:
309
308
    QList <QWidgetItem*> m_sections;
310
309
};
311
}
310
312
311
class ToolBox::Private
313
312
{
314
313
public:
@@ -348,8 +347,8 @@ ToolBox::ToolBox(KoCanvasController *can
348
347
    // Update visibility of buttons
349
348
    setButtonsVisible(canvas, QList<QString>());
350
349
351
    connect(KoToolManager::instance(), SIGNAL(changedTool(const KoCanvasController*, int)),
352
            this, SLOT(setActiveTool(const KoCanvasController*, int)));
350
    connect(KoToolManager::instance(), SIGNAL(changedTool(KoCanvasController*, int)),
351
            this, SLOT(setActiveTool(KoCanvasController*, int)));
353
352
    connect(KoToolManager::instance(), SIGNAL(currentLayerChanged(const KoCanvasController*,const KoShapeLayer*)),
354
353
            this, SLOT(setCurrentLayer(const KoCanvasController*,const KoShapeLayer*)));
355
354
    connect(KoToolManager::instance(), SIGNAL(toolCodesSelected(const KoCanvasController*, QList<QString>)),
@@ -379,7 +378,7 @@ void ToolBox::addButton(QToolButton *but
379
378
        d->buttonGroup->addButton(button, buttonGroupId);
380
379
}
381
380
382
void ToolBox::setActiveTool(const KoCanvasController *canvas, int id)
381
void ToolBox::setActiveTool(KoCanvasController *canvas, int id)
383
382
{
384
383
    if (canvas->canvas() != d->canvas)
385
384
        return;
@@ -387,7 +386,7 @@ void ToolBox::setActiveTool(const KoCanv
387
386
    if (button)
388
387
        button->setChecked(true);
389
388
    else
390
        kWarning(30004) << "KoToolBox::setActiveTool(" << id << "): no such button found\n";
389
        kWarning(30004) << "ToolBox::setActiveTool(" << id << "): no such button found";
391
390
}
392
391
393
392
void ToolBox::setButtonsVisible(const KoCanvasController *canvas, const QList<QString> &codes)
@@ -475,14 +474,14 @@ void ToolBox::paintEvent(QPaintEvent *)
475
474
    painter.end();
476
475
}
477
476
478
KoToolBoxDocker::KoToolBoxDocker(ToolBox *toolBox)
477
ToolBoxDocker::ToolBoxDocker(ToolBox *toolBox)
479
478
    : m_toolBox(toolBox)
480
479
{
481
480
    setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
482
481
    setWidget(toolBox);
483
482
}
484
483
485
void KoToolBoxDocker::setCanvas(KoCanvasBase *canvas)
484
void ToolBoxDocker::setCanvas(KoCanvasBase *canvas)
486
485
{
487
486
    m_toolBox->setCanvas(canvas);
488
487
}

Up to file-list src/import/ToolBoxFactory.cpp:

@@ -58,7 +58,7 @@ KoDockFactory::DockPosition ToolBoxFacto
58
58
QDockWidget* ToolBoxFactory::createDockWidget()
59
59
{
60
60
    ToolBox *box = new ToolBox(d->canvas);
61
    KoToolBoxDocker *docker = new KoToolBoxDocker(box);
61
    ToolBoxDocker *docker = new ToolBoxDocker(box);
62
62
    docker->setWindowTitle(d->appName);
63
63
    docker->setObjectName("ToolBox_"+ d->appName);
64
64

Up to file-list src/import/ToolBox_p.h:

27
27
#include <QtCore/QHash>
28
28
#include <QtGui/QDockWidget>
29
29
30
class QButtonGroup;
31
class QBoxLayout;
32
30
class QToolButton;
33
class ToolArea;
34
31
class KoCanvasController;
35
32
class KoCanvasBase;
36
33
class KoShapeLayer;
37
34
38
35
/**
39
 * KoToolBox is a dock widget that can order tools according to type and
36
 * ToolBox is a dock widget that can order tools according to type and
40
37
 * priority.
41
38
 *
42
39
 * The ToolBox is a container for tool buttons which are themselves
@@ -78,7 +75,7 @@ public slots:
78
75
     * @param canvas the currently active canvas.
79
76
     * @param id an id to identify the button to activate.
80
77
     */
81
    void setActiveTool(const KoCanvasController *canvas, int id);
78
    void setActiveTool(KoCanvasController *canvas, int id);
82
79
83
80
    /**
84
81
     * Show only the dynamic buttons that have a code from parameter codes.
@@ -104,10 +101,10 @@ private:
104
101
    Private * const d;
105
102
};
106
103
107
class KoToolBoxDocker : public QDockWidget, public KoCanvasObserver
104
class ToolBoxDocker : public QDockWidget, public KoCanvasObserver
108
105
{
109
106
public:
110
    KoToolBoxDocker(ToolBox *toolBox);
107
    ToolBoxDocker(ToolBox *toolBox);
111
108
112
109
    /// reimplemented from KoCanvasObserver
113
110
    virtual void setCanvas(KoCanvasBase *canvas);