Pictures & Patterns (Apr 27)

This past week, our staff worked on graphics for our new accounting software.

First on the list were rectangles, ovals and lines. Some of our layouts use them to help organize data entry screens and printed forms. Now they draw and print properly.

Graphic shapes had one quirk to deal with: pen patterns. It’s left over from the early days of our accounting software, when some users still had 1-bit black & white monitors. For them, dots were the only way to get shades of gray. Qt supports pen patterns, but they don’t make much sense for business use. So, we wrote code to convert patterns to matching shades of gray. It looks better, and draws faster.

Next was the company logo. It prints on many of the stock business forms. You change it via File–Company Info. That way you can tweak your logo, and automatically update all the layouts that use it.

The logo also had its quirks. Goldenseal currently uses PICT for all images. It was the standard Mac graphic format for many years, but Apple abandoned it in the 64-bit OS. For TurtleSoft Pro, we need to convert all pictures to .png, .jpg or .pdf.

It’s also time to change how we store graphics. Goldenseal has them as binary data inside the company file. That’s not ideal. Pictures are much bigger then business records, and less vital. Store a lot of them, and the database grows cluttered and huge.

The modern approach is to put each graphic into a separate file. They can be resources inside the app, or regular files on your drive. For the first release, TurtleSoft Pro will store the company logo in a special folder. Replace logo.png, and it will update all your layouts. Eventually, the app will store all graphics that way. Small files are easier to back up, and easier to manage.

Next up were dimension layouts for construction estimating. Those have simple pictures (currently binary PICT data inside the layout). We saved the pix into resource files, then added one-time code to draw them onscreen. It’s not elegant, but it works. Future versions will do it better.

There are a couple more types of graphics inside Goldenseal. Users can paste pictures into records, or add them to custom layouts. Sadly, we can’t move either of those to TurtleSoft Pro. Qt can’t read PICT. Nor could we find other source code to convert it to newer formats. Writing a translator from scratch would take months.

Fortunately, image storage is only a small part of our accounting/estimating software. Most users never even discovered it. If you did add pictures, you can salvage them with a paste into Adobe Acrobat, Macintosh Preview, or MS Office (most versions).

Dennis Kolva
Programming Director
TurtleSoft.com

Printing Progress #2 (Apr 20)

Our new estimating/accounting software now prints invoices. It prints reports. It prints paychecks and regular checks. Yippee!

QTextEdit seemed like it might be a magic bullet for printing, but it wasn’t. So we had to do things the hard way. After a few days of trial and error, printing finally worked OK for reports. After that, our staff completely rewrote the code for printed forms. It was mostly obsolete, and overly complicated. Luckily, a few bits were salvageable, and forms are similar to reports. It didn’t take long. Now the code is clean and simple.

There still are a few printing bugs, but nothing serious. The hardest work is done. It coulda been a whole lot worse.

With that out of the way, our staff has moved on to a long list of small tweaks and bug fixes. Actually, there is no list. We try stuff, fix what’s broken, then move on a bit further. On a good day, the process zaps 5 medium-sized problems or 20 little ones.

Some of the bugs are just ugly screens. Pixel sizes, fonts and window controls have all changed since we wrote Goldenseal. We still read the old-style layouts, but tweak them in code to look better.

Some bugs are workflow. It takes effort to make all the functions move smoothly for daily use. Our software is more complicated than most apps. There are multiple screens doing different things. Some of them link to each other. Juggling all possible paths takes time to polish.

Many bugs are there because code changed above or below them. Over the past 7 years our staff rewrote all the interface code in Goldenseal, plus the database and many basic classes (array lists, text strings, money values, etc). Sometimes that caused fallout that we only discover during testing.

Right now we are testing the Find command. Goldenseal has a design flaw that is fixed in the new version. In the current app, Find uses the regular data entry fields and changes their function. Rarely, it goes wrong somehow and zaps a record or creates a dud. It happens to us once or twice a year, but we never have tracked down where/how it happens. The new software puts Find in a separate panel, so records won’t fail like that. But, it’s a different design. It has new and improved ways to fail. On top of that, some search code was zapped by changes in strings and money.

How long until the new accounting app is ready to release? Still too hard to tell. In another month or so we’ll have a better guess.

There are a few features that won’t be in the first release. Networking is the toughest nut left to crack. We won’t tackle that until after the single-user version is ready to go. Custom Layouts will only have a bare-bones set of features in the first version, if it’s there at all. Printing of mailing labels probably will wait for a future update (unless someone really begs us for it). That was added for TurtleSoft use, but our last bulk mailing was in 2012. Email and web are cheaper and easier now.

Dennis Kolva
Programming Director
TurtleSoft.com

Printing Progress (Apr 12)

The good news is, report printing already works great in our new accounting software. It went much faster than expected. But, there are complications. Here’s why.

Everything visible in the current Goldenseal is handled the same way. Layouts have a list of fields, buttons, text and graphic objects. Each of those has a size and position. That way our code knows exactly where to draw them on the screen or on paper. Layout data is mostly a bunch of numbers.

So far, we have used the same approach for TurtleSoft Pro.

