Kisa Logo Kisa — live! spell checker

Sunday, March 7, 2010

Subversion



Fret not dear Kisa user. We have not abandoned you.

I finally managed to find some spare time and decided that this was a good time as any to set up a Subversion repository. More info on how to access the code base here.

A couple of issues where also resolved this weekend and there are a few more left before we version is out. As promised, the next major release is going to be a native KDE plasma based application. However, I'd like to have a sold Qt version to build on for the future as it's one if the best frameworks out there.

Stay tuned!

Tuesday, February 24, 2009

exit(0)




Say that your application has subclassed QApplication and that you have some evaluation logic in the constructor that needs to exit the application if some condition is not met like so:


int main(int argc, char **argv) {
MyQApplication app(argc, argv);
return app.exec();
}

MyQApplication::MyQApplication(int argc, char** argv) :
QApplication(argc, argv) {

// want to be able to exit here
}


So what's the issue? Well QCoreApplication::exit() and QCoreApplication::quit()
(which is the same as exit(0)) needs the event loop to be up and running. As the documentation for QCoreApplication::exit() says says: "If the event loop is not running, this function does nothing."

Now from a design perspective exiting from the constructor like this is probably not the best way to go about things. But, for the sake of argument say that you really have to. And have to without refactoring the code.

So far the only two options I've come across that let's you keep your old design is qFatal() and std::exit(). However, they both leave some to be desired. qFatal() will print and "Aborted" at the end and that is no good if you have an internationalized application. std::exit(0) will require reaching outside of Qt, which is fine, but you need to update the compiler include path and that could open up issues when compiling on different (non-standard) systems.

Now if you're not to lazy a re-design is in place. I posed the question to the qt-interest mailing list and got a couple of good responses.

Arnold Krille suggested to create a bool MyQApplication::shouldRun() and then check before calling app.exec() like so:


int main(int argc, char **argv) {
MyQApplication app(argc, argv);

if (app.shouldRun())
return app.exec();
}


Scott Aron Bloom pointed out that throwing an exception is considered better practice then calling exit() directly.


MyQApplication::MyQApplication(int argc, char** argv) :
QApplication(argc, argv) {

if(errorConditionExisted)
throw ...
}

Monday, February 23, 2009

Damn bugs!



Well, bug at least. Had to push a bugfix release out. The super cool -flags option turned out to be broken. QA has been notified and have already updated their testing routines.

Get the source, ebuild, deb and rpm from the usual location.

Flags



If you're running in non KDE environment, or just missing the l10n part of KDE localizations module here is an archive containing the flags.

Use the -flags argument to specify the location of the extracted folder if it's not under /usr/share/locale/.

Sunday, February 22, 2009

New release



OK, so the idea was that starting from version 0.60 we would have full KDE support. That did not happen, but I'm happy to announce one of the strongest versions ever. Still pure Qt, still live! spell checking.

A lot of effort went into this one and there where plenty of new improvements and issues fixed. Some of the major updates are:


  • Updated the way words get entered, should be a lot more flexible now
  • Added XKb support to get the keyboard layout on non KDE systems
  • Added Ukrainian translations, thanks to Yuri Chornoivan
  • Fixed "replace in client", should be stable now
  • Fixed issue 1 and issue 5, where some correctly spelled words being treated as misspelled
  • Changed -language command line parameter to set application language


Please see the full Changelog for more information.

There is now a Kubuntu deb and a Fedora RPM as well as the regular Gentoo ebuild.

Enjoy!

Thursday, February 19, 2009

Got atoms?



This is a piece of useful code I forgot to save a while back so I had to take some time to research it again. It's for getting Xlib window property information. Change the XA_STRING to fit your needs based on the types in X11/Xatom.h.


Atom* atoms;
int num_prop_return = 0;
atoms = XListProperties(m_display, window, &num_prop_return);

for(int i = 0; i < num_prop_return; i++) {
Atom atom = *atoms;
QString name = XGetAtomName(m_display, atom);
atoms++;

Atom type;
int format;
long offset = 0;
long length = 8192;
unsigned long nitems, after;
unsigned char *data = 0;
XGetWindowProperty(m_display,
window,
atom,
offset,
length,
False,
XA_STRING,
&type,
&format,
&nitems,
&after,
&data);
qDebug() << name << QString::fromLatin1((const char*) data);
}

XFree(atoms);



References:
Xlib Properties and Atoms
qapplication_x11.cpp

Wednesday, February 18, 2009

XKb support



Finally done! Took half a day, but time well spent as I've wanted to implement this for months and never figured out a good way. Parsing these long strings is not what I hoped for, but at lease now I have something to build on. Remember what trigged this in the first place is the broken QApplication::keyboardInputLocale().