File indexing completed on 2024-12-22 05:17:15

0001 /*
0002  * This file is part of the KDE wacomtablet project. For copyright
0003  * information and license terms see the AUTHORS and COPYING files
0004  * in the top-level directory of this distribution.
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License as
0008  * published by the Free Software Foundation; either version 2 of
0009  * the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #include "globalactions.h"
0021 #include <KGlobalAccel>
0022 #include <KLocalizedString>
0023 #include <QAction>
0024 #include <QIcon>
0025 
0026 using namespace Wacom;
0027 
0028 GlobalActions::GlobalActions(bool isConfiguration, QObject *parent)
0029     : KActionCollection(parent, QLatin1String("wacomtablet"))
0030 {
0031     setComponentDisplayName(i18n("Wacom Tablet"));
0032     setConfigGlobal(true);
0033 
0034     QAction *action = addAction(QLatin1String("Toggle touch tool"));
0035     action->setText(i18nc("@action", "Enable/Disable the Touch Tool"));
0036     action->setIcon(QIcon::fromTheme(QLatin1String("input-tablet")));
0037     KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::CTRL | Qt::META | Qt::Key_T));
0038     connect(action, SIGNAL(triggered()), this, SIGNAL(toggleTouchTriggered()));
0039 
0040     action = addAction(QLatin1String("Toggle stylus mode"));
0041     action->setText(i18nc("@action", "Toggle the Stylus Tool Relative/Absolute"));
0042     action->setIcon(QIcon::fromTheme(QLatin1String("draw-path")));
0043     KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::CTRL | Qt::META | Qt::Key_S));
0044     connect(action, SIGNAL(triggered()), this, SIGNAL(toggleStylusTriggered()));
0045 
0046     action = addAction(QLatin1String("Toggle screen map selection"));
0047     action->setText(i18nc("@action", "Toggle between all screens"));
0048     action->setIcon(QIcon::fromTheme(QLatin1String("draw-path")));
0049     KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::CTRL | Qt::META | Qt::Key_M));
0050     connect(action, SIGNAL(triggered()), this, SIGNAL(toggleScreenMapTriggered()));
0051 
0052     action = addAction(QLatin1String("Map to fullscreen"));
0053     action->setText(i18nc("@action Maps the area of the tablet to all available screen space (space depends on connected monitors)", "Map to fullscreen"));
0054     action->setIcon(QIcon::fromTheme(QLatin1String("video-display")));
0055     KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::CTRL | Qt::META | Qt::Key_F));
0056     connect(action, SIGNAL(triggered()), this, SIGNAL(mapToFullScreenTriggered()));
0057 
0058     action = addAction(QLatin1String("Map to screen 1"));
0059     action->setText(i18nc("@action", "Map to screen 1"));
0060     action->setIcon(QIcon::fromTheme(QLatin1String("video-display")));
0061     KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::CTRL | Qt::META | Qt::Key_1));
0062     connect(action, SIGNAL(triggered()), this, SIGNAL(mapToScreen1Triggered()));
0063 
0064     action = addAction(QLatin1String("Map to screen 2"));
0065     action->setText(i18nc("@action", "Map to screen 2"));
0066     action->setIcon(QIcon::fromTheme(QLatin1String("video-display")));
0067     KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::CTRL | Qt::META | Qt::Key_2));
0068     connect(action, SIGNAL(triggered()), this, SIGNAL(mapToScreen2Triggered()));
0069 
0070     action = addAction(QLatin1String("Next Profile"));
0071     action->setText(i18nc("@action Switch to the next profile in the rotation", "Next profile"));
0072     action->setIcon(QIcon::fromTheme(QLatin1String("go-next-use")));
0073     KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::CTRL | Qt::META | Qt::Key_N));
0074     connect(action, SIGNAL(triggered()), this, SIGNAL(nextProfileTriggered()));
0075 
0076     action = addAction(QLatin1String("Previous Profile"));
0077     action->setText(i18nc("@action Switch to the previous profile in the rotation", "Previous Profile"));
0078     action->setIcon(QIcon::fromTheme(QLatin1String("go-previous-use")));
0079     KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::CTRL | Qt::META | Qt::Key_P));
0080     connect(action, SIGNAL(triggered()), this, SIGNAL(previousProfileTriggered()));
0081 
0082     if (isConfiguration) {
0083         Q_FOREACH (auto act, actions()) {
0084             act->setProperty("isConfigurationAction", true);
0085         }
0086     }
0087 }
0088 
0089 #include "moc_globalactions.cpp"