2007-04-29 17:35:43 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1998 Matthias Ettrich <ettrich@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.
|
|
|
|
*/
|
|
|
|
|
2008-05-30 17:47:24 +00:00
|
|
|
#include "mouse.h"
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <QLabel>
|
2009-10-30 08:10:35 +00:00
|
|
|
#include <KComboBox>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include <QLayout>
|
|
|
|
#include <QSizePolicy>
|
|
|
|
#include <QBitmap>
|
|
|
|
|
2007-09-01 15:58:40 +00:00
|
|
|
#include <QGroupBox>
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <QPixmap>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
2008-08-25 02:22:56 +00:00
|
|
|
#include <QFormLayout>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-11-01 11:29:05 +00:00
|
|
|
#include <QDebug>
|
2007-09-07 14:33:31 +00:00
|
|
|
#include <kcolorscheme.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <kseparator.h>
|
2018-06-05 10:52:57 +00:00
|
|
|
#include <QtDBus>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-07-09 19:19:26 +00:00
|
|
|
#include <cstdlib>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-03-19 11:30:22 +00:00
|
|
|
#include "kwinoptions_settings.h"
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
namespace
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QPixmap maxButtonPixmaps[3];
|
|
|
|
|
|
|
|
void createMaxButtonPixmaps()
|
|
|
|
{
|
2020-03-19 11:30:22 +00:00
|
|
|
char const *maxButtonXpms[][3 + 13] = {
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
nullptr, nullptr, nullptr,
|
2011-01-30 14:34:42 +00:00
|
|
|
"...............",
|
|
|
|
".......#.......",
|
|
|
|
"......###......",
|
|
|
|
".....#####.....",
|
|
|
|
"..#....#....#..",
|
|
|
|
".##....#....##.",
|
|
|
|
"###############",
|
|
|
|
".##....#....##.",
|
|
|
|
"..#....#....#..",
|
|
|
|
".....#####.....",
|
|
|
|
"......###......",
|
|
|
|
".......#.......",
|
|
|
|
"..............."
|
|
|
|
},
|
|
|
|
{
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
nullptr, nullptr, nullptr,
|
2011-01-30 14:34:42 +00:00
|
|
|
"...............",
|
|
|
|
".......#.......",
|
|
|
|
"......###......",
|
|
|
|
".....#####.....",
|
|
|
|
".......#.......",
|
|
|
|
".......#.......",
|
|
|
|
".......#.......",
|
|
|
|
".......#.......",
|
|
|
|
".......#.......",
|
|
|
|
".....#####.....",
|
|
|
|
"......###......",
|
|
|
|
".......#.......",
|
|
|
|
"..............."
|
|
|
|
},
|
|
|
|
{
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
nullptr, nullptr, nullptr,
|
2011-01-30 14:34:42 +00:00
|
|
|
"...............",
|
|
|
|
"...............",
|
|
|
|
"...............",
|
|
|
|
"...............",
|
|
|
|
"..#.........#..",
|
|
|
|
".##.........##.",
|
|
|
|
"###############",
|
|
|
|
".##.........##.",
|
|
|
|
"..#.........#..",
|
|
|
|
"...............",
|
|
|
|
"...............",
|
|
|
|
"...............",
|
|
|
|
"..............."
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-07-10 13:04:52 +00:00
|
|
|
QByteArray baseColor(". c " + KColorScheme(QPalette::Active, KColorScheme::View).background().color().name().toLatin1());
|
|
|
|
QByteArray textColor("# c " + KColorScheme(QPalette::Active, KColorScheme::View).foreground().color().name().toLatin1());
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int t = 0; t < 3; ++t) {
|
|
|
|
maxButtonXpms[t][0] = "15 13 2 1";
|
|
|
|
maxButtonXpms[t][1] = baseColor.constData();
|
|
|
|
maxButtonXpms[t][2] = textColor.constData();
|
|
|
|
maxButtonPixmaps[t] = QPixmap(maxButtonXpms[t]);
|
|
|
|
maxButtonPixmaps[t].setMask(maxButtonPixmaps[t].createHeuristicMask());
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2012-09-24 02:28:33 +00:00
|
|
|
KWinMouseConfigForm::KWinMouseConfigForm(QWidget *parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
2012-10-27 21:11:22 +00:00
|
|
|
setupUi(parent);
|
2012-09-24 02:28:33 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 03:02:12 +00:00
|
|
|
KWinActionsConfigForm::KWinActionsConfigForm(QWidget *parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
2012-10-27 21:11:22 +00:00
|
|
|
setupUi(parent);
|
2012-09-24 03:02:12 +00:00
|
|
|
}
|
2012-09-24 02:28:33 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void KTitleBarActionsConfig::paletteChanged()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
createMaxButtonPixmaps();
|
2012-09-24 02:28:33 +00:00
|
|
|
for (int i=0; i<3; ++i) {
|
2020-03-19 11:30:22 +00:00
|
|
|
m_ui->kcfg_MaximizeButtonLeftClickCommand->setItemIcon(i, maxButtonPixmaps[i]);
|
|
|
|
m_ui->kcfg_MaximizeButtonMiddleClickCommand->setItemIcon(i, maxButtonPixmaps[i]);
|
|
|
|
m_ui->kcfg_MaximizeButtonRightClickCommand->setItemIcon(i, maxButtonPixmaps[i]);
|
2012-09-24 02:28:33 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-03-30 07:54:09 +00:00
|
|
|
KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent)
|
2020-03-19 11:30:22 +00:00
|
|
|
: KCModule(parent), standAlone(_standAlone)
|
2012-09-24 02:28:33 +00:00
|
|
|
, m_ui(new KWinMouseConfigForm(this))
|
2020-03-30 07:54:09 +00:00
|
|
|
, m_settings(settings)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2020-03-30 07:54:09 +00:00
|
|
|
addConfig(m_settings, this);
|
2020-03-19 11:30:22 +00:00
|
|
|
|
2012-09-24 02:28:33 +00:00
|
|
|
// create the items for the maximize button actions
|
2011-01-30 14:34:42 +00:00
|
|
|
createMaxButtonPixmaps();
|
2012-09-24 02:28:33 +00:00
|
|
|
for (int i=0; i<3; ++i) {
|
2020-03-19 11:30:22 +00:00
|
|
|
m_ui->kcfg_MaximizeButtonLeftClickCommand->addItem(maxButtonPixmaps[i], QString());
|
|
|
|
m_ui->kcfg_MaximizeButtonMiddleClickCommand->addItem(maxButtonPixmaps[i], QString());
|
|
|
|
m_ui->kcfg_MaximizeButtonRightClickCommand->addItem(maxButtonPixmaps[i], QString());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2020-03-19 11:30:22 +00:00
|
|
|
createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonLeftClickCommand);
|
|
|
|
createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonMiddleClickCommand);
|
|
|
|
createMaximizeButtonTooltips(m_ui->kcfg_MaximizeButtonRightClickCommand);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
load();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 02:28:33 +00:00
|
|
|
void KTitleBarActionsConfig::createMaximizeButtonTooltips(KComboBox *combo)
|
|
|
|
{
|
|
|
|
combo->setItemData(0, i18n("Maximize"), Qt::ToolTipRole);
|
|
|
|
combo->setItemData(1, i18n("Maximize (vertical only)"), Qt::ToolTipRole);
|
|
|
|
combo->setItemData(2, i18n("Maximize (horizontal only)"), Qt::ToolTipRole);
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KTitleBarActionsConfig::showEvent(QShowEvent *ev)
|
2009-12-14 03:18:43 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!standAlone) {
|
2009-12-14 03:18:43 +00:00
|
|
|
// Workaround KCModule::showEvent() calling load(), see bug 163817
|
2011-01-30 14:34:42 +00:00
|
|
|
QWidget::showEvent(ev);
|
2009-12-14 03:18:43 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
KCModule::showEvent(ev);
|
2009-12-14 03:18:43 +00:00
|
|
|
}
|
|
|
|
|
2014-02-15 18:57:22 +00:00
|
|
|
void KTitleBarActionsConfig::changeEvent(QEvent *ev)
|
|
|
|
{
|
|
|
|
if (ev->type() == QEvent::PaletteChange) {
|
|
|
|
paletteChanged();
|
|
|
|
}
|
|
|
|
ev->accept();
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void KTitleBarActionsConfig::save()
|
|
|
|
{
|
2020-03-19 11:30:22 +00:00
|
|
|
KCModule::save();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
if (standAlone) {
|
|
|
|
// Send signal to all kwin instances
|
|
|
|
QDBusMessage message =
|
|
|
|
QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 07:54:09 +00:00
|
|
|
KWindowActionsConfig::KWindowActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent)
|
2020-03-19 11:30:22 +00:00
|
|
|
: KCModule(parent), standAlone(_standAlone)
|
2012-09-24 03:02:12 +00:00
|
|
|
, m_ui(new KWinActionsConfigForm(this))
|
2020-03-30 07:54:09 +00:00
|
|
|
, m_settings(settings)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2020-03-30 07:54:09 +00:00
|
|
|
addConfig(m_settings, this);
|
2011-01-30 14:34:42 +00:00
|
|
|
load();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KWindowActionsConfig::showEvent(QShowEvent *ev)
|
2009-12-14 03:18:43 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!standAlone) {
|
|
|
|
QWidget::showEvent(ev);
|
2009-12-14 03:18:43 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
KCModule::showEvent(ev);
|
2009-12-14 03:18:43 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void KWindowActionsConfig::save()
|
|
|
|
{
|
2020-03-19 11:30:22 +00:00
|
|
|
KCModule::save();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
if (standAlone) {
|
|
|
|
// Send signal to all kwin instances
|
|
|
|
QDBusMessage message =
|
|
|
|
QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|