Skip to content

Commit 619f86b

Browse files
authored
Merge pull request #794 from deXol/developBLEAddNewDeviceSettings
[BLE] Add Bluetooth Shortcuts and Screensaver settings
2 parents dcf6cca + 8c57449 commit 619f86b

9 files changed

Lines changed: 130 additions & 55 deletions

src/MainWindow.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ MainWindow::MainWindow(WSClient *client, DbMasterController *mc, QWidget *parent
319319
ui->comboBoxInformationTimeDelay->addItem(tr("4 seconds"), 40);
320320
ui->comboBoxInformationTimeDelay->addItem(tr("5 seconds"), 50);
321321

322+
ui->comboBoxScreensaverId->addItem(tr("None"), 0);
323+
ui->comboBoxScreensaverId->addItem(tr("Nyancat"), 1);
324+
322325
// Close behavior
323326
#ifdef Q_OS_MAC
324327
ui->closeBehaviorComboBox->addItem(

src/MainWindow.ui

Lines changed: 106 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,11 +1297,20 @@ Hint: keep your mouse positioned over an option to get more details.</string>
12971297
</widget>
12981298
</item>
12991299
<item>
1300-
<widget class="QWidget" name="settings_miscellaneous_brightness" native="true">
1300+
<widget class="QWidget" name="knockSettingsWidget" native="true">
1301+
<property name="sizePolicy">
1302+
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
1303+
<horstretch>0</horstretch>
1304+
<verstretch>0</verstretch>
1305+
</sizepolicy>
1306+
</property>
13011307
<property name="toolTip">
1302-
<string>Mooltipass screen brightness</string>
1308+
<string>Enable the knock to approve feature</string>
13031309
</property>
1304-
<layout class="QHBoxLayout" name="horizontalLayout_24">
1310+
<layout class="QHBoxLayout" name="knockSettingsLayout">
1311+
<property name="spacing">
1312+
<number>6</number>
1313+
</property>
13051314
<property name="leftMargin">
13061315
<number>0</number>
13071316
</property>
@@ -1315,24 +1324,42 @@ Hint: keep your mouse positioned over an option to get more details.</string>
13151324
<number>0</number>
13161325
</property>
13171326
<item>
1318-
<widget class="QLabel" name="label_3">
1327+
<widget class="QCheckBox" name="checkBoxKnock">
13191328
<property name="text">
1320-
<string>Screen Brightness</string>
1329+
<string/>
13211330
</property>
13221331
</widget>
13231332
</item>
13241333
<item>
1325-
<widget class="QComboBox" name="comboBoxScreenBrightness">
1326-
<property name="sizePolicy">
1327-
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
1328-
<horstretch>0</horstretch>
1329-
<verstretch>0</verstretch>
1330-
</sizepolicy>
1334+
<widget class="QLabel" name="label_KnockEnable">
1335+
<property name="text">
1336+
<string>Enable knock detection with</string>
13311337
</property>
13321338
</widget>
13331339
</item>
13341340
<item>
1335-
<spacer name="horizontalSpacer_28">
1341+
<widget class="QLabel" name="label_KnockSensitivity">
1342+
<property name="text">
1343+
<string>Knock Detection Sensitivity</string>
1344+
</property>
1345+
</widget>
1346+
</item>
1347+
<item>
1348+
<widget class="QComboBox" name="comboBoxKnock">
1349+
<property name="toolTip">
1350+
<string>How sensitive to vibration your device should be</string>
1351+
</property>
1352+
</widget>
1353+
</item>
1354+
<item>
1355+
<widget class="QLabel" name="knockSettingsSuffixLabel">
1356+
<property name="text">
1357+
<string>sensitivity</string>
1358+
</property>
1359+
</widget>
1360+
</item>
1361+
<item>
1362+
<spacer name="horizontalSpacer_26">
13361363
<property name="orientation">
13371364
<enum>Qt::Horizontal</enum>
13381365
</property>
@@ -1344,6 +1371,16 @@ Hint: keep your mouse positioned over an option to get more details.</string>
13441371
</property>
13451372
</spacer>
13461373
</item>
1374+
<item>
1375+
<widget class="QLabel" name="labelRemoveCard">
1376+
<property name="text">
1377+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic; color:#ac0000;&quot;&gt;(remove the card to change that setting)&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1378+
</property>
1379+
<property name="alignment">
1380+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
1381+
</property>
1382+
</widget>
1383+
</item>
13471384
</layout>
13481385
</widget>
13491386
</item>
@@ -1395,20 +1432,11 @@ Hint: keep your mouse positioned over an option to get more details.</string>
13951432
</widget>
13961433
</item>
13971434
<item>
1398-
<widget class="QWidget" name="knockSettingsWidget" native="true">
1399-
<property name="sizePolicy">
1400-
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
1401-
<horstretch>0</horstretch>
1402-
<verstretch>0</verstretch>
1403-
</sizepolicy>
1404-
</property>
1435+
<widget class="QWidget" name="settings_screen_saver_id" native="true">
14051436
<property name="toolTip">
1406-
<string>Enable the knock to approve feature</string>
1437+
<string>Screen saver displayed when device is idle, connected to USB</string>
14071438
</property>
1408-
<layout class="QHBoxLayout" name="knockSettingsLayout">
1409-
<property name="spacing">
1410-
<number>6</number>
1411-
</property>
1439+
<layout class="QHBoxLayout" name="horizontalLayout_62">
14121440
<property name="leftMargin">
14131441
<number>0</number>
14141442
</property>
@@ -1422,42 +1450,68 @@ Hint: keep your mouse positioned over an option to get more details.</string>
14221450
<number>0</number>
14231451
</property>
14241452
<item>
1425-
<widget class="QCheckBox" name="checkBoxKnock">
1453+
<widget class="QLabel" name="label_ScreensaverId">
14261454
<property name="text">
1427-
<string/>
1455+
<string>Screensaver</string>
14281456
</property>
14291457
</widget>
14301458
</item>
14311459
<item>
1432-
<widget class="QLabel" name="label_KnockEnable">
1433-
<property name="text">
1434-
<string>Enable knock detection with</string>
1435-
</property>
1436-
</widget>
1460+
<widget class="QComboBox" name="comboBoxScreensaverId"/>
14371461
</item>
14381462
<item>
1439-
<widget class="QLabel" name="label_KnockSensitivity">
1440-
<property name="text">
1441-
<string>Knock Detection Sensitivity</string>
1463+
<spacer name="horizontalSpacer_56">
1464+
<property name="orientation">
1465+
<enum>Qt::Horizontal</enum>
14421466
</property>
1443-
</widget>
1467+
<property name="sizeHint" stdset="0">
1468+
<size>
1469+
<width>40</width>
1470+
<height>20</height>
1471+
</size>
1472+
</property>
1473+
</spacer>
14441474
</item>
1475+
</layout>
1476+
</widget>
1477+
</item>
1478+
<item>
1479+
<widget class="QWidget" name="settings_miscellaneous_brightness" native="true">
1480+
<property name="toolTip">
1481+
<string>Mooltipass screen brightness</string>
1482+
</property>
1483+
<layout class="QHBoxLayout" name="horizontalLayout_24">
1484+
<property name="leftMargin">
1485+
<number>0</number>
1486+
</property>
1487+
<property name="topMargin">
1488+
<number>0</number>
1489+
</property>
1490+
<property name="rightMargin">
1491+
<number>0</number>
1492+
</property>
1493+
<property name="bottomMargin">
1494+
<number>0</number>
1495+
</property>
14451496
<item>
1446-
<widget class="QComboBox" name="comboBoxKnock">
1447-
<property name="toolTip">
1448-
<string>How sensitive to vibration your device should be</string>
1497+
<widget class="QLabel" name="label_3">
1498+
<property name="text">
1499+
<string>Screen Brightness</string>
14491500
</property>
14501501
</widget>
14511502
</item>
14521503
<item>
1453-
<widget class="QLabel" name="knockSettingsSuffixLabel">
1454-
<property name="text">
1455-
<string>sensitivity</string>
1504+
<widget class="QComboBox" name="comboBoxScreenBrightness">
1505+
<property name="sizePolicy">
1506+
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
1507+
<horstretch>0</horstretch>
1508+
<verstretch>0</verstretch>
1509+
</sizepolicy>
14561510
</property>
14571511
</widget>
14581512
</item>
14591513
<item>
1460-
<spacer name="horizontalSpacer_26">
1514+
<spacer name="horizontalSpacer_28">
14611515
<property name="orientation">
14621516
<enum>Qt::Horizontal</enum>
14631517
</property>
@@ -1469,16 +1523,6 @@ Hint: keep your mouse positioned over an option to get more details.</string>
14691523
</property>
14701524
</spacer>
14711525
</item>
1472-
<item>
1473-
<widget class="QLabel" name="labelRemoveCard">
1474-
<property name="text">
1475-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic; color:#ac0000;&quot;&gt;(remove the card to change that setting)&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1476-
</property>
1477-
<property name="alignment">
1478-
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
1479-
</property>
1480-
</widget>
1481-
</item>
14821526
</layout>
14831527
</widget>
14841528
</item>
@@ -1562,6 +1606,16 @@ Hint: keep your mouse positioned over an option to get more details.</string>
15621606
</property>
15631607
</widget>
15641608
</item>
1609+
<item>
1610+
<widget class="QCheckBox" name="checkBoxBTShortcuts">
1611+
<property name="toolTip">
1612+
<string>Scroll wheel shortcuts for bluetooth actions</string>
1613+
</property>
1614+
<property name="text">
1615+
<string>Bluetooth Shortcuts</string>
1616+
</property>
1617+
</widget>
1618+
</item>
15651619
</layout>
15661620
</widget>
15671621
</item>

src/Mooltipass/MPSettingsBLE.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ void MPSettingsBLE::loadParameters()
4545
set_switch_off_after_usb_disc(m_lastDeviceSettings.at(DeviceSettingsBLE::SWITCH_OFF_AFTER_USB_DISC) != 0);
4646
set_hash_display(m_lastDeviceSettings.at(DeviceSettingsBLE::HASH_DISPLAY_BYTE) != 0);
4747
set_information_time_delay(m_lastDeviceSettings.at(DeviceSettingsBLE::INFORMATION_TIME_DELAY_BYTE));
48+
set_bluetooth_shortcuts(m_lastDeviceSettings.at(DeviceSettingsBLE::BLUETOOTH_SHORTCUTS_BYTE) != 0);
49+
set_screen_saver_id(m_lastDeviceSettings.at(DeviceSettingsBLE::SCREEN_SAVER_ID_BYTE));
4850
return true;
4951
}
5052
));

