Example #1
0
int main(int argc, char *argv[])
{

    QApplication a(argc, argv);
    QWidget w;
    w.setWindowTitle ( "Quelle est cette note?" );

    w.setFixedSize(800, 720);

    // set color background
    QPalette Pal(w.palette());
    Pal.setColor(QPalette::Background, QColor::fromRgb(250, 250, 250));
    w.setAutoFillBackground(true);
    w.setPalette(Pal);


    po = new Portee(&w);
    Piano *pi = new Piano(&w);
    po->setPiano(pi);

    addMenus(&w);
    QVBoxLayout qvbox;
    qvbox.addWidget(po);
    qvbox.addWidget(pi);
    w.setLayout(&qvbox);

    w.show();

    return a.exec();
}
Example #2
0
void DJToolButton::paintEvent( QPaintEvent *event )
{	

	QWidget *parentWidget = qobject_cast<QWidget*>(parent());
	if ( parentWidget ) {
		QPalette::ColorRole parentRole	= parentWidget->backgroundRole();
			
		QPalette parentPalette = parentWidget->palette();
		//QRect rect = parentWidget->rect();
		QBrush parentBrush = parentPalette.brush( parentRole );
		//QPixmap parentPix(prect.width(),prect.height());
		//QPainter p(&pix);
		//p.fillRect(0,0,pix.width(),pix.height(),parentbrush);
		
		QPalette pal = palette();
		pal.setBrush(QPalette::Button,parentBrush);
		setPalette(pal);
	}
	
	//QRect qrect = tbw->geometry();
		//		QRect prect = parent->rect();
	
				
	/*
	QPalette pal = palette();
	//pal.setBrush(QPalette::Background,Qt::red);
	pal.setBrush(QPalette::Button,Qt::green);
	//pal.setBrush(QPalette::Base,Qt::blue);
	setPalette(pal);
	*/
	QToolButton::paintEvent( event );
}
Example #3
0
WebView *TabWidget::newTab(bool makeCurrent)
{
    // line edit
    UrlLineEdit *urlLineEdit = new UrlLineEdit;
    QLineEdit *lineEdit = urlLineEdit->lineEdit();
    if (!m_lineEditCompleter && count() > 0) {
        HistoryCompletionModel *completionModel = new HistoryCompletionModel(this);
        completionModel->setSourceModel(BrowserApplication::historyManager()->historyFilterModel());
        m_lineEditCompleter = new QCompleter(completionModel, this);
        // Should this be in Qt by default?
        QAbstractItemView *popup = m_lineEditCompleter->popup();
        QListView *listView = qobject_cast<QListView*>(popup);
        if (listView)
            listView->setUniformItemSizes(true);
    }
    lineEdit->setCompleter(m_lineEditCompleter);
    connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed()));
    m_lineEdits->addWidget(urlLineEdit);
    m_lineEdits->setSizePolicy(lineEdit->sizePolicy());

    // optimization to delay creating the more expensive WebView, history, etc
    if (count() == 0) {
        QWidget *emptyWidget = new QWidget;
        QPalette p = emptyWidget->palette();
        p.setColor(QPalette::Window, palette().color(QPalette::Base));
        emptyWidget->setPalette(p);
        emptyWidget->setAutoFillBackground(true);
        disconnect(this, SIGNAL(currentChanged(int)),
            this, SLOT(currentChanged(int)));
        addTab(emptyWidget, tr("(Untitled)"));
        connect(this, SIGNAL(currentChanged(int)),
            this, SLOT(currentChanged(int)));
        currentChanged(currentIndex());
        return 0;
    }
