Merge pull request #50 from dginovker/updateconfigdir

Change settings directory to .config/qjoypad4
This commit is contained in:
Mathias Panzenböck
2022-01-02 20:21:19 +01:00
committed by GitHub
2 changed files with 23 additions and 8 deletions

View File

@ -178,7 +178,7 @@ The top of this menu shows you which joystick devices are
currently available (see [Joystick recognition](#joystick-recognition)
if not all your devices are listed). Below that are the options
to update the layout list or the joystick devices; use these if
you have just put a new layout in ~/.qjoypad3 by hand or if
you have just put a new layout in ~/.config/qjoypad4 by hand or if
you've plugged in a new joystick device. Below even farther is
a list of the available layouts and the option to quit.
@ -467,7 +467,7 @@ named "Layout" will be considered distinct from a layout named
and there should be no serious limits on name length.
Whenever you create a new layout, QJoyPad makes a new file
called Name.lyt in `~/.qjoypad3`, where Name is the name that
called Name.lyt in `~/.config/qjoypad4`, where Name is the name that
you provided. Whenever you update that layout, it overwrites
that file to reflect your changes, whenever you revert, it
rereads that file, and if you ever remove that layout, it will
@ -478,7 +478,7 @@ you can edit them by hand if you like. The numbers used to
represent keys are standard X11 keycodes.
It's also easy to share QJoyPad layout files; just copy them
from one user's `~/.qjoypad3` directory to another and either
from one user's `~/.config/qjoypad4` directory to another and either
tell QJoyPad to update the layout list by right clicking on
the tray icon, or just restart QJoyPad. If you switch layouts
through the command line, you don't even need to do that.

View File

@ -25,7 +25,7 @@ QPointer<LayoutManager> layoutManagerPtr;
//signal handler for SIGUSR2
//SIGUSR2 means that a new layout should be loaded. It is saved in
// ~/.qjoypad/layout, where the last used layout is put.
// ~/.config/qjoypad4/layout, where the last used layout is put.
void catchSIGUSR2( int sig ) {
if (layoutManagerPtr) layoutManagerPtr->load();
//remember to catch this signal again next time.
@ -59,24 +59,39 @@ int main( int argc, char **argv )
debug_mesg("no translation for locale: %s\n", qPrintable(QLocale::system().name()));
}
//where QJoyPad saves its settings!
const QString settingsDir(QDir::homePath() + "/.qjoypad3/");
const QString settingsDir(QDir::homePath() + "/.config/qjoypad4/");
//where to look for settings. If it does not exist, it will be created
QDir dir(settingsDir);
//legacy QJoyPad settings location
const QString legacySettingsDir(QDir::homePath() + "/.qjoypad3/");
//where to look for legacy settings. If it exists, it will be moved
QDir legacyDir(legacySettingsDir);
if (legacyDir.exists()) {
errorBox(app.translate("main","Legacy settings directory detected"),
app.translate("main","We've detected settings in ~/.qjoypad3/. For standardization purposes, we're moving them to ~/.config/qjoypad4\n\nQJoyPad will continue to work as expected"));
if(!dir.rename(legacySettingsDir, settingsDir)) {
errorBox(app.translate("main","Could not move settings"),
app.translate("main","We could not move your settings - This likely means \"%1\" already exists on your system.\n\nPlease move files from \"%2\" to \"%1\" manually, then restart the application.").arg(settingsDir).arg(legacySettingsDir));
return 1;
}
}
//the directory in wich the joystick devices are (e.g. "/dev/input")
QString devdir = QJOYPAD_DEVDIR;
//if there is no new directory and we can't make it, complain
if (!dir.exists() && !dir.mkdir(settingsDir)) {
errorBox(app.translate("main","Couldn't create the QJoyPad save directory"),
app.translate("main","Couldn't create the QJoyPad save directory: %s").arg(settingsDir));
app.translate("main","Couldn't create the QJoyPad save directory: %1").arg(settingsDir));
return 1;
}
//start out with no special layout.
QString layout;
//by default, we use a tray icon