Skip to content

Commit 7e3e308

Browse files
committed
Fix window file behavior on macOS
1 parent c132cd3 commit 7e3e308

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

src/libs/application/uishell/src/qml/ProjectWindow.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ Window {
208208
source: window.icon
209209
Layout.preferredWidth: 16
210210
Layout.preferredHeight: 16
211+
sourceSize.width: 16
212+
sourceSize.height: 16
211213
}
212214
Text {
213215
readonly property color _baseColor: !titleTextGroup.menuBarMergedInTitleBar ? Theme.foregroundPrimaryColor : Theme.foregroundSecondaryColor

src/plugins/coreplugin/qml/windows/ProjectWindow.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ProjectWindow {
2121
frameless: BehaviorPreference.uiBehavior & BehaviorPreference.UB_Frameless
2222
useSeparatedMenu: !(BehaviorPreference.uiBehavior & BehaviorPreference.UB_MergeMenuAndTitleBar)
2323
documentName: [
24-
((BehaviorPreference.uiBehavior & BehaviorPreference.UB_FullPath) ? windowHandle.projectDocumentContext.fileLocker?.path : windowHandle.projectDocumentContext.fileLocker?.entryName) || qsTr("Untitled"),
24+
((BehaviorPreference.uiBehavior & BehaviorPreference.UB_FullPath) ? windowHandle.projectDocumentContext.fileLocker?.path : windowHandle.projectDocumentContext.fileLocker?.entryName) || qsTr("Untitled") + ".dspx",
2525
windowHandle.projectDocumentContext.fileLocker.fileModifiedSinceLastSave ? "Modified Externally" : ""
2626
].filter(x => x).join(" - ")
2727

src/plugins/coreplugin/windows/ProjectWindowInterface.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,36 @@ namespace Core {
204204
SVS::StatusTextContext::setStatusContext(win, new SVS::StatusTextContext(win));
205205
SVS::StatusTextContext::setContextHelpContext(win, new SVS::StatusTextContext(win));
206206
d->projectDocumentContext->openSaveProjectFileScenario()->setWindow(win);
207+
static QIcon dspxIcon = [] {
208+
QIcon icon;
209+
for (const auto &file : QDir(":/diffscope/icons/dspx").entryInfoList(QDir::Files)) {
210+
icon.addFile(file.absoluteFilePath());
211+
}
212+
return icon;
213+
}();
214+
win->setIcon(QIcon(":/diffscope/icons/dspx/24x24.png"));
215+
QString path;
216+
if (d->projectDocumentContext->fileLocker() && !d->projectDocumentContext->fileLocker()->path().isEmpty()) {
217+
path = d->projectDocumentContext->fileLocker()->path();
218+
} else {
219+
path = tr("Untitled") + ".dspx";
220+
}
221+
win->setFilePath(path);
207222
return win;
208223
}
209224
ProjectWindowInterface::ProjectWindowInterface(ProjectDocumentContext *projectDocumentContext, QObject *parent) : ProjectWindowInterface(*new ProjectWindowInterfacePrivate, parent) {
210225
Q_D(ProjectWindowInterface);
211226
m_instance = this;
212227
d->projectDocumentContext = projectDocumentContext;
228+
if (d->projectDocumentContext->fileLocker()) {
229+
connect(d->projectDocumentContext->fileLocker(), &FileLocker::pathChanged, this, [=, this] {
230+
auto win = window();
231+
if (!win)
232+
return;
233+
auto path = d->projectDocumentContext->fileLocker()->path();
234+
win->setFilePath(path.isEmpty() ? tr("Untitled") + ".dspx" : path);
235+
});
236+
}
213237
}
214238
ProjectWindowInterface::ProjectWindowInterface(ProjectWindowInterfacePrivate &d, QObject *parent) : ActionWindowInterfaceBase(parent), d_ptr(&d) {
215239
d.q_ptr = this;

0 commit comments

Comments
 (0)