Example #4
0
ContextView::ContextView( QWidget* parent, const QString& caption )
    : QWidget( parent )
    , m_trackView( new TrackView() )
    , m_temporary( false )
{
    TrackItemDelegate* del = new TrackItemDelegate( TrackItemDelegate::LovedTracks, m_trackView, m_trackView->proxyModel() );
    m_trackView->setPlaylistItemDelegate( del );
    m_trackView->proxyModel()->setStyle( PlayableProxyModel::SingleColumn );
    m_trackView->setStyleSheet( QString( "QTreeView { background-color: %1; }" ).arg( TomahawkStyle::PAGE_BACKGROUND.name() ) );
#ifndef Q_OS_MAC
    TomahawkStyle::styleScrollBar( m_trackView->verticalScrollBar() );
#endif

    setLayout( new QVBoxLayout() );
    TomahawkUtils::unmarginLayout( layout() );

    m_captionLabel = new CaptionLabel( this );
    setCaption( caption );

    QWidget* vbox = new QWidget;
    QPalette pal = vbox->palette();
    pal.setBrush( vbox->backgroundRole(), TomahawkStyle::PAGE_BACKGROUND );
    vbox->setPalette( pal );
    vbox->setAutoFillBackground( true );

    QVBoxLayout* vboxl = new QVBoxLayout();
    TomahawkUtils::unmarginLayout( vboxl );
    vboxl->setContentsMargins( 32, 32, 32, 32 );
    vboxl->setSpacing( 32 );

    vbox->setLayout( vboxl );

    QWidget* hbox = new QWidget;
    QHBoxLayout* hboxl = new QHBoxLayout();
    TomahawkUtils::unmarginLayout( hboxl );
    hboxl->setSpacing( 32 );

    m_innerLayout = new QVBoxLayout();
    TomahawkUtils::unmarginLayout( m_innerLayout );
    m_innerLayout->addWidget( m_trackView, 1 );
    m_innerLayout->addStretch();

    m_detailView = new TrackDetailView;
    m_detailView->setPlaylistInterface( playlistInterface() );
    hboxl->addWidget( m_detailView );
    hboxl->addLayout( m_innerLayout );
    hbox->setLayout( hboxl );

    vboxl->addWidget( m_captionLabel );
    vboxl->addWidget( hbox );
    layout()->addWidget( vbox );

    connect( m_captionLabel, SIGNAL( clicked() ), SIGNAL( closeClicked() ) );
    connect( m_trackView, SIGNAL( querySelected( Tomahawk::query_ptr ) ), SLOT( onQuerySelected( Tomahawk::query_ptr ) ) );
    connect( m_trackView, SIGNAL( querySelected( Tomahawk::query_ptr ) ), m_detailView, SLOT( setQuery( Tomahawk::query_ptr ) ) );
    connect( m_trackView, SIGNAL( modelChanged() ), SLOT( onModelChanged() ) );

    TomahawkUtils::fixMargins( this );
}
Example #5
0
QColor UTLauncher::iconColor() const {
    if(getenv("ICON_COLOR")) {
        return QColor(getenv("ICON_COLOR"));
    } else {
        QWidget w;
        return w.palette().color(w.foregroundRole());
    }
}
Example #6
0
/*
  Should we require that  q is a toplevel window ???

  Used by QWSManager
 */
void QWidgetPrivate::blitToScreen(const QRegion &globalrgn)
{
    Q_Q(QWidget);
    QWidget *win = q->window();
    QBrush bgBrush = win->palette().brush(win->backgroundRole());
    bool opaque = bgBrush.style() == Qt::NoBrush || bgBrush.isOpaque();
    QWidget::qwsDisplay()->repaintRegion(win->data->winid, win->windowFlags(), opaque, globalrgn);
}
void ServiceBlock::setCalendarColor(QCalendarWidget *calendarWidget,QColor color)
{
    QWidget *calendarNavBar = calendarWidget->findChild<QWidget *>("qt_calendar_navigationbar");
    if (calendarNavBar) {
        QPalette pal = calendarNavBar->palette();
        pal.setColor(calendarNavBar->backgroundRole(), color);
        calendarNavBar->setPalette(pal);
    }
}
Example #8
0
	void draw(QPainter& painter, QSize size)
	{
		static QPixmap pm;
		if(pm.isNull())
		{
			int s = ceil(size.height() / 2.0);
			pm = QPixmap(2*s, 2*s);
			QColor c1 = container->palette().color(QPalette::Midlight);
			QColor c2 = container->palette().color(QPalette::Dark);
			QPainter pmp(&pm);
			pmp.fillRect(0, 0, s, s, c1);
			pmp.fillRect(s, s, s, s, c1);
			pmp.fillRect(0, s, s, s, c2);
			pmp.fillRect(s, 0, s, s, c2);
		}
		painter.fillRect(0, 0, size.width(), size.height(), QBrush(pm));
		painter.fillRect(0, 0, size.width(), size.height(), QBrush(toQColor(theColor)));
	}
