Ejemplo n.º 1
0
void MainWindow::slotUrl(const QString &urlin)
{
  url = urlin;
  if(opt.arg_debug) printf("slotUrl url=%s\n",(const char*) url.toUtf8());
  isReconnect = 0;
  slotReconnect();
}
Ejemplo n.º 2
0
SqlStorage::SqlStorage(QObject *parent, const QString &host, const int port, const QString &dbname, const QString &username, const QString &password ) :
    QObject(parent), _host(host), _port(port), _dbname(dbname), _username(username), _password(password)
{
    reconnect = new QTimer( this );
    reconnect->setSingleShot( true );
    reconnect->setInterval( 10 * 1000 );
    connect( reconnect, SIGNAL(timeout()), this, SLOT(slotReconnect()) );
}
Ejemplo n.º 3
0
void MainWindow::keyPressEvent(QKeyEvent *e)
{
  int modifier,key;
  
  /*
  if(opt.appfontsize < 0)
  { // mobile devices debug
    char buf[1024];
    sprintf(buf,"press key=%x modifiers=%x nm=%x nscan=%x nkey=%x", (int) e->key(), (int) e->modifiers(), e->nativeModifiers(), e->nativeScanCode(), e->nativeVirtualKey());
    QMessageBox::information(this, "got key HEX values", buf);
  } 
  */

  key = e->key();
  modifier = 0;
  if     (key == Qt::Key_Menu && e->modifiers() == Qt::NoModifier)
  {
    slotToolbar();
    return;
  }
  else if(e->modifiers() == Qt::ShiftModifier)
  {
    modifier = 4;
  }
  else if(e->modifiers() == Qt::ControlModifier)
  {
    modifier = 3;
    if(key == Qt::Key_R)
    {
      slotReconnect();
      return;
    }  
  }
  else if(e->modifiers() == Qt::AltModifier)
  {
    modifier = 2;
  }
  else if(key >= Qt::Key_Escape && key <= Qt::Key_Direction_R)
  {
    if(key != Qt::Key_Left && key != Qt::Key_Up && key != Qt::Key_Right && key != Qt::Key_Down)
    {
      modifier = 1;
    }
  }
  if(modifier != 0)
  {
    char buf[80];
    if(opt.arg_debug) printf("key modifier=%d key=%d ascii=%s\n",modifier,e->key(),(const char *) e->text().toUtf8());
    sprintf(buf,"key(%d,%d,\"%s\")\n",modifier,key,(const char *) e->text().toUtf8());
    tcp_send(&pvbtab[currentTab].s,buf,strlen(buf));
  }

  #ifdef PVWIN32
  if (key != Qt::Key_F10)
  #endif     
  QMainWindow::keyPressEvent(e);
}
Ejemplo n.º 4
0
void MainWindow::slotTimeOut()
{
  int i;
  char buf[20];

  for(i=0; i<MAX_TABS; i++)
  {
    if(pvbtab[i].s != -1 && opt.closed == 0)
    {
      sprintf(buf,"@hello=%s\n",VERSION);
      //printf("tab=%d buf=%s",i,buf);
      if(tcp_send(&pvbtab[i].s,buf,strlen(buf)) == -1)
      { // connection lost
        tcp_close(&pvbtab[i].s);
        pvbtab[i].s = -1;
        QPalette palette(QColor(255,0,0));
        statusBar()->setPalette(palette);
        //statusBar()->setPaletteBackgroundColor(QColor(255,0,0));
        statusBar()->showMessage(l_status_connection_lost);
        if(opt.arg_debug) printf("view->setDisabled\n");
        pvbtab[i].rootWidget->setDisabled(1);
        pvbtab[i].interpreter.perhapsCloseModalDialog();
        qApp->beep();
      }
    }
  }

  if(pvbtab[currentTab].s == -1)
  {
    if(opt.autoreconnect == 1) 
    {
     if(strncmp(pvbtab[currentTab].url.toUtf8(),"http://",7) != 0)
     {
       isReconnect = 1;
       slotReconnect();
     }  
    }
  }
}
Ejemplo n.º 5
0
void MainWindow::createToolBars()
{
  int i;
  if(opt.arg_debug) printf("createToolbar\n");

  // begin tabbed version
  currentTab = 0;
  numTabs = 1; //MAX_TABS; //1;
  for(i=0; i<MAX_TABS; i++)
  {
    pvbtab[i].interpreter.temp = opt.temp;
    pvbtab[i].interpreter.registerMainWindow(this,&pvbtab[i].s);
    pvbtab[i].rootWidget   = new MyQWidget(&pvbtab[i].s,0,NULL);
  }
  pvbtab[0].in_use = 1;
  scroll = new MyScrollArea(this);
  setCentralWidget(scroll);
  if(opt.tabs_above_toolbar)
  {
    tabToolBar  = addToolBar(tr("Tabs"));
    addToolBarBreak(); 
    fileToolBar = addToolBar(tr("File"));
  }
  else
  {
    fileToolBar = addToolBar(tr("File"));
    addToolBarBreak(); 
    tabToolBar  = addToolBar(tr("Tabs"));
  }
  tabBar      = new QTabBar();
  deleteTab   = new QPushButton();
  deleteTab->setToolTip(l_delete_tab);
  deleteTab->setIcon(QIcon(":/images/deletetab.png"));
  deleteTab->setFixedSize(18,18);
  tabBar->addTab(tr("Tab0"));
  tabBar->setTabWhatsThis(0, "0");
  tabToolBar->addWidget(tabBar);
  tabToolBar->addWidget(deleteTab);
  connect(tabBar,    SIGNAL(currentChanged(int)), this, SLOT(slotTabChanged(int)));
  connect(deleteTab, SIGNAL(clicked()),           this, SLOT(slotDeleteTab()));
  tabToolBar->hide();
  // end tabbed version

  fileToolBar->addAction(gohomeAct);
#ifndef USE_MAEMO
  fileToolBar->addAction(storebmpAct);
  fileToolBar->addAction(logbmpAct);
  fileToolBar->addAction(logpvmAct);
#endif
#ifndef NO_PRINTER
  fileToolBar->addAction(printAct);
#endif
#ifndef USE_MAEMO
  fileToolBar->addAction(newtabActToolBar);
  fileToolBar->addSeparator();

  fileToolBar->addAction(copyAct);
#endif
  fileToolBar->addSeparator();

  urlComboBox = new QComboBox(NULL);
  urlComboBox->setMinimumWidth(400);
  urlComboBox->setMaximumWidth(500);
  urlComboBox->setEditable(true);
  //urlComboBox->setCompleter(0);
  urlComboBox->setDuplicatesEnabled(false);
  //urlComboBox->setAutoCompletion(false);
  urlComboBox->setToolTip(tr("Connect to host:\n"
                             "pv://host<:port></mask>\n"
                             "pvssh://user@host<<:remote_host>:port></mask>\n"
                             "example: pv://localhost\n"
                             "example: pv://localhost:5050\n"
                             "example: pv://localhost:5050/maskname\n"
                             "http://host"
                             ));
#ifdef USE_ANDROID
  urlComboBox->setStyleSheet(
                               "QComboBox {min-height:29px; min-width:400px; margin: 1px; padding: 1x; }"
                               "QComboBox QAbstractItemView::item {min-height:30px; }"
                               "QComboBox QAbstractItemView::item:hover {min-height:30px; }"
                               "QComboBox::drop-down { width: 30px; }"
                            );                           
                            //"QComboBox::drop-down { width: 30px; image: url(your_arrow_icon.png); }"
#endif                            
  fileToolBar->addWidget(urlComboBox);
  connect(urlComboBox, SIGNAL(activated(const QString &)), this, SLOT(slotUrl(const QString &)));
  
  reconnectActToolBar = new QAction(QIcon(":/images/view-refresh.png"), "reconnect", this);
  fileToolBar->addAction(reconnectActToolBar);
  connect(reconnectActToolBar, SIGNAL(triggered()), this, SLOT(slotReconnect()));

  editmenuActToolBar = new QAction(QIcon(":/images/arrow-up.png"), "editmenu", this);
  fileToolBar->addAction(editmenuActToolBar);
  connect(editmenuActToolBar, SIGNAL(triggered()), this, SLOT(slotEditmenu()));

  statusbarActToolBar = new QAction(QIcon(":/images/arrow-down.png"), "statusbar", this);
  fileToolBar->addAction(statusbarActToolBar);
  connect(statusbarActToolBar, SIGNAL(triggered()), this, SLOT(slotStatusbar()));

#ifndef USE_MAEMO
  fileToolBar->addSeparator();

  whatsthisAct = new QAction(QIcon(":/images/whatsthis.png"), "whatsThis", this);
  fileToolBar->addAction(whatsthisAct);
  connect(whatsthisAct, SIGNAL(triggered()), this, SLOT(slotWhatsThis()));

  fileToolBar->addSeparator();

  logoLabel = new QLabel(NULL);
  QPixmap pm(opt.customlogo);
  if(pm.isNull())
  {
    printf("customlogo=%s not found\n",opt.customlogo);
    return;
  }
  logoLabel->setPixmap(pm);
  fileToolBar->addAction(logoAct);
  fileToolBar->insertWidget(logoAct,logoLabel);
#endif
}
Ejemplo n.º 6
0
void MainWindow::createActions()
{
  if(opt.arg_debug) printf("createActions\n");

  if(opt.arg_disable == 0)
  {
    optionAct = new QAction(QIcon(":/images/option.png"), l_options, this);
#ifndef USE_MAEMO
    optionAct->setShortcut(tr("Ctrl+O"));
#endif
    optionAct->setStatusTip(l_status_options);
    connect(optionAct, SIGNAL(triggered()), this, SLOT(slotFileOpt()));
  }

  if(opt.arg_disable == 0)
  {
    windowAct = new QAction(QIcon(":/images/window.png"), l_new_window, this);
    windowAct->setShortcut(tr("Ctrl+N"));
    windowAct->setStatusTip(l_status_new_window);
    connect(windowAct, SIGNAL(triggered()), this, SLOT(slotWindow()));

    newtabAct = new QAction(QIcon(":/images/newtab.png"), l_new_tab, this);
    //newtabAct->setShortcut(tr("Ctrl+N"));
    newtabAct->setStatusTip(l_status_new_tab);
    connect(newtabAct, SIGNAL(triggered()), this, SLOT(slotNewTab()));
  }

  reconnectAct = new QAction(QIcon(":/images/view-refresh.png"), l_reconnect, this);
  reconnectAct->setShortcut(tr("Ctrl+R"));
  reconnectAct->setStatusTip(l_status_reconnect);
  connect(reconnectAct, SIGNAL(triggered()), this, SLOT(slotReconnect()));

  storebmpAct = new QAction(QIcon(":/images/storebmp.png"), l_save_as_bmp, this);
  storebmpAct->setShortcut(tr("Ctrl+B"));
  storebmpAct->setStatusTip(l_status_save_as_bmp);
  connect(storebmpAct, SIGNAL(triggered()), this, SLOT(slotStorebmp()));

  gohomeAct = new QAction(QIcon(":/images/gohome.png"), opt.initialhost, this);
  gohomeAct->setStatusTip(opt.initialhost);
  connect(gohomeAct, SIGNAL(triggered()), this, SLOT(slotGohome()));

  logbmpAct = new QAction(QIcon(":/images/logbmp.png"), l_log_as_bmp, this);
  logbmpAct->setStatusTip(l_status_log_as_bmp);
  connect(logbmpAct, SIGNAL(triggered()), this, SLOT(slotLogbmp()));

  logpvmAct = new QAction(QIcon(":/images/logpvm.png"), l_log_as_pvm, this);
  logpvmAct->setStatusTip(l_status_log_as_pvm);
  connect(logpvmAct, SIGNAL(triggered()), this, SLOT(slotLogpvm()));

  printAct = new QAction(QIcon(":/images/print.png"), l_print, this);
  printAct->setShortcut(tr("Ctrl+P"));
  printAct->setStatusTip(l_status_print);
  connect(printAct, SIGNAL(triggered()), this, SLOT(slotPrint()));

  newtabActToolBar = new QAction(QIcon(":/images/newtab.png"), l_new_tab, this);
  newtabActToolBar->setStatusTip(l_status_new_tab);
  connect(newtabActToolBar, SIGNAL(triggered()), this, SLOT(slotNewTab()));

  exitAct = new QAction(QIcon(":/images/exit.png"), l_exit, this);
  exitAct->setShortcut(tr("Ctrl+Q"));
  exitAct->setStatusTip(l_status_exit);
  connect(exitAct, SIGNAL(triggered()), this, SLOT(slotExit()));

  copyAct = new QAction(QIcon(":/images/copy.png"), l_copy, this);
  copyAct->setShortcut(tr("Ctrl+C"));
  copyAct->setStatusTip(l_status_copy);
  connect(copyAct, SIGNAL(triggered()), this, SLOT(slotCopy()));

  if(opt.arg_disable == 0)
  {
    editmenuAct = new QAction(l_editmenu, this);
    editmenuAct->setShortcut(tr("Ctrl+E"));
    editmenuAct->setStatusTip(l_status_editmenu);
    connect(editmenuAct, SIGNAL(triggered()), this, SLOT(slotEditmenu()));
    addAction(editmenuAct);

    toolbarAct = new QAction(QIcon(":/images/toolbar.png"), l_toolbar, this);
    toolbarAct->setShortcut(tr("Ctrl+T"));
    toolbarAct->setStatusTip(l_status_toolbar);
    connect(toolbarAct, SIGNAL(triggered()), this, SLOT(slotToolbar()));
    addAction(toolbarAct);

    statusbarAct = new QAction(QIcon(":/images/statusbar.png"), l_statusbar, this);
    statusbarAct->setShortcut(tr("Ctrl+S"));
    statusbarAct->setStatusTip(l_status_statusbar);
    connect(statusbarAct, SIGNAL(triggered()), this, SLOT(slotStatusbar()));
    addAction(statusbarAct);

    maximizedAct = new QAction(l_maximized, this);
    maximizedAct->setShortcut(tr("Ctrl+M"));
    maximizedAct->setStatusTip(l_status_toggle_maximized);
    connect(maximizedAct, SIGNAL(triggered()), this, SLOT(slotMaximized()));
    addAction(maximizedAct);

    fullscreenAct = new QAction(QIcon(":/images/fullscreen.png"), l_fullscreen, this);
    fullscreenAct->setShortcut(tr("Ctrl+F"));
    fullscreenAct->setStatusTip(l_status_toggle_full_screen);
    connect(fullscreenAct, SIGNAL(triggered()), this, SLOT(slotFullscreen()));
    addAction(fullscreenAct);
  }

  manualAct = new QAction(l_manual, this);
  manualAct->setShortcut(tr("Ctrl+H"));
  manualAct->setStatusTip(l_status_manual);
  connect(manualAct, SIGNAL(triggered()), this, SLOT(slotManual()));

  aboutAct = new QAction(l_about, this);
  aboutAct->setStatusTip(l_status_about);
  connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

  aboutQtAct = new QAction("About &Qt", this);
  aboutQtAct->setStatusTip("About Qt library");
  connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

  logoAct = new QAction(QIcon(":/images/app.png"),"pvbrowser", this);
  logoAct->setStatusTip(tr("About pvbrowser"));
  connect(logoAct, SIGNAL(triggered()), this, SLOT(about()));
}