mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-09 18:44:46 +00:00
Update BrowserView tab title when we visit other file
This commit is contained in:
parent
b5679a3f82
commit
2e347a1229
@ -78,11 +78,17 @@ class BrowserView::CMarkBox : public Widget {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
obs::signal<void()> FileChange;
|
||||||
|
|
||||||
CMarkBox() {
|
CMarkBox() {
|
||||||
setBgColor(SkinTheme::instance()->colors.textboxFace());
|
setBgColor(SkinTheme::instance()->colors.textboxFace());
|
||||||
setBorder(gfx::Border(4*guiscale()));
|
setBorder(gfx::Border(4*guiscale()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& file() {
|
||||||
|
return m_file;
|
||||||
|
}
|
||||||
|
|
||||||
void loadFile(const std::string& inputFile) {
|
void loadFile(const std::string& inputFile) {
|
||||||
std::string file = inputFile;
|
std::string file = inputFile;
|
||||||
{
|
{
|
||||||
@ -91,12 +97,7 @@ public:
|
|||||||
if (rf.findFirst())
|
if (rf.findFirst())
|
||||||
file = rf.filename();
|
file = rf.filename();
|
||||||
}
|
}
|
||||||
|
m_file = file;
|
||||||
if (!base::is_file(file)) {
|
|
||||||
Alert::show("Error<<File <%s> not found||&Close",
|
|
||||||
file.c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmark_parser* parser = cmark_parser_new(CMARK_OPT_DEFAULT);
|
cmark_parser* parser = cmark_parser_new(CMARK_OPT_DEFAULT);
|
||||||
FILE* fp = base::open_file_raw(file, "rb");
|
FILE* fp = base::open_file_raw(file, "rb");
|
||||||
@ -119,11 +120,14 @@ public:
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clear();
|
clear();
|
||||||
addText("File not found: " + file);
|
addText("File not found:");
|
||||||
|
addBreak();
|
||||||
|
addCodeBlock(file);
|
||||||
}
|
}
|
||||||
cmark_parser_free(parser);
|
cmark_parser_free(parser);
|
||||||
|
|
||||||
relayout();
|
relayout();
|
||||||
|
FileChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -488,6 +492,7 @@ private:
|
|||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string m_file;
|
||||||
std::string m_content;
|
std::string m_content;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -502,6 +507,11 @@ BrowserView::BrowserView()
|
|||||||
m_view.setExpansive(true);
|
m_view.setExpansive(true);
|
||||||
m_view.setProperty(SkinStylePropertyPtr(
|
m_view.setProperty(SkinStylePropertyPtr(
|
||||||
new SkinStyleProperty(theme->styles.workspaceView())));
|
new SkinStyleProperty(theme->styles.workspaceView())));
|
||||||
|
|
||||||
|
m_textBox->FileChange.connect(
|
||||||
|
[]{
|
||||||
|
App::instance()->workspace()->updateTabs();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserView::~BrowserView()
|
BrowserView::~BrowserView()
|
||||||
@ -511,15 +521,12 @@ BrowserView::~BrowserView()
|
|||||||
|
|
||||||
void BrowserView::loadFile(const std::string& file)
|
void BrowserView::loadFile(const std::string& file)
|
||||||
{
|
{
|
||||||
m_title = base::get_file_title(file);
|
|
||||||
m_filename = file;
|
|
||||||
|
|
||||||
m_textBox->loadFile(file);
|
m_textBox->loadFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string BrowserView::getTabText()
|
std::string BrowserView::getTabText()
|
||||||
{
|
{
|
||||||
return m_title;
|
return base::get_file_title(m_textBox->file());
|
||||||
}
|
}
|
||||||
|
|
||||||
TabIcon BrowserView::getTabIcon()
|
TabIcon BrowserView::getTabIcon()
|
||||||
|
@ -39,8 +39,6 @@ namespace app {
|
|||||||
|
|
||||||
ui::View m_view;
|
ui::View m_view;
|
||||||
CMarkBox* m_textBox;
|
CMarkBox* m_textBox;
|
||||||
std::string m_title;
|
|
||||||
std::string m_filename;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
Loading…
x
Reference in New Issue
Block a user