1
/***********************************************************************
3
* Copyright (C) 2011 Graeme Gott <graeme@gottcode.org>
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
***********************************************************************/
20
#include "toolbar_list.h"
24
//-----------------------------------------------------------------------------
26
ToolBarList::ToolBarList(QWidget* parent)
29
m_toolbar = new QToolBar(this);
30
m_toolbar->setFloatable(false);
31
m_toolbar->setMovable(false);
32
m_toolbar->setIconSize(QSize(16,16));
33
m_toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
34
m_toolbar->setStyleSheet("QToolBar { border-top: 1px solid palette(mid); }");
37
setContextMenuPolicy(Qt::ActionsContextMenu);
38
setMovement(QListView::Static);
39
setResizeMode(QListView::Adjust);
40
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
43
//-----------------------------------------------------------------------------
45
void ToolBarList::addToolBarAction(QAction* action)
49
m_toolbar->addAction(action);
55
//-----------------------------------------------------------------------------
57
void ToolBarList::updateGeometries()
59
// Resize viewport margins
60
QSize hint = m_toolbar->isHidden() ? QSize(0,0) : m_toolbar->sizeHint();
61
setViewportMargins(0, 0, 0, hint.height());
64
QRect rect = viewport()->geometry();
65
QRect geometry(rect.left(), rect.top() + rect.height(), rect.width(), hint.height());
66
m_toolbar->setGeometry(geometry);
68
QListWidget::updateGeometries();
71
//-----------------------------------------------------------------------------