Add "Restore to defaults" and "remove action" action in WiimotedevShortcutsConfig
This commit is contained in:
parent
774ae905e6
commit
57540119b5
|
@ -515,6 +515,9 @@ msgstr "اخفض الصوت 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr ""
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -515,6 +515,9 @@ msgstr ""
|
|||
msgid "Decrease volume"
|
||||
msgstr ""
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -527,6 +527,9 @@ msgstr "Redueix el volum un 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Redueix el volum"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Retard entre visualitzacions"
|
||||
|
||||
|
|
|
@ -516,6 +516,9 @@ msgstr "Sniž hlasitosto 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Snížit hlasitost"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -516,6 +516,9 @@ msgstr "Sænk lydstyrken med 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr ""
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -526,6 +526,9 @@ msgstr "Lautstärke um 4% verringern"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Lautstärke verringern"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Verzögerung zwischen Visualisierungen"
|
||||
|
||||
|
|
|
@ -528,6 +528,9 @@ msgstr "Μείωση της έντασης ήχου κατά 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Μείωση έντασης"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Καθυστέρηση μεταξύ οπτικών εφέ"
|
||||
|
||||
|
|
|
@ -517,6 +517,9 @@ msgstr "Decrease the volume by 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Decrease volume"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Delay between visualisations"
|
||||
|
||||
|
|
|
@ -515,6 +515,9 @@ msgstr "Decrease the volume by 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr ""
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Delay between visualisations"
|
||||
|
||||
|
|
|
@ -527,6 +527,9 @@ msgstr "Reducir el volumen en 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Disminuir volumen"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Retardo entre visualizaciones"
|
||||
|
||||
|
|
|
@ -515,6 +515,9 @@ msgstr ""
|
|||
msgid "Decrease volume"
|
||||
msgstr "Vähennä äänenvoimakkuutta"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -520,6 +520,9 @@ msgstr "Baisser le volume de 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Diminuer le volume"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Délai entre les visualisations"
|
||||
|
||||
|
|
|
@ -515,6 +515,9 @@ msgstr ""
|
|||
msgid "Decrease volume"
|
||||
msgstr ""
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -524,6 +524,9 @@ msgstr "Hangerő csökkentése 4%-kal"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Hangerő csökkentése"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Megjelenítések között váltás ideje"
|
||||
|
||||
|
|
|
@ -531,6 +531,9 @@ msgstr "Riduci il volume del 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Riduci il volume"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Ritardo tra le visualizzazioni"
|
||||
|
||||
|
|
|
@ -515,6 +515,9 @@ msgstr ""
|
|||
msgid "Decrease volume"
|
||||
msgstr ""
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -515,6 +515,9 @@ msgstr ""
|
|||
msgid "Decrease volume"
|
||||
msgstr ""
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -515,6 +515,9 @@ msgstr ""
|
|||
msgid "Decrease volume"
|
||||
msgstr ""
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -523,6 +523,9 @@ msgstr "Volume met 4% verlagen"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Volume verlagen"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Vertraging tussen visualisaties"
|
||||
|
||||
|
|
|
@ -515,6 +515,9 @@ msgstr ""
|
|||
msgid "Decrease volume"
|
||||
msgstr "Reduire lo volum"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -521,6 +521,9 @@ msgstr "Zmniejsz głośność o 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Zmniejsz głośność"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Opóźnienie pomiędzy wizualizacjami"
|
||||
|
||||
|
|
|
@ -525,6 +525,9 @@ msgstr "Diminuir o volume em 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Diminuir volume"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Atraso entre visualizações"
|
||||
|
||||
|
|
|
@ -520,6 +520,9 @@ msgstr "Diminuir volume em 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Diminuir volume"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Atraso entre as visualizações"
|
||||
|
||||
|
|
|
@ -515,6 +515,9 @@ msgstr "Scade volumul cu 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr ""
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -522,6 +522,9 @@ msgstr "Уменьшить громкость на 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Уменьшить громкость"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Задержка между визуализациями"
|
||||
|
||||
|
|
|
@ -524,6 +524,9 @@ msgstr "Znížiť hlasitosť o 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Znížiť hlasitosť"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Oneskorenie medzi vizualizáciami"
|
||||
|
||||
|
|
|
@ -523,6 +523,9 @@ msgstr "Zmanjšaj glasnost za 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Zmanjšaj glasnost"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Zamik med vizualizacijami"
|
||||
|
||||
|
|
|
@ -517,6 +517,9 @@ msgstr "Утишај јачину звука за 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Утишај звук"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Застој између визуелизација"
|
||||
|
||||
|
|
|
@ -519,6 +519,9 @@ msgstr "Sänk volymen med 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Sänk volymen"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Fördröjning mellan visualiseringar"
|
||||
|
||||
|
|
|
@ -515,6 +515,9 @@ msgstr "Ses seviyesini %4 azalt"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Sesi azalt"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Görselleştirmeler arasındaki gecikme"
|
||||
|
||||
|
|
|
@ -505,6 +505,9 @@ msgstr ""
|
|||
msgid "Decrease volume"
|
||||
msgstr ""
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -523,6 +523,9 @@ msgstr "Зменшити гучність на 4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "Зменшити гучність"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "Затримка між візуалізаціями"
|
||||
|
||||
|
|
|
@ -515,6 +515,9 @@ msgstr ""
|
|||
msgid "Decrease volume"
|
||||
msgstr "降低音量"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -519,6 +519,9 @@ msgstr "減低音量4%"
|
|||
msgid "Decrease volume"
|
||||
msgstr "減低音量"
|
||||
|
||||
msgid "Defaults"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delay between visualizations"
|
||||
msgstr "在兩個視覺化效果間延遲切換"
|
||||
|
||||
|
|
|
@ -224,6 +224,15 @@ void SettingsDialog::accept() {
|
|||
#endif
|
||||
|
||||
#ifdef ENABLE_WIIMOTEDEV
|
||||
s.beginGroup(WiimotedevShortcuts::kActionsGroup);
|
||||
s.clear();
|
||||
|
||||
foreach (const WiimotedevShortcutsConfig::Shortcut& shortcut, wiimotedev_config_->actions_) {
|
||||
s.setValue(QString::number(shortcut.button), shortcut.action);
|
||||
}
|
||||
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(WiimotedevShortcuts::kSettingsGroup);
|
||||
s.setValue("enabled", wiimotedev_config_->ui_->wiimotedev_enable->isChecked());
|
||||
s.setValue("only_when_focused", wiimotedev_config_->ui_->wiimotedev_focus->isChecked());
|
||||
|
|
|
@ -113,7 +113,18 @@ WiimotedevShortcutsConfig::WiimotedevShortcutsConfig(QWidget* parent)
|
|||
ui_->wiimotedev_device->setValue(settings_.value("device", 1).toUInt());
|
||||
settings_.endGroup();
|
||||
|
||||
LoadSettings();
|
||||
|
||||
connect(ui_->wiimotedev_enable, SIGNAL(clicked(bool)), this, SLOT(WiimotedevEnabledChecked(bool)));
|
||||
connect(ui_->list, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(ItemClicked(QTreeWidgetItem*)));
|
||||
connect(ui_->wiimotedev_delete_action, SIGNAL(clicked()), this, SLOT(DeleteAction()));
|
||||
connect(ui_->wiimotedev_reload, SIGNAL(clicked()), this , SLOT(DefaultSettings()));
|
||||
}
|
||||
|
||||
void WiimotedevShortcutsConfig::LoadSettings(){
|
||||
settings_.beginGroup(WiimotedevShortcuts::kActionsGroup);
|
||||
ui_->list->clear();
|
||||
|
||||
quint64 fvalue, svalue;
|
||||
bool fvalid, svalid;
|
||||
|
||||
|
@ -121,40 +132,70 @@ WiimotedevShortcutsConfig::WiimotedevShortcutsConfig(QWidget* parent)
|
|||
fvalue = str.toULongLong(&fvalid, 10);
|
||||
svalue = settings_.value(str, 0).toULongLong(&svalid);
|
||||
if (fvalid && svalid) {
|
||||
new QTreeWidgetItem(ui_->list,
|
||||
QStringList() << GetReadableWiiremoteSequence(fvalue) << text_actions_[svalue]);
|
||||
Shortcut s;
|
||||
s.object = new QTreeWidgetItem(ui_->list, QStringList() << GetReadableWiiremoteSequence(fvalue) << text_actions_[svalue]);
|
||||
s.button = fvalue;
|
||||
s.action = svalue;
|
||||
actions_ << s;
|
||||
}
|
||||
ui_->list->sortItems(1, Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
settings_.endGroup();
|
||||
}
|
||||
|
||||
connect(ui_->wiimotedev_enable, SIGNAL(clicked(bool)), this, SLOT(WiimotedevEnabledChecked(bool)));
|
||||
connect(ui_->list, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(ItemClicked(QTreeWidgetItem*)));
|
||||
void WiimotedevShortcutsConfig::DefaultSettings()
|
||||
{
|
||||
settings_.beginGroup(WiimotedevShortcuts::kActionsGroup);
|
||||
foreach (const QString& key, settings_.allKeys()) {
|
||||
settings_.remove(key);
|
||||
}
|
||||
settings_.setValue(QString::number(WIIMOTE_BTN_LEFT), WiimotedevShortcuts::PlayerPreviousTrack);
|
||||
settings_.setValue(QString::number(WIIMOTE_BTN_RIGHT), WiimotedevShortcuts::PlayerNextTrack);
|
||||
settings_.setValue(QString::number(WIIMOTE_BTN_SHIFT_LEFT), WiimotedevShortcuts::PlayerPreviousTrack);
|
||||
settings_.setValue(QString::number(WIIMOTE_BTN_SHIFT_RIGHT), WiimotedevShortcuts::PlayerNextTrack);
|
||||
settings_.setValue(QString::number(WIIMOTE_BTN_PLUS), WiimotedevShortcuts::PlayerIncVolume);
|
||||
settings_.setValue(QString::number(WIIMOTE_BTN_MINUS), WiimotedevShortcuts::PlayerDecVolume);
|
||||
settings_.setValue(QString::number(WIIMOTE_BTN_1), WiimotedevShortcuts::PlayerTogglePause);
|
||||
settings_.setValue(QString::number(WIIMOTE_BTN_2), WiimotedevShortcuts::PlayerShowOSD);
|
||||
settings_.endGroup();
|
||||
settings_.sync();
|
||||
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
void WiimotedevShortcutsConfig::WiimotedevEnabledChecked(bool checked) {
|
||||
ui_->wiimotedev_groupbox->setEnabled(checked);
|
||||
}
|
||||
|
||||
void WiimotedevShortcutsConfig::ItemClicked(QTreeWidgetItem* item) {
|
||||
current_id_ = item->data(0, Qt::UserRole).toString();
|
||||
void WiimotedevShortcutsConfig::ItemClicked(QTreeWidgetItem* selected_item) {
|
||||
selected_item_ = selected_item;
|
||||
}
|
||||
|
||||
QString WiimotedevShortcutsConfig::GetReadableWiiremoteSequence(quint64 value) {
|
||||
QMapIterator<quint64, QString> text(text_buttons_);
|
||||
|
||||
QStringList list;
|
||||
QString output;
|
||||
while (text.hasNext()) {
|
||||
text.next();
|
||||
if ((text.key() & value) == text.key())
|
||||
list << text.value();
|
||||
}
|
||||
|
||||
QString output;
|
||||
for (int i = 0; i < (list.count() - 1); ++i)
|
||||
output += list.at(i) + " + ";
|
||||
output += list.last();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
void WiimotedevShortcutsConfig::DeleteAction() {
|
||||
for (int i = 0; i < actions_.count(); ++i) {
|
||||
if (actions_.at(i).object == selected_item_) {
|
||||
delete selected_item_;
|
||||
actions_.removeAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,18 +29,32 @@ public:
|
|||
WiimotedevShortcutsConfig(QWidget* parent = 0);
|
||||
Ui_WiimotedevShortcutsConfig* ui_;
|
||||
|
||||
struct Shortcut {
|
||||
QTreeWidgetItem* object;
|
||||
quint64 button;
|
||||
quint32 action;
|
||||
};
|
||||
|
||||
QList <struct Shortcut> actions_;
|
||||
|
||||
private:
|
||||
QSettings settings_;
|
||||
QString current_id_;
|
||||
|
||||
QMap < quint64, QString> text_buttons_;
|
||||
QMap < quint32, QString> text_actions_;
|
||||
QTreeWidgetItem* selected_item_;
|
||||
|
||||
QMap <quint64, QString> text_buttons_;
|
||||
QMap <quint32, QString> text_actions_;
|
||||
|
||||
QString GetReadableWiiremoteSequence(quint64 value);
|
||||
|
||||
private slots:
|
||||
void LoadSettings();
|
||||
void DefaultSettings();
|
||||
void DeleteAction();
|
||||
|
||||
void WiimotedevEnabledChecked(bool checked);
|
||||
void ItemClicked(QTreeWidgetItem* item);
|
||||
void ItemClicked(QTreeWidgetItem*);
|
||||
};
|
||||
|
||||
#endif // WIIMOTEDEVSHORTCUTSCONFIG_H
|
||||
|
|
|
@ -174,6 +174,17 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="wiimotedev_reload">
|
||||
<property name="text">
|
||||
<string>Defaults</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../data/data.qrc">
|
||||
<normaloff>:/icons/22x22/view-refresh.png</normaloff>:/icons/22x22/view-refresh.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
|
|
|
@ -29,11 +29,11 @@ WiimotedevShortcuts::WiimotedevShortcuts(Player* player, QObject* parent)
|
|||
wiimotedev_buttons_(0),
|
||||
wiimotedev_device_(1),
|
||||
wiimotedev_active_(true),
|
||||
wiimotedev_enable_(true),
|
||||
wiimotedev_focus_(false),
|
||||
wiimotedev_notification_(true)
|
||||
{
|
||||
ReloadSettings();
|
||||
|
||||
wiimotedev_iface_ = new DBusDeviceEventsInterface(WIIMOTEDEV_DBUS_SERVICE_NAME,
|
||||
WIIMOTEDEV_DBUS_EVENTS_OBJECT,
|
||||
QDBusConnection::systemBus(),
|
||||
|
@ -43,35 +43,15 @@ WiimotedevShortcuts::WiimotedevShortcuts(Player* player, QObject* parent)
|
|||
this, SLOT(DbusWiimoteGeneralButtons(quint32, quint64)));
|
||||
}
|
||||
|
||||
void WiimotedevShortcuts::SetEnabled(bool enabled)
|
||||
{
|
||||
disconnect(this, 0, player_, 0);
|
||||
if (!enabled) return;
|
||||
|
||||
connect(this, SIGNAL(Next()), player_, SLOT(Next()));
|
||||
connect(this, SIGNAL(Previous()), player_, SLOT(Previous()));
|
||||
connect(this, SIGNAL(Play()), player_, SLOT(Play()));
|
||||
connect(this, SIGNAL(Stop()), player_, SLOT(Stop()));
|
||||
connect(this, SIGNAL(IncVolume()), player_, SLOT(VolumeUp()));
|
||||
connect(this, SIGNAL(DecVolume()), player_, SLOT(VolumeDown()));
|
||||
connect(this, SIGNAL(Mute()), player_, SLOT(Mute()));
|
||||
connect(this, SIGNAL(Pause()), player_, SLOT(Pause()));
|
||||
connect(this, SIGNAL(TogglePause()), player_, SLOT(PlayPause()));
|
||||
connect(this, SIGNAL(SeekBackward()), player_, SLOT(SeekBackward()));
|
||||
connect(this, SIGNAL(SeekForward()), player_, SLOT(SeekForward()));
|
||||
connect(this, SIGNAL(ShowOSD()), player_, SLOT(ShowOSD()));
|
||||
}
|
||||
|
||||
void WiimotedevShortcuts::ReloadSettings() {
|
||||
settings_.beginGroup(WiimotedevShortcuts::kActionsGroup);
|
||||
actions_.clear();
|
||||
|
||||
if (!settings_.allKeys().count()) {
|
||||
SetDefaultSettings();
|
||||
settings_.sync();
|
||||
}
|
||||
|
||||
actions_.clear();
|
||||
|
||||
quint64 fvalue, svalue;
|
||||
bool fvalid, svalid;
|
||||
|
||||
|
@ -84,8 +64,8 @@ void WiimotedevShortcuts::ReloadSettings() {
|
|||
settings_.endGroup();
|
||||
|
||||
settings_.beginGroup(WiimotedevShortcuts::kSettingsGroup);
|
||||
SetEnabled(settings_.value("enabled", quint64(true)).toBool());
|
||||
wiimotedev_device_ = settings_.value("device", 1).toInt();
|
||||
wiimotedev_enable_ = settings_.value("enabled", wiimotedev_enable_).toBool();
|
||||
wiimotedev_device_ = settings_.value("device", wiimotedev_device_).toInt();
|
||||
wiimotedev_active_ = settings_.value("use_active_action", wiimotedev_active_).toBool();
|
||||
wiimotedev_focus_ = settings_.value("only_when_focused", wiimotedev_focus_).toBool();
|
||||
wiimotedev_notification_ = settings_.value("use_notification", wiimotedev_notification_).toBool();
|
||||
|
@ -97,6 +77,9 @@ void WiimotedevShortcuts::SetDefaultSettings()
|
|||
{
|
||||
QSettings settings;
|
||||
settings.beginGroup(WiimotedevShortcuts::kActionsGroup);
|
||||
foreach (const QString& key, settings_.allKeys()) {
|
||||
settings_.remove(key);
|
||||
}
|
||||
settings.setValue(QString::number(WIIMOTE_BTN_LEFT), PlayerPreviousTrack);
|
||||
settings.setValue(QString::number(WIIMOTE_BTN_RIGHT), PlayerNextTrack);
|
||||
settings.setValue(QString::number(WIIMOTE_BTN_SHIFT_LEFT), PlayerPreviousTrack);
|
||||
|
@ -108,47 +91,41 @@ void WiimotedevShortcuts::SetDefaultSettings()
|
|||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(WiimotedevShortcuts::kSettingsGroup);
|
||||
foreach (const QString& key, settings_.allKeys()) {
|
||||
settings_.remove(key);
|
||||
}
|
||||
settings.setValue("enabled", true);
|
||||
settings.setValue("device", 1);
|
||||
settings.setValue("use_active_action", true);
|
||||
settings.setValue("only_when_focused", false);
|
||||
settings.setValue("use_notification", true);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
void WiimotedevShortcuts::EmitRequest(quint32 action) {
|
||||
switch (action) {
|
||||
case PlayerNextTrack: emit Next(); break;
|
||||
case PlayerPreviousTrack: emit Previous(); break;
|
||||
case PlayerPlay: emit Play(); break;
|
||||
case PlayerStop: emit Stop(); break;
|
||||
case PlayerIncVolume: emit IncVolume(); break;
|
||||
case PlayerDecVolume: emit DecVolume(); break;
|
||||
case PlayerMute: emit Mute(); break;
|
||||
case PlayerPause: emit Pause(); break;
|
||||
case PlayerTogglePause: emit TogglePause(); break;
|
||||
case PlayerSeekBackward: emit SeekBackward(); break;
|
||||
case PlayerSeekForward: emit SeekForward(); break;
|
||||
case PlayerStopAfter: emit StopAfter(); break;
|
||||
case PlayerShowOSD: emit ShowOSD(); break;
|
||||
}
|
||||
}
|
||||
|
||||
void WiimotedevShortcuts::DbusWiimoteGeneralButtons(quint32 id, quint64 value) {
|
||||
if (id != wiimotedev_device_) return;
|
||||
if (id != wiimotedev_device_ || !wiimotedev_enable_) return;
|
||||
|
||||
quint64 buttons = value & ~(WIIMOTE_TILT_MASK | NUNCHUK_TILT_MASK);
|
||||
|
||||
if (wiimotedev_buttons_ == buttons) return;
|
||||
|
||||
QMapIterator<quint64, quint32> actions(actions_);
|
||||
|
||||
while (actions.hasNext()) {
|
||||
actions.next();
|
||||
if (!actions.key()) continue;
|
||||
if ((actions.key() & buttons) == actions.key()) EmitRequest(actions.value());
|
||||
if (actions_.contains(buttons)) {
|
||||
switch (actions_.value(buttons, 0xff)) {
|
||||
case PlayerNextTrack: player_->Next(); break;
|
||||
case PlayerPreviousTrack: player_->Previous(); break;
|
||||
case PlayerPlay: player_->Play(); break;
|
||||
case PlayerStop: player_->Stop(); break;
|
||||
case PlayerIncVolume: player_->VolumeUp(); break;
|
||||
case PlayerDecVolume: player_->VolumeDown(); break;
|
||||
case PlayerMute: player_->Mute(); break;
|
||||
case PlayerPause: player_->Pause(); break;
|
||||
case PlayerTogglePause: player_->PlayPause(); break;
|
||||
case PlayerSeekBackward: player_->SeekBackward(); break;
|
||||
case PlayerSeekForward: player_->SeekForward(); break;
|
||||
case PlayerStopAfter: player_->Stop(); break;
|
||||
case PlayerShowOSD: player_->ShowOSD(); break;
|
||||
}
|
||||
}
|
||||
|
||||
wiimotedev_buttons_ = buttons;
|
||||
|
|
|
@ -35,27 +35,25 @@ public:
|
|||
public slots:
|
||||
void ReloadSettings();
|
||||
void SetDefaultSettings();
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
private slots:
|
||||
void DbusWiimoteGeneralButtons(quint32 id, quint64 value);
|
||||
|
||||
private:
|
||||
void EmitRequest(quint32 action);
|
||||
|
||||
DBusDeviceEventsInterface* wiimotedev_iface_;
|
||||
Player* player_;
|
||||
quint64 wiimotedev_buttons_;
|
||||
QSettings settings_;
|
||||
|
||||
quint32 wiimotedev_device_;
|
||||
quint32 wiimotedev_device_;
|
||||
bool wiimotedev_active_;
|
||||
bool wiimotedev_enable_;
|
||||
bool wiimotedev_focus_;
|
||||
bool wiimotedev_notification_;
|
||||
|
||||
public:
|
||||
enum Action {
|
||||
WiimotedevActive,
|
||||
WiimotedevActive = 0,
|
||||
WiimotedevDeactive,
|
||||
PlayerNextTrack,
|
||||
PlayerPreviousTrack,
|
||||
|
@ -69,26 +67,12 @@ public:
|
|||
PlayerSeekBackward,
|
||||
PlayerSeekForward,
|
||||
PlayerStopAfter,
|
||||
PlayerShowOSD
|
||||
PlayerShowOSD,
|
||||
ActionNone = 0xff
|
||||
};
|
||||
|
||||
private:
|
||||
QMap <quint64, quint32> actions_;
|
||||
|
||||
signals:
|
||||
void Next();
|
||||
void Previous();
|
||||
void Play();
|
||||
void Stop();
|
||||
void IncVolume();
|
||||
void DecVolume();
|
||||
void Mute();
|
||||
void Pause();
|
||||
void TogglePause();
|
||||
void SeekBackward();
|
||||
void SeekForward();
|
||||
void StopAfter();
|
||||
void ShowOSD();
|
||||
QHash <quint64, quint32> actions_;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue