This fixes at least three issues: * Help window is not synched with window manager's `X`-button * Help window is not being closed on track destruction or on closing the plugin window * Trims help window strings and force-adds a newline, because `QLabel::sizeHint` sometimes computes too small values. Now, together with #6956, all help windows fit their strings. Some help windows are too large by one line, but this seems better than forcing the user to resize them if they are too small by one line.
This commit is contained in:
@@ -137,7 +137,8 @@ AutoLilvNode Lv2ViewProc::uri(const char *uriStr)
|
||||
|
||||
|
||||
|
||||
Lv2ViewBase::Lv2ViewBase(QWidget* meAsWidget, Lv2ControlBase *ctrlBase)
|
||||
Lv2ViewBase::Lv2ViewBase(QWidget* meAsWidget, Lv2ControlBase *ctrlBase) :
|
||||
m_helpWindowEventFilter(this)
|
||||
{
|
||||
auto grid = new QGridLayout(meAsWidget);
|
||||
|
||||
@@ -172,7 +173,7 @@ Lv2ViewBase::Lv2ViewBase(QWidget* meAsWidget, Lv2ControlBase *ctrlBase)
|
||||
LILV_FOREACH(nodes, itr, props.get())
|
||||
{
|
||||
const LilvNode* node = lilv_nodes_get(props.get(), itr);
|
||||
auto infoLabel = new QLabel(lilv_node_as_string(node));
|
||||
auto infoLabel = new QLabel(QString(lilv_node_as_string(node)).trimmed() + "\n");
|
||||
infoLabel->setWordWrap(true);
|
||||
infoLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
|
||||
@@ -181,8 +182,9 @@ Lv2ViewBase::Lv2ViewBase(QWidget* meAsWidget, Lv2ControlBase *ctrlBase)
|
||||
btnBox->addWidget(m_helpButton);
|
||||
|
||||
m_helpWindow = getGUI()->mainWindow()->addWindowedWidget(infoLabel);
|
||||
m_helpWindow->setSizePolicy(QSizePolicy::Minimum,
|
||||
m_helpWindow->setSizePolicy(QSizePolicy::Expanding,
|
||||
QSizePolicy::Expanding);
|
||||
m_helpWindow->installEventFilter(&m_helpWindowEventFilter);
|
||||
m_helpWindow->setAttribute(Qt::WA_DeleteOnClose, false);
|
||||
m_helpWindow->hide();
|
||||
|
||||
@@ -203,6 +205,7 @@ Lv2ViewBase::Lv2ViewBase(QWidget* meAsWidget, Lv2ControlBase *ctrlBase)
|
||||
|
||||
|
||||
Lv2ViewBase::~Lv2ViewBase() {
|
||||
closeHelpWindow();
|
||||
// TODO: hide UI if required
|
||||
}
|
||||
|
||||
@@ -228,6 +231,14 @@ void Lv2ViewBase::toggleHelp(bool visible)
|
||||
|
||||
|
||||
|
||||
void Lv2ViewBase::closeHelpWindow()
|
||||
{
|
||||
if (m_helpWindow) { m_helpWindow->close(); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Lv2ViewBase::modelChanged(Lv2ControlBase *ctrlBase)
|
||||
{
|
||||
// reconnect models
|
||||
@@ -248,6 +259,32 @@ AutoLilvNode Lv2ViewBase::uri(const char *uriStr)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Lv2ViewBase::onHelpWindowClosed()
|
||||
{
|
||||
m_helpButton->setChecked(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
HelpWindowEventFilter::HelpWindowEventFilter(Lv2ViewBase* viewBase) :
|
||||
m_viewBase(viewBase) {}
|
||||
|
||||
|
||||
|
||||
|
||||
bool HelpWindowEventFilter::eventFilter(QObject* , QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::Close) {
|
||||
m_viewBase->m_helpButton->setChecked(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace lmms::gui
|
||||
|
||||
#endif // LMMS_HAVE_LV2
|
||||
|
||||
Reference in New Issue
Block a user