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 ) {
98 const int primaryScreen = 0;
99 const int screen = (widgetsScreen >= 0 && widgetsScreen < QGuiApplication::screens().size()) ? widgetsScreen : primaryScreen;
100 const int toolbuttonSize =
buttonSize(screen);
101 KConfigGroup cfg = KSharedConfig::openConfig()->group(
"KoToolBox");
102 d->
iconSize = cfg.readEntry(
"iconSize", toolbuttonSize);
113 setCompact(cfg.readEntry<
bool>(
"compact",
false));
147 QAction *toolQAction = actionCollection->
action(toolAction->
id());
150 qWarning() <<
"Toolbox is missing button for tool" << toolAction->
id();
153 (*button)->attachAction(toolQAction);
163 QString sectionToBeAddedTo;
164 const QString section = toolAction->
section();
165 if (section.contains(qApp->applicationName())) {
166 sectionToBeAddedTo =
"main";
167 }
else if (section.contains(
"main")) {
168 sectionToBeAddedTo =
"main";
169 }
else if (section.contains(
"dynamic")) {
170 sectionToBeAddedTo =
"dynamic";
172 sectionToBeAddedTo = section;
176 if (sectionWidget == 0) {
177 sectionWidget =
new Section(
this);
196 button->setHighlightColor();
203 warnWidgets <<
"KoToolBox::setActiveTool(" <<
id <<
"): no such button found";
212 if (code.startsWith(QLatin1String(
"flake/"))) {
216 if (code.endsWith( QLatin1String(
"/always"))) {
220 else if (code.isEmpty()) {
222 button->setEnabled( codes.count() != 0 );
225 button->setVisible( codes.contains(code) );
228 layout()->invalidate();
240 button->setEnabled(enabled);
246 QPainter painter(
this);
249 int halfSpacing = layout()->spacing();
250 if (halfSpacing > 0) {
253 for(
auto iterator = sections.begin(); iterator != sections.end(); ++iterator) {
259 QStyleOption styleoption;
260 styleoption.palette =
palette();
263 int y = section->y() - halfSpacing;
264 styleoption.state = QStyle::State_None;
265 styleoption.rect = QRect(section->x(), y-1, section->width(), 2);
267 style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &styleoption, &painter);
271 int x = section->x() - halfSpacing;
272 styleoption.state = QStyle::State_Horizontal;
273 styleoption.rect = QRect(x-1, section->y(), 2, section->height());
275 style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &styleoption, &painter);
277 int x = section->x() + section->width() + halfSpacing;
278 styleoption.state = QStyle::State_Horizontal;
279 styleoption.rect = QRect(x-1, section->y(), 2, section->height());
281 style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &styleoption, &painter);
290 QWidget::changeEvent(event);
291 if (event->type() == QEvent::PaletteChange) {
304 QTimer::singleShot(0,
this, SLOT(update()));
335 QAction* action = qobject_cast<QAction*>(sender());
342 action->setChecked(
true);
349 KConfigGroup cfg = KSharedConfig::openConfig()->group(
"KoToolBox");
350 cfg.writeEntry(
"iconSize",
iconSize);
363 QActionGroup *sizeGroup =
new QActionGroup(menu);
365 sizes << 12 << 14 << 16 << 22 << 32 << 48 << 64;
366 Q_FOREACH (
int i, sizes) {
369 action->setActionGroup(sizeGroup);
370 action->setCheckable(
true);
372 action->setChecked(
true);
383#include "moc_KoToolBoxScrollArea_p.cpp"
int iconSize(qreal width, qreal height)
A container for a set of QAction objects.
QAction * action(int index) const
virtual KisKActionCollection * actionCollection() const
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)
QString button(const QWheelEvent &ev)
int getScreenNumberForWidget(const QWidget *w)
rgba palette[MAX_PALETTE]