1414
1515#include < QFileIconProvider>
1616#include < QPainter>
17+ #include < QPainterPath>
18+ #include < QRect>
1719#include < QApplication>
1820#include < QMouseEvent>
1921#include < QStyleFactory>
@@ -105,9 +107,28 @@ QSize FolderStatusDelegate::sizeHint(const QStyleOptionViewItem &option,
105107 h += margin + btnSize.height ();
106108 }
107109
110+ // Make sure its at least 76 Pixel high
111+ h = std::max (h, 76 );
112+
108113 return {0 , h};
109114}
110115
116+ QRect FolderStatusDelegate::moreRectPos (const QRect &rectIndex)
117+ {
118+ if (rectIndex.isValid ())
119+ {
120+ constexpr int buttonWidth = 88 ;
121+ constexpr int buttonHeight = 32 ;
122+ constexpr int margin = 16 ;
123+
124+ const int xMoreButton = rectIndex.right () - buttonWidth - margin;
125+ const int yMoreButton = rectIndex.center ().y () - (buttonHeight / 2 );
126+
127+ return QRect (xMoreButton, yMoreButton, buttonWidth, buttonHeight);
128+ }
129+ return {};
130+ }
131+
111132int FolderStatusDelegate::rootFolderHeightWithoutErrors (const QFontMetrics &fm, const QFontMetrics &aliasFm)
112133{
113134 const int aliasMargin = aliasFm.height () / 2 ;
@@ -129,6 +150,56 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
129150 const_cast <QStyleOptionViewItem &>(option).showDecorationSelected = false ;
130151 }
131152
153+ const QModelIndex parentIndex = index.parent (); // NMC customization
154+ {
155+ painter->save ();
156+
157+ // Verhindere das Zeichnen des "Neuer Ordner"-Buttons
158+ if (index.data (AddButton).toBool ()) {
159+ return ;
160+ }
161+
162+ const QRect leftRect (0 , option.rect .y (), option.rect .x (), option.rect .height ());
163+
164+ if (option.state & QStyle::State_MouseOver) {
165+ QColor hoverColor = QApplication::palette ().color (QPalette::Mid);
166+ painter->fillRect (option.rect , hoverColor);
167+ painter->fillRect (leftRect, hoverColor);
168+ }
169+
170+ if (option.state & QStyle::State_Selected) {
171+ // Auswahlhintergrundfarbe abrufen
172+ const QColor selectionColor = option.palette .color (QPalette::Highlight);
173+ painter->fillRect (option.rect , selectionColor);
174+ painter->fillRect (leftRect, selectionColor);
175+ }
176+
177+ const QTreeView* treeView = qobject_cast<const QTreeView*>(option.widget );
178+ if (treeView) {
179+ QIcon leftIcon;
180+ QSize iconSize (16 , 16 );
181+
182+ if (!parentIndex.isValid ()) {
183+ // Wir befinden uns im Stammverzeichnis, also Icon vergrößern
184+ iconSize = QSize (24 , 24 );
185+ }
186+
187+ if (index.isValid () && treeView->isExpanded (index)) {
188+ // Das übergeordnete Element ist erweitert
189+ leftIcon = QIcon (Theme::createColorAwareIcon (QStringLiteral (" :/client/theme/NMCIcons/collapse-down.svg" )));
190+ } else {
191+ // Das übergeordnete Element ist nicht erweitert
192+ leftIcon = QIcon (Theme::createColorAwareIcon (QStringLiteral (" :/client/theme/NMCIcons/collapse-right.svg" )));
193+ }
194+
195+ const QPoint iconPos (leftRect.width () - iconSize.width (),
196+ leftRect.y () + leftRect.height () / 2 - iconSize.height () / 2 );
197+ painter->drawPixmap (iconPos, leftIcon.pixmap (iconSize));
198+ }
199+
200+ painter->restore ();
201+ }
202+
132203 QStyledItemDelegate::paint (painter, option, index);
133204
134205 auto textAlign = Qt::AlignLeft;
@@ -223,12 +294,19 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
223294
224295 auto optionsButtonVisualRect = optionsButtonRect (option.rect , option.direction );
225296
226- statusIcon.paint (
227- painter,
228- QStyle::visualRect (option.direction , option.rect , iconRect),
229- Qt::AlignCenter,
230- syncEnabled ? QIcon::Normal : QIcon::Disabled
231- );
297+ // NMC Customization
298+ if (!parentIndex.isValid ()) {
299+ QIcon nmcFolderIcon = QIcon (QLatin1String (" :/client/theme/NMCIcons/folderLogo.svg" ));
300+ const auto nmcFolderPixmap = nmcFolderIcon.pixmap (iconSize, iconSize, QIcon::Normal);
301+ painter->drawPixmap (QStyle::visualRect (option.direction , option.rect , iconRect).left (), iconRect.top (), nmcFolderPixmap);
302+
303+ const QSize statusIconSize (24 ,24 );
304+ const auto statusPixmap = statusIcon.pixmap (statusIconSize.width (), statusIconSize.height (), syncEnabled ? QIcon::Normal : QIcon::Disabled);
305+ painter->drawPixmap (QStyle::visualRect (option.direction , option.rect , iconRect).right () - statusIconSize.width () * 0.6 , iconRect.bottom () - statusIconSize.height () * 0.8 , statusPixmap);
306+ } else {
307+ const auto statusPixmap = statusIcon.pixmap (iconSize, iconSize, syncEnabled ? QIcon::Normal : QIcon::Disabled);
308+ painter->drawPixmap (QStyle::visualRect (option.direction , option.rect , iconRect).left (), iconRect.top (), statusPixmap);
309+ }
232310
233311 auto palette = option.palette ;
234312
@@ -341,18 +419,23 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
341419 drawTextBox (infoTexts, QColor (0x4d , 0x4d , 0xba ));
342420 }
343421
422+ // NMC customization: we need these infos already here to adjust the progress bar
423+ const QRect currentButtonRectPos = moreRectPos (option.rect );
424+ const int nmcWidth = currentButtonRectPos.x () - nextToIcon - 8 ; // 8 is the margin to "More" button
425+
344426 // Sync File Progress Bar: Show it if syncFile is not empty.
345427 if (showProgess) {
346428 const auto fileNameTextHeight = subFm.boundingRect (tr (" File" )).height ();
347429 constexpr auto barHeight = 7 ; // same height as quota bar
348430 const auto overallWidth = option.rect .right () - aliasMargin - optionsButtonVisualRect.width () - nextToIcon;
431+ Q_UNUSED (overallWidth);
349432
350433 painter->save ();
351434
352435 // Overall Progress Bar.
353436 const auto progressBarRect = QRect (nextToIcon,
354437 remotePathRect.top (),
355- overallWidth - 2 * margin ,
438+ nmcWidth ,
356439 barHeight);
357440
358441 QStyleOptionProgressBar progressBarOpt;
@@ -384,21 +467,55 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
384467 painter->restore ();
385468 }
386469
387- painter->restore ();
388-
389470 {
390471 QStyleOptionToolButton btnOpt;
391472 btnOpt.state = option.state ;
392473 btnOpt.state &= ~(QStyle::State_Selected | QStyle::State_HasFocus);
393474 btnOpt.state |= QStyle::State_Raised;
394475 btnOpt.arrowType = Qt::NoArrow;
395476 btnOpt.subControls = QStyle::SC_ToolButton;
396- btnOpt.rect = optionsButtonVisualRect;
477+ // NMC customization
478+ btnOpt.rect = currentButtonRectPos;
479+ // make sure the button is not too far away from the left border
480+ btnOpt.rect .setRight (btnOpt.rect .x () + btnOpt.rect .width () + 4 );
481+
482+ // Create QPainterPath with rounded corners
483+ QPainterPath path;
484+ path.addRoundedRect (btnOpt.rect , 4 , 4 ); // 4 ist der Radius für die abgerundeten Ecken
485+
486+ // Draw border line
487+ QPen borderPen (QColor (0 , 0 , 0 )); // Beispiel: Schwarzer Rand
488+ borderPen.setWidth (1 );
489+ painter->setPen (borderPen);
490+ painter->drawPath (path);
491+
492+ // Fill the rectangle
493+ painter->fillPath (path, Qt::transparent);
494+
495+ // Draw the icon in rectangle
397496 btnOpt.icon = _iconMore;
398497 const auto buttonSize = QApplication::style ()->pixelMetric (QStyle::PM_ButtonIconSize);
399498 btnOpt.iconSize = QSize (buttonSize, buttonSize);
400- QApplication::style ()->drawComplexControl (QStyle::CC_ToolButton, &btnOpt, painter);
499+
500+ // Set icon position
501+ int iconX = btnOpt.rect .x () + btnOpt.rect .width ()/5 ;
502+ int iconY = btnOpt.rect .y () + (btnOpt.rect .height () - btnOpt.iconSize .height ()) / 2 ;
503+
504+ painter->drawPixmap (iconX, iconY, btnOpt.icon .pixmap (btnOpt.iconSize ));
505+
506+ // Add text
507+ const QString buttonText = QCoreApplication::translate (" " , " MORE" );
508+ painter->setFont (btnOpt.font );
509+ painter->setPen (option.palette .color (QPalette::ButtonText));
510+ int textX = iconX + btnOpt.iconSize .width () + 10 ;
511+ int textY = iconY;
512+ int textWidth = currentButtonRectPos.x () + currentButtonRectPos.width () - textX;
513+ int textHeight = btnOpt.fontMetrics .height ();
514+
515+ painter->drawText (QRect (textX, textY, textWidth, textHeight), Qt::AlignLeft | Qt::AlignVCenter, buttonText);
401516 }
517+
518+ painter->restore ();
402519}
403520
404521bool FolderStatusDelegate::editorEvent (QEvent *event, QAbstractItemModel *model,
0 commit comments