Loading debian/changelog +9 −0 Changes for debian/changelog: 9 added lines, 0 removed lines. Original line number Diff line number Diff line blogi (20260419+1) unstable; urgency=medium * Editor: tab support for multiple open documents * File browser: double-click or context menu to open files in tabs * Text file editing with monospace editor for non-XML files * Ctrl+S saves both XML widget documents and plain text files -- Jan Koester <jan.koester@tuxist.de> Sat, 19 Apr 2026 12:00:00 +0200 blogi (20260418+7) unstable; urgency=medium * File browser: move files to folders via context menu Loading editor/localapi.cpp +237 −16 Changes for editor/localapi.cpp: 237 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -178,7 +178,186 @@ void LocalApi::renderPreviewOnServer(bool mobile, const QString &target, const Q }); } /* File Browser */ /* ---------- Tab management ---------- */ int LocalApi::currentTabIndex() const { return _activeTab; } int LocalApi::tabCount() const { return _tabs.size(); } QString LocalApi::getTabsJson() const { QJsonArray arr; for (int i = 0; i < _tabs.size(); ++i) { QJsonObject obj; obj["path"] = _tabs[i].filePath; obj["modified"] = _tabs[i].modified; obj["active"] = (i == _activeTab); obj["isTextFile"] = _tabs[i].isTextFile; // Display name: filename or "Untitled" if (_tabs[i].filePath.isEmpty()) obj["name"] = QString("Untitled"); else obj["name"] = QFileInfo(_tabs[i].filePath).fileName(); arr.append(obj); } return QString::fromUtf8(QJsonDocument(arr).toJson(QJsonDocument::Compact)); } void LocalApi::storeCurrentTab() { if (_activeTab >= 0 && _activeTab < _tabs.size()) { _tabs[_activeTab].filePath = _currentFile; if (!_tabs[_activeTab].isTextFile) _tabs[_activeTab].xmlContent = _doc->exportXml(); } } void LocalApi::loadTab(int index) { if (index < 0 || index >= _tabs.size()) return; _activeTab = index; const TabInfo &tab = _tabs[index]; if (tab.isTextFile) { // Text file — emit content for the QML text editor emit textContentChanged(tab.textContent); } else if (!tab.xmlContent.isEmpty()) { _doc->importXml(tab.xmlContent); } else if (!tab.filePath.isEmpty()) { _doc->loadFromFile(tab.filePath); } else { _doc->newDocument(); } _currentFile = tab.filePath; emit currentFileChanged(_currentFile); emit documentChanged(); } void LocalApi::openFileInTab(const QString &path) { if (path.isEmpty()) return; // Check if already open in a tab for (int i = 0; i < _tabs.size(); ++i) { if (_tabs[i].filePath == path) { if (i != _activeTab) { storeCurrentTab(); loadTab(i); emit tabsChanged(); } return; } } // Save current tab state storeCurrentTab(); // Determine if this is an XML widget file or a plain text file QString suffix = QFileInfo(path).suffix().toLower(); bool isXml = (suffix == "xml"); // Create new tab TabInfo tab; tab.filePath = path; tab.isTextFile = !isXml; if (isXml) { if (_doc->loadFromFile(path)) { tab.xmlContent = _doc->exportXml(); } } else { QFile file(path); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file); tab.textContent = in.readAll(); file.close(); } } _tabs.append(tab); _activeTab = _tabs.size() - 1; _currentFile = path; emit currentFileChanged(_currentFile); if (tab.isTextFile) { emit textContentChanged(tab.textContent); } emit documentChanged(); emit tabsChanged(); emit statusMessage("Opened: " + QFileInfo(path).fileName()); } void LocalApi::newTab() { storeCurrentTab(); TabInfo tab; _tabs.append(tab); _activeTab = _tabs.size() - 1; _doc->newDocument(); _currentFile.clear(); emit currentFileChanged(_currentFile); emit documentChanged(); emit tabsChanged(); emit statusMessage("New tab"); } void LocalApi::closeTab(int index) { if (index < 0 || index >= _tabs.size()) return; if (_tabs.size() == 1) { // Last tab — reset to empty document _tabs[0].filePath.clear(); _tabs[0].xmlContent.clear(); _tabs[0].textContent.clear(); _tabs[0].modified = false; _tabs[0].isTextFile = false; _activeTab = 0; _doc->newDocument(); _currentFile.clear(); emit currentFileChanged(_currentFile); emit documentChanged(); emit tabsChanged(); return; } _tabs.removeAt(index); if (_activeTab >= _tabs.size()) _activeTab = _tabs.size() - 1; else if (_activeTab > index) _activeTab--; else if (_activeTab == index) { _activeTab = qMin(index, _tabs.size() - 1); } loadTab(_activeTab); emit tabsChanged(); } void LocalApi::switchToTab(int index) { if (index < 0 || index >= _tabs.size() || index == _activeTab) return; storeCurrentTab(); loadTab(index); emit tabsChanged(); } bool LocalApi::isActiveTabTextFile() const { if (_activeTab >= 0 && _activeTab < _tabs.size()) return _tabs[_activeTab].isTextFile; return false; } QString LocalApi::getActiveTabTextContent() const { if (_activeTab >= 0 && _activeTab < _tabs.size()) return _tabs[_activeTab].textContent; return QString(); } void LocalApi::setActiveTabTextContent(const QString &content) { if (_activeTab >= 0 && _activeTab < _tabs.size() && _tabs[_activeTab].isTextFile) { _tabs[_activeTab].textContent = content; _tabs[_activeTab].modified = true; emit tabsChanged(); } } /* ---------- File Browser ---------- */ QString LocalApi::getLastBrowserFolder() { QSettings settings; return settings.value("lastBrowserFolder", QDir::homePath()).toString(); Loading Loading @@ -396,11 +575,7 @@ QString LocalApi::gitLog(int maxCount) { } void LocalApi::newDocument() { _doc->newDocument(); _currentFile.clear(); emit currentFileChanged(_currentFile); emit documentChanged(); emit statusMessage("New document created"); newTab(); } void LocalApi::openDocument() { Loading @@ -408,14 +583,7 @@ void LocalApi::openDocument() { nullptr, "Open Document", QString(), "XML Files (*.xml);;All Files (*)"); if (path.isEmpty()) return; if (_doc->loadFromFile(path)) { _currentFile = path; emit currentFileChanged(_currentFile); emit documentChanged(); emit statusMessage("Opened: " + path); } else { emit statusMessage("Failed to load " + path); } openFileInTab(path); } void LocalApi::importHtmlFile() { Loading @@ -438,6 +606,12 @@ bool LocalApi::importHtml(const QString &html) { if (_doc->importHtml(html)) { _currentFile.clear(); emit currentFileChanged(_currentFile); if (_activeTab >= 0 && _activeTab < _tabs.size()) { _tabs[_activeTab].filePath.clear(); _tabs[_activeTab].modified = true; _tabs[_activeTab].xmlContent = _doc->exportXml(); emit tabsChanged(); } emit documentChanged(); emit statusMessage("HTML erfolgreich importiert!"); return true; Loading Loading @@ -518,7 +692,24 @@ void LocalApi::saveDocument() { saveAsDocument(); return; } // Text file tab — write text content directly if (_activeTab >= 0 && _activeTab < _tabs.size() && _tabs[_activeTab].isTextFile) { if (writeTextFile(_currentFile, _tabs[_activeTab].textContent)) { _tabs[_activeTab].modified = false; emit tabsChanged(); emit statusMessage("Saved: " + _currentFile); } else { emit statusMessage("Failed to save " + _currentFile); } return; } // XML document tab if (_doc->saveToFile(_currentFile)) { if (_activeTab >= 0 && _activeTab < _tabs.size()) { _tabs[_activeTab].modified = false; _tabs[_activeTab].xmlContent = _doc->exportXml(); emit tabsChanged(); } emit statusMessage("Saved: " + _currentFile); } else { emit statusMessage("Failed to save " + _currentFile); Loading @@ -526,18 +717,42 @@ void LocalApi::saveDocument() { } void LocalApi::saveAsDocument() { QString path = QFileDialog::getSaveFileName( nullptr, "Save Document", QString(), "XML Files (*.xml);;All Files (*)"); QString filter; if (_activeTab >= 0 && _activeTab < _tabs.size() && _tabs[_activeTab].isTextFile) filter = "All Files (*)"; else filter = "XML Files (*.xml);;All Files (*)"; QString path = QFileDialog::getSaveFileName(nullptr, "Save Document", QString(), filter); if (path.isEmpty()) return; if (_activeTab >= 0 && _activeTab < _tabs.size() && _tabs[_activeTab].isTextFile) { if (writeTextFile(path, _tabs[_activeTab].textContent)) { _currentFile = path; emit currentFileChanged(_currentFile); _tabs[_activeTab].filePath = path; _tabs[_activeTab].modified = false; emit tabsChanged(); emit statusMessage("Saved: " + path); } else { emit statusMessage("Failed to save " + path); } } else { if (_doc->saveToFile(path)) { _currentFile = path; emit currentFileChanged(_currentFile); if (_activeTab >= 0 && _activeTab < _tabs.size()) { _tabs[_activeTab].filePath = path; _tabs[_activeTab].modified = false; _tabs[_activeTab].xmlContent = _doc->exportXml(); emit tabsChanged(); } emit statusMessage("Saved: " + path); } else { emit statusMessage("Failed to save " + path); } } } void LocalApi::publishToServer() { if (!_pub->isConfigured()) { Loading Loading @@ -933,6 +1148,12 @@ void LocalApi::publishToTargetOverwrite(const QString &target, const QString &pa } void LocalApi::refresh() { if (_tabs.isEmpty()) { TabInfo tab; _tabs.append(tab); _activeTab = 0; emit tabsChanged(); } emit documentChanged(); } Loading editor/localapi.h +28 −0 Changes for editor/localapi.h: 28 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -29,8 +29,17 @@ #include <QObject> #include <QString> #include <QList> #include "gitfilesystemmodel.h" struct TabInfo { QString filePath; QString xmlContent; QString textContent; bool modified = false; bool isTextFile = false; }; class DocumentManager; class PublishClient; Loading Loading @@ -94,6 +103,18 @@ public: Q_INVOKABLE QString collectRepeaterParams(QObject *repeater); Q_INVOKABLE QString jsonSet(const QString &json, const QString &key, const QString &value); /* Tab management */ Q_INVOKABLE int currentTabIndex() const; Q_INVOKABLE int tabCount() const; Q_INVOKABLE QString getTabsJson() const; Q_INVOKABLE void openFileInTab(const QString &path); Q_INVOKABLE void newTab(); Q_INVOKABLE void closeTab(int index); Q_INVOKABLE void switchToTab(int index); Q_INVOKABLE bool isActiveTabTextFile() const; Q_INVOKABLE QString getActiveTabTextContent() const; Q_INVOKABLE void setActiveTabTextContent(const QString &content); /* File Browser */ Q_INVOKABLE QString getLastBrowserFolder(); Q_INVOKABLE void setLastBrowserFolder(const QString &path); Loading Loading @@ -161,10 +182,17 @@ signals: void surveyDeleted(bool ok, const QString &msg); void savedConnectionsChanged(); void gitOperationFinished(bool ok, const QString &msg); void tabsChanged(); void textContentChanged(const QString &content); private: DocumentManager *_doc; PublishClient *_pub; QString _currentFile; GitFileSystemModel *_fsModel; QList<TabInfo> _tabs; int _activeTab = -1; void storeCurrentTab(); void loadTab(int index); }; editor/qml/FileBrowserTab.qml +15 −1 Changes for editor/qml/FileBrowserTab.qml: 15 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -81,8 +81,9 @@ Item { anchors.fill: parent onClicked: (mouse) => { if (mouse.button === Qt.LeftButton) { if (model.isDirectory) { fileTree.toggleExpanded(row) // In future: open file if !model.isDirectory } } else if (mouse.button === Qt.RightButton) { ctxMenu.targetPath = model.filePath ctxMenu.targetName = model.fileName Loading @@ -90,6 +91,11 @@ Item { ctxMenu.popup() } } onDoubleClicked: (mouse) => { if (mouse.button === Qt.LeftButton && !model.isDirectory) { localApi.openFileInTab(model.filePath) } } } } } Loading @@ -101,6 +107,14 @@ Item { property string targetName: "" property bool isDir: false Action { text: qsTr("Open") enabled: !ctxMenu.isDir onTriggered: { localApi.openFileInTab(ctxMenu.targetPath) } } MenuSeparator {} Action { text: qsTr("Rename") onTriggered: { Loading editor/qml/Main.qml +126 −3 Changes for editor/qml/Main.qml: 126 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ ApplicationWindow { color: Theme.bgPrimary property string currentFile: "" property bool activeTabIsText: false menuBar: MenuBar { background: Rectangle { color: Theme.bgSecondary } Loading Loading @@ -114,10 +115,99 @@ ApplicationWindow { } } /* ---- Preview (WebEngine) ---- */ /* ---- Preview (WebEngine) with document tabs ---- */ ColumnLayout { SplitView.fillWidth: true spacing: 0 RowLayout { Layout.fillWidth: true spacing: 0 TabBar { id: documentTabs Layout.fillWidth: true background: Rectangle { color: Theme.bgSecondary } Repeater { id: tabRepeater model: ListModel { id: tabModel } TabButton { text: model.name + (model.modified ? " *" : "") width: Math.min(implicitWidth + 32, 200) onClicked: localApi.switchToTab(index) contentItem: RowLayout { spacing: 4 Label { text: model.name + (model.modified ? " *" : "") elide: Text.ElideRight Layout.fillWidth: true color: Theme.textPrimary font.pixelSize: 12 } ToolButton { text: "✕" font.pixelSize: 10 implicitWidth: 20 implicitHeight: 20 onClicked: localApi.closeTab(index) } } } } } ToolButton { text: "+" font.pixelSize: 14 implicitWidth: 28 implicitHeight: 28 onClicked: localApi.newTab() ToolTip.text: qsTr("New Tab") ToolTip.visible: hovered } } PreviewPane { id: previewFrame SplitView.fillWidth: true Layout.fillWidth: true Layout.fillHeight: true visible: !activeTabIsText } ScrollView { Layout.fillWidth: true Layout.fillHeight: true visible: activeTabIsText clip: true TextArea { id: textEditor font.family: "Monospace" font.pixelSize: 13 wrapMode: TextArea.NoWrap selectByMouse: true color: Theme.textPrimary background: Rectangle { color: Theme.bgPrimary } property bool ignoreChanges: false onTextChanged: { if (!ignoreChanges && activeTabIsText) { localApi.setActiveTabTextContent(text) } } Keys.onPressed: (event) => { if (event.key === Qt.Key_S && (event.modifiers & Qt.ControlModifier)) { localApi.saveDocument() event.accepted = true } } } } } /* ---- Connection Manager + Publish Settings (right) ---- */ Loading Loading @@ -171,21 +261,54 @@ ApplicationWindow { function setStatus(msg) { statusLabel.text = msg } Component.onCompleted: localApi.refresh() Component.onCompleted: { localApi.refresh() reloadTabs() } Connections { target: localApi function onDocumentChanged() { if (!activeTabIsText) { docTree.reload() previewFrame.reload() connPanelInst.requestServerPreview() } } function onStatusMessage(msg) { statusLabel.text = msg } function onCurrentFileChanged(path) { root.currentFile = path } function onTabsChanged() { reloadTabs() } function onTextContentChanged(content) { textEditor.ignoreChanges = true textEditor.text = content textEditor.ignoreChanges = false } } function reloadTabs() { var json = localApi.getTabsJson() var tabs = JSON.parse(json) tabModel.clear() var activeIdx = 0 for (var i = 0; i < tabs.length; i++) { tabModel.append({ "name": tabs[i].name, "path": tabs[i].path, "modified": tabs[i].modified, "isTextFile": tabs[i].isTextFile }) if (tabs[i].active) { activeIdx = i activeTabIsText = tabs[i].isTextFile } } documentTabs.currentIndex = activeIdx } AiPromptDialog { id: aiPromptDlg } Loading Loading
debian/changelog +9 −0 Changes for debian/changelog: 9 added lines, 0 removed lines. Original line number Diff line number Diff line blogi (20260419+1) unstable; urgency=medium * Editor: tab support for multiple open documents * File browser: double-click or context menu to open files in tabs * Text file editing with monospace editor for non-XML files * Ctrl+S saves both XML widget documents and plain text files -- Jan Koester <jan.koester@tuxist.de> Sat, 19 Apr 2026 12:00:00 +0200 blogi (20260418+7) unstable; urgency=medium * File browser: move files to folders via context menu Loading
editor/localapi.cpp +237 −16 Changes for editor/localapi.cpp: 237 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -178,7 +178,186 @@ void LocalApi::renderPreviewOnServer(bool mobile, const QString &target, const Q }); } /* File Browser */ /* ---------- Tab management ---------- */ int LocalApi::currentTabIndex() const { return _activeTab; } int LocalApi::tabCount() const { return _tabs.size(); } QString LocalApi::getTabsJson() const { QJsonArray arr; for (int i = 0; i < _tabs.size(); ++i) { QJsonObject obj; obj["path"] = _tabs[i].filePath; obj["modified"] = _tabs[i].modified; obj["active"] = (i == _activeTab); obj["isTextFile"] = _tabs[i].isTextFile; // Display name: filename or "Untitled" if (_tabs[i].filePath.isEmpty()) obj["name"] = QString("Untitled"); else obj["name"] = QFileInfo(_tabs[i].filePath).fileName(); arr.append(obj); } return QString::fromUtf8(QJsonDocument(arr).toJson(QJsonDocument::Compact)); } void LocalApi::storeCurrentTab() { if (_activeTab >= 0 && _activeTab < _tabs.size()) { _tabs[_activeTab].filePath = _currentFile; if (!_tabs[_activeTab].isTextFile) _tabs[_activeTab].xmlContent = _doc->exportXml(); } } void LocalApi::loadTab(int index) { if (index < 0 || index >= _tabs.size()) return; _activeTab = index; const TabInfo &tab = _tabs[index]; if (tab.isTextFile) { // Text file — emit content for the QML text editor emit textContentChanged(tab.textContent); } else if (!tab.xmlContent.isEmpty()) { _doc->importXml(tab.xmlContent); } else if (!tab.filePath.isEmpty()) { _doc->loadFromFile(tab.filePath); } else { _doc->newDocument(); } _currentFile = tab.filePath; emit currentFileChanged(_currentFile); emit documentChanged(); } void LocalApi::openFileInTab(const QString &path) { if (path.isEmpty()) return; // Check if already open in a tab for (int i = 0; i < _tabs.size(); ++i) { if (_tabs[i].filePath == path) { if (i != _activeTab) { storeCurrentTab(); loadTab(i); emit tabsChanged(); } return; } } // Save current tab state storeCurrentTab(); // Determine if this is an XML widget file or a plain text file QString suffix = QFileInfo(path).suffix().toLower(); bool isXml = (suffix == "xml"); // Create new tab TabInfo tab; tab.filePath = path; tab.isTextFile = !isXml; if (isXml) { if (_doc->loadFromFile(path)) { tab.xmlContent = _doc->exportXml(); } } else { QFile file(path); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file); tab.textContent = in.readAll(); file.close(); } } _tabs.append(tab); _activeTab = _tabs.size() - 1; _currentFile = path; emit currentFileChanged(_currentFile); if (tab.isTextFile) { emit textContentChanged(tab.textContent); } emit documentChanged(); emit tabsChanged(); emit statusMessage("Opened: " + QFileInfo(path).fileName()); } void LocalApi::newTab() { storeCurrentTab(); TabInfo tab; _tabs.append(tab); _activeTab = _tabs.size() - 1; _doc->newDocument(); _currentFile.clear(); emit currentFileChanged(_currentFile); emit documentChanged(); emit tabsChanged(); emit statusMessage("New tab"); } void LocalApi::closeTab(int index) { if (index < 0 || index >= _tabs.size()) return; if (_tabs.size() == 1) { // Last tab — reset to empty document _tabs[0].filePath.clear(); _tabs[0].xmlContent.clear(); _tabs[0].textContent.clear(); _tabs[0].modified = false; _tabs[0].isTextFile = false; _activeTab = 0; _doc->newDocument(); _currentFile.clear(); emit currentFileChanged(_currentFile); emit documentChanged(); emit tabsChanged(); return; } _tabs.removeAt(index); if (_activeTab >= _tabs.size()) _activeTab = _tabs.size() - 1; else if (_activeTab > index) _activeTab--; else if (_activeTab == index) { _activeTab = qMin(index, _tabs.size() - 1); } loadTab(_activeTab); emit tabsChanged(); } void LocalApi::switchToTab(int index) { if (index < 0 || index >= _tabs.size() || index == _activeTab) return; storeCurrentTab(); loadTab(index); emit tabsChanged(); } bool LocalApi::isActiveTabTextFile() const { if (_activeTab >= 0 && _activeTab < _tabs.size()) return _tabs[_activeTab].isTextFile; return false; } QString LocalApi::getActiveTabTextContent() const { if (_activeTab >= 0 && _activeTab < _tabs.size()) return _tabs[_activeTab].textContent; return QString(); } void LocalApi::setActiveTabTextContent(const QString &content) { if (_activeTab >= 0 && _activeTab < _tabs.size() && _tabs[_activeTab].isTextFile) { _tabs[_activeTab].textContent = content; _tabs[_activeTab].modified = true; emit tabsChanged(); } } /* ---------- File Browser ---------- */ QString LocalApi::getLastBrowserFolder() { QSettings settings; return settings.value("lastBrowserFolder", QDir::homePath()).toString(); Loading Loading @@ -396,11 +575,7 @@ QString LocalApi::gitLog(int maxCount) { } void LocalApi::newDocument() { _doc->newDocument(); _currentFile.clear(); emit currentFileChanged(_currentFile); emit documentChanged(); emit statusMessage("New document created"); newTab(); } void LocalApi::openDocument() { Loading @@ -408,14 +583,7 @@ void LocalApi::openDocument() { nullptr, "Open Document", QString(), "XML Files (*.xml);;All Files (*)"); if (path.isEmpty()) return; if (_doc->loadFromFile(path)) { _currentFile = path; emit currentFileChanged(_currentFile); emit documentChanged(); emit statusMessage("Opened: " + path); } else { emit statusMessage("Failed to load " + path); } openFileInTab(path); } void LocalApi::importHtmlFile() { Loading @@ -438,6 +606,12 @@ bool LocalApi::importHtml(const QString &html) { if (_doc->importHtml(html)) { _currentFile.clear(); emit currentFileChanged(_currentFile); if (_activeTab >= 0 && _activeTab < _tabs.size()) { _tabs[_activeTab].filePath.clear(); _tabs[_activeTab].modified = true; _tabs[_activeTab].xmlContent = _doc->exportXml(); emit tabsChanged(); } emit documentChanged(); emit statusMessage("HTML erfolgreich importiert!"); return true; Loading Loading @@ -518,7 +692,24 @@ void LocalApi::saveDocument() { saveAsDocument(); return; } // Text file tab — write text content directly if (_activeTab >= 0 && _activeTab < _tabs.size() && _tabs[_activeTab].isTextFile) { if (writeTextFile(_currentFile, _tabs[_activeTab].textContent)) { _tabs[_activeTab].modified = false; emit tabsChanged(); emit statusMessage("Saved: " + _currentFile); } else { emit statusMessage("Failed to save " + _currentFile); } return; } // XML document tab if (_doc->saveToFile(_currentFile)) { if (_activeTab >= 0 && _activeTab < _tabs.size()) { _tabs[_activeTab].modified = false; _tabs[_activeTab].xmlContent = _doc->exportXml(); emit tabsChanged(); } emit statusMessage("Saved: " + _currentFile); } else { emit statusMessage("Failed to save " + _currentFile); Loading @@ -526,18 +717,42 @@ void LocalApi::saveDocument() { } void LocalApi::saveAsDocument() { QString path = QFileDialog::getSaveFileName( nullptr, "Save Document", QString(), "XML Files (*.xml);;All Files (*)"); QString filter; if (_activeTab >= 0 && _activeTab < _tabs.size() && _tabs[_activeTab].isTextFile) filter = "All Files (*)"; else filter = "XML Files (*.xml);;All Files (*)"; QString path = QFileDialog::getSaveFileName(nullptr, "Save Document", QString(), filter); if (path.isEmpty()) return; if (_activeTab >= 0 && _activeTab < _tabs.size() && _tabs[_activeTab].isTextFile) { if (writeTextFile(path, _tabs[_activeTab].textContent)) { _currentFile = path; emit currentFileChanged(_currentFile); _tabs[_activeTab].filePath = path; _tabs[_activeTab].modified = false; emit tabsChanged(); emit statusMessage("Saved: " + path); } else { emit statusMessage("Failed to save " + path); } } else { if (_doc->saveToFile(path)) { _currentFile = path; emit currentFileChanged(_currentFile); if (_activeTab >= 0 && _activeTab < _tabs.size()) { _tabs[_activeTab].filePath = path; _tabs[_activeTab].modified = false; _tabs[_activeTab].xmlContent = _doc->exportXml(); emit tabsChanged(); } emit statusMessage("Saved: " + path); } else { emit statusMessage("Failed to save " + path); } } } void LocalApi::publishToServer() { if (!_pub->isConfigured()) { Loading Loading @@ -933,6 +1148,12 @@ void LocalApi::publishToTargetOverwrite(const QString &target, const QString &pa } void LocalApi::refresh() { if (_tabs.isEmpty()) { TabInfo tab; _tabs.append(tab); _activeTab = 0; emit tabsChanged(); } emit documentChanged(); } Loading
editor/localapi.h +28 −0 Changes for editor/localapi.h: 28 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -29,8 +29,17 @@ #include <QObject> #include <QString> #include <QList> #include "gitfilesystemmodel.h" struct TabInfo { QString filePath; QString xmlContent; QString textContent; bool modified = false; bool isTextFile = false; }; class DocumentManager; class PublishClient; Loading Loading @@ -94,6 +103,18 @@ public: Q_INVOKABLE QString collectRepeaterParams(QObject *repeater); Q_INVOKABLE QString jsonSet(const QString &json, const QString &key, const QString &value); /* Tab management */ Q_INVOKABLE int currentTabIndex() const; Q_INVOKABLE int tabCount() const; Q_INVOKABLE QString getTabsJson() const; Q_INVOKABLE void openFileInTab(const QString &path); Q_INVOKABLE void newTab(); Q_INVOKABLE void closeTab(int index); Q_INVOKABLE void switchToTab(int index); Q_INVOKABLE bool isActiveTabTextFile() const; Q_INVOKABLE QString getActiveTabTextContent() const; Q_INVOKABLE void setActiveTabTextContent(const QString &content); /* File Browser */ Q_INVOKABLE QString getLastBrowserFolder(); Q_INVOKABLE void setLastBrowserFolder(const QString &path); Loading Loading @@ -161,10 +182,17 @@ signals: void surveyDeleted(bool ok, const QString &msg); void savedConnectionsChanged(); void gitOperationFinished(bool ok, const QString &msg); void tabsChanged(); void textContentChanged(const QString &content); private: DocumentManager *_doc; PublishClient *_pub; QString _currentFile; GitFileSystemModel *_fsModel; QList<TabInfo> _tabs; int _activeTab = -1; void storeCurrentTab(); void loadTab(int index); };
editor/qml/FileBrowserTab.qml +15 −1 Changes for editor/qml/FileBrowserTab.qml: 15 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -81,8 +81,9 @@ Item { anchors.fill: parent onClicked: (mouse) => { if (mouse.button === Qt.LeftButton) { if (model.isDirectory) { fileTree.toggleExpanded(row) // In future: open file if !model.isDirectory } } else if (mouse.button === Qt.RightButton) { ctxMenu.targetPath = model.filePath ctxMenu.targetName = model.fileName Loading @@ -90,6 +91,11 @@ Item { ctxMenu.popup() } } onDoubleClicked: (mouse) => { if (mouse.button === Qt.LeftButton && !model.isDirectory) { localApi.openFileInTab(model.filePath) } } } } } Loading @@ -101,6 +107,14 @@ Item { property string targetName: "" property bool isDir: false Action { text: qsTr("Open") enabled: !ctxMenu.isDir onTriggered: { localApi.openFileInTab(ctxMenu.targetPath) } } MenuSeparator {} Action { text: qsTr("Rename") onTriggered: { Loading
editor/qml/Main.qml +126 −3 Changes for editor/qml/Main.qml: 126 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ ApplicationWindow { color: Theme.bgPrimary property string currentFile: "" property bool activeTabIsText: false menuBar: MenuBar { background: Rectangle { color: Theme.bgSecondary } Loading Loading @@ -114,10 +115,99 @@ ApplicationWindow { } } /* ---- Preview (WebEngine) ---- */ /* ---- Preview (WebEngine) with document tabs ---- */ ColumnLayout { SplitView.fillWidth: true spacing: 0 RowLayout { Layout.fillWidth: true spacing: 0 TabBar { id: documentTabs Layout.fillWidth: true background: Rectangle { color: Theme.bgSecondary } Repeater { id: tabRepeater model: ListModel { id: tabModel } TabButton { text: model.name + (model.modified ? " *" : "") width: Math.min(implicitWidth + 32, 200) onClicked: localApi.switchToTab(index) contentItem: RowLayout { spacing: 4 Label { text: model.name + (model.modified ? " *" : "") elide: Text.ElideRight Layout.fillWidth: true color: Theme.textPrimary font.pixelSize: 12 } ToolButton { text: "✕" font.pixelSize: 10 implicitWidth: 20 implicitHeight: 20 onClicked: localApi.closeTab(index) } } } } } ToolButton { text: "+" font.pixelSize: 14 implicitWidth: 28 implicitHeight: 28 onClicked: localApi.newTab() ToolTip.text: qsTr("New Tab") ToolTip.visible: hovered } } PreviewPane { id: previewFrame SplitView.fillWidth: true Layout.fillWidth: true Layout.fillHeight: true visible: !activeTabIsText } ScrollView { Layout.fillWidth: true Layout.fillHeight: true visible: activeTabIsText clip: true TextArea { id: textEditor font.family: "Monospace" font.pixelSize: 13 wrapMode: TextArea.NoWrap selectByMouse: true color: Theme.textPrimary background: Rectangle { color: Theme.bgPrimary } property bool ignoreChanges: false onTextChanged: { if (!ignoreChanges && activeTabIsText) { localApi.setActiveTabTextContent(text) } } Keys.onPressed: (event) => { if (event.key === Qt.Key_S && (event.modifiers & Qt.ControlModifier)) { localApi.saveDocument() event.accepted = true } } } } } /* ---- Connection Manager + Publish Settings (right) ---- */ Loading Loading @@ -171,21 +261,54 @@ ApplicationWindow { function setStatus(msg) { statusLabel.text = msg } Component.onCompleted: localApi.refresh() Component.onCompleted: { localApi.refresh() reloadTabs() } Connections { target: localApi function onDocumentChanged() { if (!activeTabIsText) { docTree.reload() previewFrame.reload() connPanelInst.requestServerPreview() } } function onStatusMessage(msg) { statusLabel.text = msg } function onCurrentFileChanged(path) { root.currentFile = path } function onTabsChanged() { reloadTabs() } function onTextContentChanged(content) { textEditor.ignoreChanges = true textEditor.text = content textEditor.ignoreChanges = false } } function reloadTabs() { var json = localApi.getTabsJson() var tabs = JSON.parse(json) tabModel.clear() var activeIdx = 0 for (var i = 0; i < tabs.length; i++) { tabModel.append({ "name": tabs[i].name, "path": tabs[i].path, "modified": tabs[i].modified, "isTextFile": tabs[i].isTextFile }) if (tabs[i].active) { activeIdx = i activeTabIsText = tabs[i].isTextFile } } documentTabs.currentIndex = activeIdx } AiPromptDialog { id: aiPromptDlg } Loading