1
0
mirror of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git synced 2025-04-01 02:42:39 +08:00

Fixed ElidingLabel to properly support Qt::ElideNone

added setElideMode function to CDockWidgetTab
This commit is contained in:
Uwe Kindler 2020-04-10 21:06:43 +02:00
parent 19331ebe2b
commit dbf90a4233
4 changed files with 17 additions and 3 deletions

View File

@ -176,7 +176,7 @@ DockWidgetTabPrivate::DockWidgetTabPrivate(CDockWidgetTab* _public) :
void DockWidgetTabPrivate::createLayout() void DockWidgetTabPrivate::createLayout()
{ {
TitleLabel = new tTabLabel(); TitleLabel = new tTabLabel();
TitleLabel->setElideMode(Qt::ElideRight); TitleLabel->setElideMode(Qt::ElideNone);
TitleLabel->setText(DockWidget->windowTitle()); TitleLabel->setText(DockWidget->windowTitle());
TitleLabel->setObjectName("dockWidgetTabLabel"); TitleLabel->setObjectName("dockWidgetTabLabel");
TitleLabel->setAlignment(Qt::AlignCenter); TitleLabel->setAlignment(Qt::AlignCenter);
@ -578,6 +578,8 @@ void CDockWidgetTab::setText(const QString& title)
d->TitleLabel->setText(title); d->TitleLabel->setText(title);
} }
//============================================================================
bool CDockWidgetTab::isTitleElided() const bool CDockWidgetTab::isTitleElided() const
{ {
return d->TitleLabel->isElided(); return d->TitleLabel->isElided();
@ -630,6 +632,13 @@ void CDockWidgetTab::onDockWidgetFeaturesChanged()
} }
//============================================================================
void CDockWidgetTab::setElideMode(Qt::TextElideMode mode)
{
d->TitleLabel->setElideMode(mode);
}
} // namespace ads } // namespace ads

View File

@ -147,6 +147,11 @@ public:
*/ */
virtual bool event(QEvent *e) override; virtual bool event(QEvent *e) override;
/**
* Sets the text elide mode
*/
void setElideMode(Qt::TextElideMode mode);
public slots: public slots:
virtual void setVisible(bool visible) override; virtual void setVisible(bool visible) override;

View File

@ -197,13 +197,13 @@ QSize CElidingLabel::sizeHint() const
//============================================================================ //============================================================================
void CElidingLabel::setText(const QString &text) void CElidingLabel::setText(const QString &text)
{ {
d->Text = text;
if (d->isModeElideNone()) if (d->isModeElideNone())
{ {
Super::setText(text); Super::setText(text);
} }
else else
{ {
d->Text = text;
internal::setToolTip(this, text); internal::setToolTip(this, text);
d->elideText(this->size().width()); d->elideText(this->size().width());
} }

View File

@ -66,7 +66,7 @@ namespace ads
{ {
enum eStateFileVersion enum eStateFileVersion
{ {
InitialVerison = 0, InitialVersion = 0,
Version1 = 1, Version1 = 1,
CurrentVersion = Version1 CurrentVersion = Version1
}; };