Skip to content

Commit

Permalink
refactor: Add Qt wrapper for different version[978001]
Browse files Browse the repository at this point in the history
  • Loading branch information
Greedysky committed Jun 25, 2022
1 parent 1922978 commit 93df07e
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion TTKCommon/ttkqtwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ namespace Qt

/// String skip empty parts
#if TTK_QT_VERSION_CHECK(5,15,0)
# define QtSkipEmptyParts Qt::QtSkipEmptyParts
# define QtSkipEmptyParts Qt::SkipEmptyParts
#else
# define QtSkipEmptyParts QString::SkipEmptyParts
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,18 @@ void MusicItemQueryTableWidget::createSearchedItem(const MusicSearchedItem &song
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
item->setToolTip(songItem.m_singerName + " - " + songItem.m_songName);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 31));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 1, item);

item = new QTableWidgetItem;
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
item->setToolTip(songItem.m_albumName);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(2) - 31));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 2, item);

item = new QTableWidgetItem(songItem.m_duration);
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(count, 3, item);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void MusicLrcDownloadBatchWidget::downloadButtonClicked()
const QString &path = QString("%1/%2%3").arg(prefix, song->name(), LRC_FILE);
if(skip && QFile::exists(path))
{
QtItemSetForegroundColor(it, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(it, QColor(MusicUIObject::MQSSColor02));
it->setText(tr("Skip"));
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ void MusicLrcSearchTableWidget::createSearchedItem(const MusicSearchedItem &song
item = new QTableWidgetItem;
item->setToolTip(songItem.m_songName);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 20));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 1, item);

item = new QTableWidgetItem;
item->setToolTip(songItem.m_singerName);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(2) - 20));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 2, item);

item = new QTableWidgetItem(songItem.m_duration);
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 3, item);

item = new QTableWidgetItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ void MusicSongSearchPopTableWidget::createItems(int index, const QString &name,
QHeaderView *headerview = horizontalHeader();
QTableWidgetItem *item = new QTableWidgetItem(MusicUtils::Widget::elidedText(font(), " " + name, Qt::ElideRight, headerview->sectionSize(0) - 20));
item->setToolTip(name);
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(index, 0, item);

item = new QTableWidgetItem(time);
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
item->setTextAlignment(Qt::AlignCenter);
setItem(index, 1, item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ void MusicCloudManagerTableWidget::createItem(const MusicCloudDataItem &data)
item = new QTableWidgetItem;
item->setToolTip(data.m_dataItem.m_name);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 20));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(row, 1, item);

Expand All @@ -490,14 +490,14 @@ void MusicCloudManagerTableWidget::createItem(const MusicCloudDataItem &data)
item = new QTableWidgetItem;
item->setToolTip(MusicUtils::Number::sizeByte2Label(data.m_dataItem.m_size));
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(3) - 5));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
setItem(row, 3, item);

item = new QTableWidgetItem;
item->setToolTip(data.m_dataItem.m_putTime);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(4) - 5));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
setItem(row, 4, item);
}
Expand Down
8 changes: 4 additions & 4 deletions TTKModule/TTKWidget/musicToolsKits/musiccloudtablewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void MusicCloudDownloadTableWidget::createItem(int index, const MusicSong &recor
item = new QTableWidgetItem;
item->setToolTip(record.name());
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 20));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(index, 1, item);

Expand All @@ -51,7 +51,7 @@ void MusicCloudDownloadTableWidget::createItem(int index, const MusicSong &recor
setItem(index, 2, item);

item = new QTableWidgetItem(record.sizeStr());
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
item->setData(MUSIC_TIME_ROLE, record.addTimeStr());
setItem(index, 3, item);
Expand Down Expand Up @@ -160,12 +160,12 @@ void MusicCloudUploadTableWidget::createItem(int index, const MusicSong &record)
item = new QTableWidgetItem;
item->setToolTip(record.name());
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 20));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(index, 1, item);

item = new QTableWidgetItem(record.sizeStr());
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
item->setData(MUSIC_TIME_ROLE, record.addTimeStr());
setItem(index, 2, item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void MusicDownloadRecordTableWidget::createItem(int index, const MusicSong &reco
item = new QTableWidgetItem;
item->setToolTip(record.name());
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 20));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(index, 1, item);

Expand All @@ -46,7 +46,7 @@ void MusicDownloadRecordTableWidget::createItem(int index, const MusicSong &reco
setItem(index, 2, item);

item = new QTableWidgetItem(record.sizeStr());
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
item->setData(MUSIC_TIME_ROLE, record.addTimeStr());
setItem(index, 3, item);
Expand Down
2 changes: 1 addition & 1 deletion TTKModule/TTKWidget/musicToolsKits/musictoolsetswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void MusicToolSetsWidget::addListWidgetItem()
for(const ToolItem &pair : qAsConst(pairs))
{
QListWidgetItem *item = new QListWidgetItem(QIcon(pair.m_icon), pair.m_name, m_ui->listItemWidget);
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setSizeHint(QSize(80, 90));
m_ui->listItemWidget->addItem(item);
}
Expand Down
8 changes: 4 additions & 4 deletions TTKModule/TTKWidget/musicToolsKits/musicwebdjradiowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,22 @@ void MusicWebDJRadioProgramTableWidget::createProgramItem(const MusicResultsItem
item = new QTableWidgetItem;
item->setToolTip(data.m_name);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(2) - 31));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(index, 2, item);

