mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-02 04:10:20 +02:00
Add some scaling to the Accounts widget
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2012 Teo Mrnjavac <teo@kde.org>
|
* Copyright 2012, 2013 Teo Mrnjavac <teo@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
AccountListWidget::AccountListWidget( AccountModelFactoryProxy* model, QWidget* parent )
|
AccountListWidget::AccountListWidget( AccountModelFactoryProxy* model, QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
|
, TomahawkUtils::DpiScaler( this )
|
||||||
, m_model( model )
|
, m_model( model )
|
||||||
{
|
{
|
||||||
QVBoxLayout* mainLayout = new QVBoxLayout( this );
|
QVBoxLayout* mainLayout = new QVBoxLayout( this );
|
||||||
@@ -38,7 +39,7 @@ AccountListWidget::AccountListWidget( AccountModelFactoryProxy* model, QWidget*
|
|||||||
m_layout = new QVBoxLayout;
|
m_layout = new QVBoxLayout;
|
||||||
TomahawkUtils::unmarginLayout( m_layout );
|
TomahawkUtils::unmarginLayout( m_layout );
|
||||||
mainLayout->addLayout( m_layout );
|
mainLayout->addLayout( m_layout );
|
||||||
mainLayout->setSpacing( 8 );
|
mainLayout->setSpacing( scaledY( 8 ) );
|
||||||
|
|
||||||
connect( m_model, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
|
connect( m_model, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
|
||||||
this, SLOT( updateEntries( QModelIndex, QModelIndex ) ) );
|
this, SLOT( updateEntries( QModelIndex, QModelIndex ) ) );
|
||||||
@@ -58,7 +59,7 @@ AccountListWidget::AccountListWidget( AccountModelFactoryProxy* model, QWidget*
|
|||||||
separatorLine->setStyleSheet( "QWidget { border-top: 1px solid " +
|
separatorLine->setStyleSheet( "QWidget { border-top: 1px solid " +
|
||||||
TomahawkStyle::BORDER_LINE.name() + "; }" ); //from ProxyStyle
|
TomahawkStyle::BORDER_LINE.name() + "; }" ); //from ProxyStyle
|
||||||
mainLayout->insertWidget( 0, separatorLine );
|
mainLayout->insertWidget( 0, separatorLine );
|
||||||
mainLayout->addSpacing( 6 );
|
mainLayout->addSpacing( scaledY( 6 ) );
|
||||||
|
|
||||||
QLabel *connectionsLabel = new QLabel( tr( "Connections" ).toUpper(), this );
|
QLabel *connectionsLabel = new QLabel( tr( "Connections" ).toUpper(), this );
|
||||||
QFont clFont = connectionsLabel->font();
|
QFont clFont = connectionsLabel->font();
|
||||||
@@ -75,7 +76,7 @@ AccountListWidget::AccountListWidget( AccountModelFactoryProxy* model, QWidget*
|
|||||||
|
|
||||||
QHBoxLayout *headerLayout = new QHBoxLayout();
|
QHBoxLayout *headerLayout = new QHBoxLayout();
|
||||||
headerLayout->addWidget( connectionsLabel );
|
headerLayout->addWidget( connectionsLabel );
|
||||||
headerLayout->addSpacing( 30 );
|
headerLayout->addSpacing( scaledX( 30 ) );
|
||||||
headerLayout->addWidget( m_toggleOnlineButton );
|
headerLayout->addWidget( m_toggleOnlineButton );
|
||||||
mainLayout->insertLayout( 0, headerLayout );
|
mainLayout->insertLayout( 0, headerLayout );
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#define ACCOUNTLISTWIDGET_H
|
#define ACCOUNTLISTWIDGET_H
|
||||||
|
|
||||||
#include "AccountModelFactoryProxy.h"
|
#include "AccountModelFactoryProxy.h"
|
||||||
|
#include "utils/DpiScaler.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
class AccountWidget;
|
class AccountWidget;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
|
||||||
class AccountListWidget : public QWidget
|
class AccountListWidget : public QWidget, private TomahawkUtils::DpiScaler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@@ -45,15 +45,16 @@
|
|||||||
|
|
||||||
AccountWidget::AccountWidget( QWidget* parent )
|
AccountWidget::AccountWidget( QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
|
, TomahawkUtils::DpiScaler( this )
|
||||||
{
|
{
|
||||||
QHBoxLayout *mainLayout = new QHBoxLayout( this );
|
QHBoxLayout *mainLayout = new QHBoxLayout( this );
|
||||||
TomahawkUtils::unmarginLayout( mainLayout );
|
TomahawkUtils::unmarginLayout( mainLayout );
|
||||||
setLayout( mainLayout );
|
setLayout( mainLayout );
|
||||||
setContentsMargins( 0, 8, 0, 8 );
|
setContentsMargins( 0, scaledY( 8 ), 0, scaledY( 8 ) );
|
||||||
|
|
||||||
m_imageLabel = new QLabel( this );
|
m_imageLabel = new QLabel( this );
|
||||||
mainLayout->addWidget( m_imageLabel );
|
mainLayout->addWidget( m_imageLabel );
|
||||||
mainLayout->setSpacing( 4 );
|
mainLayout->setSpacing( scaledX( 4 ) );
|
||||||
|
|
||||||
QGridLayout* vLayout = new QGridLayout( this );
|
QGridLayout* vLayout = new QGridLayout( this );
|
||||||
vLayout->setSpacing( 8 );
|
vLayout->setSpacing( 8 );
|
||||||
@@ -156,7 +157,7 @@ AccountWidget::update( const QPersistentModelIndex& idx, int accountIdx )
|
|||||||
if ( account )
|
if ( account )
|
||||||
{
|
{
|
||||||
const QPixmap& pixmap = account->icon();
|
const QPixmap& pixmap = account->icon();
|
||||||
QSize pixmapSize( 32, 32 );
|
QSize pixmapSize( scaled( 32, 32 ) );
|
||||||
m_imageLabel->setPixmap( pixmap.scaled( pixmapSize, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
|
m_imageLabel->setPixmap( pixmap.scaled( pixmapSize, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
|
||||||
m_imageLabel->setFixedSize( pixmapSize );
|
m_imageLabel->setFixedSize( pixmapSize );
|
||||||
|
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
#ifndef ACCOUNTWIDGET_H
|
#ifndef ACCOUNTWIDGET_H
|
||||||
#define ACCOUNTWIDGET_H
|
#define ACCOUNTWIDGET_H
|
||||||
|
|
||||||
|
#include "utils/DpiScaler.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPersistentModelIndex>
|
#include <QPersistentModelIndex>
|
||||||
|
|
||||||
@@ -31,7 +33,7 @@ class QLineEdit;
|
|||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
|
|
||||||
class AccountWidget : public QWidget
|
class AccountWidget : public QWidget, private TomahawkUtils::DpiScaler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
AccountsToolButton::AccountsToolButton( QWidget* parent )
|
AccountsToolButton::AccountsToolButton( QWidget* parent )
|
||||||
: QToolButton( parent )
|
: QToolButton( parent )
|
||||||
|
, TomahawkUtils::DpiScaler( this )
|
||||||
{
|
{
|
||||||
m_popup = new AccountsPopupWidget( this );
|
m_popup = new AccountsPopupWidget( this );
|
||||||
m_popup->hide();
|
m_popup->hide();
|
||||||
@@ -42,7 +43,7 @@ AccountsToolButton::AccountsToolButton( QWidget* parent )
|
|||||||
if ( toolbar )
|
if ( toolbar )
|
||||||
setIconSize( toolbar->iconSize() );
|
setIconSize( toolbar->iconSize() );
|
||||||
else
|
else
|
||||||
setIconSize( QSize( 22, 22 ) );
|
setIconSize( scaled( 22, 22 ) );
|
||||||
|
|
||||||
//Set up popup...
|
//Set up popup...
|
||||||
QWidget *w = new QWidget( this );
|
QWidget *w = new QWidget( this );
|
||||||
@@ -52,7 +53,7 @@ AccountsToolButton::AccountsToolButton( QWidget* parent )
|
|||||||
|
|
||||||
TomahawkUtils::unmarginLayout( w->layout() );
|
TomahawkUtils::unmarginLayout( w->layout() );
|
||||||
|
|
||||||
w->setContentsMargins( 6, 6, 6, 6 );
|
w->setContentsMargins( scaled( 6, 6, 6, 6 ) );
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
w->setContentsMargins( 6, 6, 6, 0 );
|
w->setContentsMargins( 6, 6, 6, 0 );
|
||||||
wMainLayout->setMargin( 12 );
|
wMainLayout->setMargin( 12 );
|
||||||
@@ -82,7 +83,7 @@ AccountsToolButton::AccountsToolButton( QWidget* parent )
|
|||||||
TomahawkStyle::BORDER_LINE.name() + "; }" ); //from ProxyStyle
|
TomahawkStyle::BORDER_LINE.name() + "; }" ); //from ProxyStyle
|
||||||
wMainLayout->addWidget( separatorLine );
|
wMainLayout->addWidget( separatorLine );
|
||||||
|
|
||||||
wMainLayout->addSpacing( 6 );
|
wMainLayout->addSpacing( scaledY( 6 ) );
|
||||||
|
|
||||||
QPushButton *settingsButton = new QPushButton( w );
|
QPushButton *settingsButton = new QPushButton( w );
|
||||||
settingsButton->setIcon( TomahawkUtils::defaultPixmap( TomahawkUtils::AccountSettings ) );
|
settingsButton->setIcon( TomahawkUtils::defaultPixmap( TomahawkUtils::AccountSettings ) );
|
||||||
|
@@ -23,10 +23,11 @@
|
|||||||
|
|
||||||
#include "accounts/AccountModel.h"
|
#include "accounts/AccountModel.h"
|
||||||
#include "AccountModelFactoryProxy.h"
|
#include "AccountModelFactoryProxy.h"
|
||||||
|
#include "utils/DpiScaler.h"
|
||||||
|
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
class AccountsToolButton : public QToolButton
|
class AccountsToolButton : public QToolButton, private TomahawkUtils::DpiScaler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
Reference in New Issue
Block a user