11 #include <QButtonGroup>
12 #if TTK_QT_VERSION_CHECK(5,0,0)
13 # include <QStandardPaths>
15 # include <QDesktopServices>
25 return v.isEmpty() ? QObject::tr(
"Various Artist") : v;
32 return v.isEmpty() ? QObject::tr(
"Various Album") : v;
39 return v.isEmpty() ? QObject::tr(
"Various Year") : v;
46 return v.isEmpty() ? QObject::tr(
"Various Genre") : v;
56 QHeaderView *headerView = horizontalHeader();
57 headerView->setVisible(
true);
58 headerView->resizeSection(0, 100);
59 headerView->resizeSection(1, 55);
61 setAlternatingRowColors(
true);
62 setFrameShape(QFrame::Box);
63 setTextElideMode(Qt::ElideRight);
67 setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
78 setRowCount(song.count());
81 for(
auto it = song.constBegin(); it != song.constEnd(); ++it, ++index)
83 QTableWidgetItem *item =
new QTableWidgetItem;
84 item->setToolTip(it.key());
85 item->setText(item->toolTip());
87 setItem(index, 0, item);
89 item =
new QTableWidgetItem;
90 item->setToolTip(QString::number(it.value()));
91 item->setText(item->toolTip());
93 setItem(index, 1, item);
100 QHeaderView *headerView = horizontalHeader();
110 setSelectionMode(QAbstractItemView::ExtendedSelection);
113 QHeaderView *headerView = horizontalHeader();
114 headerView->setVisible(
true);
115 headerView->resizeSection(0, 200);
116 headerView->resizeSection(1, 100);
117 headerView->resizeSection(2, 100);
118 headerView->resizeSection(3, 40);
119 headerView->resizeSection(4, 100);
120 headerView->resizeSection(5, 100);
121 headerView->resizeSection(6, 200);
123 setAlternatingRowColors(
true);
124 setFrameShape(QFrame::Box);
125 setTextElideMode(Qt::ElideRight);
128 setHorizontalHeaderLabels({tr(
"Title"), tr(
"Artist"), tr(
"Album"), tr(
"Track"), tr(
"Year"), tr(
"Genre"), tr(
"Path")});
129 setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
143 setRowCount(songs.count());
145 for(
int i = 0; i < songs.count(); ++i)
149 QTableWidgetItem *item =
new QTableWidgetItem;
151 item->setText(item->toolTip());
155 item =
new QTableWidgetItem;
157 item->setText(item->toolTip());
161 item =
new QTableWidgetItem;
163 item->setText(item->toolTip());
167 item =
new QTableWidgetItem;
169 item->setText(item->toolTip());
173 item =
new QTableWidgetItem;
174 item->setToolTip(v.
m_year);
175 item->setText(item->toolTip());
179 item =
new QTableWidgetItem;
181 item->setText(item->toolTip());
185 item =
new QTableWidgetItem;
186 item->setToolTip(v.
m_path);
187 item->setText(item->toolTip());
198 QHeaderView *headerView = horizontalHeader();
213 MusicAbstractSongsListTableWidget::contextMenuEvent(event);
217 menu.addAction(QIcon(
":/contextMenu/btn_play"), tr(
"Play"),
this, SLOT(
playClicked()));
224 menu.addAction(QIcon(
":/contextMenu/btn_local_file"), tr(
"Open File Dir"),
this, SLOT(
openFileDir()))->setEnabled(status);
225 menu.addAction(QIcon(
":/contextMenu/btn_ablum"), tr(
"Ablum"),
this, SLOT(
showAlbumQueryWidget()));
228 menu.exec(QCursor::pos());
238 QVBoxLayout *layout =
new QVBoxLayout(
this);
239 layout->setSpacing(0);
240 layout->setContentsMargins(0, 0, 0, 0);
243 QWidget *mainWidget =
new QWidget(
this);
244 QVBoxLayout *mainLayout =
new QVBoxLayout(mainWidget);
245 mainLayout->setSpacing(0);
246 mainLayout->setContentsMargins(20, 10, 20, 10);
247 mainWidget->setLayout(mainLayout);
248 layout->addWidget(mainWidget);
250 QWidget *topWidget =
new QWidget(mainWidget);
251 mainLayout->addWidget(topWidget);
253 QVBoxLayout *topLayout =
new QVBoxLayout(topWidget);
254 topLayout->setSpacing(0);
255 topLayout->setContentsMargins(0, 0, 0, 10);
256 topWidget->setLayout(topLayout);
258 QWidget *functionWidget =
new QWidget(topWidget);
259 QHBoxLayout *functionWidgetLayout =
new QHBoxLayout(functionWidget);
260 functionWidgetLayout->setContentsMargins(0, 0, 0, 10);
261 functionWidget->setLayout(functionWidgetLayout);
263 QLabel *pLabel =
new QLabel(tr(
"Media Library"), functionWidget);
264 QFont pLabelFont = pLabel->font();
265 pLabelFont.setPixelSize(33);
266 pLabel->setFont(pLabelFont);
268 functionWidgetLayout->addWidget(pLabel);
273 functionWidgetLayout->addStretch(1);
275 QPushButton *refresh =
new QPushButton(tr(
"Refresh"), functionWidget);
276 refresh->setIcon(QIcon(
":/functions/btn_similar_hover"));
277 refresh->setFixedSize(90, 30);
279 refresh->setCursor(QCursor(Qt::PointingHandCursor));
280 functionWidgetLayout->addWidget(refresh);
282 QPushButton *button =
new QPushButton(tr(
"Settings"), functionWidget);
283 button->setIcon(QIcon(
":/functions/btn_setting_hover"));
284 button->setFixedSize(90, 30);
286 button->setCursor(QCursor(Qt::PointingHandCursor));
287 functionWidgetLayout->addWidget(button);
291 topLayout->addWidget(functionWidget);
294 QWidget *tabWidget =
new QWidget(mainWidget);
295 QHBoxLayout *tabWidgetLayout =
new QHBoxLayout(tabWidget);
296 tabWidgetLayout->setSpacing(0);
297 tabWidgetLayout->setContentsMargins(0, 0, 0, 0);
298 tabWidget->setLayout(tabWidgetLayout);
299 mainLayout->addWidget(tabWidget);
307 refresh->setFocusPolicy(Qt::NoFocus);
308 button->setFocusPolicy(Qt::NoFocus);
311 QWidget *centerWidget =
new QWidget(mainWidget);
312 QHBoxLayout *centerWidgetLayout =
new QHBoxLayout(centerWidget);
313 centerWidgetLayout->setSpacing(2);
314 centerWidgetLayout->setContentsMargins(0, 5, 0, 0);
315 centerWidget->setLayout(centerWidgetLayout);
316 mainLayout->addWidget(centerWidget);
329 connect(refresh, SIGNAL(clicked()), SLOT(
refreshItems()));
355 case 0:
m_searchEdit->
editor()->setPlaceholderText(tr(
"Please input search song words"));
break;
356 case 1:
m_searchEdit->
editor()->setPlaceholderText(tr(
"Please input search artist words"));
break;
357 case 2:
m_searchEdit->
editor()->setPlaceholderText(tr(
"Please input search album words"));
break;
358 case 3:
m_searchEdit->
editor()->setPlaceholderText(tr(
"Please input search year words"));
break;
359 case 4:
m_searchEdit->
editor()->setPlaceholderText(tr(
"Please input search genre words"));
break;
387 #if TTK_QT_VERSION_CHECK(5,0,0)
388 path = QStandardPaths::writableLocation(QStandardPaths::MusicLocation) +
TTK_SEPARATOR;
390 path = QDesktopServices::storageLocation(QDesktopServices::MusicLocation) +
TTK_SEPARATOR;
397 m_sizeLabel->setText(tr(
" (Songs Totol: %1)").arg(files.size()));
401 for(
const QString &path :
qAsConst(files))
423 qApp->processEvents();
464 MusicSongInfoItemList data;
465 for(
const int index :
qAsConst(result))
487 QWidget::resizeEvent(event);
508 data = item.m_artist;
509 label = tr(
"Artist");
533 if(!statistic.contains(data))
535 statistic.insert(data, 1);
539 statistic.insert(data, statistic[data] + 1);
TTK_MODULE_EXPORT QString getExistingDirectory(QWidget *parent)
TTK_MODULE_EXPORT QString generateSongName(const QString &title, const QString &artist)
MusicSongInfoItemList m_containerItems
static QString generateYear(const QString &v)
TTK_MODULE_EXPORT void enableBreakPoint(bool enable)
void mappedSearchRow(int pos, int &row) const
static const QString ScrollBarStyle04
#define QtItemSetTextAlignment(p, a)
Item text alignment.
static QString generateAlbum(const QString &v)
TTKSearchItems m_searchResultItems
MusicSearchEdit * editor() const
static const QString ColorStyle01
Color.
The class of the local song item information.
static const QString ColorStyle02
static const QString PushButtonStyle03
The namespace of the process utils.
#define TTK_SIGNLE_SHOT(...)
static QString generateArtist(const QString &v)
TTK_MODULE_EXPORT bool isBreakPointEnabled()
static const QString BackgroundStyle01
Background.
static QString generateGenre(const QString &v)
static const QString BackgroundStyle10
static const QString MenuStyle02
TTK_MODULE_EXPORT QStringList fileListByPath(const QString &dpath, const QStringList &filter={}, bool recursively=true)
The class of the music song info.
The class of the query line edit widget.
TTK_MODULE_EXPORT bool isNetworkUrl(const QString &path)