~adamreichold/qpdfview/trunk

« back to all changes in this revision

Viewing changes to sources/shortcuthandler.cpp

  • Committer: Adam Reichold
  • Date: 2018-05-04 17:49:20 UTC
  • Revision ID: adam.reichold@t-online.de-20180504174920-mqn268i0h46fq311
Add static_resources configuration option to embed translations and online help into binary to facilitate single binary builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <QSettings>
26
26
 
27
27
#include "documentview.h"
28
 
#include "compatibility.h"
29
28
 
30
29
namespace
31
30
{
175
174
{
176
175
    if(role == Qt::EditRole && index.column() == 1 && index.row() >= 0 && index.row() < m_actions.count())
177
176
    {
178
 
        const QList< QKeySequence > shortcuts = toShortcuts(value.toString().split(';', SplitBehaviorValues::SkipEmptyParts));
 
177
        QList< QKeySequence > shortcuts = toShortcuts(value.toString().split(";", QString::SkipEmptyParts));
179
178
 
180
179
        if(!shortcuts.isEmpty() || value.toString().isEmpty())
181
180
        {
190
189
    return false;
191
190
}
192
191
 
193
 
QKeySequence ShortcutHandler::defaultZoomIn()
194
 
{
195
 
#ifdef Q_OS_MAC
196
 
    return QKeySequence(Qt::CTRL | Qt::Key_Plus);
197
 
#else
198
 
    return QKeySequence(Qt::CTRL | Qt::Key_Up);
199
 
#endif
200
 
}
201
 
 
202
 
QKeySequence ShortcutHandler::defaultZoomOut()
203
 
{
204
 
#ifdef Q_OS_MAC
205
 
    return QKeySequence(Qt::CTRL | Qt::Key_Minus);
206
 
#else
207
 
    return QKeySequence(Qt::CTRL | Qt::Key_Down);
208
 
#endif
209
 
}
210
 
 
211
 
QKeySequence ShortcutHandler::defaultRotateLeft()
212
 
{
213
 
#ifdef Q_OS_MAC
214
 
    return QKeySequence(Qt::ALT | Qt::Key_Left);
215
 
#else
216
 
    return QKeySequence(Qt::CTRL | Qt::Key_Left);
217
 
#endif
218
 
}
219
 
 
220
 
QKeySequence ShortcutHandler::defaultRotateRight()
221
 
{
222
 
#ifdef Q_OS_MAC
223
 
    return QKeySequence(Qt::ALT | Qt::Key_Right);
224
 
#else
225
 
    return QKeySequence(Qt::CTRL | Qt::Key_Right);
226
 
#endif
227
 
}
228
 
 
229
 
QKeySequence ShortcutHandler::defaultPreviousPage()
230
 
{
231
 
#ifdef Q_OS_MAC
232
 
    return QKeySequence(Qt::ALT | Qt::Key_Up);
233
 
#else
234
 
    return QKeySequence(Qt::Key_Backspace);
235
 
#endif
236
 
}
237
 
 
238
 
QKeySequence ShortcutHandler::defaultNextPage()
239
 
{
240
 
#ifdef Q_OS_MAC
241
 
    return QKeySequence(Qt::ALT | Qt::Key_Down);
242
 
#else
243
 
    return QKeySequence(Qt::Key_Space);
244
 
#endif
245
 
}
246
 
 
247
 
QKeySequence ShortcutHandler::defaultJumpToPage()
248
 
{
249
 
#ifdef Q_OS_MAC
250
 
    return QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_G);
251
 
#else
252
 
    return QKeySequence(Qt::CTRL | Qt::Key_J);
253
 
#endif
254
 
}
255
 
 
256
 
QKeySequence ShortcutHandler::defaultFullscreen()
257
 
{
258
 
#ifdef Q_OS_MAC
259
 
    return QKeySequence(Qt::CTRL | Qt::META | Qt::Key_F);
260
 
#else
261
 
    return QKeySequence(Qt::Key_F11);
262
 
#endif
263
 
}
264
 
 
265
 
QKeySequence ShortcutHandler::defaultPresentation()
266
 
{
267
 
#ifdef Q_OS_MAC
268
 
    return QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_F);
269
 
#else
270
 
    return QKeySequence(Qt::Key_F12);
271
 
#endif
272
 
}
273
 
 
274
 
QKeySequence ShortcutHandler::defaultPreviousTab()
275
 
{
276
 
#ifdef Q_OS_MAC
277
 
    return QKeySequence(Qt::META | Qt::SHIFT | Qt::Key_Tab);
278
 
#else
279
 
    return QKeySequence::PreviousChild;
280
 
#endif
281
 
}
282
 
 
283
 
QKeySequence ShortcutHandler::defaultNextTab()
284
 
{
285
 
#ifdef Q_OS_MAC
286
 
    return QKeySequence(Qt::META | Qt::Key_Tab);
287
 
#else
288
 
    return QKeySequence::NextChild;
289
 
#endif
290
 
}
291
 
 
292
192
bool ShortcutHandler::matchesSkipBackward(const QKeySequence& keySequence) const
293
193
{
294
194
    return matches(keySequence, m_skipBackwardAction->shortcuts());
360
260
{
361
261
    m_skipBackwardAction = createAction(
362
262
                tr("Skip backward"), QLatin1String("skipBackward"),
363
 
                QList< QKeySequence >() << QKeySequence(Qt::Key_PageUp) << QKeySequence(Qt::KeypadModifier | Qt::Key_PageUp));
 
263
                QList< QKeySequence >() << QKeySequence(Qt::Key_PageUp) << QKeySequence(Qt::KeypadModifier + Qt::Key_PageUp));
364
264
 
365
265
    m_skipForwardAction = createAction(
366
266
                tr("Skip forward"), QLatin1String("skipForward"),
367
 
                QList< QKeySequence >() << QKeySequence(Qt::Key_PageDown) << QKeySequence(Qt::KeypadModifier | Qt::Key_PageDown));
 
267
                QList< QKeySequence >() << QKeySequence(Qt::Key_PageDown) << QKeySequence(Qt::KeypadModifier + Qt::Key_PageDown));
368
268
 
369
269
    m_moveUpAction = createAction(
370
270
                tr("Move up"), QLatin1String("moveUp"),
371
 
                QList< QKeySequence >() << QKeySequence(Qt::Key_Up) << QKeySequence(Qt::KeypadModifier | Qt::Key_Up));
 
271
                QList< QKeySequence >() << QKeySequence(Qt::Key_Up) << QKeySequence(Qt::KeypadModifier + Qt::Key_Up));
