Commit f1ec9985 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Remember bin icon size and cleanup

parent 0c961b34
......@@ -203,6 +203,7 @@ Bin::Bin(QWidget* parent) :
, m_folderUp(NULL)
, m_doc(NULL)
, m_iconSize(160, 90)
, m_blankThumb()
, m_propertiesPanel(NULL)
{
QVBoxLayout *layout = new QVBoxLayout(this);
......@@ -260,8 +261,7 @@ Bin::Bin(QWidget* parent) :
m_slider->setMinimumWidth(40);
m_slider->setRange(0, 10);
// TODO: fix view zoom on startup
//m_slider->setValue(KdenliveSettings::bin_zoom());
m_slider->setValue(4);
m_slider->setValue(KdenliveSettings::bin_zoom());
connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(slotSetIconSize(int)));
QWidgetAction * widgetslider = new QWidgetAction(this);
widgetslider->setDefaultWidget(m_slider);
......@@ -509,7 +509,6 @@ void Bin::setDocument(KdenliveDoc* project)
m_doc = project;
int iconHeight = QFontInfo(font()).pixelSize() * 3.5;
m_iconSize = QSize(iconHeight * m_doc->dar(), iconHeight);
m_itemModel->setIconSize(m_iconSize);
m_jobManager = new JobManager(this, project->fps());
m_rootFolder = new ProjectFolder(this);
setEnabled(true);
......@@ -549,7 +548,7 @@ void Bin::createClip(QDomElement xml)
parentFolder = m_rootFolder;
}
}
ProjectClip *newItem = new ProjectClip(xml, parentFolder);
ProjectClip *newItem = new ProjectClip(xml, m_blankThumb, parentFolder);
}
void Bin::slotAddFolder()
......@@ -842,9 +841,11 @@ void Bin::slotInitView(QAction *action)
}
m_itemView->setMouseTracking(true);
m_itemView->viewport()->installEventFilter(m_eventEater);
QSize zoom = m_iconSize;
zoom = zoom * (m_slider->value() / 4.0);
QSize zoom = m_iconSize * (m_slider->value() / 4.0);
m_itemView->setIconSize(zoom);
QPixmap pix(zoom);
pix.fill(Qt::lightGray);
m_blankThumb.addPixmap(pix);
m_itemView->setModel(m_proxyModel);
m_itemView->setSelectionModel(m_proxyModel->selectionModel());
m_splitter->addWidget(m_itemView);
......@@ -888,6 +889,9 @@ void Bin::slotSetIconSize(int size)
QSize zoom = m_iconSize;
zoom = zoom * (size / 4.0);
m_itemView->setIconSize(zoom);
QPixmap pix(zoom);
pix.fill(Qt::lightGray);
m_blankThumb.addPixmap(pix);
}
......@@ -1944,3 +1948,4 @@ void Bin::deleteAllClipMarkers(const QString &id)
if (command->childCount() > 0) m_doc->commandStack()->push(command);
else delete command;
}
......@@ -118,7 +118,7 @@ public:
return QSize(hint.width(), qMin(option.fontMetrics.lineSpacing() + 4, hint.height()));
}
if (type == AbstractProjectItem::ClipItem) {
return QSize(hint.width(), qMax(option.fontMetrics.lineSpacing() * 2 + 4, hint.height()));
return QSize(hint.width(), qMax(option.fontMetrics.lineSpacing() * 2 + 4, qMax(hint.height(), option.decorationSize.height())));
}
if (type == AbstractProjectItem::SubClipItem) {
return QSize(hint.width(), qMin((int) (option.fontMetrics.lineSpacing() * 1.5) + 4, hint.height()));
......@@ -503,6 +503,7 @@ private:
QSlider *m_slider;
KSplitterCollapserButton *m_collapser;
Monitor *m_monitor;
QIcon m_blankThumb;
QMenu *m_menu;
QAction *m_openAction;
QAction *m_reloadAction;
......
......@@ -45,9 +45,7 @@ ProjectClip::ProjectClip(const QString &id, ClipController *controller, ProjectF
, m_audioThumbCreated(false)
{
m_clipStatus = StatusReady;
QPixmap pix(64, 36);
pix.fill(Qt::lightGray);
m_thumbnail = QIcon(pix);
m_thumbnail = bin()->defaultPixmap();
m_name = m_controller->clipName();
m_duration = m_controller->getStringDuration();
getFileHash();
......@@ -55,7 +53,7 @@ ProjectClip::ProjectClip(const QString &id, ClipController *controller, ProjectF
bin()->loadSubClips(id, m_controller->getSubClips());
}
ProjectClip::ProjectClip(const QDomElement& description, ProjectFolder* parent) :
ProjectClip::ProjectClip(const QDomElement& description, QIcon thumb, ProjectFolder* parent) :
AbstractProjectItem(AbstractProjectItem::ClipItem, description, parent)
, m_controller(NULL)
, audioFrameCache()
......@@ -63,9 +61,7 @@ ProjectClip::ProjectClip(const QDomElement& description, ProjectFolder* parent)
{
Q_ASSERT(description.hasAttribute("id"));
m_clipStatus = StatusWaiting;
QPixmap pix(64, 36);
pix.fill(Qt::lightGray);
m_thumbnail = QIcon(pix);
m_thumbnail = thumb;
QString resource = getXmlProperty(description, "resource");
QString clipName = getXmlProperty(description, "kdenlive:clipname");
if (!clipName.isEmpty()) {
......
......@@ -62,7 +62,7 @@ public:
* @brief Constructor.
* @param description element describing the clip; the "id" attribute and "resource" property are used
*/
ProjectClip(const QDomElement &description, ProjectFolder *parent);
ProjectClip(const QDomElement &description, QIcon thumb, ProjectFolder *parent);
virtual ~ProjectClip();
void reloadProducer(bool thumbnailOnly = false);
......
......@@ -39,7 +39,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
ProjectItemModel::ProjectItemModel(Bin *bin) :
QAbstractItemModel(bin)
, m_bin(bin)
, m_iconSize(160, 90)
{
connect(m_bin, SIGNAL(itemUpdated(AbstractProjectItem*)), this, SLOT(onItemUpdated(AbstractProjectItem*)));
}
......@@ -48,12 +47,6 @@ ProjectItemModel::~ProjectItemModel()
{
}
void ProjectItemModel::setIconSize(QSize s)
{
m_iconSize = s;
}
QVariant ProjectItemModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid()) {
......
......@@ -83,8 +83,6 @@ public slots:
private:
/** @brief Reference to the project bin */
Bin *m_bin;
/** @brief The default size for thumbnails */
QSize m_iconSize;
signals:
//TODO
......
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