mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-24 06:37:52 -04:00
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:
@@ -37,7 +37,7 @@
|
||||
|
||||
class QPushButton;
|
||||
class QMdiSubWindow;
|
||||
|
||||
class QLabel;
|
||||
namespace lmms
|
||||
{
|
||||
|
||||
@@ -64,9 +64,25 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class HelpWindowEventFilter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
class Lv2ViewBase* const m_viewBase;
|
||||
protected:
|
||||
bool eventFilter(QObject* obj, QEvent* event) override;
|
||||
public:
|
||||
HelpWindowEventFilter(class Lv2ViewBase* viewBase);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//! Base class for view for one Lv2 plugin
|
||||
class LMMS_EXPORT Lv2ViewBase : public LinkedModelGroupsView
|
||||
{
|
||||
friend class HelpWindowEventFilter;
|
||||
protected:
|
||||
//! @param pluginWidget A child class which inherits QWidget
|
||||
Lv2ViewBase(class QWidget *pluginWidget, Lv2ControlBase *ctrlBase);
|
||||
@@ -79,6 +95,7 @@ protected:
|
||||
|
||||
void toggleUI();
|
||||
void toggleHelp(bool visible);
|
||||
void closeHelpWindow();
|
||||
|
||||
// to be called by child virtuals
|
||||
//! Reconnect models if model changed
|
||||
@@ -94,12 +111,14 @@ private:
|
||||
|
||||
static AutoLilvNode uri(const char *uriStr);
|
||||
LinkedModelGroupView* getGroupView() override { return m_procView; }
|
||||
void onHelpWindowClosed();
|
||||
|
||||
Lv2ViewProc* m_procView;
|
||||
|
||||
//! Numbers of controls per row; must be multiple of 2 for mono effects
|
||||
const int m_colNum = 6;
|
||||
QMdiSubWindow* m_helpWindow = nullptr;
|
||||
HelpWindowEventFilter m_helpWindowEventFilter;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -72,4 +72,13 @@ void Lv2FxControlDialog::modelChanged()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Lv2FxControlDialog::hideEvent(QHideEvent *event)
|
||||
{
|
||||
closeHelpWindow();
|
||||
QWidget::hideEvent(event);
|
||||
}
|
||||
|
||||
|
||||
} // namespace lmms::gui
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
private:
|
||||
Lv2FxControls *lv2Controls();
|
||||
void modelChanged() final;
|
||||
void hideEvent(QHideEvent *event) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -295,6 +295,15 @@ void Lv2InsView::dropEvent(QDropEvent *_de)
|
||||
|
||||
|
||||
|
||||
void Lv2InsView::hideEvent(QHideEvent *event)
|
||||
{
|
||||
closeHelpWindow();
|
||||
QWidget::hideEvent(event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Lv2InsView::modelChanged()
|
||||
{
|
||||
Lv2ViewBase::modelChanged(castModel<Lv2Instrument>());
|
||||
|
||||
@@ -124,6 +124,7 @@ public:
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent *_dee) override;
|
||||
void dropEvent(QDropEvent *_de) override;
|
||||
void hideEvent(QHideEvent* event) override;
|
||||
|
||||
private:
|
||||
void modelChanged() override;
|
||||
|
||||
@@ -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