MuseScore/mscore/palette.h
Joachim Schmitz b7b35643a1 Fix Deprecation warnings with Qt 5.15 (and 5.14)
* fix 383 warnings C4996 (deprecated) with one single line change
* fix 5 'empty' warnings about invalid slots, not sure the remaining
slots serve any purpose though
* disable warnings C4127 and C4996 for thirdparty/google_analytics
* fix 30 warnings C4996 using the suggested alternatives available since
at least Qt 5.9, so won't break building against that
* change as requested in code review plus some more fixes using the same
idea
* fixing yet more warnings
* disable deprecation warnings in qoogle_analytics for MinGW too
although I believe maxOS and Linux may use those too. Easy to extend to
those, if need be.
* Fix qml runtime warnings exactly following the advice given by that
warning, but without really know what I'm doing here or whether that is
still backwards compatible to Qt 5.9.
* Use replacements as suggested, if available and no `endl` neded with
`qDebug()`
* fix 24 more
* 2 more
* 7 more (one only seen in DEBUG mode)
* Fix the `endl` warnings
* maybe more changes this way?
* Add all warnings C5999 or bigger to the ignore list for telemetry
with Qt 5.15 Beta 1 as avoiding only C26439, C26444,C 26452, C26495,
C26498, C26812 isn't possible
* fix 2 deprecation warning new with Qt 5.15 beta 1
* fix 4 new warnings and also Qt 5.12 builds, disable some dead code
* fix deprecation warnings new with Qt 5.15's MSVC 2019 integration and
revert some (`QNetworkReply::networkError()`) that Qt 5.15 beta 2
reverted too
* fix warning reg. obsolete operator < for QVariants
* revert changes needed prior to beta 3 And clarifying some earlier
changes
* mark ToDos
* fix warning reg QString()::null
* fix a 'regression' from a revert of an earlier change
2020-06-03 12:59:19 +02:00

200 lines
6.8 KiB
C++

