コード例 #1
0
ファイル: Action.cpp プロジェクト: 335/synergy
QString Action::text() const
{
	QString text = QString(m_ActionTypeNames[keySequence().isMouseButton() ? type() + 6 : type()  ]) + "(";

	switch (type())
	{
		case keyDown:
		case keyUp:
		case keystroke:
			{
				text += keySequence().toString();

				if (!keySequence().isMouseButton())
				{
					const QStringList& screens = typeScreenNames();
					if (haveScreens() && !screens.isEmpty())
					{
						text += ",";

						for (int i = 0; i < screens.size(); i++)
						{
							text += screens[i];
							if (i != screens.size() - 1)
								text += ":";
						}
					}
					else
						text += ",*";
				}
			}
			break;

		case switchToScreen:
			text += switchScreenName();
			break;

		case switchInDirection:
			text += m_SwitchDirectionNames[m_SwitchDirection];
			break;

		case lockCursorToScreen:
			text += m_LockCursorModeNames[m_LockCursorMode];
			break;

		default:
			Q_ASSERT(0);
			break;
	}

	text += ")";

	return text;
}
コード例 #2
0
ファイル: KeySequenceWidget.cpp プロジェクト: 335/synergy
void KeySequenceWidget::stopRecording()
{
	if (!keySequence().valid())
	{
		keySequence() = backupSequence();
		updateOutput();
	}

	setDown(false);
	focusNextChild();
	releaseKeyboard();
	setStatus(Stopped);
	emit keySequenceChanged();
}
コード例 #3
0
void MenuCallback::addCommand(QString commandId,
                              QString label,
                              QString tooltip,
                              QString shortcut)
{
   shortcut = shortcut.replace("Enter", "\n");

   QKeySequence keySequence(shortcut);
#ifndef Q_WS_MAC
   if (shortcut.contains("\n"))
   {
      int value = (keySequence[0] & Qt::MODIFIER_MASK) + Qt::Key_Enter;
      keySequence = QKeySequence(value);
   }
#endif

   QAction* pAction = menuStack_.top()->addAction(QIcon(),
                                                  label,
                                                  this,
                                                  SLOT(actionInvoked()),
                                                  keySequence);
   pAction->setData(commandId);
   pAction->setToolTip(tooltip);

   menuActions_[menuStack_.first()].append(pAction);
}
コード例 #4
0
void MenuCallback::addCommand(QString commandId,
                              QString label,
                              QString tooltip,
                              QString shortcut)
{
   shortcut = shortcut.replace(QString::fromUtf8("Enter"), QString::fromAscii("\n"));

   QKeySequence keySequence(shortcut);
#ifndef Q_WS_MAC
   if (shortcut.contains(QString::fromAscii("\n")))
   {
      int value = (keySequence[0] & Qt::MODIFIER_MASK) + Qt::Key_Enter;
      keySequence = QKeySequence(value);
   }
#endif

   // allow custom action handlers first shot
   QAction* pAction = addCustomAction(commandId, label, tooltip);

   // if there was no custom handler then do stock command-id processing
   if (pAction == NULL)
   {
      pAction = menuStack_.top()->addAction(QIcon(),
                                            label,
                                            this,
                                            SLOT(actionInvoked()),
                                            keySequence);
      pAction->setData(commandId);
      pAction->setToolTip(tooltip);

      MenuActionBinder* pBinder = new MenuActionBinder(menuStack_.top(), pAction);
      connect(pBinder, SIGNAL(manageCommand(QString,QAction*)),
              this, SIGNAL(manageCommand(QString,QAction*)));

   }
コード例 #5
0
ファイル: keyinput.cpp プロジェクト: sakazuki/actiona
	bool KeyInput::fromPortableText(const QString &key, bool isQtKey)
	{
		mIsQtKey = isQtKey;

		if(mIsQtKey)
		{
			QKeySequence keySequence(key);

			mKey = keySequence[0];
			mKey &= ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier);

			return true;
		}

		for(int i = 0; i < KeyCount; ++i)
		{
			if(mKeyNames.first[i] == key)
			{
				mKey = i;

				return true;
			}
		}

		return false;
	}
