123 Commits

Author SHA1 Message Date
ruglory c67c6bc864 Tagging the 0.12 release
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/tags/release-0.12@153 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-24 00:44:48 +00:00
ruglory d32d6ab1e6 Prepared for 0.12
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@152 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-24 00:40:45 +00:00
ruglory 06b2f841dc Bugfix for not properly drawing partically covered window background
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@151 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-24 00:32:52 +00:00
ruglory b55b148cca Bugfix for error in open qlx
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@150 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-24 00:32:10 +00:00
ruglory 086181cd8f Bugfix for labels opened from commandline not updating menu
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@149 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-24 00:31:23 +00:00
ruglory 51402c10d6 Added ability to open image as a document
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@148 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-23 20:52:17 +00:00
ruglory c298a43b2f Round text changes radius and angle when is dragged by mouse instead of moving the center
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@147 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-22 02:48:03 +00:00
ruglory 577280f001 Main window stores/restores position and size from/to config
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@146 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-20 20:41:25 +00:00
ruglory be3a94cf74 Typo fixed
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@145 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-15 05:58:13 +00:00
ruglory 9537ece5fd Prepared for 0.12 prerelease
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@144 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-15 05:55:54 +00:00
ruglory 704cfe0831 Fixed bug for round text not updateting last used font
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@143 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-15 05:55:10 +00:00
ruglory 72c3e11909 Prepared for 0.11
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@141 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-04 03:41:06 +00:00
ruglory 9f94e61ad6 Added ability to eject media after print
Report to syslog added


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@140 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-04 03:36:07 +00:00
ruglory ce0b6d2ee4 Program settings added
Added option to eject media after print


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@139 cac9541e-1b8d-4bfa-827e-589bba606050
2009-04-04 03:11:42 +00:00
ruglory a455e2e8ca deb package updated so dbus config files are installed/removed by dpkg
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@138 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-27 05:02:09 +00:00
ruglory 0e045cbf01 prepared for 0.11
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@137 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-27 04:33:04 +00:00
ruglory ecdd91d206 Gentoo patch-3 accepted
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@136 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-27 04:31:29 +00:00
ruglory a112d90ce9 Ready for 0.10
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@134 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-25 02:55:00 +00:00
ruglory dfe6ab4495 Gentoo patch from Mario Fetka
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@133 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-25 02:47:58 +00:00
ruglory 10639af10e Undo/redo implemented
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@132 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-24 22:26:57 +00:00
ruglory 7b8838c2cd doc updated
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@131 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-12 22:28:53 +00:00
ruglory 471b00cd56 debian file fixed for 0.9
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@130 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-11 01:06:14 +00:00
ruglory d2ca370801 Prepared for release 0.9
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@128 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-11 00:47:35 +00:00
ruglory 7d2ba90c7f Sticky bit removed
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@127 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-11 00:44:32 +00:00
ruglory 513f175a17 Documentation created
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@126 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-10 22:03:13 +00:00
ruglory 9d0dedee69 Resource added
Icon is set for appliaction


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@125 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-10 20:12:31 +00:00
ruglory d60b1e5026 Menu items are enabled/disabled on events
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@124 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-10 19:34:05 +00:00
ruglory ed318f7a16 Clipboard copy/cut/paste for items implemented
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@123 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-10 18:56:30 +00:00
ruglory 6795aead5f Fixed issue with printing to jpeg
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@122 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-10 17:34:32 +00:00
ruglory c101314bec Placholders has ? around name
Not set placeholders have their value replaced with empty string


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@121 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-10 03:42:49 +00:00
ruglory ac027069c0 Added parameter --file - to process file with KEY=VALUE lines
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@120 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-10 03:41:54 +00:00
ruglory 657053175a Image name moved to object from metadata
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@119 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-10 03:40:59 +00:00
ruglory 47f54badc2 Print to image command line added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@118 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-09 22:42:35 +00:00
ruglory 56242ad4d1 Updated for amd64 ubuntu package
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@117 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-05 17:11:20 +00:00
ruglory 5bc5aa05be Changes for ubuntu proper build
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@116 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-05 06:06:05 +00:00
ruglory 991a18aab2 Fixed bug with missing signals
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@113 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-05 03:39:23 +00:00
ruglory 22f68d0e90 Prepared for 0.8 release
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@111 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-05 03:04:53 +00:00
ruglory 43e705ec5b Dbus service file created
Dbus variables fixed
Installation of lscribed and config files added


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@110 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-05 02:47:51 +00:00
ruglory 47a4e66d7c DBUS variables fixed
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@109 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-05 02:46:30 +00:00
ruglory 354920a751 Termination on timeout added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@108 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-05 01:36:44 +00:00
ruglory 72128fabee Check for image size added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@107 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-03 01:15:52 +00:00
ruglory 7ee08c8f57 Callbacks on print implemented
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@106 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-03 01:13:56 +00:00
ruglory 97d6a88eec Preview implemented
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@105 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-03 01:02:43 +00:00
ruglory 782695beb8 Debug drive added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@104 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-02 21:48:36 +00:00
ruglory c56be0b72c Added threading functionality
DrivesManager and Drive created


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@103 cac9541e-1b8d-4bfa-827e-589bba606050
2009-03-02 05:27:54 +00:00
ruglory b0872ed024 Missing header added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@102 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-26 02:59:39 +00:00
ruglory e3ab667555 Override cursod is added to print()
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@101 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-25 22:52:49 +00:00
ruglory f5b923cff1 Cosmetic changes
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@100 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-25 22:51:13 +00:00
ruglory 58e7b7e325 Override cursor added for dbus operations
Placeholders for BlockWithGui added but error seems not to be processed properly


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@99 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-25 22:50:45 +00:00
ruglory e9e2e0ca9e Potentially unsave string processing code replaced
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@98 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-25 21:57:16 +00:00
ruglory c7489c8aa8 Message handling moved to object interface
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@97 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-25 21:50:48 +00:00
ruglory 72c56fddb1 IntrospectHandler class added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@96 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-25 21:23:46 +00:00
ruglory 45565e319c Cosmetic changes
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@95 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-23 23:14:34 +00:00
ruglory 217066fca3 Added objects introspection
Adde handling for Manager and drives


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@94 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-23 22:51:21 +00:00
ruglory 86ed2ae007 DBus search improved
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@93 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-23 22:50:34 +00:00
ruglory 9ca35f35a0 error handling improved
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@92 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-23 22:49:43 +00:00
ruglory 3da9370b98 new method name added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@91 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-23 22:49:27 +00:00
ruglory 38f74b2970 manager added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@90 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-23 19:48:54 +00:00
ruglory 327508395e Dbus path to drives added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@89 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-23 04:45:40 +00:00
ruglory 16d043ff5d Base dbus functionality implemented
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@88 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-23 04:44:51 +00:00
ruglory fd77471f1a QObject2StringMap is used everywhere
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@87 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-23 03:31:14 +00:00
ruglory 7ef4666fce signal parameter changed from long to int
marshalling implemented


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@86 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-23 02:59:26 +00:00
ruglory 93e0426ba9 Added dbus config file
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@85 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 22:37:36 +00:00
ruglory cbac965e47 qlscribe.h renamed to qlscribe.h.in to be generated from cmake
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@84 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 22:30:18 +00:00
ruglory c27ea7e8a4 Configurable header added
qtcreator project added


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@83 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 22:28:23 +00:00
ruglory 733d7e29c3 QConsolePrintProgress fixed to connect to drive
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@82 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 06:36:38 +00:00
ruglory 80d1d040a6 Interface to dbus implemented
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@81 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 06:32:49 +00:00
ruglory 5112d2d409 Prepared for release 0.8
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@80 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 06:32:15 +00:00
ruglory 63f769fc04 Check for uid removed
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@79 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 06:31:50 +00:00
ruglory 5e67454a9b extimateTiume signal returned
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@78 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 06:31:34 +00:00
ruglory 737b94e463 Prepared to move for dbus implementation
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@77 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 05:31:38 +00:00
ruglory 2732500e95 Fixed xml format for qdbusxml2cpp
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@76 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 05:30:51 +00:00
ruglory b9629e2064 Qt dependecies moved to src
added subdir qlscribed


