Fix up add from database dialog
This commit is contained in:
parent
301bee4ba5
commit
9ee5730b14
@ -781,6 +781,9 @@ class DbDialog(QDialog):
|
|||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
self.ui.searchString.textEdited.connect(self.chars_typed)
|
self.ui.searchString.textEdited.connect(self.chars_typed)
|
||||||
self.ui.matchList.itemDoubleClicked.connect(self.double_click)
|
self.ui.matchList.itemDoubleClicked.connect(self.double_click)
|
||||||
|
self.ui.btnAdd.clicked.connect(self.add_selected)
|
||||||
|
self.ui.btnAddClose.clicked.connect(self.add_selected_and_close)
|
||||||
|
self.ui.btnClose.clicked.connect(self.close)
|
||||||
|
|
||||||
record = Settings.get_int("dbdialog_width")
|
record = Settings.get_int("dbdialog_width")
|
||||||
width = record.f_int or 800
|
width = record.f_int or 800
|
||||||
@ -797,6 +800,18 @@ class DbDialog(QDialog):
|
|||||||
if record.f_int != self.width():
|
if record.f_int != self.width():
|
||||||
record.update({'f_int': self.width()})
|
record.update({'f_int': self.width()})
|
||||||
|
|
||||||
|
def add_selected(self):
|
||||||
|
if not self.ui.matchList.selectedItems():
|
||||||
|
return
|
||||||
|
|
||||||
|
item = self.ui.matchList.currentItem()
|
||||||
|
track_id = item.data(Qt.UserRole)
|
||||||
|
self.add_track(track_id)
|
||||||
|
|
||||||
|
def add_selected_and_close(self):
|
||||||
|
self.add_selected()
|
||||||
|
self.close()
|
||||||
|
|
||||||
def chars_typed(self, s):
|
def chars_typed(self, s):
|
||||||
if len(s) >= 3:
|
if len(s) >= 3:
|
||||||
matches = Tracks.search_titles(s)
|
matches = Tracks.search_titles(s)
|
||||||
@ -813,8 +828,10 @@ class DbDialog(QDialog):
|
|||||||
|
|
||||||
def double_click(self, entry):
|
def double_click(self, entry):
|
||||||
track_id = entry.data(Qt.UserRole)
|
track_id = entry.data(Qt.UserRole)
|
||||||
track = Tracks.track_from_id(track_id)
|
self.add_track(track_id)
|
||||||
|
|
||||||
|
def add_track(self, track_id):
|
||||||
|
track = Tracks.track_from_id(track_id)
|
||||||
# Store in current playlist in database
|
# Store in current playlist in database
|
||||||
db_playlist = Playlists.get_playlist_by_id(self.parent().playlist_id)
|
db_playlist = Playlists.get_playlist_by_id(self.parent().playlist_id)
|
||||||
db_playlist.add_track(track)
|
db_playlist.add_track(track)
|
||||||
|
|||||||
@ -15,71 +15,69 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<widget class="QLabel" name="label">
|
||||||
<item row="0" column="0">
|
<property name="text">
|
||||||
<widget class="QLabel" name="label">
|
<string>Title:</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Title:</string>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLineEdit" name="searchString"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="searchString"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="matchList"/>
|
<widget class="QListWidget" name="matchList"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="orientation">
|
<item>
|
||||||
<enum>Qt::Horizontal</enum>
|
<spacer name="horizontalSpacer">
|
||||||
</property>
|
<property name="orientation">
|
||||||
<property name="standardButtons">
|
<enum>Qt::Horizontal</enum>
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
</property>
|
||||||
</property>
|
<property name="sizeHint" stdset="0">
|
||||||
</widget>
|
<size>
|
||||||
|
<width>88</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnAdd">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Add</string>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnAddClose">
|
||||||
|
<property name="text">
|
||||||
|
<string>A&dd and close</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnClose">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Close</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Dialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Dialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user