task#85459 主题框架实现一键切换机制 / 文件管理器一键切换适配

This commit is contained in:
兰悦 2022-05-24 05:40:38 +00:00 committed by Yue-Lan
parent 616f9f24c1
commit 378cb56ae2
15 changed files with 45 additions and 48 deletions

View File

@ -34,6 +34,8 @@
#include <openssl/aes.h>
#include <glib.h>
#include <QApplication>
using namespace Peony;
static const QString ftpTypeStr="ftp";
static const QString sftpTypeStr="sftp";
@ -73,7 +75,7 @@ void ButtonStyle::drawControl(QStyle::ControlElement element, const QStyleOption
default:
break;
}
QProxyStyle::drawControl(element, option, painter, widget);
qApp->style()->drawControl(element, option, painter, widget);
}
int ButtonStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const

View File

@ -57,7 +57,7 @@ void IconViewStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyle
if (element == PE_Frame) {
return;
}
return QProxyStyle::drawPrimitive(element, option, painter, widget);
return qApp->style()->drawPrimitive(element, option, painter, widget);
}
void IconViewStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
@ -71,20 +71,20 @@ void IconViewStyle::drawControl(QStyle::ControlElement element, const QStyleOpti
} else {
opt.rect = QRect();
}
return QProxyStyle::drawControl(element, &opt, painter, widget);
return qApp->style()->drawControl(element, &opt, painter, widget);
}
}
QProxyStyle::drawControl(element, option, painter, widget);
qApp->style()->drawControl(element, option, painter, widget);
}
void IconViewStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
{
//qDebug()<<"drawItemPixmap";
QProxyStyle::drawItemPixmap(painter, rect, alignment, pixmap);
qApp->style()->drawItemPixmap(painter, rect, alignment, pixmap);
}
void IconViewStyle::drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole) const
{
//qDebug()<<"drawItemText";
QProxyStyle::drawItemText(painter, rect, flags, pal, enabled, text, textRole);
qApp->style()->drawItemText(painter, rect, flags, pal, enabled, text, textRole);
}

View File

@ -28,6 +28,8 @@
#include <QStyleOptionViewItem>
#include <QTextLayout>
#include <QApplication>
using namespace Peony;
using namespace Peony::DirectoryView;
@ -180,7 +182,7 @@ void ListViewStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyle
opt.palette.setColor(QPalette::Highlight, opt.palette.mid().color());
}
}
return QProxyStyle::drawPrimitive(element, &opt, painter, widget);
return qApp->style()->drawPrimitive(element, &opt, painter, widget);
}
case QStyle::PE_IndicatorItemViewItemDrop: {
if (option->rect.height() <= 1) {
@ -195,7 +197,7 @@ void ListViewStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyle
return;
}
default:
return QProxyStyle::drawPrimitive(element, option, painter, widget);
return qApp->style()->drawPrimitive(element, option, painter, widget);
}
}
@ -279,7 +281,7 @@ void ListViewStyle::drawControl(QStyle::ControlElement element, const QStyleOpti
default:
break;
}
return QProxyStyle::drawControl(element, option, painter, widget);
return qApp->style()->drawControl(element, option, painter, widget);
}
//绘制列表视图文本
void ListViewStyle::viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const

View File

@ -84,8 +84,6 @@ ListView::ListView(QWidget *parent) : QTreeView(parent)
setAutoFillBackground(true);
setBackgroundRole(QPalette::Base);
setItemDelegate(new ListViewDelegate(this));
header()->setSectionResizeMode(QHeaderView::Interactive);
header()->setSectionsMovable(true);
//header()->setStretchLastSection(true);

View File

@ -28,6 +28,8 @@
#include <QGraphicsDropShadowEffect>
#include <QApplication>
using namespace Peony;
IconContainer::IconContainer(QWidget *parent) : QPushButton(parent)
@ -81,5 +83,5 @@ void IconContainerStyle::drawControl(QStyle::ControlElement element, const QStyl
return;
}
}
return QProxyStyle::drawControl(element, option, painter, widget);
return qApp->style()->drawControl(element, option, painter, widget);
}

