int main(int argc, char** argv) { qDebug() << "main(), thread " << QThread::currentThreadId(); QApplication app(argc, argv); ControlWindow control; control.show( ); int out = app.exec(); return out; }
int main(int argc, char ** argv) { QApplication * app = new QApplication(argc, argv); int cx = -1; int cy = -1; int w = QApplication::desktop()->width(); int h = QApplication::desktop()->height(); QSettings settings(QSettings::IniFormat, QSettings::UserScope, "DoUML", "settings"); settings.setIniCodec(QTextCodec::codecForName("UTF-8")); int uid = settings.value("Main/id", -1).toInt(); int l, t, r, b; l = settings.value("Desktop/left", -1).toInt(); r = settings.value("Desktop/right", -1).toInt(); t = settings.value("Desktop/top", -1).toInt(); b = settings.value("Desktop/bottom", -1).toInt(); if(l != -1 && r != -1 && t != -1 && b != -1) { if (!((r == 0) && (t == 0) && (r == 0) && (b == 0)) && !((r < 0) || (t < 0) || (r < 0) || (b < 0)) && !((r <= l) || (b <= t))) { cx = (r + l) / 2; cy = (t + b) / 2; w = r - l; h = b - t; } } if (uid == -1) QMessageBox::critical(0, "Control project", "Own identifier not defined"); else if ((uid < 2) || (uid > 127)) QMessageBox::critical(0, "Control project", "invalid Identifier"); else { set_user_id(uid, homeDir.dirName()); app->connect(app, SIGNAL(lastWindowClosed()), SLOT(quit())); init_pixmaps(); ControlWindow * ww = new ControlWindow(homeDir); ww->resize((w * 3) / 5, (h * 3) / 5); if (cx != -1) ww->move(ww->x() + cx - (ww->x() + ww->width() / 2), ww->y() + cy - (ww->y() + ww->height() / 2)); ww->show(); app->exec(); } return 0; }
int main(int argc, char ** argv) { QApplication * app = new QApplication(argc, argv); int uid = -1; // note : QFile fp(QDir::home().absFilePath(".boumlrc")) doesn't work // if the path contains non latin1 characters, for instance cyrillic ! QDir homeDir = QDir::home(); QString s = homeDir.absFilePath(".boumlrc"); FILE * fp = fopen((const char *) s, "r"); int cx = -1; int cy = -1; int w = QApplication::desktop()->width(); int h = QApplication::desktop()->height(); if (fp != 0) { char line[512]; while (fgets(line, sizeof(line) - 1, fp) != 0) { remove_crlf(line); if (!strncmp(line, "ID ", 3)) { sscanf(line+3, "%d", &uid); break; } else if (!strncmp(line, "DESKTOP ", 8)) { int l, t, r, b; if (sscanf(line+8, "%d %d %d %d", &l, &t, &r, &b) == 4) { if (!((r == 0) && (t == 0) && (r == 0) && (b == 0)) && !((r < 0) || (t < 0) || (r < 0) || (b < 0)) && !((r <= l) || (b <= t))) { cx = (r + l) / 2; cy = (t + b) / 2; w = r - l; h = b - t; } } } } fclose(fp); } if (uid == -1) QMessageBox::critical(0, "Control project", "Own identifier not defined"); else if ((uid < 2) || (uid > 127)) QMessageBox::critical(0, "Control project", "invalid Identifier"); else { set_user_id(uid, homeDir.dirName()); app->connect(app, SIGNAL(lastWindowClosed()), SLOT(quit()) ); init_pixmaps(); ControlWindow * ww = new ControlWindow(homeDir); ww->resize((w * 3)/5, (h * 3)/5); if (cx != -1) ww->move(ww->x() + cx - (ww->x() + ww->width() / 2), ww->y() + cy - (ww->y() + ww->height() / 2)); ww->show(); app->exec(); } return 0; }