added config.h.in and moved some defines there

This commit is contained in:
Mathias Panzenböck
2014-02-16 18:04:32 +01:00
parent d76571babf
commit 6a91eca365
13 changed files with 57 additions and 31 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -1,3 +1,4 @@
#include "config.h"
#include "button_edit.h"
#include <QHBoxLayout>
@ -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);

15
src/config.h.in Normal file
View File

@ -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

View File

@ -25,8 +25,6 @@
#define SENSITIVITY_MIN 1e-8F
#define SENSITIVITY_MAX 1e+8F
#define NAME "QJoyPad 4.1"
#define MOUSE_OFFSET 400
#endif

View File

@ -3,10 +3,12 @@
#include <qmessagebox.h>
#include <stdarg.h>
#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);
}

View File

@ -1,4 +1,5 @@
#include <QX11Info>
#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

View File

@ -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);

View File

@ -1,5 +1,6 @@
#include "layout.h"
#include <errno.h>
#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);

View File

@ -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);

View File

@ -1,12 +1,14 @@
#define MAIN
//to create a qapplication
#include <QFile>
//for ouput when there is no GUI going
#include <stdio.h>
#include <unistd.h>
//to create and handle signals for various events
#include <signal.h>
#include <getopt.h>
//to create a qapplication
#include <QFile>
#include <QSystemTrayIcon>
#include <QPointer>
//to load layouts
#include "layout.h"
@ -14,9 +16,7 @@
#include "event.h"
//to produce errors!
#include "error.h"
#include <QSystemTrayIcon>
#include <QPointer>
#include <getopt.h>
#include "config.h"
//variables needed in various functions in this file
QPointer<LayoutManager> 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':