Commit cc295bc9 authored by Jörg Schummer's avatar Jörg Schummer Committed by Kai Koehne
Browse files

QuickDesigner.itemLibrary: enable mouse wheel interaction in items view

Task-number: BAUHAUS-657
parent 1373fc13
......@@ -153,6 +153,7 @@ ItemLibrary::ItemLibrary(QWidget *parent) :
QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(m_d->m_itemsView->rootObject());
connect(rootItem, SIGNAL(itemSelected(int)), this, SLOT(showItemInfo(int)));
connect(rootItem, SIGNAL(itemDragged(int)), this, SLOT(startDragAndDrop(int)));
connect(this, SIGNAL(scrollItemsView(QVariant)), rootItem, SLOT(scrollView(QVariant)));
connect(this, SIGNAL(resetItemsView()), rootItem, SLOT(resetView()));
/* create Resources view and its model */
......@@ -318,4 +319,14 @@ void ItemLibrary::showItemInfo(int /*itemLibId*/)
// qDebug() << "showing item info about id" << itemLibId;
}
void ItemLibrary::wheelEvent(QWheelEvent *event)
{
if (m_d->m_stackedWidget->currentIndex() == 0 &&
m_d->m_itemsView->rect().contains(event->pos())) {
emit scrollItemsView(event->delta());
event->accept();
} else
QFrame::wheelEvent(event);
}
}
......@@ -61,8 +61,12 @@ public Q_SLOTS:
void startDragAndDrop(int itemLibId);
void showItemInfo(int itemLibId);
protected:
void wheelEvent(QWheelEvent *event);
signals:
void itemActivated(const QString& itemName);
void scrollItemsView(QVariant delta);
void resetItemsView();
private:
......
......@@ -60,6 +60,10 @@ Rectangle {
// public
function scrollView(delta) {
scrollbar.scroll(-delta / style.scrollbarWheelDeltaFactor)
}
function resetView() {
expandAllEntries()
scrollbar.reset()
......
......@@ -41,6 +41,7 @@ Item {
property string scrollbarGradientMiddleColor: "#656565"
property string scrollbarGradientEndColor: "#888888"
property int scrollbarClickScrollAmount: 40
property int scrollbarWheelDeltaFactor: 4
property string itemNameTextColor: "#FFFFFF"
......
......@@ -38,6 +38,10 @@ Item {
property variant flickable
function scroll(delta) {
handle.y = Math.max(0, Math.min(scrollHeight, handle.y + delta))
}
function reset() {
handle.y = 0
}
......@@ -100,7 +104,7 @@ Item {
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: handle.top
onClicked: handle.y = Math.max(0, handle.y - style.scrollbarClickScrollAmount)
onClicked: scroll(-style.scrollbarClickScrollAmount)
}
Item {
......@@ -151,6 +155,6 @@ Item {
anchors.right: parent.right
anchors.top: handle.bottom
anchors.bottom: parent.bottom
onClicked: handle.y = Math.min(scrollHeight, handle.y + style.scrollbarClickScrollAmount)
onClicked: scroll(style.scrollbarClickScrollAmount)
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment