File indexing completed on 2024-12-22 04:14:46
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "arrange_docker_widget.h" 0008 #include "ui_arrange_docker_widget.h" 0009 0010 #include "kis_debug.h" 0011 0012 #include "kactioncollection.h" 0013 0014 #include <QAction> 0015 #include <QToolButton> 0016 0017 struct ArrangeDockerWidget::Private 0018 { 0019 }; 0020 0021 ArrangeDockerWidget::ArrangeDockerWidget(QWidget *parent) : 0022 QWidget(parent), 0023 ui(new Ui::ArrangeDockerWidget), 0024 m_d(new Private) 0025 { 0026 ui->setupUi(this); 0027 } 0028 0029 ArrangeDockerWidget::~ArrangeDockerWidget() 0030 { 0031 } 0032 0033 0034 void replaceAction(QToolButton *button, QAction *newAction) 0035 { 0036 Q_FOREACH (QAction *action, button->actions()) { 0037 button->removeAction(action); 0038 } 0039 0040 if (newAction) { 0041 button->setDefaultAction(newAction); 0042 } 0043 } 0044 0045 void ArrangeDockerWidget::setActionCollection(KisKActionCollection *collection) 0046 { 0047 const bool enabled = collection->action("object_order_front"); 0048 0049 if (enabled) { 0050 replaceAction(ui->bringToFront, collection->action("object_order_front")); 0051 replaceAction(ui->raiseLevel, collection->action("object_order_raise")); 0052 replaceAction(ui->lowerLevel, collection->action("object_order_lower")); 0053 replaceAction(ui->sendBack, collection->action("object_order_back")); 0054 0055 replaceAction(ui->leftAlign, collection->action("object_align_horizontal_left")); 0056 replaceAction(ui->hCenterAlign, collection->action("object_align_horizontal_center")); 0057 replaceAction(ui->rightAlign, collection->action("object_align_horizontal_right")); 0058 replaceAction(ui->topAlign, collection->action("object_align_vertical_top")); 0059 replaceAction(ui->vCenterAlign, collection->action("object_align_vertical_center")); 0060 replaceAction(ui->bottomAlign, collection->action("object_align_vertical_bottom")); 0061 0062 replaceAction(ui->hDistributeLeft, collection->action("object_distribute_horizontal_left")); 0063 replaceAction(ui->hDistributeCenter, collection->action("object_distribute_horizontal_center")); 0064 replaceAction(ui->hDistributeRight, collection->action("object_distribute_horizontal_right")); 0065 replaceAction(ui->hDistributeGaps, collection->action("object_distribute_horizontal_gaps")); 0066 0067 replaceAction(ui->vDistributeTop, collection->action("object_distribute_vertical_top")); 0068 replaceAction(ui->vDistributeCenter, collection->action("object_distribute_vertical_center")); 0069 replaceAction(ui->vDistributeBottom, collection->action("object_distribute_vertical_bottom")); 0070 replaceAction(ui->vDistributeGaps, collection->action("object_distribute_vertical_gaps")); 0071 0072 0073 replaceAction(ui->group, collection->action("object_group")); 0074 replaceAction(ui->ungroup, collection->action("object_ungroup")); 0075 } 0076 0077 setEnabled(enabled); 0078 } 0079 0080 void ArrangeDockerWidget::switchState(bool enabled) 0081 { 0082 if (enabled) { 0083 ui->buttons->show(); 0084 ui->disabledLabel->hide(); 0085 } else { 0086 ui->buttons->hide(); 0087 ui->disabledLabel->show(); 0088 } 0089 } 0090 0091