Consistent way to get layout spacing
This commit is contained in:
committed by
craig.p.drummond
parent
bdd7b75664
commit
89d415ded2
@@ -218,11 +218,7 @@ void CacheTree::showEvent(QShowEvent *e)
|
||||
CacheSettings::CacheSettings(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
int spacing=style()->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Vertical);
|
||||
if (spacing<0) {
|
||||
spacing=4;
|
||||
}
|
||||
|
||||
int spacing=Utils::layoutSpacing(this);
|
||||
QGridLayout *layout=new QGridLayout(this);
|
||||
layout->setMargin(0);
|
||||
int row=0;
|
||||
|
||||
@@ -310,10 +310,7 @@ void CoverPreview::downloading(const QString &u)
|
||||
scrollArea->hide();
|
||||
pbar->show();
|
||||
pbar->setValue(0);
|
||||
int spacing=style()->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Vertical);
|
||||
if (spacing<0) {
|
||||
spacing=4;
|
||||
}
|
||||
int spacing=Utils::layoutSpacing(this);
|
||||
QApplication::processEvents();
|
||||
adjustSize();
|
||||
resize(qMin(200, loadingLabel->width()+32), loadingLabel->height()+pbar->height()+(3*spacing));
|
||||
|
||||
@@ -239,10 +239,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
// With ambiance (which has a drak toolbar) we need a gap between the toolbar and the earch fields. But, in the context view we dont
|
||||
// want a gap - as this looks odd with a background. To workaround this, the tabwidget and playqueue sides of the splitter have a
|
||||
// spacer added. The size of this needs to be controllable by the style - so we do this here...
|
||||
int spacing=style()->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Vertical);
|
||||
if (spacing<0) {
|
||||
spacing=4;
|
||||
}
|
||||
int spacing=Utils::layoutSpacing(this);
|
||||
if (tabWidgetSpacer->minimumSize().height()!=spacing) {
|
||||
tabWidgetSpacer->changeSize(spacing, spacing, QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
playQueueSpacer->changeSize(spacing, spacing, QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
@@ -933,10 +930,7 @@ void MainWindow::initSizes()
|
||||
MusicLibraryItemAlbum::setup();
|
||||
|
||||
// Calculate size for cover widget...
|
||||
int spacing=style()->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Vertical);
|
||||
if (spacing<0) {
|
||||
spacing=4;
|
||||
}
|
||||
int spacing=Utils::layoutSpacing(this);
|
||||
playPauseTrackButton->adjustSize();
|
||||
trackLabel->adjustSize();
|
||||
artistLabel->adjustSize();
|
||||
@@ -2289,10 +2283,7 @@ int MainWindow::calcMinHeight()
|
||||
|
||||
int MainWindow::calcCompactHeight()
|
||||
{
|
||||
int spacing=style()->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Vertical);
|
||||
if (spacing<0) {
|
||||
spacing=4;
|
||||
}
|
||||
int spacing=Utils::layoutSpacing(this);
|
||||
// For some reason height is always larger than it needs to be - so fix this to cover height +4
|
||||
return qMax(qMax(playPauseTrackButton->height(),
|
||||
trackLabel->height()+artistLabel->height()+spacing)+
|
||||
|
||||
@@ -30,8 +30,10 @@
|
||||
#include <QDir>
|
||||
#include <QSet>
|
||||
#include <QThread>
|
||||
#include <QCoreApplication>
|
||||
#include <QApplication>
|
||||
#include <QDateTime>
|
||||
#include <QWidget>
|
||||
#include <QStyle>
|
||||
#ifdef ENABLE_KDE_SUPPORT
|
||||
#include <KDE/KStandardDirs>
|
||||
#endif
|
||||
@@ -529,3 +531,12 @@ void Utils::touchFile(const QString &fileName)
|
||||
{
|
||||
::utime(QFile::encodeName(fileName).constData(), 0);
|
||||
}
|
||||
|
||||
extern int Utils::layoutSpacing(QWidget *w)
|
||||
{
|
||||
int spacing=(w ? w->style() : qApp->style())->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Vertical);
|
||||
if (spacing<0) {
|
||||
spacing=QApplication::fontMetrics().height()>20 ? 8 : 4;
|
||||
}
|
||||
return spacing;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#endif
|
||||
|
||||
class QString;
|
||||
class QWidget;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
@@ -69,6 +70,8 @@ namespace Utils
|
||||
extern QString cacheDir(const QString &sub=QString(), bool create=true);
|
||||
extern void clearOldCache(const QString &sub, int maxAge);
|
||||
extern void touchFile(const QString &fileName);
|
||||
|
||||
extern int layoutSpacing(QWidget *w);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "wizardpage.h"
|
||||
#include "icon.h"
|
||||
#include "utils.h"
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
|
||||
@@ -38,10 +39,7 @@ void WizardPage::setBackground(const Icon &i)
|
||||
|
||||
void WizardPage::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
int spacing=style()->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Vertical);
|
||||
if (spacing<0) {
|
||||
spacing=4;
|
||||
}
|
||||
int spacing=Utils::layoutSpacing(this);
|
||||
spacing*=2;
|
||||
|
||||
QWizardPage::paintEvent(e);
|
||||
|
||||
Reference in New Issue
Block a user