示例#1
0
void OSCQueryDevice::slot_createDevice()
{
  const auto& cur_settings = settings();
  const auto& stgs
      = cur_settings.deviceSpecificSettings.value<OSCQuerySpecificSettings>();

  try
  {
    std::unique_ptr<ossia::net::protocol_base> ossia_settings
        = std::make_unique<ossia::oscquery::oscquery_mirror_protocol>(
            stgs.host.toStdString());

    auto& p = static_cast<ossia::oscquery::oscquery_mirror_protocol&>(
        *ossia_settings);
    m_mirror = &p;

    if (stgs.rate)
    {
      ossia_settings = std::make_unique<ossia::net::rate_limiting_protocol>(
          std::chrono::milliseconds{*stgs.rate}, std::move(ossia_settings));
    }

    // run the commands in the Qt event loop
    // FIXME they should be disabled upon manual disconnection

    m_dev = std::make_unique<ossia::net::generic_device>(
        std::move(ossia_settings), settings().name.toStdString());

    deviceChanged(nullptr, m_dev.get());

    p.set_command_callback([=] { sig_command(); });
    p.set_disconnect_callback([=] { sig_disconnect(); });
    p.set_fail_callback([=] { sig_disconnect(); });

    setLogging_impl(Device::get_cur_logging(isLogging()));

    enableCallbacks();
    m_connected = true;
  }
  catch (std::exception& e)
  {
    qDebug() << "Could not connect: " << e.what();
    m_connected = false;
    if (!m_dev)
      m_mirror = nullptr;
  }
  catch (...)
  {
    // TODO save the reason of the non-connection.
    m_connected = false;
    if (!m_dev)
      m_mirror = nullptr;
  }

  connectionChanged(m_connected);
}
示例#2
0
ofxConsole::ofxConsole()
{
	enableCallbacks();
	bActive = true;
	setDefaultCommand(this, &ofxConsole::defaultFunction);
	//setDefaultCommandPre(this, &ofxConsole::defaultFunctionPre);
		
	/*
	 * this is just to show the difference between the syntax. The boost part is
	 * some syntactic c++ madness but pretty straight forward to use and alot more powerful
	 * than the default version since you can register almost any void function you want!
	 */

#ifndef USE_BOOST
	addFunction("close", this, &ofxConsole::close);
#else
	//adds the close function to the console the boost way (boost::function< void(argument types (eg: int, float)) >)
	addFunction("close", (boost::function< void() >)(boost::bind(&ofxConsole::close, this)));
#endif


	backgroundColor.set(255, 255, 255);		// history background
	copyTextColor.set(130, 130, 130);       // history text
	commandlineColor.set(0, 0, 0);          // current background
	commandlineTextColor.set(80, 80, 80);	// current text
	messageTextColor.set(100, 100, 102);	// message like testInt
	sugestColor.set(255, 0, 0);
	errorTextColor.set(200, 0, 100);	// error

	setToggleKey('+');
	
	bw = 13; /// band width
	sp = 100; /// space before string
		
	boxW = 300;
	boxH = bw * (textBufferSize+1);

	bSugestMode = false;
	bFixConsolePos = true;

    commandLineClearCount = 0;

}
//-------------------------------------------------------------------------------------------------
BachKeywordView::BachKeywordView( QWidget * parent )
:	RecordTreeView( parent )
,	m_MouseIn( false )
,	m_ShowAll( true )
,	m_CallbacksEnabled( false )
{
	mKeywordsModel = new RecordSuperModel( this );
	new BachKeywordTranslator( mKeywordsModel->treeBuilder() );
	mKeywordsModel->setHeaderLabels(QStringList() << "name");
	setModel( mKeywordsModel );
	setItemDelegateForColumn( Column_Has, new KeywordDelegate( this ) );
	setItemDelegateForColumn( Column_Name, new KeywordDelegate( this ) );
	// TODO: why is it "name" aswell?
	// setItemDelegateForColumn( Column_Name, new KeywordDelegate( this ) );

	connect( this, SIGNAL( clicked( const QModelIndex & ) ), SLOT( onClicked( const QModelIndex & ) ) );
	enableCallbacks();

    setSelectionMode( QAbstractItemView::SingleSelection );
    mKeywordsModel->sort(Column_Name, Qt::AscendingOrder);
    header()->setSortIndicator(Column_Name, Qt::AscendingOrder);
}