mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
TabManager: Use italic font and "disabled" style for non-loaded saved tab item.
This commit is contained in:
parent
b9a9c24060
commit
33846b9523
|
@ -38,10 +38,11 @@ void TabManagerDelegate::paint(QPainter* painter, const QStyleOptionViewItem &op
|
|||
const QStyle* style = w ? w->style() : QApplication::style();
|
||||
const Qt::LayoutDirection direction = w ? w->layoutDirection() : QApplication::layoutDirection();
|
||||
const bool isActiveOrCaption = index.data(TabItem::ActiveOrCaptionRole).toBool();
|
||||
const bool isSavedTab = index.data(TabItem::SavedRole).toBool();
|
||||
|
||||
const QPalette::ColorRole colorRole = opt.state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text;
|
||||
|
||||
QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
|
||||
QPalette::ColorGroup cg = (opt.state & QStyle::State_Enabled) && !isSavedTab ? QPalette::Normal : QPalette::Disabled;
|
||||
if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active)) {
|
||||
cg = QPalette::Inactive;
|
||||
}
|
||||
|
@ -122,7 +123,9 @@ void TabManagerDelegate::paint(QPainter* painter, const QStyleOptionViewItem &op
|
|||
painter->drawRect(textRect.adjusted(0, 0, -1, -1));
|
||||
}
|
||||
|
||||
if (isActiveOrCaption)
|
||||
if (isSavedTab)
|
||||
opt.font.setItalic(true);
|
||||
else if (isActiveOrCaption)
|
||||
opt.font.setBold(true);
|
||||
|
||||
painter->setFont(opt.font);
|
||||
|
|
|
@ -751,6 +751,11 @@ void TabItem::setWebTab(WebTab* webTab)
|
|||
{
|
||||
m_webTab = webTab;
|
||||
|
||||
if (m_webTab->isRestored())
|
||||
setIsActiveOrCaption(m_webTab->isCurrentTab());
|
||||
else
|
||||
setIsSavedTab(true);
|
||||
|
||||
connect(m_webTab->webView()->page(), SIGNAL(audioMutedChanged(bool)), this, SLOT(updateIcon()));
|
||||
connect(m_webTab->webView()->page(), SIGNAL(loadFinished(bool)), this, SLOT(updateIcon()));
|
||||
connect(m_webTab->webView()->page(), SIGNAL(loadStarted()), this, SLOT(updateIcon()));
|
||||
|
@ -778,9 +783,15 @@ void TabItem::updateIcon()
|
|||
else {
|
||||
setIcon(0, QIcon(":tabmanager/data/tab-pinned.png"));
|
||||
}
|
||||
|
||||
if (m_webTab->isRestored())
|
||||
setIsActiveOrCaption(m_webTab->isCurrentTab());
|
||||
else
|
||||
setIsSavedTab(true);
|
||||
}
|
||||
else {
|
||||
setIcon(0, QIcon(":tabmanager/data/tab-loading.png"));
|
||||
setIsActiveOrCaption(m_webTab->isCurrentTab());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -793,4 +804,11 @@ void TabItem::setTitle(const QString &title)
|
|||
void TabItem::setIsActiveOrCaption(bool yes)
|
||||
{
|
||||
setData(0, ActiveOrCaptionRole, yes ? QVariant(true) : QVariant());
|
||||
|
||||
setIsSavedTab(false);
|
||||
}
|
||||
|
||||
void TabItem::setIsSavedTab(bool yes)
|
||||
{
|
||||
setData(0, SavedRole, yes ? QVariant(true) : QVariant());
|
||||
}
|
||||
|
|
|
@ -103,7 +103,8 @@ class TabItem : public QObject, public QTreeWidgetItem
|
|||
|
||||
public:
|
||||
enum StateRole {
|
||||
ActiveOrCaptionRole = Qt::UserRole + 1
|
||||
ActiveOrCaptionRole = Qt::UserRole + 1,
|
||||
SavedRole = Qt::UserRole + 2
|
||||
};
|
||||
|
||||
TabItem(QTreeWidget* treeWidget, QTreeWidgetItem* parent = 0, bool addToTree = true);
|
||||
|
@ -118,6 +119,7 @@ public slots:
|
|||
void updateIcon();
|
||||
void setTitle(const QString& title);
|
||||
void setIsActiveOrCaption(bool yes);
|
||||
void setIsSavedTab(bool yes);
|
||||
|
||||
private:
|
||||
QTreeWidget* m_treeWidget;
|
||||
|
|
Loading…
Reference in New Issue
Block a user