using signal slot to update the combobox entries
This commit is contained in:
parent
3f2713bd16
commit
44732057b6
|
@ -31,7 +31,6 @@ private:
|
|||
// functions
|
||||
private:
|
||||
void setupWidgets();
|
||||
void setupAssetLibrary();
|
||||
void updateAssetTree(QString);
|
||||
void openFileDialog();
|
||||
void openFile(QString);
|
||||
|
@ -46,12 +45,13 @@ public slots:
|
|||
void printMessage(QString message, int severity);
|
||||
void setFileInfo(QString name, QVector<Material>* materials, int vertices, int triangle);
|
||||
|
||||
// private slots
|
||||
private slots:
|
||||
void setupAssetLibrary();
|
||||
void on_fileListWidget_doubleClicked(const QModelIndex &index);
|
||||
void on_dirDropDownList_currentTextChanged(const QString &arg1);
|
||||
|
||||
// signals
|
||||
signals:
|
||||
void loadFile(QString);
|
||||
|
||||
// private slots
|
||||
private slots:
|
||||
void on_fileListWidget_doubleClicked(const QModelIndex &index);
|
||||
void on_dirDropDownList_currentTextChanged(const QString &arg1);
|
||||
};
|
||||
|
|
|
@ -72,4 +72,8 @@ public:
|
|||
void setAutoColor(int value);
|
||||
|
||||
void updateDirectories(QString path);
|
||||
|
||||
// signals
|
||||
signals:
|
||||
void dirsChanged();
|
||||
};
|
||||
|
|
|
@ -58,6 +58,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
// setup dropdown
|
||||
setupAssetLibrary();
|
||||
connect(SettingsManager::getInstance(), &SettingsManager::dirsChanged, this, &MainWindow::setupAssetLibrary);
|
||||
|
||||
printMessage("MeshViewer by Anakin", 0);
|
||||
}
|
||||
|
||||
|
@ -167,18 +169,6 @@ void MainWindow::setupWidgets()
|
|||
m_output->raise();
|
||||
}
|
||||
|
||||
void MainWindow::setupAssetLibrary()
|
||||
{
|
||||
// get all directories and put them in the dropdown.
|
||||
QStringList tmp_list = SettingsManager::getInstance()->getListOfDirs();
|
||||
for (QString &it : tmp_list)
|
||||
ui->dirDropDownList->addItem(it, it);
|
||||
|
||||
// choose the current path and display it.
|
||||
if (ui->dirDropDownList->currentData().isValid())
|
||||
updateAssetTree(ui->dirDropDownList->currentData().toString());
|
||||
}
|
||||
|
||||
void MainWindow::updateAssetTree(QString path)
|
||||
{
|
||||
ui->fileListWidget->clear();
|
||||
|
@ -242,6 +232,21 @@ void MainWindow::resizeEvent(QResizeEvent * e)
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
// slots
|
||||
|
||||
void MainWindow::setupAssetLibrary()
|
||||
{
|
||||
// get all directories and put them in the dropdown.
|
||||
while (ui->dirDropDownList->count() != 0)
|
||||
ui->dirDropDownList->removeItem(0);
|
||||
|
||||
QStringList tmp_list = SettingsManager::getInstance()->getListOfDirs();
|
||||
for (QString &it : tmp_list)
|
||||
ui->dirDropDownList->addItem(it, it);
|
||||
|
||||
// choose the current path and display it.
|
||||
if (ui->dirDropDownList->currentData().isValid())
|
||||
updateAssetTree(ui->dirDropDownList->currentData().toString());
|
||||
}
|
||||
|
||||
void MainWindow::on_fileListWidget_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
int slotVal = index.row();
|
||||
|
|
|
@ -238,5 +238,6 @@ void SettingsManager::updateDirectories(QString path)
|
|||
m_listOfDirs.removeAll(path);
|
||||
else
|
||||
m_listOfDirs.append(path);
|
||||
}
|
||||
|
||||
emit dirsChanged();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue