示例#1
0
void SettingsDlg::slotGridCBChecked(bool value)
{
    if (value == false) {
        QPalette palette;
        m_UiWidgets.gridColorB->setColor( palette.alternateBase().color() );
        m_UiWidgets.gridColorB->setDisabled(true);
    }
    else {
        m_UiWidgets.gridColorB->setDisabled(false);
    }
}
/**
 * @brief Loads the default application settings.
 */
void Settings::load_default_application_settings() {

  QPalette palette;
  QString alternate_color = palette.alternateBase().color().name();
  QString base_color = palette.base().color().name();

  // Map editor.
  default_values[map_background] = alternate_color;

  // Sprite editor.
  default_values[sprite_main_background] = base_color;
  default_values[sprite_previewer_background] = base_color;
}
示例#3
0
void VideoWindow::highlight(int ms)
{
    for(int r=0; r < this->eventsPositionInMiliseconds.size(); r++){
        QTableWidgetItem* item = this->ui->sequence->item(r,0);
        if(this->eventsPositionInMiliseconds.at(r) <= ms+125){
            if(this->eventsPositionInMiliseconds.at(r) >= ms-125)  item->setBackgroundColor(Qt::green);
            else item->setBackgroundColor(QColor(153,255,255));
        } else {
            QPalette p;
            if(r%2==0)
                item->setBackground(p.base());
            else
                item->setBackground(p.alternateBase());
        }
    }
}
示例#4
0
/*! \~russian
 * \brief Метод инициализирует элементы настройки цвета в соответствии с переданной палитрой.
 * \param palette - палитра для инициализации
 */
void Settings::initColorPickers(QPalette palette)
{
    ui->Frame_Style_Window->setColor( palette.window().color() );
    ui->Frame_Style_WindowText->setColor( palette.windowText().color() );
    ui->Frame_Style_Base->setColor( palette.base().color() );
    ui->Frame_Style_AlternateBase->setColor( palette.alternateBase().color() );
    ui->Frame_Style_ToolTipBase->setColor( palette.toolTipBase().color() );
    ui->Frame_Style_ToolTipText->setColor( palette.toolTipText().color() );
    ui->Frame_Style_Text->setColor( palette.text().color() );
    ui->Frame_Style_Button->setColor( palette.button().color() );
    ui->Frame_Style_ButtonText->setColor( palette.buttonText().color() );
    ui->Frame_Style_BrightText->setColor( palette.brightText().color() );
    ui->Frame_Style_Link->setColor( palette.link().color() );
    ui->Frame_Style_Highlight->setColor( palette.highlight().color() );
    ui->Frame_Style_HighlightedText->setColor( palette.highlightedText().color() );
}
示例#5
0
QString Charm::reportStylesheet( const QPalette& palette )
{
    QString style;
    QFile stylesheet( ":/Charm/report_stylesheet.sty" );
    if ( stylesheet.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
        style = stylesheet.readAll();
        style.replace(QLatin1String("@header_row_background_color@"), palette.highlight().color().name());
        style.replace(QLatin1String("@header_row_foreground_color@"), palette.highlightedText().color().name());
        style.replace(QLatin1String("@alternate_row_background_color@"), palette.alternateBase().color().name());
        style.replace(QLatin1String("@event_attributes_row_background_color@"), palette.midlight().color().name());
        if ( style.isEmpty() ) {
            qWarning() << "reportStylesheet: default style sheet is empty, too bad";
        }
    } else {
        qCritical() << "reportStylesheet: cannot load report style sheet:" << stylesheet.errorString();
    }
    return style;
}
示例#6
0
void KWidgetListbox::setItemColors(int index, bool even)
{
  QWidget* itm = item(index);
  // KDE4 add
  QPalette p = palette();
if ( !itm){ kDebug()<<"no widget at index "<<index; return; }
/*
  if(index == selected())
  {
    itm->setPaletteBackgroundColor(KGlobalSettings::highlightColor());
    itm->setPaletteForegroundColor(KGlobalSettings::highlightedTextColor());
  }*/
  if(even)
   p.setColor(backgroundRole(), p.base().color() );
  else
   p.setColor(backgroundRole(), p.alternateBase().color() );
  
  p.setColor(foregroundRole(), p.text().color() );
  itm->setPalette(p); 
}
示例#7
0
QVariantMap Bridge::get_palette()
{
    QVariantMap colors;
    QPalette palette = qApp->palette();
    colors.insert("window", palette.window().color().name());
    colors.insert("window_text", palette.windowText().color().name());
    colors.insert("base", palette.base().color().name());
    colors.insert("alternate_base", palette.alternateBase().color().name());
    colors.insert("text", palette.text().color().name());
    colors.insert("button", palette.buttonText().color().name());
    colors.insert("bright_text", palette.brightText().color().name());
    colors.insert("light", palette.light().color().name());
    colors.insert("midlight", palette.midlight().color().name());
    colors.insert("dark", palette.dark().color().name());
    colors.insert("mid", palette.mid().color().name());
    colors.insert("shadow", palette.shadow().color().name());
    colors.insert("highlight", palette.highlight().color().name());
    colors.insert("highlight_text", palette.highlightedText().color().name());
    colors.insert("link", palette.link().color().name());
    colors.insert("link_visited", palette.linkVisited().color().name());
    return colors;
}
示例#8
0
/* Fill a single protocol tree item with its string value and set its color. */
static void
proto_tree_draw_node(proto_node *node, gpointer data)
{
    field_info   *fi = PNODE_FINFO(node);
    gchar         label_str[ITEM_LABEL_LENGTH];
    gchar        *label_ptr;
    gboolean      is_branch;

    /* dissection with an invisible proto tree? */
    g_assert(fi);

    if (PROTO_ITEM_IS_HIDDEN(node) && !prefs.display_hidden_proto_items)
        return;

    // Fill in our label
    /* was a free format label produced? */
    if (fi->rep) {
        label_ptr = fi->rep->representation;
    }
    else { /* no, make a generic label */
        label_ptr = label_str;
        proto_item_fill_label(fi, label_str);
    }

    if (node->first_child != NULL) {
        is_branch = TRUE;
        g_assert(fi->tree_type >= 0 && fi->tree_type < num_tree_types);
    }
    else {
        is_branch = FALSE;
    }

    if (PROTO_ITEM_IS_GENERATED(node)) {
        if (PROTO_ITEM_IS_HIDDEN(node)) {
            label_ptr = g_strdup_printf("<[%s]>", label_ptr);
        } else {
            label_ptr = g_strdup_printf("[%s]", label_ptr);
        }
    } else if (PROTO_ITEM_IS_HIDDEN(node)) {
        label_ptr = g_strdup_printf("<%s>", label_ptr);
    }

    QTreeWidgetItem *parentItem = (QTreeWidgetItem *)data;
    QTreeWidgetItem *item;
    ProtoTree *proto_tree = qobject_cast<ProtoTree *>(parentItem->treeWidget());

    item = new QTreeWidgetItem(parentItem, 0);

    // Set our colors.
    QPalette pal = QApplication::palette();
    if (fi && fi->hfinfo) {
        if(fi->hfinfo->type == FT_PROTOCOL) {
            item->setData(0, Qt::BackgroundRole, pal.alternateBase());
        }

        if((fi->hfinfo->type == FT_FRAMENUM) ||
                (FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type))) {
            QFont font = item->font(0);

            item->setData(0, Qt::ForegroundRole, pal.link());
            font.setUnderline(true);
            item->setData(0, Qt::FontRole, font);

            if (fi->hfinfo->type == FT_FRAMENUM) {
                proto_tree->emitRelatedFrame(fi->value.value.uinteger);
            }
        }
    }

    // XXX - Add routines to get our severity colors.
    if(FI_GET_FLAG(fi, PI_SEVERITY_MASK)) {
        switch(FI_GET_FLAG(fi, PI_SEVERITY_MASK)) {
        case(PI_COMMENT):
            item->setData(0, Qt::BackgroundRole, expert_color_comment);
            break;
        case(PI_CHAT):
            item->setData(0, Qt::BackgroundRole, expert_color_chat);
            break;
        case(PI_NOTE):
            item->setData(0, Qt::BackgroundRole, expert_color_note);
            break;
        case(PI_WARN):
            item->setData(0, Qt::BackgroundRole, expert_color_warn);
            break;
        case(PI_ERROR):
            item->setData(0, Qt::BackgroundRole, expert_color_error);
            break;
        default:
            g_assert_not_reached();
        }
        item->setData(0, Qt::ForegroundRole, expert_color_foreground);
    }

    item->setText(0, label_ptr);
    item->setData(0, Qt::UserRole, qVariantFromValue(fi));

    if (PROTO_ITEM_IS_GENERATED(node) || PROTO_ITEM_IS_HIDDEN(node)) {
        g_free(label_ptr);
    }

    if (is_branch) {
        if (tree_expanded(fi->tree_type)) {
            item->setExpanded(true);
        } else {
            item->setExpanded(false);
        }

        proto_tree_children_foreach(node, proto_tree_draw_node, item);
    }
}
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;
}
示例#10
0
文件: CodeView.cpp 项目: emoon/ProDBG
void CodeView::lineNumberAreaPaintEvent(QPaintEvent* event)
{
    QPalette pal = QApplication::palette();

#ifdef _WIN32
    QFont font(QStringLiteral("Courier"), 11);
#else
    QFont font(QStringLiteral("Courier"), 13);
#endif

    QPainter painter(m_lineNumberArea);
    painter.fillRect(event->rect(), pal.alternateBase());

    painter.setFont(font);

    QTextBlock block = firstVisibleBlock();
    int blockNumber = block.blockNumber();
    int top = (int)blockBoundingGeometry(block).translated(contentOffset()).top();
    int bottom = top + (int)blockBoundingRect(block).height();
    int width = m_lineNumberArea->width() - 4;
    int height = fontMetrics().height();

    int fontHeight = fontMetrics().height() - 2;

    while (block.isValid() && top <= event->rect().bottom()) {
        if (block.isVisible() && bottom >= event->rect().top()) {
            QString number = QString::number(blockNumber + 1);
            painter.setPen(pal.text().color());

            painter.drawText(0, top, width, height, Qt::AlignRight, number);

            if (m_breakpoints->hasBreakpointFileLine(m_sourceFile, blockNumber + 1)) {
                painter.setBrush(Qt::red);
                painter.drawEllipse(4, top, fontHeight, fontHeight);
            }

            // Draw ugly arrow!

            if ((blockNumber + 1) == m_currentSourceLine) {
                float scale = fontHeight / 2.0f;
                float pos_x = 10.0f;
                float pos_y = top + scale;

                const QPointF points[7] = {
                    QPointF((0.0f * scale) + pos_x, (-0.5f * scale) + pos_y),
                    QPointF((0.5f * scale) + pos_x, (-0.5f * scale) + pos_y),
                    QPointF((0.5f * scale) + pos_x, (-1.0f * scale) + pos_y),

                    QPointF((1.0f * scale) + pos_x, (0.0f * scale) + pos_y),

                    QPointF((0.5f * scale) + pos_x, (1.0f * scale) + pos_y),
                    QPointF((0.5f * scale) + pos_x, (0.5f * scale) + pos_y),
                    QPointF((0.0f * scale) + pos_x, (0.5f * scale) + pos_y),
                };

                painter.setPen(Qt::yellow);
                painter.setBrush(Qt::yellow);
                painter.drawConvexPolygon(points, 7);
            }
        }

        block = block.next();
        top = bottom;
        bottom = top + (int)blockBoundingRect(block).height();
        ++blockNumber;
    }
}
示例#11
0
void DateTimeEditor::paintEvent(QPaintEvent* /*event*/)
{
  QPainter painter(this);
  
  QStyleOptionFrame panel;
  initStyleOption(&panel);
  style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &painter, this);

  QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this);
  const int margin = 2;
  r.setX(r.x() + margin);
  r.setY(r.y() + margin);
  r.setRight(r.right() - margin);
  r.setBottom(r.bottom() - margin);
  painter.setClipRect(r);
  
  QPalette pal = style()->standardPalette();

  if (m_selectedPosition >= 0)
  {
    const GroupInfo& g = m_groups[m_selectedGroup];
    
    for (auto p: g.positions)
    {
      const QRect r = getCharacterRect(p);
      painter.fillRect(r, pal.alternateBase());
    }

    const QRect r = getCharacterRect(m_selectedPosition);
    if (g.invalid)
    {
      painter.fillRect(r, Qt::red);
    }
    else
    {
      painter.fillRect(r, pal.highlight());
    }
  }
  
  painter.setRenderHint(QPainter::Antialiasing);
  for (const CharacterInfo& c : m_characters)
  {
    const QRect r = getCharacterRect(c.m_position);   
    if (c.m_position == m_selectedPosition)
    {
      painter.setPen(pal.highlightedText().color());
    }
    else
    {
      const GroupInfo& g = m_groups[c.m_group];
      if (g.invalid)
      {
        painter.setPen(Qt::red);
      }
      else
      {
        painter.setPen(pal.text().color());
      }
    }
    
    painter.drawText(r, Qt::AlignCenter, c.m_character);
  }
}
示例#12
0
void FastSizeHintItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    painter->save();

    painter->setClipping(true);
    painter->setClipRect(option.rect);
    QBrush bgBrush;
