khotkeys: drop it

the only use case is to launch ksnapshot which can be done by
plasma-desktop, some of the actions code is borked (notably window
matching, global and menu actions were working) and I have no
intention to fix it. even if fixed when a window (and thus possibly
application) key is grabbed there is a chance the window (application)
may want to grab the grabbed key and fail (i.e. grab conflict) so it
shall be left to the application to set what keys shall be global
(grabbed) hence the bits to start ksnapshot are moved to plasma-desktop

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-29 22:57:16 +03:00
parent cf558d649b
commit 5949b572bc
161 changed files with 31 additions and 18182 deletions

View file

@ -292,7 +292,6 @@ if(Q_WS_X11 AND X11_Xinput_FOUND)
endif(Q_WS_X11 AND X11_Xinput_FOUND)
add_subdirectory(kcminit)
add_subdirectory(khotkeys)
if (LightDM_FOUND)
add_subdirectory(kgreeter)

View file

@ -18,7 +18,7 @@ check_function_exists(nice HAVE_NICE)
check_include_files(malloc.h HAVE_MALLOC_H)
kde4_bool_to_01(FONTCONFIG_FOUND HAVE_FONTCONFIG) # kcontrol/fonts
kde4_bool_to_01(FREETYPE_FOUND HAVE_FREETYPE) # kcontrol/fonts
kde4_bool_to_01(X11_XTest_FOUND HAVE_XTEST) # khotkeys, kxkb
kde4_bool_to_01(X11_XTest_FOUND HAVE_XTEST) # kcontrol/keyboard
kde4_bool_to_01(X11_Xcomposite_FOUND HAVE_XCOMPOSITE) # plasma, kwin
kde4_bool_to_01(X11_Xcursor_FOUND HAVE_XCURSOR) # many uses
kde4_bool_to_01(X11_Xdamage_FOUND HAVE_XDAMAGE) # kwin

View file

@ -1,20 +0,0 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/libkhotkeysprivate
${CMAKE_CURRENT_BINARY_DIR}/libkhotkeysprivate
# for kworkspace_export.h
${CMAKE_BINARY_DIR}/libs/kworkspace
)
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=1217)
# Convenience library
add_subdirectory( libkhotkeysprivate )
# has to be before kcm_hotkeys
add_subdirectory( app )
# kcm module to configure hotkeys
add_subdirectory( kcm_hotkeys )
# kdedmodule and standalone demon for hotkeys
add_subdirectory( data )
# add_subdirectory( test )

View file

@ -1,4 +0,0 @@
#! /bin/sh
#This file outputs in a separate line each file with a .desktop syntax
#that needs to be translated but has a non .desktop extension
find -name \*.khotkeys -print

View file

@ -1,4 +0,0 @@
#!/bin/bash
$EXTRACTRC `find . -name \*.ui` >> rc.cpp || exit 11
$XGETTEXT rc.cpp `find . -name \*.cpp -o -name \*.h` -o $podir/khotkeys.pot
rm -f rc.cpp

View file

@ -1,35 +0,0 @@
########### next target ###############
set(kded_khotkeys_PART_SRCS
kded.cpp
${CMAKE_CURRENT_BINARY_DIR}/org.kde.khotkeys.xml)
qt4_generate_dbus_interface(kded.h org.kde.khotkeys.xml )
kde4_add_plugin(kded_khotkeys ${kded_khotkeys_PART_SRCS})
target_link_libraries(kded_khotkeys
KDE4::kdeui
# I'm not sure if this is needed anymore. Check it
${X11_XTest_LIB}
khotkeysprivate
kworkspace
)
########### install files ###############
install(
TARGETS kded_khotkeys
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
)
install(
FILES khotkeys.desktop
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}/kded
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.khotkeys.xml
DESTINATION ${KDE4_DBUS_INTERFACES_INSTALL_DIR}
)

View file

@ -1,238 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#include "kded.h"
#include "action_data/action_data_group.h"
#include "action_data/menuentry_shortcut_action_data.h"
#include "actions/actions.h"
#include "shortcuts_handler.h"
#include <kdebug.h>
#include <kglobalaccel.h>
#include <kpluginfactory.h>
#include <kpluginloader.h>
#include <unistd.h>
#define COMPONENT_NAME "khotkeys"
K_PLUGIN_FACTORY(KHotKeysModuleFactory,
registerPlugin<KHotKeysModule>();
)
K_EXPORT_PLUGIN(KHotKeysModuleFactory(COMPONENT_NAME))
using namespace KHotKeys;
// KhotKeysModule
KHotKeysModule::KHotKeysModule(QObject* parent, const QList<QVariant>&)
: KDEDModule(parent)
, actions_root(NULL)
, _settings()
,_initialized(false)
{
// initialize
kDebug() << "Installing the delayed initialization callback.";
QMetaObject::invokeMethod( this, "initialize", Qt::QueuedConnection);
}
void KHotKeysModule::initialize()
{
if (_initialized)
{
return;
}
kDebug() << "Delayed initialization.";
_initialized = true;
// Initialize the global data, grab keys
KHotKeys::init_global_data( true, this );
// If a shortcut was changed (global shortcuts kcm), save
connect(
keyboard_handler.data(), SIGNAL(shortcutChanged()),
this, SLOT(save()));
// Read the configuration from file khotkeysrc
reread_configuration();
KGlobalAccel::cleanComponent(COMPONENT_NAME);
if (_settings.update())
{
save();
}
}
KHotKeysModule::~KHotKeysModule()
{
// actions_root belongs to _settings.
actions_root = NULL;
}
void KHotKeysModule::reread_configuration()
{
kDebug() << "Reloading the khotkeys configuration";
// Stop listening
actions_root = NULL; // Disables the dbus interface effectively
KHotKeys::khotkeys_set_active( false );
// Load the settings
_settings.reread_settings(true);
actions_root = _settings.actions();
KHotKeys::khotkeys_set_active( true );
}
SimpleActionData* KHotKeysModule::menuentry_action(const QString &storageId)
{
ActionDataGroup *menuentries = _settings.get_system_group(
ActionDataGroup::SYSTEM_MENUENTRIES);
// Now try to find the action
Q_FOREACH(ActionDataBase* element, menuentries->children())
{
SimpleActionData *actionData = dynamic_cast<SimpleActionData*>(element);
if (actionData && actionData->action())
{
MenuEntryAction *action = dynamic_cast<MenuEntryAction*>(actionData->action());
if (action && action->service() && (action->service()->storageId() == storageId))
{
return actionData;
}
}
}
return NULL;
}
QString KHotKeysModule::get_menuentry_shortcut(const QString &storageId)
{
SimpleActionData* actionData = menuentry_action(storageId);
// No action found
if (actionData == NULL) return "";
// The action must have a shortcut trigger. but don't assume to much
ShortcutTrigger* shortcutTrigger = dynamic_cast<ShortcutTrigger*>(actionData->trigger());
Q_ASSERT(shortcutTrigger);
if (shortcutTrigger == NULL) return "";
return shortcutTrigger->shortcut().primary().toString();
}
QString KHotKeysModule::register_menuentry_shortcut(
const QString &storageId,
const QString &sequence)
{
kDebug() << storageId << "(" << sequence << ")";
// Check the service we got. If it is invalid there is no need to
// continue.
KService::Ptr wantedService = KService::serviceByStorageId(storageId);
if (wantedService.isNull())
{
kError() << "Storage Id " << storageId << "not valid";
return "";
}
// Look for the action
SimpleActionData* actionData = menuentry_action(storageId);
// No action found. Create on if sequence is != ""
if (actionData == NULL)
{
kDebug() << "No action found";
// If the sequence is empty there is no need to create a action.
if (sequence.isEmpty()) return "";
kDebug() << "Creating a new action";
// Create the action
ActionDataGroup *menuentries = _settings.get_system_group(
ActionDataGroup::SYSTEM_MENUENTRIES);
MenuEntryShortcutActionData *newAction = new MenuEntryShortcutActionData(
menuentries,
wantedService->name(),
storageId,
KShortcut(sequence),
storageId);
newAction->enable();
_settings.write();
// Return the real shortcut
return newAction->trigger()->shortcut().primary().toString();
}
// We found a action
else
{
if (sequence.isEmpty())
{
kDebug() << "Deleting the action";
actionData->aboutToBeErased();
delete actionData;
_settings.write();
return "";
}
else
{
kDebug() << "Changing the action";
// The action must have a shortcut trigger. but don't assume to much
ShortcutTrigger* shortcutTrigger =
dynamic_cast<ShortcutTrigger*>(actionData->trigger());
Q_ASSERT(shortcutTrigger);
if (shortcutTrigger == NULL) return "";
// Change the actionData
shortcutTrigger->set_key_sequence(sequence);
_settings.write();
// Remove the resulting real shortcut
return shortcutTrigger->shortcut().primary().toString();
}
}
Q_ASSERT(false);
return "";
}
void KHotKeysModule::quit()
{
deleteLater();
}
void KHotKeysModule::save()
{
KHotKeys::khotkeys_set_active( false );
_settings.write();
KHotKeys::khotkeys_set_active( true );
}
#include "moc_kded.cpp"

View file

@ -1,103 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#ifndef _KHOTKEYS_KDED_H_
#define _KHOTKEYS_KDED_H_
#include <kdedmodule.h>
#include "settings.h"
#include <QtCore/QObject>
#include <QtDBus/QtDBus>
#include <QtGui/QKeySequence>
#include <KService>
namespace KHotKeys
{
class ActionDataGroup;
class SimpleActionData;
}
class KHotKeysModule
: public KDEDModule
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.khotkeys")
public Q_SLOTS:
Q_SCRIPTABLE void reread_configuration();
Q_SCRIPTABLE void quit();
/**
* Register an shortcut for service @serviceStorageId with the key
* sequence @seq.
*
* @param serviceStorageId the KService::storageId of the service
* @param sequence the key sequence to use
*
* @returns @c true if the key sequence was successfully set, @c if
* the sequence is not available.
*/
Q_SCRIPTABLE QString register_menuentry_shortcut(const QString &storageId, const QString &sequence);
/**
* Get the currently active shortcut for service @p serviceStorageId.
*
* @param serviceStorageId the KService::storageId of the service
*
* @returns the active global shortcuts for that service
*/
Q_SCRIPTABLE QString get_menuentry_shortcut(const QString &storageId);
private Q_SLOTS:
//! Save
void save();
//! Initialize the module. Delayed initialization.
void initialize();
public:
KHotKeysModule(QObject* parent, const QList<QVariant>&);
virtual ~KHotKeysModule();
private:
//! The action list from _settings for convenience
KHotKeys::ActionDataGroup* actions_root;
//! The current settings
KHotKeys::Settings _settings;
//! Is the module initialized
bool _initialized;
/**
* @name Some method in need for a better home
*/
//@{
//! Get the group for the menuentries. Will create it if needed
KHotKeys::ActionDataGroup *menuentries_group();
//! Find a menuentry_action for the service with @storageId in group @group
KHotKeys::SimpleActionData *menuentry_action(const QString &storageId);
//@}
};
//***************************************************************************
// Inline
//***************************************************************************
#endif

View file

@ -1,153 +0,0 @@
[Desktop Entry]
Name=Input Actions
Name[af]=Inset Aksies
Name[ar]=إجراءات الإدخال
Name[ast]=Aiciones d'entrada
Name[be]=Дзеянні уводу
Name[be@latin]=Uvodnyja aperacyi
Name[bg]=Входни действия
Name[bn_IN]=
Name[br]=Oberoù enkas
Name[bs]=Radnje unosa
Name[ca]=Accions d'entrada
Name[ca@valencia]=Accions d'entrada
Name[cs]=Vstupní činnosti
Name[csb]=Klawiszowé dzéjania
Name[da]=Input-handlinger
Name[de]=Tastenkombinationen
Name[el]=Ενέργειες εισόδου
Name[en_GB]=Input Actions
Name[eo]=Enir-agadoj
Name[es]=Acciones de Entrada
Name[et]=Sisestustoimingud
Name[eu]=Sarrerako ekintzak
Name[fa]=کنشهای ورودی
Name[fi]=Syöttötoiminnot
Name[fr]=Actions d'entrée
Name[fy]=Ynfieraksjes
Name[ga]=Gníomhartha Ionchurtha
Name[gl]=Accións de entrada
Name[gu]= િ
Name[he]=פעולות קלט
Name[hi]= ि
Name[hne]=
Name[hr]=Akcije prečaca
Name[hsb]=Zapodawanske akcije
Name[hu]=Beviteli műveletek
Name[ia]=Input Actions (Actiones de insertar)
Name[id]=Aksi Masukan
Name[is]=Inntaksaðgerðir
Name[it]=Azioni di immissione
Name[ja]=
Name[ka]=
Name[kk]=Енгізу әрекеттері
Name[km]=
Name[kn]= ಿ
Name[ko]=
Name[lt]=Įvesties veiksmai
Name[lv]=Ievades darbības
Name[mai]= ि
Name[mk]=Влезни дејства
Name[ml]=
Name[mr]= ि
Name[ms]=Tindakan Input
Name[nb]=Input-handlinger
Name[nds]=Ingaavakschonen
Name[ne]=
Name[nl]=Invoeracties
Name[nn]=Inn­handlingar
Name[pa]=
Name[pl]=Działania wejścia
Name[pt]=Acções de Entrada
Name[pt_BR]=Ações de entrada
Name[ro]=Acțiuni de intrare
Name[ru]=Действия
Name[se]=Sisačoallodoaimmat
Name[si]=
Name[sk]=Vstupné akcie
Name[sl]=Vnosna dejanja
Name[sr]=Радње уноса
Name[sr@ijekavian]=Радње уноса
Name[sr@ijekavianlatin]=Radnje unosa
Name[sr@latin]=Radnje unosa
Name[sv]=Inmatningsåtgärder
Name[ta]=
Name[te]=
Name[tg]=Тарзи вуруд
Name[th]=
Name[tr]=Girdi Eylemleri
Name[ug]=كىرگۈزۈش مەشغۇلاتى
Name[uk]=Ввід
Name[uz]=Kiritish amallari
Name[uz@cyrillic]=Киритиш амаллари
Name[vi]=Hành đng nhp
Name[wa]=Accions en intrêye
Name[x-test]=xxInput Actionsxx
Name[zh_CN]=
Name[zh_TW]=
Comment=Input Actions service performing configured actions on key presses
Comment[ar]=خدمة إجراءات الإدخال تنفذ الإجراءات المضبوطة عند ضغط المفاتيح
Comment[ast]=El serviciu d'Aiciones d'Entrada faciendo les aiciones configuraes según les tecles calcaes
Comment[bg]=Услугата за входни действия изпълнява зададени действия при натискане на клавиши комбинации
Comment[bs]=Servis radnji unosa, izvršava podešene radnje na pritiske tastera
Comment[ca]=Servei d'accions d'entrada que porta a terme accions configurades en prémer tecles
Comment[ca@valencia]=Servei d'accions d'entrada que porta a terme accions configurades en prémer tecles
Comment[cs]=Služba vstupních akcí jenž po stisknutí klávesy vykoná nakonfigurovanou akci
Comment[da]=Input-handlinger-tjeneste som udfører konfigurerede handlinger ved tastetryk
Comment[de]=Tastenkombinationen führt benutzerdefinierte Aktionen auf Tastendruck aus.
Comment[el]=Υπηρεσία ενεργειών εισόδου εκτελεί διαμορφωμένες ενέργειες με το πάτημα πλήκτρων
Comment[en_GB]=Input Actions service performing configured actions on key presses
Comment[es]=El servicio de Acciones de Entrada realizando las acciones configuradas para la pulsación de teclas
Comment[et]=Sisestustoimingute teenus, mis võimaldab klahve vajutades ette võtta teatavaid määratud toiminguid
Comment[eu]=Sarrerako ekintzen zerbitzua, konfiguratutako ekintzak burutzen teklak sakatutakoan
Comment[fi]=Syöttötoimintopalvelut suoritetaan asetetuille toiminnoille näppäinpainalluksilla
Comment[fr]=Service des actions d'entrée exécutant les actions configurées lors d'appuis de touches du clavier
Comment[gl]=O servizo de accións de entrada responde á pulsación de teclas facendo as accións que se configuren
Comment[he]=שירות פעולות קלט מבצע פעולות מוגדרות בלחיצת מקש.
Comment[hr]=Usluga akcije prečaca izvršava podešene akcije na pritisak tipke
Comment[hu]=A Beviteli műveletek szolgáltatás beállított műveleteket hajt végre billentyűlenyomáskor
Comment[ia]=Servicio de Input Actions que il exeque actiones configurate sur pressiones de claves
Comment[id]=Layanan Aksi Masukan melakukan aksi yang diatur ketika tombol ditekan
Comment[is]=Inntaksaðgerðaþjónustan sér um að framkvæma forstilltar aðgerðir þegar ýtt er á skilgreinda lykla
Comment[it]=Il servizio azioni di immissione effettua particolari azioni quando certi tasti vengono premuti
Comment[ja]=
Comment[kk]=Енгізу әрекеттер қызметі перне басқанда баптап қойған әрекетті істейді
Comment[km]=
Comment[kn]=ಿ ಿ, ಿ( ) ಿಿ ಿ
Comment[ko]=
Comment[lt]=Įvesties veiksmų servisas, paspaudus atitinkamus klavišus vykdantis nurodytus veiksmus
Comment[lv]=Ievades darbību serviss izpilda konfigurētās darbības pie taustiņu nospiešanas
Comment[mr]= ि ि
Comment[nb]=Tjeneste for inndata-handlinger, som utfører definerte handlinger for tastetrykk
Comment[nds]=Ingaavakschonen mit fastleggt Tastendruckakschonen utföhren
Comment[nl]=Service voor invoeracties die ingestelde acties uitvoert bij toetsen indrukken
Comment[nn]=Teneste for innhandlingar som utfører dei oppsette handlingane ved tastetrykk
Comment[pa]=ਿ ਿ
Comment[pl]=Usługa wykonująca skonfigurowane działania po naciśnięciu klawiszy
Comment[pt]=Serviço de acções de entrada que efectua acções configuradas ao carregar nas teclas
Comment[pt_BR]=Serviço de ações de entrada que realiza ações configuradas ao pressionar as teclas
Comment[ro]=Serviciu de acțiuni de intrare care execută acțiunile configurate la apăsarea tastelor
Comment[ru]=Служба действий выполняет настроенные действия при нажатии клавиш
Comment[si]=
Comment[sk]=Služba pre vstupné akcie, ktorá vykonáva nastavené akcie pri stlačení kláves
Comment[sl]=Storitev za vnosna dejanja, ki ob pritisku tipk izvede nastavljeno dejanje
Comment[sr]=Сервис радњи уноса, извршава подешене радње на притиске тастера
Comment[sr@ijekavian]=Сервис радњи уноса, извршава подешене радње на притиске тастера
Comment[sr@ijekavianlatin]=Servis radnji unosa, izvršava podešene radnje na pritiske tastera
Comment[sr@latin]=Servis radnji unosa, izvršava podešene radnje na pritiske tastera
Comment[sv]=Tjänst för inmatningsåtgärder som utför inställda åtgärder vid tangentnedtryckning
Comment[th]=
Comment[tr]=Tuş basımları üzerinde önceden yapılandırılmış eylemleri gerçekleştiren Girdi Eylemleri hizmeti
Comment[ug]=كىرگۈزۈش مەشغۇلات مۇلازىمىتى كۇنۇپكا بېسىلغاندا ئالدىن سەپلەنگەن مەشغۇلاتنى ئىجرا قىلىدۇ
Comment[uk]=Служба «Ввід» виконує вказані дії у відповідь на натискання певних клавіш
Comment[vi]=Dch v Hành đng nhp thc hin các hành đng đưc cu hình khi có phím nhn
Comment[wa]=Siervice des faitindjes d' intrêye fijhant les faitindjes apontieyes cwand on tchôke les tapes
Comment[x-test]=xxInput Actions service performing configured actions on key pressesxx
Comment[zh_CN]=
Comment[zh_TW]=
Type=Service
X-KDE-ServiceTypes=KDEDModule
X-KDE-Library=khotkeys
X-KDE-DBus-ModuleName=khotkeys
X-KDE-Kded-autoload=true
OnlyShowIn=KDE;

View file

@ -1,6 +0,0 @@
install(
FILES
defaults.khotkeys
printscreen.khotkeys
DESTINATION ${KDE4_DATA_INSTALL_DIR}/khotkeys
)

View file

@ -1,400 +0,0 @@
[Data]
DataCount=1
[Data_1]
Comment=Comment
Comment[ar]=التعليق
Comment[ast]=Comentariu
Comment[bg]=Коментар
Comment[bn]=মন্তব্য
Comment[bs]=Komentar
Comment[ca]=Comentari
Comment[ca@valencia]=Comentari
Comment[cs]=Komentář
Comment[csb]=Dopòwiesc
Comment[da]=Kommentar
Comment[de]=Kommentar
Comment[el]=Σχόλιο
Comment[en_GB]=Comment
Comment[eo]=Komento
Comment[es]=Comentario
Comment[et]=Kommentaar
Comment[eu]=Iruzkina
Comment[fi]=Kommentti
Comment[fr]=Commentaire
Comment[fy]=Kommentaar
Comment[ga]=Nóta
Comment[gl]=Comentario
Comment[gu]=ટીપ્પણી
Comment[he]=הערה
Comment[hi]=टिप्पणी
Comment[hr]=Komentar
Comment[hu]=Megjegyzés
Comment[ia]=Commento
Comment[id]=Komentar
Comment[is]=Athugasemd
Comment[it]=Commento
Comment[ja]=コメント
Comment[kk]=Түсініктеме
Comment[km]=មតិយោបល់
Comment[kn]=ಟಿಪ್ಪಣಿ
Comment[ko]=설명
Comment[lt]=Komentaras
Comment[lv]=Komentārs
Comment[mai]=टिप्पणी
Comment[mk]=Коментар
Comment[ml]=അഭിപ്രായം
Comment[mr]=टीप
Comment[nb]=Kommentar
Comment[nds]=Kommentar
Comment[nl]=Toelichting
Comment[nn]=Merknad
Comment[pa]=ਟਿੱਪਣੀ
Comment[pl]=Komentarz
Comment[pt]=Comentário
Comment[pt_BR]=Comentário
Comment[ro]=Comentariu
Comment[ru]=Комментарий
Comment[si]=සටහන
Comment[sk]=Komentár
Comment[sl]=Opomba
Comment[sr]=Коментар
Comment[sr@ijekavian]=Коментар
Comment[sr@ijekavianlatin]=Komentar
Comment[sr@latin]=Komentar
Comment[sv]=Kommentar
Comment[tg]=Шарҳ
Comment[th]=คำอธิบาย
Comment[tr]=Açıklamalar
Comment[ug]=ئىزاھات
Comment[uk]=Коментар
Comment[vi]=Chú thích
Comment[wa]=Rawete
Comment[x-test]=xxCommentxx
Comment[zh_CN]=注释
Comment[zh_TW]=註解
DataCount=1
Enabled=true
Name=KMenuEdit
Name[ar]=محرّر قوائم كدي
Name[ast]=KMenuEdit
Name[bg]=Редактор на системното меню
Name[bn]=KMenuEdit
Name[bs]=Uređivač Kmenija
Name[ca]=KMenuEdit
Name[ca@valencia]=KMenuEdit
Name[cs]=Editor nabídek
Name[csb]=Editora menu KDE
Name[da]=KMenuEdit
Name[de]=KMenuEdit
Name[el]=KMenuEdit
Name[en_GB]=KMenuEdit
Name[eo]=KMenuredaktilo
Name[es]=KMenuEdit
Name[et]=KMenuEdit
Name[eu]=KMenuEdit
Name[fi]=Valikkomuokkain
Name[fr]=KMenuEdit
Name[fy]=KMenuEdit
Name[ga]=KMenuEdit
Name[gl]=KMenuEdit
Name[gu]=KMenuEdit
Name[he]=עורך תפריט הK
Name[hi]=KMenuEdit
Name[hr]=Uređivač izbornika
Name[hu]=KMenuEdit
Name[ia]=KMenuEdit
Name[id]=KMenuEdit
Name[is]=Sýsla með aðalvalmynd
Name[it]=KMenuEdit
Name[ja]=KMenuEdit
Name[kk]=KMenuEdit
Name[km]=KMenuEdit
Name[kn]=KMenuEdit
Name[ko]=KMenuEdit
Name[lt]=KMenuEdit
Name[lv]=KMenuEdit
Name[mai]=केमेनूसंपादक
Name[mk]=KMenuEdit
Name[ml]=കെമെനുഎഡിറ്റ്
Name[mr]=के मेन्यू एडिट
Name[nb]=KMenuEdit
Name[nds]=KMenuEdit
Name[nl]=KMenuEdit
Name[nn]=KMenuEdit
Name[pa]=ਕੇ-ਮੇਨੂ ਐਡੀਟਰ
Name[pl]=Edytor menu
Name[pt]=KMenuEdit
Name[pt_BR]=KMenuEdit
Name[ro]=KMenuEdit
Name[ru]=KMenuEdit
Name[si]=KMenuEdit
Name[sk]=KMenuEdit
Name[sl]=KMenuEdit
Name[sr]=Уређивач К‑менија
Name[sr@ijekavian]=Уређивач К‑менија
Name[sr@ijekavianlatin]=Uređivač Kmenija
Name[sr@latin]=Uređivač Kmenija
Name[sv]=Menyeditor
Name[tg]=Таҳриргари меню
Name[th]=แก้ไขเมนู-K
Name[tr]=KMenuEdit
Name[ug]=KMenuEdit
Name[uk]=KMenuEdit
Name[vi]=KMenuEdit
Name[wa]=KMenuEdit
Name[x-test]=xxKMenuEditxx
Name[zh_CN]=KMenuEdit
Name[zh_TW]=選單編輯器
SystemGroup=1
Type=ACTION_DATA_GROUP
[Data_1Conditions]
Comment=
ConditionsCount=0
[Data_1_1]
Comment=Comment
Comment[ar]=التعليق
Comment[ast]=Comentariu
Comment[bg]=Коментар
Comment[bn]=মন্তব্য
Comment[bs]=Komentar
Comment[ca]=Comentari
Comment[ca@valencia]=Comentari
Comment[cs]=Komentář
Comment[csb]=Dopòwiesc
Comment[da]=Kommentar
Comment[de]=Kommentar
Comment[el]=Σχόλιο
Comment[en_GB]=Comment
Comment[eo]=Komento
Comment[es]=Comentario
Comment[et]=Kommentaar
Comment[eu]=Iruzkina
Comment[fi]=Kommentti
Comment[fr]=Commentaire
Comment[fy]=Kommentaar
Comment[ga]=Nóta
Comment[gl]=Comentario
Comment[gu]=ટીપ્પણી
Comment[he]=הערה
Comment[hi]=टिप्पणी
Comment[hr]=Komentar
Comment[hu]=Megjegyzés
Comment[ia]=Commento
Comment[id]=Komentar
Comment[is]=Athugasemd
Comment[it]=Commento
Comment[ja]=コメント
Comment[kk]=Түсініктеме
Comment[km]=មតិយោបល់
Comment[kn]=ಟಿಪ್ಪಣಿ
Comment[ko]=설명
Comment[lt]=Komentaras
Comment[lv]=Komentārs
Comment[mai]=टिप्पणी
Comment[mk]=Коментар
Comment[ml]=അഭിപ്രായം
Comment[mr]=टीप
Comment[nb]=Kommentar
Comment[nds]=Kommentar
Comment[nl]=Toelichting
Comment[nn]=Merknad
Comment[pa]=ਟਿੱਪਣੀ
Comment[pl]=Komentarz
Comment[pt]=Comentário
Comment[pt_BR]=Comentário
Comment[ro]=Comentariu
Comment[ru]=Комментарий
Comment[si]=සටහන
Comment[sk]=Komentár
Comment[sl]=Opomba
Comment[sr]=Коментар
Comment[sr@ijekavian]=Коментар
Comment[sr@ijekavianlatin]=Komentar
Comment[sr@latin]=Komentar
Comment[sv]=Kommentar
Comment[tg]=Шарҳ
Comment[th]=คำอธิบาย
Comment[tr]=Açıklamalar
Comment[ug]=ئىزاھات
Comment[uk]=Коментар
Comment[vi]=Chú thích
Comment[wa]=Rawete
Comment[x-test]=xxCommentxx
Comment[zh_CN]=注释
Comment[zh_TW]=註解
Enabled=true
Name=Search
Name[ar]=ابحث
Name[ast]=Gueta
Name[bg]=Търсене
Name[bn]=অনুসন্ধান
Name[bs]=Pretraga
Name[ca]=Cerca
Name[ca@valencia]=Cerca
Name[cs]=Hledat
Name[csb]=Szëkba
Name[da]=Søg
Name[de]=Suchen
Name[el]=Αναζήτηση
Name[en_GB]=Search
Name[eo]=Serĉo
Name[es]=Búsqueda
Name[et]=Otsing
Name[eu]=Bilatu
Name[fi]=Haku
Name[fr]=Rechercher
Name[fy]=Sykje
Name[ga]=Cuardach
Name[gl]=Buscar
Name[gu]=શોધ
Name[he]=חפש
Name[hi]=खोज
Name[hr]=Pretraživanje
Name[hu]=Keresés
Name[ia]=Cerca
Name[id]=Cari
Name[is]=Leita
Name[it]=Ricerca
Name[ja]=検索
Name[kk]=Іздеу
Name[km]=ការ​ស្វែងរក
Name[kn]=ಹುಡುಕು
Name[ko]=검색
Name[lt]=Paieška
Name[lv]=Meklēšana
Name[mai]=खोजू
Name[mk]=Пребарување
Name[ml]=തെരച്ചില്‍
Name[mr]=शोध
Name[nb]=Søk
Name[nds]=Söök
Name[nl]=Zoeken
Name[nn]=Søk
Name[pa]=ਖੋਜ
Name[pl]=Znajdź
Name[pt]=Pesquisa
Name[pt_BR]=Pesquisar
Name[ro]=Caută
Name[ru]=Поиск
Name[si]=සෙවුම
Name[sk]=Hľadať
Name[sl]=Poišči
Name[sr]=Претрага
Name[sr@ijekavian]=Претрага
Name[sr@ijekavianlatin]=Pretraga
Name[sr@latin]=Pretraga
Name[sv]=Sök
Name[tg]=Ҷустуҷӯи PHP
Name[th]=ค้นหา
Name[tr]=Ara
Name[ug]=ئىزدە
Name[uk]=Пошук
Name[wa]=Trover
Name[x-test]=xxSearchxx
Name[zh_CN]=搜索
Name[zh_TW]=搜尋
Type=SIMPLE_ACTION_DATA
[Data_1_1Actions]
ActionsCount=1
[Data_1_1Actions0]
CommandURL=http://google.com
Type=COMMAND_URL
[Data_1_1Conditions]
Comment=
ConditionsCount=0
[Data_1_1Triggers]
Comment=Simple_action
Comment[ar]=إجراء_بسيط
Comment[ast]=Aición cenciella
Comment[be@latin]=Prostaja_aperacyja
Comment[bg]=Обикновеноействие
Comment[bs]=Prosta_radnja
Comment[ca]=Acció_senzilla
Comment[ca@valencia]=Acció_senzilla
Comment[cs]=Jednoduchá činnost
Comment[csb]=Prosté_dzejanié
Comment[da]=Simple_action
Comment[de]=Einfache_Aktion
Comment[el]=Απλή_ενέργεια
Comment[en_GB]=Simple_action
Comment[eo]=Simpla ago
Comment[es]=Acción sencilla
Comment[et]=Lihtne toiming
Comment[eu]=Ekintza_sinplea
Comment[fi]=Yksinkertainen_toiminto
Comment[fr]=Action simple
Comment[fy]=Ienfâldige_aksje
Comment[ga]=Gníomh simplí
Comment[gl]=Acción_sinxela
Comment[gu]=સરળ_ક્રિયા
Comment[he]=פעולה פשוטה
Comment[hi]=सामान्य_क्रिया
Comment[hne]=सामान्य_काम
Comment[hr]=Jednostavna_akcija
Comment[hsb]=Jednora_akcija
Comment[hu]=Egyszerű_művelet
Comment[ia]=Simple_action
Comment[id]=Aksi_sederhana
Comment[is]=Einföld_aðgerð
Comment[it]=Azione_semplice
Comment[ja]=Simple_action
Comment[kk]=Қарапайым_әрекет
Comment[km]=Simple_action
Comment[kn]=ಸರಳ_ಕ್ರಿಯೆ
Comment[ko]=Simple_action
Comment[ku]=Simple_action
Comment[lt]=Paprastas_veiksmas
Comment[lv]=Vieknārša_darbība
Comment[mai]=सामान्य_क्रिया
Comment[mk]=Едноставноејство
Comment[ml]=ലഘു പ്രവൃത്തി
Comment[mr]=सामान्य_क्रिया
Comment[nb]=Enkel_handling
Comment[nds]=Eenfach_Akschoon
Comment[ne]=साधारण कार्य
Comment[nl]=Eenvoudige_handeling
Comment[nn]=Enkel_handling
Comment[pa]=Simple_action
Comment[pl]=Proste_działanie
Comment[pt]=Acção Simples
Comment[pt_BR]=Ação simples
Comment[ro]=Simple_action
Comment[ru]=Простое действие
Comment[se]=Oktageardánis_dáhpáhus
Comment[si]=සරල_ක්රියාව
Comment[sk]=Jednoduchá akcia
Comment[sl]=Preprosto_dejanje
Comment[sr]=Проста_радња
Comment[sr@ijekavian]=Проста_радња
Comment[sr@ijekavianlatin]=Prosta_radnja
Comment[sr@latin]=Prosta_radnja
Comment[sv]=Enkel åtgärd
Comment[ta]=Simple_action
Comment[te]=సాదారణ_చర్య
Comment[tg]=Амали оддӣ
Comment[th]=Simple_action
Comment[tr]=Basit_eylem
Comment[ug]=ئاددىي_ھەرىكەت
Comment[uk]=Simple_action
Comment[vi]=Hành động đơn giản
Comment[wa]=Simpe_accion
Comment[x-test]=xxSimple_actionxx
Comment[zh_CN]=简易_动作
Comment[zh_TW]=簡易動作
TriggersCount=1
[Data_1_1Triggers0]
Key=Search
Type=SHORTCUT
Uuid=d03619b6-9b3c-48cc-9d9c-a2aadb485550
[Main]
Version=3
ImportId=defaults

