Commit a1a6a383 authored by Sylvain Thery's avatar Sylvain Thery Committed by Pierre Kraemer

smaller growing dialogList

parent de65e00f
......@@ -26,6 +26,8 @@ public:
virtual ~ListPopUp();
virtual void show();
QListWidget* list();
QListWidgetItem* addItem(const QString& str, Qt::CheckState checked = Qt::Unchecked);
......
......@@ -67,7 +67,7 @@ void ControlDock_CameraTab::selectedCameraChanged()
void ControlDock_CameraTab::cameraProjectionChanged(QAbstractButton* b)
{
if (!b_updatingUI)
if (!b_updatingUI && m_selectedCamera)
{
if(radio_orthographicProjection->isChecked())
m_selectedCamera->setProjectionType(qglviewer::Camera::ORTHOGRAPHIC);
......
......@@ -8,20 +8,15 @@ namespace CGoGN
namespace SCHNApps
{
ListPopUp::ListPopUp(const QString& name, QWidget* parent):
ListPopUp::ListPopUp(const QString& name, QWidget* parent) :
QDialog(parent)
{
setWindowTitle(name);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint);
m_layout = new QVBoxLayout(this);
setLayout(m_layout);
m_layout->setContentsMargins(1, 1, 1, 1);
m_list_items = new QListWidget();
QSizePolicy test;
test.setHorizontalPolicy(QSizePolicy::Preferred);
m_list_items->setSizePolicy(test);
m_list_items->setSelectionMode(QAbstractItemView::NoSelection);
m_layout->addWidget(m_list_items);
}
......@@ -32,7 +27,7 @@ ListPopUp::~ListPopUp()
QSize ListPopUp::sizeHint() const
{
return QSize(150,150);
return QSize(170,100);
}
QListWidget* ListPopUp::list()
......@@ -40,11 +35,33 @@ QListWidget* ListPopUp::list()
return m_list_items;
}
void ListPopUp::show()
{
int rows = m_list_items->model()->rowCount();
int rowSize = m_list_items->sizeHintForRow(0);
int height = rows * rowSize + 6;
if (height < 96)
height = 96;
m_list_items->setFixedHeight(height);
QDialog::show();
}
QListWidgetItem* ListPopUp::addItem(const QString& str, Qt::CheckState checked)
{
QListWidgetItem* item = new QListWidgetItem(str, m_list_items);
item->setCheckState(checked);
int rows = m_list_items->model()->rowCount();
int rowSize = m_list_items->sizeHintForRow(0);
int height = rows * rowSize;
if (height >= m_list_items->size().height())
m_list_items->setFixedHeight(height + 6);
//QFontMetrics fm(m_list_items->font());
//int maxTextWidth = fm.width(item->text());
//if (maxTextWidth < 140)
// maxTextWidth = 140;
//m_list_items->setFixedWidth(maxTextWidth + 40);
return item;
}
......@@ -72,6 +89,7 @@ bool ListPopUp::removeItem(const QString& str)
if(items.empty())
return false;
m_list_items->takeItem(m_list_items->row(items[0]));
return true;
}
......
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