localization and more const& params
This commit is contained in:
@@ -40,8 +40,8 @@ set(qjoypad_QOBJECT_HEADERS
|
||||
layout.h
|
||||
quickset.h)
|
||||
|
||||
QT4_WRAP_CPP(qjoypad_HEADERS_MOC ${qjoypad_QOBJECT_HEADERS})
|
||||
add_executable(qjoypad ${qjoypad_SOURCES} ${qjoypad_HEADERS_MOC})
|
||||
qt4_wrap_cpp(qjoypad_HEADERS_MOC ${qjoypad_QOBJECT_HEADERS})
|
||||
add_executable(qjoypad ${qjoypad_SOURCES} ${qjoypad_HEADERS_MOC}) # ${qjoypad_TRANS})
|
||||
target_link_libraries(qjoypad ${QT_LIBRARIES} Xtst X11 ${LIBUDEV_LIBRARIES})
|
||||
|
||||
install(TARGETS qjoypad RUNTIME DESTINATION "bin")
|
||||
|
||||
@@ -266,6 +266,10 @@ bool Axis::isDefault() {
|
||||
(nuseMouse == false) ;
|
||||
}
|
||||
|
||||
QString Axis::getName() {
|
||||
return tr("Axis %1").arg(index+1);
|
||||
}
|
||||
|
||||
bool Axis::inDeadZone( int val ) {
|
||||
int value;
|
||||
if (throttle == 0)
|
||||
|
||||
@@ -43,7 +43,7 @@ class Axis : public QObject {
|
||||
void toDefault();
|
||||
//True iff currently at defaults
|
||||
bool isDefault();
|
||||
QString getName() { return tr("Axis %1").arg(index+1);}
|
||||
QString getName();
|
||||
//true iff the given value is in the dead zone for this axis.
|
||||
bool inDeadZone( int val );
|
||||
//a descriptive string used as a label for the button representing this axis
|
||||
|
||||
@@ -123,6 +123,10 @@ bool Button::isDefault() {
|
||||
(keycode == 0);
|
||||
}
|
||||
|
||||
QString Button::getName() {
|
||||
return tr("Button %1").arg(index+1);
|
||||
}
|
||||
|
||||
QString Button::status() {
|
||||
if (useMouse) {
|
||||
return tr("%1 : Mouse %2").arg(getName()).arg(keycode);
|
||||
|
||||
@@ -29,7 +29,7 @@ class Button : public QObject {
|
||||
//True iff is currently using default settings
|
||||
bool isDefault();
|
||||
//returns a string representation of this button.
|
||||
QString getName() { return tr("Button %1").arg(index+1); }
|
||||
QString getName();
|
||||
//a descriptive string used as a label for the button representing this axis
|
||||
QString status();
|
||||
//set the key code for this axis. Used by quickset.
|
||||
|
||||
@@ -12,11 +12,13 @@ inline void errorBox(const QString &type, const QString &message, QWidget *paren
|
||||
message, QMessageBox::Ok, Qt::NoButton);
|
||||
}
|
||||
|
||||
inline void debug_mesg(const char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||
|
||||
#ifdef _DEBUG
|
||||
inline void debug_mesg(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, NULL);
|
||||
vprintf(fmt, ap);
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//Modified here (and in .h) to not have default arguments for 2 and 3.
|
||||
//This caused an error with a development version of g++ on a Mandrake system
|
||||
//in Sweden.
|
||||
FlashButton::FlashButton( QString text, QString name, QWidget* parent )
|
||||
FlashButton::FlashButton(const QString &text, const QString &name, QWidget* parent )
|
||||
: QPushButton( text, parent )
|
||||
{
|
||||
this->setObjectName(name);
|
||||
|
||||
@@ -16,7 +16,7 @@ class FlashButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FlashButton(QString text, QString name = "" , QWidget* parent = 0);
|
||||
FlashButton(const QString& text, const QString& name = "" , QWidget* parent = 0);
|
||||
public slots:
|
||||
//make the button turn blue if it was gray, or visa versa.
|
||||
void flash();
|
||||
|
||||
@@ -101,6 +101,18 @@ void JoyPad::open(int dev) {
|
||||
debug_mesg("done resetting to dev\n");
|
||||
}
|
||||
|
||||
const QString &JoyPad::getDeviceId() const {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
QString JoyPad::getName() const {
|
||||
return tr("Joystick %1 (%2)").arg(index+1).arg(deviceId);
|
||||
}
|
||||
|
||||
int JoyPad::getIndex() const {
|
||||
return index;
|
||||
}
|
||||
|
||||
void JoyPad::toDefault() {
|
||||
//to reset the whole, reset all the parts.
|
||||
foreach (Axis *axis, axes) {
|
||||
|
||||
@@ -41,9 +41,9 @@ class JoyPad : public QObject {
|
||||
bool isDefault();
|
||||
//read the dimensions on the real joystick and use them
|
||||
void open( int dev );
|
||||
const QString& getDeviceId() const { return deviceId; }
|
||||
QString getName() const { return tr("Joystick %1 (%2)").arg(index+1).arg(deviceId); }
|
||||
int getIndex() const { return index; }
|
||||
const QString& getDeviceId() const;
|
||||
QString getName() const;
|
||||
int getIndex() const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
24
src/main.cpp
24
src/main.cpp
@@ -62,8 +62,8 @@ int main( int argc, char **argv )
|
||||
|
||||
//if there is no new directory and we can't make it, complain
|
||||
if (!dir.exists() && !dir.mkdir(settingsDir)) {
|
||||
errorBox(app.tr("Couldn't create the QJoyPad save directory"),
|
||||
app.tr("Couldn't create the QJoyPad save directory: %s").arg(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));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ int main( int argc, char **argv )
|
||||
|
||||
switch (c) {
|
||||
case 'h':
|
||||
printf("%s", qPrintable(app.tr("%1\n"
|
||||
printf("%s", qPrintable(app.translate("main","%1\n"
|
||||
"Usage: %2 [--device=\"/device/path\"] [--notray|--force-tray] [\"layout name\"]\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
@@ -102,7 +102,7 @@ int main( int argc, char **argv )
|
||||
" -d, --device=PATH Look for joystick devices in PATH. This should\n"
|
||||
" be something like \"/dev/input\" if your game\n"
|
||||
" devices are in /dev/input/js0, /dev/input/js1, etc.\n"
|
||||
" -t, --force-tray Forece to use a system tray icon.\n"
|
||||
" -t, --force-tray Force to use a system tray icon.\n"
|
||||
" -T, --notray Do not use a system tray icon. This is useful for\n"
|
||||
" window managers that don't support this feature.\n"
|
||||
" -u, --update Force a running instance of QJoyPad to update its\n"
|
||||
@@ -117,8 +117,8 @@ int main( int argc, char **argv )
|
||||
devdir = optarg;
|
||||
}
|
||||
else {
|
||||
errorBox(app.tr("Not a directory"),
|
||||
app.tr("Path is not a directory: %1").arg(optarg));
|
||||
errorBox(app.translate("main","Not a directory"),
|
||||
app.translate("main","Path is not a directory: %1").arg(optarg));
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@@ -137,7 +137,7 @@ int main( int argc, char **argv )
|
||||
break;
|
||||
|
||||
case '?':
|
||||
fprintf(stderr, "%s", qPrintable(app.tr(
|
||||
fprintf(stderr, "%s", qPrintable(app.translate("main",
|
||||
"Illeagal argument.\n"
|
||||
"See `%1 --help` for more information\n").arg(argc > 0 ? argv[0] : "qjoypad")));
|
||||
return 1;
|
||||
@@ -148,7 +148,7 @@ int main( int argc, char **argv )
|
||||
layout = argv[optind ++];
|
||||
|
||||
if (optind < argc) {
|
||||
fprintf(stderr, "%s", qPrintable(app.tr(
|
||||
fprintf(stderr, "%s", qPrintable(app.translate("main",
|
||||
"Too many arguments.\n"
|
||||
"See `%1 --help` for more information\n").arg(argc > 0 ? argv[0] : "qjoypad")));
|
||||
return 1;
|
||||
@@ -190,8 +190,8 @@ int main( int argc, char **argv )
|
||||
//however, if we are setting the layout or updating the device
|
||||
//list, this is not an error and we shouldn't make one!
|
||||
if (layout.isEmpty() && !update)
|
||||
errorBox(app.tr("Instance Error"),
|
||||
app.tr("There is already a running instance of QJoyPad; please close\nthe old instance before starting a new one."));
|
||||
errorBox(app.translate("main","Instance Error"),
|
||||
app.translate("main","There is already a running instance of QJoyPad; please close\nthe old instance before starting a new one."));
|
||||
else {
|
||||
//if one of these is the case, send the approrpriate signal!
|
||||
if (update) {
|
||||
@@ -219,8 +219,8 @@ int main( int argc, char **argv )
|
||||
sleep(1);
|
||||
sleepCounter++;
|
||||
if (sleepCounter > 20) {
|
||||
errorBox(app.tr("System tray isn't loading"),
|
||||
app.tr("Waited more than 20 seconds for the system tray to load. Giving up."));
|
||||
errorBox(app.translate("main","System tray isn't loading"),
|
||||
app.translate("main","Waited more than 20 seconds for the system tray to load. Giving up."));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user