mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 02:42:50 +00:00
generic: replace QUuid with QByteArray and qRandomUuid()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
ff13ae7a6a
commit
3ca810a7d4
10 changed files with 42 additions and 25 deletions
|
@ -393,8 +393,8 @@ TriggersCount=1
|
|||
[Data_1_1Triggers0]
|
||||
Key=Search
|
||||
Type=SHORTCUT
|
||||
Uuid={d03619b6-9b3c-48cc-9d9c-a2aadb485550}
|
||||
Uuid=d03619b6-9b3c-48cc-9d9c-a2aadb485550
|
||||
|
||||
[Main]
|
||||
Version=2
|
||||
Version=3
|
||||
ImportId=defaults
|
||||
|
|
|
@ -432,5 +432,5 @@ Key=Print
|
|||
Type=SHORTCUT
|
||||
|
||||
[Main]
|
||||
Version=2
|
||||
Version=3
|
||||
ImportId=printscreen
|
||||
|
|
|
@ -234,12 +234,13 @@ bool Settings::isConfigFileValid(KConfigBase const &config, ImportType ask)
|
|||
int version = mainGroup.readEntry( "Version", -1234576 );
|
||||
switch (version)
|
||||
{
|
||||
case 2:
|
||||
case 3:
|
||||
valid = true;
|
||||
break;
|
||||
|
||||
case 1: // Version 1 files no longer supported
|
||||
kDebug() << "Version 1 file encountered.";
|
||||
case 2:
|
||||
case 1: // Version 1 and 2 files no longer supported
|
||||
kDebug() << "Version 1 or 2 file encountered.";
|
||||
break;
|
||||
|
||||
case -1234576: // No Version entry -> invalid file
|
||||
|
@ -461,9 +462,9 @@ bool Settings::read_settings(ActionDataGroup *root, KConfigBase const &config, b
|
|||
QString import_id = mainGroup.readEntry( "ImportId" );
|
||||
switch (version)
|
||||
{
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
kDebug() << "Version 2 File!";
|
||||
kDebug() << "Version 3 File!";
|
||||
SettingsReaderV2 reader(this, include_disabled, stateStrategy, import_id);
|
||||
reader.read(config, root);
|
||||
}
|
||||
|
|
|
@ -301,9 +301,9 @@ KHotKeys::Trigger_list *SettingsReaderV2::readTriggerList(
|
|||
{
|
||||
KConfigGroup triggerConfig( triggersGroup.config(), triggersGroup.name() + QString::number( i ));
|
||||
QString type = triggerConfig.readEntry("Type");
|
||||
QUuid uuid = triggerConfig.readEntry( "Uuid" );
|
||||
QByteArray uuid = triggerConfig.readEntry( "Uuid", QByteArray() );
|
||||
if( uuid.isNull())
|
||||
uuid = QUuid::createUuid();
|
||||
uuid = createShortcutID();
|
||||
|
||||
if (type == "SHORTCUT" || type == "SINGLE_SHORTCUT")
|
||||
trigger = new KHotKeys::ShortcutTrigger(parent, KShortcut(), uuid);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
namespace KHotKeys {
|
||||
|
||||
const int CurrentFileVersion = 2;
|
||||
const int CurrentFileVersion = 3;
|
||||
|
||||
|
||||
SettingsWriter::SettingsWriter(
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
#include <config-X11.h>
|
||||
|
||||
#include "input.h"
|
||||
#include "triggers/triggers.h"
|
||||
#include "shortcuts_handler.h"
|
||||
#include "windows_handler.h"
|
||||
#include "khotkeysglobal.h"
|
||||
|
||||
|
||||
#include <X11/X.h>
|
||||
// #include <X11/Xutil.h>
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
|
@ -33,7 +33,6 @@
|
|||
#include <KAction>
|
||||
#include <KDebug>
|
||||
|
||||
#include <QtCore/QUuid>
|
||||
#include <kkeyserver.h>
|
||||
|
||||
namespace KHotKeys {
|
||||
|
@ -70,7 +69,7 @@ KAction *ShortcutsHandler::addAction(
|
|||
if (_actions->action(id))
|
||||
{
|
||||
qDebug() << id << " already present. Using new id!";
|
||||
realId = QUuid::createUuid().toString();
|
||||
realId = QString::fromLatin1(createShortcutID());
|
||||
}
|
||||
|
||||
// Create the action
|
||||
|
|
|
@ -36,9 +36,9 @@ ShortcutTriggerVisitor::~ShortcutTriggerVisitor()
|
|||
ShortcutTrigger::ShortcutTrigger(
|
||||
ActionData* data_P,
|
||||
const KShortcut& shortcut,
|
||||
const QUuid &uuid )
|
||||
const QByteArray &uuid )
|
||||
: Trigger( data_P ),
|
||||
_uuid(uuid.toString()),
|
||||
_uuid(uuid),
|
||||
_active(false),
|
||||
_shortcut(shortcut)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ void ShortcutTrigger::activate( bool newState )
|
|||
KAction *act = keyboard_handler->addAction( _uuid, name, _shortcut );
|
||||
// addAction can change the uuid. That's why we store the uuid from the
|
||||
// action
|
||||
_uuid = act->objectName();
|
||||
_uuid = act->objectName().toLatin1();
|
||||
|
||||
connect(
|
||||
act, SIGNAL(triggered(bool)),
|
||||
|
@ -128,7 +128,7 @@ void ShortcutTrigger::cfg_write( KConfigGroup& cfg_P ) const
|
|||
|
||||
ShortcutTrigger* ShortcutTrigger::copy( ActionData* data_P ) const
|
||||
{
|
||||
return new ShortcutTrigger( data_P ? data_P : data, shortcut(), QUuid::createUuid());
|
||||
return new ShortcutTrigger( data_P ? data_P : data, shortcut(), createShortcutID());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QUuid>
|
||||
#include <QtCore/QByteArray>
|
||||
|
||||
#include <KShortcut>
|
||||
|
||||
|
@ -35,6 +35,15 @@
|
|||
|
||||
#include <QKeySequence>
|
||||
|
||||
static inline QByteArray createShortcutID()
|
||||
{
|
||||
#if QT_VERSION >= 0x041200
|
||||
return qRandomUuid();
|
||||
#else
|
||||
return QByteArray::number(qrand());
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace KHotKeys
|
||||
{
|
||||
|
||||
|
@ -153,7 +162,7 @@ class KDE_EXPORT ShortcutTrigger
|
|||
ShortcutTrigger(
|
||||
ActionData* data,
|
||||
const KShortcut& shortcut = KShortcut(),
|
||||
const QUuid &uuid = QUuid::createUuid() );
|
||||
const QByteArray &uuid = createShortcutID() );
|
||||
|
||||
virtual ~ShortcutTrigger();
|
||||
virtual void cfg_write( KConfigGroup& cfg_P ) const;
|
||||
|
@ -195,7 +204,7 @@ class KDE_EXPORT ShortcutTrigger
|
|||
private:
|
||||
|
||||
//! A persistent identifier for this shortcut
|
||||
QString _uuid;
|
||||
QByteArray _uuid;
|
||||
|
||||
//! Are the conditions met?
|
||||
bool _active;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QUuid>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
|
||||
|
@ -44,6 +43,15 @@
|
|||
#include "history.h"
|
||||
#include "historystringitem.h"
|
||||
|
||||
static inline QByteArray createActionID()
|
||||
{
|
||||
#if QT_VERSION >= 0x041200
|
||||
return qRandomUuid();
|
||||
#else
|
||||
return QByteArray::number(qrand());
|
||||
#endif
|
||||
}
|
||||
|
||||
URLGrabber::URLGrabber(History* history):
|
||||
m_myMenu(0L),
|
||||
m_myPopupKillTimer(new QTimer( this )),
|
||||
|
@ -228,7 +236,7 @@ void URLGrabber::actionMenu( const HistoryItem* item, bool automatically_invoked
|
|||
if ( item.isEmpty() )
|
||||
item = command.command;
|
||||
|
||||
QString id = QUuid::createUuid().toString();
|
||||
QByteArray id = createActionID();
|
||||
QAction * action = new QAction(this);
|
||||
action->setData(id);
|
||||
action->setText(item);
|
||||
|
@ -270,7 +278,7 @@ void URLGrabber::slotItemSelected(QAction* action)
|
|||
if (m_myMenu)
|
||||
m_myMenu->hide(); // deleted by the timer or the next action
|
||||
|
||||
QString id = action->data().toString();
|
||||
QByteArray id = action->data().toByteArray();
|
||||
|
||||
if (id.isEmpty()) {
|
||||
kDebug() << "Klipper: no command associated";
|
||||
|
|
|
@ -83,7 +83,7 @@ private:
|
|||
const HistoryItem* m_myClipItem;
|
||||
|
||||
// holds mappings of menu action IDs to action commands (action+cmd index in it)
|
||||
QHash<QString, QPair<ClipAction*, int> > m_myCommandMapper;
|
||||
QHash<QByteArray, QPair<ClipAction*, int> > m_myCommandMapper;
|
||||
KMenu* m_myMenu;
|
||||
QTimer* m_myPopupKillTimer;
|
||||
int m_myPopupKillTimeout;
|
||||
|
|
Loading…
Add table
Reference in a new issue