Continues migration with DDS, Common
This commit is contained in:
1 parent
9b15cee841
commit
fa48db111e
668 files changed
+111841
-2
No files matched your search
Executable
+172
@@ -0,0 +1,172 @@
|
||||
|
||||
|
||||
|
||||
#include "lts_dialog_helper.h"
|
||||
#include "lts_dialog.h"
|
||||
#include "ui_lts_dialog_helper.h"
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <QScrollBar>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
class LDHScrollBar : public QScrollBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using QScrollBar::QScrollBar;
|
||||
|
||||
void showEvent(QShowEvent *e) override
|
||||
{
|
||||
QScrollBar::showEvent(e);
|
||||
emit scrollbarVisiblityChanged(true);
|
||||
}
|
||||
void hideEvent(QHideEvent *e) override
|
||||
{
|
||||
QScrollBar::hideEvent(e);
|
||||
emit scrollbarVisiblityChanged(false);
|
||||
}
|
||||
Q_SIGNALS:
|
||||
void scrollbarVisiblityChanged(bool visible);
|
||||
};
|
||||
|
||||
|
||||
LtsDialogHelper::LtsDialogHelper(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::LtsDialogHelper())
|
||||
, m_dialog(nullptr)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
auto hScroll = new LDHScrollBar(this);
|
||||
auto vScroll = new LDHScrollBar(this);
|
||||
m_ui->scrollArea->setHorizontalScrollBar(hScroll);
|
||||
m_ui->scrollArea->setVerticalScrollBar(vScroll);
|
||||
connect(hScroll, &LDHScrollBar::scrollbarVisiblityChanged,
|
||||
this, &LtsDialogHelper::onHScrollBarVisibilityChanged);
|
||||
connect(vScroll, &LDHScrollBar::scrollbarVisiblityChanged,
|
||||
this, &LtsDialogHelper::onVScrollBarVisibilityChanged);
|
||||
|
||||
#ifdef TABLET_MODE
|
||||
QList<QWidget *> scrollWidgets = findChildren<QWidget *>();
|
||||
|
||||
for (auto i = scrollWidgets.begin(); i != scrollWidgets.end(); ++i)
|
||||
{
|
||||
QWidget *widget = *i;
|
||||
|
||||
QVariant isConst = widget->property("const");
|
||||
if (isConst.isValid() && isConst.toBool())
|
||||
continue;
|
||||
|
||||
LtsWidgets::addTouchScroll(widget);
|
||||
}
|
||||
#endif
|
||||
m_ui->buttonBox->setMinimumHeight(m_ui->buttonBox->sizeHint().height());
|
||||
}
|
||||
|
||||
|
||||
LtsDialogHelper::~LtsDialogHelper()
|
||||
{
|
||||
m_ui->scrollArea->horizontalScrollBar()->disconnect(this);
|
||||
m_ui->scrollArea->verticalScrollBar()->disconnect(this);
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
LtsDialogButtonBox *LtsDialogHelper::getButtonBox()
|
||||
{
|
||||
return m_ui->buttonBox;
|
||||
}
|
||||
|
||||
|
||||
void LtsDialogHelper::setDialog(LtsDialog *dialog)
|
||||
{
|
||||
if (m_dialog != nullptr)
|
||||
return;
|
||||
|
||||
m_dialog = dialog;
|
||||
m_dialog->setContentsMargins(QMargins());
|
||||
if (m_dialog->layout())
|
||||
m_dialog->layout()->setContentsMargins(QMargins());
|
||||
m_ui->scrollArea->setWidget(m_dialog);
|
||||
|
||||
|
||||
{
|
||||
connect(dialog, &LtsDialog::destroyed, this, [this]()
|
||||
{
|
||||
m_dialog = nullptr;
|
||||
deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
LtsDialog *LtsDialogHelper::getDialog()
|
||||
{
|
||||
return m_dialog;
|
||||
}
|
||||
|
||||
void LtsDialogHelper::retranslate()
|
||||
{
|
||||
if (m_dialog == nullptr)
|
||||
return;
|
||||
|
||||
m_dialog->setContentsMargins(QMargins());
|
||||
if (m_dialog->layout())
|
||||
m_dialog->layout()->setContentsMargins(QMargins());
|
||||
|
||||
bool oldChangesFlag = m_dialog->m_changesMade;
|
||||
|
||||
|
||||
|
||||
m_dialog->retranslate();
|
||||
|
||||
if (oldChangesFlag)
|
||||
m_dialog->slotChangesMade();
|
||||
else
|
||||
m_dialog->resetChanges();
|
||||
}
|
||||
|
||||
|
||||
void LtsDialogHelper::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
emit signalSizeChanged(e->size());
|
||||
}
|
||||
|
||||
|
||||
void LtsDialogHelper::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
if (e->type() == QEvent::LanguageChange)
|
||||
retranslate();
|
||||
}
|
||||
|
||||
|
||||
void LtsDialogHelper::onHScrollBarVisibilityChanged(bool visible)
|
||||
{
|
||||
if (m_dialog == nullptr || !m_dialog->layout())
|
||||
return;
|
||||
|
||||
QMargins m = m_dialog->layout()->contentsMargins();
|
||||
m.setBottom(visible ? -1 : 0);
|
||||
m_dialog->layout()->setContentsMargins(m);
|
||||
}
|
||||
|
||||
|
||||
void LtsDialogHelper::onVScrollBarVisibilityChanged(bool visible)
|
||||
{
|
||||
if (m_dialog == nullptr || !m_dialog->layout())
|
||||
return;
|
||||
|
||||
QMargins m = m_dialog->layout()->contentsMargins();
|
||||
m.setRight(visible ? -1 : 0);
|
||||
m_dialog->layout()->setContentsMargins(m);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "lts_dialog_helper.moc"
|
||||
Reference in new issue
Block a user