Re: Fullscreen themes

"Ilya Konkov" <[email protected]> Fri, 4 Apr 2008 09:26:53 +0600
Newsgroups gmane.comp.kde.gwenview
Message-ID <[email protected]>
Hello,

> It's not finished yet, I still  have to move some of Ilya styling code to the theme > stylesheet, but it's coming there (BTW Ilya, I integrated your scrolling buttons, > but using the theme system).

I tried to do it myself yesterday, but at the end decided to wait
until you finish theme code.
I added parent to QPushButton selectors in style.css to avoid styling
meta information dialog, it was okay yesterday because stylesheet was
applied only for configDialog.

--
Ilya Konkov

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

_______________________________________________
Gwenview-general mailing list
Gwenview-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/gwenview-general
gwenview.patch (text/x-patch, 12.1 KB)
Index: app/thumbnailbarview.h
===================================================================
--- app/thumbnailbarview.h	(revision 793457)
+++ app/thumbnailbarview.h	(working copy)
@@ -65,7 +65,6 @@
 	~ThumbnailBarView();
 
 	QSize sizeHint() const;
-	void setFullScreenMode(bool);
 
 protected:
 	void paintEvent(QPaintEvent*);
Index: app/fullscreencontent.cpp
===================================================================
--- app/fullscreencontent.cpp	(revision 793457)
+++ app/fullscreencontent.cpp	(working copy)
@@ -146,7 +146,6 @@
 	ThumbnailBarItemDelegate* delegate = new ThumbnailBarItemDelegate(d->mThumbnailBar);
 	d->mThumbnailBar->setItemDelegate(delegate);
 	d->mThumbnailBar->setThumbnailSize(64);
-	d->mThumbnailBar->setFullScreenMode(true);
 
 	// mInformationLabel
 	d->mInformationLabel = new QLabel;
Index: app/thumbnailbarview.cpp
===================================================================
--- app/thumbnailbarview.cpp	(revision 793457)
+++ app/thumbnailbarview.cpp	(working copy)
@@ -58,26 +58,6 @@
 const int SHADOW_SIZE = 4;
 
 
-static QString rgba(const QColor &color) {
-	return QString::fromAscii("rgba(%1, %2, %3, %4)")
-		.arg(color.red())
-		.arg(color.green())
-		.arg(color.blue())
-		.arg(color.alpha());
-}
-
-
-static QString gradient(const QColor &color, int value) {
-	QString grad =
-		"qlineargradient(x1:0, y1:0, x2:0, y2:1,"
-		"stop:0 %1, stop: 1 %2)";
-	return grad.arg(
-		rgba(PaintUtils::adjustedHsv(color, 0, 0, qMin(255 - color.value(), value/2))),
-		rgba(PaintUtils::adjustedHsv(color, 0, 0, -qMin(color.value(), value/2)))
-		);
-}
-
-
 struct ThumbnailBarItemDelegatePrivate {
 	// Key is height * 1000 + width
 	typedef QMap<int, QPixmap> ShadowCache;
@@ -271,7 +251,10 @@
 
 	mStyle = new ProxyStyle(style());
 	setStyle(mStyle);
-	setFullScreenMode(false);
+	viewport()->setStyleSheet("QWidget {background-color: rgba(60, 60, 60, 10%)}");
+
+	// Vertical spacing between viewport and scrollbar.
+	setViewportMargins(0, 0, 0, 1);
 }
 
 
@@ -290,128 +273,6 @@
 }
 
 
-void ThumbnailBarView::setFullScreenMode(bool fullScreenMode) {
-	QColor bgColor = fullScreenMode ? QColor(10, 10, 10) :
-			palette().color(QPalette::Normal, QPalette::Window);
-	QColor bgSelColor = palette().color(QPalette::Normal, QPalette::Highlight);
-
-	// Avoid dark and bright colors
-	bgColor.setHsv(bgColor.hue(), bgColor.saturation(), (127 + 3 * bgColor.value()) / 4);
-
-	QColor leftBorderColor = PaintUtils::adjustedHsv(bgColor, 0, 0, qMin(20, 255 - bgColor.value()));
-	QColor rightBorderColor = PaintUtils::adjustedHsv(bgColor, 0, 0, -qMin(40, bgColor.value()));
-	QColor borderSelColor = PaintUtils::adjustedHsv(bgSelColor, 0, 0, -qMin(60, bgSelColor.value()));
-
-	QString viewCss =
-		"#thumbnailBarView {"
-		"	background-color: rgba(0, 0, 0, 10%);"
-		"	border: 1px solid rgba(0, 0, 0, 35%);"
-		"	border-radius: 2px;"
-		"	padding: %1px;"
-		"}";
-	viewCss = viewCss.arg(QString::number(fullScreenMode ? 0 : 1));
-
-	QString viewportCss =
-		"QWidget { "
-		"	background-color: %1;"
-		"}";
-	viewportCss = viewportCss.arg(rgba(bgColor));
-	viewport()->setStyleSheet(viewportCss);
-
-	QString itemCss =
-		"QListView::item {"
-		"	background-color: %1;"
-		"	border-left: 1px solid %2;"
-		"	border-right: 1px solid %3;"
-		"}";
-	itemCss = itemCss.arg(
-		gradient(bgColor, 46),
-		gradient(leftBorderColor, 36),
-		gradient(rightBorderColor, 26));
-
-	QString itemSelCss =
-		"QListView::item:selected {"
-		"	background-color: %1;"
-		"	border-left: 1px solid %2;"
-		"	border-right: 1px solid %2;"
-		"}";
-	itemSelCss = itemSelCss.arg(
-		gradient(bgSelColor, 56),
-		rgba(borderSelColor));
-
-	if (fullScreenMode) {
-		QString scrollbarCss =
-			"QScrollBar:horizontal {"
-			"	background-color: transparent;"
-			"	height: 8px;"
-			"	margin: 0 10px 0px 10px;"
-			"	padding: 0 2px 0px 2px;"
-			"}"
-			"QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal { "
-			"	width: 0px;"
-			"	border: 0px;"
-			"}"
-			"QScrollBar::add-line:horizontal {"
-			"	width: 10px;"
-			"	border: 0px;"
-			"	background: transparent;"
-			"	subcontrol-position: right;"
-			"	subcontrol-origin: margin;"
-			"}"
-			"QScrollBar::sub-line:horizontal {"
-			"	width: 10px;"
-			"	border: 0px;"
-			"	background: transparent;"
-			"	subcontrol-position: left;"
-			"	subcontrol-origin: margin;"
-			"}"
-			"QScrollBar:left-arrow:horizontal {"
-			"	background: url($themeDir/scroll-left.png);"
-			"	height: 7px;"
-			"	width: 7px;"
-			"}"
-			"QScrollBar:right-arrow:horizontal {"
-			"	background: url($themeDir/scroll-right.png);"
-			"	height: 7px;"
-			"	width: 7px;"
-			"}";
-		FullScreenTheme* theme = FullScreenTheme::currentTheme();
-		scrollbarCss = theme->replaceThemeVars(scrollbarCss);
-
-		QString handle =
-			"background:"
-			"	qlineargradient(x1:0, y1:0, x2:0, y2:1,"
-			"	stop: 0 %1, stop: 0.5 %2,"
-			"	stop: 0.51 %3, stop: 1 %2);"
-			"border: 1px solid %2;"
-			"border-top: 1px solid %4;"
-			"}";
-
-		QColor handleColor(86, 86, 86);
-		QColor handleHoverColor = handleColor.lighter(110);
-		QString handleCss =
-			"QScrollBar::handle:horizontal {"
-			"	border-radius: 3px;"
-			"	min-width: 20px;" +
-			handle.arg(
-				rgba(handleColor),
-				rgba(PaintUtils::adjustedHsv(handleColor, 0, 0, -32)),
-				rgba(PaintUtils::adjustedHsv(handleColor, 0, 0, -64)),
-				rgba(PaintUtils::adjustedHsv(handleColor, 0, 0,  24))) +
-			"QScrollBar::handle:hover {" +
-			handle.arg(
-				rgba(handleHoverColor),
-				rgba(PaintUtils::adjustedHsv(handleHoverColor, 0, 0, -32)),
-				rgba(PaintUtils::adjustedHsv(handleHoverColor, 0, 0, -64)),
-				rgba(PaintUtils::adjustedHsv(handleHoverColor, 0, 0,  24)));
-		viewCss += scrollbarCss + handleCss;
-	}
-	// Vertical spacing between viewport and scrollbar.
-	setViewportMargins(0, 0, 0, fullScreenMode ? 1 : 2);
-	setStyleSheet(viewCss + itemCss + itemSelCss);
-}
-
-
 void ThumbnailBarView::paintEvent(QPaintEvent* event) {
 	ThumbnailView::paintEvent(event);
 
Index: app/documentview.cpp
===================================================================
--- app/documentview.cpp	(revision 793457)
+++ app/documentview.cpp	(working copy)
@@ -40,6 +40,7 @@
 #include <lib/imageview.h>
 #include <lib/imageviewpart.h>
 #include <lib/mimetypeutils.h>
+#include "lib/paintutils.h"
 
 
 namespace Gwenview {
@@ -53,6 +54,16 @@
 #define LOG(x) ;
 #endif
 
+static QString gradient(const QColor &color, int value) {
+	QString grad =
+	"qlineargradient(x1:0, y1:0, x2:0, y2:1,"
+	"stop:0 %1, stop: 1 %2)";
+	return grad.arg(
+		PaintUtils::adjustedHsv(color, 0, 0, qMin(255 - color.value(), value/2)).name(),
+		PaintUtils::adjustedHsv(color, 0, 0, -qMin(color.value(), value/2)).name()
+	);
+}
+
 struct DocumentViewPrivate {
 	DocumentView* mView;
 	QLabel* mNoDocumentLabel;
@@ -127,6 +138,50 @@
 		partPalette.setBrush(mPart->widget()->foregroundRole(), palette.text());
 		mPart->widget()->setPalette(partPalette);
 	}
+
+	void setupThumbnailBar() {
+		QPalette palette = mThumbnailBar->palette();
+		QColor bgColor = palette.color(QPalette::Normal, QPalette::Window);
+		QColor bgSelColor = palette.color(QPalette::Normal, QPalette::Highlight);
+		
+		// Avoid dark and bright colors
+		bgColor.setHsv(bgColor.hue(), bgColor.saturation(), (127 + 3 * bgColor.value()) / 4);
+	
+		QColor leftBorderColor = PaintUtils::adjustedHsv(bgColor, 0, 0, qMin(20, 255 - bgColor.value()));
+		QColor rightBorderColor = PaintUtils::adjustedHsv(bgColor, 0, 0, -qMin(40, bgColor.value()));
+		QColor borderSelColor = PaintUtils::adjustedHsv(bgSelColor, 0, 0, -qMin(60, bgSelColor.value()));
+	
+		QString viewCss =
+			"#thumbnailBarView {"
+			"	background-color: rgba(0, 0, 0, 10%);"
+			"	border: 1px solid rgba(0, 0, 0, 35%);"
+			"	border-radius: 2px;"
+			"	padding: 1px;"
+			"}";
+	
+		QString itemCss =
+			"QListView::item {"
+			"	background-color: %1;"
+			"	border-left: 1px solid %2;"
+			"	border-right: 1px solid %3;"
+			"}";
+		itemCss = itemCss.arg(
+			gradient(bgColor, 46),
+			gradient(leftBorderColor, 36),
+			gradient(rightBorderColor, 26));
+						  
+		QString itemSelCss =
+			"QListView::item:selected {"
+			"	background-color: %1;"
+			"	border-left: 1px solid %2;"
+			"	border-right: 1px solid %2;"
+			"}";
+		itemSelCss = itemSelCss.arg(
+			gradient(bgSelColor, 56),
+			borderSelColor.name());
+
+		mThumbnailBar->setStyleSheet(viewCss + itemCss + itemSelCss);
+	}
 };
 
 
@@ -163,6 +218,7 @@
 	d->mThumbnailBar = new ThumbnailBarView(d->mPartContainer);
 	ThumbnailBarItemDelegate* delegate = new ThumbnailBarItemDelegate(d->mThumbnailBar);
 	d->mThumbnailBar->setItemDelegate(delegate);
+	d->setupThumbnailBar();
 	d->mThumbnailBar->hide();
 
 	d->mPartContainerLayout = new QVBoxLayout(d->mPartContainer);
Index: fullscreenthemes/blackglass/style.css
===================================================================
--- fullscreenthemes/blackglass/style.css	(revision 793457)
+++ fullscreenthemes/blackglass/style.css	(working copy)
@@ -1,15 +1,15 @@
 /* Default text color for most widgets, but not tooltips (hence the '.' before
  * QLabel */
-.QLabel, QPushButton, QToolButton, QCheckBox {
+.QLabel, #configDialog QPushButton, QToolButton, QCheckBox {
 	color: #ccc;
 }
 
 /* Default borders, normal and hover */
-QCheckBox::indicator, QPushButton, QSlider::groove, QSlider::handle {
+QCheckBox::indicator, #configDialog QPushButton, QSlider::groove, QSlider::handle {
 	border: 1px solid #666;
 }
 
-QCheckBox::indicator:hover, QToolButton::hover, QPushButton:hover, QSlider::groove:hover, QSlider::handle:hover {
+QCheckBox::indicator:hover, QToolButton::hover, #configDialog QPushButton:hover, QSlider::groove:hover, QSlider::handle:hover {
 	border: 1px solid #ccc;
 }
 
@@ -57,7 +57,7 @@
 }
 
 /* QPushButton */
