diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-05-17 08:20:48 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-05-17 08:20:48 +0000 |
commit | aa0726b20f398264f0a2abc60215be044b106f9c (patch) | |
tree | 070fdbc19a1106cfdd7f651a8ce76bb1b89a513d /src/linklabel.cpp | |
parent | d3cf5b3e75aadc3b02d0b56f030d4c3f8c2c749d (diff) | |
download | basket-aa0726b20f398264f0a2abc60215be044b106f9c.tar.gz basket-aa0726b20f398264f0a2abc60215be044b106f9c.zip |
TQt4 port basket
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/basket@1232416 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/linklabel.cpp')
-rw-r--r-- | src/linklabel.cpp | 314 |
1 files changed, 157 insertions, 157 deletions
diff --git a/src/linklabel.cpp b/src/linklabel.cpp index be6e2e2..61cba80 100644 --- a/src/linklabel.cpp +++ b/src/linklabel.cpp @@ -18,19 +18,19 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#include <qlabel.h> +#include <tqlabel.h> #include <kurl.h> -#include <qlayout.h> +#include <tqlayout.h> #include <kiconloader.h> -#include <qcursor.h> +#include <tqcursor.h> #include <klocale.h> -#include <qpushbutton.h> -#include <qcheckbox.h> -#include <qcombobox.h> -#include <qhgroupbox.h> -#include <qpainter.h> +#include <tqpushbutton.h> +#include <tqcheckbox.h> +#include <tqcombobox.h> +#include <tqhgroupbox.h> +#include <tqpainter.h> #include <kglobalsettings.h> -#include <qstyle.h> +#include <tqstyle.h> #include <kapplication.h> #include <kaboutdata.h> #include <kdialogbase.h> @@ -69,7 +69,7 @@ LinkLook::LinkLook(const LinkLook &other) } void LinkLook::setLook(bool italic, bool bold, int underlining, - QColor color, QColor hoverColor, + TQColor color, TQColor hoverColor, int iconSize, int preview) { m_italic = italic; @@ -95,7 +95,7 @@ int LinkLook::previewSize() const return 0; } -QColor LinkLook::effectiveColor() const +TQColor LinkLook::effectiveColor() const { if (m_color.isValid()) return m_color; @@ -103,7 +103,7 @@ QColor LinkLook::effectiveColor() const return defaultColor(); } -QColor LinkLook::effectiveHoverColor() const +TQColor LinkLook::effectiveHoverColor() const { if (m_hoverColor.isValid()) return m_hoverColor; @@ -111,7 +111,7 @@ QColor LinkLook::effectiveHoverColor() const return defaultHoverColor(); } -QColor LinkLook::defaultColor() const +TQColor LinkLook::defaultColor() const { if (m_useLinkColor) return KGlobalSettings::linkColor(); @@ -119,9 +119,9 @@ QColor LinkLook::defaultColor() const return KGlobalSettings::textColor(); } -QColor LinkLook::defaultHoverColor() const +TQColor LinkLook::defaultHoverColor() const { - return Qt::red; + return TQt::red; } LinkLook* LinkLook::lookForURL(const KURL &url) @@ -129,10 +129,10 @@ LinkLook* LinkLook::lookForURL(const KURL &url) return url.isLocalFile() ? localLinkLook : networkLinkLook; } -QString LinkLook::toCSS(const QString &cssClass, const QColor &defaultTextColor) const +TQString LinkLook::toCSS(const TQString &cssClass, const TQColor &defaultTextColor) const { // Set the link class: - QString css = QString(" .%1 a { display: block; width: 100%;").arg(cssClass); + TQString css = TQString(" .%1 a { display: block; width: 100%;").tqarg(cssClass); if (underlineOutside()) css += " text-decoration: underline;"; else @@ -141,11 +141,11 @@ QString LinkLook::toCSS(const QString &cssClass, const QColor &defaultTextColor) css += " font-style: italic;"; if (m_bold == true) css += " font-weight: bold;"; - QColor textColor = (color().isValid() || m_useLinkColor ? effectiveColor() : defaultTextColor); - css += QString(" color: %1; }\n").arg(textColor.name()); + TQColor textColor = (color().isValid() || m_useLinkColor ? effectiveColor() : defaultTextColor); + css += TQString(" color: %1; }\n").tqarg(textColor.name()); // Set the hover state class: - QString hover; + TQString hover; if (m_underlining == OnMouseHover) hover = "text-decoration: underline;"; else if (m_underlining == OnMouseOutside) @@ -153,27 +153,27 @@ QString LinkLook::toCSS(const QString &cssClass, const QColor &defaultTextColor) if (effectiveHoverColor() != effectiveColor()) { if (!hover.isEmpty()) hover += " "; - hover += QString("color: %4;").arg(effectiveHoverColor().name()); + hover += TQString("color: %4;").tqarg(effectiveHoverColor().name()); } // But include it only if it contain a different style than non-hover state: if (!hover.isEmpty()) - css += QString(" .%1 a:hover { %2 }\n").arg(cssClass, hover); + css += TQString(" .%1 a:hover { %2 }\n").tqarg(cssClass, hover); return css; } /** LinkLabel */ -LinkLabel::LinkLabel(int hAlign, int vAlign, QWidget *parent, const char *name, WFlags f) - : QFrame(parent, name, f), m_isSelected(false), m_isHovered(false), m_look(0) +LinkLabel::LinkLabel(int hAlign, int vAlign, TQWidget *tqparent, const char *name, WFlags f) + : TQFrame(tqparent, name, f), m_isSelected(false), m_isHovered(false), m_look(0) { initLabel(hAlign, vAlign); } -LinkLabel::LinkLabel(const QString &title, const QString &icon, LinkLook *look, int hAlign, int vAlign, - QWidget *parent, const char *name, WFlags f) - : QFrame(parent, name, f), m_isSelected(false), m_isHovered(false), m_look(0) +LinkLabel::LinkLabel(const TQString &title, const TQString &icon, LinkLook *look, int hAlign, int vAlign, + TQWidget *tqparent, const char *name, WFlags f) + : TQFrame(tqparent, name, f), m_isSelected(false), m_isHovered(false), m_look(0) { initLabel(hAlign, vAlign); setLink(title, icon, look); @@ -181,16 +181,16 @@ LinkLabel::LinkLabel(const QString &title, const QString &icon, LinkLook *look, void LinkLabel::initLabel(int hAlign, int vAlign) { - m_layout = new QBoxLayout(this, QBoxLayout::LeftToRight); - m_icon = new QLabel(this); - m_title = new QLabel(this); - m_spacer1 = new QSpacerItem(0, 0, QSizePolicy::Preferred/*Expanding*/, QSizePolicy::Preferred/*Expanding*/); - m_spacer2 = new QSpacerItem(0, 0, QSizePolicy::Preferred/*Expanding*/, QSizePolicy::Preferred/*Expanding*/); + m_layout = new TQBoxLayout(this, TQBoxLayout::LeftToRight); + m_icon = new TQLabel(this); + m_title = new TQLabel(this); + m_spacer1 = new TQSpacerItem(0, 0, TQSizePolicy::Preferred/*Expanding*/, TQSizePolicy::Preferred/*Expanding*/); + m_spacer2 = new TQSpacerItem(0, 0, TQSizePolicy::Preferred/*Expanding*/, TQSizePolicy::Preferred/*Expanding*/); m_hAlign = hAlign; m_vAlign = vAlign; - m_title->setTextFormat(Qt::PlainText); + m_title->setTextFormat(TQt::PlainText); // DEGUB: //m_icon->setPaletteBackgroundColor("lightblue"); @@ -201,7 +201,7 @@ LinkLabel::~LinkLabel() { } -void LinkLabel::setLink(const QString &title, const QString &icon, LinkLook *look) +void LinkLabel::setLink(const TQString &title, const TQString &icon, LinkLook *look) { if (look) m_look = look; // Needed for icon size @@ -212,7 +212,7 @@ void LinkLabel::setLink(const QString &title, const QString &icon, LinkLook *loo if (icon.isEmpty()) m_icon->clear(); else { - QPixmap pixmap = DesktopIcon(icon, m_look->iconSize(), m_look->iconSize(), kapp); + TQPixmap pixmap = DesktopIcon(icon, m_look->iconSize(), m_look->iconSize(), kapp); if (!pixmap.isNull()) m_icon->setPixmap(pixmap); } @@ -226,12 +226,12 @@ void LinkLabel::setLook(LinkLook *look) // FIXME: called externaly (so, without { m_look = look; - QFont font; + TQFont font; font.setBold(look->bold()); font.setUnderline(look->underlineOutside()); font.setItalic(look->italic()); m_title->setFont(font); - m_title->setPaletteForegroundColor( m_isSelected ? KApplication::palette().active().highlightedText() : look->effectiveColor() ); + m_title->setPaletteForegroundColor( m_isSelected ? KApplication::tqpalette().active().highlightedText() : look->effectiveColor() ); m_icon->setShown( m_icon->pixmap() && ! m_icon->pixmap()->isNull() ); @@ -246,22 +246,22 @@ void LinkLabel::setAlign(int hAlign, int vAlign) if (!m_look) return; - // Define alignment flags : + // Define tqalignment flags : //FIXME TODO: Use directly flags ! int hFlag, vFlag, wBreak; switch (hAlign) { default: - case 0: hFlag = Qt::AlignLeft; break; - case 1: hFlag = Qt::AlignHCenter; break; - case 2: hFlag = Qt::AlignRight; break; + case 0: hFlag = TQt::AlignLeft; break; + case 1: hFlag = TQt::AlignHCenter; break; + case 2: hFlag = TQt::AlignRight; break; } switch (vAlign) { - case 0: vFlag = Qt::AlignTop; break; + case 0: vFlag = TQt::AlignTop; break; default: - case 1: vFlag = Qt::AlignVCenter; break; - case 2: vFlag = Qt::AlignBottom; break; + case 1: vFlag = TQt::AlignVCenter; break; + case 2: vFlag = TQt::AlignBottom; break; } - wBreak = Qt::WordBreak * (hAlign != 1); + wBreak = TQt::WordBreak * (hAlign != 1); // Clear the widget : m_layout->removeItem(m_spacer1); @@ -269,19 +269,19 @@ void LinkLabel::setAlign(int hAlign, int vAlign) m_layout->remove(m_title); m_layout->removeItem(m_spacer2); - // Otherwise, minimumSize will be incoherent (last size ? ) - m_layout->setResizeMode(QLayout::Minimum); + // Otherwise, tqminimumSize will be incoherent (last size ? ) + m_layout->setResizeMode(TQLayout::Minimum); // And re-populate the widget with the appropriates things and order bool addSpacers = hAlign == 1; - m_layout->setDirection(QBoxLayout::LeftToRight); - //m_title->setSizePolicy( QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum/*Expanding*/, 0, 0, false) ); - m_icon->setSizePolicy( QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred/*Expanding*/, 0, 0, false) ); - m_spacer1->changeSize( 0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred/*Expanding*/ ); - m_spacer2->changeSize( 0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred/*Expanding*/ ); - - m_icon->setAlignment( hFlag | vFlag ); - m_title->setAlignment( hFlag | vFlag | wBreak ); + m_layout->setDirection(TQBoxLayout::LeftToRight); + //m_title->tqsetSizePolicy( TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Maximum/*Expanding*/, 0, 0, false) ); + m_icon->tqsetSizePolicy( TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Preferred/*Expanding*/, 0, 0, false) ); + m_spacer1->changeSize( 0, 0, TQSizePolicy::Expanding, TQSizePolicy::Preferred/*Expanding*/ ); + m_spacer2->changeSize( 0, 0, TQSizePolicy::Expanding, TQSizePolicy::Preferred/*Expanding*/ ); + + m_icon->tqsetAlignment( hFlag | vFlag ); + m_title->tqsetAlignment( hFlag | vFlag | wBreak ); if ( addSpacers && (vAlign != 0) || (m_title->text().isEmpty() && hAlign == 2) ) m_layout->addItem(m_spacer1); @@ -297,24 +297,24 @@ void LinkLabel::setAlign(int hAlign, int vAlign) m_layout->addItem(m_spacer2); } -void LinkLabel::enterEvent(QEvent*) +void LinkLabel::enterEvent(TQEvent*) { m_isHovered = true; if ( ! m_isSelected ) m_title->setPaletteForegroundColor(m_look->effectiveHoverColor()); - QFont font = m_title->font(); + TQFont font = m_title->font(); font.setUnderline(m_look->underlineInside()); m_title->setFont(font); } -void LinkLabel::leaveEvent(QEvent*) +void LinkLabel::leaveEvent(TQEvent*) { m_isHovered = false; if ( ! m_isSelected ) m_title->setPaletteForegroundColor(m_look->effectiveColor()); - QFont font = m_title->font(); + TQFont font = m_title->font(); font.setUnderline(m_look->underlineOutside()); m_title->setFont(font); } @@ -323,16 +323,16 @@ void LinkLabel::setSelected(bool selected) { m_isSelected = selected; if (selected) - m_title->setPaletteForegroundColor(KApplication::palette().active().highlightedText()); + m_title->setPaletteForegroundColor(KApplication::tqpalette().active().highlightedText()); else if (m_isHovered) m_title->setPaletteForegroundColor(m_look->effectiveHoverColor()); else m_title->setPaletteForegroundColor(m_look->effectiveColor()); } -void LinkLabel::setPaletteBackgroundColor(const QColor &color) +void LinkLabel::setPaletteBackgroundColor(const TQColor &color) { - QFrame::setPaletteBackgroundColor(color); + TQFrame::setPaletteBackgroundColor(color); m_title->setPaletteBackgroundColor(color); } @@ -345,10 +345,10 @@ int LinkLabel::heightForWidth(int w) const return (titleH >= iconS) ? titleH : iconS; // No margin for the moment ! } -QString LinkLabel::toHtml(const QString &imageName) +TQString LinkLabel::toHtml(const TQString &imageName) { - QString begin = "<font color=" + m_look->effectiveColor().name() + ">"; - QString end = "</font>"; + TQString begin = "<font color=" + m_look->effectiveColor().name() + ">"; + TQString end = "</font>"; if (m_look->italic()) { begin += "<i>"; end.prepend("</i>"); @@ -362,11 +362,11 @@ QString LinkLabel::toHtml(const QString &imageName) end.prepend("</u>"); } if (m_icon->pixmap()) { - QPixmap icon(*m_icon->pixmap()); + TQPixmap icon(*m_icon->pixmap()); begin.prepend("<img src=" + imageName + " style=\"vertical-align: middle\"> "); - QMimeSourceFactory::defaultFactory()->setPixmap(imageName, icon); + TQMimeSourceFactory::defaultFactory()->setPixmap(imageName, icon); } else - QMimeSourceFactory::defaultFactory()->setData(imageName, 0L); + TQMimeSourceFactory::defaultFactory()->setData(imageName, 0L); return begin + Tools::textToHTMLWithoutP(m_title->text()) + end; } @@ -378,12 +378,12 @@ LinkDisplay::LinkDisplay() { } -void LinkDisplay::setLink(const QString &title, const QString &icon, LinkLook *look, const QFont &font) +void LinkDisplay::setLink(const TQString &title, const TQString &icon, LinkLook *look, const TQFont &font) { setLink(title, icon, m_preview, look, font); } -void LinkDisplay::setLink(const QString &title, const QString &icon, const QPixmap &preview, LinkLook *look, const QFont &font) +void LinkDisplay::setLink(const TQString &title, const TQString &icon, const TQPixmap &preview, LinkLook *look, const TQFont &font) { m_title = title; m_icon = icon; @@ -392,15 +392,15 @@ void LinkDisplay::setLink(const QString &title, const QString &icon, const QPixm m_font = font; // "Constants": - int BUTTON_MARGIN = kapp->style().pixelMetric(QStyle::PM_ButtonMargin); + int BUTTON_MARGIN = kapp->tqstyle().tqpixelMetric(TQStyle::PM_ButtonMargin); int LINK_MARGIN = BUTTON_MARGIN + 2; // Recompute m_minWidth: - QRect textRect = QFontMetrics(labelFont(font, false)).boundingRect(0, 0, /*width=*/1, 500000, Qt::AlignAuto | Qt::AlignTop | Qt::WordBreak, m_title); - int iconPreviewWidth = QMAX(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); + TQRect textRect = TQFontMetrics(labelFont(font, false)).boundingRect(0, 0, /*width=*/1, 500000, TQt::AlignAuto | TQt::AlignTop | TQt::WordBreak, m_title); + int iconPreviewWidth = TQMAX(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); m_minWidth = BUTTON_MARGIN - 1 + iconPreviewWidth + LINK_MARGIN + textRect.width(); // Recompute m_maxWidth: - textRect = QFontMetrics(labelFont(font, false)).boundingRect(0, 0, /*width=*/50000000, 500000, Qt::AlignAuto | Qt::AlignTop | Qt::WordBreak, m_title); + textRect = TQFontMetrics(labelFont(font, false)).boundingRect(0, 0, /*width=*/50000000, 500000, TQt::AlignAuto | TQt::AlignTop | TQt::WordBreak, m_title); m_maxWidth = BUTTON_MARGIN - 1 + iconPreviewWidth + LINK_MARGIN + textRect.width(); // Adjust m_width: if (m_width < m_minWidth) @@ -422,35 +422,35 @@ void LinkDisplay::setWidth(int width) /** Paint on @p painter * in (@p x, @p y, @p width, @p height) - * using @p colorGroup for the button drawing (if @p isHovered) + * using @p tqcolorGroup for the button drawing (if @p isHovered) * and the LinkLook color() for the text, - * unless [the LinkLook !color.isValid() and it does not useLinkColor()] or [@p isDefaultColor is false]: in this case it will use @p colorGroup.text(). + * unless [the LinkLook !color.isValid() and it does not useLinkColor()] or [@p isDefaultColor is false]: in this case it will use @p tqcolorGroup.text(). * It will draw the button if @p isIconButtonHovered. */ -void LinkDisplay::paint(QPainter *painter, int x, int y, int width, int height, const QColorGroup &colorGroup, +void LinkDisplay::paint(TQPainter *painter, int x, int y, int width, int height, const TQColorGroup &tqcolorGroup, bool isDefaultColor, bool isSelected, bool isHovered, bool isIconButtonHovered) const { - int BUTTON_MARGIN = kapp->style().pixelMetric(QStyle::PM_ButtonMargin); + int BUTTON_MARGIN = kapp->tqstyle().tqpixelMetric(TQStyle::PM_ButtonMargin); int LINK_MARGIN = BUTTON_MARGIN + 2; - QPixmap pixmap; + TQPixmap pixmap; // Load the preview...: if (!isHovered && m_look->previewEnabled() && !m_preview.isNull()) pixmap = m_preview; // ... Or the icon (if no preview or if the "Open" icon should be shown): else { int iconSize = m_look->iconSize(); - QString iconName = (isHovered ? Global::openNoteIcon() : m_icon); + TQString iconName = (isHovered ? Global::openNoteIcon() : m_icon); KIcon::States iconState = (isIconButtonHovered ? KIcon::ActiveState : KIcon::DefaultState); pixmap = kapp->iconLoader()->loadIcon(iconName, KIcon::Desktop, iconSize, iconState, 0L, /*canReturnNull=*/false); } - int iconPreviewWidth = QMAX(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); + int iconPreviewWidth = TQMAX(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); int pixmapX = (iconPreviewWidth - pixmap.width()) / 2; int pixmapY = (height - pixmap.height()) / 2; // Draw the button (if any) and the icon: if (isHovered) - kapp->style().drawPrimitive(QStyle::PE_ButtonCommand, painter, QRect(-1, -1, iconPreviewWidth + 2*BUTTON_MARGIN, height + 2), - colorGroup, QStyle::Style_Enabled | (isIconButtonHovered ? QStyle::Style_MouseOver : 0)); + kapp->tqstyle().tqdrawPrimitive(TQStyle::PE_ButtonCommand, painter, TQRect(-1, -1, iconPreviewWidth + 2*BUTTON_MARGIN, height + 2), + tqcolorGroup, TQStyle::Style_Enabled | (isIconButtonHovered ? TQStyle::Style_MouseOver : 0)); painter->drawPixmap(x + BUTTON_MARGIN - 1 + pixmapX, y + pixmapY, pixmap); // Figure out the text color: @@ -459,47 +459,47 @@ void LinkDisplay::paint(QPainter *painter, int x, int y, int width, int height, else if (isIconButtonHovered) painter->setPen(m_look->effectiveHoverColor()); else if (!isDefaultColor || (!m_look->color().isValid() && !m_look->useLinkColor())) // If the color is FORCED or if the link color default to the text color: - painter->setPen(colorGroup.text()); + painter->setPen(tqcolorGroup.text()); else painter->setPen(m_look->effectiveColor()); // Draw the text: painter->setFont(labelFont(m_font, isIconButtonHovered)); painter->drawText(x + BUTTON_MARGIN - 1 + iconPreviewWidth + LINK_MARGIN, y, width - BUTTON_MARGIN + 1 - iconPreviewWidth - LINK_MARGIN, height, - Qt::AlignAuto | Qt::AlignVCenter | Qt::WordBreak, m_title); + TQt::AlignAuto | TQt::AlignVCenter | TQt::WordBreak, m_title); } -QPixmap LinkDisplay::feedbackPixmap(int width, int height, const QColorGroup &colorGroup, bool isDefaultColor) +TQPixmap LinkDisplay::feedbackPixmap(int width, int height, const TQColorGroup &tqcolorGroup, bool isDefaultColor) { - int theWidth = QMIN(width, maxWidth()); - int theHeight = QMIN(height, heightForWidth(theWidth)); - QPixmap pixmap(theWidth, theHeight); - pixmap.fill(colorGroup.background()); - QPainter painter(&pixmap); - paint(&painter, 0, 0, theWidth, theHeight, colorGroup, isDefaultColor, + int theWidth = TQMIN(width, maxWidth()); + int theHeight = TQMIN(height, heightForWidth(theWidth)); + TQPixmap pixmap(theWidth, theHeight); + pixmap.fill(tqcolorGroup.background()); + TQPainter painter(&pixmap); + paint(&painter, 0, 0, theWidth, theHeight, tqcolorGroup, isDefaultColor, /*isSelected=*/false, /*isHovered=*/false, /*isIconButtonHovered=*/false); painter.end(); return pixmap; } -bool LinkDisplay::iconButtonAt(const QPoint &pos) const +bool LinkDisplay::iconButtonAt(const TQPoint &pos) const { - int BUTTON_MARGIN = kapp->style().pixelMetric(QStyle::PM_ButtonMargin); + int BUTTON_MARGIN = kapp->tqstyle().tqpixelMetric(TQStyle::PM_ButtonMargin); // int LINK_MARGIN = BUTTON_MARGIN + 2; - int iconPreviewWidth = QMAX(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); + int iconPreviewWidth = TQMAX(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); return pos.x() <= BUTTON_MARGIN - 1 + iconPreviewWidth + BUTTON_MARGIN; } -QRect LinkDisplay::iconButtonRect() const +TQRect LinkDisplay::iconButtonRect() const { - int BUTTON_MARGIN = kapp->style().pixelMetric(QStyle::PM_ButtonMargin); + int BUTTON_MARGIN = kapp->tqstyle().tqpixelMetric(TQStyle::PM_ButtonMargin); // int LINK_MARGIN = BUTTON_MARGIN + 2; - int iconPreviewWidth = QMAX(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); + int iconPreviewWidth = TQMAX(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); - return QRect(0, 0, BUTTON_MARGIN - 1 + iconPreviewWidth + BUTTON_MARGIN, m_height); + return TQRect(0, 0, BUTTON_MARGIN - 1 + iconPreviewWidth + BUTTON_MARGIN, m_height); } -QFont LinkDisplay::labelFont(QFont font, bool isIconButtonHovered) const +TQFont LinkDisplay::labelFont(TQFont font, bool isIconButtonHovered) const { if (m_look->italic()) font.setItalic(true); @@ -517,91 +517,91 @@ QFont LinkDisplay::labelFont(QFont font, bool isIconButtonHovered) const int LinkDisplay::heightForWidth(int width) const { - int BUTTON_MARGIN = kapp->style().pixelMetric(QStyle::PM_ButtonMargin); + int BUTTON_MARGIN = kapp->tqstyle().tqpixelMetric(TQStyle::PM_ButtonMargin); int LINK_MARGIN = BUTTON_MARGIN + 2; - int iconPreviewWidth = QMAX(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); - int iconPreviewHeight = QMAX(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.height() : 0)); + int iconPreviewWidth = TQMAX(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width() : 0)); + int iconPreviewHeight = TQMAX(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.height() : 0)); - QRect textRect = QFontMetrics(labelFont(m_font, false)).boundingRect(0, 0, width - BUTTON_MARGIN + 1 - iconPreviewWidth - LINK_MARGIN, 500000, Qt::AlignAuto | Qt::AlignTop | Qt::WordBreak, m_title); - return QMAX(textRect.height(), iconPreviewHeight + 2*BUTTON_MARGIN - 2); + TQRect textRect = TQFontMetrics(labelFont(m_font, false)).boundingRect(0, 0, width - BUTTON_MARGIN + 1 - iconPreviewWidth - LINK_MARGIN, 500000, TQt::AlignAuto | TQt::AlignTop | TQt::WordBreak, m_title); + return TQMAX(textRect.height(), iconPreviewHeight + 2*BUTTON_MARGIN - 2); } -QString LinkDisplay::toHtml(const QString &/*imageName*/) const +TQString LinkDisplay::toHtml(const TQString &/*imageName*/) const { // TODO return ""; } -QString LinkDisplay::toHtml(HTMLExporter *exporter, const KURL &url, const QString &title) +TQString LinkDisplay::toHtml(HTMLExporter *exporter, const KURL &url, const TQString &title) { - QString linkIcon; + TQString linkIcon; if (m_look->previewEnabled() && !m_preview.isNull()) { - QString fileName = Tools::fileNameForNewFile("preview_" + url.fileName() + ".png", exporter->iconsFolderPath); - QString fullPath = exporter->iconsFolderPath + fileName; + TQString fileName = Tools::fileNameForNewFile("preview_" + url.fileName() + ".png", exporter->iconsFolderPath); + TQString fullPath = exporter->iconsFolderPath + fileName; m_preview.save(fullPath, "PNG"); - linkIcon = QString("<img src=\"%1\" width=\"%2\" height=\"%3\" alt=\"\">") - .arg(exporter->iconsFolderName + fileName, QString::number(m_preview.width()), QString::number(m_preview.height())); + linkIcon = TQString("<img src=\"%1\" width=\"%2\" height=\"%3\" alt=\"\">") + .tqarg(exporter->iconsFolderName + fileName, TQString::number(m_preview.width()), TQString::number(m_preview.height())); } else { linkIcon = exporter->iconsFolderName + exporter->copyIcon(m_icon, m_look->iconSize()); - linkIcon = QString("<img src=\"%1\" width=\"%2\" height=\"%3\" alt=\"\">") - .arg(linkIcon, QString::number(m_look->iconSize()), QString::number(m_look->iconSize())); + linkIcon = TQString("<img src=\"%1\" width=\"%2\" height=\"%3\" alt=\"\">") + .tqarg(linkIcon, TQString::number(m_look->iconSize()), TQString::number(m_look->iconSize())); } - QString linkTitle = Tools::textToHTMLWithoutP(title.isEmpty() ? m_title : title); + TQString linkTitle = Tools::textToHTMLWithoutP(title.isEmpty() ? m_title : title); - return QString("<a href=\"%1\">%2 %3</a>").arg(url.prettyURL(), linkIcon, linkTitle); + return TQString("<a href=\"%1\">%2 %3</a>").tqarg(url.prettyURL(), linkIcon, linkTitle); } /** LinkLookEditWidget **/ -LinkLookEditWidget::LinkLookEditWidget(KCModule *module, const QString exTitle, const QString exIcon, - QWidget *parent, const char *name, WFlags fl) - : QWidget(parent, name, fl) +LinkLookEditWidget::LinkLookEditWidget(KCModule *module, const TQString exTitle, const TQString exIcon, + TQWidget *tqparent, const char *name, WFlags fl) + : TQWidget(tqparent, name, fl) { - QLabel *label; - QVBoxLayout *layout = new QVBoxLayout(this, KDialogBase::marginHint(), KDialogBase::spacingHint()); + TQLabel *label; + TQVBoxLayout *tqlayout = new TQVBoxLayout(this, KDialogBase::marginHint(), KDialogBase::spacingHint()); - m_italic = new QCheckBox(i18n("I&talic"), this); - layout->addWidget(m_italic); + m_italic = new TQCheckBox(i18n("I&talic"), this); + tqlayout->addWidget(m_italic); - m_bold = new QCheckBox(i18n("&Bold"), this); - layout->addWidget(m_bold); + m_bold = new TQCheckBox(i18n("&Bold"), this); + tqlayout->addWidget(m_bold); - QGridLayout *gl = new QGridLayout(layout, /*rows=*//*(look->canPreview() ? 5 : 4)*/5, /*columns=*//*3*/4); - gl->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding), 1, /*2*/3); + TQGridLayout *gl = new TQGridLayout(tqlayout, /*rows=*//*(look->canPreview() ? 5 : 4)*/5, /*columns=*//*3*/4); + gl->addItem(new TQSpacerItem(0, 0, TQSizePolicy::Expanding), 1, /*2*/3); - m_underlining = new QComboBox(false, this); + m_underlining = new TQComboBox(false, this); m_underlining->insertItem(i18n("Always")); m_underlining->insertItem(i18n("Never")); m_underlining->insertItem(i18n("On mouse hovering")); m_underlining->insertItem(i18n("When mouse is outside")); - label = new QLabel(m_underlining, i18n("&Underline:"), this); + label = new TQLabel(m_underlining, i18n("&Underline:"), this); gl->addWidget(label, 0, 0); gl->addWidget(m_underlining, 0, 1); - m_color = new KColorCombo2(QRgb(), this); - label = new QLabel(m_color, i18n("Colo&r:"), this); + m_color = new KColorCombo2(TQRgb(), this); + label = new TQLabel(m_color, i18n("Colo&r:"), this); gl->addWidget(label, 1, 0); gl->addWidget(m_color, 1, 1); - m_hoverColor = new KColorCombo2(QRgb(), this); - label = new QLabel(m_hoverColor, i18n("&Mouse hover color:"), this); + m_hoverColor = new KColorCombo2(TQRgb(), this); + label = new TQLabel(m_hoverColor, i18n("&Mouse hover color:"), this); gl->addWidget(label, 2, 0); gl->addWidget(m_hoverColor, 2, 1); - QHBoxLayout *icoLay = new QHBoxLayout(/*parent=*/0L, /*margin=*/0, KDialogBase::spacingHint()); + TQHBoxLayout *icoLay = new TQHBoxLayout(/*tqparent=*/0L, /*margin=*/0, KDialogBase::spacingHint()); m_iconSize = new IconSizeCombo(false, this); icoLay->addWidget(m_iconSize); - label = new QLabel(m_iconSize, i18n("&Icon size:"), this); + label = new TQLabel(m_iconSize, i18n("&Icon size:"), this); gl->addWidget(label, 3, 0); gl->addItem( icoLay, 3, 1); - m_preview = new QComboBox(false, this); + m_preview = new TQComboBox(false, this); m_preview->insertItem(i18n("None")); m_preview->insertItem(i18n("Icon size")); m_preview->insertItem(i18n("Twice the icon size")); m_preview->insertItem(i18n("Three times the icon size")); - m_label = new QLabel(m_preview, i18n("&Preview:"), this); + m_label = new TQLabel(m_preview, i18n("&Preview:"), this); m_hLabel = new HelpLabel( i18n("You disabled preview but still see images?"), i18n("<p>This is normal because there are several type of notes.<br>" @@ -614,36 +614,36 @@ LinkLookEditWidget::LinkLookEditWidget(KCModule *module, const QString exTitle, "<p>If you do not want the application to create notes depending on the content of the files you drop, " "go to the \"General\" page and uncheck \"Image or animation\" in the \"View Content of Added Files for the Following Types\" group.</p>") // TODO: Note: you can resize down maximum size of images... - .arg(kapp->aboutData()->programName(), kapp->aboutData()->programName()), + .tqarg(kapp->aboutData()->programName(), kapp->aboutData()->programName()), this); gl->addWidget(m_label, 4, 0); gl->addWidget(m_preview, 4, 1); gl->addMultiCellWidget(m_hLabel, /*fromRow=*/5, /*toRow=*/5, /*fromCol=*/1, /*toCol*/2); - QGroupBox *gb = new QHGroupBox(i18n("Example"), this); + TQGroupBox *gb = new TQHGroupBox(i18n("Example"), this); m_exLook = new LinkLook; m_example = new LinkLabel(exTitle, exIcon, m_exLook, 1, 1, gb); - m_example->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - m_example->setCursor(QCursor(Qt::PointingHandCursor)); - layout->addWidget(gb); + m_example->tqsetSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding); + m_example->setCursor(TQCursor(TQt::PointingHandCursor)); + tqlayout->addWidget(gb); m_exTitle = exTitle; m_exIcon = exIcon; - connect( m_italic, SIGNAL(stateChanged(int)), this, SLOT(slotChangeLook()) ); - connect( m_bold, SIGNAL(stateChanged(int)), this, SLOT(slotChangeLook()) ); - connect( m_underlining, SIGNAL(activated(int)), this, SLOT(slotChangeLook()) ); - connect( m_color, SIGNAL(changed(const QColor&)), this, SLOT(slotChangeLook()) ); - connect( m_hoverColor, SIGNAL(changed(const QColor&)), this, SLOT(slotChangeLook()) ); - connect( m_iconSize, SIGNAL(activated(int)), this, SLOT(slotChangeLook()) ); - connect( m_preview, SIGNAL(activated(int)), this, SLOT(slotChangeLook()) ); - - connect( m_italic, SIGNAL(stateChanged(int)), module, SLOT(changed()) ); - connect( m_bold, SIGNAL(stateChanged(int)), module, SLOT(changed()) ); - connect( m_underlining, SIGNAL(activated(int)), module, SLOT(changed()) ); - connect( m_color, SIGNAL(changed(const QColor&)), module, SLOT(changed()) ); - connect( m_hoverColor, SIGNAL(changed(const QColor&)), module, SLOT(changed()) ); - connect( m_iconSize, SIGNAL(activated(int)), module, SLOT(changed()) ); - connect( m_preview, SIGNAL(activated(int)), module, SLOT(changed()) ); + connect( m_italic, TQT_SIGNAL(stateChanged(int)), this, TQT_SLOT(slotChangeLook()) ); + connect( m_bold, TQT_SIGNAL(stateChanged(int)), this, TQT_SLOT(slotChangeLook()) ); + connect( m_underlining, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotChangeLook()) ); + connect( m_color, TQT_SIGNAL(changed(const TQColor&)), this, TQT_SLOT(slotChangeLook()) ); + connect( m_hoverColor, TQT_SIGNAL(changed(const TQColor&)), this, TQT_SLOT(slotChangeLook()) ); + connect( m_iconSize, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotChangeLook()) ); + connect( m_preview, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotChangeLook()) ); + + connect( m_italic, TQT_SIGNAL(stateChanged(int)), module, TQT_SLOT(changed()) ); + connect( m_bold, TQT_SIGNAL(stateChanged(int)), module, TQT_SLOT(changed()) ); + connect( m_underlining, TQT_SIGNAL(activated(int)), module, TQT_SLOT(changed()) ); + connect( m_color, TQT_SIGNAL(changed(const TQColor&)), module, TQT_SLOT(changed()) ); + connect( m_hoverColor, TQT_SIGNAL(changed(const TQColor&)), module, TQT_SLOT(changed()) ); + connect( m_iconSize, TQT_SIGNAL(activated(int)), module, TQT_SLOT(changed()) ); + connect( m_preview, TQT_SIGNAL(activated(int)), module, TQT_SLOT(changed()) ); } void LinkLookEditWidget::set(LinkLook *look) |