1414
1515#include < QFileIconProvider>
1616#include < QPainter>
17+ #include < QPainterPath>
18+ #include < QRect>
1719#include < QApplication>
1820#include < QMouseEvent>
1921#include < QStyleFactory>
@@ -83,9 +85,28 @@ QSize FolderStatusDelegate::sizeHint(const QStyleOptionViewItem &option,
8385 }
8486 }
8587
88+ // Make sure its at least 76 Pixel high
89+ h = std::max (h, 76 );
90+
8691 return {0 , h};
8792}
8893
94+ QRect FolderStatusDelegate::moreRectPos (const QRect &rectIndex)
95+ {
96+ if (rectIndex.isValid ())
97+ {
98+ constexpr int buttonWidth = 88 ;
99+ constexpr int buttonHeight = 32 ;
100+ constexpr int margin = 16 ;
101+
102+ const int xMoreButton = rectIndex.right () - buttonWidth - margin;
103+ const int yMoreButton = rectIndex.center ().y () - (buttonHeight / 2 );
104+
105+ return QRect (xMoreButton, yMoreButton, buttonWidth, buttonHeight);
106+ }
107+ return {};
108+ }
109+
89110int FolderStatusDelegate::rootFolderHeightWithoutErrors (const QFontMetrics &fm, const QFontMetrics &aliasFm)
90111{
91112 const int aliasMargin = aliasFm.height () / 2 ;
@@ -107,6 +128,56 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
107128 const_cast <QStyleOptionViewItem &>(option).showDecorationSelected = false ;
108129 }
109130
131+ const QModelIndex parentIndex = index.parent (); // NMC customization
132+ {
133+ painter->save ();
134+
135+ // Verhindere das Zeichnen des "Neuer Ordner"-Buttons
136+ if (index.data (AddButton).toBool ()) {
137+ return ;
138+ }
139+
140+ const QRect leftRect (0 , option.rect .y (), option.rect .x (), option.rect .height ());
141+
142+ if (option.state & QStyle::State_MouseOver) {
143+ QColor hoverColor = QApplication::palette ().color (QPalette::Mid);
144+ painter->fillRect (option.rect , hoverColor);
145+ painter->fillRect (leftRect, hoverColor);
146+ }
147+
148+ if (option.state & QStyle::State_Selected) {
149+ // Auswahlhintergrundfarbe abrufen
150+ const QColor selectionColor = option.palette .color (QPalette::Highlight);
151+ painter->fillRect (option.rect , selectionColor);
152+ painter->fillRect (leftRect, selectionColor);
153+ }
154+
155+ const QTreeView* treeView = qobject_cast<const QTreeView*>(option.widget );
156+ if (treeView) {
157+ QIcon leftIcon;
158+ QSize iconSize (16 , 16 );
159+
160+ if (!parentIndex.isValid ()) {
161+ // Wir befinden uns im Stammverzeichnis, also Icon vergrößern
162+ iconSize = QSize (24 , 24 );
163+ }
164+
165+ if (index.isValid () && treeView->isExpanded (index)) {
166+ // Das übergeordnete Element ist erweitert
167+ leftIcon = QIcon (Theme::createColorAwareIcon (QStringLiteral (" :/client/theme/NMCIcons/collapse-down.svg" )));
168+ } else {
169+ // Das übergeordnete Element ist nicht erweitert
170+ leftIcon = QIcon (Theme::createColorAwareIcon (QStringLiteral (" :/client/theme/NMCIcons/collapse-right.svg" )));
171+ }
172+
173+ const QPoint iconPos (leftRect.width () - iconSize.width (),
174+ leftRect.y () + leftRect.height () / 2 - iconSize.height () / 2 );
175+ painter->drawPixmap (iconPos, leftIcon.pixmap (iconSize));
176+ }
177+
178+ painter->restore ();
179+ }
180+
110181 QStyledItemDelegate::paint (painter, option, index);
111182
112183 auto textAlign = Qt::AlignLeft;
@@ -183,19 +254,28 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
183254 iconRect.setBottom (localPathRect.bottom ());
184255 iconRect.setWidth (iconRect.height ());
185256
186- const auto nextToIcon = iconRect.right () + aliasMargin;
257+ const auto nextToIcon = iconRect.right () + std::max ( aliasMargin, 16 ) ;
187258 aliasRect.setLeft (nextToIcon);
188259 localPathRect.setLeft (nextToIcon);
189260 remotePathRect.setLeft (nextToIcon);
190261
262+ const auto iconSize = iconRect.width ();
263+
191264 auto optionsButtonVisualRect = optionsButtonRect (option.rect , option.direction );
192265
193- statusIcon.paint (
194- painter,
195- QStyle::visualRect (option.direction , option.rect , iconRect),
196- Qt::AlignCenter,
197- syncEnabled ? QIcon::Normal : QIcon::Disabled
198- );
266+ // NMC Customization
267+ if (!parentIndex.isValid ()) {
268+ QIcon nmcFolderIcon = QIcon (QLatin1String (" :/client/theme/NMCIcons/folderLogo.svg" ));
269+ const auto nmcFolderPixmap = nmcFolderIcon.pixmap (iconSize, iconSize, QIcon::Normal);
270+ painter->drawPixmap (QStyle::visualRect (option.direction , option.rect , iconRect).left (), iconRect.top (), nmcFolderPixmap);
271+
272+ const QSize statusIconSize (24 ,24 );
273+ const auto statusPixmap = statusIcon.pixmap (statusIconSize.width (), statusIconSize.height (), syncEnabled ? QIcon::Normal : QIcon::Disabled);
274+ painter->drawPixmap (QStyle::visualRect (option.direction , option.rect , iconRect).right () - statusIconSize.width () * 0.6 , iconRect.bottom () - statusIconSize.height () * 0.8 , statusPixmap);
275+ } else {
276+ const auto statusPixmap = statusIcon.pixmap (iconSize, iconSize, syncEnabled ? QIcon::Normal : QIcon::Disabled);
277+ painter->drawPixmap (QStyle::visualRect (option.direction , option.rect , iconRect).left (), iconRect.top (), statusPixmap);
278+ }
199279
200280 auto palette = option.palette ;
201281
@@ -267,18 +347,23 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
267347 drawTextBox (infoTexts, QColor (0x4d , 0x4d , 0xba ));
268348 }
269349
350+ // NMC customization: we need these infos already here to adjust the progress bar
351+ const QRect currentButtonRectPos = moreRectPos (option.rect );
352+ const int nmcWidth = currentButtonRectPos.x () - nextToIcon - 8 ; // 8 is the margin to "More" button
353+
270354 // Sync File Progress Bar: Show it if syncFile is not empty.
271355 if (showProgess) {
272356 const auto fileNameTextHeight = subFm.boundingRect (tr (" File" )).height ();
273357 constexpr auto barHeight = 7 ; // same height as quota bar
274358 const auto overallWidth = option.rect .right () - aliasMargin - optionsButtonVisualRect.width () - nextToIcon;
359+ Q_UNUSED (overallWidth);
275360
276361 painter->save ();
277362
278363 // Overall Progress Bar.
279364 const auto progressBarRect = QRect (nextToIcon,
280365 remotePathRect.top (),
281- overallWidth - 2 * margin ,
366+ nmcWidth ,
282367 barHeight);
283368
284369 QStyleOptionProgressBar progressBarOpt;
@@ -310,21 +395,55 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
310395 painter->restore ();
311396 }
312397
313- painter->restore ();
314-
315398 {
316399 QStyleOptionToolButton btnOpt;
317400 btnOpt.state = option.state ;
318401 btnOpt.state &= ~(QStyle::State_Selected | QStyle::State_HasFocus);
319402 btnOpt.state |= QStyle::State_Raised;
320403 btnOpt.arrowType = Qt::NoArrow;
321404 btnOpt.subControls = QStyle::SC_ToolButton;
322- btnOpt.rect = optionsButtonVisualRect;
405+ // NMC customization
406+ btnOpt.rect = currentButtonRectPos;
407+ // make sure the button is not too far away from the left border
408+ btnOpt.rect .setRight (btnOpt.rect .x () + btnOpt.rect .width () + 4 );
409+
410+ // Create QPainterPath with rounded corners
411+ QPainterPath path;
412+ path.addRoundedRect (btnOpt.rect , 4 , 4 ); // 4 ist der Radius für die abgerundeten Ecken
413+
414+ // Draw border line
415+ QPen borderPen (QColor (0 , 0 , 0 )); // Beispiel: Schwarzer Rand
416+ borderPen.setWidth (1 );
417+ painter->setPen (borderPen);
418+ painter->drawPath (path);
419+
420+ // Fill the rectangle
421+ painter->fillPath (path, Qt::transparent);
422+
423+ // Draw the icon in rectangle
323424 btnOpt.icon = _iconMore;
324425 const auto buttonSize = QApplication::style ()->pixelMetric (QStyle::PM_ButtonIconSize);
325426 btnOpt.iconSize = QSize (buttonSize, buttonSize);
326- QApplication::style ()->drawComplexControl (QStyle::CC_ToolButton, &btnOpt, painter);
427+
428+ // Set icon position
429+ int iconX = btnOpt.rect .x () + btnOpt.rect .width ()/5 ;
430+ int iconY = btnOpt.rect .y () + (btnOpt.rect .height () - btnOpt.iconSize .height ()) / 2 ;
431+
432+ painter->drawPixmap (iconX, iconY, btnOpt.icon .pixmap (btnOpt.iconSize ));
433+
434+ // Add text
435+ const QString buttonText = QCoreApplication::translate (" " , " MORE" );
436+ painter->setFont (btnOpt.font );
437+ painter->setPen (option.palette .color (QPalette::ButtonText));
438+ int textX = iconX + btnOpt.iconSize .width () + 10 ;
439+ int textY = iconY;
440+ int textWidth = currentButtonRectPos.x () + currentButtonRectPos.width () - textX;
441+ int textHeight = btnOpt.fontMetrics .height ();
442+
443+ painter->drawText (QRect (textX, textY, textWidth, textHeight), Qt::AlignLeft | Qt::AlignVCenter, buttonText);
327444 }
445+
446+ painter->restore ();
328447}
329448
330449bool FolderStatusDelegate::editorEvent (QEvent *event, QAbstractItemModel *model,
0 commit comments