View File

@ -577,18 +577,18 @@ void LocationBarButtonStyle::drawComplexControl(QStyle::ComplexControl control,
auto opt = *toolButton;
if (widget && widget->objectName() == "peony_location_bar_indicator") {
opt.features.setFlag(QStyleOptionToolButton::HasMenu, false);
return QProxyStyle::drawComplexControl(control, &opt, painter);
return qApp->style()->drawComplexControl(control, &opt, painter);
} else {
opt.rect.adjust(1, 1, -1, -1);
}
return QProxyStyle::drawComplexControl(control, &opt, painter, widget);
return qApp->style()->drawComplexControl(control, &opt, painter, widget);
}
return QProxyStyle::drawComplexControl(control, option, painter, widget);
return qApp->style()->drawComplexControl(control, option, painter, widget);
}
void LocationBarButtonStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
return QProxyStyle::drawControl(element, option, painter, widget);
return qApp->style()->drawControl(element, option, painter, widget);
}
IndicatorToolButton::IndicatorToolButton(QWidget *parent) : QToolButton(parent)

View File

@ -63,6 +63,8 @@
#include "file-operation-manager.h"
#include "open-with-properties-page.h"
#include <QApplication>
using namespace Peony;
static PushButtonStyle *global_instance = nullptr;
@ -94,7 +96,7 @@ void PushButtonStyle::drawControl(QStyle::ControlElement element, const QStyleOp
default:
break;
}
QProxyStyle::drawControl(element, option, painter, widget);
qApp->style()->drawControl(element, option, painter, widget);
}
int PushButtonStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const

View File

@ -33,6 +33,8 @@
#include <QPainter>
#include <QPainterPath>
#include <QApplication>
using namespace Peony;
static ToolButtonStyle *global_instance = nullptr;
SearchBarContainer::SearchBarContainer(QWidget *parent): QWidget(parent)
@ -236,9 +238,9 @@ void ToolButtonStyle::drawComplexControl(QStyle::ComplexControl control, const Q
QPainterPath path;
path.addEllipse(widget->rect().adjusted(2, 2, -2, -2));
painter->setClipPath(path);
QProxyStyle::drawComplexControl(control, option, painter, widget);
qApp->style()->drawComplexControl(control, option, painter, widget);
painter->restore();
} else {
QProxyStyle::drawComplexControl(control, option, painter, widget);
qApp->style()->drawComplexControl(control, option, painter, widget);
}
}

View File

@ -14,18 +14,3 @@ Peony--DirectoryView--IconView::Item::selected
{
background-color: transparent;
}
Peony--DirectoryView--ListView::Item::hover
{
background-color: transparent;
}
Peony--SideBar::Item::hover
{
background-color: transparent;
}
Peony--SideBar::Item::selected
{
background-color: transparent;
}

View File

@ -54,6 +54,8 @@
#include <gio/gdesktopappinfo.h>
#include <pwd.h>
#include <QApplication>
#include "file-info-job.h"
using namespace Peony;
@ -697,7 +699,7 @@ void tabStyle::drawControl(QStyle::ControlElement element, const QStyleOption *o
}
}
if (element == CE_TabBarTabLabel) {
QProxyStyle::drawControl(element, option, painter, widget);
qApp->style()->drawControl(element, option, painter, widget);
}
}

View File

@ -642,10 +642,10 @@ void HeaderBarStyle::drawComplexControl(QStyle::ComplexControl control, const QS
button.features |= QStyleOptionToolButton::MenuButtonPopup;
button.subControls |= QStyle::SC_ToolButtonMenu;
}
return QProxyStyle::drawComplexControl(control, &button, painter, widget);
return qApp->style()->drawComplexControl(control, &button, painter, widget);
}
}
return QProxyStyle::drawComplexControl(control, option, painter, widget);
return qApp->style()->drawComplexControl(control, option, painter, widget);
}
void HeaderBarStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
@ -653,7 +653,7 @@ void HeaderBarStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyl
if (element == PE_IndicatorToolBarSeparator) {
return;
}
return QProxyStyle::drawPrimitive(element, option, painter, widget);
return qApp->style()->drawPrimitive(element, option, painter, widget);
}
HeaderBarContainer::HeaderBarContainer(QWidget *parent) : QToolBar(parent)

View File

@ -67,6 +67,8 @@
#include <QStyleOptionViewItem>
#include <QApplication>
#define NAVIGATION_SIDEBAR_ITEM_BORDER_RADIUS 4
using namespace Peony;
@ -617,7 +619,7 @@ void NavigationSideBarStyle::drawPrimitive(QStyle::PrimitiveElement element, con
opt.palette.setColor(QPalette::Highlight, opt.palette.mid().color());
}
}
QProxyStyle::drawPrimitive(element, &opt, painter, widget);
qApp->style()->drawPrimitive(element, &opt, painter, widget);
painter->restore();
return;
}
@ -633,7 +635,7 @@ void NavigationSideBarStyle::drawPrimitive(QStyle::PrimitiveElement element, con
break;
}
QProxyStyle::drawPrimitive(element, option, painter, widget);
qApp->style()->drawPrimitive(element, option, painter, widget);
painter->restore();
}
@ -650,6 +652,6 @@ void NavigationSideBarStyle::drawControl(QStyle::ControlElement element, const Q
opt.palette.setColor(QPalette::Highlight, opt.palette.mid().color());
}
}
return QProxyStyle::drawControl(element, &opt, painter, widget);
return qApp->style()->drawControl(element, &opt, painter, widget);
}
}

View File

@ -372,10 +372,10 @@ void TabBarStyle::drawComplexControl(QStyle::ComplexControl control, const QStyl
QPainterPath path;
path.addEllipse(widget->rect().adjusted(2, 2, -2, -2));
painter->setClipPath(path);
QProxyStyle::drawComplexControl(control, option, painter, widget);
qApp->style()->drawComplexControl(control, option, painter, widget);
painter->restore();
} else {
QProxyStyle::drawComplexControl(control, option, painter, widget);
qApp->style()->drawComplexControl(control, option, painter, widget);
}
}
@ -384,7 +384,7 @@ void TabBarStyle::drawControl(QStyle::ControlElement element, const QStyleOption
if (widget && widget->objectName() == "previewButtons") {
return;
}
QProxyStyle::drawControl(element, option, painter, widget);
qApp->style()->drawControl(element, option, painter, widget);
}
void TabBarStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
@ -394,9 +394,9 @@ void TabBarStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOp
case PE_IndicatorArrowRight: {
QStyleOption tmp = *option;
tmp.palette.setColor(QPalette::HighlightedText, qApp->palette().buttonText().color());
return QProxyStyle::drawPrimitive(element, &tmp, painter, widget);
return qApp->style()->drawPrimitive(element, &tmp, painter, widget);
}
default:
return QProxyStyle::drawPrimitive(element, option, painter, widget);
return qApp->style()->drawPrimitive(element, option, painter, widget);
}
}

View File

@ -96,7 +96,7 @@ void PushButtonStyle::drawControl(QStyle::ControlElement element, const QStyleOp
default:
break;
}
QProxyStyle::drawControl(element, option, painter, widget);
qApp->style()->drawControl(element, option, painter, widget);
}
int PushButtonStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const

View File

@ -139,7 +139,7 @@ PeonyApplication::PeonyApplication(int &argc, char *argv[], const char *applicat
QTranslator *t3 = new QTranslator(this);
t3->load("/usr/share/qt5/translations/qt_"+QLocale::system().name());
QApplication::installTranslator(t3);
setStyle(Peony::ComplementaryStyle::getStyle());
//setStyle(Peony::ComplementaryStyle::getStyle());
setApplicationName(tr("peony-qt"));