View file

@ -1,436 +0,0 @@
[Data]
DataCount=1
[Data_1]
Comment=This group contains actions that are set up by default.
Comment[ar]=المجموعة تحتوي إعدادات مبدئية
Comment[ast]=Esti grupu contién les aiciones predeterminaes.
Comment[be@latin]=Hety hurt źmiaščaje zmoŭčana ŭklučanyja aperacyi.
Comment[bg]=Тази група съдържа действия, които са зададени по подразбирани.
Comment[bs]=Ova grupa sadrži podrazumijevano postavljene radnje.
Comment[ca]=Aquest grup conté accions que estan configurades per omissió.
Comment[ca@valencia]=Este grup conté accions que estan configurades per omissió.
Comment[cs]=Tato skupina obsahuje činnosti, které jsou ve výchozím stavu nastaveny.
Comment[csb]=No karno zamëkô w se domëslné nastôwë dzéjaniów.
Comment[da]=Denne gruppe indeholder handlinger som er sat op som standard.
Comment[de]=Diese Gruppe enthält einige voreingestellte Aktionen.
Comment[el]=Η ομάδα αυτή περιέχει ενέργειες που είναι προκαθορισμένα καθορισμένες.
Comment[en_GB]=This group contains actions that are set up by default.
Comment[eo]=Ĉi tiu grupo enhavas agojn antaŭdifinitajn defaŭlte.
Comment[es]=Este grupo contiene las acciones predeterminadas.
Comment[et]=See grupp sisaldab vaikimisi määratud toiminguid.
Comment[eu]=Multzo honek lehenetsiz ezartzen diren ekintzak ditu.
Comment[fa]=این گروه شامل کنشهایی است که به طور پیش‌فرض برپا می‌شوند.
Comment[fi]=Tämä ryhmä sisältää oletuksena käytössä olevia toimintoja
Comment[fr]=Ce groupe contient les actions définies par défaut.
Comment[fy]=Dizze groep befettet aksjes dy standert ynsteld binne.
Comment[ga]=Tá gníomhartha réamhshocraithe sa ghrúpa seo.
Comment[gl]=Este grupo contén accións que están definidas por omisión.
Comment[gu]=આ સમૂહ મૂળભૂત રીત ગોઠવવામાં આવેલ ક્રિયાઓ ધરાવે છે.
Comment[he]=קבוצה זו כוללת פעולות המוגדרות כברירת מחדל
Comment[hi]=इस समूह में क्रियाएं हैं जो डिफ़ॉल्ट से सेट हैं
Comment[hne]=ए वाले समूह मं वो काम हे जउन हर डिफाल्ट से सेट हे
Comment[hr]=Ova grupa sadrži uobičajeno postavljene akcije.
Comment[hsb]=Tuta skupina wobsahuje standardowe akcije.
Comment[hu]=Ez a csoport az alapértelmezésben aktivált műveleteket tartalmazza.
Comment[ia]=Iste gruppo contine actiones que es fixate per definition.
Comment[id]=Grup ini berisi aksi yang diatur pada keadaan standar.
Comment[is]=Þessi hópur inniheldur aðgerðir sem eru sjálfgefið uppsettar.
Comment[it]=Questo gruppo contiene azioni attive in modo predefinito.
Comment[ja]=このグループには標準で設定されているアクションが含まれています。
Comment[kk]=Бұл топты әдетте орнатылған әрекеттер құрайды.
Comment[km]=ក្រុម​នេះ​មាន​អំពើ​ដែល​រៀបចំ​ឡើង​តាម​លំនាំ​ដើម​ ។
Comment[kn]=ಪೂರ್ವನಿಯೋಜಿತವಾಗಿ ಸಂಯೋಜಿಸಲಾದ ಕ್ರಿಯೆಗಳನ್ನು ಈ ಸಮೂಹವು ಒಳಗೊಂಡಿದೆ.
Comment[ko]=이 그룹은 기본값으로 설정되어 있는 동작을 포함합니다.
Comment[lt]=Šioje grupėje yra veiksmai, kurie yra iš anksto nustatyti.
Comment[lv]=Šī grupa satur noklusētās darbības.
Comment[mk]=Оваа група содржи дејства што се стандардно поставени.
Comment[ml]=സഹജമായി ക്രമീകരിച്ചിട്ടുള്ള പ്രവര്‍ത്തികള്‍ ഈ കൂട്ടത്തില്‍ ലഭ്യമാകുന്നു.
Comment[mr]=या समूह मध्ये मूलभूतरित्या स्थापीत क्रिया समाविष्टीत आहे.
Comment[nb]=Denne gruppa inneholder standardhandlinger.
Comment[nds]=Disse Koppel bargt vörinstellt Akschonen.
Comment[ne]=यो समूहले कार्य समाविष्ट गर्दछ जुन पूर्वनिर्धारित रूपमा सेट गरिएका छन् ।
Comment[nl]=Deze groep bevat handelingen die standaard zijn ingesteld.
Comment[nn]=Denne gruppa inneheld handlingar som er sett opp som standard.
Comment[pa]=ਇਹ ਗਰੁੱਪ ਵਿੱਚ ਐਕਸ਼ਨ ਹਨ, ਜੋ ਕਿ ਡਿਫਾਲਟ ਰੂਪ ਵਿੱਚ ਸੈੱਟਅੱਪ ਕੀਤੇ ਜਾਂਦੇ ਹਨ।
Comment[pl]=Ta grupa zawiera działania, które są ustawione domyślnie.
Comment[pt]=Este grupo contém as acções que estão configuradas por omissão.
Comment[pt_BR]=Este grupo contém ações que, por padrão, estão configuradas.
Comment[ro]=Acest grup conține acțiuni stabilite implicit.
Comment[ru]=Группа действий по умолчанию.
Comment[se]=Dán joavkkus leat doaimmat mat leat heivehuvvon standárdan.
Comment[si]=මෙම කණ්ඩායම පෙරනිමියෙන් සැකසූ ක්‍රියාවන් දරයි.
Comment[sk]=Táto skupina obsahuje akcie, ktoré sú nastavené ako predvolené.
Comment[sl]=Ta skupina vsebuje privzeto nastavljena dejanja.
Comment[sr]=Ова група садржи подразумевано постављене радње.
Comment[sr@ijekavian]=Ова група садржи подразумијевано постављене радње.
Comment[sr@ijekavianlatin]=Ova grupa sadrži podrazumijevano postavljene radnje.
Comment[sr@latin]=Ova grupa sadrži podrazumevano postavljene radnje.
Comment[sv]=Gruppen innehåller åtgärder som normalt är förinställda.
Comment[ta]=This group contains actions that are set up by default.
Comment[te]=ఈ సమూహం అప్రమేయంగా అమర్చిన చర్యలను కలిగివుంటుంది.
Comment[tg]=Эта группа содержит действия, настроенные по умолчанию
Comment[th]=กลุ่มนี้จะมีการกระทำที่ได้ตั้งไว้แล้วโดยปริยาย
Comment[tr]=Bu grup öntanımlı olarak ayarlanan eylemleri içerir.
Comment[ug]=بۇ گۇرۇپپا كۆڭۈلدىكى بەلگىلەنگەن مەشغۇلاتنى ئۆز ئىچىگە ئالغان.
Comment[uk]=Ця група містить дії, які типово налаштовано.
Comment[vi]=Nhóm này chứa các hành động được thiết lập theo mặc định.
Comment[wa]=I gn a dins c' groupe ci des faitindjes k' i sont apontyî por vos.
Comment[x-test]=xxThis group contains actions that are set up by default.xx
Comment[zh_CN]=这个组包含默认设置的动作。
Comment[zh_TW]=此群組包含了預先設定好的動作。
DataCount=1
Enabled=true
Name=Preset Actions
Name[af]=Voorafgestelde aksies
Name[ar]=الإجراءات مسبقة التعيين
Name[ast]=Aiciones predefiníes
Name[be]=Існуючыя дзеянні
Name[bg]=Фиксирани действия
Name[bn]=পূর্বনির্ধারিত অ্যাকশন
Name[bn_IN]=পূর্বনির্ধারিত কর্ম
Name[bs]=Predefinisane radnje
Name[ca]=Accions predefinides
Name[ca@valencia]=Accions predefinides
Name[cs]=Přednastavené činnosti
Name[csb]=Nastôwioné dzéjania
Name[da]=Forvalgte handlinger
Name[de]=Voreingestellte Aktionen
Name[el]=Προκαθορισμένες ενέργειες
Name[en_GB]=Preset Actions
Name[eo]=Antaŭdifinitaj agoj
Name[es]=Acciones predefinidas
Name[et]=Valmistoimingud
Name[eu]=Ekintza aurrezarriak
Name[fa]=پیش‌تنظیم کنشها
Name[fi]=Esiasetetut toiminnat
Name[fr]=Actions prédéfinies
Name[fy]=Foarynstelde aksjes
Name[ga]=Gníomhartha Réamhshocraithe
Name[gl]=Accións preconfiguradas
Name[gu]=ક્રિયાઓ ગોઠવો
Name[he]=פעולות מוגדרות מראש
Name[hi]=प्रीसेट क्रियाएँ
Name[hne]=प्रीसेट काम
Name[hr]=Pripremljene aktivnosti
Name[hsb]=Předdefinowane akcije
Name[hu]=Beállított műveletek
Name[ia]=Actiones de programmar (preset)
Name[id]=Aksi Penyetelan
Name[is]=Forskilgreindar aðgerðir
Name[it]=Azioni predefinite
Name[ja]=プリセットアクション
Name[kk]=Дайын әрекеттері
Name[km]=កំណត់​អំពើ​ជាមុន​
Name[kn]=ಕ್ರಿಯೆಗಳನ್ನುಪೂರ್ವನಿಯೋಜಿಸು
Name[ko]=미리 정의된 동작
Name[lt]=Iš anksto nustatyti veiksmai
Name[lv]=Noklusētās darbības
Name[mai]=प्रीसेट काजसभ
Name[mk]=Стандардни дејства
Name[ml]=മുമ്പു് ക്രമീകരിച്ചിട്ടുള്ള പ്രവൃത്തികള്‍
Name[mr]=पूर्वनिश्चित क्रिया
Name[nb]=Forhåndsdefinerte handlinger
Name[nds]=Vörinstellt Akschonen
Name[ne]=कार्य प्रिसेट गर्नुहोस्
Name[nl]=Voorgedefinieerde handelingen
Name[nn]=Førehandsdefinerte handlingar
Name[pa]=ਪ੍ਰੀ-ਸੈੱਟ ਐਕਸ਼ਨ
Name[pl]=Wcześniej ustawione działania
Name[pt]=Acções Predefinidas
Name[pt_BR]=Ações predefinidas
Name[ro]=Acțiuni prestabilite
Name[ru]=Примеры действий
Name[se]=Ovdalgihtii meroštuvvon doaimmat
Name[si]=පවතින ක්‍රියාවන්
Name[sk]=Prednastavené akcie
Name[sl]=Predloge nastavitev dejanj
Name[sr]=Предефинисане радње
Name[sr@ijekavian]=Предефинисане радње
Name[sr@ijekavianlatin]=Predefinisane radnje
Name[sr@latin]=Predefinisane radnje
Name[sv]=Förinställda åtgärder
Name[ta]=முன்னமைக்கப்பட்ட செயல்கள்
Name[te]=ప్రస్తుత చర్యలు
Name[tg]=Амалҳои пештанзимшуда
Name[th]=การกระทำที่ตั้งไว้แล้ว
Name[tr]=Eylemleri Belirle
Name[ug]=ئالدىن تەڭشەلگەن مەشغۇلات
Name[uk]=Заздалегідь визначені дії
Name[vi]=Hành động định sẵn
Name[wa]=Accions prédefineyes
Name[x-test]=xxPreset Actionsxx
Name[zh_CN]=预设动作
Name[zh_TW]=預先設定動作
SystemGroup=0
Type=ACTION_DATA_GROUP
AllowMerge=true
[Data_1Conditions]
Comment=
ConditionsCount=0
[Data_1_1]
Comment=Launches KSnapShot when PrintScrn is pressed.
Comment[ar]=يطلق مصور الشاشة كيدي عند الضغط على زر PrintScrn
Comment[ast]=Llanza KSnapShot al calcar Impr Pant.
Comment[be@latin]=Uklučaje prahramu „KSnapShot” pa nacisku klavišy „PrintScrn”.
Comment[bg]=Стартиране на KSnapShot при натискане на клавиша "PrintScrn"
Comment[bn_IN]=PrintScrn টেপা হলে KSnapShot আরম্ভ করা হবে
Comment[bs]=Pokreće Ksnimak po pritisku na PrintScreen
Comment[ca]=Executa el KSnapShot quan es prem ImprPant.
Comment[ca@valencia]=Executa el KSnapShot quan es prem ImprPant.
Comment[cs]=Po stisku PrintScreen spustí KSnapshot.
Comment[csb]=Zrëszô KSnapShot, jeżlë je wcësniãté „Drëkùjë ekran“.
Comment[da]=Starter KSnapshot når der trykkes på PrintScreen.
Comment[de]=Startet KSnapShot, wenn „Bildschirm Drucken“ gedrückt worden ist.
Comment[el]=Εκτέλεση του KSnapShot όταν πατηθεί το PrintScrn.
Comment[en_GB]=Launches KSnapShot when PrintScrn is pressed.
Comment[eo]=Lanĉas KSnapShot (Ekranfotilon) kiam vi premas la "Presi Ekranon" klavon.
Comment[es]=Lanza KSnapShot cuando se pulsa Impr Pant.
Comment[et]=Käivitab PrintSrcni vajutamisel KSnapShoti.
Comment[eu]=KSnapShot abiarazten du InprPant sakatzean.
Comment[fa]=وقتی PrintScrn فشار داده می‌شود، KSnapShot را راه می‌اندازد.
Comment[fi]=Käynnistää KSnapShot-ohjelman kun painetaan PrintScrn-näppäintä
Comment[fr]=Lance KSnapShot lors de l'appui sur la touche « Impr. écran ».
Comment[fy]=Set útein mei KSnapShot as PrintScrn yndrukt wurdt.
Comment[ga]=Tosaigh KSnapShot nuair a bhrúitear PrintScrn.
Comment[gl]=Inicia KSnapShot cando se preme ImpPant.
Comment[gu]=જ્યારે PrintScrn દબાવાય છે ત્યારે KSnapShot શરૂ કરે છે
Comment[he]=הפעלת KSnapShot בעת הקשה על PrintScrn.
Comment[hi]=जब प्रिंटस्क्रीन बटन दबाया जाता है तो के-स्नैप-शॉट को चालू करता है.
Comment[hne]=जब प्रिंटस्क्रीन दबाय जाथे तब केस्नेपसाट ल चलाथे.
Comment[hr]=Pokreće KSnapShot kad je pritisnuta tipka PrintScrn.
Comment[hsb]=Startuje KSnapShot, hdyž so 'Druck/S-Abf' stłóči.
Comment[hu]=Elindítja a KSnapShotot a PrintScreen lenyomásakor.
Comment[ia]=Il lancea KSnapShot quando PrintScrn es pressate.
Comment[id]=Jalankan KSnapShot ketika PrintScrn ditekan.
Comment[is]=Ræsir KSnapShot þegar ýtt er á PrintScrn lykilinn.
Comment[it]=Avvia KSnapShot quando viene premuto il tasto Stamp.
Comment[ja]=PrintScrn を押して KSnapShot を起動します。
Comment[kk]=PrintScrn басылғанда KSnapShot-ты жегеді.
Comment[km]=ចាប់ផ្ដើម​​កម្មវិធី KSnapShot នៅ​ពេល​​​ចុច​ប៊ូតុង PrintScrn 
Comment[kn]=PrintScrn ಒತ್ತಿದಾಗ KSnapShot ಅನ್ನು ಪ್ರಕ್ಷೇಪಿಸುತ್ತದೆ.
Comment[ko]=PrintScrn 키가 눌렸을 때 KSnapShot을 실행합니다.
Comment[lt]=Paleidžia KSnapShot nuspaudus Sp(PrintScrn) klavišą.
Comment[lv]=Palaiž KSnapShot ja nospiests PrintScrn.
Comment[ml]=PrintScrn അമര്‍ത്തിയാല്‍ കെസ്നാപ്ഷോട്ട് തുടങ്ങുന്നു.
Comment[mr]=PrintScrn दाबल्यावर केस्नँपशॉट चे प्रक्षेपण केले जाते.
Comment[nb]=Starter KSnapShot når PrintScrn trykkes.
Comment[nds]=Röppt "KSnapShot" op, wenn Een de "PrintScreen"-Tast drückt.
Comment[ne]=मुद्रण पर्दा थिच्दा केडीई स्न्यापसट सुरू हुन्छ ।
Comment[nl]=KSnapShot starten wanneer PrintScreen wordt ingedrukt.
Comment[nn]=Startar KSnapShot ved trykk på «Print Screen»-tasten.
Comment[pa]=ਜਦੋਂ PrintScrn ਦੱਬਿਆ ਜਾਵੇ ਤਾਂ ਕੇ-ਸਨੈਪਸ਼ਾਟ ਚਲਾਓ
Comment[pl]=Uruchamia program Zrzut ekranu po naciśnięciu Print Scrn.
Comment[pt]=Lança o KSnapShot quando carregar no PrintScrn.
Comment[pt_BR]=Abre o KSnapShot quando a tecla PrintScreen é pressionada.
Comment[ro]=Lansează KSnapShot la apăsarea PrintScrn.
Comment[ru]=Запуск KSnapShot при нажатии кнопки PrintScreen.
Comment[se]=Álggaha KSnapShot go «Print Screen»-boallu deaddiluvvo.
Comment[si]=PrintScrn එබූ විට KSnapShot ක්‍රියාත්මක කරයි.
Comment[sk]=Spustí KSnapShot pri stlačení PrintScrn.
Comment[sl]=Po pritisku tipke Print Screen zažene KSnapShot.
Comment[sr]=Покреће К‑снимак по притиску на PrintScreen
Comment[sr@ijekavian]=Покреће К‑снимак по притиску на PrintScreen
Comment[sr@ijekavianlatin]=Pokreće Ksnimak po pritisku na PrintScreen
Comment[sr@latin]=Pokreće Ksnimak po pritisku na PrintScreen
Comment[sv]=Startar Ksnapshot när Prt Sc trycks ner.
Comment[ta]=Launches KSnapShot when PrintScrn is pressed.
Comment[te]=PrintScrn వత్తినప్పుడు KSnapShot దింపబడుతుంది.
Comment[tg]=Запускает KSnapShot при нажатии кнопки PrintScrn.
Comment[th]=เรียกโปรแกรมจับภาพหน้าจอ K เมื่อมีการกดปุ่มพิมพ์ PrintScrn
Comment[tr]=PrintScrn tuşuna basıldığında KSnapShot uygulamasını başlatır.
Comment[ug]=PrintScrn بېسىلغاندا KSnapShot نى ئىجرا قىلىدۇ.
Comment[uk]=Запускає KSnapShot при натисканні PrintScrn.
Comment[vi]=Chạy KSnapShot khi nút PrintScrn được bấm.
Comment[wa]=Enonde KWaitroûlêye cwant PrintScrn est tchôkî.
Comment[x-test]=xxLaunches KSnapShot when PrintScrn is pressed.xx
Comment[zh_CN]=按下 PrintScrn 时调用 KSnapshot。
Comment[zh_TW]=按下 PrintScreen 鍵時叫出 KSnapShot。
Enabled=true
Name=PrintScreen
Name[af]=Vang skermbeeld
Name[ar]=اطبع الشاشة
Name[as]=PrintScreen
Name[ast]=Imprentar pantalla
Name[be]=PrintScreen
Name[be@latin]=PrintScreen
Name[bg]=Печат на екрана
Name[bn]=PrintScreen
Name[bn_IN]=PrintScreen
Name[bs]=Snimak ekrana
Name[ca]=Impressió de pantalla
Name[ca@valencia]=Impressió de pantalla
Name[cs]=PrintScreen
Name[csb]=Drëkùjë ekran
Name[da]=PrintScreen
Name[de]=Bildschirm Drucken
Name[el]=PrintScreen
Name[en_GB]=PrintScreen
Name[eo]=EkranPreso
Name[es]=Imprimir pantalla
Name[et]=PrintScreen
Name[eu]=InprPant
Name[fa]=چاپ صفحه
Name[fi]=PrintScreen
Name[fr]=Copie d'écran
Name[fy]=print foarbyld
Name[ga]=PrintScreen
Name[gl]=Imprimir pantalla
Name[gu]=PrintScreen
Name[he]=הדפס מסך
Name[hi]=प्रिंट-स्क्रीन
Name[hne]=प्रिंट-स्क्रीन
Name[hr]=PrintScreen
Name[hsb]=Druck/S-Abf
Name[hu]=PrintScreen
Name[ia]=PrintScreen (Il imprime le schermo)
Name[id]=Cetak Layar
Name[is]=PrentaSkjá
Name[it]=Stamp
Name[ja]=PrintScreen
Name[kk]=PrintScreen
Name[km]=ថត​អេក្រង់​
Name[kn]=ತೆರೆಯನ್ನು ಮುದ್ರಿಸು (PrintScreen)
Name[ko]=PrintScreen
Name[ku]=DîmenderaÇapkirinê
Name[lt]=Sp(PrintScreen)
Name[lv]=PrintScreen
Name[mai]=प्रिंट-स्क्रीन
Name[mk]=Печатење на екранот
Name[ml]=PrintScreen
Name[mr]=प्रिंटस्क्रीन
Name[nb]=Skriv ut skjermbildet
Name[nds]=Schirmfoto
Name[ne]=मुद्रण पर्दा
Name[nl]=PrintScreen
Name[nn]=Print Screen
Name[pa]=ਪਰਿੰਟ-ਸਕਰੀਨ
Name[pl]=Zrzut ekranu
Name[pt]=Imprimir o Ecrã
Name[pt_BR]=PrintScreen
Name[ro]=PrintScreen
Name[ru]=Снимок экрана
Name[se]=Print Screen
Name[si]=තිරය මුද්‍රණය
Name[sk]=PrintScreen
Name[sl]=PrintScreen
Name[sr]=Снимак екрана
Name[sr@ijekavian]=Снимак екрана
Name[sr@ijekavianlatin]=Snimak ekrana
Name[sr@latin]=Snimak ekrana
Name[sv]=Skriv ut skärmen
Name[ta]=திரைகாட்சி
Name[te]=తెరముద్ర
Name[tg]=PrintScreen
Name[th]=พิมพ์ภาพหน้าจอ
Name[tr]=PrintScreen
Name[ug]=PrintScreen
Name[uk]=PrintScreen
Name[vi]=In màn hình
Name[wa]=Imprimer l' waitroûle
Name[x-test]=xxPrintScreenxx
Name[zh_CN]=PrintScreen
Name[zh_TW]=PrintScreen
Type=COMMAND_URL_SHORTCUT_ACTION_DATA
[Data_1_1Actions]
ActionsCount=1
[Data_1_1Actions0]
CommandURL=ksnapshot
Type=COMMAND_URL
[Data_1_1Conditions]
Comment=
ConditionsCount=0
[Data_1_1Triggers]
Comment=Simple_action
Comment[ar]=إجراء_بسيط
Comment[ast]=Aición cenciella
Comment[be@latin]=Prostaja_aperacyja
Comment[bg]=Обикновеноействие
Comment[bs]=Prosta_radnja
Comment[ca]=Acció_senzilla
Comment[ca@valencia]=Acció_senzilla
Comment[cs]=Jednoduchá činnost
Comment[csb]=Prosté_dzejanié
Comment[da]=Simple_action
Comment[de]=Einfache_Aktion
Comment[el]=Απλή_ενέργεια
Comment[en_GB]=Simple_action
Comment[eo]=Simpla ago
Comment[es]=Acción sencilla
Comment[et]=Lihtne toiming
Comment[eu]=Ekintza_sinplea
Comment[fi]=Yksinkertainen_toiminto
Comment[fr]=Action simple
Comment[fy]=Ienfâldige_aksje
Comment[ga]=Gníomh simplí
Comment[gl]=Acción_sinxela
Comment[gu]=સરળ_ક્રિયા
Comment[he]=פעולה פשוטה
Comment[hi]=सामान्य_क्रिया
Comment[hne]=सामान्य_काम
Comment[hr]=Jednostavna_akcija
Comment[hsb]=Jednora_akcija
Comment[hu]=Egyszerű_művelet
Comment[ia]=Simple_action
Comment[id]=Aksi_sederhana
Comment[is]=Einföld_aðgerð
Comment[it]=Azione_semplice
Comment[ja]=Simple_action
Comment[kk]=Қарапайым_әрекет
Comment[km]=Simple_action
Comment[kn]=ಸರಳ_ಕ್ರಿಯೆ
Comment[ko]=Simple_action
Comment[ku]=Simple_action
Comment[lt]=Paprastas_veiksmas
Comment[lv]=Vieknārša_darbība
Comment[mai]=सामान्य_क्रिया
Comment[mk]=Едноставноејство
Comment[ml]=ലഘു പ്രവൃത്തി
Comment[mr]=सामान्य_क्रिया
Comment[nb]=Enkel_handling
Comment[nds]=Eenfach_Akschoon
Comment[ne]=साधारण कार्य
Comment[nl]=Eenvoudige_handeling
Comment[nn]=Enkel_handling
Comment[pa]=Simple_action
Comment[pl]=Proste_działanie
Comment[pt]=Acção Simples
Comment[pt_BR]=Ação simples
Comment[ro]=Simple_action
Comment[ru]=Простое действие
Comment[se]=Oktageardánis_dáhpáhus
Comment[si]=සරල_ක්රියාව
Comment[sk]=Jednoduchá akcia
Comment[sl]=Preprosto_dejanje
Comment[sr]=Проста_радња
Comment[sr@ijekavian]=Проста_радња
Comment[sr@ijekavianlatin]=Prosta_radnja
Comment[sr@latin]=Prosta_radnja
Comment[sv]=Enkel åtgärd
Comment[ta]=Simple_action
Comment[te]=సాదారణ_చర్య
Comment[tg]=Амали оддӣ
Comment[th]=Simple_action
Comment[tr]=Basit_eylem
Comment[ug]=ئاددىي_ھەرىكەت
Comment[uk]=Simple_action
Comment[vi]=Hành động đơn giản
Comment[wa]=Simpe_accion
Comment[x-test]=xxSimple_actionxx
Comment[zh_CN]=简易_动作
Comment[zh_TW]=簡易動作
TriggersCount=1
[Data_1_1Triggers0]
Key=Print
Type=SHORTCUT
[Main]
Version=3
ImportId=printscreen

View file

@ -1,90 +0,0 @@
set(
kcm_hotkeys_PART_SRCS
kcm_hotkeys.cpp
kcm_module_factory.cpp
global_settings_widget.cpp
hotkeys_export_widget.cpp
hotkeys_model.cpp
hotkeys_proxy_model.cpp
hotkeys_tree_view.cpp
hotkeys_context_menu.cpp
# HELPER WIDGETS
helper_widgets/window_selector.cpp
helper_widgets/window_definition_widget.cpp
helper_widgets/window_definition_list_widget.cpp
# TRIGGER WIDGETS
triggers/trigger_widget_base.cpp
triggers/shortcut_trigger_widget.cpp
triggers/window_trigger_widget.cpp
# ACTION WIDGETS
actions/action_widget_base.cpp
actions/command_url_action_widget.cpp
actions/dbus_action_widget.cpp
actions/menuentry_action_widget.cpp
actions/keyboard_input_action_widget.cpp
# CONDITION WiDGETS
conditions/conditions_widget.cpp
conditions/condition_type_menu.cpp
# ACTION_DATA WIDGETS
hotkeys_widget_iface.cpp
hotkeys_widget_base.cpp
action_group_widget.cpp
simple_action_data_widget.cpp
# USER INTERFACES
global_settings_widget.ui
hotkeys_export_widget.ui
kcm_hotkeys.ui
# HELPER WIDGETS
helper_widgets/window_definition_list_widget.ui
helper_widgets/window_definition_widget.ui
# TRIGGER WIDGETS
triggers/window_trigger_widget.ui
triggers/shortcut_trigger_widget.ui
# ACTION WIDGETS
actions/command_url_action_widget.ui
actions/dbus_action_widget.ui
actions/menuentry_action_widget.ui
actions/keyboard_input_action_widget.ui
# CONDITION WiDGETS
conditions/conditions_widget.ui
# ACTION_DATA WIDGETS
hotkeys_widget_base.ui
)
qt4_add_dbus_interface(
kcm_hotkeys_PART_SRCS
${CMAKE_CURRENT_BINARY_DIR}/../app/org.kde.khotkeys.xml
khotkeys_interface
)
kde4_add_plugin(kcm_hotkeys ${kcm_hotkeys_PART_SRCS})
add_dependencies(kcm_hotkeys kded_khotkeys)
target_link_libraries(kcm_hotkeys
KDE4::kio
${QT_QTGUI_LIBRARY}
${X11_X11_LIB}
khotkeysprivate
)
install(
TARGETS kcm_hotkeys
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
)
install(
FILES khotkeys.desktop
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
)

View file

@ -1,81 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "action_group_widget.h"
#include "conditions/conditions_widget.h"
#include "action_data/action_data_group.h"
ActionGroupWidget::ActionGroupWidget( QWidget *parent )
: HotkeysWidgetBase(parent)
,_conditions(new ConditionsWidget)
{
extend(_conditions, i18n("Conditions"));
connect(_conditions, SIGNAL(changed(bool)),
SLOT(slotChanged()));
}
ActionGroupWidget::~ActionGroupWidget()
{
_conditions = NULL;
}
void ActionGroupWidget::setActionData(KHotKeys::ActionDataGroup *group)
{
_data = group;
// BUG: conditions copies twice from the original. Once in
// setConditionsList and once because of the copyFromObject call below.
Q_ASSERT(_conditions);
_conditions->setConditionsList(group->conditions());
Base::copyFromObject();
}
void ActionGroupWidget::doCopyFromObject()
{
Q_ASSERT(data());
Base::doCopyFromObject();
Q_ASSERT(_conditions);
_conditions->copyFromObject();
}
void ActionGroupWidget::doCopyToObject()
{
Q_ASSERT(data());
Base::doCopyToObject();
Q_ASSERT(_conditions);
_conditions->copyToObject();
}
bool ActionGroupWidget::isChanged() const
{
return _conditions->hasChanges() || Base::isChanged();
}
#include "moc_action_group_widget.cpp"

View file

@ -1,78 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef ACTIONGROUPWIDGET_H
#define ACTIONGROUPWIDGET_H
#include "hotkeys_widget_base.h"
class ConditionsWidget;
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class ActionGroupWidget : public HotkeysWidgetBase
{
Q_OBJECT
typedef HotkeysWidgetBase Base;
public:
/**
* Default constructor
*/
ActionGroupWidget( QWidget *parent = 0 );
/**
* Destructor
*/
virtual ~ActionGroupWidget();
/**
* The associated action.
*/
KHotKeys::ActionDataBase *data()
{
return static_cast<KHotKeys::ActionDataBase*>( _data );
}
const KHotKeys::ActionDataBase *data() const
{
return static_cast<const KHotKeys::ActionDataBase*>( _data );
}
//! Are there uncommited changes?
bool isChanged() const;
void setActionData( KHotKeys::ActionDataGroup *group );
private:
void doCopyFromObject();
void doCopyToObject();
//! Widget to change the conditions
ConditionsWidget *_conditions;
};
#endif /* #ifndef ACTIONGROUPWIDGET_HPP */

