Exemplo n.º 1
0
/** Constructor */
IdDialog::IdDialog(QWidget *parent)
: MainPage(parent)
{
	ui.setupUi(this);

	mEditDialog = NULL;
	//mPulseSelected = NULL;

	ui.radioButton_ListAll->setChecked(true);
	connect( ui.pushButton_NewId, SIGNAL(clicked()), this, SLOT(OpenOrShowAddDialog()));
	connect( ui.pushButton_EditId, SIGNAL(clicked()), this, SLOT(OpenOrShowEditDialog()));
	connect( ui.treeWidget_IdList, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelection()));

	connect( ui.radioButton_ListYourself, SIGNAL(toggled( bool ) ), this, SLOT(ListTypeToggled( bool ) ) );
	connect( ui.radioButton_ListFriends, SIGNAL(toggled( bool ) ), this, SLOT(ListTypeToggled( bool ) ) );
	connect( ui.radioButton_ListOthers, SIGNAL(toggled( bool ) ), this, SLOT(ListTypeToggled( bool ) ) );
	connect( ui.radioButton_ListPseudo, SIGNAL(toggled( bool ) ), this, SLOT(ListTypeToggled( bool ) ) );
	connect( ui.radioButton_ListAll, SIGNAL(toggled( bool ) ), this, SLOT(ListTypeToggled( bool ) ) );

	QTimer *timer = new QTimer(this);
	timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
	timer->start(1000);

	rsIdentity->generateDummyData();

	mIdQueue = new TokenQueue(rsIdentity, this);

}
Exemplo n.º 2
0
EngineMeter::EngineMeter(QString name, QString title, QMeter::Type type,QWidget *parent)
	: QBaseMeter(name,title,type,parent)
{
	m_runtime = 0;
	
    m_minValue = 0;
    m_maxValue = 40; 
	m_value = m_minValue;
	m_laValue = 25;
	m_haValue = 40;
	m_lwValue = 15;
	m_hwValue = 25;

	m_startAngle =60;
	m_endAngle =60;

	m_scaleMajor = 10;
	m_scaleMiddle = 2;
    m_scaleMinor = 4;

	m_units = QStringLiteral("RPM"); 
	//m_title = QStringLiteral("תËÙ±í");
	m_compoment =0x0C0E;
	m_precision = 2;
	QTimer *timer = new QTimer(this);
	//timer->connect(timer,SIGNAL(timeout()),this,SLOT(changeValue()));
	timer->connect(timer,SIGNAL(timeout()),this,SLOT(setRuntime()));
	timer->start(1000);
}
Exemplo n.º 3
0
/** Constructor */
ServerDialog::ServerDialog(QWidget *parent)
: ConfigPage(parent)
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);

  /* Create RshareSettings object */
  _settings = new RshareSettings();

  connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) );
  connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) );

   QTimer *timer = new QTimer(this);
   timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
   timer->start(1000);

	load();
	updateStatus();

	bool b = rsPeers->getAllowServerIPDetermination() ;
	ui.allowIpDeterminationCB->setChecked(b) ;
	ui.IPServersLV->setEnabled(b) ;

	std::list<std::string> ip_servers ;
	rsPeers->getIPServersList(ip_servers) ;

	for(std::list<std::string>::const_iterator it(ip_servers.begin());it!=ip_servers.end();++it)
		ui.IPServersLV->addItem(QString::fromStdString(*it)) ;

  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    Object object;
    QTimer timer;
    timer.setSingleShot(true);
    timer.connect(&timer, SIGNAL(timeout()), &object, SLOT(print()));
    timer.start(0);
    return app.exec();
}
Exemplo n.º 5
0
ServerPage::ServerPage(QWidget * parent, Qt::WFlags flags)
    : ConfigPage(parent, flags)
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);

  connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) );
  connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) );
  connect( ui.allowTunnelConnectionCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleTunnelConnection(bool) ) );
  connect( ui._max_tr_up_per_sec_SB, SIGNAL( valueChanged( int ) ), this, SLOT( updateMaxTRUpRate(int) ) );
  connect( ui._turtle_enabled_CB, SIGNAL( toggled( bool ) ), this, SLOT( toggleTurtleRouting(bool) ) );
  connect( ui._routing_info_PB, SIGNAL( clicked() ), this, SLOT( showRoutingInfo() ) );

   QTimer *timer = new QTimer(this);
   timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
   timer->start(1000);

	_routing_info_page = NULL ;

	//load();
	updateStatus();

	bool b = rsPeers->getAllowServerIPDetermination() ;
	ui.allowIpDeterminationCB->setChecked(b) ;
	ui.IPServersLV->setEnabled(b) ;

#ifdef RS_RELEASE_VERSION
    ui.allowTunnelConnectionCB->hide();
    this->toggleTunnelConnection(false);
#else
    b = rsPeers->getAllowTunnelConnection() ;
    ui.allowTunnelConnectionCB->setChecked(b) ;
#endif

	std::list<std::string> ip_servers ;
	rsPeers->getIPServersList(ip_servers) ;

	for(std::list<std::string>::const_iterator it(ip_servers.begin());it!=ip_servers.end();++it)
		ui.IPServersLV->addItem(QString::fromStdString(*it)) ;

	TurtleRouterStatistics *trs = new TurtleRouterStatistics ;
	trs->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding)) ;
	ui.tabWidget->widget(2)->layout()->addWidget(trs) ;
	ui.tabWidget->widget(2)->layout()->setContentsMargins(0,5,0,0) ;

	QSpacerItem *verticalSpacer = new QSpacerItem(0,0,QSizePolicy::Expanding, QSizePolicy::Minimum);

	ui.tabWidget->widget(2)->layout()->addItem(verticalSpacer) ;
	ui.tabWidget->widget(2)->layout()->update() ;

  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}
