diff --git a/src/ui/screens/mainwindow/mainwindowstatusbar.cpp b/src/ui/screens/mainwindow/mainwindowstatusbar.cpp index 677ec627..57148690 100644 --- a/src/ui/screens/mainwindow/mainwindowstatusbar.cpp +++ b/src/ui/screens/mainwindow/mainwindowstatusbar.cpp @@ -10,8 +10,8 @@ #include #include #include - -#include +#include +#include #include "log/log.h" #include "rpc/serverstats.h" @@ -30,7 +30,8 @@ namespace tremotesf { addPermanentWidget(container, 1); auto layout = new QHBoxLayout(container); - layout->setContentsMargins(8, 4, 8, 4); + // Top/bottom margins are set on mServerLabel below so that they don't affect separators + layout->setContentsMargins(8, 0, 8, 0); mNoServersErrorImage = new QLabel(this); mNoServersErrorImage->setPixmap(QIcon::fromTheme("dialog-error"_l1).pixmap(16, 16)); @@ -38,15 +39,16 @@ namespace tremotesf { layout->addWidget(mNoServersErrorImage); mServerLabel = new QLabel(this); + mServerLabel->setContentsMargins(0, 5, 0, 5); layout->addWidget(mServerLabel); - mFirstSeparator = new KSeparator(Qt::Vertical, this); + mFirstSeparator = new StatusBarSeparator(this); layout->addWidget(mFirstSeparator); mStatusLabel = new QLabel(this); layout->addWidget(mStatusLabel); - mSecondSeparator = new KSeparator(Qt::Vertical, this); + mSecondSeparator = new StatusBarSeparator(this); layout->addWidget(mSecondSeparator); mDownloadSpeedImage = new QLabel(this); @@ -57,7 +59,7 @@ namespace tremotesf { mDownloadSpeedLabel = new QLabel(this); layout->addWidget(mDownloadSpeedLabel); - mThirdSeparator = new KSeparator(Qt::Vertical, this); + mThirdSeparator = new StatusBarSeparator(this); layout->addWidget(mThirdSeparator); mUploadSpeedImage = new QLabel(this); @@ -188,4 +190,24 @@ namespace tremotesf { }); menu->popup(QCursor::pos()); } + + StatusBarSeparator::StatusBarSeparator(QWidget* parent) : QWidget(parent) { + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + } + + QSize StatusBarSeparator::sizeHint() const { + QStyleOption opt{}; + opt.initFrom(this); + opt.state.setFlag(QStyle::State_Horizontal); + const int extent = style()->pixelMetric(QStyle::PM_ToolBarSeparatorExtent, &opt, this); + return {extent, extent}; + } + + void StatusBarSeparator::paintEvent(QPaintEvent*) { + QPainter p(this); + QStyleOption opt{}; + opt.initFrom(this); + opt.state.setFlag(QStyle::State_Horizontal); + style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &opt, &p, this); + } } diff --git a/src/ui/screens/mainwindow/mainwindowstatusbar.h b/src/ui/screens/mainwindow/mainwindowstatusbar.h index 5d649102..7556ddba 100644 --- a/src/ui/screens/mainwindow/mainwindowstatusbar.h +++ b/src/ui/screens/mainwindow/mainwindowstatusbar.h @@ -8,11 +8,12 @@ #include class QLabel; -class KSeparator; namespace tremotesf { class Rpc; + class StatusBarSeparator; + class MainWindowStatusBar final : public QStatusBar { Q_OBJECT @@ -28,18 +29,28 @@ namespace tremotesf { const Rpc* mRpc{}; QLabel* mNoServersErrorImage{}; QLabel* mServerLabel{}; - KSeparator* mFirstSeparator{}; + StatusBarSeparator* mFirstSeparator{}; QLabel* mStatusLabel{}; - KSeparator* mSecondSeparator{}; + StatusBarSeparator* mSecondSeparator{}; QLabel* mDownloadSpeedImage{}; QLabel* mDownloadSpeedLabel{}; - KSeparator* mThirdSeparator{}; + StatusBarSeparator* mThirdSeparator{}; QLabel* mUploadSpeedImage{}; QLabel* mUploadSpeedLabel{}; signals: void showConnectionSettingsDialog(); }; + + class StatusBarSeparator final : public QWidget { + Q_OBJECT + public: + explicit StatusBarSeparator(QWidget* parent = nullptr); + QSize sizeHint() const override; + + protected: + void paintEvent(QPaintEvent* event) override; + }; } #endif // TREMOTESF_MAINWINDOWSTATUSBAR_H