USA.
*/
-#include <QButtonGroup>
#include <QDebug>
#include <QPropertyAnimation>
#include <QSignalTransition>
#include "panelbar.h"
#include "panelcontent.h"
-#include "paneltab.h"
-#include "userinfo.h"
+#include "paneltabbar.h"
#include "tabbedpanel.h"
TabbedPanel::TabbedPanel(QWidget *parent)
: QWidget(parent),
- m_isOpen(false),
- m_activeTab(-1)
+ m_isOpen(false)
{
qDebug() << __PRETTY_FUNCTION__;
// --- TABS ---
m_panelWidgetStack = new QStackedWidget(this);
- m_tabButtonGroup = new QButtonGroup(this);
+ m_panelTabBar = new PanelTabBar(this);
- connect(m_tabButtonGroup, SIGNAL(buttonPressed(int)),
- this, SLOT(setActiveTab(int)));
+ connect(m_panelTabBar, SIGNAL(currentChanged(int)),
+ this, SLOT(showTab(int)));
+
+ connect(m_panelTabBar, SIGNAL(tabCloseRequested(int)),
+ this, SLOT(closePanel()));
+
+ connect(this, SIGNAL(panelClosed()),
+ m_panelTabBar, SLOT(deselectTabs()));
// --- BAR ---
m_panelBar = new PanelBar(this);
if(!widget)
return -1;
- int verticalStartPoint = 8;
-
index = m_panelWidgetStack->insertWidget(index, widget);
- m_tabButtonGroup->addButton(new PanelTab(this), index);
- m_tabButtonGroup->button(index)->setIcon(icon);
-
- // [BEGIN]: Purkkaa (to be removed ASAP!!!)
- if(index > 0)
- verticalStartPoint += 65 * index;
-
- m_tabButtonGroup->button(index)->move(0, verticalStartPoint);
- // [END]: Purkkaa
+ m_panelTabBar->insertTab(index, icon);
return index;
}
if(QWidget *widget = m_panelWidgetStack->widget(index)) {
m_panelWidgetStack->removeWidget(widget);
-
- QAbstractButton *tab = m_tabButtonGroup->button(index);
- m_tabButtonGroup->removeButton(tab);
- delete tab;
+ m_panelTabBar->removeTab(index);
}
}
emit toggleState();
}
+void TabbedPanel::showTab(int index)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (index < m_panelWidgetStack->count() && index >= 0) {
+ m_panelWidgetStack->setCurrentIndex(index);
+ openPanel();
+ emit currentChanged(index);
+ }
+}
+
void TabbedPanel::resizePanel(const QSize &size)
{
qDebug() << __PRETTY_FUNCTION__;
PANEL_TOP_PADDING));
}
-void TabbedPanel::setActiveTab(int index)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- if(m_activeTab == -1) {
- m_activeTab = index;
- m_panelWidgetStack->setCurrentIndex(index);
- emit tabChanged();
- emit toggleState();
- } else if(m_activeTab == index) {
- m_activeTab = -1;
- emit toggleState();
- } else {
- m_activeTab = index;
- m_panelWidgetStack->setCurrentIndex(index);
- emit tabChanged();
- }
-}
-
void TabbedPanel::stateChanged()
{
qDebug() << __PRETTY_FUNCTION__;
emit panelOpened();
} else {
m_isOpen = false;
-
- m_tabButtonGroup->setExclusive(false);
- m_tabButtonGroup->button(m_tabButtonGroup->checkedId())->setChecked(false);
- m_tabButtonGroup->setExclusive(true);
-
emit panelClosed();
}
}