Exemplo n.º 6
0
void BluemonkeyAgent::scriptLoad(qint64 id, const QString &program, const QString &fileName, int baseLineNumber)
{
	DebugOut()<<"executing script"<<endl;

	QTimer *timer = new QTimer();
	timer->setSingleShot(true);
	timer->connect(timer, SIGNAL(timeout()), this, SLOT(timeout()));
	timer->start(5000);

	timerIdMap[timer] = id;
}
Exemplo n.º 7
0
void CSMDoc::Operation::run()
{
    prepareStages();

    QTimer timer;

    timer.connect (&timer, SIGNAL (timeout()), this, SLOT (executeStage()));

    timer.start (0);

    exec();
}
Exemplo n.º 8
0
TransfersDialog::TransfersDialog(QWidget *parent)
: QWidget(parent) {
    /* Invoke the Qt Designer generated object setup routine */
    ui.setupUi(this);

    connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(download()));
    connect(ui.downloadsList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(downloadsListContextMenu(QPoint)));
    connect(ui.uploadsList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(uploadsListContextMenu(QPoint)));

    //To popup a box informing that a friend is attempting to send a file.
    //QList<qlonglong> is not a default registerd type for QT's meta-object system, so we must first manually register it.
    qRegisterMetaType<QList<qlonglong> >("QList<qlonglong>");
    QObject::connect(guiNotify, SIGNAL(suggestionReceived(unsigned int, QString, QStringList, QStringList, QList<qlonglong>)),
                     this, SLOT(suggestionReceived(unsigned int, QString, QStringList, QStringList, QList<qlonglong>)), Qt::QueuedConnection);

    QHeaderView *header = ui.downloadsList->header() ;
    header->hideSection(DOWNLOAD_FRIEND_ID);
    header->hideSection(DOWNLOAD_ITEM_TYPE);
    header->hideSection(DOWNLOAD_ITEM_ID);
    header->hideSection(DOWNLOAD_FINAL_LOCATION);

    header = ui.uploadsList->header() ;
    header->hideSection(UPLOAD_LIBRARYMIXER_ID);
    header->hideSection(UPLOAD_ITEM_ID);
    header->hideSection(UPLOAD_ITEM_TYPE);

    //Without this preliminary resizing, empty columns will visibly resize after view already displayed
    ui.downloadsList->resizeColumnToContents(DOWNLOAD_NAME_COLUMN);
    ui.downloadsList->resizeColumnToContents(DOWNLOAD_FRIEND_COLUMN);
    ui.downloadsList->resizeColumnToContents(DOWNLOAD_SPEED_COLUMN);
    ui.downloadsList->resizeColumnToContents(DOWNLOAD_REMAINING_COLUMN);
    ui.downloadsList->resizeColumnToContents(DOWNLOAD_TOTAL_SIZE_COLUMN);
    ui.downloadsList->resizeColumnToContents(DOWNLOAD_PERCENT_COLUMN);
    ui.downloadsList->resizeColumnToContents(DOWNLOAD_STATUS_COLUMN);
    ui.uploadsList->resizeColumnToContents(UPLOAD_FILE_COLUMN);
    ui.uploadsList->resizeColumnToContents(UPLOAD_FRIEND_COLUMN);
    ui.uploadsList->resizeColumnToContents(UPLOAD_SPEED_COLUMN);
    ui.uploadsList->resizeColumnToContents(UPLOAD_TRANSFERRED_COLUMN);
    ui.uploadsList->resizeColumnToContents(UPLOAD_STATUS_COLUMN);

    ui.downloadsList->sortItems(0, Qt::AscendingOrder);
    ui.uploadsList->sortItems(0, Qt::AscendingOrder);

    connect(files, SIGNAL(responseLendOfferReceived(uint,uint,QString,QStringList,QStringList,QList<qlonglong>)),
            this, SLOT(responseLendOfferReceived(uint,uint,QString,QStringList,QStringList,QList<qlonglong>)), Qt::QueuedConnection);

    /* This needs to change in the future, but for now, we simply refresh the entire view (including total transfer rates in corner) once every second. */
    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(insertTransfers()));
    timer->start(1000);
}
Exemplo n.º 9
0
/** Constructor */
NewsFeed::NewsFeed(QWidget *parent)
: MainPage (parent)
{
  	/* Invoke the Qt Designer generated object setup routine */
  	setupUi(this);

	connect(removeAllButton, SIGNAL(clicked()), this, SLOT(removeAll()));
	connect(feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions()));
	

	QTimer *timer = new QTimer(this);
	timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateFeed()));
	timer->start(1000);
}
Exemplo n.º 10
0
void PhysicallyBased::run() {
	srand( time(NULL) );
	
	QTimer* timer = new QTimer(this);
	float timestepMS = theTime.timestep * 1000;
	timer->setInterval(timestepMS);
	timer->connect(timer, SIGNAL(timeout()), this, SLOT(simLoop()));
	timer->start();
	
	exec(); // start event loop
	
	//Application* mainApp = Application::getInstance();
	//QApplication::postEvent(mainApp, new QEvent(PhysBEvent::traceStart));
	//QApplication::postEvent(mainApp->SFMLView, new QEvent(PhysBEvent::tracePixelFilled));
	//QApplication::postEvent(eventManager, new QEvent(PhysBEvent::tracePixelFilled));
	//QApplication::postEvent(mainApp, new QEvent(PhysBEvent::traceEnd));
}
Exemplo n.º 11
0
/** Constructor */
WikiDialog::WikiDialog(QWidget *parent)
: MainPage(parent)
{
	/* Invoke the Qt Designer generated object setup routine */
	ui.setupUi(this);

	mAddPageDialog = NULL;
	mAddGroupDialog = NULL;
	mEditDialog = NULL;

	connect( ui.toolButton_NewGroup, SIGNAL(clicked()), this, SLOT(OpenOrShowAddGroupDialog()));
	connect( ui.toolButton_NewPage, SIGNAL(clicked()), this, SLOT(OpenOrShowAddPageDialog()));
	connect( ui.toolButton_Edit, SIGNAL(clicked()), this, SLOT(OpenOrShowEditDialog()));
	connect( ui.toolButton_Republish, SIGNAL(clicked()), this, SLOT(OpenOrShowRepublishDialog()));

	// Usurped until Refresh works normally
	connect( ui.toolButton_Delete, SIGNAL(clicked()), this, SLOT(insertWikiGroups()));
	connect( ui.pushButton, SIGNAL(clicked()), this, SLOT(todo()));

	connect( ui.treeWidget_Pages, SIGNAL(itemSelectionChanged()), this, SLOT(groupTreeChanged()));


	// GroupTreeWidget.
	connect(ui.groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupListCustomPopupMenu(QPoint)));
	connect(ui.groupTreeWidget, SIGNAL(treeItemActivated(QString)), this, SLOT(wikiGroupChanged(QString)));


	QTimer *timer = new QTimer(this);
	timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
	timer->start(1000);

	/* setup TokenQueue */
	mWikiQueue = new TokenQueue(rsWiki->getTokenService(), this);


	/* Setup Group Tree */
	mYourGroups = ui.groupTreeWidget->addCategoryItem(tr("My Groups"), QIcon(IMAGE_FOLDER), true);
	mSubscribedGroups = ui.groupTreeWidget->addCategoryItem(tr("Subscribed Groups"), QIcon(IMAGE_FOLDERRED), true);
	mPopularGroups = ui.groupTreeWidget->addCategoryItem(tr("Popular Groups"), QIcon(IMAGE_FOLDERGREEN), false);
	mOtherGroups = ui.groupTreeWidget->addCategoryItem(tr("Other Groups"), QIcon(IMAGE_FOLDERYELLOW), false);

  //Auto refresh seems not to work, temporary solution at start
  insertWikiGroups();

}
Exemplo n.º 12
0
ServerPage::ServerPage(QWidget * parent, Qt::WFlags flags)
    : ConfigPage(parent, flags)
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);

  connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) );
  connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) );
  connect( ui.allowTunnelConnectionCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleTunnelConnection(bool) ) );
  connect( ui._max_tr_up_per_sec_SB, SIGNAL( valueChanged( int ) ), this, SLOT( updateMaxTRUpRate(int) ) );

   QTimer *timer = new QTimer(this);
   timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
   timer->start(1000);

	//load();
	updateStatus();

	bool b = rsPeers->getAllowServerIPDetermination() ;
	ui.allowIpDeterminationCB->setChecked(b) ;
	ui.IPServersLV->setEnabled(b) ;

#ifdef RS_RELEASE_VERSION
    ui.allowTunnelConnectionCB->hide();
    this->toggleTunnelConnection(false);
#else
    b = rsPeers->getAllowTunnelConnection() ;
    ui.allowTunnelConnectionCB->setChecked(b) ;
#endif

	std::list<std::string> ip_servers ;
	rsPeers->getIPServersList(ip_servers) ;

	for(std::list<std::string>::const_iterator it(ip_servers.begin());it!=ip_servers.end();++it)
		ui.IPServersLV->addItem(QString::fromStdString(*it)) ;

  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}