View file

@ -1,34 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "action_widget_base.h"
ActionWidgetBase::ActionWidgetBase( KHotKeys::Action *action, QWidget *parent )
: HotkeysWidgetIFace(parent)
,_action(action)
{}
ActionWidgetBase::~ActionWidgetBase()
{}
#include "moc_action_widget_base.cpp"

View file

@ -1,54 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef ACTION_WIDGET_BASE_H
#define ACTION_WIDGET_BASE_H
#include "hotkeys_widget_iface.h"
#include "libkhotkeysfwd.h"
#include "actions/actions.h"
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class ActionWidgetBase : public HotkeysWidgetIFace
{
Q_OBJECT
public:
/**
* Destructor
*/
virtual ~ActionWidgetBase();
virtual KHotKeys::Action * action() { return _action; }
virtual const KHotKeys::Action * action() const { return _action; }
protected:
ActionWidgetBase( KHotKeys::Action *action, QWidget *parent = 0 );
KHotKeys::Action *_action;
};
#endif /* #ifndef ACTION_WIDGET_BASE_H */

View file

@ -1,76 +0,0 @@
/* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "command_url_action_widget.h"
#include <KLineEdit>
CommandUrlActionWidget::CommandUrlActionWidget(
KHotKeys::CommandUrlAction *action,
QWidget *parent )
: Base( action, parent )
{
ui.setupUi(this);
connect(
ui.command, SIGNAL(textChanged(QString)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.command, "command" );
}
CommandUrlActionWidget::~CommandUrlActionWidget()
{
}
KHotKeys::CommandUrlAction *CommandUrlActionWidget::action()
{
return static_cast<KHotKeys::CommandUrlAction*>(_action);
}
const KHotKeys::CommandUrlAction *CommandUrlActionWidget::action() const
{
return static_cast<const KHotKeys::CommandUrlAction*>(_action);
}
void CommandUrlActionWidget::doCopyFromObject()
{
Q_ASSERT(action());
ui.command->lineEdit()->setText( action()->command_url() );
}
void CommandUrlActionWidget::doCopyToObject()
{
Q_ASSERT(action());
action()->set_command_url( ui.command->lineEdit()->text() );
}
bool CommandUrlActionWidget::isChanged() const
{
Q_ASSERT(action());
return action()->command_url() != ui.command->lineEdit()->text();
}
#include "moc_command_url_action_widget.cpp"

View file

@ -1,62 +0,0 @@
#ifndef COMMAND_URL_ACTION_WIDGET_H
#define COMMAND_URL_ACTION_WIDGET_H
/* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "action_widget_base.h"
#include "ui_command_url_action_widget.h"
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class CommandUrlActionWidget : public ActionWidgetBase
{
Q_OBJECT
typedef ActionWidgetBase Base;
public:
/**
* Default constructor
*/
CommandUrlActionWidget( KHotKeys::CommandUrlAction *action, QWidget *parent = 0 );
/**
* Destructor
*/
virtual ~CommandUrlActionWidget();
KHotKeys::CommandUrlAction *action();
const KHotKeys::CommandUrlAction *action() const;
virtual bool isChanged() const;
protected:
virtual void doCopyFromObject();
virtual void doCopyToObject();
Ui::CommandUrlActionWidget ui;
};
#endif /* #ifndef COMMAND_URL_ACTION_WIDGET_H */

View file

@ -1,46 +0,0 @@
<ui version="4.0" >
<class>CommandUrlActionWidget</class>
<widget class="QWidget" name="CommandUrlActionWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="commandLabel" >
<property name="text" >
<string>Command/URL:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="KUrlRequester" name="command" />
</item>
<item row="1" column="0" >
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>6</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KUrlRequester</class>
<extends>QFrame</extends>
<header>kurlrequester.h</header>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -1,136 +0,0 @@
/* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "dbus_action_widget.h"
#include <KMessageBox>
#include <KRun>
#include <KStandardDirs>
DbusActionWidget::DbusActionWidget(
KHotKeys::DBusAction *action,
QWidget *parent )
: Base(action, parent)
{
ui.setupUi(this);
connect(
ui.application, SIGNAL(textChanged(QString)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.application, "application" );
connect(
ui.object, SIGNAL(textChanged(QString)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.object, "object" );
connect(
ui.function, SIGNAL(textChanged(QString)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.function, "function" );
connect(
ui.arguments, SIGNAL(textChanged(QString)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.arguments, "arguments" );
connect(
ui.launchButton, SIGNAL(clicked()),
this, SLOT(launchDbusBrowser()) );
connect(
ui.execButton, SIGNAL(clicked()),
this, SLOT(execCommand()) );
}
DbusActionWidget::~DbusActionWidget()
{
}
KHotKeys::DBusAction *DbusActionWidget::action()
{
return static_cast<KHotKeys::DBusAction*>(_action);
}
const KHotKeys::DBusAction *DbusActionWidget::action() const
{
return static_cast<const KHotKeys::DBusAction*>(_action);
}
void DbusActionWidget::doCopyFromObject()
{
Q_ASSERT(action());
ui.application->setText( action()->remote_application() );
ui.object->setText( action()->remote_object() );
ui.function->setText( action()->called_function() );
ui.arguments->setText( action()->arguments() );
}
void DbusActionWidget::doCopyToObject()
{
Q_ASSERT(action());
action()->set_remote_application( ui.application->text() );
action()->set_remote_object( ui.object->text() );
action()->set_called_function( ui.function->text() );
action()->set_arguments( ui.arguments->text() );
}
void DbusActionWidget::execCommand() const
{
KHotKeys::DBusAction action(
0,
ui.application->text(),
ui.object->text(),
ui.function->text(),
ui.arguments->text() );
// TODO: Error handling
action.execute();
}
bool DbusActionWidget::isChanged() const
{
Q_ASSERT(action());
return ui.application->text() != action()->remote_application()
|| ui.object->text() != action()->remote_object()
|| ui.function->text() != action()->called_function()
|| ui.arguments->text() != action()->arguments();
}
void DbusActionWidget::launchDbusBrowser() const
{
QString qdbusviewerExe = KStandardDirs::findExe("qdbusviewer-katie");
if (qdbusviewerExe.isEmpty()) {
qdbusviewerExe = KStandardDirs::findExe("qdbusviewer-qt4");
}
if (qdbusviewerExe.isEmpty()) {
// no exe lookup, let it fail if not found
qdbusviewerExe = "qdbusviewer";
}
if( KRun::runCommand( qdbusviewerExe, window()) == 0 )
{
KMessageBox::sorry( window(), i18n( "Failed to run qdbusviewer" ));
}
}
#include "moc_dbus_action_widget.cpp"

View file

@ -1,68 +0,0 @@
#ifndef DBUS_ACTION_WIDGET_H
#define DBUS_ACTION_WIDGET_H
/* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "action_widget_base.h"
#include "ui_dbus_action_widget.h"
#include "actions/actions.h"
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class DbusActionWidget : public ActionWidgetBase
{
Q_OBJECT
typedef ActionWidgetBase Base;
public:
/**
* Default constructor
*/
DbusActionWidget( KHotKeys::DBusAction *action, QWidget *parent = 0 );
/**
* Destructor
*/
virtual ~DbusActionWidget();
KHotKeys::DBusAction *action();
const KHotKeys::DBusAction *action() const;
virtual bool isChanged() const;
public Q_SLOTS:
void launchDbusBrowser() const;
void execCommand() const;
protected:
virtual void doCopyFromObject();
virtual void doCopyToObject();
Ui::DbusActionWidget ui;
};
#endif /* #ifndef DBUS_ACTION_WIDGET_H */

View file

@ -1,117 +0,0 @@
<ui version="4.0" >
<class>DbusActionWidget</class>
<widget class="QWidget" name="DbusActionWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>539</width>
<height>248</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="applicationLabel" >
<property name="text" >
<string>Remote application:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>application</cstring>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="objectLabel" >
<property name="text" >
<string>Remote object:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>object</cstring>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="functionLabel" >
<property name="text" >
<string>Function:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>function</cstring>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="argumentsLabel" >
<property name="text" >
<string>Arguments:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>arguments</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="KLineEdit" name="arguments" />
</item>
<item row="2" column="1" >
<widget class="KLineEdit" name="function" />
</item>
<item row="1" column="1" >
<widget class="KLineEdit" name="object" />
</item>
<item row="0" column="1" >
<widget class="KLineEdit" name="application" />
</item>
<item row="4" column="0" colspan="2" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QPushButton" name="execButton" >
<property name="text" >
<string>Call</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="launchButton" >
<property name="text" >
<string>Launch D-Bus Browser</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>application</tabstop>
<tabstop>object</tabstop>
<tabstop>function</tabstop>
<tabstop>arguments</tabstop>
<tabstop>execButton</tabstop>
<tabstop>launchButton</tabstop>
</tabstops>
<connections/>
</ui>

View file

@ -1,150 +0,0 @@
/* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "keyboard_input_action_widget.h"
#include <KDebug>
KeyboardInputActionWidget::KeyboardInputActionWidget(
KHotKeys::KeyboardInputAction *action,
QWidget *parent)
: Base( action, parent )
{
ui.setupUi(this);
connect(
ui.input, SIGNAL(textChanged()),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.input, "input" );
connect(
ui.windowdef_list, SIGNAL(changed(bool)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.windowdef_list, "windowdef_list" );
connect(
ui.active_radio, SIGNAL(clicked(bool)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.active_radio, "active_radio" );
connect(
ui.action_radio, SIGNAL(clicked(bool)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.action_radio, "action_radio" );
connect(
ui.specific_radio, SIGNAL(clicked(bool)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.specific_radio, "specific_radio" );
}
KeyboardInputActionWidget::~KeyboardInputActionWidget()
{
}
KHotKeys::KeyboardInputAction *KeyboardInputActionWidget::action()
{
Q_ASSERT(dynamic_cast<KHotKeys::KeyboardInputAction*>(_action));
return static_cast<KHotKeys::KeyboardInputAction*>(_action);
}
const KHotKeys::KeyboardInputAction *KeyboardInputActionWidget::action() const
{
Q_ASSERT(dynamic_cast<KHotKeys::KeyboardInputAction*>(_action));
return static_cast<const KHotKeys::KeyboardInputAction*>(_action);
}
void KeyboardInputActionWidget::doCopyFromObject()
{
Q_ASSERT(action());
ui.input->setText(action()->input());
ui.windowdef_list->setWindowDefinitions(action()->dest_window());
ui.windowdef_list->copyFromObject();
switch (action()->destination())
{
case KHotKeys::KeyboardInputAction::SpecificWindow:
ui.specific_radio->setChecked(true);
break;
case KHotKeys::KeyboardInputAction::ActiveWindow:
ui.active_radio->setChecked(true);
break;
case KHotKeys::KeyboardInputAction::ActionWindow:
ui.action_radio->setChecked(true);
break;
default:
Q_ASSERT(false);
ui.action_radio->setChecked(true);
}
}
void KeyboardInputActionWidget::doCopyToObject()
{
Q_ASSERT(action());
action()->setInput(ui.input->toPlainText());
if (ui.action_radio->isChecked())
{
action()->setDestination(KHotKeys::KeyboardInputAction::ActionWindow);
action()->dest_window()->clear();
}
else if (ui.active_radio->isChecked())
{
action()->setDestination(KHotKeys::KeyboardInputAction::ActiveWindow);
action()->dest_window()->clear();
}
else
{
action()->setDestination(KHotKeys::KeyboardInputAction::SpecificWindow);
ui.windowdef_list->copyToObject();
}
}
bool KeyboardInputActionWidget::isChanged() const
{
Q_ASSERT(action());
if (ui.input->toPlainText() != action()->input()) return true;
switch (action()->destination())
{
case KHotKeys::KeyboardInputAction::ActionWindow:
return !ui.action_radio->isChecked();
case KHotKeys::KeyboardInputAction::ActiveWindow:
return !ui.active_radio->isChecked();
case KHotKeys::KeyboardInputAction::SpecificWindow:
return !ui.specific_radio->isChecked()
|| ui.windowdef_list->isChanged();
}
return false;
}
#include "moc_keyboard_input_action_widget.cpp"

View file

@ -1,64 +0,0 @@
#ifndef KEYBOARD_INPUT_ACTION_WIDGET_H
#define KEYBOARD_INPUT_ACTION_WIDGET_H
/* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "action_widget_base.h"
#include "ui_keyboard_input_action_widget.h"
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class KeyboardInputActionWidget : public ActionWidgetBase
{
Q_OBJECT
typedef ActionWidgetBase Base;
public:
/**
* Default constructor
*/
KeyboardInputActionWidget(
KHotKeys::KeyboardInputAction *action,
QWidget *parent = NULL);
/**
* Destructor
*/
virtual ~KeyboardInputActionWidget();
KHotKeys::KeyboardInputAction *action();
const KHotKeys::KeyboardInputAction *action() const;
virtual bool isChanged() const;
protected:
virtual void doCopyFromObject();
virtual void doCopyToObject();
Ui::KeyboardInputActionWidget ui;
};
#endif /* #ifndef KEYBOARD_INPUT_ACTION_WIDGET_H */

View file

@ -1,69 +0,0 @@
<ui version="4.0" >
<class>KeyboardInputActionWidget</class>
<widget class="QWidget" name="KeyboardInputActionWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>477</width>
<height>489</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="KTextEdit" name="input" />
</item>
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Window</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QRadioButton" name="active_radio" >
<property name="text" >
<string>Active window</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="specific_radio" >
<property name="text" >
<string>Specific window</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="action_radio" >
<property name="text" >
<string>Action window</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="WindowDefinitionListWidget" native="1" name="windowdef_list" />
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KTextEdit</class>
<extends>QTextEdit</extends>
<header>ktextedit.h</header>
</customwidget>
<customwidget>
<class>WindowDefinitionListWidget</class>
<extends>QWidget</extends>
<header>helper_widgets/window_definition_list_widget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -1,123 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "menuentry_action_widget.h"
#include <KDebug>
#include <KOpenWithDialog>
MenuentryActionWidget::MenuentryActionWidget( KHotKeys::MenuEntryAction *action, QWidget *parent )
: ActionWidgetBase(action, parent )
,storage_id()
{
ui.setupUi(this);
connect(
ui.applicationButton, SIGNAL(clicked()),
this, SLOT(selectApplicationClicked()) );
connect(
ui.application, SIGNAL(textChanged(QString)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.application, "application" );
}
MenuentryActionWidget::~MenuentryActionWidget()
{}
KHotKeys::MenuEntryAction *MenuentryActionWidget::action()
{
Q_ASSERT(dynamic_cast<KHotKeys::MenuEntryAction*>(_action));
return static_cast<KHotKeys::MenuEntryAction*>(_action);
}
const KHotKeys::MenuEntryAction *MenuentryActionWidget::action() const
{
Q_ASSERT(dynamic_cast<KHotKeys::MenuEntryAction*>(_action));
return static_cast<const KHotKeys::MenuEntryAction*>(_action);
}
void MenuentryActionWidget::doCopyFromObject()
{
Q_ASSERT(action());
KService::Ptr service = action()->service();
if (service)
{
ui.application->setText( service->name() );
storage_id = service->storageId();
}
else
{
ui.application->setText(QString());
storage_id = QString();
}
}
void MenuentryActionWidget::doCopyToObject()
{
Q_ASSERT(action());
action()->set_service( KService::serviceByStorageId(storage_id));
}
bool MenuentryActionWidget::isChanged() const
{
Q_ASSERT(action());
bool changed;
// There could be no service set, so be careful!
if (action()->service())
{
changed = ui.application->text() != action()->service()->name();
}
else
{
// No service set. If the string is not empty something changed.
changed = ! ui.application->text().isEmpty();
}
return changed;
}
void MenuentryActionWidget::selectApplicationClicked()
{
KOpenWithDialog dlg;
dlg.exec();
KService::Ptr service = dlg.service();
if (service)
{
ui.application->setText( service->name() );
storage_id = service->storageId();
}
}
#include "moc_menuentry_action_widget.cpp"

View file

@ -1,70 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MENUENTRY_ACTION_WIDGET_H
#define MENUENTRY_ACTION_WIDGET_H
#include "action_widget_base.h"
#include "ui_menuentry_action_widget.h"
#include "libkhotkeysfwd.h"
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class MenuentryActionWidget : public ActionWidgetBase
{
Q_OBJECT
typedef ActionWidgetBase Base;
public:
/**
* Default constructor
*/
MenuentryActionWidget( KHotKeys::MenuEntryAction *action, QWidget *parent = 0 );
/**
* Destructor
*/
virtual ~MenuentryActionWidget();
KHotKeys::MenuEntryAction *action();
const KHotKeys::MenuEntryAction *action() const;
virtual bool isChanged() const;
public Q_SLOTS:
void selectApplicationClicked();
protected:
virtual void doCopyFromObject();
virtual void doCopyToObject();
QString storage_id;
Ui::MenuentryActionWidget ui;
};
#endif /* #ifndef MENUENTRY_ACTION_WIDGET_H */

View file

@ -1,49 +0,0 @@
<ui version="4.0" >
<class>MenuentryActionWidget</class>
<widget class="QWidget" name="MenuentryActionWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QLabel" name="applicationLabel" >
<property name="text" >
<string>Application:</string>
</property>
</widget>
</item>
<item>
<widget class="KLineEdit" name="application" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="KPushButton" name="applicationButton" >
<property name="text" >
<string>Select Application ...</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
<customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -1,44 +0,0 @@
/* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "condition_type_menu.h"
#include <KLocale>
ConditionTypeMenu::ConditionTypeMenu(QWidget *parent)
: QMenu(parent)
{
addAction(i18nc("Condition type", "Active Window ..."))
->setData(ACTIVE_WINDOW);
addAction(i18nc("Condition type", "Existing Window ..."))
->setData(EXISTING_WINDOW);
addAction(i18nc("Condition type", "And"))
->setData(AND);
addAction(i18nc("Condition type", "Or"))
->setData(OR);
addAction(i18nc("Condition type", "Not"))
->setData(NOT);
}
ConditionTypeMenu::~ConditionTypeMenu()
{}
#include "moc_condition_type_menu.cpp"

View file

@ -1,54 +0,0 @@
#ifndef CONDITION_TYPE_MENU_H
#define CONDITION_TYPE_MENU_H
/* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <QtGui/QMenu>
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class ConditionTypeMenu : public QMenu
{
Q_OBJECT
public:
/**
* Default constructor
*/
ConditionTypeMenu(QWidget *parent = NULL);
/**
* Destructor
*/
virtual ~ConditionTypeMenu();
enum ConditionType{
ACTIVE_WINDOW,
EXISTING_WINDOW,
AND,
OR,
NOT};
};
#endif /* #ifndef CONDITION_TYPE_MENU_H */

View file

@ -1,427 +0,0 @@
/* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "conditions/conditions_widget.h"
#include "conditions/conditions_list_base.h"
#include "conditions/conditions_list.h"
#include "conditions/condition.h"
#include "conditions/conditions.h"
#include "conditions/conditions_visitor.h"
#include "conditions/existing_window_condition.h"
#include "conditions/active_window_condition.h"
#include "windows_helper/window_selection_list.h"
#include "helper_widgets/window_definition_list_widget.h"
#include "condition_type_menu.h"
#include <QtCore/QStack>
#include <KDebug>
class BuildTree : public KHotKeys::ConditionsVisitor
{
public:
BuildTree(QTreeWidget *tree);
void build();
virtual void visitConditionsListBase(KHotKeys::Condition_list_base *list);
virtual void visitConditionsList(KHotKeys::Condition_list *list);
virtual void visitCondition( KHotKeys::Condition *condition );
QMap<QTreeWidgetItem*, KHotKeys::Condition*> _items;
private:
QTreeWidget *_tree;
QStack<QTreeWidgetItem*> _stack;
};
BuildTree::BuildTree( QTreeWidget *tree )
: _tree(tree)
{
_stack.push(_tree->invisibleRootItem());
}
void BuildTree::visitCondition(KHotKeys::Condition *cond)
{
QTreeWidgetItem *item = new QTreeWidgetItem(_stack.top());
item->setText(0, cond->description());
_items.insert(item, cond);
}
void BuildTree::visitConditionsList(KHotKeys::Condition_list *list)
{
Q_ASSERT(_stack.count()==1);
QTreeWidgetItem *parent = _stack.top();
QTreeWidgetItem *item = new QTreeWidgetItem(parent);
item->setText(0, i18nc("Add a new condition", "And"));
_items.insert(item, list);
_stack.push(item);
for(KHotKeys::Condition_list_base::Iterator it = list->begin();
it != list->end();
++it)
{
(*it)->visit(this);
}
_tree->expandAll();
}
void BuildTree::visitConditionsListBase(KHotKeys::Condition_list_base *list)
{
QTreeWidgetItem *parent = _stack.top();
QTreeWidgetItem *item = new QTreeWidgetItem(parent);
item->setText(0, list->description());
_items.insert(item, list);
_stack.push(item);
for(KHotKeys::Condition_list_base::Iterator it = list->begin();
it != list->end();
++it)
{
// QTreeWidgetItem *child = new QTreeWidgetItem(item);
// child->setText(0, (*it)->description());
// _items.insert(child, list);
(*it)->visit(this);
}
_stack.pop();
}
ConditionsWidget::ConditionsWidget(QWidget *parent)
: QWidget(parent)
,_working(NULL)
,_changed(false)
{
ui.setupUi(this);
connect(ui.edit_button, SIGNAL(clicked(bool)),
SLOT(slotEdit()));
connect(ui.delete_button, SIGNAL(clicked(bool)),
SLOT(slotDelete()));
ui.new_button->setMenu(new ConditionTypeMenu(this));
connect(ui.new_button->menu(), SIGNAL(triggered(QAction*)),
SLOT(slotNew(QAction*)));
}
ConditionsWidget::~ConditionsWidget()
{
delete _working; _working = NULL;
}
void ConditionsWidget::copyFromObject()
{
Q_ASSERT(_conditions_list);
// Clear the tree and delete our old working copy
ui.tree->clear();
if (_working) delete _working;
// Create the working copy
_working = _conditions_list->copy();
Q_ASSERT(_working->count() == _conditions_list->count());
kDebug() << _working->count();
kDebug() << _conditions_list->count();
// Build the tree
BuildTree builder(ui.tree);
_working->visit(&builder);
_items = builder._items;
_changed = false;
}
void ConditionsWidget::copyToObject()
{
kDebug();
Q_ASSERT(_conditions_list);
if (!_conditions_list) return;
// Just copy the content from our working copy to the original
// Remove the old content
qDeleteAll(*_conditions_list);
_conditions_list->clear();
for (KHotKeys::Condition_list::Iterator it = _working->begin();
it != _working->end();
++it)
{
kDebug();
_conditions_list->append((*it)->copy());
}
Q_ASSERT(_working->count() == _conditions_list->count());
_changed = false;
}
void ConditionsWidget::emitChanged(bool chgd)
{
if (_changed == ( chgd || _changed ))
return;
// Once changed always changed
_changed = chgd || _changed;
emit changed(_changed);
}
bool ConditionsWidget::hasChanges() const
{
return _changed;
}
void ConditionsWidget::setConditionsList( KHotKeys::Condition_list *list)
{
Q_ASSERT(list);
_conditions_list = list;
}
void ConditionsWidget::slotDelete()
{
QTreeWidgetItem *citem = ui.tree->currentItem();
// If no item is selected just return
if (!citem) return;
// TODO: Ask for confirmation before deleting
// Get the currently select condition
KHotKeys::Condition *cond = _items.value(citem);
// Do not allow deleting the root item
if (cond==_working) return;
delete cond;
delete citem;
emitChanged(true);
}
void ConditionsWidget::slotEdit()
{
// Get the currently select condition
QTreeWidgetItem *citem = ui.tree->currentItem();
// If no item is selected just return
if (!citem) return;
KHotKeys::Condition *cond = _items.value(citem);
// Currently we only allow editing existing and active window conditions.
// TODO: Disable buttons according to active item
KHotKeys::Existing_window_condition *ewcond =
dynamic_cast<KHotKeys::Existing_window_condition*>(cond);
if (ewcond)
{
WindowDefinitionListDialog dialog(ewcond->window());
switch (dialog.exec())
{
case QDialog::Accepted:
{
citem->setText(0, ewcond->description());
emitChanged(true);
}
break;
case QDialog::Rejected:
// Nothing to do
return;
default:
Q_ASSERT(false);
return;
}
}
KHotKeys::Active_window_condition *awcond =
dynamic_cast<KHotKeys::Active_window_condition*>(cond);
if (awcond)
{
WindowDefinitionListDialog dialog(awcond->window());
switch (dialog.exec())
{
case QDialog::Accepted:
{
citem->setText(0, awcond->description());
emitChanged(true);
}
break;
case QDialog::Rejected:
// Nothing to do
return;
default:
Q_ASSERT(false);
return;
}
}
return;
}
void ConditionsWidget::slotNew(QAction* action)
{
QTreeWidgetItem *citem = ui.tree->currentItem();
KHotKeys::Condition *cond;
if (!citem)
{
// If no item is selected create the new condition as a top level
// condition
cond = _working;
citem = ui.tree->invisibleRootItem()->child(0);
Q_ASSERT(citem);
}
else
{
// Get the currently select condition
cond = _items.value(citem);
}
// get the nearest list
KHotKeys::Condition_list_base *parent = dynamic_cast<KHotKeys::Condition_list_base*>(cond);
if (!parent)
{
parent = cond->parent();
citem = citem->parent();
}
Q_ASSERT(parent);
switch (action->data().toInt())
{
case ConditionTypeMenu::ACTIVE_WINDOW:
{
KHotKeys::Windowdef_list *list = new KHotKeys::Windowdef_list();
WindowDefinitionListDialog dialog(list);
switch (dialog.exec())
{
case QDialog::Accepted:
{
KHotKeys::Active_window_condition *cond =
new KHotKeys::Active_window_condition(list, parent);
QTreeWidgetItem *item = new QTreeWidgetItem(citem);
item->setText(0, cond->description());
_items.insert(item, cond);
}
break;
case QDialog::Rejected:
delete list;
return;
default:
Q_ASSERT(false);
delete list;
return;
}
}
break;
case ConditionTypeMenu::EXISTING_WINDOW:
{
KHotKeys::Windowdef_list *list = new KHotKeys::Windowdef_list();
WindowDefinitionListDialog dialog(list);
switch (dialog.exec())
{
case QDialog::Accepted:
{
KHotKeys::Existing_window_condition *cond =
new KHotKeys::Existing_window_condition(list, parent);
QTreeWidgetItem *item = new QTreeWidgetItem(citem);
item->setText(0, cond->description());
_items.insert(item, cond);
}
break;
case QDialog::Rejected:
delete list;
return;
default:
Q_ASSERT(false);
delete list;
return;
}
}
break;
case ConditionTypeMenu::AND:
{
KHotKeys::And_condition *cond = new KHotKeys::And_condition(parent);
QTreeWidgetItem *item = new QTreeWidgetItem(citem);
item->setText(0, cond->description());
_items.insert(item, cond);
}
break;
case ConditionTypeMenu::OR:
{
KHotKeys::Or_condition *cond = new KHotKeys::Or_condition(parent);
QTreeWidgetItem *item = new QTreeWidgetItem(citem);
item->setText(0, cond->description());
_items.insert(item, cond);
}
break;
case ConditionTypeMenu::NOT:
{
KHotKeys::Not_condition *cond = new KHotKeys::Not_condition(parent);
QTreeWidgetItem *item = new QTreeWidgetItem(citem);
item->setText(0, cond->description());
_items.insert(item, cond);
}
break;
default:
Q_ASSERT(false);
break;
}
emitChanged(true);
}
#include "moc_conditions_widget.cpp"

View file

@ -1,96 +0,0 @@
#ifndef CONDITIONS_WIDGET_H
#define CONDITIONS_WIDGET_H
/* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <QtCore/QMap>
#include <QtGui/QWidget>
#include "ui_conditions_widget.h"
#include <QAction>
#include <QTreeWidgetItem>
namespace KHotKeys {
class Condition_list;
class Condition;
}
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class ConditionsWidget : public QWidget
{
Q_OBJECT
public:
/**
* Default constructor
*/
ConditionsWidget(QWidget *parent = NULL);
/**
* Destructor
*/
virtual ~ConditionsWidget();
void copyFromObject();
void copyToObject();
void setConditionsList(KHotKeys::Condition_list *list);
//! Are there uncommited changes?
bool hasChanges() const;
Q_SIGNALS:
void changed(bool);
private Q_SLOTS:
void slotNew(QAction*);
void slotEdit();
void slotDelete();
private:
// Emit the changed(bool) signal if our changed status changes
void emitChanged(bool);
//! The original
KHotKeys::Condition_list *_conditions_list;
//! The working copy
KHotKeys::Condition_list *_working;
//! User Interface Definition
Ui::ConditionsWidget ui;
//! Are there uncommited changes?
bool _changed;
//! Map between treewidgetitems and conditions
QMap<QTreeWidgetItem*, KHotKeys::Condition*> _items;
};
#endif /* #ifndef CONDITIONS_WIDGET_H */

View file

@ -1,53 +0,0 @@
<ui version="4.0" >
<class>ConditionsWidget</class>
<widget class="QWidget" name="ConditionsWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QTreeWidget" name="tree" >
<property name="headerHidden" >
<bool>true</bool>
</property>
<column>
<property name="text" >
<string>1</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QPushButton" name="new_button" >
<property name="text" >
<string comment="new condition">New</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="edit_button" >
<property name="text" >
<string>Edit...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="delete_button" >
<property name="text" >
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<connections/>
</ui>

View file

