diff --git a/src/libs/core/score/tnotecontrol.cpp b/src/libs/core/score/tnotecontrol.cpp index 727038afdf5f5c547405679a586aaa9d2b7d9046..546734c5d1c586b58acbebd2eb209b637cfe1f3c 100644 --- a/src/libs/core/score/tnotecontrol.cpp +++ b/src/libs/core/score/tnotecontrol.cpp @@ -27,6 +27,9 @@ #include <QTimer> #include <QApplication> #include <QGraphicsSceneHoverEvent> +#include <QGraphicsScene> +#include <QGraphicsEffect> +#include <QGraphicsView> // #include <QDebug> @@ -38,10 +41,20 @@ #define LEAVE_DELAY (300) #endif + +QGraphicsDropShadowEffect* ItemHighLight() { + QGraphicsDropShadowEffect *hiBlur = new QGraphicsDropShadowEffect(); + hiBlur->setColor(qApp->palette().highlight().color()); + hiBlur->setOffset(1.0, 1.0); + hiBlur->setBlurRadius(7.0); + return hiBlur; +} + TnoteControl::TnoteControl(TscoreStaff* staff, TscoreScene* scene) : TscoreItem(scene), m_scoreNote(0), - m_hasMouse(false), m_entered(false) + m_hasMouse(false), m_entered(false), + m_underItem(0) { setStaff(staff); setParentItem(staff); @@ -78,7 +91,8 @@ TnoteControl::~TnoteControl() void TnoteControl::adjustSize() { m_height = staff()->height(); m_plus->setPos(0.0, staff()->upperLinePos() - m_plus->boundingRect().height() * m_plus->scale()); - m_name->setPos(0.0, m_plus->pos().y() + m_plus->boundingRect().height() * m_plus->scale() - (m_name->boundingRect().height() / 2.5) * m_name->scale()); + m_name->setPos(0.0, m_plus->pos().y() + m_plus->boundingRect().height() * m_plus->scale() - + (m_name->boundingRect().height() / 3.5) * m_name->scale()); qreal minusY = (staff()->isPianoStaff() ? staff()->lowerLinePos() : staff()->upperLinePos()) + 11.0; m_minus->setLine(WIDTH / 4.0, minusY, WIDTH - WIDTH / 4.0, minusY); } @@ -120,11 +134,11 @@ void TnoteControl::setScoreNote(TscoreNote* sn) { setStaff(sn->staff()); parentItem()->setZValue(11); } - show(); + QTimer::singleShot(300, this, SLOT(showDelayed())); if (staff()->number() == 0 && staff()->count() < 2) m_minus->hide(); // prevent deleting only one note else - m_minus->show(); + m_minus->show(); if (pos().x() < m_scoreNote->pos().x()) // hide name for left control m_name->hide(); } else { @@ -151,15 +165,40 @@ void TnoteControl::hoverEnterDelayed() { } +void TnoteControl::showDelayed() { + show(); +} + + void TnoteControl::hoverEnterEvent(QGraphicsSceneHoverEvent* event) { QTimer::singleShot(300, this, SLOT(hoverEnterDelayed())); m_hasMouse = true; } +void TnoteControl::hoverMoveEvent(QGraphicsSceneHoverEvent* event) { + QGraphicsItem *it = scene()->itemAt(mapToScene(event->pos()), scene()->views()[0]->transform()); + if (it != this) { + if (it != m_underItem) { + it->setGraphicsEffect(ItemHighLight()); + if (m_underItem) + m_underItem->setGraphicsEffect(0); + m_underItem = it; + } + } else if (m_underItem) { + m_underItem->setGraphicsEffect(0); + m_underItem = 0; + } +} + + void TnoteControl::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) { m_hasMouse = false; // hide(); + if (m_underItem) { + m_underItem->setGraphicsEffect(0); + m_underItem = 0; + } hideWithDelay(LEAVE_DELAY); if (m_entered) TscoreItem::hoverLeaveEvent(event); diff --git a/src/libs/core/score/tnotecontrol.h b/src/libs/core/score/tnotecontrol.h index 0190aa1db8ba9d16150ff9d606e05ad05f9293af..505f6f8472bed86aca6e013677b7ac645792017f 100644 --- a/src/libs/core/score/tnotecontrol.h +++ b/src/libs/core/score/tnotecontrol.h @@ -53,11 +53,13 @@ signals: protected: virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event); virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event); + virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* event); virtual void mousePressEvent(QGraphicsSceneMouseEvent* event); protected slots: void hideDelayed(); void hoverEnterDelayed(); /** To avoid blinking with status tip when mouse is flying over score */ + void showDelayed(); private: TscoreNote *m_scoreNote; @@ -65,6 +67,7 @@ private: bool m_hasMouse, m_entered; QGraphicsSimpleTextItem *m_plus, *m_name; QGraphicsLineItem *m_minus; + QGraphicsItem *m_underItem; // Item under mouse }; #endif // TNOTECONTROL_H diff --git a/src/main.cpp b/src/main.cpp index 1ce77e07702535fce8381cf3855fe48ddf0be700..3721653772570691a626efeca445282c0a7b146d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,7 +70,11 @@ int main(int argc, char *argv[]) // to allow opening nootka files by clicking them in MacOs finder a->installEventFilter(w); #endif +#if defined (Q_OS_ANDROID) + w->showFullScreen(); +#else w->show(); +#endif if (firstTime && argc > 1) w->openFile(QString::fromLocal8Bit(argv[argc - 1])); firstTime = false; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index db02190a8ad7db18e7f37eaa35b947d12284f390..5563fe9abf6b9a3d0c773b9522c88599f284b68f 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -130,7 +130,16 @@ MainWindow::MainWindow(QWidget *parent) : nootBar->setToolButtonStyle(Qt::ToolButtonIconOnly); showMaximized(); // nootBar->hide(); +// nootBar->setAutoFillBackground(true); +// m_menuButton = new QPushButton("...", this); +// m_menuButton->setFixedWidth(fontMetrics().boundingRect("...").width() + 10); +// connect(m_menuButton, SIGNAL(clicked()), this, SLOT(menuTrigerred())); #endif + nootBar->hide(); + nootBar->setAutoFillBackground(true); + m_menuButton = new QPushButton("...", this); + m_menuButton->setFixedWidth(fontMetrics().boundingRect("...").width() + 10); + connect(m_menuButton, SIGNAL(clicked()), this, SLOT(menuTrigerred())); // QColor C(palette().text().color()); // #if defined (Q_OS_WIN) // C.setAlpha(20); @@ -149,7 +158,10 @@ MainWindow::MainWindow(QWidget *parent) : //------------------------------------------------------------------- // Setting layout QVBoxLayout *mainLay = new QVBoxLayout; - mainLay->addWidget(nootBar); + mainLay->setContentsMargins(2, 2, 2, 2); +// #if !defined (Q_OS_ANDROID) +// mainLay->addWidget(nootBar); +// #endif mainLay->addWidget(m_statLab); mainLay->addWidget(score); mainLay->addWidget(guitar); @@ -172,6 +184,8 @@ MainWindow::MainWindow(QWidget *parent) : // QMessageBox::warning(this, "", tr("Problems with sound output")); // nootBar->hide(); // m_statLab->hide(); + m_menuButton->raise(); + m_menuButton->move(1, 1); } @@ -189,6 +203,9 @@ MainWindow::~MainWindow() //########################################################################################## void MainWindow::createActions() { + menuAct = new QAction("...", this); + connect(menuAct, SIGNAL(triggered()), this, SLOT(menuTrigerred())); + settingsAct = new QAction(tr("Settings"), this); settingsAct->setStatusTip(tr("Application preferences")); settingsAct->setIcon(QIcon(gl->path + "picts/systemsettings.png")); @@ -217,6 +234,7 @@ void MainWindow::createActions() { recordAct->setIcon(QIcon(gl->path + "picts/record.png")); connect(recordAct, SIGNAL(triggered()), this, SLOT(recordSlot())); + nootBar->addAction(menuAct); nootBar->addAction(settingsAct); nootBar->addAction(levelCreatorAct); nootBar->addAction(analyseAct); @@ -614,6 +632,17 @@ void MainWindow::adjustAmbitus() { sound->setDefaultAmbitus(); } */ +void MainWindow::menuTrigerred() { + if (m_menuButton->isVisible()) { + m_menuButton->hide(); + nootBar->show(); + nootBar->raise(); + } else { + m_menuButton->show(); + nootBar->hide(); + m_menuButton->raise(); + } +} //########################################################################################## @@ -621,16 +650,6 @@ void MainWindow::adjustAmbitus() { //########################################################################################## bool MainWindow::event(QEvent *event) { -// switch (event->type()) { -// case QEvent::TouchBegin: -// case QEvent::TouchUpdate: -// case QEvent::TouchEnd: { -// QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints(); -// foreach (const QTouchEvent::TouchPoint &touchPoint, touchPoints) { -// qDebug() << touchPoint.pressure(); -// } -// } -// } #if !defined (Q_OS_ANDROID) if (gl->hintsEnabled && event->type() == QEvent::StatusTip && !m_lockStat) { QStatusTipEvent *se = static_cast<QStatusTipEvent *>(event); @@ -657,7 +676,17 @@ void MainWindow::updateSize(QSize newS) { m_statFontSize = (newS.height() / 10) / 4 - 2; if (m_statFontSize < 0) return; - nootBar->setIconSize(QSize(newS.height() / 22, height() / 22)); + nootBar->setFixedWidth(newS.width()); +#if defined (Q_OS_ANDROID) + int barIconSize = qMin(newS.width(), newS.height()) / 18; +// nootBar->setFixedWidth(newS.width()); +#else + int barIconSize = qMin(newS.width(), newS.height()) / 22; +#endif + nootBar->setIconSize(QSize(barIconSize, barIconSize)); + nootBar->adjustSize(); +// nootBar->setIconSize(QSize(newS.height() / 22, height() / 22)); + m_statLab->setFixedHeight(newS.height() / 10); QFont f = m_statLab->font(); f.setPointSize(m_statFontSize); diff --git a/src/mainwindow.h b/src/mainwindow.h index 5a3a4343d091363e362af38fa233229a7ed0e16d..8a9358205f7b49068b1e11412a71c92437936e84 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -24,6 +24,7 @@ // #include <texamexecutor.h> #include <QMainWindow> +class QPushButton; // class TanimedChBox; class QVBoxLayout; @@ -94,7 +95,7 @@ protected: // TprogressWidget *progress; QToolBar *nootBar; - QAction *settingsAct, *levelCreatorAct, *startExamAct, *aboutAct, *analyseAct, *playAct, *recordAct; + QAction *menuAct, *settingsAct, *levelCreatorAct, *startExamAct, *aboutAct, *analyseAct, *playAct, *recordAct; // void clearAfterExam(TexamExecutor::Estate examState = TexamExecutor::e_finished); void updateSize(QSize newS); /** Updates position and sizes of the widgets. */ @@ -113,6 +114,7 @@ protected slots: void restoreMessage(); void recordSlot(); + void menuTrigerred(); // void showSupportDialog(); /** Checks is score not too width and places pitchView under when it is. @@ -143,6 +145,7 @@ private: int m_statFontSize; // int m_extraFontOffset; bool m_levelCreatorExist; /** Keeps true when Dialog windows is opened, to avoid opening another file. */ + QPushButton *m_menuButton; // Tlevel m_level; // bool m_isPlayerFree; // QWidget *m_pitchContainer;