Exemplo n.º 13
0
/** Default constructor */
BandwidthGraph::BandwidthGraph(QWidget *parent, Qt::WFlags flags)
  : RWindow("BandwidthGraph", parent, flags)
{
  /* Invoke Qt Designer generated QObject setup routine */
  ui.setupUi(this);
#if defined(Q_WS_WIN)
  setShortcut("Esc", SLOT(close()));
#else
  setShortcut("Ctrl+W", SLOT(close()));
#endif

  /* Bind events to actions */
  createActions();

  /* Ask RetroShare core to notify us about bandwidth updates */
  //_rsControl = RetroShare::rsControl();
  //_rsControl->setEvent(REvents::Bandwidth, this, true);

  /* Initialize Sent/Receive data counters */
  reset();
  /* Hide Bandwidth Graph Settings frame */
  showSettingsFrame(false);
  /* Load the previously saved settings */
  loadSettings();

  /* Turn off opacity group on unsupported platforms */
#if defined(Q_WS_WIN)
  if(!(QSysInfo::WV_2000 <= QSysInfo::WindowsVersion && QSysInfo::WindowsVersion <= QSysInfo::WV_2003)) {
    ui.frmOpacity->setVisible(false);
  }
#endif
  
#if defined(Q_WS_X11)
  ui.frmOpacity->setVisible(false);
#endif

    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(updategraphstatus()));
    timer->start(5113);
}
Exemplo n.º 14
0
GPS::GPS(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::GPS)
{
    ui->setupUi(this);

    Avion=(QPixmap) *(ui->avion->pixmap());
    x=ui->mapa->pos().x();
    y=ui->mapa->pos().y();


    yaw=0;
    velocidad=0;
    pitch=0;
    lastYaw=0;


    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()),
                   this, SLOT(update()));
    timer->start(200);
}
Exemplo n.º 15
0
/** Constructor */
PhotoDialog::PhotoDialog(QWidget *parent)
: MainPage(parent)
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);

  connect( ui.peerTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( peerTreeWidgetCustomPopupMenu( QPoint ) ) );
  connect( ui.photoTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( photoTreeWidgetCustomPopupMenu( QPoint ) ) );

  connect( ui.peerTreeWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem * , QTreeWidgetItem * ) ), this, SLOT( updatePhotoList( ) ) );

  connect( ui.photoTreeWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem * , int ) ), this, SLOT( showPhoto( QTreeWidgetItem *, int ) ) );
  connect( ui.addButton, SIGNAL( clicked( ) ), this, SLOT( addPhotos( ) ) );
  connect( ui.expandButton, SIGNAL(clicked()), this, SLOT(togglefileview()));

  /* hide the Tree +/- */
  ui.photoTreeWidget -> setRootIsDecorated( false );

  QSize iconSize(PHOTO_ICON_SIZE,PHOTO_ICON_SIZE);
  ui.photoTreeWidget->setIconSize(iconSize);
  
  /* Set header resize modes and initial section sizes */
  QHeaderView * ptw_header = ui.peerTreeWidget->header () ;
  ptw_header->setResizeMode (0, QHeaderView::Interactive);

  ptw_header->resizeSection ( 0, 175 );



	/* Set a GUI update timer - much cleaner than
	 * doing everything through the notify agent 
	 */

  QTimer *timer = new QTimer(this);
  timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
  timer->start(1000);
}
Exemplo n.º 16
0
Arquivo: main.cpp Projeto: Ooya/TP4
int main(int argc, char **argv)
{
    srand(time(NULL));
    QGuiApplication app(argc, argv);
    
    QSurfaceFormat format;
    format.setSamples(16);
    
    paramCamera* c=new paramCamera();
    
    QTimer* calendar = new QTimer;

    TriangleWindow* window[4];
    for(int i = 0; i < 4; i++)
    {
        if (i == 0)
            window[i] = new TriangleWindow();
        else
            window[i] = new TriangleWindow(20);
        window[i]->setSeason(i);
        window[i]->c = c;
        window[i]->setFormat(format);
        window[i]->resize(500,375);
        int x = i%2;
        int y = i>>1;
                
        window[i]->setPosition(x*500,y*450);
        window[i]->show();

        calendar->connect(calendar, SIGNAL(timeout()),window[i], SLOT(updateSeason()));
    }
    
    calendar->start(20);

    return app.exec();
}
Exemplo n.º 17
0
int main(int argc, char **argv)
{
    //serializeUnserializeTest();
    srand(time(NULL));
    QGuiApplication app(argc, argv);
    
    QSurfaceFormat format;
    format.setSamples(16);
    
    paramCamera* c=new paramCamera();
    
    QTimer* calendar = new QTimer;

    //Add ressources
    PlyMeshReader plyReader;


    QString spring(":/springtree.ply");QString sp_name("SpringTree");
    QString summer(":/summertree.ply");QString su_name("SummerTree");
    QString autumn(":/autumntree.ply");QString au_name("AutumnTree");
    QString winter(":/wintertree.ply");QString wi_name("WinterTree");
    AssetManager::getInstance().loadMesh(sp_name,&plyReader,spring);
    AssetManager::getInstance().loadMesh(su_name,&plyReader,summer);
    AssetManager::getInstance().loadMesh(au_name,&plyReader,autumn);
    AssetManager::getInstance().loadMesh(wi_name,&plyReader,winter);

    QVector<GameWindow*> window;

    //if big file set content
    if(FileManager::getInstance().haveBigFile()) {
        qDebug() << "Saved GameWindow";
        window = FileManager::getInstance().load();
    }
    else {
        //Default four
        qDebug() << "Default GameWindow";
        for(int i = 0; i < 4; i++)
        {
            if (i == 0)
                window.append(new GameWindow());
            else
                window.append(new GameWindow(30));
            Terrain* terrain = new Terrain();
            terrain->loadHeightmap(":/heightmap-1.png");
            window.at(i)->setSeason(i);
            window.at(i)->setTerrain(terrain);
            window.at(i)->c = c;
        }

    }

    for(int i=0; i<window.size(); ++i) {
        qDebug() << "t-"<<i;
        FileManager::getInstance().link(window[i]);
        window[i]->setFormat(format);
        window[i]->resize(500,375);
        int x = i%2;
        int y = i>>1;

        window[i]->setPosition(x*500,y*450);
        window[i]->show();
        calendar->connect(calendar, SIGNAL(timeout()),window[i], SLOT(updateSeason()));
    }
    
    calendar->start(20);

    int appResult = app.exec();
    //AssetManager::getInstance().purge();
    return appResult;
}
Exemplo n.º 18
0
/** Constructor */
PeersDialog::PeersDialog(QWidget *parent)
            : RsAutoUpdatePage(1000,parent),
              historyKeeper(Rshare::dataDirectory() + "/his1.xml")
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);

  connect( ui.peertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( peertreeWidgetCostumPopupMenu( QPoint ) ) );
  connect( ui.peertreeWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend()));

  /* hide the Tree +/- */
  ui.peertreeWidget -> setRootIsDecorated( false );
  
    /* Set header resize modes and initial section sizes */
	QHeaderView * _header = ui.peertreeWidget->header () ;
   	_header->setResizeMode (0, QHeaderView::Custom);
	_header->setResizeMode (1, QHeaderView::Interactive);
	_header->setResizeMode (2, QHeaderView::Interactive);
	/*_header->setResizeMode (3, QHeaderView::Interactive);
	_header->setResizeMode (4, QHeaderView::Interactive);
	_header->setResizeMode (5, QHeaderView::Interactive);
	_header->setResizeMode (6, QHeaderView::Interactive);
	_header->setResizeMode (7, QHeaderView::Interactive);*/

    
	_header->resizeSection ( 0, 25 );
	_header->resizeSection ( 1, 100 );
	_header->resizeSection ( 2, 100 );
	/*_header->resizeSection ( 3, 120 );
	_header->resizeSection ( 4, 100 );
	_header->resizeSection ( 5, 230 );
	_header->resizeSection ( 6, 120 );
	_header->resizeSection ( 7, 220 );*/
	
    // set header text aligment
	QTreeWidgetItem * headerItem = ui.peertreeWidget->headerItem();
	headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter);

	
	  
  loadEmoticonsgroupchat();
  
  //setWindowIcon(QIcon(QString(":/images/rstray3.png")));

  connect(ui.lineEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) ));
  connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg()));
  connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat()));

   
  //connect( ui.msgSendList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgSendListCostumPopupMenu( QPoint ) ) );
  connect( ui.msgText, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoChatMenu(const QPoint&)));
 
  connect(ui.textboldChatButton, SIGNAL(clicked()), this, SLOT(setFont()));  
  connect(ui.textunderlineChatButton, SIGNAL(clicked()), this, SLOT(setFont()));  
  connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
  connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(getFont()));  
  connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(setColor()));
   
  ui.fontsButton->setIcon(QIcon(QString(":/images/fonts.png")));
  
  _currentColor = Qt::black;
  QPixmap pxm(16,16);
  pxm.fill(_currentColor);
  ui.colorChatButton->setIcon(pxm);
  
  mCurrentFont = QFont("Comic Sans MS", 12);
  ui.lineEdit->setFont(mCurrentFont);
  
  setChatInfo(tr("Welcome to RetroShare's group chat."),
              QString::fromUtf8("blue"));

  QStringList him;
  historyKeeper.getMessages(him, "", "THIS", 8);
  foreach(QString mess, him)
      ui.msgText->append(mess);
      //setChatInfo(mess,  "green");
              
  
  QMenu * grpchatmenu = new QMenu();
  grpchatmenu->addAction(ui.actionClearChat);
  ui.menuButton->setMenu(grpchatmenu);
  
  _underline = false;

  QTimer *timer = new QTimer(this);
  timer->connect(timer, SIGNAL(timeout()), this, SLOT(insertChat()));
  timer->start(500); /* half a second */

	ui.peertreeWidget->sortItems( 1, Qt::AscendingOrder );


  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}
Exemplo n.º 19
0
        void initializeGL(){
    {
		rotate_value = 0;
		constexpr static char vs[] = R"(#version 450
    layout(location=0) in vec4 iposition;
    layout(location=1) in vec4 inormal_  ;
    layout(location=1) uniform mat4 MVP ;
    layout(location=3) uniform mat4 NMVP ;
    layout(location=2) uniform vec4 light_pos = vec4(1,1,-1,1);
    out vec4 color ;
    void main(){
    gl_Position = MVP * iposition  ;
    vec4 inormal = NMVP * inormal_ ;
    vec3 light = light_pos.xyz - gl_Position.xyz ;
    light = normalize( light );
    float v = smoothstep(0,1, dot(light ,
    normalize( inormal.xyz ) ));
    v*=0.85;
    v+=0.05;
    color = vec4(v,v,v,1) ;
    }
    )";
        constexpr static char fs[] = R"(#version 450
    out vec4 fcolor ;
    in vec4 color ;
    void main(){
    fcolor = color ;
    }
    )";
        program = gl::VFProgramLoadSources(vs,fs);
    }
    glEnable(GL_CULL_FACE);
    glEnable(GL_DEPTH_TEST);
            glClearDepth(1);
            glClearColor(0,0,0,0);
    #ifdef _DEBUG_OPENGL_QT_
    QGLDebugTool::setSimpleCallbackFunction();
    QGLDebugTool::test();
    #endif
    gl::createBuffers(1, &pointsNormalBuffer);
    gl::createBuffers(1,&indexBuffer);

    {
        gl::VertexNormalElementCallBack callBack ;

        callBack.loadFile(
            ":/model.zip"
            );

        gl::bufferData(indexBuffer,
    callBack.triangles.size()*sizeof(callBack.triangles[0]),
    &callBack.triangles[0]
    );

        gl::bufferData(pointsNormalBuffer,
    callBack.pointNormal.size()*sizeof(callBack.pointNormal[0]),
    &callBack.pointNormal[0]);

		const double scale__ = (std::max)({
			double(callBack.xMax) - callBack.xMin ,
			double(callBack.yMax) - callBack.yMin,
			double(callBack.zMax) - callBack.zMin
		});

		modelScaleBase = glm::scale(glm::vec3(
            float( 1.50 / scale__),
            float( 1.50 / scale__),
            float(-1.50 / scale__)
            ));

		modelScale = modelScaleBase;
		normalMatrix = glm::mat4( 
			1,0, 0,0,
			0,1, 0,0,
			0,0,-1,0,
			0,0, 0,1
			);
        indexCount = 3 * callBack.triangles.size() ;
    }

    gl::createVertexArrays(1,&vao);
    vao.bindBuffer(0, pointsNormalBuffer, 0,
        sizeof(gl::Float) * 6, 0,
        gl::NamedVertexArrayObject::Size::Three);
    vao.bindBuffer(1, pointsNormalBuffer, 0,
        sizeof(gl::Float) * 6, sizeof(gl::Float) * 3,
        gl::NamedVertexArrayObject::Size::Three);
    vao.bindElementBuffer(indexBuffer);
	{
		typedef void(QTimer::*TT)();
		timer.connect( &timer,TT(&QTimer::timeout),
			[this]() {
			rotate();
			super->updateGL();
		}
			);
	}
	timer.start(666);
     }
