mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-21 13:53:37 -07:00
commit
ff87958188
4 changed files with 14 additions and 17 deletions
|
@ -389,7 +389,7 @@ void BitTorrent::DBResumeDataStorage::createDB() const
|
||||||
catch (const RuntimeError &err)
|
catch (const RuntimeError &err)
|
||||||
{
|
{
|
||||||
db.rollback();
|
db.rollback();
|
||||||
throw err;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,7 +566,7 @@ void BitTorrent::DBResumeDataStorage::Worker::storeQueue(const QVector<TorrentID
|
||||||
catch (const RuntimeError &err)
|
catch (const RuntimeError &err)
|
||||||
{
|
{
|
||||||
db.rollback();
|
db.rollback();
|
||||||
throw err;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const RuntimeError &err)
|
catch (const RuntimeError &err)
|
||||||
|
|
|
@ -184,9 +184,8 @@ SettingsStorage *SettingsStorage::instance()
|
||||||
|
|
||||||
bool SettingsStorage::save()
|
bool SettingsStorage::save()
|
||||||
{
|
{
|
||||||
if (!m_dirty) return true; // Obtaining the lock is expensive, let's check early
|
const QWriteLocker locker(&m_lock); // guard for `m_dirty` too
|
||||||
const QWriteLocker locker(&m_lock); // to guard for `m_dirty`
|
if (!m_dirty) return true;
|
||||||
if (!m_dirty) return true; // something might have changed while we were getting the lock
|
|
||||||
|
|
||||||
const TransactionalSettings settings(QLatin1String("qBittorrent"));
|
const TransactionalSettings settings(QLatin1String("qBittorrent"));
|
||||||
if (!settings.write(m_data))
|
if (!settings.write(m_data))
|
||||||
|
|
|
@ -112,8 +112,6 @@ namespace
|
||||||
|
|
||||||
PiecesBar::PiecesBar(QWidget *parent)
|
PiecesBar::PiecesBar(QWidget *parent)
|
||||||
: QWidget {parent}
|
: QWidget {parent}
|
||||||
, m_torrent {nullptr}
|
|
||||||
, m_hovered {false}
|
|
||||||
{
|
{
|
||||||
updatePieceColors();
|
updatePieceColors();
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
@ -156,7 +154,7 @@ void PiecesBar::enterEvent(QEvent *e)
|
||||||
void PiecesBar::leaveEvent(QEvent *e)
|
void PiecesBar::leaveEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
m_hovered = false;
|
m_hovered = false;
|
||||||
m_highlitedRegion = QRect();
|
m_highlightedRegion = {};
|
||||||
requestImageUpdate();
|
requestImageUpdate();
|
||||||
base::leaveEvent(e);
|
base::leaveEvent(e);
|
||||||
}
|
}
|
||||||
|
@ -185,11 +183,11 @@ void PiecesBar::paintEvent(QPaintEvent *)
|
||||||
painter.drawImage(imageRect, m_image);
|
painter.drawImage(imageRect, m_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_highlitedRegion.isNull())
|
if (!m_highlightedRegion.isNull())
|
||||||
{
|
{
|
||||||
QColor highlightColor {this->palette().color(QPalette::Active, QPalette::Highlight)};
|
QColor highlightColor {this->palette().color(QPalette::Active, QPalette::Highlight)};
|
||||||
highlightColor.setAlphaF(0.35);
|
highlightColor.setAlphaF(0.35);
|
||||||
QRect targetHighlightRect {m_highlitedRegion.adjusted(borderWidth, borderWidth, borderWidth, height() - 2 * borderWidth)};
|
QRect targetHighlightRect {m_highlightedRegion.adjusted(borderWidth, borderWidth, borderWidth, height() - 2 * borderWidth)};
|
||||||
painter.fillRect(targetHighlightRect, highlightColor);
|
painter.fillRect(targetHighlightRect, highlightColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,15 +316,15 @@ void PiecesBar::highlightFile(int imagePos)
|
||||||
|
|
||||||
ImageRange imageRange = transform.imagePos(filePieces);
|
ImageRange imageRange = transform.imagePos(filePieces);
|
||||||
QRect newHighlitedRegion {imageRange.first(), 0, imageRange.size(), m_image.height()};
|
QRect newHighlitedRegion {imageRange.first(), 0, imageRange.size(), m_image.height()};
|
||||||
if (newHighlitedRegion != m_highlitedRegion)
|
if (newHighlitedRegion != m_highlightedRegion)
|
||||||
{
|
{
|
||||||
m_highlitedRegion = newHighlitedRegion;
|
m_highlightedRegion = newHighlitedRegion;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!m_highlitedRegion.isEmpty())
|
else if (!m_highlightedRegion.isEmpty())
|
||||||
{
|
{
|
||||||
m_highlitedRegion = QRect();
|
m_highlightedRegion = {};
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,10 +91,10 @@ private:
|
||||||
virtual bool updateImage(QImage &image) = 0;
|
virtual bool updateImage(QImage &image) = 0;
|
||||||
void updatePieceColors();
|
void updatePieceColors();
|
||||||
|
|
||||||
const BitTorrent::Torrent *m_torrent;
|
const BitTorrent::Torrent *m_torrent = nullptr;
|
||||||
QImage m_image;
|
QImage m_image;
|
||||||
// buffered 256 levels gradient from bg_color to piece_color
|
// buffered 256 levels gradient from bg_color to piece_color
|
||||||
QVector<QRgb> m_pieceColors;
|
QVector<QRgb> m_pieceColors;
|
||||||
bool m_hovered;
|
bool m_hovered = false;
|
||||||
QRect m_highlitedRegion; //!< part of the bar can be highlighted; this rectangle is in the same frame as m_image
|
QRect m_highlightedRegion; // part of the bar can be highlighted; this rectangle is in the same frame as m_image
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue