Posts RSS Comments RSS Del.icio.us Digg Technorati Blinklist Furl reddit 125 Posts and 30 Comments till now
This wordpress theme is downloaded from wordpress themes website.

Archive for April, 2010 (2010/04)

iTunes crash problem / fix

After I upgrade to iTunes 9.1.1.12, iTunes would crash every time I open it.  I tried repair, then uninstall / reinstall, but this didn’t fix it.  Then I did this:
1) rename my iTunes_Media media folder (such as to iTunes_Media_)
2) open iTunes, close iTunes
3) rename the folder back to iTunes_Media

This appeared to fix the problem.  Until I tried (File –> Library –> Organize Library –> Consolidate files), and iTunes crashed again.

To narrow it down, I went through this rather painful process:
1) close iTunes, rename a folder inside iTunes_Media
2) open iTunes, try consolidate files to see if crashes (alt, f, b, l, c, enter)

It turned out that 5 of my author-named folders had broken audiobooks.  Yet they had working copies with “ 1.aa” at the end.  So I deleted the “my file.aa” copies, and renamed the “my file 1.aa” copies to “my file.aa”.

I’m guessing this means that the file was somehow corrupted.  I’m not sure what caused this.  But regardless of whether or not it was iTunes, this really shouldn’t make iTunes crash…  Instead, iTunes should list which files are corrupted.

iTunes_crash_fix_01

Qt Creator, Promote to

Since I’m new to Qt Creator, I wasn’t sure how to put a custom widget in the designer (outside of manually editing the .ui xml file, which seemed wrong).

Then I found that you can right click a widget (in the UI designer of Qt Creator) and choose "Promote to".

For example, you can promote a QGraphicsView to your custom child class of QGraphicsView (such as MyGraphicsView from mygraphicsview.h).

qt_promote_01

Qt stdout qDebug()

#include <QDebug>
qDebug(“qDebug, printf style, %i\n”, 5);
qDebug() << “qDebug cout style, ” << 5;

I created a new Qt4 Gui Application, and did a printf().  The printf() worked (ie, goes to the Application Output) when I run via “Start Debugging F5″.  However, it didn’t print when I run via “Run, Ctrl+R”.  But qDebug() worked in both cases.  Interesting how qDebug() lets you do both printf() style and cout style.

This got me thinking about my plan for this hobby project application.  For my day job, I use Qt just for the GUI, in a Windows / Linux C++ application (that uses Visual Studio and gcc, STL).  However, for this hobby project, I think I will lean towards using more of the pure Qt stuff (rather than STL).  Partly just to try something different.  Partly because I’m giving this new project a Qt focus, and using Qt Creator.  It will be fun to see how this goes :-)

Qt, More Native, video notes

This is just a dump of the notes I took for this Qt Video:

2009/03/04 video, More Native Look & Feel
* http://qt.nokia.com/developer/learning/online/talks/developerdays2009/tech-talks/how-to-make-your-qt-application-look-native
* Intro, Styles, Style Sheets, Dialogs, Cross platform tips, Native platform tips
* More tips at labs.trolltech.com

The 4 UI guidelines:
* Windows User Experience Interaction Guidelines
* Apple HIG
* KDE UIG
* GNOME HIG

Feel aspects:
* GNOME has (Cancel, OK)
* Windows has (OK, Cancel)