Exemplo n.º 20
0
/** Constructor */
MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
    : RWindow("MainWindow", parent, flags)
{
    /* Invoke the Qt Designer generated QObject setup routine */
    ui.setupUi(this);
    
    /* Create RshareSettings object */
    _settings = new RshareSettings();
    
    setWindowTitle(tr("RetroShare %1 a secure decentralised commmunication platform").arg(retroshareVersion())); 

    mSMPlayer = NULL;
  	
    // Setting icons
    this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
    
    /* Create all the dialogs of which we only want one instance */
    _bandwidthGraph = new BandwidthGraph();
    messengerWindow = new MessengerWindow();
    _preferencesWindow = new PreferencesWindow();
    applicationWindow = new ApplicationWindow();
    applicationWindow->hide();
	
    /** Left Side ToolBar**/
    connect(ui.actionAdd_Friend, SIGNAL(triggered() ), this , SLOT( addFriend() ) );
    connect(ui.actionAdd_Share, SIGNAL(triggered() ), this , SLOT( openShareManager() ) );
    connect(ui.actionOptions, SIGNAL(triggered()), this, SLOT( showPreferencesWindow()) );
    connect(ui.actionMessenger, SIGNAL(triggered()), this, SLOT( showMessengerWindow()) );
    connect(ui.actionSMPlayer, SIGNAL(triggered()), this, SLOT( showsmplayer()) );
    connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT( showabout()) );
    connect(ui.actionColor, SIGNAL(triggered()), this, SLOT( setStyle()) );
    //connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT( showSettings()) );
   	 
       
    /** adjusted quit behaviour: trigger a warning that can be switched off in the saved
        config file RetroShare.conf */
    connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(doQuit()));

    /* load the StyleSheet*/
    loadStyleSheet(Rshare::stylesheet()); 


    /* Create the Main pages and actions */
    QActionGroup *grp = new QActionGroup(this);


    ui.stackPages->add(networkDialog = new NetworkDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_NETWORK2), tr("Network"), grp));

  
    ui.stackPages->add(peersDialog = new PeersDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_PEERS), tr("Friends"), grp));

    //PeersFeed *peersFeed = NULL;
    //ui.stackPages->add(peersFeed = new PeersFeed(ui.stackPages),
    //		createPageAction(QIcon(IMAGE_PEERS), tr("Peers"), grp));
#ifdef TURTLE_HOPPING
    ui.stackPages->add(turtleDialog = new TurtleSearchDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_TURTLE), tr("Turtle"), grp));
#endif
    ui.stackPages->add(searchDialog = new SearchDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_SEARCH), tr("Search"), grp));
                     
    ui.stackPages->add(transfersDialog = new TransfersDialog(ui.stackPages),
                      createPageAction(QIcon(IMAGE_TRANSFERS), tr("Transfers"), grp));
                     
    //TransferFeed *transferFeed = NULL;
    //ui.stackPages->add(transferFeed = new TransferFeed(ui.stackPages),
    //		createPageAction(QIcon(IMAGE_LINKS), tr("Transfers"), grp));
	
    ui.stackPages->add(sharedfilesDialog = new SharedFilesDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_FILES), tr("Files"), grp));                     

    //MsgFeed *msgFeed = NULL;
    //ui.stackPages->add(msgFeed = new MsgFeed(ui.stackPages),
    //		createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp));

    ui.stackPages->add(messagesDialog = new MessagesDialog(ui.stackPages),
                      createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp));
                       
    LinksDialog *linksDialog = NULL;


#ifdef RS_RELEASE_VERSION    
    channelsDialog = NULL;
    ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages),
			createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp));

    ForumsDialog *forumsDialog = NULL;
    ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp));

	
#else
    channelsDialog = NULL;
    ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages),
			createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp));

    ChannelFeed *channelFeed = NULL;
    ui.stackPages->add(channelFeed = new ChannelFeed(ui.stackPages),
                      createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), grp));

    ForumsDialog *forumsDialog = NULL;
    ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp));
                       
#endif
    NewsFeed *newsFeed = NULL;
    ui.stackPages->add(newsFeed = new NewsFeed(ui.stackPages),
		createPageAction(QIcon(IMAGE_NEWSFEED), tr("News Feed"), grp));

#ifdef PLUGINMGR
    ui.stackPages->add(pluginsPage = new PluginsPage(ui.stackPages),
                       createPageAction(QIcon(IMAGE_PLUGINS), tr("Plugins"), grp));
#endif

    /* Create the toolbar */
    ui.toolBar->addActions(grp->actions());
    ui.toolBar->addSeparator();
    connect(grp, SIGNAL(triggered(QAction *)), ui.stackPages, SLOT(showPage(QAction *)));

#ifdef RS_RELEASE_VERSION    
#else   
    addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow()));                   
#endif
       
    /* Select the first action */
    grp->actions()[0]->setChecked(true);
    
    /* also an empty list of chat windows */
    messengerWindow->setChatDialog(peersDialog);

    // Allow to play files from SharedFilesDialog.
    connect(sharedfilesDialog, SIGNAL(playFiles( QStringList )), this, SLOT(playFiles( QStringList )));
    connect(transfersDialog, SIGNAL(playFiles( QStringList )), this, SLOT(playFiles( QStringList )));

    /** StatusBar section **/
    peerstatus = new PeerStatus();
    statusBar()->addWidget(peerstatus);
    
    dhtstatus = new DHTStatus();
    statusBar()->addWidget(dhtstatus);
    
    natstatus = new NATStatus();
    statusBar()->addWidget(natstatus);

	  QWidget *widget = new QWidget();
    QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
    sizePolicy.setHorizontalStretch(0);
    sizePolicy.setVerticalStretch(0);
    sizePolicy.setHeightForWidth(widget->sizePolicy().hasHeightForWidth());
    widget->setSizePolicy(sizePolicy);
    QHBoxLayout *horizontalLayout = new QHBoxLayout(widget);
	  horizontalLayout->setContentsMargins(0, 0, 0, 0);
    horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
	  _hashing_info_label = new QLabel(widget) ;
    _hashing_info_label->setObjectName(QString::fromUtf8("label"));

    horizontalLayout->addWidget(_hashing_info_label);
    QSpacerItem *horizontalSpacer = new QSpacerItem(1000, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
    horizontalLayout->addItem(horizontalSpacer);

    statusBar()->addPermanentWidget(widget);
	  _hashing_info_label->hide() ;

    ratesstatus = new RatesStatus();
    statusBar()->addPermanentWidget(ratesstatus);
    /******* Status Bar end ******/
  
    /* Create the actions that will go in the tray menu */
    createActions();
             
/******  
    * This is an annoying warning I get all the time...
    * (no help!)
    *
    *
    if (!QSystemTrayIcon::isSystemTrayAvailable())
    QMessageBox::warning(0, tr("System tray is unavailable"),
    tr("System tray unavailable"));
******/

    // Tray icon Menu
    menu = new QMenu(this);
    QObject::connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
    toggleVisibilityAction = 
            menu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
    menu->addSeparator();
    menu->addAction(_messengerwindowAct);
    menu->addAction(_messagesAct);
    menu->addAction(_bandwidthAct);

    /* bandwidth only in development version */
#ifdef RS_RELEASE_VERSION    
#else
    menu->addAction(_appAct);
#endif
    menu->addAction(_prefsAct);
    //menu->addAction(_smplayerAct);
    menu->addAction(_helpAct);
    menu->addSeparator();
    menu->addAction(QIcon(IMAGE_MINIMIZE), tr("Minimize"), this, SLOT(showMinimized()));
    menu->addAction(QIcon(IMAGE_MAXIMIZE), tr("Maximize"), this, SLOT(showMaximized()));
    menu->addSeparator();
    menu->addAction(QIcon(IMAGE_CLOSE), tr("&Quit"), this, SLOT(doQuit()));
    // End of Icon Menu
    
    // Create the tray icon
    trayIcon = new QSystemTrayIcon(this);
    trayIcon->setToolTip(tr("RetroShare"));
    trayIcon->setContextMenu(menu);
    trayIcon->setIcon(QIcon(IMAGE_RETROSHARE));
    
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, 
            SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
    trayIcon->show();

    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
    timer->start(1000);
}
Exemplo n.º 21
0
/** Constructor */
MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
    : RWindow("MainWindow", parent, flags), ui(new Ui::MainWindow)
{
    /* Invoke the Qt Designer generated QObject setup routine */
    ui->setupUi(this);

    _instance = this;

    m_bStatusLoadDone = false;
    isIdle = false;
    onlineCount = 0;

    notifyMenu = NULL;

    /* Calculate only once */
    RsPeerDetails pd;
    if (rsPeers->getPeerDetails(rsPeers->getOwnId(), pd)) {
        nameAndLocation = QString("%1 (%2)").arg(QString::fromUtf8(pd.name.c_str())).arg(QString::fromUtf8(pd.location.c_str()));
    }

    setWindowTitle(tr("RetroShare %1 a secure decentralized communication platform").arg(retroshareVersion()) + " - " + nameAndLocation);

    /* WORK OUT IF WE"RE IN ADVANCED MODE OR NOT */
    bool advancedMode = false;
    std::string advsetting;
    if (rsConfig->getConfigurationOption(RS_CONFIG_ADVANCED, advsetting) && (advsetting == "YES")) {
        advancedMode = true;
    }

    /* add url handler for RetroShare links */
    QDesktopServices::setUrlHandler(RSLINK_SCHEME, this, "retroshareLinkActivated");
    QDesktopServices::setUrlHandler("http", this, "externalLinkActivated");
    QDesktopServices::setUrlHandler("https", this, "externalLinkActivated");

    // Setting icons
    this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));

    /* Create all the dialogs of which we only want one instance */
    _bandwidthGraph = new BandwidthGraph();

    #ifdef UNFINISHED
    applicationWindow = new ApplicationWindow();
    applicationWindow->hide();
    #endif    

    /** Left Side ToolBar**/
    connect(ui->actionAdd_Friend, SIGNAL(triggered() ), this , SLOT( addFriend() ) );
    connect(ui->actionAdd_Share, SIGNAL(triggered() ), this , SLOT( openShareManager() ) );
    connect(ui->actionOptions, SIGNAL(triggered()), this, SLOT( showSettings()) );
    connect(ui->actionMessenger, SIGNAL(triggered()), this, SLOT( showMessengerWindow()) );

    ui->actionMessenger->setVisible(true);

    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT( showabout()) );
    //connect(ui->actionColor, SIGNAL(triggered()), this, SLOT( setStyle()) );

    /** adjusted quit behaviour: trigger a warning that can be switched off in the saved
        config file RetroShare.conf */
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(doQuit()));

    QList<QPair<MainPage*, QAction*> > notify;

    /* Create the Main pages and actions */
    QActionGroup *grp = new QActionGroup(this);
    QAction *action;

    ui->stackPages->add(newsFeed = new NewsFeed(ui->stackPages),
                       createPageAction(QIcon(IMAGE_NEWSFEED), tr("News feed"), grp));

