Manual shortcut test: Arrange in QGridLayout
Change-Id: I93264bec8810f4dd1e2c010cc4dd35df93f31102 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
This commit is contained in:
parent
30874fb2df
commit
370cd37cea
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QGridLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
@ -36,14 +37,41 @@
|
|||||||
class ShortcutTester : public QWidget
|
class ShortcutTester : public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ShortcutTester() {
|
ShortcutTester()
|
||||||
|
{
|
||||||
|
const QString title = QLatin1String(QT_VERSION_STR) + QLatin1Char(' ')
|
||||||
|
+ qApp->platformName();
|
||||||
|
setWindowTitle(title);
|
||||||
setupLayout();
|
setupLayout();
|
||||||
}
|
}
|
||||||
protected:
|
|
||||||
void setupLayout()
|
private:
|
||||||
|
void setupLayout();
|
||||||
|
void addToGrid(QWidget *w, int &row, int col);
|
||||||
|
void addShortcutToGrid(const QKeySequence &k, int &row, int col);
|
||||||
|
void addShortcutToGrid(int key, int &row, int col)
|
||||||
|
{ addShortcutToGrid(QKeySequence(key), row, col); }
|
||||||
|
|
||||||
|
QGridLayout *m_gridLayout = new QGridLayout;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void ShortcutTester::addToGrid(QWidget *w, int &row, int col)
|
||||||
|
{
|
||||||
|
m_gridLayout->addWidget(w, row++, col);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShortcutTester::addShortcutToGrid(const QKeySequence &k, int &row, int col)
|
||||||
|
{
|
||||||
|
QPushButton *button = new QPushButton(k.toString());
|
||||||
|
button->setShortcut(k);
|
||||||
|
addToGrid(button, row, col);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addShortcutToGrid(int key, int &row, int col);
|
||||||
|
|
||||||
|
void ShortcutTester::setupLayout()
|
||||||
{
|
{
|
||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
setLayout(layout);
|
|
||||||
|
|
||||||
QLabel *testPurpose = new QLabel();
|
QLabel *testPurpose = new QLabel();
|
||||||
testPurpose->setWordWrap(true);
|
testPurpose->setWordWrap(true);
|
||||||
@ -52,183 +80,79 @@ protected:
|
|||||||
"keyboard layouts - qwerty, dvorak, non-latin (russian, arabic), etc.");
|
"keyboard layouts - qwerty, dvorak, non-latin (russian, arabic), etc.");
|
||||||
layout->addWidget(testPurpose);
|
layout->addWidget(testPurpose);
|
||||||
|
|
||||||
QKeySequence altShiftG(Qt::AltModifier + Qt::ShiftModifier + Qt::Key_G);
|
layout->addLayout(m_gridLayout);
|
||||||
QPushButton *_altShiftG = new QPushButton(altShiftG.toString());
|
|
||||||
_altShiftG->setShortcut(altShiftG);
|
|
||||||
layout->addWidget(_altShiftG);
|
|
||||||
|
|
||||||
QKeySequence altG(Qt::AltModifier + Qt::Key_G);
|
int row = 0;
|
||||||
QPushButton *_altG = new QPushButton(altG.toString());
|
int col = 0;
|
||||||
_altG->setShortcut(altG);
|
|
||||||
layout->addWidget(_altG);
|
|
||||||
|
|
||||||
QKeySequence ctrlShiftR(Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_R);
|
const int keys1[] = {
|
||||||
QPushButton *_ctrlShiftR = new QPushButton(ctrlShiftR.toString());
|
Qt::AltModifier + Qt::ShiftModifier + Qt::Key_G,
|
||||||
_ctrlShiftR->setShortcut(ctrlShiftR);
|
Qt::AltModifier + Qt::Key_G,
|
||||||
layout->addWidget(_ctrlShiftR);
|
Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_R,
|
||||||
|
Qt::ControlModifier + Qt::Key_R,
|
||||||
|
Qt::ControlModifier + Qt::Key_Return, Qt::ControlModifier + Qt::Key_Enter,
|
||||||
|
Qt::ControlModifier + Qt::ShiftModifier + Qt::AltModifier + Qt::Key_R,
|
||||||
|
Qt::ShiftModifier + Qt::Key_5, Qt::ShiftModifier + Qt::Key_Percent,
|
||||||
|
Qt::Key_Percent, Qt::Key_5, Qt::Key_Q
|
||||||
|
};
|
||||||
|
|
||||||
QKeySequence ctrlR(Qt::ControlModifier + Qt::Key_R);
|
for (int k : keys1)
|
||||||
QPushButton *_ctrlR = new QPushButton(ctrlR.toString());
|
addShortcutToGrid(k, row, col);
|
||||||
_ctrlR->setShortcut(ctrlR);
|
|
||||||
layout->addWidget(_ctrlR);
|
|
||||||
|
|
||||||
QKeySequence ctrlReturn(Qt::ControlModifier + Qt::Key_Return);
|
row = 0;
|
||||||
QPushButton *_ctrlReturn = new QPushButton(ctrlReturn.toString());
|
col++;
|
||||||
_ctrlReturn->setShortcut(ctrlReturn);
|
|
||||||
layout->addWidget(_ctrlReturn);
|
|
||||||
|
|
||||||
QKeySequence ctrlEnter(Qt::ControlModifier + Qt::Key_Enter);
|
const int keys2[] = {
|
||||||
QPushButton *_ctrlEnter = new QPushButton(ctrlEnter.toString());
|
Qt::ControlModifier + Qt::Key_Percent,
|
||||||
_ctrlEnter->setShortcut(ctrlEnter);
|
Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_5,
|
||||||
layout->addWidget(_ctrlEnter);
|
Qt::ControlModifier + Qt::Key_5, Qt::AltModifier + Qt::Key_5,
|
||||||
|
Qt::ControlModifier + Qt::Key_Plus,
|
||||||
|
Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Plus,
|
||||||
|
Qt::ControlModifier + Qt::Key_Y, Qt::ShiftModifier + Qt::Key_Comma,
|
||||||
|
Qt::ControlModifier + Qt::Key_Comma, Qt::ControlModifier + Qt::Key_Slash,
|
||||||
|
Qt::ControlModifier + Qt::Key_Backslash
|
||||||
|
};
|
||||||
|
|
||||||
QKeySequence ctrlShiftAltR(Qt::ControlModifier + Qt::ShiftModifier + Qt::AltModifier + Qt::Key_R);
|
for (int k : keys2)
|
||||||
QPushButton *_ctrlShiftAltR = new QPushButton(ctrlShiftAltR.toString());
|
addShortcutToGrid(k, row, col);
|
||||||
_ctrlShiftAltR->setShortcut(ctrlShiftAltR);
|
|
||||||
layout->addWidget(_ctrlShiftAltR);
|
|
||||||
|
|
||||||
QKeySequence shift5(Qt::ShiftModifier + Qt::Key_5);
|
row = 0;
|
||||||
QPushButton *_shift5 = new QPushButton(shift5.toString());
|
col++;
|
||||||
_shift5->setShortcut(shift5);
|
|
||||||
layout->addWidget(_shift5);
|
|
||||||
|
|
||||||
QKeySequence shiftPercent(Qt::ShiftModifier + Qt::Key_Percent);
|
const int keys3[] = {
|
||||||
QPushButton *_shiftPercent = new QPushButton(shiftPercent.toString());
|
Qt::MetaModifier + Qt::ShiftModifier + Qt::Key_A,
|
||||||
_shiftPercent->setShortcut(shiftPercent);
|
Qt::MetaModifier + Qt::ShiftModifier + Qt::Key_5,
|
||||||
layout->addWidget(_shiftPercent);
|
Qt::ControlModifier + Qt::Key_BracketRight,
|
||||||
|
Qt::ShiftModifier + Qt::Key_F3,
|
||||||
|
Qt::ControlModifier + Qt::Key_F3,
|
||||||
|
0x20AC, // EURO SIGN e.g. US (with euro on 5) on 3rd keyboard level
|
||||||
|
Qt::ControlModifier + 0x20AC
|
||||||
|
};
|
||||||
|
|
||||||
QKeySequence percent(Qt::Key_Percent);
|
for (int k : keys3)
|
||||||
QPushButton *_percent = new QPushButton(percent.toString());
|
addShortcutToGrid(k, row, col);
|
||||||
_percent->setShortcut(percent);
|
|
||||||
layout->addWidget(_percent);
|
|
||||||
|
|
||||||
QKeySequence key5(Qt::Key_5);
|
|
||||||
QPushButton *_key5 = new QPushButton(key5.toString());
|
|
||||||
_key5->setShortcut(key5);
|
|
||||||
layout->addWidget(_key5);
|
|
||||||
|
|
||||||
QKeySequence keyQ(Qt::Key_Q);
|
|
||||||
QPushButton *_keyQ = new QPushButton(keyQ.toString());
|
|
||||||
_keyQ->setShortcut(keyQ);
|
|
||||||
layout->addWidget(_keyQ);
|
|
||||||
|
|
||||||
QKeySequence ctrlPercent(Qt::ControlModifier + Qt::Key_Percent);
|
|
||||||
QPushButton *_ctrlPercent = new QPushButton(ctrlPercent.toString());
|
|
||||||
_ctrlPercent->setShortcut(ctrlPercent);
|
|
||||||
layout->addWidget(_ctrlPercent);
|
|
||||||
|
|
||||||
QKeySequence ctrlShift5(Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_5);
|
|
||||||
QPushButton *_ctrlShift5 = new QPushButton(ctrlShift5.toString());
|
|
||||||
_ctrlShift5->setShortcut(ctrlShift5);
|
|
||||||
layout->addWidget(_ctrlShift5);
|
|
||||||
|
|
||||||
QKeySequence ctrl5(Qt::ControlModifier + Qt::Key_5);
|
|
||||||
QPushButton *_ctrl5 = new QPushButton(ctrl5.toString());
|
|
||||||
_ctrl5->setShortcut(ctrl5);
|
|
||||||
layout->addWidget(_ctrl5);
|
|
||||||
|
|
||||||
QKeySequence alt5(Qt::AltModifier + Qt::Key_5);
|
|
||||||
QPushButton *_alt5 = new QPushButton(alt5.toString());
|
|
||||||
_alt5->setShortcut(alt5);
|
|
||||||
layout->addWidget(_alt5);
|
|
||||||
|
|
||||||
QKeySequence ctrlPlus(Qt::ControlModifier + Qt::Key_Plus);
|
|
||||||
QPushButton *_ctrlPlus = new QPushButton(ctrlPlus.toString());
|
|
||||||
_ctrlPlus->setShortcut(ctrlPlus);
|
|
||||||
layout->addWidget(_ctrlPlus);
|
|
||||||
|
|
||||||
QKeySequence ctrlShiftPlus(Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Plus);
|
|
||||||
QPushButton *_ctrlShiftPlus = new QPushButton(ctrlShiftPlus.toString());
|
|
||||||
_ctrlShiftPlus->setShortcut(ctrlShiftPlus);
|
|
||||||
layout->addWidget(_ctrlShiftPlus);
|
|
||||||
|
|
||||||
QKeySequence ctrlY(Qt::ControlModifier + Qt::Key_Y);
|
|
||||||
QPushButton *_ctrlY = new QPushButton(ctrlY.toString());
|
|
||||||
_ctrlY->setShortcut(ctrlY);
|
|
||||||
layout->addWidget(_ctrlY);
|
|
||||||
|
|
||||||
QKeySequence shiftComma(Qt::ShiftModifier + Qt::Key_Comma);
|
|
||||||
QPushButton *_shiftComma = new QPushButton(shiftComma.toString());
|
|
||||||
_shiftComma->setShortcut(shiftComma);
|
|
||||||
layout->addWidget(_shiftComma);
|
|
||||||
|
|
||||||
QKeySequence ctrlComma(Qt::ControlModifier + Qt::Key_Comma);
|
|
||||||
QPushButton *_ctrlComma = new QPushButton(ctrlComma.toString());
|
|
||||||
_ctrlComma->setShortcut(ctrlComma);
|
|
||||||
layout->addWidget(_ctrlComma);
|
|
||||||
|
|
||||||
QKeySequence ctrlSlash(Qt::ControlModifier + Qt::Key_Slash);
|
|
||||||
QPushButton *_ctrlSlash = new QPushButton(ctrlSlash.toString());
|
|
||||||
_ctrlSlash->setShortcut(ctrlSlash);
|
|
||||||
layout->addWidget(_ctrlSlash);
|
|
||||||
|
|
||||||
QKeySequence ctrlBackslash(Qt::ControlModifier + Qt::Key_Backslash);
|
|
||||||
QPushButton *_ctrlBackslash = new QPushButton(ctrlBackslash.toString());
|
|
||||||
_ctrlBackslash->setShortcut(ctrlBackslash);
|
|
||||||
layout->addWidget(_ctrlBackslash);
|
|
||||||
|
|
||||||
QKeySequence metaShiftA(Qt::MetaModifier + Qt::ShiftModifier + Qt::Key_A);
|
|
||||||
QPushButton *_metaShiftA = new QPushButton(metaShiftA.toString());
|
|
||||||
_metaShiftA->setShortcut(metaShiftA);
|
|
||||||
layout->addWidget(_metaShiftA);
|
|
||||||
|
|
||||||
QKeySequence metaShift5(Qt::MetaModifier + Qt::ShiftModifier + Qt::Key_5);
|
|
||||||
QPushButton *_metaShift5 = new QPushButton(metaShift5.toString());
|
|
||||||
_metaShift5->setShortcut(metaShift5);
|
|
||||||
layout->addWidget(_metaShift5);
|
|
||||||
|
|
||||||
QKeySequence ctrlBracketRigth(Qt::ControlModifier + Qt::Key_BracketRight);
|
|
||||||
QPushButton *_ctrlBracketRigth = new QPushButton(ctrlBracketRigth.toString());
|
|
||||||
_ctrlBracketRigth->setShortcut(ctrlBracketRigth);
|
|
||||||
layout->addWidget(_ctrlBracketRigth);
|
|
||||||
|
|
||||||
QKeySequence shiftF3(Qt::ShiftModifier + Qt::Key_F3);
|
|
||||||
QPushButton *_shiftF3 = new QPushButton(shiftF3.toString());
|
|
||||||
_shiftF3->setShortcut(shiftF3);
|
|
||||||
layout->addWidget(_shiftF3);
|
|
||||||
|
|
||||||
QKeySequence ctrlF3(Qt::ControlModifier + Qt::Key_F3);
|
|
||||||
QPushButton *_ctrlF3 = new QPushButton(ctrlF3.toString());
|
|
||||||
_ctrlF3->setShortcut(ctrlF3);
|
|
||||||
layout->addWidget(_ctrlF3);
|
|
||||||
|
|
||||||
QKeySequence euro(0x20AC); // EURO SIGN e.g. US (with euro on 5) on 3rd keyboard level
|
|
||||||
QPushButton *_euro = new QPushButton(euro.toString());
|
|
||||||
_euro->setShortcut(euro);
|
|
||||||
layout->addWidget(_euro);
|
|
||||||
|
|
||||||
QKeySequence ctrlEuro(Qt::ControlModifier + 0x20AC);
|
|
||||||
QPushButton *_ctrlEuro = new QPushButton(ctrlEuro.toString());
|
|
||||||
_ctrlEuro->setShortcut(ctrlEuro);
|
|
||||||
layout->addWidget(_ctrlEuro);
|
|
||||||
|
|
||||||
// with german (neo 2) layout on linux under ISO_Level3_Shift + ISO_Level5_Shift + I
|
// with german (neo 2) layout on linux under ISO_Level3_Shift + ISO_Level5_Shift + I
|
||||||
QKeySequence greekPsi(QString(QStringLiteral("\u03A8")));
|
const QKeySequence greekPsi(QString(QStringLiteral("\u03A8")));
|
||||||
QPushButton *_greekPsi = new QPushButton(greekPsi.toString());
|
addShortcutToGrid(greekPsi, row, col);
|
||||||
_greekPsi->setShortcut(greekPsi);
|
|
||||||
layout->addWidget(_greekPsi);
|
|
||||||
|
|
||||||
layout->addWidget(new QLabel("Norwegian layout"));
|
row = 0;
|
||||||
|
col++;
|
||||||
|
|
||||||
|
addToGrid(new QLabel("Norwegian layout"), row, col);
|
||||||
// LATIN SMALL LETTER O WITH STROKE
|
// LATIN SMALL LETTER O WITH STROKE
|
||||||
QKeySequence norwegianO(QString(QStringLiteral("\u00F8")));
|
QKeySequence norwegianO(QString(QStringLiteral("\u00F8")));
|
||||||
QPushButton *_norwegianO = new QPushButton(norwegianO.toString());
|
addShortcutToGrid(norwegianO, row, col);
|
||||||
_norwegianO->setShortcut(norwegianO);
|
|
||||||
layout->addWidget(_norwegianO);
|
|
||||||
|
|
||||||
layout->addWidget(new QLabel("Russian layout"));
|
addToGrid(new QLabel("Russian layout"), row, col);
|
||||||
// CYRILLIC SMALL LETTER ZHE
|
// CYRILLIC SMALL LETTER ZHE
|
||||||
QKeySequence zhe(QString(QStringLiteral("\u0436")));
|
QKeySequence zhe(QString(QStringLiteral("\u0436")));
|
||||||
QPushButton *_zhe = new QPushButton(zhe.toString());
|
addShortcutToGrid(zhe, row, col);
|
||||||
_zhe->setShortcut(zhe);
|
|
||||||
layout->addWidget(_zhe);
|
|
||||||
|
|
||||||
// for sequence definitons see qplatformtheme.cpp
|
// for sequence definitons see qplatformtheme.cpp
|
||||||
layout->addWidget(new QLabel("QKeySequence::StandardKey(s)"));
|
addToGrid(new QLabel("QKeySequence::StandardKey(s)"), row, col);
|
||||||
QPushButton *_open = new QPushButton("Open");
|
addShortcutToGrid(QKeySequence(QKeySequence::Open), row, col); // Qt::CTRL | Qt::Key_O
|
||||||
_open->setShortcut(QKeySequence::Open); // Qt::CTRL | Qt::Key_O
|
|
||||||
layout->addWidget(_open);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user