diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2022-02-24 16:51:15 +0300 |
---|---|---|
committer | Fabian Müller <80399010+fmoc@users.noreply.github.com> | 2022-04-13 17:21:25 +0300 |
commit | 6c2a0ea867f75dc36a997b829bdf2424bcb101d5 (patch) | |
tree | 372aa7b7f20d483759f2e370b89df22d57a2690a /src/gui/folderstatusdelegate.cpp | |
parent | 4033411ffadb7d9491fafe89a2dc72f47173897e (diff) |
Allow to add Folder sync pairs based on spaces
Diffstat (limited to 'src/gui/folderstatusdelegate.cpp')
-rw-r--r-- | src/gui/folderstatusdelegate.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gui/folderstatusdelegate.cpp b/src/gui/folderstatusdelegate.cpp index a970c4f25..2a8ccf53f 100644 --- a/src/gui/folderstatusdelegate.cpp +++ b/src/gui/folderstatusdelegate.cpp @@ -41,9 +41,9 @@ FolderStatusDelegate::FolderStatusDelegate() { } -QString FolderStatusDelegate::addFolderText() +QString FolderStatusDelegate::addFolderText(bool useSpaces) { - return tr("Add Folder Sync Connection"); + return !useSpaces ? tr("Add Folder Sync Connection") : tr("Add a space"); } // allocate each item size in listview. @@ -62,7 +62,7 @@ QSize FolderStatusDelegate::sizeHint(const QStyleOptionViewItem &option, QFontMetrics fm(qApp->font("QPushButton")); QStyleOptionButton opt; static_cast<QStyleOption &>(opt) = option; - opt.text = addFolderText(); + opt.text = addFolderText(index.data(FolderStatusDelegate::IsUsingSpaces).toBool()); return QApplication::style()->sizeFromContents( QStyle::CT_PushButton, &opt, fm.size(Qt::TextSingleLine, opt.text)) .expandedTo(QApplication::globalStrut()) @@ -109,6 +109,8 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & { QStyledItemDelegate::paint(painter, option, index); + const bool useSpaces = index.data(FolderStatusDelegate::IsUsingSpaces).toBool(); + auto textAlign = Qt::AlignLeft; QFont aliasFont = makeAliasFont(option.font); @@ -131,7 +133,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & static_cast<QStyleOption &>(opt) = option; opt.state &= ~QStyle::State_Selected; opt.state |= QStyle::State_Raised; - opt.text = addFolderText(); + opt.text = addFolderText(useSpaces); opt.rect.setWidth(qMin(opt.rect.width(), hint.width())); opt.rect.adjust(0, aliasMargin, 0, -aliasMargin); opt.rect = QStyle::visualRect(option.direction, option.rect, opt.rect); |