[kcmkwin/deco] Drop outdated source and ui files

All the ui components no longer used in the decoration KCM.
icc-effect-5.14.5
Martin Gräßlin 2014-12-09 16:14:03 +01:00
parent d5233a6b6f
commit 2fa0f2fecc
12 changed files with 0 additions and 2011 deletions

View File

@ -5,18 +5,11 @@ add_subdirectory(declarative-plugin)
set(kcm_kwindecoration_PART_SRCS
kcm.cpp
# buttons.cpp
# buttonsconfigdialog.cpp
# configdialog.cpp
decorationmodel.cpp
declarative-plugin/buttonsmodel.cpp
)
ki18n_wrap_ui(kcm_kwindecoration_PART_SRCS
auroraeconfig.ui
buttons.ui
config.ui
decoration.ui
kcm.ui
)

View File

@ -1,147 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KWinAuroraeConfigForm</class>
<widget class="QWidget" name="KWinAuroraeConfigForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>384</width>
<height>95</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="KMessageWidget" name="doubleClickMessage">
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Border size:</string>
</property>
<property name="buddy">
<cstring>borderSizesCombo</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="borderSizesCombo">
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Tiny</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Normal</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Large</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Very Large</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Huge</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Very Huge</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Oversized</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Button size:</string>
</property>
<property name="buddy">
<cstring>buttonSizesCombo</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="buttonSizesCombo">
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Tiny</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Normal</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Large</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Very Large</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Huge</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Very Huge</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Oversized</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="closeWindowsDoubleClick">
<property name="toolTip">
<string extracomment="Check this option if you want windows to be closed when you double click the menu button."/>
</property>
<property name="text">
<string>Close windows by double clicking the menu button</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>KMessageWidget</class>
<extends>QFrame</extends>
<header location="global">kmessagewidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,849 +0,0 @@
/*
This is the new kwindecoration kcontrol module
Copyright (c) 2009, Urs Wolfer <uwolfer @ kde.org>
Copyright (c) 2004, Sandro Giessl <sandro@giessl.com>
Copyright (c) 2001
Karol Szwed <gallium@kde.org>
http://gallium.n3.net/
Supports new kwin configuration plugins, and titlebar button position
modification via dnd interface.
Based on original "kwintheme" (Window Borders)
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "buttons.h"
#include "pixmaps.h"
#include "config-kwin.h"
#include <QApplication>
#include <QDrag>
#include <QPainter>
#include <QFontDatabase>
#include <QLabel>
#include <QLayout>
#include <QMimeData>
#include <QScrollBar>
#include <KLocalizedString>
#ifdef KWIN_BUILD_KAPPMENU
#include <KConfigGroup>
#include <KConfig>
#endif
#include <kdecorationfactory.h>
#define BUTTONDRAGMIMETYPE "application/x-kde_kwindecoration_buttons"
namespace KWin
{
ButtonDrag::ButtonDrag(Button btn)
: QMimeData()
{
QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly);
stream << btn.name;
stream << btn.icon;
stream << btn.type;
stream << (int) btn.duplicate;
stream << (int) btn.supported;
setData(BUTTONDRAGMIMETYPE, data);
}
bool ButtonDrag::canDecode(QDropEvent* e)
{
return e->mimeData()->hasFormat(BUTTONDRAGMIMETYPE);
}
bool ButtonDrag::decode(QDropEvent* e, Button& btn)
{
QByteArray data = e->mimeData()->data(BUTTONDRAGMIMETYPE);
if (data.size()) {
e->accept();
QDataStream stream(data);
stream >> btn.name;
stream >> btn.icon;
int type;
stream >> type;
btn.type = KDecorationDefines::DecorationButton(type);
int duplicate;
stream >> duplicate;
btn.duplicate = duplicate;
int supported;
stream >> supported;
btn.supported = supported;
return true;
}
return false;
}
Button::Button()
{
}
Button::Button(const QString& n, const QBitmap& i, KDecorationDefines::DecorationButton t, bool d, bool s)
: name(n),
icon(i),
type(t),
duplicate(d),
supported(s)
{
}
Button::~Button()
{
}
// helper function to deal with the Button's bitmaps more easily...
QPixmap bitmapPixmap(const QBitmap& bm, const QColor& color)
{
QPixmap pm(bm.size());
pm.fill(Qt::white);
QPainter p(&pm);
p.setPen(color);
p.drawPixmap(0, 0, bm);
p.end();
pm.setMask(pm.createMaskFromColor(Qt::white));
return pm;
}
ButtonSource::ButtonSource(QWidget *parent)
: QListWidget(parent)
{
setDragEnabled(true);
setAcceptDrops(true);
setDropIndicatorShown(false);
setSortingEnabled(true);
}
ButtonSource::~ButtonSource()
{
}
QSize ButtonSource::sizeHint() const
{
// make the sizeHint height a bit smaller than the one of QListView...
ensurePolished();
QSize s;
if (verticalScrollBar()->isVisible())
s.setWidth(s.width() + style()->pixelMetric(QStyle::PM_ScrollBarExtent));
s += QSize(frameWidth() * 2, frameWidth() * 2);
// size hint: 4 lines of text...
s.setHeight(s.height() + fontMetrics().lineSpacing() * 3);
return s;
}
void ButtonSource::hideAllButtons()
{
for (int i = 0; i < count(); i++) {
item(i)->setHidden(true);
}
}
void ButtonSource::showAllButtons()
{
for (int i = 0; i < count(); i++) {
item(i)->setHidden(false);
}
}
void ButtonSource::showButton(QChar btn)
{
for (int i = 0; i < count(); i++) {
ButtonSourceItem *buttonItem = dynamic_cast<ButtonSourceItem*>(item(i));
if (buttonItem && buttonItem->button().type == btn) {
item(i)->setHidden(false);
return;
}
}
}
void ButtonSource::hideButton(QChar btn)
{
for (int i = 0; i < count(); i++) {
ButtonSourceItem *buttonItem = dynamic_cast<ButtonSourceItem*>(item(i));
if (buttonItem && buttonItem->button().type == btn && !buttonItem->button().duplicate) {
item(i)->setHidden(true);
return;
}
}
}
void ButtonSource::dragMoveEvent(QDragMoveEvent *e)
{
e->setAccepted(ButtonDrag::canDecode(e));
}
void ButtonSource::dragEnterEvent(QDragEnterEvent *e)
{
e->setAccepted(ButtonDrag::canDecode(e));
}
void ButtonSource::dropEvent(QDropEvent *e)
{
if (ButtonDrag::canDecode(e)) {
emit dropped();
e->accept();
} else {
e->ignore();
}
}
void ButtonSource::mousePressEvent(QMouseEvent *e)
{
ButtonSourceItem *i = dynamic_cast<ButtonSourceItem*>(itemAt(e->pos()));
if (i) {
ButtonDrag *bd = new ButtonDrag(i->button());
QDrag *drag = new QDrag(this);
drag->setMimeData(bd);
drag->setPixmap(bitmapPixmap(i->button().icon, palette().color(QPalette::WindowText)));
drag->exec();
}
}
ButtonDropSiteItem::ButtonDropSiteItem(const Button& btn)
: m_button(btn)
{
}
ButtonDropSiteItem::~ButtonDropSiteItem()
{
}
Button ButtonDropSiteItem::button()
{
return m_button;
}
int ButtonDropSiteItem::width()
{
// return m_button.icon.width();
return 20;
}
int ButtonDropSiteItem::height()
{
// return m_button.icon.height();
return 20;
}
void ButtonDropSiteItem::draw(QPainter *p, const QPalette& cg, const QRect &r)
{
if (m_button.supported)
p->setPen(cg.color(QPalette::WindowText));
else
p->setPen(cg.color(QPalette::Disabled, QPalette::WindowText));
QBitmap &i = m_button.icon;
p->drawPixmap(r.left() + (r.width() - i.width()) / 2, r.top() + (r.height() - i.height()) / 2, i);
}
ButtonDropSite::ButtonDropSite(QWidget* parent)
: QFrame(parent),
m_selected(0)
{
setAcceptDrops(true);
setFrameShape(WinPanel);
setFrameShadow(Raised);
setMinimumHeight(26);
setMaximumHeight(26);
setMinimumWidth(250); // Ensure buttons will fit
setCursor(Qt::OpenHandCursor);
}
ButtonDropSite::~ButtonDropSite()
{
clearLeft();
clearRight();
}
void ButtonDropSite::clearLeft()
{
while (!buttonsLeft.isEmpty()) {
ButtonDropSiteItem *item = buttonsLeft.first();
if (removeButton(item)) {
emit buttonRemoved(item->button().type);
delete item;
}
}
}
void ButtonDropSite::clearRight()
{
while (!buttonsRight.isEmpty()) {
ButtonDropSiteItem *item = buttonsRight.first();
if (removeButton(item)) {
emit buttonRemoved(item->button().type);
delete item;
}
}
}
void ButtonDropSite::dragMoveEvent(QDragMoveEvent* e)
{
QPoint p = e->pos();
if (leftDropArea().contains(p) || rightDropArea().contains(p) || buttonAt(p)) {
e->accept();
// 2 pixel wide drop visualizer...
QRect r = contentsRect();
int x = -1;
if (leftDropArea().contains(p)) {
x = leftDropArea().left();
} else if (rightDropArea().contains(p)) {
x = rightDropArea().right() + 1;
} else {
ButtonDropSiteItem *item = buttonAt(p);
if (item) {
if (p.x() < item->rect.left() + item->rect.width() / 2) {
x = item->rect.left();
} else {
x = item->rect.right() + 1;
}
}
}
if (x != -1) {
QRect tmpRect(x, r.y(), 2, r.height());
if (tmpRect != m_oldDropVisualizer) {
cleanDropVisualizer();
m_oldDropVisualizer = tmpRect;
update(tmpRect);
}
}
} else {
e->ignore();
cleanDropVisualizer();
}
}
void ButtonDropSite::cleanDropVisualizer()
{
if (m_oldDropVisualizer.isValid()) {
QRect rect = m_oldDropVisualizer;
m_oldDropVisualizer = QRect(); // rect is invalid
update(rect);
}
}
void ButtonDropSite::dragEnterEvent(QDragEnterEvent* e)
{
if (ButtonDrag::canDecode(e))
e->accept();
}
void ButtonDropSite::dragLeaveEvent(QDragLeaveEvent* /* e */)
{
cleanDropVisualizer();
}
void ButtonDropSite::dropEvent(QDropEvent* e)
{
cleanDropVisualizer();
QPoint p = e->pos();
// collect information where to insert the dropped button
ButtonList *buttonList = 0;
int buttonPosition;
if (leftDropArea().contains(p)) {
buttonList = &buttonsLeft;
buttonPosition = buttonsLeft.size();
} else if (rightDropArea().contains(p)) {
buttonList = &buttonsRight;
buttonPosition = 0;
} else {
ButtonDropSiteItem *aboveItem = buttonAt(p);
if (!aboveItem)
return; // invalid drop. hasn't occurred _over_ a button (or left/right dropArea), return...
int pos;
if (!getItemPos(aboveItem, buttonList, pos)) {
// didn't find the aboveItem. unlikely to happen since buttonAt() already seems to have found
// something valid. anyway...
return;
}
// got the list and the aboveItem position. now determine if the item should be inserted
// before aboveItem or after aboveItem.
QRect aboveItemRect = aboveItem->rect;
if (!aboveItemRect.isValid())
return;
if (p.x() < aboveItemRect.left() + aboveItemRect.width() / 2) {
// insert before the item
buttonPosition = pos;
} else {
buttonPosition = pos + 1;
}
}
// know where to insert the button. now see if we can use an existing item (drag within the widget = move)
// orneed to create a new one
ButtonDropSiteItem *buttonItem = 0;
if (e->source() == this && m_selected) {
ButtonList *oldList = 0;
int oldPos;
if (getItemPos(m_selected, oldList, oldPos)) {
if (oldPos == buttonPosition && oldList == buttonList)
return; // button didn't change its position during the drag...
oldList->removeAt(oldPos);
buttonItem = m_selected;
// If we're inserting to the right of oldPos, in the same list,
// better adjust the index..
if (buttonList == oldList && buttonPosition > oldPos)
--buttonPosition;
} else {
return; // m_selected not found, return...
}
} else {
// create new button from the drop object...
Button btn;
if (ButtonDrag::decode(e, btn)) {
buttonItem = new ButtonDropSiteItem(btn);
} else {
return; // something has gone wrong while we were trying to decode the drop event
}
}
// now the item can actually be inserted into the list! :)
(*buttonList).insert(buttonPosition, buttonItem);
emit buttonAdded(buttonItem->button().type);
emit changed();
recalcItemGeometry();
update();
}
bool ButtonDropSite::getItemPos(ButtonDropSiteItem *item, ButtonList* &list, int &pos)
{
if (!item)
return false;
pos = buttonsLeft.indexOf(item); // try the left list first...
if (pos >= 0) {
list = &buttonsLeft;
return true;
}
pos = buttonsRight.indexOf(item); // try the right list...
if (pos >= 0) {
list = &buttonsRight;
return true;
}
list = 0;
pos = -1;
return false;
}
QRect ButtonDropSite::leftDropArea()
{
// return a 10 pixel drop area...
QRect r = contentsRect();
int leftButtonsWidth = calcButtonListWidth(buttonsLeft);
return QRect(r.left() + leftButtonsWidth, r.top(), 10, r.height());
}
QRect ButtonDropSite::rightDropArea()
{
// return a 10 pixel drop area...
QRect r = contentsRect();
int rightButtonsWidth = calcButtonListWidth(buttonsRight);
return QRect(r.right() - rightButtonsWidth - 10, r.top(), 10, r.height());
}
void ButtonDropSite::mousePressEvent(QMouseEvent* e)
{
QDrag *drag = new QDrag(this);
m_selected = buttonAt(e->pos());
if (m_selected) {
ButtonDrag *bd = new ButtonDrag(m_selected->button());
drag->setMimeData(bd);
drag->setPixmap(bitmapPixmap(m_selected->button().icon, palette().color(QPalette::WindowText)));
drag->exec();
}
}
void ButtonDropSite::resizeEvent(QResizeEvent*)
{
recalcItemGeometry();
}
void ButtonDropSite::recalcItemGeometry()
{
QRect r = contentsRect();
// update the geometry of the items in the left button list
int offset = r.left();
for (ButtonList::const_iterator it = buttonsLeft.constBegin(); it != buttonsLeft.constEnd(); ++it) {
int w = (*it)->width();
(*it)->rect = QRect(offset, r.top(), w, (*it)->height());
offset += w;
}
// the right button list...
offset = r.right() - calcButtonListWidth(buttonsRight);
for (ButtonList::const_iterator it = buttonsRight.constBegin(); it != buttonsRight.constEnd(); ++it) {
int w = (*it)->width();
(*it)->rect = QRect(offset, r.top(), w, (*it)->height());
offset += w;
}
}
ButtonDropSiteItem *ButtonDropSite::buttonAt(QPoint p)
{
// try to find the item in the left button list
for (ButtonList::const_iterator it = buttonsLeft.constBegin(); it != buttonsLeft.constEnd(); ++it) {
if ((*it)->rect.contains(p)) {
return *it;
}
}
// try to find the item in the right button list
for (ButtonList::const_iterator it = buttonsRight.constBegin(); it != buttonsRight.constEnd(); ++it) {
if ((*it)->rect.contains(p)) {
return *it;
}
}
return 0;
}
bool ButtonDropSite::removeButton(ButtonDropSiteItem *item)
{
if (!item)
return false;
// try to remove the item from the left button list
if (buttonsLeft.removeAll(item) >= 1) {
return true;
}
// try to remove the item from the right button list
if (buttonsRight.removeAll(item) >= 1) {
return true;
}
return false;
}
int ButtonDropSite::calcButtonListWidth(const ButtonList& btns)
{
int w = 0;
for (ButtonList::const_iterator it = btns.constBegin(); it != btns.constEnd(); ++it) {
w += (*it)->width();
}
return w;
}
bool ButtonDropSite::removeSelectedButton()
{
bool succ = removeButton(m_selected);
if (succ) {
emit buttonRemoved(m_selected->button().type);
emit changed();
delete m_selected;
m_selected = 0;
recalcItemGeometry();
update(); // repaint...
}
return succ;
}
void ButtonDropSite::drawButtonList(QPainter *p, const ButtonList& btns, int offset)
{
for (ButtonList::const_iterator it = btns.constBegin(); it != btns.constEnd(); ++it) {
QRect itemRect = (*it)->rect;
if (itemRect.isValid()) {
(*it)->draw(p, palette(), itemRect);
}
offset += (*it)->width();
}
}
void ButtonDropSite::paintEvent(QPaintEvent* /*pe*/)
{
QPainter p(this);
int leftoffset = calcButtonListWidth(buttonsLeft);
int rightoffset = calcButtonListWidth(buttonsRight);
int offset = 3;
QRect r = contentsRect();
// Shrink by 1
r.translate(1 + leftoffset, 1);
r.setWidth(r.width() - 2 - leftoffset - rightoffset);
r.setHeight(r.height() - 2);
drawButtonList(&p, buttonsLeft, offset);
QColor c1(palette().color(QPalette::Mid));
p.fillRect(r, c1);
p.setPen(palette().color(QPalette::WindowText));
p.setFont(QFontDatabase::systemFont(QFontDatabase::TitleFont));
p.drawText(r.adjusted(4, 0, -4, 0), Qt::AlignLeft | Qt::AlignVCenter, i18n("KDE"));
offset = geometry().width() - 3 - rightoffset;
drawButtonList(&p, buttonsRight, offset);
if (m_oldDropVisualizer.isValid()) {
p.fillRect(m_oldDropVisualizer, Qt::Dense4Pattern);
}
}
ButtonSourceItem::ButtonSourceItem(QListWidget * parent, const Button& btn)
: QListWidgetItem(parent),
m_button(btn)
{
setButton(btn);
}
ButtonSourceItem::~ButtonSourceItem()
{
}
void ButtonSourceItem::setButton(const Button& btn)
{
m_button = btn;
if (btn.supported) {
setText(btn.name);
setIcon(bitmapPixmap(btn.icon, QApplication::palette().color(QPalette::Text)));
setForeground(QApplication::palette().brush(QPalette::Text));
} else {
setText(i18n("%1 (unavailable)", btn.name));
setIcon(bitmapPixmap(btn.icon, QApplication::palette().color(QPalette::Disabled, QPalette::Text)));
setForeground(QApplication::palette().brush(QPalette::Disabled, QPalette::Text));
}
}
Button ButtonSourceItem::button() const
{
return m_button;
}
ButtonPositionWidget::ButtonPositionWidget(QWidget *parent)
: QWidget(parent),
m_factory(0)
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setMargin(0);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QLabel* label = new QLabel(this);
m_dropSite = new ButtonDropSite(this);
label->setWordWrap(true);
label->setText(i18n("To add or remove titlebar buttons, simply <i>drag</i> items "
"between the available item list and the titlebar preview. Similarly, "
"drag items within the titlebar preview to re-position them."));
m_buttonSource = new ButtonSource(this);
m_buttonSource->setObjectName(QLatin1String("button_source"));
layout->addWidget(label);
layout->addWidget(m_dropSite);
layout->addWidget(m_buttonSource);
connect(m_dropSite, SIGNAL(buttonAdded(QChar)), m_buttonSource, SLOT(hideButton(QChar)));
connect(m_dropSite, SIGNAL(buttonRemoved(QChar)), m_buttonSource, SLOT(showButton(QChar)));
connect(m_buttonSource, SIGNAL(dropped()), m_dropSite, SLOT(removeSelectedButton()));
connect(m_dropSite, SIGNAL(changed()), SIGNAL(changed()));
// insert all possible buttons into the source (backwards to keep the preferred order...)
bool dummy;
m_supportedButtons = "MSHIAX_FBLR";
#ifdef KWIN_BUILD_KAPPMENU
KConfig config("kdeglobals", KConfig::FullConfig);
KConfigGroup configGroup = config.group("Appmenu Style");
QString style = configGroup.readEntry("Style", "InApplication");
if (style == "ButtonVertical") {
m_supportedButtons = "MNSHIAX_FBLR"; // support all buttons
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonApplicationMenu, dummy));
}
#endif
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonResize, dummy));
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonShade, dummy));
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonKeepBelow, dummy));
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonKeepAbove, dummy));
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonClose, dummy));
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonMaximizeRestore, dummy));
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonMinimize, dummy));
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonQuickHelp, dummy));
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonOnAllDesktops, dummy));
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonMenu, dummy));
new ButtonSourceItem(m_buttonSource, getButton(KDecorationDefines::DecorationButtonExplicitSpacer, dummy));
}
ButtonPositionWidget::~ButtonPositionWidget()
{
}
Button ButtonPositionWidget::getButton(KDecorationDefines::DecorationButton type, bool& success)
{
success = true;
switch (type) {
case KDecorationDefines::DecorationButtonResize: {
QBitmap bmp = QBitmap::fromData(QSize(resize_width, resize_height), resize_bits);
bmp.createMaskFromColor(Qt::white);
return Button(i18n("Resize"), bmp, type, false, m_supportedButtons.contains('R'));
}
case KDecorationDefines::DecorationButtonShade: {
QBitmap bmp = QBitmap::fromData(QSize(shade_width, shade_height), shade_bits);
bmp.createMaskFromColor(Qt::white);
return Button(i18n("Shade"), bmp, type, false, m_supportedButtons.contains('L'));
}
case KDecorationDefines::DecorationButtonKeepBelow: {
QBitmap bmp = QBitmap::fromData(QSize(keepbelowothers_width, keepbelowothers_height), keepbelowothers_bits);
bmp.createMaskFromColor(Qt::white);
return Button(i18n("Keep Below Others"), bmp, type, false, m_supportedButtons.contains('B'));
}
case KDecorationDefines::DecorationButtonKeepAbove: {
QBitmap bmp = QBitmap::fromData(QSize(keepaboveothers_width, keepaboveothers_height), keepaboveothers_bits);
bmp.createMaskFromColor(Qt::white);
return Button(i18n("Keep Above Others"), bmp, type, false, m_supportedButtons.contains('F'));
}
case KDecorationDefines::DecorationButtonClose: {
QBitmap bmp = QBitmap::fromData(QSize(close_width, close_height), close_bits);
bmp.createMaskFromColor(Qt::white);
return Button(i18n("Close"), bmp, type, false, m_supportedButtons.contains('X'));
}
case KDecorationDefines::DecorationButtonMaximizeRestore: {
QBitmap bmp = QBitmap::fromData(QSize(maximize_width, maximize_height), maximize_bits);
bmp.createMaskFromColor(Qt::white);
return Button(i18n("Maximize"), bmp, type, false, m_supportedButtons.contains('A'));
}
case KDecorationDefines::DecorationButtonMinimize: {
QBitmap bmp = QBitmap::fromData(QSize(minimize_width, minimize_height), minimize_bits);
bmp.createMaskFromColor(Qt::white);
return Button(i18n("Minimize"), bmp, type, false, m_supportedButtons.contains('I'));
}
case KDecorationDefines::DecorationButtonQuickHelp: {
QBitmap bmp = QBitmap::fromData(QSize(help_width, help_height), help_bits);
bmp.createMaskFromColor(Qt::white);
return Button(i18n("Help"), bmp, type, false, m_supportedButtons.contains('H'));
}
case KDecorationDefines::DecorationButtonOnAllDesktops: {
QBitmap bmp = QBitmap::fromData(QSize(onalldesktops_width, onalldesktops_height), onalldesktops_bits);
bmp.createMaskFromColor(Qt::white);
return Button(i18n("On All Desktops"), bmp, type, false, m_supportedButtons.contains('S'));
}
case KDecorationDefines::DecorationButtonMenu: {
QBitmap bmp = QBitmap::fromData(QSize(menu_width, menu_height), menu_bits);
bmp.createMaskFromColor(Qt::white);
return Button(i18nc("Button showing window actions menu", "Window Menu"), bmp, type, false, m_supportedButtons.contains('M'));
#ifdef KWIN_BUILD_KAPPMENU
}
case KDecorationDefines::DecorationButtonApplicationMenu: {
QBitmap bmp = QBitmap::fromData(QSize(menu_width, menu_height), menu_bits);
bmp.createMaskFromColor(Qt::white);
return Button(i18nc("Button showing application menu imported from dbusmenu", "Application Menu"), bmp, type, false, m_supportedButtons.contains('N'));
#endif
}
case KDecorationDefines::DecorationButtonExplicitSpacer: {
QBitmap bmp = QBitmap::fromData(QSize(spacer_width, spacer_height), spacer_bits);
bmp.createMaskFromColor(Qt::white);
return Button(i18n("--- spacer ---"), bmp, type, true, m_supportedButtons.contains('_'));
}
default:
success = false;
return Button();
}
}
QList<KDecorationDefines::DecorationButton> ButtonPositionWidget::buttonsLeft() const
{
QList<KDecorationDefines::DecorationButton> ret;
for (auto button : m_dropSite->buttonsLeft) {
ret << button->button().type;
}
return ret;
}
QList<KDecorationDefines::DecorationButton> ButtonPositionWidget::buttonsRight() const
{
QList<KDecorationDefines::DecorationButton> ret;
for (auto button : m_dropSite->buttonsRight) {
ret << button->button().type;
}
return ret;
}
void ButtonPositionWidget::setButtonsLeft(const QList<KDecorationDefines::DecorationButton> &buttons)
{
// to keep the button lists consistent, first remove all left buttons, then add buttons again...
m_dropSite->clearLeft();
for (auto button : buttons) {
bool succ = false;
Button btn = getButton(button, succ);
if (succ) {
m_dropSite->buttonsLeft.append(new ButtonDropSiteItem(btn));
m_buttonSource->hideButton(btn.type);
}
}
m_dropSite->recalcItemGeometry();
m_dropSite->update();
}
void ButtonPositionWidget::setButtonsRight(const QList<KDecorationDefines::DecorationButton> &buttons)
{
// to keep the button lists consistent, first remove all left buttons, then add buttons again...
m_dropSite->clearRight();
for (auto button : buttons) {
bool succ = false;
Button btn = getButton(button, succ);
if (succ) {
m_dropSite->buttonsRight.append(new ButtonDropSiteItem(btn));
m_buttonSource->hideButton(btn.type);
}
}
m_dropSite->recalcItemGeometry();
m_dropSite->update();
}
} // namespace KWin
#include "buttons.moc"
// vim: ts=4
// kate: space-indent off; tab-width 4;

