+++ /dev/null
-Qt for Embedded Linux Virtual Framebuffer
-===============================
-
-The virtual frame buffer allows a Qt for Embedded Linux program to be developed
-on your desktop machine, without switching between consoles and X11. The virtual
-framebuffer consists of a shared memory region (the virtual frame buffer)
-and a utility to display the framebuffer in a window. The display is updated
-periodically, so you will see discrete snapshots of the framebuffer rather
-than each individual drawing operation. For this reason drawing problems
-such as flickering may not be apparent until the program is run using a real
-framebuffer.
-
-To use the virtual framebuffer:
-
-1. Ensure QT_NO_QWS_VFB is not set in qconfig.h (when you configure Qt,
- add the -qvfb option).
-2. Start qvfb (qvfb should be compiled as a normal Qt for X11 application,
- NOT as a Qt for Embedded Linux application!).
-3. Start a Qt for Embedded Linux server (i.e. construct QApplication with
- QApplication::GuiServer flag, or run a client with the -qws option).
-
-qvfb supports the following command line options:
-
-[-width width] the width of the virtual framebuffer (default: 240).
-[-height height] the height of the virtual framebuffer (default: 320).
-[-depth depth] the depth of the virtual framebuffer (1,4,8 or 32, default: 8).
-[-nocursor] do not display the X11 cursor in the framebuffer window.
-[-qwsdisplay] the Qt for Embedded Linux display ID, e.g. -qwsdisplay :1 (default :0).
-[-skin skinfile] tells qvfb to load a skin file, e.g. -skin pda.skin
-
-Please refer to the file "pda.skin" as an example of what a skin file looks like.
-The format for skin files is:
- Image filename of skin with buttons in their up positions
- Image filename of skin with buttons in their down positions
- X offset of top left corner of the virtual screen on the skin image
- Y offset of top left corner of the virtual screen on the skin image
- Width of the virtual screen on the skin image
- Height of the virtual screen on the skin image
- Number of defined button regions
-Then for each button region the format is:
- Button identifier
- Qt scan codes to generate for the button
- Top left X coordinate of the button region
- Top left Y coordinate of the button region
- Bottom right X coordinate of the button region
- Bottom right Y coordinate of the button region
-
-The virtual framebuffer is a development tool only. No security issues have
-been considered in the virtual framebuffer design. It should not be used
-in a production environment and QT_NO_QWS_VFB should always be in force
-in production libraries.
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <comment>*********************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-*********************************************************************</comment>
- <class>Config</class>
- <widget class="QDialog" name="Config">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>600</width>
- <height>690</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Configure</string>
- </property>
- <property name="sizeGripEnabled">
- <bool>true</bool>
- </property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>8</number>
- </property>
- <item>
- <layout class="QHBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <widget class="QGroupBox" name="ButtonGroup1">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="title">
- <string>Size</string>
- </property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>11</number>
- </property>
- <item>
- <widget class="QRadioButton" name="size_176_220">
- <property name="text">
- <string>176x220 "SmartPhone"</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="size_240_320">
- <property name="text">
- <string>240x320 "PDA"</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="size_320_240">
- <property name="text">
- <string>320x240 "TV" / "QVGA"</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="size_640_480">
- <property name="text">
- <string>640x480 "VGA"</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="size_800_480">
- <property name="text">
- <string>800x480</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="size_800_600">
- <property name="text">
- <string>800x600</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="size_1024_768">
- <property name="text">
- <string>1024x768</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <widget class="QRadioButton" name="size_custom">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Custom</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSpinBox" name="size_width">
- <property name="minimum">
- <number>1</number>
- </property>
- <property name="maximum">
- <number>1280</number>
- </property>
- <property name="singleStep">
- <number>16</number>
- </property>
- <property name="value">
- <number>400</number>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSpinBox" name="size_height">
- <property name="minimum">
- <number>1</number>
- </property>
- <property name="maximum">
- <number>1024</number>
- </property>
- <property name="singleStep">
- <number>16</number>
- </property>
- <property name="value">
- <number>300</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="ButtonGroup2">
- <property name="title">
- <string>Depth</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QRadioButton" name="depth_1">
- <property name="text">
- <string>1 bit monochrome</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="depth_2gray">
- <property name="text">
- <string>2 bit grayscale</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="depth_4gray">
- <property name="text">
- <string>4 bit grayscale</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="depth_8">
- <property name="text">
- <string>8 bit</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="depth_12">
- <property name="text">
- <string>12 (16) bit</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="depth_15">
- <property name="text">
- <string>15 bit</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="depth_16">
- <property name="text">
- <string>16 bit</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="depth_18">
- <property name="text">
- <string>18 bit</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="depth_24">
- <property name="text">
- <string>24 bit</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="depth_32">
- <property name="text">
- <string>32 bit</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="depth_32_argb">
- <property name="text">
- <string>32 bit ARGB</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="rgbSwapped">
- <property name="toolTip">
- <string>Swap red and blue channels</string>
- </property>
- <property name="text">
- <string>BGR format</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <widget class="QLabel" name="TextLabel1_3">
- <property name="text">
- <string>Skin</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="skin">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <item>
- <property name="text">
- <string>None</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QCheckBox" name="touchScreen">
- <property name="text">
- <string>Emulate touch screen (no mouse move)</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="lcdScreen">
- <property name="text">
- <string>Emulate LCD screen (Only with fixed zoom of 3.0 times magnification)</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>10</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="TextLabel1">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string><p>Note that any applications using the virtual framebuffer will be terminated if you change the Size or Depth <i>above</i>. You may freely modify the Gamma <i>below</i>.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="GroupBox1">
- <property name="title">
- <string>Gamma</string>
- </property>
- <layout class="QGridLayout">
- <property name="margin">
- <number>11</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <item row="6" column="0">
- <widget class="QLabel" name="TextLabel3">
- <property name="text">
- <string>Blue</string>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <widget class="QSlider" name="bslider">
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Light">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>127</red>
- <green>127</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Midlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>38</red>
- <green>38</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Dark">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>127</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Mid">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>170</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="BrightText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>220</red>
- <green>220</green>
- <blue>220</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Shadow">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>10</red>
- <green>95</green>
- <blue>137</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Link">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="LinkVisited">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>232</red>
- <green>232</green>
- <blue>232</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Light">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>127</red>
- <green>127</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Midlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>38</red>
- <green>38</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Dark">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>127</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Mid">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>170</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="BrightText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>220</red>
- <green>220</green>
- <blue>220</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Shadow">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>10</red>
- <green>95</green>
- <blue>137</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Link">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="LinkVisited">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>232</red>
- <green>232</green>
- <blue>232</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Light">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>127</red>
- <green>127</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Midlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>38</red>
- <green>38</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Dark">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>127</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Mid">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>170</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="BrightText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>220</red>
- <green>220</green>
- <blue>220</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Shadow">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>10</red>
- <green>95</green>
- <blue>137</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Link">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="LinkVisited">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>232</red>
- <green>232</green>
- <blue>232</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="maximum">
- <number>400</number>
- </property>
- <property name="value">
- <number>100</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="6" column="2">
- <widget class="QLabel" name="blabel">
- <property name="text">
- <string>1.0</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="TextLabel2">
- <property name="text">
- <string>Green</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QSlider" name="gslider">
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>255</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Light">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>127</red>
- <green>255</green>
- <blue>127</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Midlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>38</red>
- <green>255</green>
- <blue>38</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Dark">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>127</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Mid">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>170</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="BrightText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>220</red>
- <green>220</green>
- <blue>220</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Shadow">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>10</red>
- <green>95</green>
- <blue>137</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Link">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="LinkVisited">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>232</red>
- <green>232</green>
- <blue>232</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>255</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Light">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>127</red>
- <green>255</green>
- <blue>127</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Midlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>38</red>
- <green>255</green>
- <blue>38</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Dark">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>127</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Mid">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>170</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="BrightText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>220</red>
- <green>220</green>
- <blue>220</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Shadow">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>10</red>
- <green>95</green>
- <blue>137</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Link">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="LinkVisited">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>232</red>
- <green>232</green>
- <blue>232</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>255</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Light">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>127</red>
- <green>255</green>
- <blue>127</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Midlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>38</red>
- <green>255</green>
- <blue>38</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Dark">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>127</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Mid">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>170</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="BrightText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>220</red>
- <green>220</green>
- <blue>220</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Shadow">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>10</red>
- <green>95</green>
- <blue>137</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Link">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="LinkVisited">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>232</red>
- <green>232</green>
- <blue>232</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="maximum">
- <number>400</number>
- </property>
- <property name="value">
- <number>100</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="4" column="2">
- <widget class="QLabel" name="glabel">
- <property name="text">
- <string>1.0</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="TextLabel7">
- <property name="text">
- <string>All</string>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QLabel" name="TextLabel8">
- <property name="text">
- <string>1.0</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QSlider" name="gammaslider">
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Light">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Midlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Dark">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>127</red>
- <green>127</green>
- <blue>127</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Mid">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>170</red>
- <green>170</green>
- <blue>170</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="BrightText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>220</red>
- <green>220</green>
- <blue>220</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Shadow">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>10</red>
- <green>95</green>
- <blue>137</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Link">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="LinkVisited">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>232</red>
- <green>232</green>
- <blue>232</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Light">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Midlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Dark">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>127</red>
- <green>127</green>
- <blue>127</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Mid">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>170</red>
- <green>170</green>
- <blue>170</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="BrightText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>220</red>
- <green>220</green>
- <blue>220</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Shadow">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>10</red>
- <green>95</green>
- <blue>137</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Link">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="LinkVisited">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>232</red>
- <green>232</green>
- <blue>232</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Light">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Midlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Dark">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>127</red>
- <green>127</green>
- <blue>127</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Mid">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>170</red>
- <green>170</green>
- <blue>170</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="BrightText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>220</red>
- <green>220</green>
- <blue>220</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Shadow">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>10</red>
- <green>95</green>
- <blue>137</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Link">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="LinkVisited">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>232</red>
- <green>232</green>
- <blue>232</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="maximum">
- <number>400</number>
- </property>
- <property name="value">
- <number>100</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="TextLabel1_2">
- <property name="text">
- <string>Red</string>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QLabel" name="rlabel">
- <property name="text">
- <string>1.0</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QSlider" name="rslider">
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Light">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>127</green>
- <blue>127</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Midlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>38</green>
- <blue>38</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Dark">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>127</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Mid">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>170</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="BrightText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>220</red>
- <green>220</green>
- <blue>220</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Shadow">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>10</red>
- <green>95</green>
- <blue>137</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Link">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="LinkVisited">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>232</red>
- <green>232</green>
- <blue>232</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Light">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>127</green>
- <blue>127</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Midlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>38</green>
- <blue>38</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Dark">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>127</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Mid">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>170</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="BrightText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>220</red>
- <green>220</green>
- <blue>220</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Shadow">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>10</red>
- <green>95</green>
- <blue>137</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Link">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="LinkVisited">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>232</red>
- <green>232</green>
- <blue>232</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Light">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>127</green>
- <blue>127</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Midlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>38</green>
- <blue>38</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Dark">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>127</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Mid">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>170</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="BrightText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>128</red>
- <green>128</green>
- <blue>128</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>220</red>
- <green>220</green>
- <blue>220</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Shadow">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>10</red>
- <green>95</green>
- <blue>137</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>255</red>
- <green>255</green>
- <blue>255</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Link">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="LinkVisited">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>232</red>
- <green>232</green>
- <blue>232</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
- <property name="maximum">
- <number>400</number>
- </property>
- <property name="value">
- <number>100</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="8" column="0" colspan="3">
- <widget class="QPushButton" name="PushButton3">
- <property name="text">
- <string>Set all to 1.0</string>
- </property>
- </widget>
- </item>
- <item row="0" column="3" rowspan="9">
- <widget class="GammaView" name="MyCustomWidget1" native="true"/>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="buttonOk">
- <property name="text">
- <string>&OK</string>
- </property>
- <property name="autoDefault">
- <bool>true</bool>
- </property>
- <property name="default">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="buttonCancel">
- <property name="text">
- <string>&Cancel</string>
- </property>
- <property name="autoDefault">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <customwidgets>
- <customwidget>
- <class>GammaView</class>
- <extends></extends>
- <header>gammaview.h</header>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections>
- <connection>
- <sender>size_width</sender>
- <signal>valueChanged(int)</signal>
- <receiver>size_custom</receiver>
- <slot>click()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>152</x>
- <y>193</y>
- </hint>
- <hint type="destinationlabel">
- <x>94</x>
- <y>199</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>size_height</sender>
- <signal>valueChanged(int)</signal>
- <receiver>size_custom</receiver>
- <slot>click()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>259</x>
- <y>196</y>
- </hint>
- <hint type="destinationlabel">
- <x>64</x>
- <y>188</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef GAMMAVIEW_H
-#define GAMMAVIEW_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-
-class GammaView: public QWidget
-{
- Q_OBJECT
-public:
- GammaView( QWidget *parent = 0, Qt::WindowFlags f = 0 )
- : QWidget(parent,f) { }
-};
-
-QT_END_NAMESPACE
-
-#endif
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qvfb.h"
-
-#include <QApplication>
-#include <QRegExp>
-#include <QLibraryInfo>
-#include <QLocale>
-#include <QTranslator>
-#include <stdlib.h>
-#include <stdio.h>
-#include <signal.h>
-#ifdef Q_WS_X11
-#include <QX11Info>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-void fn_quit_qvfb(int)
-{
- // pretend that we have quit normally
- qApp->quit();
-}
-
-
-void usage( const char *app )
-{
- printf( "Usage: %s [-width width] [-height height] [-depth depth] [-zoom zoom]"
- "[-mmap] [-nocursor] [-qwsdisplay :id] [-x11display :id] [-skin skindirectory]\n"
- "Supported depths: 1, 4, 8, 12, 15, 16, 18, 24, 32\n", app );
-}
-int qvfb_protocol = 0;
-
-int runQVfb( int argc, char *argv[] )
-{
- Q_INIT_RESOURCE(qvfb);
-
- QApplication app( argc, argv );
-
- QTranslator translator;
- QTranslator qtTranslator;
- QString sysLocale = QLocale::system().name();
- QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
- if (translator.load(QLatin1String("qvfb_") + sysLocale, resourceDir)
- && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) {
- app.installTranslator(&translator);
- app.installTranslator(&qtTranslator);
- }
-
- int width = 0;
- int height = 0;
- int depth = -32; // default, but overridable by skin
- bool depthSet = false;
- int rotation = 0;
- bool cursor = true;
- QVFb::DisplayType displayType = QVFb::QWS;
- double zoom = 1.0;
- QString displaySpec( ":0" );
- QString skin;
-
- for ( int i = 1; i < argc; i++ ){
- QString arg = argv[i];
- if ( arg == "-width" ) {
- width = atoi( argv[++i] );
- } else if ( arg == "-height" ) {
- height = atoi( argv[++i] );
- } else if ( arg == "-skin" ) {
- skin = argv[++i];
- } else if ( arg == "-depth" ) {
- depth = atoi( argv[++i] );
- depthSet = true;
- } else if ( arg == "-nocursor" ) {
- cursor = false;
- } else if ( arg == "-mmap" ) {
- qvfb_protocol = 1;
- } else if ( arg == "-zoom" ) {
- zoom = atof( argv[++i] );
- } else if ( arg == "-qwsdisplay" ) {
- displaySpec = argv[++i];
- displayType = QVFb::QWS;
-#ifdef Q_WS_X11
- } else if ( arg == "-x11display" ) {
- displaySpec = argv[++i];
- displayType = QVFb::X11;
-
- // Usually only the default X11 depth will work with Xnest,
- // so override the default of 32 with the actual X11 depth.
- if (!depthSet)
- depth = -QX11Info::appDepth(); // default, but overridable by skin
-#endif
- } else {
- printf( "Unknown parameter %s\n", arg.toLatin1().constData() );
- usage( argv[0] );
- exit(1);
- }
- }
-
- int displayId = 0;
- QRegExp r( ":[0-9]+" );
- int m = r.indexIn( displaySpec, 0 );
- int len = r.matchedLength();
- if ( m >= 0 ) {
- displayId = displaySpec.mid( m+1, len-1 ).toInt();
- }
- QRegExp rotRegExp( "Rot[0-9]+" );
- m = rotRegExp.indexIn( displaySpec, 0 );
- len = rotRegExp.matchedLength();
- if ( m >= 0 ) {
- rotation = displaySpec.mid( m+3, len-3 ).toInt();
- }
-
- signal(SIGINT, fn_quit_qvfb);
- signal(SIGTERM, fn_quit_qvfb);
-
- QVFb mw( displayId, width, height, depth, rotation, skin, displayType );
- mw.setZoom(zoom);
- //app.setMainWidget( &mw );
- mw.enableCursor(cursor);
- mw.show();
-
- return app.exec();
-}
-
-QT_END_NAMESPACE
-
-int main( int argc, char *argv[] )
-{
- return QT_PREPEND_NAMESPACE(runQVfb)(argc, argv);
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qanimationwriter.h"
-#include <QFile>
-#include <QString>
-#include <QPainter>
-#include <png.h>
-#include <limits.h>
-#include <netinet/in.h> // for htonl
-
-#ifdef QT_LINUXBASE
-# include <arpa/inet.h> // for htonl (LSB only)
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QAnimationWriterData
-{
-public:
- QAnimationWriterData(QIODevice* d) : framerate(1000), dev(d) {}
- void setFrameRate(int d) { framerate = d; }
- virtual ~QAnimationWriterData() { }
- virtual void setImage(const QImage& src)=0;
- virtual bool canCompose() const { return false; }
- virtual void composeImage(const QImage&, const QPoint& ) {}
-
-protected:
- int framerate;
- QIODevice* dev;
-};
-
-
-class QAnimationWriterMNG : public QAnimationWriterData {
- bool first;
- png_structp png_ptr;
- png_infop info_ptr;
-public:
- QAnimationWriterMNG(QIODevice* d) : QAnimationWriterData(d)
- {
- first = true;
- begin_png();
- }
-
- ~QAnimationWriterMNG()
- {
- if (first) {
- // Eh? Not images.
- QImage dummy(1,1,QImage::Format_RGB32);
- setImage(dummy);
- }
- writeMEND();
- end_png();
- }
-
- void begin_png()
- {
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0);
- info_ptr = png_create_info_struct(png_ptr);
- png_set_compression_level(png_ptr,9);
- png_set_write_fn(png_ptr, (void*)this, write, 0);
- }
-
- void end_png()
- {
- png_destroy_write_struct(&png_ptr, &info_ptr);
- }
-
- static void write( png_structp png_ptr, png_bytep data, png_size_t length)
- {
- QAnimationWriterMNG* that = (QAnimationWriterMNG*)png_get_io_ptr(png_ptr);
- /*uint nw =*/ that->dev->write((const char*)data,length);
- }
-
- void writePNG(const QImage& image)
- {
-#if !defined(QT_LINUXBASE) && \
- (PNG_LIBPNG_VER_MAJOR < 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR <= 4))
- // LSB disallows accessing the info_ptr directly. LSB's png_set_IHDR sets
- // the channels anyways, so just comment it out for LSB usage.
- // In libpng >= 1.5, the png_info struct is no longer exported.
- info_ptr->channels = 4;
-#endif
- png_set_sig_bytes(png_ptr, 8); // Pretend we already wrote the sig
- png_set_IHDR(png_ptr, info_ptr, image.width(), image.height(),
- 8, image.hasAlphaChannel()
- ? PNG_COLOR_TYPE_RGB_ALPHA : PNG_COLOR_TYPE_RGB,
- 0, 0, 0);
- png_write_info(png_ptr, info_ptr);
- if (!image.hasAlphaChannel())
- png_set_filler(png_ptr, 0,
- QSysInfo::ByteOrder == QSysInfo::BigEndian ?
- PNG_FILLER_BEFORE : PNG_FILLER_AFTER);
- //if ( QImage::systemByteOrder() == QImage::BigEndian ) {
- //png_set_swap_alpha(png_ptr);
- //}
- if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
- png_set_bgr(png_ptr);
- }
-
- int height = image.height();
- png_bytep *row_pointers = new png_bytep[height];
- for (int i = 0; i < height; ++i)
- row_pointers[i] = (png_bytep)image.scanLine(i);
- png_write_image(png_ptr, row_pointers);
- delete [] row_pointers;
- png_write_end(png_ptr, info_ptr);
- end_png();
- begin_png();
- }
-
- void writeMHDR(const QSize& size, int framerate)
- {
- dev->write("\212MNG\r\n\032\n", 8);
-
- struct {
- int width;
- int height;
- int framerate;
- int a,b,c;
- int profile;
- } chunk;
- chunk.width = htonl(size.width());
- chunk.height = htonl(size.height());
- chunk.framerate = htonl(framerate);
- chunk.a=0;
- chunk.b=0;
- chunk.c=0;
- chunk.profile = htonl(0x00000003);
-
- png_write_chunk(png_ptr, (png_byte*)"MHDR", (png_byte*)&chunk, sizeof(chunk));
- }
-
- void writeMEND()
- {
- png_write_chunk(png_ptr, (png_byte*)"MEND", 0, 0);
- }
-
- void writeDEFI(const QPoint& offset, const QSize& /*size*/)
- {
- struct {
- ushort o;
- uchar s;
- uchar concrete;
- int x,y;
- int lc,rc,tc,bc;
- } chunk;
- chunk.o=0;
- chunk.s=0;
- chunk.concrete=1;
- chunk.x=htonl(offset.x());
- chunk.y=htonl(offset.y());
- chunk.lc=0;
- chunk.rc=0;
- chunk.tc=htonl(INT_MAX);
- chunk.bc=htonl(INT_MAX);
-
- png_write_chunk(png_ptr, (png_byte*)"DEFI", (png_byte*)&chunk, sizeof(chunk));
- }
-
- void writeFRAM(const QSize& size)
- {
- struct {
- uchar mode;
- uchar n;
- uchar nu;
- uchar d;
- uchar t;
- uchar clip;
- uchar s;
- uchar deltatype;
- uint left;
- uint right;
- uint top;
- uint bottom;
- } chunk;
- chunk.mode=1;
- chunk.n='a';
- chunk.nu=0;
- chunk.d=0;
- chunk.clip=1;
- chunk.t=0;
- chunk.s=0;
- chunk.deltatype=0;
- chunk.left=0;
- chunk.right=htonl(size.width());
- chunk.top=0;
- chunk.bottom=htonl(size.height());
-
- png_write_chunk(png_ptr, (png_byte*)"FRAM", (png_byte*)&chunk, sizeof(chunk));
- }
-
- void writeMOVE(const QPoint& offset)
- {
- struct {
- uchar filler[3];
- uchar z[5];
- int x,y;
- } chunk;
- memset(chunk.z,0,5);
- chunk.x=htonl(offset.x());
- chunk.y=htonl(offset.y());
-
- png_write_chunk(png_ptr, (png_byte*)"MOVE", ((png_byte*)&chunk)+3, sizeof(chunk)-3);
- }
-
- void setImage(const QImage& src)
- {
- if (first) {
- first = false;
- writeMHDR(src.size(),framerate);
- }
- composeImage(src,QPoint(0,0));
- }
-
- bool canCompose() const { return true; }
-
- void composeImage(const QImage& src, const QPoint& offset)
- {
- writeMOVE(offset);
- //writeFRAM(src.size());
- writePNG(src);
- }
-};
-
-QAnimationWriter::QAnimationWriter(const QString& filename, const char* format)
-{
- if (qstrncmp(format, "MNG", 4)) {
- qWarning("Format \"%s\" not supported, only MNG", format);
- dev = 0;
- d = 0;
- } else {
- QFile *f = new QFile(filename);
- f->open(QIODevice::WriteOnly);
- dev = f;
- d = new QAnimationWriterMNG(dev);
- }
-}
-
-bool QAnimationWriter::okay() const
-{
- if (!dev)
- return false;
- QFile *file = qobject_cast<QFile*>(dev);
- Q_ASSERT(file);
- return (file->error() == QFile::NoError);
-}
-
-QAnimationWriter::~QAnimationWriter()
-{
- delete d;
- delete dev;
-}
-
-void QAnimationWriter::setFrameRate(int r)
-{
- if (d)
- d->setFrameRate(r);
-}
-
-void QAnimationWriter::appendFrame(const QImage& frm, const QPoint& offset)
-{
- if (!dev)
- return;
-
- const QImage frame = frm.convertToFormat(QImage::Format_RGB32);
- const int alignx = 1;
- if (prev.isNull() || !d->canCompose()) {
- d->setImage(frame);
- } else {
- bool done;
- int minx, maxx, miny, maxy;
- int w = frame.width();
- int h = frame.height();
-
- const quint32 *framePtr = reinterpret_cast<const quint32*>(frame.bits());
- const quint32 *prevPtr = reinterpret_cast<const quint32*>(prev.bits());
- const int frameStride = frame.bytesPerLine() / sizeof(quint32);
- const int prevStride = prev.bytesPerLine() / sizeof(quint32);
-
- // Find left edge of change
- done = false;
- for (minx = 0; minx < w && !done; ++minx) {
- const quint32 *p1 = framePtr + minx;
- const quint32 *p2 = prevPtr + minx + offset.x();
- for (int y = 0; y < h; ++y) {
- if (*p1 != *p2) {
- done = true;
- break;
- }
- p1 += frameStride;
- p2 += prevStride;
- }
- }
- --minx;
-
- // Find right edge of change
- done = false;
- for (maxx = w-1; maxx >= 0 && !done; --maxx) {
- const quint32 *p1 = framePtr + maxx;
- const quint32 *p2 = prevPtr + maxx + offset.x();
- for (int y = 0; y < h; ++y) {
- if (*p1 != *p2) {
- done = true;
- break;
- }
- p1 += frameStride;
- p2 += prevStride;
- }
- }
- ++maxx;
-
- // Find top edge of change
- done = false;
- for (miny = 0; miny < h && !done; ++miny) {
- const quint32 *p1 = framePtr + miny * frameStride;
- const quint32 *p2 = prevPtr + miny * prevStride + offset.x();
- for (int x = 0; x < w; ++x) {
- if (*p1 != *p2) {
- done = true;
- break;
- }
- ++p1;
- ++p2;
- }
- }
- --miny;
-
- // Find right edge of change
- done = false;
- for (maxy = h-1; maxy >= 0 && !done; --maxy) {
- const quint32 *p1 = framePtr + maxy * frameStride;
- const quint32 *p2 = prevPtr + maxy * prevStride + offset.x();
- for (int x = 0; x < w; ++x) {
- if (*p1 != *p2) {
- done = true;
- break;
- }
- ++p1;
- ++p2;
- }
- }
- ++maxy;
-
- if (minx > maxx)
- minx = maxx = 0;
- if (miny > maxy)
- miny = maxy = 0;
-
- if (alignx > 1) {
- minx -= minx % alignx;
- maxx = maxx - maxx % alignx + alignx - 1;
- }
-
- int dw = maxx - minx + 1;
- int dh = maxy - miny + 1;
-
- QImage diff(dw, dh, QImage::Format_ARGB32);
-
- int x, y;
- for (y = 0; y < dh; ++y) {
- QRgb* li = (QRgb*)frame.scanLine(y+miny)+minx;
- QRgb* lp = (QRgb*)prev.scanLine(y+miny+offset.y())+minx+offset.x();
- QRgb* ld = (QRgb*)diff.scanLine(y);
- if (alignx) {
- for (x = 0; x < dw; x += alignx) {
- int i;
- for (i = 0; i < alignx; ++i) {
- if (li[x+i] != lp[x+i])
- break;
- }
- if (i == alignx) {
- // All the same
- for (i = 0; i < alignx; ++i)
- ld[x+i] = qRgba(0,0,0,0);
- } else {
- // Some different
- for (i = 0; i < alignx; ++i)
- ld[x+i] = 0xff000000 | li[x+i];
- }
- }
- } else {
- for (x = 0; x < dw; ++x) {
- if (li[x] != lp[x])
- ld[x] = 0xff000000 | li[x];
- else
- ld[x] = qRgba(0,0,0,0);
- }
- }
- }
-
- d->composeImage(diff, QPoint(minx, miny) + offset);
- }
- if (prev.isNull() || (prev.size() == frame.size() && offset == QPoint(0,0))) {
- prev = frame;
- } else {
- QPainter p(&prev);
- p.drawImage(offset.x(), offset.y(), frame, 0, 0,
- frame.width(), frame.height());
- }
-}
-
-void QAnimationWriter::appendFrame(const QImage& frm)
-{
- appendFrame(frm, QPoint(0,0));
-}
-
-void QAnimationWriter::appendBlankFrame()
-{
- QImage i(1,1,QImage::Format_ARGB32);
- i.fill(0);
- d->composeImage(i, QPoint(0,0));
-}
-
-QT_END_NAMESPACE
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QANIMATIONWRITER_H
-#define QANIMATIONWRITER_H
-
-#include <QImage>
-
-QT_BEGIN_NAMESPACE
-
-class QAnimationWriterData;
-
-class QAnimationWriter
-{
-public:
- QAnimationWriter(const QString& filename, const char* format = "MNG");
- ~QAnimationWriter();
-
- bool okay() const;
- void setFrameRate(int);
- void appendBlankFrame();
- void appendFrame(const QImage&);
- void appendFrame(const QImage&, const QPoint& offset);
-
-private:
- QImage prev;
- QIODevice* dev;
- QAnimationWriterData* d;
-};
-
-QT_END_NAMESPACE
-
-#endif
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTKEYSYM_H
-#define QTKEYSYM_H
-
-/* Special keys used by Qtopia, mapped into the X11 private keypad range */
-#define QTOPIAXK_Select 0x11000601
-#define QTOPIAXK_Yes 0x11000602
-#define QTOPIAXK_No 0x11000603
-
-#define QTOPIAXK_Cancel 0x11000604
-#define QTOPIAXK_Printer 0x11000605
-#define QTOPIAXK_Execute 0x11000606
-#define QTOPIAXK_Sleep 0x11000607
-#define QTOPIAXK_Play 0x11000608
-#define QTOPIAXK_Zoom 0x11000609
-
-#define QTOPIAXK_Context1 0x1100060A
-#define QTOPIAXK_Context2 0x1100060B
-#define QTOPIAXK_Context3 0x1100060C
-#define QTOPIAXK_Context4 0x1100060D
-#define QTOPIAXK_Call 0x1100060E
-#define QTOPIAXK_Hangup 0x1100060F
-#define QTOPIAXK_Flip 0x11000610
-
-#define QTOPIAXK_Min QTOPIAXK_Select
-#define QTOPIAXK_Max QTOPIAXK_Flip
-
-#endif
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qvfb.h"
-#include "qvfbview.h"
-#include "qvfbhdr.h"
-#ifdef Q_WS_X11
-#include "qvfbx11view.h"
-#endif
-#include "qvfbratedlg.h"
-#include "ui_config.h"
-#include "qanimationwriter.h"
-
-#include <deviceskin.h>
-
-#include <QMenuBar>
-#include <QMenu>
-#include <QApplication>
-#include <QMessageBox>
-#include <QComboBox>
-#include <QLabel>
-#include <QFileDialog>
-#include <QSlider>
-#include <QSpinBox>
-#include <QLayout>
-#include <QRadioButton>
-#include <QImage>
-#include <QPixmap>
-#include <QCheckBox>
-#include <QCursor>
-#include <QTime>
-#include <QScrollArea>
-#include <QProgressBar>
-#include <QPushButton>
-#include <QTextStream>
-#include <QFile>
-#include <QFileInfo>
-#include <QDebug>
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/types.h>
-
-QT_BEGIN_NAMESPACE
-
-// =====================================================================
-
-static const char *red_on_led_xpm[] = {
-"11 11 10 1",
-" c None",
-". c #FF0000",
-"+ c #FF4C4C",
-"@ c #FF7A7A",
-"# c #D30000",
-"$ c #FF9393",
-"% c #BA0000",
-"& c #FFFFFF",
-"* c #7F0000",
-"= c #000000",
-" ",
-" .++@@ ",
-" .....+@ ",
-" ##...$.+@ ",
-" %#..$&$.+ ",
-" *#...$..+ ",
-" *%#...... ",
-" =*%#..... ",
-" =*%###. ",
-" ===*. ",
-" "};
-
-static const char *red_off_led_xpm[] = {
-"11 11 12 1",
-" c None",
-". c #CDB7B4",
-"+ c #D2BFBD",
-"@ c #DBCBCA",
-"# c #E5D9D8",
-"$ c #BC9E9B",
-"% c #E2D6D5",
-"& c #AD8986",
-"* c #FFFFFF",
-"= c #A8817D",
-"- c #B2908D",
-"; c #6F4D4A",
-" ",
-" .++@# ",
-" .....@# ",
-" $$...%.@# ",
-" &$..%*%.@ ",
-" =-...%..+ ",
-" =&-...... ",
-" ;==-..... ",
-" ;=&-$$. ",
-" ;==&$ ",
-" "};
-
-static bool copyButtonConfiguration(const QString &prefix, int displayId)
-{
- const QString destDir = QT_VFB_DATADIR(displayId).append("/");
- const QFileInfo src(prefix + QLatin1String("defaultbuttons.conf"));
- const QFileInfo dst(destDir + QLatin1String("defaultbuttons.conf"));
- unlink(dst.absoluteFilePath().toLatin1().constData());
- if (!src.exists())
- return false;
- const bool rc = QFile::copy(src.absoluteFilePath(), dst.absoluteFilePath());
- if (!rc)
- qWarning() << "Failed to copy the button configuration file " << src.absoluteFilePath() << " to " << dst.absoluteFilePath() << '.';
- return rc;
-}
-
-// =====================================================================
-
-class AnimationSaveWidget : public QWidget {
- Q_OBJECT
-public:
- AnimationSaveWidget(QVFbAbstractView *v);
- ~AnimationSaveWidget();
- bool detectPpmtoMpegCommand();
- void timerEvent(QTimerEvent *te);
- void convertToMpeg(QString filename);
- void removeTemporaryFiles();
-protected slots:
- void toggleRecord();
- void reset();
- void save();
-private:
- QVFbAbstractView *view;
- QProgressBar *progressBar;
- QLabel *statusText;
- bool haveMpeg, savingAsMpeg, recording;
- QCheckBox *mpegSave;
- QAnimationWriter *animation;
- QPushButton *recBt, *resetBt, *saveBt;
- QLabel *timeDpy, *recLED;
- int timerId, progressTimerId;
- QPixmap recOn, recOff;
- QTime tm;
- int elapsed, imageNum;
-};
-
-// =====================================================================
-
-Zoomer::Zoomer(QVFb* target) :
- qvfb(target)
-{
- QVBoxLayout *layout = new QVBoxLayout(this);
- QSlider *sl = new QSlider(Qt::Horizontal);
- sl->setMinimum(10);
- sl->setMaximum(64);
- sl->setPageStep(1);
- sl->setValue(32);
- layout->addWidget(sl);
- connect(sl,SIGNAL(valueChanged(int)),this,SLOT(zoom(int)));
- label = new QLabel();
- layout->addWidget(label);
-}
-
-void Zoomer::zoom(int z)
-{
- double d = (double)z/32.0;
- qvfb->setZoom(d);
- label->setText(QString::number(d,'g',2));
-}
-
-// =====================================================================
-
-QVFb::QVFb( int display_id, int w, int h, int d, int r, const QString &skin, DisplayType displayType, QWidget *parent, Qt::WindowFlags flags )
- : QMainWindow( parent, flags )
-{
- this->displayType = displayType;
- view = 0;
- secondaryView = 0;
- scroller = 0;
- this->skin = 0;
- currentSkinIndex = -1;
- findSkins(skin);
- zoomer = 0;
- QPixmap pix(":/res/images/logo.png");
- setWindowIcon( pix );
- rateDlg = 0;
- refreshRate = 30;
- // Create the menu first to avoid scroll bars in the main window
- createMenu( menuBar() );
- init( display_id, w, h, d, r, skin );
- enableCursor( true );
-}
-
-QVFb::~QVFb()
-{
-}
-
-void QVFb::popupMenu()
-{
- QMenu *pm = new QMenu( this );
- createMenu( pm );
- pm->exec(QCursor::pos());
-}
-
-void QVFb::init( int display_id, int pw, int ph, int d, int r, const QString& skin_name )
-{
- delete view;
- view = 0;
- delete secondaryView;
- secondaryView = 0;
- delete scroller;
- scroller = 0;
- delete skin;
- skin = 0;
-
- skinscaleH = skinscaleV = 1.0;
- QVFbView::Rotation rot = ((r == 90) ? QVFbView::Rot90 :
- ((r == 180) ? QVFbView::Rot180 :
- ((r == 270) ? QVFbView::Rot270 :
- QVFbView::Rot0 )));
- if ( !skin_name.isEmpty() ) {
- const bool vis = isVisible();
- DeviceSkinParameters parameters;
- QString readError;
- if (parameters.read(skin_name,DeviceSkinParameters::ReadAll, &readError)) {
- skin = new DeviceSkin(parameters, this);
- connect(skin, SIGNAL(popupMenu()), this, SLOT(popupMenu()));
- const int sw = parameters.screenSize().width();
- const int sh = parameters.screenSize().height();
- const int sd = parameters.screenDepth;
- if (!pw) pw = sw;
- if (!ph) ph = sh;
- if (d < 0) {
- if (sd)
- d = sd;
- else
- d = -d;
- }
- if (vis)
- hide();
- menuBar()->hide();
- scroller = 0;
-#ifdef Q_WS_X11
- if (displayType == X11)
- view = new QVFbX11View( display_id, pw, ph, d, rot, skin );
- else
-#endif
- view = new QVFbView( display_id, pw, ph, d, rot, skin );
- skin->setView( view );
- view->setContentsMargins( 0, 0, 0, 0 );
- view->setTouchscreenEmulation(!parameters.hasMouseHover);
- connect(skin, SIGNAL(skinKeyPressEvent(int,QString,bool)), view, SLOT(skinKeyPressEvent(int,QString,bool)));
- connect(skin, SIGNAL(skinKeyReleaseEvent(int,QString,bool)), view, SLOT(skinKeyReleaseEvent(int,QString,bool)));
-
- copyButtonConfiguration(skin->prefix(), view->displayId());
-
- setCentralWidget( skin );
- adjustSize();
- skinscaleH = (double)sw/pw;
- skinscaleV = (double)sh/ph;
- if ( skinscaleH != 1.0 || skinscaleH != 1.0 )
- setZoom(skinscaleH);
- view->show();
-
- if (parameters.hasSecondaryScreen()) {
- const QSize ssize = parameters.secondaryScreenSize();
- // assumes same depth and rotation
-#ifdef Q_WS_X11
- if (displayType == X11)
- secondaryView = new QVFbX11View( display_id+1, ssize.width(), ssize.height(), d, rot, skin );
- else
-#endif
- secondaryView = new QVFbView( display_id+1, ssize.width(), ssize.height(), d, rot, skin );
- skin->setSecondaryView(secondaryView);
- secondaryView->show();
- }
-
- if ( vis ) show();
- } else {
- qWarning("%s", qPrintable(readError));
- }
- }
-
- // If we failed to get a skin or we were not supplied
- // with one then fallback to a framebuffer without
- // a skin
- if (!skin){
- // Default values
- if (!pw)
- pw = 240;
- if (!ph)
- ph = 320;
- if (!d)
- d = 32;
- else if (d < 0)
- d = -d;
-
- if (currentSkinIndex != -1) {
- clearMask();
- setParent( 0, 0 );
- move( pos() );
- show();
- //unset fixed size:
- setMinimumSize(0,0);
- setMaximumSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX);
- }
- menuBar()->show();
- scroller = new QScrollArea(this);
- scroller->setFocusPolicy(Qt::NoFocus); // don't steal key events from the embedded app
-#ifdef Q_WS_X11
- if (displayType == X11)
- view = new QVFbX11View( display_id, pw, ph, d, rot, scroller );
- else
-#endif
- view = new QVFbView( display_id, pw, ph, d, rot, scroller );
- scroller->setWidget(view);
- view->setContentsMargins( 0, 0, 0, 0 );
- setCentralWidget(scroller);
- ph += 2; // avoid scrollbar
- scroller->show();
- // delete defaultbuttons.conf if it was left behind...
- unlink(QFileInfo(QT_VFB_DATADIR(view->displayId()).append("/defaultbuttons.conf")).absoluteFilePath().toLatin1().constData());
- if (secondaryView)
- unlink(QFileInfo(QT_VFB_DATADIR(view->displayId() + 1).append("/defaultbuttons.conf")).absoluteFilePath().toLatin1().constData());
- }
- view->setRate(refreshRate);
- if (secondaryView) {
- secondaryView->setRate(refreshRate);
- }
- // Resize QVFb to the new size
- QSize newSize = view->sizeHint();
-
- // ... fudge factor
- newSize += QSize(20, 35);
-
- resize(newSize);
-
- setWindowTitle(QString("Virtual framebuffer %1x%2 %3bpp Display :%4 Rotate %5")
- .arg(view->displayWidth()).arg(view->displayHeight())
- .arg(d).arg(display_id).arg(r));
-}
-
-void QVFb::enableCursor( bool e )
-{
- if ( skin && skin->hasCursor() ) {
- view->setCursor( Qt::BlankCursor );
- if (secondaryView)
- secondaryView->setCursor( Qt::BlankCursor );
- } else {
- view->setCursor( e ? Qt::ArrowCursor : Qt::BlankCursor );
- if (secondaryView)
- secondaryView->setCursor( e ? Qt::ArrowCursor : Qt::BlankCursor );
- }
- cursorAction->setChecked( e );
-}
-
-template <typename T>
-void QVFb::createMenu(T *menu)
-{
- menu->addMenu( createFileMenu() );
- menu->addMenu( createViewMenu() );
- menu->addSeparator();
- menu->addMenu( createHelpMenu() );
-}
-
-QMenu* QVFb::createFileMenu()
-{
- QMenu *file = new QMenu( tr("&File"), this );
- file->addAction( tr("&Configure..."), this, SLOT(configure()), QKeySequence::Preferences );
- file->addSeparator();
- file->addAction( tr("&Save image..."), this, SLOT(saveImage()), QKeySequence::Save );
- file->addAction( tr("&Animation..."), this, SLOT(toggleAnimation()), 0 );
- file->addSeparator();
- file->addAction( tr("&Quit"), qApp, SLOT(quit()), QKeySequence::Quit );
- return file;
-}
-
-QMenu* QVFb::createViewMenu()
-{
- viewMenu = new QMenu( tr("&View"), this );
- cursorAction = viewMenu->addAction( tr("Show &Cursor"), this,
- SLOT(toggleCursor()) );
- cursorAction->setCheckable(true);
- if ( view )
- enableCursor(true);
- viewMenu->addAction( tr("&Refresh Rate..."), this, SLOT(changeRate()) );
- viewMenu->addSeparator();
- viewMenu->addAction( tr("&No rotation"), this, SLOT(setRot0()) );
- viewMenu->addAction( tr("&90\260 rotation"), this, SLOT(setRot90()) );
- viewMenu->addAction( tr("1&80\260 rotation"), this, SLOT(setRot180()) );
- viewMenu->addAction( tr("2&70\260 rotation"), this, SLOT(setRot270()) );
- viewMenu->addSeparator();
- viewMenu->addAction( tr("Zoom scale &0.5"), this, SLOT(setZoomHalf()) );
- viewMenu->addAction( tr("Zoom scale 0.7&5"), this, SLOT(setZoom075()) );
- viewMenu->addAction( tr("Zoom scale &1"), this, SLOT(setZoom1()) );
- viewMenu->addAction( tr("Zoom scale &2"), this, SLOT(setZoom2()) );
- viewMenu->addAction( tr("Zoom scale &3"), this, SLOT(setZoom3()) );
- viewMenu->addAction( tr("Zoom scale &4"), this, SLOT(setZoom4()) );
- viewMenu->addSeparator();
- viewMenu->addAction( tr("Zoom &scale..."), this, SLOT(setZoom()) );
- return viewMenu;
-}
-
-
-QMenu* QVFb::createHelpMenu()
-{
- QMenu *help = new QMenu( tr("&Help"), this );
- help->addAction(tr("&About..."), this, SLOT(about()));
- return help;
-}
-
-void QVFb::setZoom(double z)
-{
- view->setZoom(z,z*skinscaleV/skinscaleH);
- if (secondaryView)
- secondaryView->setZoom(z,z*skinscaleV/skinscaleH);
-
- if (skin) {
- skin->setTransform(QMatrix().scale(z/skinscaleH,z/skinscaleV).rotate(90*view->displayRotation()));
- if (secondaryView)
- secondaryView->setFixedSize(
- int(secondaryView->displayWidth()*z),
- int(secondaryView->displayHeight()*z*skinscaleV/skinscaleH));
- }
-}
-
-void QVFb::setRotation(QVFbView::Rotation r)
-{
- view->setRotation(r);
- if (secondaryView)
- secondaryView->setRotation(r);
- setZoom(view->zoomH());
-}
-
-void QVFb::setRot0()
-{
- setRotation(QVFbView::Rot0);
-}
-
-void QVFb::setRot90()
-{
- setRotation(QVFbView::Rot90);
-}
-
-void QVFb::setRot180()
-{
- setRotation(QVFbView::Rot180);
-}
-
-void QVFb::setRot270()
-{
- setRotation(QVFbView::Rot270);
-}
-
-void QVFb::setZoomHalf()
-{
- setZoom(0.5);
-}
-
-void QVFb::setZoom075()
-{
- setZoom(0.75);
-}
-
-void QVFb::setZoom1()
-{
- setZoom(1);
-}
-
-void QVFb::setZoom()
-{
- if ( !zoomer )
- zoomer = new Zoomer(this);
- zoomer->show();
-}
-
-void QVFb::setZoom2()
-{
- setZoom(2);
-}
-
-void QVFb::setZoom3()
-{
- setZoom(3);
-}
-
-void QVFb::setZoom4()
-{
- setZoom(4);
-}
-
-void QVFb::saveImage()
-{
- QImage img = view->image();
- QString filename = QFileDialog::getSaveFileName(this, tr("Save Main Screen image"), tr("snapshot.png"), tr("Portable Network Graphics (*.png)"));
- if (!filename.isEmpty()){
- if(!img.save(filename,"PNG"))
- QMessageBox::critical(this, tr("Save Main Screen Image"), tr("Save failed. Check that you have permission to write to the target directory."));
- }
- if (secondaryView) {
- QImage img = view->image();
- QString filename = QFileDialog::getSaveFileName(this, tr("Save Second Screen image"), tr("snapshot.png"), tr("Portable Network Graphics (*.png)"));
- if (!filename.isEmpty()) {
- if(!img.save(filename,"PNG"))
- QMessageBox::critical(this, tr("Save Second Screen Image"), tr("Save failed. Check that you have permission to write to the target directory."));
- }
- }
-}
-
-void QVFb::toggleAnimation()
-{
- static AnimationSaveWidget *animWidget = 0;
- if ( !animWidget )
- animWidget = new AnimationSaveWidget(view);
- if ( animWidget->isVisible() )
- animWidget->hide();
- else
- animWidget->show();
-}
-
-void QVFb::toggleCursor()
-{
- enableCursor(cursorAction->isChecked());
-}
-
-void QVFb::changeRate()
-{
- if ( !rateDlg ) {
- rateDlg = new QVFbRateDialog( refreshRate, this );
- connect( rateDlg, SIGNAL(updateRate(int)), this, SLOT(setRate(int)) );
- }
-
- rateDlg->show();
-}
-
-void QVFb::setRate(int i)
-{
- refreshRate = i;
- view->setRate(i);
- if (secondaryView)
- secondaryView->setRate(i);
-}
-
-
-void QVFb::about()
-{
- QMessageBox::about(this, tr("About QVFB"), tr(
- "<h2>The Qt for Embedded Linux Virtual X11 Framebuffer</h2>"
- "<p>This application runs under Qt for X11, emulating a simple framebuffer, "
- "which the Qt for Embedded Linux server and clients can attach to just as if "
- "it was a hardware Linux framebuffer. "
- "<p>With the aid of this development tool, you can develop Qt for Embedded "
- "Linux applications under X11 without having to switch to a virtual console. "
- "This means you can comfortably use your other development tools such "
- "as GUI profilers and debuggers."
- ));
-}
-
-void QVFb::findSkins(const QString ¤tSkin)
-{
- skinnames.clear();
- skinfiles.clear();
- QDir dir(":/skins/","*.skin");
- const QFileInfoList l = dir.entryInfoList();
- int i = 1; // "None" is already in list at index 0
- for (QFileInfoList::const_iterator it = l.begin(); it != l.end(); ++it) {
- skinnames.append((*it).baseName()); // should perhaps be in file
- skinfiles.append((*it).filePath());
- if (((*it).baseName() + ".skin") == currentSkin)
- currentSkinIndex = i;
- i++;
- }
-}
-
-class Config : public QDialog, public Ui::Config
-{
-public:
- Config(QWidget *parent)
- : QDialog(parent)
- {
- setupUi(this);
- setModal(true);
-
- connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
- connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
- }
-};
-
-void QVFb::configure()
-{
- config = new Config(this);
-
- int w = view->displayWidth();
- int h = view->displayHeight();
-
- // Need to block signals, because we connect to animateClick(),
- // since QCheckBox doesn't have setChecked(bool) in 2.x.
- chooseSize(QSize(w,h));
- config->skin->insertItems(config->skin->count(), skinnames);
- if (currentSkinIndex > 0)
- config->skin->setCurrentIndex(currentSkinIndex);
- config->skin->addItem(tr("Browse..."));
- config->touchScreen->setChecked(view->touchScreenEmulation());
- config->lcdScreen->setChecked(view->lcdScreenEmulation());
- chooseDepth(view->displayDepth(), view->displayFormat());
- config->rgbSwapped->setChecked(view->rgbSwapped());
- connect(config->skin, SIGNAL(activated(int)), this, SLOT(skinConfigChosen(int)));
- if ( view->gammaRed() == view->gammaGreen() && view->gammaGreen() == view->gammaBlue() ) {
- config->gammaslider->setValue(int(view->gammaRed()*400));
- config->rslider->setValue(100);
- config->gslider->setValue(100);
- config->bslider->setValue(100);
- } else {
- config->gammaslider->setValue(100);
- config->rslider->setValue(int(view->gammaRed()*400));
- config->gslider->setValue(int(view->gammaGreen()*400));
- config->bslider->setValue(int(view->gammaBlue()*400));
- }
- connect(config->gammaslider, SIGNAL(valueChanged(int)), this, SLOT(setGamma400(int)));
- connect(config->rslider, SIGNAL(valueChanged(int)), this, SLOT(setR400(int)));
- connect(config->gslider, SIGNAL(valueChanged(int)), this, SLOT(setG400(int)));
- connect(config->bslider, SIGNAL(valueChanged(int)), this, SLOT(setB400(int)));
- updateGammaLabels();
-
- double ogr=view->gammaRed(), ogg=view->gammaGreen(), ogb=view->gammaBlue();
- qApp->setQuitOnLastWindowClosed(false);
-
- hide();
- if ( config->exec() ) {
- int id = view->displayId(); // not settable yet
- if ( config->size_176_220->isChecked() ) {
- w=176; h=220;
- } else if ( config->size_240_320->isChecked() ) {
- w=240; h=320;
- } else if ( config->size_320_240->isChecked() ) {
- w=320; h=240;
- } else if ( config->size_640_480->isChecked() ) {
- w=640; h=480;
- } else if ( config->size_800_480->isChecked() ) {
- w=800; h=480;
- } else if ( config->size_800_600->isChecked() ) {
- w=800; h=600;
- } else if ( config->size_1024_768->isChecked() ) {
- w=1024; h=768;
- } else {
- w=config->size_width->value();
- h=config->size_height->value();
- }
- int d;
- if ( config->depth_1->isChecked() )
- d=1;
- else if ( config->depth_2gray->isChecked() )
- d=2;
- else if ( config->depth_4gray->isChecked() )
- d=4;
- else if ( config->depth_8->isChecked() )
- d=8;
- else if ( config->depth_12->isChecked() )
- d=12;
- else if ( config->depth_15->isChecked() )
- d = 15;
- else if ( config->depth_16->isChecked() )
- d=16;
- else if ( config->depth_18->isChecked() )
- d=18;
- else if ( config->depth_24->isChecked() )
- d=24;
- else
- d=32;
- QVFbView::PixelFormat displayFormat = config->depth_32_argb->isChecked()
- ? QVFbView::ARGBFormat : QVFbView::DefaultFormat;
- int skinIndex = config->skin->currentIndex();
- if ( w != view->displayWidth() || h != view->displayHeight()
- || d != view->displayDepth() || skinIndex != currentSkinIndex ) {
- QVFbView::Rotation rot = view->displayRotation();
- int r = ((rot == QVFbView::Rot90) ? 90 :
- ((rot == QVFbView::Rot180) ? 180 :
- ((rot == QVFbView::Rot270) ? 270 : 0 )));
- currentSkinIndex = skinIndex;
- init( id, w, h, d, r, skinIndex > 0 ? skinfiles[skinIndex-1] : QString::null );
- }
- view->setViewFormat(displayFormat);
- view->setTouchscreenEmulation( config->touchScreen->isChecked() );
- if (view->rgbSwapped() != config->rgbSwapped->isChecked()) {
- //### the windowTitle logic is inside init(), and init isn't always invoked
- QString caption = windowTitle();
- if (!config->rgbSwapped->isChecked())
- caption.replace(QLatin1String(" BGR"), QString());
- else
- caption.append(QLatin1String(" BGR"));
- setWindowTitle(caption);
- view->setRgbSwapped(config->rgbSwapped->isChecked());
- }
- bool lcdEmulation = config->lcdScreen->isChecked();
- view->setLcdScreenEmulation( lcdEmulation );
- if ( lcdEmulation )
- setZoom3();
- } else {
- view->setGamma(ogr, ogg, ogb);
- }
- show();
- qApp->setQuitOnLastWindowClosed(true);
- delete config;
- config=0;
-}
-
-void QVFb::chooseSize(const QSize& sz)
-{
- config->size_width->blockSignals(true);
- config->size_height->blockSignals(true);
- config->size_width->setValue(sz.width());
- config->size_height->setValue(sz.height());
- config->size_width->blockSignals(false);
- config->size_height->blockSignals(false);
- config->size_custom->setChecked(true); // unless changed by settings below
- config->size_176_220->setChecked(sz == QSize(176,220));
- config->size_240_320->setChecked(sz == QSize(240,320));
- config->size_320_240->setChecked(sz == QSize(320,240));
- config->size_640_480->setChecked(sz == QSize(640,480));
- config->size_800_480->setChecked(sz == QSize(800,480));
- config->size_800_600->setChecked(sz == QSize(800,600));
- config->size_1024_768->setChecked(sz == QSize(1024,768));
-}
-
-void QVFb::chooseDepth(int depth, QVFbView::PixelFormat displayFormat)
-{
- config->depth_1->setChecked(depth==1);
- config->depth_2gray->setChecked(depth==2);
- config->depth_4gray->setChecked(depth==4);
- config->depth_8->setChecked(depth==8);
- config->depth_12->setChecked(depth==12);
- config->depth_15->setChecked(depth==15);
- config->depth_16->setChecked(depth==16);
- config->depth_18->setChecked(depth==18);
- config->depth_24->setChecked(depth==24);
- config->depth_32->setChecked(depth==32 && displayFormat != QVFbView::ARGBFormat);
- config->depth_32_argb->setChecked(depth==32 && displayFormat == QVFbView::ARGBFormat);
-}
-
-void QVFb::skinConfigChosen(int i)
-{
- if (i == config->skin->count() - 1) { // Browse... ?
- QFileDialog dlg(this);
- dlg.setFileMode(QFileDialog::DirectoryOnly);
- dlg.setWindowTitle(tr("Load Custom Skin..."));
- dlg.setFilter(tr("All QVFB Skins (*.skin)"));
- dlg.setDirectory(QDir::current());
- if (dlg.exec() && dlg.selectedFiles().count() == 1) {
- skinfiles.append(dlg.selectedFiles().first());
- i = skinfiles.count();
- config->skin->insertItem(i, QFileInfo(skinfiles.last()).baseName());
- config->skin->setCurrentIndex(i);
- } else {
- i = 0;
- }
- }
- if ( i ) {
- DeviceSkinParameters parameters;
- QString readError;
- if (parameters.read(skinfiles[i-1], DeviceSkinParameters::ReadSizeOnly, &readError)) {
- chooseSize(parameters.screenSize());
- if (parameters.screenDepth)
- chooseDepth(parameters.screenDepth,QVFbView::ARGBFormat);
- config->touchScreen->setChecked(!parameters.hasMouseHover);
- } else {
- qWarning("%s", qPrintable(readError));
- }
- }
-}
-
-void QVFb::setGamma400(int n)
-{
- double g = n/100.0;
- view->setGamma(config->rslider->value()/100.0*g,
- config->gslider->value()/100.0*g,
- config->bslider->value()/100.0*g);
- updateGammaLabels();
-}
-
-void QVFb::setR400(int n)
-{
- double g = n/100.0;
- view->setGamma(config->rslider->value()/100.0*g,
- view->gammaGreen(),
- view->gammaBlue());
- updateGammaLabels();
-}
-
-void QVFb::setG400(int n)
-{
- double g = n/100.0;
- view->setGamma(view->gammaRed(),
- config->gslider->value()/100.0*g,
- view->gammaBlue());
- updateGammaLabels();
-}
-
-void QVFb::setB400(int n)
-{
- double g = n/100.0;
- view->setGamma(view->gammaRed(),
- view->gammaGreen(),
- config->bslider->value()/100.0*g);
- updateGammaLabels();
-}
-
-void QVFb::updateGammaLabels()
-{
- config->rlabel->setText(QString::number(view->gammaRed(),'g',2));
- config->glabel->setText(QString::number(view->gammaGreen(),'g',2));
- config->blabel->setText(QString::number(view->gammaBlue(),'g',2));
-}
-
-QSize QVFb::sizeHint() const
-{
- return QSize(int(view->displayWidth()*view->zoomH()),
- int(menuBar()->height()+view->displayHeight()*view->zoomV()));
-}
-
-// =====================================================================
-
-AnimationSaveWidget::AnimationSaveWidget(QVFbAbstractView *v) :
- QWidget((QWidget*)0,0),
- view(v), recording(false), animation(0),
- timerId(-1), progressTimerId(-1),
- recOn(red_on_led_xpm), recOff(red_off_led_xpm),
- imageNum(0)
-{
- // Create the animation record UI dialog
- QVBoxLayout *vlayout = new QVBoxLayout( this );
-
- QWidget *hbox = new QWidget( this );
- vlayout->addWidget(hbox);
- QHBoxLayout *hlayout = new QHBoxLayout(hbox);
- recBt = new QPushButton( tr("Record"), hbox );
- hlayout->addWidget(recBt);
- resetBt = new QPushButton( tr("Reset"), hbox );
- hlayout->addWidget(resetBt);
- saveBt = new QPushButton( tr("Save"), hbox );
- hlayout->addWidget(saveBt);
- recBt->setFixedWidth( 100 );
- resetBt->setFixedWidth( 100 );
- saveBt->setFixedWidth( 100 );
- timeDpy = new QLabel( "00:00", hbox );
- hlayout->addWidget(timeDpy);
- recLED = new QLabel( hbox );
- hlayout->addWidget(recLED);
- recLED->setPixmap( recOff );
- timeDpy->setMargin( 5 );
- connect( recBt, SIGNAL(clicked()), this, SLOT(toggleRecord()) );
- connect( resetBt, SIGNAL(clicked()), this, SLOT(reset()) );
- connect( saveBt, SIGNAL(clicked()), this, SLOT(save()) );
- elapsed = 0;
- vlayout->setMargin( 5 );
- vlayout->setSpacing( 5 );
- haveMpeg = detectPpmtoMpegCommand();
- mpegSave = new QCheckBox( tr("Save in MPEG format (requires netpbm package installed)"), this );
- vlayout->addWidget(mpegSave);
- mpegSave->setChecked( haveMpeg );
- mpegSave->setEnabled( haveMpeg );
- savingAsMpeg = haveMpeg;
- QWidget *hbox2 = new QWidget( this );
- vlayout->addWidget(hbox2);
- QHBoxLayout *hlayout2 = new QHBoxLayout( hbox2 );
- statusText = new QLabel( tr("Click record to begin recording."), hbox2 );
- hlayout2->addWidget(statusText);
- progressBar = new QProgressBar( hbox2 );
- progressBar->setValue( 0 );
- hlayout2->addWidget(progressBar);
- progressBar->hide();
-}
-
-AnimationSaveWidget::~AnimationSaveWidget()
-{
- // clean up
- removeTemporaryFiles();
- delete animation;
-}
-
-// returns true if we have ppmtompeg command, else returns false
-bool AnimationSaveWidget::detectPpmtoMpegCommand()
-{
- // search the PATH for the ppmtompeg command to test we can record to mpeg
- QStringList paths = QString(::getenv("PATH")).split(":");
- for ( int i = 0; i < paths.count(); i++ )
- if ( QFile::exists( paths[i] + "/" + "ppmtompeg" ) )
- return true;
- return false;
-}
-
-void AnimationSaveWidget::timerEvent( QTimerEvent *te )
-{
- QString str;
-
- // Recording timer
- if ( te->timerId() == timerId ) {
-
- // Add a frame to the animation
- if ( savingAsMpeg && view )
- view->image().save( str.sprintf("/tmp/qvfb_tmp_image_%04d.ppm", imageNum), "PPM");
- else if ( animation && view )
- animation->appendFrame(view->image());//QPoint(0,0));
- imageNum++;
-
- // Update the display of number of seconds that have been recorded.
- int tmMsec = tm.elapsed();
- timeDpy->setText( str.sprintf("%02d:%02d", tmMsec/60000, (tmMsec%60000)/1000) );
- QObject::timerEvent( te );
-
- // Make the recording LED blink
- static int tick = 0;
- static bool on = false;
- if ( tick > 10 ) {
- tick = 0;
- if ( on )
- recLED->setPixmap( recOff );
- else
- recLED->setPixmap( recOn );
- on = !on;
- }
- tick++;
- }
-
- // Saving progress timer
- if ( te->timerId() == progressTimerId ) {
- // Parse output log file to work out the encoding progress.
- QFile f("/tmp/qvfb_tmp_output.log");
- f.open(QIODevice::ReadOnly);
- int largestNum = 0;
- bool done = false;
- char buffer[1024];
- while ( !f.atEnd() ) {
- // example of the output log entries
- // During each frame:
- // "FRAME 764 (B): I BLOCKS: 0......
- // When complete:
- // "======FRAMES READ: 766"
- f.readLine(buffer, 1024);
- str = QString(buffer);
- if ( str.left(6) == "FRAME " ) {
- int num = str.mid(6, str.indexOf(QChar(' '), 6) - 6).toInt();
- if ( num > largestNum )
- largestNum = num;
- } else if ( str.left(18) == "======FRAMES READ:" ) {
- done = true;
- }
- }
- f.close();
-
- // Update the progress bar with the frame we are up to
- progressBar->setValue( largestNum );
-
- // Finished saving
- if ( done ) {
- progressBar->hide();
- statusText->setText( tr("Finished saving."));
- removeTemporaryFiles();
- killTimer( progressTimerId );
- progressTimerId = -1;
- reset();
- }
- }
-}
-
-// Takes the saved ppm files and converts them to a mpeg file named filename
-void AnimationSaveWidget::convertToMpeg(QString filename)
-{
- recLED->setPixmap( recOff );
- killTimer( timerId );
-
- progressBar->show();
- progressBar->setRange( 0, imageNum );
- progressBar->setValue( 0 );
-
- // Build parameter file required by ppmtompeg
- QFile file("/tmp/qvfb_tmp_ppmtompeg.params");
- if ( file.open( QIODevice::WriteOnly ) ) {
- QTextStream t( &file );
- t << "PATTERN IBBPBBPBBPBBPBB\n";
- t << "OUTPUT " << filename << "\n";
- t << "INPUT_DIR /tmp\n";
- t << "INPUT\n";
- QString str;
- str = str.sprintf("%04d", imageNum - 1);
- t << "qvfb_tmp_image_*.ppm [0000-" << str << "]\n";
- t << "END_INPUT\n";
- t << "BASE_FILE_FORMAT PPM\n";
- t << "INPUT_CONVERT *\n";
- t << "GOP_SIZE 15\n";
- t << "SLICES_PER_FRAME 1\n";
- t << "PIXEL HALF\n";
- t << "RANGE 5\n";
- t << "PSEARCH_ALG LOGARITHMIC\n";
- t << "BSEARCH_ALG SIMPLE\n";
- t << "IQSCALE 1\n";
- t << "PQSCALE 1\n";
- t << "BQSCALE 1\n";
- t << "REFERENCE_FRAME DECODED\n";
- t << "ASPECT_RATIO 1\n";
- t << "FRAME_RATE 24\n";
- t << "BIT_RATE 64000\n"; // Quality
- t << "BUFFER_SIZE 2048\n";
- }
- file.close();
-
- // ### can't use QProcess, not in Qt 2.3
- // ### but it's certainly in Qt 4! use it?
- // Execute the ppmtompeg command as a separate process to do the encoding
- pid_t pid = ::fork();
- if ( !pid ) {
- // Child process
- // redirect stdout to log file
- freopen("/tmp/qvfb_tmp_output.log", "w", stdout);
- // ppmtompeg tool is from the netpbm package
- ::execlp("ppmtompeg", "ppmtompeg", "/tmp/qvfb_tmp_ppmtompeg.params", (void *)0);
- exit(0);
- }
-
- // Update the saving progress bar every 200ms
- progressTimerId = startTimer( 200 );
-}
-
-// Cleanup temporary files created during creating a mpeg file
-void AnimationSaveWidget::removeTemporaryFiles()
-{
- QString str;
- for ( int i = 0; i < imageNum; i++ )
- QFile::remove( str.sprintf("/tmp/qvfb_tmp_image_%04d.ppm", i) );
- QFile::remove("/tmp/qvfb_tmp_ppmtompeg.params");
- QFile::remove("/tmp/qvfb_tmp_output.log");
- imageNum = 0;
-}
-
-// toggles between recording and paused (usually when record button clicked)
-void AnimationSaveWidget::toggleRecord()
-{
- if ( recording ) {
- recLED->setPixmap( recOff );
- recBt->setText( tr("Record") );
- statusText->setText( tr("Paused. Click record to resume, or save if done."));
- killTimer( timerId );
- timerId = -1;
- elapsed = tm.elapsed();
- } else {
- recLED->setPixmap( recOn );
- recBt->setText( tr("Pause") );
- statusText->setText( tr("Recording..."));
- tm.start();
- if ( elapsed == 0 ) {
- savingAsMpeg = mpegSave->isChecked();
- if ( !savingAsMpeg ) {
- delete animation;
- animation = new QAnimationWriter("/tmp/qvfb_tmp_animation.mng","MNG");
- animation->setFrameRate(24);
- if ( view )
- animation->appendFrame(view->image());
- }
- }
- tm = tm.addMSecs(-elapsed);
- elapsed = 0;
- timerId = startTimer(1000 / 24);
- }
- recording = !recording;
-}
-
-// Reset everything to initial state of not recording
-void AnimationSaveWidget::reset()
-{
- if ( recording ) {
- toggleRecord();
- statusText->setText( tr("Click record to begin recording."));
- removeTemporaryFiles();
- }
- progressBar->setValue( 0 );
- timeDpy->setText( "00:00" );
- elapsed = 0;
- imageNum = 0;
- delete animation;
- animation = 0;
-}
-
-// Prompt for filename to save to and put animation in that file
-void AnimationSaveWidget::save()
-{
- if ( recording )
- toggleRecord(); // pauses
- statusText->setText( tr("Saving... "));
-
- QString filename;
- if ( savingAsMpeg ) {
- filename = QFileDialog::getSaveFileName(this, tr("Save animation..."), "", "*.mpg");
- if ( !filename.isNull() )
- convertToMpeg(filename);
- } else {
- filename = QFileDialog::getSaveFileName(this, tr("Save animation..."), "", "*.mng");
- if (filename.isNull()) {
- statusText->setText(tr("Save canceled."));
- } else {
- QFile::remove(filename);
- bool success = QFile::rename(QLatin1String("/tmp/qvfb_tmp_animation.mng"),
- filename);
- if (success) {
- statusText->setText(tr("Finished saving."));
- reset();
- } else {
- statusText->setText(tr("Save failed!"));
- }
- }
- }
-}
-
-QT_END_NAMESPACE
-
-#include "qvfb.moc"
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QVFB_H
-#define QVFB_H
-
-#include <QMainWindow>
-#include <QStringList>
-#include "qvfbview.h"
-
-QT_BEGIN_NAMESPACE
-
-class QVFbAbstractView;
-class QVFbRateDialog;
-class QPopupMenu;
-class QMenuData;
-class QAction;
-class Config;
-class DeviceSkin;
-class QVFb;
-class QLabel;
-class QMenu;
-class QScrollArea;
-
-class Zoomer : public QWidget {
- Q_OBJECT
-public:
- Zoomer(QVFb* target);
-
-private slots:
- void zoom(int);
-
-private:
- QVFb *qvfb;
- QLabel *label;
-};
-
-class QVFb: public QMainWindow
-{
- Q_OBJECT
-public:
- enum DisplayType { QWS, X11 };
-
- QVFb( int display_id, int w, int h, int d, int r, const QString &skin, DisplayType displayType, QWidget *parent = 0, Qt::WindowFlags wflags = 0 );
- ~QVFb();
-
- void enableCursor( bool e );
-
- QSize sizeHint() const;
-
-public slots:
- void popupMenu();
-
-protected slots:
- void saveImage();
- void toggleAnimation();
- void toggleCursor();
- void changeRate();
- void setRate(int);
- void about();
-
- void configure();
- void skinConfigChosen(int i);
- void chooseSize(const QSize& sz);
- void chooseDepth(int depth, QVFbView::PixelFormat displayFormat);
-
- void setZoom1();
- void setZoom2();
- void setZoom3();
- void setZoom4();
- void setZoomHalf();
- void setZoom075();
-
- void setZoom();
-
- void setRot0();
- void setRot90();
- void setRot180();
- void setRot270();
-
-public slots:
- void setZoom(double);
- void setRotation(QVFbView::Rotation);
-
-protected:
- template <typename T>
- void createMenu(T *menu);
- QMenu* createFileMenu();
- QMenu* createViewMenu();
- QMenu* createHelpMenu();
-
-private:
- void findSkins(const QString ¤tSkin);
- void init( int display_id, int w, int h, int d, int r, const QString& skin );
- DeviceSkin *skin;
- double skinscaleH,skinscaleV;
- QVFbAbstractView *view;
- QVFbAbstractView *secondaryView;
- QVFbRateDialog *rateDlg;
- QMenu *viewMenu;
- QAction *cursorAction;
- Config* config;
- QStringList skinnames;
- QStringList skinfiles;
- int currentSkinIndex;
- Zoomer *zoomer;
- QScrollArea* scroller;
- DisplayType displayType;
-
- int refreshRate;
-private slots:
- void setGamma400(int n);
- void setR400(int n);
- void setG400(int n);
- void setB400(int n);
- void updateGammaLabels();
-};
-
-QT_END_NAMESPACE
-
-#endif
+++ /dev/null
-TEMPLATE = app
-CONFIG += qt warn_on uic
-TARGET = qvfb
-DESTDIR = $$QT.designer.bins
-
-!win32:!embedded:!mac:CONFIG += x11
-
-target.path=$$[QT_INSTALL_BINS]
-INSTALLS += target
-
-DEPENDPATH = ../../include
-INCLUDEPATH += ../../src/gui/embedded
-
-FORMS = config.ui
-HEADERS = qvfb.h \
- qvfbview.h \
- qvfbratedlg.h \
- qanimationwriter.h \
- gammaview.h \
- qvfbprotocol.h \
- qvfbshmem.h \
- qvfbmmap.h \
- ../../src/gui/embedded/qvfbhdr.h \
- ../../src/gui/embedded/qlock_p.h \
- ../../src/gui/embedded/qwssignalhandler_p.h
-
-SOURCES = qvfb.cpp \
- qvfbview.cpp \
- qvfbratedlg.cpp \
- main.cpp \
- qanimationwriter.cpp \
- qvfbprotocol.cpp \
- qvfbshmem.cpp \
- qvfbmmap.cpp \
- ../../src/gui/embedded/qlock.cpp \
- ../../src/gui/embedded/qwssignalhandler.cpp
-
-include(../shared/deviceskin/deviceskin.pri)
-
-contains(QT_CONFIG, opengl) {
- QT += opengl
-}
-
-contains(QT_CONFIG, system-png) {
- LIBS += -lpng
-} else {
- INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/libpng
-}
-contains(QT_CONFIG, system-zlib) {
- LIBS += -lz
-} else {
- INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/zlib
-}
-
-unix:x11 {
- HEADERS += qvfbx11view.h \
- x11keyfaker.h \
- qtopiakeysym.h
- SOURCES += qvfbx11view.cpp \
- x11keyfaker.cpp
- LIBS += -lXtst
-}
-
-RESOURCES += qvfb.qrc
+++ /dev/null
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/res">
- <file>images/logo.png</file>
- <file>images/logo-nt.png</file>
-</qresource>
-</RCC>
-
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qvfbmmap.h"
-#include "qvfbhdr.h"
-
-#include <QTimer>
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#include <sys/types.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <sys/sem.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-QMMapViewProtocol::QMMapViewProtocol(int displayid, const QSize &s,
- int d, QObject *parent)
- : QVFbViewProtocol(displayid, parent), hdr(0), dataCache(0), windowId(0)
-{
- switch (d) {
- case 1:
- case 4:
- case 8:
- case 12:
- case 15:
- case 16:
- case 18:
- case 24:
- case 32:
- break;
- default:
- qFatal("Unsupported bit depth %d\n", d);
- }
-
- fileName = QString("/tmp/.qtvfb_map-%1").arg(displayid);
-
- int w = s.width();
- int h = s.height();
-
-
- kh = new QVFbKeyPipeProtocol(displayid);
- mh = new QVFbMouseLinuxTP(displayid);
-
- int bpl;
- if (d < 8)
- bpl = (w * d + 7) / 8;
- else
- bpl = w * ((d + 7) / 8);
-
- displaySize = bpl * h;
-
- unsigned char *data;
- uint data_offset_value = sizeof(QVFbHeader);
- const int page_size = getpagesize();
- if (data_offset_value % page_size)
- data_offset_value += page_size - (data_offset_value % page_size);
-
- dataSize = bpl * h + data_offset_value;
-
- unlink(fileName.toLocal8Bit().data());
- fd = ::open( fileName.toLocal8Bit().data(), O_CREAT|O_RDWR, 0666 );
- ::lseek(fd, dataSize, SEEK_SET);
- ::write(fd, "\0", 1);
- if (fd < 0) {
- data = (unsigned char *)-1;
- } else {
- // might need to do something about size?
- data = (unsigned char *)mmap(NULL, dataSize, PROT_WRITE | PROT_READ,
- MAP_SHARED, fd, 0);
- if (data == MAP_FAILED)
- data = (unsigned char *)-1;
- }
-
- if ( (long)data == -1 ){
- delete kh;
- delete mh;
- qFatal( "Cannot attach to mapped file %s", fileName.toLocal8Bit().data());
- }
- dataCache = (unsigned char *)malloc(displaySize);
- memset(dataCache, 0, displaySize);
- memset(data+sizeof(QVFbHeader), 0, displaySize);
-
- hdr = (QVFbHeader *)data;
- hdr->width = w;
- hdr->height = h;
- hdr->depth = d;
- hdr->linestep = bpl;
- hdr->numcols = 0;
- hdr->dataoffset = data_offset_value;
- hdr->update = QRect();
- hdr->brightness = 255;
- hdr->windowId = 0;
-
- mRefreshTimer = new QTimer(this);
- connect(mRefreshTimer, SIGNAL(timeout()), this, SLOT(flushChanges()));
-}
-
-QMMapViewProtocol::~QMMapViewProtocol()
-{
- munmap((char *)hdr, dataSize);
- ::close(fd);
- unlink(fileName.toLocal8Bit().constData());
- free(dataCache);
- delete kh;
- delete mh;
-}
-
-int QMMapViewProtocol::brightness() const
-{
- return hdr->brightness;
-}
-
-int QMMapViewProtocol::width() const
-{
- return hdr->width;
-}
-
-int QMMapViewProtocol::height() const
-{
- return hdr->height;
-}
-
-int QMMapViewProtocol::depth() const
-{
- return hdr->depth;
-}
-
-int QMMapViewProtocol::linestep() const
-{
- return hdr->linestep;
-}
-
-int QMMapViewProtocol::numcols() const
-{
- return hdr->numcols;
-}
-
-QVector<QRgb> QMMapViewProtocol::clut() const
-{
- QVector<QRgb> vector(hdr->numcols);
- for (int i=0; i < hdr->numcols; ++i)
- vector[i] = hdr->clut[i];
-
- return vector;
-}
-
-unsigned char *QMMapViewProtocol::data() const
-{
- return dataCache;
- //return ((unsigned char *)hdr)+hdr->dataoffset;
-}
-
-void QMMapViewProtocol::flushChanges()
-{
- // based of dirty rect, copy changes from hdr to hdrcopy
- memcpy(dataCache, ((char *)hdr) + hdr->dataoffset, displaySize);
- emit displayDataChanged(QRect(0, 0, width(), height()));
-}
-
-void QMMapViewProtocol::setRate(int interval)
-{
- if (interval > 0)
- return mRefreshTimer->start(1000/interval);
- else
- mRefreshTimer->stop();
-}
-
-int QMMapViewProtocol::rate() const
-{
- int i = mRefreshTimer->interval();
- if (i > 0)
- return 1000/i;
- else
- return 0;
-}
-
-QT_END_NAMESPACE
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QVFB_MMAP_PROTOCOL_H
-#define QVFB_MMAP_PROTOCOL_H
-
-#include "qvfbprotocol.h"
-
-QT_BEGIN_NAMESPACE
-
-class QVFbHeader;
-class QTimer;
-class QMMapViewProtocol : public QVFbViewProtocol
-{
- Q_OBJECT
-public:
- QMMapViewProtocol(int display_id, const QSize &size, int depth, QObject *parent = 0);
- ~QMMapViewProtocol();
-
- int width() const;
- int height() const;
- int depth() const;
- int linestep() const;
- int numcols() const;
- QVector<QRgb> clut() const;
- unsigned char *data() const;
- int brightness() const;
-
- void setRate(int);
- int rate() const;
-
-protected slots:
- void flushChanges();
-
-protected:
- QVFbKeyProtocol *keyHandler() const { return kh; }
- QVFbMouseProtocol *mouseHandler() const { return mh; }
-
-private:
- QVFbKeyPipeProtocol *kh;
- QVFbMouseLinuxTP *mh;
- QVFbHeader *hdr;
- QString fileName;
- int fd;
- size_t dataSize;
- size_t displaySize;
- unsigned char *dataCache;
- QTimer *mRefreshTimer;
- WId windowId;
-};
-
-QT_END_NAMESPACE
-
-#endif
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qvfbprotocol.h"
-#include "qvfbhdr.h"
-
-#include <QDebug>
-#include <QTimer>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <math.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef Q_OS_UNIX
-#include <unistd.h>
-#endif
-
-#include "qvfbshmem.h"
-
-QT_BEGIN_NAMESPACE
-
-QVFbViewProtocol::QVFbViewProtocol(int display_id, QObject *parent) :
- QObject(parent), mDisplayId(display_id) { }
-
-QVFbViewProtocol::~QVFbViewProtocol() {}
-
-void QVFbViewProtocol::flushChanges() {}
-
-void QVFbViewProtocol::sendKeyboardData(QString unicode, int keycode,
- int modifiers, bool press, bool repeat)
-{
- if (keyHandler())
- keyHandler()->sendKeyboardData(unicode, keycode, modifiers, press, repeat);
-}
-
-void QVFbViewProtocol::sendMouseData(const QPoint &pos, int buttons, int wheel)
-{
- if (mouseHandler())
- mouseHandler()->sendMouseData(pos, buttons, wheel);
-}
-
-static int openPipe(const char *fileName)
-{
- unlink(fileName);
-
- mkfifo(fileName, 0666);
- int fd = ::open(fileName, O_RDWR | O_NDELAY);
- return fd;
-}
-
-QVFbKeyPipeProtocol::QVFbKeyPipeProtocol(int display_id)
- : QVFbKeyProtocol(display_id)
-{
- fileName = QT_VFB_KEYBOARD_PIPE(display_id);
- fd = openPipe(fileName.toLocal8Bit().constData());
-
- if (fd == -1)
- qFatal("Cannot open keyboard pipe %s", fileName.toLocal8Bit().data());
-}
-
-QVFbKeyPipeProtocol::~QVFbKeyPipeProtocol()
-{
- sendKeyboardData(0, 0, 0, true, false); // magic die key
- ::close(fd);
- unlink(fileName.toLocal8Bit().constData());
-}
-
-void QVFbKeyPipeProtocol::sendKeyboardData(QString unicode, int keycode,
- int modifiers, bool press, bool repeat)
-{
- QVFbKeyData kd;
- kd.unicode = unicode[0].unicode();
- kd.keycode = keycode;
- kd.modifiers = static_cast<Qt::KeyboardModifier>(modifiers);
- kd.press = press;
- kd.repeat = repeat;
- write(fd, &kd, sizeof(QVFbKeyData));
-}
-
-QVFbMousePipe::QVFbMousePipe(int display_id)
- : QVFbMouseProtocol(display_id)
-{
- fileName = QT_VFB_MOUSE_PIPE(display_id);
- fd = openPipe(fileName.toLocal8Bit().constData());
-
- if (fd == -1)
- qFatal("Cannot open mouse pipe %s", fileName.toLocal8Bit().data());
-}
-
-QVFbMousePipe::~QVFbMousePipe()
-{
- ::close(fd);
- unlink(fileName.toLocal8Bit().constData());
-}
-
-
-void QVFbMousePipe::sendMouseData(const QPoint &pos, int buttons, int wheel)
-{
- write(fd, &pos, sizeof(QPoint));
- write(fd, &buttons, sizeof(int));
- write(fd, &wheel, sizeof(int));
-}
-
-QVFbMouseLinuxTP::QVFbMouseLinuxTP(int display_id)
- : QObject(), QVFbMousePipe(display_id), lastPos(-1,-1)
-{
- /* the timer is needed because a real touch screen send data as long as
- there is pressure. And the linux tp driver will filter, requiring
- a minimum of 5 samples before it even registers a press.
- */
- repeater = new QTimer(this);
- connect(repeater, SIGNAL(timeout()), this, SLOT(repeatLastPress()));
-}
-
-QVFbMouseLinuxTP::~QVFbMouseLinuxTP()
-{
-}
-
-
-void QVFbMouseLinuxTP::sendMouseData(const QPoint &pos, int buttons, int)
-{
- if (buttons & Qt::LeftButton) {
- // press
- repeater->start(5);
- writeToPipe(pos, 1);
- lastPos = pos;
- } else {
- // release
- if (lastPos == QPoint(-1,-1))
- return; /* only send one release */
- repeater->stop();
- writeToPipe(pos, 0);
- lastPos = QPoint(-1,-1);
- }
-}
-
-void QVFbMouseLinuxTP::writeToPipe(const QPoint &pos, ushort pressure)
-{
- ushort v;
- write(fd, &pressure, sizeof(ushort));
- v = pos.x();
- write(fd, &v, sizeof(ushort));
- v = pos.y();
- write(fd, &v, sizeof(ushort));
- v = 1; // pad
- write(fd, &v, sizeof(ushort));
-}
-
-void QVFbMouseLinuxTP::repeatLastPress()
-{
- writeToPipe(lastPos, 1);
-}
-
-QT_END_NAMESPACE
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QVFBPROTOCOL_H
-#define QVFBPROTOCOL_H
-
-#include <QImage>
-#include <QVector>
-#include <QColor>
-
-QT_BEGIN_NAMESPACE
-
-class QVFbKeyProtocol;
-class QVFbMouseProtocol;
-class QVFbViewProtocol : public QObject
-{
- Q_OBJECT
-public:
- QVFbViewProtocol(int display_id, QObject *parent = 0);
-
- virtual ~QVFbViewProtocol();
-
- int id() const { return mDisplayId; }
-
- void sendKeyboardData(QString unicode, int keycode,
- int modifiers, bool press, bool repeat);
- void sendMouseData(const QPoint &pos, int buttons, int wheel);
-
- virtual int width() const = 0;
- virtual int height() const = 0;
- virtual int depth() const = 0;
- virtual int linestep() const = 0;
- virtual int numcols() const = 0;
- virtual QVector<QRgb> clut() const = 0;
- virtual unsigned char *data() const = 0;
- virtual int brightness() const = 0;
-
- virtual void setRate(int) {}
-public slots:
- virtual void flushChanges();
-
-signals:
- void displayDataChanged(const QRect &);
- void displayEmbedRequested(WId windowId);
-
-protected:
- virtual QVFbKeyProtocol *keyHandler() const = 0;
- virtual QVFbMouseProtocol *mouseHandler() const = 0;
-
-private:
- int mDisplayId;
-};
-
-class QVFbKeyProtocol
-{
-public:
- QVFbKeyProtocol(int display_id) : mDisplayId(display_id) {}
- virtual ~QVFbKeyProtocol() {}
-
- int id() const { return mDisplayId; }
-
- virtual void sendKeyboardData(QString unicode, int keycode,
- int modifiers, bool press, bool repeat) = 0;
-
-private:
- int mDisplayId;
-};
-
-class QVFbMouseProtocol
-{
-public:
- QVFbMouseProtocol(int display_id) : mDisplayId(display_id) {}
- virtual ~QVFbMouseProtocol() {}
-
- int id() const { return mDisplayId; }
-
- virtual void sendMouseData(const QPoint &pos, int buttons, int wheel) = 0;
-
-private:
- int mDisplayId;
-};
-
-/* since there is very little variation in input protocols defaults are
- provided */
-
-class QVFbKeyPipeProtocol : public QVFbKeyProtocol
-{
-public:
- QVFbKeyPipeProtocol(int display_id);
- ~QVFbKeyPipeProtocol();
-
- void sendKeyboardData(QString unicode, int keycode,
- int modifiers, bool press, bool repeat);
-
- QString pipeName() const { return fileName; }
-private:
- int fd;
- QString fileName;
-};
-
-class QVFbMousePipe: public QVFbMouseProtocol
-{
-public:
- QVFbMousePipe(int display_id);
- ~QVFbMousePipe();
-
- void sendMouseData(const QPoint &pos, int buttons, int wheel);
-
- QString pipeName() const { return fileName; }
-protected:
- int fd;
- QString fileName;
-};
-
-class QTimer;
-class QVFbMouseLinuxTP : public QObject, public QVFbMousePipe
-{
- Q_OBJECT
-public:
- QVFbMouseLinuxTP(int display_id);
- ~QVFbMouseLinuxTP();
-
- void sendMouseData(const QPoint &pos, int buttons, int wheel);
-
-protected slots:
- void repeatLastPress();
-
-protected:
- void writeToPipe(const QPoint &pos, ushort pressure);
- QPoint lastPos;
- QTimer *repeater;
-};
-
-QT_END_NAMESPACE
-
-#endif
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qvfbratedlg.h"
-#include <QLayout>
-#include <QLabel>
-#include <qslider.h>
-#include <QPushButton>
-
-QT_BEGIN_NAMESPACE
-
-QVFbRateDialog::QVFbRateDialog(int rate, QWidget *parent)
- : QDialog(parent)
-{
- oldRate = rate;
-
- QVBoxLayout *tl = new QVBoxLayout(this);
- tl->setMargin(5);
-
- QLabel *label = new QLabel(tr("Target frame rate:"), this);
- tl->addWidget(label);
-
- QHBoxLayout *hl = new QHBoxLayout();
- tl->addItem(hl);
- rateSlider = new QSlider(Qt::Horizontal);
- rateSlider->setMinimum(1);
- rateSlider->setMaximum(100);
- rateSlider->setPageStep(10);
- rateSlider->setValue(rate);
- hl->addWidget(rateSlider);
- connect(rateSlider, SIGNAL(valueChanged(int)), this, SLOT(rateChanged(int)));
- rateLabel = new QLabel(tr("%1fps").arg(rate), this);
- hl->addWidget(rateLabel);
-
- hl = new QHBoxLayout();
- tl->addItem(hl);
- QPushButton *pb = new QPushButton(tr("OK"), this);
- connect(pb, SIGNAL(clicked()), this, SLOT(ok()));
- hl->addWidget(pb);
- pb = new QPushButton(tr("Cancel"), this);
- connect(pb, SIGNAL(clicked()), this, SLOT(cancel()));
- hl->addWidget(pb);
-}
-
-void QVFbRateDialog::rateChanged(int r)
-{
- if (rateSlider->value() != r)
- rateSlider->setValue(r);
- rateLabel->setText(tr("%1fps").arg(r));
- emit updateRate(r);
-}
-
-void QVFbRateDialog::cancel()
-{
- rateChanged(oldRate);
- reject();
-}
-
-void QVFbRateDialog::ok()
-{
- oldRate = rateSlider->value();
- accept();
-}
-
-QT_END_NAMESPACE
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QVFBRATEDLG_H
-#define QVFBRATEDLG_H
-
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-
-class QLabel;
-class QSlider;
-
-class QVFbRateDialog : public QDialog
-{
- Q_OBJECT
-public:
- QVFbRateDialog(int value, QWidget *parent = 0);
-
-signals:
- void updateRate(int r);
-
-protected slots:
- void rateChanged(int r);
- void cancel();
- void ok();
-
-private:
- QLabel *rateLabel;
- QSlider *rateSlider;
- int oldRate;
-};
-
-QT_END_NAMESPACE
-
-#endif
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlock_p.h"
-
-#include "qvfbshmem.h"
-#include "qvfbhdr.h"
-
-#include <QFile>
-#include <QTimer>
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#include <sys/types.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <sys/sem.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef Q_WS_QWS
-#error qvfb must be compiled with the Qt for X11 package
-#endif
-
-// Get the name of the directory where Qt for Embedded Linux temporary data should
-// live.
-static QString qws_dataDir(int qws_display_id)
-{
- QByteArray dataDir = QT_VFB_DATADIR(qws_display_id).toLocal8Bit();
- if (mkdir(dataDir, 0700)) {
- if (errno != EEXIST) {
- qFatal("Cannot create Qt for Embedded Linux data directory: %s", dataDir.constData());
- }
- }
-
- struct stat buf;
- if (lstat(dataDir, &buf))
- qFatal("stat failed for Qt for Embedded Linux data directory: %s", dataDir.constData());
-
- if (!S_ISDIR(buf.st_mode))
- qFatal("%s is not a directory", dataDir.constData());
- if (buf.st_uid != getuid())
- qFatal("Qt for Embedded Linux data directory is not owned by user %uh", getuid());
-
- if ((buf.st_mode & 0677) != 0600)
- qFatal("Qt for Embedded Linux data directory has incorrect permissions: %s", dataDir.constData());
- dataDir += "/";
-
- return QString(dataDir);
-}
-
-
-static QString displayPipe;
-static QString displayPiped;
-class DisplayLock
-{
-public:
- DisplayLock() : qlock(0) {
- if (QFile::exists(displayPiped)) {
- qlock = new QLock(displayPipe, 'd', false);
- qlock->lock(QLock::Read);
- }
- }
- ~DisplayLock() {
- if (qlock) {
- qlock->unlock();
- delete qlock;
- qlock = 0;
- }
- }
-private:
- QLock *qlock;
-};
-
-QShMemViewProtocol::QShMemViewProtocol(int displayid, const QSize &s,
- int d, QObject *parent)
- : QVFbViewProtocol(displayid, parent), hdr(0), dataCache(0), lockId(-1),
- windowId(0)
-{
- int w = s.width();
- int h = s.height();
-
- QString username = "unknown";
- const char *logname = getenv("LOGNAME");
- if ( logname )
- username = logname;
-
- qws_dataDir(displayid);
-
- QString oldPipe = "/tmp/qtembedded-" + username + "/" + QString("QtEmbedded-%1").arg(displayid);
- int oldPipeSemkey = ftok(oldPipe.toLatin1().constData(), 'd');
- if (oldPipeSemkey != -1) {
- int oldPipeLockId = semget(oldPipeSemkey, 0, 0);
- if (oldPipeLockId >= 0){
- sembuf sops;
- sops.sem_num = 0;
- sops.sem_op = 1;
- sops.sem_flg = SEM_UNDO;
- int rv;
- do {
- rv = semop(lockId,&sops,1);
- } while (rv == -1 && errno == EINTR);
-
- perror("QShMemViewProtocol::QShMemViewProtocol");
- qFatal("Cannot create lock file as an old version of QVFb has "
- "opened %s. Close other QVFb and try again",
- oldPipe.toLatin1().constData());
- }
- }
-
- displayPipe = QTE_PIPE_QVFB(displayid);
-
- kh = new QVFbKeyPipeProtocol(displayid);
- /* should really depend on receiving qt version, but how can
- one tell? */
- mh = new QVFbMousePipe(displayid);
-
- QString mousePipe = mh->pipeName();
-
- key_t key = ftok(mousePipe.toLatin1().constData(), 'b');
-
- int bpl;
- if (d < 8)
- bpl = (w * d + 7) / 8;
- else
- bpl = w * ((d + 7) / 8);
-
- displaySize = bpl * h;
-
- unsigned char *data;
- uint data_offset_value = sizeof(QVFbHeader);
-
- int dataSize = bpl * h + data_offset_value;
- shmId = shmget(key, dataSize, IPC_CREAT | 0666);
- if (shmId != -1)
- data = (unsigned char *)shmat(shmId, 0, 0);
- else {
- struct shmid_ds shm;
- shmctl(shmId, IPC_RMID, &shm);
- shmId = shmget(key, dataSize, IPC_CREAT | 0666);
- if (shmId == -1) {
- perror("QShMemViewProtocol::QShMemViewProtocol");
- qFatal("Cannot get shared memory 0x%08x", key);
- }
- data = (unsigned char *)shmat(shmId, 0, 0);
- }
-
- if ((long)data == -1) {
- delete kh;
- delete mh;
- perror("QShMemViewProtocol::QShMemViewProtocol");
- qFatal("Cannot attach to shared memory %d",shmId);
- }
- dataCache = (unsigned char *)malloc(displaySize);
- memset(dataCache, 0, displaySize);
- memset(data+sizeof(QVFbHeader), 0, displaySize);
-
- hdr = (QVFbHeader *)data;
- hdr->width = w;
- hdr->height = h;
- hdr->depth = d;
- hdr->linestep = bpl;
- hdr->dataoffset = data_offset_value;
- hdr->update = QRect();
- hdr->dirty = 0;
- hdr->numcols = 0;
- hdr->viewerVersion = QT_VERSION;
- hdr->brightness = 255;
- hdr->windowId = 0;
-
- displayPiped = displayPipe + 'd';
-
-
- mRefreshTimer = new QTimer(this);
- connect(mRefreshTimer, SIGNAL(timeout()), this, SLOT(flushChanges()));
-}
-
-QShMemViewProtocol::~QShMemViewProtocol()
-{
- struct shmid_ds shm;
- shmdt( (char*)hdr );
- shmctl( shmId, IPC_RMID, &shm );
- free(dataCache);
- delete kh;
- delete mh;
-}
-
-int QShMemViewProtocol::width() const
-{
- return hdr->width;
-}
-
-int QShMemViewProtocol::height() const
-{
- return hdr->height;
-}
-
-int QShMemViewProtocol::depth() const
-{
- return hdr->depth;
-}
-
-int QShMemViewProtocol::linestep() const
-{
- return hdr->linestep;
-}
-
-int QShMemViewProtocol::numcols() const
-{
- return hdr->numcols;
-}
-
-QVector<QRgb> QShMemViewProtocol::clut() const
-{
- QVector<QRgb> vector(hdr->numcols);
- for (int i=0; i < hdr->numcols; ++i)
- vector[i]=hdr->clut[i];
-
- return vector;
-}
-
-unsigned char *QShMemViewProtocol::data() const
-{
- return dataCache;
- //return ((unsigned char *)hdr)+hdr->dataoffset;
-}
-
-int QShMemViewProtocol::brightness() const
-{
- return hdr->brightness;
-}
-
-void QShMemViewProtocol::flushChanges()
-{
- QRect r;
- if (hdr->dirty) {
- DisplayLock();
-
- hdr->dirty = false;
- r = hdr->update;
- hdr->update = QRect();
-
- if (hdr->windowId != windowId) {
- windowId = hdr->windowId;
- emit displayEmbedRequested(hdr->windowId);
- } else if (!hdr->windowId) {
- // copy the memory area, for now, be inefficient.
- memcpy(dataCache, ((char *)hdr) + hdr->dataoffset, displaySize);
- }
- }
- emit displayDataChanged(r);
-}
-
-void QShMemViewProtocol::setRate(int interval)
-{
- if (interval > 0)
- return mRefreshTimer->start(1000/interval);
- else
- mRefreshTimer->stop();
-}
-
-int QShMemViewProtocol::rate() const
-{
- int i = mRefreshTimer->interval();
- if (i > 0)
- return 1000/i;
- else
- return 0;
-}
-
-QT_END_NAMESPACE
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QVFB_SHM_PROTOCOL_H
-#define QVFB_SHM_PROTOCOL_H
-
-#include "qvfbprotocol.h"
-
-QT_BEGIN_NAMESPACE
-
-class QVFbHeader;
-class QTimer;
-class QShMemViewProtocol : public QVFbViewProtocol
-{
- Q_OBJECT
-public:
- QShMemViewProtocol(int display_id, const QSize &size, int depth, QObject *parent = 0);
- ~QShMemViewProtocol();
-
- int width() const;
- int height() const;
- int depth() const;
- int linestep() const;
- int numcols() const;
- QVector<QRgb> clut() const;
- unsigned char *data() const;
- int brightness() const;
-
- void setRate(int);
- int rate() const;
-
-protected slots:
- void flushChanges();
-
-protected:
- QVFbKeyProtocol *keyHandler() const { return kh; }
- QVFbMouseProtocol *mouseHandler() const { return mh; }
-
-private:
- QVFbKeyPipeProtocol *kh;
- QVFbMousePipe *mh;
- QVFbHeader *hdr;
- size_t displaySize;
- unsigned char *dataCache;
- int lockId;
- int shmId;
- QTimer *mRefreshTimer;
- WId windowId;
-};
-
-QT_END_NAMESPACE
-
-#endif
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qvfbview.h"
-#include "qvfbshmem.h"
-#include "qvfbmmap.h"
-
-#include "qanimationwriter.h"
-#include <QApplication>
-#include <QPainter>
-#include <QImage>
-#include <QBitmap>
-#include <QMatrix>
-#include <QPaintEvent>
-#include <QScrollArea>
-#include <QFile>
-#include <QDebug>
-
-#ifdef Q_WS_X11
-#include <QX11EmbedContainer>
-#include <QHBoxLayout>
-#endif
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#include <sys/types.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <sys/sem.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-extern int qvfb_protocol;
-
-QVFbAbstractView::QVFbAbstractView( QWidget *parent )
-#ifdef QVFB_USE_GLWIDGET
- : QGLWidget( parent )
-#else
- : QWidget( parent )
-#endif
-{
-}
-
-QVFbAbstractView::~QVFbAbstractView()
-{
-}
-
-QVFbView::QVFbView(int id, int w, int h, int d, Rotation r, QWidget *parent)
- : QVFbAbstractView(parent),
- viewdepth(d), viewFormat(DefaultFormat), rgb_swapped(0), rsh(0), gsh(0), bsh(0), rmax(15), gmax(15), bmax(15),
- contentsWidth(w), contentsHeight(h), gred(1.0), ggreen(1.0), gblue(1.0),
- gammatable(0), refreshRate(30), animation(0),
- hzm(0.0), vzm(0.0), mView(0),
- emulateTouchscreen(false), emulateLcdScreen(false), rotation(r)
-#ifdef Q_WS_X11
- , embedContainer(0)
-#endif
-{
- switch(qvfb_protocol) {
- default:
- case 0:
- mView = new QShMemViewProtocol(id, QSize(w, h), d, this);
- break;
- case 1:
- mView = new QMMapViewProtocol(id, QSize(w, h), d, this);
- break;
- }
-
- connect(mView, SIGNAL(displayDataChanged(QRect)),
- SLOT(refreshDisplay(QRect)));
-#ifdef Q_WS_X11
- connect(mView, SIGNAL(displayEmbedRequested(WId)),
- this, SLOT(embedDisplay(WId)));
-#endif
-
- setAttribute(Qt::WA_PaintOnScreen, viewFormat != ARGBFormat);
- setMouseTracking(true);
- setFocusPolicy(Qt::StrongFocus);
- setAttribute(Qt::WA_NoSystemBackground);
-
- setZoom(1.0,1.0);
-
- setGamma(1.0,1.0,1.0);
- mView->setRate(30);
-}
-
-QVFbView::~QVFbView()
-{
- stopAnimation();
- sendKeyboardData(0, 0, 0, true, false); // magic die key
-#ifdef Q_WS_X11
- delete embedContainer;
-#endif
-}
-
-QSize QVFbView::sizeHint() const
-{
- return QSize(contentsWidth, contentsHeight);
-}
-
-void QVFbView::setRate(int i)
-{
- mView->setRate(i);
-}
-
-void QVFbView::setGamma(double gr, double gg, double gb)
-{
- gred = gr; ggreen = gg; gblue = gb;
-
- switch (viewdepth) {
- case 12:
- rsh = 12;
- gsh = 7;
- bsh = 1;
- rmax = 15;
- gmax = 15;
- bmax = 15;
- break;
- case 15:
- rsh = 10;
- gsh = 5;
- bsh = 0;
- rmax = 31;
- gmax = 31;
- bmax = 31;
- break;
- case 16:
- rsh = 11;
- gsh = 5;
- bsh = 0;
- rmax = 31;
- gmax = 63;
- bmax = 31;
- break;
- case 18:
- rsh = 12;
- gsh = 6;
- bsh = 0;
- rmax = 63;
- gmax = 63;
- bmax = 63;
- break;
- case 24:
- case 32:
- rsh = 16;
- gsh = 8;
- bsh = 0;
- rmax = 255;
- gmax = 255;
- bmax = 255;
- }
- int mm = qMax(rmax,qMax(gmax,bmax))+1;
- if (gammatable)
- delete [] gammatable;
- gammatable = new QRgb[mm];
- for (int i=0; i<mm; i++) {
- int r = int(pow(i,gr)*255/rmax);
- int g = int(pow(i,gg)*255/gmax);
- int b = int(pow(i,gb)*255/bmax);
- if (r > 255) r = 255;
- if (g > 255) g = 255;
- if (b > 255) b = 255;
- gammatable[i] = qRgb(r,g,b);
-//qDebug("%d: %d,%d,%d",i,r,g,b);
- }
-
- mView->flushChanges();
-}
-
-void QVFbView::getGamma(int i, QRgb& rgb)
-{
- if (i > 255) i = 255;
- if (i < 0) i = 0;
- rgb = qRgb(qRed(gammatable[i*rmax/255]),
- qGreen(gammatable[i*rmax/255]),
- qBlue(gammatable[i*rmax/255]));
-}
-
-int QVFbView::displayId() const
-{
- return mView->id();
-}
-
-int QVFbView::displayWidth() const
-{
- return mView->width();
-}
-
-int QVFbView::displayHeight() const
-{
- return mView->height();
-}
-
-int QVFbView::displayDepth() const
-{
- return viewdepth;
-}
-
-QVFbView::PixelFormat QVFbView::displayFormat() const
-{
- return viewFormat;
-}
-
-QVFbView::Rotation QVFbView::displayRotation() const
-{
- return rotation;
-}
-
-void QVFbView::setZoom(double hz, double vz)
-{
- if (hzm != hz || vzm != vz) {
- hzm = hz;
- vzm = vz;
- mView->flushChanges();
-
- contentsWidth = int(displayWidth()*hz);
- contentsHeight = int(displayHeight()*vz);
- if (rotation & 1)
- qSwap(contentsWidth,contentsHeight);
- resize(contentsWidth, contentsHeight);
-
- if (isVisible()) {
- updateGeometry();
- qApp->sendPostedEvents();
- topLevelWidget()->adjustSize();
- update();
- }
- }
-}
-
-void QVFbView::setRotation(QVFbView::Rotation r)
-{
- rotation = r;
- // Force update...
- double ohzm = hzm;
- hzm=0.0;
- setZoom(ohzm,vzm);
-}
-
-static QRect mapToDevice(const QRect &r, const QSize &s, QVFbView::Rotation rotation)
-{
- int x1 = r.x();
- int y1 = r.y();
- int x2 = r.right();
- int y2 = r.bottom();
- int w = s.width();
- int h = s.height();
- switch (rotation) {
- case QVFbView::Rot90:
- return QRect(
- QPoint(y1, w - x1),
- QPoint(y2, w - x2)).normalized();
- case QVFbView::Rot180:
- return QRect(
- QPoint(w - x1, h - y1),
- QPoint(w - x2, h - y2)).normalized();
- case QVFbView::Rot270:
- return QRect(
- QPoint(h - y1, x1),
- QPoint(h - y2, x2)).normalized();
- default:
- break;
- }
- return r;
-}
-
-static QRect mapFromDevice(const QRect &r, const QSize &s, QVFbView::Rotation rotation)
-{
- return mapToDevice(r,s,QVFbView::Rotation(4-(int)rotation));
-}
-
-void QVFbView::sendMouseData(const QPoint &pos, int buttons, int wheel)
-{
- QPoint p = mapToDevice(QRect(pos,QSize(1,1)), QSize(int(width()/hzm), int(height()/vzm)), rotation).topLeft();
- mView->sendMouseData(p, buttons, wheel);
-}
-
-void QVFbView::sendKeyboardData(QString unicode, int keycode, int modifiers,
- bool press, bool repeat)
-{
- mView->sendKeyboardData(unicode, keycode, modifiers, press, repeat);
-}
-
-void QVFbView::refreshDisplay(const QRect &r)
-{
- if (animation) {
- if (r.isEmpty()) {
- animation->appendBlankFrame();
- } else {
- int l;
- QImage img = getBuffer(r, l);
- animation->appendFrame(img,QPoint(r.x(),r.y()));
- }
- }
- if (!r.isNull()) {
- if (hzm == 1.0 && vzm == 1.0) // hw: workaround for 4.3.1
- update(mapFromDevice(r, QSize(displayWidth(), displayHeight()), rotation));
- else
- update();
- }
-}
-
-static void dim(QRgb* rgb, int n, int brightness)
-{
- uchar* b = (uchar*)rgb;
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- b++;
-#endif
- while (n--) {
- b[0] = (uint)b[0] * brightness / 255;
- b[1] = (uint)b[1] * brightness / 255;
- b[2] = (uint)b[2] * brightness / 255;
- b += 4;
- }
-}
-
-QImage QVFbView::getBuffer(const QRect &r, int &leading) const
-{
- const int brightness = mView->brightness();
- if ( brightness == 0 ) {
- QImage img(r.size(),QImage::Format_RGB32);
- img.fill(0);
- leading = 0;
- return img;
- }
-
- static QByteArray buffer;
-
- const int requiredSize = r.width() * r.height() * 4;
-
- QImage img;
- leading = 0;
-
- switch (viewdepth) {
- case 1: {
- if (requiredSize > buffer.size())
- buffer.resize(requiredSize);
-
- // XXX: hw: replace by drawhelper functionality
-
- const int pixelsPerByte = 8;
- quint8 *src = reinterpret_cast<quint8*>(mView->data())
- + r.y() * mView->linestep() + r.x() / pixelsPerByte;
- const int align = qMin(r.width(), (8 - (r.x() & 7)) & 7);
- const int doAlign = (align > 0 ? 1 : 0);
- const int tail = qMin(r.width(), (r.width() - align) & 7);
- const int doTail = (tail > 0 ? 1 : 0);
- const int width8 = (r.width() - align) / pixelsPerByte;
- const int stride = mView->linestep() - (width8 + doAlign);
-
- uchar *b = reinterpret_cast<uchar*>(buffer.data());
- img = QImage(b, r.width(), r.height(), QImage::Format_RGB32);
- for (int y = 0; y < r.height(); ++y) {
- quint32 *dest = reinterpret_cast<quint32*>(img.scanLine(y));
- quint8 c;
-
- if (doAlign) {
- switch (align) {
- case 7: c = ((*src & 0x40) >> 6) * 0xff;
- *dest++ = qRgb(c, c, c);
- case 6: c = ((*src & 0x20) >> 5) * 0xff;
- *dest++ = qRgb(c, c, c);
- case 5: c = ((*src & 0x10) >> 4) * 0xff;
- *dest++ = qRgb(c, c, c);
- case 4: c = ((*src & 0x08) >> 3) * 0xff;
- *dest++ = qRgb(c, c, c);
- case 3: c = ((*src & 0x04) >> 2) * 0xff;
- *dest++ = qRgb(c, c, c);
- case 2: c = ((*src & 0x02) >> 1) * 0xff;
- *dest++ = qRgb(c, c, c);
- case 1: c = ((*src & 0x01)) * 0xff;
- *dest++ = qRgb(c, c, c);
- }
- ++src;
- }
- for (int i = 0; i < width8; ++i) {
- c = ((*src & 0x80) >> 7) * 0xff;
- *dest++ = qRgb(c, c, c);
- c = ((*src & 0x40) >> 6) * 0xff;
- *dest++ = qRgb(c, c, c);
- c = ((*src & 0x20) >> 5) * 0xff;
- *dest++ = qRgb(c, c, c);
- c = ((*src & 0x10) >> 4) * 0xff;
- *dest++ = qRgb(c, c, c);
- c = ((*src & 0x08) >> 3) * 0xff;
- *dest++ = qRgb(c, c, c);
- c = ((*src & 0x04) >> 2) * 0xff;
- *dest++ = qRgb(c, c, c);
- c = ((*src & 0x02) >> 1) * 0xff;
- *dest++ = qRgb(c, c, c);
- c = ((*src & 0x01)) * 0xff;
- *dest++ = qRgb(c, c, c);
-
- ++src;
- }
- if (doTail) {
- switch (tail) {
- case 7: c = ((*src & 0x02) >> 1) * 0xff;
- dest[6] = qRgb(c, c, c);
- case 6: c = ((*src & 0x04) >> 2) * 0xff;
- dest[5] = qRgb(c, c, c);
- case 5: c = ((*src & 0x08) >> 3) * 0xff;
- dest[4] = qRgb(c, c, c);
- case 4: c = ((*src & 0x10) >> 4) * 0xff;
- dest[3] = qRgb(c, c, c);
- case 3: c = ((*src & 0x20) >> 5) * 0xff;
- dest[2] = qRgb(c, c, c);
- case 2: c = ((*src & 0x40) >> 6) * 0xff;
- dest[1] = qRgb(c, c, c);
- case 1: c = ((*src & 0x80) >> 7) * 0xff;
- dest[0] = qRgb(c, c, c);
- }
- }
- src += stride;
- }
- break;
- }
-
- case 2: {
- if (requiredSize > buffer.size())
- buffer.resize(requiredSize);
-
- // XXX: hw: replace by drawhelper functionality
-
- const int pixelsPerByte = 4;
- quint8 *src = reinterpret_cast<quint8*>(mView->data())
- + r.y() * mView->linestep() + r.x() / pixelsPerByte;
- const int align = qMin(r.width(), (4 - (r.x() & 3)) & 3);
- const int doAlign = (align > 0 ? 1 : 0);
- const int tail = qMin(r.width(), (r.width() - align) & 3);
- const int doTail = (tail > 0 ? 1 : 0);
- const int width8 = (r.width() - align) / pixelsPerByte;
- const int stride = mView->linestep() - (width8 + doAlign);
-
- uchar *b = reinterpret_cast<uchar*>(buffer.data());
- img = QImage(b, r.width(), r.height(), QImage::Format_RGB32);
- for (int y = 0; y < r.height(); ++y) {
- quint32 *dest = reinterpret_cast<quint32*>(img.scanLine(y));
- quint8 c;
-
- if (doAlign) {
- switch (align) {
- case 3: c = ((*src & 0x30) >> 4) * 0x55;
- *dest++ = qRgb(c, c, c);
- case 2: c = ((*src & 0x0c) >> 2) * 0x55;
- *dest++ = qRgb(c, c, c);
- case 1: c = ((*src & 0x03)) * 0x55;
- *dest++ = qRgb(c, c, c);
- }
- ++src;
- }
- for (int i = 0; i < width8; ++i) {
- c = ((*src & 0xc0) >> 6) * 0x55;
- *dest++ = qRgb(c, c, c);
- c = ((*src & 0x30) >> 4) * 0x55;
- *dest++ = qRgb(c, c, c);
- c = ((*src & 0x0c) >> 2) * 0x55;
- *dest++ = qRgb(c, c, c);
- c = ((*src & 0x03)) * 0x55;
- *dest++ = qRgb(c, c, c);
-
- ++src;
- }
- if (doTail) {
- switch (tail) {
- case 3: c = ((*src & 0x0c) >> 2) * 0x55;
- dest[2] = qRgb(c, c, c);
- case 2: c = ((*src & 0x30) >> 4) * 0x55;
- dest[1] = qRgb(c, c, c);
- case 1: c = ((*src & 0xc0) >> 6) * 0x55;
- dest[0] = qRgb(c, c, c);
- }
- }
- src += stride;
- }
- break;
- }
-
- case 4: {
- if (requiredSize > buffer.size())
- buffer.resize(requiredSize);
-
- // XXX: hw: replace by drawhelper functionality
-
- const int pixelsPerByte = 2;
- const int doAlign = r.x() & 1;
- const int doTail = (r.width() - doAlign) & 1;
- const int width8 = (r.width() - doAlign) / pixelsPerByte;
-
- uchar *b = reinterpret_cast<uchar*>(buffer.data());
- img = QImage(b, r.width(), r.height(), QImage::Format_RGB32);
- for (int y = 0; y < r.height(); ++y) {
- const quint8 *sptr = mView->data()
- + (r.y() + y) * mView->linestep()
- + r.x() / pixelsPerByte;
- quint32 *dptr = reinterpret_cast<quint32*>(img.scanLine(y));
-
- if (doAlign) {
- quint8 c = (*sptr++ & 0x0f);
- c |= (c << 4);
- *dptr++ = qRgb(c, c, c);
- }
-
- for (int i = 0; i < width8; ++i) {
- quint8 c1 = (*sptr >> 4);
- quint8 c2 = (*sptr & 0x0f);
- c1 |= (c1 << 4);
- c2 |= (c2 << 4);
- *dptr++ = qRgb(c1, c1, c1);
- *dptr++ = qRgb(c2, c2, c2);
- ++sptr;
- }
-
- if (doTail) {
- quint8 c = *sptr >> 4;
- c |= (c << 4);
- *dptr = qRgb(c, c, c);
- }
- }
- break;
- }
- case 12:
- img = QImage((const uchar*)(mView->data() + r.y() * mView->linestep() + r.x() * 2),
- r.width(), r.height(), mView->linestep(),
- QImage::Format_RGB444);
- break;
- case 15:
- img = QImage((const uchar*)(mView->data() + r.y() * mView->linestep() + r.x() * 2),
- r.width(), r.height(), mView->linestep(),
- QImage::Format_RGB555);
- break;
- case 16:
- img = QImage((const uchar*)(mView->data() + r.y() * mView->linestep() + r.x() * 2),
- r.width(), r.height(), mView->linestep(),
- QImage::Format_RGB16);
- break;
- case 18:
- img = QImage((const uchar*)(mView->data() + r.y() * mView->linestep() + r.x() * 3),
- r.width(), r.height(), mView->linestep(),
- QImage::Format_RGB666);
- break;
- case 24:
- img = QImage((const uchar*)(mView->data() + r.y() * mView->linestep() + r.x() * 3),
- r.width(), r.height(), mView->linestep(),
- QImage::Format_RGB888);
- break;
- case 32:
- img = QImage((const uchar*)(mView->data() + r.y() * mView->linestep() + r.x() * 4),
- r.width(), r.height(), mView->linestep(),
- viewFormat == ARGBFormat ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
- break;
- case 8:
- img = QImage(mView->data() + r.y() * mView->linestep() + r.x(),
- r.width(), r.height(), mView->linestep(),
- QImage::Format_Indexed8);
- img.setColorTable(mView->clut());
- if (img.colorCount() <= 0)
- img = QImage();
- break;
- }
-
- if (rgb_swapped)
- img = img.rgbSwapped();
-
- if ( brightness != 255 ) {
- if (img.format() == QImage::Format_Indexed8) {
- QVector<QRgb> c = img.colorTable();
- dim(c.data(),c.count(),brightness);
- img.setColorTable(c);
- } else {
- if ( img.format() != QImage::Format_ARGB32_Premultiplied )
- img = img.convertToFormat(QImage::Format_RGB32);
-
- // NOTE: calling bits() may change byteCount(), so do not
- // pass them as parameters (which are evaluated right-to-left).
- QRgb *b = (QRgb*)img.bits();
- int n = img.byteCount()/4;
- dim(b,n,brightness);
- }
- }
-
- return img;
-}
-
-static int findMultiple(int start, double m, int limit, int step)
-{
- int r = start;
- while (r != limit) {
- if (int(int(r * m)/m) == r)
- break;
- r += step;
- }
- return r;
-}
-
-void QVFbView::drawScreen(const QRect &rect)
-{
- QRect r = QRect(0, 0, mView->width(), mView->height());
-
- if (hzm == 1.0 && vzm == 1.0) // hw: workaround for 4.3.1
- r &= rect;
-
- if (int(hzm) != hzm || int(vzm) != vzm) {
- r.setLeft(findMultiple(r.left(),hzm,0,-1));
- r.setTop(findMultiple(r.top(),vzm,0,-1));
- int w = findMultiple(r.width(),hzm,mView->width(),1);
- int h = findMultiple(r.height(),vzm,mView->height(),1);
- r.setRight(r.left()+w-1);
- r.setBottom(r.top()+h-1);
- }
-
- int leading;
- const QImage img = getBuffer(r, leading);
-
- QPixmap pm;
- if (hzm == 1.0 && vzm == 1.0) {
- pm = QPixmap::fromImage(img);
- } else if (emulateLcdScreen && hzm == 3.0 && vzm == 3.0) {
- QImage img2(img.width()*3, img.height(), QImage::Format_RGB32);
- for (int row = 0; row < img2.height(); row++) {
- QRgb *dptr = (QRgb*)img2.scanLine(row);
- QRgb *sptr = (QRgb*)img.scanLine(row);
- for (int col = 0; col < img.width(); col++) {
- QRgb s = *sptr++;
- *dptr++ = qRgb(qRed(s),0,0);
- *dptr++ = qRgb(0,qGreen(s),0);
- *dptr++ = qRgb(0,0,qBlue(s));
- }
- }
- QMatrix m;
- m.scale(1.0, 3.0);
- pm = QPixmap::fromImage(img2);
- pm = pm.transformed(m);
- } else if (int(hzm) == hzm && int(vzm) == vzm) {
- QMatrix m;
- m.scale(hzm,vzm);
- pm = QPixmap::fromImage(img);
- pm = pm.transformed(m);
- } else {
- pm = QPixmap::fromImage(img.scaled(int(img.width()*hzm),int(img.height()*vzm), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
- }
-
- int x1 = r.x();
- int y1 = r.y();
- int leadingX = leading;
- int leadingY = 0;
-
- // Do the rotation thing
- int rotX1 = mView->width() - x1 - img.width();
- int rotY1 = mView->height() - y1 - img.height();
- int rotLeadingX = (leading) ? mView->width() - leadingX - img.width() : 0;
- int rotLeadingY = 0;
- switch (rotation) {
- case Rot0:
- break;
- case Rot90:
- leadingY = leadingX;
- leadingX = rotLeadingY;
- y1 = x1;
- x1 = rotY1;
- break;
- case Rot180:
- leadingX = rotLeadingX;
- leadingY = leadingY;
- x1 = rotX1;
- y1 = rotY1;
- break;
- case Rot270:
- leadingX = leadingY;
- leadingY = rotLeadingX;
- x1 = y1;
- y1 = rotX1;
- break;
- default:
- break;
- }
- x1 = int(x1*hzm);
- y1 = int(y1*vzm);
- leadingX = int(leadingX*hzm);
- leadingY = int(leadingY*vzm);
- if (rotation != 0) {
- QMatrix m;
- m.rotate(rotation * 90.0);
- pm = pm.transformed(m);
- }
-
- QPainter p(this);
- if (viewFormat == ARGBFormat) {
- QPixmap bg(":/res/images/logo-nt.png");
- p.fillRect(x1,y1,pm.width(), pm.height(), QBrush(bg));
- }
- p.drawPixmap(x1, y1, pm, leadingX, leadingY, pm.width(), pm.height());
-}
-
-//bool QVFbView::eventFilter(QObject *obj, QEvent *e)
-//{
-// if (obj == this &&
-// (e->type() == QEvent::FocusIn || e->type() == QEvent::FocusOut))
-// return true;
-//
-// return QWidgetView::eventFilter(obj, e);
-//}
-
-void QVFbView::paintEvent(QPaintEvent *e)
-{
- drawScreen(mapToDevice(e->rect(),QSize(int(width()/hzm), int(height()/vzm)),rotation));
-}
-
-void QVFbView::mousePressEvent(QMouseEvent *e)
-{
- sendMouseData(QPoint(int(e->x()/hzm),int(e->y()/vzm)), e->buttons(), 0);
-}
-
-void QVFbView::contextMenuEvent(QContextMenuEvent*)
-{
-
-}
-
-void QVFbView::mouseDoubleClickEvent(QMouseEvent *e)
-{
- sendMouseData(QPoint(int(e->x()/hzm),int(e->y()/vzm)), e->buttons(), 0);
-}
-
-void QVFbView::mouseReleaseEvent(QMouseEvent *e)
-{
- sendMouseData(QPoint(int(e->x()/hzm),int(e->y()/vzm)), e->buttons(), 0);
-}
-
-void QVFbView::skinMouseEvent(QMouseEvent *e)
-{
- sendMouseData(QPoint(int(e->x()/hzm),int(e->y()/vzm)), e->buttons(), 0);
-}
-
-void QVFbView::mouseMoveEvent(QMouseEvent *e)
-{
- if (!emulateTouchscreen || (e->buttons() & Qt::MouseButtonMask))
- sendMouseData(QPoint(int(e->x()/hzm),int(e->y()/vzm)), e->buttons(), 0);
-}
-
-void QVFbView::wheelEvent(QWheelEvent *e)
-{
- if (!e)
- return;
- sendMouseData(QPoint(int(e->x()/hzm),int(e->y()/vzm)), e->buttons(), e->delta());
-}
-
-void QVFbView::setTouchscreenEmulation(bool b)
-{
- emulateTouchscreen = b;
-}
-
-void QVFbView::setLcdScreenEmulation(bool b)
-{
- emulateLcdScreen = b;
-}
-
-void QVFbView::setViewFormat(PixelFormat f)
-{
- if (viewFormat == f)
- return;
- viewFormat = f;
- setAttribute(Qt::WA_PaintOnScreen, viewFormat != ARGBFormat);
-}
-
-#ifdef Q_WS_X11
-void QVFbView::embedDisplay(WId windowId)
-{
- if (windowId == 0) {
- delete embedContainer;
- embedContainer = 0;
- return;
- }
-
- if (!embedContainer) {
- embedContainer = new QX11EmbedContainer(this);
- embedContainer->setGeometry(rect());
- embedContainer->show();
- }
- embedContainer->embedClient(windowId);
-}
-#endif
-
-bool QVFbView::event(QEvent *e)
-{
- if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) {
- QKeyEvent *ke = static_cast<QKeyEvent*>(e);
- sendKeyboardData(ke->text(), ke->key(),
- ke->modifiers()&(Qt::ShiftModifier|Qt::ControlModifier|Qt::AltModifier),
- ke->type() == QEvent::KeyPress, ke->isAutoRepeat());
- ke->accept();
- return true;
- }
- return QVFbAbstractView::event(e);
-}
-
-void QVFbView::keyPressEvent(QKeyEvent *e)
-{
- sendKeyboardData(e->text(), e->key(),
- e->modifiers()&(Qt::ShiftModifier|Qt::ControlModifier|Qt::AltModifier),
- true, e->isAutoRepeat());
-}
-
-void QVFbView::keyReleaseEvent(QKeyEvent *e)
-{
- sendKeyboardData(e->text(), e->key(),
- e->modifiers()&(Qt::ShiftModifier|Qt::ControlModifier|Qt::AltModifier),
- false, e->isAutoRepeat());
-}
-
-
-QImage QVFbView::image() const
-{
- int l;
- QImage r = getBuffer(QRect(0, 0, mView->width(), mView->height()), l).copy();
- return r;
-}
-
-void QVFbView::startAnimation(const QString& filename)
-{
- delete animation;
- animation = new QAnimationWriter(filename,"MNG");
- animation->setFrameRate(refreshRate);
- animation->appendFrame(QImage(mView->data(),
- mView->width(), mView->height(), QImage::Format_RGB32));
-}
-
-void QVFbView::stopAnimation()
-{
- delete animation;
- animation = 0;
-}
-
-
-void QVFbView::skinKeyPressEvent(int code, const QString& text, bool autorep)
-{
- QKeyEvent e(QEvent::KeyPress,code,0,text,autorep);
- keyPressEvent(&e);
-}
-
-void QVFbView::skinKeyReleaseEvent(int code, const QString& text, bool autorep)
-{
- QKeyEvent e(QEvent::KeyRelease,code,0,text,autorep);
- keyReleaseEvent(&e);
-}
-
-QT_END_NAMESPACE
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QVFBVIEW_H
-#define QVFBVIEW_H
-
-//#ifdef QT_NO_OPENGL
-#include <QWidget>
-//#else
-//#define QVFB_USE_GLWIDGET
-//#include <QGLWidget>
-//#endif
-
-QT_BEGIN_NAMESPACE
-
-class QImage;
-class QTimer;
-class QAnimationWriter;
-struct QVFbHeader;
-class QVFbViewProtocol;
-class QX11EmbedContainer;
-
-class QVFbAbstractView :
-#ifdef QVFB_USE_GLWIDGET
- public QGLWidget
-#else
- public QWidget
-#endif
-{
- Q_OBJECT
-public:
- enum Rotation { Rot0, Rot90, Rot180, Rot270 };
- enum PixelFormat { DefaultFormat, GrayscaleFormat, RGBFormat, ARGBFormat };
- QVFbAbstractView( QWidget *parent = 0);
- virtual ~QVFbAbstractView();
-
- virtual int displayId() const = 0;
- virtual int displayWidth() const = 0;
- virtual int displayHeight() const = 0;
- virtual int displayDepth() const = 0;
- virtual PixelFormat displayFormat() const { return DefaultFormat; }
- virtual bool rgbSwapped() const { return false; }
- virtual Rotation displayRotation() const = 0;
-
- virtual void setGamma(double gr, double gg, double gb) = 0;
- virtual double gammaRed() const = 0;
- virtual double gammaGreen() const = 0;
- virtual double gammaBlue() const = 0;
- virtual void getGamma(int i, QRgb& rgb) = 0;
-
- virtual bool touchScreenEmulation() const = 0;
- virtual bool lcdScreenEmulation() const = 0;
- virtual int rate() = 0;
- virtual bool animating() const = 0;
- virtual QImage image() const = 0;
- virtual void setRate(int) = 0;
-
- virtual double zoomH() const = 0;
- virtual double zoomV() const = 0;
-
-public slots:
- virtual void setTouchscreenEmulation( bool ) = 0;
- virtual void setLcdScreenEmulation( bool ) = 0;
- virtual void setZoom( double, double ) = 0;
- virtual void setRotation(Rotation) = 0;
- virtual void startAnimation( const QString& ) = 0;
- virtual void stopAnimation() = 0;
- virtual void skinKeyPressEvent( int code, const QString& text, bool autorep=FALSE ) = 0;
- virtual void skinKeyReleaseEvent( int code, const QString& text, bool autorep=FALSE ) = 0;
- virtual void setViewFormat(PixelFormat) {}
- virtual void setRgbSwapped( bool ) {};
- virtual void embedDisplay(WId) {}
-};
-
-class QVFbView : public QVFbAbstractView
-{
- Q_OBJECT
-public:
- QVFbView(int id, int w, int h, int d, Rotation r, QWidget *parent = 0);
- virtual ~QVFbView();
-
- int displayId() const;
- int displayWidth() const;
- int displayHeight() const;
- int displayDepth() const;
- PixelFormat displayFormat() const;
- bool rgbSwapped() const { return rgb_swapped; }
- Rotation displayRotation() const;
-
- bool touchScreenEmulation() const { return emulateTouchscreen; }
- bool lcdScreenEmulation() const { return emulateLcdScreen; }
- int rate() { return refreshRate; }
- bool animating() const { return !!animation; }
- QImage image() const;
-
- void setGamma(double gr, double gg, double gb);
- double gammaRed() const { return gred; }
- double gammaGreen() const { return ggreen; }
- double gammaBlue() const { return gblue; }
- void getGamma(int i, QRgb& rgb);
- void skinMouseEvent(QMouseEvent *e);
-
- double zoomH() const { return hzm; }
- double zoomV() const { return vzm; }
-
- QSize sizeHint() const;
- void setRate(int);
-
-public slots:
- void setTouchscreenEmulation(bool);
- void setLcdScreenEmulation(bool);
- void setZoom(double, double);
- void setRotation(Rotation);
- void startAnimation(const QString&);
- void stopAnimation();
- void skinKeyPressEvent(int code, const QString& text, bool autorep=FALSE);
- void skinKeyReleaseEvent(int code, const QString& text, bool autorep=FALSE);
- void setViewFormat(PixelFormat);
- void setRgbSwapped(bool b) { rgb_swapped = b; }
-#ifdef Q_WS_X11
- void embedDisplay(WId id);
-#endif
-
-protected slots:
- void refreshDisplay(const QRect &);
-
-protected:
- QImage getBuffer(const QRect &r, int &leading) const;
- void drawScreen(const QRect &r);
- void sendMouseData(const QPoint &pos, int buttons, int wheel);
- void sendKeyboardData(QString unicode, int keycode, int modifiers,
- bool press, bool repeat);
- //virtual bool eventFilter(QObject *obj, QEvent *e);
- virtual void paintEvent(QPaintEvent *pe);
- virtual void contextMenuEvent(QContextMenuEvent *e);
- virtual void mousePressEvent(QMouseEvent *e);
- virtual void mouseDoubleClickEvent(QMouseEvent *e);
- virtual void mouseReleaseEvent(QMouseEvent *e);
- virtual void mouseMoveEvent(QMouseEvent *e);
- virtual void wheelEvent(QWheelEvent *e);
- virtual void keyPressEvent(QKeyEvent *e);
- virtual void keyReleaseEvent(QKeyEvent *e);
- virtual bool event(QEvent *event);
-
-private:
- void setDirty(const QRect&);
- int viewdepth; // "faked" depth
- PixelFormat viewFormat;
- bool rgb_swapped;
- int rsh;
- int gsh;
- int bsh;
- int rmax;
- int gmax;
- int bmax;
- int contentsWidth;
- int contentsHeight;
- double gred, ggreen, gblue;
- QRgb* gammatable;
-
- int refreshRate;
- QAnimationWriter *animation;
- double hzm,vzm;
- QVFbViewProtocol *mView;
- bool emulateTouchscreen;
- bool emulateLcdScreen;
- Rotation rotation;
-
-#ifdef Q_WS_X11
- QX11EmbedContainer *embedContainer;
-#endif
-};
-
-QT_END_NAMESPACE
-
-#endif
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qvfbx11view.h"
-#include "x11keyfaker.h"
-#include <qevent.h>
-#include <QX11Info>
-#include <QTimer>
-#include <QProcess>
-#include <QDebug>
-#include <QUuid>
-#include <QDataStream>
-#include <QTemporaryFile>
-#include <X11/Xlib.h>
-
-QT_BEGIN_NAMESPACE
-
-QVFbX11View::QVFbX11View
- (int id, int w, int h, int d, Rotation r, QWidget *parent)
- : QVFbAbstractView(parent)
-{
- this->id = id;
- this->w = w;
- this->h = h;
- this->d = d;
- this->rotation = r;
- this->gr = 1.0;
- this->gg = 1.0;
- this->gb = 1.0;
- this->touchscreen = false;
- this->lcd = false;
- this->keyFaker = 0;
- this->xnest = 0;
- this->serverAuthFile = 0;
- this->shutdown = false;
-
- // Try to find Xephyr, as it is better than Xnest in many ways.
- if (QFile::exists("/usr/bin/Xephyr"))
- xserver = "/usr/bin/Xephyr";
- else if (QFile::exists("/usr/local/bin/Xephyr"))
- xserver = "/usr/local/bin/Xephyr";
- else if (QFile::exists("/usr/X11R6/bin/Xephyr"))
- xserver = "/usr/X11R6/bin/Xephyr";
- else
- xserver = "Xnest";
-}
-
-QVFbX11View::~QVFbX11View()
-{
- shutdown = true;
- if (xnest) {
- xnest->terminate();
- xnestStopped();
- }
-}
-
-int QVFbX11View::displayId() const
-{
- return id;
-}
-
-int QVFbX11View::displayWidth() const
-{
- return ( (int)rotation & 0x01 ) ? h : w;
-}
-
-int QVFbX11View::displayHeight() const
-{
- return ( (int)rotation & 0x01 ) ? w : h;
-}
-
-int QVFbX11View::displayDepth() const
-{
- return d;
-}
-
-QVFbX11View::Rotation QVFbX11View::displayRotation() const
-{
- return rotation;
-}
-
-void QVFbX11View::skinKeyPressEvent(int code, const QString&, bool)
-{
- if (keyFaker)
- keyFaker->sendKeyEvent(code, true);
-}
-
-void QVFbX11View::skinKeyReleaseEvent(int code, const QString&, bool)
-{
- if (keyFaker)
- keyFaker->sendKeyEvent(code, false);
-}
-
-void QVFbX11View::setGamma(double gr, double gg, double gb)
-{
- // We remember the values, but don't do anything with them.
- this->gr = gr;
- this->gg = gg;
- this->gb = gb;
-}
-
-double QVFbX11View::gammaRed() const
-{
- return gr;
-}
-
-double QVFbX11View::gammaGreen() const
-{
- return gg;
-}
-
-double QVFbX11View::gammaBlue() const
-{
- return gb;
-}
-
-void QVFbX11View::getGamma(int, QRgb& rgb)
-{
- rgb = qRgb(255, 255, 255);
-}
-
-bool QVFbX11View::touchScreenEmulation() const
-{
- return touchscreen;
-}
-
-bool QVFbX11View::lcdScreenEmulation() const
-{
- return lcd;
-}
-
-int QVFbX11View::rate()
-{
- // We don't support refresh rates, so return a default value.
- return 30;
-}
-
-bool QVFbX11View::animating() const
-{
- // We don't support animation.
- return false;
-}
-
-QImage QVFbX11View::image() const
-{
- // We don't support image capture.
- return QImage();
-}
-
-void QVFbX11View::setRate(int)
-{
- // We don't support rate adjustments.
-}
-
-
-double QVFbX11View::zoomH() const
-{
- // Zoom is not possible with Xnest.
- return 1.0;
-}
-
-double QVFbX11View::zoomV() const
-{
- // Zoom is not possible with Xnest.
- return 1.0;
-}
-
-QSize QVFbX11View::sizeHint() const
-{
- return QSize(w, h);
-}
-
-void QVFbX11View::setTouchscreenEmulation( bool flag )
-{
- touchscreen = flag;
-}
-
-void QVFbX11View::setLcdScreenEmulation( bool flag )
-{
- lcd = flag;
-}
-
-void QVFbX11View::setZoom( double, double )
-{
- // Zoom is not possible with Xnest.
-}
-
-void QVFbX11View::setRotation( Rotation )
-{
- // Rotation is not possible with Xnest.
-}
-
-void QVFbX11View::startAnimation( const QString& )
-{
- // Animation is not supported.
-}
-
-void QVFbX11View::stopAnimation()
-{
- // Animation is not supported.
-}
-
-// Generate a 16-byte magic cookie string.
-static QString generateMagicCookie()
-{
- static const char hexchars[] = "0123456789abcdef";
- QUuid uuid = QUuid::createUuid();
- QByteArray ba;
- QDataStream stream(&ba, QIODevice::WriteOnly);
- stream << uuid;
- QString value;
- foreach ( char ch, ba ) {
- value += QChar( hexchars[(ch >> 4) & 0x0F] );
- value += QChar( hexchars[ch & 0x0F] );
- }
- return value;
-}
-
-void QVFbX11View::showEvent(QShowEvent *e)
-{
- if (!xnest)
- startXnest();
- QWidget::showEvent(e);
-}
-
-void QVFbX11View::keyPressEvent(QKeyEvent *e)
-{
- if (keyFaker)
- keyFaker->sendKeyEvent(e->key(), true);
- QWidget::keyPressEvent(e);
-}
-
-void QVFbX11View::keyReleaseEvent(QKeyEvent *e)
-{
- if (keyFaker)
- keyFaker->sendKeyEvent(e->key(), false);
- QWidget::keyReleaseEvent(e);
-}
-
-void QVFbX11View::startXnest()
-{
- // Add authentication credentials to the XAUTHORITY file.
- QString cookie = generateMagicCookie();
- QStringList xauthargs;
- xauthargs += "add";
- xauthargs += ":" + QString::number(displayId());
- xauthargs += "MIT-MAGIC-COOKIE-1";
- xauthargs += cookie;
- if (QProcess::execute("xauth", xauthargs) != 0)
- qWarning() << "xauth: failed to add Xnest client authentication credentials";
-
- // Write the credentials to another authentication file for the server.
- serverAuthFile = new QTemporaryFile(this);
- QString authFilename;
- if (serverAuthFile->open()) {
- authFilename = serverAuthFile->fileName();
- serverAuthFile->close();
- xauthargs.clear();
- xauthargs += "-f";
- xauthargs += authFilename;
- xauthargs += "add";
- xauthargs += ":" + QString::number(displayId());
- xauthargs += "MIT-MAGIC-COOKIE-1";
- xauthargs += cookie;
- if (QProcess::execute("xauth", xauthargs) != 0)
- qWarning() << "xauth: failed to add Xnest server authentication credentials";
- }
-
- // Create a raw X11 window to act as the Xnest's root window.
- // We cannot use winId() directly because qvfb is already
- // selecting for events that Xnest wants to select for.
- WId root = XCreateSimpleWindow
- (QX11Info::display(), winId(), 0, 0, w, h, 0,
- BlackPixel(QX11Info::display(), QX11Info::appScreen()),
- BlackPixel(QX11Info::display(), QX11Info::appScreen()));
- XMapWindow(QX11Info::display(), root);
-
- // Warn the user if the visual number looks wrong. Xnest expects
- // its root window to be on the default visual.
- if (QX11Info::appVisual() != DefaultVisual(QX11Info::display(), QX11Info::appScreen())) {
- qWarning() << "*** Qt is not using the default visual. Xnest may fail "
- "with a BadMatch error.";
- qWarning() << "*** If it fails, then restart qvfb with \" -visual"
- << DefaultVisual(QX11Info::display(), QX11Info::appScreen())
- ->visualid << "\"";
- }
-
- // Make sure the root window is in the X server before Xnest starts.
- XSync(QX11Info::display(), False);
-
- // Start the Xnest process.
- xnest = new QProcess(this);
- connect(xnest, SIGNAL(error(QProcess::ProcessError)),
- this, SLOT(xnestStopped()));
- connect(xnest, SIGNAL(finished(int,QProcess::ExitStatus)),
- this, SLOT(xnestStopped()));
- QStringList args;
- args += "-auth";
- args += authFilename;
- if (!xserver.contains("Xephyr")) {
- args += "-geometry";
- args += QString::number(w) + "x" + QString::number(h) + "+0+0";
- args += "-depth";
- args += QString::number(d);
- }
- args += "-br"; // Start Xnest with a black background.
- args += "-parent";
- args += "0x" + QString::number(root, 16);
- args += ":" + QString::number(displayId());
- xnest->setProcessChannelMode(QProcess::ForwardedChannels);
- xnest->start(xserver, args);
- //qDebug() << args;
-
- QTimer::singleShot(200, this, SLOT(startKeyFaker()));
-}
-
-void QVFbX11View::xnestStopped()
-{
- if (!shutdown) {
- if (xnest && xnest->error() == QProcess::FailedToStart)
- qWarning() << xserver << "could not be started";
- else
- qWarning() << xserver << "stopped unexpectedly";
- }
- if (keyFaker) {
- delete keyFaker;
- keyFaker = 0;
- }
- if (xnest) {
- xnest->deleteLater();
- xnest = 0;
-
- QStringList xauthargs;
- xauthargs += "remove";
- xauthargs += ":" + QString::number(displayId());
- if (QProcess::execute("xauth", xauthargs) != 0)
- qWarning() << "xauth: failed to remove Xnest authentication credentials";
- }
- if (serverAuthFile) {
- delete serverAuthFile;
- serverAuthFile = 0;
- }
-}
-
-void QVFbX11View::startKeyFaker()
-{
- if (!keyFaker && xnest)
- keyFaker = new X11KeyFaker(":" + QString::number(displayId()), this);
-}
-
-QT_END_NAMESPACE
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QVFBX11VIEW_H
-#define QVFBX11VIEW_H
-
-#include "qvfbview.h"
-
-QT_BEGIN_NAMESPACE
-
-class X11KeyFaker;
-class QProcess;
-class QTemporaryFile;
-
-class QVFbX11View : public QVFbAbstractView
-{
- Q_OBJECT
-public:
- QVFbX11View( int id, int w, int h, int d, Rotation r, QWidget *parent = 0);
- virtual ~QVFbX11View();
-
- QString xServerPath() const { return xserver; }
- void setXServerPath(const QString& path) { xserver = path; }
-
- int displayId() const;
- int displayWidth() const;
- int displayHeight() const;
- int displayDepth() const;
- Rotation displayRotation() const;
-
- void skinKeyPressEvent( int code, const QString& text, bool autorep=FALSE );
- void skinKeyReleaseEvent( int code, const QString& text, bool autorep=FALSE );
-
- void setGamma(double gr, double gg, double gb);
- double gammaRed() const;
- double gammaGreen() const;
- double gammaBlue() const;
- void getGamma(int i, QRgb& rgb);
-
- bool touchScreenEmulation() const;
- bool lcdScreenEmulation() const;
- int rate();
- bool animating() const;
- QImage image() const;
- void setRate(int);
-
- double zoomH() const;
- double zoomV() const;
-
- QSize sizeHint() const;
-
-public slots:
- void setTouchscreenEmulation( bool );
- void setLcdScreenEmulation( bool );
- void setZoom( double, double );
- void setRotation(Rotation);
- void startAnimation( const QString& );
- void stopAnimation();
-
-protected:
- void showEvent(QShowEvent *);
- void keyPressEvent(QKeyEvent *);
- void keyReleaseEvent(QKeyEvent *);
-
-private slots:
- void startXnest();
- void xnestStopped();
- void startKeyFaker();
-
-private:
- int id, w, h, d;
- Rotation rotation;
- double gr, gg, gb;
- bool touchscreen, lcd;
- X11KeyFaker *keyFaker;
- QProcess *xnest;
- QTemporaryFile *serverAuthFile;
- bool shutdown;
- QString xserver;
-};
-
-QT_END_NAMESPACE
-
-#endif
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "x11keyfaker.h"
-#include <QTimer>
-#include <QSocketNotifier>
-#include <QDebug>
-#include <X11/Xlib.h>
-#include <X11/cursorfont.h>
-#include <X11/extensions/XTest.h>
-#include <X11/keysym.h>
-#include <X11/XF86keysym.h>
-#include "qtopiakeysym.h"
-#include <unistd.h>
-#include <fcntl.h>
-
-QT_BEGIN_NAMESPACE
-
-X11KeyFaker::X11KeyFaker(const QString& displayName, QObject *parent)
- : QObject(parent)
-{
- this->displayName = displayName;
- this->dpy = 0;
- this->retryCount = 0;
- this->shiftKeycode = 0;
- this->modeSwitchKeycode = 0;
- this->modifiers = 0;
- connect();
-}
-
-X11KeyFaker::~X11KeyFaker()
-{
- if (dpy)
- XCloseDisplay(dpy);
-}
-
-void X11KeyFaker::sendKeyEvent(int qtCode, bool isPress)
-{
- if (!dpy)
- return;
-
- // Convert the Qt key code into an X keysym.
- KeySym keysym = NoSymbol;
- switch (qtCode) {
- case Qt::Key_Escape: keysym = XK_Escape; break;
- case Qt::Key_Tab: keysym = XK_Tab; break;
- case Qt::Key_Backtab: keysym = XK_ISO_Left_Tab; break;
- case Qt::Key_Backspace: keysym = XK_BackSpace; break;
- case Qt::Key_Return: keysym = XK_Return; break;
- case Qt::Key_Enter: keysym = XK_KP_Enter; break;
- case Qt::Key_Insert: keysym = XK_KP_Insert; break;
- case Qt::Key_Delete: keysym = XK_KP_Delete; break;
- case Qt::Key_Pause: keysym = XK_Pause; break;
- case Qt::Key_Print: keysym = XK_Print; break;
- case Qt::Key_SysReq: keysym = 0x1005FF60; break;
- case Qt::Key_Clear: keysym = XK_KP_Begin; break;
- case Qt::Key_Home: keysym = XK_Home; break;
- case Qt::Key_End: keysym = XK_End; break;
- case Qt::Key_Left: keysym = XK_Left; break;
- case Qt::Key_Up: keysym = XK_Up; break;
- case Qt::Key_Right: keysym = XK_Right; break;
- case Qt::Key_Down: keysym = XK_Down; break;
- case Qt::Key_PageUp: keysym = XK_Prior; break;
- case Qt::Key_PageDown: keysym = XK_Next; break;
- case Qt::Key_Shift: keysym = XK_Shift_L; break;
- case Qt::Key_Control: keysym = XK_Control_L; break;
- case Qt::Key_Meta: keysym = XK_Meta_L; break;
- case Qt::Key_Alt: keysym = XK_Alt_L; break;
- case Qt::Key_CapsLock: keysym = XK_Caps_Lock; break;
- case Qt::Key_NumLock: keysym = XK_Num_Lock; break;
- case Qt::Key_ScrollLock: keysym = XK_Scroll_Lock; break;
- case Qt::Key_F1: keysym = XK_F1; break;
- case Qt::Key_F2: keysym = XK_F2; break;
- case Qt::Key_F3: keysym = XK_F3; break;
- case Qt::Key_F4: keysym = XK_F4; break;
- case Qt::Key_F5: keysym = XK_F5; break;
- case Qt::Key_F6: keysym = XK_F6; break;
- case Qt::Key_F7: keysym = XK_F7; break;
- case Qt::Key_F8: keysym = XK_F8; break;
- case Qt::Key_F9: keysym = XK_F9; break;
- case Qt::Key_F10: keysym = XK_F10; break;
- case Qt::Key_F11: keysym = XK_F11; break;
- case Qt::Key_F12: keysym = XK_F12; break;
- case Qt::Key_F13: keysym = XK_F13; break;
- case Qt::Key_F14: keysym = XK_F14; break;
- case Qt::Key_F15: keysym = XK_F15; break;
- case Qt::Key_F16: keysym = XK_F16; break;
- case Qt::Key_F17: keysym = XK_F17; break;
- case Qt::Key_F18: keysym = XK_F18; break;
- case Qt::Key_F19: keysym = XK_F19; break;
- case Qt::Key_F20: keysym = XK_F20; break;
- case Qt::Key_F21: keysym = XK_F21; break;
- case Qt::Key_F22: keysym = XK_F22; break;
- case Qt::Key_F23: keysym = XK_F23; break;
- case Qt::Key_F24: keysym = XK_F24; break;
- case Qt::Key_F25: keysym = XK_F25; break;
- case Qt::Key_F26: keysym = XK_F26; break;
- case Qt::Key_F27: keysym = XK_F27; break;
- case Qt::Key_F28: keysym = XK_F28; break;
- case Qt::Key_F29: keysym = XK_F29; break;
- case Qt::Key_F30: keysym = XK_F30; break;
- case Qt::Key_F31: keysym = XK_F31; break;
- case Qt::Key_F32: keysym = XK_F32; break;
- case Qt::Key_F33: keysym = XK_F33; break;
- case Qt::Key_F34: keysym = XK_F34; break;
- case Qt::Key_F35: keysym = XK_F35; break;
- case Qt::Key_Super_L: keysym = XK_Super_L; break;
- case Qt::Key_Super_R: keysym = XK_Super_R; break;
- case Qt::Key_Menu: keysym = XK_Menu; break;
- case Qt::Key_Hyper_L: keysym = XK_Hyper_L; break;
- case Qt::Key_Hyper_R: keysym = XK_Hyper_R; break;
- case Qt::Key_Help: keysym = XK_Help; break;
- case Qt::Key_Direction_L: keysym = NoSymbol; break; // ???
- case Qt::Key_Direction_R: keysym = NoSymbol; break; // ???
- case Qt::Key_Space: keysym = XK_space; break;
- case Qt::Key_Exclam: keysym = XK_exclam; break;
- case Qt::Key_QuoteDbl: keysym = XK_quotedbl; break;
- case Qt::Key_NumberSign: keysym = XK_numbersign; break;
- case Qt::Key_Dollar: keysym = XK_dollar; break;
- case Qt::Key_Percent: keysym = XK_percent; break;
- case Qt::Key_Ampersand: keysym = XK_ampersand; break;
- case Qt::Key_Apostrophe: keysym = XK_apostrophe; break;
- case Qt::Key_ParenLeft: keysym = XK_parenleft; break;
- case Qt::Key_ParenRight: keysym = XK_parenright; break;
- case Qt::Key_Asterisk: keysym = XK_asterisk; break;
- case Qt::Key_Plus: keysym = XK_plus; break;
- case Qt::Key_Comma: keysym = XK_comma; break;
- case Qt::Key_Minus: keysym = XK_minus; break;
- case Qt::Key_Period: keysym = XK_period; break;
- case Qt::Key_Slash: keysym = XK_slash; break;
- case Qt::Key_0: keysym = XK_0; break;
- case Qt::Key_1: keysym = XK_1; break;
- case Qt::Key_2: keysym = XK_2; break;
- case Qt::Key_3: keysym = XK_3; break;
- case Qt::Key_4: keysym = XK_4; break;
- case Qt::Key_5: keysym = XK_5; break;
- case Qt::Key_6: keysym = XK_6; break;
- case Qt::Key_7: keysym = XK_7; break;
- case Qt::Key_8: keysym = XK_8; break;
- case Qt::Key_9: keysym = XK_9; break;
- case Qt::Key_Colon: keysym = XK_colon; break;
- case Qt::Key_Semicolon: keysym = XK_semicolon; break;
- case Qt::Key_Less: keysym = XK_less; break;
- case Qt::Key_Equal: keysym = XK_equal; break;
- case Qt::Key_Greater: keysym = XK_greater; break;
- case Qt::Key_Question: keysym = XK_question; break;
- case Qt::Key_At: keysym = XK_at; break;
- case Qt::Key_A: keysym = XK_a; break; // Must be lower case keysyms
- case Qt::Key_B: keysym = XK_b; break; // for correct shift handling.
- case Qt::Key_C: keysym = XK_c; break;
- case Qt::Key_D: keysym = XK_d; break;
- case Qt::Key_E: keysym = XK_e; break;
- case Qt::Key_F: keysym = XK_f; break;
- case Qt::Key_G: keysym = XK_g; break;
- case Qt::Key_H: keysym = XK_h; break;
- case Qt::Key_I: keysym = XK_i; break;
- case Qt::Key_J: keysym = XK_j; break;
- case Qt::Key_K: keysym = XK_k; break;
- case Qt::Key_L: keysym = XK_l; break;
- case Qt::Key_M: keysym = XK_m; break;
- case Qt::Key_N: keysym = XK_n; break;
- case Qt::Key_O: keysym = XK_o; break;
- case Qt::Key_P: keysym = XK_p; break;
- case Qt::Key_Q: keysym = XK_q; break;
- case Qt::Key_R: keysym = XK_r; break;
- case Qt::Key_S: keysym = XK_s; break;
- case Qt::Key_T: keysym = XK_t; break;
- case Qt::Key_U: keysym = XK_u; break;
- case Qt::Key_V: keysym = XK_v; break;
- case Qt::Key_W: keysym = XK_w; break;
- case Qt::Key_X: keysym = XK_x; break;
- case Qt::Key_Y: keysym = XK_y; break;
- case Qt::Key_Z: keysym = XK_z; break;
- case Qt::Key_BracketLeft: keysym = XK_bracketleft; break;
- case Qt::Key_Backslash: keysym = XK_backslash; break;
- case Qt::Key_BracketRight: keysym = XK_bracketright; break;
- case Qt::Key_AsciiCircum: keysym = XK_asciicircum; break;
- case Qt::Key_Underscore: keysym = XK_underscore; break;
- case Qt::Key_QuoteLeft: keysym = XK_quoteleft; break;
- case Qt::Key_BraceLeft: keysym = XK_braceleft; break;
- case Qt::Key_Bar: keysym = XK_bar; break;
- case Qt::Key_BraceRight: keysym = XK_braceright; break;
- case Qt::Key_AsciiTilde: keysym = XK_asciitilde; break;
-
- case Qt::Key_nobreakspace: keysym = XK_nobreakspace; break;
- case Qt::Key_exclamdown: keysym = XK_exclamdown; break;
- case Qt::Key_cent: keysym = XK_cent; break;
- case Qt::Key_sterling: keysym = XK_sterling; break;
- case Qt::Key_currency: keysym = XK_currency; break;
- case Qt::Key_yen: keysym = XK_yen; break;
- case Qt::Key_brokenbar: keysym = XK_brokenbar; break;
- case Qt::Key_section: keysym = XK_section; break;
- case Qt::Key_diaeresis: keysym = XK_diaeresis; break;
- case Qt::Key_copyright: keysym = XK_copyright; break;
- case Qt::Key_ordfeminine: keysym = XK_ordfeminine; break;
- case Qt::Key_guillemotleft: keysym = XK_guillemotleft; break;
- case Qt::Key_notsign: keysym = XK_notsign; break;
- case Qt::Key_hyphen: keysym = XK_hyphen; break;
- case Qt::Key_registered: keysym = XK_registered; break;
- case Qt::Key_macron: keysym = XK_macron; break;
- case Qt::Key_degree: keysym = XK_degree; break;
- case Qt::Key_plusminus: keysym = XK_plusminus; break;
- case Qt::Key_twosuperior: keysym = XK_twosuperior; break;
- case Qt::Key_threesuperior: keysym = XK_threesuperior; break;
- case Qt::Key_acute: keysym = XK_acute; break;
- case Qt::Key_mu: keysym = XK_mu; break;
- case Qt::Key_paragraph: keysym = XK_paragraph; break;
- case Qt::Key_periodcentered: keysym = XK_periodcentered; break;
- case Qt::Key_cedilla: keysym = XK_cedilla; break;
- case Qt::Key_onesuperior: keysym = XK_onesuperior; break;
- case Qt::Key_masculine: keysym = XK_masculine; break;
- case Qt::Key_guillemotright: keysym = XK_guillemotright; break;
- case Qt::Key_onequarter: keysym = XK_onequarter; break;
- case Qt::Key_onehalf: keysym = XK_onehalf; break;
- case Qt::Key_threequarters: keysym = XK_threequarters; break;
- case Qt::Key_questiondown: keysym = XK_questiondown; break;
- case Qt::Key_Agrave: keysym = XK_agrave; break; // Lower case keysyms
- case Qt::Key_Aacute: keysym = XK_aacute; break; // for shift handling.
- case Qt::Key_Acircumflex: keysym = XK_acircumflex; break;
- case Qt::Key_Atilde: keysym = XK_atilde; break;
- case Qt::Key_Adiaeresis: keysym = XK_adiaeresis; break;
- case Qt::Key_Aring: keysym = XK_aring; break;
- case Qt::Key_AE: keysym = XK_ae; break;
- case Qt::Key_Ccedilla: keysym = XK_ccedilla; break;
- case Qt::Key_Egrave: keysym = XK_egrave; break;
- case Qt::Key_Eacute: keysym = XK_eacute; break;
- case Qt::Key_Ecircumflex: keysym = XK_ecircumflex; break;
- case Qt::Key_Ediaeresis: keysym = XK_ediaeresis; break;
- case Qt::Key_Igrave: keysym = XK_igrave; break;
- case Qt::Key_Iacute: keysym = XK_iacute; break;
- case Qt::Key_Icircumflex: keysym = XK_icircumflex; break;
- case Qt::Key_Idiaeresis: keysym = XK_idiaeresis; break;
- case Qt::Key_ETH: keysym = XK_eth; break;
- case Qt::Key_Ntilde: keysym = XK_ntilde; break;
- case Qt::Key_Ograve: keysym = XK_ograve; break;
- case Qt::Key_Oacute: keysym = XK_oacute; break;
- case Qt::Key_Ocircumflex: keysym = XK_ocircumflex; break;
- case Qt::Key_Otilde: keysym = XK_otilde; break;
- case Qt::Key_Odiaeresis: keysym = XK_odiaeresis; break;
- case Qt::Key_multiply: keysym = XK_multiply; break;
- case Qt::Key_Ooblique: keysym = XK_ooblique; break;
- case Qt::Key_Ugrave: keysym = XK_ugrave; break;
- case Qt::Key_Uacute: keysym = XK_uacute; break;
- case Qt::Key_Ucircumflex: keysym = XK_ucircumflex; break;
- case Qt::Key_Udiaeresis: keysym = XK_udiaeresis; break;
- case Qt::Key_Yacute: keysym = XK_yacute; break;
- case Qt::Key_THORN: keysym = XK_thorn; break;
- case Qt::Key_ssharp: keysym = XK_ssharp; break;
- case Qt::Key_division: keysym = XK_division; break;
- case Qt::Key_ydiaeresis: keysym = XK_ydiaeresis; break;
-
- case Qt::Key_AltGr: keysym = XK_ISO_Level3_Shift; break;
- case Qt::Key_Multi_key: keysym = XK_Multi_key; break;
- case Qt::Key_Codeinput: keysym = XK_Codeinput; break;
- case Qt::Key_SingleCandidate: keysym = XK_SingleCandidate; break;
- case Qt::Key_MultipleCandidate: keysym = XK_MultipleCandidate; break;
- case Qt::Key_PreviousCandidate: keysym = XK_PreviousCandidate; break;
-
- case Qt::Key_Mode_switch: keysym = XK_Mode_switch; break;
-
- case Qt::Key_Kanji: keysym = XK_Kanji; break;
- case Qt::Key_Muhenkan: keysym = XK_Muhenkan; break;
- case Qt::Key_Henkan: keysym = XK_Henkan; break;
- case Qt::Key_Romaji: keysym = XK_Romaji; break;
- case Qt::Key_Hiragana: keysym = XK_Hiragana; break;
- case Qt::Key_Katakana: keysym = XK_Katakana; break;
- case Qt::Key_Hiragana_Katakana: keysym = XK_Hiragana_Katakana; break;
- case Qt::Key_Zenkaku: keysym = XK_Zenkaku; break;
- case Qt::Key_Hankaku: keysym = XK_Hankaku; break;
- case Qt::Key_Zenkaku_Hankaku: keysym = XK_Zenkaku_Hankaku; break;
- case Qt::Key_Touroku: keysym = XK_Touroku; break;
- case Qt::Key_Massyo: keysym = XK_Massyo; break;
- case Qt::Key_Kana_Lock: keysym = XK_Kana_Lock; break;
- case Qt::Key_Kana_Shift: keysym = XK_Kana_Shift; break;
- case Qt::Key_Eisu_Shift: keysym = XK_Eisu_Shift; break;
- case Qt::Key_Eisu_toggle: keysym = XK_Eisu_toggle; break;
-
- case Qt::Key_Hangul: keysym = XK_Hangul; break;
- case Qt::Key_Hangul_Start: keysym = XK_Hangul_Start; break;
- case Qt::Key_Hangul_End: keysym = XK_Hangul_End; break;
- case Qt::Key_Hangul_Hanja: keysym = XK_Hangul_Hanja; break;
- case Qt::Key_Hangul_Jamo: keysym = XK_Hangul_Jamo; break;
- case Qt::Key_Hangul_Romaja: keysym = XK_Hangul_Romaja; break;
- case Qt::Key_Hangul_Jeonja: keysym = XK_Hangul_Jeonja; break;
- case Qt::Key_Hangul_Banja: keysym = XK_Hangul_Banja; break;
- case Qt::Key_Hangul_PreHanja: keysym = XK_Hangul_PreHanja; break;
- case Qt::Key_Hangul_PostHanja: keysym = XK_Hangul_PostHanja; break;
- case Qt::Key_Hangul_Special: keysym = XK_Hangul_Special; break;
-
- case Qt::Key_Dead_Grave: keysym = XK_dead_grave; break;
- case Qt::Key_Dead_Acute: keysym = XK_dead_acute; break;
- case Qt::Key_Dead_Circumflex: keysym = XK_dead_circumflex; break;
- case Qt::Key_Dead_Tilde: keysym = XK_dead_tilde; break;
- case Qt::Key_Dead_Macron: keysym = XK_dead_macron; break;
- case Qt::Key_Dead_Breve: keysym = XK_dead_breve; break;
- case Qt::Key_Dead_Abovedot: keysym = XK_dead_abovedot; break;
- case Qt::Key_Dead_Diaeresis: keysym = XK_dead_diaeresis; break;
- case Qt::Key_Dead_Abovering: keysym = XK_dead_abovering; break;
- case Qt::Key_Dead_Doubleacute: keysym = XK_dead_doubleacute; break;
- case Qt::Key_Dead_Caron: keysym = XK_dead_caron; break;
- case Qt::Key_Dead_Cedilla: keysym = XK_dead_cedilla; break;
- case Qt::Key_Dead_Ogonek: keysym = XK_dead_ogonek; break;
- case Qt::Key_Dead_Iota: keysym = XK_dead_iota; break;
- case Qt::Key_Dead_Voiced_Sound: keysym = XK_dead_voiced_sound; break;
- case Qt::Key_Dead_Semivoiced_Sound: keysym = XK_dead_semivoiced_sound; break;
- case Qt::Key_Dead_Belowdot: keysym = XK_dead_belowdot; break;
- case Qt::Key_Dead_Hook: keysym = XK_dead_hook; break;
- case Qt::Key_Dead_Horn: keysym = XK_dead_horn; break;
-
- case Qt::Key_Back: keysym = XF86XK_Back; break;
- case Qt::Key_Forward: keysym = XF86XK_Forward; break;
- case Qt::Key_Stop: keysym = XF86XK_Stop; break;
- case Qt::Key_Refresh: keysym = XF86XK_Refresh; break;
-
- case Qt::Key_VolumeDown: keysym = XF86XK_AudioLowerVolume; break;
- case Qt::Key_VolumeMute: keysym = XF86XK_AudioMute; break;
- case Qt::Key_VolumeUp: keysym = XF86XK_AudioRaiseVolume; break;
- case Qt::Key_BassBoost: keysym = NoSymbol; break; // ???
- case Qt::Key_BassUp: keysym = NoSymbol; break; // ???
- case Qt::Key_BassDown: keysym = NoSymbol; break; // ???
- case Qt::Key_TrebleUp: keysym = NoSymbol; break; // ???
- case Qt::Key_TrebleDown: keysym = NoSymbol; break; // ???
-
- case Qt::Key_MediaPlay: keysym = XF86XK_AudioPlay; break;
- case Qt::Key_MediaStop: keysym = XF86XK_AudioStop; break;
- case Qt::Key_MediaPrevious: keysym = XF86XK_AudioPrev; break;
- case Qt::Key_MediaNext: keysym = XF86XK_AudioNext; break;
- case Qt::Key_MediaRecord: keysym = XF86XK_AudioRecord; break;
-
- case Qt::Key_HomePage: keysym = XF86XK_HomePage; break;
- case Qt::Key_Favorites: keysym = XF86XK_Favorites; break;
- case Qt::Key_Search: keysym = XF86XK_Search; break;
- case Qt::Key_Standby: keysym = XF86XK_Standby; break;
- case Qt::Key_OpenUrl: keysym = XF86XK_OpenURL; break;
-
- case Qt::Key_LaunchMail: keysym = XF86XK_Mail; break;
- case Qt::Key_LaunchMedia: keysym = XF86XK_AudioMedia; break;
- case Qt::Key_Launch0: keysym = XF86XK_Launch0; break;
- case Qt::Key_Launch1: keysym = XF86XK_Launch1; break;
- case Qt::Key_Launch2: keysym = XF86XK_Launch2; break;
- case Qt::Key_Launch3: keysym = XF86XK_Launch3; break;
- case Qt::Key_Launch4: keysym = XF86XK_Launch4; break;
- case Qt::Key_Launch5: keysym = XF86XK_Launch5; break;
- case Qt::Key_Launch6: keysym = XF86XK_Launch6; break;
- case Qt::Key_Launch7: keysym = XF86XK_Launch7; break;
- case Qt::Key_Launch8: keysym = XF86XK_Launch8; break;
- case Qt::Key_Launch9: keysym = XF86XK_Launch9; break;
- case Qt::Key_LaunchA: keysym = XF86XK_LaunchA; break;
- case Qt::Key_LaunchB: keysym = XF86XK_LaunchB; break;
- case Qt::Key_LaunchC: keysym = XF86XK_LaunchC; break;
- case Qt::Key_LaunchD: keysym = XF86XK_LaunchD; break;
- case Qt::Key_LaunchE: keysym = XF86XK_LaunchE; break;
- case Qt::Key_LaunchF: keysym = XF86XK_LaunchF; break;
-
- case Qt::Key_MediaLast: keysym = NoSymbol; break; // ???
-
- case Qt::Key_Select: keysym = QTOPIAXK_Select; break;
- case Qt::Key_Yes: keysym = QTOPIAXK_Yes; break;
- case Qt::Key_No: keysym = QTOPIAXK_No; break;
-
- case Qt::Key_Cancel: keysym = QTOPIAXK_Cancel; break;
- case Qt::Key_Printer: keysym = QTOPIAXK_Printer; break;
- case Qt::Key_Execute: keysym = QTOPIAXK_Execute; break;
- case Qt::Key_Sleep: keysym = QTOPIAXK_Sleep; break;
- case Qt::Key_Play: keysym = QTOPIAXK_Play; break;
- case Qt::Key_Zoom: keysym = QTOPIAXK_Zoom; break;
-
- case Qt::Key_Context1: keysym = QTOPIAXK_Context1; break;
- case Qt::Key_Context2: keysym = QTOPIAXK_Context2; break;
- case Qt::Key_Context3: keysym = QTOPIAXK_Context3; break;
- case Qt::Key_Context4: keysym = QTOPIAXK_Context4; break;
- case Qt::Key_Call: keysym = QTOPIAXK_Call; break;
- case Qt::Key_Hangup: keysym = QTOPIAXK_Hangup; break;
- case Qt::Key_Flip: keysym = QTOPIAXK_Flip; break;
-
- case Qt::Key_unknown: keysym = NoSymbol; break;
- }
- if (keysym == NoSymbol)
- return;
-
- // Convert the X keysym into an X keycode.
- KeyCode keycode = XKeysymToKeycode(dpy, keysym);
- if (keycode == NoSymbol)
- return;
-
- // Determine if we need to fake shift keys as well.
- int index = 0;
- while (index < 4 && XKeycodeToKeysym(dpy, keycode, index) != keysym)
- ++index;
- int extraModifiers = 0;
- if ((index & 1) != 0)
- extraModifiers |= ShiftMask;
- if ((index & 2) != 0)
- extraModifiers |= Mod2Mask;
- if ((modifiers & LockMask) != 0) {
- // If Caps Lock is set, then flip the shift state for alphabetic keys.
- if (qtCode >= Qt::Key_A && qtCode <= Qt::Key_Z)
- extraModifiers ^= ShiftMask;
- if (qtCode >= Qt::Key_Agrave && qtCode <= Qt::Key_THORN &&
- qtCode != Qt::Key_multiply)
- extraModifiers ^= ShiftMask;
- }
-
- // Adjust modifier keys for the shift states. This is needed for
- // things like the * and # phone keys, which need Shift to be pressed
- // when entering from a keyboard, but don't need Shift from a skin.
- unsigned long delay = 0;
- if (extraModifiers != 0) {
- if ((extraModifiers & ShiftMask) != 0) {
- if ((modifiers & ShiftMask) == 0)
- XTestFakeKeyEvent(dpy, shiftKeycode, true, delay++);
- } else {
- if ((modifiers & ShiftMask) != 0)
- XTestFakeKeyEvent(dpy, shiftKeycode, false, delay++);
- }
- if ((extraModifiers & Mod2Mask) != 0) {
- if ((modifiers & Mod2Mask) == 0)
- XTestFakeKeyEvent(dpy, modeSwitchKeycode, true, delay++);
- } else {
- if ((modifiers & Mod2Mask) != 0)
- XTestFakeKeyEvent(dpy, modeSwitchKeycode, false, delay++);
- }
- }
-
- // Fake the actual key.
- XTestFakeKeyEvent(dpy, keycode, (Bool)isPress, delay++);
-
- // Adjust the modifiers back.
- if (extraModifiers != 0) {
- if ((extraModifiers & ShiftMask) != 0) {
- if ((modifiers & ShiftMask) == 0)
- XTestFakeKeyEvent(dpy, shiftKeycode, false, delay++);
- } else {
- if ((modifiers & ShiftMask) != 0)
- XTestFakeKeyEvent(dpy, shiftKeycode, true, delay++);
- }
- if ((extraModifiers & Mod2Mask) != 0) {
- if ((modifiers & Mod2Mask) == 0)
- XTestFakeKeyEvent(dpy, modeSwitchKeycode, false, delay++);
- } else {
- if ((modifiers & Mod2Mask) != 0)
- XTestFakeKeyEvent(dpy, modeSwitchKeycode, true, delay++);
- }
- }
-
- // Flush the key events.
- XFlush(dpy);
-
- // Update the modifiers if this was a shift key.
- if (isPress) {
- if (qtCode == Qt::Key_Shift)
- modifiers |= ShiftMask;
- if (qtCode == Qt::Key_CapsLock)
- modifiers |= LockMask;
- if (qtCode == Qt::Key_Mode_switch)
- modifiers |= Mod2Mask;
- } else {
- if (qtCode == Qt::Key_Shift)
- modifiers &= ~ShiftMask;
- if (qtCode == Qt::Key_CapsLock)
- modifiers &= ~LockMask;
- if (qtCode == Qt::Key_Mode_switch)
- modifiers &= ~Mod2Mask;
- }
-}
-
-// Determine if an X11 keycode is currently mapped to one or more keysyms.
-static bool keycodeInUse(Display *dpy, int keycode)
-{
- for (int index = 0; index < 8; ++index) {
- if (XKeycodeToKeysym(dpy, keycode, index) != NoSymbol)
- return true;
- }
- return false;
-}
-
-// Allocate a keycode for a special keysym.
-static bool allocateSpecialKeysym
- (Display *dpy, int& min_keycode, int& max_keycode, KeySym key)
-{
- if (XKeysymToKeycode(dpy, key) != NoSymbol)
- return true; // There is already a mapping for this key. Good!
- while (max_keycode >= min_keycode) {
- if (!keycodeInUse(dpy, max_keycode))
- break;
- --max_keycode;
- }
- if (max_keycode < min_keycode)
- return false;
- XChangeKeyboardMapping(dpy, max_keycode, 1, &key, 1);
- --max_keycode;
- return true;
-}
-
-void X11KeyFaker::connect()
-{
- // Open the display.
- dpy = XOpenDisplay(displayName.toLatin1().data());
- if (!dpy) {
- // Try again in a few milliseconds. Xnest may not be alive yet.
- // Give up after 10 seconds.
- if (++retryCount < 50)
- QTimer::singleShot(200, this, SLOT(connect()));
- else
- QTimer::singleShot(0, this, SIGNAL(couldNotConnect()));
- return;
- }
-
- // Query the XTest extension, which we need to fake the key events.
- int event_base, error_base, major, minor;
- if (!XTestQueryExtension
- (dpy, &event_base, &error_base, &major, &minor)) {
- XCloseDisplay(dpy);
- dpy = 0;
- QTimer::singleShot(0, this, SIGNAL(couldNotConnect()));
- return;
- }
-
- // Modify the Xnest's keyboard mappings to add Qtopia's special keysyms.
- int min_keycode = 1, max_keycode = 255;
- XDisplayKeycodes(dpy, &min_keycode, &max_keycode);
- bool ok = true;
- for (KeySym key = QTOPIAXK_Max; key >= QTOPIAXK_Min; --key) {
- // This is an extension keysym, not part of the standard X11 set.
- if (!allocateSpecialKeysym(dpy, min_keycode, max_keycode, key)) {
- ok = false;
- break;
- }
- }
- static const KeySym specials[] = {
- XF86XK_Back, // Qt::Key_Back
- XF86XK_AudioLowerVolume, // Qt::Key_VolumeUp
- XF86XK_AudioRaiseVolume, // Qt::Key_VolumeDown
- XK_F28, // Qt::Key_F28
- NoSymbol
- };
- int index = 0;
- while (ok && specials[index] != NoSymbol) {
- // This is a standard X11/XFree86 keysym that Qtopia uses,
- // but it may not be on the user's physical keyboard.
- if (!allocateSpecialKeysym
- (dpy, min_keycode, max_keycode, specials[index]))
- ok = false;
- ++index;
- }
- if (!ok)
- qWarning() << "There are insufficient spare X11 keycodes to allocate the special Qtopia keys";
-
- // Change the root cursor to something more reasonable than "X".
- Cursor cursor = XCreateFontCursor(dpy, XC_left_ptr);
- XDefineCursor(dpy, RootWindow(dpy, DefaultScreen(dpy)), cursor);
-
- // Look up the shift keys.
- shiftKeycode = XKeysymToKeycode(dpy, XK_Shift_L);
- if (shiftKeycode == NoSymbol)
- shiftKeycode = XKeysymToKeycode(dpy, XK_Shift_R);
- modeSwitchKeycode = XKeysymToKeycode(dpy, XK_Mode_switch);
-
- // Make sure all of the above changes are flushed.
- XFlush(dpy);
-
- // Set up event handling for the display.
- QSocketNotifier *notifier = new QSocketNotifier
- (ConnectionNumber(dpy), QSocketNotifier::Read, this);
- QObject::connect(notifier, SIGNAL(activated(int)), this, SLOT(readyRead()));
-
- // Make sure the file descriptor is not inherited across exec's.
- fcntl(ConnectionNumber(dpy), F_SETFD, 1);
-
- // Notify interested parties that we are now connected to the X display.
- QTimer::singleShot(0, this, SIGNAL(connected()));
-}
-
-void X11KeyFaker::readyRead()
-{
- if (dpy) {
- // Read incoming events and discard them. The only event
- // we care about is keyboard mapping changes. Since we
- // don't have any active windows, there's nothing more to do.
- while (XEventsQueued(dpy, QueuedAfterFlush)) {
- XEvent event;
- XNextEvent(dpy, &event);
- if (event.xany.type == MappingNotify)
- XRefreshKeyboardMapping(&event.xmapping);
- }
- }
-}
-
-QT_END_NAMESPACE
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the tools of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef X11KEYFAKER_H
-#define X11KEYFAKER_H
-
-#include <QObject>
-#include <QX11Info>
-#include <qnamespace.h>
-
-QT_BEGIN_NAMESPACE
-
-class X11KeyFaker : public QObject
-{
- Q_OBJECT
-public:
- X11KeyFaker(const QString& displayName, QObject *parent = 0);
- ~X11KeyFaker();
-
- bool isConnected() const { return dpy != 0; }
-
- void sendKeyEvent(int qtCode, bool isPress);
-
-private slots:
- void connect();
- void readyRead();
-
-signals:
- void connected();
- void couldNotConnect();
-
-private:
- QString displayName;
- Display *dpy;
- int retryCount;
- int shiftKeycode;
- int modeSwitchKeycode;
- int modifiers;
-};
-
-QT_END_NAMESPACE
-
-#endif