Open the last selected tab on restart

This commit is contained in:
fourtf 2018-04-10 15:59:53 +02:00
parent d0f1ea8502
commit c744659ce0
3 changed files with 26 additions and 8 deletions

View file

@ -186,6 +186,11 @@ void WindowManager::initialize()
tab->getTab()->useDefaultTitle = false; tab->getTab()->useDefaultTitle = false;
} }
// selected
if (tab_obj.value("selected").toBool(false)) {
window.getNotebook().select(tab);
}
// load splits // load splits
int colNr = 0; int colNr = 0;
for (QJsonValue column_val : tab_obj.value("splits").toArray()) { for (QJsonValue column_val : tab_obj.value("splits").toArray()) {
@ -251,6 +256,11 @@ void WindowManager::save()
tab_obj.insert("title", tab->getTab()->getTitle()); tab_obj.insert("title", tab->getTab()->getTitle());
} }
// selected
if (window->getNotebook().getSelectedPage() == tab) {
tab_obj.insert("selected", true);
}
// splits // splits
QJsonArray columns_arr; QJsonArray columns_arr;
std::vector<std::vector<widgets::Split *>> columns = tab->getColumns(); std::vector<std::vector<widgets::Split *>> columns = tab->getColumns();

View file

@ -119,6 +119,20 @@ void Notebook::removeCurrentPage()
this->removePage(this->selectedPage); this->removePage(this->selectedPage);
} }
SplitContainer *Notebook::getOrAddSelectedPage()
{
if (selectedPage == nullptr) {
this->addNewPage(true);
}
return selectedPage;
}
SplitContainer *Notebook::getSelectedPage()
{
return selectedPage;
}
void Notebook::select(SplitContainer *page) void Notebook::select(SplitContainer *page)
{ {
if (page == this->selectedPage) { if (page == this->selectedPage) {

View file

@ -30,14 +30,8 @@ public:
void select(SplitContainer *page); void select(SplitContainer *page);
void selectIndex(int index); void selectIndex(int index);
SplitContainer *getOrAddSelectedPage() SplitContainer *getOrAddSelectedPage();
{ SplitContainer *getSelectedPage();
if (selectedPage == nullptr) {
this->addNewPage(true);
}
return selectedPage;
}
void performLayout(bool animate = true); void performLayout(bool animate = true);