372
272
 
373
273
    m_moveDownAction = createAction(
374
274
                tr("Move down"), QLatin1String("moveDown"),
375
 
                QList< QKeySequence >() << QKeySequence(Qt::Key_Down) << QKeySequence(Qt::KeypadModifier | Qt::Key_Down));
 
275
                QList< QKeySequence >() << QKeySequence(Qt::Key_Down) << QKeySequence(Qt::KeypadModifier + Qt::Key_Down));
376
276
 
377
277
    m_moveLeftAction = createAction(
378
278
                tr("Move left"), QLatin1String("moveLeft"),
379
 
                QList< QKeySequence >() << QKeySequence(Qt::Key_Left) << QKeySequence(Qt::KeypadModifier | Qt::Key_Left));
 
279
                QList< QKeySequence >() << QKeySequence(Qt::Key_Left) << QKeySequence(Qt::KeypadModifier + Qt::Key_Left));
380
280
 
381
281
    m_moveRightAction = createAction(
382
282
                tr("Move right"), QLatin1String("moveRight"),
383
 
                QList< QKeySequence >() << QKeySequence(Qt::Key_Right) << QKeySequence(Qt::KeypadModifier | Qt::Key_Right));
 
283
                QList< QKeySequence >() << QKeySequence(Qt::Key_Right) << QKeySequence(Qt::KeypadModifier + Qt::Key_Right));
384
284
}
385
285
 
386
286
QAction* ShortcutHandler::createAction(const QString& text, const QString& objectName, const QList<QKeySequence>& shortcuts)