|
|
|
|
@@ -32,15 +32,16 @@ CSelectIconDlg::CSelectIconDlg(Database* database,int CurrentID,QWidget* parent,
|
|
|
|
|
setupUi(this);
|
|
|
|
|
db=database;
|
|
|
|
|
CtxMenu=new QMenu(this);
|
|
|
|
|
ReplaceAction=CtxMenu->addAction(*Icon_Swap,tr("Replace..."));
|
|
|
|
|
DeleteAction=CtxMenu->addAction(*Icon_EditDelete,tr("Delete"));
|
|
|
|
|
connect(Button_AddIcon, SIGNAL(clicked()), this, SLOT(OnAddIcon()));
|
|
|
|
|
connect(Button_PickIcon, SIGNAL(clicked()), this, SLOT(OnPickIcon()));
|
|
|
|
|
connect(Button_Cancel, SIGNAL(clicked()), this, SLOT(OnCancel()));
|
|
|
|
|
connect(DeleteAction,SIGNAL(triggered()),this,SLOT(OnDelete()));
|
|
|
|
|
connect(ReplaceAction,SIGNAL(triggered()),this,SLOT(OnReplace()));
|
|
|
|
|
connect(List,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(OnSelectionChanged(QListWidgetItem*,QListWidgetItem*)));
|
|
|
|
|
updateView();
|
|
|
|
|
List->setCurrentItem(List->item(CurrentID));
|
|
|
|
|
ModFlag=false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSelectIconDlg::updateView(){
|
|
|
|
|
@@ -60,7 +61,7 @@ for(int i=0; i<db->numIcons(); i++){
|
|
|
|
|
void CSelectIconDlg::OnAddIcon(){
|
|
|
|
|
QStringList filenames=QFileDialog::getOpenFileNames(this,tr("Add Icons..."),QDir::homePath(),tr("Images (%1)")
|
|
|
|
|
.arg("*.png *.jpeg *.jpg *.bmp *.gif *.bpm *.pgm *.ppm *.xbm *xpm"));
|
|
|
|
|
QStringList errors;
|
|
|
|
|
QString errors;
|
|
|
|
|
for(int i=0;i<filenames.size();i++){
|
|
|
|
|
QPixmap icon;
|
|
|
|
|
if(!icon.load(filenames[i])){
|
|
|
|
|
@@ -69,8 +70,7 @@ for(int i=0;i<filenames.size();i++){
|
|
|
|
|
db->addIcon(icon.scaled(16,16,Qt::KeepAspectRatio,Qt::SmoothTransformation));
|
|
|
|
|
}
|
|
|
|
|
if(errors.size())
|
|
|
|
|
QMessageBox::warning(this,tr("Error"),tr("An error occured while loading the icon(s):\n"));
|
|
|
|
|
ModFlag=true;
|
|
|
|
|
QMessageBox::warning(this,tr("Error"),tr("An error occured while loading the icon(s):\n%1").arg(errors));
|
|
|
|
|
updateView();
|
|
|
|
|
List->setCurrentItem(List->item(List->count()-1));
|
|
|
|
|
}
|
|
|
|
|
@@ -80,21 +80,35 @@ void CSelectIconDlg::contextMenuEvent(QContextMenuEvent *event){
|
|
|
|
|
QListWidgetItem* item=List->itemAt(List->mapFromParent(event->pos()));
|
|
|
|
|
|
|
|
|
|
if(!item)return;
|
|
|
|
|
if(item->data(32).toInt()<BUILTIN_ICONS)
|
|
|
|
|
if(item->data(32).toInt()<BUILTIN_ICONS){
|
|
|
|
|
DeleteAction->setDisabled(true);
|
|
|
|
|
else
|
|
|
|
|
ReplaceAction->setDisabled(true);}
|
|
|
|
|
else{
|
|
|
|
|
DeleteAction->setDisabled(false);
|
|
|
|
|
ReplaceAction->setDisabled(false);}
|
|
|
|
|
|
|
|
|
|
event->accept();
|
|
|
|
|
CtxMenu->popup(event->globalPos());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSelectIconDlg::OnDelete(){
|
|
|
|
|
ModFlag=true;
|
|
|
|
|
db->removeIcon(List->currentItem()->data(32).toInt());
|
|
|
|
|
updateView();
|
|
|
|
|
List->setCurrentItem(List->item(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSelectIconDlg::OnReplace(){
|
|
|
|
|
QString filename=QFileDialog::getOpenFileName(this,tr("Add Icons..."),QDir::homePath(),tr("Images (%1)")
|
|
|
|
|
.arg("*.png *.jpeg *.jpg *.bmp *.gif *.bpm *.pgm *.ppm *.xbm *xpm"));
|
|
|
|
|
if(filename==QString())return;
|
|
|
|
|
QPixmap icon;
|
|
|
|
|
if(!icon.load(filename)){
|
|
|
|
|
QMessageBox::warning(this,tr("Error"),tr("An error occured while loading the icon."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
db->replaceIcon(List->currentItem()->data(32).toInt(),icon.scaled(16,16,Qt::KeepAspectRatio,Qt::SmoothTransformation));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSelectIconDlg::OnPickIcon(){
|
|
|
|
|
done(List->currentItem()->data(32).toInt());
|
|
|
|
|
}
|
|
|
|
|
@@ -107,6 +121,4 @@ done(-1);
|
|
|
|
|
void CSelectIconDlg::OnSelectionChanged(QListWidgetItem* cur,QListWidgetItem* prev){
|
|
|
|
|
Button_PickIcon->setEnabled(cur);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|