View File

@ -1,225 +0,0 @@
/*
This is the new kwindecoration kcontrol module
Copyright (c) 2009, Urs Wolfer <uwolfer @ kde.org>
Copyright (c) 2004, Sandro Giessl <sandro@giessl.com>
Copyright (c) 2001
Karol Szwed <gallium@kde.org>
http://gallium.n3.net/
Supports new kwin configuration plugins, and titlebar button position
modification via dnd interface.
Based on original "kwintheme" (Window Borders)
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef BUTTONS_H
#define BUTTONS_H
#include <kdecoration.h>
#include <QBitmap>
#include <QListWidget>
#include <QMimeData>
namespace KWin
{
/**
* This class holds the button data.
*/
class Button
{
public:
Button();
Button(const QString& name, const QBitmap& icon, KDecorationDefines::DecorationButton type, bool duplicate, bool supported);
virtual ~Button();
QString name;
QBitmap icon;
KDecorationDefines::DecorationButton type;
bool duplicate;
bool supported;
};
class ButtonDrag : public QMimeData
{
public:
explicit ButtonDrag(Button btn);
~ButtonDrag() {}
static bool canDecode(QDropEvent* e);
static bool decode(QDropEvent* e, Button& btn);
};
/**
* This is plugged into ButtonDropSite
*/
class ButtonDropSiteItem
{
public:
explicit ButtonDropSiteItem(const Button& btn);
~ButtonDropSiteItem();
Button button();
QRect rect;
int width();
int height();
void draw(QPainter *p, const QPalette& cg, const QRect &rect);
private:
Button m_button;
};
/**
* This is plugged into ButtonSource
*/
class ButtonSourceItem : public QListWidgetItem
{
public:
ButtonSourceItem(QListWidget * parent, const Button& btn);
virtual ~ButtonSourceItem();
void setButton(const Button& btn);
Button button() const;
private:
Button m_button;
};
/**
* Implements the button drag source list view
*/
class ButtonSource : public QListWidget
{
Q_OBJECT
public:
explicit ButtonSource(QWidget *parent = nullptr);
virtual ~ButtonSource();
QSize sizeHint() const;
void hideAllButtons();
void showAllButtons();
void dragMoveEvent(QDragMoveEvent *e);
void dragEnterEvent(QDragEnterEvent *e);
void dropEvent(QDropEvent *e);
void mousePressEvent(QMouseEvent *e);
Q_SIGNALS:
void dropped();
public Q_SLOTS:
void hideButton(QChar btn);
void showButton(QChar btn);
};
typedef QList<ButtonDropSiteItem*> ButtonList;
/**
* This class renders and handles the demo titlebar dropsite
*/
class ButtonDropSite: public QFrame
{
Q_OBJECT
public:
explicit ButtonDropSite(QWidget* parent = nullptr);
~ButtonDropSite();
// Allow external classes access our buttons - ensure buttons are
// not duplicated however.
ButtonList buttonsLeft;
ButtonList buttonsRight;
void clearLeft();
void clearRight();
void resizeEvent(QResizeEvent* e);
void dragEnterEvent(QDragEnterEvent* e);
void dragMoveEvent(QDragMoveEvent* e);
void dragLeaveEvent(QDragLeaveEvent* e);
void dropEvent(QDropEvent* e);
void mousePressEvent(QMouseEvent* e); ///< Starts dragging a button...
void paintEvent(QPaintEvent* p);
Q_SIGNALS:
void buttonAdded(QChar btn);
void buttonRemoved(QChar btn);
void changed();
public Q_SLOTS:
bool removeSelectedButton(); ///< This slot is called after we drop on the item listbox...
void recalcItemGeometry(); ///< Call this whenever the item list changes... updates the items' rect property
protected:
ButtonDropSiteItem *buttonAt(QPoint p);
bool removeButton(ButtonDropSiteItem *item);
int calcButtonListWidth(const ButtonList& buttons); ///< Computes the total space the buttons will take in the titlebar
void drawButtonList(QPainter *p, const ButtonList& buttons, int offset);
QRect leftDropArea();
QRect rightDropArea();
private:
/**
* Try to find the item. If found, set its list and index and return true, else return false
*/
bool getItemPos(ButtonDropSiteItem *item, ButtonList* &list, int &pos);
void cleanDropVisualizer();
QRect m_oldDropVisualizer;
ButtonDropSiteItem *m_selected;
};
class ButtonPositionWidget : public QWidget
{
Q_OBJECT
public:
explicit ButtonPositionWidget(QWidget *parent = nullptr);
~ButtonPositionWidget();
QList<KDecorationDefines::DecorationButton> buttonsLeft() const;
QList<KDecorationDefines::DecorationButton> buttonsRight() const;
void setButtonsLeft(const QList<KDecorationDefines::DecorationButton> &buttons);
void setButtonsRight(const QList<KDecorationDefines::DecorationButton> &buttons);
Q_SIGNALS:
void changed();
private:
void clearButtonList(const ButtonList& btns);
Button getButton(KDecorationDefines::DecorationButton type, bool& success);
ButtonDropSite* m_dropSite;
ButtonSource *m_buttonSource;
KDecorationFactory *m_factory;
QString m_supportedButtons;
};
} // namespace KWin
#endif
// vim: ts=4
// kate: space-indent off; tab-width 4;