#ifndef NOKDE
    const KColorScheme& scheme=activeScheme;
    if (option.state&QStyle::State_MouseOver)
        bgBrush=scheme.background(KColorScheme::LinkBackground);
    else if (index.row()%2)
        bgBrush=scheme.background(KColorScheme::AlternateBackground);
    else
        bgBrush=scheme.background(KColorScheme::NormalBackground);
#else
    static QPalette p;
    if (option.state&QStyle::State_MouseOver)
        bgBrush=p.highlight();
    else if (index.row()%2)
        bgBrush=p.alternateBase();
    else
        bgBrush=p.base();
#endif
    
    painter->fillRect(option.rect, bgBrush);
    painter->setClipRect(option.rect.adjusted(0,0,-2,0));
    //painter->setFont(option.font);

    RowColumnUnion rc;
    rc.index.row=index.row();
    rc.index.column=index.column();
    //TMDBModel* m=static_cast<const TMDBModel*>(index.model());
    if (!cache.contains(rc.v))
    {
        QString text=index.data(FastSizeHintItemDelegate::HtmlDisplayRole).toString();
        cache.insert(rc.v, new QStaticText(text));
        cache.object(rc.v)->setTextFormat(richTextColumns.at(index.column())?Qt::RichText:Qt::PlainText);
    }
    int rectWidth=option.rect.width();
    QStaticText* staticText=cache.object(rc.v);
    //staticText->setTextWidth(rectWidth-4);
    QPoint textStartPoint=option.rect.topLeft();
    textStartPoint.rx()+=2;
    painter->drawStaticText(textStartPoint, *staticText);


    if (staticText->size().width()<=rectWidth-4)
    {
        painter->restore();
        return;
    }

    painter->setPen(bgBrush.color());
    QPoint p1=option.rect.topRight();
    QPoint p2=option.rect.bottomRight();
    int limit=qMin(8, rectWidth-2);
    int i=limit;
    while(--i>0)
    {
        painter->setOpacity(float(i)/limit);
        painter->drawLine(p1, p2);
        p1.rx()--;
        p2.rx()--;
    }
    painter->restore();
}
示例#13
0
文件: simonview.cpp 项目: KDE/simon
/**
 * @brief Constructor
 *
 * This is the constructor of the main-UI class - the Simon View class.
 * It displays a little splash screen and initializes the member-variables
 *
 * @author Peter Grasch
 * @param Qwidget *parent
 * The parent which is passed on to the QMainWindow initialization - Default: 0
 * @param Qt::WFlags flags
 * The flags which are also passed on to the QMainWindow constructor - as before: Default: 0
 *
 */