Example #9
0
void MainWindow::resizeEvent(QResizeEvent* event)
{
    //call methode of parent class
    QMainWindow::resizeEvent(event);

    //calcluate position and size for given event.size()
    int newHeight = event->size().height();
    int newWidth = event->size().width();

    double ratioSpeedWidget = this->speedWidget->heightForWidth(1); //just to get ratio
    int newWidthSpeedWidget = (newHeight-20) / ratioSpeedWidget;

    int newWidthTabWidgets = newWidth - newWidthSpeedWidget - 70;

    //update ScaleInformation signleton
    ScaleInformation::getInstance()->setMainWindowSize( event->size() );


    //determine minimum width of ClickGenerator Widgets
    int minimumWidthClickGeneratorWidgets = 0;
    if(this->clickGeneratorDivisionWidget->getMinimumWidthForMainWindowHeight( newHeight ) > minimumWidthClickGeneratorWidgets )
        minimumWidthClickGeneratorWidgets = this->clickGeneratorDivisionWidget->getMinimumWidthForMainWindowHeight( event->size().height() );

    if(this->clickGeneratorXoYWidget->getMinimumWidthForMainWindowHeight( newHeight ) > minimumWidthClickGeneratorWidgets )
        minimumWidthClickGeneratorWidgets = this->clickGeneratorXoYWidget->getMinimumWidthForMainWindowHeight( event->size().height() );

    if(this->clickGeneratorPASWidget->getMinimumWidthForMainWindowHeight( newHeight ) > minimumWidthClickGeneratorWidgets )
        minimumWidthClickGeneratorWidgets = this->clickGeneratorPASWidget->getMinimumWidthForMainWindowHeight( event->size().height() );

    //determine minimumWidthForMainWindow
    if(minimumWidthClickGeneratorWidgets > newWidthTabWidgets)
    {
        newWidth += minimumWidthClickGeneratorWidgets - newWidthTabWidgets;
        newWidthTabWidgets = minimumWidthClickGeneratorWidgets;
        this->resize(newWidth, newHeight);
    }


    //resize speedWidget
    this->speedWidget->setGeometry(10, 20, newWidthSpeedWidget, newHeight-20);
    this->theClickForm->speedGroupBox->setGeometry(newWidth-newWidthSpeedWidget-30, 0, newWidthSpeedWidget+20, newHeight-10);

    //debug
    QWidget* debugWidget = this->m_XToXAssociationWidget->leftScrollList;
    QPalette pal =  debugWidget->palette();
    pal.setColor(QPalette::Background, Qt::blue);
    debugWidget->setPalette(pal);
    debugWidget->setBackgroundRole( QPalette::Background );
    debugWidget->setAutoFillBackground(true);
    debugWidget->repaint();

    //resize ClickGenerators
    this->clickGeneratorScrollListOfWidgets->setGeometry( QRect(10, 20, newWidthTabWidgets, newHeight-40) );
    this->m_XToXAssociationWidget->setGeometry( QRect(10, 20, newWidthTabWidgets, newHeight-40) );
    this->theClickForm->tabWidget->setGeometry(10, 0, newWidthTabWidgets+20, newHeight-10);
}
Example #10
0
EAppearance RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) const
{
    // Default bits: no focus, no mouse over
    option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver);

    if (!isEnabled(o))
        option.state &= ~QStyle::State_Enabled;

    if (isReadOnlyControl(o))
        // Readonly is supported on textfields.
        option.state |= QStyle::State_ReadOnly;

    if (supportsFocus(o->style()->appearance()) && isFocused(o))
        option.state |= QStyle::State_HasFocus;

    if (isHovered(o))
        option.state |= QStyle::State_MouseOver;

    EAppearance result = o->style()->appearance();

    switch (result) {
        case PushButtonAppearance:
        case SquareButtonAppearance:
        case ButtonAppearance:
        case ButtonBevelAppearance:
        case ListItemAppearance:
        case MenulistButtonAppearance:
        case ScrollbarButtonLeftAppearance:
        case ScrollbarButtonRightAppearance:
        case ScrollbarTrackHorizontalAppearance:
        case ScrollbarTrackVerticalAppearance:
        case ScrollbarThumbHorizontalAppearance:
        case ScrollbarThumbVerticalAppearance:
        case SearchFieldResultsButtonAppearance:
        case SearchFieldCancelButtonAppearance: {
            if (isPressed(o))
                option.state |= QStyle::State_Sunken;
            else if (result == PushButtonAppearance)
                option.state |= QStyle::State_Raised;
            break;
        }
    }

    if(result == RadioAppearance || result == CheckboxAppearance)
        option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off);

    // If the webview has a custom palette, use it
    Page* page = o->document()->page();
    if (page) {
        QWidget* view = static_cast<ChromeClientQt*>(page->chrome()->client())->m_webPage->view();
        if (view)
            option.palette = view->palette();
    }

    return result;
}
Example #11
0
void DesktopDock::createDefaultConfiguration()
{
	QWidget w;

	config_file.addVariable("Desktop Dock", "DockingColor", w.palette().color(QPalette::Active, QPalette::Window));
	config_file.addVariable("Desktop Dock", "DockingTransparency", true);
	config_file.addVariable("Desktop Dock", "MoveInMenu", true);
	config_file.addVariable("Desktop Dock", "PositionX", 0);
	config_file.addVariable("Desktop Dock", "PositionY", 0);
}
Example #12
0
void ProviderConfigWidget::showRegisterError(const Attica::Metadata& metadata)
{
    if (metadata.error() == Attica::Metadata::NetworkError) {
        showRegisterHint("dialog-close", i18n("Failed to register new account."));
    } else {
        /*
# 100 - successful / valid account
# 101 - please specify all mandatory fields
# 102 - please specify a valid password
# 103 - please specify a valid login
# 104 - login already exists
# 105 - email already taken
*/
        // TODO: Looks like more correct place for this stuff is in libattica,
        // for example metadata().statusString() or smth like that.
        // So here will be only showRegisterHint("dialog-close", statusString);
        // no switch.
        QWidget* widgetToHighlight = 0;
        QString hint;
        switch (metadata.statusCode()) {
            case 102:
                hint = i18n("Failed to register new account: invalid password.");
                widgetToHighlight = m_ui.passwordEditRP;
                break;
            case 103:
                hint = i18n("Failed to register new account: invalid username.");
                widgetToHighlight = m_ui.userEditRP;
                break;
            case 104:
                hint = i18n("Failed to register new account: the requested username is already taken.");
                widgetToHighlight = m_ui.userEditRP;
                break;
            case 105:
                hint = i18n("Failed to register new account: the specified email address is already taken.");
                widgetToHighlight = m_ui.mailEdit;
                break;
            case 106:
                hint = i18n("Failed to register new account: the specified email address is invalid.");
                widgetToHighlight = m_ui.mailEdit;
            default:
                hint = i18n("Failed to register new account.");
                break;
        }

        if (!hint.isEmpty())
            showRegisterHint("dialog-close", hint);

        if (widgetToHighlight) {
            QPalette pal = widgetToHighlight->palette();
            KColorScheme::adjustBackground(pal, KColorScheme::NegativeBackground, QPalette::Base);
            widgetToHighlight->setPalette(pal);
            widgetToHighlight->setFocus();
        }
    }
}
Example #13
0
void QmitkPropertyDelegate::setModelData(QWidget *editor, QAbstractItemModel* model
  , const QModelIndex &index) const
{
  QVariant data = index.data(Qt::EditRole);
  QVariant displayData = index.data(Qt::DisplayRole);

  if(data.isValid())
  {

    if(data.type() == QVariant::Color)
    {
      QWidget *colorBtn = qobject_cast<QWidget *>(editor);
      QVariant colorVariant;
      colorVariant.setValue<QColor>(colorBtn->palette().color(QPalette::Button));
      model->setData(index, colorVariant);
    }

    else if(data.type() == QVariant::Int)
    {
      QSpinBox* spinBox = qobject_cast<QSpinBox *>(editor);
      int intValue = spinBox->value();

      QVariant intValueVariant;
      intValueVariant.setValue<float>(static_cast<float>(intValue));
      model->setData(index, intValueVariant);
    }

    else if(static_cast<QMetaType::Type>(data.type()) == QMetaType::Float)
    {
      QDoubleSpinBox* spinBox = qobject_cast<QDoubleSpinBox *>(editor);
      double doubleValue = spinBox->value();

      QVariant doubleValueVariant;
      doubleValueVariant.setValue<float>(static_cast<float>(doubleValue));
      model->setData(index, doubleValueVariant);
    }

    else if(data.type() == QVariant::StringList)
    {
      QString displayData = data.value<QString>();

      QComboBox* comboBox = qobject_cast<QComboBox *>(editor);
      QString comboBoxValue = comboBox->currentText();

      QVariant comboBoxValueVariant;
      comboBoxValueVariant.setValue<QString>(comboBoxValue);
      model->setData(index, comboBoxValueVariant);
    }

    else
      QStyledItemDelegate::setModelData(editor, model, index);
  }

}
Example #14
0
 bool PreviewMdiArea::viewportEvent (QEvent * event) {
     if (event->type() != QEvent::Paint)
         return QMdiArea::viewportEvent (event);
     QWidget *paintWidget = viewport();
     QPainter p(paintWidget);
     p.fillRect(rect(), paintWidget->palette().color(backgroundRole()).dark());
     p.setPen(QPen(Qt::white));
     //: Palette editor background
     p.drawText(0, height() / 2,  width(), height(), Qt::AlignHCenter,
                QCoreApplication::translate("qdesigner_internal::PreviewMdiArea", "The moose in the noose\nate the goose who was loose."));
     return true;
 }