@ -1,103 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "global_settings_widget.h"
#include "hotkeys_model.h"
#include "settings.h"
#include <KDebug>
#include <KDesktopFile>
#include <KGlobal>
#include <KStandardDirs>
#include <KConfigGroup>
GlobalSettingsWidget::GlobalSettingsWidget( QWidget *parent )
: HotkeysWidgetIFace( parent )
,_model(NULL)
{
ui.setupUi(this);
QString path = KGlobal::dirs()->findResource( "services", "kded/khotkeys.desktop");
if ( KDesktopFile::isDesktopFile(path) )
{
_config = KSharedConfig::openConfig(
path,
KConfig::NoGlobals,
"services" );
}
connect(
ui.enabled, SIGNAL(stateChanged(int)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.enabled, "enabled" );
}
GlobalSettingsWidget::~GlobalSettingsWidget()
{
}
void GlobalSettingsWidget::doCopyFromObject()
{
if (_config)
{
KConfigGroup file(_config, "Desktop Entry");
ui.enabled->setChecked(file.readEntry("X-KDE-Kded-autoload", false));
}
}
void GlobalSettingsWidget::doCopyToObject()
{
if (_config)
{
KConfigGroup file(_config, "Desktop Entry");
file.writeEntry("X-KDE-Kded-autoload", ui.enabled->checkState()==Qt::Checked);
_config->sync();
}
}
bool GlobalSettingsWidget::isChanged() const
{
if (_config)
{
KConfigGroup file(_config, "Desktop Entry");
bool enabled = file.readEntry("X-KDE-Kded-autoload", false);
if (enabled!=ui.enabled->isChecked())
{
return true;
}
}
return false;
}
void GlobalSettingsWidget::setModel(KHotkeysModel *model)
{
_model = model;
doCopyFromObject();
}
#include "moc_global_settings_widget.cpp"

View file

@ -1,73 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef GLOBAL_SETTINGS_WIDGET_H
#define GLOBAL_SETTINGS_WIDGET_H
#include <ui_global_settings_widget.h>
#include "hotkeys_widget_iface.h"
#include <KSharedConfig>
class KHotkeysModel;
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class GlobalSettingsWidget : public HotkeysWidgetIFace
{
Q_OBJECT
public:
/**
* Default constructor
*/
GlobalSettingsWidget(QWidget *parent = NULL);
/**
* Destructor
*/
~GlobalSettingsWidget();
/**
* Set the model we configure
*/
void setModel(KHotkeysModel *);
private Q_SLOTS:
bool isChanged() const;
protected:
virtual void doCopyFromObject();
virtual void doCopyToObject();
private:
KSharedConfigPtr _config;
KHotkeysModel *_model;
Ui::GlobalSettingsWidget ui;
};
#endif /* #ifndef GLOBAL_SETTINGS_WIDGET_H */

View file

@ -1,64 +0,0 @@
<?xml version="1.0" encoding="System"?>
<ui version="4.0">
<class>GlobalSettingsWidget</class>
<widget class="QWidget" name="GlobalSettingsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>354</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="global_group">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="title">
<string>Input Actions Daemon</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="enabled">
<property name="text">
<string>Start the Input Actions daemon on login</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="spacer2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
<tabstop>enabled</tabstop>
</tabstops>
<connections/>
</ui>

View file

@ -1,274 +0,0 @@
/* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "window_definition_list_widget.h"
#include "window_definition_widget.h"
#include "windows_helper/window_selection_rules.h"
#include "kdebug.h"
WindowDefinitionListWidget::WindowDefinitionListWidget(QWidget *parent)
: HotkeysWidgetIFace(parent)
,_windowdefs(NULL)
,_working(NULL)
,_changed(false)
{
ui.setupUi(this);
connect(
ui.edit_button, SIGNAL(clicked(bool)),
SLOT(slotEdit(bool)));
connect(
ui.delete_button, SIGNAL(clicked(bool)),
SLOT(slotDelete(bool)));
connect(
ui.duplicate_button, SIGNAL(clicked(bool)),
SLOT(slotDuplicate(bool)));
connect(
ui.new_button, SIGNAL(clicked(bool)),
SLOT(slotNew(bool)));
}
WindowDefinitionListWidget::WindowDefinitionListWidget(KHotKeys::Windowdef_list *windowdef, QWidget *parent)
: HotkeysWidgetIFace(parent)
,_windowdefs(NULL)
,_working(NULL)
,_changed(false)
{
ui.setupUi(this);
setWindowDefinitions(windowdef);
connect(
ui.edit_button, SIGNAL(clicked(bool)),
SLOT(slotEdit(bool)));
connect(
ui.delete_button, SIGNAL(clicked(bool)),
SLOT(slotDelete(bool)));
connect(
ui.duplicate_button, SIGNAL(clicked(bool)),
SLOT(slotDuplicate(bool)));
connect(
ui.new_button, SIGNAL(clicked(bool)),
SLOT(slotNew(bool)));
}
WindowDefinitionListWidget::~WindowDefinitionListWidget()
{
delete _working;
}
void WindowDefinitionListWidget::doCopyFromObject()
{
// We are asked to copy again from object. Recreate our working copy
if (_working) delete _working;
_working = _windowdefs->copy();
ui.comment->setText(_working->comment());
for ( KHotKeys::Windowdef_list::ConstIterator it(_working->constBegin());
it != _working->constEnd();
++it)
{
new QListWidgetItem((*it)->description(), ui.list);
}
emitChanged(false);
}
void WindowDefinitionListWidget::doCopyToObject()
{
// Delete the old content
qDeleteAll(*_windowdefs);
_windowdefs->clear();
_windowdefs->set_comment(ui.comment->text());
for (int i=0; i<_working->size(); ++i)
{
_windowdefs->append(_working->at(i)->copy());
}
// Reset our _changed state
_changed = false;
emitChanged(false);
}
void WindowDefinitionListWidget::emitChanged( bool chgd )
{
if (_changed == chgd)
return;
// emitChanged will never reset _changed to false because we have
// currently no way to compare the contents of _working and _windowdefs.
// That's why we say once changed -> always changed.
_changed = chgd || _changed;
emit changed(_changed);
}
bool WindowDefinitionListWidget::isChanged() const
{
return _changed;
}
void WindowDefinitionListWidget::slotDelete(bool)
{
// TODO: Deactivate buttons if nothing is selected
if (ui.list->currentRow() == -1)
return;
Q_ASSERT(ui.list->currentRow() < _working->count());
KHotKeys::Windowdef *def = _working->at(ui.list->currentRow());
KHotKeys::Windowdef_simple *sim = dynamic_cast<KHotKeys::Windowdef_simple*>(def);
Q_ASSERT(sim);
// Remove it from the list
ui.list->takeItem(ui.list->currentRow());
// delete it
_working->removeAll(sim);
delete sim;
emitChanged(true);
return;
}
void WindowDefinitionListWidget::slotDuplicate(bool)
{
// TODO: Deactivate buttons if nothing is selected
if (ui.list->currentRow() == -1)
return;
Q_ASSERT(ui.list->currentRow() < _working->count());
// Get the template
KHotKeys::Windowdef *def = _working->at(ui.list->currentRow());
KHotKeys::Windowdef_simple *orig = dynamic_cast<KHotKeys::Windowdef_simple*>(def);
Q_ASSERT(orig);
// Create a copy
KHotKeys::Windowdef_simple *sim = orig->copy();
Q_ASSERT(sim);
WindowDefinitionDialog dialog(sim, this);
switch (dialog.exec())
{
case QDialog::Accepted:
// Update our list if necessary
new QListWidgetItem(sim->description(), ui.list);
_working->append(sim);
emitChanged(true);
break;
case QDialog::Rejected:
// Nothing to do
delete sim;
break;
default:
Q_ASSERT(false);
delete sim;
}
}
void WindowDefinitionListWidget::slotEdit(bool)
{
// TODO: Deactivate buttons if nothing is selected
if (ui.list->currentRow() == -1)
return;
Q_ASSERT(ui.list->currentRow() < _working->count());
QListWidgetItem *item = ui.list->currentItem();
KHotKeys::Windowdef *def = _working->at(ui.list->currentRow());
KHotKeys::Windowdef_simple *sim = dynamic_cast<KHotKeys::Windowdef_simple*>(def);
Q_ASSERT(sim);
if (!sim) return;
WindowDefinitionDialog dialog(sim, this);
switch (dialog.exec())
{
case QDialog::Accepted:
// Update our list if necessary
item->setText(sim->description());
emitChanged(true);
break;
case QDialog::Rejected:
// Nothing to do
break;
default:
Q_ASSERT(false);
}
}
void WindowDefinitionListWidget::slotNew(bool)
{
KHotKeys::Windowdef_simple *sim = new KHotKeys::Windowdef_simple();
WindowDefinitionDialog dialog(sim, this);
switch (dialog.exec())
{
case QDialog::Accepted:
// Update our list if necessary
new QListWidgetItem(sim->description(), ui.list);
_working->append(sim);
emitChanged(true);
break;
case QDialog::Rejected:
// Nothing to do
delete sim;
break;
default:
Q_ASSERT(false);
delete sim;
}
}
void WindowDefinitionListWidget::setWindowDefinitions(KHotKeys::Windowdef_list *list)
{
Q_ASSERT(list);
_windowdefs = list;
}
#include "moc_window_definition_list_widget.cpp"

View file

@ -1,121 +0,0 @@
#ifndef WINDOW_DEFINITION_LIST_WIDGET_H
#define WINDOW_DEFINITION_LIST_WIDGET_H
/* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "hotkeys_widget_iface.h"
#include "ui_window_definition_list_widget.h"
#include "windows_helper/window_selection_list.h"
#include <KDialog>
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class WindowDefinitionListWidget : public HotkeysWidgetIFace
{
Q_OBJECT
public:
/**
* Default constructor
*/
WindowDefinitionListWidget(
KHotKeys::Windowdef_list *windowdef_list,
QWidget *parent = NULL);
WindowDefinitionListWidget(QWidget *parent);
/**
* Destructor
*/
virtual ~WindowDefinitionListWidget();
void setWindowDefinitions(KHotKeys::Windowdef_list *windowdef_list);
bool isChanged() const;
private:
void emitChanged(bool);
private Q_SLOTS:
void slotDelete(bool);
void slotDuplicate(bool);
void slotEdit(bool);
void slotNew(bool);
protected:
void doCopyFromObject();
void doCopyToObject();
private:
// The Windowdefinition list
KHotKeys::Windowdef_list *_windowdefs;
KHotKeys::Windowdef_list *_working;
// The User Interface
Ui::WindowDefinitionListWidget ui;
// Unsaved changes?
bool _changed;
};
class WindowDefinitionListDialog : public KDialog
{
Q_OBJECT
public:
WindowDefinitionListDialog(
KHotKeys::Windowdef_list *list,
QWidget *parent=NULL)
: KDialog(parent)
,def(NULL)
{
def = new WindowDefinitionListWidget(list, this);
setMainWidget(def);
def->copyFromObject();
}
~WindowDefinitionListDialog()
{
def = NULL;
}
virtual void accept()
{
def->copyToObject();
KDialog::accept();
}
private:
WindowDefinitionListWidget *def;
};
#endif /* #ifndef WINDOW_DEFINITION_LIST_WIDGET_H */

View file

@ -1,77 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WindowDefinitionListWidget</class>
<widget class="QWidget" name="WindowDefinitionListWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>308</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="comment_label">
<property name="text">
<string>Comment:</string>
</property>
</widget>
</item>
<item>
<widget class="KLineEdit" name="comment"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="list"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="edit_button">
<property name="text">
<string>&amp;Edit...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="new_button">
<property name="text">
<string>&amp;New...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="duplicate_button">
<property name="text">
<string>&amp;Duplicate...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="delete_button">
<property name="text">
<string>&amp;Delete</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -1,204 +0,0 @@
/* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "window_definition_widget.h"
#include "ui_window_definition_widget.h"
#include "windows_handler.h"
#include "helper_widgets/window_selector.h"
#include "windows_helper/window_selection_rules.h"
#include <KDebug>
WindowDefinitionWidget::WindowDefinitionWidget(KHotKeys::Windowdef_simple *windowdef, QWidget *parent)
: HotkeysWidgetIFace(parent)
,ui(new Ui_WindowDefinitionWidget)
,_windowdef(windowdef)
{
ui->setupUi(this);
connect(ui->window_class_combo, SIGNAL(currentIndexChanged(int)),
SLOT(slotWindowClassChanged(int)));
connect(ui->window_title_combo, SIGNAL(currentIndexChanged(int)),
SLOT(slotWindowTitleChanged(int)));
connect(ui->window_role_combo, SIGNAL(currentIndexChanged(int)),
SLOT(slotWindowRoleChanged(int)));
connect(ui->autodetect, SIGNAL(clicked()),
SLOT(slotAutoDetect()));
// user changes -> isChanged for all others
connect(
ui->comment, SIGNAL(textChanged(QString)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui->comment, "text" );
connect(
ui->window_class, SIGNAL(textChanged(QString)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui->window_class, "window_class" );
connect(
ui->window_role, SIGNAL(textChanged(QString)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui->window_role, "window_role" );
connect(
ui->window_title, SIGNAL(textChanged(QString)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui->window_title, "window_title" );
connect(
ui->type_dialog, SIGNAL(toggled(bool)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui->type_dialog, "window_type_dialog" );
connect(
ui->type_dock, SIGNAL(toggled(bool)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui->type_dock, "window_type_dock" );
connect(
ui->type_desktop, SIGNAL(toggled(bool)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui->type_desktop, "window_type_desktop" );
connect(
ui->type_normal, SIGNAL(toggled(bool)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui->type_normal, "window_type_normal" );
}
WindowDefinitionWidget::~WindowDefinitionWidget()
{ delete ui; }
void WindowDefinitionWidget::doCopyFromObject()
{
ui->comment->setText(_windowdef->comment());
ui->window_class->setText(_windowdef->wclass());
ui->window_class_combo->setCurrentIndex(_windowdef->wclass_match_type());
ui->window_role->setText(_windowdef->role());
ui->window_role_combo->setCurrentIndex(_windowdef->role_match_type());
ui->window_title->setText(_windowdef->title());
ui->window_title_combo->setCurrentIndex(_windowdef->title_match_type());
ui->type_desktop->setChecked(
_windowdef->type_match(KHotKeys::Windowdef_simple::WINDOW_TYPE_DESKTOP));
ui->type_dialog->setChecked(
_windowdef->type_match(KHotKeys::Windowdef_simple::WINDOW_TYPE_DIALOG));
ui->type_dock->setChecked(
_windowdef->type_match(KHotKeys::Windowdef_simple::WINDOW_TYPE_DOCK));
ui->type_normal->setChecked(
_windowdef->type_match(KHotKeys::Windowdef_simple::WINDOW_TYPE_NORMAL));
}
void WindowDefinitionWidget::doCopyToObject()
{
_windowdef->set_comment(ui->comment->text());
_windowdef->set_wclass(ui->window_class->text());
_windowdef->set_wclass_match_type(static_cast<KHotKeys::Windowdef_simple::substr_type_t>(ui->window_class_combo->currentIndex()));
_windowdef->set_role(ui->window_role->text());
_windowdef->set_role_match_type(static_cast<KHotKeys::Windowdef_simple::substr_type_t>(ui->window_role_combo->currentIndex()));
_windowdef->set_title(ui->window_title->text());
_windowdef->set_title_match_type(static_cast<KHotKeys::Windowdef_simple::substr_type_t>(ui->window_title_combo->currentIndex()));
int types = 0;
if (ui->type_desktop->isChecked())
types |= KHotKeys::Windowdef_simple::WINDOW_TYPE_DESKTOP;
if (ui->type_dialog->isChecked())
types |= KHotKeys::Windowdef_simple::WINDOW_TYPE_DIALOG;
if (ui->type_dock->isChecked())
types |= KHotKeys::Windowdef_simple::WINDOW_TYPE_DOCK;
if (ui->type_normal->isChecked())
types |= KHotKeys::Windowdef_simple::WINDOW_TYPE_NORMAL;
_windowdef->set_window_types(types);
}
bool WindowDefinitionWidget::isChanged() const
{
if ( _windowdef->comment() != ui->comment->text()
|| _windowdef->wclass() != ui->window_class->text()
|| _windowdef->wclass_match_type() != ui->window_class_combo->currentIndex()
|| _windowdef->role() != ui->window_role->text()
|| _windowdef->role_match_type() != ui->window_role_combo->currentIndex()
|| _windowdef->title() != ui->window_title->text()
|| _windowdef->title_match_type() != ui->window_title_combo->currentIndex())
{
return true;
}
int types = 0;
if (ui->type_desktop->isChecked())
types |= KHotKeys::Windowdef_simple::WINDOW_TYPE_DESKTOP;
if (ui->type_dialog->isChecked())
types |= KHotKeys::Windowdef_simple::WINDOW_TYPE_DIALOG;
if (ui->type_dock->isChecked())
types |= KHotKeys::Windowdef_simple::WINDOW_TYPE_DOCK;
if (ui->type_normal->isChecked())
types |= KHotKeys::Windowdef_simple::WINDOW_TYPE_NORMAL;
kDebug() << _windowdef->window_types() << types;
return _windowdef->window_types() != types;
}
void WindowDefinitionWidget::slotAutoDetect()
{
KHotKeys::WindowSelector* sel = new KHotKeys::WindowSelector( this, SLOT(slotWindowSelected(WId)));
sel->select();
}
void WindowDefinitionWidget::slotWindowClassChanged(int index)
{
ui->window_class->setEnabled(index!=0);
slotChanged("window_class");
}
void WindowDefinitionWidget::slotWindowRoleChanged(int index)
{
ui->window_role->setEnabled(index!=0);
slotChanged("window_role");
}
void WindowDefinitionWidget::slotWindowSelected(WId window)
{
if (window)
{
KHotKeys::Window_data data( window );
ui->window_title->setText( data.title );
ui->window_role->setText( data.role );
ui->window_class->setText( data.wclass );
ui->type_normal->setChecked( data.type == NET::Normal );
ui->type_dialog->setChecked( data.type == NET::Dialog );
ui->type_dock->setChecked( data.type == NET::Dock );
ui->type_desktop->setChecked( data.type == NET::Desktop );
}
}
void WindowDefinitionWidget::slotWindowTitleChanged(int index)
{
ui->window_title->setEnabled(index!=0);
slotChanged("window_title");
}
#include "moc_window_definition_widget.cpp"

View file

@ -1,113 +0,0 @@
#ifndef WINDOW_DEFINITION_H
#define WINDOW_DEFINITION_H
/* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "hotkeys_widget_iface.h"
#include "qwindowdefs.h"
#include <QtGui/QWidget>
#include <KDialog>
QT_BEGIN_NAMESPACE
class Ui_WindowDefinitionWidget;
QT_END_NAMESPACE
namespace KHotKeys {
class Windowdef_simple;
}
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class WindowDefinitionWidget : public HotkeysWidgetIFace
{
Q_OBJECT
public:
/**
* Default constructor
*/
WindowDefinitionWidget(KHotKeys::Windowdef_simple *windowdef, QWidget *parent = NULL);
/**
* Destructor
*/
virtual ~WindowDefinitionWidget();
bool isChanged() const;
protected:
void doCopyFromObject();
void doCopyToObject();
private Q_SLOTS:
void slotWindowClassChanged(int);
void slotWindowRoleChanged(int);
void slotWindowTitleChanged(int);
void slotAutoDetect();
void slotWindowSelected(WId);
private:
Ui_WindowDefinitionWidget *ui;
KHotKeys::Windowdef_simple *_windowdef;
};
class WindowDefinitionDialog : public KDialog
{
Q_OBJECT
public:
WindowDefinitionDialog( KHotKeys::Windowdef_simple *windowdef, QWidget *parent=NULL)
: KDialog(parent)
,def(NULL)
{
def = new WindowDefinitionWidget(windowdef, this);
setMainWidget(def);
def->copyFromObject();
}
~WindowDefinitionDialog()
{
def = NULL;
}
virtual void accept()
{
def->copyToObject();
KDialog::accept();
}
private:
WindowDefinitionWidget *def;
};
#endif /* #ifndef WINDOW_DEFINITION_H */

View file

@ -1,249 +0,0 @@
<ui version="4.0" >
<class>WindowDefinitionWidget</class>
<widget class="QWidget" name="WindowDefinitionWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>371</width>
<height>404</height>
</rect>
</property>
<layout class="QVBoxLayout" name="_2" >
<item>
<widget class="QGroupBox" name="groupBox_2" >
<property name="title" >
<string>Window Data</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="comment_label" >
<property name="text" >
<string>Comment:</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="window_title_label" >
<property name="text" >
<string>Window title:</string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QComboBox" name="window_title_combo" >
<item>
<property name="text" >
<string comment="window title is not important">Is Not Important</string>
</property>
</item>
<item>
<property name="text" >
<string>Contains</string>
</property>
</item>
<item>
<property name="text" >
<string>Is</string>
</property>
</item>
<item>
<property name="text" >
<string>Matches Regular Expression</string>
</property>
</item>
<item>
<property name="text" >
<string>Does Not Contain</string>
</property>
</item>
<item>
<property name="text" >
<string>Is Not</string>
</property>
</item>
<item>
<property name="text" >
<string>Does Not Match Regular Expression</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="window_class_label" >
<property name="text" >
<string>Window class:</string>
</property>
</widget>
</item>
<item row="3" column="2" >
<widget class="QComboBox" name="window_class_combo" >
<item>
<property name="text" >
<string comment="window class is not important">Is Not Important</string>
</property>
</item>
<item>
<property name="text" >
<string>Contains</string>
</property>
</item>
<item>
<property name="text" >
<string>Is</string>
</property>
</item>
<item>
<property name="text" >
<string>Matches Regular Expression</string>
</property>
</item>
<item>
<property name="text" >
<string>Does Not Contain</string>
</property>
</item>
<item>
<property name="text" >
<string>Is Not</string>
</property>
</item>
<item>
<property name="text" >
<string>Does Not Match Regular Expression</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="window_role_label" >
<property name="text" >
<string>Window role:</string>
</property>
</widget>
</item>
<item row="5" column="2" >
<widget class="QComboBox" name="window_role_combo" >
<item>
<property name="text" >
<string comment="window role is not important">Is Not Important</string>
</property>
</item>
<item>
<property name="text" >
<string>Contains</string>
</property>
</item>
<item>
<property name="text" >
<string>Is</string>
</property>
</item>
<item>
<property name="text" >
<string>Matches Regular Expression</string>
</property>
</item>
<item>
<property name="text" >
<string>Does Not Contain</string>
</property>
</item>
<item>
<property name="text" >
<string>Is Not</string>
</property>
</item>
<item>
<property name="text" >
<string>Does Not Match Regular Expression</string>
</property>
</item>
</widget>
</item>
<item row="2" column="2" >
<widget class="KLineEdit" name="window_title" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="2" >
<widget class="KLineEdit" name="window_class" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="2" >
<widget class="KLineEdit" name="window_role" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="KLineEdit" name="comment" />
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="autodetect" >
<property name="text" >
<string>&amp;Autodetect</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Window Types</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" >
<item row="0" column="0" >
<widget class="QRadioButton" name="type_normal" >
<property name="text" >
<string>Normal</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QRadioButton" name="type_desktop" >
<property name="text" >
<string>Desktop</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QRadioButton" name="type_dialog" >
<property name="text" >
<string>Dialog</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QRadioButton" name="type_dock" >
<property name="text" >
<string>Dock</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -1,89 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#define WINDOWSELECTOR_CPP
#include "helper_widgets/window_selector.h"
#include <kdebug.h>
#include <kapplication.h>
#include <QtGui/QDesktopWidget>
#include <X11/Xlib.h>
#include <QtGui/qx11info_x11.h>
#include <fixx11h.h>
namespace KHotKeys
{
WindowSelector::WindowSelector( QObject* receiver_P, const char* slot_P )
{
connect( this, SIGNAL(selected_signal(WId)), receiver_P, slot_P );
}
void WindowSelector::select()
{
kapp->desktop()->grabMouse( QCursor( Qt::CrossCursor ));
kapp->installX11EventFilter( this );
}
bool WindowSelector::x11Event( XEvent* e )
{
if( e->type != ButtonPress )
return false;
kapp->desktop()->releaseMouse();
if( e->xbutton.button == Button1 )
{
WId window = findRealWindow( e->xbutton.subwindow );
if( window )
selected_signal( window );
}
delete this;
return true;
}
WId WindowSelector::findRealWindow( WId w, int depth )
{
if( depth > 5 )
return None;
static Atom wm_state = XInternAtom( QX11Info::display(), "WM_STATE", False );
Atom type;
int format;
unsigned long nitems, after;
unsigned char* prop;
if( XGetWindowProperty( QX11Info::display(), w, wm_state, 0, 0, False, AnyPropertyType,
&type, &format, &nitems, &after, &prop ) == Success )
{
if( prop != NULL )
XFree( prop );
if( type != None )
return w;
}
Window root, parent;
Window* children;
unsigned int nchildren;
Window ret = None;
if( XQueryTree( QX11Info::display(), w, &root, &parent, &children, &nchildren ) != 0 )
{
for( unsigned int i = 0;
i < nchildren && ret == None;
++i )
ret = findRealWindow( children[ i ], depth + 1 );
if( children != NULL )
XFree( children );
}
return ret;
}
} // namespace KHotKeys
#include "moc_window_selector.cpp"

View file

@ -1,36 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#ifndef WINDOWSELECTOR_H
#define WINDOWSELECTOR_H
#include <QWidget>
namespace KHotKeys
{
class WindowSelector : public QWidget
{
Q_OBJECT
public:
WindowSelector( QObject* receiver, const char* slot );
void select();
protected:
virtual bool x11Event( XEvent* e );
Q_SIGNALS:
void selected_signal( WId w );
private:
WId findRealWindow( WId w, int depth = 0 );
};
} // namespace KHotKeys
#endif

View file

@ -1,381 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "hotkeys_tree_view.h"
#include "hotkeys_context_menu.h"
#include "hotkeys_export_widget.h"
#include "hotkeys_model.h"
#include "actions/actions.h"
#include "action_data/action_data_group.h"
#include "action_data/simple_action_data.h"
#include <KDebug>
#include <KFileDialog>
#include <KLocale>
#include <KUrl>
#include <QtCore/QSignalMapper>
#include <QtGui/qevent.h>
HotkeysTreeViewContextMenu::HotkeysTreeViewContextMenu( const QModelIndex &index, HotkeysTreeView *parent )
: QMenu(parent)
,_index(index)
,_view(parent)
{
setTitle( i18n("Test") );
connect(this, SIGNAL(aboutToShow()),
SLOT(slotAboutToShow()));
}
HotkeysTreeViewContextMenu::HotkeysTreeViewContextMenu( HotkeysTreeView *parent )
: QMenu(parent)
,_index()
,_view(parent)
{
setTitle( i18n("Test") );
connect(this, SIGNAL(aboutToShow()),
SLOT(slotAboutToShowForCurrent()));
}
HotkeysTreeViewContextMenu::~HotkeysTreeViewContextMenu()
{}
KHotKeys::Action *
HotkeysTreeViewContextMenu::createActionFromType(
int actionType,
KHotKeys::SimpleActionData* data
) const
{
KHotKeys::Action *action = NULL;
switch (actionType)
{
case KHotKeys::Action::CommandUrlActionType:
action = new KHotKeys::CommandUrlAction( data );
break;
case KHotKeys::Action::DBusActionType:
action = new KHotKeys::DBusAction( data );
break;
case KHotKeys::Action::KeyboardInputActionType:
action = new KHotKeys::KeyboardInputAction( data );
break;
case KHotKeys::Action::MenuEntryActionType:
action = new KHotKeys::MenuEntryAction( data );
break;
default:
Q_ASSERT(false);
return NULL;
}
data->set_action(action);
return action;
}
void HotkeysTreeViewContextMenu::slotAboutToShowForCurrent()
{
_index = _view->currentIndex();
slotAboutToShow();
}
void HotkeysTreeViewContextMenu::slotAboutToShow()
{
clear();
if (_index.isValid())
{
KHotKeys::ActionDataBase *element = _view->model()->indexToActionDataBase(_index);
KHotKeys::ActionDataGroup *group = _view->model()->indexToActionDataGroup(_index);
bool isGroup = group; // Is the current element a group
if (!isGroup)
{
group = element->parent();
}
// Create the create actions
createTriggerMenus(group->allowedTriggerTypes(), group->allowedActionTypes());
// It is not allowed to create a subgroup for a system group.
if (!group->is_system_group())
{
addAction( i18n("New Group") , this, SLOT(newGroupAction()) );
}
// It is not allowed to delete a system group
if (!(isGroup && group->is_system_group()))
{
// Item related actions
addAction( i18n("Delete"), this, SLOT(deleteAction()) );
}
}
else
{
createTriggerMenus(KHotKeys::Trigger::AllTypes, KHotKeys::Action::AllTypes);
addAction( i18n("New Group") , this, SLOT(newGroupAction()) );
}
addSeparator();
addAction( i18n("Export Group..."), this, SLOT(exportAction()) );
addAction( i18n("Import..."), this, SLOT(importAction()) );
}
void HotkeysTreeViewContextMenu::createTriggerMenus(
KHotKeys::Trigger::TriggerTypes triggerTypes,
KHotKeys::Action::ActionTypes actionTypes)
{
QMenu *newMenu = new QMenu(i18nc("@title:menu create various trigger types", "New"));
if (triggerTypes & KHotKeys::Trigger::ShortcutTriggerType)
{
QSignalMapper *mapper = new QSignalMapper(this);
QMenu *menu = new QMenu( i18n("Global Shortcut") );
populateTriggerMenu(menu, mapper, actionTypes);
newMenu->addMenu(menu);
connect(
mapper, SIGNAL(mapped(int)),
this, SLOT(newGlobalShortcutActionAction(int)) );
}
if (triggerTypes & KHotKeys::Trigger::WindowTriggerType)
{
QSignalMapper *mapper = new QSignalMapper(this);
QMenu *menu = new QMenu( i18n("Window Action") );
populateTriggerMenu(menu, mapper, actionTypes);
newMenu->addMenu(menu);
connect(
mapper, SIGNAL(mapped(int)),
this, SLOT(newWindowTriggerActionAction(int)) );
}
addMenu(newMenu);
}
void HotkeysTreeViewContextMenu::importAction()
{
KUrl url = KFileDialog::getOpenFileName(KUrl(), "*.khotkeys", this);
if (!url.isEmpty())
{
KConfig config(url.path(), KConfig::SimpleConfig);
_view->model()->importInputActions(_index, config);
}
}
void HotkeysTreeViewContextMenu::exportAction()
{
KHotkeysExportDialog *widget = new KHotkeysExportDialog(this);
KHotKeys::ActionDataGroup *group = _view->model()->indexToActionDataGroup(_index);
if (!group)
group = _view->model()->indexToActionDataBase(_index)->parent();
widget->setImportId(group->importId());
widget->setAllowMerging(group->allowMerging());
if (widget->exec() == QDialog::Accepted)
{
KHotKeys::ActionState state;
switch (widget->state())
{
case 0:
state = KHotKeys::Retain;
break;
case 1:
state = KHotKeys::Enabled;
break;
case 2:
state = KHotKeys::Disabled;
break;
default:
// Unknown value alled to our ui file. Use disabled as a
// default.
Q_ASSERT(false);
state = KHotKeys::Disabled;
break;
}
QString id = widget->importId();
KUrl url = widget->url();
bool allowMerging = widget->allowMerging();
if (!url.isEmpty())
{
KConfig config(url.path(), KConfig::SimpleConfig);
_view->model()->exportInputActions(_index, config, id, state, allowMerging);
}
}
delete widget;
}
void HotkeysTreeViewContextMenu::populateTriggerMenu(
QMenu *menu,
QSignalMapper *mapper,
KHotKeys::Action::ActionTypes types)
{
if (types & KHotKeys::Action::CommandUrlActionType)
{
mapper->setMapping(
menu->addAction( i18n("Command/URL"), mapper, SLOT(map()) ),
KHotKeys::Action::CommandUrlActionType );
}
if (types & KHotKeys::Action::DBusActionType)
{
mapper->setMapping(
menu->addAction( i18n("D-Bus Command"), mapper, SLOT(map()) ),
KHotKeys::Action::DBusActionType );
}
if (types & KHotKeys::Action::MenuEntryActionType)
{
mapper->setMapping(
menu->addAction( i18n("K-Menu Entry"), mapper, SLOT(map()) ),
KHotKeys::Action::MenuEntryActionType );
}
if (types & KHotKeys::Action::KeyboardInputActionType)
{
mapper->setMapping(
menu->addAction( i18n("Send Keyboard Input"), mapper, SLOT(map()) ),
KHotKeys::Action::KeyboardInputActionType );
}
}
void HotkeysTreeViewContextMenu::newGlobalShortcutActionAction( int actionType )
{
QModelIndex parent; // == root element
if (!_index.isValid()
|| _view->model()->data( _index.sibling( _index.row(), KHotkeysModel::IsGroupColumn)).toBool())
{
// if the index is invalid (root index) or represents an group use it.
parent = _index;
}
else
{
// It is an action. Take the parent.
parent = _index.parent();
}
KHotKeys::SimpleActionData *data =
new KHotKeys::SimpleActionData( 0, i18n("New Action"), i18n("Comment"));
data->set_trigger( new KHotKeys::ShortcutTrigger( data, KShortcut() ) );
data->enable();
createActionFromType(actionType, data);
QModelIndex newAct = _view->model()->insertActionData(data, parent);
_view->setCurrentIndex(newAct);
_view->edit(newAct);
_view->resizeColumnToContents(KHotkeysModel::NameColumn);
}
void HotkeysTreeViewContextMenu::newWindowTriggerActionAction( int actionType )
{
QModelIndex parent; // == root element
if (!_index.isValid()
|| _view->model()->data( _index.sibling( _index.row(), KHotkeysModel::IsGroupColumn)).toBool())
{
// if the index is invalid (root index) or represents an group use it.
parent = _index;
}
else
{
// It is an action. Take the parent.
parent = _index.parent();
}
KHotKeys::SimpleActionData *data =
new KHotKeys::SimpleActionData( 0, i18n("New Action"), i18n("Comment"));
data->set_trigger( new KHotKeys::WindowTrigger(data) );
data->enable();
createActionFromType(actionType, data);
QModelIndex newAct = _view->model()->insertActionData(data, parent);
_view->setCurrentIndex(newAct);
_view->edit(newAct);
_view->resizeColumnToContents(KHotkeysModel::NameColumn);
}
void HotkeysTreeViewContextMenu::newGroupAction()
{
QModelIndex parent; // == root element
if (!_index.isValid()
|| _view->model()->data( _index.sibling( _index.row(), KHotkeysModel::IsGroupColumn)).toBool())
{
// if the index is invalid (root index) or represents an group use it.
parent = _index;
}
else
{
// It is an action. Take the parent.
parent = _index.parent();
}
QModelIndex newGroup = _view->model()->addGroup(parent);
_view->setCurrentIndex(newGroup);
_view->edit(newGroup);
_view->resizeColumnToContents(KHotkeysModel::NameColumn);
}
void HotkeysTreeViewContextMenu::deleteAction()
{
if (!_index.isValid())
{
Q_ASSERT( _index.isValid() );
return;
}
bool deletionSuccess;
deletionSuccess = _view->model()->removeRow(_index.row(), _index.parent());
Q_ASSERT(deletionSuccess == true);
Q_UNUSED(deletionSuccess);
_view->setCurrentIndex(QModelIndex());
}
#include "moc_hotkeys_context_menu.cpp"

View file

