summaryrefslogtreecommitdiff
path: root/src/moapplication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/moapplication.cpp')
-rw-r--r--src/moapplication.cpp51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/moapplication.cpp b/src/moapplication.cpp
index 7e3104db..f09b2fd9 100644
--- a/src/moapplication.cpp
+++ b/src/moapplication.cpp
@@ -25,6 +25,50 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QStringList>
#include <QPlastiqueStyle>
#include <QCleanlooksStyle>
+#include <QProxyStyle>
+#include <QStyleFactory>
+#include <QPainter>
+#include <QStyleOption>
+
+
+#include <QDebug>
+
+
+class ProxyStyle : public QProxyStyle {
+public:
+ ProxyStyle(QStyle *baseStyle = 0)
+ : QProxyStyle(baseStyle)
+ {
+ }
+
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const {
+ if(element == QStyle::PE_IndicatorItemViewItemDrop) {
+ painter->setRenderHint(QPainter::Antialiasing, true);
+
+ QColor col(option->palette.foreground().color());
+ QPen pen(col);
+ pen.setWidth(2);
+ col.setAlpha(50);
+ QBrush brush(col);
+
+ painter->setPen(pen);
+ painter->setBrush(brush);
+ if(option->rect.height() == 0) {
+ QPoint tri[3] = {
+ option->rect.topLeft(),
+ option->rect.topLeft() + QPoint(-5, 5),
+ option->rect.topLeft() + QPoint(-5, -5)
+ };
+ painter->drawPolygon(tri, 3);
+ painter->drawLine(QPoint(option->rect.topLeft().x(), option->rect.topLeft().y()), option->rect.topRight());
+ } else {
+ painter->drawRoundedRect(option->rect, 5, 5);
+ }
+ } else {
+ QProxyStyle::drawPrimitive(element, option, painter, widget);
+ }
+ }
+};
MOApplication::MOApplication(int argc, char **argv)
@@ -32,6 +76,7 @@ MOApplication::MOApplication(int argc, char **argv)
{
connect(&m_StyleWatcher, SIGNAL(fileChanged(QString)), SLOT(updateStyle(QString)));
m_DefaultStyle = style()->objectName();
+ setStyle(new ProxyStyle(style()));
}
@@ -79,13 +124,13 @@ bool MOApplication::notify(QObject *receiver, QEvent *event)
void MOApplication::updateStyle(const QString &fileName)
{
if (fileName == "Plastique") {
- setStyle(new QPlastiqueStyle);
+ setStyle(new ProxyStyle(new QPlastiqueStyle));
setStyleSheet("");
} else if (fileName == "Cleanlooks") {
- setStyle(new QCleanlooksStyle);
+ setStyle(new ProxyStyle(new QCleanlooksStyle));
setStyleSheet("");
} else {
- setStyle(m_DefaultStyle);
+ setStyle(new ProxyStyle(QStyleFactory::create(m_DefaultStyle)));
if (QFile::exists(fileName)) {
setStyleSheet(QString("file:///%1").arg(fileName));
} else {