From 0dea7c3dad15f397600458ae9a81af29e95752fa Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 30 Apr 2022 21:12:44 +0200 Subject: Make 'super' database, encapsulating both the krecipes one and the gourmet one. Add small vignettes to the recipe list images to indicate from which soucre each item is coming from. --- src/mainwindow.cc | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/mainwindow.cc') diff --git a/src/mainwindow.cc b/src/mainwindow.cc index cb68039..711370f 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -125,10 +125,42 @@ void MainWindow::readDatabase() image = QImage(QSize({64,64}), QImage::Format_RGBA8888); image.fill(0); } - listItem->setData(Qt::UserRole, item.id); + image = image.scaled({64,64}); + QString mark; + QColor mark_color; + switch(item.db) + { + case DatabaseSource::KRecipes: + mark_color = QColor(0,0,200); + mark = "K"; + break; + case DatabaseSource::Gourmet: + mark_color = QColor(100,100,25); + mark = "G"; + break; + case DatabaseSource::Qookie: + mark_color = QColor(200,0,0); + mark = "Q"; + break; + } + + QPainter painter(&image); + auto font = painter.font(); + font.setBold(true); + font.setPixelSize(12); + painter.setFont(font); + painter.setPen(Qt::transparent); + painter.setBrush(QColor(255, 255, 255, 180)); + painter.drawEllipse(QRect{-7,-6,20,20}); + painter.setPen(mark_color); + painter.drawText(0, 10, mark); + + QIcon icon; icon.addPixmap(QPixmap::fromImage(image)); listItem->setIcon(icon); + + listItem->setData(Qt::UserRole, (double)item.id); listWidget->addItem(listItem); } } -- cgit v1.2.3