Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+115
@@ -0,0 +1,115 @@
|
||||
#include "dev_permissions_dialog.h"
|
||||
#include "ui_dev_permissions_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
namespace DeveloperTools
|
||||
{
|
||||
|
||||
PermissionsDialog::PermissionsDialog()
|
||||
: LtsWidgets::LtsDialog()
|
||||
, m_ui(new Ui::PermissionsDialog())
|
||||
, m_session(nullptr)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->pushButton, &QPushButton::clicked,
|
||||
this, &PermissionsDialog::setThings);
|
||||
}
|
||||
|
||||
|
||||
PermissionsDialog::~PermissionsDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
bool PermissionsDialog::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
setThings();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void PermissionsDialog::setThings()
|
||||
{
|
||||
const QVector<LtsWidgets::PluginData> &missingRightActions = m_session->missingRightActions();
|
||||
|
||||
for (auto i = missingRightActions.constBegin(); i != missingRightActions.constEnd(); ++i)
|
||||
{
|
||||
QWidget *container = new QWidget();
|
||||
QHBoxLayout *l = new QHBoxLayout();
|
||||
container->setLayout(l);
|
||||
|
||||
const LtsWidgets::PluginData &pd = *i;
|
||||
QLabel *text = new QLabel(QStringLiteral("Menu: %1 - Text: %2 - Ident: %3").arg(pd.menuGroup, pd.menuText, pd.identifier));
|
||||
QPushButton *execute = new QPushButton(QStringLiteral("execute"));
|
||||
connect(execute, &QPushButton::clicked,
|
||||
this, [this, pd]()
|
||||
{
|
||||
if (pd.createWidgetFunc)
|
||||
{
|
||||
LtsDialog *w = pd.createWidgetFunc(this);
|
||||
|
||||
if (w)
|
||||
m_session->addWidget(w, pd.menuGroup, pd.identifier, pd.layoutArea, pd.closable);
|
||||
}
|
||||
|
||||
if (pd.directFunc)
|
||||
{
|
||||
pd.directFunc(pd);
|
||||
}
|
||||
});
|
||||
|
||||
QPushButton *allow = new QPushButton(QStringLiteral("allow"));
|
||||
|
||||
if (pd.createInstant == LtsWidgets::CreateInstantType::CreateInstantAndDiscardAction)
|
||||
{
|
||||
allow->setCursor(QCursor(Qt::WhatsThisCursor));
|
||||
allow->setToolTip(QStringLiteral("CreateInstantType == CreateInstantAndDiscardAction !"));
|
||||
allow->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
connect(allow, &QPushButton::clicked,
|
||||
this, [this, pd /* cpy */, container]()
|
||||
{
|
||||
LtsWidgets::PluginData _pd = pd; // copy
|
||||
_pd.operatorRight = 0; // temporary allow adding this nasty action
|
||||
m_session->addAction(_pd);
|
||||
container->deleteLater(); // allowed, now delete container
|
||||
|
||||
// remove action from missing right list (session)
|
||||
QVector<LtsWidgets::PluginData> &missingRightActions = m_session->missingRightActions();
|
||||
for (int i = 0; i < missingRightActions.count(); i++)
|
||||
{
|
||||
LtsWidgets::PluginData &__pd = missingRightActions[i];
|
||||
if (__pd.identifier == _pd.identifier &&
|
||||
__pd.menuGroup == _pd.menuGroup &&
|
||||
__pd.menuText == _pd.menuText)
|
||||
{
|
||||
missingRightActions.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
l->addWidget(text, 1);
|
||||
l->addWidget(execute);
|
||||
l->addWidget(allow);
|
||||
|
||||
m_ui->verticalLayout->addWidget(container);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace DeveloperTools
|
||||
Reference in new issue
Block a user