added native shortcut support (win)

This commit is contained in:
Skycoder42
2016-12-04 16:49:53 +01:00
parent 5cc4b7bf2d
commit 686abe219a
5 changed files with 347 additions and 41 deletions
+21
View File
@@ -11,6 +11,7 @@ HotTestWidget::HotTestWidget(QWidget *parent) :
hotkey_5(new QHotkey(NULL)),
thread4(new QThread(this)),
thread5(new QThread(this)),
nativeHotkey(new QHotkey(this)),
testHotkeys()
{
ui->setupUi(this);
@@ -91,6 +92,10 @@ HotTestWidget::HotTestWidget(QWidget *parent) :
this->testHotkeys += new QHotkey(Qt::Key_K, Qt::ShiftModifier | Qt::AltModifier, false, this);
connect(this->testHotkeys.last(), &QHotkey::activated,
this->ui->hotkeyShiftAltKCheckBox_2, &QCheckBox::toggle);
//native
connect(this->nativeHotkey, &QHotkey::activated,
this, &HotTestWidget::increase_native);
}
HotTestWidget::~HotTestWidget()
@@ -217,3 +222,19 @@ void HotTestWidget::on_threadEnableCheckBox_clicked()
this->ui->tabWidget->setCurrentIndex(0);
}
void HotTestWidget::on_registeredCheckBox_toggled(bool checked)
{
if(checked) {
this->nativeHotkey->setNativeShortcut({
(quint32)this->ui->nativeKeySpinBox->value(),
(quint32)this->ui->nativeModifiersSpinBox->value()
}, true);
} else
this->nativeHotkey->setRegistered(false);
}
void HotTestWidget::increase_native()
{
this->ui->nativeCount->display(this->ui->nativeCount->intValue() + 1);
}
+5
View File
@@ -39,6 +39,9 @@ private slots:
void on_groupBox_toggled(bool checked);
void on_threadEnableCheckBox_clicked();
void on_registeredCheckBox_toggled(bool checked);
void increase_native();
private:
Ui::HotTestWidget *ui;
@@ -52,6 +55,8 @@ private:
QThread *thread5;
QList<QHotkey*> testHotkeys;
QHotkey *nativeHotkey;
};
#endif // HOTTESTWIDGET_H
+277 -41
View File
@@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="playTab">
<attribute name="title">
@@ -965,6 +965,194 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="nativeTab">
<attribute name="title">
<string>Native Shortcut</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,1">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;QHotkey allows you to set native shortcuts explicitly. These, of course, only work on the platform they were choosen for. All platform use special constants for their key codes and modifiers, which makes it pretty simple to use them from code. If you want to test them out here, google for the tables.&lt;/p&gt;&lt;p&gt;In most cases, you will not need to specify native shortcuts directly. However, as explaind on previos tabs, some shotcuts may not be creatable from Qt's key (e.g. Numblock numbers). In that case, you can set the directly.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; text-decoration: underline;&quot;&gt;Example: Ctrl+A&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Windows:&lt;/span&gt; Key: &lt;span style=&quot; font-style:italic;&quot;&gt;0x41&lt;/span&gt;, Modifier: &lt;span style=&quot; font-style:italic;&quot;&gt;0x02&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;X11:&lt;/span&gt; Key: &lt;span style=&quot; font-style:italic;&quot;&gt;0x1E&lt;/span&gt;, Modifier: &lt;span style=&quot; font-style:italic;&quot;&gt;0x02&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;OsX:&lt;/span&gt; Key: &lt;span style=&quot; font-style:italic;&quot;&gt;0x41&lt;/span&gt;, Modifier: &lt;span style=&quot; font-style:italic;&quot;&gt;0x02&lt;/span&gt;&lt;span style=&quot; text-decoration: underline;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="keyLabel">
<property name="text">
<string>Key:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="nativeKeySpinBox">
<property name="prefix">
<string>0x</string>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="modifiersLabel">
<property name="text">
<string>Modifiers:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="nativeModifiersSpinBox">
<property name="prefix">
<string>0x</string>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="countLabel">
<property name="text">
<string>Count:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLCDNumber" name="nativeCount">
<property name="enabled">
<bool>false</bool>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>85</red>
<green>255</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>85</red>
<green>255</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="registeredLabel">
<property name="text">
<string>Registered:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="registeredCheckBox"/>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@@ -996,12 +1184,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>36</x>
<y>52</y>
<x>31</x>
<y>45</y>
</hint>
<hint type="destinationlabel">
<x>375</x>
<y>62</y>
<x>417</x>
<y>43</y>
</hint>
</hints>
</connection>
@@ -1012,12 +1200,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>44</x>
<y>82</y>
<x>31</x>
<y>74</y>
</hint>
<hint type="destinationlabel">
<x>359</x>
<y>82</y>
<x>417</x>
<y>72</y>
</hint>
</hints>
</connection>
@@ -1028,12 +1216,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>52</x>
<y>113</y>
<x>31</x>
<y>103</y>
</hint>
<hint type="destinationlabel">
<x>375</x>
<y>120</y>
<x>417</x>
<y>101</y>
</hint>
</hints>
</connection>
@@ -1044,12 +1232,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>58</x>
<y>140</y>
<x>31</x>
<y>132</y>
</hint>
<hint type="destinationlabel">
<x>375</x>
<y>149</y>
<x>417</x>
<y>130</y>
</hint>
</hints>
</connection>
@@ -1060,12 +1248,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>28</x>
<y>163</y>
<x>31</x>
<y>161</y>
</hint>
<hint type="destinationlabel">
<x>375</x>
<y>178</y>
<x>417</x>
<y>159</y>
</hint>
</hints>
</connection>
@@ -1076,12 +1264,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>62</x>
<y>50</y>
<x>31</x>
<y>45</y>
</hint>
<hint type="destinationlabel">
<x>127</x>
<y>52</y>
<x>109</x>
<y>43</y>
</hint>
</hints>
</connection>
@@ -1092,12 +1280,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>83</x>
<y>79</y>
<x>31</x>
<y>74</y>
</hint>
<hint type="destinationlabel">
<x>161</x>
<y>81</y>
<x>109</x>
<y>72</y>
</hint>
</hints>
</connection>
@@ -1108,12 +1296,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>75</x>
<y>106</y>
<x>31</x>
<y>103</y>
</hint>
<hint type="destinationlabel">
<x>116</x>
<y>109</y>
<x>109</x>
<y>101</y>
</hint>
</hints>
</connection>
@@ -1124,12 +1312,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>69</x>
<y>135</y>
<x>31</x>
<y>132</y>
</hint>
<hint type="destinationlabel">
<x>117</x>
<y>141</y>
<x>109</x>
<y>130</y>
</hint>
</hints>
</connection>
@@ -1140,12 +1328,60 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>81</x>
<y>168</y>
<x>31</x>
<y>161</y>
</hint>
<hint type="destinationlabel">
<x>145</x>
<y>164</y>
<x>109</x>
<y>159</y>
</hint>
</hints>
</connection>
<connection>
<sender>registeredCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>nativeCount</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>93</x>
<y>326</y>
</hint>
<hint type="destinationlabel">
<x>150</x>
<y>349</y>
</hint>
</hints>
</connection>
<connection>
<sender>registeredCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>nativeModifiersSpinBox</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>108</x>
<y>327</y>
</hint>
<hint type="destinationlabel">
<x>111</x>
<y>305</y>
</hint>
</hints>
</connection>
<connection>
<sender>registeredCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>nativeKeySpinBox</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>183</x>
<y>327</y>
</hint>
<hint type="destinationlabel">
<x>194</x>
<y>279</y>
</hint>
</hints>
</connection>