Last week our staff wrote code to print from our current report layouts. It didn’t work. The print dialog ran OK, but nothing printed. All attempts to fix it failed.

It was time to get help. Any sample projects to start with? Nope, no examples at all for printing. Any info on Qt Forum or Stack Overflow? Sure, there were a dozen posts already, asking how to print QTableWidget (the parent for our report tables). We aren’t the first with the problem.

There were answers, but not what we wanted. Some said to use QTextEdit (it’s similar to Mac TextEdit or Windows NotePad). Others suggested QWebEngine (a built in web browser). None explained how to print tables directly. All the solutions moved data into some other format before printing.

We finally found code to print some other types of QWidget (the parent of all the above). That was a good start. We ran it. It printed OK on Windows, but did nothing on the Mac. Aha! That’s why we also failed. Qt has other problems that only happen on Macs, so it’s not a surprise. Problem is, we need to support both platforms.

As a work-around, QTextEdit seemed possible. It also would be good for contracts and other formatted text. So we gave it a whirl for reports. End result: they look good, and they print great.

QTextEdit is almost a magic bullet. Printing is a snap, with no extra futzing at all. It even handles page breaks properly for long tables. We spent weeks on that little detail in Goldenseal: counting pixels so text wouldn’t split in the middle. Fonts are surprisingly difficult.

The problem is that QTextEdit acts like a word processor, not a graphics layout program. It doesn’t put things at exact pixel locations. Instead, everything flows with the text.

That’s not so bad for reports. Most are simple. We probably can get all of them looking pretty decent. Printed forms will be a bigger problem. Those have boxes, logos and funkier layouts. We haven’t worked with QTextEdit enough yet to know how well it will handle them. If the built-in features are not enough, programmer tricks may help. We can insert transparent objects to space things, maybe.

There’s also a bigger problem. How will users customize QTextEdit-based reports and forms in the Layouts panel? Right now you drag a field around, and it sets the position and size. QTextEdit doesn’t roll that way. In fact, it is downright weird. You add things to it with an imaginary cursor. Almost as if you clicked, then typed or pasted stuff by hand. How do we make a user interface for that? How do we store the data?

It’s a real dilemma. Life will be so much better if Qt handles the printing for us. There are so many ways to go wrong. However, the extra coding and design time may wipe out any time savings. Or we may just have mediocre printed forms.

For now, our staff will keep fiddling with QTextEdit, but also move on to other parts of the accounting software. Better to ease into a decision gradually. Maybe we can find the secret to printing tables directly.

Dennis Kolva
Programming Director
TurtleSoft.com

Printing/Reports/Rabbits (Apr 6)

For the past month our staff has been testing the new accounting software with TurtleSoft data. It’s called “eating your own dog food”. Plenty of details are still unfinished, so it’s not yet ready for daily use. Sometimes progress takes minutes or hours. Sometimes it’s slower.

Last week we tried printing a sales receipt. The button just beeped. No code at all there, yet. Time to tackle another hard problem. Luckily, there aren’t many of those left.

Printing is complicated. There are different paper sizes. Landscape or portrait. Color or B&W. Printers vary in their dots per inch and printable margins. Every operating system has a way to talk with printers, but none are very easy. Our staff probably has spent a full programmer-year on the Goldenseal printing code, much of it just futzing with margins. Hopefully, Qt will be easier than previous frameworks, once we figure it out.

Most apps send users to Page Setup before they print. Let the OS and the user decide how it should look. After that, most apps have it easy: use the same code that draws on the screen, but send images to the printer instead.

Printing business forms is more complicated. They don’t look the same as what’s on the screen. They come in different shapes and sizes. A detailed estimate may have several pages of breakdowns, all coming from one record. Splitting lines of text between pages can be tricky. Mailing labels are the opposite: they may have 15 or 30 records on each page, without much wiggle room.

To handle all that, each printed form has its specs built in, set via Custom Layouts (Goldenseal) or the Layouts button (TurtleSoft Pro). That means you can just hit Print Forms, and get what you want. No need to visit Page Setup. Easier for you, but more complicated for us.

We decided to ease into printing by starting off with reports, rather than printed forms. Their print version matches what’s on the screen, so there are fewer ways to go wrong. We clicked the Reports button to see one. Oops, not much there. We set up the buttons and layout loading a year ago. But it still needed coding to fill in text and numbers.

Most of the reports show a table, with rows and columns of data. Report tables share some features with breakdown tables, which already work OK. But there are differences. Moving to Qt meant diving down into the base classes that apply to all tables. That’s yet another complicated bit of code.

We rewrote the memory storage in tables 5 years ago, as part of the Cocoa project. Our staff has gotten better at modern C++ since then. So, we spent a couple days refactoring the base tables. The new code does the same things, but with less risk of crashing or leaking memory. Tables now are less fragile, and easier to maintain. They still have room for improvement, but that can be a gradual process.

It has been bit of a rabbit hole. Going deeper and deeper. But, report tables now fill in text, so we are starting to ascend. Most likely it will take a few weeks to reach the surface. Get tables more solid, get reports fully working, then get them printing. Then print some forms…

Dennis Kolva
Programming Director
TurtleSoft.com