Skip to content

Commit

Permalink
Merge pull request #121 from Infomaniak/KDESKTOP-857-Conflict-resolut…
Browse files Browse the repository at this point in the history
…ion-window-Wrong-color-of-text-in-dark-theme

KDESKTOP-857-Conflict-resolution-window-Wrong-color-of-text-in-dark-theme
  • Loading branch information
ClementKunz authored May 16, 2024
2 parents fde913f + ee45a77 commit e3adcfa
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 81 deletions.
1 change: 1 addition & 0 deletions resources/styles/stylesheetblack.qss
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,7 @@ KDC--AccountItemWidget QLabel#statusLabel
KDC--AbstractFileItemWidget
{
qproperty-background_color: #35393D;
qproperty-logo_color: #C0C0C0;
}

KDC--AbstractFileItemWidget QLabel#fileNameLabel
Expand Down
9 changes: 5 additions & 4 deletions resources/styles/stylesheetwhite.qss
Original file line number Diff line number Diff line change
Expand Up @@ -1233,37 +1233,38 @@ KDC--AccountItemWidget QLabel#statusLabel
KDC--AbstractFileItemWidget
{
qproperty-background_color: #FFFFFF;
qproperty-logo_color: #666666;
}

KDC--AbstractFileItemWidget QLabel#fileNameLabel
{
color: #444444;
font-family: "Suisse Int'l";
font-weight: $$medium_font$$;
font-weight: $$medium_font$$; /* medium */
font-size: 14px;
}

KDC--AbstractFileItemWidget QLabel#errorLabel
{
color: #666666;
font-family: "Suisse Int'l";
font-weight: $$normal_font$$;
font-weight: $$normal_font$$; /* normal */
font-size: 12px;
}

KDC--AbstractFileItemWidget QLabel#filePathLabel
{
color: #0098FF;
font-family: "Suisse Int'l";
font-weight: $$normal_font$$;
font-weight: $$normal_font$$; /* normal */
font-size: 11px;
}

KDC--AbstractFileItemWidget QLabel#fileDateLabel
{
color: #666666;
font-family: "Suisse Int'l";
font-weight: $$normal_font$$;
font-weight: $$normal_font$$; /* normal */
font-size: 12px;
}

Expand Down
58 changes: 35 additions & 23 deletions src/gui/abstractfileitemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,40 @@

