blob: 1d7d556574ba8af694c7306f883fd634f894e33c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#include "uiconfig.h"
#include "style.h"
#include <QApplication>
#include <QPlainTextEdit>
#include <QStyle>
#include <QStandardItem>
#include <QDir>
#include <QDebug>
#define DEFINE_COLOR_HELPER_FN(COLOR_NAME) \
QColor get##COLOR_NAME() \
{ \
return CFG_UI.Colors.COLOR_NAME##Custom.get() ? \
CFG_UI.Colors.COLOR_NAME.get() : \
getDefault##COLOR_NAME().value<QColor>(); \
}
namespace Cfg
{
QVariant getStyleDefaultValue()
{
return QApplication::style()->objectName();
}
QVariant getDefaultTextEditorFont()
{
QPlainTextEdit monoEdit;
QFont font = monoEdit.document()->defaultFont();
#ifdef Q_OS_MACX
font.setFamily("Courier New");
#elif defined(Q_OS_WIN32)
font.setFamily("Consolas");
#else
font.setFamily("DejaVu Sans Mono");
#endif
return QVariant::fromValue<QFont>(font);
}
QVariant getDefaultItemViewFont()
{
QStandardItem it;
return it.font();
}
QVariant getDefaultDbTreeLabelFont()
{
QFont font = getDefaultItemViewFont().value<QFont>();
#ifdef Q_OS_WIN32
font.setPointSize(font.pointSize() - 1);
#else
font.setPointSize(font.pointSize() - 2);
#endif
return font;
}
QVariant getDefaultSyntaxParenthesisBg()
{
return STYLE->standardPalette().windowText();
}
QVariant getDefaultSyntaxParenthesisFg()
{
return STYLE->standardPalette().window();
}
QVariant getDefaultSyntaxCurrentLineBg()
{
return STYLE->extendedPalette().editorLineBase();
}
QVariant getDefaultSyntaxCurrentQueryBg()
{
return STYLE->extendedPalette().editorCurrentQueryBase();
}
QVariant getDefaultSyntaxValidObject()
{
return STYLE->standardPalette().link();
}
QVariant getDefaultSyntaxForeground()
{
return STYLE->standardPalette().text();
}
QVariant getDefaultSyntaxStringFg()
{
return STYLE->extendedPalette().editorString();
}
QVariant getDefaultSyntaxKeywordFg()
{
return STYLE->standardPalette().windowText();
}
QVariant getDefaultSyntaxBindParamFg()
{
return STYLE->standardPalette().linkVisited();
}
QVariant getDefaultSyntaxBlobFg()
{
return STYLE->standardPalette().text();
}
QVariant getDefaultSyntaxCommentFg()
{
return STYLE->standardPalette().dark();
}
QVariant getDefaultSyntaxNumberFg()
{
return STYLE->standardPalette().text();
}
DEFINE_COLOR_HELPER_FN(SyntaxParenthesisBg)
DEFINE_COLOR_HELPER_FN(SyntaxParenthesisFg)
DEFINE_COLOR_HELPER_FN(SyntaxCurrentLineBg)
DEFINE_COLOR_HELPER_FN(SyntaxCurrentQueryBg)
DEFINE_COLOR_HELPER_FN(SyntaxValidObject)
DEFINE_COLOR_HELPER_FN(SyntaxForeground)
DEFINE_COLOR_HELPER_FN(SyntaxStringFg)
DEFINE_COLOR_HELPER_FN(SyntaxKeywordFg)
DEFINE_COLOR_HELPER_FN(SyntaxBindParamFg)
DEFINE_COLOR_HELPER_FN(SyntaxBlobFg)
DEFINE_COLOR_HELPER_FN(SyntaxCommentFg)
DEFINE_COLOR_HELPER_FN(SyntaxNumberFg)
}
CFG_DEFINE(Ui)
void setFileDialogInitPathByFile(const QString& filePath)
{
if (filePath.isNull())
return;
QDir newDir(filePath);
newDir.cdUp();
setFileDialogInitPath(newDir.absolutePath());
}
void setFileDialogInitPath(const QString& path)
{
CFG_UI.General.FileDialogLastPath.set(path);
}
QString getFileDialogInitPath()
{
return CFG_UI.General.FileDialogLastPath.get();
}
|