@ -1,82 +0,0 @@
#ifndef HOTKEYS_CONTEXT_MENU_H
#define HOTKEYS_CONTEXT_MENU_H
/**
* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "triggers/triggers.h"
#include "actions/actions.h"
#include "libkhotkeysfwd.h"
#include <QtGui/QMenu>
#include <QtCore/qabstractitemmodel.h>
class HotkeysTreeView;
#include <QModelIndex>
#include <QSignalMapper>
class HotkeysTreeViewContextMenu : public QMenu
{
Q_OBJECT
public:
HotkeysTreeViewContextMenu( const QModelIndex &index, HotkeysTreeView *parent = 0 );
HotkeysTreeViewContextMenu( HotkeysTreeView *parent = 0 );
virtual ~HotkeysTreeViewContextMenu();
//! Create a submenu per allowed trigger type
void createTriggerMenus(
KHotKeys::Trigger::TriggerTypes triggerTypes,
KHotKeys::Action::ActionTypes actionTypes);
//! Populate a trigger menu
void populateTriggerMenu(QMenu *menu, QSignalMapper *mapper, KHotKeys::Action::ActionTypes types);
private Q_SLOTS:
void slotAboutToShow();
void slotAboutToShowForCurrent();
void deleteAction();
void exportAction();
void importAction();
void newGlobalShortcutActionAction(int);
void newWindowTriggerActionAction(int);
void newGroupAction();
private:
KHotKeys::Action* createActionFromType(
int type,
KHotKeys::SimpleActionData *data) const;
QModelIndex _index;
HotkeysTreeView *_view;
};
#endif /* HOTKEYS_CONTEXT_MENU_H */

View file

@ -1,93 +0,0 @@
/**
* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "hotkeys_export_widget.h"
#include <KLocale>
KHotkeysExportWidget::KHotkeysExportWidget(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
}
KHotkeysExportWidget::~KHotkeysExportWidget()
{
}
KHotkeysExportDialog::KHotkeysExportDialog(QWidget *parent)
: KDialog(parent)
{
setCaption(i18n("Export Group"));
setButtons(KDialog::Ok | KDialog::Cancel);
w = new KHotkeysExportWidget(this);
setMainWidget(w);
}
KHotkeysExportDialog::~KHotkeysExportDialog()
{}
bool
KHotkeysExportDialog::allowMerging() const
{
return w->ui.allowMerging->isChecked();
}
QString
KHotkeysExportDialog::importId() const
{
return w->ui.id->text();
}
void
KHotkeysExportDialog::setAllowMerging(bool allow)
{
w->ui.allowMerging->setChecked(allow);
}
void
KHotkeysExportDialog::setImportId(const QString &id)
{
w->ui.id->setText(id);
}
int
KHotkeysExportDialog::state() const
{
return w->ui.state->currentIndex();
}
KUrl
KHotkeysExportDialog::url() const
{
return w->ui.filename->url();
}
#include "moc_hotkeys_export_widget.cpp"

View file

@ -1,70 +0,0 @@
#ifndef HOTKEYS_EXPORT_WIDGET_H
#define HOTKEYS_EXPORT_WIDGET_H
/**
* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "ui_hotkeys_export_widget.h"
#include "kdialog.h"
#include "kurl.h"
#include <QtGui/QWidget>
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class KHotkeysExportWidget : public QWidget
{
Q_OBJECT
public:
KHotkeysExportWidget(QWidget *parent);
virtual ~KHotkeysExportWidget();
// The layout
Ui::KHotkeysExportWidget ui;
}; // KHotkeysExportWidget
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class KHotkeysExportDialog : public KDialog
{
public:
KHotkeysExportDialog(QWidget*);
virtual ~KHotkeysExportDialog();
QString importId() const;
bool allowMerging() const;
void setAllowMerging(bool);
void setImportId(const QString &id);
int state() const;
KUrl url() const;
private:
KHotkeysExportWidget *w;
}; // KHotkeysExportDialog
#endif /* HOTKEYS_EXPORT_WIDGET_H */

View file

@ -1,165 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KHotkeysExportWidget</class>
<widget class="QWidget" name="KHotkeysExportWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>587</width>
<height>128</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="stateLabel">
<property name="toolTip">
<string>Change the exported state for the actions.</string>
</property>
<property name="text">
<string>Export Actions</string>
</property>
<property name="buddy">
<cstring>state</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="state">
<property name="whatsThis">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Configure in which state the actions should be exported.&lt;/p&gt;
&lt;p style=&quot; margin-top:8px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Actual State&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:30px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Export the actions in their current state.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Disabled&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:30px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Export the actions in a disabled state.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Enabled&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:8px; margin-left:30px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Export the actions in an enabled state.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string comment="Don't change the state of exported hotkey actions.">Actual State</string>
</property>
</item>
<item>
<property name="text">
<string comment="Export hotkey actions in enabled state.">Enabled</string>
</property>
</item>
<item>
<property name="text">
<string comment="Export hotkey actions into disabled state">Disabled</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="idLabel">
<property name="statusTip">
<string>KHotkeys file id.</string>
</property>
<property name="whatsThis">
<string>A khotkeys file id is used to ensure files are not imported more than once. They are mostly used for automatic updates from the KDE developers.</string>
</property>
<property name="text">
<string>Id</string>
</property>
<property name="buddy">
<cstring>id</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KLineEdit" name="id">
<property name="clickMessage">
<string>Set import id for file, or leave empty</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="filenameLabel">
<property name="text">
<string>Filename</string>
</property>
<property name="buddy">
<cstring>filename</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KUrlRequester" name="filename">
<property name="filter">
<string notr="true">*.khotkeys</string>
</property>
<property name="mode">
<set>KFile::File</set>
</property>
<property name="clickMessage">
<string/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="allowMergingLabel">
<property name="text">
<string>Allow Merging</string>
</property>
<property name="buddy">
<cstring>allowMerging</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="allowMerging">
<property name="toolTip">
<string>Merge into existing directories on import?</string>
</property>
<property name="whatsThis">
<string>Allow merging of content if a directory with the same name exists on importing. If merging is not allowed, there will be two directories with the same name.</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KUrlRequester</class>
<extends>QFrame</extends>
<header>kurlrequester.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>state</tabstop>
<tabstop>id</tabstop>
<tabstop>allowMerging</tabstop>
<tabstop>filename</tabstop>
</tabstops>
<connections/>
</ui>

View file

@ -1,712 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "hotkeys_model.h"
#include "action_data/simple_action_data.h"
#include "action_data/menuentry_shortcut_action_data.h"
#include "action_data/action_data_group.h"
#include <typeinfo>
#include <QMimeData>
#include <KDebug>
#include <KLocale>
#include <KIcon>
static KHotKeys::ActionDataBase *findElement(
void *ptr
,KHotKeys::ActionDataGroup *root)
{
Q_ASSERT(root);
if (!root) return NULL;
KHotKeys::ActionDataBase *match = NULL;
Q_FOREACH( KHotKeys::ActionDataBase *element, root->children())
{
if (ptr == element)
{
match = element;
break;
}
if (KHotKeys::ActionDataGroup *subGroup = dynamic_cast<KHotKeys::ActionDataGroup*>(element))
{
match = findElement(ptr, subGroup);
if (match) break;
}
}
return match;
}
KHotkeysModel::KHotkeysModel( QObject *parent )
: QAbstractItemModel(parent)
,_settings()
,_actions(0)
{}
KHotkeysModel::~KHotkeysModel()
{
}
QModelIndex KHotkeysModel::addGroup( const QModelIndex & parent )
{
KHotKeys::ActionDataGroup *list;
if (parent.isValid())
{
list = indexToActionDataGroup(parent);
}
else
{
list = _actions;
}
Q_ASSERT(list);
beginInsertRows( parent, list->size(), list->size() );
/* KHotKeys:: ActionDataGroup *action = */
new KHotKeys::ActionDataGroup( list, i18n("New Group"), i18n("Comment"));
endInsertRows();
return index( list->size()-1, NameColumn, parent );
}
// Add a group
QModelIndex KHotkeysModel::insertActionData( KHotKeys::ActionDataBase *data, const QModelIndex & parent )
{
Q_ASSERT(data);
KHotKeys::ActionDataGroup *list;
if (parent.isValid())
{
list = indexToActionDataGroup(parent);
}
else
{
list = _actions;
}
Q_ASSERT(list);
beginInsertRows( parent, list->size(), list->size() );
list->add_child(data);
endInsertRows();
return index( list->size()-1, NameColumn, parent );
}
int KHotkeysModel::columnCount( const QModelIndex & ) const
{
return 2;
}
QVariant KHotkeysModel::data( const QModelIndex &index, int role ) const
{
// Check that the index is valid
if (!index.isValid())
{
return QVariant();
}
// Get the item behind the index
KHotKeys::ActionDataBase *action = indexToActionDataBase(index);
Q_ASSERT(action);
// Handle CheckStateRole
if (role==Qt::CheckStateRole)
{
switch(index.column())
{
case EnabledColumn:
// If the parent is enabled we display the state of the object.
// If the parent is disabled this object is disabled too.
if (action->parent() && !action->parent()->isEnabled())
{
return Qt::Unchecked;
}
return action->isEnabled()
? Qt::Checked
: Qt::Unchecked;
default:
return QVariant();
}
}
// Display and Tooltip. Tooltip displays the complete name. That's nice if
// there is not enough space
else if (role==Qt::DisplayRole || role==Qt::ToolTipRole)
{
switch (index.column())
{
case NameColumn:
return action->name();
case EnabledColumn:
return QVariant();
case IsGroupColumn:
return indexToActionDataGroup(index)!=0;
case TypeColumn:
{
const std::type_info &ti = typeid(*action);
if (ti==typeid(KHotKeys::SimpleActionData))
return KHotkeysModel::SimpleActionData;
else if (ti==typeid(KHotKeys::MenuEntryShortcutActionData))
return KHotkeysModel::SimpleActionData;
else if (ti==typeid(KHotKeys::ActionDataGroup))
return KHotkeysModel::ActionDataGroup;
else
return KHotkeysModel::Other;
}
default:
return QVariant();
}
}
// Decoration role
else if (role==Qt::DecorationRole)
{
switch (index.column())
{
// The 0 is correct here. We want to decorate that column
// regardless of the content it has
case 0:
return dynamic_cast<KHotKeys::ActionDataGroup*>(action)
? KIcon("folder")
: QVariant();
default:
return QVariant();
}
}
//Providing the current action name on edit
else if (role==Qt::EditRole)
{
switch (index.column())
{
case NameColumn:
return action->name();
default:
return QVariant();
}
}
else if (role==Qt::ForegroundRole)
{
QPalette pal;
switch (index.column())
{
case NameColumn:
if (!action->isEnabled())
{
return pal.color(QPalette::Disabled, QPalette::Foreground);
}
default:
return QVariant();
}
}
// For everything else
return QVariant();
}
bool KHotkeysModel::dropMimeData(
const QMimeData *data
,Qt::DropAction action
,int row
,int column
,const QModelIndex &parent)
{
Q_UNUSED(column);
// We only support move actions and our own mime type
if ( (action!=Qt::CopyAction)
|| !data->hasFormat("application/x-pointer"))
{
kDebug() << "Drop not supported " << data->formats();
return false;
}
// Decode the stream
QByteArray encodedData = data->data("application/x-pointer");
QDataStream stream(&encodedData, QIODevice::ReadOnly);
QList<quintptr> ptrs;
while (!stream.atEnd())
{
qulonglong ptr;
stream >> ptr;
ptrs << quintptr(ptr);
}
// No pointers, nothing to do
if (ptrs.empty()) return false;
// Get the group we have to drop into. If the drop target is no group get
// it's parent and drop behind it
int position = row;
QModelIndex dropIndex = parent;
KHotKeys::ActionDataGroup *dropToGroup = indexToActionDataGroup(dropIndex);
if (!dropToGroup)
{
dropIndex = parent.parent();
dropToGroup = indexToActionDataGroup(dropIndex);
position = dropToGroup->children().indexOf(indexToActionDataBase(parent));
}
if (position==-1)
{
position = dropToGroup->size();
}
// Do the moves
Q_FOREACH(quintptr ptr, ptrs)
{
KHotKeys::ActionDataBase *element = findElement(
reinterpret_cast<void*>(ptr),
_actions);
if (element) moveElement(element, dropToGroup, position);
}
return true;
}
void KHotkeysModel::emitChanged(KHotKeys::ActionDataBase *item)
{
Q_ASSERT( item );
KHotKeys::ActionDataGroup *parent = item->parent();
QModelIndex topLeft;
QModelIndex bottomRight;
if (!parent)
{
topLeft = createIndex( 0, 0, _actions );
bottomRight = createIndex( 0, 0, _actions );
}
else
{
int row = parent->children().indexOf(item);
topLeft = createIndex( row, 0, parent );
bottomRight = createIndex( row, columnCount(topLeft), parent );
}
emit dataChanged( topLeft, bottomRight );
}
void KHotkeysModel::exportInputActions(
const QModelIndex &index,
KConfigBase &config,
const QString& id,
const KHotKeys::ActionState state,
bool mergingAllowed)
{
KHotKeys::ActionDataBase *element = indexToActionDataBase(index);
KHotKeys::ActionDataGroup *group = indexToActionDataGroup(index);
settings()->exportTo(
group ? group : element->parent(),
config,
id,
state,
mergingAllowed);
}
Qt::ItemFlags KHotkeysModel::flags( const QModelIndex &index ) const
{
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
Q_ASSERT(!(flags & Qt::ItemIsDropEnabled));
Q_ASSERT(!(flags & Qt::ItemIsDragEnabled));
if (!index.isValid())
{
return flags | Qt::ItemIsDropEnabled;
}
KHotKeys::ActionDataBase *element = indexToActionDataBase(index);
KHotKeys::ActionDataGroup *actionGroup = indexToActionDataGroup(index);
if (!actionGroup) actionGroup = element->parent();
Q_ASSERT(element);
Q_ASSERT(actionGroup);
// We do not allow dragging for system groups and their elements
// We do not allow dropping into systemgroups
if (!actionGroup->is_system_group())
{
flags |= Qt::ItemIsDragEnabled;
flags |= Qt::ItemIsDropEnabled;
}
// Show a checkbox in column 1 whatever is shown there.
switch (index.column())
{
case 1:
return flags
| Qt::ItemIsUserCheckable;
default:
return flags
| Qt::ItemIsEditable;
}
}
// Get header data for section
QVariant KHotkeysModel::headerData( int section, Qt::Orientation, int role ) const
{
if (role!=Qt::DisplayRole)
{
return QVariant();
}
switch (section)
{
case NameColumn:
return QVariant(i18nc("action name", "Name"));
case EnabledColumn:
return QVariant();
return QVariant(i18nc("action enabled", "Enabled"));
case IsGroupColumn:
return QVariant(i18n("Type"));
default:
return QVariant();
}
}
void KHotkeysModel::importInputActions(const QModelIndex &index, KConfigBase const &config)
{
KHotKeys::ActionDataGroup *group = indexToActionDataGroup(index);
QModelIndex groupIndex = index;
if (!group)
{
group = indexToActionDataBase(index)->parent();
groupIndex = index.parent();
}
if (settings()->importFrom(group, config, KHotKeys::ImportAsk, KHotKeys::Retain))
{
kDebug();
reset();
save();
}
}
QModelIndex KHotkeysModel::index( int row, int column, const QModelIndex &parent ) const
{
KHotKeys::ActionDataGroup *actionGroup = indexToActionDataGroup(parent);
if (!actionGroup || row>=actionGroup->children().size() )
{
return QModelIndex();
}
KHotKeys::ActionDataBase *action = actionGroup->children().at(row);
Q_ASSERT( action );
return createIndex( row, column, action );
}
// Convert index to ActionDataBase
KHotKeys::ActionDataBase *KHotkeysModel::indexToActionDataBase( const QModelIndex &index ) const
{
if (!index.isValid())
{
return _actions;
}
return static_cast<KHotKeys::ActionDataBase*>( index.internalPointer() );
}
// Convert index to ActionDataGroup
KHotKeys::ActionDataGroup *KHotkeysModel::indexToActionDataGroup( const QModelIndex &index ) const
{
if (!index.isValid())
{
return _actions;
}
return dynamic_cast<KHotKeys::ActionDataGroup*>( indexToActionDataBase(index) );
}
void KHotkeysModel::load()
{
_settings.reread_settings(true);
_actions = _settings.actions();
reset();
}
QMimeData *KHotkeysModel::mimeData(const QModelIndexList &indexes) const
{
QMimeData * mimeData = new QMimeData();
QByteArray encodedData;
QDataStream stream(&encodedData, QIODevice::WriteOnly);
Q_FOREACH (const QModelIndex &index, indexes)
{
if (index.isValid() and index.column() == 0)
{
KHotKeys::ActionDataBase *element = indexToActionDataBase(index);
// We use the pointer as id.
stream << qulonglong(reinterpret_cast<quintptr>(element));
}
}
mimeData->setData("application/x-pointer", encodedData);
return mimeData;
}
QStringList KHotkeysModel::mimeTypes() const
{
QStringList types;
types << "application/x-pointer";
return types;
}
bool KHotkeysModel::moveElement(
KHotKeys::ActionDataBase *element
,KHotKeys::ActionDataGroup *newGroup
,int position)
{
Q_ASSERT(element && newGroup);
if (!element || !newGroup) return false;
// TODO: Make this logic more advanced
// We do not allow moving into our systemgroup
if (newGroup->is_system_group()) return false;
// Make sure we don't move a group to one of it's children or
// itself.
KHotKeys::ActionDataGroup *tmp = newGroup;
do {
if (tmp == element)
{
kDebug() << "Forbidden move" << tmp->name();
return false;
}
}
while((tmp = tmp->parent()));
KHotKeys::ActionDataGroup *oldParent = element->parent();
// TODO: Make this logic more advanced
// We do not allow moving from our systemgroup
if (oldParent->is_system_group()) return false;
// Adjust position if oldParent and newGroup are identical
if (oldParent == newGroup)
{
if (oldParent->children().indexOf(element) < position)
{
--position;
}
}
emit layoutAboutToBeChanged();
// Remove it from it's current place
oldParent->remove_child(element);
newGroup->add_child(element, position);
emit layoutChanged();
return true;
}
// Get parent object for index
QModelIndex KHotkeysModel::parent( const QModelIndex &index ) const
{
KHotKeys::ActionDataBase *action = indexToActionDataBase(index);
if (!action)
{
return QModelIndex();
}
KHotKeys::ActionDataGroup *parent = action->parent();
if (!parent)
{
return QModelIndex();
}
KHotKeys::ActionDataGroup *grandparent = parent->parent();
if (!grandparent)
{
return QModelIndex();
}
int row = grandparent->children().indexOf(parent);
return createIndex( row, 0, parent );
}
// Remove rows ( items )
bool KHotkeysModel::removeRows( int row, int count, const QModelIndex &parent )
{
Q_ASSERT( count == 1 );
beginRemoveRows( parent, row, row+count-1 );
KHotKeys::ActionDataGroup *list;
if (parent.isValid())
{
list = indexToActionDataGroup(parent);
}
else
{
list = _actions;
}
Q_ASSERT(list);
Q_UNUSED(list);
KHotKeys::ActionDataBase *action = indexToActionDataBase(index(row,0,parent));
action->aboutToBeErased();
delete action;
endRemoveRows();
return true;
}
// Number of rows for index
int KHotkeysModel::rowCount( const QModelIndex &index ) const
{
KHotKeys::ActionDataGroup *group = indexToActionDataGroup(index);
if (!group)
{
return 0;
}
return group->children().count();
}
void KHotkeysModel::save()
{
_settings.write();
}
// Set data
bool KHotkeysModel::setData( const QModelIndex &index, const QVariant &value, int role )
{
if ( !index.isValid() )
{
return false;
}
KHotKeys::ActionDataBase *action = indexToActionDataBase(index);
Q_ASSERT( action );
// Handle CheckStateRole
if ( role == Qt::CheckStateRole )
{
switch(index.column())
{
case EnabledColumn:
{
// If the parent is enabled we display the state of the object.
// If the parent is disabled this object is disabled too.
if (action->parent() && !action->parent()->isEnabled())
{
// TODO: Either show a message box or enhance the gui to
// show this item cannot be enabled
return false;
}
value.toInt() == Qt::Checked
? action->enable()
: action->disable();
// If this is a group we have to inform the view that all our
// childs have changed. They are all disabled now
KHotKeys::ActionDataGroup *actionGroup = indexToActionDataGroup(index);
if (actionGroup && actionGroup->size())
{
Q_EMIT dataChanged(
createIndex(0, 0, actionGroup),
createIndex(actionGroup->size(), columnCount(index), actionGroup));
}
}
break;
default:
return false;
}
}
else if ( role == Qt::EditRole )
{
switch ( index.column() )
{
case NameColumn:
{
action->set_name( value.toString() );
}
break;
default:
return false;
}
}
else
return false;
emit dataChanged( index, index );
return true;
}
KHotKeys::Settings *KHotkeysModel::settings()
{
return &_settings;
}
#include "moc_hotkeys_model.cpp"

View file

@ -1,171 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KHOTKEYSMODEL_H
#define KHOTKEYSMODEL_H
#include "libkhotkeysfwd.h"
#include "settings.h"
#include <QtCore/QAbstractItemModel>
/**
*/
class KHotkeysModel : public QAbstractItemModel
{
Q_OBJECT
public:
enum ItemType {
Other //!< Some unknown action type
,ActionDataGroup //!< A shortcut group
,SimpleActionData
};
enum Column {
NameColumn,
EnabledColumn,
IsGroupColumn,
TypeColumn };
/**
* Default constructor
*
* @param
*/
KHotkeysModel( QObject *parent = 0 );
/**
* Destructor
*/
virtual ~KHotkeysModel();
/**
* \group Qt Model/View Framework methods
*/
//@{
QModelIndex index( int, int, const QModelIndex &parent = QModelIndex() ) const;
QModelIndex parent( const QModelIndex &index ) const;
int rowCount( const QModelIndex &index ) const;
int columnCount( const QModelIndex &index ) const;
QVariant headerData( int section, Qt::Orientation, int role = Qt::DisplayRole ) const;
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
bool setData( const QModelIndex &index, const QVariant &value, int role );
Qt::ItemFlags flags( const QModelIndex &index ) const;
//@}
/**
* \group Drag and Drop Support
*/
//@{
bool dropMimeData(
const QMimeData *data
,Qt::DropAction action
,int row
,int column
,const QModelIndex &parent);
QMimeData *mimeData(const QModelIndexList &indexes) const;
QStringList mimeTypes() const;
//@}
/**
* Add a group as child of @a parent.
*
* @return the index for the new group
*/
QModelIndex addGroup( const QModelIndex &parent );
/**
* Export the input actions into @a config.
*/
void exportInputActions(
const QModelIndex &index,
KConfigBase &config,
const QString& id,
const KHotKeys::ActionState state,
bool allowMerging);
/**
*Import the input actions from @a config.
*/
void importInputActions(const QModelIndex &index, KConfigBase const &config);
/**
* Get the KHotKeys::ActionDataBase behind the index.
*/
KHotKeys::ActionDataBase *indexToActionDataBase( const QModelIndex &index ) const;
/**
* Get the KHotKeys::ActionDataBase behind the index or 0.
*
* Getting 0 doesn't mean the index is invalid. It means you provided a
* action object.
*/
KHotKeys::ActionDataGroup *indexToActionDataGroup( const QModelIndex &index ) const;
/**
* Insert @a data as a child of @a parent.
*/
QModelIndex insertActionData( KHotKeys::ActionDataBase *data, const QModelIndex &parent );
/**
* Load the settings from the file
*/
void load();
/**
* Move @p element to @p newGroup at @position.
*
* @param element move this element
* @param newGroup to this group
* @param position and put it at this position. default is last
*
* @return @c true if moved, @c false if not.
*/
bool moveElement(
KHotKeys::ActionDataBase *element
,KHotKeys::ActionDataGroup *newGroup
,int position = -1);
/**
* Remove @a count rows starting with @a row under @a parent.
*/
bool removeRows( int row, int count, const QModelIndex &parent );
/**
* Save the settings to the file
*/
void save();
/**
* Return the settings we handle
*/
KHotKeys::Settings *settings();
void emitChanged( KHotKeys::ActionDataBase *item );
private:
KHotKeys::Settings _settings;
KHotKeys::ActionDataGroup *_actions;
};
#endif /* #ifndef KHOTKEYSMODEL_HPP */

View file

@ -1,82 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "hotkeys_proxy_model.h"
#include "hotkeys_model.h"
class KHotkeysProxyModelPrivate
{
public:
KHotkeysProxyModelPrivate( KHotkeysProxyModel *host );
//! Our host
KHotkeysProxyModel *q;
}; // class KHotkeysProxyModelPrivate
KHotkeysProxyModelPrivate::KHotkeysProxyModelPrivate( KHotkeysProxyModel *host )
: q(host)
{}
KHotkeysProxyModel::KHotkeysProxyModel( QObject *parent )
: QSortFilterProxyModel(parent)
,d( new KHotkeysProxyModelPrivate(this) )
{}
KHotkeysProxyModel::~KHotkeysProxyModel()
{
delete d; d=0;
}
bool KHotkeysProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
{
Q_UNUSED(source_row);
Q_UNUSED(source_parent);
return true;
}
// Convert index to ActionDataBase
KHotKeys::ActionDataBase *KHotkeysProxyModel::indexToActionDataBase( const QModelIndex &index ) const
{
return sourceModel()->indexToActionDataBase( mapToSource(index) );
}
// Convert index to ActionDataGroup
KHotKeys::ActionDataGroup *KHotkeysProxyModel::indexToActionDataGroup( const QModelIndex &index ) const
{
return sourceModel()->indexToActionDataGroup( mapToSource(index) );
}
// Return the source model
KHotkeysModel *KHotkeysProxyModel::sourceModel() const
{
return static_cast<KHotkeysModel*>( QSortFilterProxyModel::sourceModel() );
}
#include "moc_hotkeys_proxy_model.cpp"

View file

@ -1,81 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KHOTKEYSPROXYMODEL_H
#define KHOTKEYSPROXYMODEL_H
#include "libkhotkeysfwd.h"
#include <QtGui/QSortFilterProxyModel>
class KHotkeysProxyModelPrivate;
class KHotkeysModel;
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class KHotkeysProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
/**
* Default constructor
*/
KHotkeysProxyModel( QObject *parent );
/**
* Destructor
*/
virtual ~KHotkeysProxyModel();
/**
* Returns true if the item in column @a column should be included in
* the model.
*/
bool filterAcceptsRow( int source_column, const QModelIndex &source_parent ) const;
/**
* Get the KHotKeys::ActionDataBase behind the index.
*/
KHotKeys::ActionDataBase *indexToActionDataBase( const QModelIndex &index ) const;
/**
* Get the KHotKeys::ActionDataBase behind the index or 0.
*
* Getting 0 doesn't mean the index is invalid. It means you provided a
* action object.
*/
KHotKeys::ActionDataGroup *indexToActionDataGroup( const QModelIndex &index ) const;
/**
* Return the source model. Casted to the correct class.
*/
KHotkeysModel *sourceModel() const;
private:
//! Implementation details
KHotkeysProxyModelPrivate *d;
};
#endif /* #ifndef KHOTKEYSPROXYMODEL_HPP */

View file

@ -1,97 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "hotkeys_tree_view.h"
#include "hotkeys_context_menu.h"
#include "hotkeys_model.h"
#include "actions/actions.h"
#include "action_data/action_data_group.h"
#include "action_data/simple_action_data.h"
#include <KLocale>
#include <KDebug>
#include <QtGui/qevent.h>
HotkeysTreeView::HotkeysTreeView( QWidget *parent )
: QTreeView(parent)
{
setObjectName("khotkeys treeview");
setAllColumnsShowFocus(true);
setDragEnabled(true);
setAcceptDrops(true);
setDropIndicatorShown(true);
}
HotkeysTreeView::~HotkeysTreeView()
{}
void
HotkeysTreeView::contextMenuEvent( QContextMenuEvent *event )
{
QModelIndex index = indexAt(event->pos());
// KHotKeys::ActionDataBase *item = model()->indexToActionDataBase(index);
HotkeysTreeViewContextMenu menu( index, this );
menu.exec(event->globalPos());
}
void
HotkeysTreeView::modelReset()
{
resizeColumnToContents(KHotkeysModel::NameColumn);
}
KHotkeysModel *HotkeysTreeView::model()
{
return dynamic_cast<KHotkeysModel*>( QTreeView::model() );
}
void
HotkeysTreeView::setModel( QAbstractItemModel *model )
{
if (!dynamic_cast<KHotkeysModel*>( model ))
{
Q_ASSERT(dynamic_cast<KHotkeysModel*>( model ));
return;
}
QTreeView::setModel(model);
setAllColumnsShowFocus(true);
setAlternatingRowColors(true);
setSelectionBehavior( QAbstractItemView::SelectRows );
setSelectionMode( QAbstractItemView::SingleSelection );
connect(
model, SIGNAL(modelReset()),
this, SLOT(modelReset()));
resizeColumnToContents(KHotkeysModel::EnabledColumn);
resizeColumnToContents(KHotkeysModel::NameColumn);
}
#include "moc_hotkeys_tree_view.cpp"

View file

@ -1,72 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef HOTKEYS_TREE_VIEW_H
#define HOTKEYS_TREE_VIEW_H
#include "libkhotkeysfwd.h"
#include "triggers/triggers.h"
#include "actions/actions.h"
#include <QtGui/QMenu>
#include <QtGui/QTreeView>
#include <QSignalMapper>
class KHotkeysModel;
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class HotkeysTreeView : public QTreeView
{
Q_OBJECT
public:
/**
* Default constructor
*/
HotkeysTreeView( QWidget *parent = 0 );
/**
* Destructor
*/
virtual ~HotkeysTreeView();
/**
* The user requested a context menu
*/
void contextMenuEvent( QContextMenuEvent *event );
/**
* Set a new model
*/
void setModel( QAbstractItemModel *model );
KHotkeysModel *model();
private Q_SLOTS:
void modelReset();
};
#endif /* #ifndef HOTKEYS_TREE_VIEW_H */

View file

@ -1,75 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "hotkeys_widget_base.h"
#include "action_data/action_data_group.h"
#include <KDebug>
HotkeysWidgetBase::HotkeysWidgetBase( QWidget *parent )
: HotkeysWidgetIFace(parent)
{
ui.setupUi( this );
connect(
ui.comment, SIGNAL(textChanged()),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(ui.comment, "comment" );
}
HotkeysWidgetBase::~HotkeysWidgetBase()
{
}
void HotkeysWidgetBase::apply()
{
HotkeysWidgetIFace::apply();
emit changed(_data);
}
void HotkeysWidgetBase::extend(QWidget *w, const QString &label)
{
ui.tabs->addTab(w, label);
}
bool HotkeysWidgetBase::isChanged() const
{
return _data->comment() != ui.comment->toPlainText();
}
void HotkeysWidgetBase::doCopyFromObject()
{
ui.comment->setText( _data->comment() );
}
void HotkeysWidgetBase::doCopyToObject()
{
_data->set_comment( ui.comment->toPlainText() );
}
#include "moc_hotkeys_widget_base.cpp"

View file

@ -1,95 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef HOTKEYS_WIDGET_BASE_H
#define HOTKEYS_WIDGET_BASE_H
#include "ui_hotkeys_widget_base.h"
#include "hotkeys_widget_iface.h"
#include "libkhotkeysfwd.h"
class HotkeysWidgetBasePrivate;
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class HotkeysWidgetBase : public HotkeysWidgetIFace
{
Q_OBJECT
public:
/**
* Default constructor
*/
HotkeysWidgetBase( QWidget *parent = 0 );
/**
* Destructor
*/
virtual ~HotkeysWidgetBase();
virtual void apply();
/**
* The associated action.
*/
KHotKeys::ActionDataBase *data()
{
return _data;
}
const KHotKeys::ActionDataBase *data() const
{
return _data;
}
virtual bool isChanged() const;
using HotkeysWidgetIFace::changed;
Q_SIGNALS:
void changed(KHotKeys::ActionDataBase*);
protected:
#if 0
/**
* Append the QLayoutItems from QGridLayout \from to QGridLayout \to.
*/
void mergeLayouts( QGridLayout *to, QGridLayout *from );
#endif
protected:
void extend(QWidget*, const QString &);
virtual void doCopyFromObject();
virtual void doCopyToObject();
Ui::HotkeysWidgetBase ui;
KHotKeys::ActionDataBase *_data;
};
#endif /* #ifndef HOTKEYS_WIDGET_BASE_H */

View file

@ -1,46 +0,0 @@
<ui version="4.0" >
<class>HotkeysWidgetBase</class>
<widget class="QWidget" name="HotkeysWidgetBase" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>799</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="tabs" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="comment_tab" >
<attribute name="title" >
<string>Comment</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="KTextEdit" name="comment" />
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KTextEdit</class>
<extends>QTextEdit</extends>
<header>ktextedit.h</header>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -1,66 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "hotkeys_widget_iface.h"
HotkeysWidgetIFace::HotkeysWidgetIFace( QWidget *parent )
: QWidget(parent)
,_changedSignals(new QSignalMapper(this))
{
// Listen to the signal mapper, but not yet
connect(
_changedSignals, SIGNAL(mapped(QString)),
this, SLOT(slotChanged(QString)) );
_changedSignals->blockSignals(true);
}
HotkeysWidgetIFace::~HotkeysWidgetIFace()
{}
void HotkeysWidgetIFace::apply()
{
copyToObject();
}
void HotkeysWidgetIFace::copyFromObject()
{
_changedSignals->blockSignals(true);
doCopyFromObject();
_changedSignals->blockSignals(false);
}
void HotkeysWidgetIFace::copyToObject()
{
doCopyToObject();
}
void HotkeysWidgetIFace::slotChanged( const QString & /* what */ )
{
emit changed(isChanged());
}
#include "moc_hotkeys_widget_iface.cpp"

View file

@ -1,73 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef HOTKEYS_WIDGET_IFACE
#define HOTKEYS_WIDGET_IFACE
#include "libkhotkeysfwd.h"
#include <QtCore/QSignalMapper>
#include <QtGui/QWidget>
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class HotkeysWidgetIFace : public QWidget
{
Q_OBJECT
public:
/**
* Default constructor
*/
HotkeysWidgetIFace( QWidget *parent = 0 );
/**
* Destructor
*/
virtual ~HotkeysWidgetIFace();
virtual bool isChanged() const = 0;
void copyFromObject();
void copyToObject();
virtual void apply();
Q_SIGNALS:
void changed(bool) const;
public Q_SLOTS:
void slotChanged(const QString &what = "Nothing" );
protected:
QSignalMapper *_changedSignals;
virtual void doCopyFromObject() = 0;
virtual void doCopyToObject() = 0;
};
#endif /* #ifndef HOTKEYS_WIDGET_BASE_H */

View file

@ -1,438 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kcm_hotkeys.h"
#include "hotkeys_context_menu.h"
#include "ui_kcm_hotkeys.h"
#include "kcm_module_factory.h"
#include <typeinfo>
// ACTION_DATAS
#include "action_data/action_data_group.h"
// OUR ACTION WIDGETS
#include "action_group_widget.h"
#include "simple_action_data_widget.h"
#include "global_settings_widget.h"
// REST
#include "daemon/daemon.h"
#include "khotkeys_interface.h"
#include "hotkeys_model.h"
#include "hotkeys_proxy_model.h"
#include "hotkeys_tree_view.h"
#include "khotkeysglobal.h"
#include <QtDBus/QtDBus>
#include <KAboutData>
#include <KDebug>
#include <KLocale>
#include <KMessageBox>
#include <KPluginLoader>
#include <kdeversion.h>
#include <config-workspace.h>
class KCMHotkeysPrivate : public Ui::KCMHotkeysWidget
{
public:
KCMHotkeysPrivate( KCMHotkeys *host );
/** The model holding the shortcut settings. Beware! There is a proxy
* model between us and that model */
KHotkeysModel *model;
//! Our host
KCMHotkeys *q;
//! The currently shown dialog
HotkeysWidgetIFace *current;
//! The currently shown item
QModelIndex currentIndex;
/**
* Show the widget. If the current widget has changes allow
* cancelation ! of this action
*/
bool maybeShowWidget(const QModelIndex &next);
/**
* Applies the changes from the current item
*/
void applyCurrentItem();
/**
* A Hotkey was changed. Update the treeview.
*/
void _k_hotkeyChanged(KHotKeys::ActionDataBase*);
/**
* Activate the current item. The method is needed because of qt bug
*/
void _k_activateCurrentItem();
void load();
void save();
};
KCMHotkeys::KCMHotkeys( QWidget *parent, const QVariantList & /* args */ )
: KCModule( KCMModuleFactory::componentData(), parent )
,d( new KCMHotkeysPrivate(this) )
{
// Inform KCModule of the buttons we support
KCModule::setButtons(KCModule::Buttons(KCModule::Default | KCModule::Apply | KCModule::Help));
// Add the about data
KAboutData *about = new KAboutData(
"khotkeys",
0,
ki18n("KDE Hotkeys Configuration Module"),
KDE_VERSION_STRING,
KLocalizedString(),
KAboutData::License_GPL,
ki18n("Copyright 2008 (c) Michael Jansen")
);
about->addAuthor(
ki18n("Michael Jansen"),
ki18n("Maintainer"),
"kde@michael-jansen.biz" );
setAboutData(about);
// Tell KCModule we were changed.
connect(
d->action_group, SIGNAL(changed(bool)),
this, SIGNAL(changed(bool)) );
connect(
d->simple_action, SIGNAL(changed(bool)),
this, SIGNAL(changed(bool)) );
connect(
d->global_settings, SIGNAL(changed(bool)),
this, SIGNAL(changed(bool)) );
// Update TreeView if hotkeys was changed
connect(
d->simple_action, SIGNAL(changed(KHotKeys::ActionDataBase*)),
this, SLOT(_k_hotkeyChanged(KHotKeys::ActionDataBase*)));
connect(
d->action_group, SIGNAL(changed(KHotKeys::ActionDataBase*)),
this, SLOT(_k_hotkeyChanged(KHotKeys::ActionDataBase*)));
// Show the context menu
d->menu_button->setMenu(new HotkeysTreeViewContextMenu(d->tree_view));
// Switch to the global settings dialog
connect(d->settings_button, SIGNAL(clicked(bool)),
SLOT(showGlobalSettings()));
}
void KCMHotkeys::currentChanged( const QModelIndex &pCurrent, const QModelIndex &pPrevious )
{
// We're not interested in changes of columns. Just compare the rows
QModelIndex current =
pCurrent.isValid()
? pCurrent.sibling( pCurrent.row(), 0 )
: QModelIndex();
QModelIndex previous =
pPrevious.isValid()
? pPrevious.sibling( pPrevious.row(), 0 )
: QModelIndex();
// Now it's possible for previous and current to be the same
if (current==previous || current==d->currentIndex)
{
return;
}
// Current and previous differ. Ask user if there are unsaved changes
if ( !d->maybeShowWidget(current) )
{
// Bring focus back to the current item
d->tree_view->selectionModel()->setCurrentIndex(
d->currentIndex,
QItemSelectionModel::SelectCurrent);
// See http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=132516
QTimer::singleShot(0, this, SLOT(_k_activateCurrentItem()));
return;
}
if (!current.isValid())
{
return showGlobalSettings();
}
// Now go on and activate the new item;
KHotKeys::ActionDataBase *item = d->model->indexToActionDataBase( current );
QModelIndex typeOfIndex = d->model->index( current.row(), KHotkeysModel::TypeColumn, current.parent() );
switch (d->model->data( typeOfIndex ).toInt())
{
case KHotkeysModel::SimpleActionData:
{
KHotKeys::SimpleActionData *data = dynamic_cast<KHotKeys::SimpleActionData*>(item);
if (data)
{
d->simple_action->setActionData( data );
d->current = d->simple_action;
}
}
break;
case KHotkeysModel::ActionDataGroup:
{
KHotKeys::ActionDataGroup *group = dynamic_cast<KHotKeys::ActionDataGroup*>(item);
if (group)
{
d->action_group->setActionData( group );
d->current = d->action_group;
}
}
break;
default:
{
const std::type_info &ti = typeid(*item);
kDebug() << "##### Unknown ActionDataType " << ti.name();
}
} // switch
d->currentIndex = current;
d->stack->setCurrentWidget( d->current );
}
KCMHotkeys::~KCMHotkeys()
{
delete d; d=0;
}
void KCMHotkeys::defaults()
{
kWarning() << "not yet implemented!";
}
void KCMHotkeys::load()
{
showGlobalSettings();
d->load();
}
void KCMHotkeys::showGlobalSettings()
{
d->current = d->global_settings;
d->currentIndex = QModelIndex();
d->tree_view->setCurrentIndex(d->currentIndex);
d->global_settings->copyFromObject();
d->stack->setCurrentWidget( d->global_settings );
}
void KCMHotkeys::slotChanged()
{
emit changed(true);
}
void KCMHotkeys::slotReset()
{
showGlobalSettings();
}
void KCMHotkeys::save()
{
d->save();
emit changed(false);
}
// ==========================================================================
// KCMHotkeysPrivate
KCMHotkeysPrivate::KCMHotkeysPrivate( KCMHotkeys *host )
: Ui::KCMHotkeysWidget()
,model(NULL)
,q(host)
,current(NULL)
{
setupUi(q);
// Initialize the global part of the khotkeys lib ( handler ... )
KHotKeys::init_global_data(false, q);
}
void KCMHotkeysPrivate::load()
{
// Start khotkeys
KHotKeys::Daemon::start();
// disconnect the signals
if (tree_view->selectionModel())
{
QObject::disconnect(
tree_view->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
q, SLOT(currentChanged(QModelIndex,QModelIndex)) );
}
// Create a new model;
tree_view->setModel(new KHotkeysModel);
// Delete the old
delete model;
// Now use the old
model = tree_view->model();
model->load();
global_settings->setModel(model);
QObject::connect(
model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
q, SLOT(slotChanged()));
QObject::connect(
model, SIGNAL(rowsInserted(QModelIndex,int,int)),
q, SLOT(slotChanged()));
QObject::connect(
model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
q, SLOT(slotChanged()));
QObject::connect(
model, SIGNAL(modelAboutToBeReset()),
q, SLOT(slotReset()));
// reconnect the signals
QObject::connect(
tree_view->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
q, SLOT(currentChanged(QModelIndex,QModelIndex)) );
}
bool KCMHotkeysPrivate::maybeShowWidget(const QModelIndex &nextIndex)
{
kDebug();
// If the current widget is changed, ask user if switch is ok
if (current && (currentIndex != nextIndex) && current->isChanged())
{
int choice = KMessageBox::warningContinueCancel(
q,
i18n("The current action has unsaved changes. If you continue these changes will be lost."),
i18n("Save changes") );
if (choice != KMessageBox::Continue)
{
return false;
}
// Apply the changes from the current item
//applyCurrentItem();
//save();
}
return true;
}
void KCMHotkeysPrivate::save()
{
if (current)
applyCurrentItem();
// Write the settings
model->save();
if (!KHotKeys::Daemon::isRunning())
{
if (!KHotKeys::Daemon::start())
{
// On startup the demon does the updating stuff, therefore reload
// the actions.
model->load();
}
else
{
KMessageBox::error(
q,
"<qt>" + i18n("Unable to contact khotkeys. Your changes are saved, but they could not be activated.") + "</qt>" );
}
return;
}
// Inform kdedkhotkeys demon to reload settings
QDBusConnection bus = QDBusConnection::sessionBus();
QPointer<OrgKdeKhotkeysInterface> iface = new OrgKdeKhotkeysInterface(
"org.kde.kded",
"/modules/khotkeys",
bus,
q);
QDBusError err;
if(!iface->isValid())
{
err = iface->lastError();
if (err.isValid())
{
kError() << err.name() << ":" << err.message();
}
KMessageBox::error(
q,
"<qt>" + i18n("Unable to contact khotkeys. Your changes are saved, but they could not be activated.") + "</qt>" );
return;
}
// Reread the configuration. We have no possibility to check if it worked.
iface->reread_configuration();
}
void KCMHotkeysPrivate::applyCurrentItem()
{
Q_ASSERT( current );
// Only save when really changed
if (current->isChanged())
{
current->apply();
}
}
void KCMHotkeysPrivate::_k_hotkeyChanged(KHotKeys::ActionDataBase* hotkey)
{
model->emitChanged(hotkey);
}
void KCMHotkeysPrivate::_k_activateCurrentItem()
{
tree_view->selectionModel()->setCurrentIndex(
tree_view->selectionModel()->currentIndex(),
QItemSelectionModel::SelectCurrent);
}
#include "moc_kcm_hotkeys.cpp"

View file

@ -1,97 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KCMHOTKEYS_H
#define KCMHOTKEYS_H
#include <KCModule>
#include <QtCore/qabstractitemmodel.h>
class KCMHotkeysPrivate;
#include <QWidget>
namespace KHotKeys {
class ActionDataBase;
}
/**
* @brief KCMHotkeys KDE KCM Hotkeys Configuration Module
* @author Michael Jansen <kde@michael-jansen.biz>
* @date 2008-03-07
*/
class KCMHotkeys : public KCModule
{
Q_OBJECT
public:
/**
* Create the module.
*
* @param parent Parent widget
*/
KCMHotkeys( QWidget *parent, const QVariantList &arg );
/**
* Destroy the module
*/
virtual ~KCMHotkeys();
/**
* Set all settings back to defaults.
*/
void defaults();
/**
* Load all settings.
*/
void load();
/**
* Save the settings
*/
void save();
public Q_SLOTS:
void slotChanged();
void slotReset();
/**
* Call when the current item has changed
*/
void currentChanged( const QModelIndex &current, const QModelIndex &previous );
/**
* Show global settings dialog
*/
void showGlobalSettings();
private:
Q_PRIVATE_SLOT(d, void _k_hotkeyChanged(KHotKeys::ActionDataBase*))
Q_PRIVATE_SLOT(d, void _k_activateCurrentItem())
KCMHotkeysPrivate *d;
};
#endif /* #ifndef KCMHOTKEYS_HPP */

View file

@ -1,85 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KCMHotkeysWidget</class>
<widget class="QWidget" name="KCMHotkeysWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>631</width>
<height>435</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="HotkeysTreeView" name="tree_view"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="menu_button">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="settings_button">
<property name="text">
<string>Settings</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QStackedWidget" name="stack">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="GlobalSettingsWidget" name="global_settings"/>
<widget class="SimpleActionDataWidget" name="simple_action"/>
<widget class="ActionGroupWidget" name="action_group"/>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HotkeysTreeView</class>
<extends>QTreeView</extends>
<header>hotkeys_tree_view.h</header>
</customwidget>
<customwidget>
<class>ActionGroupWidget</class>
<extends>QWidget</extends>
<header>action_group_widget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>SimpleActionDataWidget</class>
<extends>QWidget</extends>
<header>simple_action_data_widget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GlobalSettingsWidget</class>
<extends>QWidget</extends>
<header>global_settings_widget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -1,35 +0,0 @@
/* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kcm_module_factory.h"
// local
#include "kcm_hotkeys.h"
// libkhotkeys
#include "daemon/daemon.h"
// KDE
#include <KDebug>
#include <KToolInvocation>
K_PLUGIN_FACTORY_DEFINITION(
KCMModuleFactory,
registerPlugin<KCMHotkeys>("khotkeys" /*plugin keyword, cf .desktop file*/);
)
K_EXPORT_PLUGIN(KCMModuleFactory("khotkeys" /*component data name & catalog name*/))

View file

@ -1,28 +0,0 @@
#ifndef KCM_MODULE_FACTORY_H
#define KCM_MODULE_FACTORY_H
/* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <KPluginFactory>
#include "kcm_hotkeys.h"
K_PLUGIN_FACTORY_DECLARATION(KCMModuleFactory)
#endif /* #ifndef KCM_MODULE_FACTORY_H */

View file

@ -1,187 +0,0 @@
[Desktop Entry]
Exec=kcmshell4 khotkeys
Icon=preferences-desktop-keyboard-khotkeys
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=kcm_hotkeys
X-KDE-PluginKeyword=khotkeys
X-KDE-System-Settings-Parent-Category=shortcuts-and-gestures
X-KDE-ParentApp=kcontrol
X-DocPath=kcontrol/khotkeys/index.html
Name=Custom Shortcuts
Name[ar]=اختصارات مخصصة
Name[ast]=Accesos rápidos personalizaos
Name[bg]=Потребителски бързи клавиши
Name[bn]=ি
Name[bs]=Posebne prečice
Name[ca]=Dreceres personalitzades
Name[ca@valencia]=Dreceres personalitzades
Name[cs]=Vlastní zkratky
Name[da]=Brugervalgte genveje
Name[de]=Eigene Kurzbefehle
Name[el]=Προσαρμοσμένες συντομεύσεις
Name[en_GB]=Custom Shortcuts
Name[es]=Accesos rápidos personalizados
Name[et]=Kohandatud kiirklahvid
Name[eu]=Lasterbide pertsonalizatuak
Name[fi]=Mukautetut pikatoiminnot
Name[fr]=Raccourcis personnalisés
Name[ga]=Aicearraí Saincheaptha
Name[gl]=Atallos personalizados
Name[he]=קיצורי דרך מותאמים אישית
Name[hr]=Prilagođeni prečaci
Name[hu]=Egyedi billentyűparancsok
Name[ia]=Vias breve adaptabile
Name[id]=Jalan Pintas Suai
Name[is]=Sérsniðnar flýtivísanir
Name[it]=Scorciatoie personalizzate
Name[ja]=
Name[kk]=Өзінің тіркесімдері
Name[km]=
Name[kn]= ( )
Name[ko]=
Name[lt]=Spartieji klavišai
Name[lv]=Pielāgoti īsceļi
Name[mr]=ि
Name[nb]=Egendefinerte snarveier
Name[nds]=Egen Tastkombinatschonen
Name[nl]=Aangepaste snelkoppelingen
Name[nn]=Tilpassa snarvegar
Name[pa]=
Name[pl]=Własne skróty
Name[pt]=Atalhos Personalizados
Name[pt_BR]=Atalhos personalizados
Name[ro]=Acceleratori personalizați
Name[ru]=Специальные действия
Name[si]=
Name[sk]=Vlastné skratky
Name[sl]=Bližnjice po meri
Name[sr]=Посебне пречице
Name[sr@ijekavian]=Посебне пречице
Name[sr@ijekavianlatin]=Posebne prečice
Name[sr@latin]=Posebne prečice
Name[sv]=Egna webbgenvägar
Name[tg]=Истинодҳои интихобӣ
Name[th]=
Name[tr]=Özel Kısayollar
Name[ug]=ئىختىيارى تېزلەتمە
Name[uk]=Нетипові скорочення
Name[vi]=Phím tt tu chnh
Name[wa]=Rascourtis da vosse
Name[x-test]=xxCustom Shortcutsxx
Name[zh_CN]=
Name[zh_TW]=
Comment=Configure Input Actions settings
Comment[ar]=اضبط إعدادات إجراءات الإدخال
Comment[ast]=Configuración de les preferencies d'aiciones d'entrada
Comment[bg]=Настройване на входящите действия
Comment[bs]=Podešavanje postavki radnji unosa
Comment[ca]=Configura l'arranjament de les accions d'entrada
Comment[ca@valencia]=Configura l'arranjament de les accions d'entrada
Comment[cs]=Nastavení vstupních činností
Comment[csb]=Kònfigùracëjô dzéjaniów weńdzeniô
Comment[da]=Indstilling af input-handlinger
Comment[de]=Eingabe-Aktionen einrichten
Comment[el]=Διαμόρφωση ενεργειών εισόδου
Comment[en_GB]=Configure Input Actions settings
Comment[eo]=Agordo de enigaj agoj
Comment[es]=Configuración de las preferencias de acciones de entrada
Comment[et]=Sisestustoimingute seadistamine
Comment[eu]=Konfiguratu sarrerako ekintzen ezarpenak
Comment[fi]=Syöttötoimintojen asetukset
Comment[fr]=Configurer les paramètres des actions d'entrée
Comment[fy]=Ynfier aksjes ynstelle
Comment[ga]=Cumraigh socruithe na nGníomhartha Ionchurtha
Comment[gl]=Configura as opcións de entrada
Comment[gu]= િ િ
Comment[he]=הגדרות פעולות קלט
Comment[hr]=Konfiguriranje postavki ulaznih akcija
Comment[hu]=A beviteli műveletek beállításai
Comment[ia]=Configura preferentias de actiones de insertar
Comment[id]=Atur pengaturan Aksi Masukan
Comment[is]=Stillingar inntaksaðgerða
Comment[it]=Configura le impostazioni delle azioni di immissione
Comment[ja]=
Comment[kk]=Енгізу әрекеттерінің параметрлерін баптау
Comment[km]=
Comment[kn]= ಿ ಿ
Comment[ko]=
Comment[lt]=Konfigūruoti įvedimo veiklų nustatymus
Comment[lv]=Konfigurēt ievades darbību iestatījumus
Comment[mk]=Конфигурирајте ги поставувањата за влезни дејства
Comment[ml]= ി
Comment[mr]= ि
Comment[nb]=Sett opp innstillinger for inndata-handlinger
Comment[nds]=Instellen för Ingaavakschonen fastleggen
Comment[nl]=Invoeractieinstellingen configureren
Comment[nn]=Set opp innstillingar for innhandlingar
Comment[pa]= ਿ
Comment[pl]=Ustawienia działań wejściowych
Comment[pt]=Configurar as opções das Acções de Entrada
Comment[pt_BR]=Configura as opções das ações de entrada
Comment[ro]=Configurează acțiunile de intrare
Comment[ru]=Настройка способов запуска действий
Comment[si]=
Comment[sk]=Nastavenie vstupných akcií
Comment[sl]=Nastavi vhodna dejanja
Comment[sr]=Подешавање поставки радњи уноса
Comment[sr@ijekavian]=Подешавање поставки радњи уноса
Comment[sr@ijekavianlatin]=Podešavanje postavki radnji unosa
Comment[sr@latin]=Podešavanje postavki radnji unosa
Comment[sv]=Anpassa inställningar av inmatningsåtgärder
Comment[tg]=Танзимоти сабад
Comment[th]=
Comment[tr]=Girdi Eylemleri ayarlarını yapılandır
Comment[ug]=كىرگۈزۈش مەشغۇلات تەڭشەك سەپلىمىسى
Comment[uk]=Налаштування параметрів дій з вводу
Comment[vi]=Cu hình các thiết lp cho Hành đng nhp
Comment[wa]=Apontyî les tchuzes des Faitindjes èn intrêye
Comment[x-test]=xxConfigure Input Actions settingsxx
Comment[zh_CN]=
Comment[zh_TW]=
Categories=Qt;KDE;X-KDE-settings-accessibility;
X-KDE-Keywords=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch
X-KDE-Keywords[bs]=globalni, prečice na tastaturi, učestale tipke, vreleTipke, kVreleTipke, ulazne akcije, kretnje miša, akcije, pokretanja, lansira
X-KDE-Keywords[ca]=global,dreceres de teclat,dreceres de teclat,hotkeys,KHotKeys,accions d'entrada,gestos del ratolí,accions,activadors,llança
X-KDE-Keywords[ca@valencia]=global,dreceres de teclat,dreceres de teclat,hotkeys,KHotKeys,accions d'entrada,gestos del ratolí,accions,activadors,llança
X-KDE-Keywords[da]=globale,tastaturgenveje,genvejstaster,hotkeys,KHotKeys,input-handlinger,musegestusser,handlinger,udløsere,kør
X-KDE-Keywords[de]=global,tastatur,tastenkürzel,kurzbefehle,hot keys,hotkeys,KHotKeys,eingaben,mausgesten,aktionen,auslöser,starten
X-KDE-Keywords[el]=καθολικές,συντομεύσεις πληκτρολογίου,πλήκτρα συντόμευσης,hotkeys,KHotKeys,ενέργειες δεδομένων εισόδου,νεύματα ποντικιού,ενέργειες,ενεργοποιήσεις,εκτελέσεις
X-KDE-Keywords[en_GB]=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch
X-KDE-Keywords[es]=global,accesos rápidos de teclado,atajos de teclado,teclas rápidas,KHotKeys,acciones de entrada,gestos del ratón,acciones,disparadores,lanzamiento
X-KDE-Keywords[et]=globaalne,klaviatuur,kiirklahvid,KHotKeys,sisestustoimingud,hiirežestid,toimingud,käivitajad,käivitamine
X-KDE-Keywords[eu]=orokorra,laster-tekla,sarrerako ekintzak,sagu bidezko keinuak, ekintzak, abiarazle, abiarazi
X-KDE-Keywords[fi]=globaali,työpöydänlaajuinen,pikanäppäimet,näppäimistön pikavalinnat,näppäinyhdistelmät,oikotiet,KHotKeys,syöttötoiminnot,hiirieleet,toiminnot,laukaisimet,käynnistys,pikatoiminnot
X-KDE-Keywords[fr]=global, raccourcis clavier, touches de raccourcis, raccourcis, KHotKeys, actions de saisie, mouvement de la souris, actions, déclencheurs, lancer
X-KDE-Keywords[gl]=global,atallos de teclado,atallo,accións de entrada,acenos co rato,accións,disparadores,iniciar,lanzar
X-KDE-Keywords[hu]=globális,gyorsbillentyűk,gyorsbillentyűk,gyorsbillentyűk,KHotKeys,beviteli műveletek,egérmozdulatok,műveletek,triggerek,indítás
X-KDE-Keywords[ia]=global,vias breve de claviero, claves calide,claves calide,KHotKeys, actiones de ingresso,gestos de mus,actiones,discatenator,lancear
X-KDE-Keywords[it]=globale,scorciatoie di tastiera,scorciatoie,KHotKeys,azioni di immissione,gesti del mouse,azioni,attivazione,avvio
X-KDE-Keywords[kk]=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch
X-KDE-Keywords[km]=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch
X-KDE-Keywords[ko]=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch,,, , ,, ,,,
X-KDE-Keywords[mr]=, , , , , ि, , ि, ,
X-KDE-Keywords[nb]=global,tastesnarveier,hurtigtaster,KHotKeys,inndata-handlinger,musebevegelser,handlinger,utløsere,oppstart
X-KDE-Keywords[nds]=Globaal,Tastkombinatschonen,KHotKeys,Ingaavakschonen,Muustekens;Akschonen,Utlösers,starten
X-KDE-Keywords[nl]=globaal,toetsenbordsneltoets,hot-keys,hotkeys,KHotKeys,invoeracties,muisbeweging,acties,triggers,opstarten
X-KDE-Keywords[pl]=globalne,skróty klawiaturowe,gorące klawisze,KHotKeys,działania wejścia, gesty myszy,działania,wyzwalacze,uruchomienie
X-KDE-Keywords[pt]=global,atalhos de teclado,KHotKeys,acções de entrada,gestos do rato,acções,eventos,lançamento
X-KDE-Keywords[pt_BR]=global,atalhos de teclado,KHotKeys,ações de entrada,gestos do mouse,ações,eventos,lançamento,execução
X-KDE-Keywords[ru]=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch,глобальные,комбинации клавиш,горячие клавиши,действия,запуск действий,росчерки мышью,запуск
X-KDE-Keywords[sk]=globálne,globálne skratky,horúce klávesy,hotkeys,KHotKeys,vstupné akcie,gestá myši,akcie,spúšťače,spustenie
X-KDE-Keywords[sl]=splošno,tipkovne bližnjice,bližnjice,hitre tipke,khotkeys,vhodna dejanja,vnosna dejanja,kretnje z miško,dejanja,sprožilci,zagon
X-KDE-Keywords[sr]=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch,глобалне,пречице са тастатуре,Кпречице,радње улаза,гестови мишем,радње,окидачи,покретање
X-KDE-Keywords[sr@ijekavian]=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch,глобалне,пречице са тастатуре,Кпречице,радње улаза,гестови мишем,радње,окидачи,покретање
X-KDE-Keywords[sr@ijekavianlatin]=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch,globalne,prečice sa tastature,Kprečice,radnje ulaza,gestovi mišem,radnje,okidači,pokretanje
X-KDE-Keywords[sr@latin]=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch,globalne,prečice sa tastature,Kprečice,radnje ulaza,gestovi mišem,radnje,okidači,pokretanje
X-KDE-Keywords[sv]=global,tangentbordsgenvägar,KHotKeys,indataåtgärder,musgester,åtgärder,avtryckare,start
X-KDE-Keywords[tr]=genel,sistem geneli,klavye kısayolları,KHotKeys,girdi eylemleri,fare hareketleri,eylemler,tetikleyiciler,çalıştır,başlat
X-KDE-Keywords[uk]=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch,загальні,глобальні,клавіатура,клавіатурні скорочення,введення,жести,жести мишею,дії,вмикання,запуск
X-KDE-Keywords[x-test]=xxglobal,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launchxx
X-KDE-Keywords[zh_CN]=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch,,,,,,,,
X-KDE-Keywords[zh_TW]=global,keyboard shortcuts,hot keys,hotkeys,KHotKeys,input actions,mouse gestures,actions,triggers,launch

View file

@ -1,162 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "simple_action_data_widget.h"
#include "actions/command_url_action_widget.h"
#include "actions/dbus_action_widget.h"
#include "actions/menuentry_action_widget.h"
#include "actions/keyboard_input_action_widget.h"
#include "triggers/shortcut_trigger_widget.h"
#include "triggers/window_trigger_widget.h"
#include <KDebug>
SimpleActionDataWidget::SimpleActionDataWidget( QWidget *parent )
: HotkeysWidgetBase( parent )
,currentTrigger(NULL)
,currentAction(NULL)
{}
SimpleActionDataWidget::~SimpleActionDataWidget()
{
delete currentTrigger;
delete currentAction;
}
bool SimpleActionDataWidget::isChanged() const
{
return ( currentTrigger && currentTrigger->isChanged() )
|| ( currentAction && currentAction->isChanged() )
|| Base::isChanged();
}
void SimpleActionDataWidget::doCopyFromObject()
{
Base::doCopyFromObject();
if (currentTrigger)
{
currentTrigger->copyFromObject();
}
if (currentAction)
{
currentAction->copyFromObject();
}
}
void SimpleActionDataWidget::doCopyToObject()
{
Base::doCopyToObject();
if (currentTrigger)
{
currentTrigger->copyToObject();
}
if (currentAction)
{
currentAction->copyToObject();
}
}
void SimpleActionDataWidget::setActionData( KHotKeys::SimpleActionData* pData )
{
_data = pData;
// Now go and work on the trigger
delete currentTrigger; currentTrigger = NULL;
if ( KHotKeys::Trigger *trg = data()->trigger() )
{
switch ( trg->type() )
{
case KHotKeys::Trigger::ShortcutTriggerType:
kDebug() << "1";
currentTrigger = new ShortcutTriggerWidget( static_cast<KHotKeys::ShortcutTrigger*>(trg) );
break;
case KHotKeys::Trigger::WindowTriggerType:
kDebug() << "2";
currentTrigger = new WindowTriggerWidget( static_cast<KHotKeys::WindowTrigger*>(trg) );
break;
default:
kDebug() << "Unknown trigger type";
};
}
if (currentTrigger )
{
connect(
currentTrigger, SIGNAL(changed(bool)),
this, SLOT(slotChanged()));
extend(currentTrigger, i18n("Trigger"));
}
// Now go and work on the action
delete currentAction; currentAction = NULL;
if ( KHotKeys::Action *act = data()->action() )
{
switch ( act->type() )
{
case KHotKeys::Action::MenuEntryActionType:
currentAction = new MenuentryActionWidget( static_cast<KHotKeys::MenuEntryAction*>(act) );
break;
case KHotKeys::Action::DBusActionType:
currentAction = new DbusActionWidget( static_cast<KHotKeys::DBusAction*>(act) );
break;
case KHotKeys::Action::CommandUrlActionType:
currentAction = new CommandUrlActionWidget( static_cast<KHotKeys::CommandUrlAction*>(act) );
break;
case KHotKeys::Action::KeyboardInputActionType:
currentAction = new KeyboardInputActionWidget( static_cast<KHotKeys::KeyboardInputAction*>(act) );
break;
default:
kDebug() << "Unknown action type";
};
}
if (currentAction )
{
connect(
currentAction, SIGNAL(changed(bool)),
this, SLOT(slotChanged()));
extend(currentAction, i18n("Action"));
}
Base::copyFromObject();
}
#include "moc_simple_action_data_widget.cpp"

View file

@ -1,82 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef SIMPLE_ACTION_DATA_WIDGET_H
#define SIMPLE_ACTION_DATA_WIDGET_H
#include "hotkeys_widget_base.h"
#include "action_data/simple_action_data.h"
#include <QtGui/QWidget>
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class SimpleActionDataWidget : public HotkeysWidgetBase
{
Q_OBJECT
typedef HotkeysWidgetBase Base;
public:
/**
* Default constructor
*/
SimpleActionDataWidget( QWidget *parent = 0 );
/**
* Edit \a action.
*/
void setActionData( KHotKeys::SimpleActionData *action );
KHotKeys::SimpleActionData *data()
{
return static_cast<KHotKeys::SimpleActionData*>( _data );
}
const KHotKeys::SimpleActionData *data() const
{
return static_cast<const KHotKeys::SimpleActionData*>( _data );
}
/**
* Destructor
*/
virtual ~SimpleActionDataWidget();
virtual bool isChanged() const;
protected:
virtual void doCopyFromObject();
virtual void doCopyToObject();
private:
HotkeysWidgetIFace *currentTrigger;
HotkeysWidgetIFace *currentAction;
};
#endif /* #ifndef SIMPLE_ACTION_DATA_WIDGET_H */

View file

