Connection syntax migration (#637)
This commit is contained in:
@@ -43,9 +43,9 @@ AutoExpandingTreeView::AutoExpandingTreeView(QWidget *parent)
|
||||
setExpandsOnDoubleClick(true);
|
||||
setAnimated(true);
|
||||
|
||||
connect(this, SIGNAL(expanded(QModelIndex)), SLOT(ItemExpanded(QModelIndex)));
|
||||
connect(this, SIGNAL(clicked(QModelIndex)), SLOT(ItemClicked(QModelIndex)));
|
||||
connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(ItemDoubleClicked(QModelIndex)));
|
||||
QObject::connect(this, &AutoExpandingTreeView::expanded, this, &AutoExpandingTreeView::ItemExpanded);
|
||||
QObject::connect(this, &AutoExpandingTreeView::clicked, this, &AutoExpandingTreeView::ItemClicked);
|
||||
QObject::connect(this, &AutoExpandingTreeView::doubleClicked, this, &AutoExpandingTreeView::ItemDoubleClicked);
|
||||
|
||||
}
|
||||
|
||||
@@ -54,11 +54,11 @@ void AutoExpandingTreeView::reset() {
|
||||
|
||||
// Expand nodes in the tree until we have about 50 rows visible in the view
|
||||
if (auto_open_ && expand_on_reset_) {
|
||||
RecursivelyExpand(rootIndex());
|
||||
RecursivelyExpandSlot(rootIndex());
|
||||
}
|
||||
}
|
||||
|
||||
void AutoExpandingTreeView::RecursivelyExpand(const QModelIndex &idx) {
|
||||
void AutoExpandingTreeView::RecursivelyExpandSlot(const QModelIndex &idx) {
|
||||
int rows = model()->rowCount(idx);
|
||||
RecursivelyExpand(idx, &rows);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class AutoExpandingTreeView : public QTreeView {
|
||||
void SetAddOnDoubleClick(bool v) { add_on_double_click_ = v; }
|
||||
|
||||
public slots:
|
||||
void RecursivelyExpand(const QModelIndex &idx);
|
||||
void RecursivelyExpandSlot(const QModelIndex &idx);
|
||||
void UpAndFocus();
|
||||
void DownAndFocus();
|
||||
|
||||
@@ -82,4 +82,3 @@ class AutoExpandingTreeView : public QTreeView {
|
||||
};
|
||||
|
||||
#endif // AUTOEXPANDINGTREEVIEW_H
|
||||
|
||||
|
||||
@@ -58,4 +58,3 @@ class BusyIndicator : public QWidget {
|
||||
};
|
||||
|
||||
#endif // BUSYINDICATOR_H
|
||||
|
||||
|
||||
@@ -459,7 +459,7 @@ FancyTabWidget::FancyTabWidget(QWidget *parent) : QTabWidget(parent),
|
||||
setStyle(style_);
|
||||
}
|
||||
|
||||
connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
|
||||
QObject::connect(tabBar, &FancyTabBar::currentChanged, this, &FancyTabWidget::currentTabChanged);
|
||||
|
||||
}
|
||||
|
||||
@@ -685,7 +685,7 @@ void FancyTabWidget::SetMode(FancyTabWidget::Mode mode) {
|
||||
updateGeometry();
|
||||
|
||||
// There appears to be a bug in QTabBar which causes tabSizeHint to be ignored thus the need for this second shot repaint
|
||||
QTimer::singleShot(1, this, SLOT(tabBarUpdateGeometry()));
|
||||
QTimer::singleShot(1, this, &FancyTabWidget::tabBarUpdateGeometry);
|
||||
|
||||
emit ModeChanged(mode);
|
||||
|
||||
@@ -695,7 +695,7 @@ void FancyTabWidget::addMenuItem(QActionGroup* group, const QString& text, Mode
|
||||
|
||||
QAction* action = group->addAction(text);
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered, [this, mode]() { SetMode(mode); } );
|
||||
QObject::connect(action, &QAction::triggered, [this, mode]() { SetMode(mode); } );
|
||||
|
||||
if (mode == mode_) action->setChecked(true);
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FAVORITEWIDGET_H
|
||||
#define FAVORITEWIDGET_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QObject>
|
||||
@@ -58,3 +61,5 @@ class FavoriteWidget : public QWidget {
|
||||
QPixmap off_;
|
||||
QRect rect_;
|
||||
};
|
||||
|
||||
#endif // FAVORITEWIDGET_H
|
||||
|
||||
@@ -58,8 +58,7 @@ FileView::FileView(QWidget *parent)
|
||||
model_(nullptr),
|
||||
undo_stack_(new QUndoStack(this)),
|
||||
task_manager_(nullptr),
|
||||
storage_(new FilesystemMusicStorage("/"))
|
||||
{
|
||||
storage_(new FilesystemMusicStorage("/")) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
|
||||
@@ -69,23 +68,23 @@ FileView::FileView(QWidget *parent)
|
||||
ui_->home->setIcon(IconLoader::Load("go-home"));
|
||||
ui_->up->setIcon(IconLoader::Load("go-up"));
|
||||
|
||||
connect(ui_->back, SIGNAL(clicked()), undo_stack_, SLOT(undo()));
|
||||
connect(ui_->forward, SIGNAL(clicked()), undo_stack_, SLOT(redo()));
|
||||
connect(ui_->home, SIGNAL(clicked()), SLOT(FileHome()));
|
||||
connect(ui_->up, SIGNAL(clicked()), SLOT(FileUp()));
|
||||
connect(ui_->path, SIGNAL(textChanged(QString)), SLOT(ChangeFilePath(QString)));
|
||||
QObject::connect(ui_->back, &QToolButton::clicked, undo_stack_, &QUndoStack::undo);
|
||||
QObject::connect(ui_->forward, &QToolButton::clicked, undo_stack_, &QUndoStack::redo);
|
||||
QObject::connect(ui_->home, &QToolButton::clicked, this, &FileView::FileHome);
|
||||
QObject::connect(ui_->up, &QToolButton::clicked, this, &FileView::FileUp);
|
||||
QObject::connect(ui_->path, &QLineEdit::textChanged, this, &FileView::ChangeFilePath);
|
||||
|
||||
connect(undo_stack_, SIGNAL(canUndoChanged(bool)), ui_->back, SLOT(setEnabled(bool)));
|
||||
connect(undo_stack_, SIGNAL(canRedoChanged(bool)), ui_->forward, SLOT(setEnabled(bool)));
|
||||
QObject::connect(undo_stack_, &QUndoStack::canUndoChanged, ui_->back, &FileView::setEnabled);
|
||||
QObject::connect(undo_stack_, &QUndoStack::canRedoChanged, ui_->forward, &FileView::setEnabled);
|
||||
|
||||
connect(ui_->list, SIGNAL(activated(QModelIndex)), SLOT(ItemActivated(QModelIndex)));
|
||||
connect(ui_->list, SIGNAL(doubleClicked(QModelIndex)), SLOT(ItemDoubleClick(QModelIndex)));
|
||||
connect(ui_->list, SIGNAL(AddToPlaylist(QMimeData*)), SIGNAL(AddToPlaylist(QMimeData*)));
|
||||
connect(ui_->list, SIGNAL(CopyToCollection(QList<QUrl>)), SIGNAL(CopyToCollection(QList<QUrl>)));
|
||||
connect(ui_->list, SIGNAL(MoveToCollection(QList<QUrl>)), SIGNAL(MoveToCollection(QList<QUrl>)));
|
||||
connect(ui_->list, SIGNAL(CopyToDevice(QList<QUrl>)), SIGNAL(CopyToDevice(QList<QUrl>)));
|
||||
connect(ui_->list, SIGNAL(Delete(QStringList)), SLOT(Delete(QStringList)));
|
||||
connect(ui_->list, SIGNAL(EditTags(QList<QUrl>)), SIGNAL(EditTags(QList<QUrl>)));
|
||||
QObject::connect(ui_->list, &FileViewList::activated, this, &FileView::ItemActivated);
|
||||
QObject::connect(ui_->list, &FileViewList::doubleClicked, this, &FileView::ItemDoubleClick);
|
||||
QObject::connect(ui_->list, &FileViewList::AddToPlaylist, this, &FileView::AddToPlaylist);
|
||||
QObject::connect(ui_->list, &FileViewList::CopyToCollection, this, &FileView::CopyToCollection);
|
||||
QObject::connect(ui_->list, &FileViewList::MoveToCollection, this, &FileView::MoveToCollection);
|
||||
QObject::connect(ui_->list, &FileViewList::CopyToDevice, this, &FileView::CopyToDevice);
|
||||
QObject::connect(ui_->list, &FileViewList::Delete, this, &FileView::Delete);
|
||||
QObject::connect(ui_->list, &FileViewList::EditTags, this, &FileView::EditTags);
|
||||
|
||||
QString filter(FileView::kFileFilter);
|
||||
filter_list_ << filter.split(" ");
|
||||
@@ -238,7 +237,7 @@ void FileView::Delete(const QStringList &filenames) {
|
||||
#endif
|
||||
|
||||
DeleteFiles *delete_files = new DeleteFiles(task_manager_, storage_, use_trash);
|
||||
connect(delete_files, SIGNAL(Finished(SongList)), SLOT(DeleteFinished(SongList)));
|
||||
QObject::connect(delete_files, &DeleteFiles::Finished, this, &FileView::DeleteFinished);
|
||||
delete_files->Start(filenames);
|
||||
|
||||
}
|
||||
|
||||
@@ -65,13 +65,13 @@ class FileView : public QWidget {
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
signals:
|
||||
void PathChanged(const QString &path);
|
||||
void PathChanged(QString path);
|
||||
|
||||
void AddToPlaylist(QMimeData *data);
|
||||
void CopyToCollection(const QList<QUrl> &urls);
|
||||
void MoveToCollection(const QList<QUrl> &urls);
|
||||
void CopyToDevice(const QList<QUrl> &urls);
|
||||
void EditTags(const QList<QUrl> &urls);
|
||||
void CopyToCollection(QList<QUrl> urls);
|
||||
void MoveToCollection(QList<QUrl> urls);
|
||||
void CopyToDevice(QList<QUrl> urls);
|
||||
void EditTags(QList<QUrl> urls);
|
||||
|
||||
private slots:
|
||||
void FileUp();
|
||||
|
||||
@@ -38,21 +38,20 @@
|
||||
|
||||
FileViewList::FileViewList(QWidget *parent)
|
||||
: QListView(parent),
|
||||
menu_(new QMenu(this))
|
||||
{
|
||||
menu_(new QMenu(this)) {
|
||||
|
||||
menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, SLOT(AddToPlaylistSlot()));
|
||||
menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, SLOT(LoadSlot()));
|
||||
menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, SLOT(OpenInNewPlaylistSlot()));
|
||||
menu_->addAction(IconLoader::Load("media-playback-start"), tr("Append to current playlist"), this, &FileViewList::AddToPlaylistSlot);
|
||||
menu_->addAction(IconLoader::Load("media-playback-start"), tr("Replace current playlist"), this, &FileViewList::LoadSlot);
|
||||
menu_->addAction(IconLoader::Load("document-new"), tr("Open in new playlist"), this, &FileViewList::OpenInNewPlaylistSlot);
|
||||
menu_->addSeparator();
|
||||
menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy to collection..."), this, SLOT(CopyToCollectionSlot()));
|
||||
menu_->addAction(IconLoader::Load("go-jump"), tr("Move to collection..."), this, SLOT(MoveToCollectionSlot()));
|
||||
menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, SLOT(CopyToDeviceSlot()));
|
||||
menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."), this, SLOT(DeleteSlot()));
|
||||
menu_->addAction(IconLoader::Load("edit-copy"), tr("Copy to collection..."), this, &FileViewList::CopyToCollectionSlot);
|
||||
menu_->addAction(IconLoader::Load("go-jump"), tr("Move to collection..."), this, &FileViewList::MoveToCollectionSlot);
|
||||
menu_->addAction(IconLoader::Load("device"), tr("Copy to device..."), this, &FileViewList::CopyToDeviceSlot);
|
||||
menu_->addAction(IconLoader::Load("edit-delete"), tr("Delete from disk..."), this, &FileViewList::DeleteSlot);
|
||||
|
||||
menu_->addSeparator();
|
||||
menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit track information..."), this, SLOT(EditTagsSlot()));
|
||||
menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, SLOT(ShowInBrowser()));
|
||||
menu_->addAction(IconLoader::Load("edit-rename"), tr("Edit track information..."), this, &FileViewList::EditTagsSlot);
|
||||
menu_->addAction(IconLoader::Load("document-open-folder"), tr("Show in file browser..."), this, &FileViewList::ShowInBrowser);
|
||||
|
||||
setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
|
||||
|
||||
@@ -49,11 +49,11 @@ class FileViewList : public QListView {
|
||||
|
||||
signals:
|
||||
void AddToPlaylist(QMimeData *data);
|
||||
void CopyToCollection(const QList<QUrl>& urls);
|
||||
void MoveToCollection(const QList<QUrl>& urls);
|
||||
void CopyToDevice(const QList<QUrl>& urls);
|
||||
void Delete(const QStringList& filenames);
|
||||
void EditTags(const QList<QUrl>& urls);
|
||||
void CopyToCollection(QList<QUrl> urls);
|
||||
void MoveToCollection(QList<QUrl> urls);
|
||||
void CopyToDevice(QList<QUrl> urls);
|
||||
void Delete(QStringList filenames);
|
||||
void EditTags(QList<QUrl> urls);
|
||||
void Back();
|
||||
void Forward();
|
||||
|
||||
@@ -81,4 +81,3 @@ class FileViewList : public QListView {
|
||||
};
|
||||
|
||||
#endif // FILEVIEWLIST_H
|
||||
|
||||
|
||||
@@ -72,20 +72,22 @@ GroupedIconView::GroupedIconView(QWidget *parent)
|
||||
proxy_model_->AddSortSpec(Role_Group);
|
||||
proxy_model_->setDynamicSortFilter(true);
|
||||
|
||||
connect(proxy_model_, SIGNAL(modelReset()), SLOT(LayoutItems()));
|
||||
QObject::connect(proxy_model_, &MultiSortFilterProxy::modelReset, this, &GroupedIconView::LayoutItems);
|
||||
|
||||
}
|
||||
|
||||
void GroupedIconView::AddSortSpec(int role, Qt::SortOrder order) {
|
||||
void GroupedIconView::AddSortSpec(const int role, const Qt::SortOrder order) {
|
||||
proxy_model_->AddSortSpec(role, order);
|
||||
}
|
||||
|
||||
void GroupedIconView::setModel(QAbstractItemModel *model) {
|
||||
|
||||
proxy_model_->setSourceModel(model);
|
||||
proxy_model_->sort(0);
|
||||
|
||||
QListView::setModel(proxy_model_);
|
||||
LayoutItems();
|
||||
|
||||
}
|
||||
|
||||
int GroupedIconView::header_height() const {
|
||||
@@ -152,9 +154,9 @@ void GroupedIconView::LayoutItems() {
|
||||
headers_.clear();
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
const QModelIndex index(model()->index(i, 0));
|
||||
const QString group = index.data(Role_Group).toString();
|
||||
const QSize size(rectForIndex(index).size());
|
||||
const QModelIndex idx(model()->index(i, 0));
|
||||
const QString group = idx.data(Role_Group).toString();
|
||||
const QSize size(rectForIndex(idx).size());
|
||||
|
||||
// Is this the first item in a new group?
|
||||
if (group != last_group) {
|
||||
@@ -209,10 +211,12 @@ void GroupedIconView::LayoutItems() {
|
||||
update();
|
||||
}
|
||||
|
||||
QRect GroupedIconView::visualRect(const QModelIndex &index) const {
|
||||
if (index.row() < 0 || index.row() >= visual_rects_.count())
|
||||
QRect GroupedIconView::visualRect(const QModelIndex &idx) const {
|
||||
|
||||
if (idx.row() < 0 || idx.row() >= visual_rects_.count())
|
||||
return QRect();
|
||||
return visual_rects_[index.row()].translated(-horizontalOffset(), -verticalOffset());
|
||||
return visual_rects_[idx.row()].translated(-horizontalOffset(), -verticalOffset());
|
||||
|
||||
}
|
||||
|
||||
QModelIndex GroupedIconView::indexAt(const QPoint &p) const {
|
||||
@@ -315,8 +319,8 @@ void GroupedIconView::setSelection(const QRect &rect, QItemSelectionModel::Selec
|
||||
QVector<QModelIndex> indexes(IntersectingItems(rect.translated(horizontalOffset(), verticalOffset())));
|
||||
QItemSelection selection;
|
||||
|
||||
for (const QModelIndex &index : indexes) {
|
||||
selection << QItemSelectionRange(index);
|
||||
for (const QModelIndex &idx : indexes) {
|
||||
selection << QItemSelectionRange(idx);
|
||||
}
|
||||
|
||||
selectionModel()->select(selection, command);
|
||||
@@ -336,14 +340,17 @@ QVector<QModelIndex> GroupedIconView::IntersectingItems(const QRect &rect) const
|
||||
}
|
||||
|
||||
QRegion GroupedIconView::visualRegionForSelection(const QItemSelection &selection) const {
|
||||
|
||||
QRegion ret;
|
||||
for (const QModelIndex &index : selection.indexes()) {
|
||||
ret += visual_rects_[index.row()];
|
||||
for (const QModelIndex &idx : selection.indexes()) {
|
||||
ret += visual_rects_[idx.row()];
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
QModelIndex GroupedIconView::moveCursor(CursorAction action, Qt::KeyboardModifiers) {
|
||||
|
||||
if (model()->rowCount() == 0) {
|
||||
return QModelIndex();
|
||||
}
|
||||
@@ -367,9 +374,11 @@ QModelIndex GroupedIconView::moveCursor(CursorAction action, Qt::KeyboardModifie
|
||||
}
|
||||
|
||||
return model()->index(qBound(0, ret, model()->rowCount()), 0);
|
||||
|
||||
}
|
||||
|
||||
int GroupedIconView::IndexAboveOrBelow(int index, int d) const {
|
||||
int GroupedIconView::IndexAboveOrBelow(int index, const int d) const {
|
||||
|
||||
const QRect orig_rect(visual_rects_[index]);
|
||||
|
||||
while (index >= 0 && index < visual_rects_.count()) {
|
||||
@@ -384,4 +393,5 @@ int GroupedIconView::IndexAboveOrBelow(int index, int d) const {
|
||||
}
|
||||
|
||||
return index;
|
||||
|
||||
}
|
||||
|
||||
@@ -65,16 +65,16 @@ class GroupedIconView : public QListView {
|
||||
Role_Group = 1158300,
|
||||
};
|
||||
|
||||
void AddSortSpec(int role, Qt::SortOrder order = Qt::AscendingOrder);
|
||||
void AddSortSpec(const int role, const Qt::SortOrder order = Qt::AscendingOrder);
|
||||
|
||||
int header_spacing() const { return header_spacing_; }
|
||||
int header_indent() const { return header_indent_; }
|
||||
int item_indent() const { return item_indent_; }
|
||||
const QString &header_text() const { return header_text_;}
|
||||
|
||||
void set_header_spacing(int value) { header_spacing_ = value; }
|
||||
void set_header_indent(int value) { header_indent_ = value; }
|
||||
void set_item_indent(int value) { item_indent_ = value; }
|
||||
void set_header_spacing(const int value) { header_spacing_ = value; }
|
||||
void set_header_indent(const int value) { header_indent_ = value; }
|
||||
void set_item_indent(const int value) { item_indent_ = value; }
|
||||
void set_header_text(const QString &value) { header_text_ = value; }
|
||||
|
||||
// QAbstractItemView
|
||||
@@ -95,7 +95,7 @@ class GroupedIconView : public QListView {
|
||||
QModelIndex indexAt(const QPoint &p) const override;
|
||||
void rowsInserted(const QModelIndex &parent, int start, int end) override;
|
||||
void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override;
|
||||
QRect visualRect(const QModelIndex &index) const override;
|
||||
QRect visualRect(const QModelIndex &idx) const override;
|
||||
QRegion visualRegionForSelection(const QItemSelection &selection) const override;
|
||||
|
||||
private slots:
|
||||
@@ -115,7 +115,7 @@ class GroupedIconView : public QListView {
|
||||
QVector<QModelIndex> IntersectingItems(const QRect &rect) const;
|
||||
|
||||
// Returns the index of the item above (d=-1) or below (d=+1) the given item.
|
||||
int IndexAboveOrBelow(int index, int d) const;
|
||||
int IndexAboveOrBelow(int index, const int d) const;
|
||||
|
||||
MultiSortFilterProxy *proxy_model_;
|
||||
QVector<QRect> visual_rects_;
|
||||
|
||||
@@ -72,9 +72,17 @@ ExtendedEditor::ExtendedEditor(QWidget *widget, int extra_right_padding, bool dr
|
||||
reset_button_->setFocusPolicy(Qt::NoFocus);
|
||||
reset_button_->hide();
|
||||
|
||||
widget->connect(clear_button_, SIGNAL(clicked()), widget, SLOT(setFocus()));
|
||||
if (qobject_cast<QLineEdit*>(widget) || qobject_cast<QPlainTextEdit*>(widget) || qobject_cast<QSpinBox*>(widget)) {
|
||||
widget->connect(clear_button_, SIGNAL(clicked()), widget, SLOT(clear()));
|
||||
if (LineEdit *lineedit = qobject_cast<LineEdit*>(widget)) {
|
||||
QObject::connect(clear_button_, &QToolButton::clicked, lineedit, &LineEdit::set_focus);
|
||||
QObject::connect(clear_button_, &QToolButton::clicked, lineedit, &LineEdit::clear);
|
||||
}
|
||||
else if (TextEdit *textedit = qobject_cast<TextEdit*>(widget)) {
|
||||
QObject::connect(clear_button_, &QToolButton::clicked, textedit, &TextEdit::set_focus);
|
||||
QObject::connect(clear_button_, &QToolButton::clicked, textedit, &TextEdit::clear);
|
||||
}
|
||||
else if (SpinBox *spinbox = qobject_cast<SpinBox*>(widget)) {
|
||||
QObject::connect(clear_button_, &QToolButton::clicked, spinbox, &SpinBox::set_focus);
|
||||
QObject::connect(clear_button_, &QToolButton::clicked, spinbox, &SpinBox::clear);
|
||||
}
|
||||
|
||||
UpdateButtonGeometry();
|
||||
@@ -160,8 +168,8 @@ void ExtendedEditor::Resize() {
|
||||
}
|
||||
|
||||
LineEdit::LineEdit(QWidget *parent) : QLineEdit(parent), ExtendedEditor(this) {
|
||||
connect(reset_button_, SIGNAL(clicked()), SIGNAL(Reset()));
|
||||
connect(this, SIGNAL(textChanged(QString)), SLOT(text_changed(QString)));
|
||||
QObject::connect(reset_button_, &QToolButton::clicked, this, &LineEdit::Reset);
|
||||
QObject::connect(this, &LineEdit::textChanged, this, &LineEdit::text_changed);
|
||||
}
|
||||
|
||||
void LineEdit::text_changed(const QString &text) {
|
||||
@@ -191,10 +199,11 @@ void LineEdit::resizeEvent(QResizeEvent *e) {
|
||||
|
||||
TextEdit::TextEdit(QWidget *parent)
|
||||
: QPlainTextEdit(parent),
|
||||
ExtendedEditor(this)
|
||||
{
|
||||
connect(reset_button_, SIGNAL(clicked()), SIGNAL(Reset()));
|
||||
connect(this, SIGNAL(textChanged()), viewport(), SLOT(update())); // To clear the hint
|
||||
ExtendedEditor(this) {
|
||||
|
||||
QObject::connect(reset_button_, &QToolButton::clicked, this, &TextEdit::Reset);
|
||||
QObject::connect(this, &TextEdit::textChanged, [this]() { viewport()->update(); }); // To clear the hint
|
||||
|
||||
}
|
||||
|
||||
void TextEdit::paintEvent(QPaintEvent *e) {
|
||||
@@ -212,7 +221,7 @@ SpinBox::SpinBox(QWidget *parent)
|
||||
: QSpinBox(parent),
|
||||
ExtendedEditor(this, 14, false)
|
||||
{
|
||||
connect(reset_button_, SIGNAL(clicked()), SIGNAL(Reset()));
|
||||
QObject::connect(reset_button_, &QToolButton::clicked, this, &SpinBox::Reset);
|
||||
}
|
||||
|
||||
void SpinBox::paintEvent(QPaintEvent *e) {
|
||||
@@ -226,9 +235,10 @@ void SpinBox::resizeEvent(QResizeEvent *e) {
|
||||
}
|
||||
|
||||
CheckBox::CheckBox(QWidget *parent)
|
||||
: QCheckBox(parent), ExtendedEditor(this, 14, false)
|
||||
{
|
||||
connect(reset_button_, SIGNAL(clicked()), SIGNAL(Reset()));
|
||||
: QCheckBox(parent), ExtendedEditor(this, 14, false) {
|
||||
|
||||
QObject::connect(reset_button_, &QToolButton::clicked, this, &CheckBox::Reset);
|
||||
|
||||
}
|
||||
|
||||
void CheckBox::paintEvent(QPaintEvent *e) {
|
||||
|
||||
@@ -118,12 +118,12 @@ class LineEdit : public QLineEdit, public ExtendedEditor {
|
||||
|
||||
// ExtendedEditor
|
||||
void set_enabled(bool enabled) override { QLineEdit::setEnabled(enabled); }
|
||||
void set_focus() override { QLineEdit::setFocus(); }
|
||||
|
||||
QVariant value() const override { return QLineEdit::text(); }
|
||||
void set_value(const QVariant &value) override { QLineEdit::setText(value.toString()); }
|
||||
|
||||
public slots:
|
||||
void set_focus() override { QLineEdit::setFocus(); }
|
||||
void clear() override { QLineEdit::clear(); }
|
||||
|
||||
protected:
|
||||
@@ -152,12 +152,12 @@ class TextEdit : public QPlainTextEdit, public ExtendedEditor {
|
||||
|
||||
// ExtendedEditor
|
||||
void set_enabled(bool enabled) override { QPlainTextEdit::setEnabled(enabled); }
|
||||
void set_focus() override { QPlainTextEdit::setFocus(); }
|
||||
|
||||
QVariant value() const override { return QPlainTextEdit::toPlainText(); }
|
||||
void set_value(const QVariant &value) override { QPlainTextEdit::setPlainText(value.toString()); }
|
||||
|
||||
public slots:
|
||||
void set_focus() override { QPlainTextEdit::setFocus(); }
|
||||
void clear() override { QPlainTextEdit::clear(); }
|
||||
|
||||
protected:
|
||||
@@ -182,13 +182,13 @@ class SpinBox : public QSpinBox, public ExtendedEditor {
|
||||
|
||||
// ExtendedEditor
|
||||
void set_enabled(bool enabled) override { QSpinBox::setEnabled(enabled); }
|
||||
void set_focus() override { QSpinBox::setFocus(); }
|
||||
|
||||
QVariant value() const override { return QSpinBox::value(); }
|
||||
void set_value(const QVariant &value) override { QSpinBox::setValue(value.toInt()); }
|
||||
bool is_empty() const override { return text().isEmpty() || text() == "0"; }
|
||||
|
||||
public slots:
|
||||
void set_focus() override { QSpinBox::setFocus(); }
|
||||
void clear() override { QSpinBox::clear(); }
|
||||
|
||||
protected:
|
||||
@@ -210,7 +210,6 @@ class CheckBox : public QCheckBox, public ExtendedEditor {
|
||||
|
||||
// ExtendedEditor
|
||||
void set_enabled(bool enabled) override { QCheckBox::setEnabled(enabled); }
|
||||
void set_focus() override { QCheckBox::setFocus(); }
|
||||
|
||||
bool is_empty() const override { return text().isEmpty() || text() == "0"; }
|
||||
QVariant value() const override { return QCheckBox::isChecked(); }
|
||||
@@ -218,6 +217,7 @@ class CheckBox : public QCheckBox, public ExtendedEditor {
|
||||
void set_partially() override { QCheckBox::setCheckState(Qt::PartiallyChecked); }
|
||||
|
||||
public slots:
|
||||
void set_focus() override { QCheckBox::setFocus(); }
|
||||
void clear() override { QCheckBox::setChecked(false); }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -50,7 +50,7 @@ LoginStateWidget::LoginStateWidget(QWidget *parent)
|
||||
bold_font.setBold(true);
|
||||
ui_->signed_out_label->setFont(bold_font);
|
||||
|
||||
connect(ui_->sign_out, SIGNAL(clicked()), SLOT(Logout()));
|
||||
QObject::connect(ui_->sign_out, &QPushButton::clicked, this, &LoginStateWidget::Logout);
|
||||
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ void LoginStateWidget::SetLoggedIn(const State state, const QString &account_nam
|
||||
// A login just failed - give focus back to the last crediental field (usually password).
|
||||
// We have to do this after control gets back to the
|
||||
// event loop because the user might have just closed a dialog and our widget might not be active yet.
|
||||
QTimer::singleShot(0, this, SLOT(FocusLastCredentialField()));
|
||||
QTimer::singleShot(0, this, &LoginStateWidget::FocusLastCredentialField);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,13 +44,15 @@ const int MultiLoadingIndicator::kSpacing = 6;
|
||||
MultiLoadingIndicator::MultiLoadingIndicator(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
task_manager_(nullptr),
|
||||
spinner_(new BusyIndicator(this))
|
||||
{
|
||||
spinner_(new BusyIndicator(this)) {
|
||||
|
||||
spinner_->move(kHorizontalPadding, kVerticalPadding);
|
||||
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
|
||||
|
||||
}
|
||||
|
||||
QSize MultiLoadingIndicator::sizeHint() const {
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
||||
const int width = kHorizontalPadding * 2 + spinner_->sizeHint().width() + kSpacing + fontMetrics().horizontalAdvance(text_);
|
||||
#else
|
||||
@@ -59,11 +61,14 @@ QSize MultiLoadingIndicator::sizeHint() const {
|
||||
const int height = kVerticalPadding * 2 + qMax(spinner_->sizeHint().height(), fontMetrics().height());
|
||||
|
||||
return QSize(width, height);
|
||||
|
||||
}
|
||||
|
||||
void MultiLoadingIndicator::SetTaskManager(TaskManager* task_manager) {
|
||||
void MultiLoadingIndicator::SetTaskManager(TaskManager *task_manager) {
|
||||
|
||||
task_manager_ = task_manager;
|
||||
connect(task_manager_, SIGNAL(TasksChanged()), SLOT(UpdateText()));
|
||||
QObject::connect(task_manager_, &TaskManager::TasksChanged, this, &MultiLoadingIndicator::UpdateText);
|
||||
|
||||
}
|
||||
|
||||
void MultiLoadingIndicator::UpdateText() {
|
||||
@@ -106,4 +111,3 @@ void MultiLoadingIndicator::paintEvent(QPaintEvent*) {
|
||||
p.drawText(text_rect, Qt::TextSingleLine | Qt::AlignLeft, fontMetrics().elidedText(text_, Qt::ElideRight, text_rect.width()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class MultiLoadingIndicator : public QWidget {
|
||||
void TaskCountChange(int tasks);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
void paintEvent(QPaintEvent*) override;
|
||||
|
||||
private slots:
|
||||
void UpdateText();
|
||||
@@ -64,4 +64,3 @@ class MultiLoadingIndicator : public QWidget {
|
||||
};
|
||||
|
||||
#endif // MULTILOADINGINDICATOR_H
|
||||
|
||||
|
||||
@@ -106,13 +106,13 @@ PlayingWidget::PlayingWidget(QWidget *parent)
|
||||
fit_cover_width_action_ = menu_->addAction(tr("Fit cover to width"));
|
||||
fit_cover_width_action_->setCheckable(true);
|
||||
fit_cover_width_action_->setEnabled(true);
|
||||
connect(fit_cover_width_action_, SIGNAL(toggled(bool)), SLOT(FitCoverWidth(bool)));
|
||||
QObject::connect(fit_cover_width_action_, &QAction::toggled, this, &PlayingWidget::FitCoverWidth);
|
||||
fit_cover_width_action_->setChecked(fit_width_);
|
||||
menu_->addSeparator();
|
||||
|
||||
// Animations
|
||||
connect(timeline_show_hide_, SIGNAL(frameChanged(int)), SLOT(SetHeight(int)));
|
||||
connect(timeline_fade_, SIGNAL(valueChanged(qreal)), SLOT(FadePreviousTrack(qreal)));
|
||||
QObject::connect(timeline_show_hide_, &QTimeLine::frameChanged, this, &PlayingWidget::SetHeight);
|
||||
QObject::connect(timeline_fade_, &QTimeLine::valueChanged, this, &PlayingWidget::FadePreviousTrack);
|
||||
timeline_fade_->setDirection(QTimeLine::Backward); // 1.0 -> 0.0
|
||||
|
||||
details_->setUndoRedoEnabled(false);
|
||||
@@ -143,13 +143,13 @@ void PlayingWidget::Init(Application *app, AlbumCoverChoiceController *album_cov
|
||||
s.beginGroup(kSettingsGroup);
|
||||
above_statusbar_action_->setChecked(s.value("above_status_bar", false).toBool());
|
||||
s.endGroup();
|
||||
connect(above_statusbar_action_, SIGNAL(toggled(bool)), SLOT(ShowAboveStatusBar(bool)));
|
||||
QObject::connect(above_statusbar_action_, &QAction::toggled, this, &PlayingWidget::ShowAboveStatusBar);
|
||||
|
||||
connect(album_cover_choice_controller_, SIGNAL(AutomaticCoverSearchDone()), this, SLOT(AutomaticCoverSearchDone()));
|
||||
QObject::connect(album_cover_choice_controller_, &AlbumCoverChoiceController::AutomaticCoverSearchDone, this, &PlayingWidget::AutomaticCoverSearchDone);
|
||||
|
||||
}
|
||||
|
||||
void PlayingWidget::SetEnabled(bool enabled) {
|
||||
void PlayingWidget::SetEnabled(const bool enabled) {
|
||||
|
||||
if (enabled == enabled_) return;
|
||||
|
||||
@@ -178,7 +178,7 @@ void PlayingWidget::SetDisabled() {
|
||||
|
||||
}
|
||||
|
||||
void PlayingWidget::SetVisible(bool visible) {
|
||||
void PlayingWidget::SetVisible(const bool visible) {
|
||||
|
||||
if (timeline_show_hide_->state() == QTimeLine::Running) {
|
||||
if (timeline_show_hide_->direction() == QTimeLine::Backward && enabled_ && active_) {
|
||||
@@ -198,7 +198,7 @@ void PlayingWidget::SetVisible(bool visible) {
|
||||
|
||||
}
|
||||
|
||||
void PlayingWidget::set_ideal_height(int height) {
|
||||
void PlayingWidget::set_ideal_height(const int height) {
|
||||
|
||||
small_ideal_height_ = height;
|
||||
UpdateHeight();
|
||||
@@ -209,17 +209,17 @@ QSize PlayingWidget::sizeHint() const {
|
||||
return QSize(cover_loader_options_.desired_height_, total_height_);
|
||||
}
|
||||
|
||||
void PlayingWidget::CreateModeAction(Mode mode, const QString &text, QActionGroup *group) {
|
||||
void PlayingWidget::CreateModeAction(const Mode mode, const QString &text, QActionGroup *group) {
|
||||
|
||||
QAction *action = new QAction(text, group);
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered, [this, mode]() { SetMode(mode); } );
|
||||
QObject::connect(action, &QAction::triggered, [this, mode]() { SetMode(mode); } );
|
||||
|
||||
if (mode == mode_) action->setChecked(true);
|
||||
|
||||
}
|
||||
|
||||
void PlayingWidget::SetMode(int mode) {
|
||||
void PlayingWidget::SetMode(const int mode) {
|
||||
|
||||
mode_ = Mode(mode);
|
||||
|
||||
@@ -236,7 +236,7 @@ void PlayingWidget::SetMode(int mode) {
|
||||
|
||||
}
|
||||
|
||||
void PlayingWidget::FitCoverWidth(bool fit) {
|
||||
void PlayingWidget::FitCoverWidth(const bool fit) {
|
||||
|
||||
fit_width_ = fit;
|
||||
UpdateHeight();
|
||||
@@ -249,7 +249,7 @@ void PlayingWidget::FitCoverWidth(bool fit) {
|
||||
|
||||
}
|
||||
|
||||
void PlayingWidget::ShowAboveStatusBar(bool above) {
|
||||
void PlayingWidget::ShowAboveStatusBar(const bool above) {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
@@ -467,7 +467,7 @@ void PlayingWidget::DrawContents(QPainter *p) {
|
||||
|
||||
}
|
||||
|
||||
void PlayingWidget::FadePreviousTrack(qreal value) {
|
||||
void PlayingWidget::FadePreviousTrack(const qreal value) {
|
||||
|
||||
if (!visible_) return;
|
||||
|
||||
@@ -492,13 +492,13 @@ void PlayingWidget::resizeEvent(QResizeEvent* e) {
|
||||
|
||||
}
|
||||
|
||||
void PlayingWidget::contextMenuEvent(QContextMenuEvent* e) {
|
||||
void PlayingWidget::contextMenuEvent(QContextMenuEvent *e) {
|
||||
|
||||
// show the menu
|
||||
menu_->popup(mapToGlobal(e->pos()));
|
||||
}
|
||||
|
||||
void PlayingWidget::mouseDoubleClickEvent(QMouseEvent* e) {
|
||||
void PlayingWidget::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
|
||||
// Same behaviour as right-click > Show Fullsize
|
||||
if (e->button() == Qt::LeftButton && song_.is_valid()) {
|
||||
@@ -531,7 +531,7 @@ void PlayingWidget::SearchCoverInProgress() {
|
||||
|
||||
// Show a spinner animation
|
||||
spinner_animation_.reset(new QMovie(":/pictures/spinner.gif", QByteArray(), this));
|
||||
connect(spinner_animation_.get(), SIGNAL(updated(QRect)), SLOT(update()));
|
||||
QObject::connect(spinner_animation_.get(), &QMovie::updated, this, &PlayingWidget::Update);
|
||||
spinner_animation_->start();
|
||||
update();
|
||||
|
||||
|
||||
@@ -63,10 +63,10 @@ class PlayingWidget : public QWidget {
|
||||
|
||||
void Init(Application *app, AlbumCoverChoiceController *album_cover_choice_controller);
|
||||
bool IsEnabled() { return enabled_; }
|
||||
void SetEnabled(bool enabled);
|
||||
void SetEnabled(const bool enabled);
|
||||
void SetEnabled();
|
||||
void SetDisabled();
|
||||
void set_ideal_height(int height);
|
||||
void set_ideal_height(const int height);
|
||||
QSize sizeHint() const override;
|
||||
bool show_above_status_bar() const { return above_statusbar_action_->isChecked(); }
|
||||
|
||||
@@ -79,6 +79,7 @@ class PlayingWidget : public QWidget {
|
||||
void Error();
|
||||
void SongChanged(const Song &song);
|
||||
void SearchCoverInProgress();
|
||||
void AlbumCoverLoaded(const Song &song, const QImage &image);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
@@ -89,15 +90,15 @@ class PlayingWidget : public QWidget {
|
||||
void dropEvent(QDropEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void SetMode(int mode);
|
||||
void ShowAboveStatusBar(bool above);
|
||||
void FitCoverWidth(bool fit);
|
||||
void Update() { update(); }
|
||||
void SetMode(const int mode);
|
||||
void ShowAboveStatusBar(const bool above);
|
||||
void FitCoverWidth(const bool fit);
|
||||
|
||||
void AutomaticCoverSearchDone();
|
||||
|
||||
void AlbumCoverLoaded(const Song &song, const QImage &image);
|
||||
void SetHeight(int height);
|
||||
void FadePreviousTrack(qreal value);
|
||||
void SetHeight(const int height);
|
||||
void FadePreviousTrack(const qreal value);
|
||||
|
||||
private:
|
||||
|
||||
@@ -118,7 +119,7 @@ class PlayingWidget : public QWidget {
|
||||
AlbumCoverChoiceController *album_cover_choice_controller_;
|
||||
Mode mode_;
|
||||
QMenu *menu_;
|
||||
QAction* above_statusbar_action_;
|
||||
QAction *above_statusbar_action_;
|
||||
QAction *fit_cover_width_action_;
|
||||
bool enabled_;
|
||||
bool visible_;
|
||||
@@ -142,8 +143,8 @@ class PlayingWidget : public QWidget {
|
||||
QPixmap pixmap_previous_track_;
|
||||
std::unique_ptr<QMovie> spinner_animation_;
|
||||
|
||||
void SetVisible(bool visible);
|
||||
void CreateModeAction(Mode mode, const QString &text, QActionGroup *group);
|
||||
void SetVisible(const bool visible);
|
||||
void CreateModeAction(const Mode mode, const QString &text, QActionGroup *group);
|
||||
void UpdateDetailsText();
|
||||
void UpdateHeight();
|
||||
void SetImage(const QImage &image);
|
||||
|
||||
@@ -29,7 +29,7 @@ class QSearchField : public QWidget {
|
||||
void setFocus();
|
||||
|
||||
signals:
|
||||
void textChanged(const QString &text);
|
||||
void textChanged(QString text);
|
||||
void editingFinished();
|
||||
void returnPressed();
|
||||
|
||||
|
||||
@@ -64,10 +64,10 @@ class QSearchFieldPrivate : public QObject {
|
||||
QSearchField::QSearchField(QWidget *parent) : QWidget(parent) {
|
||||
|
||||
QLineEdit *lineEdit = new QLineEdit(this);
|
||||
connect(lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged(QString)));
|
||||
connect(lineEdit, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
|
||||
connect(lineEdit, SIGNAL(returnPressed()), this, SIGNAL(returnPressed()));
|
||||
connect(lineEdit, SIGNAL(textChanged(QString)), this, SLOT(setText(QString)));
|
||||
QObject::connect(lineEdit, &QLineEdit::textChanged, this, &QSearchField::textChanged);
|
||||
QObject::connect(lineEdit, &QLineEdit::editingFinished, this, &QSearchField::editingFinished);
|
||||
QObject::connect(lineEdit, &QLineEdit::returnPressed, this, &QSearchField::returnPressed);
|
||||
QObject::connect(lineEdit, &QLineEdit::textChanged, this, &QSearchField::setText);
|
||||
|
||||
QToolButton *clearbutton = new QToolButton(this);
|
||||
QIcon clearIcon(IconLoader::Load("edit-clear-locationbar-ltr"));
|
||||
@@ -77,7 +77,7 @@ QSearchField::QSearchField(QWidget *parent) : QWidget(parent) {
|
||||
clearbutton->setStyleSheet("border: none; padding: 0px;");
|
||||
clearbutton->resize(clearbutton->sizeHint());
|
||||
|
||||
connect(clearbutton, SIGNAL(clicked()), this, SLOT(clear()));
|
||||
QObject::connect(clearbutton, &QToolButton::clicked, this, &QSearchField::clear);
|
||||
|
||||
pimpl = new QSearchFieldPrivate(this, lineEdit, clearbutton);
|
||||
|
||||
|
||||
@@ -48,4 +48,3 @@ class RenameTabLineEdit : public QLineEdit {
|
||||
};
|
||||
|
||||
#endif // RENAMETABLINEEDIT_H
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ StretchHeaderView::StretchHeaderView(const Qt::Orientation orientation, QWidget
|
||||
stretch_enabled_(false),
|
||||
in_mouse_move_event_(false) {
|
||||
|
||||
connect(this, SIGNAL(sectionResized(int,int,int)), SLOT(SectionResized(int,int,int)));
|
||||
QObject::connect(this, &StretchHeaderView::sectionResized, this, &StretchHeaderView::SectionResized);
|
||||
setMinimumSectionSize(kMinimumColumnWidth);
|
||||
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class StretchHeaderView : public QHeaderView {
|
||||
|
||||
signals:
|
||||
// Emitted when the stretch mode is changed.
|
||||
void StretchEnabledChanged(const bool enabled);
|
||||
void StretchEnabledChanged(bool enabled);
|
||||
|
||||
protected:
|
||||
// QWidget
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
const char* TrackSlider::kSettingsGroup = "MainWindow";
|
||||
|
||||
TrackSlider::TrackSlider(QWidget* parent)
|
||||
TrackSlider::TrackSlider(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui_(new Ui_TrackSlider),
|
||||
#ifdef HAVE_MOODBAR
|
||||
@@ -51,8 +51,8 @@ TrackSlider::TrackSlider(QWidget* parent)
|
||||
#endif
|
||||
setting_value_(false),
|
||||
show_remaining_time_(true),
|
||||
slider_maximum_value_(0)
|
||||
{
|
||||
slider_maximum_value_(0) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
|
||||
UpdateLabelWidth();
|
||||
@@ -61,14 +61,15 @@ TrackSlider::TrackSlider(QWidget* parent)
|
||||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
show_remaining_time_ = s.value("show_remaining_time").toBool();
|
||||
s.endGroup();
|
||||
|
||||
connect(ui_->slider, SIGNAL(sliderMoved(int)), SIGNAL(ValueChanged(int)));
|
||||
connect(ui_->slider, SIGNAL(valueChanged(int)), SLOT(ValueMaybeChanged(int)));
|
||||
connect(ui_->remaining, SIGNAL(Clicked()), SLOT(ToggleTimeDisplay()));
|
||||
connect(ui_->slider, SIGNAL(SeekForward()), SIGNAL(SeekForward()));
|
||||
connect(ui_->slider, SIGNAL(SeekBackward()), SIGNAL(SeekBackward()));
|
||||
connect(ui_->slider, SIGNAL(Previous()), SIGNAL(Previous()));
|
||||
connect(ui_->slider, SIGNAL(Next()), SIGNAL(Next()));
|
||||
QObject::connect(ui_->slider, &TrackSliderSlider::sliderMoved, this, &TrackSlider::ValueChanged);
|
||||
QObject::connect(ui_->slider, &TrackSliderSlider::valueChanged, this, &TrackSlider::ValueMaybeChanged);
|
||||
QObject::connect(ui_->remaining, &ClickableLabel::Clicked, this, &TrackSlider::ToggleTimeDisplay);
|
||||
QObject::connect(ui_->slider, &TrackSliderSlider::SeekForward, this, &TrackSlider::SeekForward);
|
||||
QObject::connect(ui_->slider, &TrackSliderSlider::SeekBackward, this, &TrackSlider::SeekBackward);
|
||||
QObject::connect(ui_->slider, &TrackSliderSlider::Previous, this, &TrackSlider::Previous);
|
||||
QObject::connect(ui_->slider, &TrackSliderSlider::Next, this, &TrackSlider::Next);
|
||||
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ TrackSlider::~TrackSlider() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void TrackSlider::SetApplication(Application* app) {
|
||||
void TrackSlider::SetApplication(Application *app) {
|
||||
#ifdef HAVE_MOODBAR
|
||||
if (!moodbar_style_) moodbar_style_ = new MoodbarProxyStyle(app, ui_->slider);
|
||||
#else
|
||||
@@ -93,7 +94,7 @@ void TrackSlider::UpdateLabelWidth() {
|
||||
UpdateLabelWidth(ui_->remaining, "-0:00:00");
|
||||
}
|
||||
|
||||
void TrackSlider::UpdateLabelWidth(QLabel* label, const QString& text) {
|
||||
void TrackSlider::UpdateLabelWidth(QLabel *label, const QString &text) {
|
||||
|
||||
QString old_text = label->text();
|
||||
label->setText(text);
|
||||
@@ -117,7 +118,7 @@ QSize TrackSlider::sizeHint() const {
|
||||
|
||||
}
|
||||
|
||||
void TrackSlider::SetValue(int elapsed, int total) {
|
||||
void TrackSlider::SetValue(const int elapsed, const int total) {
|
||||
|
||||
setting_value_ = true; // This is so we don't emit from QAbstractSlider::valueChanged
|
||||
ui_->slider->setMaximum(total);
|
||||
@@ -131,7 +132,7 @@ void TrackSlider::SetValue(int elapsed, int total) {
|
||||
|
||||
}
|
||||
|
||||
void TrackSlider::UpdateTimes(int elapsed) {
|
||||
void TrackSlider::UpdateTimes(const int elapsed) {
|
||||
|
||||
ui_->elapsed->setText(Utilities::PrettyTime(elapsed));
|
||||
// Update normally if showing remaining time
|
||||
@@ -162,23 +163,23 @@ void TrackSlider::SetStopped() {
|
||||
|
||||
}
|
||||
|
||||
void TrackSlider::SetCanSeek(bool can_seek) {
|
||||
void TrackSlider::SetCanSeek(const bool can_seek) {
|
||||
ui_->slider->setEnabled(can_seek);
|
||||
}
|
||||
|
||||
void TrackSlider::Seek(int gap) {
|
||||
void TrackSlider::Seek(const int gap) {
|
||||
if (ui_->slider->isEnabled())
|
||||
ui_->slider->setValue(ui_->slider->value() + gap * kMsecPerSec);
|
||||
}
|
||||
|
||||
void TrackSlider::ValueMaybeChanged(int value) {
|
||||
void TrackSlider::ValueMaybeChanged(const int value) {
|
||||
if (setting_value_) return;
|
||||
|
||||
UpdateTimes(value / kMsecPerSec);
|
||||
emit ValueChangedSeconds(value / kMsecPerSec);
|
||||
}
|
||||
|
||||
bool TrackSlider::event(QEvent* e) {
|
||||
bool TrackSlider::event(QEvent *e) {
|
||||
|
||||
switch (e->type()) {
|
||||
case QEvent::ApplicationFontChange:
|
||||
|
||||
@@ -59,10 +59,10 @@ class TrackSlider : public QWidget {
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
public slots:
|
||||
void SetValue(int elapsed, int total);
|
||||
void SetValue(const int elapsed, const int total);
|
||||
void SetStopped();
|
||||
void SetCanSeek(bool can_seek);
|
||||
void Seek(int gap);
|
||||
void SetCanSeek(const bool can_seek);
|
||||
void Seek(const int gap);
|
||||
|
||||
signals:
|
||||
void ValueChanged(int value);
|
||||
@@ -74,19 +74,19 @@ class TrackSlider : public QWidget {
|
||||
void Previous();
|
||||
|
||||
private slots:
|
||||
void ValueMaybeChanged(int value);
|
||||
void ValueMaybeChanged(const int value);
|
||||
void ToggleTimeDisplay();
|
||||
|
||||
private:
|
||||
void UpdateTimes(int elapsed);
|
||||
void UpdateTimes(const int elapsed);
|
||||
void UpdateLabelWidth();
|
||||
void UpdateLabelWidth(QLabel* label, const QString& text);
|
||||
void UpdateLabelWidth(QLabel *label, const QString &text);
|
||||
|
||||
private:
|
||||
Ui_TrackSlider* ui_;
|
||||
Ui_TrackSlider *ui_;
|
||||
|
||||
#ifdef HAVE_MOODBAR
|
||||
MoodbarProxyStyle* moodbar_style_;
|
||||
MoodbarProxyStyle *moodbar_style_;
|
||||
#endif
|
||||
|
||||
bool setting_value_;
|
||||
|
||||
@@ -73,4 +73,4 @@ public:
|
||||
QPixmap background_cache_;
|
||||
};
|
||||
|
||||
#endif // TRACKSLIDERPOPUP_H
|
||||
#endif // TRACKSLIDERPOPUP_H
|
||||
|
||||
@@ -39,22 +39,22 @@
|
||||
#endif
|
||||
#include "tracksliderslider.h"
|
||||
|
||||
TrackSliderSlider::TrackSliderSlider(QWidget* parent)
|
||||
TrackSliderSlider::TrackSliderSlider(QWidget *parent)
|
||||
: QSlider(parent),
|
||||
#ifndef Q_OS_MACOS
|
||||
popup_(new TrackSliderPopup(window())),
|
||||
#endif
|
||||
mouse_hover_seconds_(0) {
|
||||
mouse_hover_seconds_(0) {
|
||||
|
||||
setMouseTracking(true);
|
||||
#ifndef Q_OS_MACOS
|
||||
popup_->hide();
|
||||
connect(this, SIGNAL(valueChanged(int)), SLOT(UpdateDeltaTime()));
|
||||
QObject::connect(this, &TrackSliderSlider::valueChanged, this, &TrackSliderSlider::UpdateDeltaTime);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void TrackSliderSlider::mousePressEvent(QMouseEvent* e) {
|
||||
void TrackSliderSlider::mousePressEvent(QMouseEvent *e) {
|
||||
// QSlider asks QStyle which mouse button should do what (absolute move or page step).
|
||||
// We force our own behaviour here because it makes more sense for a music player IMO.
|
||||
|
||||
@@ -74,9 +74,11 @@ void TrackSliderSlider::mousePressEvent(QMouseEvent* e) {
|
||||
|
||||
if (new_event.isAccepted())
|
||||
e->accept();
|
||||
|
||||
}
|
||||
|
||||
void TrackSliderSlider::mouseReleaseEvent(QMouseEvent* e) {
|
||||
void TrackSliderSlider::mouseReleaseEvent(QMouseEvent *e) {
|
||||
|
||||
QSlider::mouseReleaseEvent(e);
|
||||
if (e->button() == Qt::XButton1) {
|
||||
emit Previous();
|
||||
@@ -85,9 +87,11 @@ void TrackSliderSlider::mouseReleaseEvent(QMouseEvent* e) {
|
||||
emit Next();
|
||||
}
|
||||
e->accept();
|
||||
|
||||
}
|
||||
|
||||
void TrackSliderSlider::mouseMoveEvent(QMouseEvent* e) {
|
||||
void TrackSliderSlider::mouseMoveEvent(QMouseEvent *e) {
|
||||
|
||||
QSlider::mouseMoveEvent(e);
|
||||
|
||||
// Borrowed from QSliderPrivate::pixelPosToRangeValue
|
||||
@@ -107,6 +111,7 @@ void TrackSliderSlider::mouseMoveEvent(QMouseEvent* e) {
|
||||
UpdateDeltaTime();
|
||||
popup_->SetPopupPosition(mapTo(window(), QPoint(e->pos().x(), rect().center().y())));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void TrackSliderSlider::wheelEvent(QWheelEvent *e) {
|
||||
@@ -126,24 +131,29 @@ void TrackSliderSlider::enterEvent(QEnterEvent *e) {
|
||||
#else
|
||||
void TrackSliderSlider::enterEvent(QEvent *e) {
|
||||
#endif
|
||||
|
||||
QSlider::enterEvent(e);
|
||||
#ifndef Q_OS_MACOS
|
||||
if (isEnabled()) {
|
||||
popup_->show();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void TrackSliderSlider::leaveEvent(QEvent *e) {
|
||||
|
||||
QSlider::leaveEvent(e);
|
||||
#ifndef Q_OS_MACOS
|
||||
if (popup_->isVisible()) {
|
||||
popup_->hide();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void TrackSliderSlider::keyPressEvent(QKeyEvent *event) {
|
||||
|
||||
if (event->key() == Qt::Key_Left || event->key() == Qt::Key_Down) {
|
||||
emit SeekBackward();
|
||||
event->accept();
|
||||
@@ -155,13 +165,16 @@ void TrackSliderSlider::keyPressEvent(QKeyEvent *event) {
|
||||
else {
|
||||
QSlider::keyPressEvent(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TrackSliderSlider::UpdateDeltaTime() {
|
||||
|
||||
#ifndef Q_OS_MACOS
|
||||
if (popup_->isVisible()) {
|
||||
int delta_seconds = mouse_hover_seconds_ - (value() / kMsecPerSec);
|
||||
popup_->SetSmallText(Utilities::PrettyTimeDelta(delta_seconds));
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ class TrackSliderSlider : public QSlider {
|
||||
void Next();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* e) override;
|
||||
void mouseReleaseEvent(QMouseEvent* e) override;
|
||||
void mouseMoveEvent(QMouseEvent* e) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
void wheelEvent(QWheelEvent *e) override;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
void enterEvent(QEnterEvent *e) override;
|
||||
@@ -69,7 +69,7 @@ class TrackSliderSlider : public QSlider {
|
||||
|
||||
private:
|
||||
#ifndef Q_OS_MACOS
|
||||
TrackSliderPopup* popup_;
|
||||
TrackSliderPopup *popup_;
|
||||
#endif
|
||||
|
||||
int mouse_hover_seconds_;
|
||||
|
||||
@@ -224,7 +224,7 @@ VolumeSlider::VolumeSlider(QWidget* parent, uint max)
|
||||
setMinimumWidth(m_pixmapInset.width());
|
||||
setMinimumHeight(m_pixmapInset.height());
|
||||
|
||||
connect(m_animTimer, SIGNAL(timeout()), this, SLOT(slotAnimTimer()));
|
||||
QObject::connect(m_animTimer, &QTimer::timeout, this, &VolumeSlider::slotAnimTimer);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user