For some Gtk styles, make it appear as if there is just one line between views.
This commit is contained in:
committed by
craig.p.drummond
parent
6ce8491b52
commit
0dd5b07989
@@ -31,6 +31,7 @@
|
||||
#include <QSpinBox>
|
||||
#include <QScrollBar>
|
||||
#include <QAbstractScrollArea>
|
||||
#include <QAbstractItemView>
|
||||
#include <QMenu>
|
||||
#include <QToolBar>
|
||||
#include <QApplication>
|
||||
@@ -85,15 +86,15 @@ static inline void addEventFilter(QObject *object, QObject *filter)
|
||||
object->installEventFilter(filter);
|
||||
}
|
||||
|
||||
GtkProxyStyle::GtkProxyStyle(ScrollbarType sb, bool styleSpin, const QMap<QString, QString> &c)
|
||||
GtkProxyStyle::GtkProxyStyle(ScrollbarType sb, bool styleSpin, const QMap<QString, QString> &c, bool modView)
|
||||
: QProxyStyle()
|
||||
, sbarType(sb)
|
||||
, touchStyleSpin(styleSpin)
|
||||
, modViewFrame(modView)
|
||||
, css(c)
|
||||
{
|
||||
shortcutHander=new ShortcutHandler(this);
|
||||
|
||||
sbarType=sb;
|
||||
touchStyleSpin=styleSpin;
|
||||
|
||||
if (SB_Standard!=sbarType) {
|
||||
QByteArray env=qgetenv("LIBOVERLAY_SCROLLBAR");
|
||||
if (!env.isEmpty() && env!="1") {
|
||||
@@ -388,6 +389,15 @@ void GtkProxyStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *
|
||||
painter->fillRect(option->rect, option->palette.brush(QPalette::Base));
|
||||
} else {
|
||||
baseStyle()->drawPrimitive(element, option, painter, widget);
|
||||
if (modViewFrame && PE_Frame==element && widget && widget->property(GtkStyle::constHideFrameProp).isValid()) {
|
||||
const QRect &r=option->rect;
|
||||
painter->setPen(QPen(option->palette.color(QPalette::Base), 1));
|
||||
if (Qt::LeftToRight==option->direction) {
|
||||
painter->drawLine(r.topRight()+QPoint(0, 1), r.bottomRight()+QPoint(0, -1));
|
||||
} else {
|
||||
painter->drawLine(r.topLeft()+QPoint(0, 1), r.bottomLeft()+QPoint(0, -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
SB_Thin
|
||||
};
|
||||
|
||||
GtkProxyStyle(ScrollbarType sb, bool styleSpin, const QMap<QString, QString> &c);
|
||||
GtkProxyStyle(ScrollbarType sb, bool styleSpin, const QMap<QString, QString> &c, bool modView);
|
||||
~GtkProxyStyle();
|
||||
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
||||
int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const;
|
||||
@@ -60,6 +60,7 @@ private:
|
||||
ScrollbarType sbarType;
|
||||
int sbarPlainViewWidth;
|
||||
bool touchStyleSpin;
|
||||
bool modViewFrame;
|
||||
QMap<QString, QString> css;
|
||||
};
|
||||
|
||||
|
||||
@@ -233,6 +233,8 @@ static ProxyStyle *plainProxyStyle=0;
|
||||
static bool symbolicIcons=false;
|
||||
static QColor symbolicIconColor(0, 0, 0);
|
||||
|
||||
const char * GtkStyle::constHideFrameProp="hide-frame";
|
||||
|
||||
void GtkStyle::applyTheme(QWidget *widget)
|
||||
{
|
||||
#if defined Q_OS_WIN || defined QT_NO_STYLE_GTK
|
||||
@@ -248,6 +250,7 @@ void GtkStyle::applyTheme(QWidget *widget)
|
||||
QString theme=GtkStyle::themeName().toLower();
|
||||
GtkProxyStyle::ScrollbarType sbType=GtkProxyStyle::SB_Standard;
|
||||
bool touchStyleSpin=false;
|
||||
bool modViewFrame=false;
|
||||
QMap<QString, QString> css;
|
||||
WindowManager *wm=0;
|
||||
if (!theme.isEmpty()) {
|
||||
@@ -270,6 +273,7 @@ void GtkStyle::applyTheme(QWidget *widget)
|
||||
sbType=GtkProxyStyle::SB_Thin;
|
||||
}
|
||||
touchStyleSpin=line.contains("spinbox:touch");
|
||||
modViewFrame=line.contains("modview:true");
|
||||
int pos=line.indexOf(symKey);
|
||||
if (pos>0 && pos+6<line.length()) {
|
||||
symbolicIcons=true;
|
||||
@@ -286,7 +290,7 @@ void GtkStyle::applyTheme(QWidget *widget)
|
||||
}
|
||||
}
|
||||
if (!gtkProxyStyle) {
|
||||
gtkProxyStyle=new GtkProxyStyle(sbType, touchStyleSpin, css);
|
||||
gtkProxyStyle=new GtkProxyStyle(sbType, touchStyleSpin, css, modViewFrame);
|
||||
qApp->setStyle(gtkProxyStyle);
|
||||
QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ class QWidget;
|
||||
|
||||
namespace GtkStyle
|
||||
{
|
||||
extern const char * constHideFrameProp;
|
||||
|
||||
extern bool isActive();
|
||||
extern void drawSelection(const QStyleOptionViewItemV4 &opt, QPainter *painter, double opacity);
|
||||
extern QString themeName();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* drag:toolbar scrollbar:overlay symbolic-icons:#dfdbd2 spinbox:touch*/
|
||||
/* drag:toolbar scrollbar:overlay symbolic-icons:#dfdbd2 spinbox:touch modview:true*/
|
||||
|
||||
QToolBar#MainToolBar { background-color: #3c3b37; border: 0px;} QToolBar#MainToolBar:active { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #3c3b37, stop: 1 #575651); border: 0px;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel { color: #bfbbb2;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel:active { color: #dfdbd2;} QToolBar#MainToolBar QToolButton:disabled,QToolBar#MainToolBar QLabel:disabled { color: #9f9b92;} QToolBar#MainToolBar QToolButton { background: transparent; border: 1px outset transparent;} QToolBar#MainToolBar QToolButton:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #464640, stop: 1 #303025); border-radius: 5px; border: 1px outset #3c3b37;} QToolBar#MainToolBar QToolButton:pressed,QToolBar#MainToolBar QToolButton:checked { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #383730, stop: 1 #2b2c27); border-radius: 5px; border: 1px inset #292825;} QToolBar#MainToolBar:separator { width: 1px; background: #3f3b32; margin-top: 4px; margin-bottom: 4px; margin-left: 7px; margin-right: 7px;}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* drag:toolbar scrollbar:overlay symbolic-icons:#dfdbd2 spinbox:touch*/
|
||||
/* drag:toolbar scrollbar:overlay symbolic-icons:#dfdbd2 spinbox:touch modview:true*/
|
||||
|
||||
QToolBar#MainToolBar { background-color: #3c3b37; border: 0px;} QToolBar#MainToolBar:active { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #3c3b37, stop: 1 #575651); border: 0px;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel { color: #bfbbb2;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel:active { color: #dfdbd2;} QToolBar#MainToolBar QToolButton:disabled,QToolBar#MainToolBar QLabel:disabled { color: #9f9b92;} QToolBar#MainToolBar QToolButton { background: transparent; border: 1px outset transparent;} QToolBar#MainToolBar QToolButton:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #464640, stop: 1 #303025); border-radius: 5px; border: 1px outset #3c3b37;} QToolBar#MainToolBar QToolButton:pressed,QToolBar#MainToolBar QToolButton:checked { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #383730, stop: 1 #2b2c27); border-radius: 5px; border: 1px inset #292825;} QToolBar#MainToolBar:separator { width: 1px; background: #3f3b32; margin-top: 4px; margin-bottom: 4px; margin-left: 7px; margin-right: 7px;}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* drag:toolbar scrollbar:overlay symbolic-icons:#3d434f spinbox:touch*/
|
||||
/* drag:toolbar scrollbar:overlay symbolic-icons:#3d434f spinbox:touch modview:true*/
|
||||
|
||||
QToolBar#MainToolBar { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ececec, stop: 1 #d2d2d2); border: 0px;} QToolBar#MainToolBar:active { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #cccccc, stop: 1 #b0b0b0); border: 0px;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel { color: #222222;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel:active { color: #222222;} QToolBar#MainToolBar QToolButton { background: transparent; border: 1px outset transparent;} QToolBar#MainToolBar QToolButton:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #eeeeee, stop: 1 #d8d8d8); border-radius: 4px; border: 1px outset #606060;} QToolBar#MainToolBar QToolButton:pressed,QToolBar#MainToolBar QToolButton:checked { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #a0a0a0, stop: 1 #d8d8d8); border-radius: 4px; border: 1px inset #505050;}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
/* drag:toolbar scrollbar:overlay symbolic-icons:#2b2b2b spinbox:touch*/
|
||||
/* drag:toolbar scrollbar:overlay symbolic-icons:#2b2b2b spinbox:touch modview:true*/
|
||||
|
||||
QToolBar#MainToolBar { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.99, x3: 0, y3: 1, stop: 0 #d7d7d7, stop: 0.99 #bdbdbd, stop: 1 #969696); border: 0px;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel { color: #2b2b2b;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QToolBar#MainToolBar QToolButton { background: transparent; border: 1px outset transparent;} QToolBar#MainToolBar QToolButton:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #eeeeee, stop: 1 #d8d8d8); border-radius: 4px; border: 1px outset #606060;} QToolBar#MainToolBar QToolButton:pressed,QToolBar#MainToolBar QToolButton:checked { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #a0a0a0, stop: 1 #d8d8d8); border-radius: 4px; border: 1px inset #505050;}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
/* drag:toolbar scrollbar:overlay symbolic-icons:#3c3c3c spinbox:touch*/
|
||||
/* drag:toolbar scrollbar:overlay symbolic-icons:#3c3c3c spinbox:touch modview:true*/
|
||||
|
||||
QToolBar#MainToolBar { background-color: #dfd7d0; border: 0px;} QToolBar#MainToolBar:active { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #d5cdc6, stop: 1 #efe7e0); border: 0px;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel { color: #6c6c6c;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel:active { color: #3c3c3c;} QToolBar#MainToolBar QToolButton { background: transparent; border: 1px outset transparent;} QToolBar#MainToolBar QToolButton:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #efe7e0, stop: 1 #cfc7c0); border-radius: 5px; border: 1px solid #afa7a0;} QToolBar#MainToolBar QToolButton:pressed,QToolBar#MainToolBar QToolButton:checked { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #cfc7c0, stop: 1 #dfd7d0); border-radius: 5px; border: 1px solid #afa7a0;}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
/* drag:toolbar scrollbar:overlay symbolic-icons:#3c3c3c spinbox:touch*/
|
||||
/* drag:toolbar scrollbar:overlay symbolic-icons:#3c3c3c spinbox:touch modview:true*/
|
||||
|
||||
QToolBar#MainToolBar { background-color: #dfd7d0; border: 0px;} QToolBar#MainToolBar:active { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #d5cdc6, stop: 1 #efe7e0); border: 0px;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel { color: #6c6c6c;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel:active { color: #3c3c3c;} QToolBar#MainToolBar QToolButton { background: transparent; border: 1px outset transparent;} QToolBar#MainToolBar QToolButton:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #efe7e0, stop: 1 #cfc7c0); border-radius: 5px; border: 1px solid #afa7a0;} QToolBar#MainToolBar QToolButton:pressed,QToolBar#MainToolBar QToolButton:checked { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #cfc7c0, stop: 1 #dfd7d0); border-radius: 5px; border: 1px solid #afa7a0;}
|
||||
|
||||
@@ -586,6 +586,8 @@ ItemView::ItemView(QWidget *p)
|
||||
TreeDelegate *td=new TreeDelegate(treeView);
|
||||
listView->setItemDelegate(ld);
|
||||
treeView->setItemDelegate(td);
|
||||
listView->setProperty(GtkStyle::constHideFrameProp, true);
|
||||
treeView->setProperty(GtkStyle::constHideFrameProp, true);
|
||||
ViewEventHandler *listViewEventHandler=new ViewEventHandler(ld, listView);
|
||||
listView->installEventFilter(listViewEventHandler);
|
||||
treeView->installEventFilter(new ViewEventHandler(td, treeView));
|
||||
@@ -625,6 +627,7 @@ void ItemView::allowGroupedView()
|
||||
connect(groupedView, SIGNAL(itemActivated(const QModelIndex &)), this, SLOT(itemActivated(const QModelIndex &)));
|
||||
connect(groupedView, SIGNAL(doubleClicked(const QModelIndex &)), this, SIGNAL(doubleClicked(const QModelIndex &)));
|
||||
connect(groupedView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(itemClicked(const QModelIndex &)));
|
||||
groupedView->setProperty(GtkStyle::constHideFrameProp, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,6 +644,7 @@ void ItemView::allowTableView(TableView *v)
|
||||
connect(tableView, SIGNAL(itemActivated(const QModelIndex &)), this, SLOT(itemActivated(const QModelIndex &)));
|
||||
connect(tableView, SIGNAL(doubleClicked(const QModelIndex &)), this, SIGNAL(doubleClicked(const QModelIndex &)));
|
||||
connect(tableView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(itemClicked(const QModelIndex &)));
|
||||
tableView->setProperty(GtkStyle::constHideFrameProp, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user