Compare commits
No commits in common. "e8a0ce88c5938c7c2f1c0d87bc74cd4afd314121" and "ff666eda9b20181135e163b0553a70101c196589" have entirely different histories.
e8a0ce88c5
...
ff666eda9b
@ -21,7 +21,7 @@ void NewMenu::open() noexcept {
|
||||
m_selectedType = 0;
|
||||
m_itemName = "";
|
||||
m_typeName = "";
|
||||
m_useDefaultPath = true;
|
||||
m_path = "";
|
||||
m_explorer.setModel(buildFileTreeModel(
|
||||
m_explorer,
|
||||
[](ox::StringViewCR, ox::FileStat const&s) {
|
||||
@ -29,10 +29,9 @@ void NewMenu::open() noexcept {
|
||||
}).or_value(ox::UPtr<FileTreeModel>{}));
|
||||
}
|
||||
|
||||
void NewMenu::openPath(ox::StringViewCR path) noexcept {
|
||||
void NewMenu::openPath(ox::StringParam path) noexcept {
|
||||
open();
|
||||
m_useDefaultPath = false;
|
||||
std::ignore = m_explorer.setSelectedPath(path);
|
||||
m_path = std::move(path);
|
||||
}
|
||||
|
||||
void NewMenu::close() noexcept {
|
||||
@ -94,9 +93,10 @@ void NewMenu::drawNewItemType(StudioContext const&sctx) noexcept {
|
||||
drawFirstPageButtons(im.itemTemplates().size() == 1 ?
|
||||
Stage::NewItemTransitioningToPath : Stage::NewItemTemplate);
|
||||
if (m_stage == Stage::NewItemTransitioningToPath || m_stage == Stage::NewItemTemplate) {
|
||||
if (m_useDefaultPath) {
|
||||
std::ignore = m_explorer.setSelectedPath(im.defaultPath());
|
||||
if (m_path.len() == 0) {
|
||||
m_path = im.defaultPath();
|
||||
}
|
||||
std::ignore = m_explorer.setSelectedPath(m_path);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -193,8 +193,10 @@ void NewMenu::finish(StudioContext &sctx) noexcept {
|
||||
return;
|
||||
}
|
||||
auto const&im = *m_types[m_selectedType];
|
||||
auto const path = sfmt("{}/{}.{}",
|
||||
m_explorer.selectedPath().or_value(ox::String{}), m_itemName, im.fileExt());
|
||||
if (auto p = m_explorer.selectedPath()) {
|
||||
m_path = std::move(*p);
|
||||
}
|
||||
auto const path = sfmt("{}/{}.{}", m_path, m_itemName, im.fileExt());
|
||||
if (sctx.project->exists(path)) {
|
||||
oxLogError(ox::Error{1, "New file error: file already exists"});
|
||||
return;
|
||||
|
@ -34,7 +34,7 @@ class NewMenu final: public Popup {
|
||||
keel::Context &m_kctx;
|
||||
ox::String m_typeName;
|
||||
ox::IString<255> m_itemName;
|
||||
bool m_useDefaultPath{};
|
||||
ox::String m_path;
|
||||
ox::Vector<ox::UPtr<ItemMaker>> m_types;
|
||||
FileExplorer m_explorer{m_kctx};
|
||||
size_t m_selectedType = 0;
|
||||
@ -44,7 +44,7 @@ class NewMenu final: public Popup {
|
||||
public:
|
||||
NewMenu(keel::Context &kctx) noexcept;
|
||||
|
||||
void openPath(ox::StringViewCR path) noexcept;
|
||||
void openPath(ox::StringParam path) noexcept;
|
||||
|
||||
void open() noexcept override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user