int NetScanningController::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: newData((*reinterpret_cast< const QList<Device*>(*)>(_a[1]))); break;
        case 1: infInformation((*reinterpret_cast< SVT_NotifyType(*)>(_a[1]))); break;
        case 2: deviceCountChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: newDeviceNotify((*reinterpret_cast< SVT_NotifyType(*)>(_a[1]))); break;
        case 4: routerTypeChanged(); break;
        case 5: gatewayChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 6: onNewData((*reinterpret_cast< SVT_NotifyType(*)>(_a[1]))); break;
        case 7: onInfInformation((*reinterpret_cast< SVT_NotifyType(*)>(_a[1]))); break;
        case 8: onCountChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 9: onNode2Device((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< Device*(*)>(_a[2]))); break;
        case 10: onDeviceDataChanged((*reinterpret_cast< const Device(*)>(_a[1]))); break;
        case 11: onRefresh(); break;
        case 12: onSubscribeData((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 13: startScan(); break;
        default: ;
        }
        _id -= 14;
    }
    return _id;
}
Esempio n. 2
0
Joysticks::Joysticks (QWidget* parent) : QWidget (parent) {
    /* Create Widgets */
    m_joystickNames    = new QListWidget (this);
    m_JSIndicators     = new QGroupBox   (tr ("USB"),     this);
    m_POVIndicators    = new QGroupBox   (tr ("POVs"),    this);
    m_axisIndicators   = new QGroupBox   (tr ("Axes"),    this);
    m_buttonIndicators = new QGroupBox   (tr ("Buttons"), this);

    /* Create container widgets */
    m_axesContainer    = new QWidget     (this);
    m_povsContainer    = new QWidget     (this);
    m_buttonsContainer = new QWidget     (this);

    /* Create the container layouts */
    m_axesBox          = new QVBoxLayout (m_axesContainer);
    m_povsBox          = new QVBoxLayout (m_povsContainer);
    m_buttonsBox       = new QGridLayout (m_buttonsContainer);

    /* Set indicator layouts */
    m_joystickBox      = new QVBoxLayout (m_JSIndicators);
    m_povGroupBox      = new QVBoxLayout (m_POVIndicators);
    m_axisGroupBox     = new QVBoxLayout (m_axisIndicators);
    m_buttonGroupBox   = new QVBoxLayout (m_buttonIndicators);

    /* Set layout spacings */
    int s = DPI_SCALE (4);
    m_joystickBox->setSpacing            (s);
    m_povGroupBox->setSpacing            (s);
    m_axisGroupBox->setSpacing           (s);
    m_buttonGroupBox->setSpacing         (s);
    m_povsBox->setSpacing                (s);
    m_axesBox->setSpacing                (s);
    m_buttonsBox->setSpacing             (s);
    m_povGroupBox->setSpacing            (s);
    m_axisGroupBox->setSpacing           (s);
    m_buttonGroupBox->setSpacing         (s);

    /* Set the margins */
    int m = DPI_SCALE (2);
    m_joystickBox->setContentsMargins    (m, m, m, m);
    m_povGroupBox->setContentsMargins    (m, m, m, m);
    m_axisGroupBox->setContentsMargins   (m, m, m, m);
    m_buttonGroupBox->setContentsMargins (m, m, m, m);
    m_povsBox->setContentsMargins        (m, m, m, m);
    m_axesBox->setContentsMargins        (m, m, m, m);
    m_buttonsBox->setContentsMargins     (m, m, m, m);

    /* Set indicators layout */
    m_axisGroupBox->addWidget            (m_axesContainer);
    m_povGroupBox->addWidget             (m_povsContainer);
    m_buttonGroupBox->addWidget          (m_buttonsContainer);
    m_axisGroupBox->addSpacerItem        (SPACER());
    m_povGroupBox->addSpacerItem         (SPACER());
    m_buttonGroupBox->addSpacerItem      (SPACER());

    /* Set main layout */
    m_mainLayout = new QHBoxLayout       (this);
    m_mainLayout->setSpacing             (DPI_SCALE (5));
    m_mainLayout->addWidget              (m_JSIndicators);
    m_mainLayout->addWidget              (m_axisIndicators);
    m_mainLayout->addWidget              (m_buttonIndicators);
    m_mainLayout->addWidget              (m_POVIndicators);
    m_mainLayout->addSpacerItem          (SPACER());
    m_joystickBox->addWidget             (m_joystickNames);

    /* Update UI config */
    m_POVIndicators->setVisible          (false);
    m_axisIndicators->setVisible         (false);
    m_buttonIndicators->setVisible       (false);
    m_buttonIndicators->setStyleSheet    (BUTTON_CSS);
    onCountChanged();

    /* Connect slots */
    connect (JOYSTICK_MANAGER(), &JoystickManager::countChanged,
             this,               &Joysticks::onCountChanged);
    connect (JOYSTICK_MANAGER(), &JoystickManager::POVEvent,
             this,               &Joysticks::onPOVEvent);
    connect (JOYSTICK_MANAGER(), &JoystickManager::axisEvent,
             this,               &Joysticks::onAxisEvent);
    connect (JOYSTICK_MANAGER(), &JoystickManager::buttonEvent,
             this,               &Joysticks::onButtonEvent);
    connect (m_joystickNames,    &QListWidget::currentRowChanged,
             this,               &Joysticks::setupIndicators);

    DS::log (DS::kInfoLevel, "MainWindow: Joysticks widget created");
}
Esempio n. 3
0
void Joysticks::showEvent (QShowEvent* event) {
    onCountChanged();
    event->accept();
}
Esempio n. 4
0
TransfersWindow::TransfersWindow(StackedWindow *parent) :
    StackedWindow(parent),
    m_model(new TransferModel(this)),
    m_view(new QTreeView(this)),
    m_startAction(new QAction(tr("Start all transfers"), this)),
    m_pauseAction(new QAction(tr("Pause all transfers"), this)),
    m_contextMenu(new QMenu(this)),
    m_transferCommandAction(m_contextMenu->addAction(tr("Set custom command"),
                                                             this, SLOT(setCurrentTransferCustomCommand()))),
    m_transferStartAction(m_contextMenu->addAction(tr("Start"), this, SLOT(startCurrentTransfer()))),
    m_transferPauseAction(m_contextMenu->addAction(tr("Pause"), this, SLOT(pauseCurrentTransfer()))),
    m_transferCategoryMenu(m_contextMenu->addMenu(tr("Category"))),
    m_transferCategoryGroup(new QActionGroup(this)),
    m_transferPriorityMenu(m_contextMenu->addMenu(tr("Priority"))),
    m_transferPriorityGroup(new QActionGroup(this)),
    m_transferHighPriorityAction(m_transferPriorityMenu->addAction(tr("High"), this, SLOT(setCurrentTransferPriority()))),
    m_transferNormalPriorityAction(m_transferPriorityMenu->addAction(tr("Normal"), this, SLOT(setCurrentTransferPriority()))),
    m_transferLowPriorityAction(m_transferPriorityMenu->addAction(tr("Low"), this, SLOT(setCurrentTransferPriority()))),
    m_transferRemoveAction(m_contextMenu->addAction(tr("Remove"), this, SLOT(removeCurrentTransfer()))),
    m_label(new QLabel(QString("<p align='center'; style='font-size: 40px; color: %1'>%2</p>")
                              .arg(palette().color(QPalette::Mid).name()).arg(tr("No transfers queued")), this))
{
    setWindowTitle(tr("Transfers"));
    setCentralWidget(new QWidget);
        
    m_view->setModel(m_model);
    m_view->setSelectionBehavior(QTreeView::SelectRows);
    m_view->setContextMenuPolicy(Qt::CustomContextMenu);
    m_view->setEditTriggers(QTreeView::NoEditTriggers);
    m_view->setItemsExpandable(false);
    m_view->setIndentation(0);
    m_view->setUniformRowHeights(true);
    m_view->setAllColumnsShowFocus(true);
    m_view->setColumnHidden(1, true);
    
    QHeaderView *header = m_view->header();

    if (!header->restoreState(Settings::transfersHeaderViewState())) {
        const QFontMetrics fm = header->fontMetrics();
        header->resizeSection(0, fm.width("A long transfer name") + 10);
        header->resizeSection(2, fm.width(m_model->headerData(2).toString()) + 10);
        header->resizeSection(3, fm.width("999.99MB of 999.99MB (99.99%)") + 10);
        header->setSectionHidden(1, true);
    }
    
    m_transferCategoryGroup->setExclusive(true);
    m_transferPriorityGroup->setExclusive(true);
    m_transferHighPriorityAction->setCheckable(true);
    m_transferHighPriorityAction->setActionGroup(m_transferPriorityGroup);
    m_transferNormalPriorityAction->setCheckable(true);
    m_transferNormalPriorityAction->setActionGroup(m_transferPriorityGroup);
    m_transferLowPriorityAction->setCheckable(true);
    m_transferLowPriorityAction->setActionGroup(m_transferPriorityGroup);
    
    m_label->hide();
    
    m_layout = new QVBoxLayout(centralWidget());
    m_layout->addWidget(m_view);
    m_layout->addWidget(m_label);
    m_layout->setContentsMargins(0, 0, 0, 0);
    
    menuBar()->addAction(m_startAction);
    menuBar()->addAction(m_pauseAction);
    
    connect(m_model, SIGNAL(countChanged(int)), this, SLOT(onCountChanged(int)));
    connect(m_startAction, SIGNAL(triggered()), Transfers::instance(), SLOT(start()));
    connect(m_pauseAction, SIGNAL(triggered()), Transfers::instance(), SLOT(pause()));
    connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
    connect(m_contextMenu, SIGNAL(aboutToShow()), this, SLOT(setTransferMenuActions()));
    connect(Settings::instance(), SIGNAL(categoriesChanged()), this, SLOT(setCategoryMenuActions()));
    
    onCountChanged(m_model->rowCount());
    setCategoryMenuActions();
}