Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e467e60bd7 | |||
| 78b56ec751 | |||
| dc96e6f6d8 | |||
| de8eceae1b | |||
| b45ed50368 | |||
| 9d756d716c | |||
| 3e38fc464a | |||
| 6b2b9dee08 | |||
| bbcd213258 | |||
| cce010828c | |||
| 2ad40d2507 | |||
| dac561fdad | |||
| 82e4a20b80 | |||
| 527033561e | |||
| 66570f00c1 | |||
| 8b5ff178eb | |||
| aab969817e | |||
| 716c35655a | |||
| f856d58660 | |||
| a69001b273 | |||
| f7dbf18fb3 | |||
| df16dfcc47 | |||
| 000135760b | |||
| d3e38888b2 | |||
| 35ca5d04d5 | |||
| f4a53541b0 | |||
| 6311433f85 | |||
| bf922904bc | |||
| b351e239e1 | |||
| d32d6ab1e6 | |||
| 06b2f841dc | |||
| b55b148cca | |||
| 086181cd8f | |||
| 51402c10d6 | |||
| c298a43b2f | |||
| 577280f001 | |||
| be3a94cf74 | |||
| 9537ece5fd | |||
| 704cfe0831 | |||
| 72c3e11909 | |||
| 9f94e61ad6 | |||
| ce0b6d2ee4 | |||
| a455e2e8ca | |||
| 0e045cbf01 | |||
| ecdd91d206 |
@@ -0,0 +1 @@
|
||||
/build/
|
||||
+12
-7
@@ -18,20 +18,25 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
PROJECT( qlscribe )
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.21)
|
||||
PROJECT(qlscribe VERSION 0.18 LANGUAGES CXX)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
|
||||
SET(CMAKE_CXX_STANDARD 17)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
SET(CMAKE_AUTOUIC ON)
|
||||
SET(CMAKE_AUTORCC ON)
|
||||
|
||||
SET( FINAL_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Final install path")
|
||||
SET( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )
|
||||
|
||||
SET( QLSCRIBE_DBUS_SERVICE org.lightscribe )
|
||||
SET( QLSCRIBE_DBUS_MANAGER_SERVICE ${QLSCRIBE_DBUS_SERVICE}.Manager )
|
||||
SET( QLSCRIBE_DBUS_MANAGER_SERVICE ${QLSCRIBE_DBUS_SERVICE}.printManager )
|
||||
SET( QLSCRIBE_DBUS_DRIVES_SERVICE ${QLSCRIBE_DBUS_SERVICE}.drives )
|
||||
SET( QLSCRIBE_DBUS_PATH /org/lightscribe )
|
||||
SET( QLSCRIBE_DBUS_MANAGER_PATH ${QLSCRIBE_DBUS_PATH}/Manager ) # path to manager
|
||||
SET( QLSCRIBE_DBUS_MANAGER_PATH ${QLSCRIBE_DBUS_PATH}/printManager ) # path to manager
|
||||
SET( QLSCRIBE_DBUS_DRIVES_PATH ${QLSCRIBE_DBUS_PATH}/drives ) # base path under which drives located
|
||||
|
||||
SUBDIRS( src )
|
||||
SUBDIRS( resources )
|
||||
SUBDIRS( lscribed )
|
||||
ADD_SUBDIRECTORY(src)
|
||||
ADD_SUBDIRECTORY(resources)
|
||||
ADD_SUBDIRECTORY(lscribed)
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
* For historical reasons: this is when I imported qlscribe into
|
||||
SourceForge.
|
||||
|
||||
$Revision:$ $Date:$
|
||||
$Revision$ $Date$
|
||||
|
||||
|
||||
@@ -1,6 +1,30 @@
|
||||
Qt lightScribe Installaton instructions
|
||||
=======================================
|
||||
|
||||
To compile qlscribe succesfully you may need additional packages installed.
|
||||
|
||||
So for Ubuntu folowing packages are required:
|
||||
build-essential
|
||||
cmake
|
||||
libqt4-dev
|
||||
libdbus-1-dev
|
||||
|
||||
For 64 bit Ubuntu you need also to install folowing packages:
|
||||
ia32-libs
|
||||
libc6-dev-i386 (maverick only, see notes)
|
||||
g++-multilib
|
||||
|
||||
(Note: this will work for maverick (10.10) version, for lucid and karmic
|
||||
/usr/lib32/libstdc++.so.5 is missing in ia32-libs so you would have to
|
||||
find it see https://bugs.launchpad.net/ubuntu/+source/ia32-libs/+bug/431091 )
|
||||
(Note: On 64 bit if you get "undefined reference std::_Rb_tree_increment..." link error it is
|
||||
possible that link /usr/lib32/libstdc++.so points to /usr/lib32/libstdc++.so.5... change it
|
||||
so it points /usr/lib32/libstdc++.so.6...)
|
||||
|
||||
For 64 bit Ubuntu libdbus-1-dev does not have link for i386 libdbus-1.so you may need to create one manually:
|
||||
sudo ln -s libdbus-1.so.3 /lib/i386-linux-gnu/libdbus-1.so
|
||||
|
||||
|
||||
To compile and install, first download release from http://qlscribe.sourceforge.net/
|
||||
or check out project from subversion repository for particular release:
|
||||
|
||||
@@ -30,7 +54,7 @@ Include files should be in ${LIGHTSCRIBEDIR}/include and lib in ${LIGHTSCRIBEDIR
|
||||
You need manually install dbus config and service files. They are located in INSTALL_PATH/share/qlscribe
|
||||
So on my ubuntu system I do
|
||||
sudo cp /usr/local/share/qlscribe/lightscribe.conf /etc/dbus-1/system.d/
|
||||
sudo cp /usr/local/share/qlscribe/org.lightscribe.Manager.service /usr/share/dbus-1/system-services/
|
||||
sudo cp /usr/local/share/qlscribe/org.lightscribe.printManager.service /usr/share/dbus-1/system-services/
|
||||
sudo /etc/init.d/dbus reload
|
||||
|
||||
Your system may have different path please refer dbus system daemon documentation
|
||||
|
||||
@@ -1,5 +1,46 @@
|
||||
NEWS - list of user-visible changes between releases of qlscribe
|
||||
|
||||
New in 0.18
|
||||
-----------
|
||||
* Fixed the mandatory 32-bit printing daemon build with GCC 15.
|
||||
* Fixed 32-bit D-Bus library detection on multilib Gentoo systems.
|
||||
|
||||
New in 0.17
|
||||
-----------
|
||||
* Ported the application and build system from Qt 4 to Qt 6.
|
||||
* Modernized the CMake build while retaining the required LightScribe daemon.
|
||||
|
||||
New in 0.16
|
||||
Fixed build on 64 bit Ubuntu Saucy
|
||||
Fixed bug with alarm() not found
|
||||
Added instructions for 64 bit
|
||||
|
||||
New in 0.15
|
||||
Added ability to align regular text to left, right or center the same way as rounded text
|
||||
Fixed issue with filters in open dialog
|
||||
Added image preview to Qt open file dialog
|
||||
|
||||
New in 0.14
|
||||
Added Software Render for preview to make preview when no drive is available
|
||||
Items have Z coordinate set to remove ambiguity
|
||||
Saves from previous versions will have Z coordinate of items reordered on load
|
||||
|
||||
New in 0.13:
|
||||
Fixes in dbus config for Ubuntu Jaunty
|
||||
|
||||
New in 0.12:
|
||||
Fixed bug for round text not updating last used font
|
||||
Main window stores/restores position and size from/to config
|
||||
Round text changes radius and angle when dragged by mouse instead of moving the center
|
||||
Added ability to open image as a document
|
||||
Bugfix for labels opened from commandline not updating menu
|
||||
Bugfix for not properly drawing partially covered window background
|
||||
|
||||
New in 0.11:
|
||||
Application settings added with default font to use and option to eject media
|
||||
Added functionality to eject media after print
|
||||
Debian packages use standard procedure to install/upgrade config files
|
||||
|
||||
New in 0.10:
|
||||
Undo/Redo mechanism implemented
|
||||
Some minor bugfixes
|
||||
@@ -55,4 +96,3 @@ New in 0.2:
|
||||
New in 0.1:
|
||||
Open/save as implemented. Text, round text and image items can be inserted and edited
|
||||
Print preview and print is working (no exclusive lock or tray lock on printing yet)
|
||||
|
||||
|
||||
+11
-4
@@ -22,9 +22,16 @@ FIND_PATH( DBUS_INCLUDE_DIR dbus/dbus.h
|
||||
PATH_SUFFIXES dbus-1.0 )
|
||||
|
||||
IF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
|
||||
FIND_LIBRARY( DBUS_LIBRARY dbus-1
|
||||
PATHS /lib32 /usr/lib32 /usr/local/lib32
|
||||
NO_DEFAULT_PATH )
|
||||
# Gentoo's 32-bit ABI lives in /usr/lib. find_library() rewrites
|
||||
# that path to lib64 for a 64-bit CMake process, so select the
|
||||
# existing multilib file explicitly.
|
||||
IF(EXISTS "/usr/lib/libdbus-1.so")
|
||||
SET(DBUS_LIBRARY "/usr/lib/libdbus-1.so" CACHE FILEPATH
|
||||
"32-bit D-Bus library" FORCE)
|
||||
ELSEIF(EXISTS "/usr/lib32/libdbus-1.so")
|
||||
SET(DBUS_LIBRARY "/usr/lib32/libdbus-1.so" CACHE FILEPATH
|
||||
"32-bit D-Bus library" FORCE)
|
||||
ENDIF()
|
||||
ENDIF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
|
||||
|
||||
FIND_LIBRARY( DBUS_LIBRARY dbus-1 )
|
||||
@@ -32,7 +39,7 @@ FIND_LIBRARY( DBUS_LIBRARY dbus-1 )
|
||||
get_filename_component( _dbusLibPath ${DBUS_LIBRARY} PATH )
|
||||
|
||||
FIND_PATH( DBUS_LIBINCLUDE_DIR dbus/dbus-arch-deps.h
|
||||
PATHS /lib /usr/lib /usr/local/lib ${_dbusLibPath}
|
||||
PATHS /lib /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu ${_dbusLibPath}
|
||||
PATH_SUFFIXES dbus-1.0/include )
|
||||
|
||||
if( DBUS_INCLUDE_DIR AND DBUS_LIBINCLUDE_DIR AND DBUS_LIBRARY )
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
FIND_PATH( LSCRIBE_INCLUDE_DIR lightscribe.h /usr/local/include /usr/include/lightsribe $ENV{LIGHTSCRIBEDIR}/include )
|
||||
FIND_PATH( LSCRIBE_INCLUDE_DIR lightscribe.h /usr/local/include /usr/include/lightscribe $ENV{LIGHTSCRIBEDIR}/include )
|
||||
|
||||
FIND_LIBRARY( LSCRIBE_LIBRARY lightscribe /usr/local/lib /opt/lightscribe/lib /opt/lightscribe/lib32 $ENV{LIGHTSCRIBEDIR}/lib )
|
||||
|
||||
|
||||
Vendored
+7
-1
@@ -1,4 +1,10 @@
|
||||
qlscribe (0.10-0ubuntu1) unstable; urgency=low
|
||||
qlscribe (0.15-0lenny1) unstable; urgency=low
|
||||
* Release 0.16 imported
|
||||
* Release 0.15 imported
|
||||
* Release 0.14 imported
|
||||
* Release 0.13 imported
|
||||
* Release 0.12 imported
|
||||
* Release 0.11 imported
|
||||
* Release 0.10 imported
|
||||
* Release 0.9 imported
|
||||
* Release 0.8 imported
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
/usr/share/dbus-1/system-services/org.lightscribe.printManager.service
|
||||
Vendored
+2
-2
@@ -2,12 +2,12 @@ Source: qlscribe
|
||||
Section: qt
|
||||
Priority: optional
|
||||
Maintainer: Vyacheslav Kononenko <vyacheslav@kononenko.net>
|
||||
Build-Depends: debhelper (>= 7)
|
||||
Build-Depends: debhelper (>= 7), cmake, qt4-qmake, libqt4-dev, libdbus-1-dev, lightscribepublicsdk, lightscribe
|
||||
Standards-Version: 3.7.3
|
||||
Homepage: http://qlscribe.sourceforge.net/
|
||||
|
||||
Package: qlscribe
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, lightscribe
|
||||
Depends: ${shlibs:Depends}
|
||||
Description: Qt based application to print lightScribe discs
|
||||
Qt lightScribe is a GUI application to burn labels on lightScribe capable drives.
|
||||
|
||||
Vendored
+2
-2
@@ -9,7 +9,7 @@ Upstream Author(s):
|
||||
|
||||
Copyright:
|
||||
|
||||
<Copyright (C) 2009 Vyacheslav Kononenko>
|
||||
<Copyright (C) 2009-2010 Vyacheslav Kononenko>
|
||||
|
||||
License:
|
||||
|
||||
@@ -30,7 +30,7 @@ License:
|
||||
On Debian systems, the complete text of the GNU General
|
||||
Public License can be found in `/usr/share/common-licenses/GPL'.
|
||||
|
||||
The Debian packaging is (C) 2009, Vyacheslav Kononenko <vyacheslav@kononenko.net> and
|
||||
The Debian packaging is (C) 2009-2010, Vyacheslav Kononenko <vyacheslav@kononenko.net> and
|
||||
is licensed under the GPL, see above.
|
||||
|
||||
|
||||
|
||||
Vendored
+1
-3
@@ -2,9 +2,7 @@
|
||||
set -e
|
||||
|
||||
if [ "$1" = "configure" ] ; then
|
||||
cp -f /usr/share/qlscribe/lightscribe.conf /etc/dbus-1/system.d/
|
||||
cp -f /usr/share/qlscribe/org.lightscribe.Manager.service /usr/share/dbus-1/system-services/
|
||||
/etc/init.d/dbus reload
|
||||
invoke-rc.d dbus reload
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
Vendored
+2
-5
@@ -2,16 +2,13 @@
|
||||
set -e
|
||||
|
||||
if [ "$1" = "remove" -o "$1" = "upgrade" ] ; then
|
||||
PID=`pidof lscribed`
|
||||
if [ "X$PID" != "X" ] ; then
|
||||
if PID=`pidof lscribed` ; then
|
||||
kill $PID
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "remove" ] ; then
|
||||
rm -f /etc/dbus-1/system.d/lightscribe.conf
|
||||
rm -f /usr/share/dbus-1/system-services/org.lightscribe.Manager.service
|
||||
/etc/init.d/dbus reload
|
||||
invoke-rc.d dbus reload
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
Vendored
+3
-3
@@ -15,9 +15,9 @@ configure-stamp:
|
||||
# Add here commands to configure the package.
|
||||
mkdir -p build
|
||||
cd build; cmake .. -DCMAKE_INSTALL_PREFIX=$(CURDIR)/debian/qlscribe/usr \
|
||||
-DFINAL_INSTALL_PREFIX=/usr
|
||||
touch configure-stamp
|
||||
|
||||
-DFINAL_INSTALL_PREFIX=/usr \
|
||||
-DDBUS_SYSTEM_POLICY_DIR=$(CURDIR)/debian/qlscribe/etc/dbus-1/system.d \
|
||||
-DDBUS_SYSTEM_SERVICE_DIR=$(CURDIR)/debian/qlscribe/usr/share/dbus-1/system-services
|
||||
|
||||
build: build-stamp
|
||||
|
||||
|
||||
+14
-5
@@ -22,7 +22,7 @@ FIND_PACKAGE( Dbus32 REQUIRED )
|
||||
FIND_PACKAGE( LightScribe REQUIRED )
|
||||
|
||||
SET( LSCRIBED_CONF_FILE ${CMAKE_CURRENT_BINARY_DIR}/lightscribe.conf )
|
||||
SET( LSCRIBED_SERVICE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${QLSCRIBE_DBUS_SERVICE}.Manager.service )
|
||||
SET( LSCRIBED_SERVICE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${QLSCRIBE_DBUS_SERVICE}.printManager.service )
|
||||
|
||||
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/lscribed.h.in ${CMAKE_CURRENT_BINARY_DIR}/lscribed.h @ONLY )
|
||||
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/lightscribe.conf.in ${LSCRIBED_CONF_FILE} @ONLY )
|
||||
@@ -36,11 +36,21 @@ ENDIF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_COMPILER_IS_GNUCXX )
|
||||
|
||||
IF (DBUS_SYSTEM_POLICY_DIR)
|
||||
INSTALL( FILES ${LSCRIBED_CONF_FILE} DESTINATION ${DBUS_SYSTEM_POLICY_DIR})
|
||||
endif (DBUS_SYSTEM_POLICY_DIR)
|
||||
ELSE (DBUS_SYSTEM_POLICY_DIR)
|
||||
MESSAGE(STATUS "It is necessary to specify the directory where the client policy file for Qt Lightscribe is installed as DBUS_SYSTEM_POLICY_DIR.")
|
||||
MESSAGE(STATUS "Otherwise it will be installed into share/qlscribe")
|
||||
MESSAGE(STATUS "Normally this is /etc/dbus-1/system.d on a Linux system")
|
||||
INSTALL( FILES ${LSCRIBED_CONF_FILE} DESTINATION share/qlscribe )
|
||||
ENDIF (DBUS_SYSTEM_POLICY_DIR)
|
||||
|
||||
IF (DBUS_SYSTEM_SERVICE_DIR)
|
||||
INSTALL( FILES ${LSCRIBED_SERVICE_FILE} DESTINATION ${DBUS_SYSTEM_SERVICE_DIR})
|
||||
endif (DBUS_SYSTEM_SERVICE_DIR)
|
||||
ELSE (DBUS_SYSTEM_SERVICE_DIR)
|
||||
MESSAGE(STATUS "It is necessary to specify the directory where the client service file for Qt Lightscribe is installed as DBUS_SYSTEM_SERVICE_DIR.")
|
||||
MESSAGE(STATUS "Otherwise it will be installed into share/qlscribe")
|
||||
MESSAGE(STATUS "Normally this is /usr/share/dbus-1/services on a Linux system")
|
||||
INSTALL( FILES ${LSCRIBED_SERVICE_FILE} DESTINATION share/qlscribe )
|
||||
ENDIF (DBUS_SYSTEM_SERVICE_DIR)
|
||||
|
||||
SET( LSCRIBED_SRCS main.cpp dbuscpp.cpp drives.cpp managerhandler.cpp drivehandler.cpp
|
||||
introspecthandler.cpp )
|
||||
@@ -50,9 +60,8 @@ ADD_DEFINITIONS( -Wall )
|
||||
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} )
|
||||
|
||||
ADD_EXECUTABLE( lscribed ${LSCRIBED_SRCS} )
|
||||
SET_TARGET_PROPERTIES(lscribed PROPERTIES AUTOMOC OFF AUTOUIC OFF AUTORCC OFF)
|
||||
|
||||
TARGET_LINK_LIBRARIES( lscribed ${LSCRIBE_LIBRARIES} ${DBUS_LIBRARIES} pthread )
|
||||
|
||||
INSTALL( TARGETS lscribed DESTINATION sbin )
|
||||
INSTALL( FILES ${LSCRIBED_CONF_FILE} ${LSCRIBED_SERVICE_FILE} DESTINATION share/qlscribe )
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "dbuscpp.h"
|
||||
#include "lscribed.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
using namespace DBusCpp;
|
||||
|
||||
MessageHandler::~MessageHandler()
|
||||
@@ -216,4 +218,3 @@ const char *Message::member() const
|
||||
{
|
||||
return dbus_message_get_member( m_message );
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define DBUSCPP_H
|
||||
|
||||
#include <dbus/dbus.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
|
||||
@@ -46,12 +46,12 @@ static const char *strDriveIntrospect =
|
||||
</signal>\
|
||||
<method name=\"preview\">\
|
||||
<arg type=\"s\" direction=\"out\"/>\
|
||||
<arg name=\"params\" type=\"(iiii)\" direction=\"in\"/>\
|
||||
<arg name=\"params\" type=\"(iiiii)\" direction=\"in\"/>\
|
||||
<arg name=\"image\" type=\"ay\" direction=\"in\"/>\
|
||||
<arg name=\"previewSize\" type=\"(ii)\" direction=\"in\"/>\
|
||||
</method>\
|
||||
<method name=\"print\">\
|
||||
<arg name=\"params\" type=\"(iiii)\" direction=\"in\"/>\
|
||||
<arg name=\"params\" type=\"(iiiii)\" direction=\"in\"/>\
|
||||
<arg name=\"image\" type=\"ay\" direction=\"in\"/>\
|
||||
</method>\
|
||||
<method name=\"abort\">\
|
||||
|
||||
+55
-40
@@ -24,10 +24,12 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <syslog.h>
|
||||
#include <lightscribe_cxx.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace LightScribe;
|
||||
|
||||
static pthread_key_t drivesKey;
|
||||
@@ -197,6 +199,7 @@ void Drive::routine()
|
||||
LS_DrawOptions options;
|
||||
LS_PrintQuality quality;
|
||||
LS_MediaOptimizationLevel level;
|
||||
bool eject= false;
|
||||
|
||||
char *image = 0;
|
||||
int imageSize = 0;
|
||||
@@ -205,15 +208,16 @@ void Drive::routine()
|
||||
|
||||
try {
|
||||
DBusCpp::MessageConstIter iter = m_message->constIter();
|
||||
if( iter.signature() != "(iiii)" )
|
||||
throw std::string( "invalid argument for params: " ) + iter.signature() + ", (iiii) expected";
|
||||
if( iter.signature() != "(iiiii)" )
|
||||
throw std::string( "invalid argument for params: " ) + iter.signature() + ", (iiiii) expected";
|
||||
|
||||
DBusCpp::MessageConstIter sub = iter.recurse();
|
||||
|
||||
mode = LS_LabelMode( sub.getValue<int32_t>() ); sub.next();
|
||||
options = LS_DrawOptions( sub.getValue<int32_t>() ); sub.next();
|
||||
quality = LS_PrintQuality( sub.getValue<int32_t>() ); sub.next();
|
||||
level = LS_MediaOptimizationLevel( sub.getValue<int32_t>() );
|
||||
level = LS_MediaOptimizationLevel( sub.getValue<int32_t>() ); sub.next();
|
||||
eject = sub.getValue<int32_t>();
|
||||
|
||||
if( !iter.next() )
|
||||
throw std::string( "image argument missing" );
|
||||
@@ -240,6 +244,7 @@ void Drive::routine()
|
||||
std::cout << "exception " << str << std::endl;
|
||||
DBusCpp::Message reply = m_message->newError( DBUS_ERROR_INVALID_ARGS, str.c_str() );
|
||||
man.connection().send( reply );
|
||||
syslog( LOG_ERR, "error in parsing request: %s", str.c_str() );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -273,20 +278,54 @@ void Drive::routine()
|
||||
|
||||
function = "LS_DiscPrintMgr_EnumDiscPrinters";
|
||||
EnumDiscPrinters printers = manager.EnumDiscPrinters();
|
||||
if( m_index >= printers.Count() )
|
||||
if( m_index >= int( printers.Count() ) )
|
||||
throw std::string( "internal error: invalid index" );
|
||||
|
||||
DiscPrinter printer = printers.Item( m_index );
|
||||
|
||||
function = "LS_DiscPrinter_OpenPrintSession";
|
||||
DiscPrintSession session = printer.OpenPrintSession();
|
||||
{
|
||||
function = "LS_DiscPrinter_OpenPrintSession";
|
||||
DiscPrintSession session = printer.OpenPrintSession();
|
||||
|
||||
DBusCpp::Message reply = m_message->newMethodReturn();
|
||||
DBusCpp::Message reply = m_message->newMethodReturn();
|
||||
|
||||
if( preview ) {
|
||||
if( preview ) {
|
||||
|
||||
function = "LS_DiscPrintSession_PrintPreview";
|
||||
session.PrintPreview( LS_windows_bitmap,
|
||||
syslog( LOG_INFO, "generating preview into temp file %s", tmpFile.c_str() );
|
||||
function = "LS_DiscPrintSession_PrintPreview";
|
||||
session.PrintPreview( LS_windows_bitmap,
|
||||
mode,
|
||||
options,
|
||||
quality,
|
||||
level,
|
||||
image + 14,
|
||||
bitmapHeaderSize - 14,
|
||||
image + bitmapHeaderSize,
|
||||
imageSize - bitmapHeaderSize,
|
||||
const_cast< char *>( tmpFile.c_str() ),
|
||||
LS_windows_bitmap,
|
||||
size,
|
||||
true );
|
||||
reply.append( tmpFile );
|
||||
man.connection().send( reply );
|
||||
|
||||
} else {
|
||||
|
||||
syslog( LOG_INFO, "printing label with parameters: mode %d, options %d, quality %d, level %d, eject %d",
|
||||
mode, options, quality, level, eject );
|
||||
|
||||
LS_PrintCallbacks callbacks;
|
||||
callbacks.AbortLabel = clAbortLabel;
|
||||
callbacks.ReportPrepareProgress = clReportPrepareProgress;
|
||||
callbacks.ReportLabelProgress = clReportLabelProgress;
|
||||
callbacks.ReportFinished = clReportFinished;
|
||||
callbacks.ReportLabelTimeEstimate = clReportLabelTimeEstimate;
|
||||
session.SetProgressCallback( &callbacks );
|
||||
|
||||
man.connection().send( reply );
|
||||
|
||||
function = 0;
|
||||
session.PrintDisc( LS_windows_bitmap,
|
||||
mode,
|
||||
options,
|
||||
quality,
|
||||
@@ -294,37 +333,11 @@ void Drive::routine()
|
||||
image + 14,
|
||||
bitmapHeaderSize - 14,
|
||||
image + bitmapHeaderSize,
|
||||
imageSize - bitmapHeaderSize,
|
||||
const_cast< char *>( tmpFile.c_str() ),
|
||||
LS_windows_bitmap,
|
||||
size,
|
||||
true );
|
||||
reply.append( tmpFile );
|
||||
man.connection().send( reply );
|
||||
|
||||
} else {
|
||||
|
||||
LS_PrintCallbacks callbacks;
|
||||
callbacks.AbortLabel = clAbortLabel;
|
||||
callbacks.ReportPrepareProgress = clReportPrepareProgress;
|
||||
callbacks.ReportLabelProgress = clReportLabelProgress;
|
||||
callbacks.ReportFinished = clReportFinished;
|
||||
callbacks.ReportLabelTimeEstimate = clReportLabelTimeEstimate;
|
||||
session.SetProgressCallback( &callbacks );
|
||||
|
||||
man.connection().send( reply );
|
||||
|
||||
function = 0;
|
||||
session.PrintDisc( LS_windows_bitmap,
|
||||
mode,
|
||||
options,
|
||||
quality,
|
||||
level,
|
||||
image + 14,
|
||||
bitmapHeaderSize - 14,
|
||||
image + bitmapHeaderSize,
|
||||
imageSize - bitmapHeaderSize );
|
||||
imageSize - bitmapHeaderSize );
|
||||
}
|
||||
}
|
||||
if( !preview && eject )
|
||||
printer.OpenDriveTray();
|
||||
}
|
||||
catch( LightScribe::LSException &ex ) {
|
||||
if( function ) {
|
||||
@@ -332,6 +345,7 @@ void Drive::routine()
|
||||
sprintf( message, "\"%s()\" failed with code 0x%X", function, ex.GetCode() );
|
||||
DBusCpp::Message reply = m_message->newError( DBUS_ERROR_FAILED, message );
|
||||
man.connection().send( reply );
|
||||
syslog( LOG_ERR, "%s", message );
|
||||
} else
|
||||
clReportFinished( ex.GetCode() );
|
||||
continue;
|
||||
@@ -339,6 +353,7 @@ void Drive::routine()
|
||||
catch( const std::string &str ) {
|
||||
DBusCpp::Message reply = m_message->newError( DBUS_ERROR_FAILED, str.c_str() );
|
||||
man.connection().send( reply );
|
||||
syslog( LOG_ERR, "operation failed: \"%s\"", str.c_str() );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ DBusHandlerResult IntrospectHandler::processMessage( const Message &msg )
|
||||
std::string( DBusManagerPath + pathlen, sublen )
|
||||
+ "\"/>";
|
||||
} else
|
||||
introspect += "<node name=\"Manager\"/><node name=\"drives\"/>";
|
||||
introspect += "<node name=\"printManager\"/><node name=\"drives\"/>";
|
||||
}
|
||||
introspect += "</node>";
|
||||
|
||||
|
||||
@@ -7,15 +7,12 @@
|
||||
<!-- Only root can own the service -->
|
||||
<policy user="root">
|
||||
<allow own="@QLSCRIBE_DBUS_MANAGER_SERVICE@"/>
|
||||
<allow send_interface="@QLSCRIBE_DBUS_MANAGER_SERVICE@"/>
|
||||
<allow send_interface="@QLSCRIBE_DBUS_DRIVES_SERVICE@"/>
|
||||
</policy>
|
||||
|
||||
<!-- Allow anyone to invoke methods on the interfaces -->
|
||||
<policy context="default">
|
||||
<allow send_interface="@QLSCRIBE_DBUS_MANAGER_SERVICE@"/>
|
||||
<allow send_interface="@QLSCRIBE_DBUS_DRIVES_SERVICE@"/>
|
||||
<allow receive_interface="@QLSCRIBE_DBUS_DRIVES_SERVICE@"/>
|
||||
<allow send_destination="@QLSCRIBE_DBUS_MANAGER_SERVICE@"/>
|
||||
<allow send_destination="@QLSCRIBE_DBUS_DRIVES_SERVICE@"/>
|
||||
</policy>
|
||||
|
||||
</busconfig>
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lscribed.h"
|
||||
#include "dbuscpp.h"
|
||||
@@ -52,6 +54,7 @@ void onAlarm( int )
|
||||
lastActivity = curr;
|
||||
return;
|
||||
}
|
||||
syslog( LOG_INFO, "terminating due to inactivity timeout" );
|
||||
terminateOnTimeout = true;
|
||||
}
|
||||
|
||||
@@ -65,6 +68,7 @@ void usage()
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
openlog( "lscribed", LOG_PID, LOG_DAEMON );
|
||||
for( int i = 1; i < argc; ++i ) {
|
||||
if( strcmp( argv[i], "--help" ) == 0 ) {
|
||||
usage();
|
||||
@@ -102,11 +106,13 @@ int main( int argc, char **argv )
|
||||
int ret = dbus_bus_request_name( conn.ptr(), DBusServiceName, DBUS_NAME_FLAG_REPLACE_EXISTING, &err );
|
||||
if( dbus_error_is_set( &err ) ) {
|
||||
std::cerr << "dbus_bus_request_name error: " << err.message << std::endl;
|
||||
syslog( LOG_ERR, "dbus_bus_request_name error: %s", err.message );
|
||||
dbus_error_free( &err );
|
||||
return 2;
|
||||
}
|
||||
if( ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER ) {
|
||||
std::cerr << "could not get ownership of \"" << DBusServiceName << "\" terminating" << std::endl;
|
||||
syslog( LOG_ERR, "could not get ownership of \"%s\" terminating", DBusServiceName );
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
+9
-40
@@ -18,61 +18,30 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
FIND_PACKAGE( Qt4 REQUIRED )
|
||||
SET( QT_USE_QTDBUS 1 )
|
||||
FIND_PACKAGE(Qt6 6.5 REQUIRED COMPONENTS Core Gui Widgets DBus)
|
||||
|
||||
SET( QLSCRIBE_SRCS main.cpp mainwindow.cpp qcdscene.cpp qcdview.cpp
|
||||
qdialogpixmap.cpp qdialogroundtext.cpp qdialogtext.cpp qlightroundtextitem.cpp
|
||||
qlightscribe.cpp qshapefactory.cpp qlighttextitem.cpp qlightpixmapitem.cpp
|
||||
qdialogprint.cpp qdialogprogress.cpp qdialogcdproperties.cpp qconsoleprintprogress.cpp)
|
||||
qdialogprint.cpp qdialogprogress.cpp qdialogcdproperties.cpp qconsoleprintprogress.cpp
|
||||
qdialogsettings.cpp previewinjector.cpp )
|
||||
|
||||
SET( QLSCRIBE_UIS qdialogtext.ui qdialogroundtext.ui qdialogpixmap.ui
|
||||
qdialogprint.ui qdialogprogress.ui qdialogcdproperties.ui)
|
||||
|
||||
SET( QLSCRIBE_MOC_HDRS mainwindow.h qcdscene.h qdialogpixmap.h qdialogroundtext.h
|
||||
qdialogtext.h qlightscribe.h qdialogprint.h qdialogprogress.h
|
||||
qdialogcdproperties.h qconsoleprintprogress.h)
|
||||
qdialogprint.ui qdialogprogress.ui qdialogcdproperties.ui qdialogsettings.ui )
|
||||
|
||||
ADD_DEFINITIONS( -Wall )
|
||||
|
||||
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/qlscribe.h.in ${CMAKE_CURRENT_BINARY_DIR}/qlscribe.h @ONLY )
|
||||
|
||||
INCLUDE( ${QT_USE_FILE} )
|
||||
|
||||
QT4_WRAP_UI( QLSCRIBE_UI_HDRS ${QLSCRIBE_UIS} )
|
||||
|
||||
QT4_WRAP_CPP( QLSCRIBE_MOC_SRCS ${QLSCRIBE_MOC_HDRS} )
|
||||
|
||||
QT4_ADD_RESOURCES( QLSCRIBE_RCC_SRCS ../resources/qlscribe.qrc )
|
||||
|
||||
MACRO(ADD_DBUS_INTERFACE _sources _interface _basename)
|
||||
GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
|
||||
SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
|
||||
SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
|
||||
SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
|
||||
|
||||
ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
|
||||
COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -i qlightscribe.h -p ${_basename} ${_infile}
|
||||
DEPENDS ${_infile})
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
|
||||
|
||||
QT4_GENERATE_MOC(${_header} ${_moc})
|
||||
|
||||
SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
|
||||
MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
|
||||
ENDMACRO(ADD_DBUS_INTERFACE)
|
||||
|
||||
ADD_DBUS_INTERFACE( QLSCRIBE_DBUS_SRCS lightscribe.xml lightscribe_interface )
|
||||
SET_SOURCE_FILES_PROPERTIES(lightscribe.xml PROPERTIES INCLUDE qlightscribe.h)
|
||||
QT6_ADD_DBUS_INTERFACE(QLSCRIBE_DBUS_SRCS lightscribe.xml lightscribe_interface)
|
||||
|
||||
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
|
||||
ADD_EXECUTABLE( qlscribe ${QLSCRIBE_SRCS} ${QLSCRIBE_MOC_SRCS}
|
||||
${QLSCRIBE_RCC_SRCS} ${QLSCRIBE_UI_HDRS}
|
||||
${QLSCRIBE_DBUS_SRCS} )
|
||||
ADD_EXECUTABLE(qlscribe ${QLSCRIBE_SRCS} ${QLSCRIBE_UIS}
|
||||
${QLSCRIBE_DBUS_SRCS} ../resources/qlscribe.qrc)
|
||||
|
||||
TARGET_LINK_LIBRARIES( qlscribe ${QT_LIBRARIES} )
|
||||
TARGET_LINK_LIBRARIES(qlscribe PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets Qt6::DBus)
|
||||
|
||||
INSTALL( TARGETS qlscribe
|
||||
DESTINATION bin )
|
||||
|
||||
|
||||
+6
-6
@@ -24,7 +24,7 @@
|
||||
<node>
|
||||
<interface name="org.lightscribe.printManager">
|
||||
<method name="getDrives">
|
||||
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QObject2StringMap"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QObject2StringMap"/>
|
||||
<arg type="a{ss}" direction="out"/>
|
||||
</method>
|
||||
</interface>
|
||||
@@ -44,16 +44,16 @@
|
||||
<arg name="status" type="i" direction="out"/>
|
||||
</signal>
|
||||
<method name="preview">
|
||||
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="const PrintParameters &"/>
|
||||
<annotation name="com.trolltech.QtDBus.QtTypeName.In2" value="QSize"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="const PrintParameters &"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In2" value="QSize"/>
|
||||
<arg type="s" direction="out"/>
|
||||
<arg name="params" type="(iiii)" direction="in"/>
|
||||
<arg name="params" type="(iiiii)" direction="in"/>
|
||||
<arg name="image" type="ay" direction="in"/>
|
||||
<arg name="previewSize" type="(ii)" direction="in"/>
|
||||
</method>
|
||||
<method name="print">
|
||||
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="const PrintParameters &"/>
|
||||
<arg name="params" type="(iiii)" direction="in"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="const PrintParameters &"/>
|
||||
<arg name="params" type="(iiiii)" direction="in"/>
|
||||
<arg name="image" type="ay" direction="in"/>
|
||||
</method>
|
||||
<method name="abort">
|
||||
|
||||
+4
-1
@@ -34,7 +34,7 @@
|
||||
|
||||
std::ostream &operator<<( std::ostream &os, const QString &str )
|
||||
{
|
||||
return os << str.toAscii().data();
|
||||
return os << str.toUtf8().constData();
|
||||
}
|
||||
|
||||
void usage()
|
||||
@@ -56,6 +56,9 @@ void usage()
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
app.setApplicationName( "qlscribe" );
|
||||
//app.setOrganizationName( "" );
|
||||
app.setOrganizationDomain( "qlscribe.sourceforge.org" );
|
||||
app.addLibraryPath( "/usr/lib32/qt4/plugins" );
|
||||
app.setWindowIcon( QIcon( ":/qlscribe64.png" ) );
|
||||
|
||||
|
||||
+147
-23
@@ -27,6 +27,8 @@
|
||||
#include "qdialogprint.h"
|
||||
#include "qdialogprogress.h"
|
||||
#include "qdialogcdproperties.h"
|
||||
#include "qdialogsettings.h"
|
||||
#include "previewinjector.h"
|
||||
|
||||
#include <QMenuBar>
|
||||
#include <QStatusBar>
|
||||
@@ -39,6 +41,10 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QMimeData>
|
||||
#include <QSettings>
|
||||
#include <QImageReader>
|
||||
#include <QPicture>
|
||||
|
||||
|
||||
MainWindow::MainWindow( bool enablePrint )
|
||||
@@ -70,11 +76,13 @@ MainWindow::MainWindow( bool enablePrint )
|
||||
SLOT(map()) );
|
||||
m_newLabelMapper->setMapping( action, modeTitle );
|
||||
}
|
||||
connect( m_newLabelMapper, SIGNAL(mapped(int)), this, SLOT(onMenuNewLabel(int)) );
|
||||
connect(m_newLabelMapper, &QSignalMapper::mappedInt,
|
||||
this, &MainWindow::onMenuNewLabel);
|
||||
|
||||
m_menuFile->addAction( tr( "Open...", "Menu item \"Open\"" ),
|
||||
this,
|
||||
SLOT(onMenuOpen()) );
|
||||
SLOT(onMenuOpen()),
|
||||
QKeySequence( Qt::CTRL + Qt::Key_O ) );
|
||||
|
||||
m_actionSave = m_menuFile->addAction( tr( "Save", "Menu item \"Save\"" ),
|
||||
this,
|
||||
@@ -107,7 +115,7 @@ MainWindow::MainWindow( bool enablePrint )
|
||||
m_menuFile->addAction( tr( "Exit", "Menu item \"Exit\"" ),
|
||||
this,
|
||||
SLOT(close()),
|
||||
QKeySequence( Qt::CTRL + Qt::Key_X ) );
|
||||
QKeySequence( Qt::CTRL + Qt::Key_Q ) );
|
||||
|
||||
|
||||
m_menuEdit = menuBar()->addMenu( tr( "Edit", "Menu item \"Edit\"" ) );
|
||||
@@ -139,6 +147,12 @@ MainWindow::MainWindow( bool enablePrint )
|
||||
|
||||
m_menuInsert = m_menuEdit->addMenu( tr( "Insert", "Menu item \"Insert\"" ) );
|
||||
|
||||
m_menuEdit->addSeparator();
|
||||
|
||||
m_actionSettings = m_menuEdit->addAction( tr( "Settings...", "Menu item \"Settings\"" ),
|
||||
this,
|
||||
SLOT(onMenuSettings()) );
|
||||
|
||||
m_menuHelp = menuBar()->addMenu( tr( "Help", "Menu item \"Help\"" ) );
|
||||
|
||||
m_menuHelp->addAction( tr( "About...", "Menu item \"About\"" ),
|
||||
@@ -157,7 +171,8 @@ MainWindow::MainWindow( bool enablePrint )
|
||||
m_insertMapper->setMapping( action, i->first );
|
||||
connect( action, SIGNAL(triggered()), m_insertMapper, SLOT(map()) );
|
||||
}
|
||||
connect( m_insertMapper, SIGNAL(mapped(int)), this, SLOT(onMenuInsert(int)) );
|
||||
connect(m_insertMapper, &QSignalMapper::mappedInt,
|
||||
this, &MainWindow::onMenuInsert);
|
||||
|
||||
connect( QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)),
|
||||
this, SLOT(updateMenu()) );
|
||||
@@ -165,6 +180,13 @@ MainWindow::MainWindow( bool enablePrint )
|
||||
this, SLOT(updateMenu()) );
|
||||
|
||||
updateMenu();
|
||||
|
||||
QSettings settings;
|
||||
|
||||
settings.beginGroup( "MainWindow");
|
||||
resize( settings.value( "size", QSize(800, 400) ).toSize() );
|
||||
move( settings.value( "pos", QPoint(200, 200) ).toPoint() );
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -182,6 +204,8 @@ void MainWindow::open( const QStringList &files )
|
||||
delete newView;
|
||||
continue;
|
||||
}
|
||||
connect( scene, SIGNAL(selectionChanged()), this, SLOT(updateMenu()) );
|
||||
connect( scene, SIGNAL(changed()), this, SLOT(updateMenu()) );
|
||||
|
||||
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( newView );
|
||||
subWindow->show();
|
||||
@@ -247,6 +271,13 @@ bool MainWindow::saveScene( QCDScene *scene )
|
||||
return;
|
||||
}
|
||||
}
|
||||
QSettings settings;
|
||||
|
||||
settings.beginGroup( "MainWindow" );
|
||||
settings.setValue( "size", size());
|
||||
settings.setValue( "pos", pos());
|
||||
settings.endGroup();
|
||||
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@@ -297,19 +328,29 @@ void MainWindow::onMenuInsert( int id )
|
||||
return;
|
||||
}
|
||||
|
||||
item->setFlag( QGraphicsItem::ItemIsMovable, true );
|
||||
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
|
||||
cdscene->addItem( item );
|
||||
cdscene->addItem( item, true );
|
||||
cdscene->setChanged();
|
||||
}
|
||||
|
||||
void MainWindow::onMenuOpen()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName( this,
|
||||
tr( "Open:" ),
|
||||
QString(),
|
||||
tr("qlscribe document (*.qlx)") );
|
||||
|
||||
QString filter( tr("qlscribe document (*.qlx);;Images ( ") );
|
||||
QList<QByteArray> list = QImageReader::supportedImageFormats();
|
||||
foreach( QByteArray arr, list ) {
|
||||
filter += QString( "*." ) + arr.data() + " ";
|
||||
}
|
||||
filter += tr( ");;All Files (*)" );
|
||||
|
||||
QFileDialog fd( this, "Open:", QString(), filter );
|
||||
|
||||
bool injectPreview = QSettings().value( cfgInjectPreview, true ).toBool();
|
||||
PreviewInjector pj( injectPreview ? &fd : 0 );
|
||||
fd.setFileMode( QFileDialog::ExistingFile );
|
||||
|
||||
if( fd.exec() != QDialog::Accepted )
|
||||
return;
|
||||
|
||||
QString fileName = fd.selectedFiles().value(0);
|
||||
if( fileName.isNull() )
|
||||
return;
|
||||
|
||||
@@ -349,6 +390,24 @@ void MainWindow::onMenuProperties()
|
||||
QDialogCDProperties::exec( this, scene );
|
||||
}
|
||||
|
||||
namespace {
|
||||
const int bigImageSize = 1600;
|
||||
}
|
||||
|
||||
inline
|
||||
void drawCircle( QPainter &painter, double radi )
|
||||
{
|
||||
const int half = bigImageSize / 2;
|
||||
painter.drawEllipse( QRectF( half - radi, half - radi, radi * 2, radi * 2 ) );
|
||||
}
|
||||
|
||||
inline
|
||||
void drawCircle( QPainterPath &path, double radi )
|
||||
{
|
||||
const int half = bigImageSize / 2;
|
||||
path.addEllipse( QRectF( half - radi, half - radi, radi * 2, radi * 2 ) );
|
||||
}
|
||||
|
||||
void MainWindow::onMenuPrintPreview()
|
||||
{
|
||||
QCDScene *cdscene = getScene( m_mdiArea );
|
||||
@@ -357,21 +416,81 @@ void MainWindow::onMenuPrintPreview()
|
||||
|
||||
PrintParameters params;
|
||||
params.m_labelMode = cdscene->labelMode();
|
||||
QLightDrive *drive = QDialogPrint::exec( this, params );
|
||||
if( !drive )
|
||||
QPair< bool, QLightDrive * > bd = QDialogPrint::exec( this, params, true );
|
||||
if( !bd.first )
|
||||
return;
|
||||
|
||||
try {
|
||||
QPixmap pixmap = drive->preview( params, cdscene, QSize( 400, 400 ) );
|
||||
if( !bd.second ) {
|
||||
// software "rendering"
|
||||
QPixmap image( bigImageSize, bigImageSize );
|
||||
image.fill( 0xFFFFFFFF );
|
||||
|
||||
cdscene->clearSelection();
|
||||
{
|
||||
QPainter painter( &image );
|
||||
QColor circleColor( 0xd8, 0xd8, 0xd8 );
|
||||
painter.setPen( circleColor );
|
||||
painter.setBrush( circleColor );
|
||||
drawCircle( painter, bigImageSize / 2 );
|
||||
|
||||
cdscene->render( &painter, image.rect() );
|
||||
|
||||
QPainterPath p1;
|
||||
p1.addRect( image.rect() );
|
||||
{
|
||||
QPainterPath p2;
|
||||
drawCircle( p2, bigImageSize / 2 );
|
||||
painter.setClipPath( p1.subtracted( p2 ) );
|
||||
painter.fillRect( image.rect(), Qt::white );
|
||||
painter.setClipPath( p1 );
|
||||
}
|
||||
|
||||
painter.setBrush( circleColor );
|
||||
|
||||
if( params.m_labelMode == modeTitle ) {
|
||||
// 3.22
|
||||
QPainterPath p2;
|
||||
drawCircle( p2, bigImageSize / 3.20 );
|
||||
painter.setClipPath( p1.subtracted( p2 ) );
|
||||
drawCircle( painter, bigImageSize / 2 );
|
||||
// 3.74
|
||||
painter.setClipPath( p1 );
|
||||
drawCircle( painter, bigImageSize / 3.74 );
|
||||
} else
|
||||
if( params.m_labelMode == modeContent ) {
|
||||
// 3.22
|
||||
QPainterPath p2;
|
||||
drawCircle( p2, bigImageSize / 3.20 );
|
||||
painter.setClipPath( p1.subtracted( p2 ) );
|
||||
drawCircle( painter, bigImageSize / 2 );
|
||||
|
||||
// 4.69
|
||||
painter.setClipPath( p1 );
|
||||
drawCircle( painter, bigImageSize / 4.69 );
|
||||
}
|
||||
|
||||
painter.setBrush( Qt::white );
|
||||
drawCircle( painter, bigImageSize / 4.93 );
|
||||
}
|
||||
QLabel *label = new QLabel;
|
||||
label->setPixmap( pixmap );
|
||||
label->setPixmap( image.scaled( QSize( 400, 400 ) ) );
|
||||
|
||||
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( label );
|
||||
subWindow->setWindowTitle( "Preview: " + cdscene->name() );
|
||||
subWindow->setWindowTitle( "Software preview: " + cdscene->name() );
|
||||
subWindow->show();
|
||||
}
|
||||
catch( const QString &err ) {
|
||||
QMessageBox::critical( this, tr( "Error on print preview" ), err );
|
||||
|
||||
} else {
|
||||
try {
|
||||
QPixmap pixmap = bd.second->preview( params, cdscene, QSize( 400, 400 ) );
|
||||
QLabel *label = new QLabel;
|
||||
label->setPixmap( pixmap );
|
||||
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( label );
|
||||
subWindow->setWindowTitle( "Preview: " + cdscene->name() );
|
||||
subWindow->show();
|
||||
}
|
||||
catch( const QString &err ) {
|
||||
QMessageBox::critical( this, tr( "Error on print preview" ), err );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,8 +498,8 @@ void MainWindow::onMenuPrint()
|
||||
{
|
||||
QCDScene *cdscene = getScene( m_mdiArea );
|
||||
if( !cdscene )
|
||||
|
||||
return;
|
||||
|
||||
try {
|
||||
QDialogProgress::exec( this, cdscene );
|
||||
}
|
||||
@@ -429,7 +548,7 @@ void MainWindow::onMenuAbout()
|
||||
QMessageBox::about( this,
|
||||
tr( "About" ),
|
||||
tr( "<h3>qlscribe - Qt lisghtScribe</h3>"
|
||||
"<p>release 0.10 $Revision$</p>"
|
||||
"<p>release 0.18</p>"
|
||||
"<p>visit project at home page "
|
||||
"<a href=\"http://qlscribe.sourceforge.net/\">qlscribe.sourceforge.net</a></p>" ) );
|
||||
}
|
||||
@@ -439,6 +558,11 @@ void MainWindow::onMenuQtAbout()
|
||||
QMessageBox::aboutQt( this );
|
||||
}
|
||||
|
||||
void MainWindow::onMenuSettings()
|
||||
{
|
||||
QDialogSettings::exec( this );
|
||||
}
|
||||
|
||||
void MainWindow::updateMenu()
|
||||
{
|
||||
QCDScene *scene = getScene( m_mdiArea );
|
||||
|
||||
+3
-1
@@ -21,7 +21,7 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QMainWindow>
|
||||
|
||||
class QMdiArea;
|
||||
class QSignalMapper;
|
||||
@@ -53,6 +53,7 @@ private slots:
|
||||
void onMenuCopy();
|
||||
void onMenuCut();
|
||||
void onMenuPaste();
|
||||
void onMenuSettings();
|
||||
void onMenuInsert( int id );
|
||||
void onMenuAbout();
|
||||
void onMenuQtAbout();
|
||||
@@ -79,6 +80,7 @@ private:
|
||||
QAction *m_actionCopy;
|
||||
QAction *m_actionCut;
|
||||
QAction *m_actionPaste;
|
||||
QAction *m_actionSettings;
|
||||
|
||||
QSignalMapper *m_insertMapper;
|
||||
QSignalMapper *m_newLabelMapper;
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#include "previewinjector.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QLabel>
|
||||
#include <QSplitter>
|
||||
#include <QImageReader>
|
||||
|
||||
PreviewInjector::PreviewInjector( QFileDialog * dl ) :
|
||||
m_label( 0 ),
|
||||
m_size( 160, 120 )
|
||||
{
|
||||
if( !dl )
|
||||
return;
|
||||
|
||||
QSplitter *sp = dl->findChild<QSplitter *>("splitter");
|
||||
if( !sp )
|
||||
return;
|
||||
|
||||
m_label = new QLabel;
|
||||
m_label->resize( m_size );
|
||||
sp->addWidget( m_label );
|
||||
connect( dl, SIGNAL(currentChanged(QString)),SLOT(onSelectionChanged(QString)));
|
||||
}
|
||||
|
||||
PreviewInjector::~PreviewInjector()
|
||||
{
|
||||
delete m_label;
|
||||
}
|
||||
|
||||
void PreviewInjector::onSelectionChanged(QString file)
|
||||
{
|
||||
QImageReader reader( file );
|
||||
|
||||
if( !reader.canRead() ) {
|
||||
m_label->setPixmap( QPixmap() );
|
||||
return;
|
||||
}
|
||||
|
||||
m_label->resize( m_size );
|
||||
QSize toSize = m_size;
|
||||
QSize sz = reader.size();
|
||||
if( !sz.isNull() ) {
|
||||
double r1 = m_label->size().width() / double( sz.width() );
|
||||
double r2 = m_label->size().height() / double( sz.height() );
|
||||
|
||||
double ratio = std::max( r1, r2 );
|
||||
if( ratio < 1.0 ) {
|
||||
toSize.setWidth( sz.width() * ratio );
|
||||
toSize.setHeight( sz.height() * ratio );
|
||||
}
|
||||
}
|
||||
|
||||
reader.setScaledSize( toSize );
|
||||
QImage img = reader.read();
|
||||
if( img.isNull() ) {
|
||||
m_label->setPixmap( QPixmap() );
|
||||
return;
|
||||
}
|
||||
m_label->setPixmap( QPixmap::fromImage( img ) );
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef PREVIEWINJECTOR_HPP
|
||||
#define PREVIEWINJECTOR_HPP
|
||||
|
||||
#include <QObject>
|
||||
#include <QSize>
|
||||
|
||||
class QFileDialog;
|
||||
class QLabel;
|
||||
|
||||
class PreviewInjector : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
PreviewInjector( QFileDialog * dl );
|
||||
~PreviewInjector();
|
||||
|
||||
bool injected() const { return m_label; }
|
||||
|
||||
private slots:
|
||||
void onSelectionChanged(QString );
|
||||
|
||||
private:
|
||||
QLabel *m_label;
|
||||
QSize m_size;
|
||||
};
|
||||
|
||||
#endif // PREVIEWINJECTOR_HPP
|
||||
+85
-33
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "qcdscene.h"
|
||||
#include "qshapefactory.h"
|
||||
#include "qlightpixmapitem.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
@@ -30,10 +31,10 @@
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QMessageBox>
|
||||
#include <QGraphicsView>
|
||||
#include <QRegExp>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QMimeData>
|
||||
#include <QFileInfo>
|
||||
|
||||
QCDScene::QCDScene( QObject * parent )
|
||||
: QGraphicsScene( parent ),
|
||||
@@ -81,31 +82,70 @@ void QCDScene::start( LabelMode mode )
|
||||
|
||||
bool QCDScene::load( const QString &fileName, QString *errMessage )
|
||||
{
|
||||
QFile file( fileName );
|
||||
if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
|
||||
if( errMessage )
|
||||
*errMessage = "cannot open file for reading";
|
||||
else
|
||||
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot open file for reading\n" ) + fileName );
|
||||
return false;
|
||||
}
|
||||
QXmlStreamReader reader( &file );
|
||||
try {
|
||||
read( reader );
|
||||
}
|
||||
catch( const QString &err ) {
|
||||
if( errMessage )
|
||||
*errMessage = err;
|
||||
else
|
||||
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot read file " ) + fileName + "\n" + err );
|
||||
return false;
|
||||
}
|
||||
m_fileName = fileName;
|
||||
m_saved = true;
|
||||
setName();
|
||||
if (fileName.endsWith(".qlx", Qt::CaseInsensitive)) {
|
||||
QFile file( fileName );
|
||||
if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
|
||||
if( errMessage )
|
||||
*errMessage = "cannot open file for reading";
|
||||
else
|
||||
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot open file for reading\n" ) + fileName );
|
||||
return false;
|
||||
}
|
||||
QXmlStreamReader reader( &file );
|
||||
try {
|
||||
read( reader );
|
||||
}
|
||||
catch( const QString &err ) {
|
||||
if( errMessage )
|
||||
*errMessage = err;
|
||||
else
|
||||
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot read file " ) + fileName + "\n" + err );
|
||||
return false;
|
||||
}
|
||||
m_fileName = fileName;
|
||||
m_saved = true;
|
||||
setName();
|
||||
|
||||
pushUndo();
|
||||
return true;
|
||||
pushUndo();
|
||||
|
||||
QList<QGraphicsItem *> list = items();
|
||||
bool oldFormat = true;
|
||||
foreach(QGraphicsItem *item, list ) {
|
||||
if( item->zValue() != 0.0 ) {
|
||||
oldFormat = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( oldFormat ) {
|
||||
double z = 1.0;
|
||||
foreach(QGraphicsItem *item, list ) {
|
||||
item->setZValue( z );
|
||||
z += 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
QShapeFactory &sfactory = QShapeFactory::instance();
|
||||
QLightPixmapItem *item =
|
||||
static_cast<QLightPixmapItem *>(sfactory.create( QShapeControllerPixmap::Type ) );
|
||||
addItem( item, true );
|
||||
if( item->loadImage( fileName ) ) {
|
||||
QSize size = item->pixmap().size();
|
||||
item->setOffset( -QPointF( size.height(), size.width() ) / 2.0 );
|
||||
item->setTransform( QTransform().scale( size.width() ? 120.0 / size.width() : 1.0,
|
||||
size.height() ? 120.0 / size.height() : 1.0 ) );
|
||||
setName();
|
||||
pushUndo();
|
||||
return true;
|
||||
} else {
|
||||
if( errMessage )
|
||||
*errMessage = "cannot load image";
|
||||
else
|
||||
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot load image " ) +
|
||||
fileName + "\n" );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -147,9 +187,7 @@ void QCDScene::setName()
|
||||
}
|
||||
m_name = "Unnamed_" + QString::number( m_index );
|
||||
} else {
|
||||
QRegExp rx( "(.*/)?(.*)\\.qlx" );
|
||||
rx.indexIn( m_fileName );
|
||||
m_name = rx.cap( 2 );
|
||||
m_name = QFileInfo(m_fileName).completeBaseName();
|
||||
}
|
||||
|
||||
updateTitles();
|
||||
@@ -237,8 +275,22 @@ void QCDScene::write( QXmlStreamWriter &writer )
|
||||
writer.writeEndDocument();
|
||||
}
|
||||
|
||||
void QCDScene::addItem( QGraphicsItem *item, bool top )
|
||||
{
|
||||
if( top ) {
|
||||
double topZ = 1.0;
|
||||
QList<QGraphicsItem *> list = items();
|
||||
foreach(QGraphicsItem *item, list ) {
|
||||
if( item->zValue() >= topZ )
|
||||
topZ = item->zValue() + 0.1;
|
||||
}
|
||||
item->setZValue( topZ );
|
||||
}
|
||||
QGraphicsScene::addItem( item );
|
||||
}
|
||||
|
||||
bool QCDScene::readItem( QXmlStreamReader &reader )
|
||||
|
||||
bool QCDScene::readItem( QXmlStreamReader &reader, bool top )
|
||||
{
|
||||
QShapeFactory &sfactory = QShapeFactory::instance();
|
||||
|
||||
@@ -255,7 +307,7 @@ bool QCDScene::readItem( QXmlStreamReader &reader )
|
||||
if( item ) {
|
||||
item->setFlag( QGraphicsItem::ItemIsMovable, true );
|
||||
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
|
||||
addItem( item );
|
||||
addItem( item, top );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -284,7 +336,7 @@ void QCDScene::read( QXmlStreamReader &reader )
|
||||
}
|
||||
|
||||
if( elementName == "item" ) {
|
||||
readItem( reader );
|
||||
readItem( reader, false );
|
||||
} else
|
||||
throw QString( "QCDScene: unknown element \"" ) + elementName + "\"";
|
||||
}
|
||||
@@ -342,7 +394,7 @@ void QCDScene::getItemFromClipboard()
|
||||
QString elementName = reader.name().toString();
|
||||
|
||||
if( elementName == "item" ) {
|
||||
if( readItem( reader ) )
|
||||
if( readItem( reader, true ) )
|
||||
setChanged();
|
||||
}
|
||||
}
|
||||
@@ -350,7 +402,7 @@ void QCDScene::getItemFromClipboard()
|
||||
|
||||
void QCDScene::contextMenuEvent( QGraphicsSceneContextMenuEvent *mouseEvent )
|
||||
{
|
||||
QGraphicsItem *item = itemAt( mouseEvent->scenePos() );
|
||||
QGraphicsItem *item = itemAt(mouseEvent->scenePos(), QTransform());
|
||||
if( !item )
|
||||
return;
|
||||
item->setSelected( true );
|
||||
|
||||
+2
-1
@@ -60,6 +60,7 @@ public:
|
||||
|
||||
void putItemToClipboard( bool move );
|
||||
void getItemFromClipboard();
|
||||
void addItem( QGraphicsItem *item, bool top );
|
||||
|
||||
void updateTitles() const;
|
||||
void redrawViews() const;
|
||||
@@ -82,7 +83,7 @@ private slots:
|
||||
|
||||
private:
|
||||
void write( QXmlStreamWriter &writer );
|
||||
bool readItem( QXmlStreamReader &reader );
|
||||
bool readItem( QXmlStreamReader &reader, bool top );
|
||||
void read( QXmlStreamReader &reader );
|
||||
void sendItemTo( bool front );
|
||||
void pushUndo();
|
||||
|
||||
+6
-3
@@ -147,19 +147,22 @@ void QCDView::drawForeground ( QPainter * painter, const QRectF & rect )
|
||||
m_labelMode = cdscene->labelMode();
|
||||
|
||||
*m_mask = QPixmap( frameSize() );
|
||||
QRectF rectf( QPointF( -frameSize().width(), -frameSize().height() ), frameSize() * 2 );
|
||||
|
||||
{
|
||||
QPainter paint( m_mask );
|
||||
paint.setWorldTransform( painter->transform() );
|
||||
drawCD( &paint, rect, false );
|
||||
drawCD( &paint, rectf, false );
|
||||
}
|
||||
|
||||
{
|
||||
QPixmap alpha( frameSize() );
|
||||
QPainter paint( &alpha );
|
||||
paint.setWorldTransform( painter->transform() );
|
||||
drawCD( &paint, rect, true );
|
||||
m_mask->setAlphaChannel( alpha );
|
||||
drawCD( &paint, rectf, true );
|
||||
QImage maskImage = m_mask->toImage().convertToFormat(QImage::Format_ARGB32);
|
||||
maskImage.setAlphaChannel(alpha.toImage());
|
||||
*m_mask = QPixmap::fromImage(maskImage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef QDIALOGCDPROPERTIES_H
|
||||
#define QDIALOGCDPROPERTIES_H
|
||||
|
||||
#include <QtGui/QDialog>
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class QDialogCDProperties;
|
||||
|
||||
+16
-3
@@ -22,10 +22,12 @@
|
||||
#include "ui_qdialogpixmap.h"
|
||||
#include "qlightpixmapitem.h"
|
||||
#include "qcdscene.h"
|
||||
#include "previewinjector.h"
|
||||
|
||||
#include <QImageReader>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
|
||||
QDialogPixmap::QDialogPixmap(QWidget *parent) :
|
||||
QItemDialog( parent ),
|
||||
@@ -68,7 +70,7 @@ bool QDialogPixmap::exec( QGraphicsItem *graphicsItem )
|
||||
m_item->imageName( item->imageName() );
|
||||
m_item->setTransform( item->transform() );
|
||||
|
||||
scene.addItem( m_item );
|
||||
scene.addItem( m_item, true );
|
||||
|
||||
m_ui->spinX->setValue( m_item->pos().x() );
|
||||
m_ui->spinY->setValue( m_item->pos().y() );
|
||||
@@ -118,8 +120,19 @@ void QDialogPixmap::onLoadImage()
|
||||
foreach( QByteArray arr, list ) {
|
||||
filter += QString( "*." ) + arr.data() + " ";
|
||||
}
|
||||
filter += tr( ")\nAll Files (*)" );
|
||||
QString fileName = QFileDialog::getOpenFileName( this, "Load image:", QString(), filter );
|
||||
filter += tr( ");;All Files (*.*)" );
|
||||
|
||||
QFileDialog fd( this, "Load image:", QString(), filter );
|
||||
//fd.setOption( QFileDialog::DontUseNativeDialog ); // for testing
|
||||
|
||||
bool injectPreview = QSettings().value( cfgInjectPreview, true ).toBool();
|
||||
PreviewInjector pj( injectPreview ? &fd : 0 );
|
||||
fd.setFileMode( QFileDialog::ExistingFile );
|
||||
|
||||
if( fd.exec() != QDialog::Accepted )
|
||||
return;
|
||||
|
||||
QString fileName = fd.selectedFiles().value(0);
|
||||
if( fileName.isNull() )
|
||||
return;
|
||||
|
||||
|
||||
+14
-5
@@ -46,12 +46,14 @@ void QDialogPrint::changeEvent(QEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
QLightDrive *QDialogPrint::exec( QWidget *parent, PrintParameters ¶ms )
|
||||
QPair<bool, QLightDrive *> QDialogPrint::exec( QWidget *parent, PrintParameters ¶ms, bool preview )
|
||||
{
|
||||
QPair<bool, QLightDrive *> rez( false, 0 );
|
||||
|
||||
QList<QLightDrive *> drives = QLightScribe::instance()->getDrives();
|
||||
if( drives.isEmpty() ) {
|
||||
if( !preview && drives.isEmpty() ) {
|
||||
QMessageBox::critical( parent, tr( "Error" ), tr( "Cannot find any lightScribe drive" ) );
|
||||
return 0;
|
||||
return rez;
|
||||
}
|
||||
QDialogPrint dialog( parent );
|
||||
switch( params.m_labelMode ) {
|
||||
@@ -64,8 +66,11 @@ QLightDrive *QDialogPrint::exec( QWidget *parent, PrintParameters ¶ms )
|
||||
foreach( QLightDrive *drv, drives ) {
|
||||
dialog.m_ui->comboDrive->insertItem( index++, drv->displayName() );
|
||||
}
|
||||
if( preview )
|
||||
dialog.m_ui->comboDrive->insertItem( index++, tr( "Software renderer" ) );
|
||||
|
||||
if( dialog.QDialog::exec() == Rejected )
|
||||
return 0;
|
||||
return rez;
|
||||
|
||||
params = PrintParameters(); // reset to default
|
||||
|
||||
@@ -87,5 +92,9 @@ QLightDrive *QDialogPrint::exec( QWidget *parent, PrintParameters ¶ms )
|
||||
if( dialog.m_ui->radioMediaGeneric->isChecked() )
|
||||
params.m_mediaOptimizationLevel = mediaGeneric;
|
||||
|
||||
return drives.at( dialog.m_ui->comboDrive->currentIndex() );
|
||||
rez.first = true;
|
||||
if( dialog.m_ui->comboDrive->currentIndex() < drives.size() )
|
||||
rez.second = drives.at( dialog.m_ui->comboDrive->currentIndex() );
|
||||
|
||||
return rez;
|
||||
}
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@
|
||||
#ifndef QDIALOGPRINT_H
|
||||
#define QDIALOGPRINT_H
|
||||
|
||||
#include <QtGui/QDialog>
|
||||
#include <QDialog>
|
||||
|
||||
#include "qlightscribe.h"
|
||||
|
||||
@@ -33,7 +33,7 @@ class QDialogPrint : public QDialog {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(QDialogPrint)
|
||||
public:
|
||||
static QLightDrive *exec( QWidget *parent, PrintParameters ¶ms );
|
||||
static QPair<bool, QLightDrive *> exec( QWidget *parent, PrintParameters ¶ms, bool preview );
|
||||
|
||||
protected:
|
||||
explicit QDialogPrint(QWidget *parent = 0);
|
||||
|
||||
@@ -27,13 +27,15 @@
|
||||
#include <QMessageBox>
|
||||
#include <QAbstractButton>
|
||||
#include <QTime>
|
||||
#include <QElapsedTimer>
|
||||
#include <QTimer>
|
||||
#include <QSettings>
|
||||
|
||||
QDialogProgress::QDialogProgress( QWidget *parent, QLightDrive *drive )
|
||||
: QDialog(parent),
|
||||
m_ui(new Ui::QDialogProgress),
|
||||
m_drive( drive ),
|
||||
m_start( new QTime ),
|
||||
m_start(new QElapsedTimer),
|
||||
m_timer( new QTimer( this ) )
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
@@ -64,10 +66,12 @@ bool QDialogProgress::exec( QWidget *parent, QCDScene *scene )
|
||||
{
|
||||
PrintParameters params;
|
||||
params.m_labelMode = scene->labelMode();
|
||||
QLightDrive *drive = QDialogPrint::exec( parent, params );
|
||||
QLightDrive *drive = QDialogPrint::exec( parent, params, false ).second;
|
||||
if( !drive )
|
||||
return false;
|
||||
|
||||
params.m_ejectAfterComplete = QSettings().value( cfgEjectAfterFinish, false ).toBool();
|
||||
|
||||
QDialogProgress dialog( parent, drive );
|
||||
dialog.setWindowTitle( tr( "Printing: " ) + scene->name() );
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef QDIALOGPROGRESS_H
|
||||
#define QDIALOGPROGRESS_H
|
||||
|
||||
#include <QtGui/QDialog>
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class QDialogProgress;
|
||||
@@ -29,7 +29,7 @@ namespace Ui {
|
||||
|
||||
class QCDScene;
|
||||
class QAbstractButton;
|
||||
class QTime;
|
||||
class QElapsedTimer;
|
||||
class QTimer;
|
||||
class QLightDrive;
|
||||
|
||||
@@ -56,7 +56,7 @@ private:
|
||||
|
||||
Ui::QDialogProgress *m_ui;
|
||||
QLightDrive *m_drive;
|
||||
QTime *m_start;
|
||||
QElapsedTimer *m_start;
|
||||
QTimer *m_timer;
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ui_qdialogroundtext.h"
|
||||
#include "qlightroundtextitem.h"
|
||||
#include "qcdscene.h"
|
||||
#include "qdialogsettings.h"
|
||||
|
||||
#include <QFontDialog>
|
||||
#include <QColorDialog>
|
||||
@@ -72,7 +73,7 @@ bool QDialogRoundText::exec( QGraphicsItem *graphicsItem )
|
||||
m_item->setAlignment( item->alignment() );
|
||||
m_item->setOutside( item->outside() );
|
||||
|
||||
scene.addItem( m_item );
|
||||
scene.addItem( m_item, true );
|
||||
|
||||
m_ui->spinX->setValue( m_item->pos().x() );
|
||||
m_ui->spinY->setValue( m_item->pos().y() );
|
||||
@@ -132,6 +133,7 @@ void QDialogRoundText::onFont()
|
||||
//font.setPointSizeF( font.pointSizeF() / 2.0 );
|
||||
if( ok ) {
|
||||
m_item->setFont( font );
|
||||
QDialogSettings::setLastUsedFont( font );
|
||||
fontChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/* qlscribe - Qt based application to print lightScribe discs
|
||||
|
||||
Copyright (C) 2009 Vyacheslav Kononenko <vyacheslav@kononenko.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
$Id$ */
|
||||
|
||||
#include "qdialogsettings.h"
|
||||
#include "ui_qdialogsettings.h"
|
||||
#include "qlscribe.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QFontDialog>
|
||||
|
||||
QFont *QDialogSettings::m_lastUsedFont = 0;
|
||||
|
||||
QDialogSettings::QDialogSettings(QWidget *parent) :
|
||||
QDialog( parent ),
|
||||
m_ui( new Ui::QDialogSettings )
|
||||
{
|
||||
m_ui->setupUi( this );
|
||||
connect( m_ui->btnFont, SIGNAL(clicked()), this, SLOT(onFont()) );
|
||||
connect( m_ui->btnLastUsedFont, SIGNAL(clicked()), this, SLOT(onLastUsedFont()) );
|
||||
m_ui->btnLastUsedFont->setEnabled( m_lastUsedFont );
|
||||
}
|
||||
|
||||
QDialogSettings::~QDialogSettings()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void QDialogSettings::changeEvent(QEvent *e)
|
||||
{
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
m_ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool QDialogSettings::exec( QWidget *parent )
|
||||
{
|
||||
QDialogSettings dialog( parent );
|
||||
QSettings sts;
|
||||
dialog.m_font = sts.value( cfgDefaultFont ).value<QFont>();
|
||||
dialog.m_ui->fontName->setCurrentFont( dialog.m_font );
|
||||
dialog.m_ui->chkEject->setChecked( sts.value( cfgEjectAfterFinish, false ).toBool() );
|
||||
dialog.m_ui->chkPreview->setChecked( sts.value( cfgInjectPreview, true ).toBool() );
|
||||
|
||||
if( dialog.QDialog::exec() == Rejected ) return false;
|
||||
|
||||
sts.setValue( cfgDefaultFont, dialog.m_font );
|
||||
sts.setValue( cfgEjectAfterFinish, dialog.m_ui->chkEject->isChecked() );
|
||||
sts.setValue( cfgInjectPreview, dialog.m_ui->chkPreview->isChecked() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QDialogSettings::onFont()
|
||||
{
|
||||
bool ok = true;
|
||||
QFont font = QFontDialog::getFont( &ok, m_font, this );
|
||||
if( ok ) {
|
||||
m_font = font;
|
||||
m_ui->fontName->setCurrentFont( font );
|
||||
}
|
||||
}
|
||||
|
||||
void QDialogSettings::onLastUsedFont()
|
||||
{
|
||||
if( m_lastUsedFont ) {
|
||||
m_font = *m_lastUsedFont;
|
||||
m_ui->fontName->setCurrentFont( *m_lastUsedFont );
|
||||
}
|
||||
}
|
||||
|
||||
void QDialogSettings::setLastUsedFont( const QFont &font )
|
||||
{
|
||||
if( !m_lastUsedFont ) m_lastUsedFont = new QFont( font );
|
||||
else *m_lastUsedFont = font;
|
||||
}
|
||||
|
||||
QFont QDialogSettings::defaultFont()
|
||||
{
|
||||
return QSettings().value( cfgDefaultFont ).value<QFont>();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/* qlscribe - Qt based application to print lightScribe discs
|
||||
|
||||
Copyright (C) 2009 Vyacheslav Kononenko <vyacheslav@kononenko.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
$Id$ */
|
||||
|
||||
#ifndef QDIALOGSETTINGS_H
|
||||
#define QDIALOGSETTINGS_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class QDialogSettings;
|
||||
}
|
||||
|
||||
class QDialogSettings : public QDialog {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(QDialogSettings)
|
||||
public:
|
||||
|
||||
static bool exec( QWidget *parent = 0 );
|
||||
static void setLastUsedFont( const QFont &font );
|
||||
static QFont defaultFont();
|
||||
|
||||
private:
|
||||
explicit QDialogSettings( QWidget *parent = 0 );
|
||||
virtual ~QDialogSettings();
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e);
|
||||
|
||||
private slots:
|
||||
void onFont();
|
||||
void onLastUsedFont();
|
||||
|
||||
private:
|
||||
Ui::QDialogSettings *m_ui;
|
||||
QFont m_font;
|
||||
static QFont *m_lastUsedFont;
|
||||
};
|
||||
|
||||
#endif // QDIALOGSETTINGS_H
|
||||
@@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QDialogSettings</class>
|
||||
<widget class="QDialog" name="QDialogSettings">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::NonModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>320</width>
|
||||
<height>170</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Default font:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QFontComboBox" name="fontName">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<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="btnFont">
|
||||
<property name="text">
|
||||
<string>Font...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnLastUsedFont">
|
||||
<property name="text">
|
||||
<string>Last used</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkEject">
|
||||
<property name="text">
|
||||
<string>Eject tray after finish</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkPreview">
|
||||
<property name="text">
|
||||
<string>Enable image preview in open dialog</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>QDialogSettings</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>QDialogSettings</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
+27
-10
@@ -21,8 +21,9 @@
|
||||
#include "qdialogtext.h"
|
||||
#include "ui_qdialogtext.h"
|
||||
#include "qcdscene.h"
|
||||
#include "qdialogsettings.h"
|
||||
#include "qlighttextitem.h"
|
||||
|
||||
#include <QGraphicsSimpleTextItem>
|
||||
#include <QFontDialog>
|
||||
#include <QColorDialog>
|
||||
|
||||
@@ -54,39 +55,48 @@ void QDialogText::changeEvent(QEvent *e)
|
||||
|
||||
bool QDialogText::exec( QGraphicsItem *graphicsItem )
|
||||
{
|
||||
QGraphicsSimpleTextItem *item = dynamic_cast< QGraphicsSimpleTextItem * >( graphicsItem );
|
||||
QLightTextItem *item = dynamic_cast< QLightTextItem * >( graphicsItem );
|
||||
if( !item )
|
||||
return false;
|
||||
|
||||
QCDScene scene;
|
||||
m_ui->cdView->setScene( &scene );
|
||||
m_item = new QGraphicsSimpleTextItem;
|
||||
m_item = new QLightTextItem;
|
||||
|
||||
m_item->setPos( item->pos() );
|
||||
m_item->setText( item->text() );
|
||||
m_item->setFont( item->font() );
|
||||
m_item->setBrush( item->brush() );
|
||||
m_item->setColor( item->color() );
|
||||
m_item->setTransform( item->transform() );
|
||||
m_item->setAlignment( item->alignment() );
|
||||
|
||||
scene.addItem( m_item );
|
||||
scene.addItem( m_item, true );
|
||||
|
||||
m_ui->spinX->setValue( m_item->pos().x() );
|
||||
m_ui->spinY->setValue( m_item->pos().y() );
|
||||
m_ui->textEdit->setPlainText( m_item->text() );
|
||||
|
||||
int index = 0;
|
||||
if( m_item->alignment() == Qt::AlignRight ) index = 2;
|
||||
else if( m_item->alignment() == Qt::AlignCenter ) index = 1;
|
||||
|
||||
m_ui->comboAlignment->setCurrentIndex( index );
|
||||
|
||||
colorChanged();
|
||||
fontChanged();
|
||||
|
||||
connect( m_ui->textEdit, SIGNAL(textChanged()), this, SLOT(textChanged()) );
|
||||
connect( m_ui->spinX, SIGNAL(valueChanged(double)), this, SLOT(posChanged()) );
|
||||
connect( m_ui->spinY, SIGNAL(valueChanged(double)), this, SLOT(posChanged()) );
|
||||
connect( m_ui->comboAlignment, SIGNAL(currentIndexChanged(int)),this, SLOT(alignChanged()) );
|
||||
|
||||
if( QDialog::exec() == Rejected ) return false;
|
||||
|
||||
item->setPos( m_item->pos() );
|
||||
item->setText( m_item->text() );
|
||||
item->setFont( m_item->font() );
|
||||
item->setBrush( m_item->brush() );
|
||||
item->setColor( m_item->color() );
|
||||
item->setAlignment( m_item->alignment() );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -97,17 +107,18 @@ void QDialogText::onFont()
|
||||
QFont font = QFontDialog::getFont( &ok, m_item->font(), this );
|
||||
if( ok ) {
|
||||
m_item->setFont( font );
|
||||
QDialogSettings::setLastUsedFont( font );
|
||||
fontChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void QDialogText::onColor()
|
||||
{
|
||||
QColor color = QColorDialog::getColor( m_item->brush().color(), this );
|
||||
QColor color = QColorDialog::getColor( m_item->color(), this );
|
||||
if( color.isValid() ){
|
||||
m_item->setBrush( color );
|
||||
m_item->setColor( color );
|
||||
colorChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QDialogText::fontChanged()
|
||||
@@ -118,7 +129,7 @@ void QDialogText::fontChanged()
|
||||
void QDialogText::colorChanged()
|
||||
{
|
||||
QPixmap pixmap( m_ui->colorWidget->size() );
|
||||
pixmap.fill( m_item->brush().color() );
|
||||
pixmap.fill( m_item->color() );
|
||||
m_ui->colorWidget->setPixmap( pixmap );
|
||||
}
|
||||
|
||||
@@ -132,3 +143,9 @@ void QDialogText::posChanged()
|
||||
m_item->setPos( m_ui->spinX->value(), m_ui->spinY->value() );
|
||||
}
|
||||
|
||||
void QDialogText::alignChanged()
|
||||
{
|
||||
Qt::Alignment align[] = { Qt::AlignLeft, Qt::AlignCenter, Qt::AlignRight };
|
||||
m_item->setAlignment( align[ m_ui->comboAlignment->currentIndex() ] );
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -16,7 +16,7 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
$Id:$ */
|
||||
$Id$ */
|
||||
|
||||
#ifndef QDIALOGTEXT_H
|
||||
#define QDIALOGTEXT_H
|
||||
@@ -27,7 +27,7 @@ namespace Ui {
|
||||
class QDialogText;
|
||||
}
|
||||
|
||||
class QGraphicsSimpleTextItem;
|
||||
class QLightTextItem;
|
||||
|
||||
class QDialogText : public QItemDialog {
|
||||
Q_OBJECT
|
||||
@@ -48,10 +48,11 @@ private slots:
|
||||
void fontChanged();
|
||||
void colorChanged();
|
||||
void posChanged();
|
||||
void alignChanged();
|
||||
|
||||
private:
|
||||
Ui::QDialogText *m_ui;
|
||||
QGraphicsSimpleTextItem *m_item;
|
||||
Ui::QDialogText *m_ui;
|
||||
QLightTextItem *m_item;
|
||||
};
|
||||
|
||||
#endif // QDIALOGTEXT_H
|
||||
|
||||
+128
-96
@@ -1,10 +1,11 @@
|
||||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QDialogText</class>
|
||||
<widget class="QDialog" name="QDialogText" >
|
||||
<property name="windowModality" >
|
||||
<enum>Qt::NonModal</enum>
|
||||
<widget class="QDialog" name="QDialogText">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
@@ -12,73 +13,70 @@
|
||||
<height>627</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string>Text properties</string>
|
||||
</property>
|
||||
<property name="modal" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3" >
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame" >
|
||||
<property name="frameShape" >
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="lineWidth" >
|
||||
<property name="lineWidth">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||
<property name="sizeConstraint" >
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>X:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QDoubleSpinBox" name="spinX" >
|
||||
<property name="decimals" >
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinX">
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum" >
|
||||
<property name="minimum">
|
||||
<double>-61.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<property name="maximum">
|
||||
<double>61.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Y:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QDoubleSpinBox" name="spinY" >
|
||||
<property name="decimals" >
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinY">
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum" >
|
||||
<property name="minimum">
|
||||
<double>-61.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<property name="maximum">
|
||||
<double>61.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -86,11 +84,11 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer" >
|
||||
<property name="orientation" >
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>13</width>
|
||||
<height>20</height>
|
||||
@@ -99,70 +97,104 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_3" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="text" >
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Font:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_6" >
|
||||
<property name="text" >
|
||||
<item row="0" column="1">
|
||||
<widget class="QFontComboBox" name="fontName">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QFontComboBox" name="fontName" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="editable" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLabel" name="colorWidget" >
|
||||
<property name="minimumSize" >
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="colorWidget">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize" >
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape" >
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text" >
|
||||
</property>
|
||||
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat" >
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboAlignment" >
|
||||
<property name="currentIndex" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Center</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Right</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Alignment:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2" >
|
||||
<property name="orientation" >
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>20</height>
|
||||
@@ -171,20 +203,20 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_4" >
|
||||
<property name="fieldGrowthPolicy" >
|
||||
<layout class="QFormLayout" name="formLayout_4">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QPushButton" name="btnColor" >
|
||||
<property name="text" >
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="btnColor">
|
||||
<property name="text">
|
||||
<string>Color...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QPushButton" name="btnFont" >
|
||||
<property name="text" >
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="btnFont">
|
||||
<property name="text">
|
||||
<string>Font...</string>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -194,26 +226,26 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" >
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Text</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="textEdit" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<widget class="QPlainTextEdit" name="textEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>50</height>
|
||||
@@ -224,20 +256,20 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCDView" name="cdView" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<widget class="QCDView" name="cdView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>2</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="baseSize" >
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="interactive" >
|
||||
<property name="interactive">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -246,11 +278,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||
<property name="orientation" >
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons" >
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -281,11 +313,11 @@
|
||||
<receiver>QDialogText</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>258</x>
|
||||
<y>582</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
@@ -297,11 +329,11 @@
|
||||
<receiver>QDialogText</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>326</x>
|
||||
<y>582</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
|
||||
@@ -29,6 +29,17 @@ QLightPixmapItem::QLightPixmapItem()
|
||||
{
|
||||
}
|
||||
|
||||
bool QLightPixmapItem::loadImage( const QString &name )
|
||||
{
|
||||
QPixmap pixmap( name );
|
||||
if( pixmap.isNull() )
|
||||
return false;
|
||||
m_imageName = name;
|
||||
setPixmap( pixmap );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant QLightPixmapItem::itemChange( GraphicsItemChange change, const QVariant & value )
|
||||
{
|
||||
if( scene() && change == ItemPositionHasChanged )
|
||||
@@ -112,7 +123,7 @@ void QShapeControllerPixmap::readData( const QString &element,
|
||||
}
|
||||
pixmapItem->imageName( data );
|
||||
pixmapItem->setPixmap( pixmap );
|
||||
pixmapItem->setOffset( -QPointF( pixmap.size().height(), pixmap.size().width() ) / 2.0 );
|
||||
pixmapItem->setOffset( -QPointF( pixmap.size().width(), pixmap.size().height() ) / 2.0 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
|
||||
#include "qshapefactory.h"
|
||||
|
||||
class QLightPixmapItem : public QGraphicsPixmapItem
|
||||
{
|
||||
class QLightPixmapItem : public QGraphicsPixmapItem {
|
||||
public:
|
||||
QLightPixmapItem();
|
||||
|
||||
bool loadImage( const QString &name );
|
||||
void imageName( const QString &name ) { m_imageName = name; }
|
||||
const QString &imageName() const { return m_imageName; }
|
||||
|
||||
|
||||
+38
-12
@@ -21,6 +21,7 @@
|
||||
#include "qlightroundtextitem.h"
|
||||
#include "qdialogroundtext.h"
|
||||
#include "qcdscene.h"
|
||||
#include "qdialogsettings.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QFontMetrics>
|
||||
@@ -28,6 +29,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QTextLayout>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@@ -127,7 +129,7 @@ QPainterPath QLightRoundTextItem::shape() const
|
||||
const double pad = 1;
|
||||
|
||||
for( int i = 0; i < m_text.size(); ++i )
|
||||
arcAngle += mcs.width( m_text[ i ] );
|
||||
arcAngle += mcs.horizontalAdvance(m_text[i]);
|
||||
|
||||
double height = ( mcs.height() * 2 ) / 3;
|
||||
double in, out;
|
||||
@@ -190,10 +192,10 @@ void QLightRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsIt
|
||||
switch( m_alignment ) {
|
||||
case Qt::AlignCenter :
|
||||
case Qt::AlignHCenter :
|
||||
angle += mcs.width( m_text ) / diam * ( m_outside ? -1 : 1 );
|
||||
angle += mcs.horizontalAdvance(m_text) / diam * ( m_outside ? -1 : 1 );
|
||||
break;
|
||||
case Qt::AlignRight :
|
||||
angle += mcs.width( m_text ) / radi * ( m_outside ? -1 : 1 );
|
||||
angle += mcs.horizontalAdvance(m_text) / radi * ( m_outside ? -1 : 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -211,12 +213,12 @@ void QLightRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsIt
|
||||
for( int i = 0; i < m_text.size(); ++i ) {
|
||||
QChar ch = m_text[ i ];
|
||||
|
||||
double d = ( prevWidth + mcs.width( ch ) ) / diam;
|
||||
double d = (prevWidth + mcs.horizontalAdvance(ch)) / diam;
|
||||
trans.reset();
|
||||
trans.rotateRadians( m_outside ? d : -d );
|
||||
painter->setWorldTransform( trans, true );
|
||||
|
||||
prevWidth = mcs.width( ch );
|
||||
prevWidth = mcs.horizontalAdvance(ch);
|
||||
|
||||
painter->drawText( int( -prevWidth / 2.0 ),
|
||||
int( m_outside ? -m_radius : m_radius ),
|
||||
@@ -225,19 +227,43 @@ void QLightRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsIt
|
||||
painter->restore();
|
||||
if (option->state & QStyle::State_Selected) {
|
||||
painter->setPen( QPen( option->palette.windowText(), 0, Qt::DashLine ) );
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
painter->setBrush( Qt::NoBrush );
|
||||
painter->drawPath( shape() );
|
||||
}
|
||||
}
|
||||
|
||||
QVariant QLightRoundTextItem::itemChange( GraphicsItemChange change, const QVariant & value )
|
||||
inline
|
||||
double distance( const QPointF &p1, const QPointF &p2 )
|
||||
{
|
||||
if( scene() && change == ItemPositionHasChanged )
|
||||
static_cast<QCDScene *>( scene() )->itemMoved();
|
||||
|
||||
return value;
|
||||
QPointF d = p1 - p2;
|
||||
return sqrt( d.x() * d.x() + d.y() * d.y() );
|
||||
}
|
||||
|
||||
inline
|
||||
double angle( const QPointF &p1, const QPointF &p2 )
|
||||
{
|
||||
QPointF d = p1 - p2;
|
||||
return atan2( d.y(), d.x() ) * 180.0 / 3.14159;
|
||||
}
|
||||
|
||||
void QLightRoundTextItem::mouseMoveEvent( QGraphicsSceneMouseEvent *event )
|
||||
{
|
||||
if( event->buttons() & Qt::LeftButton ) {
|
||||
double dradi = distance( scenePos(), event->lastScenePos() ) - distance( scenePos(), event->scenePos() );
|
||||
double dangle = ::angle( scenePos(), event->lastScenePos() ) - ::angle( scenePos(), event->scenePos() );
|
||||
|
||||
prepareGeometryChange();
|
||||
m_radius -= dradi;
|
||||
m_angle -= dangle;
|
||||
if( m_angle > 360.0 ) m_angle -= 360.0;
|
||||
if( m_angle < 0.0 ) m_angle += 360.0;
|
||||
|
||||
static_cast<QCDScene *>( scene() )->itemMoved();
|
||||
} else
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
|
||||
RegisterController< QShapeControllerRoundText > regControllerRoundText;
|
||||
|
||||
QString QShapeControllerRoundText::name() const
|
||||
@@ -253,6 +279,7 @@ QString QShapeControllerRoundText::menuName() const
|
||||
QGraphicsItem *QShapeControllerRoundText::create() const
|
||||
{
|
||||
QLightRoundTextItem *item = new QLightRoundTextItem;
|
||||
item->setFont( QDialogSettings::defaultFont() );
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -344,4 +371,3 @@ void QShapeControllerRoundText::readData( const QString &element,
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
class QLightRoundTextItem : public QAbstractGraphicsShapeItem {
|
||||
public:
|
||||
enum { Type = UserType + 1 };
|
||||
enum { Type = UserType + 1 };
|
||||
|
||||
QLightRoundTextItem( QGraphicsItem * parent = 0 );
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
virtual int type() const { return Type; }
|
||||
|
||||
protected:
|
||||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value );
|
||||
virtual void mouseMoveEvent( QGraphicsSceneMouseEvent *event );
|
||||
|
||||
private:
|
||||
QFont m_font;
|
||||
|
||||
+21
-19
@@ -37,7 +37,7 @@
|
||||
QDBusArgument &operator<<( QDBusArgument &argument, const PrintParameters &p )
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument << p.m_labelMode << p.m_drawOptions << p.m_printQuality << p.m_mediaOptimizationLevel;
|
||||
argument << p.m_labelMode << p.m_drawOptions << p.m_printQuality << p.m_mediaOptimizationLevel << (int) p.m_ejectAfterComplete;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
@@ -46,13 +46,14 @@
|
||||
const QDBusArgument &operator>>( const QDBusArgument &argument, PrintParameters &p )
|
||||
{
|
||||
argument.beginStructure();
|
||||
int drawOptions = 0, labelMode = 0, mediaOptimizationLevel = 0, printQuality = 0;
|
||||
argument >> labelMode >> drawOptions >> printQuality >> mediaOptimizationLevel;
|
||||
int drawOptions = 0, labelMode = 0, mediaOptimizationLevel = 0, printQuality = 0, ejectAfterComplete = 0;
|
||||
argument >> labelMode >> drawOptions >> printQuality >> mediaOptimizationLevel >> ejectAfterComplete;
|
||||
argument.endStructure();
|
||||
p = PrintParameters( LabelMode( labelMode ),
|
||||
DrawOptions( drawOptions ),
|
||||
PrintQuality( printQuality ),
|
||||
MediaOptimizationLevel( mediaOptimizationLevel ) );
|
||||
MediaOptimizationLevel( mediaOptimizationLevel ),
|
||||
ejectAfterComplete );
|
||||
return argument;
|
||||
}
|
||||
|
||||
@@ -108,24 +109,25 @@ QLightDrive::QLightDrive( QObject *parent, const QString &path, const QString &n
|
||||
static
|
||||
void printScene( QCDScene *scene, QByteArray &array )
|
||||
{
|
||||
QImage image( 2772, 2772, QImage::Format_RGB888 );
|
||||
image.fill( 0xFFFFFFFF );
|
||||
const int resolution = 2772;
|
||||
QImage image( resolution, resolution, QImage::Format_RGB888 );
|
||||
image.fill( 0xFFFFFFFF );
|
||||
|
||||
scene->clearSelection();
|
||||
{
|
||||
QPainter painter( &image );
|
||||
scene->render( &painter, image.rect() );
|
||||
}
|
||||
image.setDotsPerMeterX( 23622 );
|
||||
image.setDotsPerMeterY( 23622 );
|
||||
scene->clearSelection();
|
||||
{
|
||||
QPainter painter( &image );
|
||||
scene->render( &painter, image.rect() );
|
||||
}
|
||||
image.setDotsPerMeterX( resolution * 8 );
|
||||
image.setDotsPerMeterY( resolution * 8 );
|
||||
|
||||
array.clear();
|
||||
QBuffer buffer( &array );
|
||||
buffer.open( QIODevice::WriteOnly );
|
||||
image.save( &buffer, "bmp", 100 );
|
||||
array.clear();
|
||||
QBuffer buffer( &array );
|
||||
buffer.open( QIODevice::WriteOnly );
|
||||
image.save( &buffer, "bmp", 100 );
|
||||
}
|
||||
|
||||
QPixmap QLightDrive::preview( const PrintParameters ¶ms, QCDScene *scene, const QSize &size ) throw( QString )
|
||||
QPixmap QLightDrive::preview(const PrintParameters ¶ms, QCDScene *scene, const QSize &size)
|
||||
{
|
||||
qApp->setOverrideCursor( Qt::WaitCursor );
|
||||
QByteArray array;
|
||||
@@ -148,7 +150,7 @@ QPixmap QLightDrive::preview( const PrintParameters ¶ms, QCDScene *scene, co
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
void QLightDrive::print( const PrintParameters ¶ms, QCDScene *scene ) throw( QString )
|
||||
void QLightDrive::print(const PrintParameters ¶ms, QCDScene *scene)
|
||||
{
|
||||
qApp->setOverrideCursor( Qt::WaitCursor );
|
||||
QByteArray array;
|
||||
|
||||
+13
-5
@@ -24,6 +24,7 @@
|
||||
#include "qlscribe.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QMetaType>
|
||||
|
||||
@@ -35,13 +36,20 @@ struct PrintParameters {
|
||||
DrawOptions m_drawOptions;
|
||||
PrintQuality m_printQuality;
|
||||
MediaOptimizationLevel m_mediaOptimizationLevel;
|
||||
bool m_ejectAfterComplete;
|
||||
|
||||
PrintParameters()
|
||||
: m_labelMode( modeFull ), m_drawOptions( drawDefault ),
|
||||
m_printQuality( qualityBest ), m_mediaOptimizationLevel( mediaRecognized ) {}
|
||||
PrintParameters( LabelMode labelMode, DrawOptions drawOptions, PrintQuality printQuality, MediaOptimizationLevel mediaOptimizationLevel )
|
||||
m_printQuality( qualityBest ), m_mediaOptimizationLevel( mediaRecognized ), m_ejectAfterComplete( false ) {}
|
||||
PrintParameters( LabelMode labelMode,
|
||||
DrawOptions drawOptions,
|
||||
PrintQuality printQuality,
|
||||
MediaOptimizationLevel mediaOptimizationLevel,
|
||||
bool ejectAfterComplete )
|
||||
: m_labelMode( labelMode ), m_drawOptions( drawOptions ),
|
||||
m_printQuality( printQuality ), m_mediaOptimizationLevel( mediaOptimizationLevel ) {}
|
||||
m_printQuality( printQuality ), m_mediaOptimizationLevel( mediaOptimizationLevel ),
|
||||
m_ejectAfterComplete( ejectAfterComplete )
|
||||
{}
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( PrintParameters );
|
||||
@@ -79,8 +87,8 @@ public:
|
||||
double innerRadius() const { return m_innerRadius; }
|
||||
double outerRadius() const { return m_outerRadius; }
|
||||
|
||||
QPixmap preview( const PrintParameters ¶ms, QCDScene *scene, const QSize &size ) throw( QString );
|
||||
void print( const PrintParameters ¶ms, QCDScene *scene ) throw( QString );
|
||||
QPixmap preview(const PrintParameters ¶ms, QCDScene *scene, const QSize &size);
|
||||
void print(const PrintParameters ¶ms, QCDScene *scene);
|
||||
|
||||
friend class QLightScribe;
|
||||
|
||||
|
||||
+67
-6
@@ -21,9 +21,11 @@
|
||||
#include "qlighttextitem.h"
|
||||
#include "qdialogtext.h"
|
||||
#include "qcdscene.h"
|
||||
#include "qdialogsettings.h"
|
||||
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QTextDocument>
|
||||
|
||||
|
||||
QLightTextItem::QLightTextItem()
|
||||
@@ -38,6 +40,58 @@ QVariant QLightTextItem::itemChange( GraphicsItemChange change, const QVariant &
|
||||
return value;
|
||||
}
|
||||
|
||||
QString QLightTextItem::text() const
|
||||
{
|
||||
return QGraphicsSimpleTextItem::text();
|
||||
}
|
||||
|
||||
QColor QLightTextItem::color() const
|
||||
{
|
||||
return this->brush().color();
|
||||
}
|
||||
|
||||
Qt::Alignment QLightTextItem::alignment() const
|
||||
{
|
||||
return m_alignment;
|
||||
}
|
||||
|
||||
void QLightTextItem::setText( const QString &txt )
|
||||
{
|
||||
QGraphicsSimpleTextItem::setText( txt );
|
||||
updateTrans();
|
||||
}
|
||||
|
||||
void QLightTextItem::setFont( const QFont &font )
|
||||
{
|
||||
QGraphicsSimpleTextItem::setFont( font );
|
||||
updateTrans();
|
||||
}
|
||||
|
||||
|
||||
void QLightTextItem::setColor( const QColor &color )
|
||||
{
|
||||
this->setBrush( color );
|
||||
}
|
||||
|
||||
|
||||
void QLightTextItem::setAlignment( Qt::Alignment align )
|
||||
{
|
||||
m_alignment = align;
|
||||
updateTrans();
|
||||
}
|
||||
|
||||
void QLightTextItem::updateTrans()
|
||||
{
|
||||
double size = this->boundingRect().width();
|
||||
|
||||
QTransform trans;
|
||||
trans.scale( 0.5, 0.5 );
|
||||
switch( m_alignment ) {
|
||||
case Qt::AlignRight : trans.translate( -size, 0 ); break;
|
||||
case Qt::AlignCenter : trans.translate( -size / 2.0, 0 ); break;
|
||||
}
|
||||
this->setTransform( trans );
|
||||
}
|
||||
|
||||
RegisterController< QShapeControllerText > regControllerText;
|
||||
|
||||
@@ -53,7 +107,8 @@ QString QShapeControllerText::menuName() const
|
||||
|
||||
QGraphicsItem *QShapeControllerText::create() const
|
||||
{
|
||||
QGraphicsItem *item = new QLightTextItem;
|
||||
QLightTextItem *item = new QLightTextItem;
|
||||
item->setFont( QDialogSettings::defaultFont() );
|
||||
item->setTransform( QTransform().scale( 0.5, 0.5 ), true );
|
||||
item->setPos( 0, -40.0 );
|
||||
|
||||
@@ -67,20 +122,21 @@ QItemDialog *QShapeControllerText::createDialog( QWidget *parent ) const
|
||||
|
||||
void QShapeControllerText::writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const
|
||||
{
|
||||
const QGraphicsSimpleTextItem *textItem = static_cast< const QGraphicsSimpleTextItem * >( item );
|
||||
const QLightTextItem *textItem = static_cast< const QLightTextItem * >( item );
|
||||
writer.writeEmptyElement( "pos" );
|
||||
writer.writeAttribute( QXmlStreamAttribute( "x", QString::number( textItem->pos().x() ) ) );
|
||||
writer.writeAttribute( QXmlStreamAttribute( "y", QString::number( textItem->pos().y() ) ) );
|
||||
writer.writeAttribute( QXmlStreamAttribute( "z", QString::number( textItem->zValue() ) ) );
|
||||
|
||||
writer.writeTextElement( "font", textItem->font().toString() );
|
||||
writer.writeTextElement( "color", textItem->brush().color().name() );
|
||||
writer.writeTextElement( "color", textItem->color().name() );
|
||||
writer.writeTextElement( "text", textItem->text() );
|
||||
writer.writeTextElement( "alignment", QString::number( textItem->alignment() ) );
|
||||
}
|
||||
|
||||
void QShapeControllerText::replace( QGraphicsItem *item, const QString &from, const QString &to ) const
|
||||
{
|
||||
QGraphicsSimpleTextItem *textItem = static_cast< QGraphicsSimpleTextItem * >( item );
|
||||
QLightTextItem *textItem = static_cast< QLightTextItem * >( item );
|
||||
|
||||
bool placeHolder = textItem->text().left( 1 ) == "?" && textItem->text().right( 1 ) == "?";
|
||||
|
||||
@@ -100,7 +156,7 @@ void QShapeControllerText::readData( const QString &element,
|
||||
const QString &data,
|
||||
QGraphicsItem *item ) const
|
||||
{
|
||||
QGraphicsSimpleTextItem *textItem = static_cast< QGraphicsSimpleTextItem * >( item );
|
||||
QLightTextItem *textItem = static_cast< QLightTextItem * >( item );
|
||||
|
||||
if( element == "pos" ) {
|
||||
textItem->setPos( attrs.value( "x" ).toString().toDouble(),
|
||||
@@ -117,7 +173,7 @@ void QShapeControllerText::readData( const QString &element,
|
||||
}
|
||||
|
||||
if( element == "color" ) {
|
||||
textItem->setBrush( QColor( data ) );
|
||||
textItem->setColor( QColor( data ) );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,4 +181,9 @@ void QShapeControllerText::readData( const QString &element,
|
||||
textItem->setText( data );
|
||||
return;
|
||||
}
|
||||
|
||||
if( element == "alignment" ) {
|
||||
textItem->setAlignment( Qt::Alignment( data.toInt() ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,22 @@ class QLightTextItem : public QGraphicsSimpleTextItem
|
||||
public:
|
||||
QLightTextItem();
|
||||
|
||||
QString text() const;
|
||||
Qt::Alignment alignment() const;
|
||||
QColor color() const;
|
||||
|
||||
void setText( const QString &txt );
|
||||
void setColor( const QColor &color );
|
||||
void setFont( const QFont &font );
|
||||
void setAlignment( Qt::Alignment align );
|
||||
|
||||
protected:
|
||||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value );
|
||||
|
||||
private:
|
||||
void updateTrans();
|
||||
|
||||
Qt::Alignment m_alignment;
|
||||
};
|
||||
|
||||
class QShapeControllerText : public QShapeController {
|
||||
|
||||
@@ -64,4 +64,10 @@ const char * const itemMimeType = "application/x-qlscribe;item";
|
||||
const char * const DBusServiceName = "@QLSCRIBE_DBUS_MANAGER_SERVICE@";
|
||||
const char * const DBusManagerPath = "@QLSCRIBE_DBUS_MANAGER_PATH@";
|
||||
|
||||
// config keys
|
||||
const char * const cfgDefaultFont = "DefaultTextFont";
|
||||
const char * const cfgEjectAfterFinish = "EjectAfterFinish";
|
||||
const char * const cfgInjectPreview = "InjectPreview";
|
||||
|
||||
|
||||
#endif // QLSCRIBE_H
|
||||
|
||||
+8
-3
@@ -20,7 +20,9 @@ SOURCES += main.cpp \
|
||||
qlighttextitem.cpp \
|
||||
qlightpixmapitem.cpp \
|
||||
qdialogcdproperties.cpp \
|
||||
qconsoleprintprogress.cpp
|
||||
qconsoleprintprogress.cpp \
|
||||
qdialogsettings.cpp \
|
||||
previewinjector.cpp
|
||||
QMAKE_LIBS += -llightscribe
|
||||
HEADERS += mainwindow.h \
|
||||
qlightroundtextitem.h \
|
||||
@@ -36,10 +38,13 @@ HEADERS += mainwindow.h \
|
||||
qlighttextitem.h \
|
||||
qlightpixmapitem.h \
|
||||
qdialogcdproperties.h \
|
||||
qconsoleprintprogress.h
|
||||
qconsoleprintprogress.h \
|
||||
qdialogsettings.h \
|
||||
previewinjector.h
|
||||
FORMS += qdialogtext.ui \
|
||||
qdialogroundtext.ui \
|
||||
qdialogpixmap.ui \
|
||||
qdialogprint.ui \
|
||||
qdialogprogress.ui \
|
||||
qdialogcdproperties.ui
|
||||
qdialogcdproperties.ui \
|
||||
qdialogsettings.ui
|
||||
|
||||
@@ -118,7 +118,13 @@ QString QShapeFactory::name( int type ) const
|
||||
QGraphicsItem *QShapeFactory::create( int type ) const
|
||||
{
|
||||
QShapeController *ctrl = getController( type );
|
||||
return ctrl ? ctrl->create() : 0;
|
||||
if( !ctrl ) return 0;
|
||||
QGraphicsItem *item = ctrl->create();
|
||||
if( item ) {
|
||||
item->setFlag( QGraphicsItem::ItemIsMovable, true );
|
||||
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
bool QShapeFactory::edit( QGraphicsItem *item, QWidget *parent ) const
|
||||
|
||||
Reference in New Issue
Block a user