add commond to menu
This commit is contained in:
parent
142a61f1d0
commit
50144adbc9
@ -37,16 +37,22 @@ SimuRunMenu::~SimuRunMenu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SimuRunMenu::OnWorkspaceChanged(WorkSpace* ws) {
|
void SimuRunMenu::OnWorkspaceChanged(WorkSpace* ws) {
|
||||||
Q_UNUSED(ws);
|
// Reconnect to workspace commands change to refresh buttons when path changes
|
||||||
|
if (wsCmdConn_) {
|
||||||
|
QObject::disconnect(wsCmdConn_);
|
||||||
|
}
|
||||||
|
if (ws) {
|
||||||
|
wsCmdConn_ = connect(ws, &WorkSpace::CommandsChanged, this, &SimuRunMenu::RefreshButtons);
|
||||||
|
}
|
||||||
RefreshButtons();
|
RefreshButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimuRunMenu::RefreshButtons() {
|
void SimuRunMenu::RefreshButtons() {
|
||||||
// Clear existing buttons
|
// Clear existing buttons
|
||||||
ClearAllBtn();
|
ClearAllBtn();
|
||||||
|
|
||||||
CreateMatlabParam();
|
CreateMatlabParam();
|
||||||
CreateLine();
|
CreateLine();
|
||||||
|
|
||||||
auto* ws = WorkSpaceManager::Get().GetCurrent();
|
auto* ws = WorkSpaceManager::Get().GetCurrent();
|
||||||
if (!ws)
|
if (!ws)
|
||||||
@ -122,21 +128,22 @@ void SimuRunMenu::CreateGroup(const QString& title,
|
|||||||
|
|
||||||
void SimuRunMenu::CreateMatlabParam()
|
void SimuRunMenu::CreateMatlabParam()
|
||||||
{
|
{
|
||||||
QHBoxLayout* layout = qobject_cast<QHBoxLayout*>(this->layout());
|
QHBoxLayout* layout = qobject_cast<QHBoxLayout*>(this->layout());
|
||||||
if (!layout)
|
if (!layout)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QToolButton *pBtn = new QToolButton();
|
QToolButton *pBtn = new QToolButton();
|
||||||
pBtn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
pBtn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||||
pBtn->setText(QString::fromLocal8Bit("参数设置"));
|
pBtn->setText(tr("setting param"));
|
||||||
pBtn->setIcon(QIcon(":/res/default/menu_setting_restore.png"));
|
pBtn->setIcon(QIcon(":/res/default/menu_setting_restore.png"));
|
||||||
pBtn->setToolTip(QString::fromLocal8Bit("设置Matlab的输入参数"));
|
pBtn->setToolTip(QString::fromLocal8Bit("set Matlab param"));
|
||||||
|
|
||||||
connect(pBtn, SIGNAL(clicked()), this, SLOT(slotHandleMatlabParam()));
|
connect(pBtn, SIGNAL(clicked()), this, SLOT(slotHandleMatlabParam()));
|
||||||
|
|
||||||
layout->addWidget(pBtn);
|
layout->addWidget(pBtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SimuRunMenu::CreateLine()
|
void SimuRunMenu::CreateLine()
|
||||||
{
|
{
|
||||||
QHBoxLayout* layout = qobject_cast<QHBoxLayout*>(this->layout());
|
QHBoxLayout* layout = qobject_cast<QHBoxLayout*>(this->layout());
|
||||||
@ -182,18 +189,18 @@ void SimuRunMenu::ClearAllBtn()
|
|||||||
|
|
||||||
void SimuRunMenu::slotHandleMatlabParam()
|
void SimuRunMenu::slotHandleMatlabParam()
|
||||||
{
|
{
|
||||||
if (WorkSpaceManager::Get().GetCurrent())
|
if (WorkSpaceManager::Get().GetCurrent())
|
||||||
{
|
{
|
||||||
if (!m_pParam)
|
if (!m_pParam)
|
||||||
{
|
{
|
||||||
m_pParam = new DockWidget(m_mainWindow);
|
m_pParam = new DockWidget(m_mainWindow);
|
||||||
m_pParam->setAllowedAreas(Qt::NoDockWidgetArea);
|
m_pParam->setAllowedAreas(Qt::NoDockWidgetArea);
|
||||||
|
|
||||||
DockTitleBar* titleBar = new DockTitleBar(m_pParam);
|
DockTitleBar* titleBar = new DockTitleBar(m_pParam);
|
||||||
titleBar->SetFloatVisible(false);
|
titleBar->SetFloatVisible(false);
|
||||||
titleBar->SetMaxVisible(false);
|
titleBar->SetMaxVisible(false);
|
||||||
m_pParam->SetDockWidgetTitleBar(titleBar);
|
m_pParam->SetDockWidgetTitleBar(titleBar);
|
||||||
m_pParam->setWindowTitle(QString::fromLocal8Bit("参数设置"));
|
m_pParam->setWindowTitle(tr("set param"));
|
||||||
|
|
||||||
QString strDir = WorkSpaceManager::Get().GetCurrent()->GetDir();
|
QString strDir = WorkSpaceManager::Get().GetCurrent()->GetDir();
|
||||||
AddParamSetting *pParam = new AddParamSetting(strDir);
|
AddParamSetting *pParam = new AddParamSetting(strDir);
|
||||||
@ -204,10 +211,10 @@ void SimuRunMenu::slotHandleMatlabParam()
|
|||||||
|
|
||||||
m_pParam->setFloating(true);
|
m_pParam->setFloating(true);
|
||||||
m_pParam->show();
|
m_pParam->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimuRunMenu::SetMainWindow(MainWindow* mainWindow)
|
void SimuRunMenu::SetMainWindow(MainWindow* mainWindow)
|
||||||
{
|
{
|
||||||
m_mainWindow = mainWindow;
|
m_mainWindow = mainWindow;
|
||||||
}
|
}
|
||||||
@ -32,6 +32,9 @@ private:
|
|||||||
|
|
||||||
void ClearAllBtn();
|
void ClearAllBtn();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMetaObject::Connection wsCmdConn_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DockWidget *m_pParam;
|
DockWidget *m_pParam;
|
||||||
MainWindow* m_mainWindow;
|
MainWindow* m_mainWindow;
|
||||||
|
|||||||
@ -53,6 +53,7 @@ void WorkSpace::SetCommondFilePath(const QString& path) {
|
|||||||
dirPath.toLocal8Bit().data(),
|
dirPath.toLocal8Bit().data(),
|
||||||
sucess);
|
sucess);
|
||||||
commondPath_ = fileInfo.fileName();
|
commondPath_ = fileInfo.fileName();
|
||||||
|
emit CommandsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated path APIs removed
|
// Deprecated path APIs removed
|
||||||
|
|||||||
@ -141,6 +141,7 @@ Q_SIGNALS:
|
|||||||
void TimestepChanged(class Timestep* timestep);
|
void TimestepChanged(class Timestep* timestep);
|
||||||
void LampStatusChanged(class LampStatus* lampStatus);
|
void LampStatusChanged(class LampStatus* lampStatus);
|
||||||
void FilesChanged(FileEntryType type, std::shared_ptr<FileEntry> fileEntry);
|
void FilesChanged(FileEntryType type, std::shared_ptr<FileEntry> fileEntry);
|
||||||
|
void CommandsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString name_;
|
QString name_;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user