示例#1
0
int main(int argc, char **argv)
{
    QApplication a(argc, argv);
    a.setApplicationName("QFaktury");
    a.setOrganizationName("www.e-linux.pl");

    DatabaseManager test;
    if (test.openDB())
        qDebug() << "openned";
    else
        qDebug() << "failed to open";

    qDebug() << test.getTables();
    test.createTables();

    // multilangage
    a.installTranslator(sett().getTranslation());


    QResource::registerResource("qfaktury.rcc"); // using the rcc file so it's more portable
    // Q_INIT_RESOURCE(qfaktury);


    QRect screen = QApplication::desktop()->screenGeometry();

    QSplashScreen splash(QPixmap(":/res/icons/splash.png"));


    MainWindow w(0);
    w.move(screen.center() - QPoint(w.width() / 2, w.height() / 2));
    w.show();



#if 1
    old_MainWindow old_w(0);
    old_w.move(screen.center() - QPoint(old_w.width() / 2, old_w.height() / 2));
    old_w.show();
#endif

    a.connect(&w, SIGNAL(closingWindow), &old_w, SLOT(close));

    //if (a.arguments().contains("--nosplash")) {


    /*} else {
  splash.show();

  a.processEvents();

  QTimer::singleShot(5000, &w, SLOT(show()));
  QTimer::singleShot(4960, &splash, SLOT(close()));
        }*/

    a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));

    QIcon icon;
    icon.addPixmap(QPixmap(":/res/icons/qfaktury_48.png"), QIcon::Normal, QIcon::Off);
    a.setWindowIcon(icon);
    return a.exec();
}
示例#2
0
bool createDirectories(QString previousMemoryPath)
{
    QDir dir(QDir::home());

    QString mainDirectoryName = QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss");

    if(!dir.mkdir(mainDirectoryName)) return false;

    dir.cd(mainDirectoryName);

    mainDirectoryPath = dir.path();
    qDebug()<<"Main Directory Path"<<mainDirectoryPath;


    QDir mainDir(QDir::homePath().append("/").append(mainDirectoryName));

    QString imageDirectory = "images";

    if(!mainDir.mkdir(imageDirectory)) return false;

    mainDir.cd(imageDirectory);

    imagesPath = mainDir.path();

    qDebug()<<"Image directory path"<<imagesPath;


    QString databasepath = QDir::homePath();

    databasepath.append("/emptydb");

    QString detecplacesdbpath = databasepath;
    detecplacesdbpath.append("/detected_places.db");

    QFile file(detecplacesdbpath);

    if(file.exists())
    {
        QString newdir = mainDirectoryPath;
        newdir.append("/detected_places.db");
        QFile::copy(detecplacesdbpath,newdir);

        if(!dbmanager.openDB(newdir))
            return false;
        //   file.close();
    }
    else
        return false;

    // If we don't have a previous memory than create an empty memory
    if(previousMemoryPath.size() <= 1 || previousMemoryPath.isNull())
    {
        QString knowledgedbpath = databasepath;
        knowledgedbpath.append("/knowledge.db");

        QFile file2(knowledgedbpath);

        if(file2.exists())
        {
            QString newdir = mainDirectoryPath;
            QFile::copy(knowledgedbpath,newdir.append("/knowledge.db"));
            // file.close();
        }
        else
            return false;

    }
    // If we have supplied a previous memory path, then open that db
    else
    {
        QString knowledgedbpath = previousMemoryPath;
        knowledgedbpath.append("/knowledge.db");

        QFile file2(knowledgedbpath);

        if(file2.exists())
        {
            QString newdir = mainDirectoryPath;
            QFile::copy(knowledgedbpath,newdir.append("/knowledge.db"));
            // file.close();
        }
        else
            return false;


    }

    return true;

}