MuseScore/mscore/scorePreview.cpp
Peter Jonas c2ac2846dd New Score Wizard: Template page: implement as tree view
- Template list is QTreeWidget
- Show template preview
- Move searchbox to be above list
- Create mscore/widgets subdirectory to improve organisation
- New FilterableView class and SearchBox widget to search item views
- Pressing Up or Down key in searchbox controls the tree view
2019-01-06 01:53:21 +00:00

83 lines
2.2 KiB
C++

//=============================================================================
// 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"
#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)
{
ScoreInfo fi(s);
fi.setPixmap(mscore->extractThumbnail(s));
setScore(fi);
}
void ScorePreview::setScore(const ScoreInfo& si)
{
scoreInfo = si;
name->setText(si.completeBaseName());
creationDate->setText(si.created().toString());
fileSize->setText(QString("%1 KiB").arg(si.size() / 1024));
name->setEnabled(true);
creationDate->setEnabled(true);
fileSize->setEnabled(true);
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);
}
}