示例#1
0
TopMenuBar::TopMenuBar()
    : MenuBar(),
      m_prevCursorPos(-1, -1),
      m_mouseTracker(new QTimer(this)),
      m_hideGlowTimer(new QTimer(this)),
      m_glowBar(new GlowBar())
{
    connect(this, SIGNAL(aboutToHide()), this, SLOT(slotAboutToHide()));
    connect(m_mouseTracker, SIGNAL(timeout()), this, SLOT(slotMouseTracker()));
    connect(m_hideGlowTimer, SIGNAL(timeout()), this, SLOT(slotHideGlowBar()));
}
示例#2
0
MenuBar::MenuBar()
    : QGraphicsView(),
    m_hideTimer(new QTimer(this)),
    m_background(new Plasma::FrameSvg(this)),
    m_shadows(new Shadows(this)),
    m_scene(new QGraphicsScene(this)),
    m_container(new MenuWidget(this))
{
    qreal left, top, right, bottom;

    //Setup the window properties
    setWindowFlags(Qt::Tool|Qt::X11BypassWindowManagerHint|Qt::WindowStaysOnTopHint);
    setAttribute(Qt::WA_TranslucentBackground);
    KWindowSystem::setType(winId(), NET::Dock);
    setFrameStyle(QFrame::NoFrame);
    viewport()->setAutoFillBackground(false);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    //Setup the widgets
    m_background->setImagePath("widgets/tooltip");
    m_background->setEnabledBorders(Plasma::FrameSvg::BottomBorder|Plasma::FrameSvg::LeftBorder|Plasma::FrameSvg::RightBorder);

    m_container->initLayout();

    m_scene->addItem(m_container);

    setScene(m_scene);

    m_background->getMargins(left, top, right, bottom);
    m_container->layout()->setContentsMargins(left, top, right, bottom);

    resize(sizeHint());

    connect(m_container, SIGNAL(aboutToHide()), this, SLOT(slotAboutToHide()));
    connect(m_container, SIGNAL(needResize()), this, SIGNAL(needResize()));
    connect(m_hideTimer, SIGNAL(timeout()), this, SLOT(slotAboutToHide()));

    connect(KWindowSystem::self(), SIGNAL(compositingChanged(bool)), this, SLOT(slotCompositingChanged(bool)));
}