src/MooltipassCmds.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ class MPParams: public QObject
235235
DISABLE_BLE_ON_LOCK,
236236
NB_20MINS_TICKS_FOR_LOCK,
237237
SWITCH_OFF_AFTER_USB_DISC,
238-
INFORMATION_TIME_DELAY
238+
INFORMATION_TIME_DELAY,
239+
BLUETOOTH_SHORTCUTS,
240+
SCREEN_SAVER_ID
239241
};
240242
Q_ENUM(Param)
241243
};

src/Settings/DeviceSettingsBLE.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,9 @@ void DeviceSettingsBLE::fillParameterMapping()
4343
m_bleByteMapping[MPParams::HASH_DISPLAY_FEATURE_PARAM] = HASH_DISPLAY_BYTE;
4444
m_paramMap.insert(MPParams::INFORMATION_TIME_DELAY, "information_time_delay");
4545
m_bleByteMapping[MPParams::INFORMATION_TIME_DELAY] = INFORMATION_TIME_DELAY_BYTE;
46+
m_paramMap.insert(MPParams::BLUETOOTH_SHORTCUTS, "bluetooth_shortcuts");
47+
m_bleByteMapping[MPParams::BLUETOOTH_SHORTCUTS] = BLUETOOTH_SHORTCUTS_BYTE;
48+
m_paramMap.insert(MPParams::SCREEN_SAVER_ID, "screen_saver_id");
49+
m_bleByteMapping[MPParams::SCREEN_SAVER_ID] = SCREEN_SAVER_ID_BYTE;
4650
}
4751

