Пример #1
0
/*virtual*/
bool ChoiceFilter::eventFilter(QObject *obj, QEvent *event)
{
    QPalette palette;
    QLabel *label;

    if (event->type() == QEvent::Enter) {
        label = qobject_cast<QLabel*>(obj);
        palette = label->palette();
        this->usualColor = palette.color(QPalette::Text);
        palette.setColor(label->foregroundRole(), QColor(Qt::cyan));
        label->setPalette(palette);

        return true;
    }

    if (event->type() == QEvent::Leave) {
        label = qobject_cast<QLabel*>(obj);
        palette = label->palette();
        palette.setColor(label->foregroundRole(), this->usualColor);
        label->setPalette(palette);

        return true;
    }
    return false;
}
Пример #2
0
/** Returns a pointer to a new validator QLabel. The code is copied from
*  AlgorithmDialog.cpp and wont know if the validator label changes there
*  @param parent :: a pointer to an object that will look after it deleting it
*/
QLabel *UserSubWindow::newValidator(QWidget *parent) {
  QLabel *validLbl = new QLabel("*", parent);
  QPalette pal = validLbl->palette();
  pal.setColor(QPalette::WindowText, Qt::darkRed);
  validLbl->setPalette(pal);
  return validLbl;
}
Пример #3
0
QuickHelp::QuickHelp(QWidget* widget, QPoint pos, QString text)
	: QFrame(0, Qt::ToolTip),
	  widget_(widget),
	  window_(widget->window())
{
	setAttribute(Qt::WA_DeleteOnClose);
	
	widget_->installEventFilter(this);
	window_->installEventFilter(this);
	
	QLabel* label = new QLabel;
	label->setStyleSheet(
		QString("QLabel { background-color: %1; }").arg(label->palette().toolTipBase().color().name())
	);
	label->setTextFormat(Qt::RichText);
	// label->setOpenExternalLinks(true);
	label->setText(text);
	connect(label, SIGNAL(linkActivated(const QString&)), this, SLOT(openLink(const QString&)));
	
	#ifdef QT_MAC_USE_COCOA
	setFrameStyle(QFrame::NoFrame);
	#else
	setFrameStyle(QFrame::Plain|QFrame::StyledPanel);
	#endif
	
	QVBoxLayout* col = new QVBoxLayout;
	col->setSpacing(0);
	col->setMargin(0);
	col->addWidget(label);
	setLayout(col);
	
	move(widget->mapToGlobal(pos));
	show();
}
Пример #4
0
void InfoPane::createLabels(const QString& title, const QString& value, const int num_cols, int& x, int& y)
{
	QLabel* labelTitle = new QLabel(title, this);
	labelTitle->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
	labelTitle->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);

	QPalette palette = labelTitle->palette();
	QColor f = palette.color(QPalette::Foreground);
	f.setAlpha(128);
	palette.setColor(QPalette::Foreground, f);
	labelTitle->setPalette(palette);

	gridLayout().addWidget(labelTitle, y, x, 1, 1);

	QLabel* labelValue = new QLabel(value, this);
	labelValue->setTextInteractionFlags(Qt::TextBrowserInteraction);
	labelValue->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
	gridLayout().addWidget(labelValue, y, x + 1, 1, 1);

	x += 2;

	if (x % num_cols == 0)
	{
		x = 0;
		y++;
	}
}
Пример #5
0
void TimeAnalysisWidget::updateLegend()
{
    std::vector<std::string> &labels = _selectedScalar->labels();

    // removinb previous legend
    QFormLayout *layout = (QFormLayout *)_ui->legendGroupBox->layout();
    QLayoutItem *child;
    while (layout->count()!=0 && (child = layout->takeAt(0)) != 0) {
        child->widget()->deleteLater();
        delete child;
    }

    for (unsigned i=0; i<labels.size(); ++i) {
        QLabel *colorLabel = new QLabel;
        colorLabel->setAutoFillBackground(true);
        colorLabel->setMinimumSize(70, 15);
        QPalette palette = colorLabel->palette();

        float denom = _selectedScalar->max() - _selectedScalar->min();
        float normalizedValue = ( i - _selectedScalar->min() ) / ( denom == 0 ? 1.f : denom );

        palette.setColor(colorLabel->backgroundRole(), _ui->projectionWidget->colorScale()->getColor(normalizedValue));
        colorLabel->setPalette(palette);

        layout->addRow(new QLabel(labels[i].c_str()), colorLabel);
    }

    repaint();
}
Пример #6
0
static QLabel* createLabel()
{
    QLabel *label = new QLabel;
    QPalette palette = label->palette();
    palette.setBrush(QPalette::Window, QBrush(Qt::white));
    label->setPalette(palette);
    return label;
}
Пример #7
0
void ray_options::set_color(qint32 red, qint32 green, qint32 blue)
{
	QLabel *l = ui->color_preview;
	QColor col(red, green, blue);
	QPalette pal = l->palette();
	pal.setColor(l->backgroundRole(), col);
	l->setPalette(pal);
	r->set_color(col);
	backgroung->update();
}
Пример #8
0
QWidget* AutoImportWindow::setupInputFolderContainer() {
    GroupContainer* container = new GroupContainer();
    container->setTitle("Import Folder");

    QFormLayout* layout = new QFormLayout;
    layout->setHorizontalSpacing(10);
    layout->setVerticalSpacing(0);
    layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
    layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
    layout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
    layout->setLabelAlignment(Qt::AlignLeft);

    BrowserWidget* filesDirBrowser_ = new BrowserWidget(BrowserWidget::BrowseType::DIRECTORY);
    ParametersConfiguration* conf  = projectData.projectParameterData();
    QString importImagesPath = conf->getValue("import_dir");
    filesDirBrowser_->setPath(importImagesPath);
    setupWatcherPaths();
    connect(filesDirBrowser_, &BrowserWidget::pathChanged, [ = ] (const QString & value){
        conf->set("import_dir", value);
        setupWatcherPaths();
        analyzeImport();
    });
    layout->addRow(filesDirBrowser_);

    QLabel* introLabel = new QLabel(introText());
    introLabel->setWordWrap(true);
    QPalette pal = introLabel->palette();
    pal.setColor(QPalette::WindowText, Qt::darkGray);
    introLabel->setPalette(pal);
    layout->addRow(introLabel);

    QCheckBox* restartCheck = new QCheckBox("Import new images in the import folder on start");
    restartCheck->setChecked(ProjectPreferences().importRestartCheck());
    connect(restartCheck, &QCheckBox::toggled, [ = ] (bool check){
        ProjectPreferences().setImportRestartCheck(check);
    });
    layout->addRow(restartCheck);

    
    layout->addRow(continuous);
    
    deleteCheck = new QCheckBox("DELETE the original images in import folder after importing them");
    deleteCheck->setChecked(ProjectPreferences().importDeleteCheck());
    deleteLabel_->setVisible(deleteCheck->isChecked());
    connect(deleteCheck, &QCheckBox::toggled, [ = ] (bool check){
        ProjectPreferences().setImportDeleteCheck(check);
        deleteLabel_->setVisible(check);
    });
    layout->addRow(deleteCheck);
    
    container->setContainerLayout(layout);

    return container;
}
Пример #9
0
void SessionAnalysisWidget::setupColors()
{
    for (int i = 0; i < ui.gridLayout->columnCount(); i += 2)
    {
        QLabel *lab = (QLabel*)ui.gridLayout->itemAtPosition(0, i)->widget();

        QPalette palette = lab->palette();
        palette.setColor(QPalette::Window, ColorsManager::getInstance().getDriverColors()[i]);
        lab->setPalette(palette);

        lab = (QLabel*)ui.gridLayout->itemAtPosition(1, i)->widget();

        palette = lab->palette();
        palette.setColor(QPalette::Window, ColorsManager::getInstance().getDriverColors()[i+1]);
        lab->setPalette(palette);
    }
    setupIcons(ColorsManager::getInstance().getDriverColors());

    update();
}
Пример #10
0
void DetailWindow::blankKeyLabel(){
  deleteKeyLabels();
  QLabel* dummyLabel = new QLabel();
  QPalette pal = dummyLabel->palette();
  pal.setColor(backgroundRole(), Qt::black);
  dummyLabel->setPalette(pal);
  dummyLabel->setAutoFillBackground(true);
  dummyLabel->setMinimumHeight(20);
  dummyLabel->setMaximumHeight(30);
  dummyLabel->setToolTip(wrapToolTip(tr("Drag an audio file onto the window.")));
  ui->horizontalLayout_keyLabels->addWidget(dummyLabel);
  keyLabels.push_back(dummyLabel);
}
Пример #11
0
void Tray::paintIcon( int mergePixels, bool force )
{
    // skip redrawing the same pixmap
    static int mergePixelsCache = 0;
    if ( mergePixels == mergePixelsCache && !force )
         return;
    mergePixelsCache = mergePixels;

    if ( mergePixels < 0 )
        return blendOverlay( baseIcon );

    // make up the grayed icon
    if ( !grayedIcon )
    {
        QImage tmpTrayIcon = baseIcon->toImage();
        KIconEffect::semiTransparent( tmpTrayIcon );
        grayedIcon = new QPixmap( QPixmap::fromImage( tmpTrayIcon ) );
    }
    if ( mergePixels == 0 )
        return blendOverlay( grayedIcon );

    // make up the alternate icon (use hilight color but more saturated)
    if ( !alternateIcon )
    {
        QImage tmpTrayIcon = baseIcon->toImage();
        // eros: this looks cool with dark red blue or green but sucks with
        // other colors (such as kde default's pale pink..). maybe the effect
        // or the blended color has to be changed..
        QLabel label; //just a hack to get the palette
        QColor saturatedColor = label.palette().color(QPalette::Active, QPalette::Highlight);
        int hue, sat, value;
        saturatedColor.getHsv( &hue, &sat, &value );
        saturatedColor.setHsv( hue, (sat + 510) / 3, value );
        KIconEffect::colorize( tmpTrayIcon, saturatedColor/* Qt::blue */, 0.9 );
        alternateIcon = new QPixmap( QPixmap::fromImage( tmpTrayIcon ) );
    }
    if ( mergePixels >= alternateIcon->height() )
        return blendOverlay( alternateIcon );

    // mix [ grayed <-> colored ] icons
    QPixmap tmpTrayPixmap( *alternateIcon );
    QPainter paint;
    paint.begin( &tmpTrayPixmap );
    paint.drawPixmap( 0, 0, *grayedIcon, 0, 0,
        alternateIcon->width(), alternateIcon->height() - mergePixels );
    paint.end();

    blendOverlay( &tmpTrayPixmap );
}
Пример #12
0
QLabel* UtilityIconPainting::buildLighterTextLabel(const QString& text, QWidget* parentWidget) {

    QLabel* textLabel = new QLabel(text, parentWidget);

    QPalette textLabelPalette = textLabel->palette();
    QColor fgcolor = KColorUtils::tint(textLabelPalette.color(QPalette::Disabled, QPalette::WindowText),
                                       textLabelPalette.color(QPalette::Active, QPalette::WindowText),
                                       0.6);

    textLabelPalette.setColor(QPalette::WindowText, fgcolor);

    textLabel->setPalette(textLabelPalette);

    return textLabel;
}
Пример #13
0
bool ElideFadeDrawer::eventFilter(QObject *obj, QEvent *event) {
	if ( event->type() == QEvent::Paint ) {
		QLabel *q = static_cast<QLabel*>(obj);
		QPainter painter(q);
		QFontMetrics fm(q->font());
		QRect rect = q->contentsRect();
		int flags = q->alignment() | Qt::TextSingleLine;

		if ( fm.width(q->text()) > rect.width() ) {
			//QPixmap pixmap(rect.size());//, QImage::Format_ARGB32);
			QImage pixmap(rect.size(), QImage::Format_ARGB32);
			pixmap.fill(Qt::transparent);

			QPainter p(&pixmap);
			p.setPen(painter.pen());
			p.setFont(painter.font());

			/*
			QLinearGradient gradient(rect.topLeft(), rect.topRight());
			QColor from = q->palette().color(QPalette::WindowText);
			QColor to = from;
			to.setAlpha(0);
			gradient.setColorAt(0.8, from);
			gradient.setColorAt(1.0, to);
			p.setPen(QPen(gradient, 0));
			*/
			p.drawText(pixmap.rect(), flags, q->text());

			QLinearGradient alphaGradient(rect.topLeft(), rect.topRight());
			alphaGradient.setColorAt(0.8, QColor(0,0,0,255));
			alphaGradient.setColorAt(1.0, QColor(0,0,0,0));
			p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
			p.fillRect(pixmap.rect(), alphaGradient);

			painter.drawImage(rect.topLeft(), pixmap);
		}
		else {
			painter.setPen(q->palette().color(QPalette::WindowText));
			painter.drawText(rect, flags, q->text());
		}
		
		return true;
	}

	// standard event processing
	return QObject::eventFilter(obj, event);
}
Пример #14
0
/** Add the optional message in a light yellow box to the layout
 *
 * @param mainLay :: layout
 */