コード例 #6
0
ファイル: mainwindow2.cpp プロジェクト: Verlet/pencil
QKeySequence cmdKeySeq( QString strCommandName )
{
    strCommandName = QString( "shortcuts/" ) + strCommandName;
    QKeySequence keySequence( pencilSettings()->value( strCommandName ).toString() );

    return keySequence;
}
コード例 #7
0
ファイル: KeySequenceWidget.cpp プロジェクト: 335/synergy
bool KeySequenceWidget::event(QEvent* event)
{
	if (status() == Recording)
	{
		switch(event->type())
		{
			case QEvent::KeyPress:
				keyPressEvent(static_cast<QKeyEvent*>(event));
				return true;

			case QEvent::MouseButtonRelease:
				event->accept();
				return true;

			case QEvent::ShortcutOverride:
				event->accept();
				return true;

			case QEvent::FocusOut:
				stopRecording();
				if (!valid())
				{
					keySequence() = backupSequence();
					updateOutput();
				}
				break;

			default:
				break;
		}
	}

	return QPushButton::event(event);
}
コード例 #8
0
ファイル: shortcutedit.cpp プロジェクト: FengJianjian/zeal
bool ShortcutEdit::event(QEvent *event)
{
    switch (event->type()) {
    case QEvent::KeyPress: {
        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
        switch (keyEvent->key()) {
        case Qt::Key_Alt:
        case Qt::Key_Control:
        case Qt::Key_Meta:
        case Qt::Key_Shift:
            return true;
        default:
            m_key = keyEvent->key();
            m_key |= translateModifiers(keyEvent->modifiers(), keyEvent->text());
            setText(keySequence().toString(QKeySequence::NativeText));
        }
    }
    case QEvent::ShortcutOverride:
        event->accept();
    case QEvent::KeyRelease:
    case QEvent::Shortcut:
        return true;
    default:
        return QLineEdit::event(event);
    }
}
コード例 #9
0
void MenuCallback::addCommand(QString commandId,
                              QString label,
                              QString tooltip,
                              QString shortcut)
{
   shortcut = shortcut.replace(QString::fromUtf8("Enter"), QString::fromAscii("\n"));

   QKeySequence keySequence(shortcut);
#ifndef Q_WS_MAC
   if (shortcut.contains(QString::fromAscii("\n")))
   {
      int value = (keySequence[0] & Qt::MODIFIER_MASK) + Qt::Key_Enter;
      keySequence = QKeySequence(value);
   }
#endif

   QAction* pAction = menuStack_.top()->addAction(QIcon(),
                                                  label,
                                                  this,
                                                  SLOT(actionInvoked()),
                                                  keySequence);
   pAction->setData(commandId);
   pAction->setToolTip(tooltip);

   MenuActionBinder* pBinder = new MenuActionBinder(menuStack_.top(), pAction);
   connect(pBinder, SIGNAL(manageCommand(QString,QAction*)),
           this, SIGNAL(manageCommand(QString,QAction*)));
}
コード例 #10
0
ファイル: KeySequenceWidget.cpp プロジェクト: 335/synergy
void KeySequenceWidget::setKeySequence(const KeySequence& seq)
{
	keySequence() = seq;
	backupSequence() = seq;

	setStatus(Stopped);
	updateOutput();
}
コード例 #11
0
ファイル: KeySequenceWidget.cpp プロジェクト: 335/synergy
void KeySequenceWidget::startRecording()
{
	keySequence() = KeySequence();
	setDown(true);
	setFocus();
	grabKeyboard();
	setStatus(Recording);
}
コード例 #12
0
ファイル: keyedit.cpp プロジェクト: dotminic/actionaz
	KeyEdit::KeyEdit(QWidget *parent)
		: CodeComboBox(parent)
	{
		installEventFilter(this);

		connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(currentIndexChanged(QString)));

		QKeySequence keySequence(Qt::Key_Print);
		addItem(keySequence.toString(QKeySequence::NativeText));
	}
コード例 #13
0
ファイル: keyinput.cpp プロジェクト: sakazuki/actiona
	QString KeyInput::toPortableText() const
	{
		if(mIsQtKey)
		{
			QKeySequence keySequence(mKey);

			return keySequence.toString(QKeySequence::PortableText);
		}

		return mKeyNames.first[mKey];
	}
コード例 #14
0
ファイル: keyinput.cpp プロジェクト: sakazuki/actiona
	QString KeyInput::toTranslatedText() const
	{
		if(mIsQtKey)
		{
			QKeySequence keySequence(mKey);

			return keySequence.toString(QKeySequence::NativeText);
		}

		return mKeyNames.second[mKey];
	}
