1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00

update picture effect tabbar

This commit is contained in:
tianduanrui 2017-11-16 13:07:23 +08:00
parent 9bc227dd28
commit 782a7e8340
17 changed files with 89 additions and 68 deletions

View File

@ -45,6 +45,12 @@ MainWindow::MainWindow(QWidget* parent) :
tab->setIconStyle(QQtPictureEffectTabBar::IconStyle_Cover_And_RightText);
tab->setTabPixmap(0, "./skin/default/bt_setting.png", "./skin/default/bt_setting_press.png");
tab->setTabPixmap(1, "./skin/default/bt_user.png", "./skin/default/bt_user_press.png");
ui->tw1->setStyleSheet("QTabWidget#tw1 QTabBar::tab { width:90px; height:30px; }");
QQtPictureEffectTabBar* tab1 = (QQtPictureEffectTabBar*)ui->tw1->localTabBar();
tab1->setIconStyle(QQtPictureEffectTabBar::IconStyle_Cover_And_RightText);
tab1->setTabPixmap(0, "./skin/default/bt_setting.png", "./skin/default/bt_setting_press.png");
tab1->setTabPixmap(1, "./skin/default/bt_user.png", "./skin/default/bt_user_press.png");
}
MainWindow::~MainWindow()

View File

@ -18,7 +18,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -141,6 +141,22 @@
<attribute name="title">
<string>Tab 1</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QQtPictureEffectTabWidget" name="tw1">
<widget class="QWidget" name="tab_14">
<attribute name="title">
<string>Tab 1</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_15">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_11">
<attribute name="title">

View File

@ -280,8 +280,8 @@ private:
// QWidget interface
protected:
virtual void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
virtual void mouseDoubleClickEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent(QMouseEvent* event) override;
virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
};
#endif //QQTCUSTOMEFFECTPROGRESSBAR_H

View File

@ -105,20 +105,6 @@ void QQtHorizontalTextEffectTabBar::paintEvent(QPaintEvent* e)
setShape(QTabBar::RoundedWest);
}
// Only draw the tear indicator if necessary. Most of the time we don't need too.
if (0 && cutLeft >= 0)
{
cutTabLeft.rect = rect();
cutTabLeft.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicatorLeft, &cutTabLeft, this);
p.drawPrimitive(QStyle::PE_IndicatorTabTearLeft, cutTabLeft);
}
if (0 && cutRight >= 0)
{
cutTabRight.rect = rect();
cutTabRight.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicatorRight, &cutTabRight, this);
p.drawPrimitive(QStyle::PE_IndicatorTabTearRight, cutTabRight);
}
}
void QQtHorizontalTextEffectTabBar::drawTextLabel(QPainter* p)

View File

@ -27,37 +27,37 @@ public slots:
private:
static void initStyleBaseOption(QStyleOptionTabBarBase* optTabBase, QTabBar* tabbar, QSize size)
{
QStyleOptionTab tabOverlap;
tabOverlap.shape = tabbar->shape();
int overlap = tabbar->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap, tabbar);
QWidget* theParent = tabbar->parentWidget();
optTabBase->init(tabbar);
optTabBase->shape = tabbar->shape();
optTabBase->documentMode = tabbar->documentMode();
if (theParent && overlap > 0)
{
QRect rect;
switch (tabOverlap.shape)
{
case QTabBar::RoundedNorth:
case QTabBar::TriangularNorth:
rect.setRect(0, size.height() - overlap, size.width(), overlap);
break;
case QTabBar::RoundedSouth:
case QTabBar::TriangularSouth:
rect.setRect(0, 0, size.width(), overlap);
break;
case QTabBar::RoundedEast:
case QTabBar::TriangularEast:
rect.setRect(0, 0, overlap, size.height());
break;
case QTabBar::RoundedWest:
case QTabBar::TriangularWest:
rect.setRect(size.width() - overlap, 0, overlap, size.height());
break;
}
optTabBase->rect = rect;
}
// QStyleOptionTab tabOverlap;
// tabOverlap.shape = tabbar->shape();
// int overlap = tabbar->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap, tabbar);
// QWidget* theParent = tabbar->parentWidget();
// optTabBase->init(tabbar);
// optTabBase->shape = tabbar->shape();
// optTabBase->documentMode = tabbar->documentMode();
// if (theParent && overlap > 0)
// {
// QRect rect;
// switch (tabOverlap.shape)
// {
// case QTabBar::RoundedNorth:
// case QTabBar::TriangularNorth:
// rect.setRect(0, size.height() - overlap, size.width(), overlap);
// break;
// case QTabBar::RoundedSouth:
// case QTabBar::TriangularSouth:
// rect.setRect(0, 0, size.width(), overlap);
// break;
// case QTabBar::RoundedEast:
// case QTabBar::TriangularEast:
// rect.setRect(0, 0, overlap, size.height());
// break;
// case QTabBar::RoundedWest:
// case QTabBar::TriangularWest:
// rect.setRect(size.width() - overlap, 0, overlap, size.height());
// break;
// }
// optTabBase->rect = rect;
// }
}
};

View File

