@@ -111,9 +111,9 @@ Savestate2snesw::Savestate2snesw(QWidget *parent) :
111111 {
112112 sDebug () << " Attempting to load the last categoryloaded" << m_settings->value (" lastCategoryLoaded" ).toString ();
113113 QStandardItem* repRoot = repStateModel->invisibleRootItem ();
114- QStandardItem* catFound = NULL ;
114+ QStandardItem* catFound = nullptr ;
115115
116- if (repRoot != NULL )
116+ if (repRoot != nullptr )
117117 {
118118 if (repRoot->hasChildren ())
119119 {
@@ -129,9 +129,10 @@ Savestate2snesw::Savestate2snesw(QWidget *parent) :
129129 }
130130 }
131131 }
132- if (catFound != NULL )
132+ if (catFound != nullptr )
133133 {
134134 ui->categoryTreeView ->expand (repStateModel->indexFromItem (catFound));
135+ ui->categoryTreeView ->setCurrentIndex (catFound->index ());
135136 loadCategory (catFound);
136137 }
137138
@@ -261,6 +262,7 @@ void Savestate2snesw::createMenus()
261262 categoryMenu->addAction (ui->actionRemoveCategory );
262263 categoryMenu->addAction (ui->actionAddSubCategory );
263264 categoryMenu->addAction (ui->actionAddCategory );
265+ categoryMenu->addAction (ui->actionCategorySetIcon );
264266}
265267
266268
@@ -686,3 +688,18 @@ void Savestate2snesw::on_actionSave_a_savestate_triggered()
686688 if (ui->saveSaveStatePushButton ->isEnabled ())
687689 on_saveSaveStatePushButton_clicked ();
688690}
691+
692+ void Savestate2snesw::on_actionCategorySetIcon_triggered ()
693+ {
694+ const QString& catName = repStateModel->itemFromIndex (ui->categoryTreeView ->currentIndex ())->text ();
695+ const QString& catPath = repStateModel->itemFromIndex (ui->categoryTreeView ->currentIndex ())->data (MyRolePath).toString ();
696+ QString fileName = QFileDialog::getOpenFileName (this , QString (tr (" Select an icon for %1" )).arg (catName), QString (), tr (" Image Files (*.png *.jpg *.bmp)" ));
697+ if (fileName.isEmpty ())
698+ return ;
699+ QFileInfo fi (fileName);
700+ QString newName = catPath + " /icon." + fi.suffix ();
701+ sDebug () << " Setting icon for cat : " << newName;
702+ QFile::copy (fileName, newName);
703+ handleStuff->setCategoryIcon (catPath, newName);
704+ repStateModel->itemFromIndex (ui->categoryTreeView ->currentIndex ())->setIcon (QIcon (newName));
705+ }
0 commit comments