Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c67c6bc864 | |||
| d32d6ab1e6 | |||
| 06b2f841dc | |||
| b55b148cca | |||
| 086181cd8f | |||
| 51402c10d6 | |||
| c298a43b2f | |||
| 577280f001 | |||
| be3a94cf74 | |||
| 9537ece5fd | |||
| 704cfe0831 | |||
| 72c3e11909 | |||
| 9f94e61ad6 | |||
| ce0b6d2ee4 | |||
| a455e2e8ca | |||
| 0e045cbf01 | |||
| ecdd91d206 | |||
| a112d90ce9 | |||
| dfe6ab4495 | |||
| 10639af10e | |||
| 7b8838c2cd | |||
| 471b00cd56 | |||
| d2ca370801 | |||
| 7d2ba90c7f | |||
| 513f175a17 | |||
| 9d0dedee69 | |||
| d60b1e5026 | |||
| ed318f7a16 | |||
| 6795aead5f | |||
| c101314bec | |||
| ac027069c0 | |||
| 657053175a | |||
| 47f54badc2 | |||
| 56242ad4d1 | |||
| 5bc5aa05be |
@@ -22,6 +22,7 @@ PROJECT( qlscribe )
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
|
||||
|
||||
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 )
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
NEWS - list of user-visible changes between releases of qlscribe
|
||||
|
||||
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
|
||||
|
||||
New in 0.9:
|
||||
Parameter --image added to print label in console mode into image
|
||||
Parameter --file added to process file in format KEY=VALUE
|
||||
Copy/cut/paste added for items in label
|
||||
Menu rearranged and menu items enabled/disabled based on state
|
||||
Application icon added
|
||||
|
||||
New in 0.8:
|
||||
Application is splitted into 2 parts: qlscribe and dbus daemon lscribed
|
||||
qlscribe does not require sticky bit and can be compiled in 64 bit mode if necessary
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
FIND_PATH( LSCRIBE_INCLUDE_DIR lightscribe.h /usr/local/include $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 $ENV{LIGHTSCRIBEDIR}/lib )
|
||||
FIND_LIBRARY( LSCRIBE_LIBRARY lightscribe /usr/local/lib /opt/lightscribe/lib /opt/lightscribe/lib32 $ENV{LIGHTSCRIBEDIR}/lib )
|
||||
|
||||
if( LSCRIBE_INCLUDE_DIR AND LSCRIBE_LIBRARY )
|
||||
SET( LSCRIBE_FOUND TRUE )
|
||||
|
||||
Vendored
+6
-2
@@ -1,5 +1,9 @@
|
||||
qlscribe (0.7-0ubuntu1) unstable; urgency=low
|
||||
|
||||
qlscribe (0.12-0ubuntu1) unstable; urgency=low
|
||||
* Release 0.12 imported
|
||||
* Release 0.11 imported
|
||||
* Release 0.10 imported
|
||||
* Release 0.9 imported
|
||||
* Release 0.8 imported
|
||||
* Initial release
|
||||
|
||||
-- Vyacheslav Kononenko <vyacheslav@kononenko.net> Sun, 15 Feb 2009 21:49:41 -0500
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
/usr/share/dbus-1/services/org.lightscribe.Manager.service
|
||||
Vendored
+2
-2
@@ -7,7 +7,7 @@ Standards-Version: 3.7.3
|
||||
Homepage: http://qlscribe.sourceforge.net/
|
||||
|
||||
Package: qlscribe
|
||||
Architecture: i386
|
||||
Depends: ${shlibs:Depends}, lightscribe, libstdc++5
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, lightscribe
|
||||
Description: Qt based application to print lightScribe discs
|
||||
Qt lightScribe is a GUI application to burn labels on lightScribe capable drives.
|
||||
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ "$1" = "configure" ] ; then
|
||||
/etc/init.d/dbus reload
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ "$1" = "remove" -o "$1" = "upgrade" ] ; then
|
||||
PID=`pidof lscribed`
|
||||
if [ "X$PID" != "X" ] ; then
|
||||
kill $PID
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "remove" ] ; then
|
||||
/etc/init.d/dbus reload
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
Vendored
+5
-4
@@ -14,9 +14,10 @@ configure-stamp:
|
||||
dh_testdir
|
||||
# Add here commands to configure the package.
|
||||
mkdir -p build
|
||||
cd build; cmake .. -DCMAKE_INSTALL_PREFIX=$(CURDIR)/debian/qlscribe/usr
|
||||
touch configure-stamp
|
||||
|
||||
cd build; cmake .. -DCMAKE_INSTALL_PREFIX=$(CURDIR)/debian/qlscribe/usr \
|
||||
-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/services
|
||||
|
||||
build: build-stamp
|
||||
|
||||
@@ -77,7 +78,7 @@ binary-arch: build install
|
||||
# dh_link
|
||||
# dh_strip
|
||||
dh_compress
|
||||
# dh_fixperms #need suid
|
||||
dh_fixperms
|
||||
# dh_perl
|
||||
# dh_makeshlibs
|
||||
dh_installdeb
|
||||
|
||||
Executable
+128
@@ -0,0 +1,128 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="keywords" content="Qt,lightscribe,linux,cddb">
|
||||
|
||||
<meta name="GENERATOR" content="PageBreeze Free HTML Editor (http://www.pagebreeze.com)">
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" >
|
||||
<title>HOWTO print CDDB titles with Qt lightscribe</title>
|
||||
|
||||
<style>
|
||||
<!--
|
||||
h1 { font-family: Arial, sans-serif; font-size: 30px; }
|
||||
h2 { font-family: Arial, sans-serif; font-size: 18px; }
|
||||
|
||||
body,p,b,i,em,dt,dd,dl,sl,caption,th,td,tr,u,blink,select,option,form,div,li { font-family: Arial, sans-serif; font-size: 12px; }
|
||||
-->
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body bgcolor="#ffffff">
|
||||
<p>This document describes how you can create a qlscribe
|
||||
template for printing labels with CDDB information embedded. So let's start.</p>
|
||||
<h4>1 Materials used.</h4>
|
||||
<p>qlscribe version 0.9 or later is used. If you have older
|
||||
version please <a
|
||||
href="https://sourceforge.net/project/showfiles.php?group_id=251217">update</a> </p>
|
||||
<p>I downloaded label images from <a
|
||||
href="http://www.lightscribe.com/ideas/index.aspx?id=2358">lightScribe design
|
||||
center</a></p>
|
||||
<p>Music album "Aphex Twin / Girl Boy EP" I used just as an example, I do not
|
||||
actually have this disc nor copy of it.</p>
|
||||
<p>cddbcmd utility is part of package cddb and on Ubuntu
|
||||
can be downloaded from standard repository:</p>
|
||||
<pre> sudo apt-get install cddb</pre>
|
||||
<h4>2 Create new label and load image</h4>
|
||||
<p>Start qlscribe, hit File -> New Label -> Full. You
|
||||
should see something like this:</p>
|
||||
<p><img hspace="0" src="/dbimage.php?id=207997" border=0></p>
|
||||
<p>Insert image Edit -> Insert -> Image then on
|
||||
dialog click "Load image.." select image "MixTape.jpg" downloaded from <a
|
||||
href="http://www.lightscribe.com/ideas/index.aspx?id=2358">lightScribe design
|
||||
center</a> Here how my label is looking now:</p>
|
||||
<p><img hspace="0" src="/dbimage.php?id=207998" border=0></p>
|
||||
<h4>3 Create text placeholders</h4>
|
||||
<p>Now select Edit -> Insert -> Text and on
|
||||
dialog put text "?DTITLE?". Question marks around name will make this text
|
||||
disapear in qlscribe console mode print. This could be not necessary for disk
|
||||
title as it usually set in CDDB data anyway, but would not harm. We should
|
||||
put question marks on song names, as number of placeholders of title
|
||||
names should be at least not less than songs on the disk. Adjust font size, so
|
||||
when printed it would fit in white area. Now move your text box in the
|
||||
place:</p>
|
||||
<p><img hspace="0" src="/dbimage.php?id=207999" border=0></p>
|
||||
<p>First we would create a placeholder for the first song,
|
||||
adjust font properly and then copy/paste it for others. So Edit -> Insert
|
||||
-> Text and put "?TTITLE0?". Again if we would not put question marks around
|
||||
name it will still work, but unused placeholders will be printed as ugly
|
||||
TTITLEN... strings. Move the text box to the proper position and press Ctrl-C or
|
||||
from menu Edit -> Copy. Press Ctrl-V and move the text box to the new postion
|
||||
for TTITLE1. Right click, then "edit..." and change text to "?TTITLE1?". Repeat
|
||||
until you have enough titles. Your label could look like this one now:</p>
|
||||
<p><img hspace="0" src="/dbimage.php?id=208000" border=0></p>
|
||||
<p>Hit menu File -> Save, save it for example
|
||||
as "tape.qlx" and exit qlscribe.</p>
|
||||
<h4>4 Download CDDB data</h4>
|
||||
<p>If you do not have audio disk in cd-rom you can lookup
|
||||
your disk id from http://www.freedb.org/ or similar. Copy it and run this command:</p>
|
||||
<pre> cddbcmd cddb read rock 4d03a706 > girlboy.txt</pre>
|
||||
<p>In my case disk id is rock/4d03a706.</p>
|
||||
<p>Check that file have proper data, it should look similar
|
||||
to this:</p>
|
||||
|
||||
<pre><code># xmcd CD database file
|
||||
#^M
|
||||
|
||||
# Track frame offsets:
|
||||
# 182
|
||||
# 22097
|
||||
# 40767
|
||||
# 47095
|
||||
# 55912
|
||||
# 62745
|
||||
#^M
|
||||
|
||||
# Disc length: 937 seconds
|
||||
#^M
|
||||
|
||||
# Revision: 0
|
||||
# Processed by: cddbd v1.5.2PL0 Copyright (c) Steve Scherf et al.
|
||||
# Submitted via: IdiotJukebox 1.0 (Emacs 19.34.1)
|
||||
#^M
|
||||
|
||||
DISCID=4d03a706
|
||||
DTITLE=Aphex Twin / Girl Boy EP
|
||||
TTITLE0=Girl Boy (nls mix)
|
||||
TTITLE1=Milk Man
|
||||
TTITLE2=Inkey$
|
||||
TTITLE3=Girl Boy (Snarerushmix)
|
||||
TTITLE4=Beetles
|
||||
TTITLE5=Girl Boy (Redruthmix)
|
||||
EXTD=
|
||||
EXTT0=
|
||||
EXTT1=
|
||||
EXTT2=
|
||||
EXTT3=
|
||||
EXTT4=
|
||||
EXTT5=
|
||||
PLAYORDER=</code></pre>
|
||||
<h4>5 Test you template</h4>
|
||||
<p>Now we can test how our created at step 2-3 template works with the data. Run qlscribe
|
||||
in console mode to print label as an image:</p>
|
||||
<pre> qlscribe --image girlboy.jpg --file girlboy.txt tape.qlx</pre>
|
||||
<p>If everything fine you should now see file girlboy.jpg
|
||||
in the current directory. Here is what I got for mine:</p>
|
||||
<p><img src="/dbimage.php?id=208002"></p>
|
||||
<h4>6 Print label</h4>
|
||||
<p>Now if you are happy with the result at step 5 you can print label
|
||||
directly:</p>
|
||||
<pre> qlscribe --print --file girlboy.txt tape.qlx</pre>
|
||||
<p>Enjoy!</p>
|
||||
<p>Please send comments, suggestions or noticed errors
|
||||
directly to <a
|
||||
href="mailto:vyacheslav@kononenko.net">mailto:vyacheslav@kononenko.net</a> or
|
||||
visit <a
|
||||
href="http://qlscribe.sourceforge.net">http://qlscribe.sourceforge.net</a> and create
|
||||
an item in the Bug tracker.</p>
|
||||
</body>
|
||||
</html>
|
||||
+19
-2
@@ -34,6 +34,24 @@ IF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_COMPILER_IS_GNUCXX )
|
||||
SET( CMAKE_EXE_LINKER_FLAGS "-m32 -pthread ${CMAKE_EXE_LINKER_FLAGS}" )
|
||||
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})
|
||||
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})
|
||||
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 )
|
||||
|
||||
@@ -43,8 +61,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} )
|
||||
|
||||
ADD_EXECUTABLE( lscribed ${LSCRIBED_SRCS} )
|
||||
|
||||
TARGET_LINK_LIBRARIES( lscribed ${LSCRIBE_LIBRARIES} ${DBUS_LIBRARIES} )
|
||||
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 )
|
||||
|
||||
|
||||
@@ -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\">\
|
||||
|
||||
+54
-39
@@ -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;
|
||||
}
|
||||
|
||||
@@ -278,15 +283,49 @@ void Drive::routine()
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "lscribed.h"
|
||||
#include "dbuscpp.h"
|
||||
@@ -52,6 +53,7 @@ void onAlarm( int )
|
||||
lastActivity = curr;
|
||||
return;
|
||||
}
|
||||
syslog( LOG_INFO, "terminating due to inactivity timeout" );
|
||||
terminateOnTimeout = true;
|
||||
}
|
||||
|
||||
@@ -65,6 +67,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 +105,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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
[D-BUS Service]
|
||||
Name=@QLSCRIBE_DBUS_MANAGER_SERVICE@
|
||||
Exec=@CMAKE_INSTALL_PREFIX@/sbin/lscribed
|
||||
Exec=@FINAL_INSTALL_PREFIX@/sbin/lscribed
|
||||
User=root
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>qlscribe64.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
+10
-6
@@ -24,14 +24,15 @@ SET( QT_USE_QTDBUS 1 )
|
||||
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 )
|
||||
|
||||
SET( QLSCRIBE_UIS qdialogtext.ui qdialogroundtext.ui qdialogpixmap.ui
|
||||
qdialogprint.ui qdialogprogress.ui qdialogcdproperties.ui)
|
||||
qdialogprint.ui qdialogprogress.ui qdialogcdproperties.ui qdialogsettings.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)
|
||||
qdialogcdproperties.h qconsoleprintprogress.h qdialogsettings.h )
|
||||
|
||||
ADD_DEFINITIONS( -Wall )
|
||||
|
||||
@@ -43,6 +44,8 @@ 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)
|
||||
@@ -65,11 +68,12 @@ 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_UI_HDRS} ${QLSCRIBE_DBUS_SRCS} )
|
||||
ADD_EXECUTABLE( qlscribe ${QLSCRIBE_SRCS} ${QLSCRIBE_MOC_SRCS}
|
||||
${QLSCRIBE_RCC_SRCS} ${QLSCRIBE_UI_HDRS}
|
||||
${QLSCRIBE_DBUS_SRCS} )
|
||||
|
||||
TARGET_LINK_LIBRARIES( qlscribe ${QT_LIBRARIES} )
|
||||
|
||||
INSTALL( TARGETS qlscribe
|
||||
DESTINATION bin
|
||||
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETUID )
|
||||
DESTINATION bin )
|
||||
|
||||
|
||||
+2
-2
@@ -47,13 +47,13 @@
|
||||
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="const PrintParameters &"/>
|
||||
<annotation name="com.trolltech.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"/>
|
||||
<arg name="params" type="(iiiii)" direction="in"/>
|
||||
<arg name="image" type="ay" direction="in"/>
|
||||
</method>
|
||||
<method name="abort">
|
||||
|
||||
+85
-1
@@ -21,6 +21,10 @@
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QMap>
|
||||
#include <QPainter>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QIcon>
|
||||
#include "mainwindow.h"
|
||||
#include "qcdscene.h"
|
||||
#include "qlightscribe.h"
|
||||
@@ -41,21 +45,31 @@ void usage()
|
||||
<< "\tParameters:\n"
|
||||
<< "\t\t--help | -h - print this message\n"
|
||||
<< "\t\t--print | -p - switch to print mode\n"
|
||||
<< "\t\t--image | -i image - print to this image\n"
|
||||
<< "\t\t--size | -s size - image size, 400 by default\n"
|
||||
<< "\t\t--drive | -d NUMBER - use this drive, starts from 0, 0 is default\n"
|
||||
<< "\t\t--replace | -r KEY=VALUE - replace text from KEY to VALUE\n"
|
||||
<< "\t\t--file | -f filename - read replacements in format KEY=VALUE from file\n"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
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" ) );
|
||||
|
||||
bool doPrint = false;
|
||||
QStringList arguments = app.arguments();
|
||||
QStringList files;
|
||||
QCDScene::QString2String replacements;
|
||||
int driveIndex = 0;
|
||||
int imageSize = 400;
|
||||
QString imageName;
|
||||
QString replacementsFile;
|
||||
PrintParameters params;
|
||||
bool labelModeOverriden = false;
|
||||
|
||||
@@ -85,6 +99,29 @@ int main( int argc, char **argv )
|
||||
replacements[ param.left( pos ) ] = param.right( param.size() - pos - 1 );
|
||||
continue;
|
||||
}
|
||||
if( arg == "--file" || arg == "-f" ) {
|
||||
if( i == arguments.size() - 1 ) {
|
||||
std::cerr << "Error: arg#" << i
|
||||
<< " argument expected for \"" << arg << "\" not enough parameters" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
QFile data( arguments[ ++i ] );
|
||||
if( !data.open( QIODevice::ReadOnly ) ) {
|
||||
std::cerr << "cannot open file \"" << arguments[ i ] << "\" for reading" << std::endl;
|
||||
return 2;
|
||||
}
|
||||
QTextStream stream( &data );
|
||||
while( true ) {
|
||||
QString line = stream.readLine();
|
||||
if( line.isNull() )
|
||||
break;
|
||||
int pos = line.indexOf( '=' );
|
||||
if( pos == -1 )
|
||||
continue;
|
||||
replacements[ line.left( pos ) ] = line.right( line.size() - pos - 1 );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if( arg == "--drive" || arg == "-d" ) {
|
||||
if( i == arguments.size() - 1 ) {
|
||||
std::cerr << "Error: arg#" << i
|
||||
@@ -94,6 +131,30 @@ int main( int argc, char **argv )
|
||||
QString param = arguments[ ++i ];
|
||||
driveIndex = param.toInt();
|
||||
}
|
||||
if( arg == "--image" || arg == "-i" ) {
|
||||
if( i == arguments.size() - 1 ) {
|
||||
std::cerr << "Error: arg#" << i
|
||||
<< " argument expected for \"" << arg << "\" not enough parameters" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
doPrint = true;
|
||||
imageName = arguments[ ++i ];
|
||||
continue;
|
||||
}
|
||||
if( arg == "--size" || arg == "-s" ) {
|
||||
if( i == arguments.size() - 1 ) {
|
||||
std::cerr << "Error: arg#" << i
|
||||
<< " argument expected for \"" << arg << "\" not enough parameters" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
imageSize = arguments[ ++i ].toInt();
|
||||
if( imageSize <=0 ) {
|
||||
std::cerr << "Error: arg#" << i
|
||||
<< " invalid argument for image size, value > 0 is expected" << std::endl;
|
||||
return 2;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if( arg[0] != '-' )
|
||||
files.append( arg );
|
||||
}
|
||||
@@ -120,10 +181,32 @@ int main( int argc, char **argv )
|
||||
if( !labelModeOverriden )
|
||||
params.m_labelMode = scene.labelMode();
|
||||
|
||||
if( !imageName.isEmpty() ) {
|
||||
QImage image( imageSize, imageSize, QImage::Format_RGB32 );
|
||||
image.fill( 0xFFFFFFFF );
|
||||
{
|
||||
QPainter painter( &image );
|
||||
|
||||
/*int innerSize = int( imageSize / 120.0 * 24.7 );
|
||||
int center = imageSize / 2;
|
||||
painter.setBrush( Qt::lightGray );
|
||||
painter.drawEllipse( 0, 0, imageSize, imageSize );
|
||||
painter.setBrush( Qt::white );
|
||||
painter.drawEllipse( center - innerSize, center - innerSize,
|
||||
innerSize * 2, innerSize * 2 );*/
|
||||
scene.render( &painter, image.rect() );
|
||||
}
|
||||
std::cerr << "Printing to \"" << imageName << "\" as "
|
||||
<< imageSize << "x" << imageSize <<" image"
|
||||
<< std::endl;
|
||||
image.save( imageName );
|
||||
return 0;
|
||||
}
|
||||
QLightScribe *scribe = QLightScribe::instance();
|
||||
QList< QLightDrive * > drives = scribe->getDrives();
|
||||
if( driveIndex >= drives.size() ) {
|
||||
std::cerr << "Error: drive " << driveIndex << " specified, but there are only " << drives.size() << " drives" << std::endl;
|
||||
std::cerr << "Error: drive " << driveIndex
|
||||
<< " specified, but there are only " << drives.size() << " drives" << std::endl;
|
||||
return 6;
|
||||
}
|
||||
std::cout << "Printing label " << files.front() << std::endl;
|
||||
@@ -132,6 +215,7 @@ int main( int argc, char **argv )
|
||||
QConsolePrintProgress progress( drive );
|
||||
drive->print( params, &scene );
|
||||
rez = app.exec();
|
||||
|
||||
} else {
|
||||
MainWindow mwindow( true );
|
||||
mwindow.show();
|
||||
|
||||
+169
-26
@@ -27,6 +27,7 @@
|
||||
#include "qdialogprint.h"
|
||||
#include "qdialogprogress.h"
|
||||
#include "qdialogcdproperties.h"
|
||||
#include "qdialogsettings.h"
|
||||
|
||||
#include <QMenuBar>
|
||||
#include <QStatusBar>
|
||||
@@ -37,6 +38,10 @@
|
||||
#include <QFileDialog>
|
||||
#include <QLabel>
|
||||
#include <QCloseEvent>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QSettings>
|
||||
#include <QImageReader>
|
||||
|
||||
|
||||
MainWindow::MainWindow( bool enablePrint )
|
||||
@@ -49,7 +54,7 @@ MainWindow::MainWindow( bool enablePrint )
|
||||
setWindowTitle( tr( "Qt lightScribe", "Main window title \"Qt lightScribe\"" ) );
|
||||
setCentralWidget( m_mdiArea );
|
||||
|
||||
m_menuFile = menuBar()->addMenu( tr( "File", "Menu item \"File\"" ) );
|
||||
m_menuFile = menuBar()->addMenu( tr( "File", "Menu item \"File\"" ) );
|
||||
|
||||
{
|
||||
QMenu *newSubMenu = m_menuFile->addMenu( tr( "New label", "Menu item \"New lable\"" ) );
|
||||
@@ -72,41 +77,77 @@ MainWindow::MainWindow( bool enablePrint )
|
||||
|
||||
m_menuFile->addAction( tr( "Open...", "Menu item \"Open\"" ),
|
||||
this,
|
||||
SLOT(onMenuOpen()) );
|
||||
SLOT(onMenuOpen()),
|
||||
QKeySequence( Qt::CTRL + Qt::Key_O ) );
|
||||
|
||||
m_menuFile->addAction( tr( "Save", "Menu item \"Save\"" ),
|
||||
this,
|
||||
SLOT(onMenuSave()) );
|
||||
m_actionSave = m_menuFile->addAction( tr( "Save", "Menu item \"Save\"" ),
|
||||
this,
|
||||
SLOT(onMenuSave()),
|
||||
QKeySequence( Qt::CTRL + Qt::Key_S ) );
|
||||
|
||||
|
||||
m_menuFile->addAction( tr( "Save as...", "Menu item \"Save as\"" ),
|
||||
this,
|
||||
SLOT(onMenuSaveAs()) );
|
||||
m_actionSaveAs = m_menuFile->addAction( tr( "Save as...", "Menu item \"Save as\"" ),
|
||||
this,
|
||||
SLOT(onMenuSaveAs()) );
|
||||
|
||||
m_menuFile->addSeparator();
|
||||
|
||||
m_menuFile->addAction( tr( "Label properties...", "Menu item \"Label propeties...\"" ),
|
||||
this,
|
||||
SLOT(onMenuProperties()) );
|
||||
m_actionLabelProperties =
|
||||
m_menuFile->addAction( tr( "Label properties...", "Menu item \"Label propeties...\"" ),
|
||||
this,
|
||||
SLOT(onMenuProperties()) );
|
||||
|
||||
m_menuFile->addSeparator();
|
||||
|
||||
m_menuFile->addAction( tr( "Print preview...", "Menu item \"Print preview\"" ),
|
||||
this,
|
||||
SLOT(onMenuPrintPreview()) );
|
||||
m_actionPrintPreview =
|
||||
m_menuFile->addAction( tr( "Print preview...", "Menu item \"Print preview\"" ),
|
||||
this,
|
||||
SLOT(onMenuPrintPreview()) );
|
||||
|
||||
QAction *printAction =
|
||||
m_actionPrint =
|
||||
m_menuFile->addAction( tr( "Print...", "Menu item \"Print\"" ),
|
||||
this,
|
||||
SLOT(onMenuPrint()) );
|
||||
if( !enablePrint )
|
||||
printAction->setEnabled( false );
|
||||
|
||||
m_menuFile->addAction( tr( "Exit", "Menu item \"Exit\"" ),
|
||||
this,
|
||||
SLOT(close()));
|
||||
SLOT(close()),
|
||||
QKeySequence( Qt::CTRL + Qt::Key_Q ) );
|
||||
|
||||
m_menuInsert = menuBar()->addMenu( tr( "Insert", "Menu item \"Insert\"" ) );
|
||||
|
||||
m_menuEdit = menuBar()->addMenu( tr( "Edit", "Menu item \"Edit\"" ) );
|
||||
|
||||
m_actionUndo = m_menuEdit->addAction( tr( "Undo", "Menu item \"Undo\"" ),
|
||||
this,
|
||||
SLOT(onMenuUndo()),
|
||||
QKeySequence( Qt::CTRL + Qt::Key_Z ) );
|
||||
|
||||
m_actionRedo = m_menuEdit->addAction( tr( "Redo", "Menu item \"Redo\"" ),
|
||||
this,
|
||||
SLOT(onMenuRedo()),
|
||||
QKeySequence( Qt::CTRL + Qt::Key_R ) );
|
||||
|
||||
m_actionCopy = m_menuEdit->addAction( tr( "Copy", "Menu item \"Copy\"" ),
|
||||
this,
|
||||
SLOT(onMenuCopy()),
|
||||
QKeySequence( Qt::CTRL + Qt::Key_C ) );
|
||||
|
||||
m_actionCut = m_menuEdit->addAction( tr( "Cut", "Menu item \"Cut\"" ),
|
||||
this,
|
||||
SLOT(onMenuCut()),
|
||||
QKeySequence( Qt::CTRL + Qt::Key_X ) );
|
||||
|
||||
m_actionPaste = m_menuEdit->addAction( tr( "Paste", "Menu item \"Paste\"" ),
|
||||
this,
|
||||
SLOT(onMenuPaste()),
|
||||
QKeySequence( Qt::CTRL + Qt::Key_V ) );
|
||||
|
||||
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\"" ) );
|
||||
|
||||
@@ -127,6 +168,20 @@ MainWindow::MainWindow( bool enablePrint )
|
||||
connect( action, SIGNAL(triggered()), m_insertMapper, SLOT(map()) );
|
||||
}
|
||||
connect( m_insertMapper, SIGNAL(mapped(int)), this, SLOT(onMenuInsert(int)) );
|
||||
|
||||
connect( QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)),
|
||||
this, SLOT(updateMenu()) );
|
||||
connect( m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),
|
||||
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()
|
||||
@@ -144,6 +199,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();
|
||||
@@ -209,6 +266,13 @@ bool MainWindow::saveScene( QCDScene *scene )
|
||||
return;
|
||||
}
|
||||
}
|
||||
QSettings settings;
|
||||
|
||||
settings.beginGroup( "MainWindow" );
|
||||
settings.setValue( "size", size());
|
||||
settings.setValue( "pos", pos());
|
||||
settings.endGroup();
|
||||
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@@ -216,9 +280,11 @@ void MainWindow::onMenuNewLabel( int mode )
|
||||
{
|
||||
QCDView *newView = new QCDView;
|
||||
QCDScene *scene = new QCDScene( newView );
|
||||
scene->setLabelMode( LabelMode( mode ) );
|
||||
scene->start( LabelMode( mode ) );
|
||||
newView->setScene( scene );
|
||||
scene->setName();
|
||||
connect( scene, SIGNAL(selectionChanged()), this, SLOT(updateMenu()) );
|
||||
connect( scene, SIGNAL(changed()), this, SLOT(updateMenu()) );
|
||||
|
||||
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( newView );
|
||||
subWindow->show();
|
||||
@@ -257,18 +323,23 @@ void MainWindow::onMenuInsert( int id )
|
||||
return;
|
||||
}
|
||||
|
||||
item->setFlag( QGraphicsItem::ItemIsMovable, true );
|
||||
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
|
||||
cdscene->addItem( item );
|
||||
cdscene->setChanged();
|
||||
}
|
||||
|
||||
void MainWindow::onMenuOpen()
|
||||
{
|
||||
QString filter( tr("qlscribe document (*.qlx)\nImages ( ") );
|
||||
QList<QByteArray> list = QImageReader::supportedImageFormats();
|
||||
foreach( QByteArray arr, list ) {
|
||||
filter += QString( "*." ) + arr.data() + " ";
|
||||
}
|
||||
filter += tr( ")\nAll Files (*)" );
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName( this,
|
||||
tr( "Open:" ),
|
||||
QString(),
|
||||
tr("qlscribe document (*.qlx)") );
|
||||
filter );
|
||||
|
||||
if( fileName.isNull() )
|
||||
return;
|
||||
@@ -281,6 +352,8 @@ void MainWindow::onMenuOpen()
|
||||
delete newView;
|
||||
return;
|
||||
}
|
||||
connect( scene, SIGNAL(selectionChanged()), this, SLOT(updateMenu()) );
|
||||
connect( scene, SIGNAL(changed()), this, SLOT(updateMenu()) );
|
||||
|
||||
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( newView );
|
||||
subWindow->show();
|
||||
@@ -337,8 +410,8 @@ void MainWindow::onMenuPrint()
|
||||
{
|
||||
QCDScene *cdscene = getScene( m_mdiArea );
|
||||
if( !cdscene )
|
||||
|
||||
return;
|
||||
|
||||
try {
|
||||
QDialogProgress::exec( this, cdscene );
|
||||
}
|
||||
@@ -347,12 +420,47 @@ void MainWindow::onMenuPrint()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onMenuUndo()
|
||||
{
|
||||
QCDScene *scene = getScene( m_mdiArea );
|
||||
if( scene )
|
||||
scene->undo();
|
||||
}
|
||||
|
||||
void MainWindow::onMenuRedo()
|
||||
{
|
||||
QCDScene *scene = getScene( m_mdiArea );
|
||||
if( scene )
|
||||
scene->redo();
|
||||
}
|
||||
|
||||
void MainWindow::onMenuCopy()
|
||||
{
|
||||
QCDScene *scene = getScene( m_mdiArea );
|
||||
if( scene )
|
||||
scene->putItemToClipboard( false );
|
||||
}
|
||||
|
||||
void MainWindow::onMenuCut()
|
||||
{
|
||||
QCDScene *scene = getScene( m_mdiArea );
|
||||
if( scene )
|
||||
scene->putItemToClipboard( true );
|
||||
}
|
||||
|
||||
void MainWindow::onMenuPaste()
|
||||
{
|
||||
QCDScene *scene = getScene( m_mdiArea );
|
||||
if( scene )
|
||||
scene->getItemFromClipboard();
|
||||
}
|
||||
|
||||
void MainWindow::onMenuAbout()
|
||||
{
|
||||
QMessageBox::about( this,
|
||||
tr( "About" ),
|
||||
tr( "<h3>qlscribe - Qt lisghtScribe</h3>"
|
||||
"<p>release 0.8 $Revision$</p>"
|
||||
"<p>release 0.12 $Revision$</p>"
|
||||
"<p>visit project at home page "
|
||||
"<a href=\"http://qlscribe.sourceforge.net/\">qlscribe.sourceforge.net</a></p>" ) );
|
||||
}
|
||||
@@ -361,3 +469,38 @@ void MainWindow::onMenuQtAbout()
|
||||
{
|
||||
QMessageBox::aboutQt( this );
|
||||
}
|
||||
|
||||
void MainWindow::onMenuSettings()
|
||||
{
|
||||
QDialogSettings::exec( this );
|
||||
}
|
||||
|
||||
void MainWindow::updateMenu()
|
||||
{
|
||||
QCDScene *scene = getScene( m_mdiArea );
|
||||
|
||||
m_actionSave->setEnabled( scene );
|
||||
m_actionSaveAs->setEnabled( scene );
|
||||
m_actionLabelProperties->setEnabled( scene );
|
||||
m_actionPrint->setEnabled( scene );
|
||||
m_actionPrintPreview->setEnabled( scene );
|
||||
m_menuInsert->setEnabled( scene );
|
||||
|
||||
if( !scene ) {
|
||||
m_actionUndo->setEnabled( false );
|
||||
m_actionRedo->setEnabled( false );
|
||||
m_actionCopy->setEnabled( false );
|
||||
m_actionCut->setEnabled( false );
|
||||
m_actionPaste->setEnabled( false );
|
||||
} else {
|
||||
m_actionUndo->setEnabled( scene->canUndo() );
|
||||
m_actionRedo->setEnabled( scene->canRedo() );
|
||||
|
||||
const QMimeData *mdata = QApplication::clipboard()->mimeData();
|
||||
m_actionPaste->setEnabled( mdata && mdata->hasFormat( itemMimeType ) );
|
||||
|
||||
bool selected = scene->selectedItems().count();
|
||||
m_actionCopy->setEnabled( selected );
|
||||
m_actionCut->setEnabled( selected );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,19 +48,40 @@ private slots:
|
||||
void onMenuProperties();
|
||||
void onMenuPrintPreview();
|
||||
void onMenuPrint();
|
||||
void onMenuUndo();
|
||||
void onMenuRedo();
|
||||
void onMenuCopy();
|
||||
void onMenuCut();
|
||||
void onMenuPaste();
|
||||
void onMenuSettings();
|
||||
void onMenuInsert( int id );
|
||||
void onMenuAbout();
|
||||
void onMenuQtAbout();
|
||||
|
||||
void updateMenu();
|
||||
|
||||
private:
|
||||
bool saveSceneAs( QCDScene *scene );
|
||||
|
||||
QMdiArea *m_mdiArea;
|
||||
|
||||
QMenu *m_menuFile;
|
||||
QMenu *m_menuEdit;
|
||||
QMenu *m_menuInsert;
|
||||
QMenu *m_menuHelp;
|
||||
|
||||
QAction *m_actionSave;
|
||||
QAction *m_actionSaveAs;
|
||||
QAction *m_actionLabelProperties;
|
||||
QAction *m_actionPrint;
|
||||
QAction *m_actionPrintPreview;
|
||||
QAction *m_actionUndo;
|
||||
QAction *m_actionRedo;
|
||||
QAction *m_actionCopy;
|
||||
QAction *m_actionCut;
|
||||
QAction *m_actionPaste;
|
||||
QAction *m_actionSettings;
|
||||
|
||||
QSignalMapper *m_insertMapper;
|
||||
QSignalMapper *m_newLabelMapper;
|
||||
};
|
||||
|
||||
+225
-39
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "qcdscene.h"
|
||||
#include "qshapefactory.h"
|
||||
#include "qlightpixmapitem.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
@@ -31,15 +32,22 @@
|
||||
#include <QMessageBox>
|
||||
#include <QGraphicsView>
|
||||
#include <QRegExp>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QMimeData>
|
||||
#include <QRegExp>
|
||||
|
||||
QCDScene::QCDScene( QObject * parent )
|
||||
: QGraphicsScene( parent ),
|
||||
m_index( 0 ),
|
||||
m_saved( true ),
|
||||
m_itemMoved( false ),
|
||||
m_labelMode( modeFull ),
|
||||
m_cdColor( Qt::white )
|
||||
m_cdColor( Qt::white ),
|
||||
m_undoPosition( m_undoBuffer.end() )
|
||||
{
|
||||
setSceneRect( -60.0, -60.0, 60.0 * 2, 60.0 * 2 );
|
||||
|
||||
}
|
||||
|
||||
//#include <iostream>
|
||||
@@ -60,35 +68,71 @@ void QCDScene::replace( const QString2String &strings )
|
||||
f->second->replace( item, st.key(), st.value() );
|
||||
}
|
||||
}
|
||||
foreach(QGraphicsItem *item, list ) {
|
||||
QShapeFactory::iterator f = sfactory.find( item->type() );
|
||||
if( f != sfactory.end() )
|
||||
f->second->replace( item, "", "" ); // to clean placeholders
|
||||
}
|
||||
}
|
||||
|
||||
void QCDScene::start( LabelMode mode )
|
||||
{
|
||||
setLabelMode( mode );
|
||||
pushUndo();
|
||||
}
|
||||
|
||||
bool QCDScene::load( const QString &fileName, QString *errMessage )
|
||||
{
|
||||
QFile file( fileName );
|
||||
if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
|
||||
if( QRegExp( ".*.\\.qlx$", Qt::CaseInsensitive ).exactMatch( fileName ) ) {
|
||||
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;
|
||||
}
|
||||
QShapeFactory &sfactory = QShapeFactory::instance();
|
||||
QLightPixmapItem *item =
|
||||
static_cast<QLightPixmapItem *>(sfactory.create( QShapeControllerPixmap::Type ) );
|
||||
addItem( item );
|
||||
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 open file for reading";
|
||||
*errMessage = "cannot load image";
|
||||
else
|
||||
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot open file for reading\n" ) + fileName );
|
||||
return false;
|
||||
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot load image " ) +
|
||||
fileName + "\n" );
|
||||
}
|
||||
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();
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool QCDScene::save()
|
||||
{
|
||||
QFile file( m_fileName );
|
||||
@@ -135,10 +179,32 @@ void QCDScene::setName()
|
||||
updateTitles();
|
||||
}
|
||||
|
||||
void QCDScene::setChanged()
|
||||
void QCDScene::setChanged( bool undo )
|
||||
{
|
||||
m_saved = false;
|
||||
updateTitles();
|
||||
|
||||
if( undo && m_undoPosition != m_undoBuffer.end() )
|
||||
pushUndo();
|
||||
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void QCDScene::pushUndo()
|
||||
{
|
||||
if( canRedo() ) {
|
||||
UndoBuffer::iterator pos = m_undoBuffer.begin() + 1 + ( m_undoPosition - m_undoBuffer.begin() );
|
||||
m_undoBuffer.erase( pos, m_undoBuffer.end() );
|
||||
}
|
||||
|
||||
QString data;
|
||||
QXmlStreamWriter writer( &data );
|
||||
write( writer );
|
||||
m_undoBuffer.push_back( data );
|
||||
if( m_undoBuffer.size() > 20 )
|
||||
m_undoBuffer.pop_front();
|
||||
|
||||
m_undoPosition = m_undoBuffer.end() - 1;
|
||||
}
|
||||
|
||||
void QCDScene::updateTitles() const
|
||||
@@ -195,12 +261,34 @@ void QCDScene::write( QXmlStreamWriter &writer )
|
||||
writer.writeEndDocument();
|
||||
}
|
||||
|
||||
|
||||
bool QCDScene::readItem( QXmlStreamReader &reader )
|
||||
{
|
||||
QShapeFactory &sfactory = QShapeFactory::instance();
|
||||
|
||||
QString type = reader.attributes().value( "type" ).toString();
|
||||
QShapeFactory::iterator f = sfactory.find( type );
|
||||
if( f == sfactory.end() ) {
|
||||
QMessageBox::warning( 0,
|
||||
"Warning",
|
||||
QString( "QCDScene: unknown item type \"" )
|
||||
+ type + "\"" );
|
||||
return false;
|
||||
}
|
||||
QGraphicsItem *item = f->second->read( reader );
|
||||
if( item ) {
|
||||
item->setFlag( QGraphicsItem::ItemIsMovable, true );
|
||||
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
|
||||
addItem( item );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QCDScene::read( QXmlStreamReader &reader )
|
||||
{
|
||||
bool gotScene = false;
|
||||
|
||||
QShapeFactory &sfactory = QShapeFactory::instance();
|
||||
|
||||
while( !reader.atEnd() ) {
|
||||
QXmlStreamReader::TokenType ttype = reader.readNext();
|
||||
if( ttype != QXmlStreamReader::StartElement )
|
||||
@@ -220,27 +308,70 @@ void QCDScene::read( QXmlStreamReader &reader )
|
||||
}
|
||||
|
||||
if( elementName == "item" ) {
|
||||
QString type = reader.attributes().value( "type" ).toString();
|
||||
QShapeFactory::iterator f = sfactory.find( type );
|
||||
if( f == sfactory.end() ) {
|
||||
QMessageBox::warning( 0,
|
||||
"Warning",
|
||||
QString( "QCDScene: unknown item type \"" )
|
||||
+ type + "\"" );
|
||||
continue;
|
||||
}
|
||||
QGraphicsItem *item = f->second->read( reader );
|
||||
if( item ) {
|
||||
item->setFlag( QGraphicsItem::ItemIsMovable, true );
|
||||
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
|
||||
addItem( item );
|
||||
}
|
||||
readItem( reader );
|
||||
} else
|
||||
throw QString( "QCDScene: unknown element \"" ) + elementName + "\"";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QCDScene::putItemToClipboard( bool move )
|
||||
{
|
||||
QList<QGraphicsItem *> list = selectedItems();
|
||||
if( list.empty() )
|
||||
return;
|
||||
QGraphicsItem *item = list.front();
|
||||
|
||||
QShapeFactory &sfactory = QShapeFactory::instance();
|
||||
QShapeFactory::iterator f = sfactory.find( item->type() );
|
||||
if( f == sfactory.end() ) {
|
||||
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot find controller for type %n", 0, item->type() ) );
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray array;
|
||||
QXmlStreamWriter writer( &array );
|
||||
|
||||
f->second->write( writer, item );
|
||||
QMimeData *mdata = new QMimeData;
|
||||
mdata->setData( itemMimeType, array );
|
||||
mdata->setText( array.data() );
|
||||
|
||||
QApplication::clipboard()->setMimeData( mdata );
|
||||
|
||||
if( move ) {
|
||||
removeItem( item );
|
||||
delete item;
|
||||
setChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void QCDScene::getItemFromClipboard()
|
||||
{
|
||||
const QMimeData *mdata = QApplication::clipboard()->mimeData();
|
||||
if( !mdata )
|
||||
return;
|
||||
|
||||
if( !mdata->hasFormat( itemMimeType ) )
|
||||
return;
|
||||
|
||||
QByteArray array = mdata->data( itemMimeType );
|
||||
QXmlStreamReader reader( array );
|
||||
|
||||
while( !reader.atEnd() ) {
|
||||
QXmlStreamReader::TokenType ttype = reader.readNext();
|
||||
if( ttype != QXmlStreamReader::StartElement )
|
||||
continue;
|
||||
|
||||
QString elementName = reader.name().toString();
|
||||
|
||||
if( elementName == "item" ) {
|
||||
if( readItem( reader ) )
|
||||
setChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QCDScene::contextMenuEvent( QGraphicsSceneContextMenuEvent *mouseEvent )
|
||||
{
|
||||
QGraphicsItem *item = itemAt( mouseEvent->scenePos() );
|
||||
@@ -249,12 +380,24 @@ void QCDScene::contextMenuEvent( QGraphicsSceneContextMenuEvent *mouseEvent )
|
||||
item->setSelected( true );
|
||||
QMenu menu;
|
||||
menu.addAction( tr( "edit..." ), this, SLOT( onMenuEdit() ) );
|
||||
menu.addAction( tr( "copy" ), this, SLOT( onMenuCopy() ) );
|
||||
menu.addAction( tr( "cut" ), this, SLOT( onMenuCut() ) );
|
||||
menu.addAction( tr( "bring to Front" ), this, SLOT( onMenuToFront() ) );
|
||||
menu.addAction( tr( "send to Back" ), this, SLOT( onMenuToBack() ) );
|
||||
menu.addAction( tr( "delete" ), this, SLOT( onMenuDelete() ) );
|
||||
menu.exec( mouseEvent->screenPos() );
|
||||
}
|
||||
|
||||
void QCDScene::mouseReleaseEvent ( QGraphicsSceneMouseEvent *mouseEvent )
|
||||
{
|
||||
if( m_itemMoved ) {
|
||||
setChanged();
|
||||
m_itemMoved = false;
|
||||
}
|
||||
|
||||
QGraphicsScene::mouseReleaseEvent( mouseEvent );
|
||||
}
|
||||
|
||||
void QCDScene::onMenuEdit()
|
||||
{
|
||||
QList<QGraphicsItem *> list = selectedItems();
|
||||
@@ -264,6 +407,16 @@ void QCDScene::onMenuEdit()
|
||||
QShapeFactory::instance().edit( item, 0 );
|
||||
}
|
||||
|
||||
void QCDScene::onMenuCopy()
|
||||
{
|
||||
putItemToClipboard( false );
|
||||
}
|
||||
|
||||
void QCDScene::onMenuCut()
|
||||
{
|
||||
putItemToClipboard( true );
|
||||
}
|
||||
|
||||
void QCDScene::onMenuToFront()
|
||||
{
|
||||
sendItemTo( true );
|
||||
@@ -302,4 +455,37 @@ void QCDScene::sendItemTo( bool front )
|
||||
zValue = item->zValue() - 0.1;
|
||||
}
|
||||
selectedItem->setZValue( zValue );
|
||||
setChanged();
|
||||
}
|
||||
|
||||
bool QCDScene::canUndo() const
|
||||
{
|
||||
return m_undoPosition - m_undoBuffer.begin() > 0;
|
||||
}
|
||||
|
||||
bool QCDScene::canRedo() const
|
||||
{
|
||||
return m_undoBuffer.end() - m_undoPosition > 1;
|
||||
}
|
||||
|
||||
void QCDScene::unredo( bool undo )
|
||||
{
|
||||
if( undo ) {
|
||||
if( !canUndo() )
|
||||
return;
|
||||
--m_undoPosition;
|
||||
} else {
|
||||
if( !canRedo() )
|
||||
return;
|
||||
++m_undoPosition;
|
||||
}
|
||||
|
||||
try {
|
||||
clear();
|
||||
QXmlStreamReader reader( *m_undoPosition );
|
||||
read( reader );
|
||||
}
|
||||
catch(...) {
|
||||
}
|
||||
setChanged( false );
|
||||
}
|
||||
|
||||
+30
-7
@@ -44,39 +44,62 @@ public:
|
||||
|
||||
bool isSaved() const { return m_saved; }
|
||||
bool isUnnamed() const { return m_fileName.isEmpty(); }
|
||||
bool canUndo() const;
|
||||
bool canRedo() const;
|
||||
|
||||
void setChanged();
|
||||
void itemMoved() { m_itemMoved = true; }
|
||||
void setChanged( bool undo = true );
|
||||
void setName();
|
||||
void start( LabelMode mode );
|
||||
bool load( const QString &fileName, QString *errMessage = 0 );
|
||||
void replace( const QString2String &strings );
|
||||
bool save();
|
||||
bool saveAs( const QString &fileName );
|
||||
void undo() { unredo( true ); }
|
||||
void redo() { unredo( false ); }
|
||||
|
||||
void putItemToClipboard( bool move );
|
||||
void getItemFromClipboard();
|
||||
|
||||
void updateTitles() const;
|
||||
void redrawViews() const;
|
||||
QString name() const { return m_name; }
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
protected:
|
||||
virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent *contextMenuEvent );
|
||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent *mouseEvent );
|
||||
|
||||
private slots:
|
||||
void onMenuEdit();
|
||||
void onMenuCopy();
|
||||
void onMenuCut();
|
||||
void onMenuToFront();
|
||||
void onMenuToBack();
|
||||
void onMenuDelete();
|
||||
|
||||
private:
|
||||
void write( QXmlStreamWriter &writer );
|
||||
bool readItem( QXmlStreamReader &reader );
|
||||
void read( QXmlStreamReader &reader );
|
||||
void sendItemTo( bool front );
|
||||
void pushUndo();
|
||||
void unredo( bool undo );
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QString m_fileName;
|
||||
int m_index;
|
||||
bool m_saved;
|
||||
LabelMode m_labelMode;
|
||||
QColor m_cdColor;
|
||||
typedef QList<QString> UndoBuffer;
|
||||
|
||||
QString m_name;
|
||||
QString m_fileName;
|
||||
int m_index;
|
||||
bool m_saved;
|
||||
bool m_itemMoved;
|
||||
LabelMode m_labelMode;
|
||||
QColor m_cdColor;
|
||||
UndoBuffer m_undoBuffer;
|
||||
UndoBuffer::const_iterator m_undoPosition;
|
||||
};
|
||||
|
||||
#endif //QCDSCENE_H
|
||||
|
||||
+3
-2
@@ -147,18 +147,19 @@ 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 );
|
||||
drawCD( &paint, rectf, true );
|
||||
m_mask->setAlphaChannel( alpha );
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
#include "qdialogpixmap.h"
|
||||
#include "ui_qdialogpixmap.h"
|
||||
#include "qlightpixmapitem.h"
|
||||
#include "qcdscene.h"
|
||||
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QImageReader>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
@@ -54,25 +54,25 @@ void QDialogPixmap::changeEvent(QEvent *e)
|
||||
|
||||
bool QDialogPixmap::exec( QGraphicsItem *graphicsItem )
|
||||
{
|
||||
QGraphicsPixmapItem *item = dynamic_cast< QGraphicsPixmapItem * >( graphicsItem );
|
||||
QLightPixmapItem *item = dynamic_cast< QLightPixmapItem * >( graphicsItem );
|
||||
if( !item )
|
||||
return false;
|
||||
|
||||
QCDScene scene;
|
||||
m_ui->cdView->setScene( &scene );
|
||||
m_item = new QGraphicsPixmapItem;
|
||||
m_item = new QLightPixmapItem;
|
||||
|
||||
m_item->setPos( item->pos() );
|
||||
m_item->setOffset( item->offset() );
|
||||
m_item->setPixmap( item->pixmap() );
|
||||
m_item->setData( 0, item->data( 0 ) );
|
||||
m_item->imageName( item->imageName() );
|
||||
m_item->setTransform( item->transform() );
|
||||
|
||||
scene.addItem( m_item );
|
||||
|
||||
m_ui->spinX->setValue( m_item->pos().x() );
|
||||
m_ui->spinY->setValue( m_item->pos().y() );
|
||||
m_ui->lineEdit->setText( m_item->data( 0 ).toString() );
|
||||
m_ui->lineEdit->setText( m_item->imageName() );
|
||||
if( !m_item->pixmap().isNull() ) {
|
||||
QSize size = m_item->pixmap().size();
|
||||
QPointF scale = m_item->transform().map( QPointF( size.width(), size.height() ) );
|
||||
@@ -105,7 +105,7 @@ bool QDialogPixmap::exec( QGraphicsItem *graphicsItem )
|
||||
item->setPos( m_item->pos() );
|
||||
item->setOffset( m_item->offset() );
|
||||
item->setPixmap( m_item->pixmap() );
|
||||
item->setData( 0, m_item->data( 0 ) );
|
||||
item->imageName( m_item->imageName() );
|
||||
item->setTransform( m_item->transform() );
|
||||
|
||||
return true;
|
||||
@@ -131,7 +131,7 @@ void QDialogPixmap::onLoadImage()
|
||||
return;
|
||||
}
|
||||
m_item->setPixmap( pixmap );
|
||||
m_item->setData( 0, fileName );
|
||||
m_item->imageName( fileName );
|
||||
m_item->setOffset( -QPointF( pixmap.size().width(), pixmap.size().height() ) / 2.0 );
|
||||
|
||||
m_ui->lineEdit->setText( fileName );
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ namespace Ui {
|
||||
class QDialogPixmap;
|
||||
}
|
||||
|
||||
class QGraphicsPixmapItem;
|
||||
class QLightPixmapItem;
|
||||
|
||||
class QDialogPixmap : public QItemDialog {
|
||||
Q_OBJECT
|
||||
@@ -48,8 +48,8 @@ private slots:
|
||||
void sizeChanged();
|
||||
|
||||
private:
|
||||
Ui::QDialogPixmap *m_ui;
|
||||
QGraphicsPixmapItem *m_item;
|
||||
Ui::QDialogPixmap *m_ui;
|
||||
QLightPixmapItem *m_item;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QAbstractButton>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
#include <QSettings>
|
||||
|
||||
QDialogProgress::QDialogProgress( QWidget *parent, QLightDrive *drive )
|
||||
: QDialog(parent),
|
||||
@@ -68,6 +69,8 @@ bool QDialogProgress::exec( QWidget *parent, QCDScene *scene )
|
||||
if( !drive )
|
||||
return false;
|
||||
|
||||
params.m_ejectAfterComplete = QSettings().value( cfgEjectAfterFinish, false ).toBool();
|
||||
|
||||
QDialogProgress dialog( parent, drive );
|
||||
dialog.setWindowTitle( tr( "Printing: " ) + scene->name() );
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ui_qdialogroundtext.h"
|
||||
#include "qlightroundtextitem.h"
|
||||
#include "qcdscene.h"
|
||||
#include "qdialogsettings.h"
|
||||
|
||||
#include <QFontDialog>
|
||||
#include <QColorDialog>
|
||||
@@ -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,99 @@
|
||||
/* 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() );
|
||||
|
||||
if( dialog.QDialog::exec() == Rejected ) return false;
|
||||
|
||||
sts.setValue( cfgDefaultFont, dialog.m_font );
|
||||
sts.setValue( cfgEjectAfterFinish, dialog.m_ui->chkEject->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 <QtGui/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,140 @@
|
||||
<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>305</width>
|
||||
<height>156</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>
|
||||
</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>
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "qdialogtext.h"
|
||||
#include "ui_qdialogtext.h"
|
||||
#include "qcdscene.h"
|
||||
#include "qdialogsettings.h"
|
||||
|
||||
#include <QGraphicsSimpleTextItem>
|
||||
#include <QFontDialog>
|
||||
@@ -97,6 +98,7 @@ void QDialogText::onFont()
|
||||
QFont font = QFontDialog::getFont( &ok, m_item->font(), this );
|
||||
if( ok ) {
|
||||
m_item->setFont( font );
|
||||
QDialogSettings::setLastUsedFont( font );
|
||||
fontChanged();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-5
@@ -1,8 +1,8 @@
|
||||
<ui version="4.0" >
|
||||
<class>QDialogText</class>
|
||||
<widget class="QDialog" name="QDialogText" >
|
||||
<property name="windowModality" >
|
||||
<enum>Qt::NonModal</enum>
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
@@ -15,9 +15,6 @@
|
||||
<property name="windowTitle" >
|
||||
<string>Text properties</string>
|
||||
</property>
|
||||
<property name="modal" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3" >
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
|
||||
@@ -29,10 +29,21 @@ 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 )
|
||||
static_cast<QCDScene *>( scene() )->setChanged();
|
||||
static_cast<QCDScene *>( scene() )->itemMoved();
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -66,8 +77,8 @@ QItemDialog *QShapeControllerPixmap::createDialog( QWidget *parent ) const
|
||||
|
||||
void QShapeControllerPixmap::writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const
|
||||
{
|
||||
const QGraphicsPixmapItem *pixmapItem
|
||||
= static_cast< const QGraphicsPixmapItem * >( item );
|
||||
const QLightPixmapItem *pixmapItem
|
||||
= static_cast< const QLightPixmapItem * >( item );
|
||||
|
||||
writer.writeEmptyElement( "pos" );
|
||||
writer.writeAttribute( QXmlStreamAttribute( "x", QString::number( pixmapItem->pos().x() ) ) );
|
||||
@@ -81,7 +92,7 @@ void QShapeControllerPixmap::writeData( QXmlStreamWriter &writer, const QGraphic
|
||||
writer.writeAttribute(
|
||||
QXmlStreamAttribute( "sy", QString::number( scale.y() ) ) );
|
||||
|
||||
writer.writeTextElement( "image", pixmapItem->data( 0 ).toString() );
|
||||
writer.writeTextElement( "image", pixmapItem->imageName() );
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +101,7 @@ void QShapeControllerPixmap::readData( const QString &element,
|
||||
const QString &data,
|
||||
QGraphicsItem *item ) const
|
||||
{
|
||||
QGraphicsPixmapItem *pixmapItem = static_cast< QGraphicsPixmapItem * >( item );
|
||||
QLightPixmapItem *pixmapItem = static_cast< QLightPixmapItem * >( item );
|
||||
|
||||
if( element == "pos" ) {
|
||||
pixmapItem->setPos( attrs.value( "x" ).toString().toDouble(),
|
||||
@@ -105,12 +116,12 @@ void QShapeControllerPixmap::readData( const QString &element,
|
||||
}
|
||||
|
||||
if( element == "image" ) {
|
||||
pixmapItem->setData( 0, data );
|
||||
QPixmap pixmap( data );
|
||||
if( pixmap.isNull() ) {
|
||||
throw QString( "QShapeControllerPixmap: image loading from \"" ) +
|
||||
data + "\" failed";
|
||||
}
|
||||
pixmapItem->imageName( data );
|
||||
pixmapItem->setPixmap( pixmap );
|
||||
pixmapItem->setOffset( -QPointF( pixmap.size().height(), pixmap.size().width() ) / 2.0 );
|
||||
return;
|
||||
|
||||
@@ -25,13 +25,19 @@
|
||||
|
||||
#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; }
|
||||
|
||||
protected:
|
||||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value );
|
||||
|
||||
private:
|
||||
QString m_imageName;
|
||||
};
|
||||
|
||||
class QShapeControllerPixmap : public QShapeController {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -230,14 +232,38 @@ void QLightRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsIt
|
||||
}
|
||||
}
|
||||
|
||||
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() )->setChanged();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -264,7 +291,15 @@ QItemDialog *QShapeControllerRoundText::createDialog( QWidget *parent ) const
|
||||
void QShapeControllerRoundText::replace( QGraphicsItem *item, const QString &from, const QString &to ) const
|
||||
{
|
||||
QLightRoundTextItem *textItem = static_cast< QLightRoundTextItem * >( item );
|
||||
if( textItem->text() == from )
|
||||
bool placeHolder = textItem->text().left( 1 ) == "?" && textItem->text().right( 1 ) == "?";
|
||||
|
||||
bool replace = false;
|
||||
if( from.isEmpty() )
|
||||
replace = placeHolder;
|
||||
else
|
||||
replace = textItem->text() == ( placeHolder ? QString( "?%1?" ).arg( from ) : from );
|
||||
|
||||
if( replace )
|
||||
textItem->setText( to );
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+10
-3
@@ -35,13 +35,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 );
|
||||
|
||||
+14
-3
@@ -21,6 +21,7 @@
|
||||
#include "qlighttextitem.h"
|
||||
#include "qdialogtext.h"
|
||||
#include "qcdscene.h"
|
||||
#include "qdialogsettings.h"
|
||||
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QXmlStreamReader>
|
||||
@@ -33,7 +34,7 @@ QLightTextItem::QLightTextItem()
|
||||
QVariant QLightTextItem::itemChange( GraphicsItemChange change, const QVariant & value )
|
||||
{
|
||||
if( scene() && change == ItemPositionHasChanged )
|
||||
static_cast<QCDScene *>( scene() )->setChanged();
|
||||
static_cast<QCDScene *>( scene() )->itemMoved();
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -53,7 +54,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 );
|
||||
|
||||
@@ -81,7 +83,16 @@ void QShapeControllerText::writeData( QXmlStreamWriter &writer, const QGraphicsI
|
||||
void QShapeControllerText::replace( QGraphicsItem *item, const QString &from, const QString &to ) const
|
||||
{
|
||||
QGraphicsSimpleTextItem *textItem = static_cast< QGraphicsSimpleTextItem * >( item );
|
||||
if( textItem->text() == from )
|
||||
|
||||
bool placeHolder = textItem->text().left( 1 ) == "?" && textItem->text().right( 1 ) == "?";
|
||||
|
||||
bool replace = false;
|
||||
if( from.isEmpty() )
|
||||
replace = placeHolder;
|
||||
else
|
||||
replace = textItem->text() == ( placeHolder ? QString( "?%1?" ).arg( from ) : from );
|
||||
|
||||
if( replace )
|
||||
textItem->setText( to );
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,14 @@ enum MediaOptimizationLevel {
|
||||
mediaGeneric
|
||||
};
|
||||
|
||||
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";
|
||||
|
||||
|
||||
#endif // QLSCRIBE_H
|
||||
|
||||
+6
-3
@@ -20,7 +20,8 @@ SOURCES += main.cpp \
|
||||
qlighttextitem.cpp \
|
||||
qlightpixmapitem.cpp \
|
||||
qdialogcdproperties.cpp \
|
||||
qconsoleprintprogress.cpp
|
||||
qconsoleprintprogress.cpp \
|
||||
qdialogsettings.cpp
|
||||
QMAKE_LIBS += -llightscribe
|
||||
HEADERS += mainwindow.h \
|
||||
qlightroundtextitem.h \
|
||||
@@ -36,10 +37,12 @@ HEADERS += mainwindow.h \
|
||||
qlighttextitem.h \
|
||||
qlightpixmapitem.h \
|
||||
qdialogcdproperties.h \
|
||||
qconsoleprintprogress.h
|
||||
qconsoleprintprogress.h \
|
||||
qdialogsettings.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