Commit 1862b0f6 authored by Michael Pyne's avatar Michael Pyne

hidpi: Port remaining icon uses to use QIcon for HiDPI support.

GUI: This fixes things like the warning icons in the file deletion
dialog, file renamer, menu icons (such as Create Playlist from Selected
Items), and the "Jump to Playing Track" button on the status bar.

The track position slider remains unfixed.
parent c31920fa
...@@ -70,13 +70,13 @@ void DeleteWidget::slotShouldDelete(bool shouldDelete) ...@@ -70,13 +70,13 @@ void DeleteWidget::slotShouldDelete(bool shouldDelete)
if(shouldDelete) { if(shouldDelete) {
m_ui->ddDeleteText->setText(i18n("<qt>These items will be <b>permanently " m_ui->ddDeleteText->setText(i18n("<qt>These items will be <b>permanently "
"deleted</b> from your hard disk.</qt>")); "deleted</b> from your hard disk.</qt>"));
m_ui->ddWarningIcon->setPixmap(KIconLoader::global()->loadIcon("dialog-warning", m_ui->ddWarningIcon->setPixmap(
KIconLoader::Desktop, KIconLoader::SizeLarge)); QIcon::fromTheme("dialog-warning").pixmap(KIconLoader::SizeLarge));
} }
else { else {
m_ui->ddDeleteText->setText(i18n("<qt>These items will be moved to the Trash Bin.</qt>")); m_ui->ddDeleteText->setText(i18n("<qt>These items will be moved to the Trash Bin.</qt>"));
m_ui->ddWarningIcon->setPixmap(KIconLoader::global()->loadIcon("user-trash-full", m_ui->ddWarningIcon->setPixmap(
KIconLoader::Desktop, KIconLoader::SizeLarge)); QIcon::fromTheme("user-trash-full").pixmap(KIconLoader::SizeLarge));
} }
} }
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
vboxLayout->addWidget(hbox); vboxLayout->addWidget(hbox);
QLabel *l = new QLabel(hbox); QLabel *l = new QLabel(hbox);
l->setPixmap(SmallIcon("dialog-warning", 32)); l->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(KIconLoader::SizeLarge));
hboxVLayout->addWidget(l); hboxVLayout->addWidget(l);
l = new QLabel(i18n("You are about to rename the following files. " l = new QLabel(i18n("You are about to rename the following files. "
...@@ -336,8 +336,8 @@ FileRenamerWidget::~FileRenamerWidget() ...@@ -336,8 +336,8 @@ FileRenamerWidget::~FileRenamerWidget()
int FileRenamerWidget::addRowCategory(TagType category) int FileRenamerWidget::addRowCategory(TagType category)
{ {
static QIcon up = SmallIcon("go-up"); static QIcon up = QIcon::fromTheme("go-up");
static QIcon down = SmallIcon("go-down"); static QIcon down = QIcon::fromTheme("go-down");
// Find number of categories already of this type. // Find number of categories already of this type.
int categoryCount = 0; int categoryCount = 0;
......
...@@ -1868,7 +1868,7 @@ void Playlist::slotShowRMBMenu(const QPoint &point) ...@@ -1868,7 +1868,7 @@ void Playlist::slotShowRMBMenu(const QPoint &point)
m_rmbMenu = new QMenu(this); m_rmbMenu = new QMenu(this);
m_rmbMenu->addAction(SmallIcon("go-jump-today"), m_rmbMenu->addAction(QIcon::fromTheme("go-jump-today"),
i18n("Add to Play Queue"), this, SLOT(slotAddToUpcoming())); i18n("Add to Play Queue"), this, SLOT(slotAddToUpcoming()));
m_rmbMenu->addSeparator(); m_rmbMenu->addSeparator();
...@@ -1897,7 +1897,9 @@ void Playlist::slotShowRMBMenu(const QPoint &point) ...@@ -1897,7 +1897,9 @@ void Playlist::slotShowRMBMenu(const QPoint &point)
m_rmbMenu->addSeparator(); m_rmbMenu->addSeparator();
m_rmbMenu->addAction( m_rmbMenu->addAction(
SmallIcon("folder-new"), i18n("Create Playlist From Selected Items..."), this, SLOT(slotCreateGroup())); QIcon::fromTheme("folder-new"),
i18n("Create Playlist From Selected Items..."),
this, SLOT(slotCreateGroup()));
} }
// Ignore any columns added by subclasses. // Ignore any columns added by subclasses.
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "playlistbox.h" #include "playlistbox.h"
#include <kiconloader.h>
#include <kmessagebox.h> #include <kmessagebox.h>
#include <kactioncollection.h> #include <kactioncollection.h>
#include <ktoggleaction.h> #include <ktoggleaction.h>
...@@ -746,12 +745,7 @@ void PlaylistBox::Item::init() ...@@ -746,12 +745,7 @@ void PlaylistBox::Item::init()
list->setupItem(this); list->setupItem(this);
const auto iconLoader = KIconLoader::global(); setIcon(0, QIcon::fromTheme(m_iconName));
const KIconLoader::Group iconGroup =
list->viewModeIndex() == 0
? KIconLoader::Desktop
: KIconLoader::Toolbar;
setIcon(0, iconLoader->loadIcon(m_iconName, iconGroup));
list->addNameToDict(m_text); list->addNameToDict(m_text);
if(m_playlist) { if(m_playlist) {
......
...@@ -938,7 +938,7 @@ PlaylistCollection::ActionHandler::ActionHandler(PlaylistCollection *collection) ...@@ -938,7 +938,7 @@ PlaylistCollection::ActionHandler::ActionHandler(PlaylistCollection *collection)
menu = new KActionMenu(i18n("&Guess Tag Information"), actions()); menu = new KActionMenu(i18n("&Guess Tag Information"), actions());
actions()->addAction("guessTag", menu); actions()->addAction("guessTag", menu);
/* menu->setIcon(SmallIcon("wizard")); */ menu->setIcon(QIcon::fromTheme("wizard"));
menu->addAction(createAction(i18n("From &File Name"), SLOT(slotGuessTagFromFile()), menu->addAction(createAction(i18n("From &File Name"), SLOT(slotGuessTagFromFile()),
"guessTagFile", "document-import", QKeySequence(Qt::CTRL + Qt::Key_G))); "guessTagFile", "document-import", QKeySequence(Qt::CTRL + Qt::Key_G)));
...@@ -971,7 +971,7 @@ PlaylistCollection::ActionHandler::ActionHandler(PlaylistCollection *collection) ...@@ -971,7 +971,7 @@ PlaylistCollection::ActionHandler::ActionHandler(PlaylistCollection *collection)
menu = new KActionMenu(i18n("Cover Manager"), actions()); menu = new KActionMenu(i18n("Cover Manager"), actions());
actions()->addAction("coverManager", menu); actions()->addAction("coverManager", menu);
/* menu->setIcon(SmallIcon("image-x-generic")); */ menu->setIcon(QIcon::fromTheme("image-x-generic"));
menu->addAction(createAction(i18n("&View Cover"), menu->addAction(createAction(i18n("&View Cover"),
SLOT(slotViewCovers()), "viewCover", "document-preview")); SLOT(slotViewCovers()), "viewCover", "document-preview"));
menu->addAction(createAction(i18n("Get Cover From &File..."), menu->addAction(createAction(i18n("Get Cover From &File..."),
......
...@@ -99,33 +99,6 @@ FileHandle PlaylistItem::file() const ...@@ -99,33 +99,6 @@ FileHandle PlaylistItem::file() const
return d->fileHandle; return d->fileHandle;
} }
Q_GLOBAL_STATIC_WITH_ARGS(QPixmap, globalGenericImage, (SmallIcon("image-x-generic")))
Q_GLOBAL_STATIC_WITH_ARGS(QPixmap, globalPlayingImage, (UserIcon("playing")))
const QPixmap *PlaylistItem::pixmap(int column) const
{
int offset = playlist()->columnOffset();
// Don't use hasCover here because that may dig into the track itself.
// Besides, we really just want to know if the cover manager has a cover
// for the track.
if((column - offset) == CoverColumn &&
d->fileHandle.coverInfo()->coverId() != CoverManager::NoMatch)
{
return globalGenericImage;
}
if(column == playlist()->leftColumn() &&
m_playingItems.contains(const_cast<PlaylistItem *>(this)))
{
return globalPlayingImage;
}
//return QTreeWidgetItem::pixmap(column);
return nullptr;
}
QString PlaylistItem::text(int column) const QString PlaylistItem::text(int column) const
{ {
if(!d->fileHandle.tag()) if(!d->fileHandle.tag())
......
...@@ -96,7 +96,6 @@ public: ...@@ -96,7 +96,6 @@ public:
void setFile(const QString &file); void setFile(const QString &file);
FileHandle file() const; FileHandle file() const;
virtual const QPixmap *pixmap(int column) const;
virtual QString text(int column) const; virtual QString text(int column) const;
virtual void setText(int column, const QString &text); virtual void setText(int column, const QString &text);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <QAction> #include <QAction>
#include <QMouseEvent> #include <QMouseEvent>
#include <QLabel> #include <QLabel>
#include <QIcon>
#include <QFrame> #include <QFrame>
#include <QEvent> #include <QEvent>
#include <QPushButton> #include <QPushButton>
...@@ -79,7 +80,7 @@ StatusLabel::StatusLabel(const PlaylistInterface &currentPlaylist, QStatusBar *p ...@@ -79,7 +80,7 @@ StatusLabel::StatusLabel(const PlaylistInterface &currentPlaylist, QStatusBar *p
setItemCurrentTime(0); setItemCurrentTime(0);
QPushButton *jumpButton = new QPushButton(this); QPushButton *jumpButton = new QPushButton(this);
jumpButton->setIcon(SmallIcon("go-up")); jumpButton->setIcon(QIcon::fromTheme("go-jump"));
jumpButton->setFlat(true); jumpButton->setFlat(true);
jumpButton->setToolTip(i18n("Jump to the currently playing item")); jumpButton->setToolTip(i18n("Jump to the currently playing item"));
......
...@@ -156,8 +156,8 @@ SystemTray::SystemTray(PlayerManager *player, QWidget *parent) : ...@@ -156,8 +156,8 @@ SystemTray::SystemTray(PlayerManager *player, QWidget *parent) :
setCategory(ApplicationStatus); setCategory(ApplicationStatus);
setStatus(Active); // We were told to dock in systray by user, force us visible setStatus(Active); // We were told to dock in systray by user, force us visible
m_forwardPix = SmallIcon("media-skip-forward"); m_forwardPix = QIcon::fromTheme("media-skip-forward");
m_backPix = SmallIcon("media-skip-backward"); m_backPix = QIcon::fromTheme("media-skip-backward");
// Just create this here so that it show up in the DBus interface and the // Just create this here so that it show up in the DBus interface and the
// key bindings dialog. // key bindings dialog.
...@@ -491,16 +491,16 @@ void SystemTray::setToolTip(const QString &tip, const QPixmap &cover) ...@@ -491,16 +491,16 @@ void SystemTray::setToolTip(const QString &tip, const QPixmap &cover)
if(tip.isEmpty()) if(tip.isEmpty())
KStatusNotifierItem::setToolTip("juk", i18n("JuK"), QString()); KStatusNotifierItem::setToolTip("juk", i18n("JuK"), QString());
else { else {
QPixmap myCover; QIcon myCover;
if(cover.isNull()) { if(cover.isNull()) {
myCover = DesktopIcon("juk"); myCover = QIcon::fromTheme("juk");
} else { } else {
//Scale to proper icon size, otherwise KStatusNotifierItem will show an unknown icon //Scale to proper icon size, otherwise KStatusNotifierItem will show an unknown icon
int iconSize = KIconLoader::global()->currentSize(KIconLoader::Desktop); const int iconSize = KIconLoader::global()->currentSize(KIconLoader::Desktop);
myCover = cover.scaled(iconSize, iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); myCover = QIcon(cover.scaled(iconSize, iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
} }
KStatusNotifierItem::setToolTip(QIcon(myCover), i18n("JuK"), tip); KStatusNotifierItem::setToolTip(myCover, i18n("JuK"), tip);
} }
} }
......
...@@ -129,8 +129,8 @@ private slots: ...@@ -129,8 +129,8 @@ private slots:
void scrollEvent(int delta, Qt::Orientation orientation); void scrollEvent(int delta, Qt::Orientation orientation);
private: private:
QPixmap m_backPix; QIcon m_backPix;
QPixmap m_forwardPix; QIcon m_forwardPix;
QColor m_startColor, m_endColor; QColor m_startColor, m_endColor;
PassiveInfo *m_popup; PassiveInfo *m_popup;
......
...@@ -163,16 +163,16 @@ void ViewMode::setShown(bool shown) ...@@ -163,16 +163,16 @@ void ViewMode::setShown(bool shown)
{ {
m_visible = shown; m_visible = shown;
if(shown) { if(shown) {
updateIcons(32); updateIcons();
m_needsRefresh = true; m_needsRefresh = true;
} }
} }
void ViewMode::updateIcons(int size) void ViewMode::updateIcons()
{ {
for(QTreeWidgetItemIterator it(m_playlistBox); *it; ++it) { for(QTreeWidgetItemIterator it(m_playlistBox); *it; ++it) {
PlaylistBox::Item *i = static_cast<PlaylistBox::Item *>(*it); PlaylistBox::Item *i = static_cast<PlaylistBox::Item *>(*it);
i->setIcon(0, SmallIcon(i->iconName(), size)); i->setIcon(0, QIcon::fromTheme(i->iconName()));
} }
} }
...@@ -293,7 +293,7 @@ void CompactViewMode::setShown(bool shown) ...@@ -293,7 +293,7 @@ void CompactViewMode::setShown(bool shown)
setVisible(shown); setVisible(shown);
if(shown) { if(shown) {
updateIcons(16); updateIcons();
updateHeights(); updateHeights();
} }
} }
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef VIEWMODE_H #ifndef JUK_VIEWMODE_H
#define VIEWMODE_H #define JUK_VIEWMODE_H
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
...@@ -81,7 +81,7 @@ protected: ...@@ -81,7 +81,7 @@ protected:
PlaylistBox *playlistBox() const { return m_playlistBox; } PlaylistBox *playlistBox() const { return m_playlistBox; }
bool visible() const { return m_visible; } bool visible() const { return m_visible; }
void setVisible(bool v) { m_visible = v; } void setVisible(bool v) { m_visible = v; }
void updateIcons(int size); void updateIcons();
virtual void updateHeights(); virtual void updateHeights();
static void paintDropIndicator(QPainter *painter, int width, int height); static void paintDropIndicator(QPainter *painter, int width, int height);
......
...@@ -156,7 +156,8 @@ void WebImageFetcher::slotWebRequestFinished(KJob *job) ...@@ -156,7 +156,8 @@ void WebImageFetcher::slotWebRequestFinished(KJob *job)
//FIXME: We assume they have a sane sorting (smallest -> largest) //FIXME: We assume they have a sane sorting (smallest -> largest)
const QString imageUrl = n.lastChildElement("image").text(); const QString imageUrl = n.lastChildElement("image").text();
if (imageUrl.isEmpty()) { if (imageUrl.isEmpty()) {
KMessageBox::information(nullptr, i18n("No available cover for the album '%1'.", d->albumName), i18nc("@title:window", "Cover not Available")); KMessageBox::information(nullptr, i18n("No available cover for the album '%1'.", d->albumName),
i18nc("@title:window", "Cover not Available"));
statusBar->clearMessage(); statusBar->clearMessage();
return; return;
} }
...@@ -187,9 +188,10 @@ void WebImageFetcher::slotImageFetched(KJob* j) ...@@ -187,9 +188,10 @@ void WebImageFetcher::slotImageFetched(KJob* j)
auto dlgVLayout = new QVBoxLayout(d->dialog); auto dlgVLayout = new QVBoxLayout(d->dialog);
if(job->error()) { if(job->error()) {
qCCritical(JUK_LOG) << "Unable to grab image\n"; qCCritical(JUK_LOG) << "Unable to grab image" << job->errorText();
d->dialog->setWindowIcon(DesktopIcon("dialog-error"));
// TODO: What kind of error announcement is this?? KMessageBox::sorry(nullptr, i18n("Failed to download requested cover art: %1", job->errorString()),
i18nc("@title:window", "Could not download cover art"));
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment