diff --git a/CMakeLists.txt b/CMakeLists.txt index 9453b1c..26f4ba4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 2.8.8) project(qjoypad) +set(QJOYPAD_MAJOR 4) +set(QJOYPAD_MINOR 1) +set(QJOYPAD_PATCH 0) + find_package(Qt4 REQUIRED) set(DEVICE_DIR "/dev/input" CACHE PATH "Set the path where QJoyPad will look for your joystick devices. If your devices are /dev/js0, /dev/js1, etc., this should be just \"/dev\". By default, this is /dev/input.") @@ -9,7 +13,6 @@ set(DEVICE_DIR "/dev/input" CACHE PATH "Set the path where QJoyPad will look for set(PLAIN_KEYS OFF CACHE BOOL "Force QJoyPad to use standard XWindows keynames without filtering them for appearance. This will make displays less attractive and readable, but will save processor power and ensure that you see the right names for keys you press.") message("-- Using device directory: ${DEVICE_DIR}") -add_definitions(-DDEVDIR="${DEVICE_DIR}") if(PLAIN_KEYS) message("-- Using regular XWindows key names.") @@ -30,8 +33,9 @@ endif() include(${QT_USE_FILE}) add_definitions(${QT_DEFINITIONS}) -add_definitions(-DICON24="${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/24x24/apps/qjoypad.png") -add_definitions(-DICON64="${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/64x64/apps/qjoypad.png") + +# for config.h +include_directories("${PROJECT_BINARY_DIR}/src") add_subdirectory(icons) add_subdirectory(src) diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt index 216781b..2733874 100644 --- a/icons/CMakeLists.txt +++ b/icons/CMakeLists.txt @@ -1,2 +1,2 @@ install(FILES gamepad4-24x24.png DESTINATION "share/icons/hicolor/24x24/apps" RENAME qjoypad.png) -install(FILES gamepad3-64x64.png DESTINATION "share/icons/hicolor/64x64/apps" RENAME qjoypad.png) +install(FILES gamepad4-64x64.png DESTINATION "share/icons/hicolor/64x64/apps" RENAME qjoypad.png) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eb21e4e..d63e776 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,7 @@ +include(GenerateExportHeader) + +configure_file(config.h.in "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY) + set(qjoypad_SOURCES axis.cpp axis_edit.cpp @@ -36,8 +40,6 @@ set(qjoypad_QOBJECT_HEADERS layout.h quickset.h) -set(qjoypad_HEADERS ${qjoypad_QOBJECT_HEADERS} constant.h error.h event.h) - QT4_WRAP_CPP(qjoypad_HEADERS_MOC ${qjoypad_QOBJECT_HEADERS}) add_executable(qjoypad ${qjoypad_SOURCES} ${qjoypad_HEADERS_MOC}) target_link_libraries(qjoypad ${QT_LIBRARIES} Xtst X11) diff --git a/src/axis_edit.cpp b/src/axis_edit.cpp index c2c1a90..2bbf3f5 100644 --- a/src/axis_edit.cpp +++ b/src/axis_edit.cpp @@ -1,3 +1,4 @@ +#include "config.h" #include "axis_edit.h" @@ -6,7 +7,7 @@ AxisEdit::AxisEdit( Axis* ax ) //build the dialog, display current axis settings :) axis = ax; setWindowTitle("Set " + axis->getName()); - setWindowIcon(QPixmap(ICON24)); + setWindowIcon(QPixmap(QJOYPAD_ICON24)); //h, v, and v2 are all references to layouts. They are used to refer to //various layouts as the dialog is built and are not pointing to the same diff --git a/src/button_edit.cpp b/src/button_edit.cpp index dc3c8a9..93985f0 100644 --- a/src/button_edit.cpp +++ b/src/button_edit.cpp @@ -1,3 +1,4 @@ +#include "config.h" #include "button_edit.h" #include @@ -9,7 +10,7 @@ ButtonEdit::ButtonEdit(Button* butt) //build the dialog! button = butt; setWindowTitle("Set " + button->getName()); - setWindowIcon(QPixmap(ICON24)); + setWindowIcon(QPixmap(QJOYPAD_ICON24)); QVBoxLayout* v = new QVBoxLayout(this); v->setMargin(5); diff --git a/src/config.h.in b/src/config.h.in new file mode 100644 index 0000000..467e576 --- /dev/null +++ b/src/config.h.in @@ -0,0 +1,15 @@ +#ifndef QJOYPAD_CONFIG_H_IN +#define QJOYPAD_CONFIG_H_IN + +#cmakedefine QJOYPAD_MAJOR +#cmakedefine QJOYPAD_MINOR +#cmakedefine QJOYPAD_PATCH + +#define QJOYPAD_VERSION "@QJOYPAD_MAJOR@.@QJOYPAD_MINOR@.@QJOYPAD_PATCH@" +#define QJOYPAD_NAME "QJoyPad @QJOYPAD_MAJOR@.@QJOYPAD_MINOR@" +#define QJOYPAD_DEVDIR "@DEVICE_DIR@" + +#define QJOYPAD_ICON24 "@CMAKE_INSTALL_PREFIX@/share/icons/hicolor/24x24/apps/qjoypad.png" +#define QJOYPAD_ICON64 "@CMAKE_INSTALL_PREFIX@/share/icons/hicolor/64x64/apps/qjoypad.png" + +#endif diff --git a/src/constant.h b/src/constant.h index def9f79..f415b94 100644 --- a/src/constant.h +++ b/src/constant.h @@ -25,8 +25,6 @@ #define SENSITIVITY_MIN 1e-8F #define SENSITIVITY_MAX 1e+8F -#define NAME "QJoyPad 4.1" - #define MOUSE_OFFSET 400 #endif diff --git a/src/error.h b/src/error.h index 22346d0..2b4e03f 100644 --- a/src/error.h +++ b/src/error.h @@ -3,10 +3,12 @@ #include #include +#include "config.h" + //a nice simple way of throwing up an error message if something goes wrong. inline void errorBox(const QString &type, const QString &message, QWidget *parent = 0) { - QMessageBox::warning(parent, QString("%1 - %2").arg(NAME, type), + QMessageBox::warning(parent, QString("%1 - %2").arg(QJOYPAD_DEVDIR, type), message, QMessageBox::Ok, Qt::NoButton); } diff --git a/src/getkey.cpp b/src/getkey.cpp index 8c93c47..d4d6660 100644 --- a/src/getkey.cpp +++ b/src/getkey.cpp @@ -1,4 +1,5 @@ #include +#include "config.h" #include "getkey.h" GetKey::GetKey( QString button, bool m ) @@ -7,7 +8,7 @@ GetKey::GetKey( QString button, bool m ) //prepare the dialog mouse = m; setWindowTitle( "Choose a key" ); - setWindowIcon(QIcon(ICON24)); + setWindowIcon(QIcon(QJOYPAD_ICON24)); //I'd use a QLabel, but that steals x11Events! //So, I'll draw the text directly. That means diff --git a/src/icon.cpp b/src/icon.cpp index e95b4b4..224f83a 100644 --- a/src/icon.cpp +++ b/src/icon.cpp @@ -1,10 +1,10 @@ #include "icon.h" - +#include "config.h" FloatingIcon::FloatingIcon( const QPixmap &icon, QMenu *popup, QWidget *parent, const char *name) : QDialog( parent ) { this->setObjectName(name); - setWindowTitle(NAME); + setWindowTitle(QJOYPAD_NAME); QPalette palette; palette.setBrush(backgroundRole(), QBrush(icon)); setPalette(palette); diff --git a/src/layout.cpp b/src/layout.cpp index 6d193bc..3160b28 100644 --- a/src/layout.cpp +++ b/src/layout.cpp @@ -1,5 +1,6 @@ -#include "layout.h" #include +#include "layout.h" +#include "config.h" //initialize things and set up an icon :) LayoutManager::LayoutManager( bool useTrayIcon, const QString &devdir, const QString &settingsDir ) @@ -18,13 +19,13 @@ LayoutManager::LayoutManager( bool useTrayIcon, const QString &devdir, const QSt if (useTrayIcon) { QSystemTrayIcon *tray = new QSystemTrayIcon(this); tray->setContextMenu(&trayMenu); - tray->setIcon(QIcon(ICON24)); + tray->setIcon(QIcon(QJOYPAD_ICON24)); tray->show(); connect(tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayClick(QSystemTrayIcon::ActivationReason))); } //or make a floating icon else { - FloatingIcon* icon = new FloatingIcon(QPixmap(ICON64),&trayMenu,0,"tray"); + FloatingIcon* icon = new FloatingIcon(QPixmap(QJOYPAD_ICON64),&trayMenu,0,"tray"); connect(icon, SIGNAL( clicked()), this, SLOT( iconClick())); connect(icon, SIGNAL( closed()), qApp, SLOT( quit())); icon->show(); @@ -188,7 +189,7 @@ void LayoutManager::save() { //if it's good, start writing the file if (file.open(QIODevice::WriteOnly)) { QTextStream stream( &file ); - stream << "# " NAME " Layout File\n\n"; + stream << "# " QJOYPAD_NAME " Layout File\n\n"; foreach (JoyPad *joypad, joypads) { joypad->write( stream ); } @@ -203,7 +204,7 @@ void LayoutManager::save() { void LayoutManager::saveAs() { bool ok; //request a new name! - QString name = QInputDialog::getText(0, NAME" - Name new layout","Enter a name for the new layout:", QLineEdit::Normal, QString::null, &ok ); + QString name = QInputDialog::getText(0, QJOYPAD_NAME" - Name new layout","Enter a name for the new layout:", QLineEdit::Normal, QString::null, &ok ); if (!ok) { return; } @@ -237,7 +238,7 @@ void LayoutManager::saveDefault() { void LayoutManager::remove() { if (currentLayout == NL) return; - if (QMessageBox::warning( 0, NAME" - Delete layout?","Remove layout permanently from your hard drive?", "Yes", "No", 0, 0, 1 ) == 1) return; + if (QMessageBox::warning( 0, QJOYPAD_NAME" - Delete layout?","Remove layout permanently from your hard drive?", "Yes", "No", 0, 0, 1 ) == 1) return; QString filename = getFileName( currentLayout ); if (!QFile(filename).remove()) { errorBox("Remove error", "Could not remove file " + filename); diff --git a/src/layout_edit.cpp b/src/layout_edit.cpp index 7351013..8540d9e 100644 --- a/src/layout_edit.cpp +++ b/src/layout_edit.cpp @@ -1,11 +1,12 @@ #include "layout_edit.h" +#include "config.h" //build the dialog LayoutEdit::LayoutEdit( LayoutManager* l ): QWidget(NULL) { lm = l; setAttribute(Qt::WA_DeleteOnClose); - setWindowTitle( NAME ); - setWindowIcon(QPixmap(ICON24)); + setWindowTitle( QJOYPAD_NAME ); + setWindowIcon(QPixmap(QJOYPAD_ICON64)); mainLayout = new QVBoxLayout( this); mainLayout->setSpacing(5); diff --git a/src/main.cpp b/src/main.cpp index 973f904..f216374 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,12 +1,14 @@ -#define MAIN - -//to create a qapplication -#include //for ouput when there is no GUI going #include #include //to create and handle signals for various events #include +#include + +//to create a qapplication +#include +#include +#include //to load layouts #include "layout.h" @@ -14,9 +16,7 @@ #include "event.h" //to produce errors! #include "error.h" -#include -#include -#include +#include "config.h" //variables needed in various functions in this file QPointer layoutManagerPtr; @@ -58,7 +58,7 @@ int main( int argc, char **argv ) QDir dir(settingsDir); //the directory in wich the joystick devices are (e.g. "/dev/input") - QString devdir = DEVDIR; + QString devdir = QJOYPAD_DEVDIR; //if there is no new directory and we can't make it, complain if (!dir.exists() && !dir.mkdir(settingsDir)) { @@ -108,7 +108,7 @@ int main( int argc, char **argv ) " list of devices and layouts.\n" " \"layout name\" Load the given layout in an already running\n" " instance of QJoyPad, or start QJoyPad using the\n" - " given layout.\n", NAME, argc > 0 ? argv[0] : "qjoypad"); + " given layout.\n", QJOYPAD_NAME, argc > 0 ? argv[0] : "qjoypad"); return 0; case 'd':