Esempio n. 1
0
TrackInfoWidget::TrackInfoWidget( const Tomahawk::query_ptr& query, QWidget* parent )
    : QWidget( parent )
    , ui( new Ui::TrackInfoWidget )
    , m_scrollArea( 0 )
{
    QWidget* widget = new QWidget;
    ui->setupUi( widget );

    ui->artistLabel->setContentsMargins( 6, 2, 6, 2 );
    ui->artistLabel->setElideMode( Qt::ElideMiddle );
    ui->artistLabel->setType( QueryLabel::Artist );
    connect( ui->artistLabel, SIGNAL( clickedArtist() ), SLOT( onArtistClicked() ) );

    ui->statsLabel->setStyleSheet( "QLabel { background-image:url(); border: 2px solid #dddddd; background-color: #faf9f9; border-radius: 4px; padding: 12px; }" );
    ui->lyricsView->setStyleSheet( "QTextBrowser#lyricsView { background-color: transparent; }" );

    ui->lyricsView->setFrameShape( QFrame::NoFrame );
    ui->lyricsView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
    ui->lyricsView->setVisible( false ); // FIXME eventually

    ui->similarTracksView->setAutoResize( true );
    ui->similarTracksView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
//    TomahawkUtils::styleScrollBar( ui->similarTracksView->verticalScrollBar() );
    TomahawkUtils::styleScrollBar( ui->lyricsView->verticalScrollBar() );

//    ui->similarTracksView->setStyleSheet( "QListView { background-color: transparent; } QListView::item { background-color: transparent; }" );

    QFont f = ui->statsLabel->font();
    f.setPointSize( TomahawkUtils::defaultFontSize() + 2 );
    f.setBold( true );
    ui->statsLabel->setFont( f );

    QPalette p = ui->lyricsView->palette();
    p.setColor( QPalette::Foreground, Qt::white );
    p.setColor( QPalette::Text, Qt::white );

    ui->lyricsView->setPalette( p );
    ui->label->setPalette( p );
    ui->artistLabel->setPalette( p );
    ui->trackLabel->setPalette( p );

    m_relatedTracksModel = new PlayableModel( ui->similarTracksView );
    ui->similarTracksView->setPlayableModel( m_relatedTracksModel );
    ui->similarTracksView->proxyModel()->sort( -1 );
    ui->similarTracksView->setEmptyTip( tr( "Sorry, but we could not find similar tracks for this song!" ) );

    m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::Original, QSize( 48, 48 ) );
    ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::Grid, ui->cover->size() ) );
    ui->cover->setShowText( false );

    m_scrollArea = new QScrollArea();
    m_scrollArea->setWidgetResizable( true );
    m_scrollArea->setWidget( widget );
    m_scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );

    QPalette pal = palette();
    pal.setBrush( backgroundRole(), TomahawkStyle::PAGE_BACKGROUND );
    m_scrollArea->setPalette( pal );
    m_scrollArea->setAutoFillBackground( true );
    m_scrollArea->setFrameShape( QFrame::NoFrame );
    m_scrollArea->setAttribute( Qt::WA_MacShowFocusRect, 0 );

    QHBoxLayout* l = new QHBoxLayout( ui->statsWidget );
    m_playStatsGauge = new StatsGauge( ui->statsWidget );
    m_playStatsGauge->setText( tr( "# PLAYS / ARTIST" ) );
    m_playStatsTotalGauge = new StatsGauge( ui->statsWidget );
    m_playStatsTotalGauge->setText( tr( "# IN YOUR CHARTS" ) );
    m_playStatsTotalGauge->setInvertedAppearance( true );

    l->addSpacerItem( new QSpacerItem( 0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ) );
    l->addWidget( m_playStatsGauge );
    l->addSpacerItem( new QSpacerItem( 0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ) );
    l->addWidget( m_playStatsTotalGauge );
    l->addSpacerItem( new QSpacerItem( 0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ) );
    ui->statsWidget->setLayout( l );
    ui->statsLabel->setVisible( false );

    QVBoxLayout* layout = new QVBoxLayout();
    layout->addWidget( m_scrollArea );
    setLayout( layout );
    TomahawkUtils::unmarginLayout( layout );

    ui->similarTracksView->setStyleSheet( "QListView { background-color: transparent; }" );
    ui->frame->setStyleSheet( "QFrame#frame { background-color: transparent; }"
                              "QFrame#frame { "
                              "border-image: url(" RESPATH "images/widget-border.png) 3 3 3 3 stretch stretch;"
                              "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" );

    load( query );
}
Esempio n. 2
0
void QBookScreenSaver::paintEvent(QPaintEvent *event)
{
    qDebug() << Q_FUNC_INFO;

    QPainter painter(this);
    painter.setBackgroundMode(Qt::OpaqueMode);
    painter.fillRect( 0, 0, Screen::getInstance()->screenWidth(), Screen::getInstance()->screenHeight(), Qt::white);

    QFont font;
    font.setFamily(QString::fromUtf8("DejaVu Sans"));
    font.setPointSize(16);
    painter.setFont(font);
    QColor color(255, 255, 255);
    QBrush brush(color);
    painter.setBackground(brush);

    switch (screenType) {
    case SLEEP:
    {
        qDebug() << Q_FUNC_INFO << "Enter sleep";

        // Check charging
        if(ADConverter::getInstance()->getStatus() != ADConverter::ADC_STATUS_NO_WIRE)
        {
            showChargingImage(&painter);
            event->accept();
            return;
        }

        // Check battery
        if(checkAndShowBatteryWarnings(&painter))
            return;

        switch (QBook::settings().value("setting/screensaver", BOOK_COVER).toInt()){
        case STORED_IMAGES:
        {
            QString randomImage = getScreenSaverImgName();

            if (!randomImage.isEmpty())
                showGeneralImage(&painter,randomImage);
            else
                showDefaultSleepImage(&painter);
            break;
        }

        case DEFAULT_IMAGE:
        {
            showDefaultSleepImage(&painter);
            break;
        }

        case BOOK_COVER:
        {
            // TODO: Extra checks like file existance, etc...
            showGeneralImage(&painter,QBook::settings().value("setting/screensaverCoverToShow", "").toString());
            break;
        }
        default:
            showDefaultSleepImage(&painter);
        }
        break;
    }

    case POWER_OFF:
    {
        qDebug() << Q_FUNC_INFO << "powerOff";

        if(!checkAndShowBatteryWarnings(&painter))
        {
            QString downloadedImagePath = Storage::getInstance()->getDataPartition()->getMountPoint() + QDir::separator() + QString("powerOffDeviceImage.png");
            #ifndef HACKERS_EDITION
            if(QBookApp::instance()->isActivated() || QBookApp::instance()->isLinked())
                painter.drawPixmap(0, 0, QPixmap(downloadedImagePath));
            else
            #endif
                painter.drawPixmap(0, 0, QPixmap(":/powerOffDeviceImage.png"));
        }
    }
    break;

    case DEFAULT_SETTINGS:
        if(DeviceInfo::getInstance()->getHwId() == DeviceInfo::E60Q22)
            painter.drawPixmap(0, 0, QPixmap(":/factoryReset_E60Q22.png"));
        else // E606A2 or E60672
            painter.drawPixmap(0, 0, QPixmap(":/factoryReset.png"));
    break;

    event->accept();

    }
}
Esempio n. 3
0
/* Settings Dialog Constructor: */
UISettingsDialog::UISettingsDialog(QWidget *pParent)
    /* Parent class: */
    : QIWithRetranslateUI<QIMainDialog>(pParent)
    /* Protected variables: */
    , m_pSelector(0)
    , m_pStack(0)
    /* Common variables: */
    , m_dialogType(SettingsDialogType_Wrong)
    , m_fPolished(false)
    /* Loading/saving stuff: */
    , m_fLoaded(false)
    , m_fSaved(false)
    /* Status bar stuff: */
    , m_pStatusBar(new QStackedWidget(this))
    /* Process bar stuff: */
    , m_pProcessBar(new QProgressBar(this))
    /* Error/Warning stuff: */
    , m_fValid(true)
    , m_fSilent(true)
    , m_pWarningPane(new VBoxWarningPane(this))
    /* Whats-this stuff: */
    , m_pWhatsThisTimer(new QTimer(this))
    , m_pWhatsThisCandidate(0)
{
    /* Apply UI decorations: */
    Ui::UISettingsDialog::setupUi(this);

#ifdef Q_WS_MAC
    /* No status bar on the mac: */
    setSizeGripEnabled(false);
    setStatusBar(0);
#endif /* Q_WS_MAC */

    /* Page-title font is derived from the system font: */
    QFont pageTitleFont = font();
    pageTitleFont.setBold(true);
    pageTitleFont.setPointSize(pageTitleFont.pointSize() + 2);
    m_pLbTitle->setFont(pageTitleFont);

    /* Get main grid layout: */
    QGridLayout *pMainLayout = static_cast<QGridLayout*>(centralWidget()->layout());
#ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS
    /* No page-title with tool-bar: */
    m_pLbTitle->hide();
    /* No whats-this with tool-bar: */
    m_pLbWhatsThis->hide();
    /* Create modern tool-bar selector: */
    m_pSelector = new VBoxSettingsToolBarSelector(this);
    static_cast<UIToolBar*>(m_pSelector->widget())->setMacToolbar();
    addToolBar(qobject_cast<QToolBar*>(m_pSelector->widget()));
    /* No title in this mode, we change the title of the window: */
    pMainLayout->setColumnMinimumWidth(0, 0);
    pMainLayout->setHorizontalSpacing(0);
#else
    /* Create classical tree-view selector: */
    m_pSelector = new VBoxSettingsTreeViewSelector(this);
    pMainLayout->addWidget(m_pSelector->widget(), 0, 0, 3, 1);
    m_pSelector->widget()->setFocus();
    pMainLayout->setSpacing(10);
#endif /* VBOX_GUI_WITH_TOOLBAR_SETTINGS */

    /* Creating stack of pages: */
    m_pStack = new QStackedWidget(m_pWtStackHandler);
    QVBoxLayout *pStackLayout = new QVBoxLayout(m_pWtStackHandler);
    pStackLayout->setContentsMargins(0, 0, 0, 0);
    pStackLayout->addWidget(m_pStack);

    /* Status bar: */
    m_pStatusBar->addWidget(new QWidget);
    m_pButtonBox->addExtraWidget(m_pStatusBar);

    /* Setup process bar stuff: */
    m_pStatusBar->addWidget(m_pProcessBar);

    /* Setup error & warning stuff: */
    m_pStatusBar->addWidget(m_pWarningPane);
    m_errorIcon = UIIconPool::defaultIcon(UIIconPool::MessageBoxCriticalIcon, this).pixmap(16, 16);
    m_warningIcon = UIIconPool::defaultIcon(UIIconPool::MessageBoxWarningIcon, this).pixmap(16, 16);

    /* Setup whatsthis stuff: */
    qApp->installEventFilter(this);
    m_pWhatsThisTimer->setSingleShot(true);
    connect(m_pWhatsThisTimer, SIGNAL(timeout()), this, SLOT(sltUpdateWhatsThis()));
    m_pLbWhatsThis->setAutoFillBackground(true);
    QPalette whatsThisPalette = m_pLbWhatsThis->palette();
    whatsThisPalette.setBrush(QPalette::Window, whatsThisPalette.brush(QPalette::Midlight));
    m_pLbWhatsThis->setPalette(whatsThisPalette);
    m_pLbWhatsThis->setFixedHeight(m_pLbWhatsThis->frameWidth() * 2 +
                                   m_pLbWhatsThis->margin() * 2 +
                                   m_pLbWhatsThis->fontMetrics().lineSpacing() * 4);

    /* Set the default button: */
    m_pButtonBox->button(QDialogButtonBox::Ok)->setDefault(true);

    /* Setup connections: */
    connect(m_pSelector, SIGNAL(categoryChanged(int)), this, SLOT(sltCategoryChanged(int)));
    connect(m_pButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog()));

    /* Translate UI: */
    retranslateUi();
}
Esempio n. 4
0
PrefsDialog::PrefsDialog(QWidget *parent): QDialog(parent),ui(new Ui::PrefsDialog){
	ui->setupUi(this);
	this->setWindowFlags(Qt::WindowTitleHint | Qt::CustomizeWindowHint);

	// initialise Preferences object to ensure initial QSettings is written
	Preferences prefsObj;

	// these strings store the chars relating to each index of their dropdowns
	temporalWindowComboIndex = "bmn";
	hcdfComboIndex = "nhca";
	similarityMeasureComboIndex = "ck";
  tagFieldComboIndex = "cgk";
  tagFormatComboIndex = "kcb";

	// set preferences from QSettings
	QSettings settings;

	settings.beginGroup("analysisFrequencies");
	ui->stFreq->setCurrentIndex(log2(settings.value("startingFrequencyA").toFloat()/27.5));
	ui->octaves->setValue(settings.value("numOctaves").toInt());
	ui->octaveOffset->setChecked(settings.value("octaveBeginOffset").toInt() > 0);
	ui->bps->setValue(settings.value("bandsPerSemitone").toInt());
	settings.endGroup();

	settings.beginGroup("spectralAnalysis");
	ui->temporalWindow->setCurrentIndex(temporalWindowComboIndex.indexOf(settings.value("temporalWindow").toChar()));
	ui->fftFrameSize->setCurrentIndex(log2(settings.value("fftFrameSize").toInt()/512));
	ui->hopSize->setCurrentIndex(log2(settings.value("hopSize").toInt()/128));
	ui->directSkStretch->setValue(settings.value("directSkStretch").toFloat());
	settings.endGroup();

	settings.beginGroup("downsampling");
	ui->dFactor->setValue(settings.value("dFactor").toInt());
	settings.endGroup();

	settings.beginGroup("tuning");
	ui->tuningMethod->setCurrentIndex(settings.value("tuningMethod").toInt());
	ui->detunedBandWeight->setValue(settings.value("detunedBandWeight").toFloat());
	settings.endGroup();

	settings.beginGroup("harmonicChangeDetectionFunction");
	ui->hcdf->setCurrentIndex(hcdfComboIndex.indexOf(settings.value("hcdf").toChar()));
	ui->hcdfGaussianSize->setValue(settings.value("hcdfGaussianSize").toInt());
	ui->hcdfGaussianSigma->setValue(settings.value("hcdfGaussianSigma").toFloat());
	ui->hcdfPeakPickingNeighbours->setValue(settings.value("hcdfPeakPickingNeighbours").toInt());
	ui->hcdfArbitrarySegments->setValue(settings.value("hcdfArbitrarySegments").toInt());
	settings.endGroup();

	settings.beginGroup("keyClassification");
  ui->toneProfile->setCurrentIndex(settings.value("toneProfile").toInt());
	ui->similarityMeasure->setCurrentIndex(similarityMeasureComboIndex.indexOf(settings.value("similarityMeasure").toChar()));
	settings.endGroup();

	settings.beginGroup("customToneProfile");
	ui->maj0->setValue(settings.value("maj0").toFloat());
	ui->maj1->setValue(settings.value("maj1").toFloat());
	ui->maj2->setValue(settings.value("maj2").toFloat());
	ui->maj3->setValue(settings.value("maj3").toFloat());
	ui->maj4->setValue(settings.value("maj4").toFloat());
	ui->maj5->setValue(settings.value("maj5").toFloat());
	ui->maj6->setValue(settings.value("maj6").toFloat());
	ui->maj7->setValue(settings.value("maj7").toFloat());
	ui->maj8->setValue(settings.value("maj8").toFloat());
	ui->maj9->setValue(settings.value("maj9").toFloat());
	ui->maj10->setValue(settings.value("maj10").toFloat());
	ui->maj11->setValue(settings.value("maj11").toFloat());
	ui->min0->setValue(settings.value("min0").toFloat());
	ui->min1->setValue(settings.value("min1").toFloat());
	ui->min2->setValue(settings.value("min2").toFloat());
	ui->min3->setValue(settings.value("min3").toFloat());
	ui->min4->setValue(settings.value("min4").toFloat());
	ui->min5->setValue(settings.value("min5").toFloat());
	ui->min6->setValue(settings.value("min6").toFloat());
	ui->min7->setValue(settings.value("min7").toFloat());
	ui->min8->setValue(settings.value("min8").toFloat());
	ui->min9->setValue(settings.value("min9").toFloat());
	ui->min10->setValue(settings.value("min10").toFloat());
	ui->min11->setValue(settings.value("min11").toFloat());
	settings.endGroup();

	settings.beginGroup("customKeyCodes");
	ui->majKey0->setText(settings.value("majKey0").toString());
	ui->majKey1->setText(settings.value("majKey1").toString());
	ui->majKey2->setText(settings.value("majKey2").toString());
	ui->majKey3->setText(settings.value("majKey3").toString());
	ui->majKey4->setText(settings.value("majKey4").toString());
	ui->majKey5->setText(settings.value("majKey5").toString());
	ui->majKey6->setText(settings.value("majKey6").toString());
	ui->majKey7->setText(settings.value("majKey7").toString());
	ui->majKey8->setText(settings.value("majKey8").toString());
	ui->majKey9->setText(settings.value("majKey9").toString());
	ui->majKey10->setText(settings.value("majKey10").toString());
	ui->majKey11->setText(settings.value("majKey11").toString());
	ui->minKey0->setText(settings.value("minKey0").toString());
	ui->minKey1->setText(settings.value("minKey1").toString());
	ui->minKey2->setText(settings.value("minKey2").toString());
	ui->minKey3->setText(settings.value("minKey3").toString());
	ui->minKey4->setText(settings.value("minKey4").toString());
	ui->minKey5->setText(settings.value("minKey5").toString());
	ui->minKey6->setText(settings.value("minKey6").toString());
	ui->minKey7->setText(settings.value("minKey7").toString());
	ui->minKey8->setText(settings.value("minKey8").toString());
	ui->minKey9->setText(settings.value("minKey9").toString());
	ui->minKey10->setText(settings.value("minKey10").toString());
	ui->minKey11->setText(settings.value("minKey11").toString());
	ui->silence->setText(settings.value("silence").toString());
	settings.endGroup();

  settings.beginGroup("tags");
  ui->tagFormat->setCurrentIndex(tagFormatComboIndex.indexOf(settings.value("tagFormat").toChar()));
  ui->tagField->setCurrentIndex(tagFieldComboIndex.indexOf(settings.value("tagField").toChar()));
  ui->writeTagsAutomatically->setChecked(settings.value(("writeTagsAutomatically")).toBool());
  settings.endGroup();

	// enable/disable fields as necessary
	tuningEnabled();
	binAdaptiveTuningEnabled();
	hcdfEnabled();
	customProfileEnabled();

  //relative sizing on Mac only
  #ifdef Q_OS_MAC
    QFont smallerFont;
    smallerFont.setPointSize(smallerFont.pointSize() - 2);
    for(int i=0; i<ui->gridLayoutKeyCodes->count(); i++)
      if(!ui->gridLayoutKeyCodes->itemAt(i)->isEmpty())
        if(ui->gridLayoutKeyCodes->itemAt(i)->widget()->inherits("QLabel"))
          ui->gridLayoutKeyCodes->itemAt(i)->widget()->setFont(smallerFont);
    for(int i=0; i<ui->customMajor->count(); i++)
      if(!ui->customMajor->itemAt(i)->isEmpty())
        if(ui->customMajor->itemAt(i)->widget()->inherits("QLabel"))
          ui->customMajor->itemAt(i)->widget()->setFont(smallerFont);
    for(int i=0; i<ui->customMinor->count(); i++)
      if(!ui->customMinor->itemAt(i)->isEmpty())
        if(ui->customMinor->itemAt(i)->widget()->inherits("QLabel"))
          ui->customMinor->itemAt(i)->widget()->setFont(smallerFont);
  #endif
}
Esempio n. 5
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    isStart = false;
    isHexWorkspace = true;

    mAbout = new AboutUi(this);

    threadBuffer = (unsigned char*) malloc(BUFFER_SIZE);
    hexBuffer = (char*) malloc(4000);

    mSerialThread = new SerialThread(threadBuffer,BUFFER_SIZE);

    numberOfCharacter = 0;

    temp.reserve(1000);
    asciiOriginalBuffer.reserve(1000);

    QPixmap pix = QPixmap(":/MainUi/Start.png");
    iconStart = new QIcon(pix);
    pix = QPixmap(":/MainUi/Stop.png");
    iconStop = new QIcon(pix);
    pix = QPixmap(":/MainUi/Ascii.png");
    iconAscii = new QIcon(pix);
    pix = QPixmap(":/MainUi/Hex.png");
    iconHex = new QIcon(pix);
    pix = QPixmap(":/MainUi/DSR_R.png");
    iconDSR_R = new QIcon(pix);
    pix = QPixmap(":/MainUi/DTR_R.png");
    iconDTR_R = new QIcon(pix);
    pix = QPixmap(":/MainUi/RTS_R.png");
    iconRTS_R = new QIcon(pix);
    pix = QPixmap(":/MainUi/CTS_R.png");
    iconCTS_R = new QIcon(pix);
    pix = QPixmap(":/MainUi/DCD_R.png");
    iconDCD_R = new QIcon(pix);
    pix = QPixmap(":/MainUi/RNG_R.png");
    iconRNG_R = new QIcon(pix);
    pix = QPixmap(":/MainUi/DSR_V.png");
    iconDSR_V = new QIcon(pix);
    pix = QPixmap(":/MainUi/DTR_V.png");
    iconDTR_V = new QIcon(pix);
    pix = QPixmap(":/MainUi/RTS_V.png");
    iconRTS_V = new QIcon(pix);
    pix = QPixmap(":/MainUi/CTS_V.png");
    iconCTS_V = new QIcon(pix);
    pix = QPixmap(":/MainUi/DCD_V.png");
    iconDCD_V = new QIcon(pix);
    pix = QPixmap(":/MainUi/RNG_V.png");
    iconRNG_V = new QIcon(pix);

    mSerialPort = new QComboBox;
    Utils::setPortComList(mSerialPort);
    // Setup by setPortComList
    //mSerialPort->setCurrentIndex(0);

    mBaudrate = new QComboBox;
    QStringList baudrate;
    baudrate << tr("230400") << tr("115200") << tr("57600") << tr("56000") << tr("38400") << tr("28800") << tr("19200") << tr("14400") << tr("9600") << tr("4800") << tr("2400") << tr("1200") << tr("600") << tr("300") << tr("110");
    mBaudrate->addItems(baudrate);
    mBaudrate->setCurrentIndex(1);

    mStartStop = new QAction(tr("StartStop"), this);
    mStartStop->setShortcut(tr("Ctrl+Return"));
    mStartStop->setToolTip(tr("Start communication"));
    mStartStop->setStatusTip(tr("Start communication"));
    mStartStop->setWhatsThis(tr("Start communication"));
    mStartStop->setIcon(*iconStart);

    mHexAscii = new QAction(tr("HexAscii"), this);
    mHexAscii->setShortcut(tr("Ctrl+A"));
    mHexAscii->setToolTip(tr("Change to Ascii workspace"));
    mHexAscii->setStatusTip(tr("Change to Ascii workspace"));
    mHexAscii->setWhatsThis(tr("Change to Ascii workspace"));
    mHexAscii->setIcon(*iconAscii);

    mClearButton = new QAction(tr("Clear"), this);
    mClearButton->setShortcut(tr("Ctrl+E"));
    mClearButton->setToolTip(tr("Clean output ascii and hex"));
    mClearButton->setStatusTip(tr("Clean output ascii and hex"));
    mClearButton->setWhatsThis(tr("Clean output ascii and hex"));
    mClearButton->setIcon( QIcon(QPixmap(":/MainUi/Delete.png")));

    mConfigToolbar = addToolBar(tr("Pointer type"));
    mConfigToolbar->addWidget(mSerialPort);
    mConfigToolbar->addWidget(mBaudrate);
    mConfigToolbar->addAction(mStartStop);
    mConfigToolbar->addAction(mHexAscii);
    mConfigToolbar->addAction(mClearButton);

    ui->setupUi(this);

    connect( mStartStop, SIGNAL(triggered() ), this, SLOT(eventStartStop()) );
    connect( mHexAscii, SIGNAL(triggered() ), this, SLOT(eventHexAscii()) );
    connect( mClearButton, SIGNAL(triggered() ), this, SLOT(eventClearButton()) );
    connect( ui->actionQuit, SIGNAL(triggered() ), this, SLOT(eventQuit()) );
    connect( ui->actionAbout, SIGNAL(triggered() ), this, SLOT(eventAbout()) );
    connect( ui->actionSaveInputOutput, SIGNAL(triggered() ), this, SLOT(eventSaveInputOutput()) );
    connect( ui->actionSaveTerminalContent, SIGNAL(triggered() ), this, SLOT(eventSaveTerminalContent()) );
    connect( ui->actionSave_Input_Output, SIGNAL(triggered() ), this, SLOT(eventSaveInputOutput()) );
    connect( ui->actionSave_Terminal_Content, SIGNAL(triggered() ), this, SLOT(eventSaveTerminalContent()) );
    connect( mSerialPort, SIGNAL(currentIndexChanged(const QString &)),this, SLOT(eventSerialPort()));
    connect( mBaudrate, SIGNAL(currentIndexChanged(const QString &)),this, SLOT(eventBaudrate()));
    connect( ui->addOutputFrame, SIGNAL(clicked()), this, SLOT(eventAddOutputFrame()));
    connect( ui->deleteOutputFrame, SIGNAL(clicked()), this, SLOT(eventDeleteOutputFrame()));
    connect( ui->sendOutputFrame, SIGNAL(clicked()), this, SLOT(eventSendOutputFrame()));
    connect( ui->outputTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(eventDoubleClickOutputTable(QModelIndex)));
    connect( ui->addOutputFrameHex, SIGNAL(clicked()), this, SLOT(eventAddOutputFrameHex()));
    connect( ui->deleteOutputFrameHex, SIGNAL(clicked()), this, SLOT(eventDeleteOutputFrameHex()));
    connect( ui->sendOutputFrameHex, SIGNAL(clicked()), this, SLOT(eventSendOutputFrameHex()));
    connect( ui->outputTableHex, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(eventDoubleClickOutputTableHex(QModelIndex)));
    connect( ui->directAsciiText, SIGNAL(textChanged(QString)), this, SLOT(eventDirectAsciiChanged(QString)));
    connect( ui->directHexText, SIGNAL(textChanged(QString)), this, SLOT(eventDirectHexChanged(QString)));
    connect( ui->actionSetDTR, SIGNAL(triggered(bool)), this, SLOT(eventSetDTR(bool)));
    connect( ui->actionSetRTS, SIGNAL(triggered(bool)), this, SLOT(eventSetRTS(bool)));

    connect( ui->actionClear_log, SIGNAL(triggered()), this, SLOT(eventClearLog()));
    connect( ui->actionClear_Ascii_Hex_log, SIGNAL(triggered()), this, SLOT(eventClearAsciiHexLog()));
    connect( ui->actionClear_Ascii_log, SIGNAL(triggered()), this, SLOT(eventClearAsciiLog()));
    connect( ui->actionControl_Status, SIGNAL(triggered(bool)), this, SLOT(eventHideControlStatus(bool)));
    connect( ui->actionActivate_Control_Line, SIGNAL(triggered(bool)), this, SLOT(eventActivateControlLine(bool)) );

    connect( ui->actionOutput_Ascii, SIGNAL(triggered(bool)), this, SLOT(eventHideOutputAscii(bool)));
    connect( ui->actionOutput_Hex, SIGNAL(triggered(bool)), this, SLOT(eventHideOutputHex(bool)));
    connect( ui->actionLog, SIGNAL(triggered(bool)), this, SLOT(eventHideLog(bool)));
    connect( ui->actionOpenFrameProject, SIGNAL(triggered()), this, SLOT(eventOpenFrameProject()));

    ui->terminalOutputHex->setVerticalScrollBar(ui->verticalScrollBar);
    ui->terminalOutputAscii->setVerticalScrollBar(ui->verticalScrollBar);

    ui->dockOutputAscii->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    ui->dockOutputHex->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    ui->dockLog->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);

    QFont font = ui->terminalOutputAscii->font();
