[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bwacomtablet=5D_src/kcmodule=3A_pad/touch_mapping_ta?=
From: Jörg_Ehrichs <Joerg.Ehrichs () gmx ! de>
Date: 2011-03-31 21:14:16
Message-ID: 20110331211416.9FCA3A60AE () git ! kde ! org
[Download RAW message or body]
Git commit 07f7f48ed6206914007d996f2e1aed17b1bb2bf7 by Jörg Ehrichs.
Committed on 31/03/2011 at 21:45.
Pushed by jehrichs into branch 'master'.
pad/touch mapping tab added. First version of graphical tablet representation for \
easy calibration
M +1 -0 src/kcmodule/CMakeLists.txt
M +87 -148 src/kcmodule/padmapping.cpp
M +5 -4 src/kcmodule/padmapping.h
M +218 -347 src/kcmodule/padmapping.ui
A +382 -0 src/kcmodule/tabletarea.cpp [License: GPL (v2+)]
A +79 -0 src/kcmodule/tabletarea.h [License: GPL (v2+)]
M +12 -0 src/kcmodule/tabletwidget.cpp
M +1 -0 src/kcmodule/tabletwidget.h
http://commits.kde.org/wacomtablet/07f7f48ed6206914007d996f2e1aed17b1bb2bf7
diff --git a/src/kcmodule/CMakeLists.txt b/src/kcmodule/CMakeLists.txt
index 970764b..946a76f 100644
--- a/src/kcmodule/CMakeLists.txt
+++ b/src/kcmodule/CMakeLists.txt
@@ -14,6 +14,7 @@ set( kcm_tablet_SRCS
tabletwidget.cpp
calibrationdialog.cpp
touchwidget.cpp
+ tabletarea.cpp
)
kde4_add_ui_files( kcm_tablet_SRCS
diff --git a/src/kcmodule/padmapping.cpp b/src/kcmodule/padmapping.cpp
index be575da..dc89e1d 100644
--- a/src/kcmodule/padmapping.cpp
+++ b/src/kcmodule/padmapping.cpp
@@ -21,6 +21,8 @@
#include "profilemanagement.h"
#include "calibrationdialog.h"
+#include "tabletarea.h"
+
//KDE includes
#include <KDE/KDebug>
#include <KDE/KSharedConfigPtr>
@@ -61,74 +63,74 @@ PadMapping::~PadMapping()
delete m_ui;
}
-void PadMapping::saveToProfile()
+void PadMapping::setTool( int tool )
{
- // save current calibration area to the right temp rect
- if( m_ui->toolCombobox->currentIndex() == 0 ) {
- m_stylusArea.setX( m_ui->topX->value() );
- m_stylusArea.setY( m_ui->topY->value() );
- m_stylusArea.setWidth( m_ui->bottomX->value() );
- m_stylusArea.setHeight( m_ui->bottomY->value() );
+ m_tool = tool;
+
+ m_tabletArea = new TabletArea();
+
+ QString toolName;
+ if( tool == 0 ) {
+ QDBusReply<QString> stylusName = m_deviceInterface->call( QLatin1String( \
"stylusName" ) ); + toolName = stylusName.value();
}
- else {
- m_touchArea.setX( m_ui->topX->value() );
- m_touchArea.setY( m_ui->topY->value() );
- m_touchArea.setWidth( m_ui->bottomX->value() );
- m_touchArea.setHeight( m_ui->bottomY->value() );
+ else if( tool == 1 ) {
+ QDBusReply<QString> touchName = m_deviceInterface->call( QLatin1String( \
"touchName" ) ); + toolName = touchName.value();
}
- // read in from stylus.
- // values for stylus/eraser/touch will be the same
- KConfigGroup stylusConfig = m_profileManagement->configGroup( QLatin1String( \
"stylus" ) );
- KConfigGroup eraserConfig = m_profileManagement->configGroup( QLatin1String( \
"eraser" ) ); + m_tabletArea->setTool( toolName );
+ m_ui->tabletAreaBox->layout()->addWidget( m_tabletArea );
- stylusConfig.writeEntry( QLatin1String( "Rotate" ), \
m_ui->rotationComboBox->currentIndex() );
- eraserConfig.writeEntry( QLatin1String( "Rotate" ), \
m_ui->rotationComboBox->currentIndex() ); + connect( m_tabletArea, SIGNAL( \
selectedArea( QString ) ), this, SLOT( profileChanged() ) ); +}
- if( !m_ui->screenComboBox->currentText().isEmpty() ) {
- stylusConfig.writeEntry( QLatin1String( "MapToOutput" ), \
m_ui->screenComboBox->currentText() );
- eraserConfig.writeEntry( QLatin1String( "MapToOutput" ), \
m_ui->screenComboBox->currentText() );
- }
+void PadMapping::saveToProfile()
+{
+ if( m_tool == 0 ) {
+ // read in from stylus.
+ // values for stylus/eraser/touch will be the same
+ KConfigGroup stylusConfig = m_profileManagement->configGroup( QLatin1String( \
"stylus" ) ); + KConfigGroup eraserConfig = m_profileManagement->configGroup( \
QLatin1String( "eraser" ) );
- if( m_ui->xrandrRotationCheckBox->isChecked() ) {
- stylusConfig.writeEntry( QLatin1String( "RotateWithScreen" ), "true" );
- eraserConfig.writeEntry( QLatin1String( "RotateWithScreen" ), "true" );
- }
- else {
- stylusConfig.writeEntry( QLatin1String( "RotateWithScreen" ), "false" );
- eraserConfig.writeEntry( QLatin1String( "RotateWithScreen" ), "false" );
- }
+ stylusConfig.writeEntry( QLatin1String( "Rotate" ), \
m_ui->rotationComboBox->currentIndex() ); + eraserConfig.writeEntry( \
QLatin1String( "Rotate" ), m_ui->rotationComboBox->currentIndex() );
- if( m_ui->workingAreaBox->isChecked() ) {
- stylusConfig.writeEntry( QLatin1String( "0ChangeArea" ), "true" );
- eraserConfig.writeEntry( QLatin1String( "0ChangeArea" ), "true" );
- }
- else {
- stylusConfig.writeEntry( QLatin1String( "0ChangeArea" ), "false" );
- eraserConfig.writeEntry( QLatin1String( "0ChangeArea" ), "false" );
- }
+ if( m_ui->xrandrRotationCheckBox->isChecked() ) {
+ stylusConfig.writeEntry( QLatin1String( "RotateWithScreen" ), "true" );
+ eraserConfig.writeEntry( QLatin1String( "RotateWithScreen" ), "true" );
+ }
+ else {
+ stylusConfig.writeEntry( QLatin1String( "RotateWithScreen" ), "false" );
+ eraserConfig.writeEntry( QLatin1String( "RotateWithScreen" ), "false" );
+ }
- stylusConfig.writeEntry( QLatin1String( "Area" ), QString::fromLatin1( "%1 %2 %3 \
%4" )
- .arg( m_stylusArea.x() ).arg( m_stylusArea.y() )
- .arg( m_stylusArea.width() ).arg( m_stylusArea.height() \
) );
- eraserConfig.writeEntry( QLatin1String( "Area" ), QString::fromLatin1( "%1 %2 %3 \
%4" )
- .arg( m_stylusArea.x() ).arg( m_stylusArea.y() )
- .arg( m_stylusArea.width() ).arg( m_stylusArea.height() \
) ); + if( !m_ui->screenComboBox->currentText().isEmpty() || \
m_ui->screenComboBox->currentIndex() != 0 ) { + stylusConfig.writeEntry( \
QLatin1String( "MapToOutput" ), m_ui->screenComboBox->currentText() ); + \
eraserConfig.writeEntry( QLatin1String( "MapToOutput" ), \
m_ui->screenComboBox->currentText() ); + }
- stylusConfig.sync();
- eraserConfig.sync();
+ if( m_ui->fullTablet->isChecked() ) {
+ stylusConfig.writeEntry( QLatin1String( "0ChangeArea" ), "true" );
+ eraserConfig.writeEntry( QLatin1String( "0ChangeArea" ), "true" );
+ }
+ else {
+ stylusConfig.writeEntry( QLatin1String( "0ChangeArea" ), "false" );
+ eraserConfig.writeEntry( QLatin1String( "0ChangeArea" ), "false" );
+ }
- // if we have a touch device, update these values too
- QDBusReply<QString> touchName = m_deviceInterface->call( QLatin1String( \
"touchName" ) ); + stylusConfig.writeEntry( QLatin1String( "Area" ), \
m_tabletArea->getSelectedAreaString() ); + eraserConfig.writeEntry( \
QLatin1String( "Area" ), m_tabletArea->getSelectedAreaString() );
- QString validName = touchName.value();
- if( !validName.isEmpty() ) {
+ stylusConfig.sync();
+ eraserConfig.sync();
+ }
+ else if( m_tool == 1 ) {
+ // read in from stylus.
+ // values for stylus/eraser/touch will be the same
KConfigGroup touchConfig = m_profileManagement->configGroup( QLatin1String( \
"touch" ) );
- touchConfig.writeEntry( QLatin1String( "Rotate" ), \
m_ui->rotationComboBox->currentIndex() );
- if( !m_ui->screenComboBox->currentText().isEmpty() ) {
- touchConfig.writeEntry( QLatin1String( "MapToOutput" ), \
m_ui->screenComboBox->currentText() );
- }
+ touchConfig.writeEntry( QLatin1String( "Rotate" ), \
m_ui->rotationComboBox->currentIndex() );
if( m_ui->xrandrRotationCheckBox->isChecked() ) {
touchConfig.writeEntry( QLatin1String( "RotateWithScreen" ), "true" );
@@ -137,16 +139,18 @@ void PadMapping::saveToProfile()
touchConfig.writeEntry( QLatin1String( "RotateWithScreen" ), "false" );
}
- if( m_ui->workingAreaBox->isChecked() ) {
+ if( !m_ui->screenComboBox->currentText().isEmpty() || \
m_ui->screenComboBox->currentIndex() != 0 ) { + touchConfig.writeEntry( \
QLatin1String( "MapToOutput" ), m_ui->screenComboBox->currentText() ); + }
+
+ if( m_ui->fullTablet->isChecked() ) {
touchConfig.writeEntry( QLatin1String( "0ChangeArea" ), "true" );
}
else {
touchConfig.writeEntry( QLatin1String( "0ChangeArea" ), "false" );
}
- touchConfig.writeEntry( QLatin1String( "Area" ), QString::fromLatin1( "%1 %2 \
%3 %4" )
- .arg( m_touchArea.x() ).arg( m_touchArea.y() )
- .arg( m_touchArea.width() ).arg( \
m_touchArea.height() ) ); + touchConfig.writeEntry( QLatin1String( "Area" ), \
m_tabletArea->getSelectedAreaString() );
touchConfig.sync();
}
@@ -155,63 +159,32 @@ void PadMapping::saveToProfile()
void PadMapping::loadFromProfile()
{
// read in from stylus.
- // values for stylus/eraser/touch will be the same
- KConfigGroup stylusConfig = m_profileManagement->configGroup( QLatin1String( \
"stylus" ) );
-
- m_ui->rotationComboBox->setCurrentIndex( stylusConfig.readEntry( QLatin1String( \
"Rotate" ) ).toInt() ); + // values for stylus/eraser will be the same
+ KConfigGroup config;
- if( stylusConfig.readEntry( QLatin1String( "RotateWithScreen" ) ) == \
QLatin1String( "true" ) ) {
- m_ui->xrandrRotationCheckBox->setChecked( true );
+ if( m_tool == 0 ) {
+ config = m_profileManagement->configGroup( QLatin1String( "stylus" ) );
}
-
- int index = m_ui->screenComboBox->findText( stylusConfig.readEntry( \
QLatin1String( "MapToOutput" ) ) );
- m_ui->screenComboBox->setCurrentIndex( index );
-
-
- if( stylusConfig.readEntry( QLatin1String( "0ChangeArea" ) ) == QLatin1String( \
"true" ) ) {
- m_ui->workingAreaBox->setChecked( true );
+ else {
+ config = m_profileManagement->configGroup( QLatin1String( "touch" ) );
}
- // check if we have a touch tool available
- // this means we want to calibrate the tablet area in two different ways
- QDBusReply<QString> touchName = m_deviceInterface->call( QLatin1String( \
"touchName" ) );
-
- QString validName = touchName.value();
- if( !validName.isEmpty() ) {
- KConfigGroup touchConfig = m_profileManagement->configGroup( QLatin1String( \
"touch" ) );
-
- QString workingArea = touchConfig.readEntry( QLatin1String( "Area" ) );
- QStringList waList = workingArea.split( QLatin1String( " " ) );
-
- if( waList.size() != 4 ) {
- kDebug() << "Error while parsing touch Area settings. Entry must have 4 \
ints seperated by a space. For example: 0 0 100 100";
- return;
- }
+ m_ui->rotationComboBox->setCurrentIndex( config.readEntry( QLatin1String( \
"Rotate" ) ).toInt() );
- m_touchArea.setX( waList.at( 0 ).toInt() );
- m_touchArea.setY( waList.at( 1 ).toInt() );
- m_touchArea.setWidth( waList.at( 2 ).toInt() );
- m_touchArea.setHeight( waList.at( 3 ).toInt() );
+ if( config.readEntry( QLatin1String( "RotateWithScreen" ) ) == QLatin1String( \
"true" ) ) { + m_ui->xrandrRotationCheckBox->setChecked( true );
}
- QString workingArea = stylusConfig.readEntry( QLatin1String( "Area" ) );
- QStringList waList = workingArea.split( QLatin1String( " " ) );
+ int index = m_ui->screenComboBox->findText( config.readEntry( QLatin1String( \
"MapToOutput" ) ) ); + m_ui->screenComboBox->setCurrentIndex( index );
- if( waList.size() != 4 ) {
- kDebug() << "Error while parsing Area settings. Entry must have 4 ints \
seperated by a space. For example: 0 0 100 100";
- return;
+ if( config.readEntry( QLatin1String( "0ChangeArea" ) ) == QLatin1String( "true" \
) ) { + m_ui->partOfTablet->setChecked( true );
}
- m_stylusArea.setX( waList.at( 0 ).toInt() );
- m_stylusArea.setY( waList.at( 1 ).toInt() );
- m_stylusArea.setWidth( waList.at( 2 ).toInt() );
- m_stylusArea.setHeight( waList.at( 3 ).toInt() );
+ QString workingArea = config.readEntry( QLatin1String( "Area" ) );
- // default to stylus/areaser area
- m_ui->topX->setValue( m_stylusArea.x() );
- m_ui->topY->setValue( m_stylusArea.y() );
- m_ui->bottomX->setValue( m_stylusArea.width() );
- m_ui->bottomY->setValue( m_stylusArea.height() );
+ m_tabletArea->setSelection( workingArea );
}
void PadMapping::profileChanged()
@@ -232,17 +205,6 @@ void PadMapping::reloadWidget()
}
m_ui->screenComboBox->blockSignals( false );
XRRFreeScreenResources( sr );
-
- // check if the connected tabled has touch features
- // hides the tool selection box if no touch is available
- // helps to reduce the ui clutter for "normal" tablets
- QDBusReply<QString> touchName = m_deviceInterface->call( QLatin1String( \
"touchName" ) );
-
- QString validName = touchName.value();
- if( validName.isEmpty() ) {
- m_ui->toolLabel->hide();
- m_ui->toolCombobox->hide();
- }
}
void PadMapping::showCalibrationDialog()
@@ -263,13 +225,14 @@ void PadMapping::showCalibrationDialog()
}
QString toolName;
- if( m_ui->toolCombobox->currentIndex() == 0 ) {
+
+ if( m_tool == 0 ) {
QDBusReply<QString> stylusName = m_deviceInterface->call( QLatin1String( \
"stylusName" ) ); toolName = stylusName.value();
}
else {
- QDBusReply<QString> touchName = m_deviceInterface->call( QLatin1String( \
"touchName" ) );
- toolName = touchName.value();
+ QDBusReply<QString> stylusName = m_deviceInterface->call( QLatin1String( \
"touchName" ) ); + toolName = stylusName.value();
}
CalibrationDialog cdlg( toolName );
@@ -277,11 +240,13 @@ void PadMapping::showCalibrationDialog()
cdlg.exec();
QRect newCalibration = cdlg.calibratedArea();
- m_ui->topX->setValue( newCalibration.x() );
- m_ui->topY->setValue( newCalibration.y() );
- m_ui->bottomX->setValue( newCalibration.width() );
- m_ui->bottomY->setValue( newCalibration.height() );
+ QString area = QString::fromLatin1( "%1 %2 %3 %4" )
+ .arg( newCalibration.x() )
+ .arg( newCalibration.y() )
+ .arg( newCalibration.width() )
+ .arg( newCalibration.height() );
+ m_tabletArea->setSelection( area );
if( oldstate ) {
config.writeEntry( QLatin1String( "Enabled" ), true );
@@ -293,29 +258,3 @@ void PadMapping::showCalibrationDialog()
QDBusConnection::sessionBus().send( message );
}
}
-
-void PadMapping::switchCalibrationTool()
-{
- if( m_ui->toolCombobox->currentIndex() == 1 ) {
- m_stylusArea.setX( m_ui->topX->value() );
- m_stylusArea.setY( m_ui->topY->value() );
- m_stylusArea.setWidth( m_ui->bottomX->value() );
- m_stylusArea.setHeight( m_ui->bottomY->value() );
-
- m_ui->topX->setValue( m_touchArea.x());
- m_ui->topY->setValue( m_touchArea.y());
- m_ui->bottomX->setValue( m_touchArea.width());
- m_ui->bottomY->setValue( m_touchArea.height());
- }
- else {
- m_touchArea.setX( m_ui->topX->value() );
- m_touchArea.setY( m_ui->topY->value() );
- m_touchArea.setWidth( m_ui->bottomX->value() );
- m_touchArea.setHeight( m_ui->bottomY->value() );
-
- m_ui->topX->setValue( m_stylusArea.x());
- m_ui->topY->setValue( m_stylusArea.y());
- m_ui->bottomX->setValue( m_stylusArea.width());
- m_ui->bottomY->setValue( m_stylusArea.height());
- }
-}
diff --git a/src/kcmodule/padmapping.h b/src/kcmodule/padmapping.h
index 0a1dd52..e3de104 100644
--- a/src/kcmodule/padmapping.h
+++ b/src/kcmodule/padmapping.h
@@ -31,6 +31,7 @@ class QDBusInterface;
namespace Wacom
{
class ProfileManagement;
+class TabletArea;
/**
* This class implements the widget to change the pad mapping
@@ -55,6 +56,8 @@ public:
*/
~PadMapping();
+ void setTool(int tool);
+
/**
* Saves all values to the current profile
*/
@@ -85,8 +88,6 @@ public slots:
*/
void showCalibrationDialog();
- void switchCalibrationTool();
-
signals:
/**
* Used to inform the main widget that unsaved changes in the current profile \
are available. @@ -98,8 +99,8 @@ private:
QDBusInterface *m_deviceInterface; /**< Connection to the tablet daemon \
DBus /Device Interface */
ProfileManagement *m_profileManagement; /**< Handler for the profile config \
connection */
- QRect m_stylusArea; /**< Calibrated area for the \
stylus/eraser tool */
- QRect m_touchArea; /**< Calibrated area for the touch \
tool */ + int m_tool;
+ TabletArea *m_tabletArea;
};
}
diff --git a/src/kcmodule/padmapping.ui b/src/kcmodule/padmapping.ui
index 3546be2..78cb426 100644
--- a/src/kcmodule/padmapping.ui
+++ b/src/kcmodule/padmapping.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>375</width>
- <height>348</height>
+ <width>413</width>
+ <height>342</height>
</rect>
</property>
<property name="windowTitle">
@@ -16,302 +16,206 @@
<property name="locale">
<locale language="English" country="UnitedKingdom"/>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
+ <layout class="QVBoxLayout" name="verticalLayout_4">
<item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Orientation</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="rotationLabel">
- <property name="text">
- <string comment="Rotation of the tablet pad">Rotation:</string>
- </property>
- <property name="buddy">
- <cstring>rotationComboBox</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KComboBox" name="rotationComboBox">
- <property name="toolTip">
- <string>Select the rotation of the tablet device.</string>
- </property>
- <item>
- <property name="text">
- <string comment="no pad rotation">none</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string comment="rotate the pad counter clock wise">couter \
clockwise</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string comment="rotate the tablet clockwise">clockwise</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string comment="pad rotation up side down (180 °)">half</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QCheckBox" name="xrandrRotationCheckBox">
- <property name="toolTip">
- <string>If enabled the tablet is automatically rotated together with the \
screen</string>
- </property>
- <property name="text">
- <string>Rotate tablet with screen</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="labelScreenN0">
- <property name="text">
- <string>Map to output:</string>
- </property>
- <property name="buddy">
- <cstring>screenComboBox</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="KComboBox" name="screenComboBox">
- <property name="toolTip">
- <string>Select the XRandR display which will be used to map the tablet \
area on it.</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="workingAreaBox">
- <property name="toolTip">
- <string>If enabled, the working area can be changed.
- If disabled the default values from xorg are used</string>
- </property>
- <property name="title">
- <string>Adjust Working Area</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <property name="spacing">
- <number>10</number>
- </property>
- <item>
- <widget class="QLabel" name="toolLabel">
- <property name="text">
- <string>Select Tool:</string>
- </property>
- <property name="buddy">
- <cstring>toolCombobox</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="toolCombobox">
- <item>
- <property name="text">
- <string>Stylus/Eraser</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Touch</string>
- </property>
- </item>
- </widget>
- </item>
- <item>
- <widget class="KPushButton" name="calibrateButton">
- <property name="toolTip">
- <string>Opens a fullscreen window to calibrate the tablet.</string>
- </property>
- <property name="text">
- <string>Calibrate Tablet</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="1">
- <widget class="KIntSpinBox" name="topX">
- <property name="toolTip">
- <string>X-Coordinate of the top left point</string>
- </property>
- <property name="minimum">
- <number>-99999</number>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Orientation</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="rotationLabel">
+ <property name="text">
+ <string comment="Rotation of the tablet pad">Rotation:</string>
</property>
- <property name="maximum">
- <number>99999</number>
+ <property name="buddy">
+ <cstring>rotationComboBox</cstring>
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="KIntSpinBox" name="topY">
+ <item row="0" column="1">
+ <widget class="KComboBox" name="rotationComboBox">
<property name="toolTip">
- <string>Y-Coordinate of the top right point</string>
- </property>
- <property name="minimum">
- <number>-99999</number>
- </property>
- <property name="maximum">
- <number>99999</number>
+ <string>Select the rotation of the tablet device.</string>
</property>
+ <item>
+ <property name="text">
+ <string comment="no pad rotation">none</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string comment="rotate the pad counter clock wise">couter \
clockwise</string> + </property>
+ </item>
+ <item>
+ <property name="text">
+ <string comment="rotate the tablet clockwise">clockwise</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string comment="pad rotation up side down (180 °)">half</string>
+ </property>
+ </item>
</widget>
</item>
- <item row="2" column="0">
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ <item row="1" column="0" colspan="2">
+ <widget class="QCheckBox" name="xrandrRotationCheckBox">
+ <property name="toolTip">
+ <string>If enabled the tablet is automatically rotated together with \
the screen</string> </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
+ <property name="text">
+ <string>Rotate with screen</string>
</property>
- </spacer>
+ </widget>
</item>
- <item row="2" column="3">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Screen Area</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout_2">
+ <property name="labelAlignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ <property name="horizontalSpacing">
+ <number>10</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>-1</number>
+ </property>
+ <property name="margin">
+ <number>8</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QRadioButton" name="radioButton">
+ <property name="text">
+ <string>Map to output</string>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
+ <property name="checked">
+ <bool>true</bool>
</property>
- </spacer>
+ </widget>
</item>
- <item row="3" column="3">
- <widget class="KIntSpinBox" name="bottomY">
+ <item row="0" column="1">
+ <widget class="KComboBox" name="screenComboBox">
<property name="toolTip">
- <string>Height of the used tablet area</string>
- </property>
- <property name="minimum">
- <number>-99999</number>
- </property>
- <property name="maximum">
- <number>99999</number>
+ <string>Select the XRandR display which will be used to map the tablet \
area on it.</string> </property>
+ <item>
+ <property name="text">
+ <string>---</string>
+ </property>
+ </item>
</widget>
</item>
- <item row="4" column="1">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
+ <item row="1" column="0">
+ <widget class="QRadioButton" name="radioButton_2">
+ <property name="text">
+ <string>Part of the Screen</string>
</property>
- </spacer>
+ </widget>
</item>
- <item row="4" column="2">
- <widget class="KIntSpinBox" name="bottomX">
- <property name="toolTip">
- <string>Width of the tablet area</string>
- </property>
- <property name="maximum">
- <number>99999</number>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>Tablet Area</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QRadioButton" name="fullTablet">
+ <property name="text">
+ <string>Full tablet</string>
</property>
- <property name="value">
- <number>0</number>
+ <property name="checked">
+ <bool>true</bool>
</property>
</widget>
</item>
- <item row="1" column="1" rowspan="3" colspan="2">
- <widget class="QLabel" name="label">
- <property name="frameShape">
- <enum>QFrame::Box</enum>
- </property>
+ <item>
+ <widget class="QRadioButton" name="partOfTablet">
<property name="text">
- <string>Working
-Area</string>
+ <string>Part of the Tablet</string>
</property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBox">
+ <property name="text">
+ <string>Force Proportions</string>
</property>
</widget>
</item>
</layout>
- </item>
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>161</width>
- <height>147</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="KPushButton" name="calibrateButton">
+ <property name="toolTip">
+ <string>Opens a fullscreen window to calibrate the tablet.</string>
+ </property>
+ <property name="text">
+ <string>Calibrate</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="tabletAreaBox">
+ <property name="title">
+ <string>Tablet Area</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout"/>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>59</height>
+ </size>
+ </property>
+ </spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
- <class>KIntSpinBox</class>
- <extends>QSpinBox</extends>
- <header>knuminput.h</header>
- </customwidget>
- <customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
@@ -326,177 +230,145 @@ Area</string>
<connections>
<connection>
<sender>rotationComboBox</sender>
- <signal>currentIndexChanged(int)</signal>
+ <signal>currentIndexChanged(QString)</signal>
<receiver>PadMapping</receiver>
<slot>profileChanged()</slot>
<hints>
<hint type="sourcelabel">
- <x>231</x>
- <y>56</y>
+ <x>78</x>
+ <y>44</y>
</hint>
<hint type="destinationlabel">
- <x>264</x>
- <y>19</y>
+ <x>1</x>
+ <y>39</y>
</hint>
</hints>
</connection>
<connection>
- <sender>topY</sender>
- <signal>valueChanged(int)</signal>
+ <sender>xrandrRotationCheckBox</sender>
+ <signal>toggled(bool)</signal>
<receiver>PadMapping</receiver>
<slot>profileChanged()</slot>
<hints>
<hint type="sourcelabel">
- <x>74</x>
- <y>235</y>
+ <x>25</x>
+ <y>79</y>
</hint>
<hint type="destinationlabel">
- <x>254</x>
- <y>61</y>
+ <x>2</x>
+ <y>80</y>
</hint>
</hints>
</connection>
<connection>
- <sender>bottomY</sender>
- <signal>valueChanged(int)</signal>
+ <sender>radioButton</sender>
+ <signal>toggled(bool)</signal>
<receiver>PadMapping</receiver>
<slot>profileChanged()</slot>
<hints>
<hint type="sourcelabel">
- <x>272</x>
- <y>303</y>
+ <x>27</x>
+ <y>139</y>
</hint>
<hint type="destinationlabel">
- <x>223</x>
- <y>120</y>
+ <x>2</x>
+ <y>139</y>
</hint>
</hints>
</connection>
<connection>
- <sender>bottomX</sender>
- <signal>valueChanged(int)</signal>
+ <sender>radioButton_2</sender>
+ <signal>toggled(bool)</signal>
<receiver>PadMapping</receiver>
<slot>profileChanged()</slot>
<hints>
<hint type="sourcelabel">
- <x>206</x>
- <y>330</y>
+ <x>29</x>
+ <y>171</y>
</hint>
<hint type="destinationlabel">
- <x>87</x>
- <y>110</y>
+ <x>1</x>
+ <y>172</y>
</hint>
</hints>
</connection>
<connection>
- <sender>topX</sender>
- <signal>valueChanged(int)</signal>
+ <sender>screenComboBox</sender>
+ <signal>currentIndexChanged(int)</signal>
<receiver>PadMapping</receiver>
<slot>profileChanged()</slot>
<hints>
<hint type="sourcelabel">
- <x>140</x>
- <y>208</y>
- </hint>
- <hint type="destinationlabel">
- <x>40</x>
- <y>77</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>calibrateButton</sender>
- <signal>clicked()</signal>
- <receiver>PadMapping</receiver>
- <slot>showCalibrationDialog()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>320</x>
- <y>178</y>
+ <x>166</x>
+ <y>138</y>
</hint>
<hint type="destinationlabel">
- <x>84</x>
- <y>306</y>
+ <x>0</x>
+ <y>118</y>
</hint>
</hints>
</connection>
<connection>
- <sender>screenComboBox</sender>
- <signal>currentIndexChanged(QString)</signal>
+ <sender>fullTablet</sender>
+ <signal>toggled(bool)</signal>
<receiver>PadMapping</receiver>
<slot>profileChanged()</slot>
<hints>
<hint type="sourcelabel">
- <x>179</x>
- <y>111</y>
+ <x>22</x>
+ <y>238</y>
</hint>
<hint type="destinationlabel">
<x>2</x>
- <y>47</y>
+ <y>237</y>
</hint>
</hints>
</connection>
<connection>
- <sender>workingAreaBox</sender>
- <signal>clicked()</signal>
+ <sender>partOfTablet</sender>
+ <signal>toggled(bool)</signal>
<receiver>PadMapping</receiver>
<slot>profileChanged()</slot>
<hints>
<hint type="sourcelabel">
- <x>185</x>
- <y>165</y>
+ <x>26</x>
+ <y>261</y>
</hint>
<hint type="destinationlabel">
- <x>374</x>
- <y>78</y>
+ <x>3</x>
+ <y>267</y>
</hint>
</hints>
</connection>
<connection>
- <sender>xrandrRotationCheckBox</sender>
- <signal>clicked()</signal>
+ <sender>checkBox</sender>
+ <signal>toggled(bool)</signal>
<receiver>PadMapping</receiver>
<slot>profileChanged()</slot>
<hints>
<hint type="sourcelabel">
- <x>244</x>
- <y>83</y>
- </hint>
- <hint type="destinationlabel">
- <x>374</x>
- <y>44</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>toolCombobox</sender>
- <signal>currentIndexChanged(int)</signal>
- <receiver>PadMapping</receiver>
- <slot>switchCalibrationTool()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>127</x>
- <y>168</y>
+ <x>26</x>
+ <y>287</y>
</hint>
<hint type="destinationlabel">
<x>2</x>
- <y>167</y>
+ <y>302</y>
</hint>
</hints>
</connection>
<connection>
- <sender>toolCombobox</sender>
- <signal>currentIndexChanged(int)</signal>
+ <sender>calibrateButton</sender>
+ <signal>clicked()</signal>
<receiver>PadMapping</receiver>
- <slot>profileChanged()</slot>
+ <slot>showCalibrationDialog()</slot>
<hints>
<hint type="sourcelabel">
- <x>117</x>
- <y>155</y>
+ <x>47</x>
+ <y>319</y>
</hint>
<hint type="destinationlabel">
- <x>2</x>
- <y>124</y>
+ <x>-2</x>
+ <y>336</y>
</hint>
</hints>
</connection>
@@ -504,6 +376,5 @@ Area</string>
<slots>
<slot>profileChanged()</slot>
<slot>showCalibrationDialog()</slot>
- <slot>switchCalibrationTool()</slot>
</slots>
</ui>
diff --git a/src/kcmodule/tabletarea.cpp b/src/kcmodule/tabletarea.cpp
new file mode 100644
index 0000000..cb629e7
--- /dev/null
+++ b/src/kcmodule/tabletarea.cpp
@@ -0,0 +1,382 @@
+/*
+ * Copyright 2011 Jörg Ehrichs <joerg.ehichs@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "tabletarea.h"
+
+#include <QtGui/QMouseEvent>
+#include <QtGui/QCursor>
+#include <QtGui/QPainter>
+#include <QtGui/QPen>
+#include <QtGui/QBrush>
+
+#include <QtCore/QDebug>
+
+#include <QtGui/QX11Info>
+
+// X11 includes
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/XInput2.h>
+
+using namespace Wacom;
+
+const qreal handleSize = 6;
+const int tabletGap = 20;
+
+TabletArea::TabletArea( QWidget *parent ) :
+ QWidget( parent )
+{
+ setMouseTracking( true );
+
+ setMinimumWidth( 300 + 2 * tabletGap );
+ setMaximumWidth( 300 + 2 * tabletGap );
+}
+
+void TabletArea::setTool( QString toolName )
+{
+ m_toolName = toolName;
+ setupWidget();
+}
+
+QRect TabletArea::getOriginalArea()
+{
+ return m_origialArea.toRect();
+}
+
+QString TabletArea::getOriginalAreaString()
+{
+ int x = ( m_origialArea.x());
+ int y = ( m_origialArea.y() );
+ int width = m_origialArea.width();
+ int height = m_origialArea.height();
+
+ QString area = QString::fromLatin1( "%1 %2 %3 %4" ).arg( x ).arg( y ).arg( width \
).arg( height ); +
+ return area;
+}
+
+QRect TabletArea::getSelectedArea()
+{
+ QRect area;
+ area.setX( m_selectedArea.x() / m_scaling );
+ area.setY( m_selectedArea.y() / m_scaling );
+ area.setWidth( m_selectedArea.width() / m_scaling );
+ area.setHeight( m_selectedArea.height() / m_scaling );
+
+ return area;
+}
+
+QString TabletArea::getSelectedAreaString()
+{
+ int x = ( m_selectedArea.x() - tabletGap ) / m_scaling;
+ int y = ( m_selectedArea.y() - tabletGap ) / m_scaling;
+ int width = m_selectedArea.width() / m_scaling;
+ int height = m_selectedArea.height() / m_scaling;
+
+ QString area = QString::fromLatin1( "%1 %2 %3 %4" ).arg( x ).arg( y ).arg( width \
).arg( height ); +
+ return area;
+}
+
+void TabletArea::resetSelection()
+{
+ m_selectedArea = QRect( rect().x() + tabletGap,
+ rect().y() + tabletGap,
+ rect().width() - 2 * tabletGap,
+ rect().height() - 2 * tabletGap );
+
+ updateDragHandle();
+ update();
+}
+
+void TabletArea::setSelection( QString area )
+{
+ QStringList list = area.split( QLatin1String(" ") );
+
+ m_selectedArea.setX( list.at( 0 ).toInt() * m_scaling + tabletGap );
+ m_selectedArea.setY( list.at( 1 ).toInt() * m_scaling + tabletGap );
+ m_selectedArea.setWidth( list.at( 2 ).toInt() * m_scaling );
+ m_selectedArea.setHeight( list.at( 3 ).toInt() * m_scaling );
+
+ updateDragHandle();
+ update();
+}
+
+void TabletArea::paintEvent( QPaintEvent *event )
+{
+ Q_UNUSED( event );
+
+ QPainter painter( this );
+ painter.setRenderHint( QPainter::Antialiasing );
+
+ QPen pen;
+ pen.setWidth( 1 );
+ pen.setColor( Qt::red );
+ painter.setPen( pen );
+ painter.setBrush( Qt::gray );
+ painter.drawRect( m_selectedArea );
+
+ painter.setPen( Qt::black );
+ painter.setBrush( Qt::transparent );
+ painter.drawRect( rect().x() + tabletGap,
+ rect().y() + tabletGap,
+ rect().width() - 2 * tabletGap,
+ rect().height() - 2 * tabletGap );
+
+ painter.setPen( pen );
+
+ // draw drag handles
+ painter.setBrush( Qt::red );
+ painter.drawRect( m_dragHandleLeft );
+ painter.drawRect( m_dragHandleRight );
+ painter.drawRect( m_dragHandleTop );
+ painter.drawRect( m_dragHandleBottom );
+
+ // draw area info in the middle
+ painter.setPen(Qt::black);
+ painter.drawText(rect().width()/2 - 50, rect().height()/2 -15, \
getOriginalAreaString()); + painter.setPen(Qt::darkRed);
+ painter.drawText(rect().width()/2 - 50, rect().height()/2 +15, \
getSelectedAreaString()); +}
+
+void TabletArea::mouseMoveEvent( QMouseEvent *event )
+{
+ if( !m_dragMode ) {
+ if( m_dragHandleLeft.contains( event->pos() )
+ || m_dragHandleRight.contains( event->pos() ) ) {
+
+ setCursor( Qt::SizeHorCursor );
+
+ }
+ else if( m_dragHandleTop.contains( event->pos() )
+ || m_dragHandleBottom.contains( event->pos() ) ) {
+
+ setCursor( Qt::SizeVerCursor );
+
+ }
+ else {
+ setCursor( Qt::ArrowCursor );
+ }
+ }
+
+ if( m_dragMode ) {
+ switch( m_mode ) {
+ case 1:
+ if( event->x() > 0 && event->x() < width() ) {
+ m_selectedArea.setX( event->x() );
+ }
+ break;
+ case 2:
+ if( event->x() > 0 && event->x() < width() ) {
+
+ m_selectedArea.setWidth( event->x() - m_selectedArea.x() );
+ }
+ break;
+ case 3:
+ if( event->y() > 0 && event->y() < height() ) {
+ m_selectedArea.setY( event->y() );
+ }
+ break;
+ case 4:
+ if( event->y() > 0 && event->y() < height() ) {
+ qreal newHeight = event->y() - m_selectedArea.y();
+
+ if( newHeight > m_origialArea.height() * m_scaling ) {
+ newHeight = m_origialArea.height() * m_scaling;
+ }
+ m_selectedArea.setHeight( newHeight );
+ }
+ break;
+ case 5:
+ if( event->x() > 0 && event->x() < width()
+ && event->y() > 0 && event->y() < height() ) {
+
+ qreal newX = m_selectedArea.x() + event->pos().x() - \
m_dragPoint.x(); +
+ if( newX >= 0 && newX + m_selectedArea.width() < rect().width() ) {
+ m_selectedArea.setX( newX );
+ m_selectedArea.setWidth( m_selectedArea.width() + \
event->pos().x() - m_dragPoint.x() ); + }
+
+ qreal newXY = m_selectedArea.y() + event->pos().y() - \
m_dragPoint.y(); +
+ if( newXY >= 0 && newXY + m_selectedArea.height() < rect().height() \
) { + m_selectedArea.setY( newXY );
+ m_selectedArea.setHeight( m_selectedArea.height() + \
event->pos().y() - m_dragPoint.y() ); + }
+ m_dragPoint = event->pos();
+ }
+ break;
+ }
+
+ // cap tablet width / height
+ if( m_selectedArea.height() > m_origialArea.height() * m_scaling ) {
+ m_selectedArea.setHeight( m_origialArea.height() * m_scaling );
+ }
+
+ if( m_selectedArea.width() > m_origialArea.width() * m_scaling ) {
+ m_selectedArea.setWidth( m_origialArea.width() * m_scaling );
+ }
+
+ updateDragHandle();
+ update();
+
+ emit selectedArea( getSelectedAreaString() );
+ }
+}
+
+void TabletArea::mousePressEvent( QMouseEvent *event )
+{
+ if( !m_dragMode ) {
+ m_mode = 0;
+ if( m_dragHandleLeft.contains( event->pos() ) ) {
+ m_dragMode = true;
+ m_mode = 1;
+ }
+ else if( m_dragHandleRight.contains( event->pos() ) ) {
+ m_dragMode = true;
+ m_mode = 2;
+ }
+ else if( m_dragHandleTop.contains( event->pos() ) ) {
+ m_dragMode = true;
+ m_mode = 3;
+ }
+ else if( m_dragHandleBottom.contains( event->pos() ) ) {
+ m_dragMode = true;
+ m_mode = 4;
+ }
+ else if( m_selectedArea.contains( event->pos() ) ) {
+ m_dragMode = true;
+ m_mode = 5;
+ setCursor( Qt::SizeAllCursor );
+
+ m_dragPoint = event->pos();
+ }
+ }
+}
+
+void TabletArea::mouseReleaseEvent( QMouseEvent *event )
+{
+ Q_UNUSED(event);
+
+ m_dragMode = false;
+ m_mode = 0;
+}
+
+void TabletArea::setupWidget()
+{
+ // original area from xinput
+ getMaxTabletArea();
+
+ m_scaling = ( width() - 2 * tabletGap ) / m_origialArea.width();
+
+ setMaximumHeight( m_origialArea.height() * m_scaling + 2 * tabletGap );
+ setMinimumHeight( m_origialArea.height() * m_scaling + 2 * tabletGap );
+
+ m_selectedArea = QRect( rect().x() + tabletGap,
+ rect().y() + tabletGap,
+ rect().width() - 2 * tabletGap,
+ rect().height() - 2 * tabletGap );
+
+ updateDragHandle();
+ update();
+}
+
+void TabletArea::updateDragHandle()
+{
+ m_dragHandleLeft.setX( m_selectedArea.x() - handleSize / 2 );
+ m_dragHandleLeft.setY( m_selectedArea.y() + m_selectedArea.height() / 2 - \
handleSize / 2 ); + m_dragHandleLeft.setWidth( handleSize );
+ m_dragHandleLeft.setHeight( handleSize );
+
+ m_dragHandleRight.setX( m_selectedArea.x() + m_selectedArea.width() - handleSize \
/ 2 ); + m_dragHandleRight.setY( m_selectedArea.y() + m_selectedArea.height() / 2 \
- handleSize / 2 ); + m_dragHandleRight.setWidth( handleSize );
+ m_dragHandleRight.setHeight( handleSize );
+
+ m_dragHandleTop.setX( m_selectedArea.x() + m_selectedArea.width() / 2 - \
handleSize / 2 ); + m_dragHandleTop.setY( m_selectedArea.y() - handleSize / 2 );
+ m_dragHandleTop.setWidth( handleSize );
+ m_dragHandleTop.setHeight( handleSize );
+
+ m_dragHandleBottom.setX( m_selectedArea.x() + m_selectedArea.width() / 2 - \
handleSize / 2 ); + m_dragHandleBottom.setY( m_selectedArea.y() + \
m_selectedArea.height() - handleSize / 2 ); + m_dragHandleBottom.setWidth( \
handleSize ); + m_dragHandleBottom.setHeight( handleSize );
+}
+
+void TabletArea::getMaxTabletArea()
+{
+ int ndevices;
+ XDevice *dev = NULL;
+ Display *dpy = QX11Info::display();
+
+ XDeviceInfo *info = XListInputDevices( dpy, &ndevices );
+ for( int i = 0; i < ndevices; i++ ) {
+ if( info[i].name == m_toolName.toLatin1() ) {
+ dev = XOpenDevice( dpy, info[i].id );
+ break;
+ }
+ }
+
+ Atom prop, type;
+ int format;
+ unsigned char *data = NULL;
+ unsigned char *dataOld = NULL;
+ unsigned long nitems, bytes_after;
+ long *ldata;
+
+ prop = XInternAtom( dpy, "Wacom Tablet Area", True );
+
+ XGetDeviceProperty( dpy, dev, prop, 0, 1000, False, AnyPropertyType,
+ &type, &format, &nitems, &bytes_after, &dataOld );
+
+ XGetDeviceProperty( dpy, dev, prop, 0, 1000, False, AnyPropertyType,
+ &type, &format, &nitems, &bytes_after, &data );
+
+ ldata = ( long * )data;
+
+ // first reset to default values
+ ldata[0] = -1;
+ ldata[1] = -1;
+ ldata[2] = -1;
+ ldata[3] = -1;
+
+ XChangeDeviceProperty( dpy, dev, prop, type, format,
+ PropModeReplace, data, nitems );
+
+ // Now get the defaults
+ XGetDeviceProperty( dpy, dev, prop, 0, 1000, False, AnyPropertyType,
+ &type, &format, &nitems, &bytes_after, &data );
+
+ ldata = ( long * )data;
+ m_origialArea.setX( ldata[0] );
+ m_origialArea.setX( ldata[1] );
+ m_origialArea.setWidth( ldata[2] );
+ m_origialArea.setHeight( ldata[3] );
+
+ // and apply the old values again
+ XChangeDeviceProperty( dpy, dev, prop, type, format,
+ PropModeReplace, dataOld, nitems );
+
+ XFlush( dpy );
+
+ free( data );
+ XFreeDeviceList( info );
+ XCloseDevice( QX11Info::display(), dev );
+}
diff --git a/src/kcmodule/tabletarea.h b/src/kcmodule/tabletarea.h
new file mode 100644
index 0000000..b05e7e0
--- /dev/null
+++ b/src/kcmodule/tabletarea.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2011 Jörg Ehrichs <joerg.ehichs@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TABLETAREA_H
+#define TABLETAREA_H
+
+#include <QWidget>
+#include <QRect>
+#include <QRectF>
+
+namespace Wacom {
+
+class TabletArea : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit TabletArea(QWidget *parent = 0);
+
+ void setTool(QString toolName);
+
+ QRect getOriginalArea();
+ QString getOriginalAreaString();
+ QRect getSelectedArea();
+ QString getSelectedAreaString();
+
+ void resetSelection();
+ void setSelection(QString area);
+
+ protected:
+ void paintEvent(QPaintEvent *event);
+ void mouseMoveEvent ( QMouseEvent * event );
+ void mousePressEvent ( QMouseEvent * event );
+ void mouseReleaseEvent ( QMouseEvent * event );
+
+signals:
+ void selectedArea(QString area);
+
+ private:
+
+ /**
+ * @brief Get tablet width/height from xinput
+ */
+ void getMaxTabletArea();
+ void setupWidget();
+ void updateDragHandle();
+
+ QString m_toolName;
+
+ QRectF m_origialArea; // [tablet units]
+ qreal m_scaling; // scaling factor between tablet/widget units
+ QRectF m_selectedArea; // [widget units]
+
+ QRectF m_dragHandleLeft;
+ QRectF m_dragHandleRight;
+ QRectF m_dragHandleTop;
+ QRectF m_dragHandleBottom;
+
+ bool m_dragMode;
+ int m_mode;
+ QPoint m_dragPoint;
+
+};
+
+}
+#endif // TABLETAREA_H
diff --git a/src/kcmodule/tabletwidget.cpp b/src/kcmodule/tabletwidget.cpp
index 4489877..818c722 100644
--- a/src/kcmodule/tabletwidget.cpp
+++ b/src/kcmodule/tabletwidget.cpp
@@ -59,6 +59,7 @@ TabletWidget::~TabletWidget()
delete m_generalPage;
delete m_padButtonPage;
delete m_padMappingPage;
+ delete m_touchMappingPage;
delete m_penPage;
delete m_touchPage;
}
@@ -77,6 +78,9 @@ void TabletWidget::init()
m_generalPage = new GeneralWidget( m_deviceInterface, m_profileManagement );
m_padButtonPage = new PadButtonWidget( m_profileManagement );
m_padMappingPage = new PadMapping( m_deviceInterface, m_profileManagement );
+ m_padMappingPage->setTool( 0 );
+ m_touchMappingPage = new PadMapping( m_deviceInterface, m_profileManagement );
+ m_touchMappingPage->setTool( 1 );
m_penPage = new PenWidget( m_profileManagement );
m_touchPage = new TouchWidget( m_profileManagement );
m_ui->setupUi( this );
@@ -88,6 +92,7 @@ void TabletWidget::init()
connect( m_ui->profileSelector, SIGNAL( currentIndexChanged( const QString ) ), \
SLOT( switchProfile( const QString ) ) );
connect( m_padButtonPage, SIGNAL( changed() ), SLOT( profileChanged() ) );
connect( m_padMappingPage, SIGNAL( changed() ), SLOT( profileChanged() ) );
+ connect( m_touchMappingPage, SIGNAL( changed() ), SLOT( profileChanged() ) );
connect( m_penPage, SIGNAL( changed() ), SLOT( profileChanged() ) );
connect( m_touchPage, SIGNAL( changed() ), SLOT( profileChanged() ) );
connect( m_generalPage, SIGNAL( changed() ), SLOT( profileChanged() ) );
@@ -125,6 +130,7 @@ void TabletWidget::loadTabletInformation()
m_generalPage->reloadWidget();
m_padButtonPage->reloadWidget();
m_padMappingPage->reloadWidget();
+ m_touchMappingPage->reloadWidget();
m_penPage->reloadWidget();
m_touchPage->reloadWidget();
@@ -169,6 +175,9 @@ void TabletWidget::loadTabletInformation()
}
m_ui->deviceTabWidget->addTab( m_padMappingPage, i18n( "Pad Mapping" ) );
+ if( !touchName.isEmpty() ) {
+ m_ui->deviceTabWidget->addTab( m_touchMappingPage, i18n( "Touch Mapping" ) \
); + }
// switch to the current active profile
QDBusReply<QString> profile = m_tabletInterface->call( QLatin1String( "profile" \
) ); @@ -220,6 +229,7 @@ void TabletWidget::saveProfile()
m_generalPage->saveToProfile();
m_padButtonPage->saveToProfile();
m_padMappingPage->saveToProfile();
+ m_touchMappingPage->saveToProfile();
m_penPage->saveToProfile();
m_touchPage->saveToProfile();
@@ -252,6 +262,7 @@ void TabletWidget::switchProfile( const QString &profile )
m_generalPage->loadFromProfile();
m_padButtonPage->loadFromProfile();
m_padMappingPage->loadFromProfile();
+ m_touchMappingPage->loadFromProfile();
m_penPage->loadFromProfile();
m_touchPage->loadFromProfile();
@@ -266,6 +277,7 @@ void TabletWidget::reloadProfile()
m_generalPage->loadFromProfile();
m_padButtonPage->loadFromProfile();
m_padMappingPage->loadFromProfile();
+ m_touchMappingPage->loadFromProfile();
m_penPage->loadFromProfile();
m_touchPage->loadFromProfile();
diff --git a/src/kcmodule/tabletwidget.h b/src/kcmodule/tabletwidget.h
index 9aace59..4d2b7fc 100644
--- a/src/kcmodule/tabletwidget.h
+++ b/src/kcmodule/tabletwidget.h
@@ -155,6 +155,7 @@ private:
GeneralWidget *m_generalPage; /**< Widget that shows some basic \
information about the tablet */
PadButtonWidget *m_padButtonPage; /**< Widget for the pad button \
settings */
PadMapping *m_padMappingPage; /**< Widget for the pad rotation and \
working area */ + PadMapping *m_touchMappingPage; /**< Widget for the \
touch rotation and working area */
PenWidget *m_penPage; /**< Widget for the pen settings \
(stylus/eraser) */
TouchWidget *m_touchPage; /**< Widget for the touch settings */
bool m_profileChanged; /**< True if the profile was changed \
and not saved yet */
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic