const& params++, no need to rebuild menu when layout changes
This commit is contained in:
@ -45,7 +45,7 @@ LayoutManager::~LayoutManager() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LayoutManager::getFileName( QString layoutname ) {
|
QString LayoutManager::getFileName(const QString& layoutname ) {
|
||||||
return QString("%1%2.lyt").arg(settingsDir, layoutname);
|
return QString("%1%2.lyt").arg(settingsDir, layoutname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,8 +230,7 @@ void LayoutManager::saveAs() {
|
|||||||
void LayoutManager::saveDefault() {
|
void LayoutManager::saveDefault() {
|
||||||
QFile file( settingsDir + "layout");
|
QFile file( settingsDir + "layout");
|
||||||
if (file.open(QIODevice::WriteOnly)) {
|
if (file.open(QIODevice::WriteOnly)) {
|
||||||
QTextStream stream(&file);
|
QTextStream(&file) << currentLayout;
|
||||||
stream << currentLayout;
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -265,9 +264,19 @@ QStringList LayoutManager::getLayoutNames() const {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayoutManager::setLayoutName(QString name) {
|
void LayoutManager::setLayoutName(const QString& name) {
|
||||||
currentLayout = name;
|
QList<QAction*> actions = layoutGroup->actions();
|
||||||
fillPopup();
|
bool found = false;
|
||||||
|
for (int i = 0; i < actions.size(); ++ i) {
|
||||||
|
QAction* action = actions[i];
|
||||||
|
if (action->data().toString() == name) {
|
||||||
|
action->setChecked(true);
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentLayout = found ? name : NL;
|
||||||
|
|
||||||
if (le) {
|
if (le) {
|
||||||
le->setLayout(name);
|
le->setLayout(name);
|
||||||
|
@ -71,9 +71,9 @@ class LayoutManager : public QObject {
|
|||||||
void layoutTriggered();
|
void layoutTriggered();
|
||||||
private:
|
private:
|
||||||
//change to the given layout name and make all the necesary adjustments
|
//change to the given layout name and make all the necesary adjustments
|
||||||
void setLayoutName(QString name);
|
void setLayoutName(const QString& name);
|
||||||
//get the file name for a layout name
|
//get the file name for a layout name
|
||||||
QString getFileName( QString layoutname );
|
QString getFileName(const QString& layoutname);
|
||||||
//the directory in wich the joystick devices are (e.g. "/dev/input")
|
//the directory in wich the joystick devices are (e.g. "/dev/input")
|
||||||
QString devdir;
|
QString devdir;
|
||||||
QString settingsDir;
|
QString settingsDir;
|
||||||
|
@ -84,7 +84,7 @@ LayoutEdit::LayoutEdit( LayoutManager* l ): QWidget(NULL) {
|
|||||||
this->show();
|
this->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayoutEdit::setLayout(QString layout) {
|
void LayoutEdit::setLayout(const QString &layout) {
|
||||||
//change the text,
|
//change the text,
|
||||||
cmbLayouts->setCurrentIndex(lm->getLayoutNames().indexOf(layout));
|
cmbLayouts->setCurrentIndex(lm->getLayoutNames().indexOf(layout));
|
||||||
//update all the JoyPadWidgets.
|
//update all the JoyPadWidgets.
|
||||||
|
@ -18,7 +18,7 @@ class LayoutEdit : public QWidget {
|
|||||||
public:
|
public:
|
||||||
LayoutEdit( LayoutManager* l );
|
LayoutEdit( LayoutManager* l );
|
||||||
//swap to a new layout
|
//swap to a new layout
|
||||||
void setLayout(QString layout);
|
void setLayout(const QString& layout);
|
||||||
//update the list of available layouts
|
//update the list of available layouts
|
||||||
void updateLayoutList();
|
void updateLayoutList();
|
||||||
void updateJoypadWidgets();
|
void updateJoypadWidgets();
|
||||||
|
Reference in New Issue
Block a user