git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@75 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 05:30:08 +00:00
ruglory 35258f9bfa dbus interface spec added
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@74 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 04:12:09 +00:00
ruglory 8dd3982ec2 added dbus daemon basic structure
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@73 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 01:28:45 +00:00
ruglory dec9f11d2b Added module to find dbus 32 library
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@72 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-22 01:27:45 +00:00
ruglory c26da6e633 debian dir copied to trunk
git-svn-id: https://svn.code.sf.net/p/qlscribe/svn/trunk@71 cac9541e-1b8d-4bfa-827e-589bba606050
2009-02-20 20:47:39 +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
83 changed files with 4945 additions and 735 deletions
+10 -8
View File
@@ -22,14 +22,16 @@ PROJECT( qlscribe )
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
# lightSribe provides library only for m32 (yet?)
IF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_COMPILER_IS_GNUCXX )
ADD_DEFINITIONS( -m32 )
SET( CMAKE_EXE_LINKER_FLAGS "-m32 ${CMAKE_EXE_LINKER_FLAGS}" )
ENDIF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_COMPILER_IS_GNUCXX )
SET( FINAL_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Final install path")
SET( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )
FIND_PACKAGE( Qt4 REQUIRED )
FIND_PACKAGE( LightScribe REQUIRED )
SET( QLSCRIBE_DBUS_SERVICE org.lightscribe )
SET( QLSCRIBE_DBUS_MANAGER_SERVICE ${QLSCRIBE_DBUS_SERVICE}.Manager )
SET( QLSCRIBE_DBUS_DRIVES_SERVICE ${QLSCRIBE_DBUS_SERVICE}.drives )
SET( QLSCRIBE_DBUS_PATH /org/lightscribe )
SET( QLSCRIBE_DBUS_MANAGER_PATH ${QLSCRIBE_DBUS_PATH}/Manager ) # path to manager
SET( QLSCRIBE_DBUS_DRIVES_PATH ${QLSCRIBE_DBUS_PATH}/drives ) # base path under which drives located
SUBDIRS( src )
SUBDIRS( resources )
SUBDIRS( lscribed )
+43
View File
@@ -0,0 +1,43 @@
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
You need manually install dbus config and service files. They are located in INSTALL_PATH/share/qlscribe
So on my ubuntu system I do
sudo cp /usr/local/share/qlscribe/lightscribe.conf /etc/dbus-1/system.d/
sudo cp /usr/local/share/qlscribe/org.lightscribe.Manager.service /usr/share/dbus-1/system-services/
sudo /etc/init.d/dbus reload
Your system may have different path please refer dbus system daemon documentation
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!
+68 -3
View File
@@ -1,6 +1,71 @@
NEWS - list of user-visible changes between releases of qlscribe
New in 0.1:
* First release of qlscribe
* *
New in 0.12:
Fixed bug for round text not updating last used font
Main window stores/restores position and size from/to config
Round text changes radius and angle when dragged by mouse instead of moving the center
Added ability to open image as a document
Bugfix for labels opened from commandline not updating menu
Bugfix for not properly drawing partially covered window background
New in 0.11:
Application settings added with default font to use and option to eject media
Added functionality to eject media after print
Debian packages use standard procedure to install/upgrade config files
New in 0.10:
Undo/Redo mechanism implemented
Some minor bugfixes
New in 0.9:
Parameter --image added to print label in console mode into image
Parameter --file added to process file in format KEY=VALUE
Copy/cut/paste added for items in label
Menu rearranged and menu items enabled/disabled based on state
Application icon added
New in 0.8:
Application is splitted into 2 parts: qlscribe and dbus daemon lscribed
qlscribe does not require sticky bit and can be compiled in 64 bit mode if necessary
lscribed provides lightScribe service through system bus
lscribed is activated by dbus daemon and automatically terminates after 5 minutes of inactivity
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
+55
View File
@@ -0,0 +1,55 @@
# 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$
FIND_PATH( DBUS_INCLUDE_DIR dbus/dbus.h
PATH_SUFFIXES dbus-1.0 )
IF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
FIND_LIBRARY( DBUS_LIBRARY dbus-1
PATHS /lib32 /usr/lib32 /usr/local/lib32
NO_DEFAULT_PATH )
ENDIF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
FIND_LIBRARY( DBUS_LIBRARY dbus-1 )
get_filename_component( _dbusLibPath ${DBUS_LIBRARY} PATH )
FIND_PATH( DBUS_LIBINCLUDE_DIR dbus/dbus-arch-deps.h
PATHS /lib /usr/lib /usr/local/lib ${_dbusLibPath}
PATH_SUFFIXES dbus-1.0/include )
if( DBUS_INCLUDE_DIR AND DBUS_LIBINCLUDE_DIR AND DBUS_LIBRARY )
SET( Dbus32_FOUND TRUE )
SET( DBUS_LIBRARIES ${DBUS_LIBRARY} )
INCLUDE_DIRECTORIES(${DBUS_INCLUDE_DIR} ${DBUS_LIBINCLUDE_DIR} )
ENDIF( DBUS_INCLUDE_DIR AND DBUS_LIBINCLUDE_DIR AND DBUS_LIBRARY )
IF( Dbus32_FOUND )
IF( NOT Dbus32_FIND_QUIETLY )
MESSAGE( STATUS "Found dbus include: ${DBUS_INCLUDE_DIR}" )
MESSAGE( STATUS "Found dbus libraries: ${DBUS_LIBRARIES}" )
ENDIF( NOT Dbus32_FIND_QUIETLY )
ELSE( Dbus32_FOUND )
IF( Dbus32_FIND_REQUIRED )
MESSAGE( FATAL_ERROR "Could not find dbus" )
ENDIF( Dbus32_FIND_REQUIRED )
ENDIF( Dbus32_FOUND )
MARK_AS_ADVANCED( Dbus32_FOUND DBUS_INCLUDE_DIR DBUS_LIBRARY DBUS_LIBINCLUDE_DIR )
+4 -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 /usr/include/lightscribe $ENV{LIGHTSCRIBEDIR}/include )
FIND_LIBRARY( LSCRIBE_LIBRARY lightscribe /usr/local/lib )
FIND_LIBRARY( LSCRIBE_LIBRARY lightscribe /usr/local/lib /opt/lightscribe/lib /opt/lightscribe/lib32 $ENV{LIGHTSCRIBEDIR}/lib )
if( LSCRIBE_INCLUDE_DIR AND LSCRIBE_LIBRARY )
SET( LSCRIBE_FOUND TRUE )
SET( LSCRIBE_LIBRARIES ${LSCRIBE_LIBRARY} )
INCLUDE_DIRECTORIES(${LSCRIBE_INCLUDE_DIR})
ENDIF( LSCRIBE_INCLUDE_DIR AND LSCRIBE_LIBRARY )
IF( LSCRIBE_FOUND )
@@ -38,3 +39,4 @@ ELSE( LSCRIBE_FOUND )
ENDIF( LightScribe_FIND_REQUIRED )
ENDIF( LSCRIBE_FOUND )
MARK_AS_ADVANCED( LSCRIBE_INCLUDE_DIR LSCRIBE_LIBRARY LSCRIBE_FOUND )
+10
View File
@@ -0,0 +1,10 @@
qlscribe (0.12-0ubuntu1) unstable; urgency=low
* Release 0.12 imported
* Release 0.11 imported
* Release 0.10 imported
* Release 0.9 imported
* Release 0.8 imported
* Initial release
-- Vyacheslav Kononenko <vyacheslav@kononenko.net> Sun, 15 Feb 2009 21:49:41 -0500
+1
View File
@@ -0,0 +1 @@
7
+1
View File
@@ -0,0 +1 @@
/usr/share/dbus-1/services/org.lightscribe.Manager.service
+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: any
Depends: ${shlibs:Depends}, lightscribe
Description: Qt based application to print lightScribe discs
Qt lightScribe is a GUI application to burn labels on lightScribe capable drives.
+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
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
set -e
if [ "$1" = "configure" ] ; then
/etc/init.d/dbus reload
fi
#DEBHELPER#
exit 0
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
set -e
if [ "$1" = "remove" -o "$1" = "upgrade" ] ; then
PID=`pidof lscribed`
if [ "X$PID" != "X" ] ; then
kill $PID
fi
fi
if [ "$1" = "remove" ] ; then
/etc/init.d/dbus reload
fi
#DEBHELPER#
exit 0
Vendored Executable
+91
View File
@@ -0,0 +1,91 @@
#!/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 \
-DFINAL_INSTALL_PREFIX=/usr \
-DDBUS_SYSTEM_POLICY_DIR=$(CURDIR)/debian/qlscribe/etc/dbus-1/system.d \
-DDBUS_SYSTEM_SERVICE_DIR=$(CURDIR)/debian/qlscribe/usr/share/dbus-1/services
build: build-stamp
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
# 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
+128
View File
@@ -0,0 +1,128 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta name="keywords" content="Qt,lightscribe,linux,cddb">
<meta name="GENERATOR" content="PageBreeze Free HTML Editor (http://www.pagebreeze.com)">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" >
<title>HOWTO print CDDB titles with Qt lightscribe</title>
<style>
<!--
h1 { font-family: Arial, sans-serif; font-size: 30px; }
h2 { font-family: Arial, sans-serif; font-size: 18px; }
body,p,b,i,em,dt,dd,dl,sl,caption,th,td,tr,u,blink,select,option,form,div,li { font-family: Arial, sans-serif; font-size: 12px; }
-->
</style>
</head>
<body bgcolor="#ffffff">
<p>This document describes how you can create a qlscribe
template for printing labels with CDDB information embedded. So let's start.</p>
<h4>1 Materials used.</h4>
<p>qlscribe version 0.9 or later is used. If you have older
version please <a
href="https://sourceforge.net/project/showfiles.php?group_id=251217">update</a> </p>
<p>I downloaded label images from <a
href="http://www.lightscribe.com/ideas/index.aspx?id=2358">lightScribe design
center</a></p>
<p>Music album "Aphex Twin / Girl Boy EP"&nbsp;I used just as an example, I do not
actually have this disc nor copy of it.</p>
<p>cddbcmd utility is part of package cddb and on Ubuntu
can be downloaded from standard repository:</p>
<pre> sudo apt-get install cddb</pre>
<h4>2 Create new label and load image</h4>
<p>Start qlscribe, hit File -&gt; New Label -&gt; Full. You
should see something like this:</p>
<p><img hspace="0" src="/dbimage.php?id=207997" border=0></p>
<p>Insert image Edit -&gt; Insert -&gt; Image then on
dialog click "Load image.." select image "MixTape.jpg" downloaded from <a
href="http://www.lightscribe.com/ideas/index.aspx?id=2358">lightScribe design
center</a>&nbsp;Here how&nbsp;my label is&nbsp;looking now:</p>
<p><img hspace="0" src="/dbimage.php?id=207998" border=0></p>
<h4>3 Create text placeholders</h4>
<p>Now select Edit -&gt; Insert -&gt; Text&nbsp;and on
dialog put text "?DTITLE?". Question marks around name will make this text
disapear in qlscribe console mode print. This could be not necessary for disk
title as it usually set in CDDB data anyway, but would not harm. We should
put question marks on song names, as number of placeholders of title
names should be at least not less than songs on the disk. Adjust font size, so
when printed it would fit in white area. Now move your text box in the
place:</p>
<p><img hspace="0" src="/dbimage.php?id=207999" border=0></p>
<p>First we would create a placeholder for the first song,
adjust font properly and then copy/paste it for others. So Edit -&gt; Insert
-&gt; Text and put "?TTITLE0?". Again if we would not put question marks around
name it will still work, but unused placeholders will be printed as ugly
TTITLEN... strings. Move the text box to the proper position and press Ctrl-C or
from menu Edit -&gt; Copy. Press Ctrl-V and move the text box to the new postion
for TTITLE1. Right click, then "edit..." and change text to "?TTITLE1?". Repeat
until you have enough titles. Your label could look like this one now:</p>
<p><img hspace="0" src="/dbimage.php?id=208000" border=0></p>
<p>Hit menu File -&gt; Save, save it&nbsp;for example
as&nbsp;"tape.qlx" and exit qlscribe.</p>
<h4>4 Download CDDB data</h4>
<p>If you do not have audio disk in cd-rom you can lookup
your disk id from http://www.freedb.org/ or similar. Copy it and run this command:</p>
<pre> cddbcmd cddb read rock 4d03a706 &gt; girlboy.txt</pre>
<p>In my case disk id is rock/4d03a706.</p>
<p>Check that file have proper data, it should look similar
to this:</p>
<pre><code># xmcd CD database file
#^M
# Track frame offsets:
# 182
# 22097
# 40767
# 47095
# 55912
# 62745
#^M
# Disc length: 937 seconds
#^M
# Revision: 0
# Processed by: cddbd v1.5.2PL0 Copyright (c) Steve Scherf et al.
# Submitted via: IdiotJukebox 1.0 (Emacs 19.34.1)
#^M
DISCID=4d03a706
DTITLE=Aphex Twin / Girl Boy EP
TTITLE0=Girl Boy (nls mix)
TTITLE1=Milk Man
TTITLE2=Inkey$
TTITLE3=Girl Boy (Snarerushmix)
TTITLE4=Beetles
TTITLE5=Girl Boy (Redruthmix)
EXTD=
EXTT0=
EXTT1=
EXTT2=
EXTT3=
EXTT4=
EXTT5=
PLAYORDER=</code></pre>
<h4>5 Test you template</h4>
<p>Now we can test how our created at step 2-3 template works with the data. Run qlscribe
in console mode to print label as an image:</p>
<pre> qlscribe --image girlboy.jpg --file girlboy.txt tape.qlx</pre>
<p>If everything fine you should now see file girlboy.jpg
in the current directory. Here is what I got for mine:</p>
<p><img src="/dbimage.php?id=208002"></p>
<h4>6 Print label</h4>
<p>Now if you are happy with the result at step 5 you can print label
directly:</p>
<pre> qlscribe --print --file girlboy.txt tape.qlx</pre>
<p>Enjoy!</p>
<p>Please send comments,&nbsp;suggestions or noticed errors
directly to <a
href="mailto:vyacheslav@kononenko.net">mailto:vyacheslav@kononenko.net</a> or
visit <a
href="http://qlscribe.sourceforge.net">http://qlscribe.sourceforge.net</a> and create
an item in the Bug tracker.</p>
</body>
</html>
+67
View File
@@ -0,0 +1,67 @@
# 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$
FIND_PACKAGE( Dbus32 REQUIRED )
FIND_PACKAGE( LightScribe REQUIRED )
SET( LSCRIBED_CONF_FILE ${CMAKE_CURRENT_BINARY_DIR}/lightscribe.conf )
SET( LSCRIBED_SERVICE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${QLSCRIBE_DBUS_SERVICE}.Manager.service )
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/lscribed.h.in ${CMAKE_CURRENT_BINARY_DIR}/lscribed.h @ONLY )
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/lightscribe.conf.in ${LSCRIBED_CONF_FILE} @ONLY )
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/service.in ${LSCRIBED_SERVICE_FILE} @ONLY )
# lightSribe provides library only for m32 (yet?)
IF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_COMPILER_IS_GNUCXX )
ADD_DEFINITIONS( -m32 )
SET( CMAKE_EXE_LINKER_FLAGS "-m32 -pthread ${CMAKE_EXE_LINKER_FLAGS}" )
ENDIF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_COMPILER_IS_GNUCXX )
IF (DBUS_SYSTEM_POLICY_DIR)
INSTALL( FILES ${LSCRIBED_CONF_FILE} DESTINATION ${DBUS_SYSTEM_POLICY_DIR})
ELSE (DBUS_SYSTEM_POLICY_DIR)
MESSAGE(STATUS "It is necessary to specify the directory where the client policy file for Qt Lightscribe is installed as DBUS_SYSTEM_POLICY_DIR.")
MESSAGE(STATUS "Otherwise it will be installed into share/qlscribe")
MESSAGE(STATUS "Normally this is /etc/dbus-1/system.d on a Linux system")
INSTALL( FILES ${LSCRIBED_CONF_FILE} DESTINATION share/qlscribe )
ENDIF (DBUS_SYSTEM_POLICY_DIR)
IF (DBUS_SYSTEM_SERVICE_DIR)
INSTALL( FILES ${LSCRIBED_SERVICE_FILE} DESTINATION ${DBUS_SYSTEM_SERVICE_DIR})
ELSE (DBUS_SYSTEM_SERVICE_DIR)
MESSAGE(STATUS "It is necessary to specify the directory where the client service file for Qt Lightscribe is installed as DBUS_SYSTEM_SERVICE_DIR.")
MESSAGE(STATUS "Otherwise it will be installed into share/qlscribe")
MESSAGE(STATUS "Normally this is /usr/share/dbus-1/services on a Linux system")
INSTALL( FILES ${LSCRIBED_SERVICE_FILE} DESTINATION share/qlscribe )
ENDIF (DBUS_SYSTEM_SERVICE_DIR)
SET( LSCRIBED_SRCS main.cpp dbuscpp.cpp drives.cpp managerhandler.cpp drivehandler.cpp
introspecthandler.cpp )
ADD_DEFINITIONS( -Wall )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} )
ADD_EXECUTABLE( lscribed ${LSCRIBED_SRCS} )
TARGET_LINK_LIBRARIES( lscribed ${LSCRIBE_LIBRARIES} ${DBUS_LIBRARIES} pthread )
INSTALL( TARGETS lscribed DESTINATION sbin )
+219
View File
@@ -0,0 +1,219 @@
/* 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 "dbuscpp.h"
#include "lscribed.h"
using namespace DBusCpp;
MessageHandler::~MessageHandler()
{
}
std::string MessageHandler::generateInrospectHeader( const std::string &nodename )
{
std::string rez = "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" "
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">";
rez += " <node";
if( !nodename.empty() )
rez += "=\"" + nodename + "\"";
rez += "> <interface name=\"org.freedesktop.DBus.Introspectable\">"
" <method name=\"Introspect\">"
" <arg name=\"data\" direction=\"out\" type=\"s\"/>"
" </method>"
"</interface>";
return rez;
}
namespace {
DBusObjectPathVTable vtable;
DBusHandlerResult processMessage( DBusConnection *connPtr,
DBusMessage *messagePtr,
void *data )
{
Message message = Message::parameter( messagePtr );
lastActivity = time( 0 );
return reinterpret_cast< MessageHandler * >( data )->processMessage( message );
}
}
Connection::Connection( DBusConnection *conn )
: m_connection( conn )
{
if( !vtable.message_function )
vtable.message_function = processMessage;
}
Connection::~Connection()
{
for( Handlers::iterator it = m_handlers.begin(); it != m_handlers.end(); ++it ) {
dbus_connection_unregister_object_path( m_connection, it->first.c_str() );
delete it->second;
}
}
dbus_uint32_t Connection::send( const Message &msg )
{
dbus_uint32_t rez;
dbus_connection_send( m_connection, msg.m_message, &rez );
return rez;
}
void Connection::registerHandler( const std::string &path, MessageHandler *handler, bool fallback )
{
handler->m_connection = this;
m_handlers.insert( std::make_pair( path, handler ) );
if( fallback )
dbus_connection_register_fallback( m_connection, path.c_str(), &vtable, handler );
else
dbus_connection_register_object_path( m_connection, path.c_str(), &vtable, handler );
}
MessageIter::MessageIter( const MessageIter &an )
: m_iter( an.m_iter ), m_container( an.m_container )
{
if( m_container )
const_cast< MessageIter & >( an ).m_container = 0;
}
MessageIter::~MessageIter()
{
if( m_container )
dbus_message_iter_close_container( m_container, &m_iter );
}
MessageIter MessageIter::openContainer( int elemType, const char *signature )
{
MessageIter rez;
dbus_message_iter_open_container( &m_iter, elemType, signature, &rez.m_iter );
rez.m_container = &m_iter;
return rez;
}
void MessageIter::append( const char *str )
{
dbus_message_iter_append_basic( &m_iter, DBUS_TYPE_STRING, &str );
}
std::string MessageConstIter::signature() const
{
char *ptr = dbus_message_iter_get_signature( const_cast< DBusMessageIter *>( &m_iter ) );
std::string rez( ptr );
dbus_free( ptr );
return rez;
}
MessageConstIter MessageConstIter::recurse() const
{
MessageConstIter rez;
dbus_message_iter_recurse( const_cast< DBusMessageIter *>( &m_iter ), &rez.m_iter );
return rez;
}
void *MessageConstIter::getFixedArray( int &elements ) const
{
void *data =0;
dbus_message_iter_get_fixed_array( const_cast< DBusMessageIter *>( &m_iter ), &data, &elements );
return data;
}
Message::Message( int type )
{
m_message = dbus_message_new( type );
}
Message::Message( const Message &msg )
: m_message( msg.m_message )
{
dbus_message_ref( m_message );
}
Message::Message( DBusMessage *msg, bool ownership )
: m_message( msg )
{
if( !ownership )
dbus_message_ref( m_message );
}
Message::~Message()
{
dbus_message_unref( m_message );
}
Message Message::newSignal( const std::string &path,
const std::string &interface,
const std::string &name )
{
return Message( dbus_message_new_signal( path.c_str(), interface.c_str(), name.c_str() ),
true );
}
Message Message::newMethodReturn() const
{
return Message( dbus_message_new_method_return( m_message ), true );
}
Message Message::newError( const char *error, const char *message ) const
{
return Message( dbus_message_new_error( m_message, error, message ), true );
}
MessageConstIter Message::constIter() const
{
MessageConstIter rez;
dbus_message_iter_init( m_message, &rez.m_iter );
return rez;
}
MessageIter Message::appendIter()
{
MessageIter rez;
dbus_message_iter_init_append( m_message, &rez.m_iter );
return rez;
}
void Message::append( const char *str )
{
dbus_message_append_args( m_message, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID );
}
void Message::append( int32_t i )
{
dbus_message_append_args( m_message, DBUS_TYPE_INT32, &i, DBUS_TYPE_INVALID );
}
const char *Message::path() const
{
return dbus_message_get_path( m_message );
}
const char *Message::interface() const
{
return dbus_message_get_interface( m_message );
}
const char *Message::member() const
{
return dbus_message_get_member( m_message );
}
+144
View File
@@ -0,0 +1,144 @@
/* 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 DBUSCPP_H
#define DBUSCPP_H
#include <dbus/dbus.h>
#include <string>
#include <map>
namespace DBusCpp {
class Message;
class Connection;
class MessageHandler {
public:
MessageHandler() : m_connection( 0 ) {}
virtual ~MessageHandler();
virtual DBusHandlerResult processMessage( const Message &msg ) = 0;
Connection *connection() const { return m_connection; }
static std::string generateInrospectHeader( const std::string &nodename = std::string() );
friend class Connection;
private:
Connection *m_connection;
};
class Connection {
public:
Connection( DBusConnection *conn );
Connection( const Connection &conn ) : m_connection( conn.m_connection ) {}
~Connection();
dbus_uint32_t send( const Message &msg );
void registerHandler( const std::string &path, MessageHandler *handler, bool fallback );
void flush() { dbus_connection_flush( m_connection ); }
DBusConnection *ptr() const { return m_connection; }
private:
typedef std::map< std::string, MessageHandler * > Handlers;
DBusConnection *m_connection;
Handlers m_handlers;
};
class MessageIter {
public:
MessageIter( const MessageIter &an );
~MessageIter();
MessageIter openContainer( int eemType, const char *signature );
void append( const std::string &str ) { append( str.c_str() ); }
void append( const char *str );
friend class Message;
private:
MessageIter() : m_container( 0 ) {}
DBusMessageIter m_iter;
DBusMessageIter *m_container;
};
class MessageConstIter {
public:
MessageConstIter recurse() const;
std::string signature() const;
bool next() { return dbus_message_iter_next( &m_iter ); }
bool hasNext() const { return dbus_message_iter_has_next( const_cast< DBusMessageIter *>( &m_iter ) ); }
void *getFixedArray( int &elements ) const;
template <typename T> T getValue() const
{
T rez = T();
dbus_message_iter_get_basic( const_cast< DBusMessageIter *>( &m_iter ), &rez );
return rez;
}
friend class Message;
private:
DBusMessageIter m_iter;
};
class Message {
public:
explicit Message( int type );
Message( const Message &msg );
~Message();
static Message parameter( DBusMessage *msg ) { return Message( msg, false ); }
Message newMethodReturn() const;
Message newError( const char *error, const char *message ) const;
static Message newSignal( const std::string &path,
const std::string &interface,
const std::string &name );
bool isMethodCall( const char *interface, const char *method ) const
{ return dbus_message_is_method_call( m_message, interface, method ); }
MessageConstIter constIter() const;
MessageIter appendIter();
void append( const std::string &str ) { append( str.c_str() ); }
void append( const char *str );
void append( int32_t i );
const char *path() const;
const char *interface() const;
const char *member() const;
friend class Connection;
private:
Message( DBusMessage *msg, bool ownership );
DBusMessage *m_message;
};
}
#endif // DBUSCPP_H
+116
View File
@@ -0,0 +1,116 @@
/* 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 <iostream>
#include <string.h>
#include "lscribed.h"
#include "drivehandler.h"
#include "drives.h"
using namespace DBusCpp;
static const char *strDriveIntrospect =
"<interface name=\"org.lightscribe.drive\">\
<signal name=\"prepareProgress\">\
<arg name=\"current\" type=\"i\" direction=\"out\"/>\
<arg name=\"final\" type=\"i\" direction=\"out\"/>\
</signal>\
<signal name=\"labelProgress\">\
<arg name=\"current\" type=\"i\" direction=\"out\"/>\
<arg name=\"final\" type=\"i\" direction=\"out\"/>\
</signal>\
<signal name=\"timeEstimate\">\
<arg name=\"time\" type=\"i\" direction=\"out\"/>\
</signal>\
<signal name=\"finished\">\
<arg name=\"status\" type=\"i\" direction=\"out\"/>\
</signal>\
<method name=\"preview\">\
<arg type=\"s\" direction=\"out\"/>\
<arg name=\"params\" type=\"(iiiii)\" direction=\"in\"/>\
<arg name=\"image\" type=\"ay\" direction=\"in\"/>\
<arg name=\"previewSize\" type=\"(ii)\" direction=\"in\"/>\
</method>\
<method name=\"print\">\
<arg name=\"params\" type=\"(iiiii)\" direction=\"in\"/>\
<arg name=\"image\" type=\"ay\" direction=\"in\"/>\
</method>\
<method name=\"abort\">\
</method>\
<method name=\"name\">\
<arg direction=\"out\" type=\"s\"/>\
</method>\
</interface>";
DBusHandlerResult DriveHandler::processMessage( const Message &msg )
{
DBusHandlerResult rez = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
const char *path = msg.path();
if( !path )
return rez;
const char *item = strrchr( path, '/' );
if( !item )
return rez;
if( item[ 0 ] == '/' ) ++item;
DrivesManager &manager = DrivesManager::instance();
if( msg.isMethodCall( "org.freedesktop.DBus.Introspectable", "Introspect" ) ) {
std::string introspect = generateInrospectHeader();
if( strcmp( item, "drives" ) == 0 ) {
for( DrivesManager::const_iterator it = manager.begin(); it != manager.end(); ++it )
introspect += "<node name=\"" + (*it)->path() + "\"/>";
}
else
introspect += strDriveIntrospect;
introspect += "</node>";
Message reply = msg.newMethodReturn();
reply.append( introspect );
connection()->send( reply );
return rez = DBUS_HANDLER_RESULT_HANDLED;
}
const char *interface = msg.interface();
if( !interface || strcmp( interface, "org.lightscribe.drive" ) )
return rez;
const char *member = msg.member();
if( !member )
return rez;
DrivesManager::const_iterator f = manager.find( item );
if( f == manager.end() )
return rez;
rez = DBUS_HANDLER_RESULT_HANDLED;
std::cout << "calling method " << member << " on item " << item << std::endl;
(*f)->invoke( member, msg );
return rez;
}
+35
View File
@@ -0,0 +1,35 @@
/* 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 DRIVEHANDLER_H
#define DRIVEHANDLER_H
#include "dbuscpp.h"
namespace DBusCpp {
class DriveHandler : public MessageHandler {
public:
virtual DBusHandlerResult processMessage( const Message &msg );
};
}
#endif // DRIVEHANDLER_H
+421
View File
@@ -0,0 +1,421 @@
/* 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 "drives.h"
#include "lscribed.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <syslog.h>
#include <lightscribe_cxx.h>
#include <fstream>
#include <iostream>
using namespace LightScribe;
static pthread_key_t drivesKey;
static Drive *getDriveForThread()
{
return reinterpret_cast<Drive *>( pthread_getspecific( drivesKey ) );
}
static bool clAbortLabel()
{
Drive *drive = getDriveForThread();
return drive ? drive->isAborted() : true;
}
static void clReportPrepareProgress( long current, long final )
{
Drive *drive = getDriveForThread();
if( drive ) {
DBusCpp::Message msg = DBusCpp::Message::newSignal( drive->fullPath(),
"org.lightscribe.drive",
"prepareProgress" );
msg.append( current );
msg.append( final );
DrivesManager::instance().connection().send( msg );
}
}
static void clReportLabelProgress( long current, long final )
{
Drive *drive = getDriveForThread();
if( drive ) {
DBusCpp::Message msg = DBusCpp::Message::newSignal( drive->fullPath(),
"org.lightscribe.drive",
"labelProgress" );
msg.append( current );
msg.append( final );
DrivesManager::instance().connection().send( msg );
}
}
void clReportFinished( LSError status )
{
Drive *drive = getDriveForThread();
if( drive ) {
DBusCpp::Message msg = DBusCpp::Message::newSignal( drive->fullPath(),
"org.lightscribe.drive",
"finished" );
msg.append( status );
DrivesManager::instance().connection().send( msg );
}
}
static bool clReportLabelTimeEstimate( long time )
{
Drive *drive = getDriveForThread();
if( drive ) {
DBusCpp::Message msg = DBusCpp::Message::newSignal( drive->fullPath(),
"org.lightscribe.drive",
"timeEstimate" );
msg.append( time );
DrivesManager::instance().connection().send( msg );
}
return false;
}
static std::string generateTmp()
{
char *temp = tempnam( 0, ".bmp" );
std::string rez( temp );
free( temp );
return rez;
}
Drive::Drive( int index, const std::string &path, const std::string &name )
: m_index( index ), m_path( path ), m_name( name ), m_threadStarted( false ), m_message( 0 )
{
}
Drive::~Drive()
{
if( m_threadStarted ) {
pthread_cancel( m_thread );
pthread_join( m_thread, 0 );
pthread_cond_destroy( &m_cond );
}
}
std::string Drive::fullPath() const
{
return std::string( DBusDrivesPath ) + "/" + path();
}
bool Drive::active() const
{
return m_message != 0;
}
void *routine( void *ptr )
{
reinterpret_cast< Drive * >( ptr )->routine();
return ptr;
}
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void Drive::invoke( const std::string &method, const DBusCpp::Message &msg )
{
DrivesManager &man = DrivesManager::instance();
if( method == "name" ) {
DBusCpp::Message reply = msg.newMethodReturn();
reply.append( name() );
man.connection().send( reply );
return;
}
if( method == "abort" ) {
m_aborted = true;
DBusCpp::Message reply = msg.newMethodReturn();
man.connection().send( reply );
return;
}
if( method == "preview" || method == "print" ) {
if( !m_threadStarted ) {
m_threadStarted = true;
pthread_cond_init( &m_cond, 0 );
pthread_create( &m_thread, 0, ::routine, this );
}
pthread_mutex_lock( &mutex );
if( m_message ) {
DBusCpp::Message reply = msg.newError( DBUS_ERROR_FAILED, "drive is busy, try again later" );
man.connection().send( reply );
}
m_aborted = false;
m_message = new DBusCpp::Message( msg );
pthread_cond_signal( &m_cond );
pthread_mutex_unlock( &mutex );
return;
}
DBusCpp::Message reply = msg.newError( DBUS_ERROR_UNKNOWN_METHOD, "method is not supported" );
man.connection().send( reply );
}
void Drive::routine()
{
pthread_setspecific( drivesKey, this );
DrivesManager &man = DrivesManager::instance();
bool first = true;
while( true ) {
pthread_mutex_lock( &mutex );
if( first )
first = false;
else {
delete m_message;
m_message = 0;
}
while( !m_message )
pthread_cond_wait( &m_cond, &mutex );
pthread_mutex_unlock( &mutex );
bool preview = strcmp( m_message->member(), "preview" ) == 0;
LS_LabelMode mode;
LS_DrawOptions options;
LS_PrintQuality quality;
LS_MediaOptimizationLevel level;
bool eject= false;
char *image = 0;
int imageSize = 0;
LS_Size size;
try {
DBusCpp::MessageConstIter iter = m_message->constIter();
if( iter.signature() != "(iiiii)" )
throw std::string( "invalid argument for params: " ) + iter.signature() + ", (iiiii) expected";
DBusCpp::MessageConstIter sub = iter.recurse();
mode = LS_LabelMode( sub.getValue<int32_t>() ); sub.next();
options = LS_DrawOptions( sub.getValue<int32_t>() ); sub.next();
quality = LS_PrintQuality( sub.getValue<int32_t>() ); sub.next();
level = LS_MediaOptimizationLevel( sub.getValue<int32_t>() ); sub.next();
eject = sub.getValue<int32_t>();
if( !iter.next() )
throw std::string( "image argument missing" );
if( iter.signature() != "ay" )
throw std::string( "invalid argument for image: " ) + iter.signature() + ", ay expected";
sub = iter.recurse();
image = reinterpret_cast< char * >( sub.getFixedArray( imageSize ) );
if( preview ) {
if( !iter.next() )
throw std::string( "size argument missing" );
if( iter.signature() != "(ii)" )
throw std::string( "invalid argument for size: " ) + iter.signature() + ", (ii) expected";
sub = iter.recurse();
size.x = sub.getValue<int32_t>(); sub.next();
size.y = sub.getValue<int32_t>();
}
}
catch( const std::string &str ) {
std::cout << "exception " << str << std::endl;
DBusCpp::Message reply = m_message->newError( DBUS_ERROR_INVALID_ARGS, str.c_str() );
man.connection().send( reply );
syslog( LOG_ERR, "error in parsing request: %s", str.c_str() );
continue;
}
std::string tmpFile;
if( preview )
tmpFile = generateTmp();
if( m_index == -1 ) {
DBusCpp::Message reply = m_message->newMethodReturn();
if( preview ) { // this is debug drive, so just write input into output
std::ofstream out( tmpFile.c_str() );
out.write( image, imageSize );
out.close();
reply.append( tmpFile );
}
man.connection().send( reply );
continue;
}
const char *function = 0;
try {
const size_t bitmapHeaderSize = 54;
if( size_t( imageSize ) <= bitmapHeaderSize )
throw "Invalid image";
function = "LS_DiscPrintMgr_Create";
DiscPrintMgr manager;
function = "LS_DiscPrintMgr_EnumDiscPrinters";
EnumDiscPrinters printers = manager.EnumDiscPrinters();
if( m_index >= printers.Count() )
throw std::string( "internal error: invalid index" );
DiscPrinter printer = printers.Item( m_index );
{
function = "LS_DiscPrinter_OpenPrintSession";
DiscPrintSession session = printer.OpenPrintSession();
DBusCpp::Message reply = m_message->newMethodReturn();
if( preview ) {
syslog( LOG_INFO, "generating preview into temp file %s", tmpFile.c_str() );
function = "LS_DiscPrintSession_PrintPreview";
session.PrintPreview( LS_windows_bitmap,
mode,
options,
quality,
level,
image + 14,
bitmapHeaderSize - 14,
image + bitmapHeaderSize,
imageSize - bitmapHeaderSize,
const_cast< char *>( tmpFile.c_str() ),
LS_windows_bitmap,
size,
true );
reply.append( tmpFile );
man.connection().send( reply );
} else {
syslog( LOG_INFO, "printing label with parameters: mode %d, options %d, quality %d, level %d, eject %d",
mode, options, quality, level, eject );
LS_PrintCallbacks callbacks;
callbacks.AbortLabel = clAbortLabel;
callbacks.ReportPrepareProgress = clReportPrepareProgress;
callbacks.ReportLabelProgress = clReportLabelProgress;
callbacks.ReportFinished = clReportFinished;
callbacks.ReportLabelTimeEstimate = clReportLabelTimeEstimate;
session.SetProgressCallback( &callbacks );
man.connection().send( reply );
function = 0;
session.PrintDisc( LS_windows_bitmap,
mode,
options,
quality,
level,
image + 14,
bitmapHeaderSize - 14,
image + bitmapHeaderSize,
imageSize - bitmapHeaderSize );
}
}
if( !preview && eject )
printer.OpenDriveTray();
}
catch( LightScribe::LSException &ex ) {
if( function ) {
char message[ 255 ];
sprintf( message, "\"%s()\" failed with code 0x%X", function, ex.GetCode() );
DBusCpp::Message reply = m_message->newError( DBUS_ERROR_FAILED, message );
man.connection().send( reply );
syslog( LOG_ERR, "%s", message );
} else
clReportFinished( ex.GetCode() );
continue;
}
catch( const std::string &str ) {
DBusCpp::Message reply = m_message->newError( DBUS_ERROR_FAILED, str.c_str() );
man.connection().send( reply );
syslog( LOG_ERR, "operation failed: \"%s\"", str.c_str() );
continue;
}
}
}
DrivesManager::DrivesManager()
: m_connection( 0 )
{
}
void DrivesManager::init( DBusCpp::Connection conn, bool debug )
{
pthread_key_create( &drivesKey, 0 );
m_connection = conn;
if( debug )
m_drives.push_back( new Drive( -1, "drived", "Debug printer" ) );
DiscPrintMgr manager;
EnumDiscPrinters printers = manager.EnumDiscPrinters();
const unsigned count = printers.Count();
for( unsigned i = 0; i < count; ++i ) {
DiscPrinter printer = printers.Item( i );
char path[ 10 ];
sprintf( path, "drive%d", i );
m_drives.push_back( new Drive( i, path, printer.GetPrinterDisplayName() ) );
}
}
DrivesManager::~DrivesManager()
{
for( const_iterator f = begin(); f != end(); ++f )
delete *f;
}
DrivesManager &DrivesManager::instance()
{
static DrivesManager theManager;
return theManager;
}
bool DrivesManager::active() const
{
for( const_iterator f = begin(); f != end(); ++f )
if( (*f)->active() )
return true;
return false;
}
DrivesManager::const_iterator DrivesManager::find( const std::string &path ) const
{
const_iterator f;
for( f = begin(); f != end(); ++f )
if( (*f)->path() == path )
break;
return f;
}
+83
View File
@@ -0,0 +1,83 @@
/* 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 DRIVES_H
#define DRIVES_H
#include <vector>
#include <string>
#include "dbuscpp.h"
class Drive {
public:
const std::string &path() const { return m_path; }
std::string fullPath() const;
const std::string &name() const { return m_name; }
bool isAborted() const { return m_aborted; }
void invoke( const std::string &method, const DBusCpp::Message &msg );
bool active() const;
friend class DrivesManager;
friend void *routine( void * );
private:
Drive( int index, const std::string &path, const std::string &name );
~Drive();
void routine();
int m_index;
std::string m_path;
std::string m_name;
bool m_aborted;
bool m_threadStarted;
pthread_t m_thread;
pthread_cond_t m_cond;
DBusCpp::Message *m_message;
};
class DrivesManager {
public:
typedef std::vector< Drive * > Drives;
typedef Drives::const_iterator const_iterator;
static DrivesManager &instance();
void init( DBusCpp::Connection conn, bool debug );
const_iterator begin() const { return m_drives.begin(); }
const_iterator end() const { return m_drives.end(); }
const_iterator find( const std::string &path ) const;
bool active() const;
DBusCpp::Connection connection() const { return m_connection; }
private:
DrivesManager();
~DrivesManager();
Drives m_drives;
DBusCpp::Connection m_connection;
};
#endif // DRIVES_H
+58
View File
@@ -0,0 +1,58 @@
/* 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 "introspecthandler.h"
#include "lscribed.h"
#include <string.h>
using namespace DBusCpp;
DBusHandlerResult IntrospectHandler::processMessage( const Message &msg )
{
if( msg.isMethodCall( "org.freedesktop.DBus.Introspectable", "Introspect" ) ) {
const char *path = msg.path();
if( !path )
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
int pathlen = strlen( path );
std::string introspect = generateInrospectHeader();
if( strncmp( path, DBusManagerPath, pathlen ) == 0 ) {
if( pathlen != 1 ) ++pathlen;
const char *end = strchr( DBusManagerPath + pathlen, '/' );
if( end ) {
const int sublen = end - DBusManagerPath - pathlen;
introspect += "<node name=\"" +
std::string( DBusManagerPath + pathlen, sublen )
+ "\"/>";
} else
introspect += "<node name=\"Manager\"/><node name=\"drives\"/>";
}
introspect += "</node>";
Message reply = msg.newMethodReturn();
reply.append( introspect );
connection()->send( reply );
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
+35
View File
@@ -0,0 +1,35 @@
/* 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 INTROSPECTHANDLER_H
#define INTROSPECTHANDLER_H
#include "dbuscpp.h"
namespace DBusCpp {
class IntrospectHandler : public MessageHandler {
public:
virtual DBusHandlerResult processMessage( const Message &msg );
};
}
#endif // INTROSPECTHANDLER_H
+21
View File
@@ -0,0 +1,21 @@
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- ../system.conf have denied everything, so we just punch some holes -->
<!-- Only root can own the service -->
<policy user="root">
<allow own="@QLSCRIBE_DBUS_MANAGER_SERVICE@"/>
<allow send_interface="@QLSCRIBE_DBUS_MANAGER_SERVICE@"/>
<allow send_interface="@QLSCRIBE_DBUS_DRIVES_SERVICE@"/>
</policy>
<!-- Allow anyone to invoke methods on the interfaces -->
<policy context="default">
<allow send_interface="@QLSCRIBE_DBUS_MANAGER_SERVICE@"/>
<allow send_interface="@QLSCRIBE_DBUS_DRIVES_SERVICE@"/>
<allow receive_interface="@QLSCRIBE_DBUS_DRIVES_SERVICE@"/>
</policy>
</busconfig>
+34
View File
@@ -0,0 +1,34 @@
/* 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 LSCRIBED_H
#define LSCRIBED_H
#include <map>
#include <string>
const char * const DBusServiceName = "@QLSCRIBE_DBUS_MANAGER_SERVICE@";
const char * const DBusPath = "@QLSCRIBE_DBUS_PATH@";
const char * const DBusManagerPath = "@QLSCRIBE_DBUS_MANAGER_PATH@";
const char * const DBusDrivesPath = "@QLSCRIBE_DBUS_DRIVES_PATH@";
extern unsigned int lastActivity;
#endif // LSCRIBED_H
+20
View File
@@ -0,0 +1,20 @@
# -------------------------------------------------
# Project created by QtCreator 2009-02-22T16:31:18
# -------------------------------------------------
QT -= core \
gui
TARGET = lscribed
TEMPLATE = lib
INCLUDEPATH += /usr/include/dbus-1.0/
CONFIG += staticlib
SOURCES += main.cpp \
dbuscpp.cpp \
managerhandler.cpp \
drivehandler.cpp \
introspecthandler.cpp \
drives.cpp
HEADERS += dbuscpp.h \
drivehandler.h \
managerhandler.h \
introspecthandler.h \
drives.h
+134
View File
@@ -0,0 +1,134 @@
/* 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 <iostream>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <syslog.h>
#include "lscribed.h"
#include "dbuscpp.h"
#include "introspecthandler.h"
#include "managerhandler.h"
#include "drivehandler.h"
#include "drives.h"
unsigned int lastActivity = 0;
unsigned int activityTimeout = 300; // 5 min by default
bool terminateOnTimeout = false;
int alarmInterval = 1;
bool debug = false;
void onAlarm( int )
{
alarm( alarmInterval );
unsigned int curr = time( 0 );
if( lastActivity == 0 ) {
lastActivity = curr;
return;
}
if( curr - lastActivity < activityTimeout )
return;
if( DrivesManager::instance().active() ) {
lastActivity = curr;
return;
}
syslog( LOG_INFO, "terminating due to inactivity timeout" );
terminateOnTimeout = true;
}
void usage()
{
std::cerr << "usage: lscribed [--help] [--timeout t] [--debug]" << std::endl;
std::cerr << "\t--help print this message" << std::endl;
std::cerr << "\t--timeout interval (seconds) to terminate after inactivity 0 - disable, default 300" << std::endl;
std::cerr << "\t--debug to enable virtual drive and print debug statements" << std::endl;
}
int main( int argc, char **argv )
{
openlog( "lscribed", LOG_PID, LOG_DAEMON );
for( int i = 1; i < argc; ++i ) {
if( strcmp( argv[i], "--help" ) == 0 ) {
usage();
return 1;
}
if( strcmp( argv[i], "--timeout" ) == 0 ) {
if( i == argc - 1 ) {
std::cerr << "Error: agrument for --timeout expected" << std::endl;
usage();
return 2;
}
activityTimeout = atoi( argv[ ++ i ] );
continue;
}
if( strcmp( argv[i], "--debug" ) == 0 ) {
debug = true;
continue;
}
std::cerr << "Error: unknown parameter " << argv[ i ] << std::endl;
usage();
return 3;
}
dbus_threads_init_default();
DBusError err;
dbus_error_init( &err );
DBusCpp::Connection conn ( dbus_bus_get_private( DBUS_BUS_SYSTEM, &err ) );
if( dbus_error_is_set( &err ) ) {
std::cerr << "dbus_bus_get() error: " << err.message << std::endl;
dbus_error_free( &err );
return 1;
}
int ret = dbus_bus_request_name( conn.ptr(), DBusServiceName, DBUS_NAME_FLAG_REPLACE_EXISTING, &err );
if( dbus_error_is_set( &err ) ) {
std::cerr << "dbus_bus_request_name error: " << err.message << std::endl;
syslog( LOG_ERR, "dbus_bus_request_name error: %s", err.message );
dbus_error_free( &err );
return 2;
}
if( ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER ) {
std::cerr << "could not get ownership of \"" << DBusServiceName << "\" terminating" << std::endl;
syslog( LOG_ERR, "could not get ownership of \"%s\" terminating", DBusServiceName );
return 3;
}
conn.registerHandler( "/", new DBusCpp::IntrospectHandler, true );
conn.registerHandler( DBusManagerPath, new DBusCpp::ManagerHandler, false );
conn.registerHandler( DBusDrivesPath, new DBusCpp::DriveHandler, true );
DrivesManager::instance().init( conn, debug );
if( activityTimeout ) {
signal( SIGALRM, onAlarm );
alarm( alarmInterval );
}
while( dbus_connection_read_write_dispatch( conn.ptr(), 10 ) ) {
if( terminateOnTimeout )
dbus_connection_close( conn.ptr() );
}
return 0;
}
+73
View File
@@ -0,0 +1,73 @@
/* 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 "lscribed.h"
#include "managerhandler.h"
#include "drives.h"
using namespace DBusCpp;
#include <stdio.h>
static const char *strManagerIntrospect =
"<interface name=\"org.lightscribe.printManager\">\
<method name=\"getDrives\">\
<arg type=\"a{ss}\" direction=\"out\"/>\
</method>\
</interface>";
DBusHandlerResult ManagerHandler::processMessage( const Message &msg )
{
if( msg.isMethodCall( "org.freedesktop.DBus.Introspectable", "Introspect" ) ) {
Message reply = msg.newMethodReturn();
std::string introspect = generateInrospectHeader();
introspect += strManagerIntrospect;
introspect += "</node>";
reply.append( introspect );
connection()->send( reply );
return DBUS_HANDLER_RESULT_HANDLED;
}
if( msg.isMethodCall( "org.lightscribe.printManager", "getDrives" ) ) {
Message reply = msg.newMethodReturn();
MessageIter args = reply.appendIter();
{
MessageIter sub = args.openContainer( DBUS_TYPE_ARRAY, "{ss}" );
DrivesManager &manager = DrivesManager::instance();
for( DrivesManager::const_iterator it = manager.begin(); it != manager.end(); ++it ) {
MessageIter itemIterator = sub.openContainer( DBUS_TYPE_DICT_ENTRY, 0 );
itemIterator.append( std::string( DBusDrivesPath ) + "/" + (*it)->path() );
itemIterator.append( (*it)->name() );
}
}
connection()->send( reply );
return DBUS_HANDLER_RESULT_HANDLED;
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
+35
View File
@@ -0,0 +1,35 @@
/* 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 MANAGERHANDLER_H
#define MANAGERHANDLER_H
#include "dbuscpp.h"
namespace DBusCpp {
class ManagerHandler : public MessageHandler {
public:
virtual DBusHandlerResult processMessage( const Message &msg );
};
}
#endif // INTROSPECTHANDLER_H
+4
View File
@@ -0,0 +1,4 @@
[D-BUS Service]
Name=@QLSCRIBE_DBUS_MANAGER_SERVICE@
Exec=@FINAL_INSTALL_PREFIX@/sbin/lscribed
User=root
+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;
+5
View File
@@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>qlscribe64.png</file>
</qresource>
</RCC>
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

+44 -9
View File
@@ -18,27 +18,62 @@
#
# $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 )
FIND_PACKAGE( Qt4 REQUIRED )
SET( QT_USE_QTDBUS 1 )
SET( QLSCRIBE_UIS qdialogtext.ui qdialogroundtext.ui qdialogpixmap.ui qdialogprint.ui qdialogprogress.ui )
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
qdialogsettings.cpp )
SET( QLSCRIBE_UIS qdialogtext.ui qdialogroundtext.ui qdialogpixmap.ui
qdialogprint.ui qdialogprogress.ui qdialogcdproperties.ui qdialogsettings.ui )
SET( QLSCRIBE_MOC_HDRS mainwindow.h qcdscene.h qdialogpixmap.h qdialogroundtext.h
qdialogtext.h qlightscribe.h qdialogprint.h qdialogprogress.h )
qdialogtext.h qlightscribe.h qdialogprint.h qdialogprogress.h
qdialogcdproperties.h qconsoleprintprogress.h qdialogsettings.h )
ADD_DEFINITIONS( -Wall )
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/qlscribe.h.in ${CMAKE_CURRENT_BINARY_DIR}/qlscribe.h @ONLY )
INCLUDE( ${QT_USE_FILE} )
QT4_WRAP_UI( QLSCRIBE_UI_HDRS ${QLSCRIBE_UIS} )
QT4_WRAP_CPP( QLSCRIBE_MOC_SRCS ${QLSCRIBE_MOC_HDRS} )
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR}/src ${CMAKE_SOURCE_DIR}/src )
QT4_ADD_RESOURCES( QLSCRIBE_RCC_SRCS ../resources/qlscribe.qrc )
ADD_EXECUTABLE( qlscribe ${QLSCRIBE_SRCS} ${QLSCRIBE_MOC_SRCS} ${QLSCRIBE_UI_HDRS} )
MACRO(ADD_DBUS_INTERFACE _sources _interface _basename)
GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
TARGET_LINK_LIBRARIES( qlscribe ${QT_LIBRARIES} ${LSCRIBE_LIBRARIES} )
ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -i qlightscribe.h -p ${_basename} ${_infile}
DEPENDS ${_infile})
SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
QT4_GENERATE_MOC(${_header} ${_moc})
SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
ENDMACRO(ADD_DBUS_INTERFACE)
ADD_DBUS_INTERFACE( QLSCRIBE_DBUS_SRCS lightscribe.xml lightscribe_interface )
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
ADD_EXECUTABLE( qlscribe ${QLSCRIBE_SRCS} ${QLSCRIBE_MOC_SRCS}
${QLSCRIBE_RCC_SRCS} ${QLSCRIBE_UI_HDRS}
${QLSCRIBE_DBUS_SRCS} )
TARGET_LINK_LIBRARIES( qlscribe ${QT_LIBRARIES} )
INSTALL( TARGETS qlscribe
DESTINATION bin )
INSTALL( TARGETS qlscribe DESTINATION bin )
+65
View File
@@ -0,0 +1,65 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!-- 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$
-->
<node>
<interface name="org.lightscribe.printManager">
<method name="getDrives">
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QObject2StringMap"/>
<arg type="a{ss}" direction="out"/>
</method>
</interface>
<interface name="org.lightscribe.drive">
<signal name="prepareProgress">
<arg name="current" type="i" direction="out"/>
<arg name="final" type="i" direction="out"/>
</signal>
<signal name="labelProgress">
<arg name="current" type="i" direction="out"/>
<arg name="final" type="i" direction="out"/>
</signal>
<signal name="timeEstimate">
<arg name="time" type="i" direction="out"/>
</signal>
<signal name="finished">
<arg name="status" type="i" direction="out"/>
</signal>
<method name="preview">
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="const PrintParameters &amp;"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In2" value="QSize"/>
<arg type="s" direction="out"/>
<arg name="params" type="(iiiii)" direction="in"/>
<arg name="image" type="ay" direction="in"/>
<arg name="previewSize" type="(ii)" direction="in"/>
</method>
<method name="print">
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="const PrintParameters &amp;"/>
<arg name="params" type="(iiiii)" direction="in"/>
<arg name="image" type="ay" direction="in"/>
</method>
<method name="abort">
</method>
<method name="name">
<arg type="s" direction="out"/>
</method>
</interface>
</node>
+201 -6
View File
@@ -19,13 +19,208 @@
$Id$ */
#include <QApplication>
#include <QMessageBox>
#include <QMap>
#include <QPainter>
#include <QFile>
#include <QTextStream>
#include <QIcon>
#include "mainwindow.h"
#include "qcdscene.h"
#include "qlightscribe.h"
#include "qconsoleprintprogress.h"
int main(int argc, char **argv)
#include <iostream>
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--image | -i image - print to this image\n"
<< "\t\t--size | -s size - image size, 400 by default\n"
<< "\t\t--drive | -d NUMBER - use this drive, starts from 0, 0 is default\n"
<< "\t\t--replace | -r KEY=VALUE - replace text from KEY to VALUE\n"
<< "\t\t--file | -f filename - read replacements in format KEY=VALUE from file\n"
<< std::endl;
}
int main( int argc, char **argv )
{
QApplication app( argc, argv );
app.setApplicationName( "qlscribe" );
//app.setOrganizationName( "" );
app.setOrganizationDomain( "qlscribe.sourceforge.org" );
app.addLibraryPath( "/usr/lib32/qt4/plugins" );
app.setWindowIcon( QIcon( ":/qlscribe64.png" ) );
bool doPrint = false;
QStringList arguments = app.arguments();
QStringList files;
QCDScene::QString2String replacements;
int driveIndex = 0;
int imageSize = 400;
QString imageName;
QString replacementsFile;
PrintParameters params;
bool labelModeOverriden = false;
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 == "--file" || arg == "-f" ) {
if( i == arguments.size() - 1 ) {
std::cerr << "Error: arg#" << i
<< " argument expected for \"" << arg << "\" not enough parameters" << std::endl;
return 1;
}
QFile data( arguments[ ++i ] );
if( !data.open( QIODevice::ReadOnly ) ) {
std::cerr << "cannot open file \"" << arguments[ i ] << "\" for reading" << std::endl;
return 2;
}
QTextStream stream( &data );
while( true ) {
QString line = stream.readLine();
if( line.isNull() )
break;
int pos = line.indexOf( '=' );
if( pos == -1 )
continue;
replacements[ line.left( pos ) ] = line.right( line.size() - pos - 1 );
}
continue;
}
if( arg == "--drive" || arg == "-d" ) {
if( i == arguments.size() - 1 ) {
std::cerr << "Error: arg#" << i
<< " argument expected for \"" << arg << "\" not enough parameters" << std::endl;
return 1;
}
QString param = arguments[ ++i ];
driveIndex = param.toInt();
}
if( arg == "--image" || arg == "-i" ) {
if( i == arguments.size() - 1 ) {
std::cerr << "Error: arg#" << i
<< " argument expected for \"" << arg << "\" not enough parameters" << std::endl;
return 1;
}
doPrint = true;
imageName = arguments[ ++i ];
continue;
}
if( arg == "--size" || arg == "-s" ) {
if( i == arguments.size() - 1 ) {
std::cerr << "Error: arg#" << i
<< " argument expected for \"" << arg << "\" not enough parameters" << std::endl;
return 1;
}
imageSize = arguments[ ++i ].toInt();
if( imageSize <=0 ) {
std::cerr << "Error: arg#" << i
<< " invalid argument for image size, value > 0 is expected" << std::endl;
return 2;
}
continue;
}
if( arg[0] != '-' )
files.append( arg );
}
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;
}
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();
if( !imageName.isEmpty() ) {
QImage image( imageSize, imageSize, QImage::Format_RGB32 );
image.fill( 0xFFFFFFFF );
{
QPainter painter( &image );
/*int innerSize = int( imageSize / 120.0 * 24.7 );
int center = imageSize / 2;
painter.setBrush( Qt::lightGray );
painter.drawEllipse( 0, 0, imageSize, imageSize );
painter.setBrush( Qt::white );
painter.drawEllipse( center - innerSize, center - innerSize,
innerSize * 2, innerSize * 2 );*/
scene.render( &painter, image.rect() );
}
std::cerr << "Printing to \"" << imageName << "\" as "
<< imageSize << "x" << imageSize <<" image"
<< std::endl;
image.save( imageName );
return 0;
}
QLightScribe *scribe = QLightScribe::instance();
QList< QLightDrive * > drives = scribe->getDrives();
if( driveIndex >= drives.size() ) {
std::cerr << "Error: drive " << driveIndex
<< " specified, but there are only " << drives.size() << " drives" << std::endl;
return 6;
}
std::cout << "Printing label " << files.front() << std::endl;
QLightDrive *drive = drives[driveIndex];
QConsolePrintProgress progress( drive );
drive->print( params, &scene );
rez = app.exec();
} else {
MainWindow mwindow( true );
mwindow.show();
mwindow.open( files );
rez = app.exec();
}
return rez;
}
+315 -88
View File
@@ -19,13 +19,15 @@
$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 "qdialogsettings.h"
#include <QMenuBar>
#include <QStatusBar>
@@ -34,59 +36,118 @@
#include <QMessageBox>
#include <QSignalMapper>
#include <QFileDialog>
#include <QXmlStreamWriter>
#include <QLabel>
#include <QCloseEvent>
#include <QApplication>
#include <QClipboard>
#include <QSettings>
#include <QImageReader>
/*#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 = 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,
SLOT(onMenuOpen()) );
SLOT(onMenuOpen()),
QKeySequence( Qt::CTRL + Qt::Key_O ) );
m_menuFile->addAction( tr( "Save", "Menu item \"Save\"" ),
this,
SLOT(onMenuSave()) );
m_actionSave = m_menuFile->addAction( tr( "Save", "Menu item \"Save\"" ),
this,
SLOT(onMenuSave()),
QKeySequence( Qt::CTRL + Qt::Key_S ) );
m_menuFile->addAction( tr( "Save as...", "Menu item \"Save as\"" ),
this,
SLOT(onMenuSaveAs()) );
m_actionSaveAs = m_menuFile->addAction( tr( "Save as...", "Menu item \"Save as\"" ),
this,
SLOT(onMenuSaveAs()) );
m_menuFile->addSeparator();
m_menuFile->addAction( tr( "Print preview...", "Menu item \"Print preview\"" ),
this,
SLOT(onMenuPrintPreview()) );
m_actionLabelProperties =
m_menuFile->addAction( tr( "Label properties...", "Menu item \"Label propeties...\"" ),
this,
SLOT(onMenuProperties()) );
m_menuFile->addAction( tr( "Print...", "Menu item \"Print\"" ),
this,
SLOT(onMenuPrint()) );
m_menuFile->addSeparator();
m_actionPrintPreview =
m_menuFile->addAction( tr( "Print preview...", "Menu item \"Print preview\"" ),
this,
SLOT(onMenuPrintPreview()) );
m_actionPrint =
m_menuFile->addAction( tr( "Print...", "Menu item \"Print\"" ),
this,
SLOT(onMenuPrint()) );
m_menuFile->addAction( tr( "Exit", "Menu item \"Exit\"" ),
this,
SLOT(close()));
SLOT(close()),
QKeySequence( Qt::CTRL + Qt::Key_Q ) );
m_menuInsert = menuBar()->addMenu( tr( "Insert", "Menu item \"Insert\"" ) );
m_menuEdit = menuBar()->addMenu( tr( "Edit", "Menu item \"Edit\"" ) );
m_actionUndo = m_menuEdit->addAction( tr( "Undo", "Menu item \"Undo\"" ),
this,
SLOT(onMenuUndo()),
QKeySequence( Qt::CTRL + Qt::Key_Z ) );
m_actionRedo = m_menuEdit->addAction( tr( "Redo", "Menu item \"Redo\"" ),
this,
SLOT(onMenuRedo()),
QKeySequence( Qt::CTRL + Qt::Key_R ) );
m_actionCopy = m_menuEdit->addAction( tr( "Copy", "Menu item \"Copy\"" ),
this,
SLOT(onMenuCopy()),
QKeySequence( Qt::CTRL + Qt::Key_C ) );
m_actionCut = m_menuEdit->addAction( tr( "Cut", "Menu item \"Cut\"" ),
this,
SLOT(onMenuCut()),
QKeySequence( Qt::CTRL + Qt::Key_X ) );
m_actionPaste = m_menuEdit->addAction( tr( "Paste", "Menu item \"Paste\"" ),
this,
SLOT(onMenuPaste()),
QKeySequence( Qt::CTRL + Qt::Key_V ) );
m_menuInsert = m_menuEdit->addMenu( tr( "Insert", "Menu item \"Insert\"" ) );
m_menuEdit->addSeparator();
m_actionSettings = m_menuEdit->addAction( tr( "Settings...", "Menu item \"Settings\"" ),
this,
SLOT(onMenuSettings()) );
m_menuHelp = menuBar()->addMenu( tr( "Help", "Menu item \"Help\"" ) );
@@ -107,20 +168,124 @@ MainWindow::MainWindow(QWidget *parent) :
connect( action, SIGNAL(triggered()), m_insertMapper, SLOT(map()) );
}
connect( m_insertMapper, SIGNAL(mapped(int)), this, SLOT(onMenuInsert(int)) );
connect( QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)),
this, SLOT(updateMenu()) );
connect( m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),
this, SLOT(updateMenu()) );
updateMenu();
QSettings settings;
settings.beginGroup( "MainWindow");
resize( settings.value( "size", QSize(800, 400) ).toSize() );
move( settings.value( "pos", QPoint(200, 200) ).toPoint() );
settings.endGroup();
}
MainWindow::~MainWindow()
{
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;
}
connect( scene, SIGNAL(selectionChanged()), this, SLOT(updateMenu()) );
connect( scene, SIGNAL(changed()), this, SLOT(updateMenu()) );
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;
}
}
QSettings settings;
settings.beginGroup( "MainWindow" );
settings.setValue( "size", size());
settings.setValue( "pos", pos());
settings.endGroup();
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->start( LabelMode( mode ) );
newView->setScene( scene );
scene->setName();
connect( scene, SIGNAL(selectionChanged()), this, SLOT(updateMenu()) );
connect( scene, SIGNAL(changed()), this, SLOT(updateMenu()) );
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( newView );
subWindow->show();
}
@@ -158,48 +323,61 @@ void MainWindow::onMenuInsert( int id )
return;
}
item->setFlag( QGraphicsItem::ItemIsMovable, true );
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
cdscene->addItem( item );
cdscene->setChanged();
}
void MainWindow::onMenuOpen()
{
QString filter( tr("qlscribe document (*.qlx)\nImages ( ") );
QList<QByteArray> list = QImageReader::supportedImageFormats();
foreach( QByteArray arr, list ) {
filter += QString( "*." ) + arr.data() + " ";
}
filter += tr( ")\nAll Files (*)" );
QString fileName = QFileDialog::getOpenFileName( this,
tr( "Open:" ),
QString(),
tr("qlscribe document (*.qlx)") );
filter );
if( fileName.isNull() )
return;
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" );
}
connect( scene, SIGNAL(selectionChanged()), this, SLOT(updateMenu()) );
connect( scene, SIGNAL(changed()), this, SLOT(updateMenu()) );
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()
@@ -208,21 +386,23 @@ void MainWindow::onMenuPrintPreview()
if( !cdscene )
return;
QLightScribe::PrintParameters params;
PrintParameters params;
params.m_labelMode = cdscene->labelMode();
QLightDrive *drive = QDialogPrint::exec( this, params );
if( !drive )
return;
try {
QPixmap pixmap = QLightScribe::instance()->preview( drive, params, cdscene, QSize( 400, 400 ) );
QPixmap pixmap = drive->preview( params, cdscene, QSize( 400, 400 ) );
QLabel *label = new QLabel;
label->setPixmap( pixmap );
QMdiSubWindow *subWindow = m_mdiArea->addSubWindow( label );
subWindow->setWindowTitle( "Preview: " + cdscene->name() );
subWindow->show();
}
catch( const QString &err ) {
QMessageBox::critical( this, tr( "Error" ), err );
QMessageBox::critical( this, tr( "Error on print preview" ), err );
}
}
@@ -232,43 +412,55 @@ void MainWindow::onMenuPrint()
if( !cdscene )
return;
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;
try {
QDialogProgress::exec( this, cdscene );
}
catch( const QString &err ) {
QMessageBox::critical( this, tr( "Error on print" ), err );
}
QXmlStreamWriter writer( &file );
writer.setAutoFormatting( true );
cdscene->write( writer );
}
void MainWindow::onMenuUndo()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
scene->undo();
}
void MainWindow::onMenuRedo()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
scene->redo();
}
void MainWindow::onMenuCopy()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
scene->putItemToClipboard( false );
}
void MainWindow::onMenuCut()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
scene->putItemToClipboard( true );
}
void MainWindow::onMenuPaste()
{
QCDScene *scene = getScene( m_mdiArea );
if( scene )
scene->getItemFromClipboard();
}
void MainWindow::onMenuAbout()
{
QMessageBox::about( this,
tr( "About" ),
tr( "<h3>qlscribe - Qt lisghtScribe</h3>"
"<p>$Revision$</p>"
"<p>release 0.12 $Revision$</p>"
"<p>visit project at home page "
"<a href=\"http://qlscribe.sourceforge.net/\">qlscribe.sourceforge.net</a></p>" ) );
}
@@ -277,3 +469,38 @@ void MainWindow::onMenuQtAbout()
{
QMessageBox::aboutQt( this );
}
void MainWindow::onMenuSettings()
{
QDialogSettings::exec( this );
}
void MainWindow::updateMenu()
{
QCDScene *scene = getScene( m_mdiArea );
m_actionSave->setEnabled( scene );
m_actionSaveAs->setEnabled( scene );
m_actionLabelProperties->setEnabled( scene );
m_actionPrint->setEnabled( scene );
m_actionPrintPreview->setEnabled( scene );
m_menuInsert->setEnabled( scene );
if( !scene ) {
m_actionUndo->setEnabled( false );
m_actionRedo->setEnabled( false );
m_actionCopy->setEnabled( false );
m_actionCut->setEnabled( false );
m_actionPaste->setEnabled( false );
} else {
m_actionUndo->setEnabled( scene->canUndo() );
m_actionRedo->setEnabled( scene->canRedo() );
const QMimeData *mdata = QApplication::clipboard()->mimeData();
m_actionPaste->setEnabled( mdata && mdata->hasFormat( itemMimeType ) );
bool selected = scene->selectedItems().count();
m_actionCopy->setEnabled( selected );
m_actionCut->setEnabled( selected );
}
}
+34 -2
View File
@@ -25,33 +25,65 @@
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 onMenuUndo();
void onMenuRedo();
void onMenuCopy();
void onMenuCut();
void onMenuPaste();
void onMenuSettings();
void onMenuInsert( int id );
void onMenuAbout();
void onMenuQtAbout();
void updateMenu();
private:
bool saveSceneAs( QCDScene *scene );
QMdiArea *m_mdiArea;
QMenu *m_menuFile;
QMenu *m_menuEdit;
QMenu *m_menuInsert;
QMenu *m_menuHelp;
QAction *m_actionSave;
QAction *m_actionSaveAs;
QAction *m_actionLabelProperties;
QAction *m_actionPrint;
QAction *m_actionPrintPreview;
QAction *m_actionUndo;
QAction *m_actionRedo;
QAction *m_actionCopy;
QAction *m_actionCut;
QAction *m_actionPaste;
QAction *m_actionSettings;
QSignalMapper *m_insertMapper;
QSignalMapper *m_newLabelMapper;
};
#endif // MAINWINDOW_H
+391 -23
View File
@@ -16,21 +16,38 @@
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"
#include "qlightpixmapitem.h"
#include <QMenu>
#include <QMessageBox>
#include <QGraphicsItem>
#include <QGraphicsSceneMouseEvent>
#include <QFile>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QMessageBox>
#include <QGraphicsView>
#include <QRegExp>
#include <QApplication>
#include <QClipboard>
#include <QMimeData>
#include <QRegExp>
QCDScene::QCDScene( QObject * parent )
: QGraphicsScene( parent )
: QGraphicsScene( parent ),
m_index( 0 ),
m_saved( true ),
m_itemMoved( false ),
m_labelMode( modeFull ),
m_cdColor( Qt::white ),
m_undoPosition( m_undoBuffer.end() )
{
setSceneRect( -60.0, -60.0, 60.0 * 2, 60.0 * 2 );
}
//#include <iostream>
@@ -39,32 +56,239 @@ 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() );
}
}
foreach(QGraphicsItem *item, list ) {
QShapeFactory::iterator f = sfactory.find( item->type() );
if( f != sfactory.end() )
f->second->replace( item, "", "" ); // to clean placeholders
}
}
void QCDScene::start( LabelMode mode )
{
setLabelMode( mode );
pushUndo();
}
bool QCDScene::load( const QString &fileName, QString *errMessage )
{
if( QRegExp( ".*.\\.qlx$", Qt::CaseInsensitive ).exactMatch( fileName ) ) {
QFile file( fileName );
if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
if( errMessage )
*errMessage = "cannot open file for reading";
else
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot open file for reading\n" ) + fileName );
return false;
}
QXmlStreamReader reader( &file );
try {
read( reader );
}
catch( const QString &err ) {
if( errMessage )
*errMessage = err;
else
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot read file " ) + fileName + "\n" + err );
return false;
}
m_fileName = fileName;
m_saved = true;
setName();
pushUndo();
return true;
}
QShapeFactory &sfactory = QShapeFactory::instance();
QLightPixmapItem *item =
static_cast<QLightPixmapItem *>(sfactory.create( QShapeControllerPixmap::Type ) );
addItem( item );
if( item->loadImage( fileName ) ) {
QSize size = item->pixmap().size();
item->setOffset( -QPointF( size.height(), size.width() ) / 2.0 );
item->setTransform( QTransform().scale( size.width() ? 120.0 / size.width() : 1.0,
size.height() ? 120.0 / size.height() : 1.0 ) );
setName();
pushUndo();
return true;
} else {
if( errMessage )
*errMessage = "cannot load image";
else
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot load image " ) +
fileName + "\n" );
}
return false;
}
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( bool undo )
{
m_saved = false;
updateTitles();
if( undo && m_undoPosition != m_undoBuffer.end() )
pushUndo();
emit changed();
}
void QCDScene::pushUndo()
{
if( canRedo() ) {
UndoBuffer::iterator pos = m_undoBuffer.begin() + 1 + ( m_undoPosition - m_undoBuffer.begin() );
m_undoBuffer.erase( pos, m_undoBuffer.end() );
}
QString data;
QXmlStreamWriter writer( &data );
write( writer );
m_undoBuffer.push_back( data );
if( m_undoBuffer.size() > 20 )
m_undoBuffer.pop_front();
m_undoPosition = m_undoBuffer.end() - 1;
}
void QCDScene::updateTitles() const
{
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();
writer.writeEndDocument();
}
bool QCDScene::readItem( QXmlStreamReader &reader )
{
QShapeFactory &sfactory = QShapeFactory::instance();
QString type = reader.attributes().value( "type" ).toString();
QShapeFactory::iterator f = sfactory.find( type );
if( f == sfactory.end() ) {
QMessageBox::warning( 0,
"Warning",
QString( "QCDScene: unknown item type \"" )
+ type + "\"" );
return false;
}
QGraphicsItem *item = f->second->read( reader );
if( item ) {
item->setFlag( QGraphicsItem::ItemIsMovable, true );
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
addItem( item );
return true;
}
return false;
}
void QCDScene::read( QXmlStreamReader &reader )
{
bool gotScene = false;
QShapeFactory &sfactory = QShapeFactory::instance();
while( !reader.atEnd() ) {
QXmlStreamReader::TokenType ttype = reader.readNext();
if( ttype != QXmlStreamReader::StartElement )
@@ -76,32 +300,78 @@ 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;
}
if( elementName == "item" ) {
QString type = reader.attributes().value( "type" ).toString();
QShapeFactory::iterator f = sfactory.find( type );
if( f == sfactory.end() ) {
QMessageBox::warning( 0,
"Warning",
QString( "QCDScene: unknown item type \"" )
+ type + "\"" );
continue;
}
QGraphicsItem *item = f->second->read( reader );
if( item ) {
item->setFlag( QGraphicsItem::ItemIsMovable, true );
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
addItem( item );
}
readItem( reader );
} else
throw QString( "QCDScene: unknown element \"" ) + elementName + "\"";
}
}
void QCDScene::putItemToClipboard( bool move )
{
QList<QGraphicsItem *> list = selectedItems();
if( list.empty() )
return;
QGraphicsItem *item = list.front();
QShapeFactory &sfactory = QShapeFactory::instance();
QShapeFactory::iterator f = sfactory.find( item->type() );
if( f == sfactory.end() ) {
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot find controller for type %n", 0, item->type() ) );
return;
}
QByteArray array;
QXmlStreamWriter writer( &array );
f->second->write( writer, item );
QMimeData *mdata = new QMimeData;
mdata->setData( itemMimeType, array );
mdata->setText( array.data() );
QApplication::clipboard()->setMimeData( mdata );
if( move ) {
removeItem( item );
delete item;
setChanged();
}
}
void QCDScene::getItemFromClipboard()
{
const QMimeData *mdata = QApplication::clipboard()->mimeData();
if( !mdata )
return;
if( !mdata->hasFormat( itemMimeType ) )
return;
QByteArray array = mdata->data( itemMimeType );
QXmlStreamReader reader( array );
while( !reader.atEnd() ) {
QXmlStreamReader::TokenType ttype = reader.readNext();
if( ttype != QXmlStreamReader::StartElement )
continue;
QString elementName = reader.name().toString();
if( elementName == "item" ) {
if( readItem( reader ) )
setChanged();
}
}
}
void QCDScene::contextMenuEvent( QGraphicsSceneContextMenuEvent *mouseEvent )
{
QGraphicsItem *item = itemAt( mouseEvent->scenePos() );
@@ -110,9 +380,24 @@ void QCDScene::contextMenuEvent( QGraphicsSceneContextMenuEvent *mouseEvent )
item->setSelected( true );
QMenu menu;
menu.addAction( tr( "edit..." ), this, SLOT( onMenuEdit() ) );
menu.addAction( tr( "copy" ), this, SLOT( onMenuCopy() ) );
menu.addAction( tr( "cut" ), this, SLOT( onMenuCut() ) );
menu.addAction( tr( "bring to Front" ), this, SLOT( onMenuToFront() ) );
menu.addAction( tr( "send to Back" ), this, SLOT( onMenuToBack() ) );
menu.addAction( tr( "delete" ), this, SLOT( onMenuDelete() ) );
menu.exec( mouseEvent->screenPos() );
}
void QCDScene::mouseReleaseEvent ( QGraphicsSceneMouseEvent *mouseEvent )
{
if( m_itemMoved ) {
setChanged();
m_itemMoved = false;
}
QGraphicsScene::mouseReleaseEvent( mouseEvent );
}
void QCDScene::onMenuEdit()
{
QList<QGraphicsItem *> list = selectedItems();
@@ -121,3 +406,86 @@ void QCDScene::onMenuEdit()
QGraphicsItem *item = list.front();
QShapeFactory::instance().edit( item, 0 );
}
void QCDScene::onMenuCopy()
{
putItemToClipboard( false );
}
void QCDScene::onMenuCut()
{
putItemToClipboard( true );
}
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 );
setChanged();
}
bool QCDScene::canUndo() const
{
return m_undoPosition - m_undoBuffer.begin() > 0;
}
bool QCDScene::canRedo() const
{
return m_undoBuffer.end() - m_undoPosition > 1;
}
void QCDScene::unredo( bool undo )
{
if( undo ) {
if( !canUndo() )
return;
--m_undoPosition;
} else {
if( !canRedo() )
return;
++m_undoPosition;
}
try {
clear();
QXmlStreamReader reader( *m_undoPosition );
read( reader );
}
catch(...) {
}
setChanged( false );
}
+63 -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,75 @@ 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(); }
bool canUndo() const;
bool canRedo() const;
void itemMoved() { m_itemMoved = true; }
void setChanged( bool undo = true );
void setName();
void start( LabelMode mode );
bool load( const QString &fileName, QString *errMessage = 0 );
void replace( const QString2String &strings );
bool save();
bool saveAs( const QString &fileName );
void undo() { unredo( true ); }
void redo() { unredo( false ); }
void putItemToClipboard( bool move );
void getItemFromClipboard();
void updateTitles() const;
void redrawViews() const;
QString name() const { return m_name; }
signals:
void changed();
protected:
virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent *contextMenuEvent );
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent *mouseEvent );
private slots:
void onMenuEdit();
void onMenuCopy();
void onMenuCut();
void onMenuToFront();
void onMenuToBack();
void onMenuDelete();
private:
void write( QXmlStreamWriter &writer );
bool readItem( QXmlStreamReader &reader );
void read( QXmlStreamReader &reader );
void sendItemTo( bool front );
void pushUndo();
void unredo( bool undo );
private:
typedef QList<QString> UndoBuffer;
QString m_name;
QString m_fileName;
int m_index;
bool m_saved;
bool m_itemMoved;
LabelMode m_labelMode;
QColor m_cdColor;
UndoBuffer m_undoBuffer;
UndoBuffer::const_iterator m_undoPosition;
};
#endif //QCDSCENE_H
+83 -10
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,20 +141,25 @@ 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() );
QRectF rectf( QPointF( -frameSize().width(), -frameSize().height() ), frameSize() * 2 );
{
QPainter paint( m_mask );
paint.setWorldTransform( painter->transform() );
drawCD( &paint, rect, false );
drawCD( &paint, rectf, false );
}
{
QPixmap alpha( frameSize() );
QPainter paint( &alpha );
paint.setWorldTransform( painter->transform() );
drawCD( &paint, rect, true );
drawCD( &paint, rectf, true );
m_mask->setAlphaChannel( alpha );
}
+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
+48
View File
@@ -0,0 +1,48 @@
#include "qconsoleprintprogress.h"
#include "qlightscribe.h"
#include <QApplication>
#include <iostream>
std::ostream &operator<<( std::ostream &os, const QString &str );
QConsolePrintProgress::QConsolePrintProgress( QLightDrive *drive )
: m_drive( drive )
{
connect( drive, SIGNAL(prepareProgress(int,int)), this, SLOT(onPrepareProgress(int,int)) );
connect( drive, SIGNAL(labelProgress(int,int)), this, SLOT(onLabelProgress(int,int)) );
connect( drive, SIGNAL(timeEstimate(int)), this, SLOT(onTimeEstimate(int)) );
connect( drive, SIGNAL(finished(int)), this, SLOT(onFinished(int)) );
}
QConsolePrintProgress::~QConsolePrintProgress()
{
}
void QConsolePrintProgress::onPrepareProgress( int current, int final )
{
std::cout << "Preparing label: " << current << '/' << final << " \r";
}
void QConsolePrintProgress::onLabelProgress( int current, int final )
{
std::cout << "Printing label: " << current << '/' << final << " \r";
}
void QConsolePrintProgress::onTimeEstimate( int 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 );
}
+24
View File
@@ -0,0 +1,24 @@
#ifndef QCONSOLEPRINTPROGRESS_H
#define QCONSOLEPRINTPROGRESS_H
#include <QObject>
class QLightDrive;
class QConsolePrintProgress : public QObject {
Q_OBJECT
public:
QConsolePrintProgress( QLightDrive *drive );
~QConsolePrintProgress();
private slots:
void onPrepareProgress( int current, int final );
void onLabelProgress( int current, int final );
void onTimeEstimate( int time );
void onFinished(int status );
private:
QLightDrive *m_drive;
};
#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>
+53 -7
View File
@@ -20,9 +20,9 @@
#include "qdialogpixmap.h"
#include "ui_qdialogpixmap.h"
#include "qlightpixmapitem.h"
#include "qcdscene.h"
#include <QGraphicsPixmapItem>
#include <QImageReader>
#include <QFileDialog>
#include <QMessageBox>
@@ -54,23 +54,33 @@ void QDialogPixmap::changeEvent(QEvent *e)
bool QDialogPixmap::exec( QGraphicsItem *graphicsItem )
{
QGraphicsPixmapItem *item = dynamic_cast< QGraphicsPixmapItem * >( graphicsItem );
QLightPixmapItem *item = dynamic_cast< QLightPixmapItem * >( graphicsItem );
if( !item )
return false;
QCDScene scene;
m_ui->cdView->setScene( &scene );
m_item = new QGraphicsPixmapItem;
m_item = new QLightPixmapItem;
m_item->setPos( item->pos() );
m_item->setOffset( item->offset() );
m_item->setPixmap( item->pixmap() );
m_item->setData( 0, item->data( 0 ) );
m_item->imageName( item->imageName() );
m_item->setTransform( item->transform() );
scene.addItem( m_item );
m_ui->spinX->setValue( m_item->pos().x() );
m_ui->spinY->setValue( m_item->pos().y() );
m_ui->lineEdit->setText( m_item->imageName() );
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->imageName( m_item->imageName() );
item->setTransform( m_item->transform() );
return true;
}
@@ -108,14 +131,37 @@ void QDialogPixmap::onLoadImage()
return;
}
m_item->setPixmap( pixmap );
m_item->setData( 0, fileName );
m_item->setOffset( -QPointF( pixmap.size().height(), pixmap.size().width() ) / 2.0 );
m_item->imageName( fileName );
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() ) );
}
+5 -3
View File
@@ -27,7 +27,7 @@ namespace Ui {
class QDialogPixmap;
}
class QGraphicsPixmapItem;
class QLightPixmapItem;
class QDialogPixmap : public QItemDialog {
Q_OBJECT
@@ -44,10 +44,12 @@ protected:
private slots:
void onLoadImage();
void posChanged();
void onResetSize();
void sizeChanged();
private:
Ui::QDialogPixmap *m_ui;
QGraphicsPixmapItem *m_item;
Ui::QDialogPixmap *m_ui;
QLightPixmapItem *m_item;
};
+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>
+36 -7
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"
@@ -26,7 +46,7 @@ void QDialogPrint::changeEvent(QEvent *e)
}
}
QLightDrive *QDialogPrint::exec( QWidget *parent, QLightScribe::PrintParameters &params )
QLightDrive *QDialogPrint::exec( QWidget *parent, PrintParameters &params )
{
QList<QLightDrive *> drives = QLightScribe::instance()->getDrives();
if( drives.isEmpty() ) {
@@ -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() );
@@ -41,22 +67,25 @@ QLightDrive *QDialogPrint::exec( QWidget *parent, QLightScribe::PrintParameters
if( dialog.QDialog::exec() == Rejected )
return 0;
params = QLightScribe::PrintParameters(); // reset to default
params = 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;
params.m_printQuality = qualityNormal;
if( dialog.m_ui->radioQualityDraft->isChecked() )
params.m_printQuality = QLightScribe::qualityDraft;
params.m_printQuality = qualityDraft;
if( dialog.m_ui->radioMediaGeneric->isChecked() )
params.m_mediaOptimizationLevel = QLightScribe::mediaGeneric;
params.m_mediaOptimizationLevel = mediaGeneric;
return drives.at( dialog.m_ui->comboDrive->currentIndex() );
}
+21 -1
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
@@ -13,7 +33,7 @@ class QDialogPrint : public QDialog {
Q_OBJECT
Q_DISABLE_COPY(QDialogPrint)
public:
static QLightDrive *exec( QWidget *parent, QLightScribe::PrintParameters &params );
static QLightDrive *exec( QWidget *parent, PrintParameters &params );
protected:
explicit QDialogPrint(QWidget *parent = 0);
+65 -16
View File
@@ -1,21 +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$ */
#include "qdialogprogress.h"
#include "ui_qdialogprogress.h"
#include "qlightscribe.h"
#include "qdialogprint.h"
#include "qcdscene.h"
#include <QMessageBox>
#include <QAbstractButton>
#include <QTime>
#include <QTimer>
#include <QSettings>
QDialogProgress::QDialogProgress(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::QDialogProgress)
QDialogProgress::QDialogProgress( QWidget *parent, QLightDrive *drive )
: QDialog(parent),
m_ui(new Ui::QDialogProgress),
m_drive( drive ),
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)
@@ -31,21 +63,24 @@ void QDialogProgress::changeEvent(QEvent *e)
bool QDialogProgress::exec( QWidget *parent, QCDScene *scene )
{
QLightScribe::PrintParameters params;
PrintParameters params;
params.m_labelMode = scene->labelMode();
QLightDrive *drive = QDialogPrint::exec( parent, params );
if( !drive )
return false;
QLightScribe *scribe = QLightScribe::instance();
QDialogProgress dialog( parent );
params.m_ejectAfterComplete = QSettings().value( cfgEjectAfterFinish, false ).toBool();
QDialogProgress dialog( parent, drive );
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)) );
connect( scribe, SIGNAL(labelProgress(long,long)), &dialog, SLOT(onLabelProgress(long,long)) );
connect( scribe, SIGNAL(timeEstimate(long)), &dialog, SLOT(onTimeEstimate(long)) );
connect( scribe, SIGNAL(finished(int)), &dialog, SLOT(onFinished(int)) );
connect( drive, SIGNAL(prepareProgress(int,int)), &dialog, SLOT(onPrepareProgress(int,int)) );
connect( drive, SIGNAL(labelProgress(int,int)), &dialog, SLOT(onLabelProgress(int,int)) );
connect( drive, SIGNAL(timeEstimate(int)), &dialog, SLOT(onTimeEstimate(int)) );
connect( drive, SIGNAL(finished(int)), &dialog, SLOT(onFinished(int)) );
scribe->print( drive, params, scene );
drive->print( params, scene );
dialog.QDialog::exec();
return true;
}
@@ -58,31 +93,45 @@ void QDialogProgress::onButtonClicked( QAbstractButton *button )
tr( "Are you sure you want to interrupt?" ),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No ) == QMessageBox::Yes ) {
QLightScribe::instance()->abort();
m_drive->abort();
button->setDisabled( true );
}
} else
done( 0 );
}
void QDialogProgress::onPrepareProgress( long current, long final )
void QDialogProgress::onPrepareProgress( int current, int final )
{
m_ui->progressPreparation->setMaximum( final );
m_ui->progressPreparation->setValue( current );
}
void QDialogProgress::onLabelProgress( long current, long final )
void QDialogProgress::onLabelProgress( int current, int 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 = int( double( elapsed ) / current * final );
m_ui->timeEstimated->setTime( QTime().addMSecs( estimate ) );
}
}
void QDialogProgress::onTimeEstimate( long time )
void QDialogProgress::onTimeEstimate( int 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() ) );
}
+31 -4
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,9 @@ namespace Ui {
class QCDScene;
class QAbstractButton;
class QTime;
class QTimer;
class QLightDrive;
class QDialogProgress : public QDialog {
Q_OBJECT
@@ -18,19 +41,23 @@ public:
protected slots:
void onButtonClicked( QAbstractButton* button );
void onPrepareProgress( long current, long final );
void onLabelProgress( long current, long final );
void onTimeEstimate( long time );
void onPrepareProgress( int current, int final );
void onLabelProgress( int current, int final );
void onTimeEstimate( int time );
void onFinished(int status );
void onTimeout();
protected:
virtual void changeEvent(QEvent *e);
private:
explicit QDialogProgress(QWidget *parent = 0);
QDialogProgress(QWidget *parent, QLightDrive *drive );
virtual ~QDialogProgress();
Ui::QDialogProgress *m_ui;
QLightDrive *m_drive;
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>
+6 -3
View File
@@ -20,8 +20,9 @@
#include "qdialogroundtext.h"
#include "ui_qdialogroundtext.h"
#include "qgraphicsroundtextitem.h"
#include "qlightroundtextitem.h"
#include "qcdscene.h"
#include "qdialogsettings.h"
#include <QFontDialog>
#include <QColorDialog>
@@ -55,13 +56,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,8 +130,10 @@ 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 );
QDialogSettings::setLastUsedFont( 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>
+99
View File
@@ -0,0 +1,99 @@
/* qlscribe - Qt based application to print lightScribe discs
Copyright (C) 2009 Vyacheslav Kononenko <vyacheslav@kononenko.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
$Id$ */
#include "qdialogsettings.h"
#include "ui_qdialogsettings.h"
#include "qlscribe.h"
#include <QSettings>
#include <QFontDialog>
QFont *QDialogSettings::m_lastUsedFont = 0;
QDialogSettings::QDialogSettings(QWidget *parent) :
QDialog( parent ),
m_ui( new Ui::QDialogSettings )
{
m_ui->setupUi( this );
connect( m_ui->btnFont, SIGNAL(clicked()), this, SLOT(onFont()) );
connect( m_ui->btnLastUsedFont, SIGNAL(clicked()), this, SLOT(onLastUsedFont()) );
m_ui->btnLastUsedFont->setEnabled( m_lastUsedFont );
}
QDialogSettings::~QDialogSettings()
{
delete m_ui;
}
void QDialogSettings::changeEvent(QEvent *e)
{
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
default:
break;
}
}
bool QDialogSettings::exec( QWidget *parent )
{
QDialogSettings dialog( parent );
QSettings sts;
dialog.m_font = sts.value( cfgDefaultFont ).value<QFont>();
dialog.m_ui->fontName->setCurrentFont( dialog.m_font );
dialog.m_ui->chkEject->setChecked( sts.value( cfgEjectAfterFinish, false ).toBool() );
if( dialog.QDialog::exec() == Rejected ) return false;
sts.setValue( cfgDefaultFont, dialog.m_font );
sts.setValue( cfgEjectAfterFinish, dialog.m_ui->chkEject->isChecked() );
return true;
}
void QDialogSettings::onFont()
{
bool ok = true;
QFont font = QFontDialog::getFont( &ok, m_font, this );
if( ok ) {
m_font = font;
m_ui->fontName->setCurrentFont( font );
}
}
void QDialogSettings::onLastUsedFont()
{
if( m_lastUsedFont ) {
m_font = *m_lastUsedFont;
m_ui->fontName->setCurrentFont( *m_lastUsedFont );
}
}
void QDialogSettings::setLastUsedFont( const QFont &font )
{
if( !m_lastUsedFont ) m_lastUsedFont = new QFont( font );
else *m_lastUsedFont = font;
}
QFont QDialogSettings::defaultFont()
{
return QSettings().value( cfgDefaultFont ).value<QFont>();
}
+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 QDIALOGSETTINGS_H
#define QDIALOGSETTINGS_H
#include <QtGui/QDialog>
namespace Ui {
class QDialogSettings;
}
class QDialogSettings : public QDialog {
Q_OBJECT
Q_DISABLE_COPY(QDialogSettings)
public:
static bool exec( QWidget *parent = 0 );
static void setLastUsedFont( const QFont &font );
static QFont defaultFont();
private:
explicit QDialogSettings( QWidget *parent = 0 );
virtual ~QDialogSettings();
protected:
virtual void changeEvent(QEvent *e);
private slots:
void onFont();
void onLastUsedFont();
private:
Ui::QDialogSettings *m_ui;
QFont m_font;
static QFont *m_lastUsedFont;
};
#endif // QDIALOGSETTINGS_H
+140
View File
@@ -0,0 +1,140 @@
<ui version="4.0" >
<class>QDialogSettings</class>
<widget class="QDialog" name="QDialogSettings" >
<property name="windowModality" >
<enum>Qt::NonModal</enum>
</property>
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>305</width>
<height>156</height>
</rect>
</property>
<property name="windowTitle" >
<string>Settings</string>
</property>
<property name="modal" >
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QFrame" name="frame" >
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<layout class="QFormLayout" name="formLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Default font:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QFontComboBox" name="fontName" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="editable" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnFont" >
<property name="text" >
<string>Font...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnLastUsedFont" >
<property name="text" >
<string>Last used</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="chkEject" >
<property name="text" >
<string>Eject tray after finish</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QDialogSettings</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QDialogSettings</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+6 -3
View File
@@ -16,11 +16,12 @@
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"
#include "qcdscene.h"
#include "qdialogsettings.h"
#include <QGraphicsSimpleTextItem>
#include <QFontDialog>
@@ -32,8 +33,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 +67,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 );
@@ -96,6 +98,7 @@ void QDialogText::onFont()
QFont font = QFontDialog::getFont( &ok, m_item->font(), this );
if( ok ) {
m_item->setFont( font );
QDialogSettings::setLastUsedFont( font );
fontChanged();
}
}
+2 -5
View File
@@ -1,8 +1,8 @@
<ui version="4.0" >
<class>QDialogText</class>
<widget class="QDialog" name="QDialogText" >
<property name="windowModality" >
<enum>Qt::NonModal</enum>
<property name="enabled" >
<bool>true</bool>
</property>
<property name="geometry" >
<rect>
@@ -15,9 +15,6 @@
<property name="windowTitle" >
<string>Text properties</string>
</property>
<property name="modal" >
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3" >
<item>
<layout class="QVBoxLayout" name="verticalLayout" >
+129
View File
@@ -0,0 +1,129 @@
/* 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()
{
}
bool QLightPixmapItem::loadImage( const QString &name )
{
QPixmap pixmap( name );
if( pixmap.isNull() )
return false;
m_imageName = name;
setPixmap( pixmap );
return true;
}
QVariant QLightPixmapItem::itemChange( GraphicsItemChange change, const QVariant & value )
{
if( scene() && change == ItemPositionHasChanged )
static_cast<QCDScene *>( scene() )->itemMoved();
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 QLightPixmapItem *pixmapItem
= static_cast< const QLightPixmapItem * >( 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->imageName() );
}
void QShapeControllerPixmap::readData( const QString &element,
const QXmlStreamAttributes &attrs,
const QString &data,
QGraphicsItem *item ) const
{
QLightPixmapItem *pixmapItem = static_cast< QLightPixmapItem * >( 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" ) {
QPixmap pixmap( data );
if( pixmap.isNull() ) {
throw QString( "QShapeControllerPixmap: image loading from \"" ) +
data + "\" failed";
}
pixmapItem->imageName( data );
pixmapItem->setPixmap( pixmap );
pixmapItem->setOffset( -QPointF( pixmap.size().height(), pixmap.size().width() ) / 2.0 );
return;
}
}
+62
View File
@@ -0,0 +1,62 @@
/* 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();
bool loadImage( const QString &name );
void imageName( const QString &name ) { m_imageName = name; }
const QString &imageName() const { return m_imageName; }
protected:
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value );
private:
QString m_imageName;
};
class QShapeControllerPixmap : public QShapeController {
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,100 @@
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 "qdialogsettings.h"
#include <QPainter>
#include <QFontMetrics>
#include <QStyleOptionGraphicsItem>
#include <QMessageBox>
#include <QXmlStreamWriter>
#include <QTextLayout>
#include <QGraphicsSceneMouseEvent>
#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 +120,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 +171,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 +201,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 +217,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 +232,38 @@ void QGraphicsRoundTextItem::paint( QPainter *painter, const QStyleOptionGraphic
}
}
inline
double distance( const QPointF &p1, const QPointF &p2 )
{
QPointF d = p1 - p2;
return sqrt( d.x() * d.x() + d.y() * d.y() );
}
inline
double angle( const QPointF &p1, const QPointF &p2 )
{
QPointF d = p1 - p2;
return atan2( d.y(), d.x() ) * 180.0 / 3.14159;
}
void QLightRoundTextItem::mouseMoveEvent( QGraphicsSceneMouseEvent *event )
{
if( event->buttons() & Qt::LeftButton ) {
double dradi = distance( scenePos(), event->lastScenePos() ) - distance( scenePos(), event->scenePos() );
double dangle = ::angle( scenePos(), event->lastScenePos() ) - ::angle( scenePos(), event->scenePos() );
prepareGeometryChange();
m_radius -= dradi;
m_angle -= dangle;
if( m_angle > 360.0 ) m_angle -= 360.0;
if( m_angle < 0.0 ) m_angle += 360.0;
static_cast<QCDScene *>( scene() )->itemMoved();
} else
event->ignore();
}
RegisterController< QShapeControllerRoundText > regControllerRoundText;
QString QShapeControllerRoundText::name() const
@@ -228,7 +278,9 @@ QString QShapeControllerRoundText::menuName() const
QGraphicsItem *QShapeControllerRoundText::create() const
{
return new QGraphicsRoundTextItem;
QLightRoundTextItem *item = new QLightRoundTextItem;
item->setFont( QDialogSettings::defaultFont() );
return item;
}
QItemDialog *QShapeControllerRoundText::createDialog( QWidget *parent ) const
@@ -236,12 +288,28 @@ 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 );
bool placeHolder = textItem->text().left( 1 ) == "?" && textItem->text().right( 1 ) == "?";
bool replace = false;
if( from.isEmpty() )
replace = placeHolder;
else
replace = textItem->text() == ( placeHolder ? QString( "?%1?" ).arg( from ) : from );
if( replace )
textItem->setText( to );
}
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 +325,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 +356,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 void mouseMoveEvent( QGraphicsSceneMouseEvent *event );
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
+102 -267
View File
@@ -20,33 +20,42 @@
#include "qlightscribe.h"
#include "qcdscene.h"
#include "lightscribe_interface.h"
#include <QMutex>
#include <QWaitCondition>
#include <QApplication>
#include <QPainter>
#include <QBuffer>
#include <QTemporaryFile>
#include <QDBusConnection>
#include <QDBusArgument>
#include <QMessageBox>
#include <lightscribe_cxx.h>
//#include <lightscribe_cxx.h>
using namespace LightScribe;
//using namespace LightScribe;
// Marshall the PrintParameters data into a D-BUS argument
QDBusArgument &operator<<( QDBusArgument &argument, const PrintParameters &p )
{
argument.beginStructure();
argument << p.m_labelMode << p.m_drawOptions << p.m_printQuality << p.m_mediaOptimizationLevel << (int) p.m_ejectAfterComplete;
argument.endStructure();
return argument;
}
struct QLightScribe::Task {
enum Action { getDrives, preview, print, stop };
Action m_action;
bool m_done;
QLightDrive *m_selectedDrive;
PrintParameters m_parameters;
QSize m_size;
QImage *m_image;
QList< QLightDrive * > m_drives;
QTemporaryFile m_tmpFile;
QString m_error;
Task( Action action ) : m_action( action ), m_done( false ), m_selectedDrive( 0 ), m_image( 0 ) {}
~Task() { delete m_image; }
};
// Retrieve the PrintProperties data from the D-BUS argument
const QDBusArgument &operator>>( const QDBusArgument &argument, PrintParameters &p )
{
argument.beginStructure();
int drawOptions = 0, labelMode = 0, mediaOptimizationLevel = 0, printQuality = 0, ejectAfterComplete = 0;
argument >> labelMode >> drawOptions >> printQuality >> mediaOptimizationLevel >> ejectAfterComplete;
argument.endStructure();
p = PrintParameters( LabelMode( labelMode ),
DrawOptions( drawOptions ),
PrintQuality( printQuality ),
MediaOptimizationLevel( mediaOptimizationLevel ),
ejectAfterComplete );
return argument;
}
QLightScribe *QLightScribe::instance()
{
@@ -55,282 +64,108 @@ QLightScribe *QLightScribe::instance()
}
QLightScribe::QLightScribe()
: m_task( 0 ),
m_aborted( false ),
m_mutex( new QMutex ),
m_waitQueue( new QWaitCondition ),
m_waitDone( new QWaitCondition )
: m_managerPrx( new OrgLightscribePrintManagerInterface( DBusServiceName,
DBusManagerPath,
QDBusConnection::systemBus(),
this ) )
{
start();
qDBusRegisterMetaType<PrintParameters>();
qDBusRegisterMetaType<QObject2StringMap>();
}
QLightScribe::~QLightScribe()
{
delete m_waitDone;
delete m_waitQueue;
delete m_mutex;
}
QList< QLightDrive * > QLightScribe::getDrives( bool refresh )
QList< QLightDrive * > QLightScribe::getDrives()
{
if( m_drives.empty() || refresh ) {
QMutexLocker lock( m_mutex );
if( m_task ) // what should we do?
return m_drives;
m_task = new Task( Task::getDrives );
m_waitQueue->wakeOne();
while( !m_task->m_done )
m_waitDone->wait( m_mutex );
while( m_drives.count() ) {
delete m_drives.front();
m_drives.erase( m_drives.begin() );
if( m_drives.empty() ) {
qApp->setOverrideCursor( Qt::WaitCursor );
QDBusReply<QObject2StringMap> reply = m_managerPrx->getDrives();
qApp->restoreOverrideCursor();
if( !reply.isValid() ) {
QMessageBox::critical( 0, tr( "DBus Error" ), tr( "Error on request: " ) + reply.error().message() );
} else {
const QObject2StringMap &map = reply.value();
for( QObject2StringMap::const_iterator i = map.begin(); i != map.end(); ++i )
m_drives.push_back( new QLightDrive( this, i.key(), i.value() ) );
}
m_drives = m_task->m_drives;
delete m_task;
m_task = 0;
}
return m_drives;
}
static
QImage *printScene( QCDScene *scene )
QLightDrive::QLightDrive( QObject *parent, const QString &path, const QString &name )
: QObject( parent ),
m_drivePrx( new OrgLightscribeDriveInterface( DBusServiceName, path, QDBusConnection::systemBus(), this ) ),
m_displayName( name ),
m_path( path )
{
QImage *image = new QImage( 2772, 2772, QImage::Format_RGB888 );
image->fill( 0xFFFFFFFF );
connect( m_drivePrx, SIGNAL(finished(int)), this, SIGNAL(finished(int)) );
connect( m_drivePrx, SIGNAL(prepareProgress( int, int )), this, SIGNAL(prepareProgress( int, int )) );
connect( m_drivePrx, SIGNAL(labelProgress( int , int )), this, SIGNAL(labelProgress( int, int )) );
connect( m_drivePrx, SIGNAL(timeEstimate( int )), this, SIGNAL(timeEstimate( int )) );
}
static
void printScene( QCDScene *scene, QByteArray &array )
{
QImage image( 2772, 2772, QImage::Format_RGB888 );
image.fill( 0xFFFFFFFF );
scene->clearSelection();
{
QPainter painter( image );
scene->render( &painter, image->rect() );
QPainter painter( &image );
scene->render( &painter, image.rect() );
}
image->setDotsPerMeterX( 23622 );
image->setDotsPerMeterY( 23622 );
image.setDotsPerMeterX( 23622 );
image.setDotsPerMeterY( 23622 );
return image;
array.clear();
QBuffer buffer( &array );
buffer.open( QIODevice::WriteOnly );
image.save( &buffer, "bmp", 100 );
}
QPixmap QLightScribe::preview( QLightDrive *drive, const PrintParameters &params, QCDScene *scene, const QSize &size ) throw( QString )
QPixmap QLightDrive::preview( const PrintParameters &params, QCDScene *scene, const QSize &size ) throw( QString )
{
QMutexLocker lock( m_mutex );
if( m_task ) // what should we do?
return QPixmap();
qApp->setOverrideCursor( Qt::WaitCursor );
QByteArray array;
printScene( scene, array );
m_task = new Task( Task::preview );
m_task->m_selectedDrive = drive;
m_task->m_parameters = params;
m_task->m_size = size;
m_task->m_image = printScene( scene );
m_aborted = false;
m_waitQueue->wakeOne();
while( !m_task->m_done )
m_waitDone->wait( m_mutex );
QString err = m_task->m_error;
QPixmap pixmap;
if( err.isEmpty() )
pixmap.load( m_task->m_tmpFile.fileName(), "bmp" );
delete m_task;
m_task = 0;
if( !err.isEmpty() )
throw err;
/*QList<QVariant> argumentList;
argumentList << qVariantFromValue( params ) << qVariantFromValue( array )
<< qVariantFromValue( size );
QDBusReply<QString> reply = m_drivePrx->callWithArgumentList( QDBus::BlockWithGui,
QLatin1String( "preview" ),
argumentList);*/
QDBusReply<QString> reply = m_drivePrx->preview( params, array, size );
qApp->restoreOverrideCursor();
if( !reply.isValid() )
throw QString( "DBus error: (%1) %2" ).arg( reply.error().name(), reply.error().message() );
QString fname = reply.value();
QPixmap pixmap( fname );
QFile( fname ).remove();
return pixmap;
}
void QLightScribe::print( QLightDrive *drive, const PrintParameters &params, QCDScene *scene )
void QLightDrive::print( const PrintParameters &params, QCDScene *scene ) throw( QString )
{
QMutexLocker lock( m_mutex );
if( m_task ) // what should we do?
return;
m_task = new Task( Task::print );
m_task->m_selectedDrive = drive;
m_task->m_parameters = params;
m_task->m_image = printScene( scene );
m_aborted = false;
m_waitQueue->wakeOne();
qApp->setOverrideCursor( Qt::WaitCursor );
QByteArray array;
printScene( scene, array );
/*QList<QVariant> argumentList;
argumentList << qVariantFromValue( params ) << qVariantFromValue( array );
QDBusReply<void> reply = callWithArgumentList( QDBus::BlockWithGui,
QLatin1String( "print" ),
argumentList);*/
QDBusReply<void> reply = m_drivePrx->print( params, array );
qApp->restoreOverrideCursor();
if( !reply.isValid() )
throw QString( "DBus error: (%1) %2" ).arg( reply.error().name(), reply.error().message() );
}
void QLightScribe::abort()
void QLightDrive::abort()
{
m_aborted = true;
}
void QLightScribe::stopThread()
{
QMutexLocker lock( m_mutex );
delete m_task;
m_task = new Task( Task::stop );
m_waitQueue->wakeOne();
}
bool QLightScribe::clAbortLabel()
{
return QLightScribe::instance()->m_aborted;
}
void QLightScribe::clReportPrepareProgress(long current, long final)
{
emit instance()->prepareProgress( current, final );
}
void QLightScribe::clReportLabelProgress(long current, long final)
{
emit instance()->labelProgress( current, final );
}
void QLightScribe::clReportFinished(LSError status)
{
emit instance()->finished( status );
}
bool QLightScribe::clReportLabelTimeEstimate(long time)
{
emit instance()->timeEstimate( time );
return false;
}
void QLightScribe::run()
{
QMutexLocker lock( m_mutex );
while( true ) {
while( m_task == 0 || m_task->m_done )
m_waitQueue->wait( m_mutex );
if( m_task->m_action == Task::stop )
break;
QString function;
try {
function = "LS_DiscPrintMgr_Create";
DiscPrintMgr manager;
function = "LS_DiscPrintMgr_EnumDiscPrinters";
EnumDiscPrinters printers = manager.EnumDiscPrinters();
function = "";
if( m_task->m_action == Task::getDrives ) {
const unsigned count = printers.Count();
for( unsigned i = 0; i < count; ++i ) {
DiscPrinter printer = printers.Item( i );
QLightDrive *drive = new QLightDrive;
drive->m_displayName = QString::fromStdString( printer.GetPrinterDisplayName() );
drive->m_productName = QString::fromStdString( printer.GetPrinterProductName() );
drive->m_vendorName = QString::fromStdString( printer.GetPrinterVendorName() );
drive->m_path = QString::fromStdString( printer.GetPrinterPath() );
drive->m_innerRadius = printer.GetDriveInnerRadius() / 1000.0;
drive->m_outerRadius = printer.GetDriveOuterRadius() / 1000.0;
m_task->m_drives.append( drive );
}
} else {
QByteArray ba;
QBuffer buffer( &ba );
buffer.open( QIODevice::WriteOnly );
m_task->m_image->save( &buffer, "bmp", 100 );
int found = -1;
for( size_t i = 0; i < printers.Count(); ++i )
if( printers.Item( i ).GetPrinterDisplayName() == m_task->m_selectedDrive->displayName().toStdString() ) {
found = i;
break;
}
if( found == -1 )
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;
session.SetProgressCallback( &callbacks );
const size_t bitmapHeaderSize = 54;
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
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 );
}
catch( LightScribe::LSException &ex ) {
emit finished( ex.GetCode() );
throw;
}
//printer.UnlockDriveTray();
//printer.ReleaseExclusiveUse();
}
function = "";
}
}
catch( LightScribe::LSException &ex ) {
if( m_task )
m_task->m_error = function + tr( " failed with code 0x" ) + QString::number( ex.GetCode(), 16 );
}
catch( const QString &err ) {
if( m_task )
m_task->m_error = err;
}
if( m_task ) {
m_task->m_done = true;
m_waitDone->wakeAll();
}
}
m_drivePrx->abort();
}
+63 -100
View File
@@ -21,115 +21,62 @@
#ifndef QLIGHTSCRIBE_H
#define QLIGHTSCRIBE_H
#include <QThread>
#include "qlscribe.h"
#include <QPixmap>
#include <map>
#include <lightscribe_errors.h>
#include <QMap>
#include <QMetaType>
class QCDScene;
class QMutex;
class QWaitCondition;
class QLightDrive;
class QLightScribe : public QThread {
struct PrintParameters {
LabelMode m_labelMode;
DrawOptions m_drawOptions;
PrintQuality m_printQuality;
MediaOptimizationLevel m_mediaOptimizationLevel;
bool m_ejectAfterComplete;
PrintParameters()
: m_labelMode( modeFull ), m_drawOptions( drawDefault ),
m_printQuality( qualityBest ), m_mediaOptimizationLevel( mediaRecognized ), m_ejectAfterComplete( false ) {}
PrintParameters( LabelMode labelMode,
DrawOptions drawOptions,
PrintQuality printQuality,
MediaOptimizationLevel mediaOptimizationLevel,
bool ejectAfterComplete )
: m_labelMode( labelMode ), m_drawOptions( drawOptions ),
m_printQuality( printQuality ), m_mediaOptimizationLevel( mediaOptimizationLevel ),
m_ejectAfterComplete( ejectAfterComplete )
{}
};
Q_DECLARE_METATYPE( PrintParameters );
typedef QMap<QString,QString> QObject2StringMap;
Q_DECLARE_METATYPE( QObject2StringMap );
class OrgLightscribePrintManagerInterface;
class QLightScribe : public QObject {
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,
/** Fit the height to the label size */
drawFitHeightToLabel=1,
/** Fit the width to the label size */
drawFitWidthToLabel=2,
/** Fit the smallest dimension to the label size */
drawFitSmallestToLabel=4
};
enum PrintQuality {
/** Best and slowest. */
qualityBest=0,
/** OK for everyday use. */
qualityNormal=1,
/** Fast but lower contrast. */
qualityDraft=2
};
enum MediaOptimizationLevel {
/** Require that media is present and optimized labeling
* parameters are available */
mediaRecognized,
/** Require that media is present but optimized labeling
* parameters are not available */
mediaGeneric
};
struct PrintParameters {
LabelMode m_labelMode;
DrawOptions m_drawOptions;
PrintQuality m_printQuality;
MediaOptimizationLevel m_mediaOptimizationLevel;
PrintParameters()
: m_labelMode( modeFull ), m_drawOptions( drawDefault ),
m_printQuality( qualityBest ), m_mediaOptimizationLevel( mediaRecognized ) {}
PrintParameters( LabelMode labelMode, DrawOptions drawOptions, PrintQuality printQuality, MediaOptimizationLevel mediaOptimizationLevel )
: m_labelMode( labelMode ), m_drawOptions( drawOptions ),
m_printQuality( printQuality ), m_mediaOptimizationLevel( mediaOptimizationLevel ) {}
};
static QLightScribe *instance();
QList< QLightDrive * > getDrives( bool refresh = false );
QPixmap preview( QLightDrive *drive, const PrintParameters &params, QCDScene *scene, const QSize &size ) throw( QString );
void print( QLightDrive *drive, const PrintParameters &params, QCDScene *scene );
friend bool clAbortLabel();
public slots:
void abort();
void stopThread();
signals:
void prepareProgress( long current, long final );
void labelProgress( long current, long final );
void timeEstimate( long time );
void finished( int status );
protected:
virtual void run ();
QList<QLightDrive *> getDrives();
private:
static bool clAbortLabel();
static void clReportPrepareProgress(long current, long final);
static void clReportLabelProgress(long current, long final);
static void clReportFinished(LSError status);
static bool clReportLabelTimeEstimate(long time);
QLightScribe();
virtual ~QLightScribe();
struct Task;
QList< QLightDrive * > m_drives;
Task *m_task;
bool m_aborted;
QMutex *m_mutex;
QWaitCondition *m_waitQueue;
QWaitCondition *m_waitDone;
OrgLightscribePrintManagerInterface *m_managerPrx;
QList< QLightDrive * > m_drives;
};
class QLightDrive {
class OrgLightscribeDriveInterface;
class QLightDrive : public QObject {
Q_OBJECT
public:
const QString &productName() const { return m_productName; }
const QString &vendorName() const { return m_vendorName; }
@@ -139,16 +86,32 @@ public:
double innerRadius() const { return m_innerRadius; }
double outerRadius() const { return m_outerRadius; }
QPixmap preview( const PrintParameters &params, QCDScene *scene, const QSize &size ) throw( QString );
void print( const PrintParameters &params, QCDScene *scene ) throw( QString );
friend class QLightScribe;
private:
QString m_productName;
QString m_vendorName;
QString m_displayName;
QString m_path;
public slots:
void abort();
double m_innerRadius;
double m_outerRadius;
signals:
void prepareProgress( int current, int final );
void labelProgress( int current, int final );
void timeEstimate( int time );
void finished( int status );
private:
QLightDrive( QObject *parent, const QString &path, const QString &name );
OrgLightscribeDriveInterface *m_drivePrx;
QString m_productName;
QString m_vendorName;
QString m_displayName;
QString m_path;
double m_innerRadius;
double m_outerRadius;
};
#endif // QLIGHTSCRIBE_H
@@ -18,13 +18,28 @@
$Id$ */
#include "qshapecontrollers.h"
#include "qlighttextitem.h"
#include "qdialogtext.h"
#include "qdialogpixmap.h"
#include "qcdscene.h"
#include "qdialogsettings.h"
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
QLightTextItem::QLightTextItem()
{
}
QVariant QLightTextItem::itemChange( GraphicsItemChange change, const QVariant & value )
{
if( scene() && change == ItemPositionHasChanged )
static_cast<QCDScene *>( scene() )->itemMoved();
return value;
}
RegisterController< QShapeControllerText > regControllerText;
QString QShapeControllerText::name() const
@@ -39,7 +54,12 @@ QString QShapeControllerText::menuName() const
QGraphicsItem *QShapeControllerText::create() const
{
return new QGraphicsSimpleTextItem;
QLightTextItem *item = new QLightTextItem;
item->setFont( QDialogSettings::defaultFont() );
item->setTransform( QTransform().scale( 0.5, 0.5 ), true );
item->setPos( 0, -40.0 );
return item;
}
QItemDialog *QShapeControllerText::createDialog( QWidget *parent ) const
@@ -53,12 +73,29 @@ 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 );
bool placeHolder = textItem->text().left( 1 ) == "?" && textItem->text().right( 1 ) == "?";
bool replace = false;
if( from.isEmpty() )
replace = placeHolder;
else
replace = textItem->text() == ( placeHolder ? QString( "?%1?" ).arg( from ) : from );
if( replace )
textItem->setText( to );
}
void QShapeControllerText::readData( const QString &element,
const QXmlStreamAttributes &attrs,
@@ -70,6 +107,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 +128,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
+72
View File
@@ -0,0 +1,72 @@
/* 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
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,
/** Fit the height to the label size */
drawFitHeightToLabel=1,
/** Fit the width to the label size */
drawFitWidthToLabel=2,
/** Fit the smallest dimension to the label size */
drawFitSmallestToLabel=4
};
enum PrintQuality {
/** Best and slowest. */
qualityBest=0,
/** OK for everyday use. */
qualityNormal=1,
/** Fast but lower contrast. */
qualityDraft=2
};
enum MediaOptimizationLevel {
/** Require that media is present and optimized labeling
* parameters are available */
mediaRecognized,
/** Require that media is present but optimized labeling
* parameters are not available */
mediaGeneric
};
const char * const itemMimeType = "application/x-qlscribe;item";
const char * const DBusServiceName = "@QLSCRIBE_DBUS_MANAGER_SERVICE@";
const char * const DBusManagerPath = "@QLSCRIBE_DBUS_MANAGER_PATH@";
// config keys
const char * const cfgDefaultFont = "DefaultTextFont";
const char * const cfgEjectAfterFinish = "EjectAfterFinish";
#endif // QLSCRIBE_H
+18 -7
View File
@@ -1,37 +1,48 @@
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 \
qdialogsettings.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 \
qdialogcdproperties.h \
qconsoleprintprogress.h \
qdialogsettings.h
FORMS += qdialogtext.ui \
qdialogroundtext.ui \
qdialogpixmap.ui \
qdialogprint.ui \
qdialogprogress.ui
qdialogprogress.ui \
qdialogcdproperties.ui \
qdialogsettings.ui
+17 -2
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;
@@ -109,7 +118,13 @@ QString QShapeFactory::name( int type ) const
QGraphicsItem *QShapeFactory::create( int type ) const
{
QShapeController *ctrl = getController( type );
return ctrl ? ctrl->create() : 0;
if( !ctrl ) return 0;
QGraphicsItem *item = ctrl->create();
if( item ) {
item->setFlag( QGraphicsItem::ItemIsMovable, true );
item->setFlag( QGraphicsItem::ItemIsSelectable, true );
}
return item;
}
bool QShapeFactory::edit( QGraphicsItem *item, QWidget *parent ) const
+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;