diff --git a/AGENTS.md b/AGENTS.md index 4e689c8..efd3162 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -191,6 +191,7 @@ Platform adaptations, each forced by a missing Qt analog: - Last Filter (14.9, Swift 1.4.7: `0415aa4`, `6b81d4a`): `repeatsAsLastFilter` (the Filter menu's own kinds), `FilterEdit::repeating`, and in the session `lastFilter` (a getter and a setter that notifies, Swift's public var, which its tests write), `canRepeatLastFilter` and `repeatLastFilter`, which takes a completion callback: a pending gradient lands first (`commitGradient`'s continuation), then `beginFilter(kind, true)` opens the edit without a preview unless the kind is automatic, `commitFilter` applies it with the settings it had, and its callback cancels an edit still open, so nothing is left without a panel. `commitFilter` records the kind. Swift's `edit.repeating` check after `beginFilter` is dead and left out: the repeat commits the gradient first, so `beginFilter` either opens a repeating edit or none. Filter › Last Filter is first, then a separator, titled `Last Filter: ` once one is recorded, on Ctrl+Meta+F (Swift's Command-Control F), resting while `canRepeatLastFilter` does not hold; `ShortcutDefinition::all` gains it after Select Subject. `synchronizePanels` keeps the filter panel shut for a repeating edit. Equivalent mutant: `canRepeatLastFilter`'s `m_filterEdit` term (`canAdjust` refuses an open filter; Swift's too). Tests: `LastFilterTests` (Swift's two; an Image adjustment not recorded, the setter's signal, the gates, Vignette's on an empty layer, a pending gradient as its own step, Remove Background through its preview, the menu's title, key and panel, a preview only when automatic, a failed preview closed, a blur that cannot grow, a newer edit outlasting the repeat), the key and Swift's unique menu keys in `KeyboardShortcutsTests`, the Filter menu in `CompositorMenusTests`. - The closed hand (14.10, Swift 1.4.7: `c0a1cd0`) was held already: Swift sets the hand once a drag and lets Space's key repeats put the open hand back, so its fix holds the drag's cursor; the twin's `updateCursor` ranks a pan (`m_lastDragPoint`) above Space and the Hand tool, a repeated Space release is no release, and the release asks the cursor again, so the hand opens while Space is held. `CanvasNavigationTests::theHandToolAndSpaceDragTheView` holds it through repeats, and through Space let go mid-pan, the drag going on closed until the button comes up. - The Layers footer's ink (14.11, Swift 1.4.7: `7fb40a9`, `790195f`): `footerIcon` (in `UI/LayersPanel`, Swift's `FooterIcon`) gives the plain buttons (new layer, folder, mask, delete) the primary ink, `WindowText`, and for their disabled state the menus' own: the shape in `PlaceholderText` dimmed by the style's `generatedIconPixmap`, as Qt dims the effects and adjustment menus' icons, so a disabled button is exactly as dim as a disabled menu (Swift measures a quarter-strength white for the same end). Both inks are read from the active group, since a disabled widget's palette answers with its disabled group. The menus keep `PlaceholderText`. The panel redraws its icons from the event loop on a palette change, once its buttons carry the new palette. Tests: `LayersPanelTests::footerButtonsTakeThePrimaryInkAndDimAsTheMenus` (disabled from the start and after a busy project disables them), and the inks after a new palette in `LayerListFocusTests::aNewPaletteRedrawsEveryIcon`. +- Don't Save (14.12, Swift 1.4.7: `283d360`, `4e035bf`) was held: Swift marked the button destructive and took it back the next day, so its net change is none, Save the one coloured button. The twin's alert keeps `QMessageBox::DestructiveRole` for Don't Save, which in Qt sets only the platform's button order, no colour; Save, the first accepting button, is the default, and Cancel and Don't Save are both plain. `ProjectControllerTests::saveIsTheOneDefaultAndDontSaveIsAsPlainAsCancel` holds it. - Drops between projects: `ProjectWorkspace::draggedLayerSource` finds the tab whose document holds the dragged id (Swift reads the drag pasteboard; the twin reads the drag's `QMimeData`, which every drop target has), `canReceiveDrag(data, destination)` refuses only a layer's own tab, and `receiveProviders` copies several ids one after another, as Swift awaits each provider, so a two-row drop on the New button opens two tabs as Swift's does. `ContentView` takes such a drop over its whole area (`setWorkspace` hands it the workspace; `acceptsDrop` keeps Swift's guards: busy, the sheet, the importer, a rename; `levels` arrives with 9.x), shows the 3-point accent ring inside the canvas while targeted and hands the drop's document point on when it fell on the canvas. `ProjectTabButton` takes drops for its tab (accent fill and rim, "Add to "), and `NewCanvasButton`, the toolbar's New canvas button with the action as its default, for a fresh tab ("Open in a new project tab"), both refusing an Alt drag, which duplicates in the panel; Swift's transient `NewTabDropSlot` in the strip has no twin, the New canvas button is `NewProjectDropTarget` already. Files and pictures arrived with 10.4. - `CanvasThumbnail` draws a layer or a mask inside the canvas's box at `backingScale` 2 (the panel's pixmaps carry that ratio); a mask's ground is `LayerMask::background`, white or black by its edge's majority, as the canvas treats it (Swift's `edgeTone` mean went with 12.12b). `LayerIcons` draws the panel's SF Symbols as paths, in one palette colour, like `ToolIcons`. `BlendModePicker` is a `QComboBox` whose popup previews the highlighted mode through `previewBlendMode` for the layer it opened on (Qt calls `hidePopup` before `activated`, so the preview, the target and the highlight are cleared from the event loop, after a choice had its chance) and refuses a choice once another layer is active. `LayerAppearanceControls` is Swift's blend and opacity row: the slider's press and release are one opacity drag (the release is watched application-wide while the slider is down, so a popup opened mid-drag cannot keep the step open), the percent field applies once through its `FocusOut`, which Return and Escape cause (Swift's `releasesFocusOnCommit`), and steps with Up and Down (Swift's `isFinite` test and the steps' clamp are left out: `setLayerOpacity` refuses a value that is no finite number and clamps the rest), and another active layer makes the controls anew, as Swift's `.id` does. - `ProjectWorkspaceView` is the `QMainWindow`: the front tab's `ContentView` as its central widget, made anew when another tab comes to the front, as SwiftUI's `.id` rebuilds it, and disabled while the workspace manages; the window holds the shown tab (`std::shared_ptr`) until the old editor is deleted, as Swift's views hold their session, so a replaced or closed tab's session never ends under its editor (`ProjectWorkspace::tab` is public for this); a `QToolBar` with the New canvas action, the `ProjectTabStrip` (which takes the toolbar's free width) and the four zoom actions, since SwiftUI's `.toolbar` modifier lives in `ContentView` but the toolbar belongs to the window. Its actions follow the front session's `changed()`, and on that signal the window syncs every tab's button as well, because a busy front tab dims the other tabs' buttons, which their own sessions' signals do not reach; the strip syncs its buttons on the workspace's signal, each button on its own session's. The window's title is the front tab's, with Qt's `[*]` placeholder, so `setWindowModified` can show the mark that `isDocumentEdited` shows; `setWindowFilePath` carries `representedURL`. The editor's own minimum size is cleared inside the window, which owns the 800 × 520 minimum for the whole, toolbar included. Closing the window ignores the event and asks the workspace (`closeWindow`), which confirms tab by tab and then closes the window again with the property `closeConfirmed` set, since the workspace may not include `UI/` headers; a confirmed close is accepted and the mark cleared, so a window shown again asks again. `ProjectTabStrip` is a plain `QWidget` whose buttons are kept for the tabs that stay, made for new tabs and deleted for tabs that went, and placed by hand from `projectTabOverflow` (13.14): every button at its own size hint, so no title is squeezed below Swift's 35 points, laid out again when the strip is resized, the workspace changes or any tab's session changes; it fills no background, so the toolbar shows through (a stylesheet would do the same but freezes the widgets' palette, so a theme switch would pass them by); the unsaved dot is a character before the title. Files named on the command line go to `ProjectWorkspace::receive`, as Finder's Open With reaches the delegate. Layer drops on tabs and the New canvas button are 4.7's; file and picture drops arrived with 10.4. diff --git a/tests/ProjectControllerTests.cpp b/tests/ProjectControllerTests.cpp index 33aafe2..49a9b4c 100644 --- a/tests/ProjectControllerTests.cpp +++ b/tests/ProjectControllerTests.cpp @@ -4,6 +4,7 @@ #include "SessionRecord.h" #include <QFutureWatcher> #include <QTemporaryDir> +#include <QPushButton> #include <QtTest> // Saving, and the question before unsaved work is dropped. @@ -52,6 +53,7 @@ private slots: void aNewCanvasAsksThenClears(); void closingAsksThenClearsAndClosesTheWindow(); void aSessionThatEndsMidSaveCallsNobody(); + void saveIsTheOneDefaultAndDontSaveIsAsPlainAsCancel(); }; void ProjectControllerTests::theFirstSaveAsksWhereAndLaterSavesDoNot() @@ -386,5 +388,29 @@ void ProjectControllerTests::aSessionThatEndsMidSaveCallsNobody() QCOMPARE(calls, 0); } +void ProjectControllerTests::saveIsTheOneDefaultAndDontSaveIsAsPlainAsCancel() +{ + // Swift 1.4.7: no destructive colour; Save alone stands out. + EditorSession session; + ProjectController controller(session); + DialogDesk desk; + paint(session); + desk.note = [] { + for (QWidget *widget : QApplication::topLevelWidgets()) + if (auto *alert = qobject_cast<QMessageBox *>(widget); alert && alert->isVisible()) { + QStringList looks; + for (QAbstractButton *each : alert->buttons()) { + const auto *button = qobject_cast<QPushButton *>(each); + looks << QStringLiteral("%1:%2%3").arg(button->text()).arg(button->isDefault()).arg(button->isFlat()); + } + return looks.join(','); + } + return QStringLiteral("none"); + }; + desk.replies = {"Cancel"}; + QCOMPARE(answered([&](auto done) { controller.confirmQuit(done); }), std::optional(false)); + QCOMPARE(desk.seen.value(0).section('|', 5), QStringLiteral("Save:10,Cancel:00,Don’t Save:00")); +} + QTEST_MAIN(ProjectControllerTests) #include "ProjectControllerTests.moc"