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);
146 QAction *toolQAction = actionCollection->
action(toolAction->
id());
149 qWarning() <<
"Toolbox is missing button for tool" << toolAction->
id();
152 (*button)->attachAction(toolQAction);
162 QString sectionToBeAddedTo;
163 const QString section = toolAction->
section();
164 if (section.contains(qApp->applicationName())) {
165 sectionToBeAddedTo =
"main";
166 }
else if (section.contains(
"main")) {
167 sectionToBeAddedTo =
"main";
168 }
else if (section.contains(
"dynamic")) {
169 sectionToBeAddedTo =
"dynamic";
171 sectionToBeAddedTo = section;
175 if (sectionWidget == 0) {
176 sectionWidget =
new Section(
this);
195 button->setHighlightColor();
202 warnWidgets <<
"KoToolBox::setActiveTool(" <<
id <<
"): no such button found";
211 if (code.startsWith(QLatin1String(
"flake/"))) {
215 if (code.endsWith( QLatin1String(
"/always"))) {
219 else if (code.isEmpty()) {
221 button->setEnabled( codes.count() != 0 );
224 button->setVisible( codes.contains(code) );
227 layout()->invalidate();
239 button->setEnabled(enabled);
245 QPainter painter(
this);
249 int halfSpacing = layout()->spacing();
250 if (halfSpacing > 0) {
253 while(iterator != sections.end()) {
255 QStyleOption styleoption;
256 styleoption.palette =
palette();
259 int y = section->y() - halfSpacing;
260 styleoption.state = QStyle::State_None;
261 styleoption.rect = QRect(section->x(), y-1, section->width(), 2);
263 style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &styleoption, &painter);
267 int x = section->x() - halfSpacing;
268 styleoption.state = QStyle::State_Horizontal;
269 styleoption.rect = QRect(x-1, section->y(), 2, section->height());
271 style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &styleoption, &painter);
273 int x = section->x() + section->width() + halfSpacing;
274 styleoption.state = QStyle::State_Horizontal;
275 styleoption.rect = QRect(x-1, section->y(), 2, section->height());
277 style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &styleoption, &painter);
288 QWidget::changeEvent(event);
289 if (event->type() == QEvent::PaletteChange) {
303 QTimer::singleShot(0,
this, SLOT(update()));
324 QAction* action = qobject_cast<QAction*>(sender());
331 action->setChecked(
true);
338 KConfigGroup cfg = KSharedConfig::openConfig()->group(
"KoToolBox");
339 cfg.writeEntry(
"iconSize",
iconSize);
352 QActionGroup *sizeGroup =
new QActionGroup(menu);
354 sizes << 12 << 14 << 16 << 22 << 32 << 48 << 64;
355 Q_FOREACH (
int i, sizes) {
358 action->setActionGroup(sizeGroup);
359 action->setCheckable(
true);
361 action->setChecked(
true);
372#include "moc_KoToolBoxScrollArea_p.cpp"
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
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]