Formatting
This commit is contained in:
@@ -65,22 +65,26 @@ void AutoExpandingTreeView::RecursivelyExpandSlot(const QModelIndex &idx) {
|
||||
|
||||
bool AutoExpandingTreeView::RecursivelyExpand(const QModelIndex &idx, int *count) {
|
||||
|
||||
if (!CanRecursivelyExpand(idx))
|
||||
if (!CanRecursivelyExpand(idx)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (model()->canFetchMore(idx))
|
||||
if (model()->canFetchMore(idx)) {
|
||||
model()->fetchMore(idx);
|
||||
}
|
||||
|
||||
int children = model()->rowCount(idx);
|
||||
if (*count + children > kRowsToShow)
|
||||
if (*count + children > kRowsToShow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
expand(idx);
|
||||
*count += children;
|
||||
|
||||
for (int i = 0 ; i < children ; ++i) {
|
||||
if (!RecursivelyExpand(model()->index(i, 0, idx), count))
|
||||
for (int i = 0; i < children; ++i) {
|
||||
if (!RecursivelyExpand(model()->index(i, 0, idx), count)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -87,11 +87,13 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
|
||||
QSize sizeHint() const override {
|
||||
|
||||
FancyTabWidget *tabWidget = qobject_cast<FancyTabWidget*>(parentWidget());
|
||||
if (tabWidget->mode() == FancyTabWidget::Mode_Tabs || tabWidget->mode() == FancyTabWidget::Mode_IconOnlyTabs) return QTabBar::sizeHint();
|
||||
if (tabWidget->mode() == FancyTabWidget::Mode_Tabs || tabWidget->mode() == FancyTabWidget::Mode_IconOnlyTabs) {
|
||||
return QTabBar::sizeHint();
|
||||
}
|
||||
|
||||
QSize size;
|
||||
int h = 0;
|
||||
for (int i = 0 ; i < count() ; ++i) {
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (tabSizeHint(i).width() > size.width()) size.setWidth(tabSizeHint(i).width());
|
||||
h += tabSizeHint(i).height();
|
||||
}
|
||||
@@ -105,7 +107,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
|
||||
FancyTabWidget *tabWidget = qobject_cast<FancyTabWidget*>(parentWidget());
|
||||
if (tabWidget->mode() == FancyTabWidget::Mode_LargeSidebar || tabWidget->mode() == FancyTabWidget::Mode_SmallSidebar) {
|
||||
int w = 0;
|
||||
for (int i = 0 ; i < count() ; ++i) {
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (tabSizeHint(i).width() > w) w = tabSizeHint(i).width();
|
||||
}
|
||||
return w;
|
||||
@@ -129,7 +131,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
|
||||
|
||||
// If the text of any tab is wider than the set width then use that instead.
|
||||
int w = std::max(FancyTabWidget::TabSize_LargeSidebarMinWidth, tabWidget->iconsize_largesidebar() + 22);
|
||||
for (int i = 0 ; i < count() ; ++i) {
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
QRect rect = fm.boundingRect(QRect(0, 0, std::max(FancyTabWidget::TabSize_LargeSidebarMinWidth, tabWidget->iconsize_largesidebar() + 22), height()), Qt::TextWordWrap, QTabBar::tabText(i));
|
||||
rect.setWidth(rect.width() + 10);
|
||||
if (rect.width() > w) w = rect.width();
|
||||
@@ -168,8 +170,9 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
|
||||
QPoint pos = event->pos();
|
||||
|
||||
mouseHoverTabIndex = tabAt(pos);
|
||||
if (mouseHoverTabIndex > -1)
|
||||
if (mouseHoverTabIndex > -1) {
|
||||
update();
|
||||
}
|
||||
QTabBar::mouseMoveEvent(event);
|
||||
|
||||
}
|
||||
@@ -180,8 +183,9 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
|
||||
|
||||
bool verticalTextTabs = false;
|
||||
|
||||
if (tabWidget->mode() == FancyTabWidget::Mode_SmallSidebar)
|
||||
if (tabWidget->mode() == FancyTabWidget::Mode_SmallSidebar) {
|
||||
verticalTextTabs = true;
|
||||
}
|
||||
|
||||
// if LargeSidebar, restore spacers
|
||||
if (tabWidget->mode() == FancyTabWidget::Mode_LargeSidebar && spacers.count() > 0) {
|
||||
@@ -194,7 +198,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
|
||||
}
|
||||
else if (tabWidget->mode() != FancyTabWidget::Mode_LargeSidebar) {
|
||||
// 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
|
||||
if (!isTabEnabled(i) && !spacers.contains(i)) {
|
||||
spacers[i] = tabWidget->widget(i);
|
||||
@@ -206,7 +210,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
|
||||
|
||||
// Restore any label text that was hidden/cached for the IconOnlyTabs mode
|
||||
if (labelCache.count() > 0 && tabWidget->mode() != FancyTabWidget::Mode_IconOnlyTabs) {
|
||||
for (int i = 0 ; i < count() ; ++i) {
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
setTabToolTip(i, "");
|
||||
setTabText(i, labelCache[tabWidget->widget(i)]);
|
||||
}
|
||||
@@ -215,7 +219,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
|
||||
if (tabWidget->mode() != FancyTabWidget::Mode_LargeSidebar && tabWidget->mode() != FancyTabWidget::Mode_SmallSidebar) {
|
||||
// Cache and hide label text for IconOnlyTabs mode
|
||||
if (tabWidget->mode() == FancyTabWidget::Mode_IconOnlyTabs && labelCache.count() == 0) {
|
||||
for(int i = 0 ; i < count() ; ++i) {
|
||||
for(int i = 0; i < count(); ++i) {
|
||||
labelCache[tabWidget->widget(i)] = tabText(i);
|
||||
setTabToolTip(i, tabText(i));
|
||||
setTabText(i, "");
|
||||
@@ -486,7 +490,7 @@ void FancyTabWidget::Load(const QString &kSettingsGroup) {
|
||||
s.endGroup();
|
||||
|
||||
QMultiMap <int, TabData*> ::iterator i;
|
||||
for (i = tabs.begin() ; i != tabs.end() ; ++i) {
|
||||
for (i = tabs.begin(); i != tabs.end(); ++i) {
|
||||
TabData *tab = i.value();
|
||||
const int idx = insertTab(i.key(), tab->page(), tab->icon(), tab->label());
|
||||
tabBar()->setTabData(idx, QVariant(tab->name()));
|
||||
|
||||
@@ -113,10 +113,14 @@ void FileView::ReloadSettings() {
|
||||
}
|
||||
|
||||
void FileView::SetPath(const QString &path) {
|
||||
if (!model_)
|
||||
lazy_set_path_ = path;
|
||||
else
|
||||
|
||||
if (model_) {
|
||||
ChangeFilePathWithoutUndo(path);
|
||||
}
|
||||
else {
|
||||
lazy_set_path_ = path;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FileView::SetTaskManager(TaskManager *task_manager) {
|
||||
@@ -150,12 +154,14 @@ void FileView::ChangeFilePath(const QString &new_path_native) {
|
||||
QString new_path = QDir::fromNativeSeparators(new_path_native);
|
||||
|
||||
QFileInfo info(new_path);
|
||||
if (!info.exists() || !info.isDir())
|
||||
if (!info.exists() || !info.isDir()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString old_path(model_->rootPath());
|
||||
if (old_path == new_path)
|
||||
if (old_path == new_path) {
|
||||
return;
|
||||
}
|
||||
|
||||
undo_stack_->push(new UndoCommand(this, new_path));
|
||||
|
||||
@@ -180,8 +186,9 @@ void FileView::ItemActivated(const QModelIndex &idx) {
|
||||
|
||||
void FileView::ItemDoubleClick(const QModelIndex &idx) {
|
||||
|
||||
if (model_->isDir(idx))
|
||||
if (model_->isDir(idx)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString file_path = model_->filePath(idx);
|
||||
|
||||
@@ -287,4 +294,3 @@ void FileView::keyPressEvent(QKeyEvent *e) {
|
||||
QWidget::keyPressEvent(e);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -71,8 +71,9 @@ QList<QUrl> FileViewList::UrlListFromSelection() const {
|
||||
QList<QUrl> urls;
|
||||
const QModelIndexList indexes = menu_selection_.indexes();
|
||||
for (const QModelIndex &index : indexes) {
|
||||
if (index.column() == 0)
|
||||
if (index.column() == 0) {
|
||||
urls << QUrl::fromLocalFile(qobject_cast<QFileSystemModel*>(model())->fileInfo(index).canonicalFilePath());
|
||||
}
|
||||
}
|
||||
std::sort(urls.begin(), urls.end());
|
||||
|
||||
@@ -122,8 +123,9 @@ QStringList FileViewList::FilenamesFromSelection() const {
|
||||
QStringList filenames;
|
||||
const QModelIndexList indexes = menu_selection_.indexes();
|
||||
for (const QModelIndex &index : indexes) {
|
||||
if (index.column() == 0)
|
||||
if (index.column() == 0) {
|
||||
filenames << qobject_cast<QFileSystemModel*>(model())->filePath(index);
|
||||
}
|
||||
}
|
||||
return filenames;
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ void FreeSpaceBar::DrawBar(QPainter *p, const QRect r) {
|
||||
p->setOpacity(0.35);
|
||||
p->setRenderHint(QPainter::Antialiasing, false);
|
||||
p->setPen(QPen(palette().color(QPalette::Light), 1.0));
|
||||
for (int x = r.left() + kMarkerSpacing ; x < r.right() ; x += kMarkerSpacing) {
|
||||
for (int x = r.left() + kMarkerSpacing; x < r.right(); x += kMarkerSpacing) {
|
||||
p->drawLine(x, r.top() + 2, x, r.bottom() - 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -140,8 +140,10 @@ void GroupedIconView::dataChanged(const QModelIndex &topLeft, const QModelIndex
|
||||
}
|
||||
|
||||
void GroupedIconView::LayoutItems() {
|
||||
if (!model())
|
||||
|
||||
if (!model()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int count = model()->rowCount();
|
||||
|
||||
@@ -210,29 +212,34 @@ void GroupedIconView::LayoutItems() {
|
||||
|
||||
verticalScrollBar()->setRange(0, next_position.y() + max_row_height - viewport()->height());
|
||||
update();
|
||||
|
||||
}
|
||||
|
||||
QRect GroupedIconView::visualRect(const QModelIndex &idx) const {
|
||||
|
||||
if (idx.row() < 0 || idx.row() >= visual_rects_.count())
|
||||
if (idx.row() < 0 || idx.row() >= visual_rects_.count()) {
|
||||
return QRect();
|
||||
}
|
||||
return visual_rects_[idx.row()].translated(-horizontalOffset(), -verticalOffset());
|
||||
|
||||
}
|
||||
|
||||
QModelIndex GroupedIconView::indexAt(const QPoint &p) const {
|
||||
|
||||
const QPoint viewport_p = p + QPoint(horizontalOffset(), verticalOffset());
|
||||
|
||||
const int count = visual_rects_.count();
|
||||
for (int i=0 ; i<count ; ++i) {
|
||||
for (int i = 0; i<count; ++i) {
|
||||
if (visual_rects_[i].contains(viewport_p)) {
|
||||
return model()->index(i, 0);
|
||||
}
|
||||
}
|
||||
return QModelIndex();
|
||||
|
||||
}
|
||||
|
||||
void GroupedIconView::paintEvent(QPaintEvent *e) {
|
||||
|
||||
// This code was adapted from QListView::paintEvent(), changed to use the visualRect() of items, and to draw headers.
|
||||
|
||||
QStyleOptionViewItem option;
|
||||
@@ -241,8 +248,9 @@ void GroupedIconView::paintEvent(QPaintEvent *e) {
|
||||
#else
|
||||
option = viewOptions();
|
||||
#endif
|
||||
if (isWrapping())
|
||||
if (isWrapping()) {
|
||||
option.features = QStyleOptionViewItem::WrapText;
|
||||
}
|
||||
option.locale = locale();
|
||||
option.locale.setNumberOptions(QLocale::OmitGroupSeparator);
|
||||
option.widget = this;
|
||||
@@ -270,10 +278,12 @@ void GroupedIconView::paintEvent(QPaintEvent *e) {
|
||||
|
||||
option.rect = visualRect(*it);
|
||||
|
||||
if (flow() == TopToBottom)
|
||||
if (flow() == TopToBottom) {
|
||||
option.rect.setWidth(qMin(maxSize, option.rect.width()));
|
||||
else
|
||||
}
|
||||
else {
|
||||
option.rect.setHeight(qMin(maxSize, option.rect.height()));
|
||||
}
|
||||
|
||||
option.state = state;
|
||||
if (selections && selections->isSelected(*it))
|
||||
@@ -291,8 +301,9 @@ void GroupedIconView::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
if (focus && current == *it) {
|
||||
option.state |= QStyle::State_HasFocus;
|
||||
if (viewState == EditingState)
|
||||
if (viewState == EditingState) {
|
||||
option.state |= QStyle::State_Editing;
|
||||
}
|
||||
}
|
||||
|
||||
itemDelegate()->paint(&painter, option, *it);
|
||||
@@ -314,6 +325,7 @@ void GroupedIconView::paintEvent(QPaintEvent *e) {
|
||||
palette(),
|
||||
model()->index(header.first_row, 0).data(Role_Group).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GroupedIconView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) {
|
||||
|
||||
@@ -254,8 +254,9 @@ void CheckBox::resizeEvent(QResizeEvent *e) {
|
||||
|
||||
QString SpinBox::textFromValue(int val) const {
|
||||
|
||||
if (val <= 0 && !hint_.isEmpty())
|
||||
if (val <= 0 && !hint_.isEmpty()) {
|
||||
return "-";
|
||||
}
|
||||
return QSpinBox::textFromValue(val);
|
||||
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ void LoginStateWidget::FocusLastCredentialField() {
|
||||
line_edit->selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void LoginStateWidget::HideLoggedInState() {
|
||||
@@ -130,6 +131,7 @@ void LoginStateWidget::AddCredentialGroup(QWidget *widget) {
|
||||
}
|
||||
|
||||
bool LoginStateWidget::eventFilter(QObject *object, QEvent *event) {
|
||||
|
||||
if (!credential_fields_.contains(object))
|
||||
return QWidget::eventFilter(object, event);
|
||||
|
||||
@@ -142,6 +144,7 @@ bool LoginStateWidget::eventFilter(QObject *object, QEvent *event) {
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(object, event);
|
||||
|
||||
}
|
||||
|
||||
void LoginStateWidget::SetExpires(const QDate expires) {
|
||||
@@ -152,4 +155,5 @@ void LoginStateWidget::SetExpires(const QDate expires) {
|
||||
const QString expires_text = QLocale().toString(expires, QLocale::LongFormat);
|
||||
ui_->expires_label->setText(tr("Expires on %1").arg("<b>" + expires_text + "</b>"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -379,7 +379,9 @@ void PlayingWidget::UpdateHeight() {
|
||||
|
||||
// Update the animation settings and resize the widget now if we're visible
|
||||
timeline_show_hide_->setFrameRange(0, total_height_);
|
||||
if (visible_ && active_ && timeline_show_hide_->state() != QTimeLine::Running) setMaximumHeight(total_height_);
|
||||
if (visible_ && active_ && timeline_show_hide_->state() != QTimeLine::Running) {
|
||||
setMaximumHeight(total_height_);
|
||||
}
|
||||
|
||||
// Re-scale the current image
|
||||
if (song_.is_valid()) {
|
||||
|
||||
@@ -234,7 +234,7 @@ void QSearchField::setFocus() {
|
||||
void QSearchField::showEvent(QShowEvent *e) {
|
||||
|
||||
if (!e->spontaneous()) {
|
||||
for (int i = 0 ; i < layout()->count() ; ++i) {
|
||||
for (int i = 0; i < layout()->count(); ++i) {
|
||||
QWidget *widget = layout()->itemAt(i)->widget();
|
||||
layout()->removeWidget(widget);
|
||||
delete widget;
|
||||
|
||||
@@ -41,7 +41,7 @@ RatingPainter::RatingPainter() {
|
||||
QPixmap off(star_off.pixmap(star_off_sizes.last()));
|
||||
|
||||
// Generate the 10 states, better to do it now than on the fly
|
||||
for (int i = 0 ; i < kStarCount * 2 + 1 ; ++i) {
|
||||
for (int i = 0; i < kStarCount * 2 + 1; ++i) {
|
||||
const double rating = double(i) / double(2.0);
|
||||
|
||||
// Clear the pixmap
|
||||
@@ -51,7 +51,7 @@ RatingPainter::RatingPainter() {
|
||||
|
||||
// Draw the stars
|
||||
int x = 0;
|
||||
for (int y = 0 ; y < kStarCount ; ++y, x += kStarSize) {
|
||||
for (int y = 0; y < kStarCount; ++y, x += kStarSize) {
|
||||
const QRect rect(x, 0, kStarSize, kStarSize);
|
||||
|
||||
if (rating - 0.25 <= y) { // Totally empty
|
||||
|
||||
@@ -38,6 +38,8 @@ void StickySlider::mouseMoveEvent(QMouseEvent *e) {
|
||||
if (sticky_center_ == -1) return;
|
||||
|
||||
const int v = sliderPosition();
|
||||
if (v <= sticky_center_ + sticky_threshold_ && v >= sticky_center_ - sticky_threshold_) setSliderPosition(sticky_center_);
|
||||
if (v <= sticky_center_ + sticky_threshold_ && v >= sticky_center_ - sticky_threshold_) {
|
||||
setSliderPosition(sticky_center_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -71,24 +71,25 @@ void StretchHeaderView::NormaliseWidths(const QList<int> §ions) {
|
||||
|
||||
if (!sections.isEmpty()) {
|
||||
selected_sum = 0.0;
|
||||
for (int i = 0 ; i < count() ; ++i)
|
||||
if (sections.contains(i))
|
||||
for (int i = 0; i < count(); ++i)
|
||||
if (sections.contains(i)) {
|
||||
selected_sum += column_widths_[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (total_sum != 0.0 && !qFuzzyCompare(total_sum, 1.0)) {
|
||||
const ColumnWidthType mult = (selected_sum + (1.0 - total_sum)) / selected_sum;
|
||||
for (int i = 0 ; i < column_widths_.count() ; ++i) {
|
||||
if (sections.isEmpty() || sections.contains(i))
|
||||
for (int i = 0; i < column_widths_.count(); ++i) {
|
||||
if (sections.isEmpty() || sections.contains(i)) {
|
||||
column_widths_[i] *= mult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StretchHeaderView::UpdateWidths(const QList<int> §ions) {
|
||||
|
||||
if (!stretch_enabled_)
|
||||
return;
|
||||
if (!stretch_enabled_) return;
|
||||
|
||||
ColumnWidthType total_w = 0.0;
|
||||
|
||||
@@ -98,17 +99,20 @@ void StretchHeaderView::UpdateWidths(const QList<int> §ions) {
|
||||
|
||||
total_w += w;
|
||||
|
||||
if (!sections.isEmpty() && !sections.contains(i))
|
||||
if (!sections.isEmpty() && !sections.contains(i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pixels == 0 && !isSectionHidden(i))
|
||||
if (pixels == 0 && !isSectionHidden(i)) {
|
||||
hideSection(i);
|
||||
}
|
||||
else if (pixels != 0 && isSectionHidden(i)) {
|
||||
showSection(i);
|
||||
}
|
||||
|
||||
if (pixels != 0)
|
||||
if (pixels != 0) {
|
||||
resizeSection(i, pixels);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -117,7 +121,7 @@ void StretchHeaderView::HideSection(const int logical) {
|
||||
|
||||
// Would this hide the last section?
|
||||
bool all_hidden = true;
|
||||
for (int i = 0 ; i < count() ; ++i) {
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (i != logical && !isSectionHidden(i) && sectionSize(i) > 0) {
|
||||
all_hidden = false;
|
||||
break;
|
||||
@@ -147,9 +151,10 @@ void StretchHeaderView::ShowSection(int logical) {
|
||||
|
||||
// How many sections are visible already?
|
||||
int visible_count = 0;
|
||||
for (int i = 0 ; i < count() ; ++i) {
|
||||
if (!isSectionHidden(i))
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (!isSectionHidden(i)) {
|
||||
++visible_count;
|
||||
}
|
||||
}
|
||||
|
||||
column_widths_[logical] = visible_count == 0 ? 1.0 : 1.0 / visible_count;
|
||||
@@ -199,8 +204,9 @@ void StretchHeaderView::SectionResized(const int logical, const int, const int n
|
||||
int visual = visualIndex(logical);
|
||||
QList<int> logical_sections_to_resize;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (!isSectionHidden(i) && visualIndex(i) > visual)
|
||||
if (!isSectionHidden(i) && visualIndex(i) > visual) {
|
||||
logical_sections_to_resize << i;
|
||||
}
|
||||
}
|
||||
|
||||
// Resize just those columns
|
||||
@@ -244,9 +250,11 @@ void StretchHeaderView::SetColumnWidth(const int logical, const ColumnWidthType
|
||||
column_widths_[logical] = width;
|
||||
|
||||
QList<int> other_columns;
|
||||
for (int i = 0 ; i < count() ; ++i)
|
||||
if (!isSectionHidden(i) && i != logical)
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (!isSectionHidden(i) && i != logical) {
|
||||
other_columns << i;
|
||||
}
|
||||
}
|
||||
|
||||
NormaliseWidths(other_columns);
|
||||
|
||||
@@ -357,7 +365,7 @@ QByteArray StretchHeaderView::ResetState() {
|
||||
visual_indices.reserve(count());
|
||||
pixel_widths.reserve(count());
|
||||
|
||||
for (int i = 0 ; i < count() ; ++i) {
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
pixel_widths << 10;
|
||||
visual_indices << count();
|
||||
}
|
||||
|
||||
@@ -74,24 +74,30 @@ TrackSlider::TrackSlider(QWidget *parent)
|
||||
}
|
||||
|
||||
TrackSlider::~TrackSlider() {
|
||||
|
||||
delete ui_;
|
||||
#ifdef HAVE_MOODBAR
|
||||
if (moodbar_style_) moodbar_style_->deleteLater();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void TrackSlider::SetApplication(Application *app) {
|
||||
|
||||
#ifdef HAVE_MOODBAR
|
||||
if (!moodbar_style_) moodbar_style_ = new MoodbarProxyStyle(app, ui_->slider);
|
||||
#else
|
||||
Q_UNUSED(app);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void TrackSlider::UpdateLabelWidth() {
|
||||
|
||||
// We set the label's minimum size so it won't resize itself when the user is dragging the slider.
|
||||
UpdateLabelWidth(ui_->elapsed, "0:00:00");
|
||||
UpdateLabelWidth(ui_->remaining, "-0:00:00");
|
||||
|
||||
}
|
||||
|
||||
void TrackSlider::UpdateLabelWidth(QLabel *label, const QString &text) {
|
||||
@@ -168,15 +174,20 @@ void TrackSlider::SetCanSeek(const bool can_seek) {
|
||||
}
|
||||
|
||||
void TrackSlider::Seek(const int gap) {
|
||||
if (ui_->slider->isEnabled())
|
||||
|
||||
if (ui_->slider->isEnabled()) {
|
||||
ui_->slider->setValue(static_cast<int>(ui_->slider->value() + gap * kMsecPerSec));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TrackSlider::ValueMaybeChanged(const int value) {
|
||||
|
||||
if (setting_value_) return;
|
||||
|
||||
UpdateTimes(static_cast<int>(value / kMsecPerSec));
|
||||
emit ValueChangedSeconds(static_cast<int>(value / kMsecPerSec));
|
||||
|
||||
}
|
||||
|
||||
bool TrackSlider::event(QEvent *e) {
|
||||
|
||||
@@ -136,8 +136,9 @@ void SliderSlider::mousePressEvent(QMouseEvent *e) {
|
||||
|
||||
void SliderSlider::mouseReleaseEvent(QMouseEvent*) {
|
||||
|
||||
if (!outside_ && QSlider::value() != prev_value_)
|
||||
if (!outside_ && QSlider::value() != prev_value_) {
|
||||
emit sliderReleased(value());
|
||||
}
|
||||
|
||||
sliding_ = false;
|
||||
outside_ = false;
|
||||
|
||||
Reference in New Issue
Block a user