Exemplo n.º 1
0
bool XMLMetadata::initFromRaw(const unsigned char *raw, size_t len)
{
	char *_name = initDoc((const char *)raw, len);

	if (!_name) {
		fprintf(stderr, "Could not create document\n");
		if (doc)
			xmlFreeDoc(doc);
		doc = NULL;
		return false;
	}

        if (!parseXML(xmlDocGetRootElement(doc))) {
                fprintf(stderr, "Parse XML failed\n");
                xmlFreeDoc(doc);
		doc = NULL;
                return false;
        }

	name = _name;
        
        xmlChar *content = xmlNodeGetContent(xmlDocGetRootElement(doc));
        
	if (content) {
                setContent((char *)content);
		xmlFree(content);
	}

        xmlFreeDoc(doc);
	doc = NULL;

	return true;
}
Exemplo n.º 2
0
Arquivo: app.cpp Projeto: speakman/qlc
void App::initView(void)
{
  initSettings();
  initDoc();
  initSequenceEngine();

  QString dir;
  settings()->get(KEY_SYSTEM_DIR, dir);
  dir += QString("/") + PIXMAPPATH;
  
  setIcon(QPixmap(dir + QString("/Q.xpm")));

  initWorkspace();
  connect(m_settings, SIGNAL(outputPluginChanged(const QString&)), m_doc, SLOT(slotChangeOutputPlugin(const QString&)));

  initMenuBar();
  initStatusBar();
  initToolBar();

  initVirtualConsole();
  initDeviceManagerView();

  QString config;
  settings()->get(KEY_OPEN_LAST_WORKSPACE, config);

  if (config == Settings::trueValue())
    {
      settings()->get(KEY_LAST_WORKSPACE_NAME, config);

      doc()->loadWorkspaceAs(config);
      setCaption(KApplicationNameLong + QString(" - ") + doc()->workspaceFileName());
      virtualConsole()->hide();
    }
}
Exemplo n.º 3
0
/**
 * Constructor.
 *
 * @param doc Pointer to an existing document of NULL if a new
 *   document shall be created for this window.
 * @param parent Parent widget. Usually a workspace.
 */
QC_MDIWindow::QC_MDIWindow(RS_Document* doc,
                           QWidget* parent, Qt::WindowFlags wflags)
        : QMainWindow(parent, wflags) {

    setAttribute(Qt::WA_DeleteOnClose);
    owner = false;
    cadMdiArea=qobject_cast<QMdiArea*>(parent);
    forceClosing = false;
    initDoc(doc);
    initView();
    id = idCounter++;
    //childWindows.setAutoDelete(false);
    parentWindow = NULL;

    if (document!=NULL) {
        if (document->getLayerList()!=NULL) {
            // Link the graphic view to the layer widget
            document->getLayerList()->addListener(graphicView);
        }
        if (document->getBlockList()!=NULL) {
            // Link the graphic view to the block widget
            document->getBlockList()->addListener(graphicView);
        }
    }
//    setFocusPolicy(Qt::ClickFocus);
    //showMaximized();
}
Exemplo n.º 4
0
Arquivo: app.cpp Projeto: speakman/qlc
/**
 * Main initialization function
 */
void App::init()
{
	QSettings settings;

	setWindowIcon(QIcon(":/qlc.png"));

#ifndef __APPLE__
	/* MDI Area */
	setCentralWidget(new QMdiArea(this));
	centralWidget()->setContextMenuPolicy(Qt::CustomContextMenu);
	connect(centralWidget(),
		SIGNAL(customContextMenuRequested(const QPoint&)),
		this,
		SLOT(slotCustomContextMenuRequested(const QPoint&)));

	/* Workspace background */
	setBackgroundImage(settings.value("/workspace/background").toString());

	/* Application geometry and window state */
	QVariant var;
	var = settings.value(KXMLQLCGeometry, QRect(0, 0, 800, 600));
	if (var.isValid() == true)
		setGeometry(var.toRect());
	var = settings.value(KXMLQLCWindowState, Qt::WindowNoState);
	if (var.isValid() == true)
		setWindowState(Qt::WindowState(var.toInt()));
#else
	/* App is just a toolbar, we only need it to be the size of the
	   toolbar's buttons */
	resize(600, 32);
	move(0, 22);
#endif

	/* Input & output mappers and their plugins */
	initOutputMap();
	initInputMap();

	/* Function running engine/master timer */
	m_masterTimer = new MasterTimer(this, m_outputMap);
	m_masterTimer->start();

	/* Buses */
	Bus::init(this);

	/* Fixture definitions */
	loadFixtureDefinitions();

	// The main view
	initStatusBar();
	initActions();
	initMenuBar();
	initToolBar();

	// Document
	initDoc();

	// Start up in non-modified state
	m_doc->resetModified();
}
Exemplo n.º 5
0
void App::startup()
{
    qmlRegisterType<Fixture>("com.qlcplus.classes", 1, 0, "Fixture");
    qmlRegisterType<Function>("com.qlcplus.classes", 1, 0, "Function");
    qmlRegisterType<ModelSelector>("com.qlcplus.classes", 1, 0, "ModelSelector");

    setTitle("Q Light Controller Plus");
    setIcon(QIcon(":/qlcplus.png"));

    QFontDatabase::addApplicationFont(":/RobotoCondensed-Regular.ttf");

    rootContext()->setContextProperty("qlcplus", this);

    initDoc();

    //connect(m_doc, SIGNAL(loaded()),
    //        this, SIGNAL(docLoadedChanged()));
    //qmlRegisterType<App>("com.qlcplus.app", 1, 0, "App");

    m_ioManager = new InputOutputManager(m_doc);
    rootContext()->setContextProperty("ioManager", m_ioManager);

    m_fixtureBrowser = new FixtureBrowser(this, m_doc);
    rootContext()->setContextProperty("fixtureBrowser", m_fixtureBrowser);

    m_fixtureManager = new FixtureManager(this, m_doc);
    rootContext()->setContextProperty("fixtureManager", m_fixtureManager);

    m_functionManager = new FunctionManager(this, m_doc);
    rootContext()->setContextProperty("functionManager", m_functionManager);

    m_contextManager = new ContextManager(this, m_doc, m_fixtureManager, m_functionManager);
    rootContext()->setContextProperty("contextManager", m_contextManager);

    m_virtualConsole = new VirtualConsole(this, m_doc);
    rootContext()->setContextProperty("virtualConsole", m_virtualConsole);

    m_showManager = new ShowManager(this, m_doc);
    rootContext()->setContextProperty("showManager", m_showManager);

    // register an uncreatable type just to use the enums in QML
    qmlRegisterUncreatableType<ShowManager>("com.qlcplus.classes", 1, 0, "ShowManager", "Can't create a ShowManager !");

    m_actionManager = new ActionManager(this, m_functionManager, m_showManager, m_virtualConsole);
    rootContext()->setContextProperty("actionManager", m_actionManager);

    // register an uncreatable type just to use the enums in QML
    qmlRegisterUncreatableType<ActionManager>("com.qlcplus.classes", 1, 0,  "ActionManager", "Can't create an ActionManager !");

    // Start up in non-modified state
    m_doc->resetModified();

    // and here we go !
    setSource(QUrl("qrc:/MainView.qml"));
    //m_contextManager->activateContext("2D");
}
Exemplo n.º 6
0
Arquivo: app.cpp Projeto: speakman/qlc
void App::newDocument()
{
  setCaption(KApplicationNameLong);
  
  initDoc();
  initDeviceManagerView();
  initVirtualConsole();
  
  //
  // Set the last workspace name
  //
  m_settings->set(KEY_LAST_WORKSPACE_NAME, QString::null);
  m_doc->setModified(false);
}
/**
 * Constructor.
 *
 * @param doc Pointer to an existing document of NULL if a new 
 *   document shall be created for this window.
 * @param parent Parent widget. Usually a workspace.
 */
QC_MDIWindow::QC_MDIWindow(RS_Document* doc,
                           QWidget* parent,
                           const char* name, int wflags)
        : QMainWindow(parent, name, wflags) {

    owner = false;
	forceClosing = false;
    initDoc(doc);
    initView();
    id = idCounter++;
    childWindows.setAutoDelete(false);
    parentWindow = NULL;

    if (document!=NULL) {
        if (document->getLayerList()!=NULL) {
            // Link the graphic view to the layer widget
            document->getLayerList()->addListener(graphicView);
        }
        if (document->getBlockList()!=NULL) {
            // Link the graphic view to the block widget
            document->getBlockList()->addListener(graphicView);
        }
    }
}
Exemplo n.º 8
0
Arquivo: app.cpp Projeto: speakman/qlc
void App::newDocument()
{
	initDoc();
	VirtualConsole::resetContents();
	doc()->resetModified();
}
Exemplo n.º 9
0
void App::init()
{
    QSettings settings;

    setWindowIcon(QIcon(":/qlcplus.png"));

    m_tab = new QTabWidget(this);
    m_tab->setTabPosition(QTabWidget::South);
    setCentralWidget(m_tab);

    QLCFile::checkRaspberry();

    QVariant var = settings.value(SETTINGS_GEOMETRY);
    if (var.isValid() == true)
    {
        this->restoreGeometry(var.toByteArray());
    }
    else
    {
        /* Application geometry and window state */
        QSize size = settings.value("/workspace/size").toSize();
        if (size.isValid() == true)
            resize(size);
        else
        {
            if (QLCFile::isRaspberry())
            {
                QRect geometry = qApp->desktop()->availableGeometry();
                if (m_noGui == true)
                {
                    setGeometry(geometry.width(), geometry.height(), 1, 1);
                }
                else
                {
                    int w = geometry.width();
                    int h = geometry.height();
                    if (m_overscan == true)
                    {
                        // if we're on a Raspberry Pi, introduce a 5% margin
                        w = (float)geometry.width() * 0.95;
                        h = (float)geometry.height() * 0.95;
                    }
                    setGeometry((geometry.width() - w) / 2, (geometry.height() - h) / 2,
                                w, h);
                }
            }
            else
                resize(800, 600);
        }

        QVariant state = settings.value("/workspace/state", Qt::WindowNoState);
        if (state.isValid() == true)
            setWindowState(Qt::WindowState(state.toInt()));
    }

    QVariant dir = settings.value(SETTINGS_WORKINGPATH);
    if (dir.isValid() == true)
        m_workingDirectory = QDir(dir.toString());

    // The engine object
    initDoc();
    // Main view actions
    initActions();
    // Main tool bar
    initToolBar();

    m_dumpProperties = new DmxDumpFactoryProperties(KUniverseCount);

    // Create primary views.
    m_tab->setIconSize(QSize(24, 24));
    QWidget* w = new FixtureManager(m_tab, m_doc);
    m_tab->addTab(w, QIcon(":/fixture.png"), tr("Fixtures"));
    w = new FunctionManager(m_tab, m_doc);
    m_tab->addTab(w, QIcon(":/function.png"), tr("Functions"));
    w = new ShowManager(m_tab, m_doc);
    m_tab->addTab(w, QIcon(":/show.png"), tr("Shows"));
    w = new VirtualConsole(m_tab, m_doc);
    m_tab->addTab(w, QIcon(":/virtualconsole.png"), tr("Virtual Console"));
    w = new SimpleDesk(m_tab, m_doc);
    m_tab->addTab(w, QIcon(":/slidermatrix.png"), tr("Simple Desk"));
    w = new InputOutputManager(m_tab, m_doc);
    m_tab->addTab(w, QIcon(":/input_output.png"), tr("Inputs/Outputs"));

    // Listen to blackout changes and toggle m_controlBlackoutAction
    connect(m_doc->inputOutputMap(), SIGNAL(blackoutChanged(bool)), this, SLOT(slotBlackoutChanged(bool)));

    // Listen to DMX value changes and update each Fixture values array
    connect(m_doc->inputOutputMap(), SIGNAL(universesWritten(int, const QByteArray&)),
            this, SLOT(slotUniversesWritten(int, const QByteArray&)));

    // Enable/Disable panic button
    connect(m_doc->masterTimer(), SIGNAL(functionListChanged()), this, SLOT(slotRunningFunctionsChanged()));
    slotRunningFunctionsChanged();

    // Start up in non-modified state
    m_doc->resetModified();

    QString ssDir;

#if defined(WIN32) || defined(Q_OS_WIN)
    /* User's input profile directory on Windows */
    LPTSTR home = (LPTSTR) malloc(256 * sizeof(TCHAR));
    GetEnvironmentVariable(TEXT("UserProfile"), home, 256);
    ssDir = QString("%1/%2").arg(QString::fromUtf16(reinterpret_cast<ushort*> (home)))
                            .arg(USERQLCPLUSDIR);
    free(home);
    HotPlugMonitor::setWinId(winId());
#else
    /* User's input profile directory on *NIX systems */
    ssDir = QString("%1/%2").arg(getenv("HOME")).arg(USERQLCPLUSDIR);
#endif

    QFile ssFile(ssDir + QDir::separator() + "qlcplusStyle.qss");
    if (ssFile.exists() == true)
    {
        ssFile.open(QFile::ReadOnly);
        QString styleSheet = QLatin1String(ssFile.readAll());
        this->setStyleSheet(styleSheet);
    }

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    m_videoProvider = new VideoProvider(m_doc, this);
#endif
}
Exemplo n.º 10
0
void App::init()
{
    QSettings settings;

    setWindowIcon(QIcon(":/qlcplus.png"));

    m_tab = new QTabWidget(this);
    m_tab->setTabPosition(QTabWidget::South);
    setCentralWidget(m_tab);

    QVariant var = settings.value(SETTINGS_GEOMETRY);
    if (var.isValid() == true)
    {
        this->restoreGeometry(var.toByteArray());
    }
    else
    {
        /* Application geometry and window state */
        QSize size = settings.value("/workspace/size").toSize();
        if (size.isValid() == true)
            resize(size);
        else
            resize(800, 600);

        QVariant state = settings.value("/workspace/state", Qt::WindowNoState);
        if (state.isValid() == true)
            setWindowState(Qt::WindowState(state.toInt()));
    }

    // The engine object
    initDoc();
    // Main view actions
    initActions();
    // Main tool bar
    initToolBar();

    // Create primary views.
    m_tab->setIconSize(QSize(24, 24));
    QWidget* w = new FixtureManager(m_tab, m_doc);
    m_tab->addTab(w, QIcon(":/fixture.png"), tr("Fixtures"));
    w = new FunctionManager(m_tab, m_doc);
    m_tab->addTab(w, QIcon(":/function.png"), tr("Functions"));
    w = new ShowManager(m_tab, m_doc);
    m_tab->addTab(w, QIcon(":/show.png"), tr("Shows"));
    w = new VirtualConsole(m_tab, m_doc);
    m_tab->addTab(w, QIcon(":/virtualconsole.png"), tr("Virtual Console"));
    w = new SimpleDesk(m_tab, m_doc);
    m_tab->addTab(w, QIcon(":/slidermatrix.png"), tr("Simple Desk"));
    w = new InputOutputManager(m_tab, m_doc);
    m_tab->addTab(w, QIcon(":/input_output.png"), tr("Inputs/Outputs"));

    // Listen to blackout changes and toggle m_controlBlackoutAction
    connect(m_doc->outputMap(), SIGNAL(blackoutChanged(bool)), this, SLOT(slotBlackoutChanged(bool)));

    // Enable/Disable panic button
    connect(m_doc->masterTimer(), SIGNAL(functionListChanged()), this, SLOT(slotRunningFunctionsChanged()));
    slotRunningFunctionsChanged();

    // Start up in non-modified state
    m_doc->resetModified();
}
Exemplo n.º 11
0
Arquivo: app.cpp Projeto: speakman/qlc
//////////////////////////////////////////////////////////////////////
// Main initialization function                                     //
//                                                                  //
// This creates all items that are not saved in workspace files     //
//////////////////////////////////////////////////////////////////////
void App::init(QString openFile)
{
  //
  // Default size
  //
  resize(maximumSize());

  //
  // Settings has to be first
  //
  initSettings();

  //
  // Menus, toolbar, statusbar
  //
  initMenuBar();
  initStatusBar();
  initToolBar();

  //
  // The main view
  //
  initWorkspace();

  //
  // Plugins
  //
  initPlugins();

  //
  // Device classes
  //
  initDeviceClasses();

  //
  // Submasters & values
  //
  initSubmasters();
  initValues();

  //
  // Function consumer
  //
  initFunctionConsumer();

  //
  // Buses
  //
  Bus::init();

  //
  // Document
  //
  initDoc();

  //
  // Views
  //
  initDeviceManagerView();
  initVirtualConsole();


  // Trying to load workspace files
  // Either specified on command line or the last active workspace
  bool success = false;
  if (openFile != "")
    {
       success = doc()->loadWorkspaceAs(openFile);
       if (!success)
         {
            QString msg = "File: " + openFile + "\ncould'nt be opened. Please check path and spelling!\n";
	            msg += "We revert to the previously used workspace.";
	    QMessageBox::warning(this, KApplicationNameShort, msg,
			       QMessageBox::Ok, 0);
         }
    }
  //
  // Load the previous workspace
  //
  if (!success)
    {
      QString config;
      if (settings()->get(KEY_OPEN_LAST_WORKSPACE, config))
       {
         if (config == Settings::trueValue())
	  {
	    if (settings()->get(KEY_LAST_WORKSPACE_NAME, config))
	      {
	         success =  doc()->loadWorkspaceAs(config);
		 if (!success)
		   {
                      QString msg = "Previously used workspace file: " + config + "\ncould'nt be opened.";
	                      msg += "We start over with a new workspace.";
	              QMessageBox::warning(this, KApplicationNameShort, msg, QMessageBox::Ok, 0);
		   }
	      }
	  }
       }
    }
  if (!success)
    {
      newDocument();
    }
}
Exemplo n.º 12
0
void App::startup()
{
    qmlRegisterUncreatableType<Fixture>("org.qlcplus.classes", 1, 0, "Fixture", "Can't create a Fixture !");
    qmlRegisterUncreatableType<Function>("org.qlcplus.classes", 1, 0, "QLCFunction", "Can't create a Function !");
    qmlRegisterType<ModelSelector>("org.qlcplus.classes", 1, 0, "ModelSelector");
    qmlRegisterUncreatableType<App>("org.qlcplus.classes", 1, 0, "App", "Can't create an App !");

    setTitle(APPNAME);
    setIcon(QIcon(":/qlcplus.svg"));

    if (QFontDatabase::addApplicationFont(":/RobotoCondensed-Regular.ttf") < 0)
        qWarning() << "Roboto condensed cannot be loaded !";

    if (QFontDatabase::addApplicationFont(":/RobotoMono-Regular.ttf") < 0)
        qWarning() << "Roboto mono cannot be loaded !";

    rootContext()->setContextProperty("qlcplus", this);

    m_pixelDensity = qMax(screen()->physicalDotsPerInch() *  0.039370, (qreal)screen()->size().height() / 220.0);
    qDebug() << "Pixel density:" << m_pixelDensity << "size:" << screen()->physicalSize();

    rootContext()->setContextProperty("screenPixelDensity", m_pixelDensity);

    initDoc();

    m_ioManager = new InputOutputManager(this, m_doc);
    rootContext()->setContextProperty("ioManager", m_ioManager);

    m_fixtureBrowser = new FixtureBrowser(this, m_doc);
    m_fixtureManager = new FixtureManager(this, m_doc);
    m_fixtureGroupEditor = new FixtureGroupEditor(this, m_doc);
    m_functionManager = new FunctionManager(this, m_doc);
    m_contextManager = new ContextManager(this, m_doc, m_fixtureManager, m_functionManager);

    m_virtualConsole = new VirtualConsole(this, m_doc, m_contextManager);
    rootContext()->setContextProperty("virtualConsole", m_virtualConsole);

    m_showManager = new ShowManager(this, m_doc);
    rootContext()->setContextProperty("showManager", m_showManager);

    m_networkManager = new NetworkManager(this, m_doc);
    rootContext()->setContextProperty("networkManager", m_networkManager);

    connect(m_networkManager, &NetworkManager::clientAccessRequest, this, &App::slotClientAccessRequest);
    connect(m_networkManager, &NetworkManager::accessMaskChanged, this, &App::setAccessMask);
    connect(m_networkManager, &NetworkManager::requestProjectLoad, this, &App::slotLoadDocFromMemory);

    m_tardis = new Tardis(this, m_doc, m_networkManager, m_fixtureManager, m_functionManager,
                          m_contextManager, m_showManager, m_virtualConsole);
    rootContext()->setContextProperty("tardis", m_tardis);

    m_contextManager->registerContext(m_virtualConsole);
    m_contextManager->registerContext(m_showManager);
    m_contextManager->registerContext(m_ioManager);

    // register an uncreatable type just to use the enums in QML
    qmlRegisterUncreatableType<ContextManager>("org.qlcplus.classes", 1, 0, "ContextManager", "Can't create a ContextManager !");
    qmlRegisterUncreatableType<ShowManager>("org.qlcplus.classes", 1, 0, "ShowManager", "Can't create a ShowManager !");
    qmlRegisterUncreatableType<NetworkManager>("org.qlcplus.classes", 1, 0, "NetworkManager", "Can't create a NetworkManager !");

    // Start up in non-modified state
    m_doc->resetModified();

    // and here we go !
    setSource(QUrl("qrc:/MainView.qml"));
}
Exemplo n.º 13
0
/**
 * Web Server main function.
 * Set signal-handler for terminating, parse configuration file and mime types file.
 * Create connections and launch threads to manage these. 
 */
