Skip to content

Commit c3d54d4

Browse files
committed
feat: project hub dir selector
1 parent 84a76e4 commit c3d54d4

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

Editor/Include/Editor/Widget/ProjectHub.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace Editor {
3838

3939
public Q_SLOTS:
4040
void CreateProject() const;
41+
QString BrowseDirectory() const;
4142

4243
private:
4344
QString GetEngineVersion() const;

Editor/Src/Widget/ProjectHub.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Created by johnk on 2025/8/3.
33
//
44

5+
#include <QFileDialog>
6+
57
#include <Editor/Widget/ProjectHub.h>
68
#include <Editor/Widget/moc_ProjectHub.cpp>
79
#include <Core/Log.h>
@@ -41,6 +43,11 @@ namespace Editor {
4143
LogInfo(ProjectHub, "ProjectHubBridge::CreateProject");
4244
}
4345

46+
QString ProjectHubBackend::BrowseDirectory() const // NOLINT
47+
{
48+
return QFileDialog::getExistingDirectory(nullptr, "Select Project Directory", QDir::rootPath());
49+
}
50+
4451
QString ProjectHubBackend::GetEngineVersion() const
4552
{
4653
return QString::fromStdString(engineVersion);

Editor/Web/src/pages/project-hub.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default function ProjectHubPage() {
2525
const [engineVersion, setEngineVersion] = useState('');
2626
const [recentProjects, setRecentProjects] = useState(Array<RecentProjectInfo>);
2727
const [projectTemplates, setProjectTemplates] = useState(Array<ProjectTemplateInfo>);
28+
const [projectPath, setProjectPath] = useState('');
2829

2930
useEffect(() => {
3031
new QWebChannel(window.qt.webChannelTransport, (channel: QWebChannel): void => {
@@ -47,10 +48,12 @@ export default function ProjectHubPage() {
4748
console.error('onOpenProject:', index);
4849
}
4950

50-
async function onBrowseProjectPath(): Promise<void> {
51-
// TODO
52-
const dirHandle = await window.showDirectoryPicker({ startIn: 'desktop' });
53-
console.error(dirHandle);
51+
function onBrowseProjectPath(): void {
52+
window.backend.BrowseDirectory((path: string) => {
53+
if (path) {
54+
setProjectPath(path);
55+
}
56+
});
5457
}
5558

5659
return (
@@ -91,7 +94,7 @@ export default function ProjectHubPage() {
9194
<Form className='w-full ml-4'>
9295
<Input fullWidth isRequired label='Project Name' labelPlacement='outside' placeholder='HelloExplosion' />
9396
<div className='flex w-full'>
94-
<Input isRequired label='Project Path' labelPlacement='outside' placeholder='/path/to/your/project' />
97+
<Input isRequired label='Project Path' labelPlacement='outside' placeholder='/path/to/your/project' value={projectPath} onValueChange={setProjectPath} />
9598
<Button className='ml-2 mt-6' onPress={() => onBrowseProjectPath()}>
9699
Browse
97100
</Button>

0 commit comments

Comments
 (0)