#ifdef Q_OS_DARWIN
    font.setPointSize(14);
#else
    font.setPointSize(10);
#endif
    ui->terminalOutputAscii->setFont(font);
    ui->terminalOutputHex->setFont(font);
    ui->terminalOutputAsciiOnly->setFont(font);

    ui->terminalOutputAsciiOnly->setVisible(false);

    if (Settings::getFirstStart()==true)
    {
        ui->dockLog->setVisible(Settings::getLogStatus());
        ui->actionLog->setChecked(Settings::getLogStatus());
        ui->dockOutputAscii->setVisible(Settings::getOutputAsciiStatus());
        ui->actionOutput_Ascii->setChecked(Settings::getOutputAsciiStatus());
        ui->dockOutputHex->setVisible(Settings::getOutputHexStatus());
        ui->actionOutput_Hex->setChecked(Settings::getOutputHexStatus());
        ui->ControlToolBar->setVisible(Settings::getControlStatus());
        ui->actionControl_Status->setChecked(Settings::getControlStatus());
        if (Settings::getTerminalStatus()==true)
        {
            eventHexAscii();
        }
    }
    else
    {
        Settings::setFirstStart(true);
        Settings::setControlStatus(true);
        Settings::setLogStatus(true);
        Settings::setOutputAsciiStatus(true);
        Settings::setOutputHexStatus(true);
        Settings::setTerminalStatus(false);
    }
}
Esempio n. 6
0
patternMetadata::patternMetadata(int pdfWidth, int titleFontSize,
                                 int patternByFontSize, int photoByFontSize,
                                 QWidget* parent)
  : cancelAcceptDialogBase(parent),
    widgetLayout_(new QVBoxLayout),
    metadataBox_(new QGroupBox(tr("Pattern information (all fields are optional, all text will be centered in the pdf)"))),
    metadataLayout_(new QVBoxLayout),
    titleLabel_(new QLabel(tr("<u><b>Pattern title</b></u> (only the first line will be used):"))),
    titleEdit_(new fixedWidthTextEdit(pdfWidth, 1, this)),
    titleSettingsKey_("pattern_title"),
    titleFontSize_(titleFontSize),
    linesToKeep_(4),
    patternByLabel_(new QLabel(tr("<u><b>Pattern information</b></u> (only the first four lines will be used):"))),
    patternByEdit_(new fixedWidthTextEdit(pdfWidth, linesToKeep_, this)),
    patternBySettingsKey_("pattern_by"),
    patternByFontSize_(patternByFontSize),
    patternByLicenseLayout_(new QHBoxLayout),
    patternByLicenseButton_(new QPushButton(tr("Insert"))),
    patternByLicenses_(new QComboBox),
    photoByLabel_(new QLabel(tr("<u><b>Photo information</b></u> (only the first four lines will be used):"))),
    photoByEdit_(new fixedWidthTextEdit(pdfWidth, linesToKeep_, this)),
    photoBySettingsKey_("photo_by"),
    photoByFontSize_(photoByFontSize),
    photoByLicenseLayout_(new QHBoxLayout),
    photoByLicenseButton_(new QPushButton(tr("Insert"))),
    photoByLicenses_(new QComboBox),
    clearMetadataButton_(new QPushButton(tr("Clear all information"))),
    symbolSizeBox_(new QGroupBox(tr("Pdf symbol size"))),
    symbolSizeLayout_(new QVBoxLayout),
    symbolSizeTitleLayout_(new QHBoxLayout),
    symbolSizeTitle_(new QLabel("Set the pdf symbol size (from " +
                                QString::number(MIN_SYMBOL_SIZE) + " to " +
                                QString::number(MAX_SYMBOL_SIZE) + "): ")),
    symbolSizeSpinBox_(new QSpinBox),
    symbolSizeKey_("pdf_symbol_size"),
    symbolPreviewLayout_(new QHBoxLayout),
    symbolPreview_(new QLabel) {

  // TODO this won't quite be right since the textEdit has mystery margins
  const int inputFieldWidth = pdfWidth + ::scrollbarWidth();
  const QFont applicationFont = QApplication::font();
  
#ifdef Q_OS_LINUX
  // Qt-linux bug (4.6.3) for QFontMetrics.lineSpacing()?
  const int linesFudge = 2;
#else
  const int linesFudge = 1;
#endif

  // title
  metadataLayout_->addWidget(titleLabel_);
  QFont titleFont = applicationFont;
  titleFont.setBold(true);
  titleFont.setPointSize(titleFontSize_);
  titleEdit_->setFont(titleFont);
  titleEdit_->setFixedWidth(inputFieldWidth);
  // TODO these fudges are probably not portable or lasting (then again,
  // what are the correct QT magic incantations to compute all of the
  // paddings, margins, frames, etc, and how often will they change?)
  const int lineHeightFudge = 8;
  const int comboBoxWidthFudge = 100;
  titleEdit_->setFixedHeight(linesFudge*QFontMetrics(titleFont).lineSpacing() +
                             lineHeightFudge);
  metadataLayout_->addWidget(titleEdit_);
  metadataLayout_->addSpacing(20);

  // patternBy
  metadataLayout_->addWidget(patternByLabel_);
  QFont patternByFont = applicationFont;
  patternByFont.setPointSize(patternByFontSize_);
  patternByEdit_->setFont(patternByFont);
  patternByEdit_->setFixedWidth(inputFieldWidth);
  patternByEdit_->
    setFixedHeight(linesFudge*linesToKeep_*QFontMetrics(patternByFont).lineSpacing() +
                   lineHeightFudge);
  connect(patternByLicenseButton_, SIGNAL(clicked()),
          this, SLOT(insertPatternByLicense()));
  // unfortunately patternByLicenseButton_ doesn't know its width yet,
  // so we have to just approximate
  patternByLicenses_->setFixedWidth(inputFieldWidth - comboBoxWidthFudge);
  loadLicenses(patternByLicenses_, patternByFont, false);
  metadataLayout_->addWidget(patternByEdit_);
  patternByLicenseLayout_->addWidget(patternByLicenseButton_, 0,
                                     Qt::AlignLeft);
  patternByLicenseLayout_->addWidget(patternByLicenses_, 1, Qt::AlignLeft);
  metadataLayout_->addLayout(patternByLicenseLayout_);
  metadataLayout_->addSpacing(20);

  // photoBy
  metadataLayout_->addWidget(photoByLabel_);
  QFont photoByFont = applicationFont;
  photoByFont.setPointSize(photoByFontSize_);
  photoByEdit_->setFont(photoByFont);
  photoByEdit_->setFixedWidth(inputFieldWidth);
  photoByEdit_->
    setFixedHeight(linesFudge*linesToKeep_*QFontMetrics(photoByFont).lineSpacing() +
                   lineHeightFudge);
  connect(photoByLicenseButton_, SIGNAL(clicked()),
          this, SLOT(insertPhotoByLicense()));
  // unfortunately photobyLicenseButton_ doesn't know its width yet,
  // so we have to just approximate
  photoByLicenses_->setFixedWidth(inputFieldWidth - comboBoxWidthFudge);
  loadLicenses(photoByLicenses_, photoByFont, true);
  metadataLayout_->addWidget(photoByEdit_);
  photoByLicenseLayout_->addWidget(photoByLicenseButton_, 0, Qt::AlignLeft);
  photoByLicenseLayout_->addWidget(photoByLicenses_, 1, Qt::AlignLeft);
  metadataLayout_->addLayout(photoByLicenseLayout_);

  connect(clearMetadataButton_, SIGNAL(clicked()),
          this, SLOT(clearMetadata()));
  metadataLayout_->addWidget(clearMetadataButton_);

  metadataBox_->setLayout(metadataLayout_);
  widgetLayout_->addWidget(metadataBox_);
  setLayout(widgetLayout_);

  // load any saved fields
  const QSettings settings("cstitch", "cstitch");
  loadSettings(settings, titleSettingsKey_, titleEdit_);
  loadSettings(settings, patternBySettingsKey_, patternByEdit_);
  loadSettings(settings, photoBySettingsKey_, photoByEdit_);

  constructSymbolPreview(settings);

  widgetLayout_->addWidget(cancelAcceptWidget());
  titleEdit_->setFocus();
  setWindowTitle(tr("Pattern information"));
}
Esempio n. 7
0
void
MainWindow::makeUI()
{
    setObjectName(QString::fromUtf8("MainWindow"));
#if 1
    action_Exit = new QAction(this);
    action_Exit->setObjectName(QString::fromUtf8("action_Exit"));
	//connect(action_Exit, SIGNAL(triggered()), qApp, SLOT(quit()));
	connect(action_Exit, SIGNAL(triggered()), this, SLOT(close()));
#endif

    centralwidget = new QWidget(this);
    centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
	
    widget = new QWidget(centralwidget);
    widget->setObjectName(QString::fromUtf8("widget"));
    widget->setGeometry(QRect(190, 0, 1080, 821));
    widget->setMinimumSize(QSize(400, 0));
    vboxLayout = new QVBoxLayout(widget);
    vboxLayout->setSpacing(0);
    vboxLayout->setMargin(0);
    vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
    dockWidget = new QDockWidget(widget);
    dockWidget->setObjectName(QString::fromUtf8("dockWidget"));
    QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(7), static_cast<QSizePolicy::Policy>(7));
    sizePolicy.setHorizontalStretch(0);
    sizePolicy.setVerticalStretch(0);
    sizePolicy.setHeightForWidth(dockWidget->sizePolicy().hasHeightForWidth());
    dockWidget->setSizePolicy(sizePolicy);
    dockWidgetContents = new QWidget(dockWidget);
    dockWidgetContents->setObjectName(QString::fromUtf8("dockWidgetContents"));

    vdockLayout = new QVBoxLayout(widget);
    vdockLayout->setSpacing(0);
    vdockLayout->setMargin(0);
    vdockLayout->setObjectName(QString::fromUtf8("vdockLayout"));

    stackedWidget = new QStackedWidget(dockWidgetContents);
    stackedWidget->setObjectName(QString::fromUtf8("stackedWidget"));
    stackedWidget->setGeometry(QRect(0, 0, 1080, 821));
    dockWidget->setWidget(dockWidgetContents);

    vboxLayout->addWidget(dockWidget);

	dockWidgetContents->setLayout(vdockLayout);
	vdockLayout->addWidget(stackedWidget);

    tabWidget = new QTabWidget(centralwidget);
    tabWidget->setObjectName(QString::fromUtf8("tabWidget"));
    tabWidget->setGeometry(QRect(0, 0, 190, 821));
    QSizePolicy sizePolicy1(static_cast<QSizePolicy::Policy>(5), static_cast<QSizePolicy::Policy>(5));
    sizePolicy1.setHorizontalStretch(0);
    sizePolicy1.setVerticalStretch(0);
    sizePolicy1.setHeightForWidth(tabWidget->sizePolicy().hasHeightForWidth());

    tabWidget->setSizePolicy(sizePolicy1);
    tabWidget->setMaximumSize(QSize(16777215, 16777215));
    tabWidget->setTabPosition(QTabWidget::West);
    tabWidget->setTabShape(QTabWidget::Triangular);
    tabWidget->setElideMode(Qt::ElideNone);

    tab_0 = new QWidget();
    tab_0->setObjectName(QString::fromUtf8("tab_0"));
    QFont font;
    font.setPointSize(14);
    vboxLayout0 = new QVBoxLayout(tab_0);
    vboxLayout0->setSpacing(6);
    vboxLayout0->setMargin(9);
    vboxLayout0->setAlignment(Qt::AlignTop);
    vboxLayout0->setObjectName(QString::fromUtf8("vboxLayout0"));

    pushButton[0] = new QPushButton(tab_0);
    pushButton[0]->setObjectName(QString::fromUtf8("pushButton_0"));
    pushButton[0]->setFont(font);
    pushButton[0]->setText(QApplication::translate("MainWindow", "PMS In Board", 0, QApplication::UnicodeUTF8));
    vboxLayout0->addWidget(pushButton[0]);

    pushButton[1] = new QPushButton(tab_0);
    pushButton[1]->setObjectName(QString::fromUtf8("pushButton_1"));
    pushButton[1]->setFont(font);
    pushButton[1]->setText(QApplication::translate("MainWindow", "PMS Out Board", 0, QApplication::UnicodeUTF8));
    vboxLayout0->addWidget(pushButton[1]);

    QSpacerItem *spacerItem;
    //spacerItem = new QSpacerItem(31, 61, QSizePolicy::Minimum, QSizePolicy::Expanding);
    spacerItem = new QSpacerItem(31, 61, QSizePolicy::Minimum, QSizePolicy::Fixed);
    vboxLayout0->addItem(spacerItem);

	//Add Code.
    archiveList = new QComboBox(tab_0);
    archiveList->setObjectName(QString::fromUtf8("archiveList"));
    vboxLayout0->addWidget(archiveList);

    Start_dateTime = new QDateTimeEdit(tab_0);
    Start_dateTime->setObjectName(QString::fromUtf8("Start_dateTime"));
    Start_dateTime->setDisplayFormat("yyyy/MM/dd hh:mm:ss");
    Start_dateTime->setDateTime(QDateTime(QDate(2012,5,29), QTime(12,0,0)));
    vboxLayout0->addWidget(Start_dateTime);

    End_dateTime = new QDateTimeEdit(tab_0);
    End_dateTime->setObjectName(QString::fromUtf8("End_dateTime"));
    End_dateTime->setDisplayFormat("yyyy/MM/dd hh:mm:ss");
    End_dateTime->setDateTime(QDateTime(QDate(2012,5,29), QTime(13,0,0)));
    vboxLayout0->addWidget(End_dateTime);

    RButton = new QPushButton(tab_0);
    RButton->setObjectName(QString::fromUtf8("RButton"));
    RButton->setText("OK");
	if(RButton!=0) connect(RButton, SIGNAL(clicked()), this, SLOT(getChannelValues()));
    //RButton->setGeometry(QRect(980, 20, 80, 27));
    vboxLayout0->addWidget(RButton);


    currentTimeLabel = new QLabel(tab_0);
    currentTimeLabel->setObjectName(QString::fromUtf8("currentTimeLabel"));
    currentTimeLabel->setText("Current Index Time");
    //currentTimeLabel->setGeometry(QRect(760, 7, 161, 21));
    vboxLayout0->addWidget(currentTimeLabel);

    timeSlider = new QSlider(tab_0);
    timeSlider->setObjectName(QString::fromUtf8("timeSlider"));
    //timeSlider->setGeometry(QRect(760, 24, 201, 16));
    timeSlider->setValue(-1);
    timeSlider->setOrientation(Qt::Horizontal);
	connect(timeSlider, SIGNAL(valueChanged(int)), this, SLOT(readValue(int)));
    vboxLayout0->addWidget(timeSlider);

	//--> Splitter
    splitter = new QSplitter(tab_0);
    splitter->setObjectName(QString::fromUtf8("splitter"));
    splitter->setOrientation(Qt::Horizontal);

    incButtonDouble = new QPushButton(splitter);
    incButtonDouble->setObjectName(QString::fromUtf8("incButtonDouble"));
    QSizePolicy sizePol(QSizePolicy::Fixed, QSizePolicy::Fixed);
    sizePol.setHeightForWidth(incButtonDouble->sizePolicy().hasHeightForWidth());
    incButtonDouble->setSizePolicy(sizePol);
    incButtonDouble->setText("<<");
	connect(incButtonDouble,SIGNAL(clicked()), this, SLOT(decDouble()));
    splitter->addWidget(incButtonDouble);

    incButton = new QPushButton(splitter);
    incButton->setObjectName(QString::fromUtf8("incButton"));
    sizePol.setHeightForWidth(incButton->sizePolicy().hasHeightForWidth());
    incButton->setSizePolicy(sizePol);
    incButton->setText("<");
	connect(incButton,SIGNAL(clicked()), this, SLOT(decrease()));
    splitter->addWidget(incButton);

    decButton = new QPushButton(splitter);
    decButton->setObjectName(QString::fromUtf8("decButton"));
    sizePol.setHeightForWidth(decButton->sizePolicy().hasHeightForWidth());
    decButton->setSizePolicy(sizePol);
    decButton->setText(">");
	connect(decButton,SIGNAL(clicked()), this, SLOT(increase()));
    splitter->addWidget(decButton);

    decButtonDouble = new QPushButton(splitter);
    decButtonDouble->setObjectName(QString::fromUtf8("decButtonDouble"));
    sizePol.setHeightForWidth(decButtonDouble->sizePolicy().hasHeightForWidth());
    decButtonDouble->setSizePolicy(sizePol);
    decButtonDouble->setText(">>");
	connect(decButtonDouble,SIGNAL(clicked()), this, SLOT(incDouble()));
    splitter->addWidget(decButtonDouble);

    vboxLayout0->addWidget(splitter);
	//<-- Splitter

    splitter2 = new QSplitter(tab_0);
    splitter2->setObjectName(QString::fromUtf8("splitter2"));
    splitter2->setOrientation(Qt::Horizontal);

    stopButton = new QPushButton(splitter2);
    stopButton->setObjectName(QString::fromUtf8("stopButton"));
    sizePol.setHeightForWidth(stopButton->sizePolicy().hasHeightForWidth());
    stopButton->setSizePolicy(sizePol);
    stopButton->setText("Stop");
	connect(stopButton,SIGNAL(clicked()), this, SLOT(timerStop()));
    splitter2->addWidget(stopButton);

    startButton = new QPushButton(splitter2);
    startButton->setObjectName(QString::fromUtf8("startButton"));
    sizePol.setHeightForWidth(startButton->sizePolicy().hasHeightForWidth());
    startButton->setSizePolicy(sizePol);
    startButton->setText("Run");
	connect(startButton,SIGNAL(clicked()), this, SLOT(timerRun()));
    splitter2->addWidget(startButton);

    vboxLayout0->addWidget(splitter2);

    tabWidget->addTab(tab_0, QApplication::translate("MainWindow", "PMS Panel", 0, QApplication::UnicodeUTF8));

    menubar = new QMenuBar(this);
    menubar->setObjectName(QString::fromUtf8("menubar"));
    menubar->setGeometry(QRect(0, 0, 1280, 30));
    menu_File = new QMenu(menubar);
    menu_File->setObjectName(QString::fromUtf8("menu_File"));
    menu_Util = new QMenu(menubar);
    menu_Util->setObjectName(QString::fromUtf8("menu_Util"));

	menu_Help = new QMenu(menubar);
	menu_Help->setObjectName(QString::fromUtf8("menu_Help"));
    setMenuBar(menubar);

    QLabel *slabel1 = new QLabel("Set your mouse on the dynamic value to read PVNAME.");
    slabel1->setAlignment(Qt::AlignHCenter);
    slabel1->setMinimumSize(slabel1->sizeHint());
    slabel1->setFrameStyle(QFrame::Panel | QFrame::Plain);

    QFrame *sframe = new QFrame();
    QVBoxLayout *svlayout = new QVBoxLayout(sframe);
    svlayout->setSpacing(1);
    svlayout->setMargin(2);

    statusBar()->addWidget(sframe,1);
    
    toolBar = new QToolBar(this);
    toolBar->setObjectName(QString::fromUtf8("toolBar"));
    QPalette palette;
    QBrush brush(QColor(108, 147, 255, 100));
    brush.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Active, QPalette::Base, brush);
    palette.setBrush(QPalette::Active, QPalette::AlternateBase, brush);
    QBrush brush1(QColor(44, 51, 91, 100));
    brush1.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Active, QPalette::Window, brush1);
    QBrush brush2(QColor(108, 147, 255, 100));
    brush2.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Inactive, QPalette::Base, brush2);
    QBrush brush3(QColor(44, 51, 91, 100));
    brush3.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Inactive, QPalette::Window, brush3);
    QBrush brush4(QColor(44, 51, 91, 100));
    brush4.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Disabled, QPalette::Base, brush4);
    QBrush brush5(QColor(44, 51, 91, 100));
    brush5.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Disabled, QPalette::Window, brush5);
    toolBar->setPalette(palette);
    toolBar->setOrientation(Qt::Horizontal);
    addToolBar(static_cast<Qt::ToolBarArea>(4), toolBar);

    menubar->addAction(menu_File->menuAction());
    menubar->addAction(menu_Util->menuAction());
	menubar->addSeparator();
    menubar->addAction(menu_Help->menuAction());


    menu_File->addAction(action_Exit);

    QSize size(1280, 1024);
    size = size.expandedTo(minimumSizeHint());
    resize(size);
    tabWidget->setCurrentIndex(0);
    QMetaObject::connectSlotsByName(this);

    msgframe = new QFrame(centralwidget);
    msgframe->setObjectName(QString::fromUtf8("msgframe"));
    QSizePolicy sizePolicy4(static_cast<QSizePolicy::Policy>(5), static_cast<QSizePolicy::Policy>(5));
    sizePolicy4.setHorizontalStretch(0);
    sizePolicy4.setVerticalStretch(0);
    msgframe->setGeometry(QRect(19, 820, 1255, 90));
    //msgframe->setSizePolicy(sizePolicy4);
    //msgframe->setGeometry(QRect(18, 880, 1254, 70));
    //msgframe->setMinimumSize(QSize(1164, 90));
    //msgframe->setFrameShape(QFrame::StyledPanel);
    //msgframe->setFrameShadow(QFrame::Raised);

	setCentralWidget(centralwidget);

	QObject::connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(setDefaultIndex(int))); 

	// Set Object Text.
	setWindowTitle(QApplication::translate("MainWindow", "PMS (Plant Monitoring System)", 0, QApplication::UnicodeUTF8));
    action_Exit->setText(QApplication::translate("MainWindow", "e&Xit", 0, QApplication::UnicodeUTF8));
    tabWidget->setTabText(tabWidget->indexOf(tab_0), QApplication::translate("MainWindow", "PMS Data Retrieval", 0, QApplication::UnicodeUTF8));
    menu_File->setTitle(QApplication::translate("MainWindow", "&File", 0, QApplication::UnicodeUTF8));
    menu_Util->setTitle(QApplication::translate("MainWindow", "&Util", 0, QApplication::UnicodeUTF8));
    menu_Help->setTitle(QApplication::translate("MainWindow", "&Help", 0, QApplication::UnicodeUTF8));

} // makeUI
InstrumentLine::InstrumentLine(QWidget* pParent)
  : PixmapWidget(pParent, __class_name)
  , m_bIsSelected(false)
{
	int h = Preferences::get_instance()->getPatternEditorGridHeight();
	setFixedSize(181, h);

	m_pNameLbl = new QLabel(this);
	m_pNameLbl->resize( 145, h );
	m_pNameLbl->move( 10, 1 );
	QFont nameFont;
	nameFont.setPointSize( 10 );
	nameFont.setBold( true );
	m_pNameLbl->setFont(nameFont);

	m_pMuteBtn = new ToggleButton(
			this,
			"/mixerPanel/btn_mute_on.png",
			"/mixerPanel/btn_mute_off.png",
			"/mixerPanel/btn_mute_off.png",
			QSize( 18, 13 )
	);
	m_pMuteBtn->move( 145, 5 );
	m_pMuteBtn->setPressed(false);
    m_pMuteBtn->setToolTip( trUtf8("Mute instrument") );
	connect(m_pMuteBtn, SIGNAL(clicked(Button*)), this, SLOT(muteClicked()));

	m_pSoloBtn = new ToggleButton(
			this,
			"/mixerPanel/btn_solo_on.png",
			"/mixerPanel/btn_solo_off.png",
			"/mixerPanel/btn_solo_off.png",
			QSize( 18, 13 )
	);
	m_pSoloBtn->move( 163, 5 );
	m_pSoloBtn->setPressed(false);
    m_pSoloBtn->setToolTip( trUtf8("Solo") );
	connect(m_pSoloBtn, SIGNAL(clicked(Button*)), this, SLOT(soloClicked()));



	// Popup menu
	m_pFunctionPopup = new QMenu( this );
	m_pFunctionPopup->addAction( trUtf8( "Clear notes" ), this, SLOT( functionClearNotes() ) );

	m_pFunctionPopupSub = new QMenu( trUtf8( "Fill notes ..." ), m_pFunctionPopup );
	m_pFunctionPopupSub->addAction( trUtf8( "Fill all notes" ), this, SLOT( functionFillAllNotes() ) );
	m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/2 notes" ), this, SLOT( functionFillEveryTwoNotes() ) );
	m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/3 notes" ), this, SLOT( functionFillEveryThreeNotes() ) );
	m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/4 notes" ), this, SLOT( functionFillEveryFourNotes() ) );
	m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/6 notes" ), this, SLOT( functionFillEverySixNotes() ) );
	m_pFunctionPopupSub->addAction( trUtf8( "Fill 1/8 notes" ), this, SLOT( functionFillEveryEightNotes() ) );
	m_pFunctionPopup->addMenu( m_pFunctionPopupSub );

	m_pFunctionPopup->addAction( trUtf8( "Randomize velocity" ), this, SLOT( functionRandomizeVelocity() ) );
	m_pFunctionPopup->addSeparator();

	m_pCopyPopupSub = new QMenu( trUtf8( "Copy notes ..." ), m_pFunctionPopup );
	m_pCopyPopupSub->addAction( trUtf8( "Only for this pattern" ), this, SLOT( functionCopyInstrumentPattern() ) );
	m_pCopyPopupSub->addAction( trUtf8( "For all patterns" ), this, SLOT( functionCopyAllInstrumentPatterns() ) );
	m_pFunctionPopup->addMenu( m_pCopyPopupSub );

	m_pPastePopupSub = new QMenu( trUtf8( "Paste notes ..." ), m_pFunctionPopup );
	m_pPastePopupSub->addAction( trUtf8( "Only for this pattern" ), this, SLOT( functionPasteInstrumentPattern() ) );
	m_pPastePopupSub->addAction( trUtf8( "For all patterns" ), this, SLOT( functionPasteAllInstrumentPatterns() ) );
	m_pFunctionPopup->addMenu( m_pPastePopupSub );

	m_pFunctionPopup->addSeparator();
	m_pFunctionPopup->addAction( trUtf8( "Delete instrument" ), this, SLOT( functionDeleteInstrument() ) );

	m_bIsSelected = true;
	setSelected(false);
}
Esempio n. 9
0
void Hruler::paintEvent(QPaintEvent *e)
{
	if (m_doc->isLoading())
		return;
	QString tx = "";
	double sc = m_view->scale();
	Scaling = sc;
	QFont ff = font();
	ff.setPointSize(6);
	setFont(ff);
	QPainter p;
	p.begin(this);
	p.setClipRect(e->rect());
	p.setFont(font());
	
	drawMarks(p);

	if (textEditMode)
	{
		int rectX1 = textPosToLocal(Extra);
		int rectX2 = textPosToLocal(ItemEndPos-ItemPos-RExtra);
		p.eraseRect(QRect(QPoint(rectX1, 1), QPoint(rectX2, 15)));
		p.drawLine(rectX1, 16, rectX2, 16);
		p.save();
		p.setRenderHints(QPainter::Antialiasing, true);
		if (Revers)
		{
			p.translate( textPosToLocal(0), 0);
			p.scale(-1, 1);
			p.translate( textPosToLocal(Extra) - textPosToLocal(ItemEndPos-ItemPos-RExtra), 0);
			p.translate(-textPosToLocal(0), 0);
		}
		for (int CurrCol = 0; CurrCol < Cols; ++CurrCol)
		{
			double ColWidth = (textWidth() - ColGap * (Cols - 1)) / Cols;
			double Pos = (ColWidth + ColGap) * CurrCol;
			double EndPos = Pos + ColWidth;
			drawTextMarks(Pos, EndPos, p);
			
			p.setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
			int xPos = textPosToLocal(Pos);
			p.drawLine(xPos, topline, xPos, bottomline);
			if (CurrCol == 0)
			{
				p.drawLine(xPos, 15, (xPos+4), 15);
				p.drawLine(xPos, topline, (xPos+4), topline);
			}
			
			p.setPen(QPen(Qt::blue, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
			
			xPos = textPosToLocal(Pos+First+Indent);
			QPolygon cr;
			cr.setPoints(3, xPos, midline, xPos+3, topline, xPos-3, topline);
			p.drawPolygon(cr);

			xPos = textPosToLocal(Pos+Indent);
			QPolygon cr2;
			cr2.setPoints(3, xPos, midline, xPos+3, bottomline, xPos-3, bottomline);
			p.drawPolygon(cr2);
			
			xPos = textPosToLocal(Pos+RMargin);
			QPolygon cr3;
			cr3.setPoints(3, xPos, topline, xPos, bottomline, xPos-3, midline);
			p.drawPolygon(cr3);

			if (TabValues.count() != 0)
			{
				p.setPen(QPen(Qt::black, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
				for (int yg = 0; yg < signed(TabValues.count()); yg++)
				{
					xPos = textPosToLocal(Pos+TabValues[yg].tabPosition);
					if (Pos+TabValues[yg].tabPosition < EndPos)
					{
						switch (static_cast<int>(TabValues[yg].tabType))
						{
							case 0:
								if (Revers)
								{
									p.save();
									p.translate(Pos + TabValues[yg].tabPosition,0);
									p.scale(-1,1);
									p.drawLine(0, tabline, 0, bottomline);
									p.drawLine(0, bottomline, 8, bottomline);
									p.restore();
								}
								else
								{
									p.drawLine(xPos, tabline, xPos, bottomline);
									p.drawLine(xPos, bottomline, xPos+8, bottomline);
								}
								break;
							case 1:
								if (Revers)
								{
									p.save();
									p.translate(Pos+TabValues[yg].tabPosition,0);
									p.scale(-1,1);
									p.drawLine(0, tabline, 0, bottomline);
									p.drawLine(0, bottomline, -8, bottomline);
									p.restore();
								}
								else
								{
									p.drawLine(xPos, tabline, xPos, bottomline);
									p.drawLine(xPos, bottomline, xPos-8, bottomline);
								}
								break;
							case 2:
							case 3:
								p.drawLine(xPos, tabline, xPos, bottomline);
								p.drawLine(xPos-4, bottomline, xPos+4, bottomline);
								p.drawLine(xPos+3, bottomline-3, xPos+2, bottomline-3);
								break;
							case 4:
								p.drawLine(xPos, tabline, xPos, bottomline);
								p.drawLine(xPos-4, bottomline, xPos+4, bottomline);
								break;
							default:
								break;
						}
					}
				}
			}
			
			p.setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
			xPos = textPosToLocal(EndPos);
			p.drawLine(xPos, topline, xPos, bottomline);
			if (CurrCol == Cols-1)
			{
				p.drawLine(xPos, bottomline, xPos-4 , bottomline);
				p.drawLine(xPos, topline, xPos-4, topline);
			}
		}
		p.restore();
	}
	if (drawMark && !Mpressed)
	{
		drawMarker(p);
	}
	p.end();
}
Esempio n. 10
0
/**
 * First Panel - Meta Info
 * All the usual MetaData are displayed and can be changed.
 **/
MetaPanel::MetaPanel( QWidget *parent,
                      intf_thread_t *_p_intf )
                      : QWidget( parent ), p_intf( _p_intf )
{
    QGridLayout *metaLayout = new QGridLayout( this );
    metaLayout->setVerticalSpacing( 0 );

    QFont smallFont = QApplication::font();
    smallFont.setPointSize( smallFont.pointSize() - 1 );
    smallFont.setBold( true );

    int line = 0; /* Counter for GridLayout */
    p_input = NULL;
    QLabel *label;

#define ADD_META( string, widget, col, colspan ) {                        \
    label = new QLabel( qtr( string ) ); label->setFont( smallFont );     \
    label->setContentsMargins( 3, 2, 0, 0 );                              \
    metaLayout->addWidget( label, line++, col, 1, colspan );              \
    widget = new QLineEdit;                                               \
    metaLayout->addWidget( widget, line, col, 1, colspan );               \
    CONNECT( widget, textEdited( QString ), this, enterEditMode() );      \
}

    /* Title, artist and album*/
    ADD_META( VLC_META_TITLE, title_text, 0, 10 ); line++;
    ADD_META( VLC_META_ARTIST, artist_text, 0, 10 ); line++;
    ADD_META( VLC_META_ALBUM, collection_text, 0, 7 );

    /* Date */
    label = new QLabel( qtr( VLC_META_DATE ) );
    label->setFont( smallFont ); label->setContentsMargins( 3, 2, 0, 0 );
    metaLayout->addWidget( label, line - 1, 7, 1, 2 );

    /* Date (Should be in years) */
    date_text = new QLineEdit;
    date_text->setAlignment( Qt::AlignRight );
    date_text->setInputMask("0000");
    date_text->setMaximumWidth( 140 );
    metaLayout->addWidget( date_text, line, 7, 1, -1 );
    line++;

    /* Genre Name */
    /* TODO List id3genres.h is not includable yet ? */
    ADD_META( VLC_META_GENRE, genre_text, 0, 7 );

    /* Number - on the same line */
    label = new QLabel( qtr( VLC_META_TRACK_NUMBER ) );
    label->setFont( smallFont ); label->setContentsMargins( 3, 2, 0, 0 );
    metaLayout->addWidget( label, line - 1, 7, 1, 3  );

    seqnum_text = new QLineEdit;
    seqnum_text->setMaximumWidth( 64 );
    seqnum_text->setAlignment( Qt::AlignRight );
    metaLayout->addWidget( seqnum_text, line, 7, 1, 1 );

    label = new QLabel( "/" ); label->setFont( smallFont );
    metaLayout->addWidget( label, line, 8, 1, 1 );

    seqtot_text = new QLineEdit;
    seqtot_text->setMaximumWidth( 64 );
    seqtot_text->setAlignment( Qt::AlignRight );
    metaLayout->addWidget( seqtot_text, line, 9, 1, 1 );
    line++;

    /* Rating - on the same line */
    /*
    metaLayout->addWidget( new QLabel( qtr( VLC_META_RATING ) ), line, 4, 1, 2 );
    rating_text = new QSpinBox; setSpinBounds( rating_text );
    metaLayout->addWidget( rating_text, line, 6, 1, 1 );
    */

    /* Now Playing - Useful for live feeds (HTTP, DVB, ETC...) */
    ADD_META( VLC_META_NOW_PLAYING, nowplaying_text, 0, 7 );
    nowplaying_text->setReadOnly( true ); line--;

    /* Language on the same line */
    ADD_META( VLC_META_LANGUAGE, language_text, 7, -1 ); line++;
    ADD_META( VLC_META_PUBLISHER, publisher_text, 0, 7 );

    fingerprintButton = new QPushButton( qtr("&Fingerprint") );
    fingerprintButton->setToolTip( qtr( "Find meta data using audio fingerprinting" ) );
    fingerprintButton->setVisible( false );
    metaLayout->addWidget( fingerprintButton, line, 7 , 3, -1 );
    CONNECT( fingerprintButton, clicked(), this, fingerprint() );

    line++;

    lblURL = new QLabel;
    lblURL->setOpenExternalLinks( true );
    lblURL->setTextFormat( Qt::RichText );
    lblURL->setMaximumWidth( 128 );
    metaLayout->addWidget( lblURL, line -1, 7, 1, -1 );

    ADD_META( VLC_META_COPYRIGHT, copyright_text, 0,  7 ); line++;

    /* ART_URL */
    art_cover = new CoverArtLabel( this, p_intf );
    metaLayout->addWidget( art_cover, line, 7, 6, 3, Qt::AlignLeft );

    ADD_META( VLC_META_ENCODED_BY, encodedby_text, 0, 7 ); line++;

    label = new QLabel( qtr( N_("Comments") ) ); label->setFont( smallFont );
    label->setContentsMargins( 3, 2, 0, 0 );
    metaLayout->addWidget( label, line++, 0, 1, 7 );
    description_text = new QTextEdit;
    description_text->setAcceptRichText( false );
    metaLayout->addWidget( description_text, line, 0, 1, 7 );
    CONNECT( description_text, textChanged(), this, enterEditMode() );
    line++;

    /* VLC_META_SETTING: Useless */
    /* ADD_META( TRACKID )  Useless ? */
    /* ADD_URI - Do not show it, done outside */

    metaLayout->setColumnStretch( 1, 20 );
    metaLayout->setColumnMinimumWidth ( 1, 80 );
    metaLayout->setRowStretch( line, 10 );
#undef ADD_META

    CONNECT( seqnum_text, textEdited( QString ), this, enterEditMode() );
    CONNECT( seqtot_text, textEdited( QString ), this, enterEditMode() );

    CONNECT( date_text, textEdited( QString ), this, enterEditMode() );
//    CONNECT( THEMIM->getIM(), artChanged( QString ), this, enterEditMode() );
/*    CONNECT( rating_text, valueChanged( QString ), this, enterEditMode( QString ) );*/

    /* We are not yet in Edit Mode */
    b_inEditMode = false;
}
Esempio n. 11
0
MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MainWindow)
{
  ui->setupUi(this);

  actionNew = actionSave = actionDelete = actionExit = NULL;
  actionScan = actionMirror = actionMake = NULL;
  actionPrint = NULL;
  vcb = NULL;
  grid = NULL;
  printpreview = NULL;
  previewTemplate = NULL;
  previewCell = NULL;

  //qDebug() << db.drivers();
  db = QSqlDatabase::addDatabase("QMYSQL");

  db.setHostName("localhost");
  db.setDatabaseName("crossword");
  db.setUserName("taras");
  db.setPassword("su112per");
  bool ok = db.open();

  if (!ok)
    {
      qDebug() << db.lastError().text();

      QMessageBox msgBox;
      msgBox.setText(tr("Database open error!"));
      msgBox.exec();
    }

  grid = new tableTemplateWidget();

  if (grid)
    {
      // File menu
      actionNew = new QAction(QIcon(":/icons/new16.png"), QString(tr("New")), this);
      connect(actionNew, SIGNAL(triggered()), grid, SLOT(createNew()));

      actionSave = new QAction(QIcon(":/icons/save16.png"), QString(tr("Save")), this);
      connect(actionSave, SIGNAL(triggered()), grid, SLOT(saveToDB()));

      actionDelete = new QAction(QIcon(":/icons/delete16.png"), QString(tr("Delete")), this);
      connect(actionDelete, SIGNAL(triggered()), grid, SLOT(deleteTemplate()));

      actionPrint = new QAction(QIcon(":/icons/preview16.png"), QString(tr("Print")), this);
      connect(actionPrint, SIGNAL(triggered(bool)), this, SLOT(printCrossword()));

      actionExit = new QAction(QIcon(":/icons/x16.png"), QString(tr("Exit")), this);
      connect(actionExit, SIGNAL(triggered()), this, SLOT(exit()));


      QMenu *menuFile = new QMenu(tr("File"), this);
      ui->menuBar->addMenu(menuFile);
      menuFile->addAction(actionNew);
      menuFile->addAction(actionSave);
      menuFile->addAction(actionDelete);
      menuFile->addAction(actionPrint);
      menuFile->addSeparator();
      menuFile->addAction(actionExit);

      ui->mainToolBar->addAction(actionNew);
      ui->mainToolBar->addAction(actionSave);
      ui->mainToolBar->addAction(actionDelete);
      ui->mainToolBar->addAction(actionPrint);

      // Edit menu
      ui->mainToolBar->addSeparator();

      QMenu *menuEdit = new QMenu(tr("Edit"), this);
      ui->menuBar->addMenu(menuEdit);
      //  actionScan = new QAction(QIcon(":/icons/search16.png"), QString(tr("Scan")), this);
      //  connect(actionScan, SIGNAL(triggered()), grid, SLOT(scanTemplate()));
      //  ui->mainToolBar->addAction(actionScan);
      //  menuEdit->addAction(actionScan);

      actionMirror = new QAction(QIcon(":/icons/favorites16.png"), QString(tr("Mirror")), this);
      actionMirror->setCheckable(true);
      actionMirror->setChecked(true);
      connect(actionMirror, SIGNAL(toggled(bool)), grid, SLOT(setSymetricalMode(bool)));
      ui->mainToolBar->addAction(actionMirror);
      menuEdit->addAction(actionMirror);

      actionMake = new QAction(QIcon(":/icons/make.png"), QString(tr("Build crossword")), this);
      actionMake->setCheckable(true);
      connect(actionMake, SIGNAL(toggled(bool)), grid, SLOT(makeCrossword()));
      ui->mainToolBar->addAction(actionMake);
      menuEdit->addAction(actionMake);

      vcb = new QComboBox(this);
      if (vcb)
      {
          QFont font;
          font.setPointSize(10);
          //font.setBold(true);

	  vcb->setFixedSize(350, 32);
	  vcb->setMaxVisibleItems(20);
	  vcb->setFont(font);

	  vcb->addItem("УСЕ (Універсальний словник-енциклопедія)", QVariant(29));
	  vcb->addItem("Орфографічний словник української мови", QVariant(35));
	  vcb->addItem("Фразеологічний словник української мови", QVariant(49));
	  vcb->addItem("Словник синонімів Полюги", QVariant(31));
	  vcb->addItem("Словник синонімів Караванського", QVariant(41));
	  vcb->addItem("Словник іншомовних слів", QVariant(36));
	  vcb->addItem("Словник іншомовних слів Мельничука", QVariant(42));
	  vcb->addItem("Словник англіцизмів", QVariant(46));
	  vcb->addItem("Eкономічна енциклопедія", QVariant(38));
	  vcb->addItem("Словник мови Стуса", QVariant(27));
	  vcb->addItem("Словник іншомовних соціокультурних термінів", QVariant(39));
	  vcb->addItem("Енциклопедія політичної думки", QVariant(40));
	  vcb->addItem("Словник церковно-обрядової термінології", QVariant(43));
	  vcb->addItem("Архітектура і монументальне мистецтво", QVariant(44));
	  vcb->addItem("Словник-антисуржик", QVariant(45));
	  vcb->addItem("Словник термінів, уживаних у чинному Законодавстві України", QVariant(48));
	  vcb->addItem("Словник бюджетної термінології", QVariant(50));
	  vcb->addItem("Термінологічний словник з економіки праці", QVariant(51));
	  vcb->addItem("Глосарій термінів Фондового ринку", QVariant(52));
	  vcb->addItem("Моделювання економіки", QVariant(53));
	  vcb->addItem("Власні імена людей", QVariant(54));
	  vcb->addItem("Словар українського сленгу", QVariant(57));
	  vcb->addItem("Музичні терміни", QVariant(58));
	  vcb->addItem("Тлумачний словник з інформатики та інформаційних систем для економістів", QVariant(59));
	  vcb->addItem("Управління якістю", QVariant(61));

	  ui->mainToolBar->insertWidget(actionMake, vcb);
	  connect(vcb, SIGNAL(currentIndexChanged(int)), this, SLOT(setVocabulary(int)));
	  setVocabulary(vcb->currentIndex());
      }

      //grid->setStyleSheet(readStyleSheet("/home/taras/Projects/qtCrossword/qribbon.qss"));
      grid->setSymetricalMode(true);
      ui->horizontalLayout->addWidget(grid);
      ui->listWidget->setTemplateGrid(grid);

      grid->setStatusBar(ui->statusBar);
      grid->setDB(&db);

      connect(grid, SIGNAL(maked()), this, SLOT(makedCrossword()));
    }

  previewTemplate = new PreviewTemplateDelegate();

  if (previewTemplate)
    ui->listWidget->setItemDelegate(previewTemplate);

  loadListPreview();

  previewCell = new PreviewCellDelegate();
  ui->tableView->setItemDelegate(previewCell);
  ui->tableView->setModel( grid->model() );
  ui->tableView->horizontalHeader()->setDefaultSectionSize(40);
  ui->tableView->verticalHeader()->setDefaultSectionSize(40);
  ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);

  printer = new QPrinter();

  if (printer)
    {
      printer->setPaperSize(QPrinter::A4);
      printer->setOrientation(QPrinter::Portrait);
      printer->setFullPage(true);
      printer->setPageMargins(20.0, 15.0, 15.0, 15.0, QPrinter::Millimeter);
      printer->newPage();

      prnPreview = new QPrintPreviewDialog(printer, this);
      connect(prnPreview, SIGNAL(paintRequested(QPrinter*)), grid, SLOT(printPreview(QPrinter*)));
      ui->horizontalLayout_8->addWidget(prnPreview);

      printpreview = new QPrintPreviewWidget(printer, this);

      if (printpreview)
        {
          printpreview->fitInView();
          printpreview->show();

          ui->horizontalLayout_8->addWidget(printpreview);
          connect(printpreview, SIGNAL(paintRequested(QPrinter*)), grid, SLOT(printPreview(QPrinter*)));
        }
    }
}
Esempio n. 12
0
/**
 * Returns the data to display at the given index and the role
 * @param index the index of the item to display
 * @param role the role this data will be used for
 */
QVariant AlbumModel::data(const QModelIndex& index, int role ) const
{
  if (!index.isValid())
    return QVariant();
  if (role == Qt::DisplayRole)
  {
    MTP::GenericObject* temp = (MTP::GenericObject*) index.internalPointer();
    if (temp->Type() == MtpAlbum && index.column() == 0)
    {
        MTP::Album* tempAlbum = (MTP::Album*)temp;
        QString first = QString::fromUtf8(tempAlbum->Name());
        return QVariant(first);
    }
    else if (temp->Type() == MtpTrack && index.column() == 0)
    {
        MTP::Track* tempTrack = (MTP::Track*)temp;
        QString temp = QString::fromUtf8(tempTrack->Name());
        return QVariant(temp);
    }
    return QVariant();
  }
  if (role == Qt::DecorationRole)
  {
    MTP::GenericObject* temp = (MTP::GenericObject*) index.internalPointer();
    if (temp->Type() == MtpAlbum && index.column() == 0)
    {
      MTP::Album* tempAlbum = (MTP::Album*)temp;
      LIBMTP_filesampledata_t sample = tempAlbum->SampleData();
      if (sample.size > 0 && sample.data )
        /*&&  interesting bug on some devices
          (sample.filetype == LIBMTP_FILETYPE_JPEG ||
          sample.filetype == LIBMTP_FILETYPE_JPX ||
          sample.filetype == LIBMTP_FILETYPE_JP2))
          */
      {
        QPixmap ret;
        ret.loadFromData( (const uchar*)sample.data, sample.size);
        //qDebug() << "album decoration found:" << sample.filetype  << " with size: " << sample.size;

        //TODO uncomment when CommandLineOpts is moved to singleton
        //qDebug()  << "Actual sample found in simulate mode!";
        return ret.scaledToWidth(24, Qt::SmoothTransformation);
      }
      else
      {
        QPixmap ret("pixmaps/AlbumIcon.png");
        return ret.scaledToWidth(24, Qt::SmoothTransformation);
      }
    }

    else if (temp->Type() == MtpTrack && index.column() == 0)
    {
        return QIcon(QPixmap (":/pixmaps/Track.png"));
    }
    else
      return QVariant();
  }
  if (role == Qt::SizeHintRole)
  {
    MTP::GenericObject* temp = (MTP::GenericObject*) index.internalPointer();
    if (temp->Type() == MtpAlbum && index.column() == 0)
      return QSize(28, 28);
  }
  if (role == Qt::FontRole)
  {
    MTP::GenericObject* temp = (MTP::GenericObject*) index.internalPointer();
    //Its an album
    if (temp->Type() == MtpAlbum && index.column() == 0)
    {
      QFont temp;
      temp.setBold(true);
      temp.setPointSize(8);
      return temp;
    }
  }
  return QVariant();
}
Esempio n. 13
0
// gpSummaryTab
bool gpSummaryTab::Init(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView, quint64 timelineStart, quint64 timelineEnd)
{
    m_pTraceView = pSessionView;
    m_pSessionDataContainer = pDataContainer;
    if (m_callType == API_CALL)
    {
        m_pSummaryTable = new gpCPUTraceSummaryTable(pDataContainer, pSessionView, m_timelineAbsoluteStart);
    }
    else if (m_callType == GPU_CALL)
    {
        m_pSummaryTable = new gpGPUTraceSummaryTable(pDataContainer, pSessionView, m_timelineAbsoluteStart);
    }
    else
    {
        m_pSummaryTable = new gpCommandListSummaryTable(pDataContainer, pSessionView, m_timelineAbsoluteStart);
    }
    bool rc = m_pSummaryTable->Init();
    if (rc == true)
    {
        m_pTop20Table = new acListCtrl(this);

        m_pTop20Caption = new QLabel(this);

        QHBoxLayout* pHLayout = new QHBoxLayout;
        QVBoxLayout* pLeftVLayout = new QVBoxLayout;
        QHBoxLayout* pLeftHLayout = new QHBoxLayout;
        QVBoxLayout* pRightVLayout = new QVBoxLayout;
        QSplitter* pVMainSplitter = new QSplitter(Qt::Horizontal);

        // set the margins to all layout to zero
        pHLayout->setContentsMargins(0, 0, 0, 0);
        pLeftVLayout->setContentsMargins(0, 0, 0, 0);
        pLeftHLayout->setContentsMargins(0, 0, 0, 0);
        pRightVLayout->setContentsMargins(0, 0, 0, 0);

        QWidget* pWidgetLeft = new QWidget;
        QWidget* pWidgetRight = new QWidget;

        m_pChkboxUseScope = new QCheckBox(GPU_STR_Use_Scope_Summary);

        QString styleSheetStr = QString("QDialog{border:1px solid gray;}");
        pLeftHLayout->addWidget(m_pChkboxUseScope, 0, Qt::AlignHCenter);
        pLeftVLayout->addLayout(pLeftHLayout);
        pWidgetLeft->setLayout(pLeftVLayout);
        pWidgetLeft->setStyleSheet(styleSheetStr);

        m_pSummaryTable->resizeColumnsToContents();
        pLeftVLayout->addWidget(m_pSummaryTable);
        m_pSummaryTable->SetSelectionBackgroundColor(acQAMD_CYAN_SELECTION_BKG_COLOUR);

        pLeftVLayout->setSpacing(0);
        pLeftVLayout->setMargin(1);

        QFont qFont = m_pTop20Caption->font();
        qFont.setBold(true);
        qFont.setPointSize(10);
        m_pTop20Caption->setFont(qFont);

        pRightVLayout->addWidget(m_pTop20Caption);
        QStringList columnCaptions;
        columnCaptions << "#";

        if (m_callType == API_CALL)
        {
            columnCaptions << GP_STR_SummaryTop20TableColumnThreadId;
        }

        columnCaptions << GP_STR_SummaryTop20TableColumnCallIndex;
        columnCaptions << GP_STR_SummaryTop20TableColumnTime;
        m_pTop20Table->initHeaders(columnCaptions, false);
        m_pTop20Table->setContextMenuPolicy(Qt::NoContextMenu);
        m_pTop20Table->resizeColumnsToContents();
        m_pTop20Table->setShowGrid(true);
        pRightVLayout->addWidget(m_pTop20Table);
        pRightVLayout->setSpacing(1);
        pRightVLayout->setMargin(1);
        pWidgetRight->setLayout(pRightVLayout);
        pWidgetRight->setStyleSheet(styleSheetStr);


        pVMainSplitter->addWidget(pWidgetLeft);
        pVMainSplitter->addWidget(pWidgetRight);

        int widgetWidth = geometry().right() - geometry().left();
        QList<int> sizes;
        sizes << (int)(widgetWidth * 0.75);
        sizes << (int)(widgetWidth * 0.25);
        pVMainSplitter->setSizes(sizes);
        pHLayout->addWidget(pVMainSplitter);

        setLayout(pHLayout);

        SetTimelineScope(false, timelineStart, timelineEnd);

        rc = connect(m_pChkboxUseScope, SIGNAL(toggled(bool)), this, SLOT(OnUseTimelineSelectionScopeChanged(bool)));
        GT_ASSERT(rc);
        rc = connect(m_pSummaryTable, SIGNAL(itemSelectionChanged()), this, SLOT(OnSummaryTableSelectionChanged()));
        GT_ASSERT(rc);
        rc = connect(m_pSummaryTable, SIGNAL(cellClicked(int, int)), this, SLOT(OnSummaryTableCellClicked(int, int)));
        GT_ASSERT(rc);
        rc = connect(m_pSummaryTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(OnSummaryTableCellDoubleClicked(int, int)));
        GT_ASSERT(rc);
        rc = connect(m_pTop20Table, SIGNAL(cellClicked(int, int)), this, SLOT(OnTop20TableCellClicked(int, int)));
        GT_ASSERT(rc);
        rc = connect(m_pTop20Table, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(OnTop20TableCellDoubleClicked(int, int)));
        GT_ASSERT(rc);

        m_pSummaryTable->selectRow(0);
        OnSummaryTableSelectionChanged(); // NZ for some reason the signal isn't enough
    }
Esempio n. 14
0
void ZGui::CreateWindow ( QWidget* parent )
{
  setMainWidgetTitle ( "zCleaner" );
  ZWidget *myWidget = new ZWidget ( this, NULL, 0, ( ZSkinService::WidgetClsID ) 40 );
  QFont f ( qApp->font() );
  f.setPointSize ( 10 );
  myWidget->setFont ( f );

  QVBoxLayout *myVBoxLayout = new QVBoxLayout ( myWidget, 0 );
  //*****************************
  //*** add elements here
  QLabel *myLabel = new QLabel ( QString ( "<qt><font size=\"+1\">zCleaner</font><br>"
                                 "<font size=\"-1\">Simple antivirus for Z6</font></qt>" ), myWidget );
  myVBoxLayout->addWidget ( myLabel, 0 );
  myLabel->setIndent ( 5 );
  myLabel->setAutoResize ( true );


  scrollPanel = new ZScrollPanel ( myWidget, NULL, 0, ( ZSkinService::WidgetClsID ) 0 );
  scrollPanel->resize ( 240, 320 );
   //-----------------------------------------------------------------------------------
  modo=new ZComboBox(this,"ZComboBox",true);//declaro los combobox
  lugar=new ZComboBox(this,"ZComboBox",true);
  modo->insertItem("Clean", 0 );
  modo->insertItem("AV", 1 );	
  //modo->insertItem("Picture/Video", 2 );  
  scrollPanel->addChild(modo , 100 , 5);//agrego el combobox de las apps al escritorio

  lab1 = new ZLabel("Mode" , this, "ZLabel", 0, (ZSkinService::WidgetClsID)4);
  lab1->setPreferredWidth(240);
  lab1->setAutoResize(true );
  
  scrollPanel->addChild(lab1 , 10 , 8);//agrego el label al menu
  
  lugar->insertItem("SD",0);
  lugar->insertItem("Phone",1);
  lugar->insertItem("SD/Phone",2);

  scrollPanel->addChild(lugar , 100 , 55);//agrego el propiestario al escritorio
  lab2  = new ZLabel("Location" , this, "ZLabel", 0, (ZSkinService::WidgetClsID)4);
  lab2->setPreferredWidth(240);
  lab2->setAutoResize(true );
  
  scrollPanel->addChild(lab2 , 10 , 58);//agrego el label al menu
  myVBoxLayout->addWidget ( scrollPanel, 0 );


  //*****************************
  setContentWidget ( myWidget );
  //************** softkeys and menus **************************
  ZSoftKey *softKey = new ZSoftKey ( NULL , this , this );
  QPixmap* pm  = new QPixmap();
  
  QRect rect, rect2, rect3, rect4;

  ZOptionsMenu* agre = new ZOptionsMenu ( rect3, softKey, NULL, 0, ( ZSkinService::WidgetClsID ) 2 );
  //pm->load(getProgramDir() + "img/about.png");
  agre->insertItem ( QString ( " ASK" ), NULL, NULL, true, 0, 0 );
  agre->insertItem ( QString ( " DELETE" ), NULL, NULL, true, 1, 1 );
  agre->connectItem ( 0, this, SLOT ( agregarTipoASK() ) );
  agre->connectItem ( 1, this, SLOT ( agregarTipoDELETE() ) );

  ZOptionsMenu* borr = new ZOptionsMenu ( rect4, softKey, NULL, 0, ( ZSkinService::WidgetClsID ) 2 );
  borr->insertItem ( QString ( " ASK" ), NULL, NULL, true, 0, 0 );
  borr->insertItem ( QString ( " DELETE" ), NULL, NULL, true, 1, 1 );
  borr->connectItem ( 0, this, SLOT ( eliminarTipoASK() ) );

  ZOptionsMenu* data = new ZOptionsMenu ( rect2, softKey, NULL, 0, ( ZSkinService::WidgetClsID ) 2 );
  pm->load(getProgramDir() + "img/add.png");
  data->insertItem ( QString ( " Add type" ), agre, pm, true, 0, 0 );
  pm->load(getProgramDir() + "img/remove.png");
  data->insertItem ( QString ( " Remove type" ), borr, pm, true, 1, 1 );

  
  ZOptionsMenu* menu = new ZOptionsMenu ( rect, softKey, NULL, 0, ( ZSkinService::WidgetClsID ) 2 );
  pm->load(getProgramDir() + "img/about.png");
  menu->insertItem ( QString ( " About" ), NULL, pm, true, 0, 0 );
  menu->insertSeparator(1, 1); 
  pm->load(getProgramDir() + "img/white.png");
  menu->insertItem ( QString ( " Clean" ), NULL, pm, true, 2, 2 );
  pm->load(getProgramDir() + "img/properties.png");
  menu->insertItem ( QString ( " Database" ), data, pm, true, 3, 3 );
  pm->load(getProgramDir() + "img/edit.png");
  menu->insertItem ( QString ( " Save delete files list" ), NULL, pm, true, 4, 4 );
  menu->insertSeparator(5, 5); 
  pm->load(getProgramDir() + "img/exit.png");
  menu->insertItem ( QString ( " Exit" ), NULL, pm, true, 6, 6 );

  menu->connectItem ( 6, qApp, SLOT ( quit() ) );
  menu->connectItem ( 2, this, SLOT ( ejecutar() ) );
  menu->connectItem ( 0, this, SLOT ( about() ) );
  menu->connectItem ( 4, this, SLOT ( verEliminados() ) );

  softKey->setOptMenu ( ZSoftKey::LEFT, menu );
  softKey->setText ( ZSoftKey::LEFT, "Menu", ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setText ( ZSoftKey::RIGHT, "Exit", ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setClickedSlot ( ZSoftKey::RIGHT, qApp, SLOT ( quit() ) ); 
  setSoftKey ( softKey );


}
Esempio n. 15
0
void CustomizeThemeDialog::setupActions()
{
	SettingsPrivate *settingsPrivate = SettingsPrivate::instance();

	// Select button theme and size
	connect(themeComboBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), this, &CustomizeThemeDialog::setThemeNameAndDialogButtons);
	connect(customizeThemeCheckBox, &QCheckBox::toggled, this, [=](bool b) {
		settingsPrivate->setButtonThemeCustomized(b);
		if (!b) {
			// Restore all buttons when unchecked
			for (QCheckBox *button : customizeButtonsScrollArea->findChildren<QCheckBox*>()) {
				if (!button->isChecked()) {
					button->toggle();
				}
			}
			for (QPushButton *pushButton : customizeButtonsScrollArea->findChildren<QPushButton*>()) {
				settingsPrivate->setCustomIcon(pushButton->objectName() + "Button", "");
			}
		}
	});
	Settings *settings = Settings::instance();
	connect(sizeButtonsSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), settings, &Settings::setButtonsSize);

	// Hide buttons or not
	QList<QCheckBox*> mediaPlayerButtons = buttonsListBox->findChildren<QCheckBox*>();
	for (QCheckBox *mediaPlayerButton : mediaPlayerButtons) {
		connect(mediaPlayerButton, &QCheckBox::toggled, this, [=](bool value) {
			settings->setMediaButtonVisible(mediaPlayerButton->objectName().replace("CheckBox", "Button"), value);
		});
	}

	// Connect a file dialog to every button if one wants to customize everything
	for (QPushButton *pushButton : customizeButtonsScrollArea->findChildren<QPushButton*>()) {
		connect(pushButton, &QPushButton::clicked, this, &CustomizeThemeDialog::openChooseIconDialog);
	}

	// Extended Search Area
	connect(radioButtonShowExtendedSearch, &QRadioButton::toggled, settingsPrivate, &SettingsPrivate::setExtendedSearchVisible);

	// Volume bar
	connect(radioButtonShowVolume, &QRadioButton::toggled, settings, &Settings::setVolumeBarTextAlwaysVisible);
	connect(spinBoxHideVolumeLabel, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), settingsPrivate, &SettingsPrivate::setVolumeBarHideAfter);

	// Fonts
	connect(fontComboBoxPlaylist, &QFontComboBox::currentFontChanged, [=](const QFont &font) {
		settingsPrivate->setFont(SettingsPrivate::FF_Playlist, font);
		this->fade();
	});
	connect(fontComboBoxLibrary, &QFontComboBox::currentFontChanged, [=](const QFont &font) {
		settingsPrivate->setFont(SettingsPrivate::FF_Library, font);
		this->fade();
	});
	connect(fontComboBoxMenus, &QFontComboBox::currentFontChanged, [=](const QFont &font) {
		settingsPrivate->setFont(SettingsPrivate::FF_Menu, font);
		this->fade();
	});

	// And fonts size
	connect(spinBoxPlaylist, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int i) {
		settingsPrivate->setFontPointSize(SettingsPrivate::FF_Playlist, i);
		this->fade();
	});
	connect(spinBoxLibrary, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int i) {
		settingsPrivate->setFontPointSize(SettingsPrivate::FF_Library, i);
		QFont lowerFont = settingsPrivate->font(SettingsPrivate::FF_Library);
		lowerFont.setPointSize(lowerFont.pointSizeF() * 0.7);
		this->fade();
	});
	connect(spinBoxMenus, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int i) {
		settingsPrivate->setFontPointSize(SettingsPrivate::FF_Menu, i);
		this->fade();
	});

	// Timer
	connect(_timer, &QTimer::timeout, [=]() { this->animate(0.5, 1.0); });

	// Colors
	connect(enableAlternateBGRadioButton, &QRadioButton::toggled, settingsPrivate, &SettingsPrivate::setColorsAlternateBG);
	for (QToolButton *b : groupBoxCustomColors->findChildren<QToolButton*>()) {
		connect(b, &QToolButton::clicked, this, &CustomizeThemeDialog::showColorDialog);
	}
	connect(enableCustomColorsRadioButton, &QCheckBox::toggled, this, [=](bool b) {
		settingsPrivate->setCustomColors(b);
		this->toggleCustomColors(b);
	});
	connect(enableCustomTextColorsRadioButton, &QCheckBox::toggled, this, [=](bool b) {
		settingsPrivate->setCustomTextColorOverride(b);
		this->toggleCustomTextColors(b);
	});

	// Change cover size
	connect(spinBoxCoverSizeLibraryTree, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int cs) {
		settings->setCoverSizeLibraryTree(cs);
		this->fade();
	});

	// Change cover size
	connect(spinBoxCoverSizeUniqueLibrary, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int cs) {
		settings->setCoverSizeLibraryTree(cs);
		this->fade();
	});

	// Change big cover opacity
	connect(radioButtonEnableBigCover, &QRadioButton::toggled, [=](bool b) {
		qDebug() << Q_FUNC_INFO;
		settings->setCoverBelowTracksEnabled(b);
		labelBigCoverOpacity->setEnabled(b);
		spinBoxBigCoverOpacity->setEnabled(b);
		this->fade();
	});
	connect(spinBoxBigCoverOpacity, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int v) {
		settings->setCoverBelowTracksOpacity(v);
		this->fade();
	});

	// Filter library
	connect(radioButtonEnableArticles, &QRadioButton::toggled, this, [=](bool b) {
		settingsPrivate->setIsLibraryFilteredByArticles(b);
		// Don't reorder the library if one hasn't typed an article yet
		if (!settingsPrivate->libraryFilteredByArticles().isEmpty()) {
			/// FIXME
			//_mainWindow->library->model()->rebuildSeparators();
		}
	});
	connect(articlesLineEdit, &CustomizeThemeTagLineEdit::taglistHasChanged, this, [=](const QStringList &articles) {
		settingsPrivate->setLibraryFilteredByArticles(articles);
		/// FIXME
		//_mainWindow->library->model()->rebuildSeparators();
	});
	connect(radioButtonEnableReorderArtistsArticle, &QRadioButton::toggled, this, [=](bool b) {
		settingsPrivate->setReorderArtistsArticle(b);
		this->fade();
		/// FIXME
		//_mainWindow->library->viewport()->repaint();
	});

	// Tabs
	connect(radioButtonTabsRect, &QRadioButton::toggled, [=](bool b) {
		settingsPrivate->setTabsRect(b);
		this->fade();
		/// FIXME
		//_mainWindow->tabPlaylists->tabBar()->update();
		//_mainWindow->tabPlaylists->cornerWidget(Qt::TopRightCorner)->update();
	});
	connect(overlapTabsSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int v) {
		settingsPrivate->setTabsOverlappingLength(v);
		this->fade();
		/// FIXME
		//_mainWindow->tabPlaylists->tabBar()->update();
	});

	// Star delegates
	connect(radioButtonEnableStarDelegate, &QRadioButton::toggled, this, [=](bool b) {
		settings->setStarsInLibrary(b);
		labelLibraryDelegates->setEnabled(b);
		radioButtonShowNeverScoredTracks->setEnabled(b);
		radioButtonHideNeverScoredTracks->setEnabled(b);
	});

	connect(radioButtonShowNeverScoredTracks, &QRadioButton::toggled, settings, &Settings::setShowNeverScored);
}
Esempio n. 16
0
void CounterInterface::input()
{
    lItens->setStyleSheet("background-color: qlineargradient(spread:pad, x1:0.498,"
                          "y1:0, x2:0.494636, y2:1, stop:0 rgba(255, 255, 255, 210),"
                          "stop:0.982955 rgba(255, 255, 255, 170));"
                          "border-radius: 5px;border: 1px solid rgba(255,255,255,255);");

    pbSaveOrdered->setObjectName("pbSaveOrdered");
    pbSaveOrdered->setStyleSheet(this->styleSheet());
    pbSaveOrdered->setText(tr("Salvar"));
    pbSaveOrdered->setFont(this->font());
    pbSaveOrdered->setCursor(Qt::PointingHandCursor);

    pbRemoveItem->setObjectName("pbRemoveItem");
    pbRemoveItem->setStyleSheet(this->styleSheet());
    pbRemoveItem->setText(tr("Remover"));
    pbRemoveItem->setFont(this->font());
    pbRemoveItem->setCursor(Qt::PointingHandCursor);

    pbClearOrdered->setObjectName("pbClearOrdered");
    pbClearOrdered->setStyleSheet(this->styleSheet());
    pbClearOrdered->setText(tr("Limpar"));
    pbClearOrdered->setFont(this->font());
    pbClearOrdered->setCursor(Qt::PointingHandCursor);

    pbCancelOrdered->setObjectName("pbCancelOrdered");
    pbCancelOrdered->setStyleSheet(this->styleSheet());
    pbCancelOrdered->setText(tr("Cancelar"));
    pbCancelOrdered->setFont(this->font());
    pbCancelOrdered->setCursor(Qt::PointingHandCursor);

    pbConfirmProduct->setObjectName("pbConfirmProduct");
    pbConfirmProduct->setStyleSheet(this->styleSheet());
    pbConfirmProduct->setFont(this->font());
    pbConfirmProduct->setText(tr("Confirmar"));
    pbConfirmProduct->setCursor(Qt::PointingHandCursor);

    pbLeaveProduct->setObjectName("pbLeaveProduct");
    pbLeaveProduct->setStyleSheet(this->styleSheet());
    pbLeaveProduct->setFont(this->font());
    pbLeaveProduct->setText(tr("Limpar"));
    pbLeaveProduct->setCursor(Qt::PointingHandCursor);

    productPreview->setStyleSheet("background-color: rgba(0,0,0,0);"
                                  "color: rgba(255,255,255,240);");

    lPizza->setImage(":/treatment/icopizza");
    lPizza->setHover(":/treatment/icopizza-hover");

    sbAmount->setPrefix(tr("Quant "));
    sbAmount->setFont(this->font());
    sbAmount->setMinimum(1);
    sbAmount->setValue(1);
    sbAmount->setMaximum(99999);

    DSBValueProduct->setPrefix(tr("R$ "));
    DSBValueProduct->setMaximum(9999999);

    lProductNotes->setPixmap(QPixmap(":/treatment/field-notes-Background"));
    lTextNotesProduct->setText(tr("Anotações"));
    lTextNotesProduct->setFont(this->font());
    lTextNotesProduct->setAlignment(Qt::AlignHCenter);
    lTextNotesProduct->setStyleSheet("color: rgba(254, 255, 180, 255);");

    teProductNotes->setStyleSheet("background-color: qlineargradient"
                                  "(spread:pad, x1:0, y1:1, x2:0.165045,"
                                  "y2:0, stop:0 rgba(254, 255, 180, 255),"
                                  "stop:0.721591 rgba(255, 250, 205, 255));"
                                  "border-radius: 5px;border: 1px solid #C0C0C0;");

    teProductNotes->setFont(this->font());

    lProduct->setPixmap(QPixmap(":/treatment/fieldBackground"));
    lProduct->setScaledContents(true);

    QFont f;

#if defined(Q_WS_X11)
    f.setPointSize(9);
#endif

#if defined(Q_WS_WIN)
    f.setPointSize(12);
#endif

    productPreview->setFont(f);
    setPreview();

    tableItem->setModel(dataModelItems);

    wPizzaMixed->setFont(this->font());
    wPizzaMixed->setStyleSheet(this->styleSheet());

    searchProduct->setCompleter(order->bd.getCompleter("product"));

    cbSize->add("Tamanhos");

    actionName->setCheckable(true);
    actionName->setChecked(true);
    actionName->setEnabled(false);

    actionNickName->setCheckable(true);
    actionNickName->setChecked(false);
    actionNickName->setEnabled(true);

    searchProduct->setAction(actionName);
    searchProduct->setAction(actionNickName);

    searchProduct->eSearch->setNextComponent(cbSize);
    cbSize->setNextComponent(DSBValueProduct);
    DSBValueProduct->setNextComponent(sbAmount);

    emit setInput();
}
Esempio n. 17
0
void MainWindow::setupArduinoRead(QCustomPlot *customPlot)
{
#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
  QMessageBox::critical(this, "", "You're using Qt < 4.7, the realtime data demo needs functions that are available with Qt 4.7 to work properly");
#endif
  demoName = "Real Time Data";
  int cnt = 0;
  int cnt1 = 0;
  int h[input+1];
  h[0] = 0;
  int s = 230;
  int v = 178;
  int a = 255;
  QPen colr[input];
  while (cnt < input){
      h[cnt+1] = (h[cnt] + 50) % 360;

      colr[cnt] = QPen(QColor::fromHsv(h[cnt], s, v, a));
      cnt = cnt +1;
  }

  while (cnt1 < input){
  customPlot->addGraph();
  customPlot->graph(cnt1)->setPen(colr[cnt1]);
  cnt1 = cnt1 + 1;
  }

  customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
  customPlot->xAxis->setDateTimeFormat("hh:mm:ss");
  customPlot->xAxis->setAutoTickStep(false);
  customPlot->xAxis->setTickStep(2);
  customPlot->axisRect()->setupFullAxesBox();

  customPlot->xAxis->setBasePen(QPen(Qt::white, 1));
  customPlot->yAxis->setBasePen(QPen(Qt::white, 1));
  customPlot->xAxis->setTickPen(QPen(Qt::white, 1));
  customPlot->yAxis->setTickPen(QPen(Qt::white, 1));
  customPlot->xAxis->setSubTickPen(QPen(Qt::white, 1));
  customPlot->yAxis->setSubTickPen(QPen(Qt::white, 1));
  customPlot->xAxis->setTickLabelColor(Qt::white);
  customPlot->yAxis->setTickLabelColor(Qt::white);
  QLinearGradient plotGradient;
  plotGradient.setStart(0, 0);
  plotGradient.setFinalStop(0, 350);
  plotGradient.setColorAt(0, QColor(80, 80, 80));
  plotGradient.setColorAt(1, QColor(50, 50, 50));
  customPlot->setBackground(plotGradient);
  QLinearGradient axisRectGradient;
  axisRectGradient.setStart(0, 0);
  axisRectGradient.setFinalStop(0, 350);
  axisRectGradient.setColorAt(0, QColor(80, 80, 80));
  axisRectGradient.setColorAt(1, QColor(30, 30, 30));
  customPlot->axisRect()->setBackground(axisRectGradient);

  customPlot->legend->setVisible(true);
  customPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignLeft);
  customPlot->legend->setBrush(QColor(255, 255, 255, 200));
  QPen legendPen;
  legendPen.setColor(QColor(130, 130, 130, 200));
  customPlot->legend->setBorderPen(legendPen);
  QFont legendFont = font();
  legendFont.setPointSize(10);
  customPlot->legend->setFont(legendFont);
  customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);

  // make left and bottom axes transfer their ranges to right and top axes:
  connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->xAxis2, SLOT(setRange(QCPRange)));
  connect(customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->yAxis2, SLOT(setRange(QCPRange)));

  // setup a timer that repeatedly calls MainWindow::realtimeDataSlot:
  connect(&dataTimer, SIGNAL(timeout()), this, SLOT(realtimeDataSlot()));
  dataTimer.start(0); // Interval 0 means to refresh as fast as possible
}
Esempio n. 18
0
/*********************************************************************
 * The Panels
 *********************************************************************/
SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                          int _number, bool small ) : QWidget( _parent ), p_intf( _p_intf )
{
    module_config_t *p_config;
    ConfigControl *control;
    number = _number;

#define CONFIG_GENERIC( option, type, label, qcontrol )                   \
            p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
            if( p_config )                                                \
            {                                                             \
                control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
                           p_config, label, ui.qcontrol, false );         \
                controls.append( control );                               \
            }                                                             \
            else {                                                        \
                ui.qcontrol->setEnabled( false );                         \
                if( label ) label->setEnabled( false );                   \
            }

#define CONFIG_BOOL( option, qcontrol )                           \
            p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
            if( p_config )                                                \
            {                                                             \
                control =  new BoolConfigControl( VLC_OBJECT(p_intf),     \
                           p_config, NULL, ui.qcontrol, false );          \
                controls.append( control );                               \
            }                                                             \
            else { ui.qcontrol->setEnabled( false ); }


#define CONFIG_GENERIC_NO_UI( option, type, label, qcontrol )             \
            p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
            if( p_config )                                                \
            {                                                             \
                control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
                           p_config, label, qcontrol, false );            \
                controls.append( control );                               \
            }                                                             \
            else {                                                        \
                QWidget *widget = label;                                  \
                qcontrol->setVisible( false );                            \
                if( widget ) widget->setEnabled( false );                 \
            }


