Hello, I think it would be nice if the user could choice to show only tasks icons (no window title) in the task manager applet (see the attached screenshot). The idea is to combine this option with the “group automatically by name” option.
I tried to write a patch for that but I'm not sure of what I'm doing, and anyway it doesn't work as expected: the size of task items is still too big, and the size of the icon too small. I've just added a showOnlyIcon attribute to the AbstractTaskItem class, which controls to show or not the text when the item is painted. And I've modified the configuration dialog accordingly. What do you think about this suggestion? How am I supposed to do it properly? Best regards, Julien
<<attachment: sshot.png>>
Index: abstracttaskitem.cpp =================================================================== --- abstracttaskitem.cpp (révision 1090185) +++ abstracttaskitem.cpp (copie de travail) @@ -83,7 +83,8 @@ m_lastViewId(0), m_showText(true), m_layoutAnimationLock(false), - m_firstGeometryUpdate(false) + m_firstGeometryUpdate(false), + m_showOnlyIcon(false) { m_layoutAnimation = new QPropertyAnimation(this, "animationPos", this); m_layoutAnimation->setEasingCurve(QEasingCurve::InOutQuad); @@ -124,7 +125,7 @@ } //kDebug() << (QObject*)this; - return QSize(mSize.width()*12 + m_applet->itemLeftMargin() + m_applet->itemRightMargin() + KIconLoader::SizeSmall, + return QSize((m_showOnlyIcon?0:(mSize.width() * 12)) + m_applet->itemLeftMargin() + m_applet->itemRightMargin() + KIconLoader::SizeSmall, qMax(mSize.height(), iconsize) + topMargin + bottomMargin); } @@ -139,7 +140,7 @@ int leftMargin = m_applet->offscreenLeftMargin(); //kDebug() << (QObject*)this; - QSizeF s(mSize.width() * 12 + leftMargin + rightMargin + KIconLoader::SizeSmall, + QSizeF s((m_showOnlyIcon?0:(mSize.width() * 12)) + leftMargin + rightMargin + KIconLoader::SizeSmall, qMax(mSize.height(), iconsize) + topMargin + bottomMargin); setPreferredSize(s); } @@ -149,6 +150,23 @@ setPreferredSize(basicPreferredSize()); } +bool AbstractTaskItem::showOnlyIcon() const +{ + return m_showOnlyIcon; +} + +void AbstractTaskItem::setShowOnlyIcon(bool showOnlyIcon) +{ + m_showOnlyIcon = showOnlyIcon; + TaskGroupItem *group = qobject_cast<TaskGroupItem *>(this); + if(group) { + foreach(AbstractTaskItem *task, group->members()) { + task->setShowOnlyIcon(showOnlyIcon); + } + } + update(); +} + AbstractTaskItem::~AbstractTaskItem() { emit destroyed(this); @@ -670,7 +688,7 @@ painter->setPen(QPen(textColor(), 1.0)); - if (m_showText) { + if (!m_showOnlyIcon && m_showText) { QRect rect = textRect(bounds).toRect(); if (rect.height() > 20) { rect.adjust(2, 2, -2, -2); // Create a text margin Index: tasksConfig.ui =================================================================== --- tasksConfig.ui (révision 1090185) +++ tasksConfig.ui (copie de travail) @@ -32,23 +32,7 @@ </property> </widget> </item> - <item row="7" column="1"> - <spacer name="verticalSpacer_6"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>64</width> - <height>5</height> - </size> - </property> - </spacer> - </item> - <item row="9" column="1"> + <item row="13" column="1"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="KIntSpinBox" name="maxRows"> @@ -75,7 +59,7 @@ </item> </layout> </item> - <item row="14" column="1"> + <item row="18" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> <widget class="QComboBox" name="groupingStrategy"> @@ -102,7 +86,7 @@ </item> </layout> </item> - <item row="15" column="1"> + <item row="19" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> <spacer name="horizontalSpacer"> @@ -135,7 +119,7 @@ </item> </layout> </item> - <item row="16" column="0"> + <item row="20" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> <string>Sorting:</string> @@ -148,7 +132,7 @@ </property> </widget> </item> - <item row="16" column="1"> + <item row="20" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> <widget class="QComboBox" name="sortingStrategy"> @@ -175,7 +159,7 @@ </item> </layout> </item> - <item row="17" column="1"> + <item row="21" column="1"> <spacer name="verticalSpacer_4"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -191,28 +175,28 @@ </property> </spacer> </item> - <item row="19" column="0" colspan="2"> + <item row="23" column="0" colspan="2"> <widget class="QCheckBox" name="showOnlyCurrentDesktop"> <property name="text"> <string>Only show tasks from the current desktop</string> </property> </widget> </item> - <item row="20" column="0" colspan="2"> + <item row="24" column="0" colspan="2"> <widget class="QCheckBox" name="showOnlyCurrentScreen"> <property name="text"> <string>Only show tasks from the current screen</string> </property> </widget> </item> - <item row="21" column="0" colspan="2"> + <item row="25" column="0" colspan="2"> <widget class="QCheckBox" name="showOnlyMinimized"> <property name="text"> <string>Only show tasks that are minimized</string> </property> </widget> </item> - <item row="22" column="1"> + <item row="26" column="1"> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -225,7 +209,7 @@ </property> </spacer> </item> - <item row="18" column="0" colspan="2"> + <item row="22" column="0" colspan="2"> <widget class="QLabel" name="label_4"> <property name="font"> <font> @@ -238,7 +222,7 @@ </property> </widget> </item> - <item row="11" column="0" colspan="2"> + <item row="15" column="0" colspan="2"> <widget class="QLabel" name="label_6"> <property name="font"> <font> @@ -297,7 +281,7 @@ </property> </widget> </item> - <item row="9" column="0"> + <item row="13" column="0"> <widget class="QLabel" name="label_3"> <property name="text"> <string>Maximum rows:</string> @@ -310,7 +294,7 @@ </property> </widget> </item> - <item row="14" column="0"> + <item row="18" column="0"> <widget class="QLabel" name="label"> <property name="text"> <string>Grouping:</string> @@ -323,7 +307,7 @@ </property> </widget> </item> - <item row="10" column="0"> + <item row="14" column="0"> <spacer name="verticalSpacer_2"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -339,6 +323,42 @@ </property> </spacer> </item> + <item row="7" column="0"> + <widget class="QLabel" name="label_10"> + <property name="whatsThis"> + <string>Show task's icons only</string> + </property> + <property name="text"> + <string>Show only icons:</string> + </property> + </widget> + </item> + <item row="12" column="1"> + <spacer name="verticalSpacer_6"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>64</width> + <height>5</height> + </size> + </property> + </spacer> + </item> + <item row="7" column="1"> + <widget class="QCheckBox" name="showOnlyIcons"> + <property name="toolTip"> + <string/> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> </layout> </widget> <customwidgets> Index: abstracttaskitem.h =================================================================== --- abstracttaskitem.h (révision 1090185) +++ abstracttaskitem.h (copie de travail) @@ -132,6 +132,9 @@ void setPreferredOffscreenSize(); void setPreferredOnscreenSize(); + void setShowOnlyIcon(bool); + bool showOnlyIcon() const; + //TODO: to be removed when we have proper animated layouts QPointF animationPos() const; void setAnimationPos(const QPointF &pos); @@ -255,6 +258,7 @@ bool m_showText : 1; bool m_layoutAnimationLock : 1; bool m_firstGeometryUpdate : 1; + bool m_showOnlyIcon : 1; }; #endif Index: tasks.cpp =================================================================== --- tasks.cpp (révision 1090185) +++ tasks.cpp (copie de travail) @@ -132,6 +132,7 @@ m_groupManager->setSortingStrategy( static_cast<TaskManager::GroupManager::TaskSortingStrategy>(cg.readEntry("sortingStrategy", static_cast<int>(TaskManager::GroupManager::AlphaSorting)))); m_rootGroupItem->setMaxRows( cg.readEntry("maxRows", 2)); m_rootGroupItem->setForceRows( cg.readEntry("forceRows", false)); + m_rootGroupItem->setShowOnlyIcon( cg.readEntry("showOnlyIcons", false)); emit settingsChanged(); } @@ -252,6 +253,7 @@ m_ui.showTooltip->setChecked(m_showTooltip); m_ui.highlightWindows->setChecked(m_highlightWindows); + m_ui.showOnlyIcons->setChecked(m_rootGroupItem->showOnlyIcon()); m_ui.showOnlyCurrentDesktop->setChecked(m_groupManager->showOnlyCurrentDesktop()); m_ui.showOnlyCurrentScreen->setChecked(m_groupManager->showOnlyCurrentScreen()); m_ui.showOnlyMinimized->setChecked(m_groupManager->showOnlyMinimized()); @@ -386,6 +388,13 @@ changed = true; } + if(m_rootGroupItem->showOnlyIcon() != m_ui.showOnlyIcons->isChecked()) { + m_rootGroupItem->setShowOnlyIcon(m_ui.showOnlyIcons->isChecked()); + KConfigGroup cg = config(); + cg.writeEntry("showOnlyIcons", m_rootGroupItem->showOnlyIcon()); + changed = true; + } + if (changed) { emit settingsChanged(); emit configNeedsSaving();
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel