Taskbar: small/panel icon size selection.

By default the 16x16 value was hardcoded into the taskbar, which
is not correct.

With this commit the default value is TDEIcon::Small (can be
defined in TCC->LookNFeel->Icons) to retain the "classic" style.

This commit adds a "Small icons" checkbox which can be unchecked
to set the icon size to TDEIcon::Panel (for consistency with
other panel icons). Combined with "Icons only", this produces
a Plasma/Windows-like big icon taskbar.

This commit also ensures that in "Icons only" mode the icons
are centered in their button, for better looking result.

Finally, this commit fixes a typo in some macros
(TABSKAR -> TASKBAR).

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/266/head
Mavridis Philippe 3 years ago committed by Michele Calgaro
parent 8059293813
commit 74466041a6
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -36,6 +36,7 @@
#include <twin.h> #include <twin.h>
#include <kcolorbutton.h> #include <kcolorbutton.h>
#include <kstandarddirs.h> #include <kstandarddirs.h>
#include <kiconloader.h>
#define protected public #define protected public
#include "kcmtaskbarui.h" #include "kcmtaskbarui.h"
@ -262,6 +263,7 @@ TaskbarConfig::TaskbarConfig(TQWidget *parent, const char* name, const TQStringL
m_widget->showAllScreens->show(); m_widget->showAllScreens->show();
} }
connect( m_widget->showAllScreens, TQT_SIGNAL( stateChanged( int )), TQT_SLOT( changed())); connect( m_widget->showAllScreens, TQT_SIGNAL( stateChanged( int )), TQT_SLOT( changed()));
connect( m_widget->smallIcons, TQT_SIGNAL(toggled(bool)), TQT_SLOT(changed()) );
TDEAboutData *about = new TDEAboutData(I18N_NOOP("kcmtaskbar"), TDEAboutData *about = new TDEAboutData(I18N_NOOP("kcmtaskbar"),
I18N_NOOP("TDE Taskbar Control Module"), I18N_NOOP("TDE Taskbar Control Module"),
@ -423,20 +425,36 @@ void TaskbarConfig::load()
slotUpdateComboBox(); slotUpdateComboBox();
updateAppearanceCombo(); updateAppearanceCombo();
m_widget->showAllScreens->setChecked(!m_settingsObject->showCurrentScreenOnly()); m_widget->showAllScreens->setChecked(!m_settingsObject->showCurrentScreenOnly());
int iconSize = m_settingsObject->iconSize();
if(kapp->iconLoader()->currentSize(TDEIcon::Small) != iconSize)
{
m_widget->smallIcons->setChecked(false);
}
} }
void TaskbarConfig::save() void TaskbarConfig::save()
{ {
TDECModule::save(); TDECModule::save();
if(m_widget->smallIcons->isChecked())
{
m_settingsObject->setIconSize(kapp->iconLoader()->currentSize(TDEIcon::Small));
}
else
{
m_settingsObject->setIconSize(kapp->iconLoader()->currentSize(TDEIcon::Panel));
}
m_settingsObject->setShowCurrentScreenOnly(!m_widget->showAllScreens->isChecked()); m_settingsObject->setShowCurrentScreenOnly(!m_widget->showAllScreens->isChecked());
int selectedAppearance = m_widget->appearance->currentItem(); int selectedAppearance = m_widget->appearance->currentItem();
if (selectedAppearance < (int)m_appearances.count()) if (selectedAppearance < (int)m_appearances.count())
{ {
m_appearances[selectedAppearance].alterSettings(); m_appearances[selectedAppearance].alterSettings();
m_settingsObject->writeConfig();
} }
m_settingsObject->writeConfig();
TQByteArray data; TQByteArray data;
kapp->dcopClient()->emitDCOPSignal("kdeTaskBarConfigChanged()", data); kapp->dcopClient()->emitDCOPSignal("kdeTaskBarConfigChanged()", data);
} }

@ -667,48 +667,6 @@ By default the taskbar groups windows when it is full.</string>
<string>Choose taskbar display mode among &lt;strong&gt;Icons and text&lt;/strong&gt;, &lt;strong&gt;Text only&lt;/strong&gt; and &lt;strong&gt;Icons only&lt;/strong&gt;.</string> <string>Choose taskbar display mode among &lt;strong&gt;Icons and text&lt;/strong&gt;, &lt;strong&gt;Text only&lt;/strong&gt; and &lt;strong&gt;Icons only&lt;/strong&gt;.</string>
</property> </property>
</widget> </widget>
<widget class="TQCheckBox" row="2" column="0" rowspan="1" colspan="4">
<property name="name">
<cstring>kcfg_ShowThumbnails</cstring>
</property>
<property name="text">
<string>Show thumbnails on hover</string>
</property>
</widget>
<spacer row="3" column="0">
<property name="name">
<cstring>spacer2_2_2_3</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<spacer row="1" column="1">
<property name="name">
<cstring>spacer2_2_2_3_2</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
<widget class="TQLabel" row="0" column="0" rowspan="1" colspan="2"> <widget class="TQLabel" row="0" column="0" rowspan="1" colspan="2">
<property name="name"> <property name="name">
<cstring>displayIconsNTextLabel</cstring> <cstring>displayIconsNTextLabel</cstring>
@ -734,6 +692,14 @@ By default the taskbar groups windows when it is full.</string>
<cstring>kcfg_DisplayIconsNText</cstring> <cstring>kcfg_DisplayIconsNText</cstring>
</property> </property>
</widget> </widget>
<widget class="TQCheckBox" row="2" column="0" rowspan="1" colspan="4">
<property name="name">
<cstring>kcfg_ShowThumbnails</cstring>
</property>
<property name="text">
<string>Show thumbnails on hover</string>
</property>
</widget>
<widget class="TQSpinBox" row="3" column="3"> <widget class="TQSpinBox" row="3" column="3">
<property name="name"> <property name="name">
<cstring>kcfg_ThumbnailMaxDimension</cstring> <cstring>kcfg_ThumbnailMaxDimension</cstring>
@ -754,6 +720,23 @@ By default the taskbar groups windows when it is full.</string>
<number>100</number> <number>100</number>
</property> </property>
</widget> </widget>
<spacer row="3" column="0">
<property name="name">
<cstring>spacer2_2_2_3</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Fixed</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="TQLabel" row="3" column="1" rowspan="1" colspan="2"> <widget class="TQLabel" row="3" column="1" rowspan="1" colspan="2">
<property name="name"> <property name="name">
<cstring>thumbMaxDimensionLabel</cstring> <cstring>thumbMaxDimensionLabel</cstring>
@ -765,6 +748,17 @@ By default the taskbar groups windows when it is full.</string>
<string>Maximum dimension:</string> <string>Maximum dimension:</string>
</property> </property>
</widget> </widget>
<widget class="TQCheckBox" row="1" column="2">
<property name="name">
<cstring>smallIcons</cstring>
</property>
<property name="text">
<string>Small icons</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</grid> </grid>
</widget> </widget>
<widget class="TQButtonGroup" row="0" column="0"> <widget class="TQButtonGroup" row="0" column="0">

