Minor code cleanup and fixes
This commit is contained in:
parent
0c0a8d70f3
commit
5221f13498
@ -782,9 +782,9 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
|||||||
|
|
||||||
if (!options.contains_play_options()) LoadPlaybackStatus();
|
if (!options.contains_play_options()) LoadPlaybackStatus();
|
||||||
|
|
||||||
qLog(Debug) << "Started";
|
|
||||||
RefreshStyleSheet();
|
RefreshStyleSheet();
|
||||||
|
|
||||||
|
qLog(Debug) << "Started";
|
||||||
initialised_ = true;
|
initialised_ = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -824,7 +824,7 @@ void MainWindow::ReloadSettings() {
|
|||||||
if (enable_tidal)
|
if (enable_tidal)
|
||||||
ui_->tabs->addTab(tidal_search_view_, IconLoader::Load("tidal"), "Tidal");
|
ui_->tabs->addTab(tidal_search_view_, IconLoader::Load("tidal"), "Tidal");
|
||||||
else
|
else
|
||||||
ui_->tabs->delTab("tidal");
|
ui_->tabs->delTab("Tidal");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STREAM_DEEZER
|
#ifdef HAVE_STREAM_DEEZER
|
||||||
@ -834,11 +834,9 @@ void MainWindow::ReloadSettings() {
|
|||||||
if (enable_deezer)
|
if (enable_deezer)
|
||||||
ui_->tabs->addTab(deezer_search_view_, IconLoader::Load("deezer"), "Deezer");
|
ui_->tabs->addTab(deezer_search_view_, IconLoader::Load("deezer"), "Deezer");
|
||||||
else
|
else
|
||||||
ui_->tabs->delTab("deezer");
|
ui_->tabs->delTab("Deezer");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ui_->tabs->loadSettings(kSettingsGroup);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ReloadAllSettings() {
|
void MainWindow::ReloadAllSettings() {
|
||||||
@ -864,6 +862,7 @@ void MainWindow::ReloadAllSettings() {
|
|||||||
void MainWindow::RefreshStyleSheet() {
|
void MainWindow::RefreshStyleSheet() {
|
||||||
setStyleSheet(styleSheet());
|
setStyleSheet(styleSheet());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::MediaStopped() {
|
void MainWindow::MediaStopped() {
|
||||||
|
|
||||||
setWindowTitle("Strawberry Music Player");
|
setWindowTitle("Strawberry Music Player");
|
||||||
@ -1403,10 +1402,6 @@ void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex
|
|||||||
#endif
|
#endif
|
||||||
playlist_open_in_browser_->setVisible(false);
|
playlist_open_in_browser_->setVisible(false);
|
||||||
|
|
||||||
//qLog(Debug) << "selected" << selected;
|
|
||||||
//qLog(Debug) << "in_queue" << in_queue << "not_in_queue" << not_in_queue;
|
|
||||||
//qLog(Debug) << "in_skipped" << in_skipped << "not_in_skipped" << not_in_skipped;
|
|
||||||
|
|
||||||
if (selected < 1) {
|
if (selected < 1) {
|
||||||
playlist_queue_->setVisible(false);
|
playlist_queue_->setVisible(false);
|
||||||
playlist_skip_->setVisible(false);
|
playlist_skip_->setVisible(false);
|
||||||
@ -1530,6 +1525,7 @@ void MainWindow::PlaylistStopAfter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::EditTracks() {
|
void MainWindow::EditTracks() {
|
||||||
|
|
||||||
SongList songs;
|
SongList songs;
|
||||||
PlaylistItemList items;
|
PlaylistItemList items;
|
||||||
|
|
||||||
@ -1548,6 +1544,7 @@ void MainWindow::EditTracks() {
|
|||||||
//EnsureEditTagDialogCreated();
|
//EnsureEditTagDialogCreated();
|
||||||
edit_tag_dialog_->SetSongs(songs, items);
|
edit_tag_dialog_->SetSongs(songs, items);
|
||||||
edit_tag_dialog_->show();
|
edit_tag_dialog_->show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::EditTagDialogAccepted() {
|
void MainWindow::EditTagDialogAccepted() {
|
||||||
@ -1605,6 +1602,7 @@ void MainWindow::SongSaveComplete(TagReaderReply *reply,const QPersistentModelIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::SelectionSetValue() {
|
void MainWindow::SelectionSetValue() {
|
||||||
|
|
||||||
Playlist::Column column = (Playlist::Column)playlist_menu_index_.column();
|
Playlist::Column column = (Playlist::Column)playlist_menu_index_.column();
|
||||||
QVariant column_value =app_->playlist_manager()->current()->data(playlist_menu_index_);
|
QVariant column_value =app_->playlist_manager()->current()->data(playlist_menu_index_);
|
||||||
|
|
||||||
@ -1623,9 +1621,11 @@ void MainWindow::SelectionSetValue() {
|
|||||||
NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)),reply, QPersistentModelIndex(source_index));
|
NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)),reply, QPersistentModelIndex(source_index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::EditValue() {
|
void MainWindow::EditValue() {
|
||||||
|
|
||||||
QModelIndex current = ui_->playlist->view()->currentIndex();
|
QModelIndex current = ui_->playlist->view()->currentIndex();
|
||||||
|
|
||||||
if (!current.isValid()) return;
|
if (!current.isValid()) return;
|
||||||
@ -1668,9 +1668,11 @@ void MainWindow::AddFile() {
|
|||||||
MimeData *data = new MimeData;
|
MimeData *data = new MimeData;
|
||||||
data->setUrls(urls);
|
data->setUrls(urls);
|
||||||
AddToPlaylist(data);
|
AddToPlaylist(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddFolder() {
|
void MainWindow::AddFolder() {
|
||||||
|
|
||||||
// Last used directory
|
// Last used directory
|
||||||
QString directory =settings_.value("add_folder_path", QDir::currentPath()).toString();
|
QString directory =settings_.value("add_folder_path", QDir::currentPath()).toString();
|
||||||
|
|
||||||
@ -1685,6 +1687,7 @@ void MainWindow::AddFolder() {
|
|||||||
MimeData *data = new MimeData;
|
MimeData *data = new MimeData;
|
||||||
data->setUrls(QList<QUrl>() << QUrl::fromLocalFile(QFileInfo(directory).canonicalFilePath()));
|
data->setUrls(QList<QUrl>() << QUrl::fromLocalFile(QFileInfo(directory).canonicalFilePath()));
|
||||||
AddToPlaylist(data);
|
AddToPlaylist(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddCDTracks() {
|
void MainWindow::AddCDTracks() {
|
||||||
@ -2215,7 +2218,7 @@ void MainWindow::CheckFullRescanRevisions() {
|
|||||||
}
|
}
|
||||||
message += "</ul>" + tr("Would you like to run a full rescan right now?");
|
message += "</ul>" + tr("Would you like to run a full rescan right now?");
|
||||||
|
|
||||||
if(QMessageBox::question(this, tr("Collection rescan notice"), message, QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
if (QMessageBox::question(this, tr("Collection rescan notice"), message, QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||||
app_->collection()->FullScan();
|
app_->collection()->FullScan();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ PlaylistView::PlaylistView(QWidget *parent)
|
|||||||
setting_initial_header_layout_(false),
|
setting_initial_header_layout_(false),
|
||||||
upgrading_from_qheaderview_(false),
|
upgrading_from_qheaderview_(false),
|
||||||
read_only_settings_(true),
|
read_only_settings_(true),
|
||||||
upgrading_from_version_(-1),
|
header_loaded_(false),
|
||||||
background_initialized_(false),
|
background_initialized_(false),
|
||||||
background_image_type_(Default),
|
background_image_type_(Default),
|
||||||
blur_radius_(kDefaultBlurRadius),
|
blur_radius_(kDefaultBlurRadius),
|
||||||
@ -198,6 +198,11 @@ PlaylistView::PlaylistView(QWidget *parent)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlaylistView::~PlaylistView() {
|
||||||
|
SaveGeometry();
|
||||||
|
delete style_;
|
||||||
|
}
|
||||||
|
|
||||||
void PlaylistView::SetApplication(Application *app) {
|
void PlaylistView::SetApplication(Application *app) {
|
||||||
|
|
||||||
Q_ASSERT(app);
|
Q_ASSERT(app);
|
||||||
@ -248,7 +253,7 @@ void PlaylistView::SetPlaylist(Playlist *playlist) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
playlist_ = playlist;
|
playlist_ = playlist;
|
||||||
LoadGeometry();
|
if (!header_loaded_) LoadGeometry();
|
||||||
ReloadSettings();
|
ReloadSettings();
|
||||||
setFocus();
|
setFocus();
|
||||||
read_only_settings_ = false;
|
read_only_settings_ = false;
|
||||||
@ -265,7 +270,7 @@ void PlaylistView::setModel(QAbstractItemModel *m) {
|
|||||||
|
|
||||||
if (model()) {
|
if (model()) {
|
||||||
disconnect(model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(InvalidateCachedCurrentPixmap()));
|
disconnect(model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(InvalidateCachedCurrentPixmap()));
|
||||||
//disconnect(model(), SIGNAL(layoutAboutToBeChanged()), this, SLOT(RatingHoverOut()));
|
|
||||||
// When changing the model, always invalidate the current pixmap.
|
// When changing the model, always invalidate the current pixmap.
|
||||||
// If a remote client uses "stop after", without invaliding the stop mark would not appear.
|
// If a remote client uses "stop after", without invaliding the stop mark would not appear.
|
||||||
InvalidateCachedCurrentPixmap();
|
InvalidateCachedCurrentPixmap();
|
||||||
@ -280,6 +285,7 @@ void PlaylistView::setModel(QAbstractItemModel *m) {
|
|||||||
void PlaylistView::LoadGeometry() {
|
void PlaylistView::LoadGeometry() {
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
header_loaded_ = true;
|
||||||
settings.beginGroup(Playlist::kSettingsGroup);
|
settings.beginGroup(Playlist::kSettingsGroup);
|
||||||
|
|
||||||
QByteArray state(settings.value("state").toByteArray());
|
QByteArray state(settings.value("state").toByteArray());
|
||||||
|
@ -97,6 +97,7 @@ class PlaylistView : public QTreeView {
|
|||||||
};
|
};
|
||||||
|
|
||||||
PlaylistView(QWidget *parent = nullptr);
|
PlaylistView(QWidget *parent = nullptr);
|
||||||
|
~PlaylistView();
|
||||||
|
|
||||||
static const int kStateVersion;
|
static const int kStateVersion;
|
||||||
// Constants for settings: are persistent, values should not be changed
|
// Constants for settings: are persistent, values should not be changed
|
||||||
@ -216,7 +217,7 @@ class PlaylistView : public QTreeView {
|
|||||||
bool setting_initial_header_layout_;
|
bool setting_initial_header_layout_;
|
||||||
bool upgrading_from_qheaderview_;
|
bool upgrading_from_qheaderview_;
|
||||||
bool read_only_settings_;
|
bool read_only_settings_;
|
||||||
int upgrading_from_version_;
|
bool header_loaded_;
|
||||||
|
|
||||||
bool background_initialized_;
|
bool background_initialized_;
|
||||||
BackgroundImageType background_image_type_;
|
BackgroundImageType background_image_type_;
|
||||||
|
@ -56,7 +56,7 @@ class FancyTabBar: public QTabBar {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int mouseHoverTabIndex = -1;
|
int mouseHoverTabIndex = -1;
|
||||||
QMap<QWidget*,QString> labelCache;
|
QMap<QWidget*, QString> labelCache;
|
||||||
QMap<int, QWidget*> spacers;
|
QMap<int, QWidget*> spacers;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -124,14 +124,14 @@ class FancyTabBar: public QTabBar {
|
|||||||
verticalTextTabs = true;
|
verticalTextTabs = true;
|
||||||
|
|
||||||
// if LargeSidebar, restore spacers
|
// if LargeSidebar, restore spacers
|
||||||
if (spacers.count() > 0 && tabWidget->mode() == FancyTabWidget::Mode_LargeSidebar) {
|
if (tabWidget->mode() == FancyTabWidget::Mode_LargeSidebar && spacers.count() > 0) {
|
||||||
for (int index : spacers.keys()) {
|
for (int index : spacers.keys()) {
|
||||||
tabWidget->insertTab(index, spacers[index], QIcon(), QString());
|
tabWidget->insertTab(index, spacers[index], QIcon(), QString());
|
||||||
tabWidget->setTabEnabled(index, false);
|
tabWidget->setTabEnabled(index, false);
|
||||||
}
|
}
|
||||||
spacers.clear();
|
spacers.clear();
|
||||||
}
|
}
|
||||||
if (tabWidget->mode() != FancyTabWidget::Mode_LargeSidebar) {
|
else if (tabWidget->mode() != FancyTabWidget::Mode_LargeSidebar) {
|
||||||
// traverse in the opposite order to save indices of spacers
|
// traverse in the opposite order to save indices of spacers
|
||||||
for (int i = count() - 1; i >= 0; --i) {
|
for (int i = count() - 1; i >= 0; --i) {
|
||||||
// spacers are disabled tabs
|
// spacers are disabled tabs
|
||||||
@ -285,7 +285,7 @@ class FancyTabBar: public QTabBar {
|
|||||||
// Spacers are just disabled pages
|
// Spacers are just disabled pages
|
||||||
void FancyTabWidget::addSpacer() {
|
void FancyTabWidget::addSpacer() {
|
||||||
|
|
||||||
QWidget *spacer = new QWidget();
|
QWidget *spacer = new QWidget(this);
|
||||||
const int index = addTab(spacer, QIcon(), QString());
|
const int index = addTab(spacer, QIcon(), QString());
|
||||||
setTabEnabled(index, false);
|
setTabEnabled(index, false);
|
||||||
|
|
||||||
@ -323,6 +323,7 @@ FancyTabWidget::FancyTabWidget(QWidget* parent) : QTabWidget(parent),
|
|||||||
{
|
{
|
||||||
|
|
||||||
FancyTabBar *tabBar = new FancyTabBar(this);
|
FancyTabBar *tabBar = new FancyTabBar(this);
|
||||||
|
tabBar->setExpanding(0);
|
||||||
|
|
||||||
setTabBar(tabBar);
|
setTabBar(tabBar);
|
||||||
setTabPosition(QTabWidget::West);
|
setTabPosition(QTabWidget::West);
|
||||||
@ -340,10 +341,9 @@ void FancyTabWidget::loadSettings(const char *kSettingsGroup) {
|
|||||||
for (int i = 0 ; i < count() ; i++) {
|
for (int i = 0 ; i < count() ; i++) {
|
||||||
QString k = "tab_" + tabBar()->tabData(i).toString().toLower();
|
QString k = "tab_" + tabBar()->tabData(i).toString().toLower();
|
||||||
int index = settings.value(k, i).toInt();
|
int index = settings.value(k, i).toInt();
|
||||||
if (index >= 0)
|
if (index >= 0) {
|
||||||
tabBar()->moveTab(i, index);
|
tabBar()->moveTab(i, index);
|
||||||
else
|
}
|
||||||
removeTab(i); // Does not delete page
|
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
@ -372,23 +372,23 @@ int FancyTabWidget::addTab(QWidget *widget, const QIcon &icon, const QString &la
|
|||||||
return insertTab(count(), widget, icon, label);
|
return insertTab(count(), widget, icon, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FancyTabWidget::insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label) {
|
int FancyTabWidget::insertTab(int index, QWidget *widget_view, const QIcon &icon, const QString &label) {
|
||||||
|
|
||||||
QWidget *page(nullptr);
|
QWidget *page(nullptr);
|
||||||
if (tabs_.contains(label)) page = tabs_.value(label);
|
if (tabs_.contains(label)) page = tabs_.value(label);
|
||||||
else {
|
else {
|
||||||
page = new QWidget();
|
page = new QWidget(this);
|
||||||
// In order to achieve the same effect as the "Bottom Widget" of the old Nokia based FancyTabWidget a VBoxLayout is used on each page
|
// In order to achieve the same effect as the "Bottom Widget" of the old Nokia based FancyTabWidget a VBoxLayout is used on each page
|
||||||
QVBoxLayout *layout = new QVBoxLayout();
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
layout->addWidget(widget);
|
layout->addWidget(widget_view);
|
||||||
page->setLayout(layout);
|
page->setLayout(layout);
|
||||||
tabs_.insert(label, page);
|
tabs_.insert(label, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0 ; i < count() ; i++) {
|
for (int i = 0 ; i < count() ; i++) {
|
||||||
QString l = tabBar()->tabData(i).toString().toLower();
|
QString l = tabBar()->tabData(i).toString();
|
||||||
if (l == label) return i;
|
if (l == label) return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,8 +401,11 @@ int FancyTabWidget::insertTab(int index, QWidget *widget, const QIcon &icon, con
|
|||||||
void FancyTabWidget::delTab(const QString &label) {
|
void FancyTabWidget::delTab(const QString &label) {
|
||||||
|
|
||||||
for (int i = 0 ; i < count() ; i++) {
|
for (int i = 0 ; i < count() ; i++) {
|
||||||
QString l = tabBar()->tabData(i).toString().toLower();
|
QString l = tabBar()->tabData(i).toString();
|
||||||
if (l == label) QTabWidget::removeTab(i);
|
if (l == label) {
|
||||||
|
removeTab(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -423,7 +426,7 @@ void FancyTabWidget::paintEvent(QPaintEvent *pe) {
|
|||||||
p.fillRect(backgroundRect, baseColor);
|
p.fillRect(backgroundRect, baseColor);
|
||||||
|
|
||||||
// Horizontal gradient over the sidebar from transparent to dark
|
// Horizontal gradient over the sidebar from transparent to dark
|
||||||
Utils::StyleHelper::verticalGradient(&p, backgroundRect, backgroundRect,false);
|
Utils::StyleHelper::verticalGradient(&p, backgroundRect, backgroundRect, false);
|
||||||
|
|
||||||
// Draw the translucent png graphics over the gradient fill
|
// Draw the translucent png graphics over the gradient fill
|
||||||
{
|
{
|
||||||
@ -491,7 +494,6 @@ void FancyTabWidget::addMenuItem(QSignalMapper* mapper, QActionGroup* group, con
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FancyTabWidget::contextMenuEvent(QContextMenuEvent* e) {
|
void FancyTabWidget::contextMenuEvent(QContextMenuEvent* e) {
|
||||||
|
|
||||||
if (!menu_) {
|
if (!menu_) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user