Example #15
0
static void initViewPalette(QAbstractItemView* view, const QColor& fgColor)
{
    QWidget* viewport = view->viewport();
    QPalette palette = viewport->palette();
    palette.setColor(viewport->backgroundRole(), Qt::transparent);
    palette.setColor(QPalette::WindowText, fgColor);
    palette.setColor(QPalette::Text, fgColor);

    // QListView uses QStyledItemDelegate, which uses the view palette for
    // foreground color, while KFilePlacesView uses the viewport palette.
    viewport->setPalette(palette);
    view->setPalette(palette);
}
CalamaresWindow::CalamaresWindow( QWidget* parent )
    : QWidget( parent )
{
    // Hide close button
    setWindowFlags( Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint );

    setMinimumSize( 1010, 560 );
    QSize availableSize = qApp->desktop()->screenGeometry( this ).size();
    int w = qBound( 1010, CalamaresUtils::defaultFontHeight() * 60, availableSize.width() );
    int h = qBound( 560,  CalamaresUtils::defaultFontHeight() * 36, availableSize.height() );

    cDebug() << "Proposed window size:" << w << h;
    resize( w, h );

    QBoxLayout* mainLayout = new QHBoxLayout;
    setLayout( mainLayout );

    QWidget* sideBox = new QWidget( this );
    mainLayout->addWidget( sideBox );

    QBoxLayout* sideLayout = new QVBoxLayout;
    sideBox->setLayout( sideLayout );
    sideBox->setFixedWidth( qMax( 190, CalamaresUtils::defaultFontHeight() * 12 ) );
    sideBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );

    QHBoxLayout* logoLayout = new QHBoxLayout;
    sideLayout->addLayout( logoLayout );
    logoLayout->addStretch();
    QLabel* logoLabel = new QLabel( "branding\ngoes\nhere", sideBox );
    {
        QPalette plt = sideBox->palette();
        sideBox->setAutoFillBackground( true );
        plt.setColor( sideBox->backgroundRole(), CalamaresStyle::SIDEBAR_BACKGROUND );
        plt.setColor( sideBox->foregroundRole(), CalamaresStyle::SIDEBAR_TEXT );
        sideBox->setPalette( plt );
        logoLabel->setPalette( plt );
    }
    logoLabel->setAlignment( Qt::AlignCenter );
    logoLabel->setFixedSize( 80, 80 );
    logoLayout->addWidget( logoLabel );
    logoLayout->addStretch();

    ProgressTreeView* tv = new ProgressTreeView( sideBox );
    sideLayout->addWidget( tv );
    CalamaresUtils::unmarginLayout( sideLayout );
    CalamaresUtils::unmarginLayout( mainLayout );

    Calamares::ViewManager* vm = new Calamares::ViewManager( this );

    mainLayout->addWidget( vm->centralWidget() );
}
Example #17
0
static QIcon codeIcon(const QString& s, QFont f)
      {
      f.setPixelSize(40);
      int w = 40;
      int h = 40;

      QWidget wi;

      QPixmap image(w, h);
      QColor bg(wi.palette().brush(QPalette::Normal, QPalette::Window).color());

      image.fill(QColor(255, 255, 255, 0));
      QPainter painter(&image);
      painter.setRenderHint(QPainter::TextAntialiasing, true);
      painter.setFont(f);

      QPen pen(wi.palette().brush(QPalette::Normal, QPalette::Text).color());

      painter.setPen(pen);
      painter.drawText(0, 0, w, h, Qt::AlignCenter, s);
      painter.end();
      return QIcon(image);
      }
