Ejemplo n.º 1
0
RubberbandmanMainWidget::RubberbandmanMainWidget( QWidget *parent, Qt::WindowFlags flags )
: QWidget( parent, flags )
, mpBrowseWidget( new BrowseWidget( this ) )
, mpSatelliteWidget( new SatelliteWidget( this ) )
, mpDatabaseWidget( new DatabaseWidget( this ) )
, mpTabs( new QTabWidget( this ) )
, mpSettingsButton( new QPushButton( tr("Settings"), this ) )
, mpDatabaseActivity( new QLabel( this ) )
, mpConfigDialog( new RubberbandmanConfigDialog( this ) )
, mActiveLED( LEDIcon::pixmap( QColor("#ff0000"), 25 ) )
, mIdleLED( LEDIcon::pixmap( QColor("#5f0000"), 25 ) )
{
   mpBrowseWidget->setObjectName( "BrowseWidget" );
   mpSatelliteWidget->setObjectName( "SatelliteWidget" );
   mpDatabaseWidget->setObjectName( "DatabaseWidget" );
   QVBoxLayout *mainLayout = new QVBoxLayout( this );
   mainLayout->setContentsMargins( 3, 3, 3, 3 );
   parent->setWindowIcon( QIcon( ":/Rubberbandman/Icon.png" ) );

   mpTabs->addTab( mpBrowseWidget,    tr("Filesystem") );
   mpTabs->addTab( mpSatelliteWidget, tr("Satellite") );
   mpTabs->addTab( mpDatabaseWidget,  tr("Database") );
   mpTabs->setCurrentIndex( Settings::value( Settings::RubberbandmanCurrentTab ) );

   mainLayout->addWidget( mpTabs );
   QHBoxLayout *bottomLayout( new QHBoxLayout() );
   bottomLayout->addWidget( mpSettingsButton, 1 );
   bottomLayout->addWidget( mpDatabaseActivity, 0 );
   mainLayout->addLayout( bottomLayout );

   connect( mpSatelliteWidget, SIGNAL(showInFilesystem(QString)),
            mpBrowseWidget, SLOT(scrollTo(QString)) );
   connect( mpSatelliteWidget, SIGNAL(showInFilesystem(QString)),
            this, SLOT(goToFilesystem()) );
   connect( mpTabs, SIGNAL(currentChanged(int)),
            this, SLOT(handleTabChange(int)) );
   connect( mpSettingsButton, SIGNAL(clicked()),
            mpConfigDialog, SLOT(exec()) );
   connect( mpSatelliteWidget, SIGNAL(partymanConfigUpdate()),
            mpDatabaseWidget, SLOT(readPartymanConfig()) );
   DatabaseInterface::get()->connectActivityIndicator( this, SLOT(databaseActive(bool)) );
   WindowIconChanger *wic = new WindowIconChanger( parent, QIcon(":/Common/DatabaseUp.png"), this );
   DatabaseInterface::get()->connectActivityIndicator( wic, SLOT(changed(bool)) );

   setLayout( mainLayout );

   mpSettingsButton->setObjectName( QString("SettingsButton") );

   WidgetShot::addWidget( "MainWidget", this );
}
Ejemplo n.º 2
0
BitFieldWidget::BitFieldWidget(QWidget* parent) :
    QWidget(parent)
{
    m_bitWidgets.reserve(NumberOfBits);
    for (int i = 0; i < NumberOfBits; ++i) {
        BitWidget* bitWidget = new BitWidget(i);
        connect(bitWidget, SIGNAL(stateChanged(bool)), this, SLOT(onBitChanged()));
        m_bitWidgets.append(bitWidget);
    }

    QGridLayout* fieldLayout = new QGridLayout;
    int bitOffset = 0;

    for (int column = 0; column < 17; ++column) {
        if ((column % 2) == 0) {
            if ((column % 4) != 0)
                continue;

            QLabel* topNumberLabel = new QLabel;
            QLabel* bottomNumberLabel = new QLabel;

            int topNumber = NumberOfBits - column * 2;
            int bottomNumber = topNumber - NumberOfBits / 2;

            if (column == 0) {
                --topNumber;
                --bottomNumber;
            }

            topNumberLabel->setText(QString("%1").arg(topNumber));
            bottomNumberLabel->setText(QString("%1").arg(bottomNumber));

            fieldLayout->addWidget(topNumberLabel, 0, column);
            fieldLayout->addWidget(bottomNumberLabel, 1, column);

        } else {
            QHBoxLayout* bottomLayout(new QHBoxLayout);
            QHBoxLayout* topLayout(new QHBoxLayout);

            for (int j = 0; j < 4; ++j) {
                const int topIndex = NumberOfBits - 1 - bitOffset * 4 - j;
                topLayout->addWidget(m_bitWidgets.at(topIndex));
                bottomLayout->addWidget(m_bitWidgets.at(topIndex - NumberOfBits / 2));
            }

            ++bitOffset;

            fieldLayout->addLayout(bottomLayout, 1, column, Qt::AlignCenter);
            fieldLayout->addLayout(topLayout, 0, column, Qt::AlignCenter);
        }
    }

    QPushButton* resetButton = new QPushButton("0");
    resetButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    connect(resetButton, SIGNAL(clicked()), this, SLOT(resetBits()));

    QPushButton* invertButton = new QPushButton("~");
    invertButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    connect(invertButton, SIGNAL(clicked()), this, SLOT(invertBits()));

    QPushButton* shiftLeftButton = new QPushButton("<<");
    shiftLeftButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    connect(shiftLeftButton, SIGNAL(clicked()), this, SLOT(shiftBitsLeft()));

    QPushButton* shiftRightButton = new QPushButton(">>");
    shiftRightButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    connect(shiftRightButton, SIGNAL(clicked()), this, SLOT(shiftBitsRight()));

    QVBoxLayout* buttonsLayout = new QVBoxLayout;
    buttonsLayout->addWidget(resetButton);
    buttonsLayout->addWidget(shiftLeftButton);

    QVBoxLayout* buttonsLayout2 = new QVBoxLayout;
    buttonsLayout2->addWidget(invertButton);
    buttonsLayout2->addWidget(shiftRightButton);

    QHBoxLayout* mainLayout = new QHBoxLayout(this);
    mainLayout->addStretch();
    mainLayout->addLayout(fieldLayout);
    mainLayout->addLayout(buttonsLayout);
    mainLayout->addLayout(buttonsLayout2);
    mainLayout->addStretch();
}