48 Commits

Author SHA1 Message Date
ruglory 12a2ff2051 debian dir added for deb build
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/tags/release-0.7@70 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-20 20:44:10 +00:00
ruglory 24d1ce7e0b Tagging the 0.7 release
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/tags/release-0.7@69 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-16 01:53:03 +00:00
ruglory 92d47eee99 News updated for 0.7
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@68 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-16 01:52:43 +00:00
ruglory 1f253d8c35 --drive parameter implemented
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@67 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-16 01:47:55 +00:00
ruglory 3b66a26e05 Issue with Thread termination fixed
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@66 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-16 01:44:04 +00:00
ruglory 9b15a68c99 Added program arguments to print labels in console mode
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@65 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-16 00:56:11 +00:00
ruglory 86d1abdfbd icons updated
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@64 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-16 00:54:48 +00:00
ruglory e3ff109311 resources subdir added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@63 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-16 00:54:16 +00:00
ruglory e9286548d1 Resources added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@62 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-15 23:34:34 +00:00
ruglory 332afaa867 ZValue saved and restored now
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@61 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-14 22:55:37 +00:00
ruglory 0f765a6313 Bug with no reading radius value fixed
Z value is saved and restored


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@60 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-14 22:51:27 +00:00
ruglory b52abb4913 Main window title is added
Prepared for 0.7 release


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@59 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-05 03:20:33 +00:00
ruglory 4f826f942d label mode radiobutton is set from scene on initialization
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@57 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-05 01:44:55 +00:00
ruglory 5497269ca7 Bug with changing mode without changing picture fixed
Sizes for different modes adjusted


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@56 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-05 01:39:05 +00:00
ruglory f3a8eef96f Fixed bug with loading old save file with black color
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@55 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-04 23:21:23 +00:00
ruglory c8a517b222 added news for 0.6
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@54 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-04 23:02:45 +00:00
ruglory 76ea823c6f Dialog added to edit CD properties
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@53 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-04 22:55:44 +00:00
ruglory 0b80340d5e Label mode in background color is added to cd scene
Menu item new replaced with new lables with subitems
cd view shows cd scene mode and color
print dialog gets cd scene mode


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@52 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-04 19:32:39 +00:00
ruglory e3d9befa07 header added for projectwise includes
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@51 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-04 19:30:38 +00:00
ruglory 545eb3a9bb default y position changed to -40 as more usable
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@50 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-04 19:27:34 +00:00
ruglory 3dc6e5badd prepared for 0.6
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@49 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-04 18:11:03 +00:00
ruglory 14fb9dfd2b git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@47 cac9541e-1b8d-4bfa-827e-589bba606050 2009-02-01 02:19:03 +00:00
ruglory 890990fb64 News updated for 0.5 release
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@46 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-01 02:18:39 +00:00
ruglory 759cf0f28a Fixed bug wit missing button "OK" on pixmap edit dialog
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@45 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-01 02:13:33 +00:00
ruglory 178c6ad757 Text scaled to 1/2
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@44 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-01 02:08:05 +00:00
ruglory e196cb6bf5 Fixed bug with not setting color on round text
Text scaled to 1/2


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@43 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-01 02:07:35 +00:00
ruglory 4ed5ad84db Maximum image size increased to 150
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@42 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-01 02:05:07 +00:00
ruglory a828af2348 CD inner size updated
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@41 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-01 02:04:10 +00:00
ruglory 9c8e9bde5f Bugfix for crash on writing
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@40 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-31 20:02:59 +00:00
ruglory 6bba618cad About is prepared for release 0.5
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@39 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-31 05:06:00 +00:00
ruglory db061768d7 NEWS updated for release 0.4
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@37 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-31 04:34:17 +00:00
ruglory 40e1c7291a Added sticky bit at installation
Program checks for sticky bit at startup and issues warning if not set
Switch to real user id during work and effective user id during writing


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@36 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-31 04:27:56 +00:00
ruglory 3d0c7be90c Bug with empty document crash fixed
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@35 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-31 04:26:13 +00:00
ruglory 31136eeb12 QGraphicsRoundTextItem renamed to QLightRoundTextItem
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@34 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-31 02:15:33 +00:00
ruglory 79813e4a8a Context menu added to bring item front/send to back/delete added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@33 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-31 00:26:33 +00:00
ruglory e0f6307fd4 TextItem and PixmapItem are new classes now
Controllers moved to their classes
Item position changes is detected now


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@32 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-30 23:52:23 +00:00
ruglory 65e862bdd6 About updated for 0.4 release
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@31 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-29 02:52:05 +00:00
ruglory 85fc6fed99 News for release 0.3 added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@29 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-29 02:30:43 +00:00
ruglory 00e160bf1f Confirmation dialog added on main window close to save changed documents
Confirmation dialog added to QCDView close to save if changed


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@28 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-29 02:18:28 +00:00
ruglory 357067be63 When new item added or edited by dialog cdscene notified to be changed
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@27 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-28 21:42:15 +00:00
ruglory 78eafba502 Install updated
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@26 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-28 21:10:08 +00:00
ruglory 2031990216 Added environment variable LIGHTSCRIBEDIR to help cmake find lightScribe api
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@25 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-28 21:06:37 +00:00
ruglory e8125ce680 Added filename and name to cd scene
Added name title on cdview window
Open, "save as" and save reimplemented


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@24 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-28 05:45:57 +00:00
ruglory efebbd450f release 0.2 prepared
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@22 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-27 02:52:28 +00:00
ruglory b1be23c186 Image items can be scaled
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@21 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-27 02:48:48 +00:00
ruglory f6adb5e773 Round text reading bug fixed (did not read angle)
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@20 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-27 01:18:25 +00:00
ruglory d2eac1cb69 Estimated and elapsed time updated on progress dialog
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@19 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-27 01:14:48 +00:00
ruglory cb36403f64 Proper README and INSTALL created
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@18 cac9541e-1b8d-4bfa-827e-589bba606050
2009-01-26 18:55:32 +00:00
56 changed files with 2110 additions and 340 deletions
+1
View File
@@ -33,3 +33,4 @@ FIND_PACKAGE( Qt4 REQUIRED )
FIND_PACKAGE( LightScribe REQUIRED )
SUBDIRS( src )
SUBDIRS( resources )
+38
View File
@@ -0,0 +1,38 @@
Qt lightScribe Installaton instructions
=======================================
To compile and install, first download release from http://qlscribe.sourceforge.net/
or check out project from subversion repository for particular release:
svn co https://qlscribe.svn.sourceforge.net/svnroot/qlscribe/tags/release-N.M qlscribe
or if you want to test latest development version:
svn co https://qlscribe.svn.sourceforge.net/svnroot/qlscribe/trunk qlscribe
Then go to the source directory and type:
mkdir build
cd build
cmake ..
(If you want to install in a different path, use instead:
cmake .. -DCMAKE_INSTALL_PREFIX=/install/path)
make
sudo make install
If cmake fails to find lightScribe API specify environment variable LIGHTSCRIBEDIR:
LIGHTSCRIBEDIR=/opt/lightscribe cmake ..
Include files should be in ${LIGHTSCRIBEDIR}/include and lib in ${LIGHTSCRIBEDIR}/lib
Once installed, you can start Qt lightScribe by typing "qlscribe", but due to API
requirement if you want to burn qlscribe has to be started by root as "sudo qlscribe"
You need to download lightScribe SDK for qlscribe to build and lightScribe runtime
for qlscribe to run. For details see lightScribe webpage:
http://www.lightscribe.org/
Enjoy!
+38 -3
View File
@@ -1,6 +1,41 @@
NEWS - list of user-visible changes between releases of qlscribe
New in 0.1:
* First release of qlscribe
* *
New in 0.7:
Z-order of items saved and resored
Bugfix for not loading radius for round text
Console mode printing implemented
While printing in console mode text can be replaced by application parameter
New in 0.6:
Label mode and background color is added to scene
Added dialog to edit properties (color and mode) of the scene (label)
Scene passes mode to the print dialog
New in 0.5:
Bugfix for crash on writing
CD inner size increased to 25mm on QCDView
Maximum image size increased to 150
Fixed bug with not setting color on round text
Text scaled to 1/2
Fixed bug with missing button "OK" on pixmap edit dialog
New in 0.4:
Scene detects when item is moved by mouse and changes status to unsaved
On installation sticky bit is set, qlscribe becomes root when burns label
Bugfix on progress dialog crush with empty document printed
New in 0.3:
Documents keep their names and detect changes (changes on item postion through window
itself is not detected yet)
Main window on close scan all documents and confirm to save changed ones
Document window confirm to save on close
New in 0.2:
Print progress dialog shows elapsed/estimated time
Bugfix for not loading angle in round text item
Image items can be scaled now
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)
+14 -4
View File
@@ -1,7 +1,17 @@
qlscribe
********
Qt lightScribe V 0.1 by Vyacheslav Kononenko <vyacheslav@kononenko.net>
Introduction
============
Qt lightScribe is Qt base application to burn CD/DVD labels on lightScribe capable
drives and medias
This is the first alpha release. Program functionality is very limited at this stage.
Please check the project page for more information, and to report new bugs.
http://qlscribe.sourceforge.net/
Application based on lightScribe(c) API: http://www.lightscribe.org
and requires lightScribe API, available to download from:
http://www.lightscribe.org/downloadSection/linux/index.aspx
Thanks and regards,
Vyacheslav
+3 -2
View File
@@ -18,13 +18,14 @@
#
# $Id$
FIND_PATH( LSCRIBE_INCLUDE_DIR lightscribe.h /usr/local/include )
FIND_PATH( LSCRIBE_INCLUDE_DIR lightscribe.h /usr/local/include $ENV{LIGHTSCRIBEDIR}/include )
FIND_LIBRARY( LSCRIBE_LIBRARY lightscribe /usr/local/lib )
FIND_LIBRARY( LSCRIBE_LIBRARY lightscribe /usr/local/lib $ENV{LIGHTSCRIBEDIR}/lib )
if( LSCRIBE_INCLUDE_DIR AND LSCRIBE_LIBRARY )
SET( LSCRIBE_FOUND TRUE )
SET( LSCRIBE_LIBRARIES ${LSCRIBE_LIBRARY} )
INCLUDE_DIRECTORIES(${LSCRIBE_INCLUDE_DIR})
ENDIF( LSCRIBE_INCLUDE_DIR AND LSCRIBE_LIBRARY )
IF( LSCRIBE_FOUND )
+6
View File
@@ -0,0 +1,6 @@
qlscribe (0.7-0ubuntu1) unstable; urgency=low
* Initial release
-- Vyacheslav Kononenko <vyacheslav@kononenko.net> Sun, 15 Feb 2009 21:49:41 -0500
+1
View File
@@ -0,0 +1 @@
7
+13
View File
@@ -0,0 +1,13 @@
Source: qlscribe
Section: qt
Priority: optional
Maintainer: Vyacheslav Kononenko <vyacheslav@kononenko.net>
Build-Depends: debhelper (>= 7)
Standards-Version: 3.7.3
Homepage: http://qlscribe.sourceforge.net/
Package: qlscribe
Architecture: i386
Depends: ${shlibs:Depends}, lightscribe, libstdc++5
Description: Qt based application to print lightScribe discs
Qt lightScribe is a GUI application to burn labels on lightScribe capable drives.
+36
View File
@@ -0,0 +1,36 @@
This package was debianized by Vyacheslav Kononenko <vyacheslav@kononenko.net> on
Sun, 15 Feb 2009 21:49:41 -0500.
It was downloaded from https://sourceforge.net/project/platformdownload.php?group_id=251217
Upstream Author(s):
Vyacheslav Kononenko <vyacheslav@kononenko.net>
Copyright:
<Copyright (C) 2009 Vyacheslav Kononenko>
License:
This package 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 package 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 package; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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
is licensed under the GPL, see above.
Vendored
+2
View File
@@ -0,0 +1,2 @@
usr/bin
usr/sbin
Vendored
+2
View File
@@ -0,0 +1,2 @@
NEWS
README
Vendored Executable
+90
View File
@@ -0,0 +1,90 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
configure: configure-stamp
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
build: build-stamp
build-stamp: configure-stamp
dh_testdir
# Add here commands to compile the package.
cd build; $(MAKE)
#docbook-to-man debian/qlscribe.sgml > qlscribe.1
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
# Add here commands to clean up after the build process.
rm -rf build
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/qlscribe.
cd build; $(MAKE) install
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs ChangeLog
# dh_installdocs
# dh_installexamples
dh_install
dh_desktop
dh_icons
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
dh_installmime
# dh_python
# dh_installinit
# dh_installcron
# dh_installinfo
# dh_installman
# dh_link
# dh_strip
dh_compress
# dh_fixperms #need suid
# dh_perl
# dh_makeshlibs
dh_installdeb
dh_shlibdeps -- --ignore-missing-info
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
+36
View File
@@ -0,0 +1,36 @@
# 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$
SET( DESKTOP_DIR share/applications )
SET( MIME_DIR share/mime/packages )
SET( ICON_DIR share/icons/hicolor )
INSTALL( FILES qlscribe.desktop DESTINATION ${DESKTOP_DIR} )
INSTALL( FILES qlscribe.xml DESTINATION ${MIME_DIR} )
MACRO( INSTALL_ICON SIZE )
INSTALL( FILES qlscribe${SIZE}.png DESTINATION ${ICON_DIR}/${SIZE}x${SIZE}/apps RENAME qlscribe.png )
ENDMACRO( INSTALL_ICON )
INSTALL_ICON( 64 )
INSTALL_ICON( 48 )
INSTALL_ICON( 32 )
+9
View File
@@ -0,0 +1,9 @@
[Desktop Entry]
Encoding=UTF-8
Name=Qt lightScribe
Exec=qlscribe
Icon=qlscribe.png
Terminal=false
Type=Application
MimeType=application/x-qlscribe;
Categories=AudioVideo;DiscBurning;
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-qlscribe">
<comment>Qt lightScribe label document</comment>
<glob pattern="*.qlx"/>
</mime-type>
</mime-info>
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