src/Settings/DeviceSettingsBLE.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class DeviceSettingsBLE : public DeviceSettings
2323
QT_SETTINGS_PROPERTY(int, nb_20mins_ticks_for_lock, 0, MPParams::NB_20MINS_TICKS_FOR_LOCK)
2424
QT_SETTINGS_PROPERTY(bool, switch_off_after_usb_disc, false, MPParams::SWITCH_OFF_AFTER_USB_DISC)
2525
QT_SETTINGS_PROPERTY(int, information_time_delay, 0, MPParams::INFORMATION_TIME_DELAY)
26+
QT_SETTINGS_PROPERTY(bool, bluetooth_shortcuts, false, MPParams::BLUETOOTH_SHORTCUTS)
27+
QT_SETTINGS_PROPERTY(int, screen_saver_id, 0, MPParams::SCREEN_SAVER_ID)
2628

2729

2830
public:
@@ -51,7 +53,9 @@ class DeviceSettingsBLE : public DeviceSettings
5153
NB_20MINS_TICKS_FOR_LOCK = 20,
5254
SWITCH_OFF_AFTER_USB_DISC = 21,
5355
HASH_DISPLAY_BYTE = 22,
54-
INFORMATION_TIME_DELAY_BYTE = 23
56+
INFORMATION_TIME_DELAY_BYTE = 23,
57+
BLUETOOTH_SHORTCUTS_BYTE = 24,
58+
SCREEN_SAVER_ID_BYTE = 25
5559
};
5660