//    ui->stackPages->add(networkDialog = new NetworkDialog(ui->stackPages),
//                       createPageAction(QIcon(IMAGE_NETWORK2), tr("Network"), grp));

    ui->stackPages->add(friendsDialog = new FriendsDialog(ui->stackPages),
                       action = createPageAction(QIcon(IMAGE_PEERS), tr("Friends"), grp));
    notify.push_back(QPair<MainPage*, QAction*>(friendsDialog, action));

//    ui->stackPages->add(searchDialog = new SearchDialog(ui->stackPages),
//                       createPageAction(QIcon(IMAGE_SEARCH), tr("Search"), grp));

    ui->stackPages->add(transfersDialog = new TransfersDialog(ui->stackPages),
                      action = createPageAction(QIcon(IMAGE_TRANSFERS), tr("File sharing"), grp));
    notify.push_back(QPair<MainPage*, QAction*>(transfersDialog, action));

    ui->stackPages->add(chatLobbyDialog = new ChatLobbyWidget(ui->stackPages),
                      action = createPageAction(QIcon(IMAGE_CHATLOBBY), tr("Chat Lobbies"), grp));
    notify.push_back(QPair<MainPage*, QAction*>(chatLobbyDialog, action));

    ui->stackPages->add(messagesDialog = new MessagesDialog(ui->stackPages),
                      action = createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp));
    notify.push_back(QPair<MainPage*, QAction*>(messagesDialog, action));

    ui->stackPages->add(channelFeed = new ChannelFeed(ui->stackPages),
                      action = createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), grp));
    notify.push_back(QPair<MainPage*, QAction*>(channelFeed, action));

#ifdef BLOGS
     ui->stackPages->add(blogsFeed = new BlogsDialog(ui->stackPages), createPageAction(QIcon(IMAGE_BLOGS), tr("Blogs"), grp));
#endif
                      
    ui->stackPages->add(forumsDialog = new ForumsDialog(ui->stackPages),
                       action = createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp));
    notify.push_back(QPair<MainPage*, QAction*>(forumsDialog, action));

	 std::cerr << "Looking for interfaces in existing plugins:" << std::endl;
	 for(int i = 0;i<rsPlugins->nbPlugins();++i)
	 {
		 QIcon icon ;

		 if(rsPlugins->plugin(i) != NULL && rsPlugins->plugin(i)->qt_page() != NULL)
		 {
			 if(rsPlugins->plugin(i)->qt_icon() != NULL)
				 icon = *rsPlugins->plugin(i)->qt_icon() ;
			 else
				 icon = QIcon(":images/extension_48.png") ;

			 std::cerr << "  Addign widget page for plugin " << rsPlugins->plugin(i)->getPluginName() << std::endl;
			 MainPage *pluginPage = rsPlugins->plugin(i)->qt_page();
			 QAction *pluginAction = createPageAction(icon, QString::fromUtf8(rsPlugins->plugin(i)->getPluginName().c_str()), grp);
			 ui->stackPages->add(pluginPage, pluginAction);
			 notify.push_back(QPair<MainPage*, QAction*>(pluginPage, pluginAction));
		 }
		 else if(rsPlugins->plugin(i) == NULL)
			 std::cerr << "  No plugin object !" << std::endl;
		 else
			 std::cerr << "  No plugin page !" << std::endl;

	 }

#ifndef RS_RELEASE_VERSION
#ifdef PLUGINMGR
    ui->stackPages->add(pluginsPage = new PluginsPage(ui->stackPages),
                       createPageAction(QIcon(IMAGE_PLUGINS), tr("Plugins"), grp));
#endif
#endif

#ifdef GETSTARTED_GUI
    MainPage *getStartedPage = NULL;

    if (!advancedMode)
    {
        ui->stackPages->add(getStartedPage = new GetStartedDialog(ui->stackPages),
                       createPageAction(QIcon(IMG_HELP), tr("Getting Started"), grp));
    }
#endif

    /* Create the toolbar */
    ui->toolBar->addActions(grp->actions());

    connect(grp, SIGNAL(triggered(QAction *)), ui->stackPages, SLOT(showPage(QAction *)));

#ifdef UNFINISHED
    ui->toolBar->addSeparator();
    addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui->toolBar), SLOT(showApplWindow()));