void AlgorithmDialog::addOptionalMessage(QVBoxLayout *mainLay) {
  QLabel *inputMessage = new QLabel(this);
  inputMessage->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  QPalette pal = inputMessage->palette();
  pal.setColor(inputMessage->backgroundRole(),
               QColor(255, 255, 224)); // Light yellow
  pal.setColor(inputMessage->foregroundRole(), Qt::black);
  inputMessage->setPalette(pal);
  inputMessage->setAutoFillBackground(true);
  inputMessage->setWordWrap(true);
  inputMessage->setAlignment(Qt::AlignJustify);
  inputMessage->setMargin(3);
  inputMessage->setText(getOptionalMessage());
  QHBoxLayout *msgArea = new QHBoxLayout;
  msgArea->addWidget(inputMessage);
  mainLay->addLayout(msgArea, 0);
}
Пример #15
0
QLabel *HUD2::InitLabel( int x, int y, int h, QString text, QColor c )
{
   QLabel *lab = new QLabel( this );
   //QFont     f = QFont( "Courier", h );
   QFont     f = QFont( "Vera", h );
   f.setBold( true );
   QPalette  p = lab->palette();
   
   p.setColor( QPalette::WindowText, c );

   lab->setGeometry( x, y, 0, 0 );
   lab->setPalette( p );
   lab->setFont(f);
   lab->setText(text);
   lab->adjustSize();

   return lab;
}
Пример #16
0
    AlignmentView(Gui::Document* pcDocument, QWidget* parent, QGLWidget* shareWidget=0, Qt::WindowFlags wflags=0)
        : AbstractSplitView(pcDocument, parent, wflags)
    {
        QSplitter* mainSplitter=0;
        mainSplitter = new QSplitter(Qt::Horizontal, this);
        _viewer.push_back(new View3DInventorViewer(mainSplitter, shareWidget));
        _viewer.back()->setDocument(pcDocument);
        _viewer.push_back(new View3DInventorViewer(mainSplitter, shareWidget));
        _viewer.back()->setDocument(pcDocument);

        QFrame* vbox = new QFrame(this);
        QVBoxLayout* layout = new QVBoxLayout();
        layout->setMargin(0);
        layout->setSpacing(0);
        vbox->setLayout(layout);

        myLabel = new QLabel(this);
        myLabel->setAutoFillBackground(true);
        QPalette pal = myLabel->palette();
        pal.setColor(QPalette::Window, Qt::darkGray);
        pal.setColor(QPalette::WindowText, Qt::white);
        myLabel->setPalette(pal);
        mainSplitter->setPalette(pal);
        myLabel->setAlignment(Qt::AlignCenter);
        myLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
        QFont font = myLabel->font();
        font.setPointSize(14);
        myLabel->setFont(font);
        layout->addWidget(myLabel);
        layout->addWidget(mainSplitter);

        vbox->show();
        setCentralWidget(vbox);

        // apply the user settings
        setupSettings();

        static_cast<SoGroup*>(getViewer(0)->getSoRenderManager()->getSceneGraph())->
            addChild(setupHeadUpDisplay(tr("Movable object")));
        static_cast<SoGroup*>(getViewer(1)->getSoRenderManager()->getSceneGraph())->
            addChild(setupHeadUpDisplay(tr("Fixed object")));
    }