item = new QTableWidgetItem(data.m_tags);
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
item->setTextAlignment(Qt::AlignCenter);
setItem(index, 3, item);

item = new QTableWidgetItem(tr("Played %1").arg(data.m_playCount));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(index, 4, item);

item = new QTableWidgetItem(data.m_updateTime);
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
item->setTextAlignment(Qt::AlignCenter);
setItem(index, 5, item);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void MusicWebFMRadioWidget::addListWidgetItem()
f.setBold(true);
item->setFont(f);
item->setText(channel.m_name);
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(index, 2, item);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void MusicSoundKMicroSearchTableWidget::createSearchedItem(const MusicSearchedIt
item = new QTableWidgetItem;
item->setToolTip(songItem.m_singerName + " - " + songItem.m_songName);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 15));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 1, item);

item = new QTableWidgetItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,17 @@ void MusicVideoSearchTableWidget::createSearchedItem(const MusicSearchedItem &so
item = new QTableWidgetItem;
item->setToolTip(songItem.m_songName);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 5));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 1, item);

item = new QTableWidgetItem;
item->setToolTip(songItem.m_singerName);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(2) - 5));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 2, item);

item = new QTableWidgetItem(songItem.m_duration);
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 3, item);

item = new QTableWidgetItem;
Expand Down
2 changes: 1 addition & 1 deletion TTKModule/TTKWidget/musicWidgetKits/musicsettingwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void MusicFunctionTableWidget::addFunctionItems(int index, const MusicFunctionIt
setItem(i, 1, item);

item = new QTableWidgetItem(fItem.m_name);
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(i, 2, item);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,23 +186,23 @@ void MusicSongSearchTableWidget::createSearchedItem(const MusicSearchedItem &son
item = new QTableWidgetItem;
item->setToolTip(songItem.m_songName);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 15));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 1, item);

item = new QTableWidgetItem;
item->setToolTip(songItem.m_singerName);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(2) - 30));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 2, item);

item = new QTableWidgetItem;
item->setToolTip(songItem.m_albumName);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(3) - 30));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 3, item);

item = new QTableWidgetItem(songItem.m_duration);
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor02);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor02));
setItem(count, 4, item);

item = new QTableWidgetItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void MusicSongsListPlayedTableWidget::updateSongsFileName(const MusicSongList &s
item = new QTableWidgetItem;
item->setToolTip(songs[i].name());
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 15));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);

setItem(i, 1, item);
Expand All @@ -58,7 +58,7 @@ void MusicSongsListPlayedTableWidget::updateSongsFileName(const MusicSongList &s
setItem(i, 3, item);

item = new QTableWidgetItem(songs[i].playTime());
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(i, 4, item);
}
Expand Down Expand Up @@ -167,15 +167,15 @@ void MusicSongsListPlayedTableWidget::adjustPlayWidgetRow()
item = new QTableWidgetItem;
item->setToolTip(name);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 15));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);

setItem(m_playRowIndex, 1, item);
setItem(m_playRowIndex, 2, new QTableWidgetItem);
setItem(m_playRowIndex, 3, new QTableWidgetItem);

item = new QTableWidgetItem((*m_songs)[m_playRowIndex].playTime());
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(m_playRowIndex, 4, item);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void MusicSongsListTableWidget::updateSongsFileName(const MusicSongList &songs)
setItem(i, 0, item);
item = new QTableWidgetItem;
item->setText(MusicUtils::Widget::elidedText(font(), songs[i].name(), Qt::ElideRight, headerview->sectionSize(1) - 10));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(i, 1, item);

Expand All @@ -104,7 +104,7 @@ void MusicSongsListTableWidget::updateSongsFileName(const MusicSongList &songs)
setItem(i, 4, item);

item = new QTableWidgetItem(songs[i].playTime());
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(i, 5, item);
}
Expand Down Expand Up @@ -234,7 +234,7 @@ void MusicSongsListTableWidget::adjustPlayWidgetRow()
setItem(m_playRowIndex, 0, item);

item = new QTableWidgetItem(MusicUtils::Widget::elidedText(font(), name, Qt::ElideRight, headerview->sectionSize(1) - 10));
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);

setItem(m_playRowIndex, 1, item);
Expand All @@ -243,7 +243,7 @@ void MusicSongsListTableWidget::adjustPlayWidgetRow()
setItem(m_playRowIndex, 4, new QTableWidgetItem);

item = new QTableWidgetItem((*m_songs)[m_playRowIndex].playTime());
QtItemSetForegroundColor(item, MusicUIObject::MQSSColor01);
QtItemSetForegroundColor(item, QColor(MusicUIObject::MQSSColor01));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(m_playRowIndex, 5, item);

Expand Down

0 comments on commit 93df07e

Please sign in to comment.