Option to disable window close on menu double click in Aurorae
For each theme the setting can be enabled individually with the default being enabled by default. It is completely handled inside the MenuButton QML component so each QML theme benefits from the option automatically, too. BUG: 301327 FIXED-IN: 4.10 REVIEW: 106160
This commit is contained in:
parent
8d55d9fa21
commit
8de1fea67e
5 changed files with 56 additions and 5 deletions
|
@ -18,6 +18,8 @@ import QtQuick 1.1
|
|||
import org.kde.qtextracomponents 0.1 as QtExtra
|
||||
|
||||
DecorationButton {
|
||||
property bool closeOnDoubleClick: true
|
||||
id: menuButton
|
||||
buttonType: "M"
|
||||
QtExtra.QIconItem {
|
||||
icon: decoration.icon
|
||||
|
@ -40,7 +42,7 @@ DecorationButton {
|
|||
// the double click delay to ensure that it was only a single click.
|
||||
if (timer.running) {
|
||||
timer.stop();
|
||||
} else {
|
||||
} else if (menuButton.closeOnDoubleClick) {
|
||||
timer.start();
|
||||
}
|
||||
}
|
||||
|
@ -59,11 +61,25 @@ DecorationButton {
|
|||
}
|
||||
onClicked: {
|
||||
// for right clicks we show the menu instantly
|
||||
if (mouse.button == Qt.RightButton) {
|
||||
// and if the option is disabled we always show menu directly
|
||||
if (!menuButton.closeOnDoubleClick || mouse.button == Qt.RightButton) {
|
||||
decoration.menuClicked();
|
||||
timer.stop();
|
||||
}
|
||||
}
|
||||
onDoubleClicked: decoration.closeWindow()
|
||||
onDoubleClicked: {
|
||||
if (menuButton.closeOnDoubleClick) {
|
||||
decoration.closeWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
menuButton.closeOnDoubleClick = decoration.readConfig("CloseOnDoubleClickMenuButton", true);
|
||||
}
|
||||
Connections {
|
||||
target: decoration
|
||||
onConfigChanged: {
|
||||
menuButton.closeOnDoubleClick = decoration.readConfig("CloseOnDoubleClickMenuButton", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,6 +112,16 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<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>
|
||||
|
|
|
@ -118,6 +118,7 @@ void DecorationModel::findDecorations()
|
|||
data.libraryName = libName;
|
||||
data.type = DecorationModelData::NativeDecoration;
|
||||
data.borderSize = KDecorationDefines::BorderNormal;
|
||||
data.closeDblClick = false;
|
||||
metaData(data, desktopFile);
|
||||
m_decorations.append(data);
|
||||
}
|
||||
|
@ -141,6 +142,7 @@ void DecorationModel::findDecorations()
|
|||
KConfigGroup config(m_config, data.auroraeName);
|
||||
data.borderSize = (KDecorationDefines::BorderSize)config.readEntry< int >("BorderSize", KDecorationDefines::BorderNormal);
|
||||
data.buttonSize = (KDecorationDefines::BorderSize)config.readEntry< int >("ButtonSize", KDecorationDefines::BorderNormal);
|
||||
data.closeDblClick = config.readEntry< bool >("CloseOnDoubleClickMenuButton", true);
|
||||
data.comment = service->comment();
|
||||
KPluginInfo info(service);
|
||||
data.author = info.author();
|
||||
|
@ -180,6 +182,7 @@ void DecorationModel::findAuroraeThemes()
|
|||
KConfigGroup config(m_config, data.auroraeName);
|
||||
data.borderSize = (KDecorationDefines::BorderSize)config.readEntry< int >("BorderSize", KDecorationDefines::BorderNormal);
|
||||
data.buttonSize = (KDecorationDefines::BorderSize)config.readEntry< int >("ButtonSize", KDecorationDefines::BorderNormal);
|
||||
data.closeDblClick = config.readEntry< bool >("CloseOnDoubleClickMenuButton", true);
|
||||
metaData(data, df);
|
||||
m_decorations.append(data);
|
||||
}
|
||||
|
@ -252,6 +255,8 @@ QVariant DecorationModel::data(const QModelIndex& index, int role) const
|
|||
return QVariant();
|
||||
case QmlMainScriptRole:
|
||||
return m_decorations[ index.row()].qmlPath;
|
||||
case CloseOnDblClickRole:
|
||||
return m_decorations[index.row()].closeDblClick;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -259,7 +264,7 @@ QVariant DecorationModel::data(const QModelIndex& index, int role) const
|
|||
|
||||
bool DecorationModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
if (!index.isValid() || (role != BorderSizeRole && role != ButtonSizeRole))
|
||||
if (!index.isValid() || (role != BorderSizeRole && role != ButtonSizeRole && role != CloseOnDblClickRole))
|
||||
return QAbstractItemModel::setData(index, value, role);
|
||||
|
||||
const DecorationModelData::DecorationType type = m_decorations[ index.row()].type;
|
||||
|
@ -286,6 +291,18 @@ bool DecorationModel::setData(const QModelIndex& index, const QVariant& value, i
|
|||
regeneratePreview(index);
|
||||
return true;
|
||||
}
|
||||
if (role == CloseOnDblClickRole && (type == DecorationModelData::AuroraeDecoration || type == DecorationModelData::QmlDecoration)) {
|
||||
if (m_decorations[ index.row()].closeDblClick == value.toBool()) {
|
||||
return false;
|
||||
}
|
||||
m_decorations[ index.row()].closeDblClick = value.toBool();
|
||||
KConfigGroup config(m_config, m_decorations[ index.row()].auroraeName);
|
||||
config.writeEntry("CloseOnDoubleClickMenuButton", value.toBool());
|
||||
config.sync();
|
||||
emit dataChanged(index, index);
|
||||
emit configChanged(m_decorations[ index.row()].auroraeName);
|
||||
return true;
|
||||
}
|
||||
return QAbstractItemModel::setData(index, value, role);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,11 @@ public:
|
|||
QString qmlPath;
|
||||
KDecorationDefines::BorderSize borderSize;
|
||||
KDecorationDefines::BorderSize buttonSize;
|
||||
/**
|
||||
* Whether the window gets closed on double clicking the Menu Button.
|
||||
* Only applies for Aurorae and QML Decoration.
|
||||
**/
|
||||
bool closeDblClick;
|
||||
|
||||
static bool less(const DecorationModelData& a, const DecorationModelData& b) {
|
||||
return a.name < b.name;
|
||||
|
@ -82,7 +87,8 @@ public:
|
|||
BorderSizeRole = Qt::UserRole + 11,
|
||||
BorderSizesRole = Qt::UserRole + 12,
|
||||
ButtonSizeRole = Qt::UserRole + 13,
|
||||
QmlMainScriptRole = Qt::UserRole + 14
|
||||
QmlMainScriptRole = Qt::UserRole + 14,
|
||||
CloseOnDblClickRole = Qt::UserRole + 15
|
||||
};
|
||||
DecorationModel(KSharedConfigPtr config, QObject* parent = 0);
|
||||
~DecorationModel();
|
||||
|
|
|
@ -352,9 +352,11 @@ void KWinDecorationModule::slotConfigureDecoration()
|
|||
dlg->setMainWidget(form);
|
||||
form->borderSizesCombo->setCurrentIndex(index.data(DecorationModel::BorderSizeRole).toInt());
|
||||
form->buttonSizesCombo->setCurrentIndex(index.data(DecorationModel::ButtonSizeRole).toInt());
|
||||
form->closeWindowsDoubleClick->setChecked(index.data(DecorationModel::CloseOnDblClickRole).toBool());
|
||||
if (dlg->exec() == KDialog::Accepted) {
|
||||
m_model->setData(index, form->borderSizesCombo->currentIndex(), DecorationModel::BorderSizeRole);
|
||||
m_model->setData(index, form->buttonSizesCombo->currentIndex(), DecorationModel::ButtonSizeRole);
|
||||
m_model->setData(index, form->closeWindowsDoubleClick->isChecked(), DecorationModel::CloseOnDblClickRole);
|
||||
reload = true;
|
||||
}
|
||||
delete dlg;
|
||||
|
|
Loading…
Reference in a new issue