Skip to content

Commit

Permalink
fix #17664: Add Score should open window to select and add score to t…
Browse files Browse the repository at this point in the history
…he list in Album
  • Loading branch information
lasconic committed Aug 6, 2012
1 parent 8d9f28f commit 5638985
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 74 deletions.
2 changes: 1 addition & 1 deletion mscore/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,7 @@ Shortcut Shortcut::sc[] = {
QT_TRANSLATE_NOOP("action","Page Settings")
),
Shortcut(
STATE_NORMAL,
STATE_DISABLED | STATE_NORMAL,
0,
"album",
Qt::ApplicationShortcut,
Expand Down
58 changes: 19 additions & 39 deletions mscore/album.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,7 @@ AlbumManager::AlbumManager(QWidget* parent)
connect(up, SIGNAL(clicked()), SLOT(upClicked()));
connect(down, SIGNAL(clicked()), SLOT(downClicked()));
connect(remove, SIGNAL(clicked()), SLOT(removeClicked()));
connect(fileDialog, SIGNAL(clicked()), SLOT(fileDialogClicked()));
connect(createNew, SIGNAL(clicked()), SLOT(createNewClicked()));
connect(scoreName, SIGNAL(textChanged(const QString&)), SLOT(scoreNameChanged(const QString&)));
connect(albumName, SIGNAL(textChanged(const QString&)), SLOT(albumNameChanged(const QString&)));
connect(scoreList, SIGNAL(currentRowChanged(int)), SLOT(currentScoreChanged(int)));
connect(scoreList, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(itemChanged(QListWidgetItem*)));
Expand All @@ -425,14 +423,27 @@ AlbumManager::AlbumManager(QWidget* parent)

void AlbumManager::addClicked()
{
QString home = preferences.myScoresPath;
QStringList files = mscore->getOpenScoreNames(
home,
tr("MuseScore Files (*.mscz *.mscx *.msc);;")+
tr("All Files (*)"),
tr("MuseScore: Add Score")
);
if (files.isEmpty())
return;
QString fn = files.front();
if (fn.isEmpty())
return;

AlbumItem* item = new AlbumItem;
item->path = scoreName->text();
item->path = fn;
album->append(item);
QFileInfo fi(item->path);
QFileInfo fi(fn);

QListWidgetItem* li = new QListWidgetItem(fi.baseName(), scoreList);
li->setToolTip(fn);
li->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
scoreName->setText("");
}

//---------------------------------------------------------
Expand Down Expand Up @@ -520,28 +531,6 @@ void AlbumManager::removeClicked()
album->remove(n);
}

//---------------------------------------------------------
// fileDialogClicked
//---------------------------------------------------------

void AlbumManager::fileDialogClicked()
{
QString home = preferences.myScoresPath;
QStringList files = mscore->getOpenScoreNames(
home,
tr("MuseScore Files (*.mscz *.mscx *.msc);;")+
tr("All Files (*)"),
tr("MuseScore: Load Score")
);
if (files.isEmpty())
return;
QString fn = files.front();
if (fn.isEmpty())
return;
scoreName->setText(fn);
add->setEnabled(true);
}

//---------------------------------------------------------
// setAlbum
//---------------------------------------------------------
Expand All @@ -553,14 +542,14 @@ void AlbumManager::setAlbum(Album* a)
delete album;
album = a;
scoreList->clear();
albumName->setText(album->name());
albumName->setText(album->name().isEmpty() ? QWidget::tr("Untitled") : album->name());
foreach(AlbumItem* a, album->scores()) {
QListWidgetItem* li = new QListWidgetItem(a->name, scoreList);
li->setToolTip(a->path);
li->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
}
scoreName->setText("");
add->setEnabled(false);
albumName->setEnabled(true);
add->setEnabled(true);
print->setEnabled(true);
}

Expand All @@ -573,15 +562,6 @@ void AlbumManager::createNewClicked()
setAlbum(new Album);
}

//---------------------------------------------------------
// scoreNameChanged
//---------------------------------------------------------

void AlbumManager::scoreNameChanged(const QString& s)
{
add->setEnabled(!s.isEmpty());
}

//---------------------------------------------------------
// albumNameChanged
//---------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions mscore/album.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ class AlbumManager : public QDialog, public Ui::AlbumManager {
void upClicked();
void downClicked();
void removeClicked();
void fileDialogClicked();
void createNewClicked();
void scoreNameChanged(const QString&);
void albumNameChanged(const QString&);
void currentScoreChanged(int);
void itemChanged(QListWidgetItem*); // score name in list is edited
Expand Down
40 changes: 8 additions & 32 deletions mscore/album.ui
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
</spacer>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="add">
<property name="text">
<string>Add Score</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="remove">
<property name="toolTip">
<string>remove current score</string>
Expand All @@ -60,11 +67,8 @@
</property>
</widget>
</item>
<item row="2" column="0" rowspan="4">
<item row="2" column="0" rowspan="5">
<widget class="QListWidget" name="scoreList">
<property name="toolTip">
<string>score list</string>
</property>
</widget>
</item>
<item row="3" column="1">
Expand All @@ -89,34 +93,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="add">
<property name="text">
<string>Add Score</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="scoreName">
<property name="toolTip">
<string>path to new score you want to add</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="fileDialog">
<property name="toolTip">
<string>open file manager</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
Expand Down

0 comments on commit 5638985

Please sign in to comment.