Skip to content

Commit

Permalink
try new design for voice selector
Browse files Browse the repository at this point in the history
  • Loading branch information
lasconic committed May 16, 2013
1 parent 92852b7 commit b87ba96
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions mscore/voiceselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ VoiceButton::VoiceButton(int v, QWidget* parent)
{
voice = v;
setToolButtonStyle(Qt::ToolButtonIconOnly);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
setFixedWidth(preferences.iconWidth+6);
setFixedHeight(preferences.iconHeight+6);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setCheckable(true);
}

Expand All @@ -47,14 +49,16 @@ void VoiceButton::paintEvent(QPaintEvent* e)
QPainter p(this);
QColor c(MScore::selectColor[voice]);
QColor bg(palette().color(QPalette::Normal, QPalette::Window));
p.fillRect(e->rect(), isChecked() ? c.light(170) : bg);
p.fillRect(QRect(0, 2, width(), height()), isChecked() ? c.light(170) : bg);
qDebug() << e->rect();
p.setPen(QPen(preferences.globalStyle == 0 ? Qt::white : Qt::black));
if (isChecked())
p.setPen(QPen(Qt::black));
QFont f = font();
f.setPixelSize(height());
f.setPointSizeF(16.0);
p.setFont(f);
p.drawText(QRect(0, 1, width(), height()), Qt::AlignCenter, QString("%1").arg(voice+1));
qDebug() << width() << height();
}

//---------------------------------------------------------
Expand All @@ -64,14 +68,14 @@ void VoiceButton::paintEvent(QPaintEvent* e)
VoiceSelector::VoiceSelector(QWidget* parent)
: QFrame(parent)
{
setLineWidth(2);
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
QGridLayout* vwl = new QGridLayout;
setLineWidth(0);
setFrameStyle(QFrame::Box | QFrame::Plain);
QHBoxLayout* vwl = new QHBoxLayout;
vwl->setSpacing(0);
vwl->setContentsMargins(0, 0, 0, 0);

static const char* sl2[4] = { "voice-1", "voice-3", "voice-2", "voice-4" };
static const int v[4] = { 0, 2, 1, 3 };
static const char* sl2[4] = { "voice-1", "voice-2", "voice-3", "voice-4" };
static const int v[4] = { 0, 1, 2, 3 };

QActionGroup* vag = new QActionGroup(this);
vag->setExclusive(true);
Expand All @@ -81,7 +85,7 @@ VoiceSelector::VoiceSelector(QWidget* parent)
vag->addAction(a);
VoiceButton* tb = new VoiceButton(v[i]);
tb->setDefaultAction(a);
vwl->addWidget(tb, i/2, i%2, 1, 1);
vwl->addWidget(tb);
}
setLayout(vwl);
connect(vag, SIGNAL(triggered(QAction*)), this, SIGNAL(triggered(QAction*)));
Expand Down
2 changes: 1 addition & 1 deletion mscore/voiceselector.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class VoiceButton : public QToolButton {

public:
VoiceButton(int voice, QWidget* parent = 0);
virtual QSize sizeHint() const { return QSize(16,8); }
virtual QSize sizeHint() const { return QSize(24,24); }
};
}

Expand Down

0 comments on commit b87ba96

Please sign in to comment.