#endif

    ui->stackPages->setCurrentIndex(Settings->getLastPageInMainWindow());

    /** StatusBar section ********/
    /* initialize combobox in status bar */
    statusComboBox = new QComboBox(statusBar());
    statusComboBox->setFocusPolicy(Qt::ClickFocus);
    initializeStatusObject(statusComboBox, true);

    QWidget *widget = new QWidget();
    QHBoxLayout *hbox = new QHBoxLayout();
    hbox->setMargin(0);
    hbox->setSpacing(6);
    hbox->addWidget(statusComboBox);
    widget->setLayout(hbox);
    statusBar()->addWidget(widget);

    peerstatus = new PeerStatus();
    statusBar()->addWidget(peerstatus);

    natstatus = new NATStatus();
    statusBar()->addWidget(natstatus);
    
    dhtstatus = new DHTStatus();
    statusBar()->addWidget(dhtstatus);

    hashingstatus = new HashingStatus();
    statusBar()->addPermanentWidget(hashingstatus);

    discstatus = new DiscStatus();
    statusBar()->addPermanentWidget(discstatus);

    ratesstatus = new RatesStatus();
    statusBar()->addPermanentWidget(ratesstatus);

    statusBar()->addPermanentWidget(new OpModeStatus());

    statusBar()->addPermanentWidget(new SoundStatus());
    /** Status Bar end ******/

    /* Creates a tray icon with a context menu and adds it to the system's * notification area. */
    createTrayIcon();

    QList<QPair<MainPage*, QAction*> >::iterator notifyIt;
    for (notifyIt = notify.begin(); notifyIt != notify.end(); ++notifyIt) {
        UserNotify *userNotify = notifyIt->first->getUserNotify(this);
        if (userNotify) {
            userNotify->initialize(ui->toolBar, notifyIt->second);
            connect(userNotify, SIGNAL(countChanged()), this, SLOT(updateTrayCombine()));
            userNotifyList.push_back(userNotify);
        }
    }

    createNotifyIcons();

    /* caclulate friend count */
    updateFriends();
    connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateFriends()));
    connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateFriends()));

    loadOwnStatus();

    /* Set focus to the current page */
    ui->stackPages->currentWidget()->setFocus();

    idle = new Idle();
    idle->start();
    connect(idle, SIGNAL(secondsIdle(int)), this, SLOT(checkAndSetIdle(int)));

    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
    timer->start(1000);
}
Exemplo n.º 22
0
/** Constructor */
BlogsDialog::BlogsDialog(QWidget *parent)
: MainPage (parent)
{
  	/* Invoke the Qt Designer generated object setup routine */
  	setupUi(this);

  	connect(actionCreate_Blog, SIGNAL(triggered()), this, SLOT(createBlog()));
  	connect(postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
  	connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeBlog ( void ) ) );
  	connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeBlog ( void ) ) );
  	
    connect(treeView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(selectBlog(const QModelIndex &)));
    connect(treeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(toggleSelection(const QModelIndex &)));
    connect(treeView, SIGNAL(customContextMenuRequested( QPoint ) ), this, SLOT( blogListCustomPopupMenu( QPoint ) ) );

  	mBlogId = "";
  	mPeerId = rsPeers->getOwnId(); // add your id

    model = new QStandardItemModel(0, 2, this);
    model->setHeaderData(0, Qt::Horizontal, tr("Name"), Qt::DisplayRole);
    model->setHeaderData(1, Qt::Horizontal, tr("ID"), Qt::DisplayRole);

    treeView->setModel(model);
    treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);

    treeView->setItemDelegate(new ChanGroupDelegate());

    // hide header and id column
    treeView->setHeaderHidden(true);
    treeView->hideColumn(1);
    
    itemFont = QFont("ARIAL", 10);
    itemFont.setBold(true);
	
    QStandardItem *OwnBlogs = new QStandardItem(tr("My Blogs"));
    OwnBlogs->setForeground(QBrush(QColor(79, 79, 79)));
    OwnBlogs->setFont(itemFont);
    
    QStandardItem *SubscribedBlogs = new QStandardItem(tr("Subscribed Blogs"));
    SubscribedBlogs->setForeground(QBrush(QColor(79, 79, 79)));
    SubscribedBlogs->setFont(itemFont);

    QStandardItem *PopularBlogs = new QStandardItem(tr("Popular Blogs"));
    PopularBlogs->setForeground(QBrush(QColor(79, 79, 79)));
    PopularBlogs->setFont(itemFont);

    QStandardItem *OtherBlogs = new QStandardItem(tr("Other Blogs"));
    OtherBlogs->setForeground(QBrush(QColor(79, 79, 79)));        
    OtherBlogs->setFont(itemFont);

    model->appendRow(OwnBlogs);
    model->appendRow(SubscribedBlogs);
    model->appendRow(PopularBlogs);
    model->appendRow(OtherBlogs);

    //added from ahead
    updateBlogList();

    mBlogFont = QFont("MS SANS SERIF", 22);
    nameLabel->setFont(mBlogFont);    
    nameLabel->setMinimumWidth(20);
		   
    QMenu *blogmenu = new QMenu();
    blogmenu->addAction(actionCreate_Blog); 
    blogmenu->addSeparator();
    blogpushButton->setMenu(blogmenu);
	
    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
    timer->start(1000);
}
Exemplo n.º 23
0
/** Constructor */
MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
    : RWindow("MainWindow", parent, flags)
{
    ui = new Ui::MainWindow;
    trayIcon = NULL;

    /* Invoke the Qt Designer generated QObject setup routine */
    ui->setupUi(this);

    _instance = this;

    m_bStatusLoadDone = false;
    isIdle = false;
    onlineCount = 0;

    notifyMenu = NULL;

    /* Calculate only once */
    RsPeerDetails pd;
    if (rsPeers->getPeerDetails(rsPeers->getOwnId(), pd)) {
        nameAndLocation = QString("%1 (%2)").arg(QString::fromUtf8(pd.name.c_str())).arg(QString::fromUtf8(pd.location.c_str()));
    }

    setWindowTitle(tr("RetroShare %1 a secure decentralized communication platform").arg(Rshare::retroshareVersion(false)) + " - " + nameAndLocation);

    /* add url handler for RetroShare links */
    QDesktopServices::setUrlHandler(RSLINK_SCHEME, this, "retroshareLinkActivated");
    QDesktopServices::setUrlHandler("http", this, "externalLinkActivated");
    QDesktopServices::setUrlHandler("https", this, "externalLinkActivated");

    // Setting icons
    this->setWindowIcon(QIcon(QString::fromUtf8(":/icons/logo_128.png")));

    /* Create all the dialogs of which we only want one instance */
    _bandwidthGraph = new BandwidthGraph();

    #ifdef UNFINISHED
    applicationWindow = new ApplicationWindow();
    applicationWindow->hide();
    #endif

    initStackedPage();
    connect(ui->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setNewPage(int)));
    connect(ui->stackPages, SIGNAL(currentChanged(int)), this, SLOT(setNewPage(int)));

    //ui->stackPages->setCurrentIndex(Settings->getLastPageInMainWindow());
    setNewPage(Settings->getLastPageInMainWindow());

    ui->splitter->setStretchFactor(0, 0);
    ui->splitter->setStretchFactor(1, 1);

    /* Load listWidget postion */
    QByteArray state = Settings->valueFromGroup("MainWindow", "SplitterState", QByteArray()).toByteArray();
    if (!state.isEmpty()) ui->splitter->restoreState(state);
    state = Settings->valueFromGroup("MainWindow", "State", QByteArray()).toByteArray();
    if (!state.isEmpty()) restoreState(state);

    /** StatusBar section ********/
    /* initialize combobox in status bar */
    statusComboBox = new QComboBox(statusBar());
    statusComboBox->setFocusPolicy(Qt::ClickFocus);
    initializeStatusObject(statusComboBox, true);

    QWidget *widget = new QWidget();
    QHBoxLayout *hbox = new QHBoxLayout();
    hbox->setMargin(0);
    hbox->setSpacing(6);
    hbox->addWidget(statusComboBox);
    widget->setLayout(hbox);
    statusBar()->addWidget(widget);

    peerstatus = new PeerStatus();
    statusBar()->addWidget(peerstatus);

    natstatus = new NATStatus();
    statusBar()->addWidget(natstatus);
    
    dhtstatus = new DHTStatus();
    statusBar()->addWidget(dhtstatus);

    hashingstatus = new HashingStatus();
    statusBar()->addPermanentWidget(hashingstatus, 1);

    discstatus = new DiscStatus();
    statusBar()->addPermanentWidget(discstatus);

    ratesstatus = new RatesStatus();
    statusBar()->addPermanentWidget(ratesstatus);

    opModeStatus = new OpModeStatus();
    statusBar()->addPermanentWidget(opModeStatus);

    soundStatus = new SoundStatus();
    soundStatus->setHidden(Settings->valueFromGroup("StatusBar", "HideSound", QVariant(false)).toBool());
    statusBar()->addPermanentWidget(soundStatus);

    toasterDisable = new ToasterDisable();
    toasterDisable->setHidden(Settings->valueFromGroup("StatusBar", "HideToaster", QVariant(false)).toBool());
    statusBar()->addPermanentWidget(toasterDisable);

    sysTrayStatus = new SysTrayStatus();
    sysTrayStatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(false)).toBool());
    statusBar()->addPermanentWidget(sysTrayStatus);


    setCompactStatusMode(Settings->valueFromGroup("StatusBar", "CompactMode", QVariant(false)).toBool());

    /** Status Bar end ******/

    /* Creates a tray icon with a context menu and adds it to the system's * notification area. */
    createTrayIcon();

    createNotifyIcons();

    /* calculate friend count */
    updateFriends();
    connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateFriends()));
    connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateFriends()));

    loadOwnStatus();

    /* Set focus to the current page */
    ui->stackPages->currentWidget()->setFocus();

    idle = new Idle();
    idle->start();
    connect(idle, SIGNAL(secondsIdle(int)), this, SLOT(checkAndSetIdle(int)));

    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
    timer->start(1000);

    connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
    settingsChanged();
}
Exemplo n.º 24
0
 Waiter(QObject * obj, const char * signal) {
    m_timer.connect(obj, signal, SIGNAL(timeout()));
 }