Use Styles:
* style()->drawPrimitive(QStyle:PE_IndicatorBranch, &opt, painter, this);
* QProxyStyle, such as for (Windows Vista) vs. (KDE Oxygen), example:
class MyProxyStyle : public QProxyStyle {
  int styleHint(StyleHint hint, …) const {
    if( hint == QSTyle::SH_UnderlineShortcut )
      return 0;
    return QProxyStyle::styleHint(hint, …);
}

Style Sheets:
* careful – they can break look and feel
* try to blend with system palette
  QString css = "QLabel{ color:palette(highlight); }";
* if you need custom colors
  QColor color(255, 0, 0);
  QString css = QString("QLabel { color:%1;}").arg(color.name())

Dialogs, QDialogButtonBox
* manages button order, layout, icon, text
  QDialogButtonBox box(QDialogButtonBox::Save | QDialogButtonBox::Discard | QDialogButtonBox::Cancel);
* can use custom buttons as well
  QDialogButtonBox box;
  box.addButon(myCustomButton, QDialogButtonBox::AcceptRole);

Dialogs, QFormLayout
* such as for config dialogs
  * Mac labels aligned right, Windows labels aligned left
* manages label alignment
* row wrapping (on embedded devices, it will split the lines)
* implicit buddy assignment

Dialogs, Dialog modality
* he said they are against the user guidelines
* on Snow Leopard (Mac OS X 10.6), they don’t ask you to confirm changes
* Mac apps tend to be a single doc interface
* QDialog methods – use open(), so that on mac os x it will be a sheet
  QDialog::exec() // modal
  QDialog::show() // non modal
  QDialog::open() // window modal
if(!messagebox) {
  messagebox = new QMessageBox(…);
  connect(messagebox, SIGNAL(finished()), this, SLOT(dialogClose(int));
}
messagebox.open()
* if we want a dialog attached to a specific window, use QDialog::open()
* a window is not a sheet, if it’s covering other windows

Cross platform tips, when showing file location in title bar
* Do this:
  setWindowModified(true);
  setWindowFilePath("untitled.txt");
* because
  Windows uses a *
  Mac puts a small dot in the close circle button X
  differences in path in title bar

Cross platform tips, ask for attention
* QApplication::alert(widget, msec = 0);
* makes the windows taskbar flash / mac dock bounce

Cross platform tips, QDesktopServices
* storageLocation(), gives access to default directories, documents, temp, music
* openUrl(), launches URL in default system application
* QUrl from PDF file will open with default app
* openUrl("mailto:myself@gmail.com")
* openUrl("http://qt.nokia.com")
* openUrl(QUrl::fromLocalFile(…))

Cross platform tips, shortcuts
* Qt has QAction::setShortcut() and QAction::setShortcuts(); use setShortcuts()
* QKeySequence::keyBindings(QKeySequence::NextChild)
  Use this to check for shortcut key conflicts
  Test it on all platforms

Cross platform tips, icons
* on windows you’re not supposed to use icons for anything anyway?  what?
* use consistent icon theme (not random conglamoration of icons)
  such as Oxygen (KDE 4), or Tango (free project, sort of GNOME related?)
* QIcon::fromTheme("documents-edit");
  QIcon::fromTheme("documents-edit", QIcon("document.png"));
  new in Qt 4.6
  lets you load an icon from an icon theme
  this is great for KDE and GNOME
  for Windows and Mac, bundle icon theme as a resource
  for KDE, the idea is to use KIcon
  test changing the theme on (such as on GNOME / KDE etc)
* QAction::setIconVisibleInMenu(bool)
  QApplication::Attribute(Qt::AA_DontShowIconsInMenu)
  Mac default is false
  But next version of GTK for GNOME is disabling these – so I should leave it alone
  Windows – he thinks people overuse icons, so I could set it to false, specifically for Windows

Cross platform tips, QAction Priority
* new Qt 4.6
* QAction::setPriority(QAction::Priority)
* allows Qt to collapse layouts intelligently (such as shrink icons, remove icon text, etc)
* decides, for which icons, the label is collapsed
* they plan to add more support for this in the future

Cross platform tips, MDI interfaces
* multiple document interfaces
* don’t use them (for example, use tabbed views instead)
* Mac doesn’t support, GTK+ doesn’t support, Microsoft discourages it (says use MDI)

Native platform tips, use native code
* ifdefs: Q_WS_WIN, W_WS_MAC, Q_WS_X11
* QWidget::winid(), gives window handle (HWND, NSVIEW, X handle)

Native platform tips, Mac MainWindow Demo
* Qt’s main window demo is not very good?
* 29 min 50 sec:
  it’s almost impossible to use the same layout on the mac and say with it straight face that it "looks native"
  Mac tends to require modifications to your interface if you truly want it to look native

Native platform tips, Mac icons
* blowing up a 32×32 icon looks terrible
  he said to use a gray icon for tray – but that’s no longer true?

Native platform tips, Mac QMenuBar
* create a QMenuBar without a parent
* first menu bar created will be the default menu bar
* "Qt Creator doesn’t do this, but it should – we’ll fix that"; is it already fixed?

Native platform tips, Mac unified tool bar
* QMainWindow::setUnifiedTitleAndToolBarOnMac()
* do enable it, but you may have to test / tweak it
* he said he hopes next version of Qt will handle the default better?
* you don’t have room for more than 10 Mac icons

Native platform tips, Mac custom doc menu (sp, dock?)
* QMenu *menu = new QMenu;
  // Add actions to the menu
  extern void qt_mac_set_dock_menu(QMenu *);
  qt_mac_set_dock_menu(menu);

Native platform tips, Mac menu placement
* Qt automatically rearranges menu entries
  based on name: about, settings, preferences, quit, exit
  just use the name to call it "settings" etc, and it will go to Application::preferences on Mac
* override with QAction::menuRole, AboutRole, PreferencesRole, NoRole (means don’t move)

Native platform tips, X11
* Qt 4.6 has KDE improvements
* see freedesktop.org, ?
* make a .desktop file
  handles application icon, menu entry, mimetype
* use standard icons
* test on both GNOME and KDE (and possibly others, such as XFCE)
  different themes, shortcuts, window behavior
* use DESKTOP_SESSION environment variable, returns GNOME or KDE or XFCE
  if we want to do different things for GNOME vs. KDE etc?

Native platform tips, Windows registry via QSettings
* QSettings reads the Windows registry, by default
  QSettings settings("HKEY_CURRENT_USER\\ …", QSettings::NativeFormat);
  bool result = settings.value("EnableBalloonTips", true).toBool();

Native platform tips, Windows QCommandLinkButton
* introduced with Windows Vista, but works just as well on other platforms (Windows 95, Mac, X11)
* great for wizards: instead of having the user do (click radio button, then click next),
  instead just do (click your choice – click just once)

Native platform tips, Windows explorer style look and feel
* Windows native – this guy says it’s lost some of it’s meaning
  he says apps tend to only use the look and feel for certain parts of the GUI
* http://labs.trolltech.com/blogs/2007/06/08/explorer-style-toolbars/
* QtDotNetStyle, Office 2003 style – although it’s going out of fashion

Native platform tips, Windows enable blur behind (Windows Vista, Windows 7)
* not supported in Qt as of 4.6
* but you can use the native Windows API, if you set
  WA_TranslucentBackground and WA_NoSystemBackground, on the widget
* he wrote an example enable blur function, EnableBlur() (sp?)

Screen Shots:

OK and Cancel Buttons
qt_video_notes_01

QDialogButtonBox
qt_video_notes_02

QFormLayout
qt_video_notes_03

Icons
qt_video_notes_04

Cross Platform GUI for Mac

I did a quick prototype using C# and .NET with the Visual Studio 2008 GUI designer.  Then I compiled and ran this on Mac OS X using MonoDevelop.

I had a very positive impression of MonoDevelop.  Though one quirk I ran into was having to do a separate post-build step path for Windows vs. Mac.  Once I got that working, here’s how it looked on Mac OS X:

cross_platform_gui_01

Mac is the most worrisome of the four (Windows 7, Mac OS X, KDE, GNOME) in terms of having a good look and feel for the GUI.  This one didn’t have a good Mac look and feel, because it used Windows Forms (WinForms).  For Mono, you’re encouraged to use GTK#.

I also tried a small Java Swing application.  I created it in NetBeans, then just copied the binaries into Mac OS X.  This had a more Cocoa / Aqua feel to it.  The Menu bar is wrong, but it at least looks a lot better than my WinForms example!

cross_platform_gui_02

Java Swing has some official doc from Apple.  On the other hand, there are also arguments in favor of Java SWT being more native.

Next, I looked at Qt.  At this point, I think I’m most likely to end up using (Qt, Qt Creator, C++).  Some are claiming that a cross platform desktop GUI will be wrong (somehow), and you should just do 4 separate native GUIs, or at least 2 separate native GUIs (one for Windows / Linux, and one for Mac OS).  However, I think this really depends on your goals, and on the specific application you are developing.  Additionally, I’m confident that in many situations, either path can yield good results (or bad results).  For my current particular hobby project, I am pretty optimistic about Qt.

Someone on the qt-creator list said he heard there are font rendering problems, so I tested this (on Snow Leopard), and I didn’t see anything wrong with it: XCode, Text Wrangler, Qt sample app (I ran it from Qt Creator):

cross_platform_gui_03

cross_platform_gui_04

cross_platform_gui_05

There’s just a little info / summary about my investigation.  Some links to check out:

* Qt is Mac OS X Native: http://doc.trolltech.com/4.6/qtmac-as-native.html

* Qt, 2009/03/04 video, More Native Look & Feel:

http://qt.nokia.com/developer/learning/online/talks/developerdays2009/tech-talks/how-to-make-your-qt-application-look-native

* The HIG’s: Windows User Experience Interaction Guidelines, Apple HIG, GNOME HIG, KDE HIG

Cross Platform GUI toolkit choices

I know they aren’t the only choices, but here’s the ones I looked at.

My top 3 ideas are:
1) Qt, C++, Qt Creator (or Visual Studio / gcc / etc)
2) Swing, Java, Eclipse (or NetBeans, or IntelliJ)
3) SWT, Java, Eclipse (or NetBeans, or IntelliJ) (JFace rather than SWT?)