int main() {

	//Socket Stuff
	int skt_lst, skt_accpt;
	struct sockaddr_in skaddr;
	socklen_t socksize;

	//Initiate signal handler for sigterm & sigint
	signal(SIGTERM, sigterm_handler);
	signal(SIGINT, sigint_handler);
	//Read conf file and save parameters
	setting = parse_config_file();

	//Load mime types from file
	extensions = load_mime_type(setting->mime_type_file);

	if(toLog > -1) {
		//Open Log File
		LogFile = openLogFile(setting->log_path);
		if(LogFile == NULL)
			toLog = -1;	
	}
	if(setting->use_wurfl == true) {
		//Open wurfl file and build the xml three
		setting->doc = initDoc(setting->wurfl_location);
		if(setting->doc == NULL) {
			setting->use_wurfl = false;
		}
		setting->start = getDevicesNode(setting->doc);
		if(setting->start == NULL) {
			xmlFree(setting->doc);
			setting->use_wurfl = false;
		}
	}
	//Create socket
	skt_lst = create_and_bind(skaddr, socksize);
	//Write On Log File when server started
	if(toLog > -1)
		writeInfoLog(START, NULL);

	for(;;) {
		if(max_thread == 0 || n_thread < max_thread) {
			//Take connection and launch thread to manage it
			if(listen(skt_lst, setting->pend_connection) == -1) {
				perror("Socket Listening Error\n");
				return(EXIT_FAILURE);
			}
	
			if((skt_accpt = accept(skt_lst, (struct sockaddr *)&skaddr, &socksize)) == -1){
				perror("Socket Accepting Error\n");
				return(EXIT_FAILURE);
			}
			n_thread++;
			create_thread(setting, skt_accpt);
		}
		else {
			again:
				usleep(1);
				if(n_thread >= max_thread) goto again;
		}
	}
	//Close socket and exit
	if(close(skt_lst) == -1) {
		perror("Socket Closing Error\n");
	}
	return EXIT_SUCCESS;

}
Exemplo n.º 14
0
Freecell::Freecell(QWidget * parent, Qt::WFlags flags)
:  QMainWindow(parent, flags)
    , rotation(90)
{
    FILE *f;

    // create ~/.qfreecell  
    QDir d("/tmp");
    char buffer[200];

    // save location of binary
    d.cdUp();
    strcpy(game_directory, (d.path()).toLatin1().data());

    strcpy(directory, QDir::homePath().toLatin1().data());
    strcat(directory, "/.qfreecell");

    d.setPath(directory);
    if (!d.exists())            // create directories if not exists
    {
        printf("Creating ~/.qfreecell...\n");
        d.mkdir(directory);
        sprintf(buffer, "%s/protocols", directory);
    }
    //Init statistics

    pstatistics = new CStatistics(this, "", false);
    protocol_file = new QString();
    protocol_fd = NULL;

    // first set configuration to default   
    opt.empty_file = new char[200];
    opt.background_file = new char[200];
    opt.background_enabled = new bool;
    opt.background_color = new QColor(0, 128, 0);
    opt.num_freecells = new int;
    opt.spinbox_freecells_min = new int;

    // set picture filename of freecells
    strcpy(opt.empty_file, directory);
    strcat(opt.empty_file, "/freecells/");
    strcat(opt.empty_file, DEFAULT_FREECELL);

    // set background filename
    strcpy(opt.background_file, directory);
    strcat(opt.background_file, "/backgrounds/");
    strcat(opt.background_file, DEFAULT_BACKGROUND);

    // enable backgrounds
    *opt.background_enabled = true;

    // set number of free cells to 4
    *opt.num_freecells = 4;

    //////////////////////////////
    // now read configuration file

    sprintf(buffer, "%s/configuration", directory);
    f = fopen(buffer, "r");
    if (f != NULL) {
        unsigned int i;
        while (fgets(buffer, 200, f) != NULL) {
            i = 0;
            while (buffer[i++] != '\0')
                if (buffer[i - 1] == '\n')
                    buffer[i - 1] = '\0';
            for (i = 0; i < strlen(buffer); i++)
                if (buffer[i] == '=')
                    break;

            if (memcmp(buffer, "background picture", 18) == 0)
                strcpy(opt.background_file, buffer + i + 1);
            if (memcmp(buffer, "freecell", 8) == 0)
                strcpy(opt.empty_file, buffer + i + 1);
            if (memcmp(buffer, "background enabled", 18) == 0)
                if (buffer[i + 1] == '1')
                    *opt.background_enabled = true;
                else
                    *opt.background_enabled = false;
        }
        fclose(f);
    }
    ///////////////////////////////////////////////////////////////////
    // call inits to invoke all other construction parts
    initMenuBar();
    initToolBar();
    initStatusBar();

    initDoc();
    initView();

    slotFileNew();
}