Exemplo n.º 25
0
/** Constructor */
LinksDialog::LinksDialog(RsPeers *peers, RsFiles *files, QWidget *parent)
: MainPage(parent), mPeers(peers), mFiles(files)
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);

  connect( ui.linkTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( linkTreeWidgetCostumPopupMenu( QPoint ) ) );


  /* link combos */
  connect( ui.rankComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortRank( int ) ) );
  connect( ui.periodComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortPeriod( int ) ) );
  connect( ui.fromComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortFrom( int ) ) );
  connect( ui.topComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedSortTop( int ) ) );

  /* add button */
  connect( ui.addButton, SIGNAL( clicked( void ) ), this, SLOT( addLinkComment( void ) ) );
  connect( ui.expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggleWindows( void ) ) );
  
  connect( ui.addToolButton, SIGNAL( clicked( ) ), this, SLOT( addNewLink( ) ) );

  connect( ui.linkTreeWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem *, QTreeWidgetItem * ) ),
  		this, SLOT( changedItem ( QTreeWidgetItem *, QTreeWidgetItem * ) ) );

  connect( ui.linkTreeWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem *, int ) ),
  		this, SLOT( openLink ( QTreeWidgetItem *, int ) ) );

  connect( ui.anonBox, SIGNAL( stateChanged ( int ) ), this, SLOT( checkAnon ( void  ) ) );

  mStart = 0;


    /* Set header resize modes and initial section sizes */
	QHeaderView * _header = ui.linkTreeWidget->header () ;
  _header->setResizeMode (0, QHeaderView::Interactive);
	_header->setResizeMode (1, QHeaderView::Interactive);
	_header->setResizeMode (2, QHeaderView::Interactive);

	_header->resizeSection ( 0, 400 );
	_header->resizeSection ( 1, 60 );
	_header->resizeSection ( 2, 150 );

	ui.linkTreeWidget->setSortingEnabled(true);
	
	ui.linklabel->setMinimumWidth(20);


	/* Set a GUI update timer - much cleaner than
	 * doing everything through the notify agent
	 */

  QTimer *timer = new QTimer(this);
  timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
  timer->start(1000);

  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif

}
Exemplo n.º 26
0
/** Constructor */
NetworkDialog::NetworkDialog(QWidget *parent)
: MainPage(parent), connectdialog(NULL)
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);

  connect( ui.connecttreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) );

  /* create a single connect dialog */
  connectdialog = new ConnectDialog();
  
  connect(ui.infoLog, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoLogMenu(const QPoint&)));
  
  /* hide the Tree +/- */
  ui.connecttreeWidget -> setRootIsDecorated( false );
  
  /* Set header resize modes and initial section sizes */
	QHeaderView * _header = ui.connecttreeWidget->header () ;   
	_header->setResizeMode (0, QHeaderView::Custom);
	_header->setResizeMode (1, QHeaderView::Interactive);
	_header->setResizeMode (2, QHeaderView::Interactive);
	_header->setResizeMode (3, QHeaderView::Interactive);
	_header->setResizeMode (4, QHeaderView::Interactive);
	_header->setResizeMode (5, QHeaderView::Interactive);
	_header->setResizeMode (6, QHeaderView::Interactive);
	_header->setResizeMode (7, QHeaderView::Interactive);
	_header->setResizeMode (8, QHeaderView::Interactive);
	_header->setResizeMode (9, QHeaderView::Interactive);
    
	_header->resizeSection ( 0, 25 );
	_header->resizeSection ( 1, 100 );
	_header->resizeSection ( 2, 100 );
	_header->resizeSection ( 3, 100 );
	_header->resizeSection ( 4, 100 );
	_header->resizeSection ( 5, 200);
	_header->resizeSection ( 6, 100 );
	_header->resizeSection ( 7, 100 );
	_header->resizeSection ( 8, 100 );
	_header->resizeSection ( 9, 100 );
	
	// set header text aligment
	QTreeWidgetItem * headerItem = ui.connecttreeWidget->headerItem();
	headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
  headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(4, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(5, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(6, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(7, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(8, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(9, Qt::AlignHCenter | Qt::AlignVCenter);
	
	/*networkview = new NetworkView(ui.networkviewTab);
	QVBoxLayout *layout = new QVBoxLayout;
	layout->addWidget(networkview);
	ui.networkviewTab->setLayout(layout);
	layout->setSpacing( 0 );
	layout->setMargin( 0 );*/

  ui.networkTab->addTab(new NetworkView(),QString(tr("Network View")));
	ui.networkTab->addTab(new TrustView(),QString(tr("Trust matrix")));
     
    // Set Log infos
    setLogInfo(tr("RetroShare %1 started.", "e.g: RetroShare v0.x started.").arg(retroshareVersion()));
    
    setLogInfo(tr("Welcome to RetroShare."), QString::fromUtf8("blue"));
      
    QMenu *menu = new QMenu(tr("View"));
    menu->addAction(ui.actionTabsright); 
    menu->addAction(ui.actionTabswest);
    menu->addAction(ui.actionTabssouth); 
    menu->addAction(ui.actionTabsnorth);
    menu->addSeparator();
    menu->addAction(ui.actionTabsTriangular); 
    menu->addAction(ui.actionTabsRounded);
    ui.viewButton->setMenu(menu);
    
    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(getNetworkStatus()));
    timer->start(100000);
    
    QTimer *timer2 = new QTimer(this);
    timer2->connect(timer, SIGNAL(timeout()), this, SLOT(updateNetworkStatus()));
    timer2->start(1000);
    
    getNetworkStatus();
    updateNetworkStatus();
    //load();
    

  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}
Exemplo n.º 27
0
int main(int argc, char **argv)
{
  QCoreApplication app(argc, argv);
//#ifdef WIN32
  // Necessary to initialize factories under Windows
  Lima::AmosePluginsManager::single();
  std::cerr << "Amose plugins initialized" << std::endl;
//#endif
  QsLogging::initQsLog();

  std::string configDir;
  std::string limaServerConfigFile;
  // list of langs to initialize analyzer
  std::vector<std::string> languages;
  // list of pipelines to initialize analyzer
  std::vector<std::string> pipelines;
  // list of inacive units in pipelines
  std::vector<std::string> vinactiveUnits;
  int optional_port;
  // time before service stop
  int service_life;
  
  // Declare the supported options.
  po::options_description desc("Usage");
  desc.add_options()
  ("help,h", "Display this help message")
  ("language,l", po::value< std::vector<std::string> >(&languages), "supported languages trigrams")
  ("config-dir", po::value<std::string>(&configDir)->default_value(qgetenv("LIMA_CONF").constData()==0?"":qgetenv("LIMA_CONF").constData(),"$LIMA_CONF"),
                                                                                                                  "Set the directory containing the (LIMA) configuration files")
  ("common-config-file", po::value<std::string>(&limaServerConfigFile)->default_value("lima-server.xml"),
                                                                                  "Set the LIMA server configuration file to use")
  ("pipeline,p", po::value< std::vector<std::string> >(&pipelines), "Set the linguistic analysis supported pipelines")
  ("inactive-units", po::value< std::vector<std::string> >(&vinactiveUnits),
   "Inactive some process units of the used pipeline")
  ("port", po::value< int >(&optional_port),
   "set the listening port")
  ("service-life,t", po::value< int >(&service_life),
   "set the service life (nb seconds)");
  
  po::positional_options_description p;
  p.add("input-file", -1);
  
  // store value of options
  po::variables_map varMap;
  // parse args and set values in store
  po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), varMap);
  po::notify(varMap);

  // 
  if (varMap.count("help")) {
    std::cout << desc << std::endl;
    return 1;
  }
  if (configDir.empty())
  {
    configDir = "/usr/share/config/lima/";
  }
  
  // Parse configuration file of lima server
  // options in command line supercede options in configuration file
  // port
  std::string fileName(configDir);
  fileName.append("/").append(limaServerConfigFile);
  XMLConfigurationFileParser configLimaServer(fileName);
  quint16 port = DEFAULT_PORT;
  std::cout << "main: before, port = " << port << std::endl;
  if (varMap.count("port")) {
    port = optional_port;
  }
  else {
    try
    {
      port = QString::fromAscii(configLimaServer.getModuleGroupParamValue("http-server","address","port").c_str()).toInt();
    }
    catch (NoSuchModule& e1)
    {
      qDebug() << "http-server module not defined in config file. Using default port" << DEFAULT_PORT;
    } catch (NoSuchGroup& e2)
    {
      qDebug() << "http-server/address group not defined in config file. Using default port" << DEFAULT_PORT;
    } catch (NoSuchParam& e3)
    {
      qDebug() << "http-server/address/port parameter not defined in config file. Using default port" << DEFAULT_PORT;
    }
  }
  std::cout << "main: after, port = " << port << std::endl;

  // analyzer languages
  {
    std::ostringstream oss;
    std::ostream_iterator<std::string> out_it (oss,", ");
    std::copy ( languages.begin(), languages.end(), out_it );
    std::cout << "main: before, languages = " << oss.str() << std::endl;
  }
  std::deque<std::string> langs;
  if (varMap.count("language")) {
    if( !languages.empty() ) {
      langs.resize(languages.size());
      std::copy(languages.begin(), languages.end(), langs.begin());
    }
  }
  else {
    try
    {
      langs = configLimaServer.getModuleGroupListValues("http-server", "analyzer", "languages") ;
    }
    catch (NoSuchModule& e1)
    {
	qDebug() << "http-server module not defined in config file. Ininialize with all available languages";
    }
    catch (NoSuchParam& e3)
    {
      qDebug() << "http-server/analyzer/languages parameter not defined in config file. Ininialize with all available languages";
    }
  }
  {
    std::ostringstream oss;
    std::ostream_iterator<std::string> out_it (oss,", ");
    std::copy ( langs.begin(), langs.end(), out_it );
    std::cout << "main: after, langs = " << oss.str() << std::endl;
  }

  // analyzer pipelines
  // analyzer languages
  std::deque<std::string> pipes;
  {
    std::ostringstream oss;
    std::ostream_iterator<std::string> out_it (oss,", ");
    std::copy ( pipes.begin(), pipes.end(), out_it );
    std::cout << "main: before, pipes = " << oss.str() << std::endl;
  }
  if (varMap.count("pipelines")) {
    if( !pipelines.empty() ) {
      pipes.resize(pipelines.size());
      std::copy(pipelines.begin(), pipelines.end(), pipes.begin());
    }
  }
  else {
    try
    {
      pipes = configLimaServer.getModuleGroupListValues("http-server", "analyzer", "pipelines") ;
    }
    catch (NoSuchModule& e1)
    {
	qDebug() << "http-server module not defined in config file. Ininialize with all available pipelines";
    }
    catch (NoSuchParam& e3)
    {
      qDebug() << "http-server/analyzer/languages parameter not defined in config file. Ininialize with all available pipelines";
    }
  }
  {
    std::ostringstream oss;
    std::ostream_iterator<std::string> out_it (oss,", ");
    std::copy ( pipes.begin(), pipes.end(), out_it );
    std::cout << "main: after, pipes = " << oss.str() << std::endl;
  }

  QTimer t;
  // Create instance of server
  LimaServer server( configDir, langs, vinactiveUnits, pipes, port, &app, &t);

  if (varMap.count("service-life")) {
    // Stop server and app after service-life seconds
    //note that we need to use t.connect, as main is not a QObject
    t.connect (&t, SIGNAL(timeout()), &server, SLOT(quit()));
    int time_out = service_life*1000;
    t.start(time_out);
  }

  //return app.exec();
  int ret = app.exec();
  std::cout << "main: return " << ret;
  return ret;
}
	void initializeGL() {
		gl::createVertexArrays(1, &vao);
		gl::createBuffers(1, &positionBuffer);
		gl::createBuffers(1, &colorBuffer);
		gl::createBuffers(1, &indexBuffer);
		vao.bindElementBuffer(indexBuffer);
		constexpr static gl::Float colors[] = {
			1,0,0,1,
			0,1,0,1,
			0,0,1,1,
			1,1,0,1,
			1,0,0,1,
			0,1,0,1,
			0,0,1,1,
			1,1,0,1,
			1,0,0,1,
			0,1,0,1,
			0,0,1,1,
			1,1,0,1,
			1,0,0,1,
			0,1,0,1,
			0,0,1,1,
			1,1,0,1,
		};
#define POS0 -0.5f, 0.5f,0,1,
#define POS1 -0.5f,-0.5f,0,1,
#define POS2  0.5f,-0.5f,0,1,
#define POS3  0.5f, 0.5f,0,1,
		constexpr static gl::Float positions[] = {
			POS0
			POS1
			POS2
			POS3
			POS1
			POS2
			POS3
			POS0
			POS2
			POS3
			POS0
			POS1
			POS3
			POS0
			POS1
			POS2
		};
		gl::bufferData(positionBuffer, sizeof(positions), positions);
		gl::bufferData(colorBuffer, sizeof(colors), colors);
		constexpr static gl::UnsignedInteger index[] = { 0 };
		gl::bufferData(indexBuffer, sizeof(index), index);
		vao.bindBuffer(0, positionBuffer);
		vao.bindBuffer(1, colorBuffer);
		vao.bindDivisor(0, 1);
		vao.bindDivisor(1, 1);
		constexpr static char vs[] = R"(#version 450
layout(location=0) in vec4 iposition;
layout(location=1) in vec4 icolor;
out vec4 color;
void main(){
gl_Position = iposition;
gl_PointSize = 36+15*gl_InstanceID;
color = icolor;
}
)";
		constexpr static char fs[] = R"(#version 450
in vec4 color;
out vec4 fcolor;
void main(){
fcolor = vec4( gl_PointCoord.xy  ,color.x, 1);
}
)";
		program = gl::VFProgramLoadSources(vs, fs);
		{
			typedef void(QTimer::*TT)();
			timer.connect(&timer,TT(&QTimer::timeout),
				[this]() {
				++baseIndex;
				if (baseIndex > 3) { baseIndex = 0; }
				super->updateGL();
			}
				);
			timer.start(666);
		}
	}