@ -19,8 +19,8 @@ private:
// QQtTabWidget interface
public:
virtual void setObjectName(const QString& name) Q_DECL_OVERRIDE;
virtual QQtTabBar* localTabBar() const Q_DECL_OVERRIDE { return m_bar; }
virtual void setObjectName(const QString& name) override;
virtual QQtTabBar* localTabBar() const override { return m_bar; }
};
#endif // QQTHORIZONTALTEXTEFFECTTABWIDGET_H

View File

@ -144,6 +144,16 @@ void QQtPictureEffectTabBar::drawText(QPainter* p)
QRect tabTextRect = tabRect(index);
//-rect.height()/20 上移
verticalTabs() ? tabTextRect.adjust(0, 0, 0, 0) : tabTextRect.adjust(0, 0, 0, 0);
if (iconStyle == IconStyle_Cover_And_BottomText)
tabTextRect.adjust(0, 0, 0, -2);
else if (iconStyle == IconStyle_Cover_And_TopText)
tabTextRect.adjust(0, +2, 0, 0);
else if (iconStyle == IconStyle_Cover_And_LeftText)
tabTextRect.adjust(+2, 0, 0, 0);
else if (iconStyle == IconStyle_Cover_And_RightText)
tabTextRect.adjust(0, 0, -2, 0);
else if (iconStyle == IconStyle_Cover_And_MiddleText)
tabTextRect.adjust(0, 0, 0, 0);
if (iconStyle == IconStyle_Left_And_RightText)
tabTextRect = QRect(tabTextRect.left() + tabTextRect.height(), tabTextRect.top(),
@ -158,6 +168,8 @@ void QQtPictureEffectTabBar::drawText(QPainter* p)
flags = Qt::AlignVCenter | Qt::AlignLeft;
else if (iconStyle == IconStyle_Cover_And_RightText)
flags = Qt::AlignVCenter | Qt::AlignRight;
else if (iconStyle == IconStyle_Cover_And_MiddleText)
flags = Qt::AlignVCenter | Qt::AlignHCenter;
//pline() << objectName() << rect;
//if on board text is normal, this is right. otherwise the palette is right

View File

@ -23,6 +23,7 @@ public:
IconStyle_Cover_And_BottomText,
IconStyle_Cover_And_LeftText,
IconStyle_Cover_And_RightText,
IconStyle_Cover_And_MiddleText,
//color style
IconStyle_Left_And_RightText,
IconStyle_Max_Style

View File

@ -19,8 +19,8 @@ private:
// QQtTabWidget interface
public:
virtual void setObjectName(const QString& name) Q_DECL_OVERRIDE;
virtual QQtTabBar* localTabBar() const Q_DECL_OVERRIDE { return m_bar; }
virtual void setObjectName(const QString& name) override;
virtual QQtTabBar* localTabBar() const override { return m_bar; }
};
#endif // QQTPICTUREEFFECTTABWIDGET_H

View File

@ -54,15 +54,15 @@ private:
// QWidget interface
protected:
virtual void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE;
virtual void paintEvent(QPaintEvent* event) override;
// QWidget interface
protected:
virtual void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QMouseEvent* event) override;
// QWidget interface
protected:
virtual void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent(QMouseEvent* event) override;
};
#endif // QQTSLIDEEFFECTTABBAR_H

View File

@ -19,8 +19,8 @@ private:
// QQtTabWidget interface
public:
virtual void setObjectName(const QString& name) Q_DECL_OVERRIDE;
virtual QQtTabBar* localTabBar() const Q_DECL_OVERRIDE { return m_bar; }
virtual void setObjectName(const QString& name) override;
virtual QQtTabBar* localTabBar() const override { return m_bar; }
};
#endif // QQTSLIDEEFFECTTABWIDGET_H

View File

@ -16,8 +16,8 @@ public:
// QQTVirtualTreeModel interface
public:
bool query(QString condition) Q_DECL_OVERRIDE;
void setFilePath(QString dbname) Q_DECL_OVERRIDE;
bool query(QString condition) override;
void setFilePath(QString dbname) override;
protected:
bool parseDatabase();

View File

@ -18,8 +18,8 @@ public slots:
// QQTTreeModel interface
public:
bool query(QString condition) Q_DECL_OVERRIDE;
void setFilePath(QString xmlfile) Q_DECL_OVERRIDE;
bool query(QString condition) override;
void setFilePath(QString xmlfile) override;
protected:
/**

View File

@ -21,7 +21,7 @@ public:
signals:
// QTcpServer interface
protected:
virtual void incomingConnection(qintptr handle) Q_DECL_OVERRIDE;
virtual void incomingConnection(qintptr handle) override;
private:
QQtProtocol* m_protocol;
};

View File

@ -115,7 +115,7 @@ contains (DEFINES, __CPP11__) {
#compile period
#LibQQt need c++11 support. Please ensure your compiler version.
#LibQQt used Q_DECL_OVERRIDE identifier
#LibQQt used override identifier
#lambda also need c++11
}

View File

@ -17,11 +17,11 @@ public slots:
// QWidget interface
protected:
virtual void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent(QMouseEvent* event) override;
// QWidget interface
protected:
virtual void mouseDoubleClickEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
};
#endif // QQTLABEL_H

View File

@ -40,12 +40,12 @@ private:
quint32 m_style;
// QWidget interface
protected:
void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent*) override;
// QWidget interface
protected:
virtual void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
virtual void mouseDoubleClickEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent(QMouseEvent* event) override;
virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
};
#endif // QPICWIDGET_H