Skip to content

Commit

Permalink
Added tabOpened to tab widget handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
albar965 committed Aug 17, 2019
1 parent 00584fc commit 31533f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
14 changes: 9 additions & 5 deletions src/gui/tabwidgethandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ int TabWidgetHandler::getCurrentTabId() const

void TabWidgetHandler::setCurrentTab(int id, bool left)
{
int index = indexForId(id);
int index = getIndexForId(id);
if(index != -1)
// Already open - push to front
tabWidget->setCurrentIndex(index);
Expand All @@ -269,7 +269,7 @@ void TabWidgetHandler::setCurrentTab(int id, bool left)

void TabWidgetHandler::openTab(int id, bool left)
{
int index = indexForId(id);
int index = getIndexForId(id);
if(index == -1)
{
{
Expand All @@ -282,7 +282,7 @@ void TabWidgetHandler::openTab(int id, bool left)

bool TabWidgetHandler::isTabVisible(int id) const
{
return indexForId(id) != -1;
return getIndexForId(id) != -1;
}

void TabWidgetHandler::currentChanged()
Expand Down Expand Up @@ -356,7 +356,7 @@ void TabWidgetHandler::toolbarActionTriggered()
else
{
// Remove
int index = indexForId(actionId);
int index = getIndexForId(actionId);
if(index != -1)
tabWidget->removeTab(index);
}
Expand All @@ -376,6 +376,8 @@ int TabWidgetHandler::insertTab(int index, int id)
int idx = tabWidget->insertTab(index, tab.widget, tab.title);
tabWidget->setTabToolTip(idx, tab.tooltip);
tabWidget->setCurrentWidget(tab.widget);

emit tabOpened(id);
return idx;
}

Expand All @@ -388,6 +390,8 @@ int TabWidgetHandler::addTab(int id)
const Tab& tab = tabs.at(id);
int idx = tabWidget->addTab(tab.widget, tab.title);
tabWidget->setTabToolTip(idx, tab.tooltip);

emit tabOpened(id);
return idx;
}

Expand Down Expand Up @@ -440,7 +444,7 @@ int TabWidgetHandler::idForWidget(QWidget *widget) const
return widget->property(ID_PROPERTY).toInt();
}

int TabWidgetHandler::indexForId(int id) const
int TabWidgetHandler::getIndexForId(int id) const
{
return tabWidget->indexOf(tabs.at(id).widget);
}
Expand Down
9 changes: 6 additions & 3 deletions src/gui/tabwidgethandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,19 @@ class TabWidgetHandler :
* is set to current. */
void reset();

/* Get index in tab widget for id or -1 if tab is not contained by widget. */
int getIndexForId(int id) const;

signals:
/* Current tab has changed */
void tabChanged(int id);

/* A tab was closed */
void tabClosed(int id);

/* A tab was opened */
void tabOpened(int id);

private:
/* Removes actions from menu button before running init */
void clear();
Expand All @@ -105,9 +111,6 @@ class TabWidgetHandler :
/* Update widget/action state based on active tabs in the widget - also replaces close button on last tab */
void updateWidgets();

/* Get index in tab widget for id or -1 if tab is not contained by widget */
int indexForId(int id) const;

/* Get id for tab or -1 if index is not valid */
int idForIndex(int index) const;

Expand Down

0 comments on commit 31533f9

Please sign in to comment.