/* * This is a sample application that utilizes libZI and libQT to illustrate the basic API. * For further information, please seek the appropriate URL(s): * - http://libzi.sourceforge.net * - http://www.troll.no * * Matt T. Proud */ #include #include #include #include #include #include "sample.h" #define CONFIG_FILE "/home/khan/.sample_config.xml" Sample::Sample ():QWidget (NULL, NULL) { setBaseSize (100, 120); a = new QPushButton ("Quit", this, "quit"); a->setGeometry (70, 50, 80, 40); connect (a, SIGNAL (clicked ()), this, SLOT (Push ())); } void Sample::Push () { cerr << "Push" << endl; WriteConfig (); qApp->quit (); ziSave (CONFIG_FILE); } void Sample::WriteConfig () { ziWriteUInt ("width", width ()); ziWriteUInt ("height", height ()); ziWriteUInt ("x", x ()); ziWriteUInt ("y", y ()); ziWriteBool ("minimized", isMinimized ()); } void Sample::ReadConfig () { setGeometry (ziReadUInt ("x"), ziReadUInt ("y"), ziReadUInt ("width"), ziReadUInt ("height")); if (ziReadBool ("minimized")) { showMinimized (); } else { showNormal (); } } int main (int argc, char **argv) { if (!ziOpen (CONFIG_FILE)) { if (!ziCreate (CONFIG_FILE)) { cerr << "Failed to manipulate configuration!" << endl; return 0; } } QApplication b (argc, argv); Sample c; c.setGeometry (120, 120, 220, 220); b.setMainWidget (&c); c.show (); c.ReadConfig (); return b.exec (); }