From 60834def28df61ca095b43a0b74a957e92d6261c Mon Sep 17 00:00:00 2001 From: teo1747 <148846371+teo1747@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:47:48 +0100 Subject: [PATCH] Docking: every view is a dock, and layouts are saved and restored MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The main window now uses Qt Advanced Docking System 5.1.1, as §11 q1 decided. It is fetched by version and SHA-256, built as a shared library (LGPL-2.1-or-later, linked dynamically) and listed in third_party/components.json. Workbench (app/src/workbench.*) places the views and handles layouts: - every view can be moved, split, tabbed, floated and closed; - the layout is saved on close and restored on start; - layouts can be saved by name and opened from View > Layouts; - View > Reset layout brings back the default; - a layout from another layout version is ignored. "Core" and "Core log" are its first two views. tst_workbench checks the rule: no view is fixed, a layout saved is the layout restored in a new window, closed views stay closed, named layouts survive a restart, and reset works. Spec §7 states the layout rule and §9 its test. Linux CI installs libxcb1-dev, which ADS links. The development guide says the first configure downloads ADS. Signed-off-by: teo1747 <148846371+teo1747@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- CMakeLists.txt | 18 ++++ app/CMakeLists.txt | 13 ++- app/src/mainwindow.cpp | 82 ++++++++++++---- app/src/mainwindow.h | 15 ++- app/src/workbench.cpp | 132 ++++++++++++++++++++++++++ app/src/workbench.h | 90 ++++++++++++++++++ app/tests/tst_workbench.cpp | 180 ++++++++++++++++++++++++++++++++++++ docs/development.md | 5 +- docs/specification.md | 10 +- third_party/components.json | 15 ++- 11 files changed, 538 insertions(+), 24 deletions(-) create mode 100644 app/src/workbench.cpp create mode 100644 app/src/workbench.h create mode 100644 app/tests/tst_workbench.cpp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 000f34c..fe97668 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: cache: true - name: Linux build dependencies if: runner.os == 'Linux' - run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev libxkbcommon-dev + run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev libxkbcommon-dev libxcb1-dev - name: MSVC environment if: runner.os == 'Windows' uses: ilammy/msvc-dev-cmd@v1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f451eb..6e287b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,4 +28,22 @@ if(EMBLINK_STUDIO_BUILD_TESTS) find_package(Qt6 REQUIRED COMPONENTS Test) endif() +# Qt Advanced Docking System (spec section 11, question 1): LGPL-2.1-or-later, so it is built +# as a shared library and linked dynamically (spec section 9). Pinned by version and SHA-256. +include(FetchContent) +set(QT_VERSION_MAJOR 6) +set(BUILD_STATIC OFF CACHE BOOL "Build Qt Advanced Docking System as a static library" FORCE) +set(BUILD_EXAMPLES OFF CACHE BOOL "Build Qt Advanced Docking System's examples" FORCE) +FetchContent_Declare(qtads + URL https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/archive/refs/tags/v5.1.1.tar.gz + URL_HASH SHA256=9ce947acbb1984946f9145c976e42e6984f99b98fb414dd7354a290af6d4ff04 + DOWNLOAD_EXTRACT_TIMESTAMP TRUE +) +FetchContent_MakeAvailable(qtads) +# Next to the application and the tests, so Windows finds the DLL without a PATH change. +set_target_properties(qtadvanceddocking-qt6 PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/app" + LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/app" +) + add_subdirectory(app) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 3d94421..dca9d56 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -19,6 +19,13 @@ target_compile_definitions(emblink_studio_corelink PUBLIC EMBLINK_STUDIO_CORE_SRC_DIR="${PROJECT_SOURCE_DIR}/core/src" ) +# The dockable layout: every view a dock, layouts saved and restored (spec section 7). +qt_add_library(emblink_studio_workbench STATIC + src/workbench.cpp src/workbench.h +) +target_include_directories(emblink_studio_workbench PUBLIC src) +target_link_libraries(emblink_studio_workbench PUBLIC Qt6::Widgets ads::qtadvanceddocking-qt6) + # The notices list shown in the About box, generated from third_party/components.json. set(notices "${CMAKE_CURRENT_BINARY_DIR}/NOTICES.md") add_custom_command( @@ -38,7 +45,7 @@ qt_add_executable(emblinkstudio WIN32 MACOSX_BUNDLE src/main.cpp src/mainwindow.cpp src/mainwindow.h ) -target_link_libraries(emblinkstudio PRIVATE emblink_studio_corelink Qt6::Widgets) +target_link_libraries(emblinkstudio PRIVATE emblink_studio_corelink emblink_studio_workbench Qt6::Widgets) target_compile_definitions(emblinkstudio PRIVATE EMBLINK_STUDIO_VERSION="${PROJECT_VERSION}") set_source_files_properties("${notices}" PROPERTIES QT_RESOURCE_ALIAS NOTICES.md) qt_add_resources(emblinkstudio notices PREFIX "/" BASE "${CMAKE_CURRENT_BINARY_DIR}" FILES "${notices}") @@ -57,4 +64,8 @@ if(EMBLINK_STUDIO_BUILD_TESTS) endforeach() target_compile_definitions(tst_coreclient PRIVATE EMBLINK_STUDIO_FAKE_CORE="${CMAKE_CURRENT_SOURCE_DIR}/tests/fake_core.py") + + qt_add_executable(tst_workbench tests/tst_workbench.cpp) + target_link_libraries(tst_workbench PRIVATE emblink_studio_workbench Qt6::Test) + add_test(NAME tst_workbench COMMAND tst_workbench) endif() diff --git a/app/src/mainwindow.cpp b/app/src/mainwindow.cpp index 75ca107..1eacb63 100644 --- a/app/src/mainwindow.cpp +++ b/app/src/mainwindow.cpp @@ -9,9 +9,12 @@ * @brief Implementation of MainWindow: layout, menus, About dialog, core lifecycle. * * @details - * Builds the status label, the restart button, the "Core log" dock (a QDockWidget - * until Qt Advanced Docking System lands, spec section 11 question 1) and the File, - * View and Help menus. The About dialog shows the third-party notices bundled as the + * Builds two Workbench views, "Core" (the status label and the restart button) and + * "Core log", and the File, View and Help menus. The View menu shows or hides each + * view, opens and saves named layouts, and resets the layout. The layout is saved to + * the user's settings when the window closes and restored when it opens (per project + * in .emblink-studio/ once projects exist, spec section 6). The About dialog shows the third-party + * notices bundled as the * :/NOTICES.md resource. The core is started when the window is built and stopped * when it closes. * @@ -21,17 +24,20 @@ */ #include "mainwindow.h" +#include "workbench.h" #include #include #include #include -#include #include +#include #include +#include #include #include #include +#include #include #include @@ -43,31 +49,44 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) setWindowTitle(tr("EmbLink Studio")); resize(960, 600); - auto *central = new QWidget(this); - auto *layout = new QVBoxLayout(central); - m_status = new QLabel(central); + m_workbench = new Workbench(this); + + auto *coreView = new QWidget; + auto *layout = new QVBoxLayout(coreView); + m_status = new QLabel(coreView); m_status->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); m_status->setWordWrap(true); - m_restart = new QPushButton(tr("&Restart the core"), central); + m_restart = new QPushButton(tr("&Restart the core"), coreView); m_restart->setVisible(false); layout->addWidget(m_status); layout->addWidget(m_restart, 0, Qt::AlignLeft); layout->addStretch(); - setCentralWidget(central); - // QDockWidget until Qt Advanced Docking System lands (decided: spec section 11, question 1). - auto *dock = new QDockWidget(tr("Core log"), this); - dock->setObjectName(QStringLiteral("coreLog")); - m_log = new QPlainTextEdit(dock); + m_log = new QPlainTextEdit; m_log->setReadOnly(true); m_log->setMaximumBlockCount(5000); - dock->setWidget(m_log); - addDockWidget(Qt::BottomDockWidgetArea, dock); + + // The ids name the views in saved layouts: keep them stable. + m_workbench->addView(QStringLiteral("core"), tr("Core"), coreView, ads::CenterDockWidgetArea); + m_workbench->addView(QStringLiteral("coreLog"), tr("Core log"), m_log, + ads::BottomDockWidgetArea); + m_workbench->captureDefaultLayout(); + { + QSettings settings; + settings.beginGroup(QStringLiteral("layout")); + m_workbench->restore(settings); + } QMenu *file = menuBar()->addMenu(tr("&File")); file->addAction(tr("&Quit"), QKeySequence::Quit, this, &QWidget::close); QMenu *view = menuBar()->addMenu(tr("&View")); - view->addAction(dock->toggleViewAction()); + for (ads::CDockWidget *v : m_workbench->views()) + view->addAction(v->toggleViewAction()); + view->addSeparator(); + m_layouts = view->addMenu(tr("&Layouts")); + connect(m_layouts, &QMenu::aboutToShow, this, &MainWindow::fillLayoutsMenu); + view->addAction(tr("&Save layout as..."), this, &MainWindow::saveLayoutAs); + view->addAction(tr("&Reset layout"), m_workbench, &Workbench::resetLayout); QMenu *help = menuBar()->addMenu(tr("&Help")); help->addAction(tr("&About EmbLink Studio"), this, &MainWindow::showAbout); @@ -127,8 +146,39 @@ void MainWindow::showAbout() dialog.exec(); } +void MainWindow::fillLayoutsMenu() +{ + m_layouts->clear(); + const QStringList names = m_workbench->namedLayouts(); + if (names.isEmpty()) { + m_layouts->addAction(tr("No saved layouts"))->setEnabled(false); + return; + } + for (const QString &name : names) + m_layouts->addAction(name, this, [this, name] { m_workbench->openNamedLayout(name); }); + m_layouts->addSeparator(); + QMenu *remove = m_layouts->addMenu(tr("&Delete")); + for (const QString &name : names) + remove->addAction(name, this, [this, name] { m_workbench->removeNamedLayout(name); }); +} + +void MainWindow::saveLayoutAs() +{ + bool ok = false; + const QString name = QInputDialog::getText(this, tr("Save layout"), + tr("Name of this layout, such as Debug:"), + QLineEdit::Normal, QString(), &ok) + .trimmed(); + if (ok && !name.isEmpty()) + m_workbench->saveNamedLayout(name); +} + void MainWindow::closeEvent(QCloseEvent *event) { + QSettings settings; + settings.beginGroup(QStringLiteral("layout")); + m_workbench->save(settings); + settings.endGroup(); m_core.stop(); event->accept(); } diff --git a/app/src/mainwindow.h b/app/src/mainwindow.h index b7a78a7..736be43 100644 --- a/app/src/mainwindow.h +++ b/app/src/mainwindow.h @@ -10,10 +10,12 @@ * * @details * Shows whether EmbLink Studio Core is connected, offers a restart when the core - * fails or stops unexpectedly, and shows the core's log in a dock. The window owns - * the CoreClient for the life of the application. + * fails or stops unexpectedly, and shows the core's log. Both are views of the + * Workbench, so they can be moved, split, floated and closed, and the layout is kept + * from one run to the next. The window owns the CoreClient for the life of the + * application. * - * @see Spec section 4; coreclient.h + * @see Spec sections 4 and 7; coreclient.h, workbench.h * @author Junior Deogracias * @date 2026-11-11 (created) */ @@ -25,12 +27,15 @@ #include class QLabel; +class QMenu; class QPlainTextEdit; class QPushButton; namespace emblinkstudio { +class Workbench; + // S0's window: the core's state, its log, and a restart if it stops (spec section 4). class MainWindow : public QMainWindow { @@ -46,8 +51,12 @@ class MainWindow : public QMainWindow void startCore(); void showAbout(); void setStatus(const QString &text, bool canRestart); + void fillLayoutsMenu(); + void saveLayoutAs(); CoreClient m_core; + Workbench *m_workbench = nullptr; + QMenu *m_layouts = nullptr; QLabel *m_status = nullptr; QPushButton *m_restart = nullptr; QPlainTextEdit *m_log = nullptr; diff --git a/app/src/workbench.cpp b/app/src/workbench.cpp new file mode 100644 index 0000000..ff896c0 --- /dev/null +++ b/app/src/workbench.cpp @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2026 Junior Deogracias +// +// This file is part of EmbLink Studio, the IDE for EmbLinkRTOS. +// Licensed under the Apache License, Version 2.0; see the LICENSE file at the repository root. + +/** + * @file workbench.cpp + * @brief Implementation of Workbench: placing views, layouts saved and restored. + * + * @details + * Layouts are Qt Advanced Docking System's own state, tagged with kLayoutVersion. + * Named layouts are its perspectives. In QSettings the current layout is the value + * "current" and the named ones the array "Perspectives", both under the caller's group. + * + * @see workbench.h + * @author Junior Deogracias + * @date 2026-11-11 (created) + */ + +#include "workbench.h" + +#include +#include +#include + +namespace emblinkstudio +{ + +namespace +{ + +// Config flags are global to the process, so they are set once, before the first manager. +void configureDocking() +{ + static bool done = false; + if (done) + return; + done = true; + using M = ads::CDockManager; + // Splitters resize live; every area has its close, undock and tabs-menu buttons. + M::setConfigFlags(M::DefaultOpaqueConfig); + M::setConfigFlag(M::FocusHighlighting, true); +} + +} // namespace + +Workbench::Workbench(QMainWindow *window) : QObject(window) +{ + configureDocking(); + m_manager = new ads::CDockManager(window); +} + +ads::CDockWidget *Workbench::addView(const QString &id, const QString &title, QWidget *content, + ads::DockWidgetArea area, ads::CDockWidget *tabWith) +{ + auto *view = new ads::CDockWidget(m_manager, title); + view->setObjectName(id); + view->setWidget(content); + // Every view can be moved, floated and closed: none is fixed in place. + view->setFeatures(ads::CDockWidget::DefaultDockWidgetFeatures); + if (tabWith && tabWith->dockAreaWidget()) + m_manager->addDockWidgetTabToArea(view, tabWith->dockAreaWidget()); + else + m_manager->addDockWidget(area, view); + m_views.append(view); + return view; +} + +void Workbench::captureDefaultLayout() +{ + m_default = saveLayout(); +} + +void Workbench::resetLayout() +{ + if (m_default.isEmpty()) + return; + for (ads::CDockWidget *view : std::as_const(m_views)) + view->toggleView(true); + restoreLayout(m_default); +} + +QByteArray Workbench::saveLayout() const +{ + return m_manager->saveState(kLayoutVersion); +} + +bool Workbench::restoreLayout(const QByteArray &state) +{ + return !state.isEmpty() && m_manager->restoreState(state, kLayoutVersion); +} + +void Workbench::saveNamedLayout(const QString &name) +{ + m_manager->addPerspective(name); + emit namedLayoutsChanged(); +} + +bool Workbench::openNamedLayout(const QString &name) +{ + if (!m_manager->perspectiveNames().contains(name)) + return false; + m_manager->openPerspective(name); + return true; +} + +void Workbench::removeNamedLayout(const QString &name) +{ + m_manager->removePerspective(name); + emit namedLayoutsChanged(); +} + +QStringList Workbench::namedLayouts() const +{ + return m_manager->perspectiveNames(); +} + +void Workbench::save(QSettings &settings) const +{ + settings.setValue(QStringLiteral("current"), saveLayout()); + m_manager->savePerspectives(settings); +} + +void Workbench::restore(QSettings &settings) +{ + m_manager->loadPerspectives(settings); + restoreLayout(settings.value(QStringLiteral("current")).toByteArray()); + emit namedLayoutsChanged(); +} + +} // namespace emblinkstudio diff --git a/app/src/workbench.h b/app/src/workbench.h new file mode 100644 index 0000000..4bbfff1 --- /dev/null +++ b/app/src/workbench.h @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2026 Junior Deogracias +// +// This file is part of EmbLink Studio, the IDE for EmbLinkRTOS. +// Licensed under the Apache License, Version 2.0; see the LICENSE file at the repository root. + +/** + * @file workbench.h + * @brief Workbench: the dockable layout of the main window. + * + * @details + * Every view is a dock of Qt Advanced Docking System (spec section 11, question 1): + * it can be moved, split, tabbed, floated onto another monitor, closed and reopened. + * No view is fixed in place (spec section 7, "The layout is the person's"). + * + * The Workbench places the views, remembers the default layout so it can be reset, + * saves and restores the current layout, and keeps layouts saved by name. It knows + * nothing about what the views show, so it is tested on its own. + * + * @see Spec sections 7 and 11; mainwindow.h + * @author Junior Deogracias + * @date 2026-11-11 (created) + */ + +#pragma once + +#include +#include +#include +#include +#include + +class QMainWindow; +class QSettings; + +namespace emblinkstudio +{ + +class Workbench : public QObject +{ + Q_OBJECT + + public: + // Becomes the window's central widget. + explicit Workbench(QMainWindow *window); + + // Adds a view in `area`, or as a tab beside `tabWith` when one is given. `id` names the + // view in saved layouts, so it must stay the same from one release to the next. + ads::CDockWidget *addView(const QString &id, const QString &title, QWidget *content, + ads::DockWidgetArea area, ads::CDockWidget *tabWith = nullptr); + + // Call once every view is placed: the layout at that moment is what Reset restores. + void captureDefaultLayout(); + void resetLayout(); + + QByteArray saveLayout() const; + // False, and the layout unchanged, if the state is from another layout version. + bool restoreLayout(const QByteArray &state); + + void saveNamedLayout(const QString &name); + bool openNamedLayout(const QString &name); + void removeNamedLayout(const QString &name); + QStringList namedLayouts() const; + + // The current layout and every named layout, under `settings`' current group. + void save(QSettings &settings) const; + void restore(QSettings &settings); + + QList views() const + { + return m_views; + } + ads::CDockManager *manager() const + { + return m_manager; + } + + // Bumped when a change to the views would make old saved layouts misleading. + static constexpr int kLayoutVersion = 1; + + signals: + void namedLayoutsChanged(); + + private: + ads::CDockManager *m_manager = nullptr; + QList m_views; + QByteArray m_default; +}; + +} // namespace emblinkstudio diff --git a/app/tests/tst_workbench.cpp b/app/tests/tst_workbench.cpp new file mode 100644 index 0000000..c0f15a0 --- /dev/null +++ b/app/tests/tst_workbench.cpp @@ -0,0 +1,180 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2026 Junior Deogracias +// +// This file is part of EmbLink Studio, the IDE for EmbLinkRTOS. +// Licensed under the Apache License, Version 2.0; see the LICENSE file at the repository root. + +/** + * @file tst_workbench.cpp + * @brief Qt Test suite for Workbench, the dockable layout. + * + * @details + * Checks the layout rule of spec section 7: every view can be moved, floated and closed; + * a layout saved is the layout restored, in a new window as after a restart; named + * layouts survive a restart through QSettings; Reset brings back the default; and a + * layout from another version is refused rather than half applied. + * + * @see workbench.h + * @author Junior Deogracias + * @date 2026-11-11 (created) + */ + +#include "workbench.h" + +#include +#include +#include +#include +#include +#include +#include + +using emblinkstudio::Workbench; + +namespace +{ + +// A window with three views: "editor" in the centre, "log" at the bottom and "console" +// as a tab beside the log: the default layout. +struct Window { + QMainWindow window; + Workbench *workbench = nullptr; + ads::CDockWidget *editor = nullptr; + ads::CDockWidget *log = nullptr; + ads::CDockWidget *console = nullptr; + + Window() + { + workbench = new Workbench(&window); + editor = workbench->addView(QStringLiteral("editor"), QStringLiteral("Editor"), + new QLabel(QStringLiteral("editor")), + ads::CenterDockWidgetArea); + log = workbench->addView(QStringLiteral("log"), QStringLiteral("Log"), + new QLabel(QStringLiteral("log")), ads::BottomDockWidgetArea); + console = workbench->addView(QStringLiteral("console"), QStringLiteral("Console"), + new QLabel(QStringLiteral("console")), + ads::BottomDockWidgetArea, log); + workbench->captureDefaultLayout(); + window.resize(1000, 700); + window.show(); + } + + // Moves the console out of the log's area, to the right of the editor. + void moveConsoleRight() + { + workbench->manager()->addDockWidget(ads::RightDockWidgetArea, console, + editor->dockAreaWidget()); + } + + bool consoleTabbedWithLog() const + { + return console->dockAreaWidget() == log->dockAreaWidget(); + } +}; + +} // namespace + +class TestWorkbench : public QObject +{ + Q_OBJECT + + private slots: + void noViewIsFixed() + { + Window w; + const auto needed = ads::CDockWidget::DockWidgetMovable | + ads::CDockWidget::DockWidgetFloatable | + ads::CDockWidget::DockWidgetClosable; + QCOMPARE(w.workbench->views().size(), 3); + for (ads::CDockWidget *view : w.workbench->views()) + QVERIFY2((view->features() & needed) == needed, qPrintable(view->objectName())); + } + + void defaultLayoutTabsTheConsoleWithTheLog() + { + Window w; + QVERIFY(w.consoleTabbedWithLog()); + QVERIFY(w.editor->dockAreaWidget() != w.log->dockAreaWidget()); + } + + void savedLayoutIsRestoredInANewWindow() + { + QByteArray state; + { + Window first; + first.moveConsoleRight(); + QVERIFY(!first.consoleTabbedWithLog()); + state = first.workbench->saveLayout(); + } + Window second; + QVERIFY(second.consoleTabbedWithLog()); + QVERIFY(second.workbench->restoreLayout(state)); + QVERIFY(!second.consoleTabbedWithLog()); + QVERIFY(second.console->dockAreaWidget() != second.editor->dockAreaWidget()); + } + + void closedViewStaysClosedAfterRestore() + { + QByteArray state; + { + Window first; + first.log->toggleView(false); + state = first.workbench->saveLayout(); + } + Window second; + QVERIFY(second.workbench->restoreLayout(state)); + QVERIFY(second.log->isClosed()); + QVERIFY(!second.console->isClosed()); + } + + void resetBringsBackTheDefault() + { + Window w; + w.moveConsoleRight(); + w.log->toggleView(false); + w.workbench->resetLayout(); + QVERIFY(w.consoleTabbedWithLog()); + QVERIFY(!w.log->isClosed()); + } + + void namedLayoutsSurviveARestart() + { + QTemporaryDir dir; + QVERIFY(dir.isValid()); + const QString ini = dir.filePath(QStringLiteral("layout.ini")); + { + Window first; + first.workbench->saveNamedLayout(QStringLiteral("Configure")); + first.moveConsoleRight(); + first.workbench->saveNamedLayout(QStringLiteral("Debug")); + QSettings settings(ini, QSettings::IniFormat); + first.workbench->save(settings); + } + Window second; + QSettings settings(ini, QSettings::IniFormat); + second.workbench->restore(settings); + QCOMPARE(second.workbench->namedLayouts(), + (QStringList{QStringLiteral("Configure"), QStringLiteral("Debug")})); + QVERIFY(!second.consoleTabbedWithLog()); // the current layout came back too + QVERIFY(second.workbench->openNamedLayout(QStringLiteral("Configure"))); + QVERIFY(second.consoleTabbedWithLog()); + QVERIFY(second.workbench->openNamedLayout(QStringLiteral("Debug"))); + QVERIFY(!second.consoleTabbedWithLog()); + QVERIFY(!second.workbench->openNamedLayout(QStringLiteral("No such layout"))); + } + + void layoutFromAnotherVersionIsRefused() + { + Window first; + first.moveConsoleRight(); + const QByteArray state = + first.workbench->manager()->saveState(Workbench::kLayoutVersion + 1); + Window second; + QVERIFY(!second.workbench->restoreLayout(state)); + QVERIFY(second.consoleTabbedWithLog()); + QVERIFY(!second.workbench->restoreLayout(QByteArray())); + } +}; + +QTEST_MAIN(TestWorkbench) +#include "tst_workbench.moc" diff --git a/docs/development.md b/docs/development.md index 078e05f..7fbb0fb 100644 --- a/docs/development.md +++ b/docs/development.md @@ -7,7 +7,10 @@ How to set up a machine, build and test EmbLink Studio, and get a change into `m CMake 3.21 or later, Ninja, Qt 6.8 or later, Python 3.11 or later, and clang-format 18 for C++ formatting (`pip install clang-format==18.1.8` gives the version CI runs). On macOS, Homebrew's `qt`, `cmake`, `ninja` and -`python` are enough. +`python` are enough. On Linux, also the `libxcb1-dev` package. + +The first `cmake --preset dev` downloads Qt Advanced Docking System, pinned by version and SHA-256 +in `CMakeLists.txt`, and builds it as a shared library. Later configures reuse it. ## Build and test diff --git a/docs/specification.md b/docs/specification.md index 9826836..bdfa1e0 100644 --- a/docs/specification.md +++ b/docs/specification.md @@ -236,6 +236,14 @@ The design is the developer's, within three principles: - Every number shown comes from the core, with its source one click away. - A change shows its effect (diagnostics, budget) before it is applied. +**The layout is the person's.** Every view is a dock of Qt Advanced Docking System (§11 q1), the editor and the drawn views included. It can be moved, split, tabbed, floated onto another monitor, closed and reopened, and no view is fixed in place. + +- The layout is saved when the window closes and restored when it opens: per project in `.emblink-studio/` (§6), and in the user's settings while no project is open. +- Layouts can be saved by name, such as Configure, Code and Debug, and opened from the View menu. Starting a debug session may switch to one, as a perspective does in other IDEs. +- Reset layout brings back the default. +- A view's id names it in saved layouts and never changes. A layout saved by another layout version is ignored, never half applied. +- Inside a view, the view lays out its own content. + | View | Shows and does | From | | --- | --- | --- | | **Start** | New project from a board or a template; recent projects | `project`, `board.list` | @@ -303,7 +311,7 @@ Until the module contract and `system.yaml` exist, S1 to S3 work on what exists: - **Widgets and Quick:** Qt Widgets for the frame, docking, tables and forms. Qt Quick, in `QQuickWidget`s, for the drawn views: pin map, clock tree, and later the trace timeline (§11). - **Third-party libraries:** only under licences compatible with the open core: MIT, BSD, Apache-2.0, LGPL linked dynamically, MPL-2.0. **No GPL libraries** in the application. Some terminal and docking widgets are GPL, so check each one. GPL tools (GDB, OpenOCD) run as separate programs and are never linked. Toolchains are downloaded from their publishers, not bundled. - **A notices list** of every component and its licence, C++ and Python alike, generated in CI and shown in the About box. CI fails on a licence that is not on the allowed list. -- **Tests:** Qt Test for the application; pytest for the core; JSON Schema checks of every message in both directions; golden projects (the RTOS's boards) whose generated outputs, YAML edits and builds are compared in CI; the GUI tested against a recorded core. +- **Tests:** Qt Test for the application; pytest for the core; JSON Schema checks of every message in both directions; golden projects (the RTOS's boards) whose generated outputs, YAML edits and builds are compared in CI; the GUI tested against a recorded core; a test that every view can be moved, floated and closed, and that a layout saved is the layout restored (§7). - **Reproducibility:** pinned dependencies, pinned toolchains with checksums, the lock file. The same project gives the same build in the IDE and on the command line. - **Code:** clang-format for C++, ruff for Python; every commit signed off (`Signed-off-by`, the DCO). - **Accessibility and languages:** keyboard navigation throughout; Qt's translation system from the start, even with only English at first. diff --git a/third_party/components.json b/third_party/components.json index 62cad3f..4fbc11b 100644 --- a/third_party/components.json +++ b/third_party/components.json @@ -6,10 +6,23 @@ "version": "6.8", "licence": "LGPL-3.0-only", "linkage": "dynamic", - "modules": ["Qt Core", "Qt GUI", "Qt Widgets"], + "modules": [ + "Qt Core", + "Qt GUI", + "Qt Widgets" + ], "url": "https://www.qt.io/", "source": "https://download.qt.io/official_releases/qt/", "used_by": "the desktop application" + }, + { + "name": "Qt Advanced Docking System", + "version": "5.1.1", + "licence": "LGPL-2.1-or-later", + "linkage": "dynamic", + "url": "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System", + "source": "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/archive/refs/tags/v5.1.1.tar.gz", + "used_by": "the desktop application: docking and layouts" } ] }