Set the size policy for the artist info widgets properly so they're not all squished together.
This commit is contained in:
parent
dcd18aacdc
commit
a85c292118
@ -159,6 +159,7 @@ set(SOURCES
|
|||||||
ui/systemtrayicon.cpp
|
ui/systemtrayicon.cpp
|
||||||
|
|
||||||
widgets/autoexpandingtreeview.cpp
|
widgets/autoexpandingtreeview.cpp
|
||||||
|
widgets/autosizedtextedit.cpp
|
||||||
widgets/busyindicator.cpp
|
widgets/busyindicator.cpp
|
||||||
widgets/elidedlabel.cpp
|
widgets/elidedlabel.cpp
|
||||||
widgets/equalizerslider.cpp
|
widgets/equalizerslider.cpp
|
||||||
@ -293,6 +294,7 @@ set(HEADERS
|
|||||||
ui/systemtrayicon.h
|
ui/systemtrayicon.h
|
||||||
|
|
||||||
widgets/autoexpandingtreeview.h
|
widgets/autoexpandingtreeview.h
|
||||||
|
widgets/autosizedtextedit.h
|
||||||
widgets/busyindicator.h
|
widgets/busyindicator.h
|
||||||
widgets/elidedlabel.h
|
widgets/elidedlabel.h
|
||||||
widgets/equalizerslider.h
|
widgets/equalizerslider.h
|
||||||
|
@ -42,8 +42,8 @@ ArtistInfoView::ArtistInfoView(QWidget *parent)
|
|||||||
// Add a container widget to the scroll area
|
// Add a container widget to the scroll area
|
||||||
QWidget* container_widget = new QWidget;
|
QWidget* container_widget = new QWidget;
|
||||||
container_widget->setLayout(container_);
|
container_widget->setLayout(container_);
|
||||||
container_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
container_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
|
||||||
container_->setSizeConstraint(QLayout::SetNoConstraint);
|
container_->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
||||||
scroll_area_->setWidget(container_widget);
|
scroll_area_->setWidget(container_widget);
|
||||||
scroll_area_->setWidgetResizable(true);
|
scroll_area_->setWidgetResizable(true);
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
const int CollapsibleInfoPane::kMargin = 6;
|
|
||||||
const int CollapsibleInfoPane::kTitleHeight = 20;
|
const int CollapsibleInfoPane::kTitleHeight = 20;
|
||||||
|
|
||||||
CollapsibleInfoPane::CollapsibleInfoPane(QWidget* parent)
|
CollapsibleInfoPane::CollapsibleInfoPane(QWidget* parent)
|
||||||
@ -29,7 +28,8 @@ CollapsibleInfoPane::CollapsibleInfoPane(QWidget* parent)
|
|||||||
expanded_(true)
|
expanded_(true)
|
||||||
{
|
{
|
||||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||||
layout->setContentsMargins(kMargin, kTitleHeight, kMargin, 0);
|
layout->setContentsMargins(0, kTitleHeight, 0, 0);
|
||||||
|
layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
|
||||||
|
@ -26,7 +26,6 @@ public:
|
|||||||
CollapsibleInfoPane(QWidget* parent = 0);
|
CollapsibleInfoPane(QWidget* parent = 0);
|
||||||
|
|
||||||
static const int kTitleHeight;
|
static const int kTitleHeight;
|
||||||
static const int kMargin;
|
|
||||||
|
|
||||||
void SetTitle(const QString& title);
|
void SetTitle(const QString& title);
|
||||||
void SetWidget(QWidget* widget);
|
void SetWidget(QWidget* widget);
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "echonestartistinfo.h"
|
#include "echonestartistinfo.h"
|
||||||
|
#include "widgets/autosizedtextedit.h"
|
||||||
#include <QTextEdit>
|
|
||||||
|
|
||||||
#include <echonest/Artist.h>
|
#include <echonest/Artist.h>
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ void EchoNestArtistInfo::BiographiesFinished() {
|
|||||||
RequestPtr request = ReplyFinished(qobject_cast<QNetworkReply*>(sender()));
|
RequestPtr request = ReplyFinished(qobject_cast<QNetworkReply*>(sender()));
|
||||||
|
|
||||||
foreach (const Echonest::Biography& bio, request->artist_->biographies()) {
|
foreach (const Echonest::Biography& bio, request->artist_->biographies()) {
|
||||||
QTextEdit* editor = new QTextEdit;
|
QTextEdit* editor = new AutoSizedTextEdit;
|
||||||
editor->setHtml(bio.text());
|
editor->setHtml(bio.text());
|
||||||
|
|
||||||
emit InfoReady(request->id_, tr("Biography from %1").arg(bio.site()), editor);
|
emit InfoReady(request->id_, tr("Biography from %1").arg(bio.site()), editor);
|
||||||
|
35
src/widgets/autosizedtextedit.cpp
Normal file
35
src/widgets/autosizedtextedit.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* This file is part of Clementine.
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "autosizedtextedit.h"
|
||||||
|
|
||||||
|
AutoSizedTextEdit::AutoSizedTextEdit(QWidget* parent)
|
||||||
|
: QTextEdit(parent)
|
||||||
|
{
|
||||||
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutoSizedTextEdit::resizeEvent(QResizeEvent* e) {
|
||||||
|
const int w = qMax(100, width());
|
||||||
|
|
||||||
|
document()->setTextWidth(w);
|
||||||
|
setMinimumHeight(document()->size().height());
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize AutoSizedTextEdit::sizeHint() const {
|
||||||
|
return minimumSize();
|
||||||
|
}
|
34
src/widgets/autosizedtextedit.h
Normal file
34
src/widgets/autosizedtextedit.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* This file is part of Clementine.
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AUTOSIZEDTEXTEDIT_H
|
||||||
|
#define AUTOSIZEDTEXTEDIT_H
|
||||||
|
|
||||||
|
#include <QTextEdit>
|
||||||
|
|
||||||
|
class AutoSizedTextEdit : public QTextEdit {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
AutoSizedTextEdit(QWidget* parent = 0);
|
||||||
|
|
||||||
|
QSize sizeHint() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent* e);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // AUTOSIZEDTEXTEDIT_H
|
Loading…
x
Reference in New Issue
Block a user