Example #18
0
void AmbientProperties::on_buttonForeground_clicked()
{
    QColor c = QColorDialog::getColor(foreSample->palette().color(foreSample->backgroundRole()), this);
    QPalette p = foreSample->palette(); p.setColor(foreSample->backgroundRole(), c); foreSample->setPalette(p);
    p = container->palette(); p.setColor(container->foregroundRole(), c); container->setPalette(p);

    if (QWorkspace *ws = qobject_cast<QWorkspace*>(container)) {
	QWidgetList list( ws->windowList() );
	for (int i = 0; i < list.count(); ++i) {
	    QWidget *widget = list.at(i);
	    p = widget->palette(); p.setColor(widget->foregroundRole(), c); widget->setPalette(p);
	}
    }
}
Example #19
0
void SyntaxHighlighter::update()
{
    ColorScheme id = static_cast<ColorScheme>(Settings::instance()->colorScheme);
    m_colorScheme = createColorScheme(id);

    QColor backgroundColor = colorForRole(DisplayBackground);
    QWidget* parentWidget = static_cast<QWidget*>(parent());
    QPalette pal = parentWidget->palette();
    pal.setColor(QPalette::Active, QPalette::Base, backgroundColor);
    pal.setColor(QPalette::Inactive, QPalette::Base, backgroundColor);
    parentWidget->setPalette(pal);

    rehighlight();
}
Example #20
0
ResourcePreview::ResourcePreview(CaptureContext *c, IReplayOutput *output, QWidget *parent)
    : QFrame(parent), ui(new Ui::ResourcePreview)
{
  ui->setupUi(this);

  CustomPaintWidget *thumb = new CustomPaintWidget(c, this);
  thumb->setOutput(output);
  thumb->setObjectName(ui->thumbnail->objectName());
  thumb->setSizePolicy(ui->thumbnail->sizePolicy());
  thumb->setMinimumSize(QSize(0, 0));

  delete ui->thumbnail;
  ui->thumbnail = thumb;
  ui->gridLayout->addWidget(ui->thumbnail, 0, 0, 1, 2);

  QPalette Pal(ui->slotLabel->palette());

  QWidget tmp;

  Pal.setColor(ui->slotLabel->foregroundRole(), tmp.palette().color(QPalette::Foreground));
  Pal.setColor(ui->slotLabel->backgroundRole(), tmp.palette().color(QPalette::Dark));

  ui->slotLabel->setAutoFillBackground(true);
  ui->slotLabel->setPalette(Pal);
  ui->descriptionLabel->setAutoFillBackground(true);
  ui->descriptionLabel->setPalette(Pal);

  QObject::connect(ui->thumbnail, &CustomPaintWidget::clicked, this, &ResourcePreview::clickEvent);
  QObject::connect(ui->slotLabel, &RDLabel::clicked, this, &ResourcePreview::clickEvent);
  QObject::connect(ui->descriptionLabel, &RDLabel::clicked, this, &ResourcePreview::clickEvent);

  QObject::connect(ui->thumbnail, &CustomPaintWidget::doubleClicked, this,
                   &ResourcePreview::doubleClickEvent);
  QObject::connect(ui->slotLabel, &RDLabel::doubleClicked, this, &ResourcePreview::doubleClickEvent);
  QObject::connect(ui->descriptionLabel, &RDLabel::doubleClicked, this,
                   &ResourcePreview::doubleClickEvent);
}
void tst_QWindowContainer::testActivation()
{
    QWidget root;

    QWindow *window = new QWindow();
    QWidget *container = QWidget::createWindowContainer(window, &root);

    container->setGeometry(100, 100, 200, 100);
    root.setGeometry(100, 100, 400, 300);

    root.show();
    root.activateWindow();
    QVERIFY(QTest::qWaitForWindowExposed(&root));

    QVERIFY(QTest::qWaitForWindowActive(root.windowHandle()));
    QVERIFY(QGuiApplication::focusWindow() == root.windowHandle());

    // Verify that all states in the root widget indicate it is active
    QVERIFY(root.windowHandle()->isActive());
    QVERIFY(root.isActiveWindow());
    QCOMPARE(root.palette().currentColorGroup(), QPalette::Active);

    // Under KDE (ubuntu 12.10), we experience that doing two activateWindow in a row
    // does not work. The second gets ignored by the window manager, even though the
    // timestamp in the xcb connection is unique for both.
    if (QGuiApplication::platformName() == "xcb")
        QTest::qWait(100);

    window->requestActivate();
    QTRY_VERIFY(QGuiApplication::focusWindow() == window);

    // Verify that all states in the root widget still indicate it is active
    QVERIFY(root.windowHandle()->isActive());
    QVERIFY(root.isActiveWindow());
    QCOMPARE(root.palette().currentColorGroup(), QPalette::Active);
}
TScriptEditorHighlighter::TScriptEditorHighlighter(QTextDocument *document, config *cfg) :
    QSyntaxHighlighter(document),
    conf(cfg)
{

    blockKeywords << "SCRIPT" << "META" << "FUNCTION" << "RETURN" << "DIALOG" << "MENU";

    metaKeywords << "INCLUDE" << "EVENT" << "COMMAND" << "TIMER" << "STIMER";

    scriptKeywords << "VAR" << "DEL" << "INC" << "DEC" << "IF" << "ELSE" << "WHILE" << "BREAK"
                   << "CONTINUE" << "ECHO" << "CON" << "WCON" << "SCON" << "DCON";

    QWidget w;
    defaultForeground = w.palette().foreground().color();
}
Example #23
0
void MainWindow::initClient()
{
    QWidget* client = new QWidget(this);
    setCentralWidget(client);

    client->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    QPalette pal = client->palette();
    pal.setBrush(QPalette::Window, QBrush("#FFFFFF"));
    client->setPalette(pal);
    client->setAutoFillBackground(true);

    QHBoxLayout* layout = new QHBoxLayout();
    layout->setContentsMargins(0, 0, 0, 0);
    client->setLayout(layout);

    m_splitter = new CWizSplitter();
    layout->addWidget(m_splitter);

    QWidget* documentPanel = new QWidget();
    QHBoxLayout* layoutDocument = new QHBoxLayout();
    layoutDocument->setContentsMargins(0, 0, 0, 0);
    layoutDocument->setSpacing(0);
    documentPanel->setLayout(layoutDocument);
    layoutDocument->addWidget(m_doc);
    layoutDocument->addWidget(m_documentSelection);
    m_documentSelection->hide();
    // append after client
    m_doc->layout()->addWidget(m_transitionView);
    m_transitionView->hide();

    m_splitter->addWidget(m_category);

    QWidget* wlist = new QWidget(this);
    QHBoxLayout* layoutList = new QHBoxLayout();
    layoutList->setContentsMargins(0, 0, 0, 0);
    layoutList->setSpacing(0);
    layoutList->addWidget(createListView());
    layoutList->addWidget(m_msgList);
    wlist->setLayout(layoutList);
    m_splitter->addWidget(wlist);
    m_splitter->addWidget(documentPanel);
    m_splitter->setStretchFactor(0, 0);
    m_splitter->setStretchFactor(1, 0);
    m_splitter->setStretchFactor(2, 1);

    m_msgList->hide();
}
QWidget *DevicesConfigurationWidget::configurerForRobotModel(RobotModelInterface &robotModel)
{
	/// @todo: What if robot model has no configurable sensors?
	QWidget *result = new QWidget;
	QPalette palette = result->palette();
	palette.setColor(QPalette::Background, Qt::transparent);
	result->setPalette(palette);
	QVBoxLayout * const layout = new QVBoxLayout(result);
	layout->setContentsMargins(0, 0, 0, 0);
	QList<PortInfo> const configurablePorts = robotModel.configurablePorts();
	for (const PortInfo &port : configurablePorts) {
		layout->addLayout(initPort(robotModel.name(), port, robotModel.allowedDevices(port)));
	}

	return result;
}
Example #25
0
QStyleOptionMenuItem KxMenuItemWidget::getStyleOption() const
{
    QWidget *q = parentWidget();
    QMenu *menu = (QMenu *)q;
    KxMenuItem *action = fMenuItem;
    QStyleOptionMenuItem opt;

    opt.initFrom(this);
    opt.palette = q->palette();
    opt.state = QStyle::State_None;

    if (q->window()->isActiveWindow())
        opt.state |= QStyle::State_Active;
    if (q->isEnabled() && action->isEnabled()
        && (!action->menu() || action->menu()->isEnabled()))
        opt.state |= QStyle::State_Enabled;
    else
        opt.palette.setCurrentColorGroup(QPalette::Disabled);

    opt.font = action->font();

    if (menu->activeAction() == action && !action->isSeparator()) {
        opt.state |= QStyle::State_Selected;
        // 					 | (mouseDown ? QStyle::State_Sunken : QStyle::State_None);
    }

    if (!action->isCheckable()) {
        opt.checkType = QStyleOptionMenuItem::NotCheckable;
    } else {
        opt.checkType = (action->actionGroup() && action->actionGroup()->isExclusive())
            ? QStyleOptionMenuItem::Exclusive : QStyleOptionMenuItem::NonExclusive;
        opt.checked = action->isChecked();
    }
    if (action->menu())
        opt.menuItemType = QStyleOptionMenuItem::SubMenu;
    else if (action->isSeparator())
        opt.menuItemType = QStyleOptionMenuItem::Separator;
    else if (menu->defaultAction() == action)
        opt.menuItemType = QStyleOptionMenuItem::DefaultItem;
    else
        opt.menuItemType = QStyleOptionMenuItem::Normal;
    opt.icon = action->icon();
    opt.text = action->text();
    opt.menuRect = q->rect();
    return opt;
}
Example #26
0
void QChildWidget::paintEvent(QPaintEvent*)
{
    for (QWidget *p = parentWidget(); p; p = p->parentWidget()){
        const QPixmap bg = p->palette().brush(p->backgroundRole()).texture();
        if (!bg.isNull()){
            QPoint pos = mapToGlobal(QPoint(0, 0));
            pos = p->mapFromGlobal(pos);
            QPainter pp(this);
            pp.drawTiledPixmap(0, 0, width(), height(), bg, pos.x(), pos.y());
            return;
        }
        if (p == topLevelWidget())
            break;
    }
    QPainter pp(this);
    pp.eraseRect(0, 0, width(), height());
}
Example #27
0
/*
 * Returns the native background color.
 */
JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getNativeBackground
(JNIEnv *env, jobject obj)
{
  QWidget *cb = (QWidget *) getNativeObject( env, obj );
  assert(cb);
  QColor c = cb->palette().background().color().toRgb();

  jclass cls = env->FindClass("java/awt/Color");
  jmethodID mid = env->GetMethodID(cls, "<init>", "(III)V");
  jvalue values[3];
  
  values[0].i = (jint) c.red();
  values[1].i = (jint) c.green();
  values[2].i = (jint) c.blue();

  return env->NewObjectA(cls, mid, values);
}
Example #28
0
void RKInput::updateColor () {
	RK_TRACE (PLUGIN);

	QWidget *widget = lineedit;
	if (!widget) widget = textedit;
	RK_ASSERT (widget);

	QPalette palette = widget->palette ();
	if (isEnabled ()) {
		if (isSatisfied ()) {
			palette.setColor (widget->backgroundRole (), QColor (255, 255, 255));
		} else {
			palette.setColor (widget->backgroundRole (), QColor (255, 0, 0));
		}
	} else {
		palette.setColor (widget->backgroundRole (), QColor (200, 200, 200));
	}
	widget->setPalette (palette);
}
Example #29
0
void drawSelectionBackground(QPainter *painter, const QStyleOption &option)
{
    QWidget colorReference;

    painter->save();
    QLinearGradient gradient;
    QColor highlightColor = colorReference.palette().highlight().color();
    if (0.5*highlightColor.saturationF()+0.75-highlightColor.valueF() < 0)
        highlightColor.setHsvF(highlightColor.hsvHueF(),0.1 + highlightColor.saturationF()*2.0, highlightColor.valueF());
    gradient.setColorAt(0, highlightColor.lighter(130));
    gradient.setColorAt(1, highlightColor.darker(130));
    gradient.setStart(option.rect.topLeft());
    gradient.setFinalStop(option.rect.bottomLeft());
    painter->fillRect(option.rect, gradient);
    painter->setPen(highlightColor.lighter());
    painter->drawLine(option.rect.topLeft(),option.rect.topRight());
    painter->setPen(highlightColor.darker());
    painter->drawLine(option.rect.bottomLeft(),option.rect.bottomRight());
    painter->restore();
}
Example #30
0
/*!
    Returns a QTextFormat object that specifies the format for
    component \a s.
*/
QTextFormat QInputContext::standardFormat(StandardFormat s) const
{
    QWidget *focus = focusWidget();
    const QPalette &pal = focus ? focus->palette() : QApplication::palette();

    QTextCharFormat fmt;
    QColor bg;
    switch (s) {
    case QInputContext::PreeditFormat: {
        fmt.setUnderlineStyle(QTextCharFormat::DashUnderline);
        break;
    }
    case QInputContext::SelectionFormat: {
        bg = pal.text().color();
        fmt.setBackground(QBrush(bg));
        fmt.setForeground(pal.background());
        break;
    }
    }
    return fmt;
}