You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(25) |
Jul
(288) |
Aug
(119) |
Sep
(31) |
Oct
(59) |
Nov
(458) |
Dec
(359) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(268) |
Feb
(26) |
Mar
(36) |
Apr
(48) |
May
(119) |
Jun
(37) |
Jul
(173) |
Aug
(429) |
Sep
(137) |
Oct
(156) |
Nov
(59) |
Dec
(45) |
| 2011 |
Jan
(398) |
Feb
(257) |
Mar
(49) |
Apr
(5) |
May
(34) |
Jun
(11) |
Jul
(38) |
Aug
(12) |
Sep
(1) |
Oct
(49) |
Nov
(5) |
Dec
(10) |
| 2012 |
Jan
(21) |
Feb
(32) |
Mar
(20) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(173) |
Aug
|
Sep
(25) |
Oct
(6) |
Nov
(44) |
Dec
|
|
From: Tapio V. <aa...@us...> - 2011-01-10 13:17:53
|
Module: editor Branch: master Commit: 1fb237f1533db535c82199348398563f7239aebc Author: Tapio Vierros <tap...@gm...> Date: Mon Jan 10 14:19:12 2011 +0200 Pixel-perfect note split. --- notegraphwidget.cc | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/notegraphwidget.cc b/notegraphwidget.cc index 17cf9f7..f5b38c0 100644 --- a/notegraphwidget.cc +++ b/notegraphwidget.cc @@ -141,10 +141,11 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event) int cutpos = int(std::ceil(child->getText().length() * relRatio)); QString firstst = child->getText().left(cutpos); QString secondst = child->getText().right(child->getText().length() - cutpos); + int w1 = relRatio * child->width(); // Create new labels - NoteLabel *newLabel1 = new NoteLabel(firstst, this,child->pos()); - new NoteLabel(secondst, this, newLabel1->pos() + QPoint(newLabel1->width(), 0)); + NoteLabel *newLabel1 = new NoteLabel(firstst, this, child->pos(), QSize(w1, 0)); + new NoteLabel(secondst, this, newLabel1->pos() + QPoint(newLabel1->width(), 0), QSize(child->width() - w1, 0)); // Delete the old one child->close(); |
|
From: Tapio V. <aa...@us...> - 2011-01-10 12:12:06
|
Module: editor
Branch: master
Commit: ad5f40af5fbe2c8a2471fde4c86fb442b715b1de
Author: Tapio Vierros <tap...@gm...>
Date: Mon Jan 10 14:11:02 2011 +0200
Vertical note position now constrained to discrete steps.
---
notegraphwidget.cc | 13 ++++++++++---
notegraphwidget.hh | 3 +++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 04b8d36..17cf9f7 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -3,6 +3,10 @@
#include <cmath>
#include "notelabel.hh"
#include "notegraphwidget.hh"
+#include "util.hh"
+
+
+const int NoteGraphWidget::noteYStep = 40;
NoteGraphWidget::NoteGraphWidget(QWidget *parent)
: QWidget(parent), m_panHotSpot(), m_selectedNote(), m_selectedAction(NONE)
@@ -25,7 +29,7 @@ void NoteGraphWidget::setLyrics(QString lyrics)
{
QTextStream ts(&lyrics, QIODevice::ReadOnly);
const int gap = 10;
- int x = gap, y = 50;
+ int x = gap, y = 2 * noteYStep;
clear();
while (!ts.atEnd()) {
@@ -151,8 +155,11 @@ void NoteGraphWidget::mouseReleaseEvent(QMouseEvent *event)
{
(void)*event;
if (m_selectedAction != NONE) {
- m_selectedNote->startResizing(0);
- m_selectedNote->startDragging(QPoint());
+ if (m_selectedNote) {
+ m_selectedNote->startResizing(0);
+ m_selectedNote->startDragging(QPoint());
+ m_selectedNote->move(m_selectedNote->pos().x(), int(round(m_selectedNote->pos().y() / float(noteYStep))) * noteYStep);
+ }
m_selectedAction = NONE;
}
m_panHotSpot = QPoint();
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index 34ce8d4..6ddd0cd 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -9,6 +9,9 @@ typedef std::list<NoteLabel*> NoteLabels;
class NoteGraphWidget: public QWidget
{
public:
+
+ static const int noteYStep;
+
NoteGraphWidget(QWidget *parent = 0);
void clear();
|
|
From: Tapio V. <aa...@us...> - 2011-01-10 12:12:03
|
Module: editor
Branch: master
Commit: e836a769ac383ade1625e97ca04c1701b9e6b9ad
Author: Tapio Vierros <tap...@gm...>
Date: Mon Jan 10 14:00:13 2011 +0200
Pan NoteGraph with mouse by dragging from empty space.
---
notegraphwidget.cc | 31 ++++++++++++++++++++++++++++---
notegraphwidget.hh | 2 ++
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 4c6bc82..04b8d36 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -5,7 +5,7 @@
#include "notegraphwidget.hh"
NoteGraphWidget::NoteGraphWidget(QWidget *parent)
- : QWidget(parent), m_selectedNote(), m_selectedAction(NONE)
+ : QWidget(parent), m_panHotSpot(), m_selectedNote(), m_selectedAction(NONE)
{
setLyrics("Please add music file and lyrics text.");
}
@@ -61,7 +61,7 @@ void NoteGraphWidget::updateNotes()
for (NoteLabels::iterator it = m_notes.begin(); it != m_notes.end(); ++it) {
NoteLabel *child = *it; //dynamic_cast<NoteLabel*>(*it);
if (!child) continue;
- std::cout << "Child, floating: " << child->isFloating() << std::endl;
+ //std::cout << "Child, floating: " << child->isFloating() << std::endl;
if (child->isFloating()) {
// Add floating note to gap
gap.addNote(child);
@@ -97,8 +97,12 @@ void NoteGraphWidget::rebuildNoteList()
void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
{
NoteLabel *child = static_cast<NoteLabel*>(childAt(event->pos()));
- if (!child)
+ if (!child) {
+ // Left click empty area = pan
+ if (event->button() == Qt::LeftButton)
+ m_panHotSpot = event->pos();
return;
+ }
QPoint hotSpot = event->pos() - child->pos();
@@ -151,6 +155,7 @@ void NoteGraphWidget::mouseReleaseEvent(QMouseEvent *event)
m_selectedNote->startDragging(QPoint());
m_selectedAction = NONE;
}
+ m_panHotSpot = QPoint();
updateNotes();
}
@@ -186,6 +191,26 @@ void NoteGraphWidget::mouseDoubleClickEvent(QMouseEvent *event)
event->accept();
}
+void NoteGraphWidget::mouseMoveEvent(QMouseEvent *event)
+{
+ // Pan
+ if (!m_panHotSpot.isNull()) {
+ setCursor(QCursor(Qt::ClosedHandCursor));
+ QScrollArea *scrollArea = NULL;
+ if (parentWidget() && parentWidget()->parent())
+ scrollArea = dynamic_cast<QScrollArea*>(parentWidget()->parent()->parent());
+ if (scrollArea) {
+ QPoint diff = event->pos() - m_panHotSpot;
+ QScrollBar *scrollHor = scrollArea->horizontalScrollBar();
+ scrollHor->setValue(scrollHor->value() + diff.x());
+ QScrollBar *scrollVer = scrollArea->horizontalScrollBar();
+ scrollVer->setValue(scrollVer->value() + diff.y());
+ m_panHotSpot = event->pos() + diff;
+ }
+ }
+}
+
+
void FloatingGap::addNote(NoteLabel* n)
{
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index e0f464a..34ce8d4 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -22,9 +22,11 @@ protected:
void mouseReleaseEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void mouseDoubleClickEvent(QMouseEvent * event);
+ void mouseMoveEvent(QMouseEvent * event);
private:
int m_requiredWidth;
+ QPoint m_panHotSpot;
NoteLabel* m_selectedNote;
enum NoteAction { NONE, RESIZE, MOVE } m_selectedAction;
NoteLabels m_notes;
|
|
From: Tapio V. <aa...@us...> - 2011-01-10 12:12:00
|
Module: editor Branch: master Commit: 81c413107597e12a441694d1b81e158b61d10f0b Author: Tapio Vierros <tap...@gm...> Date: Mon Jan 10 13:01:34 2011 +0200 User-resizable notegraph/info tabs proportions. --- editor.ui | 539 ++++++++++++++++++++++++++++++---------------------------- editorapp.cc | 3 + 2 files changed, 278 insertions(+), 264 deletions(-) |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-08 10:56:37
|
Module: editor
Branch: master
Commit: 4c669efde4c7c92ae42206feedf22221c64932cf
Author: Lasse Karkkainen <tro...@tr...>
Date: Sat Jan 8 11:55:36 2011 +0100
Add pitch visualizer (reads music.raw and renders into RAM, not yet displayed on GUI)
---
pitchvis.cc | 43 +++++++++++++++++++++++++++++++++++++++++++
pitchvis.hh | 30 ++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/pitchvis.cc b/pitchvis.cc
new file mode 100644
index 0000000..f1e746f
--- /dev/null
+++ b/pitchvis.cc
@@ -0,0 +1,43 @@
+#include "pitchvis.hh"
+
+#include "notes.hh"
+#include "pitch.hh"
+#include <fstream>
+#include <iostream>
+#include <stdexcept>
+
+/** Read the entire file into a vector of some type.
+The file needs to be in the machine-native endianess. **/
+template <typename T> void readVec(std::string const& filename, std::vector<T>& c) {
+ std::ifstream f(filename.c_str(), std::ios::binary);
+ if (!f) throw std::runtime_error("Cannot open " + filename);
+ f.seekg(0, std::ios::end);
+ unsigned size = f.tellg();
+ if (size > 1e+8) throw std::runtime_error("File too large: " + filename);
+ f.seekg(0);
+ c.resize(size / sizeof(T));
+ f.read(reinterpret_cast<char*>(&c[0]), c.size() * sizeof(T));
+ if (!f) throw std::runtime_error("Error reading " + filename);
+}
+
+PitchVis::PitchVis(std::string const& filename): height(512) {
+ std::vector<float> data;
+ try { readVec(filename, data); } catch(std::exception& e) { std::cerr << e.what() << std::endl; return; }
+ unsigned step = 1024;
+ unsigned width = data.size() / step / height;
+ img.resize(width * height);
+ Analyzer analyzer(44100, "");
+ MusicalScale scale;
+ for (unsigned x = 0; x < width; ++x) {
+ analyzer.input(data.begin() + x * step, data.begin() + (x + 1) * step);
+ analyzer.process();
+ Analyzer::Peaks peaks = analyzer.getPeaks();
+ for (unsigned i = 0; i < peaks.size(); ++i) {
+ unsigned y = static_cast<unsigned>(8.0 * (scale.getNote(peaks[i].freq)));
+ if (y >= height) continue;
+ float value = magn2dB(peaks[i].magnitude) + 80.0;
+ if (value > 0.0) (*this)(x, y).r += 0.01 * value;
+ }
+ }
+}
+
diff --git a/pitchvis.hh b/pitchvis.hh
new file mode 100644
index 0000000..05a5c58
--- /dev/null
+++ b/pitchvis.hh
@@ -0,0 +1,30 @@
+#pragma once
+
+#include <string>
+#include <vector>
+
+struct Pixel {
+ float r,g,b,a;
+ Pixel(float r, float g, float b, float a = 1.0f): r(r), g(g), b(b), a(a) {}
+ Pixel(): r(), g(), b(), a(1.0f) {}
+ unsigned rgba() {
+ unsigned ret = 0;
+ for (unsigned i = 0; i < 4; ++i) {
+ float c = (*this)[i];
+ unsigned char byte = static_cast<unsigned char>(0.5 + 255.0 * c * c); // c² is gamma correction
+ ret |= byte << (i * 8);
+ }
+ return ret;
+ }
+ float& operator[](unsigned idx) { return (&r)[idx]; }
+};
+
+class PitchVis {
+ std::size_t height;
+ std::vector<Pixel> img;
+public:
+ Pixel& operator()(std::size_t x, std::size_t y) { return img[x * height + y]; }
+ std::size_t width() const { return img.size() / height; }
+ PitchVis(std::string const& filename);
+};
+
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-08 10:56:36
|
Module: editor Branch: master Commit: e0a2f8c8d657ee6831b4fb0fce9a6cca2a675aac Author: Lasse Karkkainen <tro...@tr...> Date: Fri Jan 7 21:34:33 2011 +0100 Merge branch 'master' of git.performous.org:/gitroot/performous/editor --- |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-08 10:56:32
|
Module: editor Branch: master Commit: 03480f430605a9c60674c60ad2aaa84ef14cc28e Author: Lasse Karkkainen <tro...@tr...> Date: Fri Jan 7 14:41:09 2011 +0100 Merge branch 'master' of git.performous.org:/gitroot/performous/editor --- |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-08 10:56:30
|
Module: editor Branch: master Commit: 7ba0ad1675edf12ecfcc4780f2b48e7f12435cf4 Author: Lasse Karkkainen <tro...@tr...> Date: Fri Jan 7 12:27:49 2011 +0100 Merge branch 'master' of git.performous.org:/gitroot/performous/editor --- |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-08 10:56:27
|
Module: editor Branch: master Commit: 254da51f6967401cad4c82b2f042b890f8258314 Author: Lasse Karkkainen <tro...@tr...> Date: Thu Jan 6 22:08:54 2011 +0100 Libda (w/o mixer.hpp) and pitch.hh/cc directly from Performous commit ceeff1f138f22350fa32397aac27d110c162934f. --- libda/fft.hpp | 105 +++++++++++++++++++++++ libda/portaudio.hpp | 132 +++++++++++++++++++++++++++++ libda/sample.hpp | 66 +++++++++++++++ pitch.cc | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++ pitch.hh | 104 +++++++++++++++++++++++ 5 files changed, 637 insertions(+), 0 deletions(-) |
|
From: Tapio V. <aa...@us...> - 2011-01-07 18:50:33
|
Module: editor
Branch: master
Commit: 5e67c9f5418a0f57b8a1a1f40a61d4402298bedf
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 20:50:13 2011 +0200
Implemented note selection (not very useful yet).
---
editor.ui | 52 +++++++++++++++++++++++++++++++++++++++++++++++-----
notegraphwidget.cc | 24 +++++++++++++-----------
notegraphwidget.hh | 4 ++--
notelabel.cc | 8 ++++++--
notelabel.hh | 3 +++
5 files changed, 71 insertions(+), 20 deletions(-)
diff --git a/editor.ui b/editor.ui
index 53efc92..df72752 100644
--- a/editor.ui
+++ b/editor.ui
@@ -169,10 +169,10 @@
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
- <x>360</x>
+ <x>600</x>
<y>10</y>
- <width>70</width>
- <height>18</height>
+ <width>41</width>
+ <height>31</height>
</rect>
</property>
<property name="text">
@@ -182,10 +182,10 @@
<widget class="QComboBox" name="comboNoteType">
<property name="geometry">
<rect>
- <x>440</x>
+ <x>650</x>
<y>10</y>
<width>92</width>
- <height>28</height>
+ <height>31</height>
</rect>
</property>
<property name="editable">
@@ -207,6 +207,48 @@
</property>
</item>
</widget>
+ <widget class="QLabel" name="label_8">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>70</y>
+ <width>70</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Note</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="valNote">
+ <property name="geometry">
+ <rect>
+ <x>120</x>
+ <y>70</y>
+ <width>70</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>XXX</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="chkFloating">
+ <property name="geometry">
+ <rect>
+ <x>610</x>
+ <y>60</y>
+ <width>131</width>
+ <height>23</height>
+ </rect>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::RightToLeft</enum>
+ </property>
+ <property name="text">
+ <string>Floating note</string>
+ </property>
+ </widget>
</widget>
<widget class="QWidget" name="tabSong">
<attribute name="title">
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index f458cb4..4c6bc82 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -5,7 +5,7 @@
#include "notegraphwidget.hh"
NoteGraphWidget::NoteGraphWidget(QWidget *parent)
- : QWidget(parent), m_resizingNote(), m_movingNote()
+ : QWidget(parent), m_selectedNote(), m_selectedAction(NONE)
{
setLyrics("Please add music file and lyrics text.");
}
@@ -105,20 +105,25 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
// Left Click
if (event->button() == Qt::LeftButton) {
+ if (m_selectedNote) // Reset old pixmap
+ m_selectedNote->setSelected(false);
+ // Assign new selection
+ m_selectedNote = child;
+ m_selectedNote->setSelected();
// Determine if it is drag or resize
if (hotSpot.x() < NoteLabel::resize_margin || hotSpot.x() > child->width() - NoteLabel::resize_margin) {
// Start a resize
- m_resizingNote = child;
+ m_selectedAction = RESIZE;
child->startResizing( (hotSpot.x() < NoteLabel::resize_margin) ? -1 : 1 );
child->disableFloating();
} else {
// Start a drag
- m_movingNote = child;
+ m_selectedAction = MOVE;
child->startDragging(hotSpot);
child->disableFloating();
- child->createPixmap(child->size());
}
+ child->createPixmap(child->size());
// Right Click
} else if (event->button() == Qt::RightButton) {
@@ -141,13 +146,10 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
void NoteGraphWidget::mouseReleaseEvent(QMouseEvent *event)
{
(void)*event;
- if (m_resizingNote) {
- m_resizingNote->startResizing(0);
- m_resizingNote = NULL;
- }
- if (m_movingNote) {
- m_movingNote->startDragging(QPoint());
- m_movingNote = NULL;
+ if (m_selectedAction != NONE) {
+ m_selectedNote->startResizing(0);
+ m_selectedNote->startDragging(QPoint());
+ m_selectedAction = NONE;
}
updateNotes();
}
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index ff4e1f0..e0f464a 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -25,8 +25,8 @@ protected:
private:
int m_requiredWidth;
- NoteLabel* m_resizingNote;
- NoteLabel* m_movingNote;
+ NoteLabel* m_selectedNote;
+ enum NoteAction { NONE, RESIZE, MOVE } m_selectedAction;
NoteLabels m_notes;
};
diff --git a/notelabel.cc b/notelabel.cc
index 7deb3cc..7dab1f5 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -9,7 +9,7 @@ namespace {
const int NoteLabel::resize_margin = 5; // How many pixels is the resize area
NoteLabel::NoteLabel(const QString &text, QWidget *parent, const QPoint &position, const QSize &size, bool floating)
- : QLabel(parent), m_labelText(text), m_floating(floating), m_resizing(0), m_hotspot()
+ : QLabel(parent), m_labelText(text), m_selected(false), m_floating(floating), m_resizing(0), m_hotspot()
{
createPixmap(size);
if (!position.isNull())
@@ -40,7 +40,11 @@ void NoteLabel::createPixmap(QSize size)
QLinearGradient gradient(0, 0, 0, image.height()-1);
gradient.setColorAt(0.0, Qt::white);
- if (m_floating) {
+ if (m_selected) {
+ gradient.setColorAt(0.2, QColor(100, 180, 100));
+ gradient.setColorAt(0.8, QColor(100, 180, 100));
+ gradient.setColorAt(1.0, QColor(100, 120, 100));
+ } else if (m_floating) {
gradient.setColorAt(0.2, QColor(160, 160, 180));
gradient.setColorAt(0.8, QColor(160, 160, 180));
gradient.setColorAt(1.0, QColor(100, 100, 120));
diff --git a/notelabel.hh b/notelabel.hh
index 2a0f3a8..6607df9 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -13,6 +13,8 @@ public:
QString getText() const;
void setText(const QString &text);
+ void setSelected(bool state = true) { m_selected = state; createPixmap(size()); }
+
bool isFloating() const { return m_floating; }
void disableFloating() { m_floating = false; }
@@ -26,6 +28,7 @@ public:
private:
QString m_labelText;
+ bool m_selected;
bool m_floating;
int m_resizing;
QPoint m_hotspot;
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 18:50:30
|
Module: editor
Branch: master
Commit: 040c809e5dfcc68195485f547421781ab59379db
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 20:22:25 2011 +0200
Different mouse cursors for note moving, resizing and hovering.
---
notegraphwidget.cc | 5 ++---
notelabel.cc | 31 +++++++++++++++++++++++++++++++
notelabel.hh | 6 ++++--
3 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index aa87b97..f458cb4 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -106,11 +106,10 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
if (event->button() == Qt::LeftButton) {
// Determine if it is drag or resize
- const int resizeHandleSize = 5;
- if (hotSpot.x() < resizeHandleSize || hotSpot.x() > child->width() - resizeHandleSize) {
+ if (hotSpot.x() < NoteLabel::resize_margin || hotSpot.x() > child->width() - NoteLabel::resize_margin) {
// Start a resize
m_resizingNote = child;
- child->startResizing( (hotSpot.x() < resizeHandleSize) ? -1 : 1 );
+ child->startResizing( (hotSpot.x() < NoteLabel::resize_margin) ? -1 : 1 );
child->disableFloating();
} else {
diff --git a/notelabel.cc b/notelabel.cc
index df1b958..7deb3cc 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -6,6 +6,8 @@ namespace {
static const int text_margin = 12; // Margin of the label texts
}
+const int NoteLabel::resize_margin = 5; // How many pixels is the resize area
+
NoteLabel::NoteLabel(const QString &text, QWidget *parent, const QPoint &position, const QSize &size, bool floating)
: QLabel(parent), m_labelText(text), m_floating(floating), m_resizing(0), m_hotspot()
{
@@ -87,13 +89,42 @@ void NoteLabel::mouseMoveEvent(QMouseEvent *event)
NoteGraphWidget* ngw = dynamic_cast<NoteGraphWidget*>(parent());
if (m_resizing != 0) {
+ // Resizing
if (m_resizing < 0)
setGeometry(x() + event->pos().x(), y(), width() - event->pos().x(), height());
else
resize(event->pos().x(), height());
if (ngw) ngw->updateNotes();
+
} else if (!m_hotspot.isNull()) {
+ // Moving
move(pos() + event->pos() - m_hotspot);
if (ngw) ngw->updateNotes();
+
+ } else {
+ // Hover cursors
+ if (event->pos().x() < NoteLabel::resize_margin || event->pos().x() > width() - NoteLabel::resize_margin) {
+ setCursor(QCursor(Qt::SizeHorCursor));
+ } else {
+ setCursor(QCursor(Qt::OpenHandCursor));
+ }
}
}
+
+void NoteLabel::startResizing(int dir)
+{
+ m_resizing = dir;
+ m_hotspot = QPoint(); // Reset
+ if (dir != 0) setCursor(QCursor(Qt::SizeHorCursor));
+ else setCursor(QCursor());
+}
+
+void NoteLabel::startDragging(const QPoint& point)
+{
+ m_hotspot = point;
+ m_resizing = 0;
+
+ if (!point.isNull()) setCursor(QCursor(Qt::ClosedHandCursor));
+ else setCursor(QCursor());
+}
+
diff --git a/notelabel.hh b/notelabel.hh
index a677ac0..2a0f3a8 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -5,6 +5,8 @@
class NoteLabel: public QLabel
{
public:
+ static const int resize_margin;
+
NoteLabel(const QString &text, QWidget *parent, const QPoint &position = QPoint(), const QSize &size = QSize(), bool floating = true);
void createPixmap(QSize size = QSize());
@@ -14,8 +16,8 @@ public:
bool isFloating() const { return m_floating; }
void disableFloating() { m_floating = false; }
- void startResizing(int dir) { m_resizing = dir; m_hotspot = QPoint(); }
- void startDragging(const QPoint& point) { m_hotspot = point; m_resizing = 0; }
+ void startResizing(int dir);
+ void startDragging(const QPoint& point);
void resizeEvent(QResizeEvent *event);
void mouseMoveEvent(QMouseEvent *event);
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 15:08:04
|
Module: editor
Branch: master
Commit: 9ea0dceff9a4f6ce3f2868dd28be7a6720c8ad48
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 17:07:41 2011 +0200
Implement (partially) some menu items.
* on_actionNew_triggered()
* on_actionMusicFile_triggered()
* on_actionLyricsFromFile_triggered()
---
editor.ui | 16 ++++++++-
editorapp.cc | 95 ++++++++++++++++++++++++++++++++++++++++-----------
editorapp.hh | 11 +++++-
notegraphwidget.cc | 4 ++-
4 files changed, 102 insertions(+), 24 deletions(-)
diff --git a/editor.ui b/editor.ui
index e3c0bc9..53efc92 100644
--- a/editor.ui
+++ b/editor.ui
@@ -40,7 +40,7 @@
<x>0</x>
<y>0</y>
<width>778</width>
- <height>353</height>
+ <height>351</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
@@ -233,6 +233,20 @@
<item row="1" column="1">
<widget class="QLineEdit" name="txtArtist"/>
</item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_7">
+ <property name="text">
+ <string>Music</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="valMusicFile">
+ <property name="text">
+ <string>No music</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</widget>
diff --git a/editorapp.cc b/editorapp.cc
index 0dcbd94..d21a41f 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -6,9 +6,80 @@
EditorApp::EditorApp(QWidget *parent): QMainWindow(parent)
{
ui.setupUi(this);
- // FIXME: Should not set any lyrics here
- ui.noteGraph->setLyrics("Young man, there's no need to feel down. "
- "I said, young man, pick yourself off the ground.");
+}
+
+void EditorApp::on_actionNew_triggered()
+{
+ // TODO: Check if a save prompt is in order
+ if (true) {
+ QMessageBox::StandardButton b = QMessageBox::question(this, "Unsaved changes",
+ "There are unsaved changes. Do you wish to save before creating a new project?",
+ QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
+ switch(b) {
+ case QMessageBox::Yes:
+ // TODO: Save
+ case QMessageBox::No:
+ ui.noteGraph->clear(); break;
+ default: break;
+ }
+ } else {
+ ui.noteGraph->clear();
+ }
+}
+
+void EditorApp::on_actionExit_triggered()
+{
+ // TODO: Check if a save prompt is in order
+ if (false) {
+ QMessageBox::StandardButton b = QMessageBox::question(this, "Unsaved changes",
+ "There are unsaved changes. Do you wish to save before quitting?",
+ QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
+ switch(b) {
+ case QMessageBox::Yes:
+ // TODO: Save
+ case QMessageBox::No:
+ close(); break;
+ default: break;
+ }
+ } else {
+ close();
+ }
+}
+
+void EditorApp::on_actionMusicFile_triggered()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
+ "",
+ tr("Music files (*.mp3 *.ogg)"));
+
+ if (!fileName.isNull()) {
+ ui.valMusicFile->setText(fileName);
+ ui.tabWidget->setCurrentIndex(1);
+ // TODO: Do something the file
+ }
+}
+
+void EditorApp::on_actionLyricsFromFile_triggered()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
+ "",
+ tr("Text files (*.txt)"));
+
+ if (!fileName.isNull()) {
+ QFile file(fileName);
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+ return;
+
+ QTextStream in(&file);
+ QString text = "";
+ while (!in.atEnd()) {
+ text += in.readLine();
+ if (!in.atEnd()) text += " "; // TODO: Some kind of line separator here
+ }
+
+ if (text != "")
+ ui.noteGraph->setLyrics(text);
+ }
}
void EditorApp::on_actionLyricsFromClipboard_triggered()
@@ -36,21 +107,3 @@ void EditorApp::on_actionAbout_triggered()
);
}
-void EditorApp::on_actionExit_triggered()
-{
- // TODO: Check if a save prompt is in order
- if (false) {
- QMessageBox::StandardButton b = QMessageBox::question(this, "Unsaved changes",
- "There are unsaved changes. Do you wish to save before quitting?",
- QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
- switch(b) {
- case QMessageBox::Yes:
- // TODO: Save
- case QMessageBox::No:
- close(); break;
- default: break;
- }
- } else {
- close();
- }
-}
diff --git a/editorapp.hh b/editorapp.hh
index 23ee86e..c692b93 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -10,9 +10,18 @@ public:
EditorApp(QWidget *parent = 0);
public slots:
+ // File
+ void on_actionNew_triggered();
+ void on_actionExit_triggered();
+
+ // Insert
+ void on_actionMusicFile_triggered();
+ void on_actionLyricsFromFile_triggered();
void on_actionLyricsFromClipboard_triggered();
+
+ // Help
void on_actionAbout_triggered();
- void on_actionExit_triggered();
+
private:
Ui::EditorApp ui;
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 99a6381..aa87b97 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -7,7 +7,7 @@
NoteGraphWidget::NoteGraphWidget(QWidget *parent)
: QWidget(parent), m_resizingNote(), m_movingNote()
{
- setAcceptDrops(true);
+ setLyrics("Please add music file and lyrics text.");
}
void NoteGraphWidget::clear()
@@ -53,6 +53,8 @@ void NoteGraphWidget::updateWidth()
void NoteGraphWidget::updateNotes()
{
+ // Here happens the magic that adjusts the floating
+ // notes according to the fixed ones.
FloatingGap gap(0);
rebuildNoteList();
// Determine gaps between non-floating notes
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 13:39:50
|
Module: editor
Branch: master
Commit: cb3bc8963d84a72d7f1929637a986670ecbc17b2
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 15:39:24 2011 +0200
Fix left-side resizing.
---
notegraphwidget.cc | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 7832ee4..99a6381 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -109,6 +109,7 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
// Start a resize
m_resizingNote = child;
child->startResizing( (hotSpot.x() < resizeHandleSize) ? -1 : 1 );
+ child->disableFloating();
} else {
// Start a drag
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 13:39:47
|
Module: editor Branch: master Commit: 3792bb1066ee536791c9a0ee877e7c46f6eac75b Author: Tapio Vierros <tap...@gm...> Date: Fri Jan 7 15:38:53 2011 +0200 Minimum size for notes (no more resizing to invisibility). --- notelabel.cc | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/notelabel.cc b/notelabel.cc index 38ff366..df1b958 100644 --- a/notelabel.cc +++ b/notelabel.cc @@ -13,9 +13,10 @@ NoteLabel::NoteLabel(const QString &text, QWidget *parent, const QPoint &positio if (!position.isNull()) move(position); - show(); setMouseTracking(true); + setMinimumSize(10, 10); setAttribute(Qt::WA_DeleteOnClose); + show(); } void NoteLabel::createPixmap(QSize size) |
|
From: Tapio V. <aa...@us...> - 2011-01-07 13:22:22
|
Module: editor
Branch: master
Commit: 09681a70907bdc778343912cfbe3c65a08491fad
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 15:22:08 2011 +0200
Insta-update graph when manipulating.
---
notelabel.cc | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/notelabel.cc b/notelabel.cc
index 355588c..38ff366 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -1,5 +1,6 @@
#include <QtGui>
#include "notelabel.hh"
+#include "notegraphwidget.hh"
namespace {
static const int text_margin = 12; // Margin of the label texts
@@ -82,12 +83,16 @@ void NoteLabel::resizeEvent(QResizeEvent *event)
void NoteLabel::mouseMoveEvent(QMouseEvent *event)
{
QToolTip::showText(event->globalPos(), getText(), this);
+
+ NoteGraphWidget* ngw = dynamic_cast<NoteGraphWidget*>(parent());
if (m_resizing != 0) {
if (m_resizing < 0)
setGeometry(x() + event->pos().x(), y(), width() - event->pos().x(), height());
else
resize(event->pos().x(), height());
+ if (ngw) ngw->updateNotes();
} else if (!m_hotspot.isNull()) {
move(pos() + event->pos() - m_hotspot);
+ if (ngw) ngw->updateNotes();
}
}
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 13:18:34
|
Module: editor
Branch: master
Commit: 3a79562972d234da8ff1c995994efb4780ebca7d
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 15:18:10 2011 +0200
Remove MIME-type based dragging and implement own.
Now simpler and gives more control.
---
notegraphwidget.cc | 99 ++++++++-------------------------------------------
notegraphwidget.hh | 6 +--
notelabel.cc | 4 ++-
notelabel.hh | 4 ++-
4 files changed, 24 insertions(+), 89 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 74a7290..7832ee4 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -5,7 +5,7 @@
#include "notegraphwidget.hh"
NoteGraphWidget::NoteGraphWidget(QWidget *parent)
- : QWidget(parent), m_resizing()
+ : QWidget(parent), m_resizingNote(), m_movingNote()
{
setAcceptDrops(true);
}
@@ -92,61 +92,6 @@ void NoteGraphWidget::rebuildNoteList()
m_notes.sort(cmpNoteLabelPtr);
}
-void NoteGraphWidget::dragEnterEvent(QDragEnterEvent *event)
-{
- if (event->mimeData()->hasFormat("application/x-notelabel")) {
- if (children().contains(event->source())) {
- event->setDropAction(Qt::MoveAction);
- event->accept();
- } else {
- event->acceptProposedAction();
- }
- } else {
- event->ignore();
- }
-}
-
-void NoteGraphWidget::dragMoveEvent(QDragMoveEvent *event)
-{
- if (event->mimeData()->hasFormat("application/x-notelabel")) {
- if (children().contains(event->source())) {
- event->setDropAction(Qt::MoveAction);
- event->accept();
- } else {
- event->acceptProposedAction();
- }
- // Update note positions on-the-fly
- updateNotes();
- } else {
- event->ignore();
- }
-}
-
-void NoteGraphWidget::dropEvent(QDropEvent *event)
-{
- if (event->mimeData()->hasFormat("application/x-notelabel")) {
- const QMimeData *mime = event->mimeData();
- QByteArray itemData = mime->data("application/x-notelabel");
- QDataStream dataStream(&itemData, QIODevice::ReadOnly);
-
- QString text;
- QPoint offset;
- int w;
- dataStream >> text >> offset >> w;
- new NoteLabel(text, this, event->pos() - offset, QSize(w, 0), false);
- updateNotes();
-
- if (event->source() == this) {
- event->setDropAction(Qt::MoveAction);
- event->accept();
- } else {
- event->acceptProposedAction();
- }
- } else {
- event->ignore();
- }
-}
-
void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
{
NoteLabel *child = static_cast<NoteLabel*>(childAt(event->pos()));
@@ -162,34 +107,15 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
const int resizeHandleSize = 5;
if (hotSpot.x() < resizeHandleSize || hotSpot.x() > child->width() - resizeHandleSize) {
// Start a resize
- m_resizing = child;
- child->setResizing( (hotSpot.x() < resizeHandleSize) ? -1 : 1 );
- std::cout << "resize" << std::endl;
+ m_resizingNote = child;
+ child->startResizing( (hotSpot.x() < resizeHandleSize) ? -1 : 1 );
} else {
- // Initialize Drag
-
- QByteArray itemData;
- QDataStream dataStream(&itemData, QIODevice::WriteOnly);
- dataStream << child->getText() << QPoint(hotSpot) << child->width();
-
- QMimeData *mimeData = new QMimeData;
- mimeData->setData("application/x-notelabel", itemData);
- mimeData->setText(child->getText());
-
- QDrag *drag = new QDrag(this);
- drag->setMimeData(mimeData);
- drag->setPixmap(*child->pixmap());
- drag->setHotSpot(hotSpot);
-
+ // Start a drag
+ m_movingNote = child;
+ child->startDragging(hotSpot);
child->disableFloating();
- child->createPixmap();
- child->hide();
-
- if (drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction) == Qt::MoveAction)
- child->close();
- else
- child->show();
+ child->createPixmap(child->size());
}
// Right Click
@@ -213,8 +139,15 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
void NoteGraphWidget::mouseReleaseEvent(QMouseEvent *event)
{
(void)*event;
- m_resizing->setResizing(0);
- m_resizing = NULL;
+ if (m_resizingNote) {
+ m_resizingNote->startResizing(0);
+ m_resizingNote = NULL;
+ }
+ if (m_movingNote) {
+ m_movingNote->startDragging(QPoint());
+ m_movingNote = NULL;
+ }
+ updateNotes();
}
void NoteGraphWidget::wheelEvent(QWheelEvent *event)
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index a3587b0..ff4e1f0 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -18,9 +18,6 @@ public:
void rebuildNoteList();
protected:
- void dragEnterEvent(QDragEnterEvent *event);
- void dragMoveEvent(QDragMoveEvent *event);
- void dropEvent(QDropEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
@@ -28,7 +25,8 @@ protected:
private:
int m_requiredWidth;
- NoteLabel* m_resizing;
+ NoteLabel* m_resizingNote;
+ NoteLabel* m_movingNote;
NoteLabels m_notes;
};
diff --git a/notelabel.cc b/notelabel.cc
index 3af1271..355588c 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -6,7 +6,7 @@ namespace {
}
NoteLabel::NoteLabel(const QString &text, QWidget *parent, const QPoint &position, const QSize &size, bool floating)
- : QLabel(parent), m_labelText(text), m_floating(floating), m_resizing(0)
+ : QLabel(parent), m_labelText(text), m_floating(floating), m_resizing(0), m_hotspot()
{
createPixmap(size);
if (!position.isNull())
@@ -87,5 +87,7 @@ void NoteLabel::mouseMoveEvent(QMouseEvent *event)
setGeometry(x() + event->pos().x(), y(), width() - event->pos().x(), height());
else
resize(event->pos().x(), height());
+ } else if (!m_hotspot.isNull()) {
+ move(pos() + event->pos() - m_hotspot);
}
}
diff --git a/notelabel.hh b/notelabel.hh
index 4e1bb7f..a677ac0 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -14,7 +14,8 @@ public:
bool isFloating() const { return m_floating; }
void disableFloating() { m_floating = false; }
- void setResizing(int dir) { m_resizing = dir; }
+ void startResizing(int dir) { m_resizing = dir; m_hotspot = QPoint(); }
+ void startDragging(const QPoint& point) { m_hotspot = point; m_resizing = 0; }
void resizeEvent(QResizeEvent *event);
void mouseMoveEvent(QMouseEvent *event);
@@ -25,6 +26,7 @@ private:
QString m_labelText;
bool m_floating;
int m_resizing;
+ QPoint m_hotspot;
};
bool inline cmpNoteLabelPtr(const NoteLabel *lhs, const NoteLabel *rhs)
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 12:42:58
|
Module: editor
Branch: master
Commit: 02a9224d89a3d712994f0282629b94e94606037e
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 14:42:33 2011 +0200
Notes now remember their width after dragging.
---
notegraphwidget.cc | 7 ++++---
notelabel.cc | 17 ++++++++---------
notelabel.hh | 2 +-
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 3ba2375..74a7290 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -131,8 +131,9 @@ void NoteGraphWidget::dropEvent(QDropEvent *event)
QString text;
QPoint offset;
- dataStream >> text >> offset;
- new NoteLabel(text, this, event->pos() - offset, false);
+ int w;
+ dataStream >> text >> offset >> w;
+ new NoteLabel(text, this, event->pos() - offset, QSize(w, 0), false);
updateNotes();
if (event->source() == this) {
@@ -170,7 +171,7 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
- dataStream << child->getText() << QPoint(hotSpot);
+ dataStream << child->getText() << QPoint(hotSpot) << child->width();
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-notelabel", itemData);
diff --git a/notelabel.cc b/notelabel.cc
index 42ac8a1..3af1271 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -5,10 +5,10 @@ namespace {
static const int text_margin = 12; // Margin of the label texts
}
-NoteLabel::NoteLabel(const QString &text, QWidget *parent, const QPoint &position, bool floating)
+NoteLabel::NoteLabel(const QString &text, QWidget *parent, const QPoint &position, const QSize &size, bool floating)
: QLabel(parent), m_labelText(text), m_floating(floating), m_resizing(0)
{
- createPixmap();
+ createPixmap(size);
if (!position.isNull())
move(position);
@@ -19,13 +19,12 @@ NoteLabel::NoteLabel(const QString &text, QWidget *parent, const QPoint &positio
void NoteLabel::createPixmap(QSize size)
{
- if (!size.isValid()) {
- QFontMetrics metric(font());
- size = metric.size(Qt::TextSingleLine, m_labelText);
- size.rwidth() += text_margin;
- size.rheight() += text_margin;
- // FIXME: Size is fixed
- size.rwidth() = 50;
+ QFontMetrics metric(font());
+ if (size.width() <= 0) {
+ size.rwidth() = 50; // FIXME: Size is fixed
+ }
+ if (size.height() <= 0) {
+ size.rheight() = metric.size(Qt::TextSingleLine, m_labelText).height() + text_margin;
}
QImage image(size.width(), size.height(),
diff --git a/notelabel.hh b/notelabel.hh
index 258d5ce..4e1bb7f 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -5,7 +5,7 @@
class NoteLabel: public QLabel
{
public:
- NoteLabel(const QString &text, QWidget *parent, const QPoint &position = QPoint(), bool floating = true);
+ NoteLabel(const QString &text, QWidget *parent, const QPoint &position = QPoint(), const QSize &size = QSize(), bool floating = true);
void createPixmap(QSize size = QSize());
QString getText() const;
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 12:42:56
|
Module: editor
Branch: master
Commit: 26b0632e4218d7508aa671158477dc9792109ccd
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 14:32:07 2011 +0200
Notes can be resized by dragging from borders.
---
notegraphwidget.cc | 55 +++++++++++++++++++++++++++++++++++-----------------
notegraphwidget.hh | 2 +
notelabel.cc | 12 ++++++++--
notelabel.hh | 3 ++
4 files changed, 51 insertions(+), 21 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 23b1ac8..3ba2375 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -5,7 +5,7 @@
#include "notegraphwidget.hh"
NoteGraphWidget::NoteGraphWidget(QWidget *parent)
- : QWidget(parent)
+ : QWidget(parent), m_resizing()
{
setAcceptDrops(true);
}
@@ -157,27 +157,39 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
// Left Click
if (event->button() == Qt::LeftButton) {
- QByteArray itemData;
- QDataStream dataStream(&itemData, QIODevice::WriteOnly);
- dataStream << child->getText() << QPoint(hotSpot);
+ // Determine if it is drag or resize
+ const int resizeHandleSize = 5;
+ if (hotSpot.x() < resizeHandleSize || hotSpot.x() > child->width() - resizeHandleSize) {
+ // Start a resize
+ m_resizing = child;
+ child->setResizing( (hotSpot.x() < resizeHandleSize) ? -1 : 1 );
+ std::cout << "resize" << std::endl;
- QMimeData *mimeData = new QMimeData;
- mimeData->setData("application/x-notelabel", itemData);
- mimeData->setText(child->getText());
+ } else {
+ // Initialize Drag
- QDrag *drag = new QDrag(this);
- drag->setMimeData(mimeData);
- drag->setPixmap(*child->pixmap());
- drag->setHotSpot(hotSpot);
+ QByteArray itemData;
+ QDataStream dataStream(&itemData, QIODevice::WriteOnly);
+ dataStream << child->getText() << QPoint(hotSpot);
- child->disableFloating();
- child->createPixmap();
- child->hide();
+ QMimeData *mimeData = new QMimeData;
+ mimeData->setData("application/x-notelabel", itemData);
+ mimeData->setText(child->getText());
+
+ QDrag *drag = new QDrag(this);
+ drag->setMimeData(mimeData);
+ drag->setPixmap(*child->pixmap());
+ drag->setHotSpot(hotSpot);
+
+ child->disableFloating();
+ child->createPixmap();
+ child->hide();
- if (drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction) == Qt::MoveAction)
- child->close();
- else
- child->show();
+ if (drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction) == Qt::MoveAction)
+ child->close();
+ else
+ child->show();
+ }
// Right Click
} else if (event->button() == Qt::RightButton) {
@@ -197,6 +209,13 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
}
}
+void NoteGraphWidget::mouseReleaseEvent(QMouseEvent *event)
+{
+ (void)*event;
+ m_resizing->setResizing(0);
+ m_resizing = NULL;
+}
+
void NoteGraphWidget::wheelEvent(QWheelEvent *event)
{
NoteLabel *child = static_cast<NoteLabel*>(childAt(event->pos()));
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index bd5ebc5..a3587b0 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -22,11 +22,13 @@ protected:
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void mouseDoubleClickEvent(QMouseEvent * event);
private:
int m_requiredWidth;
+ NoteLabel* m_resizing;
NoteLabels m_notes;
};
diff --git a/notelabel.cc b/notelabel.cc
index a47ee73..42ac8a1 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -6,7 +6,7 @@ namespace {
}
NoteLabel::NoteLabel(const QString &text, QWidget *parent, const QPoint &position, bool floating)
- : QLabel(parent), m_labelText(text), m_floating(floating)
+ : QLabel(parent), m_labelText(text), m_floating(floating), m_resizing(0)
{
createPixmap();
if (!position.isNull())
@@ -24,9 +24,9 @@ void NoteLabel::createPixmap(QSize size)
size = metric.size(Qt::TextSingleLine, m_labelText);
size.rwidth() += text_margin;
size.rheight() += text_margin;
+ // FIXME: Size is fixed
+ size.rwidth() = 50;
}
- // FIXME: Size is fixed
- size.rwidth() = 50;
QImage image(size.width(), size.height(),
QImage::Format_ARGB32_Premultiplied);
@@ -83,4 +83,10 @@ void NoteLabel::resizeEvent(QResizeEvent *event)
void NoteLabel::mouseMoveEvent(QMouseEvent *event)
{
QToolTip::showText(event->globalPos(), getText(), this);
+ if (m_resizing != 0) {
+ if (m_resizing < 0)
+ setGeometry(x() + event->pos().x(), y(), width() - event->pos().x(), height());
+ else
+ resize(event->pos().x(), height());
+ }
}
diff --git a/notelabel.hh b/notelabel.hh
index 5147685..258d5ce 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -14,6 +14,8 @@ public:
bool isFloating() const { return m_floating; }
void disableFloating() { m_floating = false; }
+ void setResizing(int dir) { m_resizing = dir; }
+
void resizeEvent(QResizeEvent *event);
void mouseMoveEvent(QMouseEvent *event);
@@ -22,6 +24,7 @@ public:
private:
QString m_labelText;
bool m_floating;
+ int m_resizing;
};
bool inline cmpNoteLabelPtr(const NoteLabel *lhs, const NoteLabel *rhs)
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 12:42:53
|
Module: editor
Branch: master
Commit: a41fb8461a562fb23bb70e86797385eec11401bd
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 13:47:58 2011 +0200
Proper exit menu action (with disabled save confirmation prompt).
---
editor.ui | 3 ---
editorapp.cc | 16 +++++++++++++++-
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/editor.ui b/editor.ui
index ed20f14..e3c0bc9 100644
--- a/editor.ui
+++ b/editor.ui
@@ -10,9 +10,6 @@
<height>600</height>
</rect>
</property>
- <property name="contextMenuPolicy">
- <enum>Qt::DefaultContextMenu</enum>
- </property>
<property name="windowTitle">
<string>Editor</string>
</property>
diff --git a/editorapp.cc b/editorapp.cc
index 521bbc4..0dcbd94 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -38,5 +38,19 @@ void EditorApp::on_actionAbout_triggered()
void EditorApp::on_actionExit_triggered()
{
- exit(0); // Hack
+ // TODO: Check if a save prompt is in order
+ if (false) {
+ QMessageBox::StandardButton b = QMessageBox::question(this, "Unsaved changes",
+ "There are unsaved changes. Do you wish to save before quitting?",
+ QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
+ switch(b) {
+ case QMessageBox::Yes:
+ // TODO: Save
+ case QMessageBox::No:
+ close(); break;
+ default: break;
+ }
+ } else {
+ close();
+ }
}
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 12:42:51
|
Module: editor
Branch: master
Commit: c683dce0d1bfa152b555a4ff6cb0bf3b034d1be7
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 13:29:25 2011 +0200
Insta-tooltips for notes.
---
notelabel.cc | 7 +++++++
notelabel.hh | 1 +
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/notelabel.cc b/notelabel.cc
index 5839880..a47ee73 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -11,7 +11,9 @@ NoteLabel::NoteLabel(const QString &text, QWidget *parent, const QPoint &positio
createPixmap();
if (!position.isNull())
move(position);
+
show();
+ setMouseTracking(true);
setAttribute(Qt::WA_DeleteOnClose);
}
@@ -77,3 +79,8 @@ void NoteLabel::resizeEvent(QResizeEvent *event)
{
createPixmap(event->size());
}
+
+void NoteLabel::mouseMoveEvent(QMouseEvent *event)
+{
+ QToolTip::showText(event->globalPos(), getText(), this);
+}
diff --git a/notelabel.hh b/notelabel.hh
index ad48457..5147685 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -15,6 +15,7 @@ public:
void disableFloating() { m_floating = false; }
void resizeEvent(QResizeEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
bool operator<(const NoteLabel &rhs) const { return x() < rhs.x(); }
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 12:42:49
|
Module: editor
Branch: master
Commit: 3133a8e48df22ca03d379f4c52522bdafdb57755
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 13:28:57 2011 +0200
Added some widgets to UI.
---
editor.ui | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 160 insertions(+), 0 deletions(-)
diff --git a/editor.ui b/editor.ui
index 2d71dbe..ed20f14 100644
--- a/editor.ui
+++ b/editor.ui
@@ -81,6 +81,166 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tabNote">
+ <attribute name="title">
+ <string>&Note properties</string>
+ </attribute>
+ <widget class="QLabel" name="label_3">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>81</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Start time</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_4">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>30</y>
+ <width>81</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>End time</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_5">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>50</y>
+ <width>70</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Duration</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="valNoteBegin">
+ <property name="geometry">
+ <rect>
+ <x>120</x>
+ <y>10</y>
+ <width>70</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>XXX</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="valNoteEnd">
+ <property name="geometry">
+ <rect>
+ <x>120</x>
+ <y>30</y>
+ <width>70</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>XXX</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="valNoteDuration">
+ <property name="geometry">
+ <rect>
+ <x>120</x>
+ <y>50</y>
+ <width>70</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>XXX</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_6">
+ <property name="geometry">
+ <rect>
+ <x>360</x>
+ <y>10</y>
+ <width>70</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Type</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="comboNoteType">
+ <property name="geometry">
+ <rect>
+ <x>440</x>
+ <y>10</y>
+ <width>92</width>
+ <height>28</height>
+ </rect>
+ </property>
+ <property name="editable">
+ <bool>false</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string>Normal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Golden</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Freestyle</string>
+ </property>
+ </item>
+ </widget>
+ </widget>
+ <widget class="QWidget" name="tabSong">
+ <attribute name="title">
+ <string>&Song properties</string>
+ </attribute>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Title</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="txtTitle"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Artist</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="txtArtist"/>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
</layout>
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 10:34:28
|
Module: editor
Branch: master
Commit: 5eed5f5e32d497fb5af214c02e51a949eb56094c
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 12:33:55 2011 +0200
Initial floating/fixed note implementation.
* Notes are floating by default.
* Moving a note makes it non-floating (fixed).
* Floating notes are automatically divided
between fixed ones.
* Note width is not yet taken into account.
---
notegraphwidget.cc | 77 ++++++++++++++++++++++++++++++++++++++++++++++-----
notegraphwidget.hh | 24 +++++++++++++++-
notelabel.cc | 20 +++++++++----
notelabel.hh | 14 +++++++++-
4 files changed, 119 insertions(+), 16 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 87afe1c..23b1ac8 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -12,17 +12,20 @@ NoteGraphWidget::NoteGraphWidget(QWidget *parent)
void NoteGraphWidget::clear()
{
- const QObjectList &childlist = children ();
+ // Clear NoteLabels
+ const QObjectList &childlist = children();
for (QObjectList::const_iterator it = childlist.begin(); it != childlist.end(); ++it) {
- NoteLabel *child = static_cast<NoteLabel*>(*it);
- child->close();
+ NoteLabel *child = dynamic_cast<NoteLabel*>(*it);
+ if (child) child->close();
}
+ m_notes.clear();
}
void NoteGraphWidget::setLyrics(QString lyrics)
{
QTextStream ts(&lyrics, QIODevice::ReadOnly);
- int x = 5, y = 5;
+ const int gap = 10;
+ int x = gap, y = 50;
clear();
while (!ts.atEnd()) {
@@ -30,17 +33,63 @@ void NoteGraphWidget::setLyrics(QString lyrics)
ts >> word;
if (!word.isEmpty()) {
NoteLabel *wordLabel = new NoteLabel(word, this, QPoint(x, y));
- x += wordLabel->width() + 2;
+ x += wordLabel->width() + gap;
}
}
- requiredWidth = x + 3;
+ rebuildNoteList();
+ // Set first and last to non-floating
+ m_notes.front()->disableFloating();
+ m_notes.back()->disableFloating();
+
+ m_requiredWidth = x + gap;
updateWidth();
}
void NoteGraphWidget::updateWidth()
{
- setFixedWidth(requiredWidth);
+ setFixedWidth(m_requiredWidth);
+}
+
+void NoteGraphWidget::updateNotes()
+{
+ FloatingGap gap(0);
+ rebuildNoteList();
+ // Determine gaps between non-floating notes
+ for (NoteLabels::iterator it = m_notes.begin(); it != m_notes.end(); ++it) {
+ NoteLabel *child = *it; //dynamic_cast<NoteLabel*>(*it);
+ if (!child) continue;
+ std::cout << "Child, floating: " << child->isFloating() << std::endl;
+ if (child->isFloating()) {
+ // Add floating note to gap
+ gap.addNote(child);
+ } else {
+ // Fixed note encountered, handle the gap (divide notes evenly into it)
+ std::cout << "Gap end, width: " << gap.width() << ", notes: " << gap.notes.size() << std::endl;
+ if (!gap.isEmpty()) {
+ gap.end = child->x();
+ int step = gap.width() / (gap.notes.size() + 1);
+ int x = gap.begin + step * 0.5;
+ for (NoteLabels::iterator it2 = gap.notes.begin(); it2 != gap.notes.end(); ++it2, x += step) {
+ (*it2)->move(x, (*it2)->y());
+ }
+ }
+ // Start a new gap
+ gap = FloatingGap(child->x() + child->width());
+ std::cout << "New gap from: " << gap.begin << std::endl;
+ }
+ }
+}
+
+void NoteGraphWidget::rebuildNoteList()
+{
+ m_notes.clear();
+ const QObjectList &childlist = children();
+ for (QObjectList::const_iterator it = childlist.begin(); it != childlist.end(); ++it) {
+ NoteLabel *child = dynamic_cast<NoteLabel*>(*it);
+ if (child) m_notes.push_back(child);
+ }
+ m_notes.sort(cmpNoteLabelPtr);
}
void NoteGraphWidget::dragEnterEvent(QDragEnterEvent *event)
@@ -66,6 +115,8 @@ void NoteGraphWidget::dragMoveEvent(QDragMoveEvent *event)
} else {
event->acceptProposedAction();
}
+ // Update note positions on-the-fly
+ updateNotes();
} else {
event->ignore();
}
@@ -81,7 +132,8 @@ void NoteGraphWidget::dropEvent(QDropEvent *event)
QString text;
QPoint offset;
dataStream >> text >> offset;
- new NoteLabel(text, this, event->pos() - offset);
+ new NoteLabel(text, this, event->pos() - offset, false);
+ updateNotes();
if (event->source() == this) {
event->setDropAction(Qt::MoveAction);
@@ -118,6 +170,8 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
drag->setPixmap(*child->pixmap());
drag->setHotSpot(hotSpot);
+ child->disableFloating();
+ child->createPixmap();
child->hide();
if (drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction) == Qt::MoveAction)
@@ -174,3 +228,10 @@ void NoteGraphWidget::mouseDoubleClickEvent(QMouseEvent *event)
event->accept();
}
+
+
+void FloatingGap::addNote(NoteLabel* n)
+{
+ notes.push_back(n);
+ end = n->x();
+}
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index e261e53..bd5ebc5 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -1,6 +1,10 @@
#pragma once
#include <QWidget>
+#include <list>
+
+class NoteLabel;
+typedef std::list<NoteLabel*> NoteLabels;
class NoteGraphWidget: public QWidget
{
@@ -10,6 +14,8 @@ public:
void clear();
void setLyrics(QString lyrics);
void updateWidth();
+ void updateNotes();
+ void rebuildNoteList();
protected:
void dragEnterEvent(QDragEnterEvent *event);
@@ -20,5 +26,21 @@ protected:
void mouseDoubleClickEvent(QMouseEvent * event);
private:
- int requiredWidth;
+ int m_requiredWidth;
+ NoteLabels m_notes;
+};
+
+
+struct FloatingGap
+{
+ FloatingGap(int x): begin(x), end(x) {}
+
+ void addNote(NoteLabel* n);
+ int width() const { return end - begin; }
+ bool isEmpty() const { return notes.empty(); }
+
+ int begin;
+ int end;
+
+ NoteLabels notes;
};
diff --git a/notelabel.cc b/notelabel.cc
index ae132fb..5839880 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -5,8 +5,8 @@ namespace {
static const int text_margin = 12; // Margin of the label texts
}
-NoteLabel::NoteLabel(const QString &text, QWidget *parent, const QPoint &position)
- : QLabel(parent), m_labelText(text)
+NoteLabel::NoteLabel(const QString &text, QWidget *parent, const QPoint &position, bool floating)
+ : QLabel(parent), m_labelText(text), m_floating(floating)
{
createPixmap();
if (!position.isNull())
@@ -23,6 +23,8 @@ void NoteLabel::createPixmap(QSize size)
size.rwidth() += text_margin;
size.rheight() += text_margin;
}
+ // FIXME: Size is fixed
+ size.rwidth() = 50;
QImage image(size.width(), size.height(),
QImage::Format_ARGB32_Premultiplied);
@@ -33,9 +35,15 @@ void NoteLabel::createPixmap(QSize size)
QLinearGradient gradient(0, 0, 0, image.height()-1);
gradient.setColorAt(0.0, Qt::white);
- gradient.setColorAt(0.2, QColor(200, 200, 255));
- gradient.setColorAt(0.8, QColor(200, 200, 255));
- gradient.setColorAt(1.0, QColor(127, 127, 200));
+ if (m_floating) {
+ gradient.setColorAt(0.2, QColor(160, 160, 180));
+ gradient.setColorAt(0.8, QColor(160, 160, 180));
+ gradient.setColorAt(1.0, QColor(100, 100, 120));
+ } else {
+ gradient.setColorAt(0.2, QColor(100, 100, 255));
+ gradient.setColorAt(0.8, QColor(100, 100, 255));
+ gradient.setColorAt(1.0, QColor(100, 100, 200));
+ }
QPainter painter;
painter.begin(&image);
@@ -57,7 +65,7 @@ void NoteLabel::createPixmap(QSize size)
QString NoteLabel::getText() const
{
- return m_labelText;
+ return m_labelText;
}
void NoteLabel::setText(const QString &text)
diff --git a/notelabel.hh b/notelabel.hh
index 1a7d23a..ad48457 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -5,13 +5,25 @@
class NoteLabel: public QLabel
{
public:
- NoteLabel(const QString &text, QWidget *parent, const QPoint &position = QPoint());
+ NoteLabel(const QString &text, QWidget *parent, const QPoint &position = QPoint(), bool floating = true);
+
void createPixmap(QSize size = QSize());
QString getText() const;
void setText(const QString &text);
+ bool isFloating() const { return m_floating; }
+ void disableFloating() { m_floating = false; }
+
void resizeEvent(QResizeEvent *event);
+ bool operator<(const NoteLabel &rhs) const { return x() < rhs.x(); }
+
private:
QString m_labelText;
+ bool m_floating;
};
+
+bool inline cmpNoteLabelPtr(const NoteLabel *lhs, const NoteLabel *rhs)
+{
+ return *lhs < *rhs;
+}
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 10:34:25
|
Module: editor
Branch: master
Commit: d78a6ac65ea3b5a832d0e0061a7ddb12b1421f99
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 10:30:05 2011 +0200
Allow pasting new lyrics from clipboard.
---
editorapp.cc | 18 ++++++++++++++++++
editorapp.hh | 1 +
notegraphwidget.cc | 10 ++++++++++
notegraphwidget.hh | 1 +
4 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index 4b74e6c..521bbc4 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -11,6 +11,24 @@ EditorApp::EditorApp(QWidget *parent): QMainWindow(parent)
"I said, young man, pick yourself off the ground.");
}
+void EditorApp::on_actionLyricsFromClipboard_triggered()
+{
+ const QClipboard *clipboard = QApplication::clipboard();
+ const QMimeData *mimeData = clipboard->mimeData();
+
+ if (mimeData->hasText() && !mimeData->text().isEmpty()) {
+ QString text = mimeData->text();
+ QMessageBox::StandardButton b = QMessageBox::question(this, "Replace lyrics",
+ "Pasting lyrics from clipboard will replace the existing ones. Continue?",
+ QMessageBox::Ok | QMessageBox::Cancel);
+ if (b == QMessageBox::Ok) {
+ ui.noteGraph->setLyrics(text);
+ }
+ } else {
+ QMessageBox::warning(this, "No text to paste", "No suitable data on the clipboard.");
+ }
+}
+
void EditorApp::on_actionAbout_triggered()
{
QMessageBox::about(this, "About",
diff --git a/editorapp.hh b/editorapp.hh
index 81bf334..23ee86e 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -10,6 +10,7 @@ public:
EditorApp(QWidget *parent = 0);
public slots:
+ void on_actionLyricsFromClipboard_triggered();
void on_actionAbout_triggered();
void on_actionExit_triggered();
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 3fe99ea..87afe1c 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -10,11 +10,21 @@ NoteGraphWidget::NoteGraphWidget(QWidget *parent)
setAcceptDrops(true);
}
+void NoteGraphWidget::clear()
+{
+ const QObjectList &childlist = children ();
+ for (QObjectList::const_iterator it = childlist.begin(); it != childlist.end(); ++it) {
+ NoteLabel *child = static_cast<NoteLabel*>(*it);
+ child->close();
+ }
+}
+
void NoteGraphWidget::setLyrics(QString lyrics)
{
QTextStream ts(&lyrics, QIODevice::ReadOnly);
int x = 5, y = 5;
+ clear();
while (!ts.atEnd()) {
QString word;
ts >> word;
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index 38dfbb3..e261e53 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -7,6 +7,7 @@ class NoteGraphWidget: public QWidget
public:
NoteGraphWidget(QWidget *parent = 0);
+ void clear();
void setLyrics(QString lyrics);
void updateWidth();
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 10:34:23
|
Module: editor
Branch: master
Commit: 3ffa0b6a1a9235de8a9b61fcb3b31eccd927d773
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 09:33:21 2011 +0200
No more loading lyrics from a predefined resource file.
---
editor.qrc | 6 +-----
editorapp.cc | 5 +++--
notegraphwidget.cc | 22 ++++++++++------------
notegraphwidget.hh | 1 +
4 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/editor.qrc b/editor.qrc
index b72217d..7646d2b 100644
--- a/editor.qrc
+++ b/editor.qrc
@@ -1,5 +1 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/dictionary">
- <file>words.txt</file>
-</qresource>
-</RCC>
+<RCC/>
diff --git a/editorapp.cc b/editorapp.cc
index b72876a..4b74e6c 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -6,8 +6,9 @@
EditorApp::EditorApp(QWidget *parent): QMainWindow(parent)
{
ui.setupUi(this);
- // Now adjust the NoteGraph's width according to the content
- ui.noteGraph->updateWidth();
+ // FIXME: Should not set any lyrics here
+ ui.noteGraph->setLyrics("Young man, there's no need to feel down. "
+ "I said, young man, pick yourself off the ground.");
}
void EditorApp::on_actionAbout_triggered()
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index b63cd04..3fe99ea 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -7,27 +7,25 @@
NoteGraphWidget::NoteGraphWidget(QWidget *parent)
: QWidget(parent)
{
- QFile dictionaryFile(":/dictionary/words.txt");
- dictionaryFile.open(QFile::ReadOnly);
- QTextStream inputStream(&dictionaryFile);
+ setAcceptDrops(true);
+}
- int x = 5;
- int y = 5;
+void NoteGraphWidget::setLyrics(QString lyrics)
+{
+ QTextStream ts(&lyrics, QIODevice::ReadOnly);
+ int x = 5, y = 5;
- while (!inputStream.atEnd()) {
+ while (!ts.atEnd()) {
QString word;
- inputStream >> word;
+ ts >> word;
if (!word.isEmpty()) {
- NoteLabel *wordLabel = new NoteLabel(word, this);
- wordLabel->move(x, y);
- wordLabel->show();
- wordLabel->setAttribute(Qt::WA_DeleteOnClose);
+ NoteLabel *wordLabel = new NoteLabel(word, this, QPoint(x, y));
x += wordLabel->width() + 2;
}
}
requiredWidth = x + 3;
- setAcceptDrops(true);
+ updateWidth();
}
void NoteGraphWidget::updateWidth()
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index 1f52420..38dfbb3 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -7,6 +7,7 @@ class NoteGraphWidget: public QWidget
public:
NoteGraphWidget(QWidget *parent = 0);
+ void setLyrics(QString lyrics);
void updateWidth();
protected:
|
|
From: Tapio V. <aa...@us...> - 2011-01-07 10:34:20
|
Module: editor
Branch: master
Commit: 23e4d131db0512517340e5df502ffccf060f2afa
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 09:19:58 2011 +0200
Some new menus.
---
editor.ui | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/editor.ui b/editor.ui
index 22cc419..2d71dbe 100644
--- a/editor.ui
+++ b/editor.ui
@@ -100,12 +100,23 @@
<property name="title">
<string>&File</string>
</property>
+ <widget class="QMenu" name="menuExport">
+ <property name="title">
+ <string>Expo&rt</string>
+ </property>
+ <addaction name="actionSingStarXML"/>
+ <addaction name="separator"/>
+ <addaction name="actionLyricsToFile"/>
+ <addaction name="actionLyricsToClipboard"/>
+ </widget>
<addaction name="actionNew"/>
<addaction name="actionOpen"/>
<addaction name="separator"/>
<addaction name="actionSave"/>
<addaction name="actionSaveAs"/>
<addaction name="separator"/>
+ <addaction name="menuExport"/>
+ <addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuEdit">
@@ -123,8 +134,18 @@
</property>
<addaction name="actionAbout"/>
</widget>
+ <widget class="QMenu" name="menuInsert">
+ <property name="title">
+ <string>&Insert</string>
+ </property>
+ <addaction name="actionMusicFile"/>
+ <addaction name="separator"/>
+ <addaction name="actionLyricsFromFile"/>
+ <addaction name="actionLyricsFromClipboard"/>
+ </widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
+ <addaction name="menuInsert"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
@@ -188,6 +209,36 @@
<string>&Preferences</string>
</property>
</action>
+ <action name="actionSingStarXML">
+ <property name="text">
+ <string>&SingStar XML</string>
+ </property>
+ </action>
+ <action name="actionLyricsToFile">
+ <property name="text">
+ <string>Lyrics to fi&le</string>
+ </property>
+ </action>
+ <action name="actionLyricsToClipboard">
+ <property name="text">
+ <string>Lyrics to &clipboard</string>
+ </property>
+ </action>
+ <action name="actionMusicFile">
+ <property name="text">
+ <string>&Music file</string>
+ </property>
+ </action>
+ <action name="actionLyricsFromFile">
+ <property name="text">
+ <string>Lyrics from fi&le</string>
+ </property>
+ </action>
+ <action name="actionLyricsFromClipboard">
+ <property name="text">
+ <string>Lyrics from &clipboard</string>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>
|