+12 -6
View File
@@ -18,14 +18,17 @@
#
# $Id$
SET( QLSCRIBE_SRCS main.cpp mainwindow.cpp qcdscene.cpp qcdview.cpp qdialogpixmap.cpp qdialogroundtext.cpp
qdialogtext.cpp qgraphicsroundtextitem.cpp qlightscribe.cpp qshapecontrollers.cpp qshapefactory.cpp
qdialogprint.cpp qdialogprogress.cpp )
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)
SET( QLSCRIBE_UIS qdialogtext.ui qdialogroundtext.ui qdialogpixmap.ui qdialogprint.ui qdialogprogress.ui )
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 )
qdialogtext.h qlightscribe.h qdialogprint.h qdialogprogress.h
qdialogcdproperties.h qconsoleprintprogress.h)
ADD_DEFINITIONS( -Wall )
@@ -41,4 +44,7 @@ ADD_EXECUTABLE( qlscribe ${QLSCRIBE_SRCS} ${QLSCRIBE_MOC_SRCS} ${QLSCRIBE_UI_HDR
TARGET_LINK_LIBRARIES( qlscribe ${QT_LIBRARIES} ${LSCRIBE_LIBRARIES} )
INSTALL( TARGETS qlscribe DESTINATION bin )
INSTALL( TARGETS qlscribe
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETUID )
+144 -6
View File
@@ -19,13 +19,151 @@
$Id$ */
#include <QApplication>
#include <QMessageBox>
#include <QMap>
#include "mainwindow.h"
#include "qcdscene.h"
#include "qlightscribe.h"
#include "qconsoleprintprogress.h"
int main(int argc, char **argv)
#include <iostream>
uid_t realUserId;
std::ostream &operator<<( std::ostream &os, const QString &str )
{
QApplication app(argc, argv);
MainWindow mwindow;
mwindow.show();
return app.exec();
return os << str.toAscii().data();
}
void usage()
{
std::cout << "Usage: \n"
<< "To run GUI: qlscribe [filename] [filename] ...\n"
<< "To print label in console mode: qlscribe --print [--drive Index] [--replace KEY=VALUE] filename\n"
<< "\tParameters:\n"
<< "\t\t--help | -h - print this message\n"
<< "\t\t--print | -p - switch to print mode\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"
<< std::endl;
}
int main( int argc, char **argv )
{
QApplication app( argc, argv );
app.addLibraryPath( "/usr/lib32/qt4/plugins" );
bool doPrint = false;
QStringList arguments = app.arguments();
QStringList files;
QCDScene::QString2String replacements;
int driveIndex = 0;
QLightScribe::PrintParameters params;
bool labelModeOverriden = false;
for( int i = 1; i < arguments.size(); ++i ) {
QString arg = arguments[i];
if( arg == "--print" || arg == "-p" ) {
doPrint = true;
continue;
}
if( arg == "--help" || arg == "-h" ) {
usage();
return 0;
}
if( arg == "--replace" || arg == "-r" ) {
if( i == arguments.size() - 1 ) {
std::cerr << "Error: arg#" << i
<< " argument expected for \"" << arg << "\" not enough parameters" << std::endl;
return 1;
}
QString param = arguments[ ++i ];
int pos = param.indexOf( '=' );
if( pos == -1 ) {
std::cerr << "Error: arg#" << i
<< " invalid argument for replacement, KEY=VALUE expected, missing =" << std::endl;
return 2;
}
replacements[ param.left( pos ) ] = param.right( param.size() - pos - 1 );
continue;
}
if( arg == "--drive" || arg == "-d" ) {
if( i == arguments.size() - 1 ) {
std::cerr << "Error: arg#" << i
<< " argument expected for \"" << arg << "\" not enough parameters" << std::endl;
return 1;
}
QString param = arguments[ ++i ];
driveIndex = param.toInt();
}
if( arg[0] != '-' )
files.append( arg );
}
if( doPrint && files.size() != 1 ) {
if( files.size() )
std::cerr << "Error: only one filename expected to print, got " << files.size() << " instead" << std::endl;
else
std::cerr << "Error: filename required to print" << std::endl;
return 3;
}
bool enablePrint = false;
if( geteuid() ) {
if( !doPrint ) {
if( QMessageBox::question( 0,
QObject::tr( "Confirmation" ),
QObject::tr( "Print functionality requires setuid (sticky) flag set on the application\n"
"This program does not seem to have it set, print functionality will be disabled\n"
"You still will be able to do print preview and edit documents\n"
"Do you want to continue?" ),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No )
== QMessageBox::No )
return 4;
} else {
std::cerr << "Error: setuid flag is not set, cannot print" << std::endl;
return 4;
}
} else {
realUserId = getuid();
setreuid( 0, realUserId );
enablePrint = true;
}
int rez = 0;
if( doPrint ) {
// print here
QCDScene scene;
QString err;
if( !scene.load( files.front(), &err ) ) {
std::cerr << "Error: cannot read \"" << files.front() << "\" - " << err << std::endl;
return 5;
}
scene.replace( replacements );
if( !labelModeOverriden )
params.m_labelMode = scene.labelMode();
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;
return 6;
}
QConsolePrintProgress progress;
std::cout << "Printing label " << files.front() << std::endl;
scribe->print( drives[driveIndex], params, &scene );
rez = app.exec();
} else {
MainWindow mwindow( enablePrint );
mwindow.show();
mwindow.open( files );
rez = app.exec();
}
QLightScribe *scribe = QLightScribe::instance();
scribe->stopThread();
scribe->wait( 1000 );
return rez;
}
+148 -69
View File
@@ -19,13 +19,14 @@
$Id$ */
#include "mainwindow.h"
#include "qgraphicsroundtextitem.h"
#include "qlightroundtextitem.h"
#include "qcdview.h"
#include "qcdscene.h"
#include "qshapefactory.h"
#include "qlightscribe.h"
#include "qdialogprint.h"
#include "qdialogprogress.h"
#include "qdialogcdproperties.h"
#include <QMenuBar>
#include <QStatusBar>
@@ -34,30 +35,40 @@
#include <QMessageBox>
#include <QSignalMapper>
#include <QFileDialog>
#include <QXmlStreamWriter>
#include <QLabel>
#include <QCloseEvent>
/*#include <QImage>
#include <QBuffer>
#include <QGraphicsScene>
#include <QFontDialog>
#include <QPainter>*/
//#include <lightscribe.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
MainWindow::MainWindow( bool enablePrint )
: QMainWindow( 0 ),
m_mdiArea( new QMdiArea( this ) ),
m_menuFile( 0 ), m_menuInsert( 0 ),
m_insertMapper( new QSignalMapper( this ) )
m_insertMapper( new QSignalMapper( this ) ),
m_newLabelMapper( new QSignalMapper( this ) )
{
setWindowTitle( tr( "Qt lightScribe", "Main window title \"Qt lightScribe\"" ) );
setCentralWidget( m_mdiArea );
m_menuFile = menuBar()->addMenu( tr( "File", "Menu item \"File\"" ) );
m_menuFile->addAction( tr( "New", "Menu item \"New\"" ),
this,
SLOT(onMenuNew()) );
{
QMenu *newSubMenu = m_menuFile->addMenu( tr( "New label", "Menu item \"New lable\"" ) );
QAction *action = newSubMenu->addAction( tr( "Full", "Menu item \"Full\"" ),
m_newLabelMapper,
SLOT(map()) );
m_newLabelMapper->setMapping( action, modeFull );
action = newSubMenu->addAction( tr( "Content", "Menu item \"Content\"" ),
m_newLabelMapper,
SLOT(map()) );
m_newLabelMapper->setMapping( action, modeContent );
action = newSubMenu->addAction( tr( "Title", "Menu item \"Title\"" ),
m_newLabelMapper,
SLOT(map()) );
m_newLabelMapper->setMapping( action, modeTitle );
}
connect( m_newLabelMapper, SIGNAL(mapped(int)), this, SLOT(onMenuNewLabel(int)) );
m_menuFile->addAction( tr( "Open...", "Menu item \"Open\"" ),
this,
@@ -74,13 +85,22 @@ MainWindow::MainWindow(QWidget *parent) :
m_menuFile->addSeparator();
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_menuFile->addAction( tr( "Print...", "Menu item \"Print\"" ),
this,
SLOT(onMenuPrint()) );
QAction *printAction =
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,
@@ -111,16 +131,95 @@ MainWindow::MainWindow(QWidget *parent) :
MainWindow::~MainWindow()
{
QLightScribe *lscribe = QLightScribe::instance();
lscribe->stopThread();
lscribe->wait( 1000 );
}
void MainWindow::onMenuNew()
void MainWindow::open( const QStringList &files )
{
foreach( QString fileName, files ) {
QCDView *newView = new QCDView;
QCDScene *scene = new QCDScene( newView );
newView->setScene( scene );
if( !scene->load( fileName ) ) {
delete newView;
continue;
}
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( newView );
subWindow->show();
}
}
bool MainWindow::saveSceneAs( QCDScene *scene )
{
QString fileName =
QFileDialog::getSaveFileName( this,
scene->name() + tr( ": save as" ),
QString(),
tr("qlscribe document (*.qlx)") );
if( fileName.isNull() )
return false;
if( !fileName.contains( '.' ) )
fileName += ".qlx";
return scene->saveAs( fileName );
}
bool MainWindow::saveScene( QCDScene *scene )
{
return scene->isUnnamed() ? saveSceneAs( scene ) : scene->save();
}
void MainWindow::closeEvent(QCloseEvent *event)
{
bool saveAll = false;
QList< QMdiSubWindow * > subs = m_mdiArea->subWindowList();
foreach( QMdiSubWindow *sub, subs ) {
QCDView *cdview = dynamic_cast< QCDView * >( sub->widget() );
if( !cdview )
continue;
QCDScene *scene = cdview->scene();
if( !scene || scene->isSaved() )
continue;
bool save = saveAll;
if( !save ) {
QMessageBox::StandardButton button =
QMessageBox::question( this,
tr( "Confirmation" ),
scene->name() + tr( " is unsaved, do you want to save?" ),
QMessageBox::Save | QMessageBox::SaveAll | QMessageBox::Discard | QMessageBox::Cancel );
if( button == QMessageBox::Cancel ) {
event->ignore();
return;
}
if( button == QMessageBox::SaveAll ) {
saveAll = true;
save = true;
}
if( button == QMessageBox::Save )
save = true;
}
if( save )
if( !saveScene( scene ) ) {
event->ignore();
return;
}
}
event->accept();
}
void MainWindow::onMenuNewLabel( int mode )
{
QCDView *newView = new QCDView;
newView->setScene( new QCDScene( newView ) );
//newView->setWindowTitle( "Baba" );
QCDScene *scene = new QCDScene( newView );
scene->setLabelMode( LabelMode( mode ) );
newView->setScene( scene );
scene->setName();
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( newView );
subWindow->show();
}
@@ -161,6 +260,7 @@ void MainWindow::onMenuInsert( int id )
item->setFlag( QGraphicsItem::ItemIsMovable, true );
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
cdscene->addItem( item );
cdscene->setChanged();
}
void MainWindow::onMenuOpen()
@@ -173,33 +273,38 @@ void MainWindow::onMenuOpen()
if( fileName.isNull() )
return;
QFile file( fileName );
if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
QMessageBox::critical( this, tr( "Error" ), tr( "Cannot open file for reading\n" ) + fileName );
return;
}
QCDView *newView = new QCDView;
QCDScene *scene = new QCDScene( newView );
newView->setScene( scene );
QXmlStreamReader reader( &file );
try {
scene->read( reader );
}
catch( const QString &err ) {
QMessageBox::critical( this, tr( "Error" ), tr( "Cannot read file " ) + fileName + "\n" + err );
if( !scene->load( fileName ) ) {
delete newView;
return;
}
//newView->setWindowTitle( "Baba" );
}
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( newView );
subWindow->show();
}
void MainWindow::onMenuSave()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
saveScene( scene );
}
void MainWindow::onMenuSaveAs()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
saveSceneAs( scene );
}
void MainWindow::onMenuProperties()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
QDialogCDProperties::exec( this, scene );
}
void MainWindow::onMenuPrintPreview()
@@ -209,6 +314,7 @@ void MainWindow::onMenuPrintPreview()
return;
QLightScribe::PrintParameters params;
params.m_labelMode = cdscene->labelMode();
QLightDrive *drive = QDialogPrint::exec( this, params );
if( !drive )
return;
@@ -219,6 +325,7 @@ void MainWindow::onMenuPrintPreview()
QLabel *label = new QLabel;
label->setPixmap( pixmap );
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( label );
subWindow->setWindowTitle( "Preview: " + cdscene->name() );
subWindow->show();
}
catch( const QString &err ) {
@@ -235,40 +342,12 @@ void MainWindow::onMenuPrint()
QDialogProgress::exec( this, cdscene );
}
void MainWindow::onMenuSaveAs()
{
QCDScene *cdscene = getScene( m_mdiArea );
if( !cdscene )
return;
QString fileName =
QFileDialog::getSaveFileName( this,
tr( "Save as:" ),
QString(),
tr("qlscribe document (*.qlx)") );
if( fileName.isNull() )
return;
if( !fileName.contains( '.' ) )
fileName += ".qlx";
QFile file( fileName );
if( !file.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text ) ) {
QMessageBox::warning( this, tr( "Warning" ), tr( "Cannot open file for writing: " ) + fileName );
return;
}
QXmlStreamWriter writer( &file );
writer.setAutoFormatting( true );
cdscene->write( writer );
}
void MainWindow::onMenuAbout()
{
QMessageBox::about( this,
tr( "About" ),
tr( "<h3>qlscribe - Qt lisghtScribe</h3>"
"<p>$Revision$</p>"
"<p>release 0.7 $Revision$</p>"
"<p>visit project at home page "
"<a href=\"http://qlscribe.sourceforge.net/\">qlscribe.sourceforge.net</a></p>" ) );
}
+13 -2
View File
@@ -25,19 +25,27 @@
class QMdiArea;
class QSignalMapper;
class QCDScene;
class MainWindow : public QMainWindow {
Q_OBJECT
Q_DISABLE_COPY(MainWindow)
public:
explicit MainWindow(QWidget *parent = 0);
explicit MainWindow( bool enablePrint );
virtual ~MainWindow();
bool saveScene( QCDScene *scene );
void open( const QStringList &files );
protected:
virtual void closeEvent( QCloseEvent *event );
private slots:
void onMenuNew();
void onMenuNewLabel( int mode );
void onMenuOpen();
void onMenuSave();
void onMenuSaveAs();
void onMenuProperties();
void onMenuPrintPreview();
void onMenuPrint();
void onMenuInsert( int id );
@@ -45,6 +53,8 @@ private slots:
void onMenuQtAbout();
private:
bool saveSceneAs( QCDScene *scene );
QMdiArea *m_mdiArea;
QMenu *m_menuFile;
@@ -52,6 +62,7 @@ private:
QMenu *m_menuHelp;
QSignalMapper *m_insertMapper;
QSignalMapper *m_newLabelMapper;
};
#endif // MAINWINDOW_H
+188 -6
View File
@@ -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$ */
#include "qcdscene.h"
#include "qshapefactory.h"
@@ -25,10 +25,19 @@
#include <QMessageBox>
#include <QGraphicsItem>
#include <QGraphicsSceneMouseEvent>
#include <QFile>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QMessageBox>
#include <QGraphicsView>
#include <QRegExp>
QCDScene::QCDScene( QObject * parent )
: QGraphicsScene( parent )
: QGraphicsScene( parent ),
m_index( 0 ),
m_saved( true ),
m_labelMode( modeFull ),
m_cdColor( Qt::white )
{
setSceneRect( -60.0, -60.0, 60.0 * 2, 60.0 * 2 );
}
@@ -39,20 +48,147 @@ QCDScene::~QCDScene()
{
}
void QCDScene::replace( const QString2String &strings )
{
QShapeFactory &sfactory = QShapeFactory::instance();
QList<QGraphicsItem *> list = items();
for( QString2String::const_iterator st = strings.begin(); st != strings.end(); ++st ) {
foreach(QGraphicsItem *item, list ) {
QShapeFactory::iterator f = sfactory.find( item->type() );
if( f != sfactory.end() )
f->second->replace( item, st.key(), st.value() );
}
}
}
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();
return true;
}
bool QCDScene::save()
{
QFile file( m_fileName );
if( !file.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text ) ) {
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open file for writing: " ) + m_fileName );
return false;
}
QXmlStreamWriter writer( &file );
writer.setAutoFormatting( true );
write( writer );
m_saved = true;
setName();
return true;
}
void QCDScene::setLabelMode( LabelMode mode )
{
m_labelMode = mode;
update();
setChanged();
}
void QCDScene::setCDColor( const QColor &color )
{
m_cdColor = color;
update();
setChanged();
}
void QCDScene::setName()
{
if( m_fileName.isEmpty() ) {
if( !m_index ) {
static int index = 1;
m_index = index++;
}
m_name = "Unnamed_" + QString::number( m_index );
} else {
QRegExp rx( "(.*/)?(.*)\\.qlx" );
rx.indexIn( m_fileName );
m_name = rx.cap( 2 );
}
updateTitles();
}
void QCDScene::setChanged()
{
m_saved = false;
updateTitles();
}
void QCDScene::updateTitles() const
{
QString name = tr( "Label: ", "Window title \"Label\"" ) + m_name;
if( !m_saved )
name += " *";
QList<QGraphicsView *> allViews = views();
foreach( QGraphicsView *view, allViews ) {
view->setWindowTitle( name );
}
}
void QCDScene::redrawViews() const
{
}
bool QCDScene::saveAs( const QString &fileName )
{
QFile file( fileName );
if( !file.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text ) ) {
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open file for writing: " ) + fileName );
return false;
}
QXmlStreamWriter writer( &file );
writer.setAutoFormatting( true );
write( writer );
m_saved = true;
m_fileName = fileName;
setName();
return true;
}
void QCDScene::write( QXmlStreamWriter &writer )
{
writer.writeStartDocument();
writer.writeStartElement( "scene" );
writer.writeAttribute( QXmlStreamAttribute( "mode", QString::number( m_labelMode ) ) );
writer.writeAttribute( QXmlStreamAttribute( "color", m_cdColor.name() ) );
QShapeFactory &sfactory = QShapeFactory::instance();
QList<QGraphicsItem *> list = items();
for( QList<QGraphicsItem *>::const_iterator it = list.begin(); it != list.end(); ++it ) {
QShapeFactory::iterator f = sfactory.find( (*it)->type() );
foreach(QGraphicsItem *item, list ) {
QShapeFactory::iterator f = sfactory.find( item->type() );
if( f == sfactory.end() ) {
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot find controller for type %n", 0, (*it)->type() ) );
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot find controller for type %n", 0, item->type() ) );
continue;
}
f->second->write( writer, *it );
f->second->write( writer, item );
}
writer.writeEndElement();
@@ -76,6 +212,9 @@ void QCDScene::read( QXmlStreamReader &reader )
throw QString( "QCDScene: missing expected root element \"scene\", got \"" )
+ elementName + "\" intead";
m_labelMode = LabelMode( reader.attributes().value( "mode" ).toString().toInt() );
QString colorStr = reader.attributes().value( "color" ).toString();
m_cdColor = colorStr.isEmpty() ? Qt::white : QColor( colorStr );
gotScene = true;
continue;
}
@@ -110,6 +249,9 @@ void QCDScene::contextMenuEvent( QGraphicsSceneContextMenuEvent *mouseEvent )
item->setSelected( true );
QMenu menu;
menu.addAction( tr( "edit..." ), this, SLOT( onMenuEdit() ) );
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() );
}
@@ -121,3 +263,43 @@ void QCDScene::onMenuEdit()
QGraphicsItem *item = list.front();
QShapeFactory::instance().edit( item, 0 );
}
void QCDScene::onMenuToFront()
{
sendItemTo( true );
}
void QCDScene::onMenuToBack()
{
sendItemTo( false );
}
void QCDScene::onMenuDelete()
{
QList<QGraphicsItem *> list = selectedItems();
if( list.empty() )
return;
QGraphicsItem *item = list.front();
removeItem( item );
delete item;
setChanged();
}
void QCDScene::sendItemTo( bool front )
{
if ( selectedItems().isEmpty())
return;
QGraphicsItem *selectedItem = selectedItems().first();
QList<QGraphicsItem *> overlapItems = selectedItem->collidingItems();
qreal zValue = 0;
foreach( QGraphicsItem *item, overlapItems ) {
if( front && item->zValue() >= zValue )
zValue = item->zValue() + 0.1;
if( !front && item->zValue() <= zValue )
zValue = item->zValue() - 0.1;
}
selectedItem->setZValue( zValue );
}
+40 -3
View File
@@ -16,11 +16,13 @@
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 QCDSCENE_H
#define QCDSCENE_H
#include "qlscribe.h"
#include <QGraphicsScene>
class QXmlStreamWriter;
@@ -29,17 +31,52 @@ class QXmlStreamReader;
class QCDScene : public QGraphicsScene {
Q_OBJECT
public:
typedef QMap<QString,QString> QString2String;
QCDScene( QObject * parent = 0 );
virtual ~QCDScene();
void write( QXmlStreamWriter &writer );
void read( QXmlStreamReader &reader );
LabelMode labelMode() const { return m_labelMode; }
void setLabelMode( LabelMode mode );
QColor cdColor() const { return m_cdColor; }
void setCDColor( const QColor &color );
bool isSaved() const { return m_saved; }
bool isUnnamed() const { return m_fileName.isEmpty(); }
void setChanged();
void setName();
bool load( const QString &fileName, QString *errMessage = 0 );
void replace( const QString2String &strings );
bool save();
bool saveAs( const QString &fileName );
void updateTitles() const;
void redrawViews() const;
QString name() const { return m_name; }
protected:
virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent *contextMenuEvent );
private slots:
void onMenuEdit();
void onMenuToFront();
void onMenuToBack();
void onMenuDelete();
private:
void write( QXmlStreamWriter &writer );
void read( QXmlStreamReader &reader );
void sendItemTo( bool front );
private:
QString m_name;
QString m_fileName;
int m_index;
bool m_saved;
LabelMode m_labelMode;
QColor m_cdColor;
};
#endif //QCDSCENE_H
+80 -8
View File
@@ -16,14 +16,19 @@
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$ */
#include "qcdview.h"
#include "qcdscene.h"
#include "mainwindow.h"
#include <QCloseEvent>
#include <QMessageBox>
QCDView::QCDView( QWidget *parent )
: QGraphicsView( parent ),
m_mask( new QPixmap )
m_mask( new QPixmap ),
m_labelMode( -1 )
{
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
@@ -49,10 +54,37 @@ QCDScene *QCDView::scene() const
return static_cast< QCDScene * >( QGraphicsView::scene() );
}
void QCDView::closeEvent( QCloseEvent *event )
{
QCDScene *cdscene = scene();
if( cdscene && !cdscene->isSaved() ) {
QMessageBox::StandardButton button =
QMessageBox::question( this,
tr( "Confitmation" ),
cdscene->name() + tr( " is changed, do you want to save it?" ),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel );
if( button == QMessageBox::Cancel ) {
event->ignore();
return;
}
if( button == QMessageBox::Yes ) {
QWidget *parent = parentWidget();
for( ; parent->parentWidget(); parent = parent->parentWidget() );
if( !static_cast< MainWindow * >( parent )->saveScene( cdscene ) ) {
event->ignore();
return;
}
}
}
event->accept();
}
inline
void drawCircle( QPainter *painter, double radi )
{
painter->drawEllipse( -radi, -radi, radi * 2, radi * 2 );
painter->drawEllipse( QRectF( -radi, -radi, radi * 2, radi * 2 ) );
}
void QCDView::drawCD( QPainter *painter, const QRectF & rect, bool alpha )
@@ -60,11 +92,47 @@ void QCDView::drawCD( QPainter *painter, const QRectF & rect, bool alpha )
painter->setBrush( alpha ? Qt::lightGray : Qt::gray );
painter->drawRect( rect );
painter->setBrush( alpha ? Qt::black : Qt::white );
drawCircle( painter, 59.0 );
const double fullInner = 24.7, fullOuter = 60.0;
painter->setBrush( alpha ? Qt::lightGray : Qt::darkGray );
drawCircle( painter, 21.7 );
QCDScene *cdscene = scene();
if( cdscene ) {
double inner = 0, outer = 0;
switch( cdscene->labelMode() ) {
case modeFull : inner = 24.7; outer = 60.0; break;
case modeTitle : inner = 32.0; outer = 37.4; break;
case modeContent : inner = 25.8; outer = 37.4; break;
}
if( alpha ) {
painter->setBrush( Qt::black );
drawCircle( painter, outer );
painter->setBrush( Qt::lightGray );
drawCircle( painter, inner );
} else {
QColor darker( cdscene->cdColor().darker( 150 ) );
if( outer < fullOuter ) {
painter->setBrush( darker );
drawCircle( painter, fullOuter );
}
painter->setBrush( cdscene->cdColor() );
drawCircle( painter, outer );
if( inner > fullInner ) {
painter->setBrush( darker );
drawCircle( painter, inner );
}
painter->setBrush( Qt::darkGray );
drawCircle( painter, fullInner );
}
} else {
painter->setBrush( alpha ? Qt::black : Qt::white );
drawCircle( painter, fullOuter );
painter->setBrush( alpha ? Qt::lightGray : Qt::darkGray );
drawCircle( painter, fullInner );
}
painter->setBrush( alpha ? Qt::white : Qt::gray );
drawCircle( painter, 10.7 );
@@ -73,7 +141,11 @@ void QCDView::drawCD( QPainter *painter, const QRectF & rect, bool alpha )
void QCDView::drawForeground ( QPainter * painter, const QRectF & rect )
{
if( !painter ) return;
if( m_mask->size() != frameSize() ) {
QCDScene *cdscene = scene();
if( m_mask->size() != frameSize() || ( cdscene && m_labelMode != cdscene->labelMode() ) ) {
if( cdscene )
m_labelMode = cdscene->labelMode();
*m_mask = QPixmap( frameSize() );
{
+3 -1
View File
@@ -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 QCDVIEW_H
#define QCDVIEW_H
@@ -39,6 +39,7 @@ public:
virtual QSize sizeHint () const;
protected:
virtual void closeEvent( QCloseEvent *event );
void drawForeground ( QPainter * painter, const QRectF & rect );
void drawBackground ( QPainter * painter, const QRectF & rect );
@@ -48,6 +49,7 @@ private:
void drawCD( QPainter * painter, const QRectF & rect, bool alpha );
QPixmap *m_mask;
int m_labelMode;
};
#endif // QCDVIEW_H
+47
View File
@@ -0,0 +1,47 @@
#include "qconsoleprintprogress.h"
#include "qlightscribe.h"
#include <QApplication>
#include <iostream>
QConsolePrintProgress::QConsolePrintProgress()
{
QLightScribe *scribe = QLightScribe::instance();
connect( scribe, SIGNAL(prepareProgress(long,long)), this, SLOT(onPrepareProgress(long,long)) );
connect( scribe, SIGNAL(labelProgress(long,long)), this, SLOT(onLabelProgress(long,long)) );
connect( scribe, SIGNAL(timeEstimate(long)), this, SLOT(onTimeEstimate(long)) );
connect( scribe, SIGNAL(finished(int)), this, SLOT(onFinished(int)) );
}
QConsolePrintProgress::~QConsolePrintProgress()
{
}
void QConsolePrintProgress::onPrepareProgress( long current, long final )
{
std::cout << "Preparing label: " << current << '/' << final << " \r";
}
void QConsolePrintProgress::onLabelProgress( long current, long final )
{
std::cout << "Printing label: " << current << '/' << final << " \r";
}
void QConsolePrintProgress::onTimeEstimate( long time )
{
std::cout << std::endl;
}
void QConsolePrintProgress::onFinished( int status )
{
std::cout << "\n";
if( !status )
std::cout << "Print successfull" << std::endl;
else
std::cout << "Print failed: 0x" << QString::number( status, 16 ) << std::endl;
qApp->exit( status );
}
+19
View File
@@ -0,0 +1,19 @@
#ifndef QCONSOLEPRINTPROGRESS_H
#define QCONSOLEPRINTPROGRESS_H
#include <QObject>
class QConsolePrintProgress : public QObject {
Q_OBJECT
public:
QConsolePrintProgress();
~QConsolePrintProgress();
private slots:
void onPrepareProgress( long current, long final );
void onLabelProgress( long current, long final );
void onTimeEstimate( long time );
void onFinished(int status );
};
#endif // QCONSOLEPRINTPROGRESS_H
+100
View File
@@ -0,0 +1,100 @@
/* 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 "qdialogcdproperties.h"
#include "ui_qdialogcdproperties.h"
#include "qcdscene.h"
#include <QColorDialog>
QDialogCDProperties::QDialogCDProperties(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::QDialogCDProperties)
{
m_ui->setupUi(this);
connect( m_ui->btnColor, SIGNAL(clicked()), this, SLOT(onColor()) );
connect( m_ui->radioModeFull, SIGNAL(toggled(bool)), this, SLOT(onChangeMode()) );
connect( m_ui->radioModeContent, SIGNAL(toggled(bool)), this, SLOT(onChangeMode()) );
connect( m_ui->radioModeTitle, SIGNAL(toggled(bool)), this, SLOT(onChangeMode()) );
}
bool QDialogCDProperties::exec( QWidget *parent, QCDScene *scene )
{
QCDScene lscene;
lscene.setLabelMode( scene->labelMode() );
lscene.setCDColor( scene->cdColor() );
QDialogCDProperties dialog( parent );
dialog.setWindowTitle( tr( "Label properties: ", "Dialog title \"Label properties: \"" )
+ scene->name() );
dialog.m_ui->cdView->setScene( &lscene );
switch( scene->labelMode() ) {
case modeFull : dialog.m_ui->radioModeFull->setChecked( true ); break;
case modeTitle : dialog.m_ui->radioModeTitle->setChecked( true ); break;
case modeContent : dialog.m_ui->radioModeContent->setChecked( true ); break;
}
if( dialog.QDialog::exec() == Rejected ) return false;
scene->setLabelMode( lscene.labelMode() );
scene->setCDColor( lscene.cdColor() );
return true;
}
QDialogCDProperties::~QDialogCDProperties()
{
delete m_ui;
}
void QDialogCDProperties::changeEvent(QEvent *e)
{
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
default:
break;
}
}
void QDialogCDProperties::onChangeMode()
{
QCDScene *scene = m_ui->cdView->scene();
if( m_ui->radioModeFull->isChecked() )
scene->setLabelMode( modeFull );
if( m_ui->radioModeTitle->isChecked() )
scene->setLabelMode( modeTitle );
if( m_ui->radioModeContent->isChecked() )
scene->setLabelMode( modeContent );
}
void QDialogCDProperties::onColor()
{
QCDScene *scene = m_ui->cdView->scene();
QColor color = QColorDialog::getColor( scene->cdColor(), this );
if( color.isValid() ){
scene->setCDColor( color );
}
}
+53
View File
@@ -0,0 +1,53 @@
/* 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 QDIALOGCDPROPERTIES_H
#define QDIALOGCDPROPERTIES_H
#include <QtGui/QDialog>
namespace Ui {
class QDialogCDProperties;
}
class QCDScene;
class QDialogCDProperties : public QDialog {
Q_OBJECT
Q_DISABLE_COPY(QDialogCDProperties)
public:
static bool exec( QWidget *parent, QCDScene *scene );
protected:
virtual void changeEvent(QEvent *e);
private slots:
void onChangeMode();
void onColor();
private:
explicit QDialogCDProperties(QWidget *parent = 0);
virtual ~QDialogCDProperties();
Ui::QDialogCDProperties *m_ui;
};
#endif // QDIALOGCDPROPERTIES_H
+191
View File
@@ -0,0 +1,191 @@
<ui version="4.0" >
<class>QDialogCDProperties</class>
<widget class="QDialog" name="QDialogCDProperties" >
<property name="windowModality" >
<enum>Qt::NonModal</enum>
</property>
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>398</width>
<height>532</height>
</rect>
</property>
<property name="windowTitle" >
<string>Label properties</string>
</property>
<property name="modal" >
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3" >
<item>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QFrame" name="frame" >
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth" >
<number>3</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" >
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<layout class="QFormLayout" name="formLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Label mode:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QFrame" name="frame_2" >
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3" >
<item>
<widget class="QRadioButton" name="radioModeFull" >
<property name="text" >
<string>Full</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioModeTitle" >
<property name="text" >
<string>Title</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioModeContent" >
<property name="text" >
<string>Content</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="btnColor" >
<property name="text" >
<string>Change color...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<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>
</layout>
</item>
<item>
<widget class="QCDView" name="cdView" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="baseSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="interactive" >
<bool>false</bool>
</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>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QCDView</class>
<extends>QGraphicsView</extends>
<header>qcdview.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QDialogCDProperties</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>258</x>
<y>582</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QDialogCDProperties</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>326</x>
<y>582</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+47 -1
View File
@@ -66,11 +66,21 @@ bool QDialogPixmap::exec( QGraphicsItem *graphicsItem )
m_item->setOffset( item->offset() );
m_item->setPixmap( item->pixmap() );
m_item->setData( 0, item->data( 0 ) );
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() );
if( !m_item->pixmap().isNull() ) {
QSize size = m_item->pixmap().size();
QPointF scale = m_item->transform().map( QPointF( size.width(), size.height() ) );
m_ui->spinWidth->setValue( scale.x() );
m_ui->spinHeight->setValue( scale.y() );
m_ui->lockedRatio->setChecked( scale.x() == scale.y() ? Qt::Checked : Qt::Unchecked );
m_ui->buttonBox->setStandardButtons( m_ui->buttonBox->standardButtons() | QDialogButtonBox::Ok );
}
connect( m_ui->spinX, SIGNAL(valueChanged(double)),
this, SLOT(posChanged()) );
@@ -78,12 +88,25 @@ bool QDialogPixmap::exec( QGraphicsItem *graphicsItem )
connect( m_ui->spinY, SIGNAL(valueChanged(double)),
this, SLOT(posChanged()) );
connect( m_ui->spinWidth, SIGNAL(valueChanged(double)),
this, SLOT(sizeChanged()) );
connect( m_ui->spinHeight, SIGNAL(valueChanged(double)),
this, SLOT(sizeChanged()) );
connect( m_ui->btnSizeReset, SIGNAL(clicked()),
this, SLOT(onResetSize()) );
connect( m_ui->lockedRatio, SIGNAL(stateChanged(int)),
this, SLOT(sizeChanged()) );
if( QDialog::exec() == Rejected ) return false;
item->setPos( m_item->pos() );
item->setOffset( m_item->offset() );
item->setPixmap( m_item->pixmap() );
item->setData( 0, m_item->data( 0 ) );
item->setTransform( m_item->transform() );
return true;
}
@@ -109,13 +132,36 @@ void QDialogPixmap::onLoadImage()
}
m_item->setPixmap( pixmap );
m_item->setData( 0, fileName );
m_item->setOffset( -QPointF( pixmap.size().height(), pixmap.size().width() ) / 2.0 );
m_item->setOffset( -QPointF( pixmap.size().width(), pixmap.size().height() ) / 2.0 );
m_ui->lineEdit->setText( fileName );
m_ui->buttonBox->setStandardButtons( m_ui->buttonBox->standardButtons() | QDialogButtonBox::Ok );
onResetSize();
}
void QDialogPixmap::posChanged()
{
m_item->setPos( m_ui->spinX->value(), m_ui->spinY->value() );
}
void QDialogPixmap::onResetSize()
{
m_ui->spinWidth->setValue( m_item->pixmap().size().width() / 10.0 );
m_ui->spinHeight->setValue( m_item->pixmap().size().height() / 10.0 );
}
void QDialogPixmap::sizeChanged()
{
if( m_ui->lockedRatio->checkState() == Qt::Checked ) {
QObject *senderObj = sender();
QSize size = m_item->pixmap().size();
if( senderObj == m_ui->spinWidth || senderObj == m_ui->lockedRatio ) {
m_ui->spinHeight->setValue( m_ui->spinWidth->value() / size.width() * size.height() );
} else {
m_ui->spinWidth->setValue( m_ui->spinHeight->value() / size.height() * size.width() );
}
}
m_item->setTransform( QTransform().scale( m_ui->spinWidth->value() / m_item->pixmap().size().width(),
m_ui->spinHeight->value() / m_item->pixmap().size().height() ) );
}
+2
View File
@@ -44,6 +44,8 @@ protected:
private slots:
void onLoadImage();
void posChanged();
void onResetSize();
void sizeChanged();
private:
Ui::QDialogPixmap *m_ui;
+88 -22
View File
@@ -8,12 +8,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>542</width>
<height>649</height>
<width>464</width>
<height>618</height>
</rect>
</property>
<property name="windowTitle" >
<string>Text properties</string>
<string>Image properties</string>
</property>
<property name="modal" >
<bool>false</bool>
@@ -32,15 +32,9 @@
<property name="lineWidth" >
<number>3</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<layout class="QVBoxLayout" name="verticalLayout_3" >
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<property name="sizeConstraint" >
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<layout class="QFormLayout" name="formLayout" >
<item row="0" column="0" >
@@ -86,33 +80,105 @@
</layout>
</item>
<item>
<layout class="QFormLayout" name="formLayout_3" >
<property name="fieldGrowthPolicy" >
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<layout class="QFormLayout" name="formLayout_2" >
<item row="0" column="0" >
<widget class="QLabel" name="label_5" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Image:</string>
<string>Width:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="lineEdit" >
<property name="readOnly" >
<bool>true</bool>
<widget class="QDoubleSpinBox" name="spinWidth" >
<property name="minimum" >
<double>1.000000000000000</double>
</property>
<property name="maximum" >
<double>200.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Height:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QPushButton" name="btnImage" >
<property name="text" >
<string>Load image...</string>
<widget class="QDoubleSpinBox" name="spinHeight" >
<property name="minimum" >
<double>1.000000000000000</double>
</property>
<property name="maximum" >
<double>200.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QCheckBox" name="lockedRatio" >
<property name="text" >
<string>Locked ratio</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSizeReset" >
<property name="text" >
<string>Reset size</string>
</property>
</widget>
</item>
</layout>
</item>
<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>
</layout>
</item>
<item>
<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>Image:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="lineEdit" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QPushButton" name="btnImage" >
<property name="text" >
<string>Load image...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
+31 -2
View File
@@ -1,3 +1,23 @@
/* 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 "qdialogprint.h"
#include "ui_qdialogprint.h"
@@ -34,6 +54,12 @@ QLightDrive *QDialogPrint::exec( QWidget *parent, QLightScribe::PrintParameters
return 0;
}
QDialogPrint dialog( parent );
switch( params.m_labelMode ) {
case modeFull : dialog.m_ui->radioModeFull->setChecked( true ); break;
case modeContent : dialog.m_ui->radioModeContent->setChecked( true ); break;
case modeTitle : dialog.m_ui->radioModeTitle->setChecked( true ); break;
}
int index = 0;
foreach( QLightDrive *drv, drives ) {
dialog.m_ui->comboDrive->insertItem( index++, drv->displayName() );
@@ -43,11 +69,14 @@ QLightDrive *QDialogPrint::exec( QWidget *parent, QLightScribe::PrintParameters
params = QLightScribe::PrintParameters(); // reset to default
if( dialog.m_ui->radioModeFull->isChecked() )
params.m_labelMode = modeFull;
if( dialog.m_ui->radioModeTitle->isChecked() )
params.m_labelMode = QLightScribe::modeTitle;
params.m_labelMode = modeTitle;
if( dialog.m_ui->radioModeContent->isChecked() )
params.m_labelMode = QLightScribe::modeContent;
params.m_labelMode = modeContent;
if( dialog.m_ui->radioQualityNormal->isChecked() )
params.m_printQuality = QLightScribe::qualityNormal;
+20
View File
@@ -1,3 +1,23 @@
/* 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 QDIALOGPRINT_H
#define QDIALOGPRINT_H
+48 -2
View File
@@ -1,21 +1,51 @@
/* 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 "qdialogprogress.h"
#include "ui_qdialogprogress.h"
#include "qlightscribe.h"
#include "qdialogprint.h"
#include "qcdscene.h"
#include <QMessageBox>
#include <QAbstractButton>
#include <QTime>
#include <QTimer>
QDialogProgress::QDialogProgress(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::QDialogProgress)
m_ui(new Ui::QDialogProgress),
m_start( new QTime ),
m_timer( new QTimer( this ) )
{
m_ui->setupUi(this);
m_start->start();
connect( m_timer, SIGNAL(timeout()), this, SLOT(onTimeout()) );
m_timer->start( 500 );
}
QDialogProgress::~QDialogProgress()
{
delete m_ui;
delete m_start;
delete m_timer;
delete m_ui;
}
void QDialogProgress::changeEvent(QEvent *e)
@@ -32,12 +62,14 @@ void QDialogProgress::changeEvent(QEvent *e)
bool QDialogProgress::exec( QWidget *parent, QCDScene *scene )
{
QLightScribe::PrintParameters params;
params.m_labelMode = scene->labelMode();
QLightDrive *drive = QDialogPrint::exec( parent, params );
if( !drive )
return false;
QLightScribe *scribe = QLightScribe::instance();
QDialogProgress dialog( parent );
dialog.setWindowTitle( tr( "Printing: " ) + scene->name() );
connect( dialog.m_ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), &dialog, SLOT(onButtonClicked(QAbstractButton*)) );
connect( scribe, SIGNAL(prepareProgress(long,long)), &dialog, SLOT(onPrepareProgress(long,long)) );
@@ -75,14 +107,28 @@ void QDialogProgress::onLabelProgress( long current, long final )
{
m_ui->progressPrinting->setMaximum( final );
m_ui->progressPrinting->setValue( current );
if( current && final / double( current ) < 10.0 ) {
int elapsed = m_start->elapsed();
int estimate = double( elapsed ) / current * final;
m_ui->timeEstimated->setTime( QTime().addMSecs( estimate ) );
}
}
void QDialogProgress::onTimeEstimate( long time )
{
m_ui->timeEstimated->setTime( QTime().addSecs( time ) );
}
void QDialogProgress::onFinished(int status )
{
m_timer->stop();
m_ui->progressPrinting->setValue( m_ui->progressPrinting->maximum() );
m_ui->lineResult->setText( status ? tr( "Failed - error code: 0x" ) + QString::number( status, 16 ) : tr( "Success" ) );
m_ui->buttonBox->setStandardButtons( QDialogButtonBox::Close );
}
void QDialogProgress::onTimeout()
{
m_ui->timeElapsed->setTime( QTime().addMSecs( m_start->elapsed() ) );
}
+25
View File
@@ -1,3 +1,23 @@
/* 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 QDIALOGPROGRESS_H
#define QDIALOGPROGRESS_H
@@ -9,6 +29,8 @@ namespace Ui {
class QCDScene;
class QAbstractButton;
class QTime;
class QTimer;
class QDialogProgress : public QDialog {
Q_OBJECT
@@ -22,6 +44,7 @@ protected slots:
void onLabelProgress( long current, long final );
void onTimeEstimate( long time );
void onFinished(int status );
void onTimeout();
protected:
virtual void changeEvent(QEvent *e);
@@ -31,6 +54,8 @@ private:
virtual ~QDialogProgress();
Ui::QDialogProgress *m_ui;
QTime *m_start;
QTimer *m_timer;
};
#endif // QDIALOGPROGRESS_H
+10 -1
View File
@@ -10,7 +10,7 @@
</rect>
</property>
<property name="windowTitle" >
<string>Dialog</string>
<string>Print progress</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
@@ -85,6 +85,9 @@
<property name="displayFormat" >
<string>hh:mm:ss</string>
</property>
<property name="currentSectionIndex" >
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="0" >
@@ -172,6 +175,12 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>buttonBox</tabstop>
<tabstop>lineResult</tabstop>
<tabstop>timeEstimated</tabstop>
<tabstop>timeElapsed</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
+4 -3
View File
@@ -20,7 +20,7 @@
#include "qdialogroundtext.h"
#include "ui_qdialogroundtext.h"
#include "qgraphicsroundtextitem.h"
#include "qlightroundtextitem.h"
#include "qcdscene.h"
#include <QFontDialog>
@@ -55,13 +55,13 @@ void QDialogRoundText::changeEvent(QEvent *e)
bool QDialogRoundText::exec( QGraphicsItem *graphicsItem )
{
QGraphicsRoundTextItem *item = dynamic_cast< QGraphicsRoundTextItem * >( graphicsItem );
QLightRoundTextItem *item = dynamic_cast< QLightRoundTextItem * >( graphicsItem );
if( !item )
return false;
QCDScene scene;
m_ui->cdView->setScene( &scene );
m_item = new QGraphicsRoundTextItem;
m_item = new QLightRoundTextItem;
m_item->setPos( item->pos() );
m_item->setText( item->text() );
@@ -129,6 +129,7 @@ void QDialogRoundText::onFont()
{
bool ok = true;
QFont font = QFontDialog::getFont( &ok, m_item->font(), this );
//font.setPointSizeF( font.pointSizeF() / 2.0 );
if( ok ) {
m_item->setFont( font );
fontChanged();
+4 -4
View File
@@ -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 QDIALOGROUNDTEXT_H
#define QDIALOGROUNDTEXT_H
@@ -27,7 +27,7 @@ namespace Ui {
class QDialogRoundText;
}
class QGraphicsRoundTextItem;
class QLightRoundTextItem;
class QDialogRoundText : public QItemDialog {
Q_OBJECT
@@ -54,8 +54,8 @@ private slots:
void locChanged();
private:
Ui::QDialogRoundText *m_ui;
QGraphicsRoundTextItem *m_item;
Ui::QDialogRoundText *m_ui;
QLightRoundTextItem *m_item;
};
#endif // QDIALOGROUNDTEXT_H
+3
View File
@@ -206,6 +206,9 @@
</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>
+4 -3
View File
@@ -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$ */
#include "qdialogtext.h"
#include "ui_qdialogtext.h"
@@ -32,8 +32,8 @@ QDialogText::QDialogText(QWidget *parent) :
m_item( 0 )
{
m_ui->setupUi(this);
connect( m_ui->btnFont, SIGNAL(clicked()), this, SLOT(onFont()) );
connect( m_ui->btnColor, SIGNAL(clicked()), this, SLOT(onColor()) );
connect( m_ui->btnFont, SIGNAL(clicked()), this, SLOT(onFont()) );
connect( m_ui->btnColor, SIGNAL(clicked()), this, SLOT(onColor()) );
}
QDialogText::~QDialogText()
@@ -66,6 +66,7 @@ bool QDialogText::exec( QGraphicsItem *graphicsItem )
m_item->setText( item->text() );
m_item->setFont( item->font() );
m_item->setBrush( item->brush() );
m_item->setTransform( item->transform() );
scene.addItem( m_item );
+118
View File
@@ -0,0 +1,118 @@
/* 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 "qlightpixmapitem.h"
#include "qdialogpixmap.h"
#include "qcdscene.h"
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
QLightPixmapItem::QLightPixmapItem()
{
}
QVariant QLightPixmapItem::itemChange( GraphicsItemChange change, const QVariant & value )
{
if( scene() && change == ItemPositionHasChanged )
static_cast<QCDScene *>( scene() )->setChanged();
return value;
}
RegisterController< QShapeControllerPixmap > regControllerPixmap;
QString QShapeControllerPixmap::name() const
{
return "image";
}
QString QShapeControllerPixmap::menuName() const
{
return QObject::tr( "Image", "QShapeControllerPixmap name" );
}
QGraphicsItem *QShapeControllerPixmap::create() const
{
QGraphicsPixmapItem *item = new QLightPixmapItem;
item->setShapeMode( QGraphicsPixmapItem::BoundingRectShape );
item->setTransformationMode( Qt::SmoothTransformation );
return item;
}
QItemDialog *QShapeControllerPixmap::createDialog( QWidget *parent ) const
{
return new QDialogPixmap( parent );
}
void QShapeControllerPixmap::writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const
{
const QGraphicsPixmapItem *pixmapItem
= static_cast< const QGraphicsPixmapItem * >( item );
writer.writeEmptyElement( "pos" );
writer.writeAttribute( QXmlStreamAttribute( "x", QString::number( pixmapItem->pos().x() ) ) );
writer.writeAttribute( QXmlStreamAttribute( "y", QString::number( pixmapItem->pos().y() ) ) );
writer.writeAttribute( QXmlStreamAttribute( "z", QString::number( pixmapItem->zValue() ) ) );
QPointF scale = pixmapItem->transform().map( QPointF( 1.0, 1.0 ) );
writer.writeEmptyElement( "scale" );
writer.writeAttribute(
QXmlStreamAttribute( "sx", QString::number( scale.x() ) ) );
writer.writeAttribute(
QXmlStreamAttribute( "sy", QString::number( scale.y() ) ) );
writer.writeTextElement( "image", pixmapItem->data( 0 ).toString() );
}
void QShapeControllerPixmap::readData( const QString &element,
const QXmlStreamAttributes &attrs,
const QString &data,
QGraphicsItem *item ) const
{
QGraphicsPixmapItem *pixmapItem = static_cast< QGraphicsPixmapItem * >( item );
if( element == "pos" ) {
pixmapItem->setPos( attrs.value( "x" ).toString().toDouble(),
attrs.value( "y" ).toString().toDouble() );
pixmapItem->setZValue( attrs.value( "z" ).toString().toDouble() );
return;
}
if( element == "scale" ) {
pixmapItem->setTransform( QTransform().scale( attrs.value( "sx" ).toString().toDouble(),
attrs.value( "sy" ).toString().toDouble() ) );
}
if( element == "image" ) {
pixmapItem->setData( 0, data );
QPixmap pixmap( data );
if( pixmap.isNull() ) {
throw QString( "QShapeControllerPixmap: image loading from \"" ) +
data + "\" failed";
}
pixmapItem->setPixmap( pixmap );
pixmapItem->setOffset( -QPointF( pixmap.size().height(), pixmap.size().width() ) / 2.0 );
return;
}
}
+56
View File
@@ -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 QLIGHTPIXMAPITEM_H
#define QLIGHTPIXMAPITEM_H
#include <QGraphicsPixmapItem>
#include "qshapefactory.h"
class QLightPixmapItem : public QGraphicsPixmapItem
{
public:
QLightPixmapItem();
protected:
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value );
};
class QShapeControllerPixmap : public QShapeController {
public:
enum { Type = QLightPixmapItem::Type };
virtual QString name() const;
virtual QString menuName() const;
virtual QGraphicsItem *create() const;
protected:
virtual QItemDialog *createDialog( QWidget *parent ) const;
virtual void writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const;
virtual void readData( const QString &element,
const QXmlStreamAttributes &attrs,
const QString &data,
QGraphicsItem *item ) const;
};
#endif // QLIGHTPIXMAPITEM_H
@@ -16,95 +16,98 @@
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$ */
#include "qgraphicsroundtextitem.h"
#include "qlightroundtextitem.h"
#include "qdialogroundtext.h"
#include "qcdscene.h"
#include <QPainter>
#include <QFontMetrics>
#include <QStyleOptionGraphicsItem>
#include <QMessageBox>
#include <QXmlStreamWriter>
#include <QTextLayout>
#include <math.h>
QGraphicsRoundTextItem::QGraphicsRoundTextItem( QGraphicsItem *parent )
QLightRoundTextItem::QLightRoundTextItem( QGraphicsItem *parent )
: QAbstractGraphicsShapeItem( parent ),
m_radius( 40.0 ),
m_angle( 0.0 ),
m_alignment( Qt::AlignLeft ),
m_outside( true )
{
setBrush( Qt::black );
}
const QFont & QGraphicsRoundTextItem::font() const
const QFont & QLightRoundTextItem::font() const
{
return m_font;
}
const QString & QGraphicsRoundTextItem::text() const
const QString & QLightRoundTextItem::text() const
{
return m_text;
}
double QGraphicsRoundTextItem::radius() const
double QLightRoundTextItem::radius() const
{
return m_radius;
}
double QGraphicsRoundTextItem::angle() const
double QLightRoundTextItem::angle() const
{
return m_angle;
}
Qt::Alignment QGraphicsRoundTextItem::alignment() const
Qt::Alignment QLightRoundTextItem::alignment() const
{
return m_alignment;
}
bool QGraphicsRoundTextItem::outside() const
bool QLightRoundTextItem::outside() const
{
return m_outside;
}
void QGraphicsRoundTextItem::setFont( const QFont &font )
void QLightRoundTextItem::setFont( const QFont &font )
{
prepareGeometryChange();
m_font = font;
}
void QGraphicsRoundTextItem::setText( const QString &text )
void QLightRoundTextItem::setText( const QString &text )
{
prepareGeometryChange();
m_text = text;
}
void QGraphicsRoundTextItem::setRadius( double radius )
void QLightRoundTextItem::setRadius( double radius )
{
prepareGeometryChange();
m_radius = radius;
}
void QGraphicsRoundTextItem::setAngle( double angle )
void QLightRoundTextItem::setAngle( double angle )
{
prepareGeometryChange();
m_angle = angle;
}
void QGraphicsRoundTextItem::setAlignment( Qt::Alignment alignment )
void QLightRoundTextItem::setAlignment( Qt::Alignment alignment )
{
prepareGeometryChange();
m_alignment = alignment;
}
void QGraphicsRoundTextItem::setOutside( bool outside )
void QLightRoundTextItem::setOutside( bool outside )
{
prepareGeometryChange();
m_outside = outside;
}
QRectF QGraphicsRoundTextItem::boundingRect() const
QRectF QLightRoundTextItem::boundingRect() const
{
double height = m_radius;
if( m_outside ) {
@@ -115,9 +118,11 @@ QRectF QGraphicsRoundTextItem::boundingRect() const
return QRectF( -height, -height, 2 * height, 2 * height );
}
QPainterPath QGraphicsRoundTextItem::shape() const
QPainterPath QLightRoundTextItem::shape() const
{
QFontMetrics mcs( m_font );
QFont font( m_font );
font.setPointSizeF( m_font.pointSizeF() / 2 );
QFontMetrics mcs( font );
double arcAngle = 0.0;
const double pad = 1;
@@ -164,18 +169,20 @@ QPainterPath QGraphicsRoundTextItem::shape() const
}
void QGraphicsRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
void QLightRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
{
Q_UNUSED( option );
Q_UNUSED( widget );
if( !painter || !m_radius ) return;
painter->save();
painter->setFont( m_font );
QFont font( m_font );
font.setPointSizeF( m_font.pointSizeF() / 2 );
painter->setFont( font );
//painter->drawEllipse( - m_radius, - m_radius, m_radius * 2, m_radius * 2 );
QFontMetrics mcs( m_font );
QFontMetrics mcs( font );
const double radi = m_radius - ( m_outside ? 0 : mcs.xHeight() );
const double diam = 2 * radi;
@@ -192,8 +199,14 @@ void QGraphicsRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphic
QTransform trans;
trans.rotateRadians( angle );
painter->setRenderHint( QPainter::TextAntialiasing, true );
painter->setWorldTransform( trans, true );
QPen p;
p.setBrush( brush() );
painter->setPen( p );
painter->setBrush( Qt::NoBrush );
int prevWidth = 0;
for( int i = 0; i < m_text.size(); ++i ) {
QChar ch = m_text[ i ];
@@ -202,9 +215,12 @@ void QGraphicsRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphic
trans.reset();
trans.rotateRadians( m_outside ? d : -d );
painter->setWorldTransform( trans, true );
prevWidth = mcs.width( ch );
painter->drawText( -prevWidth / 2.0, m_outside ? -m_radius : m_radius, ch );
painter->drawText( int( -prevWidth / 2.0 ),
int( m_outside ? -m_radius : m_radius ),
ch );
}
painter->restore();
if (option->state & QStyle::State_Selected) {
@@ -214,6 +230,14 @@ void QGraphicsRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphic
}
}
QVariant QLightRoundTextItem::itemChange( GraphicsItemChange change, const QVariant & value )
{
if( scene() && change == ItemPositionHasChanged )
static_cast<QCDScene *>( scene() )->setChanged();
return value;
}
RegisterController< QShapeControllerRoundText > regControllerRoundText;
QString QShapeControllerRoundText::name() const
@@ -228,7 +252,8 @@ QString QShapeControllerRoundText::menuName() const
QGraphicsItem *QShapeControllerRoundText::create() const
{
return new QGraphicsRoundTextItem;
QLightRoundTextItem *item = new QLightRoundTextItem;
return item;
}
QItemDialog *QShapeControllerRoundText::createDialog( QWidget *parent ) const
@@ -236,12 +261,20 @@ QItemDialog *QShapeControllerRoundText::createDialog( QWidget *parent ) const
return new QDialogRoundText( parent );
}
void QShapeControllerRoundText::replace( QGraphicsItem *item, const QString &from, const QString &to ) const
{
QLightRoundTextItem *textItem = static_cast< QLightRoundTextItem * >( item );
if( textItem->text() == from )
textItem->setText( to );
}
void QShapeControllerRoundText::writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const
{
const QGraphicsRoundTextItem *textItem = static_cast< const QGraphicsRoundTextItem * >( item );
const QLightRoundTextItem *textItem = static_cast< const QLightRoundTextItem * >( 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( "radius", QString::number( textItem->radius() ) );
writer.writeTextElement( "angle", QString::number( textItem->angle() ) );
@@ -257,11 +290,12 @@ void QShapeControllerRoundText::readData( const QString &element,
const QString &data,
QGraphicsItem *item ) const
{
QGraphicsRoundTextItem *textItem = static_cast< QGraphicsRoundTextItem * >( item );
QLightRoundTextItem *textItem = static_cast< QLightRoundTextItem * >( item );
if( element == "pos" ) {
textItem->setPos( attrs.value( "x" ).toString().toDouble(),
attrs.value( "y" ).toString().toDouble() );
textItem->setZValue( attrs.value( "z" ).toString().toDouble() );
return;
}
@@ -287,6 +321,16 @@ void QShapeControllerRoundText::readData( const QString &element,
return;
}
if( element == "radius" ) {
textItem->setRadius( data.toDouble() );
return;
}
if( element == "angle" ) {
textItem->setAngle( data.toDouble() );
return;
}
if( element == "alignment" ) {
textItem->setAlignment( Qt::Alignment( data.toInt() ) );
return;
@@ -16,21 +16,21 @@
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 QGRAPHICSROUNDTEXTITEM_H
#define QGRAPHICSROUNDTEXTITEM_H
#ifndef QLIGHTROUNDTEXTITEM_H
#define QLIGHTROUNDTEXTITEM_H
#include "qshapefactory.h"
#include <QAbstractGraphicsShapeItem>
#include <QFont>
class QGraphicsRoundTextItem : public QAbstractGraphicsShapeItem {
class QLightRoundTextItem : public QAbstractGraphicsShapeItem {
public:
enum { Type = UserType + 1 };
QGraphicsRoundTextItem( QGraphicsItem * parent = 0 );
QLightRoundTextItem( QGraphicsItem * parent = 0 );
const QFont &font() const;
const QString &text() const;
@@ -53,6 +53,10 @@ public:
QWidget *widget );
virtual int type() const { return Type; }
protected:
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value );
private:
QFont m_font;
QString m_text;
@@ -64,12 +68,13 @@ private:
class QShapeControllerRoundText : public QShapeController {
public:
enum { Type = QGraphicsRoundTextItem::Type };
enum { Type = QLightRoundTextItem::Type };
virtual QString name() const;
virtual QString menuName() const;
virtual QGraphicsItem *create() const;
virtual void replace( QGraphicsItem *item, const QString &from, const QString &to ) const;
protected:
virtual QItemDialog *createDialog( QWidget *parent ) const;
@@ -81,4 +86,4 @@ protected:
};
#endif // QGRAPHICSROUNDTEXTITEM_H
#endif // QLIGHTROUNDTEXTITEM_H
+119 -51
View File
@@ -201,6 +201,69 @@ bool QLightScribe::clReportLabelTimeEstimate(long time)
return false;
}
namespace {
class AutoUidSetter {
public:
AutoUidSetter() : m_saved( 0 ) {}
AutoUidSetter( uid_t userId ) : m_saved( 0 ) { set( userId ); }
~AutoUidSetter() { unset(); }
void set( uid_t userId )
{
if( userId ) {
setreuid( userId, 0 );
m_saved = userId;
}
}
void unset()
{
if( m_saved ) {
setreuid( 0, m_saved );
m_saved = 0;
}
}
private:
uid_t m_saved;
};
typedef void (LightScribe::DiscPrinter::*DiscPrinterOp)();
template<DiscPrinterOp dlock, DiscPrinterOp dunlock >
class AutoOp {
public:
AutoOp( LightScribe::DiscPrinter &printer ) : m_printer( &printer ), m_locked( false ) {}
AutoOp() { unlock(); }
void lock()
{
if( !m_locked ) {
(m_printer->*dlock)();
m_locked = true;
}
}
void unlock()
{
if( m_locked ) {
try {
(m_printer->*dunlock)();
}
catch(...){}
m_locked = false;
}
}
private:
LightScribe::DiscPrinter *m_printer;
bool m_locked;
};
}
extern uid_t realUserId;
void QLightScribe::run()
{
QMutexLocker lock( m_mutex );
@@ -254,69 +317,74 @@ void QLightScribe::run()
throw tr( "Cannot find drive: \"" ) + m_task->m_selectedDrive->displayName() + "\"";
DiscPrinter printer = printers.Item( found );
function = "LS_DiscPrinter_OpenPrintSession";
DiscPrintSession session = printer.OpenPrintSession();
LS_PrintCallbacks callbacks;
callbacks.AbortLabel = clAbortLabel;
callbacks.ReportPrepareProgress = clReportPrepareProgress;
callbacks.ReportLabelProgress = clReportLabelProgress;
callbacks.ReportFinished = clReportFinished;
callbacks.ReportLabelTimeEstimate = clReportLabelTimeEstimate;
AutoUidSetter autoUid;
AutoOp< &DiscPrinter::AddExclusiveUse, &DiscPrinter::ReleaseExclusiveUse > autoExclusive( printer );
AutoOp< &DiscPrinter::LockDriveTray, &DiscPrinter::UnlockDriveTray > autoLock( printer );
session.SetProgressCallback( &callbacks );
if( m_task->m_action == Task::print ) {
autoUid.set( realUserId );
function = "LS_DiscPrinter_AddExclusiveUse";
autoExclusive.lock();
function = "LS_DiscPrinter_LockDriveTray";
autoLock.lock();
}
const size_t bitmapHeaderSize = 54;
{
function = "LS_DiscPrinter_OpenPrintSession";
DiscPrintSession session = printer.OpenPrintSession();
if( m_task->m_action == Task::preview ) {
LS_PrintCallbacks callbacks;
callbacks.AbortLabel = clAbortLabel;
callbacks.ReportPrepareProgress = clReportPrepareProgress;
callbacks.ReportLabelProgress = clReportLabelProgress;
callbacks.ReportFinished = clReportFinished;
callbacks.ReportLabelTimeEstimate = clReportLabelTimeEstimate;
LS_Size size;
size.x = m_task->m_size.width();
size.y = m_task->m_size.height();
session.SetProgressCallback( &callbacks );
m_task->m_tmpFile.open();
const size_t bitmapHeaderSize = 54;
function = "LS_DiscPrintSession_PrintPreview";
session.PrintPreview( LS_windows_bitmap,
LS_LabelMode( m_task->m_parameters.m_labelMode ),
LS_DrawOptions( m_task->m_parameters.m_drawOptions ),
LS_PrintQuality( m_task->m_parameters.m_printQuality ),
LS_MediaOptimizationLevel( m_task->m_parameters.m_mediaOptimizationLevel ),
if( m_task->m_action == Task::preview ) {
LS_Size size;
size.x = m_task->m_size.width();
size.y = m_task->m_size.height();
m_task->m_tmpFile.open();
function = "LS_DiscPrintSession_PrintPreview";
session.PrintPreview( LS_windows_bitmap,
LS_LabelMode( m_task->m_parameters.m_labelMode ),
LS_DrawOptions( m_task->m_parameters.m_drawOptions ),
LS_PrintQuality( m_task->m_parameters.m_printQuality ),
LS_MediaOptimizationLevel( m_task->m_parameters.m_mediaOptimizationLevel ),
ba.data() + 14,
bitmapHeaderSize - 14,
ba.data() + bitmapHeaderSize,
ba.size() - bitmapHeaderSize,
m_task->m_tmpFile.fileName().toAscii().data(),
LS_windows_bitmap,
size,
true );
} else {
PrintParameters params = m_task->m_parameters;
delete m_task;
m_task = 0;
lock.unlock();
// print here
session.PrintDisc( LS_windows_bitmap,
LS_LabelMode( params.m_labelMode ),
LS_DrawOptions( params.m_drawOptions ),
LS_PrintQuality( params.m_printQuality ),
LS_MediaOptimizationLevel( params.m_mediaOptimizationLevel ),
ba.data() + 14,
bitmapHeaderSize - 14,
ba.data() + bitmapHeaderSize,
ba.size() - bitmapHeaderSize,
m_task->m_tmpFile.fileName().toAscii().data(),
LS_windows_bitmap,
size,
true );
} else {
PrintParameters params = m_task->m_parameters;
delete m_task;
m_task = 0;
lock.unlock();
// print here
try {
//printer.AddExclusiveUse();
//printer.LockDriveTray();
session.PrintDisc( LS_windows_bitmap,
LS_LabelMode( params.m_labelMode ),
LS_DrawOptions( params.m_drawOptions ),
LS_PrintQuality( params.m_printQuality ),
LS_MediaOptimizationLevel( params.m_mediaOptimizationLevel ),
ba.data() + 14,
bitmapHeaderSize - 14,
ba.data() + bitmapHeaderSize,
ba.size() - bitmapHeaderSize );
ba.size() - bitmapHeaderSize );
}
catch( LightScribe::LSException &ex ) {
emit finished( ex.GetCode() );
throw;
}
//printer.UnlockDriveTray();
//printer.ReleaseExclusiveUse();
}
function = "";
}
}
+2 -9
View File
@@ -21,6 +21,8 @@
#ifndef QLIGHTSCRIBE_H
#define QLIGHTSCRIBE_H
#include "qlscribe.h"
#include <QThread>
#include <QPixmap>
@@ -37,15 +39,6 @@ class QLightDrive;
class QLightScribe : public QThread {
Q_OBJECT
public:
enum LabelMode {
/** label the entire disc */
modeFull=0,
/** label within the title mode constraints */
modeTitle=1,
/** label within the content mode constraints */
modeContent=2
};
enum DrawOptions {
/** disable scaling of bitmaps; they will be cropped if needed */
drawDefault=0,
@@ -18,13 +18,27 @@
$Id$ */
#include "qshapecontrollers.h"
#include "qlighttextitem.h"
#include "qdialogtext.h"
#include "qdialogpixmap.h"
#include "qcdscene.h"
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
QLightTextItem::QLightTextItem()
{
}
QVariant QLightTextItem::itemChange( GraphicsItemChange change, const QVariant & value )
{
if( scene() && change == ItemPositionHasChanged )
static_cast<QCDScene *>( scene() )->setChanged();
return value;
}
RegisterController< QShapeControllerText > regControllerText;
QString QShapeControllerText::name() const
@@ -39,7 +53,11 @@ QString QShapeControllerText::menuName() const
QGraphicsItem *QShapeControllerText::create() const
{
return new QGraphicsSimpleTextItem;
QGraphicsItem *item = new QLightTextItem;
item->setTransform( QTransform().scale( 0.5, 0.5 ), true );
item->setPos( 0, -40.0 );
return item;
}
QItemDialog *QShapeControllerText::createDialog( QWidget *parent ) const
@@ -53,12 +71,20 @@ void QShapeControllerText::writeData( QXmlStreamWriter &writer, const QGraphicsI
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( "text", textItem->text() );
}
void QShapeControllerText::replace( QGraphicsItem *item, const QString &from, const QString &to ) const
{
QGraphicsSimpleTextItem *textItem = static_cast< QGraphicsSimpleTextItem * >( item );
if( textItem->text() == from )
textItem->setText( to );
}
void QShapeControllerText::readData( const QString &element,
const QXmlStreamAttributes &attrs,
@@ -70,6 +96,7 @@ void QShapeControllerText::readData( const QString &element,
if( element == "pos" ) {
textItem->setPos( attrs.value( "x" ).toString().toDouble(),
attrs.value( "y" ).toString().toDouble() );
textItem->setZValue( attrs.value( "z" ).toString().toDouble() );
return;
}
@@ -90,67 +117,3 @@ void QShapeControllerText::readData( const QString &element,
return;
}
}
RegisterController< QShapeControllerPixmap > regControllerPixmap;
QString QShapeControllerPixmap::name() const
{
return "image";
}
QString QShapeControllerPixmap::menuName() const
{
return QObject::tr( "Image", "QShapeControllerPixmap name" );
}
QGraphicsItem *QShapeControllerPixmap::create() const
{
return new QGraphicsPixmapItem;
}
QItemDialog *QShapeControllerPixmap::createDialog( QWidget *parent ) const
{
return new QDialogPixmap( parent );
}
void QShapeControllerPixmap::writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const
{
const QGraphicsPixmapItem *pixmapItem
= static_cast< const QGraphicsPixmapItem * >( item );
writer.writeEmptyElement( "pos" );
writer.writeAttribute(
QXmlStreamAttribute( "x", QString::number( pixmapItem->pos().x() ) ) );
writer.writeAttribute(
QXmlStreamAttribute( "y", QString::number( pixmapItem->pos().y() ) ) );
writer.writeTextElement( "image", pixmapItem->data( 0 ).toString() );
}
void QShapeControllerPixmap::readData( const QString &element,
const QXmlStreamAttributes &attrs,
const QString &data,
QGraphicsItem *item ) const
{
QGraphicsPixmapItem *pixmapItem = static_cast< QGraphicsPixmapItem * >( item );
if( element == "pos" ) {
pixmapItem->setPos( attrs.value( "x" ).toString().toDouble(),
attrs.value( "y" ).toString().toDouble() );
return;
}
if( element == "image" ) {
pixmapItem->setData( 0, data );
QPixmap pixmap( data );
if( pixmap.isNull() ) {
throw QString( "QShapeControllerPixmap: image loading from \"" ) +
data + "\" failed";
}
pixmapItem->setPixmap( pixmap );
pixmapItem->setOffset( -QPointF( pixmap.size().height(), pixmap.size().width() ) / 2.0 );
return;
}
}
@@ -18,22 +18,32 @@
$Id$ */
#ifndef QSHAPECONTROLLERS_H
#define QSHAPECONTROLLERS_H
#ifndef QLIGHTTEXTITEM_H
#define QLIGHTTEXTITEM_H
#include <QGraphicsSimpleTextItem>
#include "qshapefactory.h"
#include <QGraphicsSimpleTextItem>
#include <QGraphicsPixmapItem>
class QLightTextItem : public QGraphicsSimpleTextItem
{
public:
QLightTextItem();
protected:
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value );
};
class QShapeControllerText : public QShapeController {
public:
enum { Type = QGraphicsSimpleTextItem::Type };
enum { Type = QLightTextItem::Type };
virtual QString name() const;
virtual QString menuName() const;
virtual QGraphicsItem *create() const;
virtual void replace( QGraphicsItem *item, const QString &from, const QString &to ) const;
protected:
virtual QItemDialog *createDialog( QWidget *parent ) const;
@@ -44,22 +54,4 @@ protected:
QGraphicsItem *item ) const;
};
class QShapeControllerPixmap : public QShapeController {
public:
enum { Type = QGraphicsPixmapItem::Type };
virtual QString name() const;
virtual QString menuName() const;
virtual QGraphicsItem *create() const;
protected:
virtual QItemDialog *createDialog( QWidget *parent ) const;
virtual void writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const;
virtual void readData( const QString &element,
const QXmlStreamAttributes &attrs,
const QString &data,
QGraphicsItem *item ) const;
};
#endif // QSHAPECONTROLLERS_H
#endif // QLIGHTTEXTITEM_H
+38
View File
@@ -0,0 +1,38 @@
/* 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 QLSCRIBE_H
#define QLSCRIBE_H
#include <iostream>
#include <QString>
enum LabelMode {
/** label the entire disc */
modeFull=0,
/** label within the title mode constraints */
modeTitle=1,
/** label within the content mode constraints */
modeContent=2
};
std::ostream &operator<<( std::ostream &os, const QString &str );
#endif // QLSCRIBE_H
+16 -7
View File
@@ -1,37 +1,46 @@
TEMPLATE = app
LANGUAGE = C++
CONFIG += qt
INCLUDEPATH += ../build/src
QMAKE_CXXFLAGS += -m32
QMAKE_LFLAGS += -m32
QMAKE_LIBDIR = /usr/lib32
SOURCES += main.cpp \
mainwindow.cpp \
qgraphicsroundtextitem.cpp \
qlightroundtextitem.cpp \
qcdview.cpp \
qcdscene.cpp \
qshapefactory.cpp \
qshapecontrollers.cpp \
qdialogtext.cpp \
qdialogroundtext.cpp \
qlightscribe.cpp \
qdialogpixmap.cpp \
qdialogprint.cpp \
qdialogprogress.cpp
qdialogprogress.cpp \
qlighttextitem.cpp \
qlightpixmapitem.cpp \
qdialogcdproperties.cpp \
qconsoleprintprogress.cpp
QMAKE_LIBS += -llightscribe
HEADERS += mainwindow.h \
qgraphicsroundtextitem.h \
qlightroundtextitem.h \
qcdview.h \
qcdscene.h \
qshapefactory.h \
qshapecontrollers.h \
qdialogtext.h \
qdialogroundtext.h \
qlightscribe.h \
qdialogpixmap.h \
qdialogprint.h \
qdialogprogress.h
qdialogprogress.h \
qlighttextitem.h \
qlightpixmapitem.h \
qlscribe.h \
qdialogcdproperties.h \
qconsoleprintprogress.h
FORMS += qdialogtext.ui \
qdialogroundtext.ui \
qdialogpixmap.ui \
qdialogprint.ui \
qdialogprogress.ui
qdialogprogress.ui \
qdialogcdproperties.ui
+10 -1
View File
@@ -16,9 +16,10 @@
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$ */
#include "qshapefactory.h"
#include "qcdscene.h"
#include <QGraphicsItem>
#include <QMessageBox>
@@ -43,6 +44,10 @@ bool QShapeController::edit( QGraphicsItem *item, QWidget *parent ) const
throw;
}
delete dialog;
if( rez && item->scene() )
static_cast< QCDScene * >( item->scene() )->setChanged();
return rez;
}
@@ -83,6 +88,10 @@ QGraphicsItem *QShapeController::read( QXmlStreamReader &reader ) const
return item;
}
void QShapeController::replace( QGraphicsItem *, const QString &, const QString & ) const
{
}
QShapeFactory &QShapeFactory::QShapeFactory::instance()
{
static QShapeFactory inst;
+4 -1
View File
@@ -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 QSHAPEFACTORY_H
#define QSHAPEFACTORY_H
@@ -46,10 +46,13 @@ public:
virtual QString name() const = 0;
virtual QString menuName() const = 0;
virtual QGraphicsItem *create() const = 0;
bool edit( QGraphicsItem *item, QWidget *parent ) const;
void write( QXmlStreamWriter &writer, const QGraphicsItem *item ) const;
QGraphicsItem *read( QXmlStreamReader &reader ) const;
virtual void replace( QGraphicsItem *item, const QString &from, const QString &to ) const;
protected:
virtual QItemDialog *createDialog( QWidget *parent ) const = 0;
virtual void writeData( QXmlStreamWriter &writer, const QGraphicsItem *item ) const = 0;