Fix button being present in other pages
This commit is contained in:
parent
8b790a6dd9
commit
efc44c56a6
@ -143,6 +143,11 @@ ModFolderPage::ModFolderPage(
|
||||
ui(new Ui::ModFolderPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
if(id == "mods") {
|
||||
auto act = new QAction(tr("Install Mods"), this);
|
||||
ui->actionsToolbar->insertActionBefore(ui->actionView_configs,act);
|
||||
connect(act, &QAction::triggered, this, &ModFolderPage::on_actionInstall_mods_triggered);
|
||||
}
|
||||
ui->actionsToolbar->insertSpacer(ui->actionView_configs);
|
||||
|
||||
m_inst = inst;
|
||||
|
@ -88,7 +88,6 @@
|
||||
<addaction name="actionRemove"/>
|
||||
<addaction name="actionEnable"/>
|
||||
<addaction name="actionDisable"/>
|
||||
<addaction name="actionInstall_mods"/>
|
||||
<addaction name="actionView_configs"/>
|
||||
<addaction name="actionView_Folder"/>
|
||||
</widget>
|
||||
@ -137,14 +136,6 @@
|
||||
<string>View &Folder</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInstall_mods">
|
||||
<property name="text">
|
||||
<string>Install mods</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Install mods from Modrinth or Curseforge</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -76,6 +76,20 @@ void WideBar::addSeparator()
|
||||
m_entries.push_back(entry);
|
||||
}
|
||||
|
||||
void WideBar::insertActionBefore(QAction* before, QAction* action){
|
||||
auto iter = std::find_if(m_entries.begin(), m_entries.end(), [before](BarEntry * entry) {
|
||||
return entry->wideAction == before;
|
||||
});
|
||||
if(iter == m_entries.end()) {
|
||||
return;
|
||||
}
|
||||
auto entry = new BarEntry();
|
||||
entry->qAction = insertWidget((*iter)->qAction, new ActionButton(action, this));
|
||||
entry->wideAction = action;
|
||||
entry->type = BarEntry::Action;
|
||||
m_entries.insert(iter, entry);
|
||||
}
|
||||
|
||||
void WideBar::insertSpacer(QAction* action)
|
||||
{
|
||||
auto iter = std::find_if(m_entries.begin(), m_entries.end(), [action](BarEntry * entry) {
|
||||
|
@ -18,6 +18,7 @@ public:
|
||||
void addAction(QAction *action);
|
||||
void addSeparator();
|
||||
void insertSpacer(QAction *action);
|
||||
void insertActionBefore(QAction *before, QAction *action);
|
||||
QMenu *createContextMenu(QWidget *parent = nullptr, const QString & title = QString());
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user