MuseScore/mscore/scorePreview.cpp

84 lines
2.2 KiB
C++
Raw Normal View History

//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2014 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#include "scorePreview.h"
#include "libmscore/score.h"
2014-11-14 13:17:56 +01:00
#include "musescore.h"
#include "scoreInfo.h"
namespace Ms {
//---------------------------------------------------------
// ScorePreview
//---------------------------------------------------------
ScorePreview::ScorePreview(QWidget* parent)
: QWidget(parent)
{
messageNothingToShow = tr("Nothing selected");
setupUi(this);
icon->setText(messageNothingToShow);
}
//---------------------------------------------------------
// displayInfo
//---------------------------------------------------------
void ScorePreview::displayInfo(bool show)
{
info->setVisible(show);
}
//---------------------------------------------------------
// setScore
//---------------------------------------------------------
void ScorePreview::setScore(const QString& s)
{
2014-11-14 13:17:56 +01:00
ScoreInfo fi(s);
fi.setPixmap(mscore->extractThumbnail(s));
setScore(fi);
}
void ScorePreview::setScore(const ScoreInfo& si)
{
2014-11-21 12:52:07 +01:00
scoreInfo = si;
2014-11-19 15:25:03 +01:00
name->setText(si.completeBaseName());
2014-11-14 13:17:56 +01:00
creationDate->setText(si.created().toString());
fileSize->setText(QString("%1 KiB").arg(si.size() / 1024));
2014-11-19 15:25:03 +01:00
name->setEnabled(true);
creationDate->setEnabled(true);
fileSize->setEnabled(true);
2014-11-14 13:17:56 +01:00
icon->setPixmap(si.pixmap());
}
//---------------------------------------------------------
// unsetScore
//---------------------------------------------------------
void ScorePreview::unsetScore()
{
scoreInfo = ScoreInfo();
name->setText("");
creationDate->setText("");
fileSize->setText("");
name->setEnabled(false);
creationDate->setEnabled(true);
fileSize->setEnabled(true);
icon->setText(messageNothingToShow);
}
}