View File

@ -1,73 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KWinDecorationButtonsConfigForm</class>
<widget class="QWidget" name="KWinDecorationButtonsConfigForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="showToolTipsCheckBox">
<property name="whatsThis">
<string>Enabling this checkbox will show window button tooltips. If this checkbox is off, no window button tooltips will be shown.</string>
</property>
<property name="text">
<string>&amp;Show window button tooltips</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="useCustomButtonPositionsCheckBox">
<property name="whatsThis">
<string>Please note that this option is not available on all styles yet.</string>
</property>
<property name="text">
<string>Use custom titlebar button &amp;positions</string>
</property>
</widget>
</item>
<item>
<widget class="KWin::ButtonPositionWidget" name="buttonPositionWidget" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KWin::ButtonPositionWidget</class>
<extends>QWidget</extends>
<header>buttons.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>useCustomButtonPositionsCheckBox</sender>
<signal>clicked(bool)</signal>
<receiver>buttonPositionWidget</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>205</x>
<y>39</y>
</hint>
<hint type="destinationlabel">
<x>231</x>
<y>90</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,118 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2009 Martin Gräßlin <mgraesslin@kde.org>
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"
#include "kwindecoration.h"
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <KLocalizedString>
#include <kdecoration.h>
namespace KWin
{
KWinDecorationButtonsConfigForm::KWinDecorationButtonsConfigForm(QWidget* parent)
: QWidget(parent)
{
setupUi(this);
}
KWinDecorationButtonsConfigDialog::KWinDecorationButtonsConfigDialog(DecorationButtons const *buttons, bool showTooltips, QWidget* parent, Qt::WFlags flags)
: QDialog(parent, flags)
, m_ui(new KWinDecorationButtonsConfigForm(this))
, m_showTooltip(showTooltips)
, m_buttons(buttons)
{
setWindowTitle(i18n("Buttons"));
m_buttonBox = new QDialogButtonBox(this);
m_buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Reset);
m_buttonBox->button(QDialogButtonBox::RestoreDefaults)->setEnabled(false);
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(m_ui);
layout->addWidget(m_buttonBox);
m_ui->buttonPositionWidget->setEnabled(buttons->customPositions());
setLayout(layout);
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(m_buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), this, SLOT(slotDefaultClicked()));
connect(m_buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(slotResetClicked()));
connect(m_buttonBox, SIGNAL(accepted()), SLOT(accept()));
connect(m_buttonBox, SIGNAL(rejected()), SLOT(reject()));
slotResetClicked();
}
KWinDecorationButtonsConfigDialog::~KWinDecorationButtonsConfigDialog()
{
}
bool KWinDecorationButtonsConfigDialog::customPositions() const
{
return m_ui->useCustomButtonPositionsCheckBox->isChecked();
}
bool KWinDecorationButtonsConfigDialog::showTooltips() const
{
return m_ui->showToolTipsCheckBox->isChecked();
}
QList<KDecorationDefines::DecorationButton> KWinDecorationButtonsConfigDialog::buttonsLeft() const
{
return m_ui->buttonPositionWidget->buttonsLeft();
}
QList<KDecorationDefines::DecorationButton> KWinDecorationButtonsConfigDialog::buttonsRight() const
{
return m_ui->buttonPositionWidget->buttonsRight();
}
void KWinDecorationButtonsConfigDialog::changed()
{
m_buttonBox->button(QDialogButtonBox::RestoreDefaults)->setEnabled(true);
}
void KWinDecorationButtonsConfigDialog::slotDefaultClicked()
{
m_ui->useCustomButtonPositionsCheckBox->setChecked(false);
m_ui->showToolTipsCheckBox->setChecked(true);
m_ui->buttonPositionWidget->setButtonsLeft(KDecorationOptions::defaultTitleButtonsLeft());
m_ui->buttonPositionWidget->setButtonsRight(KDecorationOptions::defaultTitleButtonsRight());
changed();
}
void KWinDecorationButtonsConfigDialog::slotResetClicked()
{
m_ui->useCustomButtonPositionsCheckBox->setChecked(m_buttons->customPositions());
m_ui->showToolTipsCheckBox->setChecked(m_showTooltip);
m_ui->buttonPositionWidget->setButtonsLeft(m_buttons->leftButtons());
m_ui->buttonPositionWidget->setButtonsRight(m_buttons->rightButtons());
changed();
m_buttonBox->button(QDialogButtonBox::Reset)->setEnabled(false);
}
} // namespace KWin
#include "buttonsconfigdialog.moc"