namespace KDC {

static const int filePathMaxSize = 50;
static const int cornerRadius = 10;
static const int hMargin = 20;
static const int vMargin = 5;
static const int boxVSpacing = 10;
static const int shadowBlurRadius = 20;
static const QSize iconSize = QSize(15, 15);

AbstractFileItemWidget::AbstractFileItemWidget(QWidget *parent /*= nullptr*/) : QWidget(parent) {
AbstractFileItemWidget::AbstractFileItemWidget(QWidget *parent /*= nullptr*/)
: QWidget(parent)
, _topLayout(new QHBoxLayout)
, _fileTypeIconLabel(new QLabel)
, _filenameLabel(new QLabel)
, _middleLayout(new QHBoxLayout)
, _messageLabel(new QLabel)
, _bottomLayout(new QHBoxLayout)
, _driveIconLabel(new QLabel)
, _pathLabel(new QLabel)
{
setContentsMargins(hMargin, vMargin, hMargin, vMargin);

QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto mainLayout = new QVBoxLayout;
mainLayout->setSpacing(boxVSpacing);
setLayout(mainLayout);

// Top layout
_topLayout = new QHBoxLayout(this);
_topLayout->setContentsMargins(0, 0, 0, 0);
_topLayout->setAlignment(Qt::AlignVCenter);

_fileTypeIconLabel = new QLabel(this);
_fileTypeIconLabel->setObjectName("fileNameLabel");
_fileTypeIconLabel->setMinimumSize(iconSize);
_fileTypeIconLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
_topLayout->addWidget(_fileTypeIconLabel);

_filenameLabel = new QLabel(this);
_filenameLabel->setObjectName("fileNameLabel");
_filenameLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
_filenameLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
_filenameLabel->setMinimumHeight(16);
Expand All @@ -66,27 +74,25 @@ AbstractFileItemWidget::AbstractFileItemWidget(QWidget *parent /*= nullptr*/) :
mainLayout->addLayout(_topLayout);

// Middle layout
_middleLayout = new QHBoxLayout(this);
_middleLayout->setContentsMargins(0, 0, 0, 0);
_middleLayout->setAlignment(Qt::AlignVCenter);

_messageLabel = new QLabel(this);
_messageLabel->setObjectName("errorLabel");
_messageLabel->setWordWrap(true);
_messageLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
_messageLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
_middleLayout->addWidget(_messageLabel);

// Bottom layout
_bottomLayout = new QHBoxLayout(this);
_bottomLayout->setContentsMargins(0, 0, 0, 0);
_bottomLayout->setAlignment(Qt::AlignVCenter);

_driveIconLabel = new QLabel(this);
_driveIconLabel->setObjectName("errorLabel");
_driveIconLabel->setMinimumSize(iconSize);
_driveIconLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
_bottomLayout->addWidget(_driveIconLabel);

_pathLabel = new QLabel(this);
_pathLabel->setObjectName("filePathLabel");
_pathLabel->setContextMenuPolicy(Qt::PreventContextMenu);
_pathLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
_pathLabel->setMinimumHeight(16);
Expand All @@ -97,7 +103,7 @@ AbstractFileItemWidget::AbstractFileItemWidget(QWidget *parent /*= nullptr*/) :
mainLayout->addLayout(_bottomLayout);

// Shadow
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this);
auto effect = new QGraphicsDropShadowEffect;
effect->setBlurRadius(shadowBlurRadius);
effect->setOffset(0);
setGraphicsEffect(effect);
Expand All @@ -114,7 +120,7 @@ QSize AbstractFileItemWidget::sizeHint() const {
int height = _filenameLabel->sizeHint().height() + _messageLabel->sizeHint().height() + _pathLabel->sizeHint().height() +
2 * boxVSpacing;

return QSize(width(), height);
return {width(), height};
}

void AbstractFileItemWidget::setFilePath(const QString &filePath, NodeType type /*= NodeTypeFile*/) {
Expand All @@ -123,8 +129,6 @@ void AbstractFileItemWidget::setFilePath(const QString &filePath, NodeType type
}

void AbstractFileItemWidget::setDriveName(const QString &driveName, const QString &localPath) {
_driveIconLabel->setPixmap(
KDC::GuiUtility::getIconWithColor(":/client/resources/icons/actions/icon-folder-empty.svg").pixmap(iconSize));
QString str = QString("<a style=\"%1\" href=\"%2\">%3</a>").arg(CommonUtility::linkStyle, localPath, driveName);
_pathLabel->setText(str);
}
Expand All @@ -136,7 +140,7 @@ void AbstractFileItemWidget::setPathIconColor(const QColor &color) {

void AbstractFileItemWidget::setMessage(const QString &str) {
_messageLabel->setText(str);
QVBoxLayout *mainLayout = qobject_cast<QVBoxLayout *>(layout());
auto mainLayout = qobject_cast<QVBoxLayout *>(layout());
mainLayout->insertLayout(1, _middleLayout);
}

Expand All @@ -151,11 +155,17 @@ void AbstractFileItemWidget::openFolder(const QString &path) {
}
}

void AbstractFileItemWidget::setLogoColor(const QColor &color) {
_logoColor = color;
_driveIconLabel->setPixmap(
KDC::GuiUtility::getIconWithColor(":/client/resources/icons/actions/icon-folder-empty.svg", _logoColor).pixmap(iconSize));
}

void AbstractFileItemWidget::paintEvent(QPaintEvent *event) {
Q_UNUSED(event);

// Update shadow color
QGraphicsDropShadowEffect *effect = qobject_cast<QGraphicsDropShadowEffect *>(graphicsEffect());
auto effect = qobject_cast<QGraphicsDropShadowEffect *>(graphicsEffect());
if (effect) {
effect->setColor(KDC::GuiUtility::getShadowColor());
}
Expand All @@ -177,18 +187,20 @@ void AbstractFileItemWidget::setFileTypeIcon(const QString &ressourcePath) {

void AbstractFileItemWidget::setFileName(const QString &path, NodeType type) {
setFileTypeIcon(CommonUtility::getFileIconPathFromFileName(path, type));
QString test = QFileInfo(path).fileName();
_filenameLabel->setText(QFileInfo(path).fileName());
}

void AbstractFileItemWidget::setPath(const QString &path) {
_driveIconLabel->setPixmap(
KDC::GuiUtility::getIconWithColor(":/client/resources/icons/actions/icon-folder-empty.svg").pixmap(iconSize));
KDC::GuiUtility::getIconWithColor(":/client/resources/icons/actions/icon-folder-empty.svg", _logoColor).pixmap(iconSize));

QString printablePath = "/" + path;
if (printablePath.size() > filePathMaxSize) {
printablePath = printablePath.left(filePathMaxSize) + "...";
}
const QFileInfo fInfo(path);
QString printablePath;
if (!fInfo.isAbsolute()) printablePath = "/";
printablePath += path;
GuiUtility::makePrintablePath(printablePath);

printablePath = QDir::toNativeSeparators(printablePath);
QString pathStr = QString("<a style=\"%1\" href=\"%2\">%3</a>").arg(CommonUtility::linkStyle, path, printablePath);

_pathLabel->setText(pathStr);
Expand Down
4 changes: 4 additions & 0 deletions src/gui/abstractfileitemwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AbstractFileItemWidget : public QWidget {
Q_OBJECT

Q_PROPERTY(QColor background_color READ backgroundColor WRITE setBackgroundColor)
Q_PROPERTY(QColor logo_color READ logoColor WRITE setLogoColor)

public:
explicit AbstractFileItemWidget(QWidget *parent = nullptr);
Expand All @@ -57,13 +58,16 @@ class AbstractFileItemWidget : public QWidget {
private:
inline QColor backgroundColor() const { return _backgroundColor; }
inline void setBackgroundColor(const QColor &value) { _backgroundColor = value; }
inline QColor logoColor() const { return _logoColor; }
void setLogoColor(const QColor &value);
void paintEvent(QPaintEvent *event) override;

void setFileTypeIcon(const QString &ressourcePath);
void setFileName(const QString &path, NodeType type = NodeTypeFile);
void setPath(const QString &path);

QColor _backgroundColor;
QColor _logoColor;

QHBoxLayout *_topLayout = nullptr;
QLabel *_fileTypeIconLabel = nullptr;
Expand Down
10 changes: 2 additions & 8 deletions src/gui/bigfoldersdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ static const int undecidedItemBoxVSpacing = 0;
static const int undecidedItemPathSpacing = 6;
static const int undecidedItemPathDriveSpacing = 4;
static const int driveIconSize = 14;
static const int folderNameMaxSize = 50;
static const int locationPathMaxSize = 50;

static const char undecidedFolderProperty[] = "undecidedFolder";

Expand Down Expand Up @@ -120,9 +118,7 @@ BigFoldersDialog::BigFoldersDialog(const std::unordered_map<int, std::pair<SyncI

QLabel *folderName = new QLabel(this);
folderName->setObjectName("largeNormalBoldTextLabel");
if (name.size() > folderNameMaxSize) {
name = name.left(folderNameMaxSize) + "...";
}
GuiUtility::makePrintablePath(name);
folderName->setText(name);
folderName->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
undecidedItemVBox->addWidget(folderName);
Expand All @@ -146,9 +142,7 @@ BigFoldersDialog::BigFoldersDialog(const std::unordered_map<int, std::pair<SyncI

QLabel *locationPathLabel = new QLabel(this);
locationPathLabel->setObjectName("folderPathLabel");
if (path.size() > locationPathMaxSize) {
path = path.left(locationPathMaxSize) + "...";
}
GuiUtility::makePrintablePath(path);
locationPathLabel->setText(path);
locationPathLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
undecidedItemPathHBox->addWidget(locationPathLabel);
Expand Down
5 changes: 2 additions & 3 deletions src/gui/driveselectionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ void DriveSelectionWidget::selectDrive(int driveDbId) {
}

QString driveName = driveInfoIt->second.name();
if (driveName.size() > driveNameMaxSize) {
driveName = driveName.left(driveNameMaxSize) + "...";
}
GuiUtility::makePrintablePath(driveName, driveNameMaxSize);

_driveTextLabel->setText(driveName);
_downIconLabel->setVisible(true);
setDriveIcon(driveInfoIt->second.color());
Expand Down
8 changes: 5 additions & 3 deletions src/gui/errortabwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,15 @@ ErrorTabWidget::ErrorTabWidget(int driveDbId, bool generic, QWidget *parent)

_resolveButton = new QPushButton(this);
_resolveButton->setObjectName("resolveButton");
_resolveButton->setText(tr("Resolve"));
_resolveButton->setVisible(false);
MenuWidgetLite *menu = new MenuWidgetLite(_resolveButton, this);

_resolveConflictsAction = new QAction(tr("Conflicted item(s)"), this);
_resolveConflictsAction = new QAction(this);
_resolveConflictsAction->setVisible(false);
menu->addAction(_resolveConflictsAction);
connect(_resolveConflictsAction, &QAction::triggered, this, &ErrorTabWidget::onResolveConflictErrors);

_resolveUnsupportedCharactersAction = new QAction(tr("Item(s) with unsupported characters"), this);
_resolveUnsupportedCharactersAction = new QAction(this);
_resolveUnsupportedCharactersAction->setVisible(false);
menu->addAction(_resolveUnsupportedCharactersAction);
connect(_resolveUnsupportedCharactersAction, &QAction::triggered, this,
Expand Down Expand Up @@ -176,6 +175,9 @@ void ErrorTabWidget::retranslateUi() {
setTabText(tabIndex, tr("To Resolve"));
_toResolveErrorsLabel->setText(tr("problem(s) detected"));
_clearToResButton->setText(tr("Clear history"));
_resolveButton->setText(tr("Resolve"));
_resolveConflictsAction->setText(tr("Conflicted item(s)"));
_resolveUnsupportedCharactersAction->setText(tr("Item(s) with unsupported characters"));

if (!_generic) {
setTabText(++tabIndex, tr("Automatically resolved"));
Expand Down
9 changes: 2 additions & 7 deletions src/gui/fileerroritemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ static const int shadowBlurRadius = 20;
static const QSize statusIconSize = QSize(15, 15);
static const int fileErrorLabelMaxWidth = 375;
static const int fileNameMaxSize = 40;
static const int filePathMaxSize = 50;
static const QString dateFormat = "d MMM yyyy - HH:mm";

Q_LOGGING_CATEGORY(lcFileErrorItemWidget, "gui.fileerroritemwidget", QtInfoMsg)
Expand Down Expand Up @@ -70,9 +69,7 @@ FileErrorItemWidget::FileErrorItemWidget(const SynchronizedItem &item, const Dri
_fileNameLabel->setObjectName("fileNameLabel");
QFileInfo fileInfo(_item.filePath());
QString fileName = fileInfo.fileName();
if (fileName.size() > fileNameMaxSize) {
fileName = fileName.left(fileNameMaxSize) + "...";
}
GuiUtility::makePrintablePath(fileName, fileNameMaxSize);
_fileNameLabel->setText(fileName);
_fileNameLabel->setWordWrap(true);
vBoxMiddle->addWidget(_fileNameLabel);
Expand All @@ -98,9 +95,7 @@ FileErrorItemWidget::FileErrorItemWidget(const SynchronizedItem &item, const Dri
_pathLabel = new QLabel(this);
_pathLabel->setObjectName("filePathLabel");
QString filePath = driveInfo.name() + dirSeparator + fileInfo.path();
if (filePath.size() > filePathMaxSize) {
filePath = filePath.left(filePathMaxSize) + "...";
}
GuiUtility::makePrintablePath(filePath);
_pathLabel->setText(QString("<a style=\"%1\" href=\"ref\">%2</a>").arg(CommonUtility::linkStyle, filePath));
_pathLabel->setWordWrap(true);
_pathLabel->setContextMenuPolicy(Qt::PreventContextMenu);
Expand Down
Loading

0 comments on commit e3adcfa

Please sign in to comment.