Block wiimotedev interface when adding new shortcut

This commit is contained in:
Bartłomiej Burdukiewicz 2010-08-31 20:35:11 +00:00
parent fbd17fd2a5
commit a05cd6d623
8 changed files with 38 additions and 10 deletions

View File

@ -1486,9 +1486,10 @@ void MainWindow::EnsureSettingsDialogCreated() {
connect(settings_dialog_.get(), SIGNAL(accepted()), ui_->library_view, SLOT(ReloadSettings()));
connect(settings_dialog_.get(), SIGNAL(accepted()), player_->GetEngine(), SLOT(ReloadSettings()));
connect(settings_dialog_.get(), SIGNAL(accepted()), ui_->playlist->view(), SLOT(ReloadSettings()));
#ifdef ENABLE_WIIMOTEDEV
#ifdef ENABLE_WIIMOTEDEV
connect(settings_dialog_.get(), SIGNAL(accepted()), wiimotedev_shortcuts_.get(), SLOT(ReloadSettings()));
#endif
connect(settings_dialog_.get(), SIGNAL(SetWiimotedevInterfaceActived(bool)), wiimotedev_shortcuts_.get(), SLOT(SetWiimotedevInterfaceActived(bool)));
#endif
}
void MainWindow::OpenSettingsDialog() {

View File

@ -71,6 +71,8 @@ SettingsDialog::SettingsDialog(QWidget* parent)
wiimotedev_layout->addWidget(wiimotedev_config_);
ui_->stacked_widget->addWidget(wiimotedev_page);
connect(wiimotedev_config_, SIGNAL(SetWiimotedevInterfaceActived(bool)), this, SIGNAL(SetWiimotedevInterfaceActived(bool)));
#endif
// Playback

View File

@ -95,6 +95,11 @@ class SettingsDialog : public QDialog {
OSDPretty* pretty_popup_;
QMap<QString, QString> language_map_;
#ifdef ENABLE_WIIMOTEDEV
signals:
void SetWiimotedevInterfaceActived(bool);
#endif
};
#endif // SETTINGSDIALOG_H

View File

@ -16,12 +16,12 @@
#include "ui/wiimotedevshortcutgrabber.h"
#include "ui_wiimotedevshortcutgrabber.h"
#include "ui/wiimotedevshortcutsconfig.h"
#include "wiimotedev/consts.h"
WiimotedevShortcutGrabber::WiimotedevShortcutGrabber(QWidget *parent)
WiimotedevShortcutGrabber::WiimotedevShortcutGrabber(quint32 action, QWidget *parent)
: QDialog(parent),
pref_action_(action),
ui_(new Ui_WiimotedevShortcutGrabber),
config_(qobject_cast<WiimotedevShortcutsConfig*>(parent)),
wiimotedev_device_(1),
@ -42,9 +42,15 @@ WiimotedevShortcutGrabber::WiimotedevShortcutGrabber(QWidget *parent)
this, SLOT(DbusWiimoteGeneralButtons(uint,qulonglong)));
}
shortcut.action = 0;
shortcut.button = 0;
shortcut.object = 0;
foreach (const QString& name, config_->text_actions_.values())
ui_->comboBox->addItem(name);
ui_->comboBox->setCurrentIndex(pref_action_);
connect(ui_->remember_shifts, SIGNAL(clicked(bool)), this, SLOT(RememberSwingChecked(bool)));
}

View File

@ -21,21 +21,25 @@
#include <boost/scoped_ptr.hpp>
#include "dbus/wiimotedev.h"
class WiimotedevShortcutsConfig;
#include "ui/wiimotedevshortcutsconfig.h"
class Ui_WiimotedevShortcutGrabber;
class WiimotedevShortcutGrabber : public QDialog {
Q_OBJECT
Q_OBJECT
public:
WiimotedevShortcutGrabber(QWidget* parent = 0);
WiimotedevShortcutGrabber(quint32 action = 0, QWidget* parent = 0);
~WiimotedevShortcutGrabber();
WiimotedevShortcutsConfig::Shortcut shortcut;
private slots:
void DbusWiimoteGeneralButtons(uint id, qulonglong value);
void RememberSwingChecked(bool checked);
private:
quint32 pref_action_;
Ui_WiimotedevShortcutGrabber* ui_;
WiimotedevShortcutsConfig* config_;
boost::scoped_ptr<OrgWiimotedevDeviceEventsInterface> wiimotedev_iface_;

View File

@ -201,8 +201,10 @@ QString WiimotedevShortcutsConfig::GetReadableWiiremoteSequence(quint64 value) {
}
void WiimotedevShortcutsConfig::AddAction() {
WiimotedevShortcutGrabber grabber(this);
emit SetWiimotedevInterfaceActived(false);
WiimotedevShortcutGrabber grabber(0, this);
grabber.exec();
emit SetWiimotedevInterfaceActived(true);
}
void WiimotedevShortcutsConfig::DeleteAction() {

View File

@ -59,6 +59,10 @@ private slots:
void WiimotedevEnabledChecked(bool checked);
void ItemClicked(QTreeWidgetItem*);
signals:
void SetWiimotedevInterfaceActived(bool);
};
#endif // WIIMOTEDEVSHORTCUTSCONFIG_H

View File

@ -97,7 +97,11 @@ void WiimotedevShortcuts::ReloadSettings() {
void WiimotedevShortcuts::DbusWiimoteGeneralButtons(uint id, qulonglong value) {
if (id != wiimotedev_device_ || !wiimotedev_enable_ || !player_) return;
quint64 buttons = value & ~(WIIMOTE_TILT_MASK | NUNCHUK_TILT_MASK);
quint64 buttons = value & ~(
WIIMOTE_TILT_MASK |
NUNCHUK_TILT_MASK |
WIIMOTE_BTN_SHIFT_SHAKE |
NUNCHUK_BTN_SHIFT_SHAKE);
if (wiimotedev_buttons_ == buttons) return;