Mercurial > hg > svgui
changeset 423:5a55d0683ee5
* More twiddling with TransformFinder
author | Chris Cannam |
---|---|
date | Mon, 29 Sep 2008 11:11:42 +0000 |
parents | ea9e41027b93 |
children | 374b72f5b4bb |
files | widgets/TransformFinder.cpp widgets/TransformFinder.h |
diffstat | 2 files changed, 51 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/widgets/TransformFinder.cpp Fri Sep 26 16:34:31 2008 +0000 +++ b/widgets/TransformFinder.cpp Mon Sep 29 11:11:42 2008 +0000 @@ -25,16 +25,16 @@ #include <QDialogButtonBox> #include <QScrollArea> #include <QApplication> +#include <QDesktopWidget> -SelectableLabel::SelectableLabel(QWidget *parent) : - QLabel(parent), +SelectableLabel::SelectableLabel(QWidget *p) : + QLabel(p), m_selected(false) { - setStyleSheet("QLabel:hover { background: #e0e0e0; text: black; } QLabel:!hover { background: white; text: black } QLabel { padding: 4px }"); - setTextFormat(Qt::RichText); - setLineWidth(2); - setFixedWidth(420); +// setLineWidth(2); +// setFixedWidth(480); + setupStyle(); } void @@ -58,20 +58,32 @@ } void +SelectableLabel::setupStyle() +{ + if (m_selected) { + setWordWrap(true); + setStyleSheet("QLabel:hover { background: #e0e0e0; color: black; } QLabel:!hover { background: #f0f0f0; color: black } QLabel { padding: 7px }"); + +// setFrameStyle(QFrame::Box | QFrame::Plain); + } else { + setWordWrap(false); + setStyleSheet("QLabel:hover { background: #e0e0e0; color: black; } QLabel:!hover { background: white; color: black } QLabel { padding: 7px }"); + +// setFrameStyle(QFrame::NoFrame); + } +} + +void SelectableLabel::setSelected(bool s) { if (m_selected == s) return; m_selected = s; if (m_selected) { setText(m_selectedText); - setWordWrap(true); -// setFrameStyle(QFrame::Box | QFrame::Plain); } else { setText(m_unselectedText); - setWordWrap(false); -// setFrameStyle(QFrame::NoFrame); } -// resize(sizeHint()); + setupStyle(); parentWidget()->resize(parentWidget()->sizeHint()); } @@ -84,7 +96,7 @@ void SelectableLabel::mousePressEvent(QMouseEvent *e) { - toggle(); + setSelected(true); emit selectionChanged(); } @@ -151,13 +163,27 @@ m_resultsScroll->setPalette(palette); // resultsFrame->setFrameStyle(QFrame::Sunken | QFrame::Box); m_resultsLayout = new QVBoxLayout; + m_resultsLayout->setSpacing(0); + m_resultsLayout->setContentsMargins(0, 0, 0, 0); m_resultsFrame->setLayout(m_resultsLayout); m_resultsScroll->setWidget(m_resultsFrame); m_resultsFrame->show(); } - resize(500, 400); //!!! - m_resultsFrame->resize(480, 380); + QDesktopWidget *desktop = QApplication::desktop(); + QRect available = desktop->availableGeometry(); + + int width = available.width() / 2; + int height = available.height() / 2; + if (height < 450) { + if (available.height() > 500) height = 450; + } + if (width < 600) { + if (available.width() > 650) width = 600; + } + + resize(width, height); + raise(); } TransformFinder::~TransformFinder() @@ -250,10 +276,19 @@ } m_labels[i]->setObjectName(desc.identifier); - m_selectedTransform = desc.identifier; + m_labels[i]->setFixedWidth(this->width() - 40); m_labels[i]->setUnselectedText(labelText); m_labels[i]->setSelectedText(selectedText); + + /* + m_labels[i]->setSelected(false); + m_selectedTransform = ""; + */ + m_labels[i]->setSelected(i == 0); + if (i == 0) { + m_selectedTransform = desc.identifier; + } /* QSize sh = m_labels[i]->sizeHint();
--- a/widgets/TransformFinder.h Fri Sep 26 16:34:31 2008 +0000 +++ b/widgets/TransformFinder.h Mon Sep 29 11:11:42 2008 +0000 @@ -55,6 +55,7 @@ virtual void mouseDoubleClickEvent(QMouseEvent *e); virtual void enterEvent(QEvent *); virtual void leaveEvent(QEvent *); + void setupStyle(); QString m_selectedText; QString m_unselectedText; bool m_selected;