示例#1
0
PlaylistPage::PlaylistPage(SPView *mainView, QWidget *parent) :
    SPPage(mainView, parent)
{
    this->m_scrollView = new QScrollArea();
    this->m_treeView = new QTreeWidget();
    this->tabWidget()->addTab(m_scrollView, QString("Playlist"));

    m_scrollView->setWidgetResizable(true);
    m_header = new SpiderPage(this, this);
    m_header->setPage(":/views/playlist_header.xml", getToken());
    QFrame *frame = new QFrame(this);
    m_scrollView->setLayout(new QVBoxLayout());
    frame->setLayout(new QVBoxLayout());
    frame->layout()->addWidget(m_header);
    m_header->size().setWidth(100);
    m_header->size().setHeight(1164);
    ((QBoxLayout*)frame->layout())->addWidget(m_treeView, 2);

    m_scrollView->setWidget(frame);
    // Add sample
    QTreeWidgetItem *item1 = new QTreeWidgetItem();
    item1->setText(0, QString("Home"));
    item1->setData(0, Qt::UserRole, QVariant("soaring:internal:home"));
    m_treeView->addTopLevelItem(item1);
}
示例#2
0
void QgsOptionsDialogBase::initOptionsBase( bool restoreUi )
{
  // don't add to dialog margins
  // redefine now, or those in inherited .ui file will be added
  if ( layout() )
  {
    layout()->setContentsMargins( 0, 0, 0, 0 ); // Qt default spacing
  }

  // start with copy of qgsoptionsdialog_template.ui to ensure existence of these objects
  mOptListWidget = findChild<QListWidget*>( "mOptionsListWidget" );
  QFrame* optionsFrame = findChild<QFrame*>("mOptionsFrame");
  mOptStackedWidget = findChild<QStackedWidget*>( "mOptionsStackedWidget" );
  mOptSplitter = findChild<QSplitter*>( "mOptionsSplitter" );
  mOptButtonBox = findChild<QDialogButtonBox*>( "buttonBox" );
  QFrame* buttonBoxFrame = findChild<QFrame*>("mButtonBoxFrame");

  if ( !mOptListWidget || !mOptStackedWidget || !mOptSplitter || !optionsFrame )
  {
    return;
  }

  QSettings settings;
  int size = settings.value( "/IconSize", 24 ).toInt();
  mOptListWidget->setIconSize( QSize(size, size) );

  optionsFrame->layout()->setContentsMargins(0,3,3,3);
  QVBoxLayout* layout = static_cast<QVBoxLayout*>(optionsFrame->layout());

  if ( buttonBoxFrame )
  {
      buttonBoxFrame->layout()->setContentsMargins(0,0,0,0);
      layout->insertWidget(layout->count() + 1, buttonBoxFrame );
  }
  else
  {
      layout->insertWidget( layout->count() + 1, mOptButtonBox );
  }

  if ( mOptButtonBox )
  {
    // enforce only one connection per signal, in case added in Qt Designer
    disconnect( mOptButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
    connect( mOptButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
    disconnect( mOptButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
    connect( mOptButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
  }
  connect( mOptSplitter, SIGNAL( splitterMoved( int, int ) ), this, SLOT( updateOptionsListVerticalTabs() ) );
  connect( mOptStackedWidget, SIGNAL( currentChanged( int ) ), this, SLOT( optionsStackedWidget_CurrentChanged( int ) ) );
  connect( mOptStackedWidget, SIGNAL( widgetRemoved( int ) ), this, SLOT( optionsStackedWidget_WidgetRemoved( int ) ) );

  mInit = true;

  if ( restoreUi )
    restoreOptionsBaseUi();
}
示例#3
0
QWidget *DialogController::frameWidget(QWidget *widget)
{
    QFrame *frame = new QFrame(m_parent);
    frame->setLayout(new QHBoxLayout);
    frame->setObjectName("actionFrame");
    frame->setMinimumWidth(widget->width());
    frame->layout()->addWidget(widget);
    frame->layout()->setContentsMargins(0,0,0,0);
    if(m_mode == Bottom) {
        frame->setStyleSheet("QFrame#actionFrame { background: rgb(35,35,35); border:none; border-top:2px solid rgb(108,108,108);}");
    }
    return frame;
}
示例#4
0
SplashScreen::SplashScreen( QWidget *parent /* = NULL*/ ):QDialog(parent) {
    setEnabled(false);
    setAttribute(Qt::WA_DeleteOnClose);
    setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
#ifdef Q_OS_WIN
    setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
#endif
    setWindowModality(Qt::ApplicationModal);
    QHBoxLayout* mainLayout = new QHBoxLayout();
    setLayout(mainLayout);
    setContentsMargins(0, 0, 0, 0);
    mainLayout->setMargin(0);
    QFrame *frame = new QFrame(this);
    mainLayout->addWidget(frame);

    QHBoxLayout* frameLayout = new QHBoxLayout();
    frameLayout->setMargin(0);
    frame->setContentsMargins(0, 0, 0, 0);
    frame->setLayout(frameLayout);

    SplashScreenWidget* sWidget = new SplashScreenWidget();

    QVBoxLayout* aWLayout = (QVBoxLayout*)frame->layout();
    aWLayout->insertWidget(0, sWidget);
    aWLayout->setStretchFactor(sWidget, 100);
    installEventFilter(this);
}
示例#5
0
void ImageView::zoomFitBest()
{
   _zoomOriginal = false;
   QFrame * frame = dynamic_cast<QFrame*>(parent());
   if ( frame ) {
      QRect rect = frame->layout()->contentsRect();
      setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
      resize(rect.width(),rect.height());
   }
}
示例#6
0
/**
 * Constructor.
 */
CQGLViewport::CQGLViewport(QWidget* pParent, Qt::WFlags f):
    QFrame(pParent, f)
    , mpVerticalScrollbar(new QScrollBar(Qt::Vertical, NULL))
    , mpHorizontalScrollbar(new QScrollBar(Qt::Horizontal, NULL))
    , mpNetworkPainter(NULL)
{
  QVBoxLayout* pVBoxLayout = new QVBoxLayout();
  this->setLayout(pVBoxLayout);
  QFrame* pHBox = new QFrame(this);
  pHBox->setLayout(new QHBoxLayout());
  pVBoxLayout->addWidget(pHBox);
  QGLFormat format;
  format.setDoubleBuffer(TRUE);
  this->mpNetworkPainter = new CQGLNetworkPainter(format, pHBox);
  pHBox->layout()->addWidget(this->mpNetworkPainter);
  pHBox->layout()->addWidget(this->mpVerticalScrollbar);
  this->mpVerticalScrollbar->setSingleStep(1);
  pVBoxLayout->addWidget(this->mpHorizontalScrollbar);
  this->mpHorizontalScrollbar->setSingleStep(1);
  connect(this->mpVerticalScrollbar, SIGNAL(valueChanged(int)), this, SLOT(slotVValueChanged(int)));
  connect(this->mpHorizontalScrollbar, SIGNAL(valueChanged(int)), this, SLOT(slotHValueChanged(int)));
}
示例#7
0
PipelineWidget::PipelineWidget(VisualizationServicePtr visualizationService, PatientModelServicePtr patientModelService, QWidget* parent, PipelinePtr pipeline) :
    BaseWidget(parent, "PipelineWidget", "Pipeline"),
    mPipeline(pipeline)
{
	this->setToolTip("Run a series of filters");
	FilterGroupPtr filters = mPipeline->getFilters();
	std::vector<SelectDataStringPropertyBasePtr> nodes = mPipeline->getNodes();
	if (filters->size()+1 != nodes.size())
		reportError("Filter/Node mismatch");

	QVBoxLayout* topLayout = new QVBoxLayout(this);
	mButtonGroup = new QButtonGroup(this);

	struct Inner
	{
		static QHBoxLayout* addHMargin(QWidget* base)
		{
			QHBoxLayout* layout = new QHBoxLayout;
			layout->addWidget(base);
			layout->setContentsMargins(4,0,4,0);
			return layout;
		}
	};

	for (unsigned i=0; i<filters->size(); ++i)
	{
		topLayout->addLayout(Inner::addHMargin(new DataSelectWidget(visualizationService, patientModelService, this, nodes[i])));

		PipelineWidgetFilterLine* algoLine = new PipelineWidgetFilterLine(this, filters->get(i), mButtonGroup);
		connect(algoLine, SIGNAL(requestRunFilter()), this, SLOT(runFilterSlot()));
		connect(algoLine, SIGNAL(filterSelected(QString)), this, SLOT(filterSelectedSlot(QString)));
		algoLine->mTimedAlgorithmProgressBar->attach(mPipeline->getTimedAlgorithm(filters->get(i)->getUid()));

		mAlgoLines.push_back(algoLine);
		QFrame* frame = this->wrapInFrame(algoLine);
		frame->layout()->setContentsMargins(4,4,4,4); // nice on linux
		frame->setObjectName("FilterBackground");
		topLayout->addWidget(frame);
	}
	topLayout->addLayout(Inner::addHMargin(new DataSelectWidget(visualizationService, patientModelService, this, nodes.back())));

	topLayout->addSpacing(12);

	mSetupWidget = new CompactFilterSetupWidget(visualizationService, patientModelService, this, filters->getOptions(), true);
	topLayout->addWidget(mSetupWidget);

	topLayout->addStretch();

	this->filterSelectedSlot(filters->get(0)->getUid());
}
示例#8
0
void SysTrayIconPlugin::apply()
{
  bool systrayon = _config->readValue("systrayon").toBool();

  if (_systrayicon != NULL) {
    if (systrayon && QSystemTrayIcon::isSystemTrayAvailable()) {
      _systrayicon->show();
      _mainwin->setQuitOnClose(false);
    } else {
      _systrayicon->hide();
      _mainwin->setQuitOnClose(true);
    }
  }

  // replace main window's quit button by a close button or restore quit button if option was unchecked.

  QFrame *mainFrmMain = _mainwin->findChild<QFrame*>("frmMain");
  QPushButton *mainBtnQuit = _mainwin->findChild<QPushButton*>("btnQuit");

  if ( systrayon && _mainButtonBar == NULL ) {
    _mainButtonBar = new SysTrayMainIconifyButtons(mainFrmMain);
    mainFrmMain->layout()->addWidget(_mainButtonBar);
    connect(_mainButtonBar->btnIconify, SIGNAL(clicked()), this, SLOT(minimize()));
    connect(_mainButtonBar->btnQuit, SIGNAL(clicked()), _mainwin, SLOT(quit()));
  }

  bool wantreplacequitbutton;
#ifdef KLF_MAC_HIDE_INSTEAD
  // the user should disable "Dock into systray" altogether if he doesn't want this
  // as the only way he would have to hide the app is through the mac menu anyway
  wantreplacequitbutton = true;
#else
  wantreplacequitbutton = _config->readValue("replacequitbutton").toBool();
#endif
    
  if ( systrayon && wantreplacequitbutton ) {
    mainBtnQuit->hide();
    _mainButtonBar->show();
  } else if (_mainButtonBar != NULL) {
    _mainButtonBar->hide();
    mainBtnQuit->show();
  }

}
示例#9
0
QToolButton * AdvancedImageWidget::addToolButton(QString name, QIcon icon, bool checkable)
{
    QFrame* holder = getToolsFrame();
    QToolButton *toolButton = new QToolButton();
    toolButton->setIcon(icon);
    toolButton->setText(name);
    toolButton->setToolTip(name);
    toolButton->setIconSize(QSize(24,24));
    if (checkable)
    {
        toolButton->setAutoExclusive(true);
        toolButton->setCheckable(true);
        toolButton->setAutoRaise(true);
    }
    holder->layout()->addWidget(toolButton);

    connect(toolButton, SIGNAL(released()),&mToolMapper, SLOT(map()));
    mToolMapper.setMapping(toolButton, toolButton);
    //connect(toolButton, SIGNAL(released()), this, SLOT(toolButtonReleased()));
    return toolButton;
}
void EditConfigTreeText::fillToolBox() {
    for(;ui->toolBox->count()>0;ui->toolBox->removeItem(0));

    for (int streamKind=0; streamKind<(int)Stream_Max; streamKind++) {
        if(streamKind==Stream_Chapters)
            continue;
        QFrame* box = new QFrame();
        qDebug() << "adding " << wstring2QString(C->StreamName((stream_t)streamKind));
        ui->toolBox->addItem(box,wstring2QString(C->StreamName((stream_t)streamKind)));
        QString s = wstring2QString(C->Parameters());
        s.replace("\r\n","\n");
        s.remove(0,s.indexOf(wstring2QString(C->StreamName((stream_t)streamKind))+"\n"));
        s.truncate((s.indexOf("\n\n")==-1?s.size():s.indexOf("\n\n")));
        QStringList sl = s.split("\n");
        sl.removeAt(0);
        sl.replaceInStrings(QRegExp(";(.*)"),"");
        box->setLayout(new QVBoxLayout());
        for (int i=0; i<sl.size(); ++i) {
            QCheckBox* check = new QCheckBox(sl.at(i));
            check->setChecked(ctt->getFields(streamKind).contains(sl.at(i)));
            box->layout()->addWidget(check);
        }
    }
}
示例#11
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    settings(qApp->organizationName(), qApp->applicationName())
{
    ui->setupUi(this);

    vkaudio = new VKAudio();
    oauth = new OAuth(this);
    connect(oauth, SIGNAL(authFinished()), vkaudio, SLOT(loadSessionInfo()));

    oauth->authenticate();

    dp = new DataProvider();

    playerControls = new PlayerControls(this);
    playerControls->setObjectName("controls");
    playerControls->setStyleSheet("#controls {background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
                        "stop: 0 #28292d,"
                        "stop: 0.98 #2e2f2c,"
                        "stop: 1 #27282c);}");

    QFrame *playerFrame = ui->PlayerFrame;
    playerFrame->layout()->addWidget(playerControls);

    player = new QMediaPlayer(this);
    playlist = new PlayerPlaylist();
    player->setPlaylist(playlist);

    createConnections();

    loadSettings();

    loadPlaylists();
    createSongsTable(0);
}
void QgsOptionsDialogBase::initOptionsBase( bool restoreUi, QString title )
{
  // use pointer to app QSettings if no custom QSettings specified
  // custom QSettings object may be from Python plugin
  mDelSettings = false;

  if ( !mSettings )
  {
    mSettings = new QSettings();
    mDelSettings = true; // only delete obj created by class
  }

  // save dialog title so it can be used to be concatenated
  // with category title in icon-only mode
  if ( title.isEmpty() )
    mDialogTitle = windowTitle();
  else
    mDialogTitle = title;

  // don't add to dialog margins
  // redefine now, or those in inherited .ui file will be added
  if ( layout() )
  {
    layout()->setContentsMargins( 0, 0, 0, 0 ); // Qt default spacing
  }

  // start with copy of qgsoptionsdialog_template.ui to ensure existence of these objects
  mOptListWidget = findChild<QListWidget*>( "mOptionsListWidget" );
  QFrame* optionsFrame = findChild<QFrame*>( "mOptionsFrame" );
  mOptStackedWidget = findChild<QStackedWidget*>( "mOptionsStackedWidget" );
  mOptSplitter = findChild<QSplitter*>( "mOptionsSplitter" );
  mOptButtonBox = findChild<QDialogButtonBox*>( "buttonBox" );
  QFrame* buttonBoxFrame = findChild<QFrame*>( "mButtonBoxFrame" );

  if ( !mOptListWidget || !mOptStackedWidget || !mOptSplitter || !optionsFrame )
  {
    return;
  }

  int size = mSettings->value( "/IconSize", 24 ).toInt();
  // buffer size to match displayed icon size in toolbars, and expected geometry restore
  // newWidth (above) may need adjusted if you adjust iconBuffer here
  int iconBuffer = 4;
  mOptListWidget->setIconSize( QSize( size + iconBuffer, size + iconBuffer ) );
  mOptListWidget->setFrameStyle( QFrame::NoFrame );

  optionsFrame->layout()->setContentsMargins( 0, 3, 3, 3 );
  QVBoxLayout* layout = static_cast<QVBoxLayout*>( optionsFrame->layout() );

  if ( buttonBoxFrame )
  {
    buttonBoxFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
    layout->insertWidget( layout->count() + 1, buttonBoxFrame );
  }
  else
  {
    layout->insertWidget( layout->count() + 1, mOptButtonBox );
  }

  if ( mOptButtonBox )
  {
    // enforce only one connection per signal, in case added in Qt Designer
    disconnect( mOptButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
    connect( mOptButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
    disconnect( mOptButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
    connect( mOptButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
  }
  connect( mOptSplitter, SIGNAL( splitterMoved( int, int ) ), this, SLOT( updateOptionsListVerticalTabs() ) );
  connect( mOptStackedWidget, SIGNAL( currentChanged( int ) ), this, SLOT( optionsStackedWidget_CurrentChanged( int ) ) );
  connect( mOptStackedWidget, SIGNAL( widgetRemoved( int ) ), this, SLOT( optionsStackedWidget_WidgetRemoved( int ) ) );

  mInit = true;

  if ( restoreUi )
    restoreOptionsBaseUi( mDialogTitle );
}
示例#13
0
void pTreeComboBox::calculPopupGeometry()
{
    if ( !mView ) {
        return;
    }
    
    QStyle * const style = this->style();

    // set current item and select it
    view()->selectionModel()->setCurrentIndex( mCurrentIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
    QFrame* container = mFrame;
    QStyleOptionComboBox opt;
    initStyleOption( &opt );
    QRect listRect( style->subControlRect( QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxListBoxPopup, this ) );
    QRect screen = popupGeometry( QApplication::desktop()->screenNumber( this ) );
    QPoint below = mapToGlobal( listRect.bottomLeft() );
    int belowHeight = screen.bottom() -below.y();
    QPoint above = mapToGlobal( listRect.topLeft() );
    int aboveHeight = above.y() -screen.y();
    bool boundToScreen = !window()->testAttribute( Qt::WA_DontShowOnScreen );
    
    listRect.moveTopLeft( mapToGlobal( rect().bottomLeft() ) );
    listRect.setSize( QSize( 
        qMax( qMax( view()->viewport()->width(), mFrame->width() ), width() )
        ,
        qMax( view()->viewport()->height(), mFrame->height() )
    ) );

    const bool usePopup = style->styleHint( QStyle::SH_ComboBox_Popup, &opt, this );
    {
        int listHeight = 0;
        int count = 0;
        QStack<QModelIndex> toCheck;
        toCheck.push( view()->rootIndex() );
#ifndef QT_NO_TREEVIEW
        QTreeView* treeView = qobject_cast<QTreeView*>( view() );
        if ( treeView && treeView->header() && !treeView->header()->isHidden() )
            listHeight += treeView->header()->height();
#endif
        while ( !toCheck.isEmpty() ) {
            QModelIndex parent = toCheck.pop();
            for ( int i = 0; i < model()->rowCount( parent ); ++i ) {
                QModelIndex idx = model()->index( i, mModelColumn, parent );
                if ( !idx.isValid() )
                    continue;
                listHeight += view()->visualRect( idx ).height();
#ifndef QT_NO_TREEVIEW
                if ( model()->hasChildren( idx ) && treeView && treeView->isExpanded( idx ) )
                    toCheck.push( idx );
#endif
                ++count;
                if ( !usePopup && count > mMaxVisibleItems ) {
                    toCheck.clear();
                    break;
                }
            }
        }
        listRect.setHeight( listHeight );
    }

    {
        // add the spacing for the grid on the top and the bottom;
        int heightMargin = 0;

        // add the frame of the container
        int marginTop, marginBottom;
        container->getContentsMargins( 0, &marginTop, 0, &marginBottom );
        heightMargin += marginTop +marginBottom;

        //add the frame of the view
        view()->getContentsMargins( 0, &marginTop, 0, &marginBottom );
        marginTop += 0/*static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->top*/;
        marginBottom += 0/*static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->bottom*/;
        heightMargin += marginTop +marginBottom;

        listRect.setHeight( listRect.height() +heightMargin );
    }

    // Add space for margin at top and bottom if the style wants it.
    if ( usePopup )
        listRect.setHeight( listRect.height() +style->pixelMetric( QStyle::PM_MenuVMargin, &opt, this ) *2 );

    // Make sure the popup is wide enough to display its contents.
    if ( usePopup ) {
        const int diff = sizeHint().width() /*d->computeWidthHint()*/ -width();
        if ( diff > 0 )
            listRect.setWidth( listRect.width() +diff );
    }

    //we need to activate the layout to make sure the min/maximum size are set when the widget was not yet show
    container->layout()->activate();
    //takes account of the minimum/maximum size of the container
    listRect.setSize( listRect.size().expandedTo(container->minimumSize())
                      .boundedTo(container->maximumSize()));

    // make sure the widget fits on screen
    if (boundToScreen) {
        if (listRect.width() > screen.width() )
            listRect.setWidth(screen.width());
        if (/*mapToGlobal(*/listRect/*.bottomRight())*/.x() > screen.right()) {
            below.setX(screen.x() + screen.width() - listRect.width());
            above.setX(screen.x() + screen.width() - listRect.width());
        }
        if (/*mapToGlobal(*/listRect/*.topLeft())*/.x() < screen.x() ) {
            below.setX(screen.x());
            above.setX(screen.x());
        }
    }

    if ( usePopup ) {
        // Position horizontally.
        listRect.moveLeft( above.x() );

        // Position vertically so the curently selected item lines up
        // with the combo box.
        /*const QRect currentItemRect = view()->visualRect( view()->currentIndex() );
        const int offset = listRect.top() -currentItemRect.top();
        listRect.moveTop( above.y() +offset -listRect.top() );*/

        // Clamp the listRect height and vertical position so we don't expand outside the
        // available screen geometry.This may override the vertical position, but it is more
        // important to show as much as possible of the popup.
        const int height = !boundToScreen ? listRect.height() : qMin(listRect.height(), screen.height());
        listRect.setHeight(height);
        if (boundToScreen) {
            if (listRect.top() < screen.top())
                listRect.moveTop(screen.top());
            if (listRect.bottom() > screen.bottom())
                listRect.moveBottom(screen.bottom());
        }
    } else if (!boundToScreen || listRect.height() <= belowHeight) {
        listRect.moveTopLeft(below);
    } else if (listRect.height() <= aboveHeight) {
        listRect.moveBottomLeft(above);
    } else if (belowHeight >= aboveHeight) {
        listRect.setHeight(belowHeight);
        listRect.moveTopLeft(below);
    } else {
        listRect.setHeight(aboveHeight);
        listRect.moveBottomLeft(above);
    }

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#ifndef QT_NO_IM
    if ( QInputContext *qic = inputContext() )
        qic->reset();
#endif
#endif
    QScrollBar* sb = view()->horizontalScrollBar();
    Qt::ScrollBarPolicy policy = view()->horizontalScrollBarPolicy();
    bool needHorizontalScrollBar = ( policy == Qt::ScrollBarAsNeeded || policy == Qt::ScrollBarAlwaysOn ) && sb->minimum() < sb->maximum();
    if ( needHorizontalScrollBar ) {
        listRect.adjust( 0, 0, 0, sb->height() );
    }
    
    container->setGeometry( listRect );

#ifndef Q_WS_MAC
    const bool updatesEnabled = container->updatesEnabled();
#endif

#if defined( Q_WS_WIN ) && !defined( QT_NO_EFFECTS )
// FIXME Fix me ASAP
    /*bool scrollDown = ( listRect.topLeft() == below );
    if ( QApplication::isEffectEnabled( Qt::UI_AnimateCombo ) 
        && !style->styleHint( QStyle::SH_ComboBox_Popup, &opt, this ) && !window()->testAttribute( Qt::WA_DontShowOnScreen ) )
        qScrollEffect( container, scrollDown ? QEffects::DownScroll : QEffects::UpScroll, 150 );*/
#endif

// Don't disable updates on Mac OS X. Windows are displayed immediately on this platform,
// which means that the window will be visible before the call to container->show() returns.
// If updates are disabled at this point we'll miss our chance at painting the popup 
// menu before it's shown, causing flicker since the window then displays the standard gray 
// background.
#ifndef Q_WS_MAC
    container->setUpdatesEnabled( false );
#endif

    container->raise();
    container->show();
    //container->updateScrollers();
    view()->setFocus();

    view()->scrollTo( view()->currentIndex(), style->styleHint( QStyle::SH_ComboBox_Popup, &opt, this ) ? QAbstractItemView::PositionAtCenter : QAbstractItemView::EnsureVisible );

#ifndef Q_WS_MAC
    container->setUpdatesEnabled( updatesEnabled );
#endif

    container->update();
#ifdef QT_KEYPAD_NAVIGATION
    if ( QApplication::keypadNavigationEnabled() )
        view()->setEditFocus( true );
#endif
}
示例#14
0
void DisplayArea::setupUI()
{
    this->setLayout(new QGridLayout());
    this->setStyleSheet("background-color: rgb(47, 47, 47); color: " +
                        QString(globcon::GREENCOLOR) + "; \n" + " QToolTip {}");
    this->setAutoFillBackground(true);
    this->layout()->setSpacing(0);
    QMargins layMargins = this->layout()->contentsMargins();
    layMargins.setBottom(0);
    layMargins.setTop(0);
    this->layout()->setContentsMargins(layMargins);

    // init header
    this->frameHeader = new QFrame();
    this->frameHeader->setLayout(new QHBoxLayout());
    dynamic_cast<QGridLayout *>(this->layout())
        ->addWidget(this->frameHeader, 0, 0);

    this->labelDeviceName = new QLabel();
    this->labelDeviceName->setText("Unknown Device");
    this->frameHeader->layout()->addWidget(this->labelDeviceName);

    dynamic_cast<QHBoxLayout *>(this->frameHeader->layout())->addStretch();

    this->labelConnect = new ClickableLabel();
    this->labelConnect->setPixmap(QPixmap(":/icons/plug_out_orange.png"));
    this->labelConnect->setMinimumWidth(37);
    this->labelConnect->setToolTip("Disconnected");
    this->labelConnect->setNoReturnValue(true);
    this->labelConnect->setAlignment(Qt::AlignCenter);
    this->frameHeader->layout()->addWidget(this->labelConnect);
    QObject::connect(this->labelConnect, &ClickableLabel::doubleClickNoValue,
                     [this]() {
                         emit this->deviceControlValueChanged(
                             static_cast<int>(globcon::LPQ_CONTROL::CONNECT), 0);
                     });

    this->labelSound = new ClickableLabel();
    this->labelSound->setPixmap(QPixmap(":/icons/speaker_orange.png"));
    this->labelSound->setMinimumWidth(25);
    this->labelSound->setToolTip("Sound on");
    this->labelSound->setNoReturnValue(true);
    this->labelSound->setAlignment(Qt::AlignCenter);
    this->frameHeader->layout()->addWidget(this->labelSound);

    this->labelLock = new ClickableLabel();
    this->labelLock->setPixmap(QPixmap(":/icons/lock-open_orange.png"));
    this->labelLock->setMinimumSize(QSize(25, 16));
    this->labelLock->setToolTip("Device Controls unlocked");
    this->labelLock->setNoReturnValue(true);
    this->labelLock->setAlignment(Qt::AlignCenter);
    this->frameHeader->layout()->addWidget(this->labelLock);

    this->headerControls = {this->labelConnect, this->labelSound,
                            this->labelLock};

    // init channels
    this->frameChannels = new QFrame();
    this->frameChannels->setLayout(new QHBoxLayout());
    this->frameChannels->layout()->setSpacing(0);
    this->frameChannels->layout()->setContentsMargins(QMargins());
    dynamic_cast<QGridLayout *>(this->layout())
        ->addWidget(this->frameChannels, 1, 0);
    this->frameChannels->setMinimumHeight(200);

    // init footer
    this->frameFooter = new QFrame();
    this->frameFooter->setLayout(new QHBoxLayout());
    this->frameFooter->layout()->setContentsMargins(0, 0, 0, 0);
    this->frameFooter->layout()->setSpacing(0);

    dynamic_cast<QGridLayout *>(this->layout())
        ->addWidget(this->frameFooter, 2, 0);

    QFrame *frameOVP = new QFrame();
    frameOVP->setLayout(new QHBoxLayout());
    frameOVP->layout()->addWidget(new QLabel("OVP:"));
    this->labelOVPSet = new ClickableLabel();
    this->labelOVPSet->setText("Off");
    this->labelOVPSet->setNoReturnValue(true);
    this->labelOVPSet->setMinimumWidth(20);
    frameOVP->layout()->addWidget(this->labelOVPSet);
    this->frameFooter->layout()->addWidget(frameOVP);
    QObject::connect(this->labelOVPSet, &ClickableLabel::doubleClickNoValue,
                     [this]() {
                         emit this->deviceControlValueChanged(
                             static_cast<int>(globcon::LPQ_CONTROL::OVP), 0);
                     });

    QFrame *frameOCP = new QFrame();
    frameOCP->setLayout(new QHBoxLayout());
    frameOCP->layout()->addWidget(new QLabel("OCP:"));
    this->labelOCPSet = new ClickableLabel();
    this->labelOCPSet->setText("Off");
    this->labelOCPSet->setNoReturnValue(true);
    this->labelOCPSet->setMinimumWidth(20);
    frameOCP->layout()->addWidget(this->labelOCPSet);
    this->frameFooter->layout()->addWidget(frameOCP);
    QObject::connect(this->labelOCPSet, &ClickableLabel::doubleClickNoValue,
                     [this]() {
                         emit this->deviceControlValueChanged(
                             static_cast<int>(globcon::LPQ_CONTROL::OCP), 0);
                     });

    QFrame *frameOTP = new QFrame();
    frameOTP->setLayout(new QHBoxLayout());
    frameOTP->layout()->addWidget(new QLabel("OTP:"));
    this->labelOTPSet = new ClickableLabel();
    this->labelOTPSet->setText("Off");
    this->labelOTPSet->setNoReturnValue(true);
    this->labelOTPSet->setMinimumWidth(20);
    frameOTP->layout()->addWidget(this->labelOTPSet);
    this->frameFooter->layout()->addWidget(frameOTP);
    QObject::connect(this->labelOTPSet, &ClickableLabel::doubleClickNoValue,
                     [this]() {
                         emit this->deviceControlValueChanged(
                             static_cast<int>(globcon::LPQ_CONTROL::OTP), 0);
                     });

    QFrame *frameTracking = new QFrame();
    frameTracking->setLayout(new QHBoxLayout());
    frameTracking->layout()->addWidget(new QLabel("Tracking:"));
    this->labelTrackingSet = new ClickableLabel();
    this->labelTrackingSet->setText("None");
    frameTracking->layout()->addWidget(this->labelTrackingSet);
    this->frameFooter->layout()->addWidget(frameTracking);

    dynamic_cast<QHBoxLayout *>(frameTracking->layout())->addStretch();
}
示例#15
0
// The following two functions are very big. Lots of code is necessay for
// dynamically build guis.
void DisplayArea::setupChannels()
{
    this->labelConnect->setClickable(false);
    QSettings settings;
    settings.beginGroup(setcon::DEVICE_GROUP);
    settings.beginGroup(settings.value(setcon::DEVICE_ACTIVE).toString());

    if (settings.contains(setcon::DEVICE_PORT)) {
        // if there is a device we must enable the connect button.
        this->labelConnect->setClickable(true);
        // TODO: One could make this more intelligent and only create / delete
        // channels that are (no longer) needed.

        // remove all channels from the frame if there are any. Happens if the
        // user changes the device specs or chooses another one.
        for (auto f : this->channelFramesVec) {
            utils::clearLayout(f->layout());
            this->frameChannels->layout()->removeWidget(f);
            delete (f);
        }
        // clear the vector
        this->channelFramesVec.clear();
        this->chanwVector.clear();

        // create the frames that control one channel
        for (int i = 1; i <= settings.value(setcon::DEVICE_CHANNELS).toInt();
             i++) {
            std::shared_ptr<ChannelWidgets> chanw =
                std::make_shared<ChannelWidgets>();

            QFrame *channelFrameContainer = new QFrame();
            channelFrameContainer->setLayout(new QVBoxLayout());
            channelFrameContainer->setObjectName("ch" + QString::number(i) +
                                                 "Container");
            // this is the container frame
            QString frameQss = QString("QFrame#%1 {border: 1px solid ") +
                               globcon::GREENCOLOR + ";}";
            channelFrameContainer->setStyleSheet(
                frameQss.arg(channelFrameContainer->objectName()));
            channelFrameContainer->layout()->setSpacing(0);
            channelFrameContainer->layout()->setContentsMargins(QMargins());

            this->frameChannels->layout()->addWidget(channelFrameContainer);

            // now the frame for the electrical values V, A, W.

            QFrame *vawFrame = new QFrame();
            vawFrame->setObjectName("ch" + QString::number(i) + "vawFrame");
            QString vawFrameQss =
                QString("QFrame#%1 {border-bottom: 1px solid ") +
                globcon::GREENCOLOR + ";}";
            vawFrame->setStyleSheet(vawFrameQss.arg(vawFrame->objectName()));
            QGridLayout *vawLayout = new QGridLayout();
            vawFrame->setLayout(vawLayout);
            channelFrameContainer->layout()->addWidget(vawFrame);

            vawLayout->addWidget(new QLabel("CH" + QString::number(i)), 0, 0, 1,
                                 0, Qt::AlignLeft);

            chanw->voltageActual = new QLabel("0.00");
            QFont actualFont = chanw->voltageActual->font();
            actualFont.setPointSize(20);
            chanw->voltageActual->setAlignment(Qt::AlignRight |
                                               Qt::AlignVCenter);
            chanw->voltageActual->setStyleSheet(
                QString("QLabel {padding-right: 0.5em;}"));
            chanw->voltageActual->setFont(actualFont);
            chanw->currentActual = new QLabel("0.000");
            chanw->currentActual->setAlignment(Qt::AlignRight |
                                               Qt::AlignVCenter);
            chanw->currentActual->setStyleSheet(
                QString("QLabel {padding-right: 0.5em;}"));
            chanw->currentActual->setFont(actualFont);
            chanw->wattageActual = new QLabel("0.000");
            chanw->wattageActual->setAlignment(Qt::AlignRight |
                                               Qt::AlignVCenter);
            chanw->wattageActual->setStyleSheet(
                QString("QLabel {padding-right: 0.5em;}"));
            chanw->wattageActual->setFont(actualFont);
            vawLayout->addWidget(chanw->voltageActual, 1, 0);
            vawLayout->addWidget(chanw->currentActual, 2, 0);
            vawLayout->addWidget(chanw->wattageActual, 3, 0);

            QLabel *vActualUnit = new QLabel("V");
            vActualUnit->setSizePolicy(QSizePolicy::Policy::Fixed,
                                       QSizePolicy::Policy::Preferred);
            vActualUnit->setAlignment(Qt::AlignTop);
            QLabel *aActualUnit = new QLabel("A");
            aActualUnit->setSizePolicy(QSizePolicy::Policy::Fixed,
                                       QSizePolicy::Policy::Preferred);
            aActualUnit->setAlignment(Qt::AlignTop);
            QLabel *wActualUnit = new QLabel("W");
            wActualUnit->setSizePolicy(QSizePolicy::Policy::Fixed,
                                       QSizePolicy::Policy::Preferred);
            wActualUnit->setAlignment(Qt::AlignTop);
            vawLayout->addWidget(vActualUnit, 1, 1);
            vawLayout->addWidget(aActualUnit, 2, 1);
            vawLayout->addWidget(wActualUnit, 3, 1);

            QFrame *bottomContainer = new QFrame();
            bottomContainer->setLayout(new QHBoxLayout());
            channelFrameContainer->layout()->addWidget(bottomContainer);
            bottomContainer->layout()->setSpacing(0);
            bottomContainer->layout()->setContentsMargins(QMargins());

            QFrame *setContainer = new QFrame();
            setContainer->setObjectName("ch" + QString::number(i) +
                                        "setContainer");
            QGridLayout *setContLayout = new QGridLayout();
            setContainer->setLayout(setContLayout);
            QString setContainerQss =
                QString("QFrame#%1 {border-right: 1px solid ") +
                globcon::GREENCOLOR + ";}";
            setContainer->setStyleSheet(
                setContainerQss.arg(setContainer->objectName()));
            chanw->voltageSet = new ClickableLabel("0.00");
            chanw->currentSet = new ClickableLabel("0.000");
            chanw->voltageSet->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
            chanw->currentSet->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

            // Now the lambdas for the set widgets
            QObject::connect(
                chanw->voltageSet, &ClickableLabel::doubleClick,
                [this, chanw, i](QPoint pos, double value) {
                    this->controlValuesDialog(
                        std::move(pos), chanw->voltageSet,
                        global_constants::LPQ_DATATYPE::SETVOLTAGE, value);
                    if (this->valuesDialog->exec()) {
                        emit this->doubleValueChanged(
                            this->valuesDialogData->voltage,
                            static_cast<int>(
                                global_constants::LPQ_DATATYPE::SETVOLTAGE),
                            i);
                    }
                });
            QObject::connect(
                chanw->currentSet, &ClickableLabel::doubleClick,
                [this, chanw, i](QPoint pos, double value) {
                    this->controlValuesDialog(
                        std::move(pos), chanw->currentSet,
                        global_constants::LPQ_DATATYPE::SETCURRENT, value);
                    if (this->valuesDialog->exec()) {
                        emit this->doubleValueChanged(
                            this->valuesDialogData->current,
                            static_cast<int>(
                                global_constants::LPQ_DATATYPE::SETCURRENT),
                            i);
                    }
                });

            QLabel *setLabel = new QLabel("Set");
            setLabel->setAlignment(Qt::AlignCenter);
            QLabel *voltageSetUnit = new QLabel("V");
            QFont bottomUnitFont = voltageSetUnit->font();
            bottomUnitFont.setPointSize(8);
            voltageSetUnit->setFont(bottomUnitFont);
            voltageSetUnit->setSizePolicy(QSizePolicy::Policy::Fixed,
                                          QSizePolicy::Policy::Preferred);
            voltageSetUnit->setAlignment(Qt::AlignTop);
            QLabel *currentSetUnit = new QLabel("A");
            currentSetUnit->setFont(bottomUnitFont);
            currentSetUnit->setSizePolicy(QSizePolicy::Policy::Fixed,
                                          QSizePolicy::Policy::Preferred);
            currentSetUnit->setAlignment(Qt::AlignTop);
            setContLayout->addWidget(setLabel, 0, 0, 1, 0);
            setContLayout->addWidget(chanw->voltageSet, 1, 0);
            setContLayout->addWidget(voltageSetUnit, 1, 1);
            setContLayout->addWidget(chanw->currentSet, 2, 0);
            setContLayout->addWidget(currentSetUnit, 2, 1);

            QFrame *modeOutputContainer = new QFrame();
            modeOutputContainer->setLayout(new QVBoxLayout());
            modeOutputContainer->layout()->setSpacing(0);
            modeOutputContainer->layout()->setContentsMargins(QMargins());

            QFrame *modeContainer = new QFrame();
            modeContainer->setLayout(new QHBoxLayout());
            modeContainer->setObjectName("ch" + QString::number(i) +
                                         "modeContainer");
            QString modeContainerQss =
                QString("QFrame#%1 {border-bottom: 1px solid ") +
                globcon::GREENCOLOR + ";}";
            modeContainer->setStyleSheet(
                modeContainerQss.arg(modeContainer->objectName()));
            QLabel *modeLabel = new QLabel("Mode");
            chanw->modeActual = new QLabel("CV");
            modeContainer->layout()->addWidget(modeLabel);
            modeContainer->layout()->addWidget(chanw->modeActual);

            QFrame *outputContainer = new QFrame();
            outputContainer->setLayout(new QHBoxLayout());
            QLabel *outputLabel = new QLabel("Output");
            chanw->outputSet = new ClickableLabel("Off");
            chanw->outputSet->setNoReturnValue(true);
            QObject::connect(
                chanw->outputSet, &ClickableLabel::doubleClickNoValue,
                [this, chanw, i]() {
                    emit this->deviceControlValueChanged(
                        static_cast<int>(global_constants::LPQ_CONTROL::OUTPUT),
                        i);
                });

            outputContainer->layout()->addWidget(outputLabel);
            outputContainer->layout()->addWidget(chanw->outputSet);

            modeOutputContainer->layout()->addWidget(modeContainer);
            modeOutputContainer->layout()->addWidget(outputContainer);

            bottomContainer->layout()->addWidget(setContainer);
            bottomContainer->layout()->addWidget(modeOutputContainer);

            this->channelFramesVec.push_back(channelFrameContainer);
            // move semantics are needed here because unique_ptr does not allow
            // copying what push_back actually does.
            this->chanwVector.push_back(std::move(chanw));
        }
    }
}
示例#16
0
pFileDialog::pFileDialog( QWidget* parent, const QString& caption, const QString& directory, const QString& filter, bool textCodecEnabled, bool openReadOnlyEnabled )
	: QFileDialog( parent, caption, directory, filter )
{
	setFileMode( QFileDialog::AnyFile );
	setOption( QFileDialog::DontUseNativeDialog );
	
	// get grid layout
	glDialog = qobject_cast<QGridLayout*>( layout() );
	
	// assert on gridlayout
	Q_ASSERT( glDialog );
	
	// relook the dialog to be more friendly
	QLabel* lLookIn = findChild<QLabel*>( "lookInLabel" );
	QComboBox* cbLookIn = findChild<QComboBox*>( "lookInCombo" );
	QToolButton* tbNewFolder = findChild<QToolButton*>( "newFolderButton" );
	QAbstractItemView* sidebar = findChild<QAbstractItemView*>( "sidebar" );
	QFrame* fFrame = findChild<QFrame*>( "frame" );
	QBoxLayout* hLayout = 0;
	
	// search layout containing tbNewFolder
	foreach ( QLayout* layout, findChildren<QLayout*>() ) {
		if ( layout->indexOf( tbNewFolder ) != -1 ) {
			hLayout = qobject_cast<QBoxLayout*>( layout );
			break;
		}
	}
	
	if ( lLookIn ) {
		lLookIn->setVisible( false );
	}
	
	if ( hLayout ) {
		hLayout->setSpacing( 3 );
		hLayout->insertStretch( hLayout->indexOf( tbNewFolder ) );
	}
	
	if ( cbLookIn && fFrame ) {
		QBoxLayout* vLayout = qobject_cast<QBoxLayout*>( fFrame->layout() );
		
		if ( vLayout ) {
			vLayout->setSpacing( 3 );
			vLayout->insertWidget( 0, cbLookIn );
			
			if ( hLayout ) {
				glDialog->removeItem( hLayout );
				hLayout->setParent( 0 );
				vLayout->insertLayout( 0, hLayout );
			}
		}
	}
	
	if ( sidebar ) {
		QWidget* viewport = sidebar->viewport();
		QPalette pal = viewport->palette();
		pal.setColor( viewport->backgroundRole(), QColor( Qt::transparent ) );
		viewport->setPalette( pal );
		sidebar->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
		sidebar->setIconSize( QSize( 16, 16 ) );
	}
	
	// text codec
	mTextCodecEnabled = true;
	
	lCodec = new QLabel( tr( "Codec:" ), this );
	cbCodec = new QComboBox( this );
	cbCodec->addItems( pCoreUtils::textCodecs() );
	setTextCodec( QTextCodec::codecForLocale()->name() );
	
	glDialog->addWidget( lCodec, 4, 0 );
	glDialog->addWidget( cbCodec, 4, 1 );
	
	// read only
	mOpenReadOnlyEnabled = true;
	
	cbOpenReadOnly = new QCheckBox( tr( "Open in read only." ), this );
	
	glDialog->addWidget( cbOpenReadOnly, 5, 1 );
	
	// configuration
	setTextCodecEnabled( textCodecEnabled );
	setOpenReadOnlyEnabled( openReadOnlyEnabled );
}
示例#17
0
void CoreWindow::createToolBar()
{ 
	//inicializacia comboboxu typov vyberu
	nodeTypeComboBox = new QComboBox();
	nodeTypeComboBox->insertItems(0,(QStringList() << "All" << "Node" << "Edge"));
	nodeTypeComboBox->setFocusPolicy(Qt::NoFocus);	
	connect(nodeTypeComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(nodeTypeComboBoxChanged(int)));

	toolBar = new QToolBar("Tools",this);

	QFrame * frame = createHorizontalFrame();
	
	frame->layout()->addWidget(noSelect);
	frame->layout()->addWidget(singleSelect);
	toolBar->addWidget(frame);
	
	frame = createHorizontalFrame();
	toolBar->addWidget(frame);
	frame->layout()->addWidget(multiSelect);
	frame->layout()->addWidget(center);

	toolBar->addWidget(nodeTypeComboBox);
	toolBar->addSeparator();

	frame = createHorizontalFrame();

	toolBar->addWidget(frame);
	frame->layout()->addWidget(addMeta);
	frame->layout()->addWidget(removeMeta);

	frame = createHorizontalFrame();

	toolBar->addWidget(frame);
	frame->layout()->addWidget(fix);
	frame->layout()->addWidget(unFix);

	frame = createHorizontalFrame();

	toolBar->addWidget(frame);
	frame->layout()->addWidget(merge);
	frame->layout()->addWidget(separate);

	toolBar->addWidget(label);
	toolBar->addSeparator();
	toolBar->addWidget(play);
	toolBar->addSeparator();
	toolBar->addWidget(add_Edge);
	toolBar->addWidget(add_Node);
	toolBar->addWidget(remove_all);
	toolBar->addWidget(applyColor);
	
	//inicializacia colorpickera
	QtColorPicker * colorPicker = new QtColorPicker();
	colorPicker->setStandardColors();
	connect(colorPicker,SIGNAL(colorChanged(const QColor &)),this,SLOT(colorPickerChanged(const QColor &)));
	toolBar->addWidget(colorPicker);	
	toolBar->addSeparator();
	
	// layout restrictions
	frame = createHorizontalFrame();
	toolBar->addWidget(frame);
	frame->layout()->addWidget(b_SetRestriction_SphereSurface);
	frame->layout()->addWidget(b_SetRestriction_Sphere);

	frame = createHorizontalFrame();
	toolBar->addWidget(frame);
	frame->layout()->addWidget(b_SetRestriction_Plane);
	frame->layout()->addWidget(b_UnsetRestriction);

	toolBar->addSeparator();

	//inicializacia slideru
	slider = new QSlider(Qt::Vertical,this);
	slider->setTickPosition(QSlider::TicksAbove);
	slider->setTickInterval(5);
	slider->setValue(5);
	slider->setFocusPolicy(Qt::NoFocus);	
	connect(slider,SIGNAL(valueChanged(int)),this,SLOT(sliderValueChanged(int)));
	
	frame = createHorizontalFrame();
	frame->setMaximumHeight(100);
	frame->layout()->setAlignment(Qt::AlignHCenter);
	toolBar->addWidget(frame);
	frame->layout()->addWidget(slider);


	addToolBar(Qt::LeftToolBarArea,toolBar);
	toolBar->setMovable(false);
}