31 : QDockWidget(i18n(
"Toolbox"))
37 QLabel *w =
new QLabel(
" ",
this);
38 w->setFrameShape(QFrame::StyledPanel);
39 w->setFrameShadow(QFrame::Raised);
40 w->setFrameStyle(QFrame::Panel | QFrame::Raised);
41 QFont font = qApp->font();
44 if (font.pixelSize() == -1) {
45 font.setPointSizeF(font.pointSizeF() * ratio);
47 font.setPixelSize(qRound(font.pixelSize() * ratio));
49 int titleSize = QFontMetrics(font).height();
50 w->setMinimumSize(titleSize, titleSize);
53 KConfigGroup cfg = KSharedConfig::openConfig()->group(
"KoToolBox");
54 const int layoutDirUnchecked = cfg.readEntry<
int>(
"layoutDir", Qt::LayoutDirectionAuto);
55 switch (layoutDirUnchecked) {
56 case Qt::LayoutDirectionAuto:
59 m_layoutDir =
static_cast<Qt::LayoutDirection
>(layoutDirUnchecked);
67 const int orientUnchecked = cfg.readEntry<
int>(
"orientation",
Auto);
68 switch (orientUnchecked) {
83 connect(
this, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)),
85 connect(
this, SIGNAL(topLevelChanged(
bool)),
190 QAction* configAction =
m_contextMenu->addAction(i18n(
"Customize Disabled Tools"));
194 QAction *compact =
m_contextMenu->addAction(i18n(
"Compact"));
195 compact->setCheckable(
true);
202 m_contextMenu->addSection(i18nc(
"Toolbox layout",
"Layout"));
203 QActionGroup *layoutActionGroup =
new QActionGroup(
m_contextMenu);
205 QAction *layoutAuto =
m_contextMenu->addAction(i18nc(
"@item:inmenu Toolbox layout direction",
"&Automatic"));
206 layoutAuto->setActionGroup(layoutActionGroup);
207 layoutAuto->setCheckable(
true);
208 connect(layoutAuto, &QAction::triggered,
this, [
this]() {
212 QAction *layoutLtr =
m_contextMenu->addAction(i18nc(
"@item:inmenu Toolbox layout direction",
"&Left-to-right"));
213 layoutLtr->setActionGroup(layoutActionGroup);
214 layoutLtr->setCheckable(
true);
215 connect(layoutLtr, &QAction::triggered,
this, [
this]() {
219 QAction *layoutRtl =
m_contextMenu->addAction(i18nc(
"@item:inmenu Toolbox layout direction",
"&Right-to-left"));
220 layoutRtl->setActionGroup(layoutActionGroup);
221 layoutRtl->setCheckable(
true);
222 connect(layoutRtl, &QAction::triggered,
this, [
this]() {
227 case Qt::LayoutDirectionAuto:
228 layoutAuto->setChecked(
true);
230 case Qt::LeftToRight:
231 layoutLtr->setChecked(
true);
233 case Qt::RightToLeft:
234 layoutRtl->setChecked(
true);
238 m_contextMenu->addSection(i18nc(
"Toolbox orientation",
"Orientation"));
239 QActionGroup *orientActionGroup =
new QActionGroup(
m_contextMenu);
241 QAction *orientAuto =
m_contextMenu->addAction(i18nc(
"@item:inmenu Toolbox orientation",
"&Automatic"));
242 orientAuto->setActionGroup(orientActionGroup);
243 orientAuto->setCheckable(
true);
244 connect(orientAuto, &QAction::triggered,
this, [
this]() {
248 QAction *orientHorizontal =
m_contextMenu->addAction(i18nc(
"@item:inmenu Toolbox orientation",
"&Horizontal"));
249 orientHorizontal->setActionGroup(orientActionGroup);
250 orientHorizontal->setCheckable(
true);
251 connect(orientHorizontal, &QAction::triggered,
this, [
this]() {
255 QAction *orientVertical =
m_contextMenu->addAction(i18nc(
"@item:inmenu Toolbox orientation",
"&Vertical"));
256 orientVertical->setActionGroup(orientActionGroup);
257 orientVertical->setCheckable(
true);
258 connect(orientVertical, &QAction::triggered,
this, [
this]() {
264 orientHorizontal->setChecked(
true);
267 orientVertical->setChecked(
true);
270 orientAuto->setChecked(
true);
280 KConfigGroup cfg = KSharedConfig::openConfig()->group(
"KoToolBox");
286 std::map<QString, std::map<int, KoToolAction *>> priorities;
293 std::vector<QString> toolNames(tools.length());
294 std::vector<QVariant> toolIds(tools.length());
295 std::vector<QIcon> toolIcons(tools.length());
298 for (
auto sections = priorities.begin(); sections != priorities.end(); ++sections) {
299 for (
auto section = sections->second.begin(); section != sections->second.end(); ++section) {
300 toolNames[i] = section->second->toolName();
301 QString
id = sections->first;
302 toolIds[i] =
id.append(
303 QString(
"_").append(QString::number(section->first).append(
"_")).append(section->second->id()));
309 std::vector<QString> disabledToolNames(cfgDisabledTools.length());
310 std::vector<QVariant> disabledToolIds(cfgDisabledTools.length());
311 std::vector<QIcon> disabledToolIcons(cfgDisabledTools.length());
316 Q_FOREACH (
auto tool, cfgDisabledTools) {
321 Q_FOREACH (
auto toolId, toolIds) {
322 if (toolId.toString().contains(tool)) {
330 disabledToolNames[i] = toolNames[j];
331 disabledToolIds[i] = toolIds[j];
332 disabledToolIcons[i] = toolIcons[j];
334 toolNames.erase(toolNames.begin() + j);
335 toolIds.erase(toolIds.begin() + j);
336 toolIcons.erase(toolIcons.begin() + j);
345 i18n(
"Enabled tools"),
346 i18n(
"Disabled tools"),
347 QList(toolNames.begin(), toolNames.end()),
348 QList(toolIds.begin(), toolIds.end()),
349 QList(toolIcons.begin(), toolIcons.end()),
350 QList(disabledToolNames.begin(), disabledToolNames.end()),
351 QList(disabledToolIds.begin(), disabledToolIds.end()),
352 QList(disabledToolIcons.begin(), disabledToolIcons.end()),
361 std::vector<QString> chosen_string(chosen.length());
363 std::transform(chosen.begin(), chosen.end(), chosen_string.begin(), [](QVariant i) {
364 return i.toString().split(QRegularExpression(
"_"))[2];