Skip to content

Commit

Permalink
FancyTabWidget: Move functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaski committed Nov 3, 2024
1 parent b7165e0 commit 7cfb175
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
54 changes: 27 additions & 27 deletions src/widgets/fancytabwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,33 +87,6 @@ void FancyTabWidget::AddTab(QWidget *widget_view, const QString &name, const QIc

}

bool FancyTabWidget::EnableTab(QWidget *widget_view) {

if (!tabs_.contains(widget_view)) return false;
FancyTabData *tab = tabs_.value(widget_view);

if (QTabWidget::indexOf(tab->page()) >= 0) return true;

(void)InsertTab(count(), tab);

return true;

}

bool FancyTabWidget::DisableTab(QWidget *widget_view) {

if (!tabs_.contains(widget_view)) return false;
FancyTabData *tab = tabs_.value(widget_view);

int idx = QTabWidget::indexOf(tab->page());
if (idx < 0) return false;

removeTab(idx);

return true;

}

void FancyTabWidget::LoadSettings(const QString &settings_group) {

Settings s;
Expand Down Expand Up @@ -250,6 +223,33 @@ int FancyTabWidget::InsertTab(const int idx, QWidget *page, const QIcon &icon, c
return QTabWidget::insertTab(idx, page, icon, label);
}

bool FancyTabWidget::EnableTab(QWidget *widget_view) {

if (!tabs_.contains(widget_view)) return false;
FancyTabData *tab = tabs_.value(widget_view);

if (QTabWidget::indexOf(tab->page()) >= 0) return true;

(void)InsertTab(count(), tab);

return true;

}

bool FancyTabWidget::DisableTab(QWidget *widget_view) {

if (!tabs_.contains(widget_view)) return false;
FancyTabData *tab = tabs_.value(widget_view);

int idx = QTabWidget::indexOf(tab->page());
if (idx < 0) return false;

removeTab(idx);

return true;

}

void FancyTabWidget::AddSpacer() {

QWidget *spacer = new QWidget(this);
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/fancytabwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ class FancyTabWidget : public QTabWidget {

void AddTab(QWidget *widget_view, const QString &name, const QIcon &icon, const QString &label);

bool EnableTab(QWidget *widget_view);
bool DisableTab(QWidget *widget_view);

void LoadSettings(const QString &settings_group);
void SaveSettings(const QString &settings_group);
void ReloadSettings();

int InsertTab(const int preffered_index, FancyTabData *tab);
int InsertTab(const int idx, QWidget *page, const QIcon &icon, const QString &label);

bool EnableTab(QWidget *widget_view);
bool DisableTab(QWidget *widget_view);

void AddSpacer();
void AddBottomWidget(QWidget *widget_view);
void SetBackgroundPixmap(const QPixmap &pixmap);
Expand Down

0 comments on commit 7cfb175

Please sign in to comment.