File indexing completed on 2025-03-09 04:46:57
0001 /* 0002 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "fancyheaderstyleplugin.h" 0008 #include "fancyheaderstyle.h" 0009 #include "fancyheaderstyleinterface.h" 0010 #include <KLocalizedString> 0011 #include <KPluginFactory> 0012 #include <MessageViewer/RichHeaderStrategy> 0013 #include <QApplication> 0014 0015 using namespace MessageViewer; 0016 0017 K_PLUGIN_CLASS_WITH_JSON(FancyHeaderStylePlugin, "messageviewer_fancyheaderstyleplugin.json") 0018 0019 FancyHeaderStylePlugin::FancyHeaderStylePlugin(QObject *parent, const QList<QVariant> &) 0020 : MessageViewer::HeaderStylePlugin(parent) 0021 , mHeaderStyle(new FancyHeaderStyle) 0022 , mHeaderStrategy(new RichHeaderStrategy) 0023 { 0024 } 0025 0026 FancyHeaderStylePlugin::~FancyHeaderStylePlugin() 0027 { 0028 delete mHeaderStyle; 0029 delete mHeaderStrategy; 0030 } 0031 0032 HeaderStyle *FancyHeaderStylePlugin::headerStyle() const 0033 { 0034 return mHeaderStyle; 0035 } 0036 0037 HeaderStrategy *FancyHeaderStylePlugin::headerStrategy() const 0038 { 0039 return mHeaderStrategy; 0040 } 0041 0042 HeaderStyleInterface *FancyHeaderStylePlugin::createView(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac, QObject *parent) 0043 { 0044 MessageViewer::HeaderStyleInterface *view = new MessageViewer::FancyHeaderStyleInterface(this, parent); 0045 if (ac) { 0046 view->createAction(menu, actionGroup, ac); 0047 } 0048 return view; 0049 } 0050 0051 QString FancyHeaderStylePlugin::name() const 0052 { 0053 return QStringLiteral("fancy"); 0054 } 0055 0056 int FancyHeaderStylePlugin::elidedTextSize() const 0057 { 0058 return 1000; 0059 } 0060 0061 QString FancyHeaderStylePlugin::extraScreenCss(const QString &headerFont) const 0062 { 0063 Q_UNUSED(headerFont) 0064 const QPalette &pal = QApplication::palette(); 0065 const QString val = QStringLiteral( 0066 "div.fancy.header > div {\n" 0067 " background-color: %1 ! important;\n" 0068 " color: %2 ! important;\n" 0069 " border: solid %3 1px ! important;\n" 0070 " line-height: normal;\n" 0071 "}\n\n" 0072 0073 "div.fancy.header > div a[href] { color: %2 ! important; }\n\n" 0074 0075 "div.fancy.header > div a[href]:hover { text-decoration: underline ! important; }\n\n" 0076 0077 "div.fancy.header > div.spamheader {\n" 0078 " background-color: #cdcdcd ! important;\n" 0079 " border-top: 0px ! important;\n" 0080 " padding: 3px ! important;\n" 0081 " color: black ! important;\n" 0082 " font-weight: bold ! important;\n" 0083 " font-size: smaller ! important;\n" 0084 "}\n\n" 0085 0086 "div.fancy.header > table.outer {\n" 0087 " all: inherit;\n" 0088 " width: auto ! important;\n" 0089 " border-spacing: 0;\n" 0090 " background-color: %4 ! important;\n" 0091 " color: %3 ! important;\n" 0092 " border-bottom: solid %3 1px ! important;\n" 0093 " border-left: solid %3 1px ! important;\n" 0094 " border-right: solid %3 1px ! important;\n" 0095 "}\n\n") 0096 .arg(pal.color(QPalette::Highlight).name(), 0097 pal.color(QPalette::HighlightedText).name(), 0098 pal.color(QPalette::WindowText).name(), 0099 pal.color(QPalette::Window).name()); 0100 return val; 0101 } 0102 0103 QString FancyHeaderStylePlugin::extraPrintCss(const QString &headerFont) const 0104 { 0105 Q_UNUSED(headerFont) 0106 const QPalette &pal = QApplication::palette(); 0107 const QString val = QStringLiteral( 0108 "div.fancy.header > div {\n" 0109 " background-color: %1 ! important;\n" 0110 " color: %2 ! important;\n" 0111 " padding: 4px ! important;\n" 0112 " border: solid %2 1px ! important;\n" 0113 " line-height: normal;\n" 0114 "}\n\n" 0115 0116 "div.fancy.header > div a[href] { color: %2 ! important; }\n\n" 0117 0118 "div.fancy.header > table.outer{\n" 0119 " all: inherit;\n" 0120 " width: auto ! important;\n" 0121 " border-spacing: 0;\n" 0122 " background-color: %1 ! important;\n" 0123 " color: %2 ! important;\n" 0124 " border-bottom: solid %2 1px ! important;\n" 0125 " border-left: solid %2 1px ! important;\n" 0126 " border-right: solid %2 1px ! important;\n" 0127 "}\n\n") 0128 .arg(pal.color(QPalette::Window).name(), pal.color(QPalette::WindowText).name()); 0129 return val; 0130 } 0131 0132 QString FancyHeaderStylePlugin::extraCommonCss(const QString &headerFont) const 0133 { 0134 const QPalette &pal = QApplication::palette(); 0135 const QString val = QStringLiteral( 0136 "div.fancy.header table {\n" 0137 " width: 100% ! important;\n" 0138 " table-layout: auto;\n" 0139 " border-width: 0px ! important;\n" 0140 " line-height: normal;\n" 0141 "}\n\n" 0142 0143 "div.fancy.header > div {\n" 0144 " font-weight: bold ! important;\n" 0145 " padding: 4px ! important;\n" 0146 " line-height: normal;\n" 0147 "}\n\n" 0148 0149 "div.fancy.header table {\n" 0150 " padding: 2px ! important;\n" 0151 " text-align: left ! important;\n" 0152 " border-collapse: separate ! important;\n" 0153 "}\n\n" 0154 0155 "div.fancy.header table th {\n" 0156 " %3\n" 0157 " width: 0% ! important;\n" 0158 " padding: 0px ! important;\n" 0159 " white-space: nowrap ! important;\n" 0160 " border-spacing: 0px ! important;\n" 0161 " text-align: left ! important;\n" 0162 " vertical-align: top ! important;\n" 0163 " background-color: %1 ! important;\n" 0164 " color: %2 ! important;\n" 0165 " border: 1px ! important;\n" 0166 0167 "}\n\n" 0168 0169 "div.fancy.header table td {\n" 0170 " %3\n" 0171 " padding: 0px ! important;\n" 0172 " border-spacing: 0px ! important;\n" 0173 " text-align: left ! important;\n" 0174 " vertical-align: top ! important;\n" 0175 " width: 100% ! important;\n" 0176 " background-color: %1 ! important;\n" 0177 " color: %2 ! important;\n" 0178 " border: 1px ! important;\n" 0179 "}\n\n" 0180 0181 "div.fancy.header table a:hover {\n" 0182 " background-color: transparent ! important;\n" 0183 "}\n\n") 0184 .arg(pal.color(QPalette::Window).name(), pal.color(QPalette::WindowText).name(), headerFont); 0185 return val; 0186 } 0187 0188 QString MessageViewer::FancyHeaderStylePlugin::attachmentHtml() const 0189 { 0190 return QStringLiteral("<div style=\"float:left;\">%1 </div>").arg(i18n("Attachments:")); 0191 } 0192 0193 #include "fancyheaderstyleplugin.moc" 0194 0195 #include "moc_fancyheaderstyleplugin.cpp"