#define CONFIG_GENERIC_NO_BOOL( option, type, label, qcontrol )           \
            p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
            if( p_config )                                                \
            {                                                             \
                control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
                           p_config, label, ui.qcontrol );                \
                controls.append( control );                               \
            }

#define CONFIG_GENERIC_FILE( option, type, label, qcontrol, qbutton )     \
            p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
            if( p_config )                                                \
            {                                                             \
                control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
                           p_config, label, qcontrol, qbutton );          \
                controls.append( control );                               \
            }

#define START_SPREFS_CAT( name , label )    \
        case SPrefs ## name:                \
        {                                   \
            Ui::SPrefs ## name ui;      \
            ui.setupUi( panel );            \
            panel_label->setText( label );

#define END_SPREFS_CAT      \
            break;          \
        }

    QVBoxLayout *panel_layout = new QVBoxLayout();
    QWidget *panel = new QWidget();
    panel_layout->setMargin( 3 );

    // Title Label
    QLabel *panel_label = new QLabel;
    QFont labelFont = QApplication::font( static_cast<QWidget*>(0) );
    labelFont.setPointSize( labelFont.pointSize() + 6 );
    labelFont.setFamily( "Verdana" );
    panel_label->setFont( labelFont );

    // Title <hr>
    QFrame *title_line = new QFrame;
    title_line->setFrameShape(QFrame::HLine);
    title_line->setFrameShadow(QFrame::Sunken);

    QFont italicFont = QApplication::font( static_cast<QWidget*>(0) );
    italicFont.setItalic( true );

    switch( number )
    {
        /******************************
         * VIDEO Panel Implementation *
         ******************************/
        START_SPREFS_CAT( Video , qtr("Video Settings") );
            CONFIG_BOOL( "video", enableVideo );

            CONFIG_BOOL( "fullscreen", fullscreen );
            CONFIG_BOOL( "overlay", overlay );
            CONFIG_BOOL( "video-on-top", alwaysOnTop );
            CONFIG_BOOL( "video-deco", windowDecorations );
            CONFIG_BOOL( "skip-frames", skipFrames );
            CONFIG_GENERIC( "vout", Module, ui.voutLabel, outputModule );

            CONFIG_BOOL( "video-wallpaper", wallpaperMode );
#ifdef WIN32
            CONFIG_GENERIC( "directx-device", StringList, ui.dxDeviceLabel,
                            dXdisplayDevice );
            CONFIG_BOOL( "directx-hw-yuv", hwYUVBox );
#else
            ui.directXBox->setVisible( false );
            ui.hwYUVBox->setVisible( false );
#endif

            CONFIG_GENERIC( "deinterlace", IntegerList, ui.deinterLabel, deinterlaceBox );
            CONFIG_GENERIC( "deinterlace-mode", StringList, ui.deinterModeLabel, deinterlaceModeBox );
            CONFIG_GENERIC( "aspect-ratio", String, ui.arLabel, arLine );

            CONFIG_GENERIC_FILE( "snapshot-path", Directory, ui.dirLabel,
                                 ui.snapshotsDirectory, ui.snapshotsDirectoryBrowse );
            CONFIG_GENERIC( "snapshot-prefix", String, ui.prefixLabel, snapshotsPrefix );
            CONFIG_BOOL( "snapshot-sequential",
                            snapshotsSequentialNumbering );
            CONFIG_GENERIC( "snapshot-format", StringList, ui.arLabel,
                            snapshotsFormat );
         END_SPREFS_CAT;

        /******************************
         * AUDIO Panel Implementation *
         ******************************/
        START_SPREFS_CAT( Audio, qtr("Audio Settings") );

            CONFIG_BOOL( "audio", enableAudio );
            ui.SPrefsAudio_zone->setEnabled( ui.enableAudio->isChecked() );
            CONNECT( ui.enableAudio, toggled( bool ),
                     ui.SPrefsAudio_zone, setEnabled( bool ) );

#define audioCommon( name ) \
            QWidget * name ## Control = new QWidget( ui.outputAudioBox ); \
            QHBoxLayout * name ## Layout = new QHBoxLayout( name ## Control); \
            name ## Layout->setMargin( 0 ); \
            name ## Layout->setSpacing( 0 ); \
            QLabel * name ## Label = new QLabel( qtr( "Device:" ), name ## Control ); \
            name ## Label->setMinimumSize(QSize(250, 0)); \
            name ## Layout->addWidget( name ## Label ); \

#define audioControl( name) \
            audioCommon( name ) \
            QComboBox * name ## Device = new QComboBox( name ## Control ); \
            name ## Layout->addWidget( name ## Device ); \
            name ## Label->setBuddy( name ## Device ); \
            outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );

#define audioControl2( name) \
            audioCommon( name ) \
            QLineEdit * name ## Device = new QLineEdit( name ## Control ); \
            name ## Layout->addWidget( name ## Device ); \
            name ## Label->setBuddy( name ## Device ); \
            QPushButton * name ## Browse = new QPushButton( qtr( "Browse..." ), name ## Control); \
            name ## Layout->addWidget( name ## Browse ); \
            outputAudioLayout->addWidget( name ## Control, outputAudioLayout->rowCount(), 0, 1, -1 );

            /* Build if necessary */
            QGridLayout * outputAudioLayout = qobject_cast<QGridLayout *>(ui.outputAudioBox->layout());
#ifdef WIN32
            audioControl( DirectX );
            optionWidgets.append( DirectXControl );
            CONFIG_GENERIC_NO_UI( "directx-audio-device-name", StringList,
                    DirectXLabel, DirectXDevice );
#else
            if( module_exists( "alsa" ) )
            {
                audioControl( alsa );
                optionWidgets.append( alsaControl );

                CONFIG_GENERIC_NO_UI( "alsa-audio-device" , StringList, alsaLabel,
                                alsaDevice );
            }
            else
                optionWidgets.append( NULL );
            if( module_exists( "oss" ) )
            {
                audioControl2( OSS );
                optionWidgets.append( OSSControl );
                CONFIG_GENERIC_FILE( "oss-audio-device" , File, NULL, OSSDevice,
                                 OSSBrowse );
            }
            else
                optionWidgets.append( NULL );
#endif

#undef audioControl2
#undef audioControl
#undef audioCommon

            /* Audio Options */
            CONFIG_GENERIC_NO_BOOL( "volume" , IntegerRangeSlider, NULL,
                                     defaultVolume );
            CONNECT( ui.defaultVolume, valueChanged( int ),
                     this, updateAudioVolume( int ) );

            CONFIG_BOOL( "qt-autosave-volume", keepVolumeRadio );
            ui.defaultVolume_zone->setEnabled( ui.resetVolumeRadio->isChecked() );
            CONNECT( ui.resetVolumeRadio, toggled( bool ),
                     ui.defaultVolume_zone, setEnabled( bool ) );

            CONFIG_GENERIC( "audio-language" , String , ui.langLabel,
                            preferredAudioLanguage );

            CONFIG_BOOL( "spdif", spdifBox );
            CONFIG_GENERIC( "force-dolby-surround", IntegerList, ui.dolbyLabel,
                            detectionDolby );

            CONFIG_GENERIC_NO_BOOL( "norm-max-level" , Float, NULL,
                                    volNormSpin );
            CONFIG_GENERIC( "audio-replay-gain-mode", StringList, ui.replayLabel,
                            replayCombo );
            CONFIG_GENERIC( "audio-visual" , Module , ui.visuLabel,
                            visualisation);
            CONFIG_BOOL( "audio-time-stretch", autoscaleBox );

            /* Audio Output Specifics */
            CONFIG_GENERIC( "aout", Module, ui.outputLabel, outputModule );

            CONNECT( ui.outputModule, currentIndexChanged( int ),
                     this, updateAudioOptions( int ) );

            /* File output exists on all platforms */
            CONFIG_GENERIC_FILE( "audiofile-file", File, ui.fileLabel,
                                 ui.fileName, ui.fileBrowseButton );

            optionWidgets.append( ui.fileControl );
            optionWidgets.append( ui.outputModule );
            optionWidgets.append( ui.volNormBox );
            /*Little mofification of ui.volumeValue to compile with Qt < 4.3 */
            ui.volumeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
            optionWidgets.append( ui.volumeValue );
            optionWidgets.append( ui.headphoneEffect );
            optionWidgets.append( ui.spdifBox );
            updateAudioOptions( ui.outputModule->currentIndex() );

            /* LastFM */
            if( module_exists( "audioscrobbler" ) )
            {
                CONFIG_GENERIC( "lastfm-username", String, ui.lastfm_user_label,
                        lastfm_user_edit );
                CONFIG_GENERIC( "lastfm-password", String, ui.lastfm_pass_label,
                        lastfm_pass_edit );

                if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
                    ui.lastfm->setChecked( true );
                else
                    ui.lastfm->setChecked( false );

                ui.lastfm_zone->setVisible( ui.lastfm->isChecked() );

                CONNECT( ui.lastfm, toggled( bool ),
                         ui.lastfm_zone, setVisible( bool ) );
                CONNECT( ui.lastfm, stateChanged( int ),
                         this, lastfm_Changed( int ) );
            }
            else
            {
Esempio n. 19
0
DialogPacket::DialogPacket(QString type, QByteArray packet, QString scriptPath, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DialogPacket)
{
    ui->setupUi(this);

    m_packet = NULL;
    m_filename = QString();
    m_textChanged = false;

    m_scriptEditor = new TextEdit(this);
    m_scriptEditor->setGeometry(5, 5, 725, 545);
    m_completer = new QCompleter(this);
    m_completer->setModel(modelFromFile());
    m_completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel);
    m_completer->setCaseSensitivity(Qt::CaseInsensitive);
    m_completer->setWrapAround(false);
    m_scriptEditor->setCompleter(m_completer);

    QFont font;
    font.setFamily("Myriad");
    font.setStyleHint(QFont::Monospace);
    font.setFixedPitch(true);
    font.setPointSize(10);

    QFontMetrics metrics(font);
    Highlighter* highlighter = new Highlighter(m_scriptEditor->document());

    m_scriptEditor->setFont(font);
    m_scriptEditor->setTabStopWidth(4 * metrics.width(" "));
    ui->tabWidget->removeTab(0);
    ui->tabWidget->insertTab(0, m_scriptEditor, tr("Script Editor"));
    ui->tabWidget->setCurrentIndex(0);
    m_scriptEditor->setFocus();

    if (!packet.isEmpty())
    {
        m_packet = new PacketReader(type, packet);
        m_packet->ReadHeader();

        ui->Opcode->setText(QString::number(m_packet->GetOpcode()));
        ui->Opcode->setDisabled(true);
        ui->Type->setCurrentIndex((m_packet->GetType() == "CMSG") ? 0 : 1);
        ui->Type->setDisabled(true);
        ui->Size->setText(QString::number(m_packet->GetSize()));

        if (m_packet->CompileScript())
            ui->tabWidget->setCurrentIndex(1);

        ui->ParsedPacket->setPlainText(m_packet->GetAnalyzedPacket());
    }

    if (m_packet && !m_packet->GetScript().isEmpty())
        m_scriptEditor->setPlainText(m_packet->GetScript());
    else if (!scriptPath.isEmpty())
        LoadFile(scriptPath);
    else
        m_scriptEditor->setPlainText("function ReadPacket()\n{\n\t// Code\n}\n\nReadPacket();");

    connect(ui->Close, SIGNAL(clicked()), this, SLOT(close()));
    connect(ui->Save, SIGNAL(clicked()), this, SLOT(Save()));
    connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(OnTabChanged(int)));
    connect(m_scriptEditor, SIGNAL(textChanged()), this, SLOT(OnTextChanged()));
}
Esempio n. 20
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    grmName="Безымянный.grm";
    progName="Formal Grammar";
    star="*";
    isSaved=false;
    isRecursionCheckEnabled=true;

    ui->setupUi(this);

    searchDialog=new SearchDialog(ui->txtGrammar,this);
    gotoDialog=new GotoDialog(ui->txtGrammar,this);
    replaceDialog=new ReplaceDialog(ui->txtGrammar,searchDialog,this);

    scanner=new GramScanner(this);
    depTree=new DependencyTree(this);
    matrixBuilder=new MatrixBuilder2(this);
    matrixView=new MatrixViewForm(scanner,matrixBuilder);

    connect(scanner,SIGNAL(message(int,QString,Position,uint,uint)),this,SLOT(onValidatorMessage(int,QString,Position,uint,uint)));
    connect(depTree,SIGNAL(message(int,QString,Position,uint,uint)),this,SLOT(onValidatorMessage(int,QString,Position,uint,uint)));
    connect(this,SIGNAL(refreshMessagesList()),this,SLOT(onRefreshMessagesList()));

    connect(ui->mnuUndo,SIGNAL(triggered()),ui->txtGrammar,SLOT(undo()));
    connect(ui->mnuRedo,SIGNAL(triggered()),ui->txtGrammar,SLOT(redo()));
    connect(ui->mnuCopy,SIGNAL(triggered()),ui->txtGrammar,SLOT(copy()));
    connect(ui->mnuPaste,SIGNAL(triggered()),ui->txtGrammar,SLOT(paste()));
    connect(ui->mnuCut,SIGNAL(triggered()),ui->txtGrammar,SLOT(cut()));
    connect(ui->mnuSelectAll,SIGNAL(triggered()),ui->txtGrammar,SLOT(selectAll()));
    connect(ui->txtGrammar,SIGNAL(copyAvailable(bool)),ui->mnuCopy,SLOT(setEnabled(bool)));
    connect(ui->txtGrammar,SIGNAL(copyAvailable(bool)),ui->mnuCut,SLOT(setEnabled(bool)));
    connect(ui->txtGrammar,SIGNAL(copyAvailable(bool)),ui->mnuDelete,SLOT(setEnabled(bool)));
    connect(ui->txtGrammar,SIGNAL(undoAvailable(bool)),ui->mnuUndo,SLOT(setEnabled(bool)));
    connect(ui->txtGrammar,SIGNAL(redoAvailable(bool)),ui->mnuRedo,SLOT(setEnabled(bool)));

    highlighter = new Highlighter(ui->txtGrammar->document());

    this->setWindowTitle(grmName+star+" - "+progName);
    QVBoxLayout * layout = new QVBoxLayout();
    layout->addWidget(ui->splitter);
    ui->centralWidget->setLayout(layout);
    layout->setMargin(0);
    layout->setSpacing(0);

    QStringList hlist;
    hlist<<" "<<" "<<" "<<"Описание"<<"Строка"<<"Столбец";
    QTreeWidgetItem *headItem= new QTreeWidgetItem(hlist);
    ui->listMessages->setHeaderItem(headItem);
    ui->listMessages->setRootIsDecorated(false);


    QFont font;
    font.setFamily("Courier");
    font.setFixedPitch(true);
    font.setPointSize(10);
    ui->txtGrammar->setFont(font);
    QStringList sample;
    sample<<"S = H A ! B \"aa\""<<"H = A \"a\" ! A"<<"A = \"bb\" A ! \"b\""<<"B = \"c\" A ! A \"b\" ! H \"c\"";
    ui->txtGrammar->setText(sample.join("\n"));
}
Esempio n. 21
0
confMode::confMode(QWidget * parent) : QDialog(parent),
settings(QSettings::IniFormat, QSettings::UserScope,"QtLog", "qtlog")
{
   setupUi(this);
   n = settings.value("FontSize").toString().toInt();
   QFont font;
   font.setPointSize(n); 			
   setFont(font);
   
   connect(pushButtonExit, SIGNAL(clicked()), this, SLOT(goExit()));
   connect(bandList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(bandListCb(QTreeWidgetItem*,int)));
   connect(modeList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(modeListCb(QTreeWidgetItem*,int)));
   connect(pwrList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(pwrListCb(QTreeWidgetItem*,int)));
   connect(lineList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(lineListCb(QTreeWidgetItem*,int)));
   connect(awdList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(awdListCb(QTreeWidgetItem*,int)));
   connect(customsList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(customsListCb(QTreeWidgetItem*,int)));
   connect(rigList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(rigListCb(QTreeWidgetItem*,int)));
   connect(ButtonHilfe, SIGNAL(clicked()), this, SLOT(getHilfeModeCb()));
   connect(SavePushButton, SIGNAL(clicked()), this, SLOT(SaveConfValues()));
   connect(NewPushButton, SIGNAL(clicked()), this, SLOT(NewAwdValues()));
   connect(RigSavePushButton, SIGNAL(clicked()), this, SLOT(RigSaveButton()));
   connect(RigClearPushButton, SIGNAL(clicked()), this, SLOT(RigClearButton()));
   
    // Band
   bandList->setColumnWidth(0,70);  // Band
   bandList->setColumnWidth(1,40);  // Set
   bandList->setColumnWidth(2,80);  // myBand
   bandList->setColumnWidth(3,70);  // Frequenz
   bandList->setColumnWidth(4,60);  // Band>Rig
   // Mode
   modeList->setColumnWidth(0,30);  // Set
   modeList->setColumnWidth(1,40);  // Mode
   // PWR
   pwrList->setColumnWidth(0,30);   // Set
   pwrList->setColumnWidth(1,40);   // Wort
   pwrList->setColumnWidth(2,60);   // PWR
   // Verbindungs_Arten
   lineList->setColumnWidth(0,30);  // set
   lineList->setColumnWidth(1,80);  // Mode
   // AWD_Typen
   awdList->setColumnWidth(0,40);   // aset
   awdList->setColumnWidth(1,80);   // atyp
   // customs_Felder
   customsList->setColumnWidth(0,80);   // custom_db_feld
   customsList->setColumnWidth(1,140);  // user_feld_name
   // Rig_List
   rigList->setColumnWidth(0,80);    // trans
   rigList->setColumnWidth(1,250);   // trans
   rigList->setColumnWidth(2,250);   // ant
   rigList->setColumnWidth(3,200);   // Linux
   QSqlQuery query;
   // Band
   qy = "SELECT band,work,mband,freq,brig FROM wband";
   query.exec(qy);
   while(query.next()) {
       n = 0;
       i = 0;
       QTreeWidgetItem *item = new QTreeWidgetItem(bandList);
       item->setText(i++,query.value(n++).toString());    // band
       item->setText(i++,query.value(n++).toString());    // work
       item->setText(i++,query.value(n++).toString());    // myband
       item->setText(i++,query.value(n++).toString());    // freq
       item->setText(i++,query.value(n++).toString());    // Band -> Rig
   }
   // Mode
   qy = "SELECT * FROM wmode ORDER BY work DESC";
   query.exec(qy);
   while(query.next()) {
       n = 0;
       i = 0;
       QTreeWidgetItem *item = new QTreeWidgetItem(modeList);
       item->setText(i++,query.value(n++).toString());     // work
       item->setText(i++,query.value(n++).toString());     // mode
   }
    // PWR
   qy = "SELECT * FROM wpwr";
   query.exec(qy);
   while(query.next()) {
       n = 0;
       i = 0;
       QTreeWidgetItem *item = new QTreeWidgetItem(pwrList);
       item->setText(i++,query.value(n++).toString());    // pwr
       item->setText(i++,query.value(n++).toString());    // work
       item->setText(i++,query.value(n++).toString());    // watt
   }
   //
   qy = "SELECT * FROM wline ";
   query.exec(qy);
   while(query.next()) {
       n = 0;
       i = 0;
       QTreeWidgetItem *item = new QTreeWidgetItem(lineList);
       item->setText(i++,query.value(n++).toString());    // id
       item->setText(i++,query.value(n++).toString());    // line
   }
   // AWD
   qy = "SELECT aset,atype FROM wawdlist ORDER BY id";
   query.exec(qy);
   while(query.next()) {
       n = 0;
       i = 0;
       QTreeWidgetItem *item = new QTreeWidgetItem(awdList);
       item->setText(i++,query.value(n++).toString());    // aset
       item->setText(i++,query.value(n++).toString());    // atype
   }
    // customs
   qy = "SELECT dbfield,refnam FROM refnamen WHERE dbfield LIKE 'custom%'";
   query.exec(qy);
   while(query.next()) {
       n = 0;
       i = 0;
       QTreeWidgetItem *item = new QTreeWidgetItem(customsList);
       item->setText(i++,query.value(n++).toString());    // db_feld
       item->setText(i++,query.value(n++).toString());    // user_name
   }
    // Rig
   qy = "SELECT * FROM wrig";
   query.exec(qy);
   while(query.next()) {
       n = 0;
       i = 0;
       QTreeWidgetItem *item = new QTreeWidgetItem(rigList);
       item->setText(i++,query.value(n++).toString());     // rigtype
       item->setText(i++,query.value(n++).toString());     // trans
       item->setText(i++,query.value(n++).toString());     // ant
       item->setText(i++,query.value(n++).toString());     // op
       item->setText(i++,query.value(n++).toString());     // spez
   }
   NewPushButton->hide();
   rtreeWidget = bandList;
   customId1 = 0;
   customId2 = 0;
   BandSetLineEdit->setFocus();
   
   LineNameEdit->setEnabled(FALSE);                // sperren 
   AwdSetLineEdit->setEnabled(FALSE);              // sperren
   NameTypeLineEdit->setEnabled(FALSE);            // sperren
   tabWidget->setCurrentIndex(settings.value("Val").toInt());
   if(settings.value("Val").toInt() == 1) {
       QPalette palette7;
       QBrush brush8(QColor(237, 255, 183, 255));  // GELB/grün
       palette7.setBrush(QPalette::Active, QPalette::Base, brush8);
       awdList->setPalette(palette7);
   }
   
   connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentIndexchangedCb(int)));
}
Esempio n. 22
0
QImage* MyTextEffect::drawImage()
{
    QFont myFont;
    QPen myPen;
    myPen.setJoinStyle( Qt::RoundJoin );
    QBrush myBrush( QColor(0,0,0,0) );
    QColor backgroundColor(0,0,0,0);
    int outline = 0;
    int align = 1;

    int arrowType = 0, arrowSize = 0, arrowPos = 0;

    QStringList sl = currentText.split("\n");
    while ( !sl.isEmpty() ) {
        if ( sl.last().trimmed().isEmpty() )
            sl.takeLast();
        else
            break;
    }
    if ( sl.count() ) {
        QStringList desc = sl[0].split("|");
        if ( desc.count() >= 9 ) {
            myFont.fromString( desc[0] );
            myFont.setPointSize( desc[1].toInt() );
            myFont.setBold( desc[2].toInt() );
            myFont.setItalic( desc[3].toInt() );

            QStringList fc = desc[4].split( "." );
            if ( fc.count() == 2 ) {
                QColor col;
                col.setNamedColor( fc[ 0 ] );
                col.setAlpha( fc[ 1 ].toInt() );
                myPen.setColor( col );
                myBrush.setColor( col );
            }

            QStringList bc = desc[5].split( "." );
            if ( bc.count() == 2 ) {
                backgroundColor.setNamedColor( bc[ 0 ] );
                backgroundColor.setAlpha( bc[ 1 ].toInt() );
            }

            align = desc[6].toInt();

            int osize = desc[7].toInt();
            if ( osize > 0 ) {
                QStringList oc = desc[8].split( "." );
                if ( oc.count() == 2 ) {
                    outline = osize;
                    myPen.setWidth( osize );
                    myFont.setStyleStrategy( QFont::ForceOutline );
                    QColor col;
                    col.setNamedColor( oc[ 0 ] );
                    col.setAlpha( oc[ 1 ].toInt() );
                    myPen.setColor( col );
                }
            }
        }
        if ( desc.count() >= 12 ) {
            arrowType = desc[9].toInt();
            arrowSize = desc[10].toInt();
            arrowPos = desc[11].toInt();
        }
        sl.takeFirst();
    }

    QImage *image = new QImage( 10, 10, QImage::Format_ARGB32_Premultiplied );
    QPainter painter;
    painter.begin( image );
    painter.setPen( myPen );
    painter.setBrush( myBrush );
    painter.setFont( myFont );
    QList<QRectF> br;
    QFontMetrics metrics( myFont );
    int h = sl.count() * metrics.lineSpacing();
    int w = 0;
    for ( int i = 0; i < sl.count(); ++i ) {
        QRectF minrect( 0, 0, 1, 1 );
        QRectF r = painter.boundingRect( minrect, Qt::AlignHCenter | Qt::AlignVCenter, sl[i] );
        if ( r.width() > w )
            w = r.width();
        br.append( r );
    }
    QRectF minrect( 0, 0, 1, 1 );
    int margin = qMax( painter.boundingRect( minrect, Qt::AlignHCenter | Qt::AlignVCenter, "M" ).width() / 3.0, 3.0 );

    painter.end();

    double x = ((double)outline + margin * 2) / 2.0;
    double y = x;
    w += 2 * x;
    h += 2 * y;
    if ( w > iwidth ) {
        x -= (w - iwidth) / 2.0;
        w = iwidth;
    }
    if ( h > iheight ) {
        y -= (h - iheight) / 2.0;
        h = iheight;
    }

    QPointF polygon[7];
    arrowSize = h * arrowSize / 100.0;
    int n = 0;
    int leftOffset = 0, topOffset = 0;
    int wMargin = 0, hMargin = 0;
    if (arrowType) {
        switch (arrowType) {
        case 1: {
            leftOffset = arrowSize;
            wMargin = arrowSize;
            polygon[n].setX(1 + arrowSize);
            polygon[n++].setY(1);

            polygon[n].setY(qMax(1.0, qMin(h - 1.0, h * arrowPos / 100.0 - arrowSize / 2.0) ) );
            polygon[n++].setX(1 + arrowSize);
            polygon[n].setY(qMax(1.0, qMin(h - 1.0, h * arrowPos / 100.0) ) );
            polygon[n++].setX(1);
            polygon[n].setY(qMax(1.0, qMin(h - 1.0, h * arrowPos / 100.0 + arrowSize / 2.0) ) );
            polygon[n++].setX(1 + arrowSize);

            polygon[n].setX(1 + arrowSize);
            polygon[n++].setY(h - 1);
            polygon[n].setX(w - 1 + arrowSize);
            polygon[n++].setY(h - 1);
            polygon[n].setX(w - 1 + arrowSize);
            polygon[n++].setY(1);
            break;
        }
        case 2: {
            wMargin = arrowSize;
            polygon[n].setX(1);
            polygon[n++].setY(1);
            polygon[n].setX(1);
            polygon[n++].setY(h - 1);
            polygon[n].setX(w - 1);
            polygon[n++].setY(h - 1);

            polygon[n].setY(qMax(1.0, qMin(h - 1.0, h * arrowPos / 100.0 + arrowSize / 2.0) ) );
            polygon[n++].setX(w - 1);
            polygon[n].setY(qMax(1.0, qMin(h - 1.0, h * arrowPos / 100.0) ) );
            polygon[n++].setX(w - 1 + arrowSize);
            polygon[n].setY(qMax(1.0, qMin(h - 1.0, h * arrowPos / 100.0 - arrowSize / 2.0) ) );
            polygon[n++].setX(w - 1);

            polygon[n].setX(w - 1);
            polygon[n++].setY(1);
            break;
        }
        case 3: {
            topOffset = arrowSize;
            hMargin = arrowSize;
            polygon[n].setX(1);
            polygon[n++].setY(1 + arrowSize);
            polygon[n].setX(1);
            polygon[n++].setY(h - 1 + arrowSize);
            polygon[n].setX(w - 1);
            polygon[n++].setY(h - 1 + arrowSize);
            polygon[n].setX(w - 1);
            polygon[n++].setY(1 + arrowSize);

            polygon[n].setX(qMax(1.0, qMin(w - 1.0, w * arrowPos / 100.0 + arrowSize / 2.0) ) );
            polygon[n++].setY(1 + arrowSize);
            polygon[n].setX(qMax(1.0, qMin(w - 1.0, w * arrowPos / 100.0) ) );
            polygon[n++].setY(1);
            polygon[n].setX(qMax(1.0, qMin(w - 1.0, w * arrowPos / 100.0 - arrowSize / 2.0) ) );
            polygon[n++].setY(1 + arrowSize);
            break;
        }
        case 4: {
            hMargin = arrowSize;
            polygon[n].setX(1);
            polygon[n++].setY(1);
            polygon[n].setX(1);
            polygon[n++].setY(h - 1);

            polygon[n].setX(qMax(1.0, qMin(w - 1.0, w * arrowPos / 100.0 - arrowSize / 2.0) ) );
            polygon[n++].setY(h - 1);
            polygon[n].setX(qMax(1.0, qMin(w - 1.0, w * arrowPos / 100.0) ) );
            polygon[n++].setY(h - 1 + arrowSize);
            polygon[n].setX(qMax(1.0, qMin(w - 1.0, w * arrowPos / 100.0 + arrowSize / 2.0) ) );
            polygon[n++].setY(h - 1);

            polygon[n].setX(w - 1);
            polygon[n++].setY(h - 1);
            polygon[n].setX(w - 1);
            polygon[n++].setY(1);
            break;
        }
        }
    }

    delete image;
    image = new QImage( w + wMargin, h + hMargin, QImage::Format_ARGB32_Premultiplied );
    image->fill( QColor(0,0,0,0) );
    painter.begin( image );
    painter.setRenderHints( QPainter::Antialiasing | QPainter::TextAntialiasing );
    if ( backgroundColor.alpha() > 0 ) {
        painter.setPen( QColor(0,0,0,0) );
        painter.setBrush( backgroundColor );
        if (arrowType) {
            painter.drawPolygon( polygon, 7 );
        }
        else {
            painter.drawRect( 1, 1, w - 2, h - 2 );
        }
    }
    painter.setPen( myPen );
    painter.setBrush( myBrush );
    painter.setFont( myFont );

    for ( int i = 0; i < sl.count(); ++i ) {
        QPointF point( 0, y + topOffset + metrics.ascent() );
        switch ( align ) {
        case 2: {
            point.setX( leftOffset + (double)w / 2.0 - br[i].width() / 2.0 );
            break;
        }
        case 3: {
            point.setX( leftOffset + w - x - br[i].width() );
            break;
        }
        default: {
            point.setX( leftOffset + x );
            break;
        }
        }
        if ( outline ) {
            QPainterPath myPath;
            myPath.addText( point, myFont, sl[i] );
            painter.drawPath( myPath );
        }
        else
            painter.drawText( point, sl[i] );
        y += metrics.lineSpacing();
    }
    painter.end();

    return image;
}
void AMSamplePlatePre2013ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {

	QString sampleName(index.data(Qt::DisplayRole).toString());
	QString elementString(index.data(AM::UserRole).toString());
	if(!elementString.isEmpty()) {
		elementString.prepend("(");
		elementString.append(")");
	}
	QString createdString(index.data(AM::DescriptionRole).toString());
	QString positionsString(index.data(AM::UserRole+1).toString());
	if(positionsString.isEmpty()) {
		positionsString = "[Unknown sample position]";
	}

	QStyleOptionViewItemV4 opt(option);
	initStyleOption(&opt, index);


	QStyle* sty = QApplication::style();

	// Draw the background: (this will handle selection for us. You can also probe selection directly with opt.state & QStyle::State_Selected)
	sty->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter);


	int textStartingPoint = 0;
	// Do we have a pixmap available?
	QRect iconRect = opt.rect;
	iconRect.adjust(6, 0, 0, 0);

	if(opt.features & QStyleOptionViewItemV4::HasDecoration) {
		QPixmap p = opt.icon.pixmap(opt.decorationSize);
		sty->drawItemPixmap(painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter, p);
		textStartingPoint += 6 + p.width() + 6;
	}

	// textRect starts 6px from the edge of the decoration, and is inset 6px on top and bottom and right. It's the full room we have available for text.
	QRect textRect = opt.rect;
	textRect.adjust( textStartingPoint, 6, -6, -6);



	QFont font = opt.font;
	font.setPointSize(font.pointSize()+4);
	painter->setFont(font);
	painter->setPen(opt.palette.text().color());
	QRect actualNameTextRect;
	painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, sampleName, &actualNameTextRect);

	// Move over by the amount that we filled with text
	QRect elementTextRect(actualNameTextRect.right() + 6,
						  textRect.top(),
						  textRect.width()-actualNameTextRect.width() - 6,
						  actualNameTextRect.height());
	font.setPointSize(font.pointSize()-4);
	font.setItalic(true);
	font.setBold(true);
	painter->setFont(font);
	painter->setPen(Qt::darkGray);
	QFontMetrics fm(font);
	QString elidedElements = fm.elidedText(elementString, Qt::ElideRight, elementTextRect.width());
	painter->drawText(elementTextRect, Qt::AlignLeft | Qt::AlignBottom, elidedElements);

	QRect descriptionTextRect(textRect.left(), actualNameTextRect.bottom(), textRect.width(), textRect.height()-actualNameTextRect.height());
	font.setPointSize(font.pointSize()-2);
	font.setItalic(false);
	font.setBold(false);
	painter->setFont(font);
	painter->setPen(Qt::darkGray);
	painter->drawText(descriptionTextRect, Qt::AlignLeft | Qt::AlignTop, createdString);


	QFontMetrics fm2(font);
	QRect actualPositionsTextRect;
	painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, fm2.elidedText(positionsString, Qt::ElideMiddle, textRect.width()), &actualPositionsTextRect);

	int dividerLineY = actualPositionsTextRect.top() - 4;
	painter->drawLine(QPoint(textRect.left(), dividerLineY), QPoint(textRect.right(), dividerLineY));
}
Esempio n. 24
0
/*!
    \fn SimpleSynthGui::SimpleSynthGui()
 */
