# HG changeset patch # User Chris Cannam # Date 1222686702 0 # Node ID 5a55d0683ee5708c4512edcd533d2b88b8be7b81 # Parent ea9e41027b93082f6c6381cf6b1444752c600daf * More twiddling with TransformFinder diff -r ea9e41027b93 -r 5a55d0683ee5 widgets/TransformFinder.cpp --- 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 #include #include +#include -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(); diff -r ea9e41027b93 -r 5a55d0683ee5 widgets/TransformFinder.h --- 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;