2007-04-29 17:35:43 +00:00
|
|
|
/*
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2005 Sandro Giessl <sandro@giessl.com>
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
copy of this software and associated documentation files (the "Software"),
|
|
|
|
to deal in the Software without restriction, including without limitation
|
|
|
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
THE AUTHORS OR COPYRIGHT HOLDERS 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.
|
|
|
|
*/
|
|
|
|
|
2007-11-29 14:11:02 +00:00
|
|
|
#include "kcommondecoration.h"
|
2008-05-30 17:47:24 +00:00
|
|
|
#include "kcommondecoration_p.h"
|
2007-11-29 14:11:02 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <QApplication>
|
2012-02-25 17:42:44 +00:00
|
|
|
#include <QBasicTimer>
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <QCursor>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
#include <kdebug.h>
|
|
|
|
|
|
|
|
#include <kapplication.h>
|
|
|
|
#include "kdecorationfactory.h"
|
|
|
|
#include <klocale.h>
|
2008-11-15 03:04:44 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "kcommondecoration.moc"
|
|
|
|
|
2008-01-16 18:13:24 +00:00
|
|
|
/** @addtogroup kdecoration */
|
|
|
|
/** @{ */
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
KCommonDecoration::KCommonDecoration(KDecorationBridge* bridge, KDecorationFactory* factory)
|
2007-11-29 14:11:02 +00:00
|
|
|
: m_previewWidget(0),
|
2007-04-29 17:35:43 +00:00
|
|
|
btnHideMinWidth(200),
|
|
|
|
btnHideLastWidth(0),
|
2007-11-29 14:11:02 +00:00
|
|
|
closing(false),
|
2011-01-30 14:34:42 +00:00
|
|
|
wrapper(new KCommonDecorationWrapper(this, bridge, factory))
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
// sizeof(...) is calculated at compile time
|
|
|
|
memset(m_button, 0, sizeof(KCommonDecorationButton *) * NumButtons);
|
2011-01-30 14:34:42 +00:00
|
|
|
connect(wrapper, SIGNAL(keepAboveChanged(bool)), this, SIGNAL(keepAboveChanged(bool)));
|
|
|
|
connect(wrapper, SIGNAL(keepBelowChanged(bool)), this, SIGNAL(keepBelowChanged(bool)));
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KCommonDecoration::~KCommonDecoration()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int n = 0; n < NumButtons; n++) {
|
2007-04-29 17:35:43 +00:00
|
|
|
if (m_button[n]) delete m_button[n];
|
|
|
|
}
|
|
|
|
delete m_previewWidget;
|
2007-11-29 14:11:02 +00:00
|
|
|
// delete wrapper; - do not do this, this object is actually owned and deleted by the wrapper
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2007-11-26 16:00:21 +00:00
|
|
|
QString KCommonDecoration::defaultButtonsLeft() const
|
2007-11-15 20:13:50 +00:00
|
|
|
{
|
|
|
|
return KDecorationOptions::defaultTitleButtonsLeft();
|
|
|
|
}
|
|
|
|
|
2007-11-26 16:00:21 +00:00
|
|
|
QString KCommonDecoration::defaultButtonsRight() const
|
2007-11-15 20:13:50 +00:00
|
|
|
{
|
|
|
|
return KDecorationOptions::defaultTitleButtonsRight();
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool KCommonDecoration::decorationBehaviour(DecorationBehaviour behaviour) const
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
switch(behaviour) {
|
|
|
|
case DB_MenuClose:
|
|
|
|
return false;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
case DB_WindowMask:
|
|
|
|
return false;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
case DB_ButtonHide:
|
|
|
|
return true;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-11-29 18:37:52 +00:00
|
|
|
int KCommonDecoration::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *button) const
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
switch(lm) {
|
|
|
|
case LM_BorderLeft:
|
|
|
|
case LM_BorderRight:
|
|
|
|
case LM_BorderBottom:
|
|
|
|
case LM_TitleEdgeTop:
|
|
|
|
case LM_TitleEdgeBottom:
|
|
|
|
case LM_TitleEdgeLeft:
|
|
|
|
case LM_TitleEdgeRight:
|
|
|
|
case LM_TitleBorderLeft:
|
|
|
|
case LM_TitleBorderRight:
|
|
|
|
return 5;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
case LM_ButtonWidth:
|
|
|
|
case LM_ButtonHeight:
|
|
|
|
case LM_TitleHeight:
|
|
|
|
return 20;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
case LM_ButtonSpacing:
|
|
|
|
return 5;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
case LM_ButtonMarginTop:
|
|
|
|
return 0;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
case LM_ExplicitButtonSpacer:
|
|
|
|
return layoutMetric(LM_ButtonWidth, respectWindowState, button) / 2; // half button width by default
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::init()
|
|
|
|
{
|
|
|
|
createMainWidget();
|
|
|
|
|
|
|
|
// for flicker-free redraws
|
|
|
|
widget()->setAttribute(Qt::WA_NoSystemBackground);
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
widget()->installEventFilter(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
resetLayout();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
connect(this, SIGNAL(keepAboveChanged(bool)), SLOT(keepAboveChange(bool)));
|
|
|
|
connect(this, SIGNAL(keepBelowChanged(bool)), SLOT(keepBelowChange(bool)));
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
updateCaption();
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::reset(unsigned long changed)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
if (changed & SettingButtons) {
|
|
|
|
resetLayout();
|
|
|
|
widget()->update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QRegion KCommonDecoration::cornerShape(WindowCorner)
|
|
|
|
{
|
|
|
|
return QRegion();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::updateCaption()
|
|
|
|
{
|
|
|
|
// This should be reimplemented in decorations for better efficiency
|
|
|
|
widget()->update();
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::borders(int& left, int& right, int& top, int& bottom) const
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
left = layoutMetric(LM_BorderLeft);
|
|
|
|
right = layoutMetric(LM_BorderRight);
|
|
|
|
bottom = layoutMetric(LM_BorderBottom);
|
|
|
|
top = layoutMetric(LM_TitleHeight) +
|
2011-01-30 14:34:42 +00:00
|
|
|
layoutMetric(LM_TitleEdgeTop) +
|
|
|
|
layoutMetric(LM_TitleEdgeBottom);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
updateLayout(); // TODO!! don't call every time we are in ::borders
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::updateLayout() const
|
|
|
|
{
|
2009-05-04 22:35:33 +00:00
|
|
|
const int paddingLeft = layoutMetric(LM_OuterPaddingLeft);
|
|
|
|
const int paddingTop = layoutMetric(LM_OuterPaddingTop);
|
|
|
|
const int paddingRight = layoutMetric(LM_OuterPaddingRight);
|
|
|
|
const int paddingBottom = layoutMetric(LM_OuterPaddingBottom);
|
|
|
|
|
|
|
|
QRect r = widget()->rect().adjusted(paddingLeft, paddingTop, -paddingRight, -paddingBottom);
|
2007-04-29 17:35:43 +00:00
|
|
|
int r_x, r_y, r_x2, r_y2;
|
|
|
|
r.getCoords(&r_x, &r_y, &r_x2, &r_y2);
|
|
|
|
|
|
|
|
// layout preview widget
|
|
|
|
if (m_previewWidget) {
|
|
|
|
const int borderLeft = layoutMetric(LM_BorderLeft);
|
|
|
|
const int borderRight = layoutMetric(LM_BorderRight);
|
|
|
|
const int borderBottom = layoutMetric(LM_BorderBottom);
|
|
|
|
const int titleHeight = layoutMetric(LM_TitleHeight);
|
|
|
|
const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop);
|
|
|
|
const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom);
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int left = r_x + borderLeft;
|
|
|
|
int top = r_y + titleEdgeTop + titleHeight + titleEdgeBottom;
|
|
|
|
int width = r_x2 - borderRight - left + 1;
|
|
|
|
int height = r_y2 - borderBottom - top + 1;
|
2007-04-29 17:35:43 +00:00
|
|
|
m_previewWidget->setGeometry(left, top, width, height);
|
2011-01-30 14:34:42 +00:00
|
|
|
moveWidget(left, top, m_previewWidget);
|
2007-04-29 17:35:43 +00:00
|
|
|
resizeWidget(width, height, m_previewWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
// resize buttons...
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int n = 0; n < NumButtons; n++) {
|
2007-04-29 17:35:43 +00:00
|
|
|
if (m_button[n]) {
|
|
|
|
QSize newSize = QSize(layoutMetric(LM_ButtonWidth, true, m_button[n]),
|
2011-01-30 14:34:42 +00:00
|
|
|
layoutMetric(LM_ButtonHeight, true, m_button[n]));
|
|
|
|
if (newSize != m_button[n]->size())
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[n]->setSize(newSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// layout buttons
|
|
|
|
int y = r_y + layoutMetric(LM_TitleEdgeTop) + layoutMetric(LM_ButtonMarginTop);
|
|
|
|
if (m_buttonsLeft.count() > 0) {
|
|
|
|
const int buttonSpacing = layoutMetric(LM_ButtonSpacing);
|
|
|
|
int x = r_x + layoutMetric(LM_TitleEdgeLeft);
|
|
|
|
for (ButtonContainer::const_iterator it = m_buttonsLeft.begin(); it != m_buttonsLeft.end(); ++it) {
|
|
|
|
bool elementLayouted = false;
|
|
|
|
if (*it) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!(*it)->isHidden()) {
|
|
|
|
moveWidget(x, y, *it);
|
|
|
|
x += layoutMetric(LM_ButtonWidth, true, qobject_cast<KCommonDecorationButton*>(*it));
|
2007-04-29 17:35:43 +00:00
|
|
|
elementLayouted = true;
|
|
|
|
}
|
|
|
|
} else {
|
2011-01-30 14:34:42 +00:00
|
|
|
x += layoutMetric(LM_ExplicitButtonSpacer);
|
2007-04-29 17:35:43 +00:00
|
|
|
elementLayouted = true;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (elementLayouted && it != m_buttonsLeft.end())
|
2007-04-29 17:35:43 +00:00
|
|
|
x += buttonSpacing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_buttonsRight.count() > 0) {
|
2011-01-30 14:34:42 +00:00
|
|
|
const int titleEdgeRightLeft = r_x2 - layoutMetric(LM_TitleEdgeRight) + 1;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
const int buttonSpacing = layoutMetric(LM_ButtonSpacing);
|
|
|
|
int x = titleEdgeRightLeft - buttonContainerWidth(m_buttonsRight);
|
|
|
|
for (ButtonContainer::const_iterator it = m_buttonsRight.begin(); it != m_buttonsRight.end(); ++it) {
|
|
|
|
bool elementLayouted = false;
|
|
|
|
if (*it) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!(*it)->isHidden()) {
|
|
|
|
moveWidget(x, y, *it);
|
|
|
|
x += layoutMetric(LM_ButtonWidth, true, qobject_cast<KCommonDecorationButton*>(*it));;
|
2007-04-29 17:35:43 +00:00
|
|
|
elementLayouted = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
x += layoutMetric(LM_ExplicitButtonSpacer);
|
|
|
|
elementLayouted = true;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (elementLayouted && it != m_buttonsRight.end())
|
2007-04-29 17:35:43 +00:00
|
|
|
x += buttonSpacing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::updateButtons() const
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int n = 0; n < NumButtons; n++)
|
2007-04-29 17:35:43 +00:00
|
|
|
if (m_button[n]) m_button[n]->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::resetButtons() const
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int n = 0; n < NumButtons; n++)
|
2007-04-29 17:35:43 +00:00
|
|
|
if (m_button[n]) m_button[n]->reset(KCommonDecorationButton::ManualReset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::resetLayout()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int n = 0; n < NumButtons; n++) {
|
2007-04-29 17:35:43 +00:00
|
|
|
if (m_button[n]) {
|
|
|
|
delete m_button[n];
|
|
|
|
m_button[n] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_buttonsLeft.clear();
|
|
|
|
m_buttonsRight.clear();
|
|
|
|
|
|
|
|
delete m_previewWidget;
|
|
|
|
m_previewWidget = 0;
|
|
|
|
|
|
|
|
// shown instead of the window contents in decoration previews
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isPreview()) {
|
|
|
|
m_previewWidget = new QLabel(i18n("<center><b>%1</b></center>", visibleName()), widget());
|
2007-09-01 20:04:10 +00:00
|
|
|
m_previewWidget->setAutoFillBackground(true);
|
2007-04-29 17:35:43 +00:00
|
|
|
m_previewWidget->show();
|
2009-08-21 07:25:58 +00:00
|
|
|
|
|
|
|
// fix double deletion, see buttonDestroyed()
|
|
|
|
connect(m_previewWidget, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*)));
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
addButtons(m_buttonsLeft,
|
|
|
|
options()->customButtonPositions() ? options()->titleButtonsLeft() : defaultButtonsLeft(),
|
|
|
|
true);
|
|
|
|
addButtons(m_buttonsRight,
|
|
|
|
options()->customButtonPositions() ? options()->titleButtonsRight() : defaultButtonsRight(),
|
|
|
|
false);
|
|
|
|
|
|
|
|
updateLayout();
|
|
|
|
|
|
|
|
const int minTitleBarWidth = 35;
|
2011-01-30 14:34:42 +00:00
|
|
|
btnHideMinWidth = buttonContainerWidth(m_buttonsLeft, true) + buttonContainerWidth(m_buttonsRight, true) +
|
|
|
|
layoutMetric(LM_TitleEdgeLeft, false) + layoutMetric(LM_TitleEdgeRight, false) +
|
|
|
|
layoutMetric(LM_TitleBorderLeft, false) + layoutMetric(LM_TitleBorderRight, false) +
|
|
|
|
minTitleBarWidth;
|
2007-04-29 17:35:43 +00:00
|
|
|
btnHideLastWidth = 0;
|
|
|
|
}
|
|
|
|
|
2009-08-21 07:25:58 +00:00
|
|
|
void KCommonDecoration::objDestroyed(QObject *obj)
|
|
|
|
{
|
|
|
|
// make sure button deletion is reflected in the m_button[] array.
|
|
|
|
// this makes sure that m_button[]-entries are not destroyed
|
|
|
|
// twice, first in their KCommonDecorationButton/QObject
|
|
|
|
// destructor (button objects are parented with the decroation
|
|
|
|
// widget in KCommonDecoration constructor), and then in
|
|
|
|
// ~KCommonDecoration. a QPointer<KCommonDecorationButton> would
|
|
|
|
// have been the better approach, but changing the button array
|
|
|
|
// would have been ABI incompatible & would have required creation
|
|
|
|
// of kcommondecorationprivate instance.
|
|
|
|
// the same applies to m_previewWidget.
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int n = 0; n < NumButtons; n++) {
|
2009-08-21 07:25:58 +00:00
|
|
|
if (m_button[n] == obj) {
|
|
|
|
m_button[n] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (obj == m_previewWidget)
|
2009-08-21 07:25:58 +00:00
|
|
|
m_previewWidget = 0;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
int KCommonDecoration::buttonsLeftWidth() const
|
|
|
|
{
|
|
|
|
return buttonContainerWidth(m_buttonsLeft);
|
|
|
|
}
|
|
|
|
|
|
|
|
int KCommonDecoration::buttonsRightWidth() const
|
|
|
|
{
|
|
|
|
return buttonContainerWidth(m_buttonsRight);
|
|
|
|
}
|
|
|
|
|
|
|
|
int KCommonDecoration::buttonContainerWidth(const ButtonContainer &btnContainer, bool countHidden) const
|
|
|
|
{
|
|
|
|
int explicitSpacer = layoutMetric(LM_ExplicitButtonSpacer);
|
|
|
|
|
|
|
|
int shownElementsCount = 0;
|
|
|
|
|
|
|
|
int w = 0;
|
|
|
|
for (ButtonContainer::const_iterator it = btnContainer.begin(); it != btnContainer.end(); ++it) {
|
|
|
|
if (*it) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (countHidden || !(*it)->isHidden()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
w += (*it)->width();
|
|
|
|
++shownElementsCount;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
w += explicitSpacer;
|
|
|
|
++shownElementsCount;
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
w += layoutMetric(LM_ButtonSpacing) * (shownElementsCount - 1);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::addButtons(ButtonContainer &btnContainer, const QString& s, bool isLeft)
|
|
|
|
{
|
|
|
|
if (s.length() > 0) {
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int n = 0; n < s.length(); n++) {
|
2007-04-29 17:35:43 +00:00
|
|
|
KCommonDecorationButton *btn = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
switch(s[n].toAscii()) {
|
|
|
|
case 'M': // Menu button
|
|
|
|
if (!m_button[MenuButton]) {
|
|
|
|
btn = createButton(MenuButton);
|
|
|
|
if (!btn) break;
|
|
|
|
btn->setTipText(i18n("Menu"));
|
|
|
|
btn->setRealizeButtons(Qt::LeftButton | Qt::RightButton);
|
|
|
|
connect(btn, SIGNAL(pressed()), SLOT(menuButtonPressed()));
|
|
|
|
connect(btn, SIGNAL(released()), this, SLOT(menuButtonReleased()));
|
|
|
|
|
|
|
|
// fix double deletion, see objDestroyed()
|
|
|
|
connect(btn, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*)));
|
|
|
|
|
|
|
|
m_button[MenuButton] = btn;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'S': // OnAllDesktops button
|
|
|
|
if (!m_button[OnAllDesktopsButton]) {
|
|
|
|
btn = createButton(OnAllDesktopsButton);
|
|
|
|
if (!btn) break;
|
|
|
|
const bool oad = isOnAllDesktops();
|
|
|
|
btn->setTipText(oad ? i18n("Not on all desktops") : i18n("On all desktops"));
|
|
|
|
btn->setToggleButton(true);
|
|
|
|
btn->setOn(oad);
|
|
|
|
connect(btn, SIGNAL(clicked()), SLOT(toggleOnAllDesktops()));
|
|
|
|
|
|
|
|
// fix double deletion, see objDestroyed()
|
|
|
|
connect(btn, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*)));
|
|
|
|
|
|
|
|
m_button[OnAllDesktopsButton] = btn;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'H': // Help button
|
|
|
|
if ((!m_button[HelpButton]) && providesContextHelp()) {
|
|
|
|
btn = createButton(HelpButton);
|
|
|
|
if (!btn) break;
|
|
|
|
btn->setTipText(i18n("Help"));
|
|
|
|
connect(btn, SIGNAL(clicked()), SLOT(showContextHelp()));
|
|
|
|
|
|
|
|
// fix double deletion, see objDestroyed()
|
|
|
|
connect(btn, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*)));
|
|
|
|
|
|
|
|
m_button[HelpButton] = btn;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'I': // Minimize button
|
|
|
|
if ((!m_button[MinButton]) && isMinimizable()) {
|
|
|
|
btn = createButton(MinButton);
|
|
|
|
if (!btn) break;
|
|
|
|
btn->setTipText(i18n("Minimize"));
|
|
|
|
connect(btn, SIGNAL(clicked()), SLOT(minimize()));
|
|
|
|
|
|
|
|
// fix double deletion, see objDestroyed()
|
|
|
|
connect(btn, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*)));
|
|
|
|
|
|
|
|
m_button[MinButton] = btn;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'A': // Maximize button
|
|
|
|
if ((!m_button[MaxButton]) && isMaximizable()) {
|
|
|
|
btn = createButton(MaxButton);
|
|
|
|
if (!btn) break;
|
|
|
|
btn->setRealizeButtons(Qt::LeftButton | Qt::MidButton | Qt::RightButton);
|
|
|
|
const bool max = maximizeMode() == MaximizeFull;
|
|
|
|
btn->setTipText(max ? i18n("Restore") : i18n("Maximize"));
|
|
|
|
btn->setToggleButton(true);
|
|
|
|
btn->setOn(max);
|
|
|
|
connect(btn, SIGNAL(clicked()), SLOT(slotMaximize()));
|
|
|
|
|
|
|
|
// fix double deletion, see objDestroyed()
|
|
|
|
connect(btn, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*)));
|
|
|
|
|
|
|
|
m_button[MaxButton] = btn;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'X': // Close button
|
|
|
|
if ((!m_button[CloseButton]) && isCloseable()) {
|
|
|
|
btn = createButton(CloseButton);
|
|
|
|
if (!btn) break;
|
|
|
|
btn->setTipText(i18n("Close"));
|
|
|
|
connect(btn, SIGNAL(clicked()), SLOT(closeWindow()));
|
|
|
|
|
|
|
|
// fix double deletion, see objDestroyed()
|
|
|
|
connect(btn, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*)));
|
|
|
|
|
|
|
|
m_button[CloseButton] = btn;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'F': // AboveButton button
|
|
|
|
if (!m_button[AboveButton]) {
|
|
|
|
btn = createButton(AboveButton);
|
|
|
|
if (!btn) break;
|
|
|
|
bool above = keepAbove();
|
|
|
|
btn->setTipText(above ? i18n("Do not keep above others") : i18n("Keep above others"));
|
|
|
|
btn->setToggleButton(true);
|
|
|
|
btn->setOn(above);
|
|
|
|
connect(btn, SIGNAL(clicked()), SLOT(slotKeepAbove()));
|
|
|
|
|
|
|
|
// fix double deletion, see objDestroyed()
|
|
|
|
connect(btn, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*)));
|
|
|
|
|
|
|
|
m_button[AboveButton] = btn;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'B': // BelowButton button
|
|
|
|
if (!m_button[BelowButton]) {
|
|
|
|
btn = createButton(BelowButton);
|
|
|
|
if (!btn) break;
|
|
|
|
bool below = keepBelow();
|
|
|
|
btn->setTipText(below ? i18n("Do not keep below others") : i18n("Keep below others"));
|
|
|
|
btn->setToggleButton(true);
|
|
|
|
btn->setOn(below);
|
|
|
|
connect(btn, SIGNAL(clicked()), SLOT(slotKeepBelow()));
|
|
|
|
|
|
|
|
// fix double deletion, see objDestroyed()
|
|
|
|
connect(btn, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*)));
|
|
|
|
|
|
|
|
m_button[BelowButton] = btn;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'L': // Shade button
|
|
|
|
if ((!m_button[ShadeButton]) && isShadeable()) {
|
|
|
|
btn = createButton(ShadeButton);
|
|
|
|
if (!btn) break;
|
|
|
|
bool shaded = isSetShade();
|
|
|
|
btn->setTipText(shaded ? i18n("Unshade") : i18n("Shade"));
|
|
|
|
btn->setToggleButton(true);
|
|
|
|
btn->setOn(shaded);
|
|
|
|
connect(btn, SIGNAL(clicked()), SLOT(slotShade()));
|
|
|
|
|
|
|
|
// fix double deletion, see objDestroyed()
|
|
|
|
connect(btn, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*)));
|
|
|
|
|
|
|
|
m_button[ShadeButton] = btn;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '_': // Spacer item
|
|
|
|
btnContainer.append(0);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (btn) {
|
|
|
|
btn->setLeft(isLeft);
|
2011-01-30 14:34:42 +00:00
|
|
|
btn->setSize(QSize(layoutMetric(LM_ButtonWidth, true, btn), layoutMetric(LM_ButtonHeight, true, btn)));
|
2007-04-29 17:35:43 +00:00
|
|
|
btn->show();
|
|
|
|
btnContainer.append(btn);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::calcHiddenButtons()
|
|
|
|
{
|
|
|
|
if (width() == btnHideLastWidth)
|
|
|
|
return;
|
|
|
|
|
|
|
|
btnHideLastWidth = width();
|
|
|
|
|
|
|
|
//Hide buttons in the following order:
|
|
|
|
KCommonDecorationButton* btnArray[] = { m_button[HelpButton], m_button[ShadeButton], m_button[BelowButton],
|
2011-01-30 14:34:42 +00:00
|
|
|
m_button[AboveButton], m_button[OnAllDesktopsButton], m_button[MaxButton],
|
|
|
|
m_button[MinButton], m_button[MenuButton], m_button[CloseButton]
|
|
|
|
};
|
|
|
|
const int buttonsCount = sizeof(btnArray) / sizeof(btnArray[ 0 ]);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int current_width = width();
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
// Hide buttons
|
2011-01-30 14:34:42 +00:00
|
|
|
while (current_width < btnHideMinWidth && count < buttonsCount) {
|
|
|
|
if (btnArray[count]) {
|
2007-04-29 17:35:43 +00:00
|
|
|
current_width += btnArray[count]->width();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (btnArray[count]->isVisible())
|
2007-04-29 17:35:43 +00:00
|
|
|
btnArray[count]->hide();
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
// Show the rest of the buttons...
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int i = count; i < buttonsCount; i++) {
|
|
|
|
if (btnArray[i]) {
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (! btnArray[i]->isHidden())
|
2007-04-29 17:35:43 +00:00
|
|
|
break; // all buttons shown...
|
|
|
|
|
|
|
|
btnArray[i]->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::show()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (decorationBehaviour(DB_ButtonHide))
|
2007-04-29 17:35:43 +00:00
|
|
|
calcHiddenButtons();
|
|
|
|
widget()->show();
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::resize(const QSize& s)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
widget()->resize(s);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QSize KCommonDecoration::minimumSize() const
|
|
|
|
{
|
|
|
|
const int minWidth = qMax(layoutMetric(LM_TitleEdgeLeft), layoutMetric(LM_BorderLeft))
|
2011-01-30 14:34:42 +00:00
|
|
|
+ qMax(layoutMetric(LM_TitleEdgeRight), layoutMetric(LM_BorderRight))
|
|
|
|
+ layoutMetric(LM_TitleBorderLeft) + layoutMetric(LM_TitleBorderRight);
|
2007-04-29 17:35:43 +00:00
|
|
|
return QSize(minWidth,
|
2011-01-30 14:34:42 +00:00
|
|
|
layoutMetric(LM_TitleEdgeTop) + layoutMetric(LM_TitleHeight)
|
|
|
|
+ layoutMetric(LM_TitleEdgeBottom)
|
|
|
|
+ layoutMetric(LM_BorderBottom));
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::maximizeChange()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_button[MaxButton]) {
|
|
|
|
m_button[MaxButton]->setOn(maximizeMode() == MaximizeFull);
|
|
|
|
m_button[MaxButton]->setTipText((maximizeMode() != MaximizeFull) ?
|
|
|
|
i18n("Maximize")
|
|
|
|
: i18n("Restore"));
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[MaxButton]->reset(KCommonDecorationButton::StateChange);
|
|
|
|
}
|
|
|
|
updateWindowShape();
|
|
|
|
widget()->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::desktopChange()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_button[OnAllDesktopsButton]) {
|
|
|
|
m_button[OnAllDesktopsButton]->setOn(isOnAllDesktops());
|
|
|
|
m_button[OnAllDesktopsButton]->setTipText(isOnAllDesktops() ?
|
2007-04-29 17:35:43 +00:00
|
|
|
i18n("Not on all desktops")
|
2011-01-30 14:34:42 +00:00
|
|
|
: i18n("On all desktops"));
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[OnAllDesktopsButton]->reset(KCommonDecorationButton::StateChange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::shadeChange()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_button[ShadeButton]) {
|
2007-04-29 17:35:43 +00:00
|
|
|
bool shaded = isSetShade();
|
2011-01-30 14:34:42 +00:00
|
|
|
m_button[ShadeButton]->setOn(shaded);
|
|
|
|
m_button[ShadeButton]->setTipText(shaded ?
|
|
|
|
i18n("Unshade")
|
|
|
|
: i18n("Shade"));
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[ShadeButton]->reset(KCommonDecorationButton::StateChange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::iconChange()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_button[MenuButton]) {
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[MenuButton]->update();
|
|
|
|
m_button[MenuButton]->reset(KCommonDecorationButton::IconChange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::activeChange()
|
|
|
|
{
|
|
|
|
updateButtons();
|
|
|
|
widget()->update(); // do something similar to updateCaption here
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::captionChange()
|
|
|
|
{
|
|
|
|
updateCaption();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::keepAboveChange(bool above)
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_button[AboveButton]) {
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[AboveButton]->setOn(above);
|
2011-01-30 14:34:42 +00:00
|
|
|
m_button[AboveButton]->setTipText(above ? i18n("Do not keep above others") : i18n("Keep above others"));
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[AboveButton]->reset(KCommonDecorationButton::StateChange);
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_button[BelowButton] && m_button[BelowButton]->isChecked()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[BelowButton]->setOn(false);
|
2011-01-30 14:34:42 +00:00
|
|
|
m_button[BelowButton]->setTipText(i18n("Keep below others"));
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[BelowButton]->reset(KCommonDecorationButton::StateChange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::keepBelowChange(bool below)
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_button[BelowButton]) {
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[BelowButton]->setOn(below);
|
2011-01-30 14:34:42 +00:00
|
|
|
m_button[BelowButton]->setTipText(below ? i18n("Do not keep below others") : i18n("Keep below others"));
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[BelowButton]->reset(KCommonDecorationButton::StateChange);
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_button[AboveButton] && m_button[AboveButton]->isChecked()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[AboveButton]->setOn(false);
|
2011-01-30 14:34:42 +00:00
|
|
|
m_button[AboveButton]->setTipText(i18n("Keep above others"));
|
2007-04-29 17:35:43 +00:00
|
|
|
m_button[AboveButton]->reset(KCommonDecorationButton::StateChange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::slotMaximize()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_button[MaxButton]) {
|
|
|
|
maximize(m_button[MaxButton]->lastMousePress());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::slotShade()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
setShade(!isSetShade());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::slotKeepAbove()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
setKeepAbove(!keepAbove());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::slotKeepBelow()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
setKeepBelow(!keepBelow());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2012-02-25 17:42:44 +00:00
|
|
|
static QBasicTimer* timer = NULL;
|
2007-04-29 17:35:43 +00:00
|
|
|
void KCommonDecoration::menuButtonPressed()
|
|
|
|
{
|
2012-02-25 17:42:44 +00:00
|
|
|
if (decorationBehaviour(DB_MenuClose)) {
|
|
|
|
if (timer == NULL) {
|
|
|
|
timer = new QBasicTimer();
|
|
|
|
}
|
|
|
|
if (!timer->isActive()) {
|
|
|
|
timer->start(150, this);
|
|
|
|
}
|
|
|
|
// double click behavior
|
|
|
|
static QTime* t = NULL;
|
|
|
|
static KCommonDecoration* lastClient = NULL;
|
|
|
|
if (t == NULL) {
|
|
|
|
t = new QTime;
|
|
|
|
}
|
|
|
|
if (lastClient == this && t->elapsed() <= QApplication::doubleClickInterval()) {
|
|
|
|
closing = true;
|
|
|
|
} else {
|
|
|
|
lastClient = this;
|
|
|
|
t->start();
|
|
|
|
}
|
|
|
|
} else {
|
2007-04-29 17:35:43 +00:00
|
|
|
KDecorationFactory* f = factory();
|
2012-02-25 17:42:44 +00:00
|
|
|
doShowWindowMenu();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!f->exists(decoration())) // 'this' was deleted
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
m_button[MenuButton]->setDown(false);
|
2012-02-25 17:42:44 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::menuButtonReleased()
|
|
|
|
{
|
2012-02-25 17:42:44 +00:00
|
|
|
if (closing) {
|
|
|
|
if (timer && timer->isActive()) {
|
|
|
|
timer->stop();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
closeWindow();
|
2012-02-25 17:42:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::timerEvent(QTimerEvent *event)
|
|
|
|
{
|
|
|
|
if (timer && event->timerId() == timer->timerId()) {
|
|
|
|
timer->stop();
|
2012-08-26 21:18:33 +00:00
|
|
|
if (closing || !m_button[MenuButton]->isDown()) {
|
2012-02-25 17:42:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-08-26 21:18:33 +00:00
|
|
|
closing = false;
|
2012-02-25 17:42:44 +00:00
|
|
|
doShowWindowMenu();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QObject::timerEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::doShowWindowMenu()
|
|
|
|
{
|
|
|
|
QRect menuRect = m_button[MenuButton]->rect();
|
|
|
|
QPoint menutop = m_button[MenuButton]->mapToGlobal(menuRect.topLeft());
|
|
|
|
QPoint menubottom = m_button[MenuButton]->mapToGlobal(menuRect.bottomRight()) + QPoint(0, 2);
|
|
|
|
showWindowMenu(QRect(menutop, menubottom));
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::resizeEvent(QResizeEvent */*e*/)
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (decorationBehaviour(DB_ButtonHide))
|
2007-04-29 17:35:43 +00:00
|
|
|
calcHiddenButtons();
|
|
|
|
|
|
|
|
updateLayout();
|
|
|
|
|
|
|
|
updateWindowShape();
|
|
|
|
// FIXME: don't update() here! this would result in two paintEvent()s
|
|
|
|
// because there is already "something" else triggering the repaint...
|
|
|
|
// widget()->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::moveWidget(int x, int y, QWidget *widget) const
|
|
|
|
{
|
|
|
|
QPoint p = widget->pos();
|
|
|
|
int oldX = p.y();
|
|
|
|
int oldY = p.x();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (x != oldX || y != oldY)
|
|
|
|
widget->move(x, y);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::resizeWidget(int w, int h, QWidget *widget) const
|
|
|
|
{
|
|
|
|
QSize s = widget->size();
|
|
|
|
int oldW = s.width();
|
|
|
|
int oldH = s.height();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (w != oldW || h != oldH)
|
|
|
|
widget->resize(w, h);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::mouseDoubleClickEvent(QMouseEvent *e)
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (e->button() != Qt::LeftButton)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
|
2009-06-11 11:49:50 +00:00
|
|
|
int tb = layoutMetric(LM_TitleEdgeTop) + layoutMetric(LM_TitleHeight) +
|
2011-01-30 14:34:42 +00:00
|
|
|
layoutMetric(LM_TitleEdgeBottom) + layoutMetric(LM_OuterPaddingTop);
|
2007-04-29 17:35:43 +00:00
|
|
|
// when shaded, react on double clicks everywhere to make it easier to unshade. otherwise
|
|
|
|
// react only on double clicks in the title bar region...
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isSetShade() || e->pos().y() <= tb)
|
2007-04-29 17:35:43 +00:00
|
|
|
titlebarDblClickOperation();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::wheelEvent(QWheelEvent *e)
|
|
|
|
{
|
2009-06-11 11:49:50 +00:00
|
|
|
int tb = layoutMetric(LM_TitleEdgeTop) + layoutMetric(LM_TitleHeight) +
|
2011-01-30 14:34:42 +00:00
|
|
|
layoutMetric(LM_TitleEdgeBottom) + layoutMetric(LM_OuterPaddingTop);
|
|
|
|
if (isSetShade() || e->pos().y() <= tb)
|
|
|
|
titlebarMouseWheelOperation(e->delta());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KCommonDecoration::Position KCommonDecoration::mousePosition(const QPoint &point) const
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
const int corner = 18 + 3 * layoutMetric(LM_BorderBottom, false) / 2;
|
2007-04-29 17:35:43 +00:00
|
|
|
Position pos = PositionCenter;
|
|
|
|
|
2009-05-04 22:35:33 +00:00
|
|
|
const int paddingLeft = layoutMetric(LM_OuterPaddingLeft);
|
|
|
|
const int paddingTop = layoutMetric(LM_OuterPaddingTop);
|
|
|
|
const int paddingRight = layoutMetric(LM_OuterPaddingRight);
|
|
|
|
const int paddingBottom = layoutMetric(LM_OuterPaddingBottom);
|
|
|
|
|
|
|
|
QRect r = widget()->rect().adjusted(paddingLeft, paddingTop, -paddingRight, -paddingBottom);
|
2007-04-29 17:35:43 +00:00
|
|
|
int r_x, r_y, r_x2, r_y2;
|
|
|
|
r.getCoords(&r_x, &r_y, &r_x2, &r_y2);
|
|
|
|
int p_x = point.x();
|
|
|
|
int p_y = point.y();
|
|
|
|
const int borderLeft = layoutMetric(LM_BorderLeft);
|
|
|
|
// const int borderRight = layoutMetric(LM_BorderRight);
|
|
|
|
const int borderBottom = layoutMetric(LM_BorderBottom);
|
|
|
|
const int titleHeight = layoutMetric(LM_TitleHeight);
|
|
|
|
const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop);
|
|
|
|
const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom);
|
|
|
|
const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
|
|
|
|
const int titleEdgeRight = layoutMetric(LM_TitleEdgeRight);
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
const int borderBottomTop = r_y2 - borderBottom + 1;
|
|
|
|
const int borderLeftRight = r_x + borderLeft - 1;
|
2007-04-29 17:35:43 +00:00
|
|
|
// const int borderRightLeft = r_x2-borderRight+1;
|
2011-01-30 14:34:42 +00:00
|
|
|
const int titleEdgeLeftRight = r_x + titleEdgeLeft - 1;
|
|
|
|
const int titleEdgeRightLeft = r_x2 - titleEdgeRight + 1;
|
|
|
|
const int titleEdgeBottomBottom = r_y + titleEdgeTop + titleHeight + titleEdgeBottom - 1;
|
|
|
|
const int titleEdgeTopBottom = r_y + titleEdgeTop - 1;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
if (p_y <= titleEdgeTopBottom) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (p_x <= r_x + corner)
|
2007-04-29 17:35:43 +00:00
|
|
|
pos = PositionTopLeft;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p_x >= r_x2 - corner)
|
2007-04-29 17:35:43 +00:00
|
|
|
pos = PositionTopRight;
|
|
|
|
else
|
|
|
|
pos = PositionTop;
|
|
|
|
} else if (p_y <= titleEdgeBottomBottom) {
|
|
|
|
if (p_x <= titleEdgeLeftRight)
|
|
|
|
pos = PositionTopLeft;
|
|
|
|
else if (p_x >= titleEdgeRightLeft)
|
|
|
|
pos = PositionTopRight;
|
|
|
|
else
|
|
|
|
pos = PositionCenter; // title bar
|
|
|
|
} else if (p_y < borderBottomTop) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (p_y < r_y2 - corner) {
|
2007-04-29 17:35:43 +00:00
|
|
|
if (p_x <= borderLeftRight)
|
|
|
|
pos = PositionLeft;
|
|
|
|
else
|
|
|
|
pos = PositionRight;
|
|
|
|
} else {
|
|
|
|
if (p_x <= borderLeftRight)
|
|
|
|
pos = PositionBottomLeft;
|
|
|
|
else
|
|
|
|
pos = PositionBottomRight;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else if (p_y >= borderBottomTop) {
|
|
|
|
if (p_x <= r_x + corner)
|
2007-04-29 17:35:43 +00:00
|
|
|
pos = PositionBottomLeft;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p_x >= r_x2 - corner)
|
2007-04-29 17:35:43 +00:00
|
|
|
pos = PositionBottomRight;
|
|
|
|
else
|
|
|
|
pos = PositionBottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecoration::updateWindowShape()
|
|
|
|
{
|
|
|
|
// don't mask the widget...
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!decorationBehaviour(DB_WindowMask))
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
int w = widget()->width();
|
|
|
|
int h = widget()->height();
|
|
|
|
|
|
|
|
QRegion mask(0, 0, w, h);
|
|
|
|
|
2009-09-17 13:08:01 +00:00
|
|
|
// Remove corners (if subclass wants to.)
|
|
|
|
mask -= cornerShape(WC_TopLeft);
|
|
|
|
mask -= cornerShape(WC_TopRight);
|
|
|
|
mask -= cornerShape(WC_BottomLeft);
|
|
|
|
mask -= cornerShape(WC_BottomRight);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
setMask(mask);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool KCommonDecoration::eventFilter(QObject* o, QEvent* e)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (o != widget())
|
|
|
|
return false;
|
|
|
|
switch(e->type()) {
|
|
|
|
case QEvent::Resize:
|
|
|
|
resizeEvent(static_cast<QResizeEvent*>(e));
|
|
|
|
return true;
|
|
|
|
case QEvent::Paint:
|
|
|
|
paintEvent(static_cast< QPaintEvent* >(e));
|
|
|
|
return true;
|
|
|
|
case QEvent::MouseButtonDblClick:
|
|
|
|
mouseDoubleClickEvent(static_cast< QMouseEvent* >(e));
|
|
|
|
return true;
|
|
|
|
case QEvent::MouseButtonPress:
|
|
|
|
processMousePressEvent(static_cast< QMouseEvent* >(e));
|
|
|
|
return true;
|
|
|
|
case QEvent::Wheel:
|
|
|
|
wheelEvent(static_cast< QWheelEvent* >(e));
|
|
|
|
return true;
|
|
|
|
default:
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const int SUPPORTED_WINDOW_TYPES_MASK = NET::NormalMask | NET::DesktopMask | NET::DockMask
|
2011-01-30 14:34:42 +00:00
|
|
|
| NET::ToolbarMask | NET::MenuMask | NET::DialogMask /*| NET::OverrideMask*/ | NET::TopMenuMask
|
|
|
|
| NET::UtilityMask | NET::SplashMask;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KCommonDecoration::isToolWindow() const
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
NET::WindowType type = windowType(SUPPORTED_WINDOW_TYPES_MASK);
|
|
|
|
return ((type == NET::Toolbar) || (type == NET::Utility) || (type == NET::Menu));
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QRect KCommonDecoration::titleRect() const
|
|
|
|
{
|
2009-05-04 22:35:33 +00:00
|
|
|
const int pl = layoutMetric(LM_OuterPaddingLeft);
|
|
|
|
const int pt = layoutMetric(LM_OuterPaddingTop);
|
|
|
|
const int pr = layoutMetric(LM_OuterPaddingRight);
|
|
|
|
const int pb = layoutMetric(LM_OuterPaddingBottom);
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
int r_x, r_y, r_x2, r_y2;
|
2009-05-04 22:35:33 +00:00
|
|
|
widget()->rect().adjusted(pl, pt, -pr, -pb).getCoords(&r_x, &r_y, &r_x2, &r_y2);
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
|
|
|
|
const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop);
|
|
|
|
const int titleEdgeRight = layoutMetric(LM_TitleEdgeRight);
|
|
|
|
const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom);
|
|
|
|
const int titleBorderLeft = layoutMetric(LM_TitleBorderLeft);
|
|
|
|
const int titleBorderRight = layoutMetric(LM_TitleBorderRight);
|
|
|
|
const int ttlHeight = layoutMetric(LM_TitleHeight);
|
2011-01-30 14:34:42 +00:00
|
|
|
const int titleEdgeBottomBottom = r_y + titleEdgeTop + ttlHeight + titleEdgeBottom - 1;
|
|
|
|
return QRect(r_x + titleEdgeLeft + buttonsLeftWidth() + titleBorderLeft, r_y + titleEdgeTop,
|
|
|
|
r_x2 - titleEdgeRight - buttonsRightWidth() - titleBorderRight - (r_x + titleEdgeLeft + buttonsLeftWidth() + titleBorderLeft),
|
|
|
|
titleEdgeBottomBottom - (r_y + titleEdgeTop));
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2009-11-25 23:32:35 +00:00
|
|
|
QRect KCommonDecoration::transparentRect() const
|
|
|
|
{
|
|
|
|
return wrapper->transparentRect();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
KCommonDecorationButton::KCommonDecorationButton(ButtonType type, KCommonDecoration *parent)
|
2011-01-30 14:34:42 +00:00
|
|
|
: QAbstractButton(parent ? parent->widget() : 0),
|
|
|
|
m_decoration(parent),
|
|
|
|
m_type(type),
|
|
|
|
m_realizeButtons(Qt::LeftButton),
|
|
|
|
m_lastMouse(Qt::NoButton),
|
|
|
|
m_isLeft(true)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
setCursor(Qt::ArrowCursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
KCommonDecorationButton::~KCommonDecorationButton()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
KCommonDecoration *KCommonDecorationButton::decoration() const
|
|
|
|
{
|
|
|
|
return m_decoration;
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonType KCommonDecorationButton::type() const
|
|
|
|
{
|
|
|
|
return m_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool KCommonDecorationButton::isLeft() const
|
|
|
|
{
|
|
|
|
return m_isLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecorationButton::setLeft(bool left)
|
|
|
|
{
|
|
|
|
m_isLeft = left;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecorationButton::setRealizeButtons(int btns)
|
|
|
|
{
|
|
|
|
m_realizeButtons = btns;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecorationButton::setSize(const QSize &s)
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!m_size.isValid() || s != size()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
m_size = s;
|
|
|
|
|
|
|
|
setFixedSize(m_size);
|
|
|
|
reset(SizeChange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize KCommonDecorationButton::sizeHint() const
|
|
|
|
{
|
|
|
|
return m_size;
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecorationButton::setTipText(const QString &tip)
|
|
|
|
{
|
|
|
|
this->setToolTip(tip);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecorationButton::setToggleButton(bool toggle)
|
|
|
|
{
|
|
|
|
QAbstractButton::setCheckable(toggle);
|
|
|
|
reset(ToggleChange);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecorationButton::setOn(bool on)
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (on != isChecked()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
QAbstractButton::setChecked(on);
|
|
|
|
reset(StateChange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecorationButton::mousePressEvent(QMouseEvent* e)
|
|
|
|
{
|
|
|
|
m_lastMouse = e->button();
|
|
|
|
// pass on event after changing button to LeftButton
|
2011-01-30 14:34:42 +00:00
|
|
|
QMouseEvent me(e->type(), e->pos(), (e->button()&m_realizeButtons) ? Qt::LeftButton : Qt::NoButton, e->buttons(), e->modifiers());
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QAbstractButton::mousePressEvent(&me);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecorationButton::mouseReleaseEvent(QMouseEvent* e)
|
|
|
|
{
|
|
|
|
m_lastMouse = e->button();
|
|
|
|
// pass on event after changing button to LeftButton
|
2011-01-30 14:34:42 +00:00
|
|
|
QMouseEvent me(e->type(), e->pos(), (e->button()&m_realizeButtons) ? Qt::LeftButton : Qt::NoButton, e->buttons(), e->modifiers());
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QAbstractButton::mouseReleaseEvent(&me);
|
|
|
|
}
|
|
|
|
|
2007-11-29 14:11:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
// *** wrap everything from KDecoration *** //
|
2011-01-30 14:34:42 +00:00
|
|
|
bool KCommonDecoration::drawbound(const QRect&, bool)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
bool KCommonDecoration::windowDocked(Position)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const KDecorationOptions* KCommonDecoration::options()
|
|
|
|
{
|
|
|
|
return KDecoration::options();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::isActive() const
|
|
|
|
{
|
|
|
|
return wrapper->isActive();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::isCloseable() const
|
|
|
|
{
|
|
|
|
return wrapper->isCloseable();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::isMaximizable() const
|
|
|
|
{
|
|
|
|
return wrapper->isMaximizable();
|
|
|
|
}
|
|
|
|
KCommonDecoration::MaximizeMode KCommonDecoration::maximizeMode() const
|
|
|
|
{
|
|
|
|
return wrapper->maximizeMode();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::isMinimizable() const
|
|
|
|
{
|
|
|
|
return wrapper->isMinimizable();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::providesContextHelp() const
|
|
|
|
{
|
|
|
|
return wrapper->providesContextHelp();
|
|
|
|
}
|
|
|
|
int KCommonDecoration::desktop() const
|
|
|
|
{
|
|
|
|
return wrapper->desktop();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::isOnAllDesktops() const
|
|
|
|
{
|
|
|
|
return wrapper->isOnAllDesktops();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::isModal() const
|
|
|
|
{
|
|
|
|
return wrapper->isModal();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::isShadeable() const
|
|
|
|
{
|
|
|
|
return wrapper->isShadeable();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::isShade() const
|
|
|
|
{
|
|
|
|
return wrapper->isShade();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::isSetShade() const
|
|
|
|
{
|
|
|
|
return wrapper->isSetShade();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::keepAbove() const
|
|
|
|
{
|
|
|
|
return wrapper->keepAbove();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::keepBelow() const
|
|
|
|
{
|
|
|
|
return wrapper->keepBelow();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::isMovable() const
|
|
|
|
{
|
|
|
|
return wrapper->isMovable();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::isResizable() const
|
|
|
|
{
|
|
|
|
return wrapper->isResizable();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
NET::WindowType KCommonDecoration::windowType(unsigned long supported_types) const
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->windowType(supported_types);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
|
|
|
QIcon KCommonDecoration::icon() const
|
|
|
|
{
|
|
|
|
return wrapper->icon();
|
|
|
|
}
|
|
|
|
QString KCommonDecoration::caption() const
|
|
|
|
{
|
|
|
|
return wrapper->caption();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::showWindowMenu(const QRect &pos)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->showWindowMenu(pos);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::showWindowMenu(QPoint pos)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->showWindowMenu(pos);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::performWindowOperation(WindowOperation op)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->performWindowOperation(op);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::setMask(const QRegion& reg, int mode)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->setMask(reg, mode);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
|
|
|
void KCommonDecoration::clearMask()
|
|
|
|
{
|
|
|
|
return wrapper->clearMask();
|
|
|
|
}
|
|
|
|
bool KCommonDecoration::isPreview() const
|
|
|
|
{
|
|
|
|
return wrapper->isPreview();
|
|
|
|
}
|
|
|
|
QRect KCommonDecoration::geometry() const
|
|
|
|
{
|
|
|
|
return wrapper->geometry();
|
|
|
|
}
|
|
|
|
QRect KCommonDecoration::iconGeometry() const
|
|
|
|
{
|
|
|
|
return wrapper->iconGeometry();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
QRegion KCommonDecoration::unobscuredRegion(const QRegion& r) const
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->unobscuredRegion(r);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
|
|
|
WId KCommonDecoration::windowId() const
|
|
|
|
{
|
|
|
|
return wrapper->windowId();
|
|
|
|
}
|
|
|
|
int KCommonDecoration::width() const
|
|
|
|
{
|
|
|
|
return wrapper->width();
|
|
|
|
}
|
|
|
|
int KCommonDecoration::height() const
|
|
|
|
{
|
|
|
|
return wrapper->height();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::processMousePressEvent(QMouseEvent* e)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->processMousePressEvent(e);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::setMainWidget(QWidget* w)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->setMainWidget(w);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::createMainWidget(Qt::WFlags flags)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->createMainWidget(flags);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
|
|
|
QWidget* KCommonDecoration::initialParentWidget() const
|
|
|
|
{
|
|
|
|
return wrapper->initialParentWidget();
|
|
|
|
}
|
|
|
|
Qt::WFlags KCommonDecoration::initialWFlags() const
|
|
|
|
{
|
|
|
|
return wrapper->initialWFlags();
|
|
|
|
}
|
|
|
|
QWidget* KCommonDecoration::widget()
|
|
|
|
{
|
|
|
|
return wrapper->widget();
|
|
|
|
}
|
|
|
|
const QWidget* KCommonDecoration::widget() const
|
|
|
|
{
|
|
|
|
return wrapper->widget();
|
|
|
|
}
|
|
|
|
KDecorationFactory* KCommonDecoration::factory() const
|
|
|
|
{
|
|
|
|
return wrapper->factory();
|
|
|
|
}
|
|
|
|
void KCommonDecoration::grabXServer()
|
|
|
|
{
|
|
|
|
return wrapper->grabXServer();
|
|
|
|
}
|
|
|
|
void KCommonDecoration::ungrabXServer()
|
|
|
|
{
|
|
|
|
return wrapper->ungrabXServer();
|
|
|
|
}
|
|
|
|
void KCommonDecoration::closeWindow()
|
|
|
|
{
|
|
|
|
return wrapper->closeWindow();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::maximize(Qt::MouseButtons button)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->maximize(button);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::maximize(MaximizeMode mode)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->maximize(mode);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
|
|
|
void KCommonDecoration::minimize()
|
|
|
|
{
|
|
|
|
return wrapper->minimize();
|
|
|
|
}
|
|
|
|
void KCommonDecoration::showContextHelp()
|
|
|
|
{
|
|
|
|
return wrapper->showContextHelp();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::setDesktop(int desktop)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->setDesktop(desktop);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
|
|
|
void KCommonDecoration::toggleOnAllDesktops()
|
|
|
|
{
|
|
|
|
return wrapper->toggleOnAllDesktops();
|
|
|
|
}
|
|
|
|
void KCommonDecoration::titlebarDblClickOperation()
|
|
|
|
{
|
|
|
|
return wrapper->titlebarDblClickOperation();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::titlebarMouseWheelOperation(int delta)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->titlebarMouseWheelOperation(delta);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::setShade(bool set)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->setShade(set);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::setKeepAbove(bool set)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->setKeepAbove(set);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
void KCommonDecoration::setKeepBelow(bool set)
|
2007-11-29 14:11:02 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
return wrapper->setKeepBelow(set);
|
2007-11-29 14:11:02 +00:00
|
|
|
}
|
|
|
|
// *** end of wrapping of everything from KDecoration *** //
|
|
|
|
|
|
|
|
const KDecoration* KCommonDecoration::decoration() const
|
|
|
|
{
|
|
|
|
return wrapper;
|
|
|
|
}
|
|
|
|
KDecoration* KCommonDecoration::decoration()
|
|
|
|
{
|
|
|
|
return wrapper;
|
|
|
|
}
|
|
|
|
|
2008-10-17 10:30:43 +00:00
|
|
|
|
2008-10-18 08:10:37 +00:00
|
|
|
KCommonDecorationUnstable::KCommonDecorationUnstable(KDecorationBridge* bridge, KDecorationFactory* factory)
|
2011-01-30 14:34:42 +00:00
|
|
|
: KCommonDecoration(bridge, factory)
|
|
|
|
{
|
|
|
|
Q_ASSERT(dynamic_cast<const KDecorationUnstable*>(decoration()));
|
|
|
|
}
|
2008-10-17 10:30:43 +00:00
|
|
|
|
2008-10-18 08:10:37 +00:00
|
|
|
KCommonDecorationUnstable::~KCommonDecorationUnstable()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2008-10-17 10:30:43 +00:00
|
|
|
|
|
|
|
// All copied from kdecoration.cpp
|
2008-10-18 08:10:37 +00:00
|
|
|
bool KCommonDecorationUnstable::compositingActive() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return static_cast<const KDecorationUnstable*>(decoration())->compositingActive();
|
|
|
|
}
|
2008-10-17 10:30:43 +00:00
|
|
|
|
2009-11-15 03:24:04 +00:00
|
|
|
// Window tabbing
|
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
int KCommonDecorationUnstable::tabCount() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
return static_cast<const KDecorationUnstable*>(decoration())->tabCount();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
QString KCommonDecorationUnstable::caption(int idx) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
return static_cast<const KDecorationUnstable*>(decoration())->caption(idx);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
QIcon KCommonDecorationUnstable::icon(int idx) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
return static_cast<const KDecorationUnstable*>(decoration())->icon(idx);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
long KCommonDecorationUnstable::tabId(int idx) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
return static_cast<const KDecorationUnstable*>(decoration())->tabId(idx);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
long KCommonDecorationUnstable::currentTabId() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
return static_cast<const KDecorationUnstable*>(decoration())->currentTabId();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KCommonDecorationUnstable::setCurrentTab(long id)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
static_cast<KDecorationUnstable*>(decoration())->setCurrentTab(id);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KCommonDecorationUnstable::tab_A_before_B(long A, long B)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
static_cast<KDecorationUnstable*>(decoration())->tab_A_before_B(A, B);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KCommonDecorationUnstable::tab_A_behind_B(long A, long B)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
static_cast<KDecorationUnstable*>(decoration())->tab_A_behind_B(A, B);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KCommonDecorationUnstable::untab(long id, const QRect& newGeom)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
static_cast<KDecorationUnstable*>(decoration())->untab(id, newGeom);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KCommonDecorationUnstable::closeTab(long id)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
static_cast<KDecorationUnstable*>(decoration())->closeTab(id);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KCommonDecorationUnstable::closeTabGroup()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
static_cast<KDecorationUnstable*>(decoration())->closeTabGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KCommonDecorationUnstable::showWindowMenu(const QPoint &pos, long id)
|
|
|
|
{
|
|
|
|
static_cast<KDecorationUnstable*>(decoration())->showWindowMenu(pos, id);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KDecoration::WindowOperation KCommonDecorationUnstable::buttonToWindowOperation(Qt::MouseButtons button)
|
|
|
|
{
|
|
|
|
return static_cast<KDecorationUnstable*>(decoration())->buttonToWindowOperation(button);
|
|
|
|
}
|
2009-11-17 07:17:49 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool KCommonDecorationUnstable::eventFilter(QObject* o, QEvent* e)
|
|
|
|
{
|
|
|
|
return KCommonDecoration::eventFilter(o, e);
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// kate: space-indent on; indent-width 4; mixedindent off; indent-mode cstyle;
|
|
|
|
|