From de7e5867a65e0a46f1388e3e50bc7eeddd1aecbf Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 27 Jan 2013 01:02:02 -0600 Subject: Rename a number of libraries and executables to avoid conflicts with KDE4 --- kdesktop/CMakeLists.txt | 2 +- kdesktop/ConfigureChecks.cmake | 7 - kdesktop/DESIGN | 4 +- kdesktop/Makefile.am | 2 +- kdesktop/bgmanager.cc | 2 +- kdesktop/desktop.cc | 4 +- kdesktop/init.cc | 4 +- kdesktop/kcustommenu.cc | 2 +- kdesktop/kdesktop.kcfg | 2 +- kdesktop/kdesktopshadowsettings.h | 2 +- kdesktop/kdiconview.cc | 4 +- kdesktop/kdiconview.h | 2 +- kdesktop/kfileividesktop.cpp | 241 ----------------------------------- kdesktop/kfileividesktop.h | 122 ------------------ kdesktop/krootwm.cc | 2 +- kdesktop/kwebdesktop/kwebdesktop.cpp | 4 +- kdesktop/kxdglauncher.cpp | 2 +- kdesktop/lock/CMakeLists.txt | 9 +- kdesktop/lock/autologout.cc | 2 +- kdesktop/lock/infodlg.cc | 2 +- kdesktop/lock/lockdlg.cc | 2 +- kdesktop/lock/lockprocess.cc | 2 - kdesktop/lock/querydlg.cc | 2 +- kdesktop/lock/sakdlg.cc | 2 +- kdesktop/lock/securedlg.cc | 2 +- kdesktop/main.cc | 2 +- kdesktop/minicli.cpp | 2 +- kdesktop/startupid.cpp | 2 +- kdesktop/tdefileividesktop.cpp | 241 +++++++++++++++++++++++++++++++++++ kdesktop/tdefileividesktop.h | 122 ++++++++++++++++++ 30 files changed, 393 insertions(+), 407 deletions(-) delete mode 100644 kdesktop/kfileividesktop.cpp delete mode 100644 kdesktop/kfileividesktop.h create mode 100644 kdesktop/tdefileividesktop.cpp create mode 100644 kdesktop/tdefileividesktop.h (limited to 'kdesktop') diff --git a/kdesktop/CMakeLists.txt b/kdesktop/CMakeLists.txt index b9751944b..968cdcc31 100644 --- a/kdesktop/CMakeLists.txt +++ b/kdesktop/CMakeLists.txt @@ -85,7 +85,7 @@ set( ${target}_SRCS pixmapserver.cc kcustommenu.cc startupid.cpp minicli_ui.ui xautolock_diy.c xautolock_engine.c kshadowengine.cpp kshadowsettings.cpp kdesktopshadowsettings.cpp - kfileividesktop.cpp kdesktopapp.cpp + tdefileividesktop.cpp kdesktopapp.cpp ) tde_add_tdeinit_executable( ${target} AUTOMOC diff --git a/kdesktop/ConfigureChecks.cmake b/kdesktop/ConfigureChecks.cmake index 9e59185a4..87e2213ce 100644 --- a/kdesktop/ConfigureChecks.cmake +++ b/kdesktop/ConfigureChecks.cmake @@ -14,10 +14,3 @@ if( WITH_PAM AND (NOT DEFINED KSCREENSAVER_PAM_SERVICE) ) set( KSCREENSAVER_PAM_SERVICE "kde" CACHE INTERNAL "" ) endif( ) - -if( WITH_KDESKTOP_LOCK_BACKTRACE ) - check_include_files( "bfd.h;demangle.h;libiberty.h" HAVE_BINUTILS_DEV ) - if( NOT HAVE_BINUTILS_DEV ) - tde_message_fatal( "binutils-dev are required, but not found on your system" ) - endif( ) -endif( ) diff --git a/kdesktop/DESIGN b/kdesktop/DESIGN index f13a7b2f5..f69ee2198 100644 --- a/kdesktop/DESIGN +++ b/kdesktop/DESIGN @@ -37,8 +37,8 @@ lock* : screen saver/locker Libs used by KDesktop ====================== -tdecore, tdeui, kfile - usual stuff :) -libkio - I/O stuff, mimetypes, services, registry +tdecore, tdeui, tdefile - usual stuff :) +libtdeio - I/O stuff, mimetypes, services, registry libkonq - properties dialog, templates ("new") menu, dir lister, settings Screensaver diff --git a/kdesktop/Makefile.am b/kdesktop/Makefile.am index 1b4927db6..f363ac17e 100644 --- a/kdesktop/Makefile.am +++ b/kdesktop/Makefile.am @@ -23,7 +23,7 @@ kdesktop_la_SOURCES = main.cc krootwm.cc xautolock.cc kdiconview.cc desktop.cc \ minicli.cpp KBackgroundIface.skel pixmapserver.cc kcustommenu.cc \ startupid.cpp minicli_ui.ui xautolock_diy.c xautolock_engine.c \ kshadowengine.cpp kshadowsettings.cpp \ - kdesktopshadowsettings.cpp kfileividesktop.cpp \ + kdesktopshadowsettings.cpp tdefileividesktop.cpp \ kdesktopapp.cpp include_HEADERS = KDesktopIface.h KScreensaverIface.h KBackgroundIface.h diff --git a/kdesktop/bgmanager.cc b/kdesktop/bgmanager.cc index e15c6aabe..cc7838b42 100644 --- a/kdesktop/bgmanager.cc +++ b/kdesktop/bgmanager.cc @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/kdesktop/desktop.cc b/kdesktop/desktop.cc index 073a69a5a..07fbaf5cd 100644 --- a/kdesktop/desktop.cc +++ b/kdesktop/desktop.cc @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/kdesktop/init.cc b/kdesktop/init.cc index cf45c71d4..e9c805bfe 100644 --- a/kdesktop/init.cc +++ b/kdesktop/init.cc @@ -17,8 +17,8 @@ Boston, MA 02110-1301, USA. */ -#include -#include +#include +#include #include #include #include diff --git a/kdesktop/kcustommenu.cc b/kdesktop/kcustommenu.cc index b32c77096..a0bf92556 100644 --- a/kdesktop/kcustommenu.cc +++ b/kdesktop/kcustommenu.cc @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include diff --git a/kdesktop/kdesktop.kcfg b/kdesktop/kdesktop.kcfg index 6fee5d5c4..bbb495989 100644 --- a/kdesktop/kdesktop.kcfg +++ b/kdesktop/kdesktop.kcfg @@ -65,7 +65,7 @@ - + diff --git a/kdesktop/kdesktopshadowsettings.h b/kdesktop/kdesktopshadowsettings.h index 7e421c6d6..c7e73db71 100644 --- a/kdesktop/kdesktopshadowsettings.h +++ b/kdesktop/kdesktopshadowsettings.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include diff --git a/kdesktop/kdiconview.cc b/kdesktop/kdiconview.cc index ad049256d..57287014a 100644 --- a/kdesktop/kdiconview.cc +++ b/kdesktop/kdiconview.cc @@ -22,7 +22,7 @@ #include "desktop.h" #include "kdesktopsettings.h" -#include +#include #include #include #include @@ -57,7 +57,7 @@ #include "kshadowengine.h" #include "kdesktopshadowsettings.h" -#include "kfileividesktop.h" +#include "tdefileividesktop.h" // for multihead extern int kdesktop_screen_number; diff --git a/kdesktop/kdiconview.h b/kdesktop/kdiconview.h index f951765ba..c9feecaf7 100644 --- a/kdesktop/kdiconview.h +++ b/kdesktop/kdiconview.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include diff --git a/kdesktop/kfileividesktop.cpp b/kdesktop/kfileividesktop.cpp deleted file mode 100644 index 90dc69327..000000000 --- a/kdesktop/kfileividesktop.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* This file is proposed to be part of the KDE base. - * Copyright (C) 2003 Laur Ivan - * - * Many thanks to: - * - Bernardo Hung for the enhanced shadow - * algorithm (currently used) - * - Tim Jansen for the API updates and fixes. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "kdesktopshadowsettings.h" -#include "kfileividesktop.h" - -//#define DEBUG - -/* Changelog: - */ - -KFileIVIDesktop::KFileIVIDesktop(KonqIconViewWidget *iconview, KFileItem* fileitem, - int size, KShadowEngine *shadow) : - KFileIVI(iconview, fileitem, size), - m_selectedImage(0L), - m_normalImage(0L), - _selectedUID(0), - _normalUID(0) -{ - m_shadow = shadow; - oldText = ""; - - calcRect( text() ); // recalculate rect including shadow -} - -KFileIVIDesktop::~KFileIVIDesktop() -{ - delete m_selectedImage; - delete m_normalImage; -} - -void KFileIVIDesktop::calcRect( const TQString& _text ) -{ - KIconViewItem::calcRect( _text ); - - if ( !iconView() || !m_shadow || - !wordWrap() || !( static_cast - ( m_shadow->shadowSettings() ) )->isEnabled() ) - return; - - int spread = shadowThickness(); - TQRect itemTextRect = textRect(); - TQRect itemRect = rect(); - - itemTextRect.setBottom( itemTextRect.bottom() + spread ); - itemTextRect.setRight( itemTextRect.right() + spread ); - itemRect.setBottom( itemRect.bottom() + spread ); - itemRect.setRight( itemRect.right() + spread ); - - setTextRect( itemTextRect ); - setItemRect( itemRect ); -} - -void KFileIVIDesktop::paintItem( TQPainter *p, const TQColorGroup &cg) -{ - TQColorGroup colors = updateColors(cg); - - TQIconView* view = iconView(); - Q_ASSERT( view ); - - if ( !view ) - return; - - if ( !wordWrap() ) - return; - - p->save(); - - // draw the pixmap as in KIconViewItem::paintItem(...) - paintPixmap(p, colors); - - // - // Paint the text as shadowed if the shadow is available - // - if (m_shadow != 0L && (static_cast (m_shadow->shadowSettings()))->isEnabled()) - drawShadowedText(p, colors); - else { - paintFontUpdate(p); - paintText(p, colors); - } - - p->restore(); - - paintOverlay(p); -} - -bool KFileIVIDesktop::shouldUpdateShadow(bool selected) -{ - unsigned long uid = (static_cast (m_shadow->shadowSettings()))->UID(); - TQString wrapped = wordWrap()->wrappedString(); - - if (wrapped != oldText){ - oldText = wrapped; - _selectedUID = _normalUID = 0; - } - - if (selected == true) - return (uid != _selectedUID); - else - return (uid != _normalUID); - - return false; -} - - - -void KFileIVIDesktop::drawShadowedText( TQPainter *p, const TQColorGroup &cg ) -{ - bool drawRoundedRect = TDEGlobalSettings::iconUseRoundedRect(); - - int textX; - if (drawRoundedRect == true) - textX = textRect( FALSE ).x() + 4; - else - textX = textRect( FALSE ).x() + 2; - int textY = textRect( FALSE ).y(); - int align = ((KIconView *) iconView())->itemTextPos() == TQIconView::Bottom - ? AlignHCenter : AlignAuto; - bool rebuild = shouldUpdateShadow(isSelected()); - - KDesktopShadowSettings *settings = (KDesktopShadowSettings *) (m_shadow->shadowSettings()); - - unsigned long uid = settings->UID(); - - p->setFont(iconView()->font()); - paintFontUpdate(p); - TQColor shadow; - TQColor text; - int spread = shadowThickness(); - - if ( isSelected() && settings->selectionType() != KShadowSettings::InverseVideoOnSelection ) { - text = cg.highlightedText(); - TQRect rect = textRect( false ); - rect.setRight( rect.right() - spread ); - rect.setBottom( rect.bottom() - spread + 1 ); - if (drawRoundedRect == true) { - p->setBrush( TQBrush( cg.highlight() ) ); - p->setPen( TQPen( cg.highlight() ) ); - p->drawRoundRect( rect, - 1000 / rect.width(), - 1000 / rect.height() ); - } - else { - p->fillRect( textRect( false ), cg.highlight() ); - } - } - else { - // use shadow - if ( isSelected() ) { - // inverse text and shadow colors - shadow = settings->textColor(); - text = settings->bgColor(); - if ( rebuild ) { - setSelectedImage( buildShadow( p, align, shadow ) ); - _selectedUID = uid; - } - } - else { - text = settings->textColor(); - shadow = ( settings->bgColor().isValid() ) ? settings->bgColor() : - ( tqGray( text.rgb() ) > 127 ) ? black : white; - if (rebuild) { - setNormalImage(buildShadow(p, align, shadow)); - _normalUID = uid; - } - } - - // draw the shadow - int shadowX = textX - spread + settings->offsetX(); - int shadowY = textY - spread + settings->offsetY(); - - p->drawImage(shadowX, shadowY, - (isSelected()) ? *selectedImage() : *normalImage(), - 0, 0, -1, -1, DITHER_FLAGS); - } - - // draw the text - p->setPen(text); - wordWrap()->drawText( p, textX, textY, align | KWordWrap::Truncate ); -} - - -TQImage *KFileIVIDesktop::buildShadow( TQPainter *p, const int align, - TQColor &shadowColor ) -{ - TQPainter pixPainter; - int spread = shadowThickness(); - - TQPixmap textPixmap(textRect( FALSE ).width() + spread * 2 + 2, - textRect( FALSE ).height() + spread * 2 + 2); - - textPixmap.fill(TQColor(0,0,0)); - textPixmap.setMask( textPixmap.createHeuristicMask(TRUE) ); - - pixPainter.begin(&textPixmap); - pixPainter.setPen(white); // get the pen from the root painter - pixPainter.setFont(p->font()); // get the font from the root painter - wordWrap()->drawText( &pixPainter, spread, spread, align | KWordWrap::Truncate ); - pixPainter.end(); - - return new TQImage(m_shadow->makeShadow(textPixmap, shadowColor)); -} - -int KFileIVIDesktop::shadowThickness() const -{ - return ( ( m_shadow->shadowSettings()->thickness() + 1 ) >> 1 ) + 1; -} - diff --git a/kdesktop/kfileividesktop.h b/kdesktop/kfileividesktop.h deleted file mode 100644 index 129abec07..000000000 --- a/kdesktop/kfileividesktop.h +++ /dev/null @@ -1,122 +0,0 @@ -/* This file is proposed to be part of the KDE base. - * Copyright (C) 2003 Laur Ivan - * - * Many thanks to: - * - Bernardo Hung for the enhanced shadow - * algorithm (currently used) - * - Tim Jansen for the API updates and fixes. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef KFILE_IVI_DESKTOP -#define KFILE_IVI_DESKTOP - -#include -#include -#include -#include -#include - -/* - * The dither flags used to display the shadow image - */ -#define DITHER_FLAGS (Qt::DiffuseAlphaDither | Qt::ColorOnly | Qt::AvoidDither) - - -class TQFont; -class KShadowEngine; - -/** - * This class replaces KFileIVI in the desktop only. - * If the shadow object is NULL, then the class should behave almost identical - * to its parent. - * @since 3.2 - */ -class KFileIVIDesktop : public KFileIVI -{ - public: - /** - * Constructor. It replicates the KFileIVI constructor and adds an - * optional shadow object. - * @param iconview the parent (iconview) - * @param fileitem the item theis object is supposed to draw - * @param size the default size of the drawn object - * @param shadow reference to the shadow object - */ - KFileIVIDesktop(KonqIconViewWidget *iconview, KFileItem* fileitem, int - size, KShadowEngine *shadow = 0L); - - /** - * Default destructor. Doesn't really do anything. - */ - ~KFileIVIDesktop(); - - protected: - /** - * Reimplements KIconView::calcRect to take the shadow metrics - * into account - */ - virtual void calcRect( const TQString& _text ); - - /** - * Paints this item. Takes care of using the normal or alpha - * blending methods depending on the configuration. - * @param p the painter for drawing the item - * @param cg the base color group - */ - virtual void paintItem(TQPainter *p, const TQColorGroup &cg); - - /** - - * Draws the shadow text. - * @param p the painter for drawing the item - * @param cg the base color group - */ - virtual void drawShadowedText(TQPainter *p, const TQColorGroup &cg); - - /** - * Builds the shadow. As the algorithm is pretty slow (at pixel level), - * This method is triggered only if the configuration has changed. - * @param p the painter for drawing the item - * @param align the shadow alignment - * @param shadowColor the shadow color - */ - virtual TQImage *buildShadow(TQPainter *p, const int align, TQColor &shadowColor); - - protected: - void setNormalImage(TQImage *newImage) { delete m_normalImage; m_normalImage = newImage; }; - void setSelectedImage(TQImage *newImage) { delete m_selectedImage; m_selectedImage = newImage; }; - - TQImage *normalImage() { return m_normalImage; }; - TQImage *selectedImage() { return m_selectedImage; }; - - private: - bool shouldUpdateShadow(bool selected); - int shadowThickness() const; - - KShadowEngine *m_shadow; - - TQImage *m_selectedImage; - TQImage *m_normalImage; - - TQString oldText; - - unsigned long _selectedUID; - unsigned long _normalUID; - -}; - -#endif diff --git a/kdesktop/krootwm.cc b/kdesktop/krootwm.cc index 08db2eb95..a263b529c 100644 --- a/kdesktop/krootwm.cc +++ b/kdesktop/krootwm.cc @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/kdesktop/kwebdesktop/kwebdesktop.cpp b/kdesktop/kwebdesktop/kwebdesktop.cpp index ff60d0fd6..661d644a6 100644 --- a/kdesktop/kwebdesktop/kwebdesktop.cpp +++ b/kdesktop/kwebdesktop/kwebdesktop.cpp @@ -22,13 +22,13 @@ #include #include -#include +#include #include #include #include #include #include -#include +#include #include #include "kwebdesktop.h" diff --git a/kdesktop/kxdglauncher.cpp b/kdesktop/kxdglauncher.cpp index 05c5f4ef2..4433ef367 100644 --- a/kdesktop/kxdglauncher.cpp +++ b/kdesktop/kxdglauncher.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include diff --git a/kdesktop/lock/CMakeLists.txt b/kdesktop/lock/CMakeLists.txt index e847cf1fc..80c2b2cdb 100644 --- a/kdesktop/lock/CMakeLists.txt +++ b/kdesktop/lock/CMakeLists.txt @@ -32,16 +32,11 @@ set( target kdesktop_lock ) set( ${target}_SRCS lockprocess.cc lockdlg.cc infodlg.cc querydlg.cc sakdlg.cc - securedlg.cc autologout.cc main.cc + securedlg.cc autologout.cc main.cc backtrace_symbols.c ) -if( WITH_KDESKTOP_LOCK_BACKTRACE ) - list( APPEND ${target}_SRCS backtrace_symbols.c ) - set( BACKTRACE_LIBRARY bfd ) -endif( ) - tde_add_executable( ${target} AUTOMOC SOURCES ${${target}_SRCS} - LINK kdesktopsettings-static dmctl-static kio-shared Xext ${BACKTRACE_LIBRARY} ${GL_LIBRARY} "${LINKER_IMMEDIATE_BINDING_FLAGS}" + LINK kdesktopsettings-static dmctl-static tdeio-shared Xext bfd ${GL_LIBRARY} "${LINKER_IMMEDIATE_BINDING_FLAGS}" DESTINATION ${BIN_INSTALL_DIR} ) diff --git a/kdesktop/lock/autologout.cc b/kdesktop/lock/autologout.cc index 024425d2c..ef683cbcc 100644 --- a/kdesktop/lock/autologout.cc +++ b/kdesktop/lock/autologout.cc @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/kdesktop/lock/infodlg.cc b/kdesktop/lock/infodlg.cc index 725122134..56ee83e38 100644 --- a/kdesktop/lock/infodlg.cc +++ b/kdesktop/lock/infodlg.cc @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/kdesktop/lock/lockdlg.cc b/kdesktop/lock/lockdlg.cc index 29dc8bd9c..2684403a5 100644 --- a/kdesktop/lock/lockdlg.cc +++ b/kdesktop/lock/lockdlg.cc @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/kdesktop/lock/lockprocess.cc b/kdesktop/lock/lockprocess.cc index 5f01274a8..a3f5fb56f 100644 --- a/kdesktop/lock/lockprocess.cc +++ b/kdesktop/lock/lockprocess.cc @@ -137,7 +137,6 @@ static Atom gXA_SCREENSAVER_VERSION; void print_trace() { -#ifdef WITH_KDESKTOP_LOCK_BACKTRACE void *array[10]; size_t size; char **strings; @@ -153,7 +152,6 @@ void print_trace() } free (strings); -#endif } static void segv_handler(int) diff --git a/kdesktop/lock/querydlg.cc b/kdesktop/lock/querydlg.cc index 401370b21..acac92127 100644 --- a/kdesktop/lock/querydlg.cc +++ b/kdesktop/lock/querydlg.cc @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/kdesktop/lock/sakdlg.cc b/kdesktop/lock/sakdlg.cc index 6f983ce70..4904e71e1 100644 --- a/kdesktop/lock/sakdlg.cc +++ b/kdesktop/lock/sakdlg.cc @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/kdesktop/lock/securedlg.cc b/kdesktop/lock/securedlg.cc index 08a70a17d..79147ae0a 100644 --- a/kdesktop/lock/securedlg.cc +++ b/kdesktop/lock/securedlg.cc @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/kdesktop/main.cc b/kdesktop/main.cc index 17fc4addf..9f549e54a 100644 --- a/kdesktop/main.cc +++ b/kdesktop/main.cc @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include "desktop.h" diff --git a/kdesktop/minicli.cpp b/kdesktop/minicli.cpp index dca215de3..6f940a5b2 100644 --- a/kdesktop/minicli.cpp +++ b/kdesktop/minicli.cpp @@ -60,7 +60,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/kdesktop/startupid.cpp b/kdesktop/startupid.cpp index 36d566e31..6603e7b7b 100644 --- a/kdesktop/startupid.cpp +++ b/kdesktop/startupid.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #define KDE_STARTUP_ICON "kmenu" diff --git a/kdesktop/tdefileividesktop.cpp b/kdesktop/tdefileividesktop.cpp new file mode 100644 index 000000000..420aeac4f --- /dev/null +++ b/kdesktop/tdefileividesktop.cpp @@ -0,0 +1,241 @@ +/* This file is proposed to be part of the KDE base. + * Copyright (C) 2003 Laur Ivan + * + * Many thanks to: + * - Bernardo Hung for the enhanced shadow + * algorithm (currently used) + * - Tim Jansen for the API updates and fixes. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "kdesktopshadowsettings.h" +#include "tdefileividesktop.h" + +//#define DEBUG + +/* Changelog: + */ + +KFileIVIDesktop::KFileIVIDesktop(KonqIconViewWidget *iconview, KFileItem* fileitem, + int size, KShadowEngine *shadow) : + KFileIVI(iconview, fileitem, size), + m_selectedImage(0L), + m_normalImage(0L), + _selectedUID(0), + _normalUID(0) +{ + m_shadow = shadow; + oldText = ""; + + calcRect( text() ); // recalculate rect including shadow +} + +KFileIVIDesktop::~KFileIVIDesktop() +{ + delete m_selectedImage; + delete m_normalImage; +} + +void KFileIVIDesktop::calcRect( const TQString& _text ) +{ + KIconViewItem::calcRect( _text ); + + if ( !iconView() || !m_shadow || + !wordWrap() || !( static_cast + ( m_shadow->shadowSettings() ) )->isEnabled() ) + return; + + int spread = shadowThickness(); + TQRect itemTextRect = textRect(); + TQRect itemRect = rect(); + + itemTextRect.setBottom( itemTextRect.bottom() + spread ); + itemTextRect.setRight( itemTextRect.right() + spread ); + itemRect.setBottom( itemRect.bottom() + spread ); + itemRect.setRight( itemRect.right() + spread ); + + setTextRect( itemTextRect ); + setItemRect( itemRect ); +} + +void KFileIVIDesktop::paintItem( TQPainter *p, const TQColorGroup &cg) +{ + TQColorGroup colors = updateColors(cg); + + TQIconView* view = iconView(); + Q_ASSERT( view ); + + if ( !view ) + return; + + if ( !wordWrap() ) + return; + + p->save(); + + // draw the pixmap as in KIconViewItem::paintItem(...) + paintPixmap(p, colors); + + // + // Paint the text as shadowed if the shadow is available + // + if (m_shadow != 0L && (static_cast (m_shadow->shadowSettings()))->isEnabled()) + drawShadowedText(p, colors); + else { + paintFontUpdate(p); + paintText(p, colors); + } + + p->restore(); + + paintOverlay(p); +} + +bool KFileIVIDesktop::shouldUpdateShadow(bool selected) +{ + unsigned long uid = (static_cast (m_shadow->shadowSettings()))->UID(); + TQString wrapped = wordWrap()->wrappedString(); + + if (wrapped != oldText){ + oldText = wrapped; + _selectedUID = _normalUID = 0; + } + + if (selected == true) + return (uid != _selectedUID); + else + return (uid != _normalUID); + + return false; +} + + + +void KFileIVIDesktop::drawShadowedText( TQPainter *p, const TQColorGroup &cg ) +{ + bool drawRoundedRect = TDEGlobalSettings::iconUseRoundedRect(); + + int textX; + if (drawRoundedRect == true) + textX = textRect( FALSE ).x() + 4; + else + textX = textRect( FALSE ).x() + 2; + int textY = textRect( FALSE ).y(); + int align = ((KIconView *) iconView())->itemTextPos() == TQIconView::Bottom + ? AlignHCenter : AlignAuto; + bool rebuild = shouldUpdateShadow(isSelected()); + + KDesktopShadowSettings *settings = (KDesktopShadowSettings *) (m_shadow->shadowSettings()); + + unsigned long uid = settings->UID(); + + p->setFont(iconView()->font()); + paintFontUpdate(p); + TQColor shadow; + TQColor text; + int spread = shadowThickness(); + + if ( isSelected() && settings->selectionType() != KShadowSettings::InverseVideoOnSelection ) { + text = cg.highlightedText(); + TQRect rect = textRect( false ); + rect.setRight( rect.right() - spread ); + rect.setBottom( rect.bottom() - spread + 1 ); + if (drawRoundedRect == true) { + p->setBrush( TQBrush( cg.highlight() ) ); + p->setPen( TQPen( cg.highlight() ) ); + p->drawRoundRect( rect, + 1000 / rect.width(), + 1000 / rect.height() ); + } + else { + p->fillRect( textRect( false ), cg.highlight() ); + } + } + else { + // use shadow + if ( isSelected() ) { + // inverse text and shadow colors + shadow = settings->textColor(); + text = settings->bgColor(); + if ( rebuild ) { + setSelectedImage( buildShadow( p, align, shadow ) ); + _selectedUID = uid; + } + } + else { + text = settings->textColor(); + shadow = ( settings->bgColor().isValid() ) ? settings->bgColor() : + ( tqGray( text.rgb() ) > 127 ) ? black : white; + if (rebuild) { + setNormalImage(buildShadow(p, align, shadow)); + _normalUID = uid; + } + } + + // draw the shadow + int shadowX = textX - spread + settings->offsetX(); + int shadowY = textY - spread + settings->offsetY(); + + p->drawImage(shadowX, shadowY, + (isSelected()) ? *selectedImage() : *normalImage(), + 0, 0, -1, -1, DITHER_FLAGS); + } + + // draw the text + p->setPen(text); + wordWrap()->drawText( p, textX, textY, align | KWordWrap::Truncate ); +} + + +TQImage *KFileIVIDesktop::buildShadow( TQPainter *p, const int align, + TQColor &shadowColor ) +{ + TQPainter pixPainter; + int spread = shadowThickness(); + + TQPixmap textPixmap(textRect( FALSE ).width() + spread * 2 + 2, + textRect( FALSE ).height() + spread * 2 + 2); + + textPixmap.fill(TQColor(0,0,0)); + textPixmap.setMask( textPixmap.createHeuristicMask(TRUE) ); + + pixPainter.begin(&textPixmap); + pixPainter.setPen(white); // get the pen from the root painter + pixPainter.setFont(p->font()); // get the font from the root painter + wordWrap()->drawText( &pixPainter, spread, spread, align | KWordWrap::Truncate ); + pixPainter.end(); + + return new TQImage(m_shadow->makeShadow(textPixmap, shadowColor)); +} + +int KFileIVIDesktop::shadowThickness() const +{ + return ( ( m_shadow->shadowSettings()->thickness() + 1 ) >> 1 ) + 1; +} + diff --git a/kdesktop/tdefileividesktop.h b/kdesktop/tdefileividesktop.h new file mode 100644 index 000000000..8dd0f1fc4 --- /dev/null +++ b/kdesktop/tdefileividesktop.h @@ -0,0 +1,122 @@ +/* This file is proposed to be part of the KDE base. + * Copyright (C) 2003 Laur Ivan + * + * Many thanks to: + * - Bernardo Hung for the enhanced shadow + * algorithm (currently used) + * - Tim Jansen for the API updates and fixes. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef KFILE_IVI_DESKTOP +#define KFILE_IVI_DESKTOP + +#include +#include +#include +#include +#include + +/* + * The dither flags used to display the shadow image + */ +#define DITHER_FLAGS (Qt::DiffuseAlphaDither | Qt::ColorOnly | Qt::AvoidDither) + + +class TQFont; +class KShadowEngine; + +/** + * This class replaces KFileIVI in the desktop only. + * If the shadow object is NULL, then the class should behave almost identical + * to its parent. + * @since 3.2 + */ +class KFileIVIDesktop : public KFileIVI +{ + public: + /** + * Constructor. It replicates the KFileIVI constructor and adds an + * optional shadow object. + * @param iconview the parent (iconview) + * @param fileitem the item theis object is supposed to draw + * @param size the default size of the drawn object + * @param shadow reference to the shadow object + */ + KFileIVIDesktop(KonqIconViewWidget *iconview, KFileItem* fileitem, int + size, KShadowEngine *shadow = 0L); + + /** + * Default destructor. Doesn't really do anything. + */ + ~KFileIVIDesktop(); + + protected: + /** + * Reimplements KIconView::calcRect to take the shadow metrics + * into account + */ + virtual void calcRect( const TQString& _text ); + + /** + * Paints this item. Takes care of using the normal or alpha + * blending methods depending on the configuration. + * @param p the painter for drawing the item + * @param cg the base color group + */ + virtual void paintItem(TQPainter *p, const TQColorGroup &cg); + + /** + + * Draws the shadow text. + * @param p the painter for drawing the item + * @param cg the base color group + */ + virtual void drawShadowedText(TQPainter *p, const TQColorGroup &cg); + + /** + * Builds the shadow. As the algorithm is pretty slow (at pixel level), + * This method is triggered only if the configuration has changed. + * @param p the painter for drawing the item + * @param align the shadow alignment + * @param shadowColor the shadow color + */ + virtual TQImage *buildShadow(TQPainter *p, const int align, TQColor &shadowColor); + + protected: + void setNormalImage(TQImage *newImage) { delete m_normalImage; m_normalImage = newImage; }; + void setSelectedImage(TQImage *newImage) { delete m_selectedImage; m_selectedImage = newImage; }; + + TQImage *normalImage() { return m_normalImage; }; + TQImage *selectedImage() { return m_selectedImage; }; + + private: + bool shouldUpdateShadow(bool selected); + int shadowThickness() const; + + KShadowEngine *m_shadow; + + TQImage *m_selectedImage; + TQImage *m_normalImage; + + TQString oldText; + + unsigned long _selectedUID; + unsigned long _normalUID; + +}; + +#endif -- cgit v1.2.1