diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2022-04-30 21:12:44 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2022-05-26 18:41:21 +0200 |
commit | 0dea7c3dad15f397600458ae9a81af29e95752fa (patch) | |
tree | b6b17f93f907e139274b967c02ac356b56422b20 /src/mainwindow.cc | |
parent | 0ae26aded59f09b969592c2e600dba176954c619 (diff) |
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.
Diffstat (limited to 'src/mainwindow.cc')
-rw-r--r-- | src/mainwindow.cc | 34 |
1 files changed, 33 insertions, 1 deletions
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); } } |