SimpleSynthGui::SimpleSynthGui(int sampleRate)
{
   SS_TRACE_IN
         setupUi(this);
         
   setSampleRate(sampleRate);
   
   pluginGui = new SS_PluginGui(this);
   pluginGui->hide();

   for (int i=0; i<SS_NR_OF_CHANNELS; i++) {
      channelButtonGroups[i] = new QGroupBox(this);
      //            channelButtonGroups[i]->setMinimumSize(SS_BTNGRP_WIDTH, SS_BTNGRP_HEIGHT);
      channelButtonGroups[i]->setTitle(QString::number(i + 1));

      QString name = QString("volumeSlider");
      name.append(i + 1);

      channelLayout->addWidget(channelButtonGroups[i]);

      QVBoxLayout* inchnlLayout = new QVBoxLayout(channelButtonGroups[i]); //, 2, 0, "channelinternallayout");
      inchnlLayout->setAlignment(Qt::AlignHCenter);
      inchnlLayout->setSpacing(1);
      inchnlLayout->setMargin(0);


      onOff[i] = new QChannelCheckbox(channelButtonGroups[i], i);
      //            onOff[i]->setMinimumSize(SS_ONOFF_WIDTH, SS_ONOFF_HEIGHT);
      onOff[i]->setToolTip("Channel " + QString::number(i + 1) + " on/off");
      inchnlLayout->addWidget(onOff[i]);
      connect(onOff[i], SIGNAL(channelState(int, bool)), SLOT(channelOnOff(int, bool)));

      ///volumeSliders[i] = new QInvertedChannelSlider(Qt::Vertical, i, channelButtonGroups[i]);
      // By Tim. p4.0.27 Inverted was not correct type. Maybe was work in progress, rest of code was not converted yet?
      QHBoxLayout *volLayout = new QHBoxLayout(channelButtonGroups[i]);

      volumeSliders[i] = new QChannelSlider(Qt::Vertical, i, channelButtonGroups[i]);

      volumeSliders[i]->setMinimum(SS_VOLUME_MIN_VALUE);
      volumeSliders[i]->setMaximum(SS_VOLUME_MAX_VALUE);

      ///volumeSliders[i]->setValue(SS_VOLUME_MAX_VALUE - SS_VOLUME_DEFAULT_VALUE);
      volumeSliders[i]->setValue(SS_VOLUME_DEFAULT_VALUE);  // p4.0.27

      //            volumeSliders[i]->setMinimumSize(SS_VOLSLDR_WIDTH, SS_VOLSLDR_LENGTH);
      volumeSliders[i]->setToolTip("Volume, channel " + QString::number(i + 1));
      //            setMinimumSize(SS_VOLSLDR_WIDTH, SS_VOLSLDR_LENGTH);
      volLayout->addWidget(volumeSliders[i]);

      chnMeter[i] = new MusEGui::Meter(channelButtonGroups[i]);
      chnMeter[i]->setFixedWidth(9);
      chnMeter[i]->setVal(0.0, 0.0, false);
      meterVal[i] = peakVal[i] = 0.0;
      chnMeter[i]->setRange(SS_minMeterVal, 10.0);
      chnMeter[i]->show();
      volLayout->addWidget(chnMeter[i]);

      inchnlLayout->addLayout(volLayout);
      //inchnlLayout->addWidget(volumeSliders[i]);
      connect(volumeSliders[i], SIGNAL(valueChanged(int, int)), SLOT(volumeChanged(int, int)));

      pitchKnobs[i] = new QChannelDial(channelButtonGroups[i], i, 0);
      pitchKnobs[i]->setRange(-63,63);
      pitchKnobs[i]->setValue(0);
      pitchKnobs[i]->setToolTip("Pitch, channel " + QString::number(i + 1));
      pitchKnobs[i]->setFixedSize(30,30);
      inchnlLayout->addWidget(pitchKnobs[i]);
      connect(pitchKnobs[i], SIGNAL(valueChanged(int,int,int)), SLOT(pitchChanged(int,int, int)));


      nOffLabel[i] = new QLabel(channelButtonGroups[i]);
      nOffLabel[i]->setText("nOff");
      inchnlLayout->addWidget(nOffLabel[i]);

      nOffIgnore[i] = new QChannelCheckbox(channelButtonGroups[i], i);
      nOffIgnore[i]->setToolTip("Note off ignore, channel " + QString::number(i + 1));
      inchnlLayout->addWidget(nOffIgnore[i]);
      connect(nOffIgnore[i], SIGNAL(channelState(int, bool)),SLOT(channelNoteOffIgnore(int, bool)));

      panSliders[i] = new QChannelSlider(Qt::Horizontal, i, channelButtonGroups[i]);
      panSliders[i]->setRange(0, 127);
      panSliders[i]->setValue(SS_PANSLDR_DEFAULT_VALUE);
      panSliders[i]->setToolTip("Pan, channel " + QString::number(i + 1));
      inchnlLayout->addWidget(panSliders[i]);
      connect(panSliders[i], SIGNAL(valueChanged(int, int)), SLOT(panChanged(int, int)));

      QGridLayout* dialGrid = new QGridLayout;
      inchnlLayout->addLayout(dialGrid);
      sendFxDial[i][0] = new QChannelDial(channelButtonGroups[i], i, 0);
      sendFxDial[i][0]->setRange(0, 127);
      sendFxDial[i][0]->setMaximumSize(SS_SENDFX_WIDTH, SS_SENDFX_HEIGHT);
      sendFxDial[i][0]->setToolTip("Fx 1 send amount");
      dialGrid->addWidget(sendFxDial[i][0], 0, 0, Qt::AlignCenter | Qt::AlignTop);

      connect(sendFxDial[i][0], SIGNAL(valueChanged(int, int, int)), SLOT(sendFxChanged(int, int, int)));

      sendFxDial[i][1] = new QChannelDial(channelButtonGroups[i], i, 1);
      sendFxDial[i][1]->setRange(0, 127);
      dialGrid->addWidget(sendFxDial[i][1], 0, 1, Qt::AlignCenter | Qt::AlignTop);
      sendFxDial[i][1]->setMaximumSize(SS_SENDFX_WIDTH, SS_SENDFX_HEIGHT);
      sendFxDial[i][1]->setToolTip("Fx 2 send amount");

      connect(sendFxDial[i][1], SIGNAL(valueChanged(int, int, int)), SLOT(sendFxChanged(int, int, int)));

      sendFxDial[i][2] = new QChannelDial(channelButtonGroups[i], i, 2);
      sendFxDial[i][2]->setRange(0, 127);
      sendFxDial[i][2]->setMaximumSize(SS_SENDFX_WIDTH, SS_SENDFX_HEIGHT);
      dialGrid->addWidget(sendFxDial[i][2], 1, 0, Qt::AlignCenter | Qt::AlignTop);
      sendFxDial[i][2]->setToolTip("Fx 3 send amount");
      connect(sendFxDial[i][2], SIGNAL(valueChanged(int, int, int)), SLOT(sendFxChanged(int, int, int)));

      sendFxDial[i][3] = new QChannelDial(channelButtonGroups[i], i, 3);
      sendFxDial[i][3]->setRange(0, 127);
      sendFxDial[i][3]->setMaximumSize(SS_SENDFX_WIDTH, SS_SENDFX_HEIGHT);
      sendFxDial[i][3]->setToolTip("Fx 4 send amount");

      dialGrid->addWidget(sendFxDial[i][3], 1, 1, Qt::AlignCenter | Qt::AlignTop);
      connect(sendFxDial[i][3], SIGNAL(valueChanged(int, int, int)), SLOT(sendFxChanged(int, int, int)));

      chnRoutingCb[i] = new QComboBox(channelButtonGroups[i]);
      chnRoutingCb[i]->addItem(tr("Mix"), QVariant(0));
      chnRoutingCb[i]->addItem(tr("Chn"), QVariant(1));
      chnRoutingCb[i]->setMaximumSize(SS_PANSLDR_WIDTH, SS_PANSLDR_LENGTH);
      chnRoutingCb[i]->setToolTip(tr("Channel routing"));
      QFont chnRFont;
      chnRFont.setPointSize(6);
      chnRoutingCb[i]->setFont(chnRFont);
      connect(chnRoutingCb[i], SIGNAL(currentIndexChanged(int)), this, SLOT(routeChanged(int)));
      inchnlLayout->addWidget(chnRoutingCb[i]);

      inchnlLayout->activate();
   }

   masterSlider = new QSlider(Qt::Vertical, this);
   masterSlider->setToolTip("Master volume");
   channelLayout->addWidget(masterSlider);
   masterSlider->setRange(0, 127);
   masterSlider->setValue((int)(SS_MASTERVOL_DEFAULT_VALUE*SS_VOLUME_MAX_VALUE)); // p4.0.27

   connect(masterSlider, SIGNAL(valueChanged(int)), SLOT(masterVolChanged(int)));  // p4.0.27


   int i=0;

   for (int c=0; c<2; c++) {
      for (int r=0; r<SS_NR_OF_CHANNELS/2; r++) {
         QHBoxLayout* strip = new QHBoxLayout;
         mgbLayout->addLayout(strip, r, c);

         QLabel* channelLabel = new QLabel(QString::number(i + 1) + ": (" +labelStrings[i] + ")");
         strip->addWidget(channelLabel);

         sampleNameLineEdit[i] = new QLineEdit();
         sampleNameLineEdit[i]->setReadOnly(true);
         sampleNameLineEdit[i]->setFixedWidth(180);
         strip->addWidget(sampleNameLineEdit[i]);

         loadSampleButton[i] = new QChannelButton(0, "L", i);
         loadSampleButton[i]->setToolTip("Load sample on channel " + QString::number(i + 1));
         loadSampleButton[i]->setFixedSize(23,23);
         strip->addWidget(loadSampleButton[i]);
         connect(loadSampleButton[i], SIGNAL(channelState(int, bool)), SLOT(loadSampleDialogue(int)));

         clearSampleButton[i] = new QChannelButton(0, "C", i);
         clearSampleButton[i]->setToolTip("Clear sample on channel " + QString::number(i + 1));
         clearSampleButton[i]->setFixedSize(23,23);
         strip->addWidget(clearSampleButton[i]);
         connect(clearSampleButton[i], SIGNAL(channelState(int, bool)), SLOT(clearSample(int)));
         i++;
      }
   }

   // Right bottom panel:
   QGroupBox* rbPanel= new QGroupBox();
   mgbLayout->addWidget(rbPanel, 1, 3, 7, 1, Qt::AlignCenter);
   QGridLayout* rbLayout = new QGridLayout(rbPanel);

   openPluginsButton = new QPushButton("&Send Effects");
   openPluginsButton->setToolTip("Configure LADSPA send effects");
   connect(openPluginsButton, SIGNAL(clicked()), SLOT(openPluginButtonClicked()));
   rbLayout->addWidget(openPluginsButton, 2, 1, Qt::AlignCenter | Qt::AlignVCenter);
   rbLayout->setSpacing(0);
   rbLayout->setMargin(0);
   aboutButton = new QPushButton("About SimpleDrums");
   connect(aboutButton, SIGNAL(clicked()), SLOT(aboutButtonClicked()));
   rbLayout->addWidget(aboutButton, 4, 1, Qt::AlignLeft | Qt::AlignVCenter);


   loadButton = new QPushButton(tr("&Load setup"), rbPanel);
   connect(loadButton, SIGNAL(clicked()), SLOT(loadSetup()));
   saveButton = new QPushButton(tr("&Save setup"), rbPanel);
   connect(saveButton, SIGNAL(clicked()), SLOT(saveSetup()));
   rbLayout->addWidget(loadButton,  3, 1, Qt::AlignCenter | Qt::AlignVCenter);
   rbLayout->addWidget(saveButton,  4, 1, Qt::AlignCenter | Qt::AlignVCenter);
   rbLayout->addWidget(aboutButton, 6, 1, Qt::AlignCenter | Qt::AlignVCenter);

   lastDir = "";
   connect(this->getGuiSignal(),SIGNAL(wakeup()),this,SLOT(readMessage()));

   SS_TRACE_OUT
}
Esempio n. 25
0
void
KRuler::paintEvent(QPaintEvent * /*e*/)
{
    //  debug ("KRuler::drawContents, %s",(horizontal==dir)?"horizontal":"vertical");

    QStylePainter p(this);
#ifdef PROFILING
    QTime time;
    time.start();
    for (int profile = 0; profile < 10; profile++) {
#endif

        int value  = this->value(),
            minval = minimum(),
            maxval;
        if (d->dir == Qt::Horizontal) {
            maxval = maximum()
                     + d->offset
                     - (d->lengthFix ? (height() - d->endOffset_length) : d->endOffset_length);
        } else {
            maxval = maximum()
                     + d->offset
                     - (d->lengthFix ? (width() - d->endOffset_length) : d->endOffset_length);
        }
        //ioffsetval = value-offset;
        //    pixelpm = (int)ppm;
        //    left  = clip.left(),
        //    right = clip.right();
        double f, fend,
               offsetmin = (double)(minval - d->offset),
               offsetmax = (double)(maxval - d->offset),
               fontOffset = (((double)minval) > offsetmin) ? (double)minval : offsetmin;

        // draw labels
        QFont font = p.font();
        font.setPointSize(LABEL_SIZE);
        p.setFont(font);
        // draw littlemarklabel

        // draw mediummarklabel

        // draw bigmarklabel

        // draw endlabel
        if (d->showEndL) {
            if (d->dir == Qt::Horizontal) {
                p.translate(fontOffset, 0);
                p.drawText(END_LABEL_X, END_LABEL_Y, d->endlabel);
            } else { // rotate text +pi/2 and move down a bit
                //QFontMetrics fm(font);
#ifdef KRULER_ROTATE_TEST
                p.rotate(-90.0 + rotate);
                p.translate(-8.0 - fontOffset - d->fontWidth + xtrans,
                            ytrans);
#else
                p.rotate(-90.0);
                p.translate(-8.0 - fontOffset - d->fontWidth, 0.0);
#endif
                p.drawText(END_LABEL_X, END_LABEL_Y, d->endlabel);
            }
            p.resetMatrix();
        }

        // draw the tiny marks
        if (d->showtm) {
            fend = d->ppm * d->tmDist;
            for (f = offsetmin; f < offsetmax; f += fend) {
                if (d->dir == Qt::Horizontal) {
                    p.drawLine((int)f, BASE_MARK_X1, (int)f, BASE_MARK_X2);
                } else {
                    p.drawLine(BASE_MARK_X1, (int)f, BASE_MARK_X2, (int)f);
                }
            }
        }
        if (d->showlm) {
            // draw the little marks
            fend = d->ppm * d->lmDist;
            for (f = offsetmin; f < offsetmax; f += fend) {
                if (d->dir == Qt::Horizontal) {
                    p.drawLine((int)f, LITTLE_MARK_X1, (int)f, LITTLE_MARK_X2);
                } else {
                    p.drawLine(LITTLE_MARK_X1, (int)f, LITTLE_MARK_X2, (int)f);
                }
            }
        }
        if (d->showmm) {
            // draw medium marks
            fend = d->ppm * d->mmDist;
            for (f = offsetmin; f < offsetmax; f += fend) {
                if (d->dir == Qt::Horizontal) {
                    p.drawLine((int)f, MIDDLE_MARK_X1, (int)f, MIDDLE_MARK_X2);
                } else {
                    p.drawLine(MIDDLE_MARK_X1, (int)f, MIDDLE_MARK_X2, (int)f);
                }
            }
        }
        if (d->showbm) {
            // draw big marks
            fend = d->ppm * d->bmDist;
            for (f = offsetmin; f < offsetmax; f += fend) {
                if (d->dir == Qt::Horizontal) {
                    p.drawLine((int)f, BIG_MARK_X1, (int)f, BIG_MARK_X2);
                } else {
                    p.drawLine(BIG_MARK_X1, (int)f, BIG_MARK_X2, (int)f);
                }
            }
        }
        if (d->showem) {
            // draw end marks
            if (d->dir == Qt::Horizontal) {
                p.drawLine(minval - d->offset, END_MARK_X1, minval - d->offset, END_MARK_X2);
                p.drawLine(maxval - d->offset, END_MARK_X1, maxval - d->offset, END_MARK_X2);
            } else {
                p.drawLine(END_MARK_X1, minval - d->offset, END_MARK_X2, minval - d->offset);
                p.drawLine(END_MARK_X1, maxval - d->offset, END_MARK_X2, maxval - d->offset);
            }
        }

        // draw pointer
        if (d->showpointer) {
            QPolygon pa(4);
            if (d->dir == Qt::Horizontal) {
                pa.setPoints(3, value - 5, 10, value + 5, 10, value/*+0*/, 15);
            } else {
                pa.setPoints(3, 10, value - 5, 10, value + 5, 15, value/*+0*/);
            }
            p.setBrush(p.background().color());
            p.drawPolygon(pa);
        }

#ifdef PROFILING
    }
    int elapsed = time.elapsed();
    debug("paint time %i", elapsed);
#endif

}
Esempio n. 26
0
void GeneralSettingsPage::apply()
{
    if (!m_ui) // page was never shown
        return;
    QFont newFont;
    const QString &family = m_ui->familyComboBox->currentFont().family();
    newFont.setFamily(family);

    int fontSize = 14;
    int currentIndex = m_ui->sizeComboBox->currentIndex();
    if (currentIndex != -1)
        fontSize = m_ui->sizeComboBox->itemData(currentIndex).toInt();
    newFont.setPointSize(fontSize);

    QString fontStyle = QLatin1String("Normal");
    currentIndex = m_ui->styleComboBox->currentIndex();
    if (currentIndex != -1)
        fontStyle = m_ui->styleComboBox->itemText(currentIndex);
    newFont.setBold(m_fontDatabase.bold(family, fontStyle));
    if (fontStyle.contains(QLatin1String("Italic")))
        newFont.setStyle(QFont::StyleItalic);
    else if (fontStyle.contains(QLatin1String("Oblique")))
        newFont.setStyle(QFont::StyleOblique);
    else
        newFont.setStyle(QFont::StyleNormal);

    const int weight = m_fontDatabase.weight(family, fontStyle);
    if (weight >= 0)    // Weight < 0 asserts...
        newFont.setWeight(weight);

    if (newFont != m_font) {
        m_font = newFont;
        LocalHelpManager::setFallbackFont(newFont);
        emit fontChanged();
    }

    QString homePage = QUrl::fromUserInput(m_ui->homePageLineEdit->text()).toString();
    if (homePage.isEmpty())
        homePage = Help::Constants::AboutBlank;
    m_ui->homePageLineEdit->setText(homePage);
    if (m_homePage != homePage) {
        m_homePage = homePage;
        LocalHelpManager::setHomePage(homePage);
    }

    const int startOption = m_ui->helpStartComboBox->currentIndex();
    if (m_startOption != startOption) {
        m_startOption = startOption;
        LocalHelpManager::setStartOption((LocalHelpManager::StartOption)m_startOption);
    }

    const int helpOption = m_ui->contextHelpComboBox->currentIndex();
    if (m_contextOption != helpOption) {
        m_contextOption = helpOption;
        LocalHelpManager::setContextHelpOption((HelpManager::HelpViewerLocation)m_contextOption);
    }

    const bool close = m_ui->m_returnOnClose->isChecked();
    if (m_returnOnClose != close) {
        m_returnOnClose = close;
        LocalHelpManager::setReturnOnClose(m_returnOnClose);
    }
}
Esempio n. 27
0
Nuclear::Nuclear(QWidget *parent)
    : QWidget(parent)
{
    //инициализация слоев всего виджета (не изменять)
    this->setLayout(new QVBoxLayout);
    this->layout()->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    this->setMinimumWidth(800);
	this->setMinimumHeight(480);

    QHBoxLayout* other = new QHBoxLayout;
    edit_box1 = new QLabel();
    QPalette pl;
    pl.setColor(QPalette::Text,Qt::red);
    edit_box1->setPalette(pl);
    this->layout()->addWidget(edit_box1);

    QFont font;
//    font.setBold(true);
    font.setPointSize(12);
    //инициализация слоя для виджетов ввода данных (не изменять)
    QVBoxLayout* input_layout = new QVBoxLayout;
    input_layout->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
    //инициализация слоя для виджетов вывода данных (не изменять)
    QVBoxLayout* output_layout = new QVBoxLayout;
    output_layout->setAlignment(Qt::AlignTop | Qt::AlignHCenter);

    //выбор тестов

    QPushButton* calculate_btn = new QPushButton("Calculate", this);
    calculate_btn->setFixedSize(150,80);
	calculate_btn->setFont(font);
	connect(calculate_btn, SIGNAL(clicked()), this, SLOT(Calculate()));
    other->addWidget(calculate_btn);

    list1 = new QListWidget;
    list1->addItem("1");
    list1->addItem("2");
    list1->addItem("3");

    list1->setMaximumHeight(30);
    QObject::connect(list1, &QListWidget::clicked,
                     this, &Nuclear::OpenTest);
    QObject::connect(list1, &QListWidget::activated,
                     this, &Nuclear::OpenTest);


    this->layout()->addWidget(list1);


	//layout для table
	QVBoxLayout* table1_layout = new QVBoxLayout;
	table1_layout->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
	QLabel* table1_name_label = new QLabel("Table example", this); //название таблицы
    table1_name_label->setAlignment(Qt::AlignHCenter);
    table1_name_label->setVisible(false);
    table1 = new QTableWidget(this);
//    table1->setMinimumSize(700,560);
//    table1_layout->addWidget(table1_name_label);
//    table1_layout->addWidget(table1);
    other->addWidget(table1_name_label);
    other->addWidget(table1);


	table1->setRowCount(22);//кол-во строк
    table1->setColumnCount(7);//кол-во столбцов
	//задание название строкам (аналогично стобцам)
	QStringList lst;
	lst << "Node" <<
		   "Chance of branch" <<
		   "Cost of branch" <<
           "EIN" <<
           "Params" <<
           "Death" <<
           "Action";
	table1->setHorizontalHeaderLabels(lst);
	lst.clear();
    table1->setVerticalHeaderLabels(lst);
	table1->setItem(0,0, new QTableWidgetItem("1"));
	table1->setItem(2,0, new QTableWidgetItem("2"));
	table1->setItem(4,0, new QTableWidgetItem("3"));
	table1->setItem(9,0, new QTableWidgetItem("4"));
	table1->setItem(15,0, new QTableWidgetItem("5"));
	table1->setItem(21,0, new QTableWidgetItem("6"));

    //заполенения output layout
    QLabel* output_label = new QLabel("Output", this);
    output_label->setFont(font);
    output_label->setFixedHeight(30);
    output_label->setAlignment(Qt::AlignHCenter);
    output_layout->addWidget(output_label);
    output_label->setVisible(false);
    //добавление необходимых виджетов для вывода данных
//    output_layout->addItem(label1_layout);
    output_layout->addItem(table1_layout);
//	output_layout->addItem(plot1_layout);
    //=====

    this->layout()->addItem(other);
    this->layout()->addItem(input_layout);
	this->layout()->addItem(output_layout);

    init();

}
Esempio n. 28
0
void
GcWindow::paintEvent(QPaintEvent * /*event*/)
{
    static QPixmap closeImage = QPixmap(":images/toolbar/popbutton.png");
    static QPixmap aluBar = QPixmap(":images/aluBar.png");
    static QPixmap aluBarDark = QPixmap(":images/aluBarDark.png");
    static QPixmap aluLight = QPixmap(":images/aluLight.jpg");
    static QPixmap carbon = QPixmap(":images/carbon.jpg");
    static QPalette defaultPalette;


    // setup a painter and the area to paint
    QPainter painter(this);
    // background light gray for now?
    QRect all(0,0,width(),height());
    painter.fillRect(all, property("color").value<QColor>());

    if (contentsMargins().top() > 0) {

        // fill in the title bar
        QRect bar(0,0,width(),contentsMargins().top());
        //if (contentsMargins().top() < 25) {
        //QColor bg;
        //if (property("active").toBool() == true) {
            //bg = GColor(CTILEBARSELECT);
            //painter.drawPixmap(bar, aluBar);
        //} else {
            //bg = GColor(CTILEBAR);
            //painter.drawPixmap(bar, aluBarDark);
        //}
        //} else {
            painter.setPen(Qt::darkGray);
            painter.drawRect(QRect(0,0,width()-1,height()-1));
        //}

        // heading
        QFont font;
        font.setPointSize((contentsMargins().top()/2)+2);
        font.setWeight(QFont::Bold);
        painter.setFont(font);
        QString subtitle = property("subtitle").toString();
        QString title = property("title").toString();
        QString heading = subtitle != "" ? subtitle : title;

        // embossed...
        //QRect shad = bar;
        //shad.setY(bar.y()+2);
        //shad.setX(bar.x()+2);
        //painter.setPen(QColor(255,255,255,180));
        //painter.drawText(shad, heading, Qt::AlignVCenter | Qt::AlignCenter);

        // pen color needs to contrast to background color
        QColor bgColor = property("color").value<QColor>();
        QColor fgColor;

        if (bgColor == Qt::black) fgColor = Qt::white;
        else if (bgColor == Qt::white) fgColor = Qt::black;
        else {

            QColor cRGB = bgColor.convertTo(QColor::Rgb);
            // lets work it out..
            int r = cRGB.red() < 128 ? 255 : 0;
            int g = cRGB.green() < 128 ? 255 : 0;
            int b = cRGB.blue() < 128 ? 255 : 0;
            fgColor = QColor(r,g,b);
        }

        painter.setPen(fgColor);
        painter.drawText(bar, heading, Qt::AlignVCenter | Qt::AlignCenter);

        // border
        painter.setBrush(Qt::NoBrush);
        if (underMouse()) {

            QPixmap sized = closeImage.scaled(QSize(contentsMargins().top()-6,
                                                    contentsMargins().top()-6));
            //painter.drawPixmap(width()-3-sized.width(), 3, sized.width(), sized.height(), sized);

        } else {
            painter.setPen(Qt::darkGray);
            //painter.drawRect(QRect(0,0,width()-1,height()-1)); //XXX pointless
        }
    } else {
        // is this a layout manager?
        // background light gray for now?
        QRect all(0,0,width(),height());
        if (property("isManager").toBool() == true) {
            //painter.drawTiledPixmap(all, carbon);
            painter.fillRect(all, QColor("#B3B4BA"));
        } else {
            //painter.drawTiledPixmap(all, aluLight);
        }
    }
}
Esempio n. 29
0
// Convert simple DOM types
QVariant domPropertyToVariant(const DomProperty *p)
{
    // requires non-const virtual nameToIcon, etc.
    switch(p->kind()) {
    case DomProperty::Bool:
        return QVariant(p->elementBool() == QFormBuilderStrings::instance().trueValue);

    case DomProperty::Cstring:
        return QVariant(p->elementCstring().toUtf8());

    case DomProperty::Point: {
        const DomPoint *point = p->elementPoint();
        return QVariant(QPoint(point->elementX(), point->elementY()));
    }

    case DomProperty::PointF: {
        const DomPointF *pointf = p->elementPointF();
        return QVariant(QPointF(pointf->elementX(), pointf->elementY()));
    }

    case DomProperty::Size: {
        const DomSize *size = p->elementSize();
        return QVariant(QSize(size->elementWidth(), size->elementHeight()));
    }

    case DomProperty::SizeF: {
        const DomSizeF *sizef = p->elementSizeF();
        return QVariant(QSizeF(sizef->elementWidth(), sizef->elementHeight()));
    }

    case DomProperty::Rect: {
        const DomRect *rc = p->elementRect();
        const QRect g(rc->elementX(), rc->elementY(), rc->elementWidth(), rc->elementHeight());
        return QVariant(g);
    }

    case DomProperty::RectF: {
        const DomRectF *rcf = p->elementRectF();
        const QRectF g(rcf->elementX(), rcf->elementY(), rcf->elementWidth(), rcf->elementHeight());
        return QVariant(g);
    }

    case DomProperty::String:
        return QVariant(p->elementString()->text());

    case DomProperty::Number:
        return QVariant(p->elementNumber());

    case DomProperty::UInt:
        return QVariant(p->elementUInt());

    case DomProperty::LongLong:
        return QVariant(p->elementLongLong());

    case DomProperty::ULongLong:
        return QVariant(p->elementULongLong());

    case DomProperty::Double:
        return QVariant(p->elementDouble());

    case DomProperty::Char: {
        const DomChar *character = p->elementChar();
        const QChar c(character->elementUnicode());
        return qVariantFromValue(c);
    }

    case DomProperty::Color: {
        const DomColor *color = p->elementColor();
        QColor c(color->elementRed(), color->elementGreen(), color->elementBlue());
        if (color->hasAttributeAlpha())
            c.setAlpha(color->attributeAlpha());
        return qVariantFromValue(c);
    }

    case DomProperty::Font: {
        const DomFont *font = p->elementFont();

        QFont f;
        if (font->hasElementFamily() && !font->elementFamily().isEmpty())
            f.setFamily(font->elementFamily());
        if (font->hasElementPointSize() && font->elementPointSize() > 0)
            f.setPointSize(font->elementPointSize());
        if (font->hasElementWeight() && font->elementWeight() > 0)
            f.setWeight(font->elementWeight());
        if (font->hasElementItalic())
            f.setItalic(font->elementItalic());
        if (font->hasElementBold())
            f.setBold(font->elementBold());
        if (font->hasElementUnderline())
            f.setUnderline(font->elementUnderline());
        if (font->hasElementStrikeOut())
            f.setStrikeOut(font->elementStrikeOut());
        if (font->hasElementKerning())
            f.setKerning(font->elementKerning());
        if (font->hasElementAntialiasing())
            f.setStyleStrategy(font->elementAntialiasing() ? QFont::PreferDefault : QFont::NoAntialias);
        if (font->hasElementStyleStrategy()) {
            f.setStyleStrategy(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QFont::StyleStrategy>("styleStrategy", font->elementStyleStrategy().toLatin1()));
        }
        return qVariantFromValue(f);
    }

    case DomProperty::Date: {
        const DomDate *date = p->elementDate();
        return QVariant(QDate(date->elementYear(), date->elementMonth(), date->elementDay()));
    }

    case DomProperty::Time: {
        const DomTime *t = p->elementTime();
        return QVariant(QTime(t->elementHour(), t->elementMinute(), t->elementSecond()));
    }

    case DomProperty::DateTime: {
        const DomDateTime *dateTime = p->elementDateTime();
        const QDate d(dateTime->elementYear(), dateTime->elementMonth(), dateTime->elementDay());
        const QTime tm(dateTime->elementHour(), dateTime->elementMinute(), dateTime->elementSecond());
        return QVariant(QDateTime(d, tm));
    }

    case DomProperty::Url: {
        const DomUrl *url = p->elementUrl();
        return QVariant(QUrl(url->elementString()->text()));
    }

#ifndef QT_NO_CURSOR
    case DomProperty::Cursor:
        return qVariantFromValue(QCursor(static_cast<Qt::CursorShape>(p->elementCursor())));

    case DomProperty::CursorShape:
        return qVariantFromValue(QCursor(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, Qt::CursorShape>("cursorShape", p->elementCursorShape().toLatin1())));
#endif

    case DomProperty::Locale: {
        const DomLocale *locale = p->elementLocale();
        return qVariantFromValue(QLocale(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Language>("language", locale->attributeLanguage().toLatin1()),
                    enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Country>("country", locale->attributeCountry().toLatin1())));
    }
    case DomProperty::SizePolicy: {
        const DomSizePolicy *sizep = p->elementSizePolicy();

        QSizePolicy sizePolicy;
        sizePolicy.setHorizontalStretch(sizep->elementHorStretch());
        sizePolicy.setVerticalStretch(sizep->elementVerStretch());

        const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType");

        if (sizep->hasElementHSizeType()) {
            sizePolicy.setHorizontalPolicy((QSizePolicy::Policy) sizep->elementHSizeType());
        } else if (sizep->hasAttributeHSizeType()) {
            const QSizePolicy::Policy sp = enumKeyToValue<QSizePolicy::Policy>(sizeType_enum, sizep->attributeHSizeType().toLatin1());
            sizePolicy.setHorizontalPolicy(sp);
        }

        if (sizep->hasElementVSizeType()) {
            sizePolicy.setVerticalPolicy((QSizePolicy::Policy) sizep->elementVSizeType());
        } else if (sizep->hasAttributeVSizeType()) {
            const  QSizePolicy::Policy sp = enumKeyToValue<QSizePolicy::Policy>(sizeType_enum, sizep->attributeVSizeType().toLatin1());
            sizePolicy.setVerticalPolicy(sp);
        }

        return qVariantFromValue(sizePolicy);
    }

    case DomProperty::StringList:
        return QVariant(p->elementStringList()->elementString());

    default:
        uiLibWarning(QCoreApplication::translate("QFormBuilder", "Reading properties of the type %1 is not supported yet.").arg(p->kind()));
        break;
    }

    return QVariant();
}
Esempio n. 30
0
QWidget* AutoReply::options() {
    if (!enabled) {
        return nullptr;
    }
    QWidget *optionsWid = new QWidget();
    messageWidget = new QTextEdit();
    messageWidget->setMaximumHeight(60);
    messageWidget->setText(Message);
    disableforWidget = new QTextEdit();
    disableforWidget->setText(DisableFor);
    enabledisableWidget = new QComboBox();
    enabledisableWidget->addItem(tr("Enable"));
    enabledisableWidget->addItem(tr("Disable"));
    enabledisableWidget->setCurrentIndex(EnableDisable);
    DisableForAccWidget = new QTextEdit();
    DisableForAccWidget->setText(DisableForAcc);
    spinWidget = new QSpinBox();
    spinWidget->setMinimum(-1);
    spinWidget->setValue(Times);
    resetWidget = new QSpinBox();
    resetWidget->setMaximum(2000);
    resetWidget->setMinimum(1);
    resetWidget->setValue(ResetTime);
    activetabWidget = new QCheckBox(tr("Disable if chat window is active"));
    activetabWidget->setChecked(ActiveTabIsEnable);
    NotInRosterWidget = new QCheckBox(tr("Disable if contact isn't from your roster"));
    NotInRosterWidget->setChecked(NotInRoster);

    sonlineWidget = new QCheckBox(tr("Online"));
    sonlineWidget->setChecked(SOnline);
    sawayWidget = new QCheckBox(tr("Away"));
    sawayWidget->setChecked(SAway);
    sdndWidget = new QCheckBox(tr("Dnd"));
    sdndWidget->setChecked(SDnd);
    sxaWidget = new QCheckBox(tr("XA"));
    sxaWidget->setChecked(SXa);
    schatWidget = new QCheckBox(tr("Chat"));
    schatWidget->setChecked(SChat);
    sinvisWidget = new QCheckBox(tr("Invisible"));
    sinvisWidget->setChecked(SInvis);

    QGroupBox *groupBox = new QGroupBox(tr("Enable if status is:"));
    QHBoxLayout *statusLayout = new QHBoxLayout;
    statusLayout->addWidget(sonlineWidget);
    if(psiOptions->getGlobalOption("options.ui.menu.status.chat").toBool()) {
        statusLayout->addWidget(schatWidget); }
    statusLayout->addWidget(sawayWidget);
    statusLayout->addWidget(sdndWidget);
    if(psiOptions->getGlobalOption("options.ui.menu.status.xa").toBool()) {
        statusLayout->addWidget(sxaWidget); }
    if(psiOptions->getGlobalOption("options.ui.menu.status.invisible").toBool()) {
        statusLayout->addWidget(sinvisWidget); }
    statusLayout->addStretch();
    groupBox->setLayout(statusLayout);

    QVBoxLayout *Layout = new QVBoxLayout;
    Layout->addWidget(new QLabel(tr("Auto Reply Message:")));
    Layout->addWidget(messageWidget);
    QVBoxLayout *disableLayout = new QVBoxLayout;
    QHBoxLayout *EnDis = new QHBoxLayout;
    EnDis->addWidget(enabledisableWidget);
    EnDis->addWidget(new QLabel(tr("for JIDs and conferences:")));
    QLabel *Label = new QLabel(tr("You can also specify a part of JID\n(without any additional symbols)"));
    QFont font;
    font.setPointSize(8);
    Label->setFont(font);
    disableLayout->addLayout(EnDis);
    disableLayout->addWidget(disableforWidget);
    disableLayout->addWidget(Label);
    QVBoxLayout *AccLayout = new QVBoxLayout;
    AccLayout->addWidget(new QLabel(tr("Disable for your accounts (specify your JIDs):")));
    AccLayout->addWidget(DisableForAccWidget);
    QHBoxLayout *resetLayout = new QHBoxLayout;
    resetLayout->addWidget(new QLabel(tr("Timeout to reset counter:")));
    resetLayout->addWidget(resetWidget);
    resetLayout->addWidget(new QLabel(tr("min.")));
    resetLayout->addStretch();
    QHBoxLayout *timesLayout = new QHBoxLayout;
    timesLayout->addWidget(new QLabel(tr("Send maximum")));
    timesLayout->addWidget(spinWidget);
    timesLayout->addWidget(new QLabel(tr("times (-1=infinite)")));
    timesLayout->addStretch();
    QVBoxLayout *flags = new QVBoxLayout;
    flags->addLayout(AccLayout);
    flags->addStretch();
    flags->addLayout(timesLayout);
    flags->addLayout(resetLayout);
    flags->addWidget(activetabWidget);
    flags->addWidget(NotInRosterWidget);
    QHBoxLayout *hLayout = new QHBoxLayout;
    hLayout->addLayout(disableLayout);
    QFrame *frame = new QFrame();
    frame->setMinimumWidth(8);
    hLayout->addWidget(frame);
    hLayout->addLayout(flags);
    QLabel *wikiLink = new QLabel(tr("<a href=\"https://psi-plus.com/wiki/plugins#autoreply_plugin\">Wiki (Online)</a>"));
    wikiLink->setOpenExternalLinks(true);
    QVBoxLayout *tab1Layout = new QVBoxLayout(optionsWid);
    tab1Layout->addLayout(Layout);
    tab1Layout->addStretch();
    tab1Layout->addLayout(hLayout);
    tab1Layout->addWidget(groupBox);
    tab1Layout->addWidget(wikiLink);

    connect(enabledisableWidget, SIGNAL(currentIndexChanged(int)), SLOT(setEnableDisableText(int)));

    return optionsWid;
}