Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
e2d7d84c
Commit
e2d7d84c
authored
Feb 11, 2019
by
Christoffer Ackelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The QT version now supports custom themes via a .pwr_style file in the users HOME directory.
parent
295adc21
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
6 deletions
+109
-6
src/lib/co/src/co_smart_ptr.h
src/lib/co/src/co_smart_ptr.h
+2
-0
xtt/lib/cow/qt/cow_style_qt.cqt
xtt/lib/cow/qt/cow_style_qt.cqt
+90
-5
xtt/lib/cow/qt/cow_style_qt.h
xtt/lib/cow/qt/cow_style_qt.h
+17
-1
No files found.
src/lib/co/src/co_smart_ptr.h
View file @
e2d7d84c
...
...
@@ -39,6 +39,8 @@
#ifndef CO_UNIQUE_PTR
#define CO_UNIQUE_PTR
#include <stddef.h>
// std::unique_ptr for single objects -> free memory with 'delete'
template
<
typename
T
>
class
unique_ptr
{
...
...
xtt/lib/cow/qt/cow_style_qt.cqt
View file @
e2d7d84c
...
...
@@ -34,13 +34,27 @@
* General Public License plus this exception.
*/
#include "co_dcli.h"
#include "cow_style_qt.h"
#include <QApplication>
#include <QDialogButtonBox>
#include <QFile>
#include <QTextStream>
PwrStyle::PwrStyle() : QGtkStyle() {
loadPalette("$HOME/.pwr_style");
}
PwrStyle::~PwrStyle() {
if (pal) {
delete pal;
}
}
int PwrStyle::pixelMetric(
PixelMetric which, const QStyleOption* option, const QWidget* widget) const
{
int PwrStyle::pixelMetric(PixelMetric which, const QStyleOption* option,
const QWidget* widget) const {
switch (which) {
case PM_LayoutLeftMargin:
case PM_LayoutTopMargin:
...
...
@@ -57,11 +71,82 @@ int PwrStyle::pixelMetric(
}
int PwrStyle::styleHint(StyleHint hint, const QStyleOption* option,
const QWidget* widget, QStyleHintReturn* returnData) const
{
const QWidget* widget, QStyleHintReturn* returnData) const {
if (hint == SH_DialogButtonLayout) {
return QDialogButtonBox::WinLayout;
}
return QGtkStyle::styleHint(hint, option, widget, returnData);
}
void PwrStyle::loadPalette(const char* path) {
char fname[200];
dcli_translate_filename(fname, path);
QFile f(fname);
if (!f.open(QFile::ReadOnly | QFile::Text)) {
return;
}
pal = new QPalette();
QTextStream in(&f);
QStringList lines = in.readAll().split('\n', QString::SkipEmptyParts);
for (int i = 0; i < lines.size(); i++) {
QStringList line = lines[i].split(' ', QString::SkipEmptyParts);
if (line.size() < 4) {
fprintf(stderr, "Error parsing line %d in file %s\n", (i+1), fname);
continue;
}
QPalette::ColorRole role = QPalette::ColorRole(atoi(qPrintable(line[0])));
pal->setBrush(QPalette::ColorGroup(0), role, QColor(line[1]));
pal->setBrush(QPalette::ColorGroup(1), role, QColor(line[2]));
pal->setBrush(QPalette::ColorGroup(2), role, QColor(line[3]));
}
QApplication::setPalette(*pal);
}
void PwrStyle::drawPrimitive(PrimitiveElement element,
const QStyleOption *option, QPainter *painter, const QWidget *widget) const {
if (pal) {
if (element == PE_PanelButtonCommand) {
QWindowsStyle::drawPrimitive(element, option, painter, widget);
return;
}
QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
} else {
QGtkStyle::drawPrimitive(element, option, painter, widget);
}
}
void PwrStyle::drawControl(ControlElement control, const QStyleOption *option,
QPainter *painter, const QWidget *widget) const {
if (pal) {
QCleanlooksStyle::drawControl(control, option, painter, widget);
} else {
QGtkStyle::drawControl(control, option, painter, widget);
}
}
void PwrStyle::drawComplexControl(ComplexControl control,
const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget)
const {
if (pal) {
QCleanlooksStyle::drawComplexControl(control, option, painter, widget);
} else {
QGtkStyle::drawComplexControl(control, option, painter, widget);
}
}
void PwrStyle::polish(QApplication *app) {
if (pal) {
QCleanlooksStyle::polish(app);
} else {
QGtkStyle::polish(app);
}
}
void PwrStyle::unpolish(QApplication *app) {
if (pal) {
QCleanlooksStyle::unpolish(app);
} else {
QGtkStyle::unpolish(app);
}
}
\ No newline at end of file
xtt/lib/cow/qt/cow_style_qt.h
View file @
e2d7d84c
...
...
@@ -43,12 +43,28 @@ class PwrStyle : public QGtkStyle {
Q_OBJECT
public:
PwrStyle
()
:
QGtkStyle
()
{}
PwrStyle
();
~
PwrStyle
();
int
pixelMetric
(
PixelMetric
which
,
const
QStyleOption
*
option
,
const
QWidget
*
widget
=
0
)
const
;
int
styleHint
(
StyleHint
hint
,
const
QStyleOption
*
option
,
const
QWidget
*
widget
,
QStyleHintReturn
*
returnData
=
0
)
const
;
void
loadPalette
(
const
char
*
path
);
void
drawPrimitive
(
PrimitiveElement
element
,
const
QStyleOption
*
option
,
QPainter
*
painter
,
const
QWidget
*
widget
)
const
;
void
drawControl
(
ControlElement
control
,
const
QStyleOption
*
option
,
QPainter
*
painter
,
const
QWidget
*
widget
)
const
;
void
drawComplexControl
(
ComplexControl
control
,
const
QStyleOptionComplex
*
option
,
QPainter
*
painter
,
const
QWidget
*
widget
)
const
;
void
polish
(
QApplication
*
app
);
void
unpolish
(
QApplication
*
app
);
private:
QPalette
*
pal
=
NULL
;
};
#endif
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment