Merge pull request #41 from minger0/addcfgnonotray
add 'add new config' option to the menu
This commit is contained in:
@ -15,6 +15,7 @@ LayoutManager::LayoutManager( bool useTrayIcon, const QString &devdir, const QSt
|
|||||||
layoutGroup(new QActionGroup(this)),
|
layoutGroup(new QActionGroup(this)),
|
||||||
updateDevicesAction(new QAction(QIcon::fromTheme("view-refresh"),tr("Update &Joystick Devices"),this)),
|
updateDevicesAction(new QAction(QIcon::fromTheme("view-refresh"),tr("Update &Joystick Devices"),this)),
|
||||||
updateLayoutsAction(new QAction(QIcon::fromTheme("view-refresh"),tr("Update &Layout List"),this)),
|
updateLayoutsAction(new QAction(QIcon::fromTheme("view-refresh"),tr("Update &Layout List"),this)),
|
||||||
|
addNewConfiguration(new QAction(QIcon::fromTheme("list-add"),tr("Add new configuration"),this)),
|
||||||
quitAction(new QAction(QIcon::fromTheme("application-exit"),tr("&Quit"),this)),
|
quitAction(new QAction(QIcon::fromTheme("application-exit"),tr("&Quit"),this)),
|
||||||
le(0) {
|
le(0) {
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ LayoutManager::LayoutManager( bool useTrayIcon, const QString &devdir, const QSt
|
|||||||
|
|
||||||
connect(updateLayoutsAction, SIGNAL(triggered()), this, SLOT(fillPopup()));
|
connect(updateLayoutsAction, SIGNAL(triggered()), this, SLOT(fillPopup()));
|
||||||
connect(updateDevicesAction, SIGNAL(triggered()), this, SLOT(updateJoyDevs()));
|
connect(updateDevicesAction, SIGNAL(triggered()), this, SLOT(updateJoyDevs()));
|
||||||
|
connect(addNewConfiguration, SIGNAL(triggered()), this, SLOT(addNewConfig()));
|
||||||
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
|
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
|
||||||
|
|
||||||
//no layout loaded at start.
|
//no layout loaded at start.
|
||||||
@ -520,20 +522,9 @@ void LayoutManager::iconClick() {
|
|||||||
errorBox(tr("No joystick devices available"),
|
errorBox(tr("No joystick devices available"),
|
||||||
tr("No joystick devices are currently available to configure.\nPlease plug in a gaming device and select\n\"Update Joystick Devices\" from the popup menu."),
|
tr("No joystick devices are currently available to configure.\nPlease plug in a gaming device and select\n\"Update Joystick Devices\" from the popup menu."),
|
||||||
le);
|
le);
|
||||||
return;
|
} else {
|
||||||
|
addNewConfig();
|
||||||
}
|
}
|
||||||
if (le) {
|
|
||||||
if (le->isActiveWindow()) {
|
|
||||||
le->close();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
le->activateWindow();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//otherwise, make a new LayoutEdit dialog and show it.
|
|
||||||
le = new LayoutEdit(this);
|
|
||||||
le->setLayout(currentLayout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayoutManager::trayClick(QSystemTrayIcon::ActivationReason reason) {
|
void LayoutManager::trayClick(QSystemTrayIcon::ActivationReason reason) {
|
||||||
@ -585,6 +576,9 @@ void LayoutManager::fillPopup() {
|
|||||||
}
|
}
|
||||||
trayMenu.addSeparator();
|
trayMenu.addSeparator();
|
||||||
|
|
||||||
|
trayMenu.addAction(addNewConfiguration);
|
||||||
|
trayMenu.addSeparator();
|
||||||
|
|
||||||
//and, at the end, quit!
|
//and, at the end, quit!
|
||||||
trayMenu.addAction(quitAction);
|
trayMenu.addAction(quitAction);
|
||||||
}
|
}
|
||||||
@ -680,6 +674,24 @@ void LayoutManager::updateJoyDevs() {
|
|||||||
debug_mesg("done updating joydevs\n");
|
debug_mesg("done updating joydevs\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LayoutManager::addNewConfig() {
|
||||||
|
if (!le) {
|
||||||
|
// make a new LayoutEdit dialog and show it.
|
||||||
|
le = new LayoutEdit(this);
|
||||||
|
le->setLayout(currentLayout);
|
||||||
|
}
|
||||||
|
if (le) {
|
||||||
|
if (le->isActiveWindow()) {
|
||||||
|
le->hide();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
le->show();
|
||||||
|
le->activateWindow();
|
||||||
|
le->raise();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LayoutManager::addJoyPad(int index) {
|
void LayoutManager::addJoyPad(int index) {
|
||||||
addJoyPad(index, QString("%1/js%2").arg(devdir, index));
|
addJoyPad(index, QString("%1/js%2").arg(devdir, index));
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,8 @@ class LayoutManager : public QObject {
|
|||||||
void fillPopup();
|
void fillPopup();
|
||||||
//update the list of available joystick devices
|
//update the list of available joystick devices
|
||||||
void updateJoyDevs();
|
void updateJoyDevs();
|
||||||
|
// open dialog to be able to add new configurations
|
||||||
|
void addNewConfig();
|
||||||
private slots:
|
private slots:
|
||||||
//when the user selects an item on the tray's popup menu
|
//when the user selects an item on the tray's popup menu
|
||||||
void layoutTriggered();
|
void layoutTriggered();
|
||||||
@ -97,6 +99,7 @@ class LayoutManager : public QObject {
|
|||||||
QActionGroup *layoutGroup;
|
QActionGroup *layoutGroup;
|
||||||
QAction *updateDevicesAction;
|
QAction *updateDevicesAction;
|
||||||
QAction *updateLayoutsAction;
|
QAction *updateLayoutsAction;
|
||||||
|
QAction *addNewConfiguration;
|
||||||
QAction *quitAction;
|
QAction *quitAction;
|
||||||
|
|
||||||
//if there is a LayoutEdit open, this points to it. Otherwise, NULL.
|
//if there is a LayoutEdit open, this points to it. Otherwise, NULL.
|
||||||
|
Reference in New Issue
Block a user