View File

@ -1,68 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2009 Martin Gräßlin <mgraesslin@kde.org>
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/>.
*********************************************************************/
#ifndef KWINDECORATIONBUTTONSCONFIGDIALOG_H
#define KWINDECORATIONBUTTONSCONFIGDIALOG_H
#include <QWidget>
#include <QDialog>
#include "ui_buttons.h"
class QDialogButtonBox;
namespace KWin
{
class DecorationButtons;
class KWinDecorationButtonsConfigForm : public QWidget, public Ui::KWinDecorationButtonsConfigForm
{
Q_OBJECT
public:
explicit KWinDecorationButtonsConfigForm(QWidget* parent);
};
class KWinDecorationButtonsConfigDialog : public QDialog
{
Q_OBJECT
public:
KWinDecorationButtonsConfigDialog(DecorationButtons const *buttons, bool showTooltips, QWidget* parent = nullptr, Qt::WFlags flags = 0);
~KWinDecorationButtonsConfigDialog();
bool customPositions() const;
bool showTooltips() const;
QList<KDecorationDefines::DecorationButton> buttonsLeft() const;
QList<KDecorationDefines::DecorationButton> buttonsRight() const;
private Q_SLOTS:
void changed();
void slotDefaultClicked();
void slotResetClicked();
private:
KWinDecorationButtonsConfigForm* m_ui;
bool m_showTooltip;
DecorationButtons const *m_buttons;
QDialogButtonBox* m_buttonBox;
};
} // namespace KWin
#endif // KWINDECORATIONCONFIGBUTTONSDIALOG_H

View File

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KWinDecorationConfigForm</class>
<widget class="QWidget" name="KWinDecorationConfigForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>188</width>
<height>38</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="borderLabel">
<property name="text">
<string>B&amp;order size:</string>
</property>
<property name="buddy">
<cstring>bordersCombo</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="bordersCombo">
<property name="whatsThis">
<string>Use this combobox to change the border size of the decoration.</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,169 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2009 Martin Gräßlin <mgraesslin@kde.org>
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 "configdialog.h"
#include <QDBusConnection>
#include <QDBusMessage>
#include <KSharedConfig>
#include <KLocalizedString>
#include <KConfigGroup>
#include <KPluginTrader>
#include <QDialogButtonBox>
#include <QPushButton>
namespace KWin
{
static const char* const border_names[ KDecorationDefines::BordersCount ] = {
I18N_NOOP2("@item:inlistbox Border size:", "Tiny"),
I18N_NOOP2("@item:inlistbox Border size:", "Normal"),
I18N_NOOP2("@item:inlistbox Border size:", "Large"),
I18N_NOOP2("@item:inlistbox Border size:", "Very Large"),
I18N_NOOP2("@item:inlistbox Border size:", "Huge"),
I18N_NOOP2("@item:inlistbox Border size:", "Very Huge"),
I18N_NOOP2("@item:inlistbox Border size:", "Oversized"),
I18N_NOOP2("@item:inlistbox Border size:", "No Side Border"),
I18N_NOOP2("@item:inlistbox Border size:", "No Border"),
};
KWinAuroraeConfigForm::KWinAuroraeConfigForm(QWidget* parent)
: QWidget(parent)
{
setupUi(this);
connect(borderSizesCombo, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()));
connect(buttonSizesCombo, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()));
connect(closeWindowsDoubleClick, SIGNAL(clicked()), SIGNAL(changed()));
}
void KWinAuroraeConfigForm::enableNoSideBorderSupport(bool enable)
{
if (!enable) {
return;
}
borderSizesCombo->addItem(i18nc("@item:inlistbox Border size:", border_names[KDecorationDefines::BorderNoSides]));
borderSizesCombo->addItem(i18nc("@item:inlistbox Border size:", border_names[KDecorationDefines::BorderNone]));
}
KWinDecorationConfigForm::KWinDecorationConfigForm(QWidget* parent)
: QWidget(parent)
{
setupUi(this);
}
KWinDecorationConfigDialog::KWinDecorationConfigDialog(QString deco, const QList<QVariant>& borderSizes,
KDecorationDefines::BorderSize size,
QWidget* parent, Qt::WFlags flags)
: QDialog(parent, flags)
, m_borderSizes(borderSizes)
, m_kwinConfig(KSharedConfig::openConfig("kwinrc"))
, m_pluginObject(nullptr)
, m_pluginConfigWidget(nullptr)
{
m_ui = new KWinDecorationConfigForm(this);
setWindowTitle(i18n("Decoration Options"));
m_buttons = new QDialogButtonBox(this);
m_buttons->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Reset);
m_buttons->button(QDialogButtonBox::Reset)->setEnabled(false);
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(m_ui);
connect(m_buttons, SIGNAL(accepted()), SLOT(accept()));
connect(m_buttons, SIGNAL(rejected()), SLOT(reject()));
m_pluginConfigWidget = new QWidget(this);
m_pluginConfigWidget->setLayout(new QVBoxLayout);
m_pluginObject = KPluginTrader::self()->createInstanceFromQuery<QObject>(QStringLiteral("kwin/kdecorations/config"),
QString(),
QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(deco),
m_pluginConfigWidget,
m_pluginConfigWidget,
QVariantList() << QStringLiteral("kwinrc") << QStringLiteral("Style"));
if (m_pluginObject) {
// connect required signals and slots together...
connect(this, SIGNAL(accepted()), this, SLOT(slotAccepted()));
connect(m_pluginObject, SIGNAL(changed()), this, SLOT(slotSelectionChanged()));
connect(this, SIGNAL(pluginSave(KConfigGroup&)), m_pluginObject, SLOT(save(KConfigGroup&)));
connect(m_buttons->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), m_pluginObject, SLOT(defaults()));
connect(m_buttons->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), SLOT(slotDefault()));
layout->addWidget(m_pluginConfigWidget);
}
layout->addWidget(m_buttons);
if (borderSizes.count() >= 2) {
foreach (const QVariant & borderSize, borderSizes) {
KDecorationDefines::BorderSize currentSize =
static_cast<KDecorationDefines::BorderSize>(borderSize.toInt());
m_ui->bordersCombo->addItem(i18nc("@item:inlistbox Border size:", border_names[currentSize]), borderSizeToIndex(currentSize, borderSizes));
}
m_ui->bordersCombo->setCurrentIndex(borderSizeToIndex(size, borderSizes));
} else {
m_ui->bordersCombo->hide();
m_ui->borderLabel->hide();
}
setLayout(layout);
}
KWinDecorationConfigDialog::~KWinDecorationConfigDialog()
{
delete m_pluginObject;
}
KDecorationDefines::BorderSize KWinDecorationConfigDialog::borderSize() const
{
if (m_borderSizes.count() >= 2)
return (KDecorationDefines::BorderSize)m_borderSizes.at(m_ui->bordersCombo->currentIndex()).toInt();
return KDecorationDefines::BorderNormal;
}
int KWinDecorationConfigDialog::borderSizeToIndex(KDecorationDefines::BorderSize size, const QList< QVariant >& sizes)
{
int pos = 0;
for (QList< QVariant >::ConstIterator it = sizes.constBegin();
it != sizes.constEnd();
++it, ++pos)
if (size <= (*it).toInt())
break;
return pos;
}
void KWinDecorationConfigDialog::slotAccepted()
{
KConfigGroup config(m_kwinConfig, "Style");
emit pluginSave(config);
config.sync();
}
void KWinDecorationConfigDialog::slotSelectionChanged()
{
m_buttons->button(QDialogButtonBox::Reset)->setEnabled(true);
}
void KWinDecorationConfigDialog::slotDefault()
{
if (m_borderSizes.count() >= 2)
m_ui->bordersCombo->setCurrentIndex(borderSizeToIndex(BorderNormal, m_borderSizes));
}
} // namespace KWin
#include "configdialog.moc"