Пример #17
0
void
PanelsWidget::addPanel( PanelData *panel )
{
    const int headerRow = layout_->rowCount();

    // icon:
    if (!panel->icon().isNull()) {
        QLabel *iconLabel = new QLabel(root_);
        iconLabel->setPixmap( panel->icon().pixmap( Constants::ICON_SIZE, Constants::ICON_SIZE ) );
        iconLabel->setContentsMargins( 0, Constants::ABOVE_HEADING_MARGIN, 0, 0 );
        layout_->addWidget( iconLabel, headerRow, 0, /*rowSpan=*/3, /*colSpan=*/1, Qt::AlignTop | Qt::AlignHCenter );
    }

    // name:
    QLabel *nameLabel = new QLabel(root_);
    nameLabel->setText( panel->displayName() );
    QPalette palette = nameLabel->palette();
    for (int i = QPalette::Active; i < QPalette::NColorGroups; ++i ) {
        QColor foregroundColor = palette.color(QPalette::ColorGroup(i), QPalette::Foreground);
        foregroundColor.setAlpha(110);
        palette.setBrush(QPalette::ColorGroup(i), QPalette::Foreground, foregroundColor);
    }
    nameLabel->setPalette(palette);
    nameLabel->setContentsMargins(0, Constants::ABOVE_HEADING_MARGIN, 0, 0);
    QFont f = nameLabel->font();
    f.setBold(true);
    f.setPointSizeF(f.pointSizeF() * 1.6);
    nameLabel->setFont(f);
    layout_->addWidget(nameLabel, headerRow, 1, 1, 1, Qt::AlignVCenter | Qt::AlignLeft);

    // line:
    const int lineRow(headerRow + 1);
    QWidget *line = new OnePixelBlackLine(root_);
    layout_->addWidget(line, lineRow, 1, 1, -1, Qt::AlignTop);

    // add the widget:
    const int widgetRow(lineRow + 1);
    addPanelWidget(panel, widgetRow);
    layout_->setRowStretch( lineRow + 1, 100 );
}
Пример #18
0
void WindowFacade::setDockFontColor(QColor fontColor) {
    QPalette p;
    foreach(QDockWidget* dock, dockWindows) {
        if(qobject_cast<QPlainTextEdit*>(dock->widget()) != NULL) {
            p = ((QPlainTextEdit*)dock->widget())->viewport()->palette();
            p.setColor(QPalette::Text, fontColor);
            ((QPlainTextEdit*)dock->widget())->viewport()->setPalette(p);
        } else if(qobject_cast<QTableWidget*>(dock->widget()) != NULL) {
            QTableWidget* tableWidget = (QTableWidget*)dock->widget();
            for(int i = 0; i < tableWidget->rowCount(); i++) {
                QLabel* widget = (QLabel*)tableWidget->cellWidget(i, 0);
                QPalette p = widget->palette();
                p.setColor(QPalette::Text, fontColor);
                widget->setPalette(p);
            }
        }
    }

    foreach(QDockWidget* dock, streamWindows) {
        p = ((QPlainTextEdit*)dock->widget())->viewport()->palette();
        p.setColor(QPalette::Text, fontColor);
        ((QPlainTextEdit*)dock->widget())->viewport()->setPalette(p);
    }
Пример #19
0
int main(int argc, char **argv)
{
    // Qt requires that we construct the global QApplication before creating any widgets.
    QApplication app(argc, argv);

    // use an ArgumentParser object to manage the program arguments.
    osg::ArgumentParser arguments(&argc,argv);

    // true = run osgViewer in a separate thread than Qt
    // false = interleave osgViewer and Qt in the main thread
    bool useFrameLoopThread = false;
    if (arguments.read("--no-frame-thread")) useFrameLoopThread = false;
    if (arguments.read("--frame-thread")) useFrameLoopThread = true;

    // true = use QWidgetImage
    // false = use QWebViewImage
    bool useWidgetImage = false;
    if (arguments.read("--useWidgetImage")) useWidgetImage = true;

    // true = use QWebView in a QWidgetImage to compare to QWebViewImage
    // false = make an interesting widget
    bool useBrowser = false;
    if (arguments.read("--useBrowser")) useBrowser = true;

    // true = use a QLabel for text
    // false = use a QTextEdit for text
    // (only applies if useWidgetImage == true and useBrowser == false)
    bool useLabel = false;
    if (arguments.read("--useLabel")) useLabel = true;

    // true = make a Qt window with the same content to compare to
    // QWebViewImage/QWidgetImage
    // false = use QWebViewImage/QWidgetImage (depending on useWidgetImage)
    bool sanityCheck = false;
    if (arguments.read("--sanityCheck")) sanityCheck = true;

    // Add n floating windows inside the QGraphicsScene.
    int numFloatingWindows = 0;
    while (arguments.read("--numFloatingWindows", numFloatingWindows));

    // true = Qt widgets will be displayed on a quad inside the 3D scene
    // false = Qt widgets will be an overlay over the scene (like a HUD)
    bool inScene = true;
    if (arguments.read("--fullscreen")) { inScene = false; }


    osg::ref_ptr<osg::Group> root = new osg::Group;

    if (!useWidgetImage)
    {
        //-------------------------------------------------------------------
        // QWebViewImage test
        //-------------------------------------------------------------------
        // Note: When the last few issues with QWidgetImage are fixed,
        // QWebViewImage and this if() {} section can be removed since
        // QWidgetImage can display a QWebView just like QWebViewImage. Use
        // --useWidgetImage --useBrowser to see that in action.

        if (!sanityCheck)
        {
            osg::ref_ptr<osgQt::QWebViewImage> image = new osgQt::QWebViewImage;

            if (arguments.argc()>1) image->navigateTo((arguments[1]));
            else image->navigateTo("http://www.openscenegraph.org/");

            osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
                                           osg::Vec3(1.0f,0.0f,0.0f),
                                           osg::Vec3(0.0f,0.0f,1.0f),
                                           osg::Vec4(1.0f,1.0f,1.0f,1.0f),
                                           osgWidget::GeometryHints::RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO);

            osg::ref_ptr<osgWidget::Browser> browser = new osgWidget::Browser;
            browser->assign(image.get(), hints);

            root->addChild(browser.get());
        }
        else
        {
            // Sanity check, do the same thing as QGraphicsViewAdapter but in
            // a separate Qt window.
            QWebPage* webPage = new QWebPage;
            webPage->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
            webPage->settings()->setAttribute(QWebSettings::PluginsEnabled, true);

            QWebView* webView = new QWebView;
            webView->setPage(webPage);

            if (arguments.argc()>1) webView->load(QUrl(arguments[1]));
            else webView->load(QUrl("http://www.openscenegraph.org/"));

            QGraphicsScene* graphicsScene = new QGraphicsScene;
            graphicsScene->addWidget(webView);

            QGraphicsView* graphicsView = new QGraphicsView;
            graphicsView->setScene(graphicsScene);

            QMainWindow* mainWindow = new QMainWindow;
            //mainWindow->setLayout(new QVBoxLayout);
            mainWindow->setCentralWidget(graphicsView);
            mainWindow->setGeometry(50, 50, 1024, 768);
            mainWindow->show();
            mainWindow->raise();
        }
    }
    else
    {
        //-------------------------------------------------------------------
        // QWidgetImage test
        //-------------------------------------------------------------------
        // QWidgetImage still has some issues, some examples are:
        //
        // 1. Editing in the QTextEdit doesn't work. Also when started with
        //    --useBrowser, editing in the search field on YouTube doesn't
        //    work. But that same search field when using QWebViewImage
        //    works... And editing in the text field in the pop-up getInteger
        //    dialog works too. All these cases use QGraphicsViewAdapter
        //    under the hood, so why do some work and others don't?
        //
        //    <<< FIXED, need TextEditorInteraction >>>
        //
        //    a) osgQtBrowser --useWidgetImage [--fullscreen] (optional)
        //    b) Try to click in the QTextEdit and type, or to select text
        //       and drag-and-drop it somewhere else in the QTextEdit. These
        //       don't work.
        //    c) osgQtBrowser --useWidgetImage --sanityCheck
        //    d) Try the operations in b), they all work.
        //    e) osgQtBrowser --useWidgetImage --useBrowser [--fullscreen]
        //    f) Try to click in the search field and type, it doesn't work.
        //    g) osgQtBrowser
        //    h) Try the operation in f), it works.
        //
        // 2. Operations on floating windows (--numFloatingWindows 1 or more).
        //    Moving by dragging the titlebar, clicking the close button,
        //    resizing them, none of these work. I wonder if it's because the
        //    OS manages those functions (they're functions of the window
        //    decorations) so we need to do something special for that? But
        //    in --sanityCheck mode they work.
        //
        //    a) osgQtBrowser --useWidgetImage --numFloatingWindows 1 [--fullscreen]
        //    b) Try to drag the floating window, click the close button, or
        //       drag its sides to resize it. None of these work.
        //    c) osgQtBrowser --useWidgetImage --numFloatingWindows 1 --sanityCheck
        //    d) Try the operations in b), all they work.
        //    e) osgQtBrowser --useWidgetImage [--fullscreen]
        //    f) Click the button so that the getInteger() dialog is
        //       displayed, then try to move that dialog or close it with the
        //       close button, these don't work.
        //    g) osgQtBrowser --useWidgetImage --sanityCheck
        //    h) Try the operation in f), it works.
        //
        // 3. (Minor) The QGraphicsView's scrollbars don't appear when
        //    using QWidgetImage or QWebViewImage. QGraphicsView is a
        //    QAbstractScrollArea and it should display scrollbars as soon as
        //    the scene is too large to fit the view.
        //
        //    <<< FIXED >>>
        //
        //    a) osgQtBrowser --useWidgetImage --fullscreen
        //    b) Resize the OSG window so it's smaller than the QTextEdit.
        //       Scrollbars should appear but don't.
        //    c) osgQtBrowser --useWidgetImage --sanityCheck
        //    d) Try the operation in b), scrollbars appear. Even if you have
        //       floating windows (by clicking the button or by adding
        //       --numFloatingWindows 1) and move them outside the view,
        //       scrollbars appear too. You can't test that case in OSG for
        //       now because of problem 2 above, but that's pretty cool.
        //
        // 4. (Minor) In sanity check mode, the widget added to the
        //    QGraphicsView is centered. With QGraphicsViewAdapter, it is not.
        //
        //    a) osgQtBrowser --useWidgetImage [--fullscreen]
        //    b) The QTextEdit and button are not in the center of the image
        //       generated by the QGraphicsViewAdapter.
        //    c) osgQtBrowser --useWidgetImage --sanityCheck
        //    d) The QTextEdit and button are in the center of the
        //       QGraphicsView.


        QWidget* widget = 0;
        if (useBrowser)
        {
            QWebPage* webPage = new QWebPage;
            webPage->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
            webPage->settings()->setAttribute(QWebSettings::PluginsEnabled, true);

            QWebView* webView = new QWebView;
            webView->setPage(webPage);

            if (arguments.argc()>1) webView->load(QUrl(arguments[1]));
            else webView->load(QUrl("http://www.youtube.com/"));

            widget = webView;
        }
        else
        {
            widget = new QWidget;
            widget->setLayout(new QVBoxLayout);

            QString text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque velit turpis, euismod ac ultrices et, molestie non nisi. Nullam egestas dignissim enim, quis placerat nulla suscipit sed. Donec molestie elementum risus sit amet sodales. Nunc consectetur congue neque, at viverra massa pharetra fringilla. Integer vitae mi sem. Donec dapibus semper elit nec sollicitudin. Vivamus egestas ultricies felis, in mollis mi facilisis quis. Nam suscipit bibendum eros sed cursus. Suspendisse mollis suscipit hendrerit. Etiam magna eros, convallis non congue vel, faucibus ac augue. Integer ante ante, porta in ornare ullamcorper, congue nec nibh. Etiam congue enim vitae enim sollicitudin fringilla. Mauris mattis, urna in fringilla dapibus, ipsum sem feugiat purus, ac hendrerit felis arcu sed sapien. Integer id velit quam, sit amet dignissim tortor. Sed mi tortor, placerat ac luctus id, tincidunt et urna. Nulla sed nunc ante.Sed ut sodales enim. Ut sollicitudin ultricies magna, vel ultricies ante venenatis id. Cras luctus mi in lectus rhoncus malesuada. Sed ac sollicitudin nisi. Nunc venenatis congue quam, et suscipit diam consectetur id. Donec vel enim ac enim elementum bibendum ut quis augue. Nulla posuere suscipit dolor, id convallis tortor congue eu. Vivamus sagittis consectetur dictum. Duis a ante quis dui varius fermentum. In hac habitasse platea dictumst. Nam dapibus dolor eu felis eleifend in scelerisque dolor ultrices. Donec arcu lectus, fringilla ut interdum non, tristique id dolor. Morbi sagittis sagittis volutpat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis venenatis ultrices euismod.Nam sit amet convallis libero. Integer lectus urna, eleifend et sollicitudin non, porttitor vel erat. Vestibulum pulvinar egestas leo, a porttitor turpis ullamcorper et. Vestibulum in ornare turpis. Ut nec libero a sem mattis iaculis quis id purus. Praesent ante neque, dictum vitae pretium vel, iaculis luctus dui. Etiam luctus tellus vel nunc suscipit a ullamcorper nisl semper. Nunc dapibus, eros in sodales dignissim, orci lectus egestas felis, sit amet vehicula tortor dolor eu quam. Vivamus pellentesque convallis quam aliquet pellentesque. Phasellus facilisis arcu ac orci fringilla aliquet. Donec sed euismod augue. Duis eget orci sit amet neque tempor fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In hac habitasse platea dictumst. Duis sollicitudin, lacus ac pellentesque lacinia, lacus magna pulvinar purus, pulvinar porttitor est nibh quis augue.Duis eleifend, massa sit amet mattis fringilla, elit turpis venenatis libero, sed convallis turpis diam sit amet ligula. Morbi non dictum turpis. Integer porttitor condimentum elit, sit amet sagittis nibh ultrices sit amet. Mauris ac arcu augue, id aliquet mauris. Donec ultricies urna id enim accumsan at pharetra dui adipiscing. Nunc luctus rutrum molestie. Curabitur libero ipsum, viverra at pulvinar ut, porttitor et neque. Aliquam sit amet dolor et purus sagittis adipiscing. Nam sit amet hendrerit sem. Etiam varius, ligula non ultricies dignissim, sapien dui commodo urna, eu vehicula enim nunc molestie augue. Fusce euismod, erat vitae pharetra tempor, quam eros tincidunt lorem, ut iaculis ligula erat vitae nibh. Aenean eu ultricies dolor. Curabitur suscipit viverra bibendum.Sed egestas adipiscing mi in egestas. Proin in neque in nibh blandit consequat nec quis tortor. Vestibulum sed interdum justo. Sed volutpat velit vitae elit pulvinar aliquam egestas elit rutrum. Proin lorem nibh, bibendum vitae sollicitudin condimentum, pulvinar ut turpis. Maecenas iaculis, mauris in consequat ultrices, ante erat blandit mi, vel fermentum lorem turpis eget sem. Integer ultrices tristique erat sit amet volutpat. In sit amet diam et nunc congue pellentesque at in dolor. Mauris eget orci orci. Integer posuere augue ornare tortor tempus elementum. Quisque iaculis, nunc ac cursus fringilla, magna elit cursus eros, id feugiat diam eros et tellus. Etiam consectetur ultrices erat quis rhoncus. Mauris eu lacinia neque. Curabitur suscipit feugiat tellus in dictum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed aliquam tempus ante a tempor. Praesent viverra erat quis sapien pretium rutrum. Praesent dictum scelerisque venenatis.Proin bibendum lectus eget nisl lacinia porta. Morbi eu erat in sapien malesuada vulputate. Cras non elit quam. Ut dictum urna quis nisl feugiat ac sollicitudin libero luctus. Donec leo mauris, varius at luctus eget, placerat quis arcu. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam tristique, mauris ut lacinia elementum, mauris erat consequat massa, ac gravida nisi tellus vitae purus. Curabitur consectetur ultricies commodo. Cras pulvinar orci nec enim adipiscing tristique. Ut ornare orci id est fringilla sit amet blandit libero pellentesque. Vestibulum tincidunt sapien ut enim venenatis vestibulum ultricies ipsum tristique. Mauris tempus eleifend varius. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vitae dui ac quam gravida semper. In ac enim ac ligula rutrum porttitor.Integer dictum sagittis leo, at convallis sapien facilisis eget. Etiam cursus bibendum tortor, faucibus aliquam lectus ullamcorper sed. Nulla pulvinar posuere quam, ut sagittis ligula tincidunt ut. Nulla convallis velit ut enim condimentum pulvinar. Quisque gravida accumsan scelerisque. Proin pellentesque nisi cursus tortor aliquet dapibus. Duis vel eros orci. Sed eget purus ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ullamcorper porta congue. Nunc id velit ut neque malesuada consequat in eu nisi. Nulla facilisi. Quisque pellentesque magna vitae nisl euismod ac accumsan tellus feugiat.Nulla facilisi. Integer quis orci lectus, non aliquam nisi. Vivamus varius porta est, ac porttitor orci blandit mattis. Sed dapibus facilisis dapibus. Duis tincidunt leo ac tortor faucibus hendrerit. Morbi sit amet sapien risus, vel luctus enim. Aliquam sagittis nunc id purus aliquam lobortis. Duis posuere viverra dui, sit amet convallis sem vulputate at. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque, lectus id imperdiet commodo, diam diam faucibus lectus, sit amet vestibulum tortor lacus viverra eros.Maecenas nec augue lectus. Duis nec arcu eget lorem tempus sollicitudin suscipit vitae arcu. Nullam vitae mauris lectus. Vivamus id risus neque, dignissim vehicula diam. Cras rhoncus velit sed velit iaculis ac dignissim turpis luctus. Suspendisse potenti. Sed vitae ligula a ligula ornare rutrum sit amet ut quam. Duis tincidunt, nibh vitae iaculis adipiscing, dolor orci cursus arcu, vel congue tortor quam eget arcu. Suspendisse tellus felis, blandit ac accumsan vitae, fringilla id lorem. Duis tempor lorem mollis est congue ut imperdiet velit laoreet. Nullam interdum cursus mollis. Pellentesque non mauris accumsan elit laoreet viverra ut at risus. Proin rutrum sollicitudin sem, vitae ultricies augue sagittis vel. Cras quis vehicula neque. Aliquam erat volutpat. Aliquam erat volutpat. Praesent non est erat, accumsan rutrum lacus. Pellentesque tristique molestie aliquet. Cras ullamcorper facilisis faucibus. In non lorem quis velit lobortis pulvinar.Phasellus non sem ipsum. Praesent ut libero quis turpis viverra semper. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In hac habitasse platea dictumst. Donec at velit tellus. Fusce commodo pharetra tincidunt. Proin lacus enim, fringilla a fermentum ut, vestibulum ut nibh. Duis commodo dolor vel felis vehicula at egestas neque bibendum. Phasellus malesuada dictum ante in aliquam. Curabitur interdum semper urna, nec placerat justo gravida in. Praesent quis mauris massa. Pellentesque porttitor lacinia tincidunt. Phasellus egestas viverra elit vel blandit. Sed dapibus nisi et lectus pharetra dignissim. Mauris hendrerit lectus nec purus dapibus condimentum. Sed ac eros nulla. Aenean semper sapien a nibh aliquam lobortis. Aliquam elementum euismod sapien, in dapibus leo dictum et. Pellentesque augue neque, ultricies non viverra eu, tincidunt ac arcu. Morbi ut porttitor lectus.");

            if (useLabel)
            {
                QLabel* label = new QLabel(text);
                label->setWordWrap(true);
                label->setTextInteractionFlags(Qt::TextEditorInteraction);

                QPalette palette = label->palette();
                palette.setColor(QPalette::Highlight, Qt::darkBlue);
                palette.setColor(QPalette::HighlightedText, Qt::white);
                label->setPalette(palette);

                QScrollArea* scrollArea = new QScrollArea;
                scrollArea->setWidget(label);

                widget->layout()->addWidget(scrollArea);
            }
            else
            {
                QTextEdit* textEdit = new QTextEdit(text);
                textEdit->setReadOnly(false);
                textEdit->setTextInteractionFlags(Qt::TextEditorInteraction);

                QPalette palette = textEdit->palette();
                palette.setColor(QPalette::Highlight, Qt::darkBlue);
                palette.setColor(QPalette::HighlightedText, Qt::white);
                textEdit->setPalette(palette);

                widget->layout()->addWidget(textEdit);
            }

            QPushButton* button = new MyPushButton("Button");
            widget->layout()->addWidget(button);

            widget->setGeometry(0, 0, 800, 600);
        }

        QGraphicsScene* graphicsScene = 0;

        if (!sanityCheck)
        {
            osg::ref_ptr<osgQt::QWidgetImage> widgetImage = new osgQt::QWidgetImage(widget);
#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
            widgetImage->getQWidget()->setAttribute(Qt::WA_TranslucentBackground);
#endif
            widgetImage->getQGraphicsViewAdapter()->setBackgroundColor(QColor(0, 0, 0, 0));
            //widgetImage->getQGraphicsViewAdapter()->resize(800, 600);
            graphicsScene = widgetImage->getQGraphicsViewAdapter()->getQGraphicsScene();

            osg::Camera* camera = 0;        // Will stay NULL in the inScene case.
            osg::Geometry* quad = osg::createTexturedQuadGeometry(osg::Vec3(0,0,0), osg::Vec3(1,0,0), osg::Vec3(0,1,0), 1, 1);
            osg::Geode* geode = new osg::Geode;
            geode->addDrawable(quad);

            osg::MatrixTransform* mt = new osg::MatrixTransform;

            osg::Texture2D* texture = new osg::Texture2D(widgetImage.get());
            texture->setResizeNonPowerOfTwoHint(false);
            texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
            texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
            texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
            mt->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);

            osgViewer::InteractiveImageHandler* handler;
            if (inScene)
            {
                mt->setMatrix(osg::Matrix::rotate(osg::Vec3(0,1,0), osg::Vec3(0,0,1)));
                mt->addChild(geode);

                handler = new osgViewer::InteractiveImageHandler(widgetImage.get());
            }
            else    // fullscreen
            {
                // The HUD camera's viewport needs to follow the size of the
                // window. MyInteractiveImageHandler will make sure of this.
                // As for the quad and the camera's projection, setting the
                // projection resize policy to FIXED takes care of them, so
                // they can stay the same: (0,1,0,1) with a quad that fits.

                // Set the HUD camera's projection and viewport to match the screen.
                camera = new osg::Camera;
                camera->setProjectionResizePolicy(osg::Camera::FIXED);
                camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1,0,1));
                camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
                camera->setViewMatrix(osg::Matrix::identity());
                camera->setClearMask(GL_DEPTH_BUFFER_BIT);
                camera->setRenderOrder(osg::Camera::POST_RENDER);
                camera->addChild(geode);
                camera->setViewport(0, 0, 1024, 768);

                mt->addChild(camera);

                handler = new osgViewer::InteractiveImageHandler(widgetImage.get(), texture, camera);
            }

            mt->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
            mt->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
            mt->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
            mt->getOrCreateStateSet()->setAttribute(new osg::Program);

            osg::Group* overlay = new osg::Group;
            overlay->addChild(mt);

            root->addChild(overlay);

            quad->setEventCallback(handler);
            quad->setCullCallback(handler);
        }
        else
        {
            // Sanity check, do the same thing as QWidgetImage and
            // QGraphicsViewAdapter but in a separate Qt window.

            graphicsScene = new QGraphicsScene;
            graphicsScene->addWidget(widget);

            QGraphicsView* graphicsView = new QGraphicsView;
            graphicsView->setScene(graphicsScene);

            QMainWindow* mainWindow = new QMainWindow;
            mainWindow->setCentralWidget(graphicsView);
            mainWindow->setGeometry(50, 50, 1024, 768);
            mainWindow->show();
            mainWindow->raise();
        }

        // Add numFloatingWindows windows to the graphicsScene.
        for (unsigned int i = 0; i < (unsigned int)numFloatingWindows; ++i)
        {
            QWidget* window = new QWidget(0, Qt::Window);
            window->setWindowTitle(QString("Window %1").arg(i));
            window->setLayout(new QVBoxLayout);
            window->layout()->addWidget(new QLabel(QString("This window %1").arg(i)));
            window->layout()->addWidget(new MyPushButton(QString("Button in window %1").arg(i)));
            window->setGeometry(100, 100, 300, 300);

            QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, Qt::Window);
            proxy->setWidget(window);
            proxy->setFlag(QGraphicsItem::ItemIsMovable, true);

            graphicsScene->addItem(proxy);
        }

    }

    root->addChild(osgDB::readNodeFile("cow.osg.(15,0,5).trans.(0.1,0.1,0.1).scale"));

    osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer(arguments);
    viewer->setSceneData(root.get());
    viewer->setCameraManipulator(new osgGA::TrackballManipulator());
    viewer->addEventHandler(new osgGA::StateSetManipulator(root->getOrCreateStateSet()));
    viewer->addEventHandler(new osgViewer::StatsHandler);
    viewer->addEventHandler(new osgViewer::WindowSizeHandler);

    viewer->setUpViewInWindow(50, 50, 1024, 768);
    viewer->getEventQueue()->windowResize(0, 0, 1024, 768);

    if (useFrameLoopThread)
    {
        // create a thread to run the viewer's frame loop
        ViewerFrameThread viewerThread(viewer.get(), true);
        viewerThread.startThread();

        // now start the standard Qt event loop, then exists when the viewerThead sends the QApplication::exit() signal.
        return QApplication::exec();

    }
    else
    {
        // run the frame loop, interleaving Qt and the main OSG frame loop
        while(!viewer->done())
        {
            // process Qt events - this handles both events and paints the browser image
            QCoreApplication::processEvents(QEventLoop::AllEvents, 100);

            viewer->frame();
        }

        return 0;
    }
}
Пример #20
0
void MainWindow::refresh()
{
    sortedValues->setVisible(false);
    if (tree.size() >= 1) {
        deleteKeyButton->setVisible(true);
        searchButton->setVisible(true);
    } else {
        deleteKeyButton->setVisible(false);
        searchButton->setVisible(false);
    }
    if (tree.size() >= 2) sortButton->setVisible(true);
    else sortButton->setVisible(false);

    delete treeWidget;
    treeWidget = nullptr;
    treeWidget = new QWidget();

    QHBoxLayout *treeLayout = new QHBoxLayout();
    treeLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);

    tree.inOrder();
    std::vector<int> values = tree.getInorderVector();
    std::vector<int> heights = tree.getHeights();

    for (int i = 0; i < (int)values.size(); i++) {
        QVBoxLayout *vl = new QVBoxLayout();
        QLabel *ql = new QLabel(QString::fromStdString(std::to_string(values[i])));

        vl->addWidget(ql);
        vl->setAlignment(Qt::AlignTop);
        vl->setSpacing(0);

        QPalette pal = ql->palette();
        int cval = (heights[i] * 10) % 125;
        pal.setColor(QPalette::Window, QColor(50+cval, 120+cval, 100+(cval *1.01), 128));

        if(heights[i]-1 == 0) {
            pal.setColor(QPalette::Window, QColor(200,200,50,128));
        }
        if(found && values[i] == foundVal) {
            pal.setColor(QPalette::Window, QColor(150,122, 200, 128));
            found = false;
        }
        ql->setAutoFillBackground(true);
        ql->setPalette(pal);
        ql->setFixedHeight(20);

        for (int j = 0; j < heights[i]-1; j++) {
            QLabel *littlel = new QLabel(" ");
            vl->addWidget(littlel);
            littlel->setAutoFillBackground(true);
            littlel->setPalette(pal);
            littlel->setFixedHeight(20);
        }

        QFont f;
        f.setPointSize(17);
        f.setBold(true);
        ql->setFont(f);


        treeLayout->addLayout(vl);
    }
    treeWidget->setLayout(treeLayout);
    mainLayout->addWidget(treeWidget);
    mainLayout->addWidget(sortButton);
}
Пример #21
0
QWidget *QmlProfilerTool::createWidgets()
{
//     Analyzer::AnalyzerManager *analyzerMgr = Analyzer::AnalyzerManager::instance();
//     Utils::FancyMainWindow *mw = analyzerMgr->mainWindow();

    QWidget *mw = this;
    d->m_traceWindow = new TraceWindow(mw);
    d->m_traceWindow->reset(d->m_client);

    connect(d->m_traceWindow, SIGNAL(gotoSourceLocation(QString,int)),this, SLOT(gotoSourceLocation(QString,int)));
    connect(d->m_traceWindow, SIGNAL(timeChanged(qreal)), this, SLOT(updateTimer(qreal)));

    d->m_statistics = new QmlProfilerEventStatistics(mw);
    d->m_eventsView = new QmlProfilerEventsView(mw, d->m_statistics);
    d->m_eventsView->setViewType(QmlProfilerEventsView::EventsView);

    connect(d->m_traceWindow, SIGNAL(range(int,int,int,qint64,qint64,QStringList,QString,int)),
            d->m_statistics, SLOT(addRangedEvent(int,int,int,qint64,qint64,QStringList,QString,int)));
    connect(d->m_traceWindow, SIGNAL(viewUpdated()),
            d->m_statistics, SLOT(complete()));
    connect(d->m_eventsView, SIGNAL(gotoSourceLocation(QString,int)),
            this, SLOT(gotoSourceLocation(QString,int)));

    d->m_calleeView = new QmlProfilerEventsView(mw, d->m_statistics);
    d->m_calleeView->setViewType(QmlProfilerEventsView::CalleesView);
    connect(d->m_calleeView, SIGNAL(gotoSourceLocation(QString,int)),
            this, SLOT(gotoSourceLocation(QString,int)));

    d->m_callerView = new QmlProfilerEventsView(mw, d->m_statistics);
    d->m_callerView->setViewType(QmlProfilerEventsView::CallersView);
    connect(d->m_callerView, SIGNAL(gotoSourceLocation(QString,int)),
            this, SLOT(gotoSourceLocation(QString,int)));

#if 0
    Core::ICore *core = Core::ICore::instance();
    Core::ActionManager *am = core->actionManager();
    Core::ActionContainer *manalyzer = am->actionContainer(Analyzer::Constants::M_DEBUG_ANALYZER);
    const Core::Context globalcontext(Core::Constants::C_GLOBAL);

    d->m_attachAction = new QAction(tr("Attach..."), manalyzer);
    Core::Command *command = am->registerAction(d->m_attachAction,
                                                Constants::ATTACH, globalcontext);
    command->setAttribute(Core::Command::CA_UpdateText);
    //manalyzer->addAction(command, Analyzer::Constants::G_ANALYZER_STARTSTOP);
    connect(d->m_attachAction, SIGNAL(triggered()), this, SLOT(attach()));

    updateAttachAction(false);

    QDockWidget *eventsDock = AnalyzerManager::createDockWidget
            (this, tr("Events"), d->m_eventsView, Qt::BottomDockWidgetArea);
    QDockWidget *timelineDock = AnalyzerManager::createDockWidget
            (this, tr("Timeline"), d->m_traceWindow, Qt::BottomDockWidgetArea);
    QDockWidget *calleeDock = AnalyzerManager::createDockWidget
            (this, tr("Callees"), d->m_calleeView, Qt::BottomDockWidgetArea);
    QDockWidget *callerDock = AnalyzerManager::createDockWidget
            (this, tr("Callers"), d->m_callerView, Qt::BottomDockWidgetArea);

    mw->splitDockWidget(mw->toolBarDockWidget(), eventsDock, Qt::Vertical);
    mw->tabifyDockWidget(eventsDock, timelineDock);
    mw->tabifyDockWidget(timelineDock, calleeDock);
    mw->tabifyDockWidget(calleeDock, callerDock);
#endif
    QTabWidget *tabWidget = new QTabWidget;
    tabWidget->addTab(d->m_eventsView, tr("Events"));
    tabWidget->addTab(d->m_traceWindow, tr("Timeline"));
    tabWidget->addTab(d->m_calleeView, tr("Callees"));
    tabWidget->addTab(d->m_callerView, tr("Callers"));

    //
    // Toolbar
    //
    QWidget *toolbarWidget = new QWidget;
    toolbarWidget->setObjectName(QLatin1String("QmlProfilerToolBarWidget"));

    QHBoxLayout *layout = new QHBoxLayout;
    layout->setMargin(0);
    layout->setSpacing(0);

    d->m_recordButton = new QToolButton(toolbarWidget);
    // icon and tooltip set in setRecording(), called later
    d->m_recordButton->setCheckable(true);

    connect(d->m_recordButton,SIGNAL(toggled(bool)), this, SLOT(setRecording(bool)));
    d->m_recordButton->setChecked(true);
    layout->addWidget(d->m_recordButton);

    d->m_clearButton = new QToolButton(toolbarWidget);
    d->m_clearButton->setIcon(QIcon(QLatin1String(":/qmlprofiler/clean_pane_small.png")));
    d->m_clearButton->setToolTip(tr("Discard data"));
    connect(d->m_clearButton,SIGNAL(clicked()), this, SLOT(clearDisplay()));
    layout->addWidget(d->m_clearButton);

    QLabel *timeLabel = new QLabel(tr("Elapsed:      0 s"));
    QPalette palette = timeLabel->palette();
    palette.setColor(QPalette::WindowText, Qt::white);
    timeLabel->setPalette(palette);
    timeLabel->setIndent(10);

    connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString)));
    layout->addWidget(timeLabel);

    toolbarWidget->setLayout(layout);

    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    mainLayout->addWidget(toolbarWidget);
    mainLayout->addWidget(tabWidget);

    return toolbarWidget;
}
Пример #22
0
void DetailWindow::analysisFinished(){
  QString error = analysisWatcher.result().errorMessage;
  if(error != ""){
    say(error);
    cleanUpAfterRun();
    return;
  }
  // Title bar
  TagLibMetadata md(filePath);
  QString shortName = md.getTitle();
  if(shortName == "")
    shortName = filePath.mid(filePath.lastIndexOf("/") + 1);
  this->setWindowTitle(GuiStrings::getInstance()->appName() + GuiStrings::getInstance()->delim() + tr("Detailed Analysis") + GuiStrings::getInstance()->delim() + shortName);
  // full chromagram
  chromagramImage = imageFromChromagram(analysisWatcher.result().core.fullChromagram);
  ui->chromagramLabel->setPixmap(QPixmap::fromImage(chromagramImage));
  ui->chromagramLabel->setMinimumHeight(analysisWatcher.result().core.fullChromagram.getBins()+2);
  ui->chromagramLabel->setMinimumWidth(analysisWatcher.result().core.fullChromagram.getHops()+2);
  // one octave chromagram
  miniChromagramImage = imageFromChromagram(analysisWatcher.result().core.oneOctaveChromagram);
  ui->miniChromagramLabel->setPixmap(QPixmap::fromImage(miniChromagramImage));
  //: A tooltip on the Detail window
  ui->miniChromagramLabel->setToolTip(wrapToolTip(tr("This is the same chromagram data, reduced to a single octave.")));
  // harmonic change signal
  int rateOfChangePrecision = 100;
  int size = (signed)analysisWatcher.result().core.harmonicChangeSignal.size();
  harmonicChangeImage = QImage(size*chromaScaleH,rateOfChangePrecision,QImage::Format_Indexed8);
  prefs.setImageColours(harmonicChangeImage,ui->chromaColourCombo->currentIndex());
  for(int h=0; h<size; h++){
    int value = analysisWatcher.result().core.harmonicChangeSignal[h] * rateOfChangePrecision;
    for(int y=0; y<rateOfChangePrecision; y++)
      for(int x=0; x<chromaScaleH; x++)
        harmonicChangeImage.setPixel(h*chromaScaleH+x, y, (rateOfChangePrecision - y > value ? 0 : 50));
  }
  ui->harmonicChangeLabel->setPixmap(QPixmap::fromImage(harmonicChangeImage));
  // Tooltip
  if(prefs.getSegmentation() == 'n'){
    //: A tooltip on the Detail window
    ui->harmonicChangeLabel->setToolTip(wrapToolTip(tr("You are not using segmentation, so there is no harmonic change data to display.")));
  }else if(prefs.getSegmentation() == 'a'){
    //: A tooltip on the Detail window
    ui->harmonicChangeLabel->setToolTip(wrapToolTip(tr("You are using arbitrary segmentation, so there is no harmonic change data to display.")));
  }else{
    //: A tooltip on the Detail window
    ui->harmonicChangeLabel->setToolTip(wrapToolTip(tr("This is the level of harmonic change detected in the chromagram over time. Peaks in this signal are used to segment the chromagram.")));
  }
  // Key estimates
  deleteKeyLabels();
  int lastChange = -1; // enable correct stretch policy for first segment
  for(int h = 0; h < (signed)analysisWatcher.result().core.segments.size(); h++){
    QLabel* newLabel = new QLabel(prefs.getKeyCode(analysisWatcher.result().core.segments[h].key));
    newLabel->setAlignment(Qt::AlignCenter);
    QPalette pal = newLabel->palette();
    pal.setColor(backgroundRole(), prefs.getKeyColour(analysisWatcher.result().core.segments[h].key));
    newLabel->setPalette(pal);
    newLabel->setFrameStyle(1);
    newLabel->setAutoFillBackground(true);
    newLabel->setMinimumHeight(20);
    newLabel->setMaximumHeight(30);
    if(prefs.getSegmentation() == 'n'){
      //: A tooltip on the Detail window
      newLabel->setToolTip(wrapToolTip(tr("This row shows the key estimate for the unsegmented chromagram.")));
    }else if(prefs.getSegmentation() == 'a'){
      //: A tooltip on the Detail window
      newLabel->setToolTip(wrapToolTip(tr("This row shows the key estimates for the arbitrary segments.")));
    }else{
      //: A tooltip on the Detail window
      newLabel->setToolTip(wrapToolTip(tr("This row shows the key estimates for the segments between peak harmonic changes.")));
    }
    ui->horizontalLayout_keyLabels->addWidget(newLabel, h - lastChange);
    keyLabels.push_back(newLabel);
    lastChange = h;
  }
  //: Text in the Batch window status bar; includes a key code at %1
  say(tr("Key estimate: %1").arg(prefs.getKeyCode(analysisWatcher.result().core.globalKeyEstimate)));
  cleanUpAfterRun();
}
Пример #23
0
NoteWidget::NoteWidget(QString title, QString text, QWidget *parent)
    : QWidget(parent)
{
	ui.setupUi(this);
	setBackgroundImage();
	this->setContentsMargins(0,0,0,0);
	
	/* create the GUI objects */
	backButton = new ButtonLabel(QPixmap(":/icons/backButton.png"), QPixmap(":/icons/backButtonPushed.png"), this);
	connect(backButton, SIGNAL(released()), this, SLOT(close()));
	quitButton = new ButtonLabel(QPixmap(":/icons/quitButton.png"), QPixmap(":/icons/quitButtonPushed.png"), this);
	connect(quitButton, SIGNAL(released()), QApplication::instance(), SLOT(quit()));
	patientIcon = new QLabel(this);
	patientIcon->setPixmap(QPixmap(":/icons/patientIcon.png"));
	
	/* initialize the footer object */
	footer = new ChangePatientFooter(this);
	
    QLabel *headerText = new QLabel(this);
    headerText->setStyleSheet("font-family: arial; font-weight: bold; font-size: 18px;");
    headerText->setText("<font color=\"#622181\">Paziente</font><font color=\"#9C9E9F\"> / </font><font color=\"#0B72B5\">Immagini</font>");
        
	QHBoxLayout *headerLayout = new QHBoxLayout();
	headerLayout->setContentsMargins(13, 13, 13, 0);
	headerLayout->addWidget(patientIcon);
	headerLayout->addSpacing(3);
	headerLayout->addWidget(headerText);
	headerLayout->setAlignment(headerText, Qt::AlignVCenter);
	headerLayout->addStretch();	
	headerLayout->addWidget(quitButton);
	
	QLabel *titleLabel = new QLabel("<font color=\"black\">Soggetto<br/></font> <font color=\"white\" >"+ title +"</font>", this);
	titleLabel->setMinimumHeight(100);
	titleLabel->setAutoFillBackground(true);
	titleLabel->setFont(QFont("helvetica"));
	titleLabel->setAlignment(Qt::AlignVCenter);
	QPalette titlePal(titleLabel->palette());
	titlePal.setColor(QPalette::Background, QColor(190,10,38));
	titleLabel->setPalette(titlePal);
	
	QLabel *note = new QLabel(text, this);
	note->setFont(QFont("helvetica"));
	QPalette notePal(note->palette());
	notePal.setColor(QPalette::Text, Qt::black);
	note->setPalette(notePal);
	note->setWordWrap(true);
	note->setAlignment(Qt::AlignJustify);
	note->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	
	QScrollArea *scrollArea = new QScrollArea();
	scrollArea->setWidgetResizable(true);
	scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	scrollArea->setWidget(note);
	scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	
	QVBoxLayout *mainLayout = new QVBoxLayout();
	mainLayout->addLayout(headerLayout);
	mainLayout->addWidget(titleLabel);
	
	QHBoxLayout *backHLayout = new QHBoxLayout();
	backHLayout->setContentsMargins(15, 0,0,0);
	backHLayout->addWidget(backButton);
	
	QHBoxLayout *scrollLayout = new QHBoxLayout();
	scrollLayout->addWidget(scrollArea);
	scrollLayout->setAlignment(scrollArea, Qt::AlignVCenter);
	mainLayout->addLayout(scrollLayout);
	mainLayout->addStretch(3);
	mainLayout->addLayout(backHLayout);
	mainLayout->addStretch(1);
	mainLayout->addWidget(footer);
			
	setLayout(mainLayout);
}
Пример #24
0
AboutDialog::AboutDialog()
: KviTalTabDialog(0)
{
	setWindowTitle(__tr2qs_ctx("About KVIrc...","about"));
	setOkButton(__tr2qs_ctx("Close","about"));

	// About tab
	QString buffer;
	g_pApp->findImage(buffer,"kvi_release_art.png");

	QPixmap pix(buffer);

	QWidget * w = new QWidget(this);
	QGridLayout * g = new QGridLayout(w);

	QLabel * l = new QLabel(w);
	l->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
	QPalette p = l->palette();
	p.setColor(backgroundRole(), Qt::black);
	l->setPalette(p);
	l->setAlignment(Qt::AlignCenter);
	l->setPixmap(pix);

	g->addWidget(l,0,0);

	QString aboutString= "<b>KVIrc " KVI_VERSION " '" KVI_RELEASE_NAME "'</b><br>";
	aboutString += __tr2qs_ctx("Forged by the <b>KVIrc Development Team</b>","about");

	l = new QLabel(aboutString,w);
	l->setAlignment(Qt::AlignCenter);
	g->addWidget(l,1,0);

	addTab(w,__tr2qs_ctx("About","about"));


	// Info tab
	w = new QWidget(this);
	g = new QGridLayout(w);

	QTextEdit * v = new QTextEdit(w);
	v->setReadOnly(true);
	g->addWidget(v,0,0);

	// Get info
	QString infoString = "<b>KVIrc " KVI_VERSION " '" KVI_RELEASE_NAME "'</b><br><br>";
	infoString += "<b>";
	infoString += __tr2qs_ctx("Runtime Info","about");
	infoString += ":</b><br>";
	infoString += __tr2qs_ctx("System name","about");
	infoString += ": ";
	infoString += KviRuntimeInfo::name();
#ifndef COMPILE_ON_MAC
	infoString += " ";
	infoString += KviRuntimeInfo::release();
#endif
	infoString += "<br>";
	infoString += __tr2qs_ctx("System version","about");
	infoString += ": ";
	infoString += KviRuntimeInfo::version();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Architecture","about");
	infoString += ": ";
	infoString += KviRuntimeInfo::machine();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Qt version","about");
	infoString += ": ";
	infoString += KviRuntimeInfo::qtVersion();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Qt theme","about");
	infoString += ": ";
	infoString += KviRuntimeInfo::qtTheme();
	infoString += "<br><br>";
	infoString += "<b>";
	infoString += __tr2qs_ctx("Build Info","about");
	infoString += ":</b><br>";
	infoString += __tr2qs_ctx("Build date","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildDate();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Sources date","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildSourcesDate();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Revision number","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildRevision();
	infoString += "<br>";
	infoString += __tr2qs_ctx("System name","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildSystem();
	infoString += "<br>";
	infoString += __tr2qs_ctx("CPU name","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildCPU();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Build command","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildCommand();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Build flags","about");
	infoString += ": <br>&nbsp;&nbsp;&nbsp;";
	QString flags = KviBuildInfo::buildFlags();
	infoString += flags.replace(QRegExp(";"),"<br>&nbsp;&nbsp;&nbsp;");
	infoString += "<br>";
	infoString += __tr2qs_ctx("Compiler name","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildCompiler();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Compiler flags","about");
	infoString += ": ";
	infoString += KviBuildInfo::buildCompilerFlags();
	infoString += "<br>";
	infoString += __tr2qs_ctx("Qt version","about");
	infoString += ": ";
	infoString += KviBuildInfo::qtVersion();

	v->setText(infoString);

	addTab(w,__tr2qs_ctx("Executable Information","about"));


	// Honor & Glory tab
	w = new QWidget(this);
	g = new QGridLayout(w);

	v = new QTextEdit(w);
	v->setReadOnly(true);
	g->addWidget(v,0,0);

	v->setText(g_szAboutText);

	addTab(w,__tr2qs_ctx("Honor && Glory","about"));


	// License tab
	w = new QWidget(this);
	g = new QGridLayout(w);

	v = new QTextEdit(w);
	v->setReadOnly(true);
	v->setWordWrapMode(QTextOption::NoWrap);
	g->addWidget(v,0,0);

	QString szLicense;

	QString szLicensePath;
	g_pApp->getGlobalKvircDirectory(szLicensePath,KviApplication::License,"COPYING");

	if(!KviFileUtils::loadFile(szLicensePath,szLicense))
	{
		szLicense = __tr2qs_ctx("Oops! Can't find the license file.\n" \
			"It MUST be included in the distribution...\n" \
			"Please report to <pragma at kvirc dot net>","about");
	}

	v->setText(szLicense);

	addTab(w,__tr2qs_ctx("License","about"));


	connect(this,SIGNAL(applyButtonPressed()),this,SLOT(closeButtonPressed()));
}
QWidget *MemcheckErrorDelegate::createDetailsWidget(const QModelIndex &errorIndex, QWidget *parent) const
{
    QWidget *widget = new QWidget(parent);
    QVBoxLayout *layout = new QVBoxLayout;
    // code + white-space:pre so the padding (see below) works properly
    // don't include frameName here as it should wrap if required and pre-line is not supported
    // by Qt yet it seems
    const QString displayTextTemplate = QString("<code style='white-space:pre'>%1:</code> %2");

    QString relativeTo = relativeToPath();

    const Error error = errorIndex.data(ErrorListModel::ErrorRole).value<Error>();

    QLabel *errorLabel = new QLabel();
    errorLabel->setWordWrap(true);
    errorLabel->setContentsMargins(0, 0, 0, 0);
    errorLabel->setMargin(0);
    errorLabel->setIndent(0);
    QPalette p = errorLabel->palette();
    QColor lc = p.color(QPalette::Text);
    QString linkStyle = QString("style=\"color:rgba(%1, %2, %3, %4);\"")
                            .arg(lc.red()).arg(lc.green()).arg(lc.blue()).arg(int(0.7 * 255));
    p.setBrush(QPalette::Text, p.highlightedText());
    errorLabel->setPalette(p);
    errorLabel->setText(QString("%1&nbsp;&nbsp;<span %4>%2</span>")
                            .arg(error.what(), errorLocation(errorIndex, error, true, linkStyle),
                                 linkStyle));
    connect(errorLabel, SIGNAL(linkActivated(QString)), SLOT(openLinkInEditor(QString)));
    layout->addWidget(errorLabel);

    const QVector<Stack> stacks = error.stacks();
    for (int i = 0; i < stacks.count(); ++i) {
        const Stack &stack = stacks.at(i);
        // auxwhat for additional stacks
        if (i > 0) {
            QLabel *stackLabel = new QLabel(stack.auxWhat());
            stackLabel->setWordWrap(true);
            stackLabel->setContentsMargins(0, 0, 0, 0);
            stackLabel->setMargin(0);
            stackLabel->setIndent(0);
            QPalette p = stackLabel->palette();
            p.setBrush(QPalette::Text, p.highlightedText());
            stackLabel->setPalette(p);
            layout->addWidget(stackLabel);
        }
        int frameNr = 1;
        foreach (const Frame &frame, stack.frames()) {
            QString frameName = makeFrameName(frame, relativeTo);
            QTC_ASSERT(!frameName.isEmpty(), qt_noop());

            QLabel *frameLabel = new QLabel(widget);
            frameLabel->setAutoFillBackground(true);
            if (frameNr % 2 == 0) {
                // alternating rows
                QPalette p = frameLabel->palette();
                p.setBrush(QPalette::Base, p.alternateBase());
                frameLabel->setPalette(p);
            }
            frameLabel->setFont(QFont("monospace"));
            connect(frameLabel, SIGNAL(linkActivated(QString)), SLOT(openLinkInEditor(QString)));
            // pad frameNr to 2 chars since only 50 frames max are supported by valgrind
            const QString displayText = displayTextTemplate
                                            .arg(frameNr++, 2).arg(frameName);
            frameLabel->setText(displayText);

            frameLabel->setToolTip(Valgrind::XmlProtocol::toolTipForFrame(frame));
            frameLabel->setWordWrap(true);
            frameLabel->setContentsMargins(0, 0, 0, 0);
            frameLabel->setMargin(0);
            frameLabel->setIndent(10);
            layout->addWidget(frameLabel);
        }
    }

    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);
    widget->setLayout(layout);
    return widget;
}
Пример #26
0
int KMessageBox::createKMessageBox(KDialog *dialog, const QIcon &icon,
                             const QString &text, const QStringList &strlist,
                             const QString &ask, bool *checkboxReturn, Options options,
                             const QString &details, QMessageBox::Icon notifyType)
{
    QWidget *mainWidget = new QWidget(dialog);
    QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
    mainLayout->setSpacing(KDialog::spacingHint() * 2); // provide extra spacing
    mainLayout->setMargin(0);

    QHBoxLayout *hLayout = new QHBoxLayout();
    hLayout->setMargin(0);
    hLayout->setSpacing(-1); // use default spacing
    mainLayout->addLayout(hLayout,5);

    QLabel *iconLabel = new QLabel(mainWidget);

    if (!icon.isNull()) {
        QStyleOption option;
        option.initFrom(mainWidget);
        iconLabel->setPixmap(icon.pixmap(mainWidget->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, &option, mainWidget)));
    }

    QVBoxLayout *iconLayout = new QVBoxLayout();
    iconLayout->addStretch(1);
    iconLayout->addWidget(iconLabel);
    iconLayout->addStretch(5);

    hLayout->addLayout(iconLayout,0);
    hLayout->addSpacing(KDialog::spacingHint());

    QLabel *messageLabel = new QLabel(text, mainWidget);
    messageLabel->setOpenExternalLinks(options & KMessageBox::AllowLink);
    Qt::TextInteractionFlags flags = Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard;
    if (options & KMessageBox::AllowLink) {
        flags |= Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard;
    }
    messageLabel->setTextInteractionFlags(flags);

    QRect desktop = KGlobalSettings::desktopGeometry(dialog);
    bool usingSqueezedTextLabel = false;
    if (messageLabel->sizeHint().width() > desktop.width() * 0.5) {
        // enable automatic wrapping of messages which are longer than 50% of screen width
        messageLabel->setWordWrap(true);
        // display a text widget with scrollbar if still too wide
        usingSqueezedTextLabel = messageLabel->sizeHint().width() > desktop.width() * 0.85;
        if (usingSqueezedTextLabel)
        {
            delete messageLabel;
            messageLabel = new KSqueezedTextLabel(text, mainWidget);
            messageLabel->setOpenExternalLinks(options & KMessageBox::AllowLink);
            messageLabel->setTextInteractionFlags(flags);
        }
    }

    QPalette messagePal(messageLabel->palette());
    messagePal.setColor(QPalette::Window, Qt::transparent);
    messageLabel->setPalette(messagePal);


    bool usingScrollArea=desktop.height() / 3 < messageLabel->sizeHint().height();
    if (usingScrollArea)
    {
        QScrollArea* messageScrollArea = new QScrollArea(mainWidget);
        messageScrollArea->setWidget(messageLabel);
        messageScrollArea->setFrameShape(QFrame::NoFrame);
        messageScrollArea->setWidgetResizable(true);
        QPalette scrollPal(messageScrollArea->palette());
        scrollPal.setColor(QPalette::Window, Qt::transparent);
        messageScrollArea->viewport()->setPalette(scrollPal);
        hLayout->addWidget(messageScrollArea,5);
    }
    else
        hLayout->addWidget(messageLabel,5);


    const bool usingListWidget=!strlist.isEmpty();
    if (usingListWidget) {
        // enable automatic wrapping since the listwidget has already a good initial width
        messageLabel->setWordWrap(true);
        QListWidget *listWidget = new QListWidget(mainWidget);
        listWidget->addItems(strlist);

        QStyleOptionViewItem styleOption;
        styleOption.initFrom(listWidget);
        QFontMetrics fm(styleOption.font);
        int w = listWidget->width();
        Q_FOREACH(const QString &str, strlist) {
            w = qMax(w, fm.width(str));
        }
        const int borderWidth = listWidget->width() - listWidget->viewport()->width() + listWidget->verticalScrollBar()->height();
        w += borderWidth;
        if (w > desktop.width() * 0.85) { // limit listWidget size to 85% of screen width
            w = qRound(desktop.width() * 0.85);
        }
        listWidget->setMinimumWidth(w);

        mainLayout->addWidget(listWidget,usingScrollArea?10:50);
        listWidget->setSelectionMode(QListWidget::NoSelection);
        messageLabel->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);
    }