Some ideas that get honorable mention:
A) multiple native GUI toolkits (Windows, WPF, Expression Blend) (Mac OS X, Cocoa, Interface Builder) (GNOME, GTK+) (KDE, Qt)
B) REAL Studio (formerly REALBasic)
C) GTK#, C# and .NET, Mono

An absolute minimum is to have very correct native visual style for the widgets (Mac OS X – Cocoa Aqua ?) (Windows – not sure if it’s Windows Forms or WPF ?) (GNOME – GTK+ ?) (KDE – Qt ?).  Beyond that, it should do things like dialogs where the position of the (OK, Cancel) buttons is correct (for Windows 7, Mac OS X, GNOME, KDE), which I know Qt at least tries to do.  Probably a native app should use different defaults shortcuts for each OS.

I saw that Apple supports Swing, and that SWT has a native widget focus.  However, I don’t know how well they compare to Qt (especially on Mac OS X) for these things.

I may have ruled out REAL Studio too soon, but I’m not enthused about that path unless it’s really a lot better than the other choices (such as Qt, Swing, SWT).

My first cross-platform GUI desktop application is just a simple specialized object based image drawing utility (you can open a png image and draw objects on it, like rectangles or polygons, and resize / move / delete / copy etc these objects).

The places I got the most information on this were:
1) doc from Apple, Qt, etc (Qt had some good videos)
2) trying it out myself (and looking at screen shots)
3) the official mailing lists, such as qt-interest and mono-osx