-QPushButton {
+#configDialog QPushButton {
 	background-color:
 		qlineargradient(x1:0, y1:0, x2:0, y2:1,
 		stop:0 #333, stop: 0.5 black, stop:1 black);
@@ -65,13 +65,13 @@
 	padding: 3px;
 }
 
-QPushButton:hover {
+#configDialog QPushButton:hover {
 	background-color:
 		qlineargradient(x1:0, y1:0, x2:0, y2:1,
 		stop:0 #444, stop: 0.6 black, stop:1 black);
 }
 
-QPushButton:pressed {
+#configDialog QPushButton:pressed {
 	background-color: #111;
 	padding-right: 1px;
 	padding-bottom: 1px;
@@ -113,3 +113,89 @@
 	border-top: 1px solid gray;
 	height: 3px;
 }
+
+/* Thumbnail Bar */
+#thumbnailBarView {
+	background-color: black;
+	border: 1px solid black;
+	border-radius: 2px;
+}
+
+#thumbnailBarView::item {
+	background-color:
+		qlineargradient(x1:0, y1:0, x2:0, y2:1,
+		stop:0 #3e3e3e, stop: 1 #101010);
+	border-left: 1px solid
+		qlineargradient(x1:0, y1:0, x2:0, y2:1,
+		stop:0 #4d4d4d, stop: 1 #292929);
+	border-right: 1px solid
+		qlineargradient(x1:0, y1:0, x2:0, y2:1,
+		stop:0 #0d0d0d, stop: 1 #000000);
+}
+
+#thumbnailBarView::item:selected {
+	background-color: palette(highlight);
+	border-left: 1px solid palette(dark);
+	border-right: 1px solid palette(dark);
+}
+
+#thumbnailBarView QScrollBar:horizontal {
+	background-color: transparent;
+	height: 8px;
+	padding: 0 2px 0px 2px;
+	margin: 0 10px 0px 10px;
+}
+
+#thumbnailBarView QScrollBar::add-page:horizontal,
+#thumbnailBarView QScrollBar::sub-page:horizontal {
+	width: 0px;
+	border: 0px;
+}
+
+#thumbnailBarView QScrollBar::add-line:horizontal {
+	width: 10px;
+	border: 0px;
+	background: transparent;
+	subcontrol-position: right;
+	subcontrol-origin: margin;
+}
+
+#thumbnailBarView QScrollBar::sub-line:horizontal {
+	width: 10px;
+	border: 0px;
+	background: transparent;
+	subcontrol-position: left;
+	subcontrol-origin: margin;
+}
+
+#thumbnailBarView QScrollBar:left-arrow:horizontal {
+	background: url($themeDir/scroll-left.png);
+	height: 7px;
+	width: 7px;
+}
+
+#thumbnailBarView QScrollBar:right-arrow:horizontal {
+	background: url($themeDir/scroll-right.png);
+	height: 7px;
+	width: 7px;
+}
+
+#thumbnailBarView QScrollBar::handle:horizontal {
+	border-radius: 3px;
+	min-width: 20px;
+	background:
+		qlineargradient(x1:0, y1:0, x2:0, y2:1,
+		stop: 0 #565656, stop: 0.5 #363636,
+		stop: 0.51 #161616, stop: 1 #363636);
+	border: 1px solid #363636;
+	border-top: 1px solid #6e6e6e;
+}
+
+#thumbnailBarView QScrollBar::handle:hover {
+	background:
+		qlineargradient(x1:0, y1:0, x2:0, y2:1,
+		stop: 0 #5e5e5e, stop: 0.5 #3e3e3e,
+		stop: 0.51 #1e1e1e, stop: 1 #3e3e3e);
+	border: 1px solid #3e3e3e;
+	border-top: 1px solid #767676;
+}