5761
static constexpr char USB_LAYOUT_ID = 0x01;

src/Settings/SettingsGuiBLE.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ void SettingsGuiBLE::updateUI()
6060
ui->checkBoxDisableBleOnCardRemove->show();
6161
ui->checkBoxDisableBleOnLock->show();
6262
ui->settings_information_time_delay->show();
63+
ui->settings_screen_saver_id->show();
64+
ui->checkBoxBTShortcuts->show();
6365

6466
ui->groupBox_BLESettings->show();
6567
ui->checkBoxBLEReserved->hide();

src/Settings/SettingsGuiHelper.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ void SettingsGuiHelper::setMainWindow(MainWindow *mw)
5757
{MPParams::DISABLE_BLE_ON_LOCK, ui->checkBoxDisableBleOnLock},
5858
{MPParams::SWITCH_OFF_AFTER_USB_DISC, ui->checkBoxSwitchOffUSBDisc},
5959
{MPParams::NB_20MINS_TICKS_FOR_LOCK, ui->comboBoxInactivityTimer},
60-
{MPParams::INFORMATION_TIME_DELAY, ui->comboBoxInformationTimeDelay}
60+
{MPParams::INFORMATION_TIME_DELAY, ui->comboBoxInformationTimeDelay},
61+
{MPParams::BLUETOOTH_SHORTCUTS, ui->checkBoxBTShortcuts},
62+
{MPParams::SCREEN_SAVER_ID, ui->comboBoxScreensaverId}
6163
};
6264
//When something changed in GUI, show save/reset buttons
6365
for (const auto& widget : m_widgetMapping)

src/Settings/SettingsGuiMini.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ void SettingsGuiMini::updateUI()
5959
ui->checkBoxDisableBleOnLock->hide();
6060

6161
ui->settings_information_time_delay->hide();
62+
ui->settings_screen_saver_id->hide();
63+
ui->checkBoxBTShortcuts->hide();
6264

6365
ui->groupBox_BLESettings->hide();
6466

0 commit comments

Comments
 (0)