At this point I’m leaning towards Qt.  More on that in my next post.

Hobby Projects – Software Development

As someone who is passionate about software development, most of my life is pretty engrossed in software / computers / technology.  In addition to things like this blog, keeping up on technology news, having technology-related hobbies, trying out new software, organizing my digital life…  I often do side projects, scripting / automation projects, and learning / studying that is not necessarily for immediate direct application to my current day job.

Some recent examples include:
* My enthusiasm for AutoHotkey scripts
* file organizing / sync / backup (and lists of applications)
* notes / note taking
* this blog / website
* a game prototype with Torque 3D, and continued attention to electronic games (and to the computer / technology industry)
* increased use and awareness of mobility computing (devices / mobile OS)
* more cross platform (Windows 7, Mac OS X, GNOME, KDE) on a daily basis, and use / develop cross platform (I use a hardware KVM)
* Try out other IDE’s / languages than what I normally use.  I normally use Visual Studio with C++.  And also (C#, Python, Java) and (EditPad text editor).  I’ve also tried out, for example, (RenderMonkey, Eclipse, NetBeans, Adobe Flex, Windows Mobile in Visual Studio, XCode / Interface Builder).
* more and deeper use of subversion
* these are just a few examples that I pulled out from memory

This small list is mostly for nights / weekends, which is separate from the work / study I do for my day job.  However, there is definitely plenty of overlap, and of course all of it helps me grow as a software developer.

Sometimes I use the phrase “side projects” to include a broad range of (programming hobby projects, scripting / automation projects, trying out hardware / software, or in some way attempting to improve my current hardware / software setups).  Other times I use the phrase “hobby projects” to only mean actual software development with a significant project size.  I might not be consistent on my terminology.  Anyway…

My next few posts are going to relate to a new software development hobby project, with a significant focus on using (Qt, C++, Qt Creator) for (cross platform GUI application development).

Gmail filters – skip the inbox

I do pretty much the same thing with tags (Gmail) as I do with folders (Outlook Exchange).  I have rules to filter particular emails into a folder (or a tag).

In Gmail, you can do this when you create a new filter.  Or, to do this for existing filters, you go to Settings –> Filters, and for each filter you do Edit –> Next Step –> check Skip the Inbox (also check, also apply to the conversations below).

gmail_filters_01

iPad keyboards

The iPad supports bluetooth 2.1 keyboards.  But there’s two keyboards in particular that Apple is initially pushing.

iPad_keyboards_01_dock

The iPad Keyboard Dock has special function buttons on the top row: home button, search button (redundant since you can just press the home button twice?), brightness down, brightness up, picture frame mode toggle, software keyboard toggle, a mysterious unlabeled button, music/video media controls (track left, pause/play toggle, track right), volume mute, volume up, volume down, screen lock.  One thing I like about it is that the bottom left keys are (Control, Option, Command).

However, the deal breaker is that the keyboard is attached to the dock, and the dock doesn’t fold – so this makes it less portable.

iPad_keyboards_02

When you checkout from the online Apple store with an iPad, the other keyboard they try to sell you is the Apple Wireless Keyboard.  I’ve used one at a Best Buy display, and I think it’s pretty slick overall (in particular, it’s small size).  However, I’m not sure how well it would fit in my laptop bag next to the iPad, with that raised cylinder.  The other concern is whether the F keys work the same as with the iPad keyboard dock.  I am hopeful that they do, even though they are labeled differently.

However, the deal breaker is that the bottom left keys are (Fn, Control, Option, Command).  The position of the Fn key is confusing for shortucts.

A similar thing that may kill me, regardless of what I do, is that, when I use Mac OS X, I remap Command to Control (and Control to Command), so that most Windows shortcuts (like ctrl+X, ctrl+C, ctrl+V – cut, copy, paste) work the same.  I am doubtful about this being easy to do on the iPad.  I know it’s close-minded, but shortcuts like cut copy paste are for my left pinky finger – not my left thumb!!!

For now, I’m waiting to hear more info about specifically how the iPad works with the specific keyboard keys…  And whether they will release another Apple Wireless Keyboard (for iPad) that doesn’t have the Fn key.  Or another iPad Keyboard Dock, that is more portable.

Update: I still don’t like that the wireless keyboard has a Fn key.  And it looks like you can’t remap the keyboard keys (like I do on Mac OS X, swapping control and command).  So you still have to do (Cmd+X, Cmd+C, Cmd+V) for (cut, copy, paste), which is the Windows equivalent of having to do (Alt+X, Alt+C, Alt+V) instead of (Ctrl+X, Ctrl+C, Ctrl+V) – in terms of the hand positioning (muscle memory for keyboard shortcuts).  However, overall, my biggest gripe is that I want an Apple wireless keyboard without that Fn key.  It really bothers me (in terms of muscle memory for keyboard shortcuts), since it means Control is no longer on the very bottom left!  I think I’d be a lot happier if they put Fn key on the right side of the spacebar.

image

iPad is not God, but it is first to market

I am interested in the iPad.  The reason is not because it’s awesome (although it is, but so are a lot of other things).  The reason is because they are first to market, and it may be a while before something that is really in the same category comes out.  The general category is, bigger than a smart phone but smaller a laptop.  However, that’s not the entire story.

iPad_first_02_ipad

I’ve pretty much lost interest in single-purpose one-color slow-screen-refresh devices, like the Amazon Kindle, or Barnes and Noble Nook.

Today’s netbooks are still slow, because Intel Atom is slow (and at the same time, Atom’s power efficiency is worse than ARM devices).  There are even some thin keyboard-less Atom tablets (such as Archos 9 PC) (Asus has a rumored Eee Tablet), and convertible Atom tablets (such as an Asus Eee model).  But that’s still a different category – an undersized x86 Windows computer (with an x86 OS), rather than an oversized ARM device (with an ARM OS).

This is the same reason why I would call the upcoming HP Slate PC to still be a significantly different category.  Yes there’s starting to be more overlap in functionality, making it feel somewhat gray.  Yes, there will be a stronger push for x86 keyboard-less tablets too.  But running (Windows 7 on a real x86 computer) vs. running (iPhone OS on an ARM device) is still a completely different experience – even if they are both tablets with screen sizes that are about the same size.  Also, HP Slate PC isn’t out yet (rumors say June).

iPad_first_01_hpslate

Another iPad competitor that looked sort of cool is the TouchBook (it’s a small ARM netbook).  And it did come out before the iPad…  But I’m skeptical about the resistive touch screen (it’s also a little thicker, even without the keyboard).  In the end, it’s another ARM tablet that supports Android OS (and other mobile OS’s), although I do love the detachable screen / keyboard design.

iPad_first_05_touchbook[4]

The real competitor for iPad (in terms of category) is other similar sized ARM devices.  Later this might include Windows Mobile 7, or even Palm Web OS, or Nokia Symbian (or who knows – maybe even BlackBerry?).  But right now the main known competitor is Android.  That’s in the near future, but not a lot out yet.  Plus, there might be further delays (before we get something that really competes) relating to Android fragmentation and multitouch support?

So I’m definitely considering an iPad myself (for now) – unless I see some really amazing Android Tablet coming out within the next month.  Then, in a year or 2 (or 3), I may also be in the market for an x86 tablet (or convertible laptop).  Maybe a nice x86 tablet with an awesome AMD/ATI Fusion processor :-)

Finally, I would like to admit that the current separation between (x86 with desktop OS: Windows 7, Mac OS X, Linux) and (ARM with mobile OS: iPhone, Android, Palm, Symbian, Windows Mobile, BlackBerry) may become even more gray.  Because both Android OS and Chrome OS support both ARM and x86.  For example, the WePad is x86, yet it’s going to run Android.

Next »