@ -1,100 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "shortcut_trigger_widget.h"
#include "action_data/action_data.h"
#include "triggers/triggers.h"
#include <QtGui/QKeySequence>
#include <KDebug>
ShortcutTriggerWidget::ShortcutTriggerWidget( KHotKeys::ShortcutTrigger *trigger, QWidget *parent )
: TriggerWidgetBase(trigger, parent)
{
shortcut_trigger_ui.setupUi(this);
shortcut_trigger_ui.shortcut->setCheckForConflictsAgainst(
// Don't know why that is necessary but it doesn't compile
// without.
KKeySequenceWidget::ShortcutTypes(
KKeySequenceWidget::GlobalShortcuts
| KKeySequenceWidget::StandardShortcuts ));
connect(
shortcut_trigger_ui.shortcut, SIGNAL(keySequenceChanged(QKeySequence)),
_changedSignals, SLOT(map()) );
_changedSignals->setMapping(shortcut_trigger_ui.shortcut, "shortcut" );
// If the global shortcuts is changed outside of the dialog just copy the
// new key sequencence. It doesn't matter if the user changed the sequence
// here.
connect(
trigger, SIGNAL(globalShortcutChanged(QKeySequence)),
this, SLOT(_k_globalShortcutChanged(QKeySequence)) );
}
ShortcutTriggerWidget::~ShortcutTriggerWidget()
{
}
KHotKeys::ShortcutTrigger *ShortcutTriggerWidget::trigger()
{
return static_cast<KHotKeys::ShortcutTrigger*>(_trigger);
}
const KHotKeys::ShortcutTrigger *ShortcutTriggerWidget::trigger() const
{
return static_cast<const KHotKeys::ShortcutTrigger*>(_trigger);
}
void ShortcutTriggerWidget::doCopyFromObject()
{
Q_ASSERT(trigger());
shortcut_trigger_ui.shortcut->setKeySequence( trigger()->shortcut().primary() );
}
void ShortcutTriggerWidget::doCopyToObject()
{
Q_ASSERT(trigger());
trigger()->set_key_sequence( shortcut_trigger_ui.shortcut->keySequence());
}
bool ShortcutTriggerWidget::isChanged() const
{
Q_ASSERT(trigger());
return trigger()->shortcut().primary() != shortcut_trigger_ui.shortcut->keySequence();
}
void ShortcutTriggerWidget::_k_globalShortcutChanged(const QKeySequence &seq)
{
shortcut_trigger_ui.shortcut->setKeySequence(seq);
}
#include "moc_shortcut_trigger_widget.cpp"

View file

@ -1,70 +0,0 @@
#ifndef SHORTCUT_TRIGGER_WIDGET_H
#define SHORTCUT_TRIGGER_WIDGET_H
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "trigger_widget_base.h"
#include "ui_shortcut_trigger_widget.h"
#include <QKeySequence>
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class ShortcutTriggerWidget : public TriggerWidgetBase
{
Q_OBJECT
typedef TriggerWidgetBase Base;
public:
/**
* Default constructor
*/
ShortcutTriggerWidget(KHotKeys::ShortcutTrigger *trigger, QWidget *parent = NULL);
/**
* Destructor
*/
virtual ~ShortcutTriggerWidget();
KHotKeys::ShortcutTrigger *trigger();
const KHotKeys::ShortcutTrigger *trigger() const;
virtual bool isChanged() const;
private Q_SLOTS:
//! Invoked if the global shortcut is changed for the corresponding
// shortcut trigger
void _k_globalShortcutChanged(const QKeySequence &);
private:
virtual void doCopyFromObject();
virtual void doCopyToObject();
Ui::ShortcutTriggerWidget shortcut_trigger_ui;
};
#endif /* #ifndef SHORTCUT_TRIGGER_WIDGET_H */

View file

@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ShortcutTriggerWidget</class>
<widget class="QWidget" name="ShortcutTriggerWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>302</width>
<height>81</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="shortcut_label">
<property name="text">
<string>&amp;Shortcut:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>shortcut</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KKeySequenceWidget" name="shortcut">
<property name="multiKeyShortcutsAllowed">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<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 row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>6</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KKeySequenceWidget</class>
<extends>QWidget</extends>
<header>kkeysequencewidget.h</header>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -1,31 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "trigger_widget_base.h"
TriggerWidgetBase::TriggerWidgetBase( KHotKeys::Trigger *trigger, QWidget *parent )
: HotkeysWidgetIFace(parent)
,_trigger(trigger)
{}
TriggerWidgetBase::~TriggerWidgetBase()
{}
#include "moc_trigger_widget_base.cpp"

View file

@ -1,57 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef TRIGGER_WIDGET_BASE_H
#define TRIGGER_WIDGET_BASE_H
#include "hotkeys_widget_iface.h"
#include "libkhotkeysfwd.h"
#include "triggers/triggers.h"
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class TriggerWidgetBase : public HotkeysWidgetIFace
{
Q_OBJECT
public:
/**
* Default constructor
*/
/**
* Destructor
*/
virtual ~TriggerWidgetBase();
virtual KHotKeys::Trigger * trigger() { return _trigger; }
virtual const KHotKeys::Trigger * trigger() const { return _trigger; }
protected:
TriggerWidgetBase( KHotKeys::Trigger *trigger, QWidget *parent = 0 );
KHotKeys::Trigger *_trigger;
};
#endif /* #ifndef TRIGGER_WIDGET_BASE_H */

View file

@ -1,141 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "window_trigger_widget.h"
#include "helper_widgets/window_definition_list_widget.h"
#include "windows_helper/window_selection_list.h"
#include "windows_helper/window_selection_rules.h"
#include "windows_handler.h"
#include "kdebug.h"
WindowTriggerWidget::WindowTriggerWidget( KHotKeys::WindowTrigger *trigger, QWidget *parent )
: TriggerWidgetBase(trigger, parent)
,_windowdef_widget(NULL)
{
window_trigger_ui.setupUi(this);
if (trigger->windows()->count() == 0)
{
trigger->windows()->insert(0, new KHotKeys::Windowdef_simple("", ""));
}
QHBoxLayout *layout = new QHBoxLayout();
_windowdef_widget = new WindowDefinitionListWidget(trigger->windows(), window_trigger_ui.window_group);
layout->addWidget(_windowdef_widget);
window_trigger_ui.window_group->setLayout(layout);
connect(window_trigger_ui.window_appears, SIGNAL(toggled(bool)),
_changedSignals, SLOT(map()));
_changedSignals->setMapping(window_trigger_ui.window_appears, "appears");
connect(window_trigger_ui.window_disappears, SIGNAL(toggled(bool)),
_changedSignals, SLOT(map()));
_changedSignals->setMapping(window_trigger_ui.window_disappears, "disappears");
connect(window_trigger_ui.window_gets_focus, SIGNAL(toggled(bool)),
_changedSignals, SLOT(map()));
_changedSignals->setMapping(window_trigger_ui.window_gets_focus, "gets focus");
connect(window_trigger_ui.window_lost_focus, SIGNAL(toggled(bool)),
_changedSignals, SLOT(map()));
_changedSignals->setMapping(window_trigger_ui.window_lost_focus, "lost focus");
connect(_windowdef_widget, SIGNAL(changed(bool)),
SLOT(slotWindowSelectionChanged(bool)));
}
WindowTriggerWidget::~WindowTriggerWidget()
{
}
KHotKeys::WindowTrigger *WindowTriggerWidget::trigger()
{
return static_cast<KHotKeys::WindowTrigger*>(_trigger);
}
const KHotKeys::WindowTrigger *WindowTriggerWidget::trigger() const
{
return static_cast<const KHotKeys::WindowTrigger*>(_trigger);
}
void WindowTriggerWidget::doCopyFromObject()
{
Q_ASSERT(trigger());
_windowdef_widget->copyFromObject();
window_trigger_ui.window_appears->setChecked(
trigger()->triggers_on(KHotKeys::WindowTrigger::WINDOW_APPEARS));
window_trigger_ui.window_disappears->setChecked(
trigger()->triggers_on(KHotKeys::WindowTrigger::WINDOW_DISAPPEARS));
window_trigger_ui.window_gets_focus->setChecked(
trigger()->triggers_on(KHotKeys::WindowTrigger::WINDOW_ACTIVATES));
window_trigger_ui.window_lost_focus->setChecked(
trigger()->triggers_on(KHotKeys::WindowTrigger::WINDOW_DEACTIVATES));
}
void WindowTriggerWidget::doCopyToObject()
{
Q_ASSERT(trigger());
_windowdef_widget->copyToObject();
KHotKeys::WindowTrigger::WindowEvents events;
if (window_trigger_ui.window_appears->isChecked())
events |= KHotKeys::WindowTrigger::WINDOW_APPEARS;
if (window_trigger_ui.window_disappears->isChecked())
events |= KHotKeys::WindowTrigger::WINDOW_DISAPPEARS;
if (window_trigger_ui.window_gets_focus->isChecked())
events |= KHotKeys::WindowTrigger::WINDOW_ACTIVATES;
if (window_trigger_ui.window_lost_focus->isChecked())
events |= KHotKeys::WindowTrigger::WINDOW_DEACTIVATES;
trigger()->setOnWindowEvents(events);
}
bool WindowTriggerWidget::isChanged() const
{
Q_ASSERT(trigger());
if( window_trigger_ui.window_appears->isChecked()
!= trigger()->triggers_on(KHotKeys::WindowTrigger::WINDOW_APPEARS)
|| window_trigger_ui.window_disappears->isChecked()
!= trigger()->triggers_on(KHotKeys::WindowTrigger::WINDOW_DISAPPEARS)
|| window_trigger_ui.window_gets_focus->isChecked()
!= trigger()->triggers_on(KHotKeys::WindowTrigger::WINDOW_ACTIVATES)
|| window_trigger_ui.window_lost_focus->isChecked()
!= trigger()->triggers_on(KHotKeys::WindowTrigger::WINDOW_DEACTIVATES))
return true;
return _windowdef_widget->isChanged();
}
void WindowTriggerWidget::slotWindowSelectionChanged(bool isChanged) const
{
emit changed(isChanged);
}
#include "moc_window_trigger_widget.cpp"

View file

@ -1,72 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef WINDOW_TRIGGER_WIDGET_H
#define WINDOW_TRIGGER_WIDGET_H
#include "trigger_widget_base.h"
#include "ui_window_trigger_widget.h"
#include <QKeySequence>
class WindowDefinitionListWidget;
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class WindowTriggerWidget : public TriggerWidgetBase
{
Q_OBJECT
typedef TriggerWidgetBase Base;
public:
/**
* Default constructor
*/
WindowTriggerWidget( KHotKeys::WindowTrigger *trigger, QWidget *parent = 0 );
/**
* Destructor
*/
virtual ~WindowTriggerWidget();
KHotKeys::WindowTrigger *trigger();
const KHotKeys::WindowTrigger *trigger() const;
virtual bool isChanged() const;
private Q_SLOTS:
void slotWindowSelectionChanged(bool) const;
private:
virtual void doCopyFromObject();
virtual void doCopyToObject();
Ui::WindowTriggerWidget window_trigger_ui;
WindowDefinitionListWidget *_windowdef_widget;
};
#endif /* #ifndef WINDOW_TRIGGER_WIDGET_H */

View file

@ -1,60 +0,0 @@
<ui version="4.0" >
<class>WindowTriggerWidget</class>
<widget class="QWidget" name="WindowTriggerWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QGroupBox" name="when_group" >
<property name="title" >
<string>Trigger When</string>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QRadioButton" name="window_appears" >
<property name="text" >
<string>Window appears</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QRadioButton" name="window_disappears" >
<property name="text" >
<string>Window disappears</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QRadioButton" name="window_gets_focus" >
<property name="text" >
<string>Window gets focus</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QRadioButton" name="window_lost_focus" >
<property name="text" >
<string>Window loses focus</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="window_group" >
<property name="title" >
<string>Window</string>
</property>
</widget>
</item>
</layout>
</widget>
<connections/>
</ui>

View file

@ -1,82 +0,0 @@
# KHotKey convenience library. Contains
# - Actions
# - Trigger
# - Conditions
# - Some gui stuff
set(khotkeysprivate_SRCS
# ACTIONS
actions/action.cpp
actions/action_list.cpp
actions/activate_window_action.cpp
actions/command_url_action.cpp
actions/dbus_action.cpp
actions/keyboard_input_action.cpp
actions/menuentry_action.cpp
# ACTION DATA
action_data/action_data.cpp
action_data/action_data_base.cpp
action_data/action_data_group.cpp
action_data/generic_action_data.cpp
action_data/menuentry_shortcut_action_data.cpp
action_data/simple_action_data.cpp
action_data/action_data_visitor.cpp
# CONDITIONS
conditions/active_window_condition.cpp
conditions/and_condition.cpp
conditions/condition.cpp
conditions/conditions_list_base.cpp
conditions/conditions_list.cpp
conditions/existing_window_condition.cpp
conditions/not_condition.cpp
conditions/or_condition.cpp
conditions/conditions_visitor.cpp
# TRIGGERS
triggers/shortcut_trigger.cpp
triggers/trigger.cpp
triggers/trigger_list.cpp
triggers/triggers.cpp
triggers/window_trigger.cpp
# WINDOWS_HELPER
windows_helper/window_selection_rules.cpp
windows_helper/window_selection_list.cpp
windows_helper/window_selection_interface.cpp
# DAEMON
daemon/daemon.h
daemon/daemon.cpp
# OTHER
khotkeysglobal.cpp
settings.cpp
settings_reader_v2.cpp
settings_writer.cpp
shortcuts_handler.cpp
windows_handler.cpp
)
add_library(khotkeysprivate SHARED ${khotkeysprivate_SRCS})
target_link_libraries(khotkeysprivate
KDE4::kio
${X11_LIBRARIES}
kworkspace
)
if(X11_XTest_FOUND)
target_link_libraries(khotkeysprivate ${X11_XTest_LIB})
endif(X11_XTest_FOUND)
set_target_properties(khotkeysprivate PROPERTIES
VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_SOVERSION}
)
install(
TARGETS khotkeysprivate
DESTINATION ${KDE4_LIB_INSTALL_DIR}
LIBRARY NAMELINK_SKIP
)

View file

@ -1,208 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#include "action_data/action_data.h"
#include "action_data/action_data_visitor.h"
#include "actions/actions.h"
#include "triggers/triggers.h"
#include <kconfiggroup.h>
#include <kdebug.h>
namespace KHotKeys
{
ActionData::ActionData(
ActionDataGroup* parent_P,
const QString& name_P,
const QString& comment_P,
Trigger_list* triggers_P,
Condition_list* conditions_P,
ActionList* actions_P)
: ActionDataBase( parent_P, name_P, comment_P, conditions_P),
_triggers( triggers_P ),
_actions( actions_P )
{
if (!_triggers)
_triggers = new Trigger_list;
if (!_actions)
_actions = new ActionList;
}
void ActionData::accept(ActionDataConstVisitor *visitor) const
{
visitor->visitActionData(this);
}
ActionData::~ActionData()
{
delete _triggers; _triggers = NULL;
delete _actions; _actions = NULL;
}
void ActionData::accept(ActionDataVisitor *visitor)
{
visitor->visitActionData(this);
}
void ActionData::doDisable()
{
triggers()->disable();
update_triggers();
}
void ActionData::doEnable()
{
triggers()->enable();
update_triggers();
}
Trigger_list* ActionData::triggers()
{
return _triggers;
}
const Trigger_list* ActionData::triggers() const
{
return _triggers;
}
void ActionData::aboutToBeErased()
{
_triggers->aboutToBeErased();
_actions->aboutToBeErased();
}
const ActionList* ActionData::actions() const
{
return _actions;
}
ActionList* ActionData::actions()
{
return _actions;
}
void ActionData::execute()
{
for( ActionList::Iterator it = _actions->begin();
it != _actions->end();
++it )
(*it)->execute();
}
void ActionData::add_trigger( Trigger* trigger_P )
{
_triggers->append( trigger_P );
}
void ActionData::add_triggers( Trigger_list* triggers_P )
{
while (!triggers_P->isEmpty())
{
_triggers->append( triggers_P->takeFirst() );
}
Q_ASSERT( triggers_P->isEmpty());
delete triggers_P;
}
void ActionData::set_triggers( Trigger_list* triggers_P )
{
if (_triggers) delete _triggers;
_triggers = triggers_P;
}
void ActionData::add_action(Action* action, Action* after)
{
if (after)
{
int index = _actions->indexOf(after);
_actions->insert(
index != -1
? index +1
: _actions->count(),
action);
}
else
{
_actions->append(action);
}
}
void ActionData::add_actions( ActionList* actions_P, Action* after_P )
{
int index = 0;
for( ActionList::Iterator it = _actions->begin();
it != _actions->end();
++it )
{
++index;
if( *it == after_P )
break;
}
while (!actions_P->empty())
{
// Insert the actions to _actions after removing them from actions_P
// to prevent their deletion upon delete actions_P below.
_actions->insert( ++index, actions_P->takeFirst() );
}
Q_ASSERT( actions_P->isEmpty());
delete actions_P;
}
void ActionData::set_actions( ActionList* actions_P )
{
if (_actions) delete _actions;
_actions = actions_P;
}
void ActionData::update_triggers()
{
if (!_triggers) return;
bool activate = false;
// Activate the triggers if the actions is enabled and the conditions
// match.
if (isEnabled() && conditions_match())
{
activate = true;
}
for( Trigger_list::Iterator it = _triggers->begin();
it != _triggers->end();
++it )
{
(*it)->activate(activate);
}
}
} // namespace KHotKeys

View file

@ -1,92 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#ifndef ACTION_DATA_H
#define ACTION_DATA_H
#include "action_data_base.h"
namespace KHotKeys {
class Action;
class ActionDataGroup;
class ActionList;
class Trigger_list;
class Trigger;
// TODO : code documentation
class KDE_EXPORT ActionData
: public ActionDataBase
{
typedef ActionDataBase base;
public:
ActionData(
ActionDataGroup* parent_P,
const QString& name_P,
const QString& comment_P,
Trigger_list* triggers_P,
Condition_list* conditions_P,
ActionList* actions_P);
virtual ~ActionData();
/**
* Visitor pattern
* @reimp
*/
virtual void accept(ActionDataVisitor *visitor);
virtual void accept(ActionDataConstVisitor *visitor) const;
virtual void update_triggers();
virtual void execute();
/**
* @reimp
*/
void aboutToBeErased();
const Trigger_list* triggers() const;
Trigger_list* triggers();
const ActionList* actions() const;
ActionList* actions();
virtual void add_trigger( Trigger* trigger_P );
virtual void add_triggers(
Trigger_list* triggers_P ); // Trigger_list instance will be deleted
virtual void set_triggers( Trigger_list* triggers_P );
virtual void add_action( Action* action_P, Action* after_P = 0 );
virtual void add_actions( ActionList* actions_P,
Action* after_P = 0 ); // ActionList will be deleted
virtual void set_actions( ActionList* actions_P );
private:
Trigger_list* _triggers;
ActionList* _actions;
virtual void doEnable();
virtual void doDisable();
};
} // namespace KHotKeys
#endif

View file

@ -1,199 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#include "action_data_base.h"
#include "action_data/action_data_visitor.h"
#include "action_data/action_data_group.h"
#include "conditions/conditions_list.h"
#include <kconfiggroup.h>
#include <kdebug.h>
namespace KHotKeys
{
ActionDataBase::ActionDataBase(
ActionDataGroup* parent_P
,const QString& name_P
,const QString& comment_P
,Condition_list* conditions_P)
: _parent(parent_P)
,_conditions(conditions_P)
,_name(name_P)
,_comment(comment_P)
,_enabled(false)
,_importId()
,_allowMerging(false)
{
if (parent()) parent()->add_child( this );
if (!_conditions)
{
_conditions = new Condition_list(QString(), this);
}
else
{
_conditions->set_data( this );
}
}
ActionDataBase::~ActionDataBase()
{
if( parent())
parent()->remove_child( this );
delete _conditions;
}
void ActionDataBase::accept(ActionDataVisitor *visitor)
{
visitor->visitActionDataBase(this);
}
void ActionDataBase::accept(ActionDataConstVisitor *visitor) const
{
visitor->visitActionDataBase(this);
}
bool ActionDataBase::cfg_is_enabled(const KConfigGroup& cfg_P )
{
return cfg_P.readEntry("Enabled", false);
}
bool ActionDataBase::allowMerging() const
{
return _allowMerging;
}
QString ActionDataBase::comment() const
{
return _comment;
}
const Condition_list* ActionDataBase::conditions() const
{
return _conditions;
}
Condition_list* ActionDataBase::conditions()
{
return _conditions;
}
bool ActionDataBase::conditions_match() const
{
return ( conditions() ? conditions()->match() : true )
&& ( parent() ? parent()->conditions_match() : true );
}
bool ActionDataBase::isEnabled(IgnoreParent ip ) const
{
if( ip == Ignore )
return _enabled;
else
return _enabled && ( parent() == 0 || parent()->isEnabled());
}
QString ActionDataBase::name() const
{
return _name;
}
ActionDataGroup* ActionDataBase::parent() const
{
return _parent;
}
void ActionDataBase::setAllowMerging(bool allowMerging)
{
_allowMerging = allowMerging;
}
void ActionDataBase::set_comment( const QString &comment )
{
_comment = comment;
}
void ActionDataBase::disable()
{
if (!_enabled)
return;
_enabled = false;
doDisable();
}
void ActionDataBase::enable()
{
if (_enabled)
return;
_enabled = true;
// Enable only if the parent is enabled too
if (isEnabled())
// FIXME: let doEnable decide if it makes sense to enable (No trigger
// .... )
doEnable();
}
QString
ActionDataBase::importId() const
{
return _importId;
}
void ActionDataBase::set_name( const QString& name_P )
{
_name = name_P;
}
void ActionDataBase::set_conditions(Condition_list* conditions)
{
if (_conditions)
{
delete _conditions;
}
_conditions = conditions;
}
void
ActionDataBase::setImportId(const QString &id)
{
_importId = id;
}
} // namespace KHotKeys
#include "moc_action_data_base.cpp"

View file

@ -1,191 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#ifndef ACTION_DATA_BASE_H
#define ACTION_DATA_BASE_H
#include "kdemacros.h"
#include <QtCore/QObject>
#include <QtCore/QString>
class KConfigGroup;
namespace KHotKeys {
class ActionDataGroup;
class ActionDataVisitor;
class ActionDataConstVisitor;
class Condition_list;
/**
* Base class for all actions.
*/
class KDE_EXPORT ActionDataBase : public QObject
{
Q_OBJECT
Q_DISABLE_COPY( ActionDataBase )
public:
/**
* Create a action data base object.
*
* \param parent A ActionDataGroup or 0. If provided this action is
* registered with the group.
* \param name Name for the object.
* \param comment Comment for the object.
* \param condition Conditions for the object or 0
*/
ActionDataBase(
ActionDataGroup* parent,
const QString& name,
const QString& comment,
Condition_list* condition);
/**
* Destructor
*/
virtual ~ActionDataBase();
/**
* Visitor pattern
*/
virtual void accept(ActionDataVisitor *visitor);
virtual void accept(ActionDataConstVisitor *visitor) const;
/**
* Get the conditions for this action or 0 if the action has no
* conditions.
*/
const Condition_list* conditions() const;
Condition_list* conditions();
/**
* Prepare this action for complete removal.
*/
virtual void aboutToBeErased() = 0;
/**
* Get the \c ActionDataGroup this object belongs to or 0 if it
* does not belong to a group.
*/
ActionDataGroup* parent() const;
/**
* \todo document this method
*/
virtual void update_triggers() = 0;
/**
* Check if the conditions match.
*/
bool conditions_match() const;
//@{
/**
* Name for the action
*/
QString name() const;
void set_name( const QString& name );
//@}
//@{
/**
* A comment for this action.
*/
QString comment() const;
void set_comment( const QString &comment );
//@}
/**
*/
void setImportId(const QString&);
QString importId() const;
/**
*/
void setAllowMerging(bool);
bool allowMerging() const;
/**
* Is the action enabled?
*
* The action has different states.
*
* Absolute State: Has the action an enabled/disabled state?
* Effective State: Even if the action is enabled it's effective state
* is disabled if it's parent is disabled.
*/
enum IgnoreParent
{
Ignore,
DontIgnore
};
bool isEnabled(IgnoreParent ip = DontIgnore) const;
/**
* Enable the action.
*/
void enable();
void disable();
//@}
/**
* See if it the config group is enabled.
*/
static bool cfg_is_enabled(const KConfigGroup& cfg);
//! Set the list of condition for this element
void set_conditions(Condition_list* conditions);
protected:
virtual void doEnable() = 0;
virtual void doDisable() = 0;
private:
friend class ActionDataGroup;
//! The parent or NULL
ActionDataGroup* _parent;
//! List of conditions for this element
Condition_list* _conditions;
//! Name for element
QString _name;
//! The comment for this element
QString _comment;
//! If this element is enabled
bool _enabled; // is not really important, only used in conf. module and when reading cfg. file
//! The importId from the file we were imported
QString _importId;
//! Is it allowed to merge this directory with others. Used when
//exporting and importig the directory
bool _allowMerging;
};
} // namespace KHotKeys
#endif // ACTION_DATA_BASE_H

View file

@ -1,194 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#include "action_data_group.h"
#include "action_data/action_data_visitor.h"
#include "actions/actions.h"
#include <kconfiggroup.h>
#include <kdebug.h>
namespace KHotKeys
{
ActionDataGroup::ActionDataGroup(
ActionDataGroup* parent_P,
const QString& name_P,
const QString& comment_P,
Condition_list* conditions_P,
system_group_t system_group_P)
: ActionDataBase(parent_P, name_P, comment_P, conditions_P)
,_list()
,_system_group(system_group_P)
{}
ActionDataGroup::~ActionDataGroup()
{
while (!_list.isEmpty())
{
delete _list.takeFirst();
}
}
void ActionDataGroup::accept(ActionDataVisitor *visitor)
{
visitor->visitActionDataGroup(this);
}
void ActionDataGroup::accept(ActionDataConstVisitor *visitor) const
{
visitor->visitActionDataGroup(this);
}
Action::ActionTypes ActionDataGroup::allowedActionTypes() const
{
switch (_system_group)
{
case SYSTEM_MENUENTRIES:
return Action::MenuEntryActionType;
default:
return Action::AllTypes;
}
}
Trigger::TriggerTypes ActionDataGroup::allowedTriggerTypes() const
{
switch (_system_group)
{
case SYSTEM_MENUENTRIES:
return Trigger::ShortcutTriggerType;
default:
return Trigger::AllTypes;
}
}
bool ActionDataGroup::is_system_group() const
{
return _system_group != SYSTEM_NONE and _system_group != SYSTEM_ROOT;
}
void ActionDataGroup::set_system_group(system_group_t group)
{
_system_group = group;
}
ActionDataGroup::system_group_t ActionDataGroup::system_group() const
{
return _system_group;
}
void ActionDataGroup::add_child(ActionDataBase* child_P)
{
// Just make sure we don't get the same child twice
Q_ASSERT(!_list.contains(child_P));
if (_list.contains(child_P)) return;
if (child_P->parent())
{
child_P->parent()->remove_child( child_P );
}
child_P->_parent = this;
_list.append( child_P );
}
void ActionDataGroup::add_child(ActionDataBase* child_P, int position)
{
// Just make sure we don't get the same child twice
Q_ASSERT(!_list.contains(child_P));
if (_list.contains(child_P)) return;
if (child_P->parent())
{
child_P->parent()->remove_child( child_P );
}
child_P->_parent = this;
_list.insert( position, child_P );
}
void ActionDataGroup::aboutToBeErased()
{
Q_FOREACH( ActionDataBase *child, _list)
{
child->aboutToBeErased();
}
}
const QList<ActionDataBase*> ActionDataGroup::children() const
{
return _list;
}
void ActionDataGroup::doDisable()
{
Q_FOREACH( ActionDataBase *child, _list)
{
child->update_triggers();
}
}
void ActionDataGroup::doEnable()
{
Q_FOREACH( ActionDataBase *child, _list)
{
child->update_triggers();
}
}
void ActionDataGroup::remove_child( ActionDataBase* child_P )
{
child_P->_parent = NULL;
_list.removeAll( child_P ); // is not auto-delete
}
int ActionDataGroup::size() const
{
return _list.size();
}
void ActionDataGroup::update_triggers()
{
Q_FOREACH(ActionDataBase *child, children())
{
child->update_triggers();
}
}
} // namespace KHotKeys
#include "moc_action_data_group.cpp"

View file

@ -1,145 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#ifndef ACTION_DATA_GROUP_H
#define ACTION_DATA_GROUP_H
#include "action_data_base.h"
#include "actions/actions.h"
#include "triggers/triggers.h"
#include "QtCore/QList"
#include "kdemacros.h"
class KHotkeysModel;
namespace KHotKeys {
/**
* A group of \c ActionDataBase objects
*
* # The group can contain actions or action groups.
* # The group has its own list of conditions. These conditions apply to all children.
*/
class KDE_EXPORT ActionDataGroup
: public ActionDataBase
{
Q_OBJECT
public:
enum system_group_t {
SYSTEM_NONE, //!< TODO
SYSTEM_MENUENTRIES, //!< Shortcuts for menu entries.
SYSTEM_ROOT, //!< TODO
/* last one*/ SYSTEM_MAX //!< End of enum marker
}; // don't remove entries
/**
* Create a \c ActionDataGroup object.
*
* \param parent_P A ActionDataGroup or 0. If provided this action is
* registered with the group.
* \param name_P Name for the object.
* \param comment_P Comment for the object.
* \param condition_P Conditions for the object or 0
* \param system_group_t Group type
* \param enabled_P Is the action enabled?
*/
ActionDataGroup(
ActionDataGroup* parent_P,
const QString& name_P = QString(),
const QString& comment_P = QString(),
Condition_list* conditions_P = NULL,
system_group_t system_group_P = SYSTEM_NONE);
virtual ~ActionDataGroup();
/**
* Visitor pattern
*/
virtual void accept(ActionDataVisitor *visitor);
virtual void accept(ActionDataConstVisitor *visitor) const;
virtual void update_triggers();
/**
* What kind of actions are allowed for this group?
*/
Action::ActionTypes allowedActionTypes() const;
/**
* What kind of trigger are allowed for this group?
*/
Trigger::TriggerTypes allowedTriggerTypes() const;
/**
* Get a shallow copy of the list of children.
*/
const QList<ActionDataBase*> children() const;
/**
* Number of childrens.
*/
int size() const;
/**
* @reimp
*/
void aboutToBeErased();
/**
* Is this a system group?
*
* @{
*/
bool is_system_group() const;
system_group_t system_group() const;
void set_system_group(system_group_t group);
//@}
// CHECKME : Why this?
using ActionDataBase::set_conditions; // make public
//! Add a child to this collection
void add_child( ActionDataBase* child_P, int position );
//! Add a child to this collection
void add_child( ActionDataBase* child_P );
//! Remove a child from this collection
void remove_child( ActionDataBase* child_P );
Q_SIGNALS:
void stateChanged(bool isEnabled);
protected:
//! The children
QList< ActionDataBase* > _list;
//! System group type
system_group_t _system_group; // e.g. menuedit entries, can't be deleted or renamed
virtual void doEnable();
virtual void doDisable();
};
} // namespace KHotKeys
#endif

View file

@ -1,61 +0,0 @@
/**
* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "action_data/action_data_visitor.h"
#include "action_data/action_data_base.h"
#include <KDebug>
namespace KHotKeys {
ActionDataVisitor::ActionDataVisitor()
{}
ActionDataVisitor::~ActionDataVisitor()
{}
void ActionDataVisitor::visitActionDataBase(ActionDataBase *action)
{
kDebug() << action->name();
Q_ASSERT(false);
}
ActionDataConstVisitor::ActionDataConstVisitor()
{}
ActionDataConstVisitor::~ActionDataConstVisitor()
{}
void ActionDataConstVisitor::visitActionDataBase(const ActionDataBase *action)
{
kDebug() << action->name();
Q_ASSERT(false);
}
} // KHotKeys

View file

@ -1,91 +0,0 @@
#ifndef ACTION_DATA_VISITOR_H
#define ACTION_DATA_VISITOR_H
/**
* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
namespace KHotKeys {
class ActionData;
class ActionDataBase;
class ActionDataGroup;
class Generic_action_data;
class MenuEntryShortcutActionData;
class SimpleActionData;
template< typename T, typename A > class SimpleActionDataHelper;
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class ActionDataVisitor
{
public:
ActionDataVisitor();
virtual ~ActionDataVisitor();
virtual void visitActionDataBase(ActionDataBase *base);
virtual void visitActionData(ActionData *base) = 0;
virtual void visitActionDataGroup(ActionDataGroup *group) = 0;
virtual void visitGenericActionData(Generic_action_data *data) = 0;
virtual void visitMenuentryShortcutActionData(MenuEntryShortcutActionData *data) = 0;
virtual void visitSimpleActionData(SimpleActionData *data) = 0;
}; // ActionDataVisitor
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class ActionDataConstVisitor
{
public:
ActionDataConstVisitor();
virtual ~ActionDataConstVisitor();
virtual void visitActionDataBase(const ActionDataBase *base);
virtual void visitActionData(const ActionData *base) = 0;
virtual void visitActionDataGroup(const ActionDataGroup *group) = 0;
virtual void visitGenericActionData(const Generic_action_data *data) = 0;
virtual void visitMenuentryShortcutActionData(const MenuEntryShortcutActionData *data) = 0;
virtual void visitSimpleActionData(const SimpleActionData *data) = 0;
template< typename T, typename A >
KHotKeys::ActionDataBase *visitSimpleActionDataHelper(const KHotKeys::SimpleActionDataHelper<T, A> *object);
private:
}; // ActionDataConstVisitor
} // KHotKeys
#endif /* ACTION_DATA_VISITOR_H */