SimonView::SimonView(QWidget* parent, Qt::WFlags flags)
: KXmlGuiWindow(parent, flags), ScenarioDisplay(),
  backButtonAnimation(new QTimeLine(700, this))
{
  Logger::log ( i18n ( "Starting Simon..." ) );

  //showing splash
  bool showSplash = KCmdLineArgs::parsedArgs()->isSet("splash");
  SimonInfo *info = 0;

  if (showSplash) {
    info = new SimonInfo();
    Logger::log ( i18n ( "Displaying Splashscreen..." ) );
    info->showSplash();
    info->writeToSplash ( i18n ( "Loading core..." ) );
  }

  KGlobal::locale()->insertCatalog("simonlib");

  control = (new SimonControl(this));

  if (!control->firstRunWizardCompleted()) {
    QPointer<FirstRunWizard> firstRun = new FirstRunWizard(this);
    bool firstRunWizardCompleted = firstRun->exec();
    delete firstRun;

    if (firstRunWizardCompleted || KMessageBox::questionYesNo(this, i18n("You did not complete the initial configuration. Simon will continue with default values.\n\nDo you want Simon to display the wizard again on the next start?"))==KMessageBox::No)
      control->setFirstRunWizardCompleted(true);
  }

  trayManager = new TrayIconManager(this);

  this->trayManager->createIcon ( KIcon ( KIconLoader().loadIcon("simon", KIconLoader::Panel, KIconLoader::SizeMedium, KIconLoader::DisabledState) ), i18n ( "Simon - Deactivated" ) );

  QMainWindow ( parent,flags );
  qApp->setQuitOnLastWindowClosed(false);
  ui.setupUi ( this );
  
  statusBar()->insertItem(i18n("Not connected"),0);
  statusBar()->insertItem("",1,10);
  statusBar()->insertPermanentWidget(2,StatusManager::global(this)->createWidget(this));

  ScenarioManager::getInstance()->registerScenarioDisplay(this);
  ScenarioManager::getInstance()->installScenarioOfferUi(this);
  
  //Preloads all Dialogs
  if (showSplash)
    info->writeToSplash ( i18n ( "Loading training..." ) );
  trainDialog = new TrainingView(this);
  ScenarioManager::getInstance()->registerScenarioDisplay(trainDialog);

  if (showSplash)
    info->writeToSplash ( i18n ( "Loading vocabulary..." ) );
  vocabularyView = new VocabularyView(this);
  ScenarioManager::getInstance()->registerScenarioDisplay(vocabularyView);

  if (showSplash)
    info->writeToSplash ( i18n ( "Loading grammar..." ) );
  grammarView = new GrammarView(this);
  ScenarioManager::getInstance()->registerScenarioDisplay(grammarView);

  if (showSplash)
    info->writeToSplash ( i18n ( "Loading context..." ) );
  contextDialog = new ContextView(this);
  ScenarioManager::getInstance()->registerScenarioDisplay(contextDialog);

  if (showSplash)
    info->writeToSplash ( i18n ( "Loading run..." ) );
  runDialog = new RunCommandView(this);
  connect(runDialog, SIGNAL(actionsChanged()), this, SLOT(updateActionList()));
  ScenarioManager::getInstance()->registerScenarioDisplay(runDialog);

  if (showSplash)
    info->writeToSplash ( i18n ( "Loading interface..." ) );

  setupActions();

  setupGUI();
  displayScenarioPrivate(ScenarioManager::getInstance()->getCurrentScenario());
  
  welcomePage = new WelcomePage(actionCollection()->action("activate"));
  ScenarioManager::getInstance()->registerScenarioDisplay(welcomePage);
  connect(welcomePage, SIGNAL(editScenario()), this, SLOT(editScenario()));
  
  ui.swMain->insertWidget(0, welcomePage);
  ui.swMain->setCurrentIndex(0);
  
  ui.inlineView->registerPage(vocabularyView);
  ui.inlineView->registerPage(trainDialog);
  ui.inlineView->registerPage(grammarView);
  ui.inlineView->registerPage(contextDialog);
  ui.inlineView->registerPage(runDialog);
  
  ui.frmBackToOverview->setMaximumHeight(0);
  connect(backButtonAnimation, SIGNAL(frameChanged(int)), this, SLOT(backButtonAnimationStep(int)));
  {
    QPalette p = ui.frmBackToOverview->palette();
    p.setBrush(QPalette::Window, p.alternateBase());
    ui.frmBackToOverview->setPalette(p);
  }
  
  connect(ui.pbBackToOverview, SIGNAL(clicked()), this, SLOT(backToOverview()));
  
  setupSignalSlots();
  control->startup();

  //hiding splash again after loading
  if (showSplash) {
    info->hideSplash();
    delete info;
  }

  if (!control->startMinimized()) {
    show();
#ifdef Q_OS_MAC
    raise();
#endif
  }
}