コード例 #15
0
void Hotkey::saveSettings(QSettings& settings) const
{
	keySequence().saveSettings(settings);

	settings.beginWriteArray("actions");
	for (int i = 0; i < actions().size(); i++)
	{
		settings.setArrayIndex(i);
		actions()[i].saveSettings(settings);
	}
	settings.endArray();
}
コード例 #16
0
ファイル: pKeySequenceEdit.cpp プロジェクト: pasnox/fresh
void pKeySequenceEdit::keyPressEvent( QKeyEvent* event )
{   
    // return if auto repeat
    if ( event->isAutoRepeat() ) {
        return;
    }
    
    // if user press something, sequence is not finished
    mFinished = false;
    
    // show current sequence
    setText( keySequence( event ) );
}
コード例 #17
0
ファイル: pKeySequenceEdit.cpp プロジェクト: pasnox/fresh
void pKeySequenceEdit::keyReleaseEvent( QKeyEvent* event )
{
    // return if auto repeat
    if ( event->isAutoRepeat() ) {
        return;
    }
    
    // check if sequence is finished or not
    if ( mFinished ) {
        return;
    }
    
    // show current sequence
    setText( keySequence( event ) );
}
コード例 #18
0
void Hotkey::loadSettings(QSettings& settings)
{
	keySequence().loadSettings(settings);

	actions().clear();
	int num = settings.beginReadArray("actions");
	for (int i = 0; i < num; i++)
	{
		settings.setArrayIndex(i);
		Action a;
		a.loadSettings(settings);
		actions().append(a);
	}

	settings.endArray();
}
コード例 #19
0
void MenuCallback::addCommand(QString commandId,
                              QString label,
                              QString tooltip,
                              QString shortcut)
{
   shortcut = shortcut.replace("Enter", "\n");

   QKeySequence keySequence(shortcut);

   QAction* pAction = menuStack_.top()->addAction(QIcon(),
                                                  label,
                                                  this,
                                                  SLOT(actionInvoked()),
                                                  keySequence);
   pAction->setData(commandId);
   pAction->setToolTip(tooltip);

   menuActions_[menuStack_.first()].append(pAction);
}
コード例 #20
0
ファイル: Action.cpp プロジェクト: 335/synergy
void Action::saveSettings(QSettings& settings) const
{
	keySequence().saveSettings(settings);
	settings.setValue("type", type());

	settings.beginWriteArray("typeScreenNames");
	for (int i = 0; i < typeScreenNames().size(); i++)
	{
		settings.setArrayIndex(i);
		settings.setValue("typeScreenName", typeScreenNames()[i]);
	}
	settings.endArray();

	settings.setValue("switchScreenName", switchScreenName());
	settings.setValue("switchInDirection", switchDirection());
	settings.setValue("lockCursorToScreen", lockCursorMode());
	settings.setValue("activeOnRelease", activeOnRelease());
	settings.setValue("hasScreens", haveScreens());
}
コード例 #21
0
ファイル: Action.cpp プロジェクト: 335/synergy
void Action::loadSettings(QSettings& settings)
{
	keySequence().loadSettings(settings);
	setType(settings.value("type", keyDown).toInt());

	typeScreenNames().clear();
	int numTypeScreens = settings.beginReadArray("typeScreenNames");
	for (int i = 0; i < numTypeScreens; i++)
	{
		settings.setArrayIndex(i);
		typeScreenNames().append(settings.value("typeScreenName").toString());
	}
	settings.endArray();

	setSwitchScreenName(settings.value("switchScreenName").toString());
	setSwitchDirection(settings.value("switchInDirection", switchLeft).toInt());
	setLockCursorMode(settings.value("lockCursorToScreen", lockCursorToggle).toInt());
	setActiveOnRelease(settings.value("activeOnRelease", false).toBool());
	setHaveScreens(settings.value("hasScreens", false).toBool());
}
コード例 #22
0
void ShortcutViewer::keyPressEvent(QKeyEvent *event)
{
	int key = event->key();
	if (key == Qt::Key_Control || key == Qt::Key_Shift || key == Qt::Key_Alt) {
		event->ignore();
		return;
	}
	Qt::KeyboardModifiers modifiers = event->modifiers();

	// Tasti che non possono essere utilizzati come shortcut
	if ((modifiers | (Qt::CTRL | Qt::SHIFT | Qt::ALT)) != (Qt::CTRL | Qt::SHIFT | Qt::ALT) || key == Qt::Key_Home || key == Qt::Key_End || key == Qt::Key_PageDown || key == Qt::Key_PageUp || key == Qt::Key_Escape || key == Qt::Key_Print || key == Qt::Key_Pause || key == Qt::Key_ScrollLock) {
		if (key != Qt::Key_Plus && key != Qt::Key_Minus && key != Qt::Key_Asterisk && key != Qt::Key_Slash) {
			event->ignore();
			return;
		} else
			modifiers = 0;
	}

	if (m_action) {
		CommandManager *cm = CommandManager::instance();
		QKeySequence keySequence(key + modifiers);
		std::string shortcutString = keySequence.toString().toStdString();
		QAction *oldAction = cm->getActionFromShortcut(keySequence.toString().toStdString());
		if (oldAction == m_action)
			return;
		if (oldAction) {
			QString msg = tr("%1 is already assigned to '%2'\nAssign to '%3'?").arg(keySequence.toString()).arg(oldAction->iconText()).arg(m_action->iconText());
			int ret = DVGui::MsgBox(msg, tr("Yes"), tr("No"), 1);
			activateWindow();
			if (ret == 2 || ret == 0)
				return;
		}
		CommandManager::instance()->setShortcut(m_action, shortcutString);
		emit shortcutChanged();
	}
	event->accept();
	update();
}
コード例 #23
0
ファイル: toolbox.cpp プロジェクト: chchwy/pencil2d
// ----------------------------------------------------------------------------------
QString GetToolTips(QString strCommandName)
{
    strCommandName = QString("shortcuts/") + strCommandName;
    QKeySequence keySequence(pencilSettings().value(strCommandName).toString());
    return QString("<b>%1</b>").arg(keySequence.toString()); // don't tr() this string.
}
コード例 #24
0
ファイル: mainwindow2.cpp プロジェクト: Forkhere/pencil
void MainWindow2::setupKeyboardShortcuts()
{
    checkExistingShortcuts();

    auto cmdKeySeq = []( QString strCommandName ) -> QKeySequence
    {
        strCommandName = QString( "shortcuts/" ) + strCommandName;
        QKeySequence keySequence( pencilSettings()->value( strCommandName ).toString() );
        return keySequence;
    };

    ui->actionNew->setShortcut( cmdKeySeq( CMD_NEW_FILE ) );
    ui->actionOpen->setShortcut( cmdKeySeq( CMD_OPEN_FILE ) );
    ui->actionSave->setShortcut( cmdKeySeq( CMD_SAVE_FILE ) );
    ui->actionSave_as->setShortcut( cmdKeySeq( CMD_SAVE_AS ) );
    ui->actionPrint->setShortcut( cmdKeySeq( CMD_PRINT ) );

    ui->actionImport_Image->setShortcut( cmdKeySeq( CMD_IMPORT_IMAGE ) );
    ui->actionImport_Image_Sequence->setShortcut( cmdKeySeq( CMD_IMPORT_IMAGE_SEQ ) );
    ui->actionImport_Movie->setShortcut( cmdKeySeq( CMD_IMPORT_MOVIE ) );
    ui->actionImport_Palette->setShortcut( cmdKeySeq( CMD_IMPORT_PALETTE ) );
    ui->actionImport_Sound->setShortcut( cmdKeySeq( CMD_IMPORT_SOUND ) );

    ui->actionExport_Image->setShortcut( cmdKeySeq( CMD_EXPORT_IMAGE ) );
    ui->actionExport_Image_Sequence->setShortcut( cmdKeySeq( CMD_EXPORT_IMAGE_SEQ ) );
    ui->actionExport_Movie->setShortcut( cmdKeySeq( CMD_EXPORT_MOVIE ) );
    ui->actionExport_Palette->setShortcut( cmdKeySeq( CMD_EXPORT_PALETTE ) );
    ui->actionExport_Svg_Image->setShortcut( cmdKeySeq( CMD_EXPORT_SVG ) );
    ui->actionExport_X_sheet->setShortcut( cmdKeySeq( CMD_EXPORT_XSHEET ) );

    // edit menu
    ui->actionUndo->setShortcut( cmdKeySeq( CMD_UNDO ) );
    ui->actionRedo->setShortcut( cmdKeySeq( CMD_REDO ) );
    ui->actionCut->setShortcut( cmdKeySeq( CMD_CUT ) );
    ui->actionCopy->setShortcut( cmdKeySeq( CMD_COPY ) );
    ui->actionPaste->setShortcut( cmdKeySeq( CMD_PASTE ) );
    ui->actionClearFrame->setShortcut( cmdKeySeq( CMD_CLEAR_FRAME ) );
    ui->actionSelect_All->setShortcut( cmdKeySeq( CMD_SELECT_ALL ) );
    ui->actionDeselect_All->setShortcut( cmdKeySeq( CMD_DESELECT_ALL ) );
    ui->actionPreference->setShortcut( cmdKeySeq( CMD_PREFERENCE ) );

    ui->actionReset_Windows->setShortcut( cmdKeySeq( CMD_RESET_WINDOWS ) );
    ui->actionReset_View->setShortcut( cmdKeySeq( CMD_RESET_ZOOM_ROTATE ) );
    ui->actionZoom_In->setShortcut( cmdKeySeq( CMD_ZOOM_IN ) );
    ui->actionZoom_Out->setShortcut( cmdKeySeq( CMD_ZOOM_OUT ) );
    ui->actionRotate_Clockwise->setShortcut( cmdKeySeq( CMD_ROTATE_CLOCK ) );
    ui->actionRotate_Anticlosewise->setShortcut( cmdKeySeq( CMD_ROTATE_ANTI_CLOCK ) );
    ui->actionHorizontal_Flip->setShortcut( cmdKeySeq( CMD_FLIP_HORIZONTAL ) );
    ui->actionVertical_Flip->setShortcut( cmdKeySeq( CMD_FLIP_VERTICAL ) );
    ui->actionPreview->setShortcut( cmdKeySeq( CMD_PREVIEW ) );
    ui->actionGrid->setShortcut( cmdKeySeq( CMD_GRID ) );
    ui->actionOnionPrevious->setShortcut( cmdKeySeq( CMD_ONIONSKIN_PREV ) );
    ui->actionOnionNext->setShortcut( cmdKeySeq( CMD_ONIONSKIN_NEXT ) );

    ui->actionPlay->setShortcut( cmdKeySeq( CMD_PLAY ) );
    ui->actionLoop->setShortcut( cmdKeySeq( CMD_LOOP ) );
    ui->actionPrevious_Frame->setShortcut( cmdKeySeq( CMD_GOTO_PREV_FRAME ) );
    ui->actionNext_Frame->setShortcut( cmdKeySeq( CMD_GOTO_NEXT_FRAME ) );
    ui->actionPrev_KeyFrame->setShortcut( cmdKeySeq( CMD_GOTO_PREV_KEY_FRAME ) );
    ui->actionNext_KeyFrame->setShortcut( cmdKeySeq( CMD_GOTO_NEXT_KEY_FRAME ) );
    ui->actionAdd_Frame->setShortcut( cmdKeySeq( CMD_ADD_FRAME ) );
    ui->actionDuplicate_Frame->setShortcut( cmdKeySeq( CMD_DUPLICATE_FRAME ) );
    ui->actionRemove_Frame->setShortcut( cmdKeySeq( CMD_REMOVE_FRAME ) );
    ui->actionMove_Frame_Backward->setShortcut( cmdKeySeq( CMD_MOVE_FRAME_BACKWARD ) );
    ui->actionMove_Frame_Forward->setShortcut( cmdKeySeq( CMD_MOVE_FRAME_FORWARD ) );

    ShortcutFilter* shortcutfilter = new ShortcutFilter( mScribbleArea );
    ui->actionMove->setShortcut( cmdKeySeq( CMD_TOOL_MOVE ) );
    ui->actionSelect->setShortcut( cmdKeySeq( CMD_TOOL_SELECT ) );
    ui->actionBrush->setShortcut( cmdKeySeq( CMD_TOOL_BRUSH ) );
    ui->actionPolyline->setShortcut( cmdKeySeq( CMD_TOOL_POLYLINE ) );
    ui->actionSmudge->setShortcut( cmdKeySeq( CMD_TOOL_SMUDGE ) );
    ui->actionPen->setShortcut( cmdKeySeq( CMD_TOOL_PEN ) );
    ui->actionHand->setShortcut( cmdKeySeq( CMD_TOOL_HAND ) );
    ui->actionPencil->setShortcut( cmdKeySeq( CMD_TOOL_PENCIL ) );
    ui->actionBucket->setShortcut( cmdKeySeq( CMD_TOOL_BUCKET ) );
    ui->actionEyedropper->setShortcut( cmdKeySeq( CMD_TOOL_EYEDROPPER ) );
    ui->actionEraser->setShortcut( cmdKeySeq( CMD_TOOL_ERASER ) );

    ui->actionMove->installEventFilter( shortcutfilter );
    ui->actionMove->installEventFilter( shortcutfilter );
    ui->actionSelect->installEventFilter( shortcutfilter );
    ui->actionBrush->installEventFilter( shortcutfilter );
    ui->actionPolyline->installEventFilter( shortcutfilter );
    ui->actionSmudge->installEventFilter( shortcutfilter );
    ui->actionPen->installEventFilter( shortcutfilter );
    ui->actionHand->installEventFilter( shortcutfilter );
    ui->actionPencil->installEventFilter( shortcutfilter );
    ui->actionBucket->installEventFilter( shortcutfilter );
    ui->actionEyedropper->installEventFilter( shortcutfilter );
    ui->actionEraser->installEventFilter( shortcutfilter );

    ui->actionTogglePalette->setShortcut( cmdKeySeq( CMD_TOGGLE_PALETTE ) );
    //mScribbleArea->getPopupPalette()->closeButton->setText( tr("close/toggle (") + pencilSettings()->value( QString( "shortcuts/" ) + CMD_TOGGLE_PALETTE ).toString() + ")" );
    //mScribbleArea->getPopupPalette()->closeButton->setShortcut( cmdKeySeq( CMD_TOGGLE_PALETTE ) );

    ui->actionNew_Bitmap_Layer->setShortcut( cmdKeySeq( CMD_NEW_BITMAP_LAYER ) );
    ui->actionNew_Vector_Layer->setShortcut( cmdKeySeq( CMD_NEW_VECTOR_LAYER ) );
    ui->actionNew_Camera_Layer->setShortcut( cmdKeySeq( CMD_NEW_CAMERA_LAYER ) );
    ui->actionNew_Sound_Layer->setShortcut( cmdKeySeq( CMD_NEW_SOUND_LAYER ) );

    mToolBox->toggleViewAction()->setShortcut( cmdKeySeq( CMD_TOGGLE_TOOLBOX ) );
    mToolOptions->toggleViewAction()->setShortcut( cmdKeySeq( CMD_TOGGLE_TOOL_OPTIONS ) );
    mColorWheel->toggleViewAction()->setShortcut( cmdKeySeq( CMD_TOGGLE_COLOR_WHEEL ) );
    mColorPalette->toggleViewAction()->setShortcut( cmdKeySeq( CMD_TOGGLE_COLOR_LIBRARY ) );
    mTimeLine->toggleViewAction()->setShortcut( cmdKeySeq( CMD_TOGGLE_TIMELINE ) );
    mDisplayOptionWidget->toggleViewAction()->setShortcut( cmdKeySeq( CMD_TOGGLE_DISPLAY_OPTIONS ) );

    ui->actionHelp->setShortcut( cmdKeySeq( CMD_HELP ) );
}
コード例 #25
0
int QKeySequenceWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 11)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 11;
    }
