diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2013-10-28 11:02:52 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2013-10-28 11:04:56 +0100 |
commit | 7119c2b2688b9e7ece707a60f28028b36d1120f9 (patch) | |
tree | f2fd5d872dfe6d684ed31d5d2c24ac6ee39672aa /kicker | |
parent | cbbc7ad02e978c5f2cb1e90338eab65996bc554e (diff) | |
download | tdebase-7119c2b2688b9e7ece707a60f28028b36d1120f9.tar.gz tdebase-7119c2b2688b9e7ece707a60f28028b36d1120f9.zip |
Add option to display only icons on taskbar
This resolves Bug 360
Diffstat (limited to 'kicker')
-rw-r--r-- | kicker/taskbar/taskbar.cpp | 120 | ||||
-rw-r--r-- | kicker/taskbar/taskbar.h | 66 | ||||
-rw-r--r-- | kicker/taskbar/taskbar.kcfg | 21 | ||||
-rw-r--r-- | kicker/taskbar/taskcontainer.cpp | 316 |
4 files changed, 263 insertions, 260 deletions
diff --git a/kicker/taskbar/taskbar.cpp b/kicker/taskbar/taskbar.cpp index ad68f1c8f..d89149b13 100644 --- a/kicker/taskbar/taskbar.cpp +++ b/kicker/taskbar/taskbar.cpp @@ -20,8 +20,13 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************** -******************************************************************/ + Additional changes: + - 2013/10/22 Michele Calgaro + * added support for display mode (Icons and Text, Text only, Icons only) + and removed "Show application icons" +*/ #include <math.h> @@ -58,7 +63,7 @@ TaskBar::TaskBar( TaskBarSettings* settingsObject, TaskBarSettings* globalSettin m_currentScreen(-1), m_showOnlyCurrentScreen(false), m_sortByDesktop(false), - m_showIcon(false), + m_displayIconsNText(settingsObject->DisplayIconsAndText), m_showOnlyIconified(false), m_showTaskStates(0), m_textShadowEngine(0), @@ -196,66 +201,47 @@ TQSize TaskBar::sizeHint( KPanelExtension::Position p, TQSize maxSize) const if ( p == KPanelExtension::Left || p == KPanelExtension::Right ) { - int actualMax = minButtonHeight * containerCount(); - - if (containerCount() == 0) - { - actualMax = minButtonHeight; - } - - if (actualMax > maxSize.height()) - { + // Vertical layout + // Minimum space allows for one icon, the window list button and the up/down scrollers + int minHeight = minButtonHeight*3; + if (minHeight > maxSize.height()) return maxSize; - } - return TQSize( maxSize.width(), actualMax ); + return TQSize(maxSize.width(), minHeight); } else { - int rows = KickerSettings::conserveSpace() ? - contentsRect().height() / minButtonHeight : - 1; - if ( rows < 1 ) - { - rows = 1; - } - - int maxWidth = READ_MERGED_TASBKAR_SETTING(maximumButtonWidth); - if (maxWidth == 0) - { - maxWidth = BUTTON_MAX_WIDTH; - } - - int actualMax = maxWidth * (containerCount() / rows); - - if (containerCount() % rows > 0) - { - actualMax += maxWidth; - } - if (containerCount() == 0) - { - actualMax = maxWidth; - } - - if (actualMax > maxSize.width()) - { - return maxSize; - } - return TQSize( actualMax, maxSize.height() ); + // Horizontal layout + // Minimum space allows for one column of icons, the window list button and the left/right scrollers + int min_width=BUTTON_MIN_WIDTH*3; + if (min_width > maxSize.width()) + return maxSize; + return TQSize(min_width, maxSize.height()); } } +bool TaskBar::showIcons() const +{ + return (m_displayIconsNText==m_settingsObject->DisplayIconsAndText || + m_displayIconsNText==m_settingsObject->DisplayIconsOnly); +} +bool TaskBar::showText() const +{ + return (m_displayIconsNText==m_settingsObject->DisplayIconsAndText || + m_displayIconsNText==m_settingsObject->DisplayTextOnly); +} + void TaskBar::configure() { bool wasShowWindows = m_showAllWindows; bool wasSortByDesktop = m_sortByDesktop; bool wasCycleWheel = m_cycleWheel; - bool wasShowIcon = m_showIcon; + bool wasDisplayIconsNText = m_displayIconsNText; bool wasShowOnlyIconified = m_showOnlyIconified; int wasShowTaskStates = m_showTaskStates; m_showAllWindows = READ_MERGED_TASBKAR_SETTING(showAllWindows); m_sortByDesktop = m_showAllWindows && READ_MERGED_TASBKAR_SETTING(sortByDesktop); - m_showIcon = READ_MERGED_TASBKAR_SETTING(showIcon); + m_displayIconsNText = READ_MERGED_TASBKAR_SETTING(displayIconsNText); m_showOnlyIconified = READ_MERGED_TASBKAR_SETTING(showOnlyIconified); m_cycleWheel = READ_MERGED_TASBKAR_SETTING(cycleWheel); m_showTaskStates = READ_MERGED_TASBKAR_SETTING(showTaskStates); @@ -280,7 +266,7 @@ void TaskBar::configure() if (wasShowWindows != m_showAllWindows || wasSortByDesktop != m_sortByDesktop || - wasShowIcon != m_showIcon || + wasDisplayIconsNText != m_displayIconsNText || wasCycleWheel != m_cycleWheel || wasShowOnlyIconified != m_showOnlyIconified || wasShowTaskStates != m_showTaskStates) @@ -757,25 +743,18 @@ void TaskBar::reLayout() // horizontal layout if (orientation() == Qt::Horizontal) { - int bwidth = BUTTON_MIN_WIDTH; + int bwidth=BUTTON_MIN_WIDTH; int rows = contentsRect().height() / minButtonHeight; - - if ( rows < 1 ) - { - rows = 1; - } + if (rows<1) + rows=1; // actual button height int bheight = contentsRect().height() / rows; - - // avoid zero devision later - if (bheight < 1) - { - bheight = 1; - } + if (bheight<1) // avoid zero devision later + bheight=1; // buttons per row - int bpr = (int)ceil( (double)list.count() / rows); + int bpr = static_cast<int>(ceil(static_cast<double>(list.count()) / rows)); // adjust content size if ( contentsRect().width() < bpr * BUTTON_MIN_WIDTH ) @@ -786,10 +765,11 @@ void TaskBar::reLayout() // maximum number of buttons per row int mbpr = contentsRect().width() / BUTTON_MIN_WIDTH; - // expand button width if space permits + // expand button width if space permits and the taskbar is not in 'icons only' mode if (mbpr > bpr) { - bwidth = contentsRect().width() / bpr; + if (!showIcons() || showText()) + bwidth = contentsRect().width() / bpr; int maxWidth = READ_MERGED_TASBKAR_SETTING(maximumButtonWidth); if (maxWidth > 0 && bwidth > maxWidth) { @@ -840,10 +820,12 @@ void TaskBar::reLayout() } else // vertical layout { + // Adjust min button height to keep gaps into account + int minButtonHeightAdjusted=minButtonHeight+4; // adjust content size - if (contentsRect().height() < (int)list.count() * minButtonHeight) + if (contentsRect().height() < (int)list.count() * minButtonHeightAdjusted) { - resizeContents(contentsRect().width(), list.count() * minButtonHeight); + resizeContents(contentsRect().width(), list.count() * minButtonHeightAdjusted); } // layout containers @@ -856,11 +838,11 @@ void TaskBar::reLayout() c->setArrowType(arrowType); - if (c->width() != contentsRect().width() || c->height() != minButtonHeight) - c->resize(contentsRect().width(), minButtonHeight); + if (c->width() != contentsRect().width() || c->height() != minButtonHeightAdjusted) + c->resize(contentsRect().width(), minButtonHeightAdjusted); - if (childX(c) != 0 || childY(c) != (i * minButtonHeight)) - moveChild(c, 0, i * minButtonHeight); + if (childX(c) != 0 || childY(c) != (i * minButtonHeightAdjusted)) + moveChild(c, 0, i * minButtonHeightAdjusted); c->setBackground(); i++; @@ -1041,8 +1023,8 @@ int TaskBar::maximumButtonsWithoutShrinking() const bool TaskBar::shouldGroup() const { return READ_MERGED_TASBKAR_SETTING(groupTasks) == m_settingsObject->GroupAlways || - (READ_MERGED_TASBKAR_SETTING(groupTasks) == m_settingsObject->GroupWhenFull && - taskCount() > maximumButtonsWithoutShrinking()); + ((READ_MERGED_TASBKAR_SETTING(groupTasks) == m_settingsObject->GroupWhenFull && + taskCount() > maximumButtonsWithoutShrinking())); } void TaskBar::reGroup() diff --git a/kicker/taskbar/taskbar.h b/kicker/taskbar/taskbar.h index 8c1c42e93..111554014 100644 --- a/kicker/taskbar/taskbar.h +++ b/kicker/taskbar/taskbar.h @@ -19,7 +19,13 @@ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -******************************************************************/ +***************************************************************** + + Additional changes: + - 2013/10/22 Michele Calgaro + * added support for display mode (Icons and Text, Text only, Icons only) + and removed "Show application icons" +*/ #ifndef __taskbar_h__ #define __taskbar_h__ @@ -31,9 +37,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "panner.h" #include "kshadowengine.h" -#define WINDOWLISTBUTTON_SIZE 15 -#define BUTTON_MAX_WIDTH 200 -#define BUTTON_MIN_WIDTH 20 +const int WINDOWLISTBUTTON_SIZE = 15; +const int BUTTON_MAX_WIDTH = 200; +const int BUTTON_MIN_WIDTH = 24; // 24 = 4+2+16+2 -> Space for borders, application icon and gaps class Startup; class Task; @@ -85,7 +91,8 @@ public: int taskCount() const; int showScreen() const; - bool showIcon() const { return m_showIcon; } + bool showIcons() const; + bool showText() const; bool sortByDesktop() const { return m_sortByDesktop; } bool showAllWindows() const { return m_showAllWindows; } @@ -140,31 +147,30 @@ private: void sortContainersByDesktop(TaskContainer::List& list); void setViewportBackground(); - bool blocklayout; - bool m_showAllWindows; - bool m_cycleWheel; - // The screen to show, -1 for all screens - int m_currentScreen; - bool m_showOnlyCurrentScreen; - bool m_sortByDesktop; - bool m_showIcon; - bool m_showOnlyIconified; - int m_showTaskStates; - ArrowType arrowType; - TaskContainer::List containers; - TaskContainer::List m_hiddenContainers; - TaskContainer::List m_deletableContainers; - PixmapList frames; - int maximumButtonsWithoutShrinking() const; - bool shouldGroup() const; - bool isGrouping; - void reGroup(); - TDEGlobalAccel* keys; - KTextShadowEngine* m_textShadowEngine; - bool m_ignoreUpdates; - bool m_sortByAppPrev; - TQTimer m_relayoutTimer; - TQImage m_blendGradient; + bool blocklayout; + bool m_showAllWindows; + bool m_cycleWheel; + int m_currentScreen; // The screen to show, -1 for all screens + bool m_showOnlyCurrentScreen; + bool m_sortByDesktop; + int m_displayIconsNText; + bool m_showOnlyIconified; + int m_showTaskStates; + ArrowType arrowType; + TaskContainer::List containers; + TaskContainer::List m_hiddenContainers; + TaskContainer::List m_deletableContainers; + PixmapList frames; + int maximumButtonsWithoutShrinking() const; + bool shouldGroup() const; + bool isGrouping; + void reGroup(); + TDEGlobalAccel* keys; + KTextShadowEngine* m_textShadowEngine; + bool m_ignoreUpdates; + bool m_sortByAppPrev; + TQTimer m_relayoutTimer; + TQImage m_blendGradient; TaskBarSettings* m_settingsObject; TaskBarSettings* m_globalSettingsObject; }; diff --git a/kicker/taskbar/taskbar.kcfg b/kicker/taskbar/taskbar.kcfg index 320b8a2d6..95596ad34 100644 --- a/kicker/taskbar/taskbar.kcfg +++ b/kicker/taskbar/taskbar.kcfg @@ -31,6 +31,22 @@ <label>Show only minimized windows</label> <whatsthis>Select this option if you want the taskbar to display <b>only</b> minimized windows. By default, this option is not selected and the taskbar will show all windows.</whatsthis> </entry> + <entry key="DisplayIconsNText" type="Enum" > + <choices> + <choice name="DisplayIconsAndText"> + <label>Never</label> + </choice> + <choice name="DisplayTextOnly"> + <label>When Taskbar Full</label> + </choice> + <choice name="DisplayIconsOnly"> + <label>Always</label> + </choice> + </choices> + <default>DisplayIconsAndText</default> + <label>Display:</label> + <whatsthis>Choose taskbar display mode among <strong>Icons and text</strong>, <strong>Text only</strong> and <strong>Icons only</strong></whatsthis> + </entry> <entry key="GroupTasks" type="Enum" > <choices> <choice name="GroupNever"> @@ -73,11 +89,6 @@ <label>Sort windows by application</label> <whatsthis>Selecting this option causes the taskbar to show windows ordered by application. By default this option is selected.</whatsthis> </entry> - <entry key="ShowIcon" type="Bool" > - <default>true</default> - <label>Show application icons</label> - <whatsthis>Select this option if you want window icons to appear along with their titles in the taskbar. By default this option is selected.</whatsthis> - </entry> <entry key="MaximumButtonWidth" type="Int" > <default>200</default> <min>0</min> diff --git a/kicker/taskbar/taskcontainer.cpp b/kicker/taskbar/taskcontainer.cpp index fa3b560a8..860c231bb 100644 --- a/kicker/taskbar/taskcontainer.cpp +++ b/kicker/taskbar/taskcontainer.cpp @@ -21,7 +21,13 @@ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -******************************************************************/ +***************************************************************** + + Additional changes: + - 2013/10/22 Michele Calgaro + * added support for display mode (Icons and Text, Text only, Icons only) + and removed "Show application icons" +*/ #include <assert.h> @@ -216,7 +222,7 @@ TaskContainer::~TaskContainer() void TaskContainer::showMe() { - if(!frames.isEmpty() && taskBar->showIcon()) + if(!frames.isEmpty() && taskBar->showIcons()) animationTimer.start(100); emit showMe(this); @@ -307,28 +313,30 @@ void TaskContainer::setLastActivated() void TaskContainer::animationTimerFired() { - if (!frames.isEmpty() && taskBar->showIcon() && frames.at(currentFrame) != frames.end()) + if (!frames.isEmpty() && taskBar->showIcons() && frames.at(currentFrame) != frames.end()) { - TQPixmap *pm = *frames.at(currentFrame); + TQPixmap *pm = *frames.at(currentFrame); - // draw pixmap - if ( pm && !pm->isNull() ) { + // draw pixmap + if ( pm && !pm->isNull() ) + { // we only have to redraw the background for frames 0, 8 and 9 - if ( currentFrame == 0 || currentFrame > 7 ) { - // double buffered painting - TQPixmap composite( animBg ); - bitBlt( &composite, 0, 0, pm ); - bitBlt( this, iconRect.x(), iconRect.y(), &composite ); - } - else - bitBlt( this, iconRect.x(), iconRect.y(), pm ); - } - - // increment frame counter - if ( currentFrame >= 9) - currentFrame = 0; - else - currentFrame++; + if ( currentFrame == 0 || currentFrame > 7 ) + { + // double buffered painting + TQPixmap composite( animBg ); + bitBlt( &composite, 0, 0, pm ); + bitBlt( this, iconRect.x(), iconRect.y(), &composite ); + } + else + bitBlt( this, iconRect.x(), iconRect.y(), pm ); + } + + // increment frame counter + if ( currentFrame >= 9) + currentFrame = 0; + else + currentFrame++; } } @@ -686,151 +694,147 @@ void TaskContainer::drawButton(TQPainter *p) p->translate(shift.x(), shift.y()); } - if (taskBar->showIcon()) - { - if (pixmap.isNull() && m_startup) - { - pixmap = SmallIcon(m_startup->icon()); - } - - if ( !pixmap.isNull() ) + TQString text = name(); // find text + int textPos = ( taskBar->showIcons() && (!pixmap.isNull() || m_startup)) ? 2 + 16 + 2 : 0; + + // show icons + if (taskBar->showIcons()) + { + if (pixmap.isNull() && m_startup) + pixmap = SmallIcon(m_startup->icon()); + + if ( !pixmap.isNull() ) + { + // make sure it is no larger than 16x16 + if ( pixmap.width() > 16 || pixmap.height() > 16 ) + { + TQImage tmp = pixmap.convertToImage(); + pixmap.convertFromImage( tmp.smoothScale( 16, 16 ) ); + } + + // fade out the icon when minimized + if (iconified) + TDEIconEffect::semiTransparent( pixmap ); + + // draw icon + TQRect pmr(0, 0, pixmap.width(), pixmap.height()); + pmr.moveCenter(iconRect.center()); + p->drawPixmap(pmr, pixmap); + } + + // modified overlay icon + if (taskBar->showText()) + { + static TQString modStr = "[" + i18n( "modified" ) + "]"; + int modStrPos = text.find( modStr ); + if (modStrPos >= 0) { - // make sure it is no larger than 16x16 - if ( pixmap.width() > 16 || pixmap.height() > 16 ) - { - TQImage tmp = pixmap.convertToImage(); - pixmap.convertFromImage( tmp.smoothScale( 16, 16 ) ); - } - - // fade out the icon when minimized + // +1 because we include a space after the closing brace. + text.remove(modStrPos, modStr.length() + 1); + TQPixmap modPixmap = SmallIcon("modified"); + + // draw modified overlay + if (!modPixmap.isNull()) + { + TQRect r = TQStyle::visualRect(TQRect(br.x() + textPos,(height() - 16) / 2, 16, 16), this); if (iconified) { - TDEIconEffect::semiTransparent( pixmap ); + TDEIconEffect::semiTransparent(modPixmap); } - - // draw icon - TQRect pmr(0, 0, pixmap.width(), pixmap.height()); - pmr.moveCenter(iconRect.center()); - p->drawPixmap(pmr, pixmap); - } - } - - // find text - TQString text = name(); - - // modified overlay - static TQString modStr = "[" + i18n( "modified" ) + "]"; - int modStrPos = text.find( modStr ); - int textPos = ( taskBar->showIcon() && (!pixmap.isNull() || m_startup)) ? 2 + 16 + 2 : 0; - - if (modStrPos >= 0) - { - // +1 because we include a space after the closing brace. - text.remove(modStrPos, modStr.length() + 1); - TQPixmap modPixmap = SmallIcon("modified"); - - // draw modified overlay - if (!modPixmap.isNull()) - { - TQRect r = TQStyle::visualRect(TQRect(br.x() + textPos, - (height() - 16) / 2, 16, 16), - this); - - if (iconified) - { - TDEIconEffect::semiTransparent(modPixmap); - } - p->drawPixmap(r, modPixmap); textPos += 16 + 2; + } } + } } // draw text - if (!text.isEmpty()) - { - TQRect tr = TQStyle::visualRect(TQRect(br.x() + textPos + 1, 0, - width() - textPos, height()), - this); - int textFlags = AlignVCenter | SingleLine; - textFlags |= reverse ? AlignRight : AlignLeft; - TQPen textPen; - - // get the color for the text label - if (iconified) - { - textPen = TQPen(KickerLib::blendColors(colors.button(), colors.buttonText())); - } - else if (!active) - { - textPen = TQPen(colors.buttonText()); - } - else // hack for the dotNET style and others - { - if (READ_MERGED_TASBKAR_SETTING(useCustomColors)) - { - textPen = TQPen(READ_MERGED_TASBKAR_SETTING(activeTaskTextColor)); - } - else - { - textPen = TQPen(colors.buttonText()); // textPen = p->pen(); - } - } - - int availableWidth = width() - (br.x() * 2) - textPos - 2 - (READ_MERGED_TASBKAR_SETTING(drawButtons) && KickerSettings::showDeepButtons())?2:0; - if (m_filteredTasks.count() > 1) - { - availableWidth -= 8; - } - - if (TQFontMetrics(font).width(text) > availableWidth) - { - // draw text into overlay pixmap - TQPixmap tpm(*pm); - TQPainter tp(&tpm); - - if (sunken) - { - tp.translate(shift.x(), shift.y()); - } - - tp.setFont(font); - tp.setPen(textPen); - - if (halo) - { - taskBar->textShadowEngine()->drawText(tp, tr, textFlags, text, size()); - } - else - { - tp.drawText(tr, textFlags, text); - } - - // blend text into background image - TQImage img = pm->convertToImage(); - TQImage timg = tpm.convertToImage(); - KImageEffect::blend(img, timg, *taskBar->blendGradient(size()), KImageEffect::Red); - - // End painting before assigning the pixmap - TQPaintDevice* opd = p->device(); - p->end(); - pm->convertFromImage(img); - p->begin(opd ,this); - } - else - { - p->setFont(font); - p->setPen(textPen); - - if (halo) - { - taskBar->textShadowEngine()->drawText(*p, tr, textFlags, text, size()); - } - else - { - p->drawText(tr, textFlags, text); - } - } + if (taskBar->showText()) + { + if (!text.isEmpty()) + { + TQRect tr = TQStyle::visualRect(TQRect(br.x() + textPos + 1, 0, + width() - textPos, height()), this); + int textFlags = AlignVCenter | SingleLine; + textFlags |= reverse ? AlignRight : AlignLeft; + TQPen textPen; + + // get the color for the text label + if (iconified) + { + textPen = TQPen(KickerLib::blendColors(colors.button(), colors.buttonText())); + } + else if (!active) + { + textPen = TQPen(colors.buttonText()); + } + else // hack for the dotNET style and others + { + if (READ_MERGED_TASBKAR_SETTING(useCustomColors)) + { + textPen = TQPen(READ_MERGED_TASBKAR_SETTING(activeTaskTextColor)); + } + else + { + textPen = TQPen(colors.buttonText()); // textPen = p->pen(); + } + } + + int availableWidth = width() - (br.x() * 2) - textPos - 2 - (READ_MERGED_TASBKAR_SETTING(drawButtons) && KickerSettings::showDeepButtons())?2:0; + if (m_filteredTasks.count() > 1) + { + availableWidth -= 8; + } + + if (TQFontMetrics(font).width(text) > availableWidth) + { + // draw text into overlay pixmap + TQPixmap tpm(*pm); + TQPainter tp(&tpm); + + if (sunken) + { + tp.translate(shift.x(), shift.y()); + } + + tp.setFont(font); + tp.setPen(textPen); + + if (halo) + { + taskBar->textShadowEngine()->drawText(tp, tr, textFlags, text, size()); + } + else + { + tp.drawText(tr, textFlags, text); + } + + // blend text into background image + TQImage img = pm->convertToImage(); + TQImage timg = tpm.convertToImage(); + KImageEffect::blend(img, timg, *taskBar->blendGradient(size()), KImageEffect::Red); + + // End painting before assigning the pixmap + TQPaintDevice* opd = p->device(); + p->end(); + pm->convertFromImage(img); + p->begin(opd ,this); + } + else + { + p->setFont(font); + p->setPen(textPen); + + if (halo) + { + taskBar->textShadowEngine()->drawText(*p, tr, textFlags, text, size()); + } + else + { + p->drawText(tr, textFlags, text); + } + } + } } if (!frames.isEmpty() && m_startup && frames.at(currentFrame) != frames.end()) |