void Console::createLayouts()
{
    /* Configure buttons layout */
    m_buttonsLayout = new QHBoxLayout   (m_buttonsWidget);
    m_buttonsLayout->addWidget          (m_copyButton);
    m_buttonsLayout->addWidget          (m_clearButton);

    /* Configure main layout */
    m_mainLayout = new QVBoxLayout      (this);
    m_mainLayout->addWidget             (m_buttonsWidget);
    m_mainLayout->addWidget             (m_console);

    /* Change spacing & resize to fit */
    m_mainLayout->setSpacing            (DPI_SCALE (10));
    m_buttonsLayout->setSpacing         (DPI_SCALE (5));
    m_buttonsLayout->setSizeConstraint  (QLayout::SetFixedSize);

    /* Set margins */
    m_mainLayout->setContentsMargins    (MAIN_MARGINS());
    m_buttonsLayout->setContentsMargins (NULL_MARGINS());

    /* Configure console output widget */
    m_console->setReadOnly              (true);
    m_console->setMaximumHeight         (DPI_SCALE (140));
    m_console->setMinimumWidth          (DPI_SCALE (320));;

    /* Set button sizes */
    m_copyButton->setFixedWidth         (DPI_SCALE (72));
    m_clearButton->setFixedWidth        (DPI_SCALE (72));
    m_copyButton->setFixedHeight        (DPI_SCALE (24));
    m_clearButton->setFixedHeight       (DPI_SCALE (24));
}
void AppTheme::loadFonts()
{
    QFont font;
    font.setFamily ("Quicksand");
    font.setPixelSize (DPI_SCALE (12));
    QApplication::setFont (font);
}
Beispiel #3
0
void Messages::createWidgets() {
    m_buttonsWidget  = new QWidget        (this);
    m_console        = new QPlainTextEdit (this);
    m_copyButton     = new QPushButton    (QChar (fa::copy),   this);
    m_clearButton    = new QPushButton    (QChar (fa::trash),  this);

    m_console->setReadOnly  (true);
    m_console->setFont      (Languages::monoFont());
    m_copyButton->setFont   (AWESOME()->font (DPI_SCALE (12)));
    m_clearButton->setFont  (AWESOME()->font (DPI_SCALE (12)));

    connect (m_copyButton,  &QPushButton::clicked, this, &Messages::copy);
    connect (m_clearButton, &QPushButton::clicked, this, &Messages::clear);
    connect (QDS(),          &DriverStation::newMessage,
             this,          &Messages::registerMessage);
}
void Preferences::createLayouts()
{
    QSpacerItem* spacer = new QSpacerItem  (5, 5,
                                            QSizePolicy::Minimum,
                                            QSizePolicy::MinimumExpanding);
    /* Left widgets */
    m_leftContainer  = new QWidget         (this);
    m_leftLayout     = new QVBoxLayout     (m_leftContainer);
    m_leftLayout->setSpacing               (DPI_SCALE (5));
    m_leftLayout->addWidget                (m_teamNumberLabel);
    m_leftLayout->addWidget                (m_teamNumber);
    m_leftLayout->addWidget                (m_dashboardLabel);
    m_leftLayout->addWidget                (m_dashboards);
    m_leftLayout->addWidget                (m_protocolLabel);
    m_leftLayout->addWidget                (m_protocols);
    m_leftLayout->addSpacerItem            (spacer);

    /* Practice timings */
    m_practiceLayout = new QGridLayout     (m_practiceTimings);
    m_practiceLayout->setVerticalSpacing   (0);
    m_practiceLayout->setHorizontalSpacing (DPI_SCALE (5));
    m_practiceLayout->addWidget            (m_countdownLabel,  0, 0);
    m_practiceLayout->addWidget            (m_autonomousLabel, 1, 0);
    m_practiceLayout->addWidget            (m_delayLabel,      2, 0);
    m_practiceLayout->addWidget            (m_teleopLabel,     3, 0);
    m_practiceLayout->addWidget            (m_endGameLabel,    4, 0);
    m_practiceLayout->addWidget            (m_countdown,       0, 1);
    m_practiceLayout->addWidget            (m_autonomous,      1, 1);
    m_practiceLayout->addWidget            (m_delay,           2, 1);
    m_practiceLayout->addWidget            (m_teleop,          3, 1);
    m_practiceLayout->addWidget            (m_endGame,         4, 1);
    m_practiceLayout->setContentsMargins   (MAIN_MARGINS());

    /* Main layout */
    m_mainLayout = new QHBoxLayout         (this);
    m_mainLayout->setSpacing               (DPI_SCALE (5));
    m_mainLayout->addWidget                (m_leftContainer);
    m_mainLayout->addWidget                (m_practiceTimings);
    m_mainLayout->setContentsMargins       (MAIN_MARGINS());
}
void Console::configureStyles()
{
    /* Set console font */
    QFont consoleFont;
#if defined Q_OS_WIN
    consoleFont.setFamily     ("Consolas");
    consoleFont.setPixelSize  (DPI_SCALE (12));
#else
    consoleFont.setFamily     ("Inconsolata");
    consoleFont.setPixelSize  (DPI_SCALE (12));
#endif
    m_console->setFont        (consoleFont);

    /* Change the fonts of the buttons */
    m_copyButton->setFont     (AWESOME()->font (DPI_SCALE (12)));
    m_clearButton->setFont    (AWESOME()->font (DPI_SCALE (12)));

    /* Set tooltips */
    m_console->setToolTip     (tr ("Displays robot messages and logs"));
    m_copyButton->setToolTip  (tr ("Copy the console log"));
    m_clearButton->setToolTip (tr ("Clear the console window"));
}
Beispiel #6
0
void Messages::createLayouts() {
    /* Configure buttons layout */
    m_buttonsLayout = new QHBoxLayout   (m_buttonsWidget);
    m_buttonsLayout->setSpacing         (DPI_SCALE (5));
    m_buttonsLayout->setContentsMargins (NULL_MARGINS());
    m_buttonsLayout->addWidget          (m_copyButton);
    m_buttonsLayout->addWidget          (m_clearButton);
    m_buttonsLayout->addSpacerItem      (SPACER());

    /* Configure main layout */
    m_mainLayout = new QVBoxLayout      (this);
    m_mainLayout->setSpacing            (DPI_SCALE (10));
    m_mainLayout->setContentsMargins    (MAIN_MARGINS());
    m_mainLayout->addWidget             (m_buttonsWidget);
    m_mainLayout->addWidget             (m_console);
    m_mainLayout->setStretch            (0, 0);
    m_mainLayout->setStretch            (1, 1);

    /* Set widget sizes */
    m_console->setMinimumSize           (DPI_SCALE (360), DPI_SCALE (96));
    m_copyButton->setFixedSize          (DPI_SCALE  (74), DPI_SCALE (24));
    m_clearButton->setFixedSize         (DPI_SCALE  (74), DPI_SCALE (24));
}
Beispiel #7
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");
}
Beispiel #8
0
void Joysticks::setupIndicators (int row) {
    /* Remove all joystick indicators in the widget */
    foreach (QSpinBox *     b, findChildren<QSpinBox*>())     delete b;
    foreach (QPushButton *  c, findChildren<QPushButton*>())  delete c;
    foreach (QProgressBar * p, findChildren<QProgressBar*>()) delete p;

    /* Clear joystick data */
    m_axes.clear();
    m_povs.clear();
    m_buttons.clear();

    /* Avoid crashing the application when there are no joysticks */
    if (row < 0)
        return;

    /* Get joystick information */
    int povCount    = JOYSTICK_MANAGER()->getInputDevice (row).numPOVs;
    int axisCount   = JOYSTICK_MANAGER()->getInputDevice (row).numAxes;
    int buttonCount = JOYSTICK_MANAGER()->getInputDevice (row).numButtons;

    /* Make the indicator containers visible */
    m_POVIndicators->setVisible (povCount > 0);
    m_axisIndicators->setVisible (axisCount > 0);
    m_buttonIndicators->setVisible (buttonCount > 0);

    /* Create a progress bar for each axis */
    for (int i = 0; i < axisCount; ++i) {
        QProgressBar* bar = new QProgressBar (this);

        bar->setFixedHeight (DPI_SCALE (19));

        bar->setValue (0);
        bar->setMaximum (100);
        bar->setMinimum (-100);
        bar->setFormat  (tr ("Axis %1").arg (i));

        m_axes.append (bar);
        m_axesBox->addWidget (bar);
    }

    /* Create a button for each joystick button */
    for (int i = 0; i < buttonCount; ++i) {
        QPushButton* button = new QPushButton (this);

        button->setEnabled (false);
        button->setCheckable (true);
        button->setFixedSize (DPI_SCALE (18), DPI_SCALE (12));
        button->setToolTip     (tr ("Button %1").arg (i));

        /* Distribute the button items in a nice layout */
        int row = (i <= 7) ? i : i - 8;
        int column = (i <= 7) ? 0 : (i / 8);

        m_buttons.append (button);
        m_buttonsBox->addWidget (button, row, column);
    }

    /* Create a spinbox for each joystick hat */
    for (int i = 0; i < povCount; ++i) {
        QSpinBox* box = new QSpinBox (this);

        box->setRange (0, 360);
        box->setEnabled (false);

        m_povs.append (box);
        m_povsBox->addWidget (box);
    }
}
void SettingsWindow::createWidgets()
{
    /* Tab widget */
    m_container         = new QTabWidget (this);
    m_containerWidget   = new QWidget (this);

    /* Network settings box */
    m_addressWidget     = new QWidget   (this);
    m_robotAddress      = new QLineEdit (this);
    m_networkingIcon    = new QLabel    ("", this);
    m_otherSettingsIcon = new QLabel    ("", this);
    m_networkingBox     = new QGroupBox (tr ("Networking"), this);
    m_useCustomAddress  = new QCheckBox (tr ("Use custom robot address"), this);

    /* Buttons */
    m_buttonsWidget     = new QWidget (this);
    m_reset             = new QPushButton (tr ("Reset"),  this);
    m_ok                = new QPushButton (tr ("OK"),     this);
    m_cancel            = new QPushButton (tr ("Cancel"), this);

    /* That crap that allows you to change the application's theme */
    m_appearanceBox     = new QGroupBox (tr ("Colors"), this);

    /* Color captions/labels */
    m_baseLabel         = new QLabel (tr ("Base"), this);
    m_highlightLabel    = new QLabel (tr ("Highlight"), this);
    m_backgroundLabel   = new QLabel (tr ("Background"), this);
    m_foregroundLabel   = new QLabel (tr ("Foreground"), this);

    /* Color rectangles */
    m_baseColor         = new QWidget (this);
    m_highlightColor    = new QWidget (this);
    m_backgroundColor   = new QWidget (this);
    m_foregroundColor   = new QWidget (this);

    /* The buttons that fire up a color dialog */
    m_baseButton        = new QPushButton ("...", this);
    m_highlightButton   = new QPushButton ("...", this);
    m_backgroundButton  = new QPushButton ("...", this);
    m_foregroundButton  = new QPushButton ("...", this);

    /* The HEX color editors */
    m_baseEdit          = new QLineEdit (this);
    m_highlightEdit     = new QLineEdit (this);
    m_backgroundEdit    = new QLineEdit (this);
    m_foregroundEdit    = new QLineEdit (this);

    /* Misc. settings such as auto-updater and sound settings */
    m_othersContainer   = new QWidget (this);
    m_otherSettingsBox  = new QGroupBox (tr ("Other Settings"), this);
    m_autoUpdater       = new QCheckBox (tr ("Check for updates automatically"),
                                         this);
    m_soundEffects      = new QCheckBox (tr ("Enable UI sound effects"), this);
    m_promptOnQuit      = new QCheckBox (tr ("Prompt on quit"), this);

    /* Defines the size of the color rectangles and color dialog buttons */
    QSize rectangle = QSize          (DPI_SCALE (24), DPI_SCALE (24));
    QSize smallRect = QSize          (DPI_SCALE (18), DPI_SCALE (18));

    /* Add 'General' tab and apply settings when user presses <ENTER> */
    m_ok->setDefault                 (true);
    m_container->addTab              (m_containerWidget, tr ("General"));

    /* Change size of the color rectanles */
    m_baseColor->setFixedSize        (smallRect);
    m_highlightColor->setFixedSize   (smallRect);
    m_backgroundColor->setFixedSize  (smallRect);
    m_foregroundColor->setFixedSize  (smallRect);

    /* Change size of '...' buttons */
    m_baseButton->setFixedSize       (rectangle);
    m_highlightButton->setFixedSize  (rectangle);
    m_backgroundButton->setFixedSize (rectangle);
    m_foregroundButton->setFixedSize (rectangle);

    /* Change size of HEX color editors */
    m_baseEdit->setFixedHeight       (rectangle.height());
    m_highlightEdit->setFixedHeight  (rectangle.height());
    m_backgroundEdit->setFixedHeight (rectangle.height());
    m_foregroundEdit->setFixedHeight (rectangle.height());

    /* Apply initial CSS for rectangle widgets */
    m_baseColor->setStyleSheet       (COLOR_RECTANGLE.arg ("#f00"));
    m_highlightColor->setStyleSheet  (COLOR_RECTANGLE.arg ("#f00"));
    m_backgroundColor->setStyleSheet (COLOR_RECTANGLE.arg ("#f00"));
    m_foregroundColor->setStyleSheet (COLOR_RECTANGLE.arg ("#f00"));

    /* Open the 'ethernet' icon for the networking settings */
    m_networkingIcon->setPixmap      (QPixmap (":/icons/ethernet.png")
                                      .scaled (DPI_SCALE (48),
                                              DPI_SCALE (48),
                                              Qt::KeepAspectRatio,
                                              Qt::SmoothTransformation));

    /* Open the 'utilities' icon for the other settings */
    m_otherSettingsIcon->setPixmap    (QPixmap (":/icons/other_settings.png")
                                       .scaled (DPI_SCALE (48),
                                               DPI_SCALE (48),
                                               Qt::KeepAspectRatio,
                                               Qt::SmoothTransformation));

    /* Change dialog size */
    m_robotAddress->setFixedWidth     (DPI_SCALE (256));

    /* Set object names so that we can identify the emitters of a signal */
    m_baseEdit->setObjectName         (BASE_OBJ_NAME);
    m_baseButton->setObjectName       (BASE_OBJ_NAME);
    m_highlightEdit->setObjectName    (HIGHLIGHT_OBJ_NAME);
    m_highlightButton->setObjectName  (HIGHLIGHT_OBJ_NAME);
    m_backgroundEdit->setObjectName   (BACKGROUND_OBJ_NAME);
    m_backgroundButton->setObjectName (BACKGROUND_OBJ_NAME);
    m_foregroundEdit->setObjectName   (FOREGROUND_OBJ_NAME);
    m_foregroundButton->setObjectName (FOREGROUND_OBJ_NAME);
}
void SettingsWindow::createLayouts()
{
    QSpacerItem* spacer = new QSpacerItem (0, 0,
                                           QSizePolicy::MinimumExpanding,
                                           QSizePolicy::MinimumExpanding);

    /* Custom address checkbox & text */
    m_addressLayout = new QVBoxLayout (m_addressWidget);
    m_addressLayout->setSpacing (DPI_SCALE (5));
    m_addressLayout->addWidget (m_useCustomAddress);
    m_addressLayout->addWidget (m_robotAddress);

    /* Network icon & custom address */
    m_networkLayout = new QHBoxLayout (m_networkingBox);
    m_networkLayout->setSpacing (DPI_SCALE (5));
    m_networkLayout->setContentsMargins (MAIN_MARGINS());
    m_networkLayout->addWidget (m_networkingIcon);
    m_networkLayout->addWidget (m_addressWidget);
    m_networkLayout->addSpacerItem (spacer);

    /* Appearance box */
    m_appearanceLayout = new QGridLayout (m_appearanceBox);
    m_appearanceLayout->setVerticalSpacing (DPI_SCALE (5));
    m_appearanceLayout->setHorizontalSpacing (DPI_SCALE (10));
    m_appearanceLayout->setContentsMargins (MAIN_MARGINS());
    m_appearanceLayout->addWidget (m_baseLabel,        0, 0);
    m_appearanceLayout->addWidget (m_highlightLabel,   1, 0);
    m_appearanceLayout->addWidget (m_backgroundLabel,  2, 0);
    m_appearanceLayout->addWidget (m_foregroundLabel,  3, 0);
    m_appearanceLayout->addWidget (m_baseColor,        0, 1);
    m_appearanceLayout->addWidget (m_highlightColor,   1, 1);
    m_appearanceLayout->addWidget (m_backgroundColor,  2, 1);
    m_appearanceLayout->addWidget (m_foregroundColor,  3, 1);
    m_appearanceLayout->addWidget (m_baseEdit,         0, 2);
    m_appearanceLayout->addWidget (m_highlightEdit,    1, 2);
    m_appearanceLayout->addWidget (m_backgroundEdit,   2, 2);
    m_appearanceLayout->addWidget (m_foregroundEdit,   3, 2);
    m_appearanceLayout->addWidget (m_baseButton,       0, 3);
    m_appearanceLayout->addWidget (m_highlightButton,  1, 3);
    m_appearanceLayout->addWidget (m_backgroundButton, 2, 3);
    m_appearanceLayout->addWidget (m_foregroundButton, 3, 3);

    /* Other settings checkboxes */
    m_otherSettingsCheckboxes = new QVBoxLayout (m_othersContainer);
    m_otherSettingsCheckboxes->setSpacing (DPI_SCALE (2));
    m_otherSettingsCheckboxes->addWidget (m_autoUpdater);
    m_otherSettingsCheckboxes->addWidget (m_soundEffects);
    m_otherSettingsCheckboxes->addWidget (m_promptOnQuit);

    /* Other settings layout */
    m_otherSettingsLayout = new QHBoxLayout (m_otherSettingsBox);
    m_otherSettingsLayout->setSpacing (DPI_SCALE (5));
    m_otherSettingsLayout->setContentsMargins (MAIN_MARGINS());
    m_otherSettingsLayout->addWidget (m_otherSettingsIcon);
    m_otherSettingsLayout->addWidget (m_othersContainer);
    m_otherSettingsLayout->addSpacerItem (spacer);

    /* Everything except the buttons */
    m_containerLayout = new QVBoxLayout (m_containerWidget);
    m_containerLayout->addWidget (m_networkingBox);
    m_containerLayout->addWidget (m_otherSettingsBox);
    m_containerLayout->addWidget (m_appearanceBox);
    m_containerLayout->addSpacerItem (spacer);

    /* Reset, Apply & Cancel buttons */
    m_buttonsLayout = new QHBoxLayout (m_buttonsWidget);
    m_buttonsLayout->addWidget (m_reset);
    m_buttonsLayout->addSpacerItem (spacer);
    m_buttonsLayout->addWidget (m_cancel);
    m_buttonsLayout->addWidget (m_ok);

    /* Window layout */
    m_mainLayout = new QVBoxLayout (this);
    m_mainLayout->addWidget (m_container);
    m_mainLayout->addWidget (m_buttonsWidget);
}