View file

@ -1,51 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#include "generic_action_data.h"
#include "action_data/action_data_visitor.h"
#include "actions/actions.h"
#include <kconfiggroup.h>
namespace KHotKeys
{
Generic_action_data::Generic_action_data(
ActionDataGroup* parent,
const QString& name,
const QString& comment,
Trigger_list* triggers,
Condition_list* conditions,
ActionList* actions)
: ActionData(parent, name, comment, triggers, conditions, actions)
{
}
Generic_action_data::~Generic_action_data()
{}
void Generic_action_data::accept(ActionDataVisitor *visitor)
{
visitor->visitGenericActionData(this);
}
void Generic_action_data::accept(ActionDataConstVisitor *visitor) const
{
visitor->visitGenericActionData(this);
}
} // namespace KHotKeys

View file

@ -1,57 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#ifndef GENERIC_ACTION_DATA_H
#define GENERIC_ACTION_DATA_H
#include "action_data.h"
namespace KHotKeys {
class ActionDataGroup;
class KDE_EXPORT Generic_action_data
: public ActionData
{
typedef ActionData base;
public:
Generic_action_data(
ActionDataGroup* parent_P,
const QString& name_P = QString(),
const QString& comment_P = QString(),
Trigger_list* triggers_P = NULL,
Condition_list* conditions_P = NULL,
ActionList* actions_P = NULL);
~Generic_action_data();
/**
* Visitor pattern
* @reimp
*/
virtual void accept(ActionDataVisitor *visitor);
virtual void accept(ActionDataConstVisitor *visitor) const;
// CHECKME: Why this?
using ActionDataBase::set_conditions; // make public
using ActionData::add_trigger; // make public
using ActionData::add_triggers; // make public
using ActionData::set_triggers; // make public
using ActionData::add_action; // make public
using ActionData::add_actions; // make public
using ActionData::set_actions; // make public
};
} // namespace KHotKeys
#endif

View file

@ -1,65 +0,0 @@
/**
* Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "menuentry_shortcut_action_data.h"
#include "action_data/action_data_visitor.h"
#include "actions/actions.h"
#include "conditions/conditions.h"
#include <kconfiggroup.h>
#include <kdebug.h>
namespace KHotKeys {
MenuEntryShortcutActionData::MenuEntryShortcutActionData(
ActionDataGroup* parent,
const QString& name,
const QString& comment,
const KShortcut& shortcut,
const QString& menuentry)
: base(parent, name, comment)
{
set_action( new MenuEntryAction( this, menuentry ));
set_trigger( new ShortcutTrigger( this, shortcut ));
}
MenuEntryShortcutActionData::MenuEntryShortcutActionData(
ActionDataGroup* parent,
const QString& name,
const QString& comment)
: base(parent, name, comment)
{}
void MenuEntryShortcutActionData::accept(ActionDataVisitor *visitor)
{
visitor->visitMenuentryShortcutActionData(this);
}
void MenuEntryShortcutActionData::accept(ActionDataConstVisitor *visitor) const
{
visitor->visitMenuentryShortcutActionData(this);
}
} // namespace KHotKeys

View file

@ -1,61 +0,0 @@
#ifndef MENUENTRY_SHORTCUT_ACTION_DATA_H
#define MENUENTRY_SHORTCUT_ACTION_DATA_H
/**
* Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "simple_action_data.h"
#include "triggers/triggers.h"
#include "actions/actions.h"
namespace KHotKeys {
class KDE_EXPORT MenuEntryShortcutActionData
: public SimpleActionDataHelper< ShortcutTrigger, MenuEntryAction >
{
public:
typedef SimpleActionDataHelper< ShortcutTrigger, MenuEntryAction > base;
MenuEntryShortcutActionData(
ActionDataGroup* parent,
const QString& name = QString(),
const QString& comment = QString());
MenuEntryShortcutActionData(
ActionDataGroup* parent,
const QString& name,
const QString& comment,
const KShortcut& shortcut,
const QString& command_url);
/**
* Visitor pattern
* @reimp
*/
virtual void accept(ActionDataVisitor *visitor);
virtual void accept(ActionDataConstVisitor *visitor) const;
};
} // namespace KHotKeys
#endif /* MENUENTRY_SHORTCUT_ACTION_DATA_H */

View file

@ -1,127 +0,0 @@
/**
* Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "simple_action_data.h"
#include "action_data/action_data_visitor.h"
#include "conditions/conditions.h"
#include "conditions/conditions_list.h"
#include <KConfigGroup>
namespace KHotKeys {
SimpleActionData::SimpleActionData(
ActionDataGroup* parent_P,
const QString& name_P,
const QString& comment_P)
: ActionData(
parent_P,
name_P,
comment_P,
0,
new Condition_list( "", this ),
0)
{}
void SimpleActionData::accept(ActionDataVisitor *visitor)
{
visitor->visitSimpleActionData(this);
}
void SimpleActionData::accept(ActionDataConstVisitor *visitor) const
{
visitor->visitSimpleActionData(this);
}
void SimpleActionData::doEnable()
{
if (trigger())
{
trigger()->enable();
update_triggers();
}
}
void SimpleActionData::doDisable()
{
if (trigger())
{
trigger()->disable();
update_triggers();
}
}
void SimpleActionData::set_action( Action* action_P )
{
ActionList* tmp = new ActionList( "Simple_action_data" );
tmp->append( action_P );
set_actions( tmp );
}
void SimpleActionData::set_trigger( Trigger* trigger_P )
{
Trigger_list* tmp = new Trigger_list( "Simple_action" );
tmp->append( trigger_P );
set_triggers( tmp );
}
const Action* SimpleActionData::action() const
{
if( actions() == 0 || actions()->isEmpty() )
return 0;
return actions()->first();
}
Action* SimpleActionData::action()
{
if( actions() == 0 || actions()->isEmpty() )
return 0;
return actions()->first();
}
const Trigger* SimpleActionData::trigger() const
{
if( triggers() == 0 || triggers()->isEmpty() )
return NULL;
return triggers()->first();
}
Trigger* SimpleActionData::trigger()
{
if( triggers() == 0 || triggers()->isEmpty() )
return NULL;
return triggers()->first();
}
} // namespace KHotKeys

View file

@ -1,143 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#ifndef SIMPLE_ACTION_DATA_H
#define SIMPLE_ACTION_DATA_H
#include "action_data/action_data.h"
#include "actions/actions.h"
#include "triggers/triggers.h"
namespace KHotKeys {
class KDE_EXPORT SimpleActionData : public ActionData
{
typedef ActionData base;
public:
SimpleActionData(
ActionDataGroup* parent_P,
const QString& name_P = QString(),
const QString& comment_P = QString());
/**
* Visitor pattern
* @reimp
*/
virtual void accept(ActionDataVisitor *visitor);
virtual void accept(ActionDataConstVisitor *visitor) const;
//! The action associated with this hotkey
virtual const Action* action() const;
virtual Action* action();
//! The trigger for this hotkey
virtual const Trigger* trigger() const;
virtual Trigger* trigger();
void set_action( Action* action_P );
void set_trigger( Trigger* trigger_P );
protected:
void doEnable();
void doDisable();
}; // class SimpleActionData
/**
* A template adding convenience methods to SimpleActionData.
*/
template< typename T, typename A >
class KDE_EXPORT SimpleActionDataHelper
: public SimpleActionData
{
typedef SimpleActionData base;
public:
SimpleActionDataHelper(
ActionDataGroup* parent_P,
const QString& name_P,
const QString& comment_P)
: base( parent_P, name_P, comment_P)
{}
//! The action associated with this hotkey
const A* action() const;
A* action();
//! The trigger for this hotkey
const T* trigger() const;
T* trigger();
void set_action( Action *action_P );
void set_trigger( Trigger *trigger_P );
};
// ==========================================================================
// TEMPLATE METHOD DEFINITIONS
template< typename T, typename A >
void SimpleActionDataHelper< T, A >::set_action( Action* action_P )
{
Q_ASSERT( dynamic_cast<A*>( action_P ) );
base::set_action(action_P);
}
template< typename T, typename A >
void SimpleActionDataHelper< T, A >::set_trigger( Trigger* trigger_P )
{
Q_ASSERT( dynamic_cast<T*>( trigger_P ) );
base::set_trigger(trigger_P);
}
template< typename T, typename A >
const A* SimpleActionDataHelper< T, A >::action() const
{
if( actions() == 0 || actions()->isEmpty() )
return 0;
return dynamic_cast< const A* >( actions()->first());
}
template< typename T, typename A >
A* SimpleActionDataHelper< T, A >::action()
{
if( actions() == 0 || actions()->isEmpty() )
return 0;
return dynamic_cast< A* >(actions()->first());
}
template< typename T, typename A >
const T* SimpleActionDataHelper< T, A >::trigger() const
{
if( triggers() == 0 || triggers()->isEmpty() )
return 0;
return dynamic_cast< const T* >( triggers()->first());
}
template< typename T, typename A >
T* SimpleActionDataHelper< T, A >::trigger()
{
if( triggers() == 0 || triggers()->isEmpty() )
return 0;
return dynamic_cast< T* >( triggers()->first());
}
} // namespace KHotKeys
#endif

View file

@ -1,55 +0,0 @@
/*
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "actions.h"
#include <KConfigGroup>
#include <KDebug>
namespace KHotKeys {
ActionVisitor::~ActionVisitor()
{}
Action::Action( ActionData* data_P )
: data( data_P )
{
}
Action::~Action()
{
}
void Action::aboutToBeErased()
{
// Nothing to do yet.
}
void Action::cfg_write( KConfigGroup& cfg_P ) const
{
cfg_P.writeEntry( "Type", "ERROR" ); // derived classes should call with their type
}
} // namespace KHotKeys

View file

@ -1,69 +0,0 @@
/*
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "actions.h"
#include <kconfiggroup.h>
namespace KHotKeys {
ActionList::ActionList( const QString& comment_P )
: QList< Action* >(), _comment( comment_P )
{}
void ActionList::aboutToBeErased()
{
QListIterator<Action*> it(*this);
while (it.hasNext())
{
it.next()->aboutToBeErased();
}
}
const QString& ActionList::comment() const
{
return _comment;
}
ActionList::~ActionList()
{
while (!isEmpty())
{
delete takeFirst();
}
}
void ActionList::cfg_write( KConfigGroup& cfg_P ) const
{
QString save_cfg_group = cfg_P.name();
int i = 0;
for( ActionList::ConstIterator it = begin();
it != end();
++it )
{
KConfigGroup group( cfg_P.config(), save_cfg_group + QString::number( i++ ) );
(*it)->cfg_write( group );
}
cfg_P.writeEntry( "ActionsCount", i );
}
} // namespace KHotKeys

View file

@ -1,64 +0,0 @@
#ifndef ACTION_VISITOR_H
#define ACTION_VISITOR_H
/**
* Copyright (C) 2009 Michael Jansen <kde@michael-jansen.biz>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
namespace KHotKeys {
class Action;
class ActionList;
class ActivateWindowAction;
class CommandUrlAction;
class DBusAction;
class KeyboardInputAction;
class MenuEntryAction;
/**
* @author Michael Jansen <kde@michael-jansen.biz>
*/
class ActionVisitor
{
public:
ActionVisitor();
virtual ~ActionVisitor();
private:
virtual void visit(Action*)= 0
virtual void visit(ActionList*)= 0
virtual void visit(ActivateWindowAction*)= 0
virtual void visit(CommandUrlAction*)= 0
virtual void visit(DBusAction*)= 0
virtual void visit(KeyboardInputAction*)= 0
virtual void visit(MenuEntryAction*)= 0
virtual void visit(Action*) const= 0
virtual void visit(ActionList*) const= 0
virtual void visit(ActivateWindowAction*) const= 0
virtual void visit(CommandUrlAction*) const= 0
virtual void visit(DBusAction*) const= 0
virtual void visit(KeyboardInputAction*) const= 0
virtual void visit(MenuEntryAction*) const= 0
}; // ActionVisitor
} // namespace KHotKeys
#endif /* ACTION_VISITOR_H */

View file

@ -1,381 +0,0 @@
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#ifndef _ACTIONS_H_
#define _ACTIONS_H_
#include <QtCore/QList>
#include <QtCore/QTimer>
#include <kservice.h>
#include <kdemacros.h>
class KConfig;
#include "khotkeysglobal.h"
namespace KHotKeys
{
class ActionData;
class Windowdef_list;
class ActionVisitor
{
public:
virtual ~ActionVisitor() = 0;
};
// this one is a base for all "real" resulting actions, e.g. running a command,
// ActionData instances usually contain at least one Action
class KDE_EXPORT Action
{
Q_DISABLE_COPY( Action )
public:
/**
* A enum for all possible action types.
*
* @see type()
*/
enum ActionType
{
ActivateWindowActionType = 0x01, //!< @see ActivateWindowAction
CommandUrlActionType = 0x02, //!< @see CommandUrlAction
DBusActionType = 0x04, //!< @see DBusAction
KeyboardInputActionType = 0x08, //!< @see KeyboardInputAction
MenuEntryActionType = 0x10, //!< @see MenuEntryAction
ActionListType = 0x11, //!< @see ActionList
AllTypes = 0xEF //!< All types. For convenience
};
Q_DECLARE_FLAGS(ActionTypes, ActionType)
/**
* Create a action
*/
Action( ActionData* data_P );
virtual ~Action();
/**
* Acyclic visitor pattern
*/
virtual void accept(ActionVisitor&) = 0;
/**
* Execute the action.
*/
virtual void execute() = 0;
/**
* Have a look what's inside.
*
* @return the type of the action.
*/
virtual ActionType type() = 0;
/**
* Returns a short descriptions of the action.
*
* The description is generated and can't be set.
*
* @return a description for this action
*/
virtual const QString description() const = 0;
/**
* Write the actions configuration to @p cfg_P.
*/
virtual void cfg_write( KConfigGroup& cfg_P ) const;
/**
* Return a copy of the action.
*
* This is a real deep copy.
*/
virtual Action* copy( ActionData* data_P ) const = 0;
/**
* The action is about to be erased permanently
*/
virtual void aboutToBeErased();
protected:
/**
* The action data corresponding to this action.
*/
ActionData* const data;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Action::ActionTypes)
class KDE_EXPORT ActionList
: public QList< Action* >
{
Q_DISABLE_COPY( ActionList )
public:
ActionList( const QString& comment = QString());
~ActionList();
void cfg_write( KConfigGroup& cfg_P ) const;
//! Some convenience typedef
typedef QList<Action*>::Iterator Iterator;
typedef QList<Action*>::ConstIterator ConstIterator;
const QString& comment() const;
/**
* @reimp
*/
void aboutToBeErased();
private:
QString _comment;
};
class CommandUrlAction;
class CommandUrlActionVisitor
{
public:
virtual ~CommandUrlActionVisitor();
virtual void visit(CommandUrlAction&) = 0;
};
class KDE_EXPORT CommandUrlAction
: public Action
{
typedef Action base;
public:
CommandUrlAction( ActionData* data_P, const QString& command_url_P = QString() );
virtual void cfg_write( KConfigGroup& cfg_P ) const;
virtual void execute();
virtual const QString description() const;
//! The command url to trigger
void set_command_url( const QString &command_url );
QString command_url() const;
virtual ActionType type() { return CommandUrlActionType; }
virtual Action* copy( ActionData* data_P ) const;
/**
* Acyclic visitor pattern
*/
virtual void accept(ActionVisitor&);
private:
QString _command_url;
};
class MenuEntryAction;
class MenuEntryActionVisitor
{
public:
virtual ~MenuEntryActionVisitor();
virtual void visit(MenuEntryAction&) = 0;
};
class KDE_EXPORT MenuEntryAction
: public CommandUrlAction
{
typedef CommandUrlAction base;
public:
MenuEntryAction( ActionData* data_P, const QString& menuentry_P = QString() );
virtual void cfg_write( KConfigGroup& cfg_P ) const;
virtual void execute();
// The service we trigger
KService::Ptr service() const;
void set_service( KService::Ptr );
virtual const QString description() const;
virtual Action* copy( ActionData* data_P ) const;
virtual ActionType type() { return Action::MenuEntryActionType; }
/**
* Acyclic visitor pattern
*/
virtual void accept(ActionVisitor&);
private:
KService::Ptr _service;
};
class DBusAction;
class DBusActionVisitor
{
public:
virtual ~DBusActionVisitor();
virtual void visit(DBusAction&) = 0;
};
class KDE_EXPORT DBusAction
: public Action
{
typedef Action base;
public:
DBusAction(
ActionData* data_P,
const QString& app_P = QString(),
const QString& obj_P = QString(),
const QString& call_P= QString(),
const QString& args_P= QString() );
virtual void cfg_write( KConfigGroup& cfg_P ) const;
virtual void execute();
const QString remote_application() const;
const QString remote_object() const;
const QString called_function() const;
const QString arguments() const;
void set_remote_application( const QString &application );
void set_remote_object( const QString &object );
void set_called_function( const QString &function );
void set_arguments( const QString &args );
virtual const QString description() const;
virtual Action* copy( ActionData* data_P ) const;
virtual ActionType type() { return DBusActionType; }
/**
* Acyclic visitor pattern
*/
virtual void accept(ActionVisitor&);
private:
QString _application; // CHECKME QCString ?
QString _object;
QString _function;
QString _arguments;
};
class KeyboardInputAction;
class KeyboardInputActionVisitor
{
public:
virtual ~KeyboardInputActionVisitor();
virtual void visit(KeyboardInputAction&) = 0;
};
class KDE_EXPORT KeyboardInputAction
: public Action
{
typedef Action base;
public:
/**
* Where should we send the data too
*/
enum DestinationWindow
{
ActiveWindow,
SpecificWindow,
ActionWindow
};
KeyboardInputAction(
ActionData* data_P,
const QString& input_P = QString(),
Windowdef_list* dest_window_P = NULL,
bool active_window_P = true);
virtual ~KeyboardInputAction();
virtual void cfg_write( KConfigGroup& cfg_P ) const;
virtual void execute();
const QString& input() const;
void setInput(const QString &input);
// send to specific window: dest_window != NULL
// send to active window: dest_window == NULL && activeWindow() == true
// send to action window: dest_window == NULL && activeWindow() == false
//
DestinationWindow destination() const;
void setDestination(const DestinationWindow &dest);
const Windowdef_list* dest_window() const;
Windowdef_list* dest_window();
void setDestinationWindowRules(Windowdef_list *list);
bool activeWindow() const;
virtual const QString description() const;
virtual Action* copy( ActionData* data_P ) const;
virtual ActionType type() { return KeyboardInputActionType; }
/**
* Acyclic visitor pattern
*/
virtual void accept(ActionVisitor&);
private:
QString _input;
Windowdef_list* _dest_window;
//! Which window should get the input
DestinationWindow _destination;
};
class ActivateWindowAction;
class ActivateWindowActionVisitor
{
public:
virtual ~ActivateWindowActionVisitor();
virtual void visit(ActivateWindowAction&) = 0;
};
class KDE_EXPORT ActivateWindowAction
: public Action
{
typedef Action base;
public:
ActivateWindowAction(
ActionData* data_P,
const Windowdef_list* window = NULL);
virtual ~ActivateWindowAction();
virtual void cfg_write( KConfigGroup& cfg_P ) const;
virtual void execute();
const Windowdef_list* window() const;
void set_window_list(Windowdef_list *list);
virtual const QString description() const;
virtual Action* copy( ActionData* data_P ) const;
virtual ActionType type() { return ActivateWindowActionType; }
/**
* Acyclic visitor pattern
*/
virtual void accept(ActionVisitor&);
private:
const Windowdef_list* _window;
};
} // namespace KHotKeys
#endif

View file

@ -1,108 +0,0 @@
/*
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "actions.h"
#include "windows_handler.h"
#include "windows_helper/window_selection_list.h"
#include <KConfigGroup>
#include <KDebug>
#ifdef Q_WS_X11
// Has to be behind all qt related stuff. Else the build fails miserably
#include <X11/X.h>
#endif
namespace KHotKeys {
ActivateWindowActionVisitor::~ActivateWindowActionVisitor()
{}
ActivateWindowAction::ActivateWindowAction( ActionData* data_P,
const Windowdef_list* window_P )
: Action( data_P ), _window( window_P )
{
}
void ActivateWindowAction::accept(ActionVisitor& visitor)
{
if (ActivateWindowActionVisitor *v = dynamic_cast<ActivateWindowActionVisitor*>(&visitor))
{
v->visit(*this);
}
else
{
kDebug() << "Visitor error";
}
}
const Windowdef_list* ActivateWindowAction::window() const
{
return _window;
}
ActivateWindowAction::~ActivateWindowAction()
{
delete _window;
}
void ActivateWindowAction::cfg_write( KConfigGroup& cfg_P ) const
{
base::cfg_write( cfg_P );
cfg_P.writeEntry( "Type", "ACTIVATE_WINDOW" ); // overwrites value set in base::cfg_write()
KConfigGroup windowGroup( cfg_P.config(), cfg_P.name() + "Window" );
window()->cfg_write( windowGroup );
}
void ActivateWindowAction::execute()
{
if( window()->match( windows_handler->active_window()))
return; // is already active
WId win_id = windows_handler->find_window( window());
if( win_id != None )
windows_handler->activate_window( win_id );
}
const QString ActivateWindowAction::description() const
{
return i18n( "Activate window: " ) + window()->comment();
}
Action* ActivateWindowAction::copy( ActionData* data_P ) const
{
return new ActivateWindowAction( data_P, window()->copy());
}
void ActivateWindowAction::set_window_list(Windowdef_list *list)
{
delete _window;
_window = list;
}
} // namespace KHotKeys

View file

@ -1,147 +0,0 @@
/*
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "actions/actions.h"
#include "action_data/action_data.h"
#include <KConfigGroup>
#include <KDebug>
#include <KRun>
#include <KService>
#include <KUriFilter>
#include <kworkspace/kworkspace.h>
namespace KHotKeys {
CommandUrlActionVisitor::~CommandUrlActionVisitor()
{}
CommandUrlAction::CommandUrlAction( ActionData* data_P, const QString& command_url_P )
: Action( data_P ), _command_url( command_url_P )
{
}
QString CommandUrlAction::command_url() const
{
return _command_url;
}
void CommandUrlAction::accept(ActionVisitor& visitor)
{
if (CommandUrlActionVisitor *v = dynamic_cast<CommandUrlActionVisitor*>(&visitor))
{
v->visit(*this);
}
else
{
kDebug() << "Visitor error";
}
}
void CommandUrlAction::cfg_write( KConfigGroup& cfg_P ) const
{
base::cfg_write( cfg_P );
cfg_P.writeEntry( "CommandURL", command_url());
cfg_P.writeEntry( "Type", "COMMAND_URL" ); // overwrites value set in base::cfg_write()
}
Action* CommandUrlAction::copy( ActionData* data_P ) const
{
return new CommandUrlAction( data_P, command_url());
}
const QString CommandUrlAction::description() const
{
return i18n( "Command/URL : " ) + command_url();
}
void CommandUrlAction::execute()
{
kDebug();
if( command_url().isEmpty())
return;
KUriFilterData uri;
QString cmd = command_url();
static bool sm_ready = false;
if( !sm_ready )
{
KWorkSpace::propagateSessionManager();
sm_ready = true;
}
// int space_pos = command_url().find( ' ' );
// if( command_url()[ 0 ] != '\'' && command_url()[ 0 ] != '"' && space_pos > -1
// && command_url()[ space_pos - 1 ] != '\\' )
// cmd = command_url().left( space_pos ); // get first 'word'
uri.setData( cmd );
KUriFilter::self()->filterUri( uri );
if( uri.uri().isLocalFile() && !uri.uri().hasFragment() )
cmd = uri.uri().toLocalFile();
else
cmd = uri.uri().url();
switch( uri.uriType())
{
case KUriFilterData::LocalFile:
case KUriFilterData::LocalDir:
case KUriFilterData::NetProtocol:
{
( void ) new KRun( uri.uri(),0L);
break;
}
case KUriFilterData::Executable:
{
if( !uri.hasArgsAndOptions())
{
KService::Ptr service = KService::serviceByDesktopName( cmd );
if( service )
{
KRun::run( *service, KUrl::List(), NULL );
break;
}
}
// fall though
}
case KUriFilterData::Shell:
{
if( !KRun::runCommand(
cmd + ( uri.hasArgsAndOptions() ? uri.argsAndOptions() : "" ),
cmd, uri.iconName(), NULL )) {
// CHECKME ?
}
break;
}
default: // error
return;
}
}
void CommandUrlAction::set_command_url( const QString &command )
{
_command_url = command;
}
} // namespace KHotKeys

View file

@ -1,189 +0,0 @@
/*
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "actions.h"
#include <QProcess>
#include <KConfigGroup>
#include <KDebug>
#include <KStandardDirs>
namespace KHotKeys {
DBusActionVisitor::~DBusActionVisitor()
{}
DBusAction::DBusAction( ActionData* data_P, const QString& app_P, const QString& obj_P,
const QString& call_P, const QString& args_P )
: Action( data_P ), _application( app_P ), _object( obj_P ), _function( call_P ), _arguments( args_P )
{
}
void DBusAction::accept(ActionVisitor& visitor)
{
if (DBusActionVisitor *v = dynamic_cast<DBusActionVisitor*>(&visitor))
{
v->visit(*this);
}
else
{
kDebug() << "Visitor error";
}
}
const QString DBusAction::remote_application() const
{
return _application;
}
const QString DBusAction::remote_object() const
{
return _object;
}
const QString DBusAction::called_function() const
{
return _function;
}
const QString DBusAction::arguments() const
{
return _arguments;
}
void DBusAction::cfg_write( KConfigGroup& cfg_P ) const
{
base::cfg_write( cfg_P );
cfg_P.writeEntry( "Type", "DBUS" ); // overwrites value set in base::cfg_write()
cfg_P.writeEntry( "RemoteApp", _application );
cfg_P.writeEntry( "RemoteObj", _object );
cfg_P.writeEntry( "Call", _function );
cfg_P.writeEntry( "Arguments", _arguments );
}
void DBusAction::execute()
{
if( _application.isEmpty() || _object.isEmpty() || _function.isEmpty())
return;
QStringList args_list;
QString args_str = _arguments;
while( !args_str.isEmpty())
{
int pos = 0;
while( args_str[ pos ] == ' ' )
++pos;
if( args_str[ pos ] == '\"' || args_str[ pos ] == '\'' )
{
QString val = "";
QChar sep = args_str[ pos ];
bool skip = false;
++pos;
for(;
pos < args_str.length();
++pos )
{
if( args_str[ pos ] == '\\' )
{
skip = true;
continue;
}
if( !skip && args_str[ pos ] == sep )
break;
skip = false;
val += args_str[ pos ];
}
if( pos >= args_str.length())
return;
++pos;
args_str = args_str.mid( pos );
args_list.append( val );
}
else
{
// one word
if( pos != 0 )
args_str = args_str.mid( pos );
int nxt_pos = args_str.indexOf( ' ' );
args_list.append( args_str.left( nxt_pos )); // should be ok if nxt_pos is -1
args_str = nxt_pos >= 0 ? args_str.mid( nxt_pos ) : "";
}
}
kDebug() << "D-Bus call:" << _application << ":" << _object << ":" << _function << ":" << args_list;
// most distributions ship a suffixed symlink to qdbus, look for that first
QString qdbusExe = KStandardDirs::findExe("qdbus-katie");
if (qdbusExe.isEmpty()) {
qdbusExe = KStandardDirs::findExe("qdbus-qt4");
}
if (qdbusExe.isEmpty()) {
// no exe lookup, let it fail if not found
qdbusExe = "qdbus";
}
QStringList qdbusArgs;
qdbusArgs << _application << _object << _function << args_list;
QProcess::startDetached(qdbusExe, qdbusArgs);
}
const QString DBusAction::description() const
{
return i18n( "D-Bus: " ) + remote_application() + "::" + remote_object() + "::"
+ called_function();
}
Action* DBusAction::copy( ActionData* data_P ) const
{
return new DBusAction( data_P, remote_application(), remote_object(),
called_function(), arguments());
}
void DBusAction::set_arguments( const QString &arguments )
{
_arguments = arguments;
}
void DBusAction::set_called_function( const QString &function )
{
_function = function;
}
void DBusAction::set_remote_application( const QString &application )
{
_application = application;
}
void DBusAction::set_remote_object( const QString &object )
{
_object = object;
}
} // namespace KHotKeys

View file

@ -1,205 +0,0 @@
/*
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "actions.h"
#include "input.h"
#include "windows_handler.h"
#include "shortcuts_handler.h"
#include "windows_helper/window_selection_list.h"
#include <KConfigGroup>
#include <KDebug>
// #include <X11/X.h>
#include <X11/Xlib.h>
#include <QtGui/qx11info_x11.h>
/*
*/
namespace KHotKeys {
KeyboardInputActionVisitor::~KeyboardInputActionVisitor()
{}
KeyboardInputAction::KeyboardInputAction(
ActionData* data_P,
const QString& input_P,
Windowdef_list* dest_window_P,
bool active_window_P)
: Action( data_P ),
_input( input_P ),
_dest_window( dest_window_P )
{
if (dest_window_P) _destination = SpecificWindow;
else if (active_window_P) _destination = ActiveWindow;
else _destination = ActionWindow;
if (!_dest_window) _dest_window = new Windowdef_list;
}
KeyboardInputAction::~KeyboardInputAction()
{
delete _dest_window;
}
void KeyboardInputAction::accept(ActionVisitor& visitor)
{
if (KeyboardInputActionVisitor *v = dynamic_cast<KeyboardInputActionVisitor*>(&visitor))
{
v->visit(*this);
}
else
{
kDebug() << "Visitor error";
}
}
const QString& KeyboardInputAction::input() const
{
return _input;
}
void KeyboardInputAction::setDestination(const DestinationWindow & dest)
{
_destination = dest;
}
void KeyboardInputAction::setDestinationWindowRules(Windowdef_list *list)
{
if (_dest_window)
delete _dest_window;
_dest_window = list;
}
void KeyboardInputAction::setInput(const QString &input)
{
_input = input;
}
const Windowdef_list* KeyboardInputAction::dest_window() const
{
return _dest_window;
}
Windowdef_list* KeyboardInputAction::dest_window()
{
return _dest_window;
}
KeyboardInputAction::DestinationWindow KeyboardInputAction::destination() const
{
return _destination;
}
void KeyboardInputAction::cfg_write( KConfigGroup& cfg_P ) const
{
base::cfg_write( cfg_P );
cfg_P.writeEntry( "Type", "KEYBOARD_INPUT" ); // overwrites value set in base::cfg_write()
cfg_P.writeEntry( "Input", input());
cfg_P.writeEntry( "DestinationWindow", int(_destination) );
if( _destination == SpecificWindow && dest_window() != NULL )
{
KConfigGroup windowGroup( cfg_P.config(), cfg_P.name() + "DestinationWindow" );
dest_window()->cfg_write( windowGroup );
}
}
void KeyboardInputAction::execute()
{
kDebug();
if( input().isEmpty())
{
kDebug() << "Input is empty";
return;
}
Window w = InputFocus;
switch (_destination)
{
case SpecificWindow:
Q_ASSERT(dest_window());
w = windows_handler->find_window(dest_window());
if (w == None) w = InputFocus;
break;
case ActionWindow:
w = windows_handler->action_window();
if (w == None) w = InputFocus;
break;
case ActiveWindow:
// Nothing to do because w is InputFocus already
break;
default:
Q_ASSERT(false);
}
int last_index = -1, start = 0;
while(( last_index = input().indexOf( ':', last_index + 1 )) != -1 ) // find next ';'
{
QString key = input().mid( start, last_index - start ).trimmed();
keyboard_handler->send_macro_key( key, w );
start = last_index + 1;
}
// and the last one
QString key = input().mid( start, input().length()).trimmed();
keyboard_handler->send_macro_key( key, w ); // the rest
XFlush( QX11Info::display());
}
const QString KeyboardInputAction::description() const
{
QString tmp = input();
tmp.replace( '\n', ' ' );
tmp.truncate( 30 );
return i18n( "Keyboard input: " ) + tmp;
}
Action* KeyboardInputAction::copy( ActionData* data_P ) const
{
return new KeyboardInputAction(
data_P,
input(),
dest_window() ? dest_window()->copy() : NULL,
_destination == ActiveWindow);
}
} // namespace KHotKeys

Some files were not shown because too many files have changed in this diff Show more