2010-01-19 13:44:22 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
2013-03-12 12:17:53 +00:00
|
|
|
Copyright (C) 2009 Martin Gräßlin <mgraesslin@kde.org>
|
2010-01-19 13:44:22 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#include "buttonsconfigdialog.h"
|
2012-01-13 10:48:04 +00:00
|
|
|
#include "kwindecoration.h"
|
2010-01-19 13:44:22 +00:00
|
|
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
2013-03-07 11:55:39 +00:00
|
|
|
#include <KDE/KLocalizedString>
|
2010-01-19 13:44:22 +00:00
|
|
|
#include <kdecoration.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KWinDecorationButtonsConfigForm::KWinDecorationButtonsConfigForm(QWidget* parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
}
|
|
|
|
|
2012-01-13 10:48:04 +00:00
|
|
|
KWinDecorationButtonsConfigDialog::KWinDecorationButtonsConfigDialog(DecorationButtons const *buttons, bool showTooltips, QWidget* parent, Qt::WFlags flags)
|
2011-01-30 14:34:42 +00:00
|
|
|
: KDialog(parent, flags)
|
|
|
|
, m_showTooltip(showTooltips)
|
2012-01-13 10:48:04 +00:00
|
|
|
, m_buttons(buttons)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
m_ui = new KWinDecorationButtonsConfigForm(this);
|
|
|
|
setWindowTitle(i18n("Buttons"));
|
|
|
|
setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Default | KDialog::Reset);
|
|
|
|
enableButton(KDialog::Reset, false);
|
2010-01-19 13:44:22 +00:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout;
|
2011-04-23 13:53:46 +00:00
|
|
|
layout->addWidget(m_ui);
|
2012-01-13 10:48:04 +00:00
|
|
|
m_ui->buttonPositionWidget->setEnabled(buttons->customPositions());
|
2010-01-19 13:44:22 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QWidget* main = new QWidget(this);
|
|
|
|
main->setLayout(layout);
|
|
|
|
setMainWidget(main);
|
2010-01-19 13:44:22 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
connect(m_ui->buttonPositionWidget, SIGNAL(changed()), this, SLOT(changed()));
|
|
|
|
connect(m_ui->showToolTipsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
|
|
|
|
connect(m_ui->useCustomButtonPositionsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
|
|
|
|
connect(this, SIGNAL(defaultClicked()), this, SLOT(slotDefaultClicked()));
|
|
|
|
connect(this, SIGNAL(resetClicked()), this, SLOT(slotResetClicked()));
|
2010-01-19 13:44:22 +00:00
|
|
|
|
|
|
|
slotResetClicked();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-01-19 13:44:22 +00:00
|
|
|
|
|
|
|
KWinDecorationButtonsConfigDialog::~KWinDecorationButtonsConfigDialog()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2010-01-19 13:44:22 +00:00
|
|
|
|
|
|
|
bool KWinDecorationButtonsConfigDialog::customPositions() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-01-19 13:44:22 +00:00
|
|
|
return m_ui->useCustomButtonPositionsCheckBox->isChecked();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-01-19 13:44:22 +00:00
|
|
|
|
|
|
|
bool KWinDecorationButtonsConfigDialog::showTooltips() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-01-19 13:44:22 +00:00
|
|
|
return m_ui->showToolTipsCheckBox->isChecked();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-01-19 13:44:22 +00:00
|
|
|
|
2013-10-10 11:53:10 +00:00
|
|
|
QList<KDecorationDefines::DecorationButton> KWinDecorationButtonsConfigDialog::buttonsLeft() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-01-19 13:44:22 +00:00
|
|
|
return m_ui->buttonPositionWidget->buttonsLeft();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-01-19 13:44:22 +00:00
|
|
|
|
2013-10-10 11:53:10 +00:00
|
|
|
QList<KDecorationDefines::DecorationButton> KWinDecorationButtonsConfigDialog::buttonsRight() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-01-19 13:44:22 +00:00
|
|
|
return m_ui->buttonPositionWidget->buttonsRight();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-01-19 13:44:22 +00:00
|
|
|
|
|
|
|
void KWinDecorationButtonsConfigDialog::changed()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
enableButton(KDialog::Reset, true);
|
|
|
|
}
|
2010-01-19 13:44:22 +00:00
|
|
|
|
|
|
|
void KWinDecorationButtonsConfigDialog::slotDefaultClicked()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
m_ui->useCustomButtonPositionsCheckBox->setChecked(false);
|
|
|
|
m_ui->showToolTipsCheckBox->setChecked(true);
|
|
|
|
m_ui->buttonPositionWidget->setButtonsLeft(KDecorationOptions::defaultTitleButtonsLeft());
|
|
|
|
m_ui->buttonPositionWidget->setButtonsRight(KDecorationOptions::defaultTitleButtonsRight());
|
2010-01-19 13:44:22 +00:00
|
|
|
changed();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-01-19 13:44:22 +00:00
|
|
|
|
|
|
|
void KWinDecorationButtonsConfigDialog::slotResetClicked()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-13 10:48:04 +00:00
|
|
|
m_ui->useCustomButtonPositionsCheckBox->setChecked(m_buttons->customPositions());
|
2011-01-30 14:34:42 +00:00
|
|
|
m_ui->showToolTipsCheckBox->setChecked(m_showTooltip);
|
2012-01-13 10:48:04 +00:00
|
|
|
m_ui->buttonPositionWidget->setButtonsLeft(m_buttons->leftButtons());
|
|
|
|
m_ui->buttonPositionWidget->setButtonsRight(m_buttons->rightButtons());
|
2010-01-19 13:44:22 +00:00
|
|
|
changed();
|
2011-01-30 14:34:42 +00:00
|
|
|
enableButton(KDialog::Reset, false);
|
|
|
|
}
|
2010-01-19 13:44:22 +00:00
|
|
|
|
|
|
|
} // namespace KWin
|
|
|
|
|
|
|
|
#include "buttonsconfigdialog.moc"
|