KarbonPaletteBarWidget::KarbonPaletteBarWidget(Qt::Orientation orientation, QWidget *parent)
    : QWidget(parent)
    , m_prevButton(0), m_nextButton(0), m_choosePalette(0), m_colorBar(0)
    , m_palettes(KoResourceServerProvider::instance()->paletteServer())
{
    m_palettes.connectToResourceServer();

    m_prevButton = new QToolButton(this);
    m_prevButton->setAutoRepeat(true);
    m_prevButton->setAutoRepeatInterval(ScrollUpdateIntervall);
    m_nextButton = new QToolButton(this);
    m_nextButton->setAutoRepeat(true);
    m_nextButton->setAutoRepeatInterval(ScrollUpdateIntervall);

    m_choosePalette = new QToolButton(this);
    m_choosePalette->setToolTip(i18n("Select palette"));
    m_choosePalette->setArrowType(Qt::DownArrow);

    m_colorBar = new KarbonPaletteWidget(this);
    m_colorBar->setOrientation(orientation);
    connect(m_prevButton, SIGNAL(clicked()), m_colorBar, SLOT(scrollBackward()));
    connect(m_nextButton, SIGNAL(clicked()), m_colorBar, SLOT(scrollForward()));
    connect(m_colorBar, SIGNAL(colorSelected(KoColor)), this, SIGNAL(colorSelected(KoColor)));
    connect(m_colorBar, SIGNAL(scrollOffsetChanged()), this, SLOT(updateButtons()));
    connect(m_choosePalette, SIGNAL(clicked()), this, SLOT(selectPalette()));

    setMinimumSize(FixedWidgetSize, FixedWidgetSize);
    m_colorBar->setMinimumSize(FixedWidgetSize, FixedWidgetSize);

    createLayout();

    m_documentColors.setName(DocumentColorsName);

    QList<KoResource*> resources = m_palettes.resources();
    if (resources.count()) {
        KConfigGroup paletteGroup = KGlobal::mainComponent().config()->group("PaletteBar");
        QString lastPalette = paletteGroup.readEntry("LastPalette", "SVG Colors");
        KoResource *r = resources.first();
        if (lastPalette == DocumentColorsName) {
            r = &m_documentColors;
        } else {
            foreach(KoResource *res, resources) {
                if (res->name() == lastPalette) {
                    r = res;
                    break;
                }
            }
        }
        m_colorBar->setPalette(dynamic_cast<KoColorSet*>(r));
        updateDocumentColors();
    }
示例#2
0
void ScrollAnimator::adjustAnimationAndSetScrollOffset(
    const ScrollOffset& offset,
    ScrollType scrollType) {
  IntSize adjustment =
      roundedIntSize(offset) - roundedIntSize(m_scrollableArea->scrollOffset());
  scrollOffsetChanged(offset, scrollType);

  if (m_runState == RunState::Idle) {
    adjustImplOnlyScrollOffsetAnimation(adjustment);
  } else if (hasRunningAnimation()) {
    m_targetOffset += ScrollOffset(adjustment);
    if (m_animationCurve) {
      m_animationCurve->applyAdjustment(adjustment);
      if (m_runState != RunState::RunningOnMainThread &&
          registerAndScheduleAnimation())
        m_runState = RunState::RunningOnCompositorButNeedsAdjustment;
    }
  }
}
示例#3
0
void ProgrammaticScrollAnimator::notifyOffsetChanged(
    const ScrollOffset& offset) {
  scrollOffsetChanged(offset, ProgrammaticScroll);
}
示例#4
0
void ScrollAnimatorBase::notifyOffsetChanged() {
  scrollOffsetChanged(m_currentOffset, UserScroll);
}