//=============================================================================
// MusE Score
// Linux Music Score Editor
//
// Copyright (C) 2002-2011 Werner Schweer and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef __PALETTE_H__
#define __PALETTE_H__
#include "palette/palettetree.h"
#include "ui_paletteProperties.h"
#include "libmscore/sym.h"
namespace Ms {
class Element;
class Sym;
class XmlWriter;
class XmlReader;
class Palette;
//---------------------------------------------------------
// PaletteProperties
//---------------------------------------------------------
class PaletteProperties : public QDialog, private Ui::PaletteProperties
{
Q_OBJECT
Palette * palette;
virtual void accept();
virtual void hideEvent(QHideEvent*);
public:
PaletteProperties(Palette* p, QWidget* parent = 0);
};
//---------------------------------------------------------
// PaletteScrollArea
//---------------------------------------------------------
class PaletteScrollArea : public QScrollArea
{
Q_OBJECT
bool _restrictHeight;
virtual void resizeEvent(QResizeEvent*);
protected:
virtual void keyPressEvent(QKeyEvent* event) override;
public:
PaletteScrollArea(Palette* w, QWidget* parent = 0);
bool restrictHeight() const { return _restrictHeight; }
void setRestrictHeight(bool val) { _restrictHeight = val; }
};
//---------------------------------------------------------
// Palette
//---------------------------------------------------------
class Palette : public QWidget
{
Q_OBJECT
QString _name;
QList<PaletteCell*> cells;
QList<PaletteCell*> dragCells; // used for filter & backup
int hgrid;
int vgrid;
int currentIdx;
int pressedIndex = -1;
int dragIdx;
int selectedIdx;
QPoint dragStartPosition;
qreal extraMag;
bool _drawGrid;
bool _selectable;
bool _disableElementsApply { false };
bool _useDoubleClickToActivate { false };
bool _readOnly;
bool _systemPalette;
qreal _yOffset; // in spatium units of "gscore"
bool filterActive { false }; // bool if filter is active
bool _moreElements;
bool _showContextMenu { true };
virtual void paintEvent(QPaintEvent*) override;
virtual void mousePressEvent(QMouseEvent*) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void mouseDoubleClickEvent(QMouseEvent*) override;
virtual void mouseMoveEvent(QMouseEvent*) override;
virtual void leaveEvent(QEvent*) override;
virtual bool event(QEvent*) override;
virtual void resizeEvent(QResizeEvent*) override;
virtual void dragEnterEvent(QDragEnterEvent*) override;
virtual void dragMoveEvent(QDragMoveEvent*) override;
virtual void dropEvent(QDropEvent*) override;
virtual void contextMenuEvent(QContextMenuEvent*) override;
int idx2(const QPoint&) const;
QRect idxRect(int) const;
const QList<PaletteCell*>* ccp() const { return filterActive ? &dragCells : &cells; }
QPixmap pixmap(int cellIdx) const;
void applyElementAtPosition(QPoint pos, Qt::KeyboardModifiers modifiers);
private slots:
void actionToggled(bool val);
signals:
void boxClicked(int);
void changed();
void displayMore(const QString& paletteName);
public:
Palette(QWidget* parent = 0);
Palette(std::unique_ptr<PalettePanel>, QWidget* parent = nullptr);
virtual ~Palette();
void nextPaletteElement();
void prevPaletteElement();
void applyPaletteElement();
static bool applyPaletteElement(Element* element, Qt::KeyboardModifiers modifiers = {});
PaletteCell* append(Element*, const QString& name, QString tag = QString(),qreal mag = 1.0);
PaletteCell* add(int idx, Element*, const QString& name,const QString tag = QString(), qreal mag = 1.0);
void emitChanged() { emit changed(); }
void setGrid(int, int);
Element* element(int idx);
void setDrawGrid(bool val) { _drawGrid = val; }
bool drawGrid() const { return _drawGrid; }
bool read(const QString& path); // TODO: remove/reuse PalettePanel code
void write(const QString& path); // TODO: remove/reuse PalettePanel code
void read(XmlReader&);
void write(XmlWriter&) const;
void clear();
void setSelectable(bool val) { _selectable = val; }
bool selectable() const { return _selectable; }
int getSelectedIdx() const { return selectedIdx; }
void setSelected(int idx) { selectedIdx = idx; }
bool readOnly() const { return _readOnly; }
void setReadOnly(bool val);
bool disableElementsApply() const { return _disableElementsApply; }
void setDisableElementsApply(bool val) { _disableElementsApply = val; }
bool useDoubleClickToActivate() const { return _useDoubleClickToActivate; }
void setUseDoubleClickToActivate(bool val) { _useDoubleClickToActivate = val; }
bool systemPalette() const { return _systemPalette; }
void setSystemPalette(bool val);
void setMag(qreal val);
qreal mag() const { return extraMag; }
void setYOffset(qreal val) { _yOffset = val; }
qreal yOffset() const { return _yOffset; }
int columns() const;
int rows() const;
int size() const { return filterActive ? dragCells.size() : cells.size(); }
PaletteCell* cellAt(int index) const { return ccp()->value(index); }
void setCellReadOnly(int c, bool v) { cells[c]->readOnly = v; }
QString name() const { return _name; }
void setName(const QString& s) { _name = s; }
int gridWidth() const { return hgrid; }
int gridHeight() const { return vgrid; }
bool moreElements() const { return _moreElements; }
void setMoreElements(bool val);
bool filter(const QString& text);
void setShowContextMenu(bool val) { _showContextMenu = val; }
static qreal guiMag();
int gridWidthM() const { return hgrid * guiMag(); }
int gridHeightM() const { return vgrid * guiMag(); }
int getCurrentIdx() { return currentIdx; }
void setCurrentIdx(int i) { currentIdx = i; }
bool isFilterActive() { return filterActive == true; }
QList<PaletteCell*> getDragCells() { return dragCells; }
virtual int heightForWidth(int) const;
virtual QSize sizeHint() const;
int idx(const QPoint&) const;
};
} // namespace Ms
#endif