Пример #27
0
QWidget* ProcessingManager::setupQueueContainer() {
    queueModel_ = new ProcessingModel(this);
    connect(&projectData, &ProjectData::toBeAddedToProcessingQueue, queueModel_, &ProcessingModel::addProcesses);
    
    QFormLayout* layout = new QFormLayout;
    layout->setHorizontalSpacing(10);
    layout->setVerticalSpacing(2);
    layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
    layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
    layout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
    layout->setLabelAlignment(Qt::AlignLeft);

    int numberOfThreads = QThread::idealThreadCount();
    if(numberOfThreads < 1) numberOfThreads = 1;
    
    processesBox_ = new QSpinBox;
    processesBox_->setFrame(false);
    processesBox_->setMinimum(1);
    processesBox_->setMaximum(numberOfThreads);
    processesBox_->setValue(ProjectPreferences().processJobs());
    connect(processesBox_, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int value){
        ProjectPreferences().setProcessJobs(value);
    });
    layout->addRow("Number of jobs to run in parallel", processesBox_);
    
    QLabel* introLabel = new QLabel("The maximum number of threads on your system is: " + QString::number(numberOfThreads));
    introLabel->setWordWrap(true);
    QPalette pal = introLabel->palette();
    pal.setColor(QPalette::WindowText, Qt::darkGray);
    introLabel->setPalette(pal);
    layout->addRow(introLabel);
    
    GroupContainer* jobcontainer = new GroupContainer;
    jobcontainer->setTitle("Concurrency Selection");
    jobcontainer->setContainerLayout(layout);
    
    QToolButton* addSelectedButton = getButton("add_queue", "Add Images", "Add selected images from the project library to the processing queue");
    connect(addSelectedButton, &GraphicalButton::clicked, [=]() {
        projectData.addSelectedToQueue();
    });
    
    QToolButton* clearSelectedButton = getButton("remove_highlighted", "Clear Selected", "Remove highlighted images from the processing queue");
    connect(clearSelectedButton, &GraphicalButton::clicked, [=]() {
        while(!queueView_->selectionModel()->selectedIndexes().isEmpty()) {
            QModelIndex i = queueView_->selectionModel()->selectedIndexes().first();
            if(!i.parent().isValid()) {
                queueModel_->removeRow(i.row());
            }
        }
        
        setQueueCount(queueModel_->rowCount());
    });
    
    QToolButton* clearAllButton = getButton("remove_all", "Clear All", "Remove all images from queue");
    connect(clearAllButton, &GraphicalButton::clicked, queueModel_, &ProcessingModel::clearAll);
    
    QToolButton* prioritizeButton = getButton("prioritize_highlighted", "Prioritize", "Prioritize the processing of highlighted images");
    connect(prioritizeButton, &GraphicalButton::clicked, [=]() {
        for(QModelIndex i : queueView_->selectionModel()->selectedRows(0)) {
            if(!i.parent().isValid()) {
                queueModel_->insertRow(0, queueModel_->takeRow(i.row()));
            }
        }
    });
    
    QHBoxLayout* buttonLayout = new QHBoxLayout();
    buttonLayout->addStretch(0);
    buttonLayout->addWidget(addSelectedButton, 0);
    buttonLayout->addStretch(1);
    buttonLayout->addWidget(prioritizeButton, 0);
    buttonLayout->addWidget(clearAllButton, 0);
    buttonLayout->addWidget(clearSelectedButton, 0);
    
    
    queueView_ = new QTreeView(this);
    queueView_->setAttribute(Qt::WA_MacShowFocusRect, 0);
    queueView_->setModel(queueModel_);
    queueView_->setSelectionMode(QAbstractItemView::ExtendedSelection);
    queueView_->setSortingEnabled(true);
    queueView_->setAllColumnsShowFocus(true);
    queueView_->setAlternatingRowColors(true);
    queueView_->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
    queueView_->setHeaderHidden(true);
    
    BlockContainer* queueContainer = new BlockContainer("Images in queue", queueView_);
    
    QVBoxLayout *queueLayout = new QVBoxLayout;
    queueLayout->setMargin(10);
    queueLayout->setSpacing(10);
    queueLayout->addLayout(buttonLayout, 0);
    queueLayout->addWidget(queueContainer, 1);

    GroupContainer* container = new GroupContainer;
    container->setTitle("Processing Queue");
    container->setContainerLayout(queueLayout);
    
    
    QVBoxLayout* mainLayout = new QVBoxLayout();
    mainLayout->setMargin(0);
    mainLayout->setSpacing(10);
    mainLayout->addStretch(0);
    mainLayout->addWidget(jobcontainer, 0);
    mainLayout->addWidget(container, 1);
    
    QWidget* mainContainer = new QWidget;
    mainContainer->setLayout(mainLayout);
    mainContainer->setMaximumWidth(500);
    
    return mainContainer;
}
Пример #28
0
void PlayersPopup::updateFromServer(const Server& server)
{
    setUpdatesEnabled(false);

    ui->svlabel_GameMode->setText(server.GameModeString);
    // time
    if (server.TimeLimit > 0)
    {
        ui->svlabel_Time->setText(QString("%1/%2").arg(QString::number(server.TimeLimit-server.TimeLeft),
                                                       QString::number(server.TimeLimit)));
    }
    else
    {
        ui->svlabel_Time->setText("unlimited");
    }
    // frags
    QString frgType = server.getPointsName();
    if (frgType == "Frags" || frgType == "Points" || frgType == "Wins")
    {
        ui->svlabel_PointsName->setText(frgType+":");
        int limit = 0;
        if (frgType == "Frags") limit = server.FragLimit;
        else if (frgType == "Points") limit = server.PointLimit;
        else if (frgType == "Wins") limit = server.WinLimit;
        if (limit > 0)
        {
            // find top point team or player
            int topPts = 0;
            if (!server.Teams.isEmpty())
            {
                topPts = -32768;
                for (int i = 0; i < server.Teams.size(); i++)
                {
                    //qDebug("%s = %d", server.Teams[i].NameClean.toUtf8().data(), server.Teams[i].Points);
                    if (server.Teams[i].Points > topPts)
                        topPts = server.Teams[i].Points;
                }
            }
            else
            {
                topPts = -32768;
                for (int i = 0; i < server.Players.size(); i++)
                {
                    if (server.Players[i].Points > topPts)
                        topPts = server.Players[i].Points;
                }
            }
            ui->svlabel_Points->setText(QString("%1/%2").arg(QString::number(topPts),
                                                             QString::number(limit)));
        }
        else
        {
            ui->svlabel_Points->setText("unlimited");
        }
    }
    else // simulating IDE behavior. although IMO in this case we should just hide the points counter.
    {
        ui->svlabel_PointsName->setText("Frags:");
        ui->svlabel_Points->setText("unlimited");
    }
    // players
    int canjoin = server.MaxPlayers-server.PlayerCount;
    // sometimes canjoin can be negative.  for example when an admin forces their join into a nospec server.
    // let's keep it negative to amuse users  ;)
    QString ptext = QString("%1/%2").arg(QString::number(server.PlayerCount+server.BotCount),
                                         QString::number(server.MaxClients));
    if (canjoin != 0)
        ptext += QString(" (")+QString::number(canjoin)+QString(" can join)");
    ui->svlabel_Players->setText(ptext);
    // teams
    // first, remove all old labels
    for (int i = 0; i < teams.size(); i++)
        delete teams[i];
    teams.clear();

    for (int i = 0; i < server.Teams.size(); i++)
    {
        QLabel* teamlabel = new QLabel(ui->frame_2);
        teamlabel->setText(QString("%1: %2").arg(server.Teams[i].NameClean, QString::number(server.Teams[i].Points)));
        QFont nf = teamlabel->font();
        nf.setBold(true);
        teamlabel->setFont(nf);
        // now adjust label background
        QPalette np = teamlabel->palette();
        QColor lbg = server.Teams[i].Color;
        np.setColor(QPalette::Background, lbg);
        float luminance = 0.299*lbg.redF() + 0.587*lbg.greenF() + 0.114*lbg.blueF();
        if (luminance > 0.5)
            np.setColor(QPalette::WindowText, QColor(0, 0, 0, 255));
        else np.setColor(QPalette::WindowText, QColor(255, 255, 255, 255));
        teamlabel->setPalette(np);
        teamlabel->setAutoFillBackground(true);
        teamlabel->setMargin(2);
        ui->svlayout_teams->addWidget(teamlabel);
        teams.append(teamlabel);
    }

    ui->svlayout_teams->activate();

    setUpdatesEnabled(true);
}