Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Cleanup: Whitespace, comments, switch indentation, formatting.
Emmet O'Neill38b0234957bb
diff --git a/libs/ui/kis_node_manager.cpp b/libs/ui/kis_node_manager.cppindex a79bd6ebd6..8a4a607c20 100644--- a/libs/ui/kis_node_manager.cpp+++ b/libs/ui/kis_node_manager.cpp@@ -81,7 +81,6 @@#include <KisSynchronizedConnection.h>struct KisNodeManager::Private {-Private(KisNodeManager *_q, KisViewManager *v): q(_q), view(v)@@ -156,7 +155,6 @@ bool KisNodeManager::Private::activateNodeImpl(KisNodeSP node)layerManager.activateLayer(0);previouslyActiveNode = q->activeNode();} else {-previouslyActiveNode = q->activeNode();KoShape * shape = view->document()->shapeForNode(node);@@ -185,6 +183,8 @@ bool KisNodeManager::Private::activateNodeImpl(KisNodeSP node)return true;}+//=====================================================================================+KisNodeManager::KisNodeManager(KisViewManager *view): m_d(new Private(this, view)){@@ -846,7 +846,6 @@ void KisNodeManager::slotUiActivatedNode(KisNodeSP node)<< "KritaFill/KisToolFill"<< "KritaFill/KisToolGradient";-KisSelectionMask *selectionMask = dynamic_cast<KisSelectionMask*>(node.data());const bool nodeHasVectorAbilities = node->inherits("KisShapeLayer") ||(selectionMask && selectionMask->selection()->hasShapeSelection());@@ -1361,7 +1360,6 @@ void KisNodeManager::saveVectorLayerAsImage()void KisNodeManager::slotSplitAlphaIntoMask(){-KisNodeSP node = activeNode();if (!canModifyLayer(node)) return;diff --git a/plugins/dockers/animation/KisAnimTimelineFramesModel.cpp b/plugins/dockers/animation/KisAnimTimelineFramesModel.cppindex f8287fedf9..8d4a3e8af7 100644--- a/plugins/dockers/animation/KisAnimTimelineFramesModel.cpp+++ b/plugins/dockers/animation/KisAnimTimelineFramesModel.cpp@@ -88,6 +88,7 @@ struct KisAnimTimelineFramesModel::Privatebool layerEditable(int row) const {KisNodeDummy *dummy = converter->dummyFromRow(row);+if (!dummy) return true;if (image->isIsolatingLayer()) {@@ -99,9 +100,11 @@ struct KisAnimTimelineFramesModel::Privatebool frameExists(int row, int column) const {KisNodeDummy *dummy = converter->dummyFromRow(row);+if (!dummy) return false;KisKeyframeChannel *primaryChannel = dummy->node()->getKeyframeChannel(KisKeyframeChannel::Raster.id());+return (primaryChannel && primaryChannel->keyframeAt(column));}@@ -123,6 +126,7 @@ struct KisAnimTimelineFramesModel::Privatebool specialKeyframeExists(int row, int column) {KisNodeDummy *dummy = converter->dummyFromRow(row);if (!dummy) return false;+Q_FOREACH(KisKeyframeChannel *channel, dummy->node()->keyframeChannels()) {if (channel->id() != KisKeyframeChannel::Raster.id() && channel->keyframeAt(column)) {return true;@@ -391,41 +395,41 @@ QVariant KisAnimTimelineFramesModel::data(const QModelIndex &index, int role) coif(!m_d->dummiesFacade) return QVariant();switch (role) {- case ActiveLayerRole: {- return index.row() == m_d->activeLayerIndex;- }- case FrameEditableRole: {- return m_d->layerEditable(index.row());- }- case FrameHasContent: {- return m_d->frameHasContent(index.row(), index.column());- }- case FrameExistsRole: {- return m_d->frameExists(index.row(), index.column());- }- case SpecialKeyframeExists: {- return m_d->specialKeyframeExists(index.row(), index.column());- }- case FrameColorLabelIndexRole: {- int label = m_d->frameColorLabel(index.row(), index.column());- return label > 0 ? label : QVariant();- }- case Qt::DisplayRole: {- return m_d->layerName(index.row());- }- case Qt::TextAlignmentRole: {- return QVariant(Qt::AlignHCenter | Qt::AlignVCenter);- }- case Qt::UserRole + KisAbstractResourceModel::LargeThumbnail: {- KisNodeDummy *dummy = m_d->converter->dummyFromRow(index.row());- if (!dummy) {- return QVariant();+ case ActiveLayerRole: {+ return index.row() == m_d->activeLayerIndex;+ }+ case FrameEditableRole: {+ return m_d->layerEditable(index.row());+ }+ case FrameHasContent: {+ return m_d->frameHasContent(index.row(), index.column());+ }+ case FrameExistsRole: {+ return m_d->frameExists(index.row(), index.column());}- const int maxSize = 200;+ case SpecialKeyframeExists: {+ return m_d->specialKeyframeExists(index.row(), index.column());+ }+ case FrameColorLabelIndexRole: {+ int label = m_d->frameColorLabel(index.row(), index.column());+ return label > 0 ? label : QVariant();+ }+ case Qt::DisplayRole: {+ return m_d->layerName(index.row());+ }+ case Qt::TextAlignmentRole: {+ return QVariant(Qt::AlignHCenter | Qt::AlignVCenter);+ }+ case Qt::UserRole + KisAbstractResourceModel::LargeThumbnail: {+ KisNodeDummy *dummy = m_d->converter->dummyFromRow(index.row());+ if (!dummy) {+ return QVariant();+ }+ const int maxSize = 200;- QImage image(dummy->node()->createThumbnailForFrame(maxSize, maxSize, index.column(), Qt::KeepAspectRatio));- return image;- }+ QImage image(dummy->node()->createThumbnailForFrame(maxSize, maxSize, index.column(), Qt::KeepAspectRatio));+ return image;+ }}return ModelWithExternalNotifications::data(index, role);@@ -436,30 +440,30 @@ bool KisAnimTimelineFramesModel::setData(const QModelIndex &index, const QVarianif (!index.isValid() || !m_d->dummiesFacade) return false;switch (role) {- case ActiveLayerRole: {- if (value.toBool() &&- index.row() != m_d->activeLayerIndex) {- int prevLayer = m_d->activeLayerIndex;- m_d->activeLayerIndex = index.row();+ case ActiveLayerRole: {+ if (value.toBool() &&+ index.row() != m_d->activeLayerIndex) {+ int prevLayer = m_d->activeLayerIndex;+ m_d->activeLayerIndex = index.row();- Q_EMIT dataChanged(this->index(prevLayer, 0), this->index(prevLayer, columnCount() - 1));- Q_EMIT dataChanged(this->index(m_d->activeLayerIndex, 0), this->index(m_d->activeLayerIndex, columnCount() - 1));+ Q_EMIT dataChanged(this->index(prevLayer, 0), this->index(prevLayer, columnCount() - 1));+ Q_EMIT dataChanged(this->index(m_d->activeLayerIndex, 0), this->index(m_d->activeLayerIndex, columnCount() - 1));- Q_EMIT headerDataChanged(Qt::Vertical, prevLayer, prevLayer);- Q_EMIT headerDataChanged(Qt::Vertical, m_d->activeLayerIndex, m_d->activeLayerIndex);+ Q_EMIT headerDataChanged(Qt::Vertical, prevLayer, prevLayer);+ Q_EMIT headerDataChanged(Qt::Vertical, m_d->activeLayerIndex, m_d->activeLayerIndex);- KisNodeDummy *dummy = m_d->converter->dummyFromRow(m_d->activeLayerIndex);- KIS_ASSERT_RECOVER(dummy) { return true; }+ KisNodeDummy *dummy = m_d->converter->dummyFromRow(m_d->activeLayerIndex);+ KIS_ASSERT_RECOVER(dummy) { return true; }- Q_EMIT requestCurrentNodeChanged(dummy->node());- Q_EMIT sigEnsureRowVisible(m_d->activeLayerIndex);+ Q_EMIT requestCurrentNodeChanged(dummy->node());+ Q_EMIT sigEnsureRowVisible(m_d->activeLayerIndex);+ }+ break;}- break;- }- case FrameColorLabelIndexRole: {- m_d->setFrameColorLabel(index.row(), index.column(), value.toInt());- }- break;+ case FrameColorLabelIndexRole: {+ m_d->setFrameColorLabel(index.row(), index.column(), value.toInt());+ }+ break;}return ModelWithExternalNotifications::setData(index, value, role);@@ -471,69 +475,69 @@ QVariant KisAnimTimelineFramesModel::headerData(int section, Qt::Orientation oriif (orientation == Qt::Vertical) {switch (role) {- case ActiveLayerRole:- return section == m_d->activeLayerIndex;- case Qt::DisplayRole: {- QVariant value = headerData(section, orientation, Qt::ToolTipRole);- if (!value.isValid()) return value;+ case ActiveLayerRole:+ return section == m_d->activeLayerIndex;+ case Qt::DisplayRole: {+ QVariant value = headerData(section, orientation, Qt::ToolTipRole);+ if (!value.isValid()) return value;- QString name = value.toString();- const int maxNameSize = 13;+ QString name = value.toString();+ const int maxNameSize = 13;- if (name.size() > maxNameSize) {- name = QString("%1...").arg(name.left(maxNameSize));- }-- return name;- }- case Qt::ForegroundRole: {- // WARNING: this role doesn't work for header views! Use- // bold font to show isolated mode instead!- return QVariant();- }- case Qt::FontRole: {- KisNodeDummy *dummy = m_d->converter->dummyFromRow(section);- if (!dummy) return QVariant();- KisNodeSP node = dummy->node();+ if (name.size() > maxNameSize) {+ name = QString("%1...").arg(name.left(maxNameSize));+ }- QFont baseFont;- if (node->projectionLeaf()->isDroppedNode()) {- baseFont.setStrikeOut(true);- } else if (m_d->image && m_d->image->isolationRootNode() &&- KisNodeModel::belongsToIsolatedGroup(m_d->image, node, m_d->dummiesFacade)) {- baseFont.setBold(true);+ return name;}- return baseFont;- }- case Qt::ToolTipRole: {- return m_d->layerName(section);- }- case TimelinePropertiesRole: {- return QVariant::fromValue(m_d->layerProperties(section));- }- case OtherLayersRole: {- TimelineNodeListKeeper::OtherLayersList list =- m_d->converter->otherLayersList();-- return QVariant::fromValue(list);- }- case PinnedToTimelineRole: {- KisNodeDummy *dummy = m_d->converter->dummyFromRow(section);- if (!dummy) return QVariant();- return dummy->node()->isPinnedToTimeline();- }- case Qt::BackgroundRole: {- int label = m_d->layerColorLabel(section);- if (label > 0) {- KisNodeViewColorScheme scm;- QColor color = scm.colorFromLabelIndex(label);- QPalette pal = qApp->palette();- color = KisPaintingTweaks::blendColors(color, pal.color(QPalette::Button), 0.3);- return QBrush(color);- } else {+ case Qt::ForegroundRole: {+ // WARNING: this role doesn't work for header views! Use+ // bold font to show isolated mode instead!return QVariant();}- }+ case Qt::FontRole: {+ KisNodeDummy *dummy = m_d->converter->dummyFromRow(section);+ if (!dummy) return QVariant();+ KisNodeSP node = dummy->node();++ QFont baseFont;+ if (node->projectionLeaf()->isDroppedNode()) {+ baseFont.setStrikeOut(true);+ } else if (m_d->image && m_d->image->isolationRootNode() &&+ KisNodeModel::belongsToIsolatedGroup(m_d->image, node, m_d->dummiesFacade)) {+ baseFont.setBold(true);+ }+ return baseFont;+ }+ case Qt::ToolTipRole: {+ return m_d->layerName(section);+ }+ case TimelinePropertiesRole: {+ return QVariant::fromValue(m_d->layerProperties(section));+ }+ case OtherLayersRole: {+ TimelineNodeListKeeper::OtherLayersList list =+ m_d->converter->otherLayersList();++ return QVariant::fromValue(list);+ }+ case PinnedToTimelineRole: {+ KisNodeDummy *dummy = m_d->converter->dummyFromRow(section);+ if (!dummy) return QVariant();+ return dummy->node()->isPinnedToTimeline();+ }+ case Qt::BackgroundRole: {+ int label = m_d->layerColorLabel(section);+ if (label > 0) {+ KisNodeViewColorScheme scm;+ QColor color = scm.colorFromLabelIndex(label);+ QPalette pal = qApp->palette();+ color = KisPaintingTweaks::blendColors(color, pal.color(QPalette::Button), 0.3);+ return QBrush(color);+ } else {+ return QVariant();+ }+ }}}@@ -546,23 +550,23 @@ bool KisAnimTimelineFramesModel::setHeaderData(int section, Qt::Orientation orieif (orientation == Qt::Vertical) {switch (role) {- case ActiveLayerRole: {- setData(index(section, 0), value, role);- break;- }- case TimelinePropertiesRole: {- KisAnimTimelineFramesModel::PropertyList props = value.value<KisAnimTimelineFramesModel::PropertyList>();+ case ActiveLayerRole: {+ setData(index(section, 0), value, role);+ break;+ }+ case TimelinePropertiesRole: {+ KisAnimTimelineFramesModel::PropertyList props = value.value<KisAnimTimelineFramesModel::PropertyList>();- int result = m_d->setLayerProperties(section, props);- Q_EMIT headerDataChanged (Qt::Vertical, section, section);- return result;- }- case PinnedToTimelineRole: {- KisNodeDummy *dummy = m_d->converter->dummyFromRow(section);- if (!dummy) return false;- dummy->node()->setPinnedToTimeline(value.toBool());- return true;- }+ int result = m_d->setLayerProperties(section, props);+ Q_EMIT headerDataChanged (Qt::Vertical, section, section);+ return result;+ }+ case PinnedToTimelineRole: {+ KisNodeDummy *dummy = m_d->converter->dummyFromRow(section);+ if (!dummy) return false;+ dummy->node()->setPinnedToTimeline(value.toBool());+ return true;+ }}}@@ -885,7 +889,6 @@ bool KisAnimTimelineFramesModel::createFrame(const QModelIndexList &dstIndex)KisAnimUtils::createKeyframeCommand(m_d->image, node, KisKeyframeChannel::Raster.id(), cell.second, false, parentCommand);}-KisProcessingApplicator::runSingleCommandStroke(m_d->image, parentCommand,KisStrokeJobData::BARRIER,KisStrokeJobData::EXCLUSIVE);@@ -1062,7 +1065,6 @@ bool KisAnimTimelineFramesModel::insertHoldFrames(const QModelIndexList &selecteparentCommand.data());}-KisProcessingApplicator::runSingleCommandStroke(m_d->image, parentCommand.take(),KisStrokeJobData::BARRIER,KisStrokeJobData::EXCLUSIVE);@@ -1083,6 +1085,7 @@ QString KisAnimTimelineFramesModel::audioChannelFileName() constvoid KisAnimTimelineFramesModel::setAudioChannelFileName(const QFileInfo &fileName){KIS_SAFE_ASSERT_RECOVER_RETURN(document());+QVector<QFileInfo> tracks;if (fileName.exists()) {tracks << fileName;diff --git a/plugins/dockers/animation/KisAnimTimelineFramesView.cpp b/plugins/dockers/animation/KisAnimTimelineFramesView.cppindex 6444c49edd..77ce04ffec 100644--- a/plugins/dockers/animation/KisAnimTimelineFramesView.cpp+++ b/plugins/dockers/animation/KisAnimTimelineFramesView.cpp@@ -821,7 +821,6 @@ void KisAnimTimelineFramesView::slotRealignScrollBars() {hBar->setMaximumWidth(desiredScrollArea.width());hBar->setMinimumWidth(desiredScrollArea.width());-vBar->parentWidget()->layout()->setAlignment(Qt::AlignBottom);vBar->setMaximumHeight(desiredScrollArea.height());vBar->setMinimumHeight(desiredScrollArea.height());@@ -887,8 +886,8 @@ void KisAnimTimelineFramesView::mousePressEvent(QMouseEvent *event)if (event->button() == Qt::RightButton) {// TODO: try calculate index under mouse cursor even when// it is outside any visible row-// qreal staticPoint = index.isValid() ? index.column() : currentIndex().column();-// m_d->zoomDragButton->beginZoom(event->pos(), staticPoint);+ // qreal staticPoint = index.isValid() ? index.column() : currentIndex().column();+ // m_d->zoomDragButton->beginZoom(event->pos(), staticPoint);} else if (event->button() == Qt::LeftButton) {m_d->initialDragPanPos = event->pos();m_d->initialDragPanValue =@@ -999,8 +998,7 @@ void KisAnimTimelineFramesView::mousePressEvent(QMouseEvent *event)m_d->model->setLastClickedIndex(index);}- m_d->lastPressedPosition =- QPoint(horizontalOffset(), verticalOffset()) + event->pos();+ m_d->lastPressedPosition = QPoint(horizontalOffset(), verticalOffset()) + event->pos();m_d->lastPressedModifier = event->modifiers();m_d->initialDragPanPos = event->pos();@@ -1038,10 +1036,8 @@ void KisAnimTimelineFramesView::mouseMoveEvent(QMouseEvent *e)}if (m_d->modifiersCatcher->modifierPressed("pan-zoom")) {-if (e->buttons() & Qt::RightButton) {--// m_d->zoomDragButton->continueZoom(e->pos());+ // m_d->zoomDragButton->continueZoom(e->pos());} else if (e->buttons() & Qt::LeftButton) {QPoint diff = e->pos() - m_d->initialDragPanPos;@@ -1058,6 +1054,7 @@ void KisAnimTimelineFramesView::mouseMoveEvent(QMouseEvent *e)horizontalScrollBar()->setValue(offset.x());verticalScrollBar()->setValue(offset.y() / height);}+e->accept();} else if (e->buttons() == Qt::MiddleButton) {QModelIndex index = model()->buddy(indexAt(e->pos()));@@ -1067,6 +1064,7 @@ void KisAnimTimelineFramesView::mouseMoveEvent(QMouseEvent *e)// The offset of the headers is needed to get the correct position inside the view.m_d->tip.showTip(this, e->pos() + QPoint(verticalHeader()->width(), horizontalHeader()->height()), option, index);}+e->accept();} else {m_d->model->setScrubState(true);@@ -1134,7 +1132,6 @@ void KisAnimTimelineFramesView::startDrag(Qt::DropActions supportedActions)}}} else {-/*** Workaround for Qt5's bug: if we start a dragging action right during* Shift-selection, Qt will get crazy. We cannot workaround it easily,@@ -1700,13 +1697,18 @@ QPixmap KisAnimTimelineFramesView::Private::renderToPixmap(const QModelIndexList{Q_ASSERT(r);QItemViewPaintPairs paintPairs = draggablePaintPairs(indexes, r);+if (paintPairs.isEmpty())return QPixmap();+QPixmap pixmap(r->size());pixmap.fill(Qt::transparent);+QPainter painter(&pixmap);+QStyleOptionViewItem option = viewOptionsV4();option.state |= QStyle::State_Selected;+for (int j = 0; j < paintPairs.count(); ++j) {option.rect = paintPairs.at(j).first.translated(-r->topLeft());const QModelIndex ¤t = paintPairs.at(j).second;@@ -1714,15 +1716,18 @@ QPixmap KisAnimTimelineFramesView::Private::renderToPixmap(const QModelIndexListq->itemDelegate(current)->paint(&painter, option, current);}+return pixmap;}void resizeToMinimalSize(QAbstractButton *w, int minimalSize){QSize buttonSize = w->sizeHint();+if (buttonSize.height() > minimalSize) {buttonSize = QSize(minimalSize, minimalSize);}+w->resize(buttonSize);}