#ifndef QT_NO_PROPERTIES
    else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            *reinterpret_cast< QKeySequence*>(_v) = keySequence();
            break;
        case 1:
            *reinterpret_cast< QKeySequenceWidget::ClearButtonShow*>(_v) = clearButtonShow();
            break;
        case 2:
            *reinterpret_cast< QString*>(_v) = noneText();
            break;
        case 3:
            *reinterpret_cast< QIcon*>(_v) = clearButtonIcon();
            break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            setKeySequence(*reinterpret_cast< QKeySequence*>(_v));
            break;
        case 1:
            setClearButtonShow(*reinterpret_cast< QKeySequenceWidget::ClearButtonShow*>(_v));
            break;
        case 2:
            setNoneText(*reinterpret_cast< QString*>(_v));
            break;
        case 3:
            setClearButtonIcon(*reinterpret_cast< QIcon*>(_v));
            break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 4;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
コード例 #26
0
ファイル: kshortcutseditoritem.cpp プロジェクト: KDE/kxmlgui
QVariant KShortcutsEditorItem::data(int column, int role) const
{
    switch (role) {
    case Qt::DisplayRole:
        switch (column) {
        case Name:
            return m_actionNameInTable;
        case Id:
            return m_id;
        case LocalPrimary:
        case LocalAlternate:
        case GlobalPrimary:
        case GlobalAlternate:
            return keySequence(column);
#if 0
        case ShapeGesture:
            return KGestureMap::self()->shapeGesture(m_action).shapeName();
        case RockerGesture:
            return KGestureMap::self()->rockerGesture(m_action).rockerName();
#endif
        default:
            break;
        }
        break;
    case Qt::DecorationRole:
        if (column == Name) {
            return m_action->icon();
        } else {
            return QIcon();
        }
    case Qt::WhatsThisRole:
        return m_action->whatsThis();
    case Qt::ToolTipRole:
        // There is no such thing as a QAction::description(). So we have
        // nothing to display here.
        return QVariant();
    case Qt::FontRole:
        if (column == Name && m_isNameBold) {
            QFont modifiedFont = treeWidget()->font();
            modifiedFont.setBold(true);
            return modifiedFont;
        }
        break;
    case KExtendableItemDelegate::ShowExtensionIndicatorRole:
        switch (column) {
        case Name:
            return false;
        case LocalPrimary:
        case LocalAlternate:
            return !m_action->property("isShortcutConfigurable").isValid()
                   || m_action->property("isShortcutConfigurable").toBool();
#if HAVE_GLOBALACCEL
        case GlobalPrimary:
        case GlobalAlternate:
            if (!KGlobalAccel::self()->hasShortcut(m_action)) {
                return false;
            }
            return true;
#endif
        default:
            return false;
        }
    //the following are custom roles, defined in this source file only
    case ShortcutRole:
        switch (column) {
        case LocalPrimary:
        case LocalAlternate:
        case GlobalPrimary:
        case GlobalAlternate:
            return keySequence(column);
#if 0
        case ShapeGesture: { //scoping for "ret"
            QVariant ret;
            ret.setValue(KGestureMap::self()->shapeGesture(m_action));
            return ret;
        }
        case RockerGesture: {
            QVariant ret;
            ret.setValue(KGestureMap::self()->rockerGesture(m_action));
            return ret;
        }
#endif
        default:
            // Column not valid for this role
            Q_ASSERT(false);
            return QVariant();
        }

    case DefaultShortcutRole: {
        QList<QKeySequence> defaultShortcuts = m_action->property("defaultShortcuts").value<QList<QKeySequence> >();
#if HAVE_GLOBALACCEL
        QList<QKeySequence> defaultGlobalShortcuts = KGlobalAccel::self()->defaultShortcut(m_action);
#endif

        switch (column) {
        case LocalPrimary:
            return primarySequence(defaultShortcuts);
        case LocalAlternate:
            return alternateSequence(defaultShortcuts);
#if HAVE_GLOBALACCEL
        case GlobalPrimary:
            return primarySequence(defaultGlobalShortcuts);
        case GlobalAlternate:
            return alternateSequence(defaultGlobalShortcuts);
#endif
#if 0
        case ShapeGesture: {
            QVariant ret;
            ret.setValue(KGestureMap::self()->defaultShapeGesture(m_action));
            return ret;
        }
        case RockerGesture: {
            QVariant ret;
            ret.setValue(KGestureMap::self()->defaultRockerGesture(m_action));
            return ret;
        }
#endif
        default:
            // Column not valid for this role
            Q_ASSERT(false);
            return QVariant();
        }
    }
    case ObjectRole:
        return qVariantFromValue(static_cast<QObject *>(m_action));

    default:
        break;
    }

    return QVariant();
}
コード例 #27
0
ファイル: command.cpp プロジェクト: leppa/qt-creator
QString Action::stringWithAppendedShortcut(const QString &str) const
{
    return Utils::ProxyAction::stringWithAppendedShortcut(str, keySequence());
}
コード例 #28
0
ファイル: parupaintKeys.cpp プロジェクト: parulina/parupaint
QString ParupaintKey::toString() const {
	return keySequence().toString();
}
コード例 #29
-1
QString Hotkey::text() const
{
	QString text = keySequence().toString();

	if (keySequence().isMouseButton())
		return "mousebutton(" + text + ")";

	return "keystroke(" + text + ")";
}