@ -49,7 +49,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "taskbar.h" #include "taskbar.h"
#include "taskbar.moc" #include "taskbar.moc"
#define READ_MERGED_TASBKAR_SETTING(x) ((m_settingsObject->useGlobalSettings())?m_globalSettingsObject->x():m_settingsObject->x()) #define READ_MERGED_TASKBAR_SETTING(x) ((m_settingsObject->useGlobalSettings())?m_globalSettingsObject->x():m_settingsObject->x())
TaskBar::TaskBar( TaskBarSettings* settingsObject, TaskBarSettings* globalSettingsObject, TQWidget *parent, const char *name ) TaskBar::TaskBar( TaskBarSettings* settingsObject, TaskBarSettings* globalSettingsObject, TQWidget *parent, const char *name )
: Panner( parent, name ), : Panner( parent, name ),
@ -81,7 +81,7 @@ TaskBar::TaskBar( TaskBarSettings* settingsObject, TaskBarSettings* globalSettin
// init // init
setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Expanding ) ); setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Expanding ) );
m_sortByAppPrev = READ_MERGED_TASBKAR_SETTING(sortByApp); m_sortByAppPrev = READ_MERGED_TASKBAR_SETTING(sortByApp);
// setup animation frames // setup animation frames
for (int i = 1; i < 11; i++) for (int i = 1; i < 11; i++)
@ -174,31 +174,40 @@ KTextShadowEngine *TaskBar::textShadowEngine()
return m_textShadowEngine; return m_textShadowEngine;
} }
int TaskBar::buttonHeight() const
TQSize TaskBar::sizeHint() const
{ {
// get our minimum height based on the minimum button height or the
// height of the font in use, which is largest
TQFontMetrics fm(TDEGlobalSettings::taskbarFont()); TQFontMetrics fm(TDEGlobalSettings::taskbarFont());
int minButtonHeight = fm.height() > READ_MERGED_TASBKAR_SETTING(minimumButtonHeight) ? int bh = TQMAX(fm.height(), READ_MERGED_TASKBAR_SETTING(minimumButtonHeight));
fm.height() : READ_MERGED_TASBKAR_SETTING(minimumButtonHeight);
if(showIcons())
{
bh = TQMAX(bh, READ_MERGED_TASKBAR_SETTING(iconSize));
}
return bh + 2;
}
int TaskBar::buttonWidth() const
{
return TQMAX(BUTTON_MIN_WIDTH, READ_MERGED_TASKBAR_SETTING(iconSize)) + 2;
}
return TQSize(BUTTON_MIN_WIDTH, minButtonHeight);
TQSize TaskBar::sizeHint() const
{
return TQSize(buttonWidth(), buttonHeight());
} }
TQSize TaskBar::sizeHint( KPanelExtension::Position p, TQSize maxSize) const TQSize TaskBar::sizeHint( KPanelExtension::Position p, TQSize maxSize) const
{ {
// get our minimum height based on the minimum button height or the // get our minimum height based on the minimum button height, the icon size or the
// height of the font in use, which is largest // height of the font in use, whichever is largest
TQFontMetrics fm(TDEGlobalSettings::taskbarFont());
int minButtonHeight = fm.height() > READ_MERGED_TASBKAR_SETTING(minimumButtonHeight) ?
fm.height() : READ_MERGED_TASBKAR_SETTING(minimumButtonHeight);
if ( p == KPanelExtension::Left || p == KPanelExtension::Right ) if ( p == KPanelExtension::Left || p == KPanelExtension::Right )
{ {
// Vertical layout // Vertical layout
// Minimum space allows for one icon, the window list button and the up/down scrollers // Minimum space allows for one icon, the window list button and the up/down scrollers
int minHeight = minButtonHeight*3; int minHeight = buttonHeight()*3;
if (minHeight > maxSize.height()) if (minHeight > maxSize.height())
return maxSize; return maxSize;
return TQSize(maxSize.width(), minHeight); return TQSize(maxSize.width(), minHeight);
@ -207,7 +216,7 @@ TQSize TaskBar::sizeHint( KPanelExtension::Position p, TQSize maxSize) const
{ {
// Horizontal layout // Horizontal layout
// Minimum space allows for one column of icons, the window list button and the left/right scrollers // Minimum space allows for one column of icons, the window list button and the left/right scrollers
int min_width=BUTTON_MIN_WIDTH*3; int min_width=buttonWidth()*3;
if (min_width > maxSize.width()) if (min_width > maxSize.width())
return maxSize; return maxSize;
return TQSize(min_width, maxSize.height()); return TQSize(min_width, maxSize.height());
@ -234,15 +243,15 @@ void TaskBar::configure()
bool wasShowOnlyIconified = m_showOnlyIconified; bool wasShowOnlyIconified = m_showOnlyIconified;
int wasShowTaskStates = m_showTaskStates; int wasShowTaskStates = m_showTaskStates;
m_showAllWindows = READ_MERGED_TASBKAR_SETTING(showAllWindows); m_showAllWindows = READ_MERGED_TASKBAR_SETTING(showAllWindows);
m_sortByDesktop = m_showAllWindows && READ_MERGED_TASBKAR_SETTING(sortByDesktop); m_sortByDesktop = m_showAllWindows && READ_MERGED_TASKBAR_SETTING(sortByDesktop);
m_displayIconsNText = READ_MERGED_TASBKAR_SETTING(displayIconsNText); m_displayIconsNText = READ_MERGED_TASKBAR_SETTING(displayIconsNText);
m_showOnlyIconified = READ_MERGED_TASBKAR_SETTING(showOnlyIconified); m_showOnlyIconified = READ_MERGED_TASKBAR_SETTING(showOnlyIconified);
m_cycleWheel = READ_MERGED_TASBKAR_SETTING(cycleWheel); m_cycleWheel = READ_MERGED_TASKBAR_SETTING(cycleWheel);
m_showTaskStates = READ_MERGED_TASBKAR_SETTING(showTaskStates); m_showTaskStates = READ_MERGED_TASKBAR_SETTING(showTaskStates);
m_currentScreen = -1; // Show all screens or re-get our screen m_currentScreen = -1; // Show all screens or re-get our screen
m_showOnlyCurrentScreen = (READ_MERGED_TASBKAR_SETTING(showCurrentScreenOnly) && m_showOnlyCurrentScreen = (READ_MERGED_TASKBAR_SETTING(showCurrentScreenOnly) &&
TQApplication::desktop()->isVirtualDesktop() && TQApplication::desktop()->isVirtualDesktop() &&
TQApplication::desktop()->numScreens() > 1); TQApplication::desktop()->numScreens() > 1);
@ -275,12 +284,12 @@ void TaskBar::configure()
} }
} }
if (m_sortByAppPrev != READ_MERGED_TASBKAR_SETTING(sortByApp)) { if (m_sortByAppPrev != READ_MERGED_TASKBAR_SETTING(sortByApp)) {
m_sortByAppPrev = READ_MERGED_TASBKAR_SETTING(sortByApp); m_sortByAppPrev = READ_MERGED_TASKBAR_SETTING(sortByApp);
reSort(); reSort();
} }
TaskManager::the()->setXCompositeEnabled(READ_MERGED_TASBKAR_SETTING(showThumbnails)); TaskManager::the()->setXCompositeEnabled(READ_MERGED_TASKBAR_SETTING(showThumbnails));
reLayoutEventually(); reLayoutEventually();
} }
@ -409,7 +418,7 @@ void TaskBar::showTaskContainer(TaskContainer* container)
} }
// try to place the container after one of the same app // try to place the container after one of the same app
if (READ_MERGED_TASBKAR_SETTING(sortByApp)) if (READ_MERGED_TASKBAR_SETTING(sortByApp))
{ {
TaskContainer::Iterator it = containers.begin(); TaskContainer::Iterator it = containers.begin();
for (; it != containers.end(); ++it) for (; it != containers.end(); ++it)
@ -731,14 +740,12 @@ void TaskBar::reLayout()
// number of rows simply depends on our height which is either the // number of rows simply depends on our height which is either the
// minimum button height or the height of the font in use, whichever is // minimum button height or the height of the font in use, whichever is
// largest // largest
TQFontMetrics fm(TDEGlobalSettings::taskbarFont()); int minButtonHeight = buttonHeight();
int minButtonHeight = fm.height() > READ_MERGED_TASBKAR_SETTING(minimumButtonHeight) ?
fm.height() : READ_MERGED_TASBKAR_SETTING(minimumButtonHeight);
// horizontal layout // horizontal layout
if (orientation() == Qt::Horizontal) if (orientation() == Qt::Horizontal)
{ {
int bwidth=BUTTON_MIN_WIDTH; int bwidth=buttonWidth();
int rows = contentsRect().height() / minButtonHeight; int rows = contentsRect().height() / minButtonHeight;
if (rows<1) if (rows<1)
rows=1; rows=1;
@ -752,20 +759,20 @@ void TaskBar::reLayout()
int bpr = static_cast<int>(ceil(static_cast<double>(list.count()) / rows)); int bpr = static_cast<int>(ceil(static_cast<double>(list.count()) / rows));
// adjust content size // adjust content size
if ( contentsRect().width() < bpr * BUTTON_MIN_WIDTH ) if ( contentsRect().width() < bpr * bwidth )
{ {
resizeContents( bpr * BUTTON_MIN_WIDTH, contentsRect().height() ); resizeContents( bpr * bwidth, contentsRect().height() );
} }
// maximum number of buttons per row // maximum number of buttons per row
int mbpr = contentsRect().width() / BUTTON_MIN_WIDTH; int mbpr = contentsRect().width() / bwidth;
// expand button width if space permits and the taskbar is not in 'icons only' mode // expand button width if space permits and the taskbar is not in 'icons only' mode
if (mbpr > bpr) if (mbpr > bpr)
{ {
if (!showIcons() || showText()) if (!showIcons() || showText())
bwidth = contentsRect().width() / bpr; bwidth = contentsRect().width() / bpr;
int maxWidth = READ_MERGED_TASBKAR_SETTING(maximumButtonWidth); int maxWidth = READ_MERGED_TASKBAR_SETTING(maximumButtonWidth);
if (maxWidth > 0 && bwidth > maxWidth) if (maxWidth > 0 && bwidth > maxWidth)
{ {
bwidth = maxWidth; bwidth = maxWidth;
@ -987,9 +994,7 @@ int TaskBar::taskCount() const
int TaskBar::maximumButtonsWithoutShrinking() const int TaskBar::maximumButtonsWithoutShrinking() const
{ {
TQFontMetrics fm(TDEGlobalSettings::taskbarFont()); int minButtonHeight = buttonHeight();
int minButtonHeight = fm.height() > READ_MERGED_TASBKAR_SETTING(minimumButtonHeight) ?
fm.height() : READ_MERGED_TASBKAR_SETTING(minimumButtonHeight);
int rows = contentsRect().height() / minButtonHeight; int rows = contentsRect().height() / minButtonHeight;
if (rows < 1) if (rows < 1)
@ -999,7 +1004,7 @@ int TaskBar::maximumButtonsWithoutShrinking() const
if ( orientation() == Qt::Horizontal ) { if ( orientation() == Qt::Horizontal ) {
// maxWidth of 0 means no max width, drop back to default // maxWidth of 0 means no max width, drop back to default
int maxWidth = READ_MERGED_TASBKAR_SETTING(maximumButtonWidth); int maxWidth = READ_MERGED_TASKBAR_SETTING(maximumButtonWidth);
if (maxWidth == 0) if (maxWidth == 0)
{ {
maxWidth = BUTTON_MAX_WIDTH; maxWidth = BUTTON_MAX_WIDTH;
@ -1017,8 +1022,8 @@ int TaskBar::maximumButtonsWithoutShrinking() const
bool TaskBar::shouldGroup() const bool TaskBar::shouldGroup() const
{ {
return READ_MERGED_TASBKAR_SETTING(groupTasks) == m_settingsObject->GroupAlways || return READ_MERGED_TASKBAR_SETTING(groupTasks) == m_settingsObject->GroupAlways ||
((READ_MERGED_TASBKAR_SETTING(groupTasks) == m_settingsObject->GroupWhenFull && ((READ_MERGED_TASKBAR_SETTING(groupTasks) == m_settingsObject->GroupWhenFull &&
taskCount() > maximumButtonsWithoutShrinking())); taskCount() > maximumButtonsWithoutShrinking()));
} }
@ -1166,7 +1171,7 @@ void TaskBar::activateNextTask(bool forward)
void TaskBar::wheelEvent(TQWheelEvent* e) void TaskBar::wheelEvent(TQWheelEvent* e)
{ {
if(READ_MERGED_TASBKAR_SETTING(cycleWheel)) { if(READ_MERGED_TASKBAR_SETTING(cycleWheel)) {
if (e->delta() > 0) if (e->delta() > 0)
{ {

@ -137,6 +137,8 @@ protected:
void moveEvent( TQMoveEvent* ); void moveEvent( TQMoveEvent* );
bool idMatch( const TQString& id1, const TQString& id2 ); bool idMatch( const TQString& id1, const TQString& id2 );
TaskContainer::List filteredContainers(); TaskContainer::List filteredContainers();
int buttonHeight() const;
int buttonWidth() const;
private: private:
void sortContainersByDesktop(TaskContainer::List& list); void sortContainersByDesktop(TaskContainer::List& list);
@ -168,6 +170,7 @@ private:
TQImage m_blendGradient; TQImage m_blendGradient;
TaskBarSettings* m_settingsObject; TaskBarSettings* m_settingsObject;
TaskBarSettings* m_globalSettingsObject; TaskBarSettings* m_globalSettingsObject;
}; };
#endif #endif

@ -212,5 +212,8 @@
<default code="true">QColor()</default> <default code="true">QColor()</default>
<whatsthis>This color is used for displaying background of taskbar buttons.</whatsthis> <whatsthis>This color is used for displaying background of taskbar buttons.</whatsthis>
</entry> </entry>
<entry name="IconSize" type="UInt" >
<default>16</default>
</entry>
</group> </group>
</kcfg> </kcfg>

@ -62,8 +62,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "taskcontainer.h" #include "taskcontainer.h"
#include "taskcontainer.moc" #include "taskcontainer.moc"
#define READ_MERGED_TASBKAR_SETTING(x) ((m_settingsObject->useGlobalSettings())?m_globalSettingsObject->x():m_settingsObject->x()) #define READ_MERGED_TASKBAR_SETTING(x) ((m_settingsObject->useGlobalSettings())?m_globalSettingsObject->x():m_settingsObject->x())
#define READ_MERGED_TASBKAR_ACTION(x) ((m_settingsObject->useGlobalSettings())?m_globalSettingsObject->action(x):m_settingsObject->action(x)) #define READ_MERGED_TASKBAR_ACTION(x) ((m_settingsObject->useGlobalSettings())?m_globalSettingsObject->action(x):m_settingsObject->action(x))
static Bool netwm_atoms_created = False; static Bool netwm_atoms_created = False;
static Atom net_wm_pid = 0; static Atom net_wm_pid = 0;
@ -192,9 +192,11 @@ void TaskContainer::init()
if (!netwm_atoms_created) create_atoms(TQPaintDevice::x11AppDisplay()); if (!netwm_atoms_created) create_atoms(TQPaintDevice::x11AppDisplay());
int iconSize = READ_MERGED_TASKBAR_SETTING(iconSize);
setWFlags(TQt::WNoAutoErase); setWFlags(TQt::WNoAutoErase);
setBackgroundMode(NoBackground); setBackgroundMode(NoBackground);
animBg = TQPixmap(16, 16); animBg = TQPixmap(iconSize, iconSize);
installEventFilter(KickerTip::the()); installEventFilter(KickerTip::the());
@ -366,11 +368,11 @@ void TaskContainer::checkAttention(const Task::Ptr t)
void TaskContainer::attentionTimerFired() void TaskContainer::attentionTimerFired()
{ {
assert( attentionState != -1 ); assert( attentionState != -1 );
if (attentionState < READ_MERGED_TASBKAR_SETTING(attentionBlinkIterations)*2) if (attentionState < READ_MERGED_TASKBAR_SETTING(attentionBlinkIterations)*2)
{ {
++attentionState; ++attentionState;
} }
else if (READ_MERGED_TASBKAR_SETTING(attentionBlinkIterations) < 1000) else if (READ_MERGED_TASKBAR_SETTING(attentionBlinkIterations) < 1000)
{ {
attentionTimer.stop(); attentionTimer.stop();
} }
@ -390,9 +392,18 @@ TQSizePolicy TaskContainer::sizePolicy() const
void TaskContainer::resizeEvent( TQResizeEvent * ) void TaskContainer::resizeEvent( TQResizeEvent * )
{ {
int iconSize = READ_MERGED_TASKBAR_SETTING(iconSize);
// calculate the icon rect // calculate the icon rect
TQRect br( style().subRect( TQStyle::SR_PushButtonContents, this ) ); if(taskBar->showText())
iconRect = TQStyle::visualRect( TQRect(br.x() + 2, (height() - 16) / 2, 16, 16), this ); {
TQRect br( style().subRect( TQStyle::SR_PushButtonContents, this ) );
iconRect = TQStyle::visualRect( TQRect(br.x() + 2, (height() - iconSize) / 2, iconSize, iconSize), this );
}
else
{
iconRect = TQStyle::visualRect( TQRect((width() - iconSize) / 2, (height() - iconSize) / 2, iconSize, iconSize), this );
}
} }
void TaskContainer::add(Task::Ptr task) void TaskContainer::add(Task::Ptr task)
@ -581,13 +592,14 @@ void TaskContainer::drawButton(TQPainter *p)
TQPixmap *pm((TQPixmap*)p->device()); TQPixmap *pm((TQPixmap*)p->device());
TQPixmap pixmap; // icon TQPixmap pixmap; // icon
Task::Ptr task = 0; Task::Ptr task = 0;
bool iconified = !READ_MERGED_TASBKAR_SETTING(showOnlyIconified); bool iconified = !READ_MERGED_TASKBAR_SETTING(showOnlyIconified);
bool halo = READ_MERGED_TASBKAR_SETTING(haloText); bool halo = READ_MERGED_TASKBAR_SETTING(haloText);
bool alwaysDrawButtons = READ_MERGED_TASBKAR_SETTING(drawButtons); bool alwaysDrawButtons = READ_MERGED_TASKBAR_SETTING(drawButtons);
bool drawButton = alwaysDrawButtons || bool drawButton = alwaysDrawButtons ||
(m_mouseOver && !halo && isEnabled() && (m_mouseOver && !halo && isEnabled() &&
READ_MERGED_TASBKAR_SETTING(showButtonOnHover)); READ_MERGED_TASKBAR_SETTING(showButtonOnHover));
TQFont font(TDEGlobalSettings::taskbarFont()); TQFont font(TDEGlobalSettings::taskbarFont());
int iconSize = READ_MERGED_TASKBAR_SETTING(iconSize);
// draw sunken if we contain the active task // draw sunken if we contain the active task
bool active = false; bool active = false;
@ -608,7 +620,7 @@ void TaskContainer::drawButton(TQPainter *p)
if (task->demandsAttention()) if (task->demandsAttention())
{ {
demandsAttention = attentionState == READ_MERGED_TASBKAR_SETTING(attentionBlinkIterations) || demandsAttention = attentionState == READ_MERGED_TASKBAR_SETTING(attentionBlinkIterations) ||
attentionState % 2 == 0; attentionState % 2 == 0;
} }
} }
@ -617,12 +629,12 @@ void TaskContainer::drawButton(TQPainter *p)
TQColorGroup colors = palette().active(); TQColorGroup colors = palette().active();
if (READ_MERGED_TASBKAR_SETTING(useCustomColors)) if (READ_MERGED_TASKBAR_SETTING(useCustomColors))
{ {
colors.setColor( TQColorGroup::Button, READ_MERGED_TASBKAR_SETTING(taskBackgroundColor)); colors.setColor( TQColorGroup::Button, READ_MERGED_TASKBAR_SETTING(taskBackgroundColor));
colors.setColor( TQColorGroup::Background, READ_MERGED_TASBKAR_SETTING(taskBackgroundColor) ); colors.setColor( TQColorGroup::Background, READ_MERGED_TASKBAR_SETTING(taskBackgroundColor) );
colors.setColor( TQColorGroup::ButtonText, READ_MERGED_TASBKAR_SETTING(inactiveTaskTextColor) ); colors.setColor( TQColorGroup::ButtonText, READ_MERGED_TASKBAR_SETTING(inactiveTaskTextColor) );
colors.setColor( TQColorGroup::Text, READ_MERGED_TASBKAR_SETTING(inactiveTaskTextColor) ); colors.setColor( TQColorGroup::Text, READ_MERGED_TASKBAR_SETTING(inactiveTaskTextColor) );
} }
if (demandsAttention) if (demandsAttention)
@ -659,7 +671,7 @@ void TaskContainer::drawButton(TQPainter *p)
// get the task icon // get the task icon
if (task) if (task)
{ {
pixmap = task->pixmap(); pixmap = task->icon(iconSize, iconSize, true);
} }
bool sunken = isDown() || (alwaysDrawButtons && (active || aboutToActivate)); bool sunken = isDown() || (alwaysDrawButtons && (active || aboutToActivate));
@ -671,7 +683,7 @@ void TaskContainer::drawButton(TQPainter *p)
// draw button background // draw button background
if (drawButton) if (drawButton)
{ {
if (READ_MERGED_TASBKAR_SETTING(drawButtons) && KickerSettings::showDeepButtons()) { if (READ_MERGED_TASKBAR_SETTING(drawButtons) && KickerSettings::showDeepButtons()) {
style().tqdrawPrimitive(TQStyle::PE_ButtonBevel, p, style().tqdrawPrimitive(TQStyle::PE_ButtonBevel, p,
TQRect(1, 1, width()-3, height()-2), TQRect(1, 1, width()-3, height()-2),
colors, sunken ? TQStyle::Style_On : TQStyle::Style_Raised); colors, sunken ? TQStyle::Style_On : TQStyle::Style_Raised);
@ -690,21 +702,21 @@ void TaskContainer::drawButton(TQPainter *p)
} }
TQString text = name(); // find text TQString text = name(); // find text
int textPos = ( taskBar->showIcons() && (!pixmap.isNull() || m_startup)) ? 2 + 16 + 2 : 0; int textPos = ( taskBar->showIcons() && (!pixmap.isNull() || m_startup)) ? 2 + iconSize + 2 : 0;
// show icons // show icons
if (taskBar->showIcons()) if (taskBar->showIcons())
{ {
if (pixmap.isNull() && m_startup) if (pixmap.isNull() && m_startup)
pixmap = SmallIcon(m_startup->icon()); pixmap = kapp->iconLoader()->loadIcon(m_startup->icon(), TDEIcon::Panel, iconSize);
if ( !pixmap.isNull() ) if ( !pixmap.isNull() )
{ {
// make sure it is no larger than 16x16 // make sure it is no larger than icon size
if ( pixmap.width() > 16 || pixmap.height() > 16 ) if ( pixmap.width() > iconSize || pixmap.height() > iconSize )
{ {
TQImage tmp = pixmap.convertToImage(); TQImage tmp = pixmap.convertToImage();
pixmap.convertFromImage( tmp.smoothScale( 16, 16 ) ); pixmap.convertFromImage( tmp.smoothScale( iconSize, iconSize ) );
} }
// fade out the icon when minimized // fade out the icon when minimized
@ -731,13 +743,13 @@ void TaskContainer::drawButton(TQPainter *p)
// draw modified overlay // draw modified overlay
if (!modPixmap.isNull()) if (!modPixmap.isNull())
{ {
TQRect r = TQStyle::visualRect(TQRect(br.x() + textPos,(height() - 16) / 2, 16, 16), this); TQRect r = TQStyle::visualRect(TQRect(br.x() + textPos,(height() - iconSize) / 2, iconSize, iconSize), this);
if (iconified) if (iconified)
{ {
TDEIconEffect::semiTransparent(modPixmap); TDEIconEffect::semiTransparent(modPixmap);
} }
p->drawPixmap(r, modPixmap); p->drawPixmap(r, modPixmap);
textPos += 16 + 2; textPos += iconSize + 2;
} }
} }
} }
@ -765,9 +777,9 @@ void TaskContainer::drawButton(TQPainter *p)
} }
else // hack for the dotNET style and others else // hack for the dotNET style and others
{ {
if (READ_MERGED_TASBKAR_SETTING(useCustomColors)) if (READ_MERGED_TASKBAR_SETTING(useCustomColors))
{ {
textPen = TQPen(READ_MERGED_TASBKAR_SETTING(activeTaskTextColor)); textPen = TQPen(READ_MERGED_TASKBAR_SETTING(activeTaskTextColor));
} }
else else
{ {
@ -775,7 +787,7 @@ void TaskContainer::drawButton(TQPainter *p)
} }
} }
int availableWidth = width() - (br.x() * 2) - textPos - 2 - (READ_MERGED_TASBKAR_SETTING(drawButtons) && KickerSettings::showDeepButtons())?2:0; int availableWidth = width() - (br.x() * 2) - textPos - 2 - (READ_MERGED_TASKBAR_SETTING(drawButtons) && KickerSettings::showDeepButtons())?2:0;
if (m_filteredTasks.count() > 1) if (m_filteredTasks.count() > 1)
{ {
availableWidth -= 8; availableWidth -= 8;
@ -852,7 +864,7 @@ void TaskContainer::drawButton(TQPainter *p)
} }
// draw popup arrow // draw popup arrow
if ((m_filteredTasks.count() > 1) && (!(READ_MERGED_TASBKAR_SETTING(drawButtons) && KickerSettings::showDeepButtons()))) if ((m_filteredTasks.count() > 1) && (!(READ_MERGED_TASKBAR_SETTING(drawButtons) && KickerSettings::showDeepButtons())))
{ {
TQStyle::PrimitiveElement e = TQStyle::PE_ArrowLeft; TQStyle::PrimitiveElement e = TQStyle::PE_ArrowLeft;
@ -995,14 +1007,14 @@ void TaskContainer::mousePressEvent( TQMouseEvent* e )
switch (e->button()) switch (e->button())
{ {
case Qt::LeftButton: case Qt::LeftButton:
buttonAction = READ_MERGED_TASBKAR_ACTION(m_settingsObject->LeftButton); buttonAction = READ_MERGED_TASKBAR_ACTION(m_settingsObject->LeftButton);
break; break;
case Qt::MidButton: case Qt::MidButton:
buttonAction = READ_MERGED_TASBKAR_ACTION(m_settingsObject->MiddleButton); buttonAction = READ_MERGED_TASKBAR_ACTION(m_settingsObject->MiddleButton);
break; break;
case Qt::RightButton: case Qt::RightButton:
default: default:
buttonAction = READ_MERGED_TASBKAR_ACTION(m_settingsObject->RightButton); buttonAction = READ_MERGED_TASKBAR_ACTION(m_settingsObject->RightButton);
break; break;
} }
@ -1018,7 +1030,7 @@ void TaskContainer::mouseReleaseEvent(TQMouseEvent *e)
{ {
m_dragStartPos = TQPoint(); m_dragStartPos = TQPoint();
if (!READ_MERGED_TASBKAR_SETTING(drawButtons)) if (!READ_MERGED_TASKBAR_SETTING(drawButtons))
{ {
setDown(false); setDown(false);
} }
@ -1036,14 +1048,14 @@ void TaskContainer::mouseReleaseEvent(TQMouseEvent *e)
switch (e->button()) switch (e->button())
{ {
case Qt::LeftButton: case Qt::LeftButton:
buttonAction = READ_MERGED_TASBKAR_ACTION(m_settingsObject->LeftButton); buttonAction = READ_MERGED_TASKBAR_ACTION(m_settingsObject->LeftButton);
break; break;
case Qt::MidButton: case Qt::MidButton:
buttonAction = READ_MERGED_TASBKAR_ACTION(m_settingsObject->MiddleButton); buttonAction = READ_MERGED_TASKBAR_ACTION(m_settingsObject->MiddleButton);
break; break;
case Qt::RightButton: case Qt::RightButton:
default: default:
buttonAction = READ_MERGED_TASBKAR_ACTION(m_settingsObject->RightButton); buttonAction = READ_MERGED_TASKBAR_ACTION(m_settingsObject->RightButton);
break; break;
} }
@ -1223,7 +1235,7 @@ void TaskContainer::popupMenu(int action)
return; return;
} }
m_menu = new TaskRMBMenu(m_filteredTasks, taskBar->showAllWindows(), (READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange))?makeTaskMoveMenu():NULL); m_menu = new TaskRMBMenu(m_filteredTasks, taskBar->showAllWindows(), (READ_MERGED_TASKBAR_SETTING(allowDragAndDropReArrange))?makeTaskMoveMenu():NULL);
} }
else else
{ {
@ -1452,7 +1464,7 @@ void TaskContainer::dragEnterEvent( TQDragEnterEvent* e )
return; return;
} }
if (e->source() && (e->source()->parent() == this->parent()) && TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange) && (!READ_MERGED_TASBKAR_SETTING(sortByApp))) if (e->source() && (e->source()->parent() == this->parent()) && TaskDrag::canDecode(e) && READ_MERGED_TASKBAR_SETTING(allowDragAndDropReArrange) && (!READ_MERGED_TASKBAR_SETTING(sortByApp)))
{ {
e->accept(); e->accept();
} }
@ -1480,7 +1492,7 @@ void TaskContainer::dropEvent( TQDropEvent* e )
return; return;
} }
if ((e->source()->parent() == this->parent()) && TaskDrag::canDecode(e) && READ_MERGED_TASBKAR_SETTING(allowDragAndDropReArrange) && (!READ_MERGED_TASBKAR_SETTING(sortByApp))) if ((e->source()->parent() == this->parent()) && TaskDrag::canDecode(e) && READ_MERGED_TASKBAR_SETTING(allowDragAndDropReArrange) && (!READ_MERGED_TASKBAR_SETTING(sortByApp)))
{ {
if (taskBar->taskMoveHandler(TaskMoveDestination::Position, TaskDrag::decode(e), TQWidget::mapTo(taskBar, e->pos()))) { if (taskBar->taskMoveHandler(TaskMoveDestination::Position, TaskDrag::decode(e), TQWidget::mapTo(taskBar, e->pos()))) {
e->accept(); e->accept();
@ -1631,7 +1643,7 @@ void TaskContainer::updateFilteredTaskList()
{ {
Task::Ptr t = *it; Task::Ptr t = *it;
if ((taskBar->showAllWindows() || t->isOnCurrentDesktop()) && if ((taskBar->showAllWindows() || t->isOnCurrentDesktop()) &&
(!READ_MERGED_TASBKAR_SETTING(showOnlyIconified) || t->isIconified())) (!READ_MERGED_TASKBAR_SETTING(showOnlyIconified) || t->isIconified()))
{ {
pid_t pid = 0; pid_t pid = 0;
#ifdef Q_WS_X11 #ifdef Q_WS_X11
@ -1652,15 +1664,15 @@ void TaskContainer::updateFilteredTaskList()
if (pid < 0) { if (pid < 0) {
m_filteredTasks.append(t); m_filteredTasks.append(t);
} }
else if (READ_MERGED_TASBKAR_SETTING(showTaskStates) != m_settingsObject->ShowAll) { else if (READ_MERGED_TASKBAR_SETTING(showTaskStates) != m_settingsObject->ShowAll) {
if (is_process_resumable(pid)) { if (is_process_resumable(pid)) {
if (READ_MERGED_TASBKAR_SETTING(showTaskStates) == m_settingsObject->ShowAll) { if (READ_MERGED_TASKBAR_SETTING(showTaskStates) == m_settingsObject->ShowAll) {
m_filteredTasks.append(t); m_filteredTasks.append(t);
} }
else if (READ_MERGED_TASBKAR_SETTING(showTaskStates) == m_settingsObject->ShowStopped) { else if (READ_MERGED_TASKBAR_SETTING(showTaskStates) == m_settingsObject->ShowStopped) {
m_filteredTasks.append(t); m_filteredTasks.append(t);
} }
else if (READ_MERGED_TASBKAR_SETTING(showTaskStates) == m_settingsObject->ShowRunning) { else if (READ_MERGED_TASKBAR_SETTING(showTaskStates) == m_settingsObject->ShowRunning) {
t->publishIconGeometry( TQRect()); t->publishIconGeometry( TQRect());
} }
else { else {
@ -1668,13 +1680,13 @@ void TaskContainer::updateFilteredTaskList()
} }
} }
else { else {
if (READ_MERGED_TASBKAR_SETTING(showTaskStates) == m_settingsObject->ShowAll) { if (READ_MERGED_TASKBAR_SETTING(showTaskStates) == m_settingsObject->ShowAll) {
m_filteredTasks.append(t); m_filteredTasks.append(t);
} }
else if (READ_MERGED_TASBKAR_SETTING(showTaskStates) == m_settingsObject->ShowStopped) { else if (READ_MERGED_TASKBAR_SETTING(showTaskStates) == m_settingsObject->ShowStopped) {
t->publishIconGeometry( TQRect()); t->publishIconGeometry( TQRect());
} }
else if (READ_MERGED_TASBKAR_SETTING(showTaskStates) == m_settingsObject->ShowRunning) { else if (READ_MERGED_TASKBAR_SETTING(showTaskStates) == m_settingsObject->ShowRunning) {
m_filteredTasks.append(t); m_filteredTasks.append(t);
} }
else { else {
@ -1742,6 +1754,8 @@ void TaskContainer::settingsChanged()
void TaskContainer::updateKickerTip(KickerTip::Data& data) void TaskContainer::updateKickerTip(KickerTip::Data& data)
{ {
int iconSize = READ_MERGED_TASKBAR_SETTING(iconSize);
if (m_startup) if (m_startup)
{ {
data.message = m_startup->text(); data.message = m_startup->text();
@ -1749,7 +1763,7 @@ void TaskContainer::updateKickerTip(KickerTip::Data& data)
data.subtext = i18n("Loading application ..."); data.subtext = i18n("Loading application ...");
data.icon = TDEGlobal::iconLoader()->loadIcon(m_startup->icon(), data.icon = TDEGlobal::iconLoader()->loadIcon(m_startup->icon(),
TDEIcon::Small, TDEIcon::Small,
TDEIcon::SizeMedium, iconSize,
TDEIcon::DefaultState, TDEIcon::DefaultState,
0, true); 0, true);
return; return;
@ -1761,21 +1775,18 @@ void TaskContainer::updateKickerTip(KickerTip::Data& data)
if (m_filteredTasks.count() > 0) if (m_filteredTasks.count() > 0)
{ {
if (READ_MERGED_TASBKAR_SETTING(showThumbnails) && if (READ_MERGED_TASKBAR_SETTING(showThumbnails) &&
m_filteredTasks.count() == 1) m_filteredTasks.count() == 1)
{ {
Task::Ptr t = m_filteredTasks.first(); Task::Ptr t = m_filteredTasks.first();
pixmap = t->thumbnail(READ_MERGED_TASBKAR_SETTING(thumbnailMaxDimension)); pixmap = t->thumbnail(READ_MERGED_TASKBAR_SETTING(thumbnailMaxDimension));
} }
if (pixmap.isNull() && tasks.count()) if (pixmap.isNull() && tasks.count())
{ {
// try to load icon via net_wm // try to load icon via net_wm
pixmap = KWin::icon(tasks.last()->window(), pixmap = KWin::icon(tasks.last()->window(), iconSize, iconSize, true);
TDEIcon::SizeMedium,
TDEIcon::SizeMedium,
true);
} }
// Collect all desktops the tasks are on. Sort naturally. // Collect all desktops the tasks are on. Sort naturally.
@ -1809,7 +1820,7 @@ void TaskContainer::updateKickerTip(KickerTip::Data& data)
} }
} }
if (READ_MERGED_TASBKAR_SETTING(showAllWindows) && KWin::numberOfDesktops() > 1) if (READ_MERGED_TASKBAR_SETTING(showAllWindows) && KWin::numberOfDesktops() > 1)
{ {
if (desktopMap.isEmpty()) if (desktopMap.isEmpty())
{ {

@ -117,6 +117,7 @@ protected:
void popupMenu(int); void popupMenu(int);
void updateFilteredTaskList(); void updateFilteredTaskList();
void updateIconSize();
protected slots: protected slots:
void animationTimerFired(); void animationTimerFired();

Loading…
Cancel
Save