Skip to content

Commit

Permalink
add palette context menu to enable single palette mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Mar 31, 2015
1 parent 772c691 commit ed6ce92
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
21 changes: 19 additions & 2 deletions mscore/palettebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,19 @@ namespace Ms {
PaletteBox::PaletteBox(QWidget* parent)
: QDockWidget(tr("Palettes"), parent)
{
setContextMenuPolicy(Qt::ActionsContextMenu);
setObjectName("palette-box");
setAllowedAreas(Qt::DockWidgetAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea));

QAction* a = new QAction(this);
a->setText(tr("single Palette"));
a->setCheckable(true);
a->setChecked(preferences.singlePalette);
addAction(a);
connect(a, SIGNAL(toggled(bool)), SLOT(setSinglePalette(bool)));

QWidget* w = new QWidget(this);
w->setContextMenuPolicy(Qt::NoContextMenu);
QVBoxLayout* vl = new QVBoxLayout(w);
QHBoxLayout* hl = new QHBoxLayout;
hl->setContentsMargins(5,5,5,0);
Expand All @@ -40,7 +49,7 @@ PaletteBox::PaletteBox(QWidget* parent)
updateWorkspaces();
hl->addWidget(workspaceList);
QToolButton* nb = new QToolButton;

nb->setMinimumHeight(27);
nb->setText(tr("+"));
nb->setToolTip(tr("Add new workspace"));
Expand All @@ -58,7 +67,6 @@ PaletteBox::PaletteBox(QWidget* parent)
sa->setFrameShape(QFrame::NoFrame);
vl->addWidget(sa);
vl->addLayout(hl);
// setWidget(sa);

QWidget* paletteList = new QWidget;
sa->setWidget(paletteList);
Expand Down Expand Up @@ -348,5 +356,14 @@ QSize PaletteBoxScrollArea::sizeHint() const
return QSize(170 * guiScaling, 170 * guiScaling);
}

//---------------------------------------------------------
// setSinglePalette
//---------------------------------------------------------

void PaletteBox::setSinglePalette(bool val)
{
preferences.singlePalette = val;
preferences.dirty = true;
}
}

5 changes: 5 additions & 0 deletions mscore/palettebox.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class PaletteBox : public QDockWidget {
void displayMore(const QString& paletteName);
void workspaceSelected(int idx);
void newWorkspaceClicked();
void setSinglePalette(bool);

signals:
void changed();
Expand All @@ -54,6 +55,10 @@ class PaletteBox : public QDockWidget {
void updateWorkspaces();
};

//---------------------------------------------------------
// PaletteBoxScrollArea
//---------------------------------------------------------

class PaletteBoxScrollArea : public QScrollArea {
Q_OBJECT

Expand Down

0 comments on commit ed6ce92

Please sign in to comment.