Exemplo n.º 29
0
QwtDial *CockpitGrid::createDial( int pos )
{
    QwtDial *dial = NULL;
    switch( pos )
    {
        case 0:
        {
            d_clock = new QwtAnalogClock( this );
#if 0
            // disable minor ticks
            d_clock->scaleDraw()->setTickLength( QwtScaleDiv::MinorTick, 0 );
#endif

            const QColor knobColor = QColor( Qt::gray ).light( 130 );

            for ( int i = 0; i < QwtAnalogClock::NHands; i++ )
            {
                QColor handColor = QColor( Qt::gray ).light( 150 );
                int width = 8;

                if ( i == QwtAnalogClock::SecondHand )
                {
                    handColor = Qt::gray;
                    width = 5;
                }

                QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle(
                    QwtDialSimpleNeedle::Arrow, true, handColor, knobColor );
                hand->setWidth( width );

                d_clock->setHand( static_cast<QwtAnalogClock::Hand>( i ), hand );
            }

            QTimer *timer = new QTimer( d_clock );
            timer->connect( timer, SIGNAL( timeout() ),
                d_clock, SLOT( setCurrentTime() ) );
            timer->start( 1000 );

            dial = d_clock;
            break;
        }
        case 1:
        {
            d_speedo = new SpeedoMeter( this );
            d_speedo->setScaleStepSize( 20.0 );
            d_speedo->setScale( 0.0, 240.0 );
            d_speedo->scaleDraw()->setPenWidth( 2 );

            QTimer *timer = new QTimer( d_speedo );
            timer->connect( timer, SIGNAL( timeout() ),
                this, SLOT( changeSpeed() ) );
            timer->start( 50 );

            dial = d_speedo;
            break;
        }
        case 2:
        {
            d_ai = new AttitudeIndicator( this );
            d_ai->scaleDraw()->setPenWidth( 3 );

            QTimer *gradientTimer = new QTimer( d_ai );
            gradientTimer->connect( gradientTimer, SIGNAL( timeout() ),
                this, SLOT( changeGradient() ) );
            gradientTimer->start( 100 );

            QTimer *angleTimer = new QTimer( d_ai );
            angleTimer->connect( angleTimer, SIGNAL( timeout() ),
                this, SLOT( changeAngle() ) );
            angleTimer->start( 100 );

            dial = d_ai;
            break;
        }

    }

    if ( dial )
    {
        dial->setReadOnly( true );
        dial->setLineWidth( 4 );
        dial->setFrameShadow( QwtDial::Sunken );
    }
    return dial;
}
Exemplo n.º 30
0
Window::Window() : plot( QString("Velocity") ), gain(5), count(0) // <-- 'c++ initialisation list' - google it!
{
      //taken purely from online, not our code! 
      //http://qwt.sourceforge.net/class_qwt_analog_clock.html
	//
	QwtAnalogClock *clock = new QwtAnalogClock();
	clock->scaleDraw()->setPenWidth(3);
	clock->setLineWidth(6);
	clock->setFrameShadow(QwtDial::Sunken);
	clock->setTime(); 
      // update the clock every second
      QTimer *timer = new QTimer(clock);
            timer->connect(timer, SIGNAL(timeout()), clock, SLOT(setCurrentTime()));
            timer->start(1000);





	// set up the gain knob
	knob.setValue(gain);

	// use the Qt signals/slots framework to update the gain -
	// every time the knob is moved, the setGain function will be called
	connect( &knob, SIGNAL(valueChanged(double)), SLOT(setGain(double)) );

	// set up the thermometer
	thermo.setFillBrush( QBrush(Qt::red) );
	thermo.setRange(0, 20);
	//thermo.show();


	// set up the initial plot data
	for( int index=0; index<plotDataSize; ++index )
	{
		xData[index] = index;
		yData[index] = gain * sin( M_PI * index/50 );
	}

	// make a plot curve from the data and attach it to the plot
	curve.setSamples(xData, yData, plotDataSize);
	curve.attach(&plot);

	plot.replot();
	plot.show();


	// set up the layout - knob above thermometer
	//vLayout.addWidget(&knob);
	  vLayout.addWidget(clock);
	//vLayout.addWidget(&thermo);


	// plot to the left of knob and thermometer
	hLayout.addLayout(&vLayout);
	hLayout.addWidget(&plot);

	setLayout(&hLayout);

        std::cout << "It is working\n";
        //Below is NOT THE RIGHT WAY TO DO IT, the preferred way is to use 
        // moveToThread() on QObject and then using the Signals and Slots sys-
        //tem. Essentially use the connect function on the QObject instantia-
        //tion to hook up the start() method of the QThread object and the 
        // desired method that does the processing 
        DaThread *ls =new DaThread();

         uint64_t  ls_time=1900;
          int ls_boolean = 1;
          uint64_t  rs_time=1100;
          int rs_boolean = 1;


        ls-> initiate(xData, yData,&ls_time, &ls_boolean, &rs_time,&rs_boolean);
        ls->start();
        std::cout << "It is working\n";

        //start the servos around the time the data starts to be read  

        // ServoThread *leftServo =new ServoThread();
        // leftServo-> initiate(PIN, &ls_time, &ls_boolean);
        // leftServo->start();
 std::cout << "It is working1\n";

         
        // ServoThread *rightServo =new ServoThread();
        // rightServo-> initiate(PIN2, &rs_time, &rs_boolean);
        // rightServo->start();
         
        // ls_boolean =0;
        // rs_boolean =0;
}