View File

@ -1,87 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2009 Martin Gräßlin <mgraesslin@kde.org>
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/>.
*********************************************************************/
#ifndef KWINDECORATIONCONFIGDIALOG_H
#define KWINDECORATIONCONFIGDIALOG_H
#include <QWidget>
#include <QDialog>
#include <kdecoration.h>
#include <KSharedConfig>
#include "ui_config.h"
#include "ui_auroraeconfig.h"
class QDialogButtonBox;
namespace KWin
{
class KWinAuroraeConfigForm : public QWidget, public Ui::KWinAuroraeConfigForm
{
Q_OBJECT
public:
explicit KWinAuroraeConfigForm(QWidget* parent);
void enableNoSideBorderSupport(bool enable);
Q_SIGNALS:
void changed();
};
class KWinDecorationConfigForm : public QWidget, public Ui::KWinDecorationConfigForm
{
Q_OBJECT
public:
explicit KWinDecorationConfigForm(QWidget* parent);
};
class KWinDecorationConfigDialog : public QDialog, public KDecorationDefines
{
Q_OBJECT
public:
KWinDecorationConfigDialog(QString decoLib, const QList<QVariant>& borderSizes,
KDecorationDefines::BorderSize size, QWidget* parent = nullptr,
Qt::WFlags flags = 0);
~KWinDecorationConfigDialog();
KDecorationDefines::BorderSize borderSize() const;
Q_SIGNALS:
void pluginSave(KConfigGroup& group);
private Q_SLOTS:
void slotSelectionChanged();
void slotAccepted();
void slotDefault();
private:
int borderSizeToIndex(KDecorationDefines::BorderSize size, const QList<QVariant>& sizes);
private:
KWinDecorationConfigForm* m_ui;
QList<QVariant> m_borderSizes;
KSharedConfigPtr m_kwinConfig;
QObject*(*allocatePlugin)(KConfigGroup& conf, QWidget* parent);
QObject* m_pluginObject;
QWidget* m_pluginConfigWidget;
QDialogButtonBox* m_buttons;
};
} // namespace KWin
#endif // KWINDECORATIONCONFIGDIALOG_H

