Commit 6a35bbe0 authored by Michael Pyne's avatar Michael Pyne

Merge branch 'Applications/18.12'

parents 89ceeb08 1862b0f6
......@@ -54,18 +54,27 @@
struct CoverPopup : public QWidget
{
CoverPopup(const QPixmap &image, const QPoint &p) :
CoverPopup(QPixmap &image, const QPoint &p) :
QWidget(0, Qt::WindowFlags(Qt::WA_DeleteOnClose | Qt::X11BypassWindowManagerHint))
{
QHBoxLayout *layout = new QHBoxLayout(this);
QLabel *label = new QLabel(this);
layout->addWidget(label);
const auto pixRatio = this->devicePixelRatioF();
QSizeF imageSize(label->width(), label->height());
if (!qFuzzyCompare(pixRatio, 1.0)) {
imageSize /= pixRatio;
image.setDevicePixelRatio(pixRatio);
}
label->setFrameStyle(QFrame::Box | QFrame::Raised);
label->setLineWidth(1);
label->setPixmap(image);
setGeometry(p.x(), p.y(), label->width(), label->height());
setGeometry(QRect(p, imageSize.toSize()));
show();
}
virtual void leaveEvent(QEvent *) { close(); }
......
......@@ -70,13 +70,13 @@ void DeleteWidget::slotShouldDelete(bool shouldDelete)
if(shouldDelete) {
m_ui->ddDeleteText->setText(i18n("<qt>These items will be <b>permanently "
"deleted</b> from your hard disk.</qt>"));
m_ui->ddWarningIcon->setPixmap(KIconLoader::global()->loadIcon("dialog-warning",
KIconLoader::Desktop, KIconLoader::SizeLarge));
m_ui->ddWarningIcon->setPixmap(
QIcon::fromTheme("dialog-warning").pixmap(KIconLoader::SizeLarge));
}
else {
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",
KIconLoader::Desktop, KIconLoader::SizeLarge));
m_ui->ddWarningIcon->setPixmap(
QIcon::fromTheme("user-trash-full").pixmap(KIconLoader::SizeLarge));
}
}
......
......@@ -71,7 +71,7 @@ public:
vboxLayout->addWidget(hbox);
QLabel *l = new QLabel(hbox);
l->setPixmap(SmallIcon("dialog-warning", 32));
l->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(KIconLoader::SizeLarge));
hboxVLayout->addWidget(l);
l = new QLabel(i18n("You are about to rename the following files. "
......@@ -336,8 +336,8 @@ FileRenamerWidget::~FileRenamerWidget()
int FileRenamerWidget::addRowCategory(TagType category)
{
static QIcon up = SmallIcon("go-up");
static QIcon down = SmallIcon("go-down");
static QIcon up = QIcon::fromTheme("go-up");
static QIcon down = QIcon::fromTheme("go-down");
// Find number of categories already of this type.
int categoryCount = 0;
......
......@@ -49,11 +49,6 @@
#include "collectionlist.h"
#include "juk_debug.h"
// Anon namespace to hide symbol from outside this translation unit
namespace {
static int g_imageSize = 64;
};
////////////////////////////////////////////////////////////////////////////////
// NowPlaying
////////////////////////////////////////////////////////////////////////////////
......@@ -78,8 +73,8 @@ NowPlaying::NowPlaying(QWidget *parent, PlaylistCollection *collection) :
const QFont defaultLargeFont(QFontDatabase::systemFont(QFontDatabase::TitleFont));
const QFontMetrics fm(defaultLargeFont, this);
g_imageSize = qMax(g_imageSize, fm.lineSpacing());
setFixedHeight(g_imageSize + 2);
const int coverIconHeight = qMax(64, fm.lineSpacing());
setFixedHeight(coverIconHeight + 2);
layout->addWidget(new CoverItem(this), 0);
layout->addWidget(new TrackItem(this), 2);
......@@ -138,9 +133,19 @@ void CoverItem::update(const FileHandle &file)
if(!file.isNull() && file.coverInfo()->hasCover()) {
show();
setPixmap(
file.coverInfo()->pixmap(CoverInfo::Thumbnail)
.scaled(g_imageSize, g_imageSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
const auto pixRatio = this->devicePixelRatioF();
const QSizeF logicalSize = QSizeF(this->height(), this->height());
const QSizeF scaledSize = logicalSize * pixRatio;
QPixmap pix =
file.coverInfo()->pixmap(CoverInfo::FullSize)
.scaled(scaledSize.toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (!qFuzzyCompare(pixRatio, 1.0)) {
pix.setDevicePixelRatio(pixRatio);
}
setPixmap(pix);
}
else
hide();
......
......@@ -1868,7 +1868,7 @@ void Playlist::slotShowRMBMenu(const QPoint &point)
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()));
m_rmbMenu->addSeparator();
......@@ -1897,7 +1897,9 @@ void Playlist::slotShowRMBMenu(const QPoint &point)
m_rmbMenu->addSeparator();
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.
......
......@@ -16,7 +16,6 @@
#include "playlistbox.h"
#include <kiconloader.h>
#include <kmessagebox.h>
#include <kactioncollection.h>
#include <ktoggleaction.h>
......@@ -746,12 +745,7 @@ void PlaylistBox::Item::init()
list->setupItem(this);
const auto iconLoader = KIconLoader::global();
const KIconLoader::Group iconGroup =
list->viewModeIndex() == 0
? KIconLoader::Desktop
: KIconLoader::Toolbar;
setIcon(0, iconLoader->loadIcon(m_iconName, iconGroup));
setIcon(0, QIcon::fromTheme(m_iconName));
list->addNameToDict(m_text);
if(m_playlist) {
......
......@@ -938,7 +938,7 @@ PlaylistCollection::ActionHandler::ActionHandler(PlaylistCollection *collection)
menu = new KActionMenu(i18n("&Guess Tag Information"), actions());
actions()->addAction("guessTag", menu);
/* menu->setIcon(SmallIcon("wizard")); */
menu->setIcon(QIcon::fromTheme("wizard"));
menu->addAction(createAction(i18n("From &File Name"), SLOT(slotGuessTagFromFile()),
"guessTagFile", "document-import", QKeySequence(Qt::CTRL + Qt::Key_G)));
......@@ -971,7 +971,7 @@ PlaylistCollection::ActionHandler::ActionHandler(PlaylistCollection *collection)
menu = new KActionMenu(i18n("Cover Manager"), actions());
actions()->addAction("coverManager", menu);
/* menu->setIcon(SmallIcon("image-x-generic")); */
menu->setIcon(QIcon::fromTheme("image-x-generic"));
menu->addAction(createAction(i18n("&View Cover"),
SLOT(slotViewCovers()), "viewCover", "document-preview"));
menu->addAction(createAction(i18n("Get Cover From &File..."),
......
......@@ -99,33 +99,6 @@ FileHandle PlaylistItem::file() const
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
{
if(!d->fileHandle.tag())
......
......@@ -96,7 +96,6 @@ public:
void setFile(const QString &file);
FileHandle file() const;
virtual const QPixmap *pixmap(int column) const;
virtual QString text(int column) const;
virtual void setText(int column, const QString &text);
......
......@@ -24,6 +24,7 @@
#include <QAction>
#include <QMouseEvent>
#include <QLabel>
#include <QIcon>
#include <QFrame>
#include <QEvent>
#include <QPushButton>
......@@ -79,7 +80,7 @@ StatusLabel::StatusLabel(const PlaylistInterface &currentPlaylist, QStatusBar *p
setItemCurrentTime(0);
QPushButton *jumpButton = new QPushButton(this);
jumpButton->setIcon(SmallIcon("go-up"));
jumpButton->setIcon(QIcon::fromTheme("go-jump"));
jumpButton->setFlat(true);
jumpButton->setToolTip(i18n("Jump to the currently playing item"));
......
......@@ -156,8 +156,8 @@ SystemTray::SystemTray(PlayerManager *player, QWidget *parent) :
setCategory(ApplicationStatus);
setStatus(Active); // We were told to dock in systray by user, force us visible
m_forwardPix = SmallIcon("media-skip-forward");
m_backPix = SmallIcon("media-skip-backward");
m_forwardPix = QIcon::fromTheme("media-skip-forward");
m_backPix = QIcon::fromTheme("media-skip-backward");
// Just create this here so that it show up in the DBus interface and the
// key bindings dialog.
......@@ -491,16 +491,16 @@ void SystemTray::setToolTip(const QString &tip, const QPixmap &cover)
if(tip.isEmpty())
KStatusNotifierItem::setToolTip("juk", i18n("JuK"), QString());
else {
QPixmap myCover;
QIcon myCover;
if(cover.isNull()) {
myCover = DesktopIcon("juk");
myCover = QIcon::fromTheme("juk");
} else {
//Scale to proper icon size, otherwise KStatusNotifierItem will show an unknown icon
int iconSize = KIconLoader::global()->currentSize(KIconLoader::Desktop);
myCover = cover.scaled(iconSize, iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
const int iconSize = KIconLoader::global()->currentSize(KIconLoader::Desktop);
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:
void scrollEvent(int delta, Qt::Orientation orientation);
private:
QPixmap m_backPix;
QPixmap m_forwardPix;
QIcon m_backPix;
QIcon m_forwardPix;
QColor m_startColor, m_endColor;
PassiveInfo *m_popup;
......
......@@ -163,16 +163,16 @@ void ViewMode::setShown(bool shown)
{
m_visible = shown;
if(shown) {
updateIcons(32);
updateIcons();
m_needsRefresh = true;
}
}
void ViewMode::updateIcons(int size)
void ViewMode::updateIcons()
{
for(QTreeWidgetItemIterator it(m_playlistBox); *it; ++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)
setVisible(shown);
if(shown) {
updateIcons(16);
updateIcons();
updateHeights();
}
}
......
......@@ -15,8 +15,8 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VIEWMODE_H
#define VIEWMODE_H
#ifndef JUK_VIEWMODE_H
#define JUK_VIEWMODE_H
#include <QObject>
#include <QStringList>
......@@ -81,7 +81,7 @@ protected:
PlaylistBox *playlistBox() const { return m_playlistBox; }
bool visible() const { return m_visible; }
void setVisible(bool v) { m_visible = v; }
void updateIcons(int size);
void updateIcons();
virtual void updateHeights();
static void paintDropIndicator(QPainter *painter, int width, int height);
......
......@@ -156,7 +156,8 @@ void WebImageFetcher::slotWebRequestFinished(KJob *job)
//FIXME: We assume they have a sane sorting (smallest -> largest)
const QString imageUrl = n.lastChildElement("image").text();
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();
return;
}
......@@ -187,9 +188,10 @@ void WebImageFetcher::slotImageFetched(KJob* j)
auto dlgVLayout = new QVBoxLayout(d->dialog);
if(job->error()) {
qCCritical(JUK_LOG) << "Unable to grab image\n";
d->dialog->setWindowIcon(DesktopIcon("dialog-error"));
// TODO: What kind of error announcement is this??
qCCritical(JUK_LOG) << "Unable to grab image" << job->errorText();
KMessageBox::sorry(nullptr, i18n("Failed to download requested cover art: %1", job->errorString()),
i18nc("@title:window", "Could not download cover art"));
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