diff options
Diffstat (limited to 'malloryclient/malloryclient.cpp')
-rw-r--r-- | malloryclient/malloryclient.cpp | 226 |
1 files changed, 113 insertions, 113 deletions
diff --git a/malloryclient/malloryclient.cpp b/malloryclient/malloryclient.cpp index cd6028c..9c3ab25 100644 --- a/malloryclient/malloryclient.cpp +++ b/malloryclient/malloryclient.cpp @@ -14,14 +14,14 @@ #include <kpixmap.h> #include <kpixmapeffect.h> -#include <qcursor.h> -#include <qfontmetrics.h> -#include <qlabel.h> -#include <qlayout.h> -#include <qpainter.h> -#include <qpixmap.h> -#include <qimage.h> -#include <qtooltip.h> +#include <tqcursor.h> +#include <tqfontmetrics.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqpainter.h> +#include <tqpixmap.h> +#include <tqimage.h> +#include <tqtooltip.h> #include "malloryclient.h" #include "malloryhandler.h" @@ -50,26 +50,26 @@ void MalloryClient::init() widget()->setBackgroundMode(NoBackground); // to avoid flicker // Set up layout - QGridLayout *mainLayout = new QGridLayout(widget(), 4, 3); // 4 x 3 grid - QHBoxLayout *titleLayout = new QHBoxLayout(); - QVBoxLayout *leftButtonLayout = new QVBoxLayout(); - QHBoxLayout *leftButtonLayout2 = new QHBoxLayout(); + TQGridLayout *mainLayout = new TQGridLayout(widget(), 4, 3); // 4 x 3 grid + TQHBoxLayout *titleLayout = new TQHBoxLayout(); + TQVBoxLayout *leftButtonLayout = new TQVBoxLayout(); + TQHBoxLayout *leftButtonLayout2 = new TQHBoxLayout(); leftButtonLayout->setSpacing(2); - QVBoxLayout *rightButtonLayout = new QVBoxLayout(); - QHBoxLayout *rightButtonLayout2 = new QHBoxLayout(); + TQVBoxLayout *rightButtonLayout = new TQVBoxLayout(); + TQHBoxLayout *rightButtonLayout2 = new TQHBoxLayout(); rightButtonLayout->setSpacing(2); - mainLayout->setResizeMode(QLayout::FreeResize); + mainLayout->setResizeMode(TQLayout::FreeResize); - m_titleBar = new QSpacerItem(1, MalloryHandler::titleSize(), QSizePolicy::Expanding, QSizePolicy::Fixed); - m_leftSpacer = new QSpacerItem(1, 1); - m_rightSpacer = new QSpacerItem(1, 1); - m_topSpacer = new QSpacerItem(1, 1); // 2nd argument is the top margin. - m_bottomSpacer = new QSpacerItem(1, MalloryHandler::borderSize()); - m_leftButtonSpacer = new QSpacerItem(MalloryHandler::buttonSpacing(), MalloryHandler::titleSize()); - m_rightButtonSpacer = new QSpacerItem(MalloryHandler::buttonSpacing(), MalloryHandler::titleSize()); - m_leftButtonSpacer2 = new QSpacerItem(1, (MalloryHandler::titleSize()-MalloryHandler::buttonSize())/2, QSizePolicy::Minimum, QSizePolicy::Fixed); - m_rightButtonSpacer2 = new QSpacerItem(1, (MalloryHandler::titleSize()-MalloryHandler::buttonSize())/2, QSizePolicy::Minimum, QSizePolicy::Fixed); + m_titleBar = new TQSpacerItem(1, MalloryHandler::titleSize(), TQSizePolicy::Expanding, TQSizePolicy::Fixed); + m_leftSpacer = new TQSpacerItem(1, 1); + m_rightSpacer = new TQSpacerItem(1, 1); + m_topSpacer = new TQSpacerItem(1, 1); // 2nd argument is the top margin. + m_bottomSpacer = new TQSpacerItem(1, MalloryHandler::borderSize()); + m_leftButtonSpacer = new TQSpacerItem(MalloryHandler::buttonSpacing(), MalloryHandler::titleSize()); + m_rightButtonSpacer = new TQSpacerItem(MalloryHandler::buttonSpacing(), MalloryHandler::titleSize()); + m_leftButtonSpacer2 = new TQSpacerItem(1, (MalloryHandler::titleSize()-MalloryHandler::buttonSize())/2, TQSizePolicy::Minimum, TQSizePolicy::Fixed); + m_rightButtonSpacer2 = new TQSpacerItem(1, (MalloryHandler::titleSize()-MalloryHandler::buttonSize())/2, TQSizePolicy::Minimum, TQSizePolicy::Fixed); mainLayout->addItem(m_topSpacer, 0, 1); mainLayout->addItem(m_bottomSpacer, 3, 1); @@ -79,11 +79,11 @@ void MalloryClient::init() mainLayout->addLayout(titleLayout, 1, 1); if (isPreview()) { - mainLayout->addWidget(new QLabel(i18n("<center><b>Mallory</b></center>"), widget()), 2, 1); + mainLayout->addWidget(new TQLabel(i18n("<center><b>Mallory</b></center>"), widget()), 2, 1); } else { - mainLayout->addItem(new QSpacerItem(0, 0), 2, 1); + mainLayout->addItem(new TQSpacerItem(0, 0), 2, 1); } // Make the window stretch @@ -101,35 +101,35 @@ void MalloryClient::init() // Add the left buttons leftButtonLayout->addItem(m_leftButtonSpacer2); leftButtonLayout->addLayout(leftButtonLayout2); - addButtons(leftButtonLayout2, options()->customButtonPositions() ? options()->titleButtonsLeft() : QString(default_left)); + addButtons(leftButtonLayout2, options()->customButtonPositions() ? options()->titleButtonsLeft() : TQString(default_left)); // Add the right buttons rightButtonLayout->addItem(m_rightButtonSpacer2); rightButtonLayout->addLayout(rightButtonLayout2); - addButtons(rightButtonLayout2, options()->customButtonPositions() ? options()->titleButtonsRight() : QString(default_right)); + addButtons(rightButtonLayout2, options()->customButtonPositions() ? options()->titleButtonsRight() : TQString(default_right)); } -bool MalloryClient::eventFilter(QObject *o, QEvent *e) +bool MalloryClient::eventFilter(TQObject *o, TQEvent *e) { if (o != widget()) return false; switch (e->type()) { - case QEvent::Resize: - resizeEvent(static_cast<QResizeEvent*>(e)); + case TQEvent::Resize: + resizeEvent(static_cast<TQResizeEvent*>(e)); return true; - case QEvent::Paint: - paintEvent(static_cast<QPaintEvent*>(e)); + case TQEvent::Paint: + paintEvent(static_cast<TQPaintEvent*>(e)); return true; - case QEvent::MouseButtonDblClick: - mouseDoubleClickEvent(static_cast<QMouseEvent*>(e)); + case TQEvent::MouseButtonDblClick: + mouseDoubleClickEvent(static_cast<TQMouseEvent*>(e)); return true; - case QEvent::MouseButtonPress: - processMousePressEvent(static_cast<QMouseEvent*>(e)); + case TQEvent::MouseButtonPress: + processMousePressEvent(static_cast<TQMouseEvent*>(e)); return true; - case QEvent::Show: - showEvent(static_cast<QShowEvent*>(e)); + case TQEvent::Show: + showEvent(static_cast<TQShowEvent*>(e)); return true; default: @@ -137,7 +137,7 @@ bool MalloryClient::eventFilter(QObject *o, QEvent *e) } } -void MalloryClient::addButtons(QBoxLayout *layout, const QString &s) +void MalloryClient::addButtons(TQBoxLayout *layout, const TQString &s) { if (s.length() > 0) { @@ -150,7 +150,7 @@ void MalloryClient::addButtons(QBoxLayout *layout, const QString &s) { m_button[ButtonMenu] = new MalloryButton(this, "menu", i18n("Menu"), ButtonMenu); connect(m_button[ButtonMenu], SIGNAL(pressed()), this, SLOT(menuButtonPressed())); - layout->addWidget(m_button[ButtonMenu], 0, Qt::AlignHCenter | Qt::AlignTop); + layout->addWidget(m_button[ButtonMenu], 0, TQt::AlignHCenter | TQt::AlignTop); } break; case 'H': // Help @@ -158,7 +158,7 @@ void MalloryClient::addButtons(QBoxLayout *layout, const QString &s) { m_button[ButtonHelp] = new MalloryButton(this, "help", i18n("Help"), ButtonHelp); connect(m_button[ButtonHelp], SIGNAL(clicked()), this, SLOT(showContextHelp())); - layout->addWidget(m_button[ButtonHelp], 0, Qt::AlignHCenter | Qt::AlignTop); + layout->addWidget(m_button[ButtonHelp], 0, TQt::AlignHCenter | TQt::AlignTop); } break; case 'I': // Minimize @@ -166,7 +166,7 @@ void MalloryClient::addButtons(QBoxLayout *layout, const QString &s) { m_button[ButtonMin] = new MalloryButton(this, "minimize", i18n("Minimize"), ButtonMin); connect(m_button[ButtonMin], SIGNAL(clicked()), this, SLOT(minimize())); - layout->addWidget(m_button[ButtonMin], 0, Qt::AlignHCenter | Qt::AlignTop); + layout->addWidget(m_button[ButtonMin], 0, TQt::AlignHCenter | TQt::AlignTop); } break; case 'A': // Maximize @@ -174,7 +174,7 @@ void MalloryClient::addButtons(QBoxLayout *layout, const QString &s) { m_button[ButtonMax] = new MalloryButton(this, "maximize", (maximizeMode()!=MaximizeRestore)?i18n("Minimize"):i18n("Maximize"), ButtonMax); connect(m_button[ButtonMax], SIGNAL(clicked()), this, SLOT(maxButtonPressed())); - layout->addWidget(m_button[ButtonMax], 0, Qt::AlignHCenter | Qt::AlignTop); + layout->addWidget(m_button[ButtonMax], 0, TQt::AlignHCenter | TQt::AlignTop); } break; case 'X': // Close @@ -182,7 +182,7 @@ void MalloryClient::addButtons(QBoxLayout *layout, const QString &s) { m_button[ButtonClose] = new MalloryButton(this, "close", i18n("Close"), ButtonClose); connect(m_button[ButtonClose], SIGNAL(clicked()), this, SLOT(closeWindow())); - layout->addWidget(m_button[ButtonClose], 0, Qt::AlignHCenter | Qt::AlignTop); + layout->addWidget(m_button[ButtonClose], 0, TQt::AlignHCenter | TQt::AlignTop); } break; case 'S': // OnAllDesktops @@ -191,7 +191,7 @@ void MalloryClient::addButtons(QBoxLayout *layout, const QString &s) m_button[ButtonOnAllDesktops] = new MalloryButton(this, "onAllDesktops", isOnAllDesktops() ? i18n("Not On All Desktops") : i18n("On All Desktops"), ButtonOnAllDesktops); m_button[ButtonOnAllDesktops]->setOnAllDesktops(isOnAllDesktops()); connect(m_button[ButtonOnAllDesktops], SIGNAL(clicked()), this, SLOT(toggleOnAllDesktops())); - layout->addWidget(m_button[ButtonOnAllDesktops], 0, Qt::AlignHCenter | Qt::AlignTop); + layout->addWidget(m_button[ButtonOnAllDesktops], 0, TQt::AlignHCenter | TQt::AlignTop); } break; case 'F': // Above all others @@ -199,7 +199,7 @@ void MalloryClient::addButtons(QBoxLayout *layout, const QString &s) { m_button[ButtonAbove] = new MalloryButton(this, "above", i18n("Keep Above Others"), ButtonAbove); connect(m_button[ButtonAbove], SIGNAL(clicked()), this, SLOT(slotKeepAbove())); - layout->addWidget(m_button[ButtonAbove], 0, Qt::AlignHCenter | Qt::AlignTop); + layout->addWidget(m_button[ButtonAbove], 0, TQt::AlignHCenter | TQt::AlignTop); } break; case 'B': // Below all others @@ -207,7 +207,7 @@ void MalloryClient::addButtons(QBoxLayout *layout, const QString &s) { m_button[ButtonBelow] = new MalloryButton(this, "below", i18n("Keep Below Others"), ButtonBelow); connect(m_button[ButtonBelow], SIGNAL(clicked()), this, SLOT(slotKeepBelow())); - layout->addWidget(m_button[ButtonBelow], 0, Qt::AlignHCenter | Qt::AlignTop); + layout->addWidget(m_button[ButtonBelow], 0, TQt::AlignHCenter | TQt::AlignTop); } break; case '_': // Spacer @@ -217,88 +217,88 @@ void MalloryClient::addButtons(QBoxLayout *layout, const QString &s) } } -void MalloryClient::paintEvent(QPaintEvent*) +void MalloryClient::paintEvent(TQPaintEvent*) { if (!MalloryHandler::initialized()) return; bool active = isActive(); - QPainter painter(widget()); + TQPainter painter(widget()); - QColor cottl = options()->color(ColorTitleBar, active); - QColor coblnd = options()->color(ColorTitleBlend, active); - QColor cofrm = options()->color(ColorFrame, active); - QColor cobttn = options()->color(ColorButtonBg, active); + TQColor cottl = options()->color(ColorTitleBar, active); + TQColor coblnd = options()->color(ColorTitleBlend, active); + TQColor cofrm = options()->color(ColorFrame, active); + TQColor cobttn = options()->color(ColorButtonBg, active); - QColorGroup widgetGroup; + TQColorGroup widgetGroup; widgetGroup = widget()->colorGroup(); - QColor coground = widgetGroup.background(); + TQColor coground = widgetGroup.background(); int cfr, cfg, cfb, alr, alg, alb; cofrm.getRgb(&cfr, &cfg, &cfb); coground.getRgb(&alr, &alg, &alb); - QColor aliasing = qRgb((cfr+alr)/2, (cfg+alg)/2, (cfb+alb)/2); + TQColor aliasing = tqRgb((cfr+alr)/2, (cfg+alg)/2, (cfb+alb)/2); - QRect titleRect(m_titleBar->geometry()); - QRect topRect(m_topSpacer->geometry()); - QRect leftRect(m_leftSpacer->geometry()); - QRect rightRect(m_rightSpacer->geometry()); - QRect bottomRect(m_bottomSpacer->geometry()); + TQRect titleRect(m_titleBar->geometry()); + TQRect topRect(m_topSpacer->geometry()); + TQRect leftRect(m_leftSpacer->geometry()); + TQRect rightRect(m_rightSpacer->geometry()); + TQRect bottomRect(m_bottomSpacer->geometry()); - QFontMetrics fm(options()->font(active, false)); + TQFontMetrics fm(options()->font(active, false)); int rr = rightRect.right(); int bb = bottomRect.bottom(); - QRegion mask; - + TQRegion mask; + if(maximizeMode() != MaximizeFull) { - mask = QRegion(0, 0, rr+1, bb+1); + mask = TQRegion(0, 0, rr+1, bb+1); if (MalloryHandler::lessRounded()) { // Remove top left corner - mask -= QRegion(0, 0, 2, 1); - mask -= QRegion(0, 1, 1, 1); + mask -= TQRegion(0, 0, 2, 1); + mask -= TQRegion(0, 1, 1, 1); // Remove top right corner - mask -= QRegion(rr-1, 0, 2, 1); - mask -= QRegion(rr, 1, 1, 1); + mask -= TQRegion(rr-1, 0, 2, 1); + mask -= TQRegion(rr, 1, 1, 1); // Remove bottom left corner - mask -= QRegion(0, bb, 2, 1); - mask -= QRegion(0, bb-1, 1, 1); + mask -= TQRegion(0, bb, 2, 1); + mask -= TQRegion(0, bb-1, 1, 1); // Remove bottom right corner - mask -= QRegion(rr-1, bb, 2, 1); - mask -= QRegion(rr, bb-1, 1, 1); + mask -= TQRegion(rr-1, bb, 2, 1); + mask -= TQRegion(rr, bb-1, 1, 1); } else { // Remove top left corner - mask -= QRegion(0, 0, 5, 1); - mask -= QRegion(0, 1, 3, 1); - mask -= QRegion(0, 2, 2, 1); - mask -= QRegion(0, 3, 1, 2); + mask -= TQRegion(0, 0, 5, 1); + mask -= TQRegion(0, 1, 3, 1); + mask -= TQRegion(0, 2, 2, 1); + mask -= TQRegion(0, 3, 1, 2); // Remove top right corner - mask -= QRegion(rr-4, 0, 5, 1); - mask -= QRegion(rr-2, 1, 3, 1); - mask -= QRegion(rr-1, 2, 2, 1); - mask -= QRegion(rr, 3, 1, 2); + mask -= TQRegion(rr-4, 0, 5, 1); + mask -= TQRegion(rr-2, 1, 3, 1); + mask -= TQRegion(rr-1, 2, 2, 1); + mask -= TQRegion(rr, 3, 1, 2); // Remove bottom left corner - mask -= QRegion(0, bb, 5, 1); - mask -= QRegion(0, bb-1, 3, 1); - mask -= QRegion(0, bb-2, 2, 1); - mask -= QRegion(0, bb-4, 1, 2); + mask -= TQRegion(0, bb, 5, 1); + mask -= TQRegion(0, bb-1, 3, 1); + mask -= TQRegion(0, bb-2, 2, 1); + mask -= TQRegion(0, bb-4, 1, 2); // Remove bottom right corner - mask -= QRegion(rr-4, bb, 5, 1); - mask -= QRegion(rr-2, bb-1, 3, 1); - mask -= QRegion(rr-1, bb-2, 2, 1); - mask -= QRegion(rr, bb-4, 1, 2); + mask -= TQRegion(rr-4, bb, 5, 1); + mask -= TQRegion(rr-2, bb-1, 3, 1); + mask -= TQRegion(rr-1, bb-2, 2, 1); + mask -= TQRegion(rr, bb-4, 1, 2); } } else { - mask = QRegion(0, 0, rightRect.right()+1, bottomRect.bottom()+1); + mask = TQRegion(0, 0, rightRect.right()+1, bottomRect.bottom()+1); } setMask(mask); @@ -306,12 +306,12 @@ void MalloryClient::paintEvent(QPaintEvent*) if (titleRect.width() > 0) // Do we even have to paint the title? { - QPixmap pufferPixmap; + TQPixmap pufferPixmap; pufferPixmap.resize(titleRect.width(), titleRect.height()-1); int flags = AlignAuto | AlignVCenter; - QPainter pufferPainter(&pufferPixmap); + TQPainter pufferPainter(&pufferPixmap); pufferPainter.drawTiledPixmap(pufferPixmap.rect(), active ? *Pixmaps::active_titlebar : *Pixmaps::inactive_titlebar); pufferPainter.setFont(options()->font(active, false)); @@ -341,7 +341,7 @@ void MalloryClient::paintEvent(QPaintEvent*) painter.setPen(coground); painter.drawLine(leftRect.left()+1, titleRect.bottom(), rightRect.right()-1, titleRect.bottom()); - QRect frame; + TQRect frame; // Left frame.setCoords(leftRect.left()+1, titleRect.bottom(), leftRect.right(), bottomRect.bottom()-1); painter.fillRect(frame, coground); @@ -484,16 +484,16 @@ void MalloryClient::paintEvent(QPaintEvent*) } } -void MalloryClient::showEvent(QShowEvent*) +void MalloryClient::showEvent(TQShowEvent*) { widget()->update(); } -void MalloryClient::resizeEvent(QResizeEvent*) +void MalloryClient::resizeEvent(TQResizeEvent*) { if ((widget()->isVisibleToTLW()) && (!widget()->testWFlags(WStaticContents))) { - QRegion region = widget()->rect(); + TQRegion region = widget()->rect(); region.subtract(m_titleBar->geometry()); widget()->erase(region); } @@ -504,7 +504,7 @@ void MalloryClient::captionChange() widget()->repaint(m_titleBar->geometry(), false); } -void MalloryClient::mouseDoubleClickEvent(QMouseEvent *e) +void MalloryClient::mouseDoubleClickEvent(TQMouseEvent *e) { if (m_titleBar->geometry().contains(e->pos())) { @@ -512,17 +512,17 @@ void MalloryClient::mouseDoubleClickEvent(QMouseEvent *e) } } -MalloryClient::Position MalloryClient::mousePosition(const QPoint &point) const +MalloryClient::Position MalloryClient::mousePosition(const TQPoint &point) const { const int corner = 24; MalloryClient::Position pos = PositionCenter; // Often needed coordinates... - QRect titleRect(m_titleBar->geometry()); - QRect topRect(m_topSpacer->geometry()); - QRect leftRect(m_leftSpacer->geometry()); - QRect rightRect(m_rightSpacer->geometry()); - QRect bottomRect(m_bottomSpacer->geometry()); + TQRect titleRect(m_titleBar->geometry()); + TQRect topRect(m_topSpacer->geometry()); + TQRect leftRect(m_leftSpacer->geometry()); + TQRect rightRect(m_rightSpacer->geometry()); + TQRect bottomRect(m_bottomSpacer->geometry()); if ((m_leftButtonSpacer2->geometry().height() > 0) ? (point.y() <= (m_leftButtonSpacer2->geometry().bottom())) : (point.y() <= topRect.bottom())) @@ -641,28 +641,28 @@ void MalloryClient::menuButtonPressed() { if (m_button[ButtonMenu]) { - QPoint pt(m_button[ButtonMenu]->rect().bottomLeft().x(), m_button[ButtonMenu]->rect().bottomLeft().y()); + TQPoint pt(m_button[ButtonMenu]->rect().bottomLeft().x(), m_button[ButtonMenu]->rect().bottomLeft().y()); showWindowMenu(m_button[ButtonMenu]->mapToGlobal(pt)); m_button[ButtonMenu]->setDown(false); } } -QSize MalloryClient::minimumSize() const +TQSize MalloryClient::minimumSize() const { - return QSize(112, 40); + return TQSize(112, 40); } void MalloryClient::borders(int& left, int& right, int& top, int& bottom) const { - m_leftSpacer->changeSize(MalloryHandler::borderSize(), 1, QSizePolicy::Expanding, QSizePolicy::Minimum ); - m_rightSpacer->changeSize(MalloryHandler::borderSize(), 1, QSizePolicy::Expanding, QSizePolicy::Minimum ); + m_leftSpacer->changeSize(MalloryHandler::borderSize(), 1, TQSizePolicy::Expanding, TQSizePolicy::Minimum ); + m_rightSpacer->changeSize(MalloryHandler::borderSize(), 1, TQSizePolicy::Expanding, TQSizePolicy::Minimum ); m_topSpacer->changeSize(1, 1); m_bottomSpacer->changeSize(1, MalloryHandler::borderSize()); m_leftButtonSpacer->changeSize( 3, 1); m_rightButtonSpacer->changeSize( 3, 1); - m_titleBar->changeSize(1, MalloryHandler::titleSize(), QSizePolicy::Expanding, QSizePolicy::Fixed); - m_leftButtonSpacer2->changeSize(1, (MalloryHandler::titleSize()-MalloryHandler::buttonSize())/2, QSizePolicy::Minimum, QSizePolicy::Fixed); - m_rightButtonSpacer2->changeSize(1, (MalloryHandler::titleSize()-MalloryHandler::buttonSize())/2, QSizePolicy::Minimum, QSizePolicy::Fixed); + m_titleBar->changeSize(1, MalloryHandler::titleSize(), TQSizePolicy::Expanding, TQSizePolicy::Fixed); + m_leftButtonSpacer2->changeSize(1, (MalloryHandler::titleSize()-MalloryHandler::buttonSize())/2, TQSizePolicy::Minimum, TQSizePolicy::Fixed); + m_rightButtonSpacer2->changeSize(1, (MalloryHandler::titleSize()-MalloryHandler::buttonSize())/2, TQSizePolicy::Minimum, TQSizePolicy::Fixed); left = right = bottom = MalloryHandler::borderSize(); top = 1 + MalloryHandler::titleSize(); @@ -676,7 +676,7 @@ void MalloryClient::reset(unsigned long) // unsigned long changed // TODO: Implementation } -void MalloryClient::resize(const QSize& s) +void MalloryClient::resize(const TQSize& s) { widget()->resize(s); } |