added config.h.in and moved some defines there
This commit is contained in:
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
15
src/config.h.in
Normal 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
|
@ -25,8 +25,6 @@
|
||||
#define SENSITIVITY_MIN 1e-8F
|
||||
#define SENSITIVITY_MAX 1e+8F
|
||||
|
||||
#define NAME "QJoyPad 4.1"
|
||||
|
||||
#define MOUSE_OFFSET 400
|
||||
|
||||
#endif
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
18
src/main.cpp
18
src/main.cpp
@ -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':
|
||||
|
Reference in New Issue
Block a user