15#include <QButtonGroup>
17#include <QStyleOption>
18#include <QActionGroup>
21#include <QApplication>
28#include <klocalizedstring.h>
30#include <kconfiggroup.h>
31#include <ksharedconfig.h>
39#define BUTTON_MARGIN 10
45 QRect rc = QGuiApplication::screens().at(screen)->availableGeometry();
46 if (rc.width() <= 1024) {
49 else if (rc.width() <= 1377) {
52 else if (rc.width() <= 1920 ) {
99 const int primaryScreen = 0;
100 const int screen = (widgetsScreen >= 0 && widgetsScreen < QGuiApplication::screens().size()) ? widgetsScreen : primaryScreen;
101 const int toolbuttonSize =
buttonSize(screen);
102 KConfigGroup cfg = KSharedConfig::openConfig()->group(
"KoToolBox");
103 d->
iconSize = cfg.readEntry(
"iconSize", toolbuttonSize);
105 setCompact(cfg.readEntry<
bool>(
"compact",
false));
148 QAction *toolQAction = actionCollection->
action(toolAction->
id());
151 qWarning() <<
"Toolbox is missing button for tool" << toolAction->
id();
154 (*button)->attachAction(toolQAction);
164 QString sectionToBeAddedTo;
165 const QString section = toolAction->
section();
166 if (section.contains(qApp->applicationName())) {
167 sectionToBeAddedTo =
"main";
168 }
else if (section.contains(
"main")) {
169 sectionToBeAddedTo =
"main";
170 }
else if (section.contains(
"dynamic")) {
171 sectionToBeAddedTo =
"dynamic";
173 sectionToBeAddedTo = section;
177 if (sectionWidget == 0) {
178 sectionWidget =
new Section(
this);
198 button->setHighlightColor();
205 warnWidgets <<
"KoToolBox::setActiveTool(" <<
id <<
"): no such button found";
214 if (code.startsWith(QLatin1String(
"flake/"))) {
218 if (code.endsWith( QLatin1String(
"/always"))) {
222 else if (code.isEmpty()) {
224 button->setEnabled( codes.count() != 0 );
227 button->setVisible( codes.contains(code) );
231 KConfigGroup cfg = KSharedConfig::openConfig()->group(
"KoToolBox");
235 if (disabledTools.isEmpty()) {
236 layout()->invalidate();
251 button->setEnabled(enabled);
257 QPainter painter(
this);
260 int halfSpacing = layout()->spacing();
261 if (halfSpacing > 0) {
264 for(
auto iterator = sections.begin(); iterator != sections.end(); ++iterator) {
270 QStyleOption styleoption;
271 styleoption.palette = palette();
274 int y = section->y() - halfSpacing;
275 styleoption.state = QStyle::State_None;
276 styleoption.rect = QRect(section->x(), y-1, section->width(), 2);
278 style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &styleoption, &painter);
282 int x = section->x() - halfSpacing;
283 styleoption.state = QStyle::State_Horizontal;
284 styleoption.rect = QRect(x-1, section->y(), 2, section->height());
286 style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &styleoption, &painter);
288 int x = section->x() + section->width() + halfSpacing;
289 styleoption.state = QStyle::State_Horizontal;
290 styleoption.rect = QRect(x-1, section->y(), 2, section->height());
292 style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &styleoption, &painter);
301 QWidget::changeEvent(event);
302 if (event->type() == QEvent::PaletteChange) {
315 QTimer::singleShot(0,
this, SLOT(update()));
346 QAction* action = qobject_cast<QAction*>(sender());
353 action->setChecked(
true);
360 KConfigGroup cfg = KSharedConfig::openConfig()->group(
"KoToolBox");
361 cfg.writeEntry(
"iconSize",
iconSize);
374 QActionGroup *sizeGroup =
new QActionGroup(menu);
376 sizes << 12 << 14 << 16 << 22 << 32 << 48 << 64;
377 Q_FOREACH (
int i, sizes) {
380 action->setActionGroup(sizeGroup);
381 action->setCheckable(
true);
383 action->setChecked(
true);
401 layout()->invalidate();
407 Q_FOREACH (QString name, names) {
411 b->setEnabled(
false);
412 b->setVisible(
false);
416 layout()->invalidate();
420#include "moc_KoToolBoxScrollArea_p.cpp"
QList< QString > QStringList
int iconSize(qreal width, qreal height)
A container for a set of QAction objects.
QAction * action(int index) const
KoToolManager * toolManager() const
virtual KisKActionCollection * actionCollection() const
QPointer< KoToolManager > toolManager
virtual bool isShapeEditable(bool recursive=true) const
checks recursively if the shape or one of its parents is not visible or locked
bool isVisible(bool recursive=true) const
void addButton(QAbstractButton *button, int priority)
void setButtonSize(QSize size)
Separators separators() const
void setOrientation(Qt::Orientation orientation)
void setName(const QString &name)
#define KIS_SAFE_ASSERT_RECOVER(cond)
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
QString button(const QWheelEvent &ev)
int getScreenNumberForWidget(const QWidget *w)