Set wider toolbuttons via style
This commit is contained in:
committed by
craig.p.drummond
parent
7a4fd51bc9
commit
0639a4bff3
@@ -42,6 +42,7 @@
|
||||
#include "mpd/mpdparseutils.h"
|
||||
#include "settings.h"
|
||||
#include "support/utils.h"
|
||||
#include "support/touchproxystyle.h"
|
||||
#include "models/musiclibrarymodel.h"
|
||||
#include "models/musiclibraryitemartist.h"
|
||||
#include "models/musiclibraryitemalbum.h"
|
||||
@@ -481,8 +482,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
#endif
|
||||
stopTrackButton->setHideMenuIndicator(true);
|
||||
int playbackButtonSize=28==playbackIconSize ? 34 : controlButtonSize;
|
||||
int controlButtonWidth=Utils::touchFriendly() ? controlButtonSize*ToolButton::constTouchScaleFactor : controlButtonSize;
|
||||
int playbackButtonWidth=Utils::touchFriendly() ? playbackButtonSize*ToolButton::constTouchScaleFactor : playbackButtonSize;
|
||||
int controlButtonWidth=Utils::touchFriendly() ? controlButtonSize*TouchProxyStyle::constScaleFactor : controlButtonSize;
|
||||
int playbackButtonWidth=Utils::touchFriendly() ? playbackButtonSize*TouchProxyStyle::constScaleFactor : playbackButtonSize;
|
||||
foreach (QToolButton *b, controlBtns) {
|
||||
b->setAutoRaise(true);
|
||||
b->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QApplication>
|
||||
|
||||
double TouchProxyStyle::constScaleFactor=1.4;
|
||||
|
||||
static void drawSpinButton(QPainter *painter, const QRect &r, const QColor &col, bool isPlus)
|
||||
{
|
||||
int length=r.height()*0.5;
|
||||
@@ -196,6 +198,8 @@ QSize TouchProxyStyle::sizeFromContents(ContentsType type, const QStyleOption *o
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (CT_ToolButton==type && Utils::touchFriendly()) {
|
||||
sz.setWidth(sz.width()*constScaleFactor);
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
class TouchProxyStyle : public ProxyStyle
|
||||
{
|
||||
public:
|
||||
static double constScaleFactor;
|
||||
|
||||
TouchProxyStyle(bool touchSpin=true);
|
||||
~TouchProxyStyle();
|
||||
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "toolbutton.h"
|
||||
#include "support/icon.h"
|
||||
#include "support/gtkstyle.h"
|
||||
#include "support/touchproxystyle.h"
|
||||
#include "config.h"
|
||||
#include "support/utils.h"
|
||||
#include <QMenu>
|
||||
@@ -33,8 +34,6 @@
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
||||
const double ToolButton::constTouchScaleFactor=1.334;
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
static QPainterPath buildPath(const QRectF &r, double radius)
|
||||
{
|
||||
@@ -124,8 +123,8 @@ QSize ToolButton::sizeHint() const
|
||||
} else {
|
||||
plainSize = menuSize = QToolButton::sizeHint();
|
||||
}
|
||||
int sz=qMax(plainSize.width(), plainSize.height());
|
||||
sh=QSize(Utils::touchFriendly() ? sz*constTouchScaleFactor : (hideMenuIndicator ? sz : menuSize.width()), sz);
|
||||
int sz=qMax(Utils::touchFriendly() ? (int)(plainSize.width()/TouchProxyStyle::constScaleFactor) : plainSize.width(), plainSize.height());
|
||||
sh=QSize(Utils::touchFriendly() ? sz*TouchProxyStyle::constScaleFactor : (hideMenuIndicator ? sz : menuSize.width()), sz);
|
||||
return sh;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ class QMenu;
|
||||
class ToolButton : public QToolButton
|
||||
{
|
||||
public:
|
||||
static const double constTouchScaleFactor;
|
||||
explicit ToolButton(QWidget *parent = 0);
|
||||
QSize sizeHint() const;
|
||||
void setMenu(QMenu *m);
|
||||
|
||||
Reference in New Issue
Block a user