| 8207 | } |
| 8208 | |
| 8209 | void DocumentViewport::decreaseSelectedAffinity() |
| 8210 | { |
| 8211 | if (!m_document || m_selectedObjects.isEmpty()) return; |
| 8212 | |
| 8213 | const int minAffinity = -1; // Background |
| 8214 | #ifdef SPEEDYNOTE_DEBUG |
| 8215 | qDebug() << "decreaseSelectedAffinity: minAffinity =" << minAffinity; |
| 8216 | #endif |
| 8217 | |
| 8218 | for (InsertedObject* obj : m_selectedObjects) { |
| 8219 | if (!obj) continue; |
| 8220 | |
| 8221 | int currentAffinity = obj->getLayerAffinity(); |
| 8222 | if (currentAffinity <= minAffinity) { |
| 8223 | #ifdef SPEEDYNOTE_DEBUG |
| 8224 | qDebug() << " obj" << obj->id << "already at min affinity" << currentAffinity; |
| 8225 | #endif |
| 8226 | continue; |
| 8227 | } |
| 8228 | |
| 8229 | Document::TileCoord tileCoord = {0, 0}; |
| 8230 | Page* page = findPageContainingObject(obj, &tileCoord); |
| 8231 | if (!page) continue; |
| 8232 | |
| 8233 | int oldAffinity = currentAffinity; |
| 8234 | page->updateObjectAffinity(obj->id, currentAffinity - 1); |
| 8235 | |
| 8236 | #ifdef SPEEDYNOTE_DEBUG |
| 8237 | qDebug() << " obj" << obj->id << "affinity:" << oldAffinity |
| 8238 | << "->" << obj->getLayerAffinity(); |
| 8239 | #endif |
| 8240 | // Phase O3.5.3: Push undo entry for affinity change |
| 8241 | pushObjectAffinityUndo(obj, oldAffinity); |
| 8242 | |
| 8243 | if (m_document->isEdgeless()) { |
| 8244 | m_document->markTileDirty(tileCoord); |
| 8245 | } else { |
| 8246 | m_document->markPageDirty(m_currentPageIndex); |
| 8247 | } |
| 8248 | } |
| 8249 | |
| 8250 | emit documentModified(); |
| 8251 | update(); |
| 8252 | } |
| 8253 | |
| 8254 | void DocumentViewport::toggleImageAspectRatioLock() |
| 8255 | { |
no test coverage detected