View File

@ -1,96 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KWinDecorationForm</class>
<widget class="QWidget" name="KWinDecorationForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>681</width>
<height>595</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,100,1">
<item>
<widget class="KLineEdit" name="searchEdit">
<property name="clickMessage" stdset="0">
<string>Search</string>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="decorationList">
<property name="whatsThis">
<string>Select the window decoration. This is the look and feel of both the window borders and the window handle.</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="configureDecorationButton">
<property name="text">
<string>Configure Decoration...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="configureButtonsButton">
<property name="text">
<string>Configure Buttons...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ghnsButton">
<property name="text">
<string>Get New Decorations...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>searchEdit</tabstop>
<tabstop>decorationList</tabstop>
<tabstop>configureDecorationButton</tabstop>
<tabstop>configureButtonsButton</tabstop>
<tabstop>ghnsButton</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -1,126 +0,0 @@
/*
This is the new kwindecoration kcontrol module
Copyright (c) 2004, Sandro Giessl <sandro@giessl.com>
Copyright (c) 2001
Karol Szwed <gallium@kde.org>
http://gallium.n3.net/
Supports new kwin configuration plugins, and titlebar button position
modification via dnd interface.
Based on original "kwintheme" (Window Borders)
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KWINDECORATION_PIXMAPS_H
#define KWINDECORATION_PIXMAPS_H
// Button icon bitmap data which is hopefully generic enough to be recognized by everyone.
// close.xbm:
#define close_width 12
#define close_height 12
static const unsigned char close_bits[] = {
0x00, 0x00, 0x06, 0x06, 0x0e, 0x07, 0x9c, 0x03, 0xf8, 0x01, 0xf0, 0x00,
0xf0, 0x00, 0xf8, 0x01, 0x9c, 0x03, 0x0e, 0x07, 0x06, 0x06, 0x00, 0x00
};
// help.xbm:
#define help_width 12
#define help_height 12
static const unsigned char help_bits[] = {
0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0xfc, 0x01, 0x8c, 0x01, 0xc0, 0x01,
0xe0, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00
};
// keepaboveothers.xbm:
#define keepaboveothers_width 12
#define keepaboveothers_height 12
static const unsigned char keepaboveothers_bits[] = {
0x00, 0x00, 0x60, 0x00, 0xf0, 0x00, 0xf8, 0x01, 0x60, 0x00, 0xfe, 0x07,
0xfe, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// keepbelowothers.xbm:
#define keepbelowothers_width 12
#define keepbelowothers_height 12
static const unsigned char keepbelowothers_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x07,
0xfe, 0x07, 0x60, 0x00, 0xf8, 0x01, 0xf0, 0x00, 0x60, 0x00, 0x00, 0x00
};
// maximize.xbm:
#define maximize_width 12
#define maximize_height 12
static const unsigned char maximize_bits[] = {
0x00, 0x00, 0xfe, 0x07, 0xfe, 0x07, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04,
0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0xfe, 0x07, 0x00, 0x00
};
// menu.xbm:
#define menu_width 12
#define menu_height 12
static const unsigned char menu_bits[] = {
0x00, 0x00, 0xfc, 0x03, 0xf4, 0x02, 0x04, 0x02, 0xf4, 0x02, 0x04, 0x02,
0xf4, 0x02, 0x04, 0x02, 0xf4, 0x02, 0x04, 0x02, 0xfc, 0x03, 0x00, 0x00
};
// minimize.xbm:
#define minimize_width 12
#define minimize_height 12
static const unsigned char minimize_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x07, 0xfe, 0x07, 0x00, 0x00
};
// onalldesktops.xbm:
#define onalldesktops_width 12
#define onalldesktops_height 12
static const unsigned char onalldesktops_bits[] = {
0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0xfe, 0x07,
0xfe, 0x07, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00
};
// resize.xbm:
#define resize_width 12
#define resize_height 12
static const unsigned char resize_bits[] = {
0x00, 0x00, 0xfe, 0x07, 0x42, 0x04, 0x42, 0x04, 0x42, 0x04, 0x42, 0x04,
0x7e, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0xfe, 0x07, 0x00, 0x00
};
// shade.xbm:
#define shade_width 12
#define shade_height 12
static const unsigned char shade_bits[] = {
0x00, 0x00, 0xfe, 0x07, 0xfe, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// spacer.xbm:
#define spacer_width 12
#define spacer_height 12
static const unsigned char spacer_bits[] = {
0x00, 0x00, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0x54, 0x03,
0xac, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0x00, 0x00
};
// vim: ts=4
#endif // KWINDECORATION_PIXMAPS_H