File indexing completed on 2024-04-21 05:46:54

0001 /*****************************************************************************
0002  *   Copyright 2003 - 2010 Craig Drummond <craig.p.drummond@gmail.com>       *
0003  *   Copyright 2013 - 2015 Yichao Yu <yyc1992@gmail.com>                     *
0004  *                                                                           *
0005  *   This program is free software; you can redistribute it and/or modify    *
0006  *   it under the terms of the GNU Lesser General Public License as          *
0007  *   published by the Free Software Foundation; either version 2.1 of the    *
0008  *   License, or (at your option) version 3, or any later version accepted   *
0009  *   by the membership of KDE e.V. (or its successor approved by the         *
0010  *   membership of KDE e.V.), which shall act as a proxy defined in          *
0011  *   Section 6 of version 3 of the license.                                  *
0012  *                                                                           *
0013  *   This program is distributed in the hope that it will be useful,         *
0014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
0015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
0016  *   Lesser General Public License for more details.                         *
0017  *                                                                           *
0018  *   You should have received a copy of the GNU Lesser General Public        *
0019  *   License along with this library. If not,                                *
0020  *   see <http://www.gnu.org/licenses/>.                                     *
0021  *****************************************************************************/
0022 
0023 #include <qtcurve-utils/log.h>
0024 #include <qtcurve-utils/map.h>
0025 #include <qtcurve-utils/dirs.h>
0026 #include <qtcurve-utils/strs.h>
0027 #include <qtcurve-utils/color.h>
0028 
0029 #include "common.h"
0030 #include "config_file.h"
0031 
0032 #include <fstream>
0033 
0034 #define CONFIG_FILE               "stylerc"
0035 #define OLD_CONFIG_FILE           "qtcurvestylerc"
0036 #define VERSION_KEY               "version"
0037 
0038 static int
0039 c2h(char ch)
0040 {
0041     return (ch>='0' && ch<='9') ? ch-'0' :
0042            (ch>='a' && ch<='f') ? 10+(ch-'a') :
0043            (ch>='A' && ch<='F') ? 10+(ch-'A') :
0044            0;
0045 }
0046 
0047 #define ATOH(str) ((c2h(*str)<<4)+c2h(*(str+1)))
0048 
0049 void qtcSetRgb(GdkColor *col, const char *str)
0050 {
0051     if (str && strlen(str)>6) {
0052         int offset = '#' == str[0] ? 1 : 0;
0053         col->red = ATOH(&str[offset]) << 8;
0054         col->green = ATOH(&str[offset + 2]) << 8;
0055         col->blue = ATOH(&str[offset + 4]) << 8;
0056         col->pixel = 0;
0057     } else {
0058         col->red = col->green = col->blue = col->pixel = 0;
0059     }
0060 }
0061 
0062 static bool
0063 loadImage(const char *file, QtCPixmap *pixmap)
0064 {
0065     pixmap->img = gdk_pixbuf_new_from_file(
0066         QtCurve::getConfFile(std::string(file)).c_str(), nullptr);
0067     return pixmap->img != nullptr;
0068 }
0069 
0070 static EDefBtnIndicator
0071 toInd(const char *str, EDefBtnIndicator def)
0072 {
0073     static const QtCurve::StrMap<EDefBtnIndicator> map{
0074         {"fontcolor", IND_FONT_COLOR},
0075         {"border", IND_FONT_COLOR},
0076         {"none", IND_NONE},
0077         {"corner", IND_CORNER},
0078         {"colored", IND_COLORED},
0079         {"tint", IND_TINT},
0080         {"glow", IND_GLOW},
0081         {"darken", IND_DARKEN},
0082         {"origselected", IND_SELECTED},
0083     };
0084     return map.search(str, def);
0085 }
0086 
0087 static ELine toLine(const char *str, ELine def)
0088 {
0089     if(str && 0!=str[0])
0090     {
0091         if(0==strncmp(str, "dashes", 6))
0092             return LINE_DASHES;
0093         if(0==strncmp(str, "none", 4))
0094             return LINE_NONE;
0095         if(0==strncmp(str, "sunken", 6))
0096             return LINE_SUNKEN;
0097         if(0==strncmp(str, "dots", 4))
0098             return LINE_DOTS;
0099         if(0==strncmp(str, "flat", 4))
0100             return LINE_FLAT;
0101         if(0==strncmp(str, "1dot", 5))
0102             return LINE_1DOT;
0103     }
0104     return def;
0105 }
0106 
0107 static ETBarBorder toTBarBorder(const char *str, ETBarBorder def)
0108 {
0109     if(str && 0!=str[0])
0110     {
0111         if(0==strncmp(str, "dark", 4))
0112             return 0==strncmp(&str[4], "-all", 4) ? TB_DARK_ALL : TB_DARK;
0113         if(0==strncmp(str, "none", 4))
0114             return TB_NONE;
0115         if(0==strncmp(str, "light", 5))
0116             return 0==strncmp(&str[5], "-all", 4) ? TB_LIGHT_ALL : TB_LIGHT;
0117     }
0118     return def;
0119 }
0120 
0121 static EMouseOver toMouseOver(const char *str, EMouseOver def)
0122 {
0123     if(str && 0!=str[0])
0124     {
0125         if(0==strncmp(str, "true", 4) || 0==strncmp(str, "colored", 7))
0126             return MO_COLORED;
0127         if(0==strncmp(str, "thickcolored", 12))
0128             return MO_COLORED_THICK;
0129         if(0==strncmp(str, "plastik", 7))
0130             return MO_PLASTIK;
0131         if(0==strncmp(str, "glow", 4))
0132             return MO_GLOW;
0133         if(0==strncmp(str, "false", 4) || 0==strncmp(str, "none", 4))
0134             return MO_NONE;
0135     }
0136     return def;
0137 }
0138 
0139 static EAppearance toAppearance(const char *str, EAppearance def, EAppAllow allow, QtCPixmap *pix, bool checkImage)
0140 {
0141     if(str && 0!=str[0])
0142     {
0143         if(0==strncmp(str, "flat", 4))
0144             return APPEARANCE_FLAT;
0145         if(0==strncmp(str, "raised", 6))
0146             return APPEARANCE_RAISED;
0147         if(0==strncmp(str, "dullglass", 9))
0148             return APPEARANCE_DULL_GLASS;
0149         if(0==strncmp(str, "glass", 5) || 0==strncmp(str, "shinyglass", 10))
0150             return APPEARANCE_SHINY_GLASS;
0151         if(0==strncmp(str, "agua", 4))
0152             return APPEARANCE_AGUA;
0153         if(0==strncmp(str, "soft", 4))
0154             return APPEARANCE_SOFT_GRADIENT;
0155         if(0==strncmp(str, "gradient", 8) || 0==strncmp(str, "lightgradient", 13))
0156             return APPEARANCE_GRADIENT;
0157         if(0==strncmp(str, "harsh", 5))
0158             return APPEARANCE_HARSH_GRADIENT;
0159         if(0==strncmp(str, "inverted", 8))
0160             return APPEARANCE_INVERTED;
0161         if(0==strncmp(str, "darkinverted", 12))
0162             return APPEARANCE_DARK_INVERTED;
0163         if(0==strncmp(str, "splitgradient", 13))
0164             return APPEARANCE_SPLIT_GRADIENT;
0165         if(0==strncmp(str, "bevelled", 8))
0166             return APPEARANCE_BEVELLED;
0167         if(APP_ALLOW_FADE==allow && 0==strncmp(str, "fade", 4))
0168             return APPEARANCE_FADE;
0169         if(APP_ALLOW_STRIPED==allow && 0==strncmp(str, "striped", 7))
0170             return APPEARANCE_STRIPED;
0171         if(APP_ALLOW_NONE==allow && 0==strncmp(str, "none", 4))
0172             return APPEARANCE_NONE;
0173         if(nullptr!=pix && APP_ALLOW_STRIPED==allow && 0==strncmp(str, "file", 4) && strlen(str)>9)
0174             return loadImage(&str[5], pix) || !checkImage ? APPEARANCE_FILE : def;
0175 
0176         if(0==strncmp(str, "customgradient", 14) && strlen(str)>14)
0177         {
0178             int i=atoi(&str[14]);
0179 
0180             i--;
0181             if(i>=0 && i<NUM_CUSTOM_GRAD)
0182                 return (EAppearance)(APPEARANCE_CUSTOM1+i);
0183         }
0184     }
0185     return def;
0186 }
0187 
0188 static EShade
0189 toShade(const char *str, bool allowMenu, EShade def,
0190         bool menuShade, GdkColor *col)
0191 {
0192     if(str && 0!=str[0])
0193     {
0194         /* true/false is from 0.25... */
0195         if((!menuShade && 0==strncmp(str, "true", 4)) || 0==strncmp(str, "selected", 8))
0196             return SHADE_BLEND_SELECTED;
0197         if(0==strncmp(str, "origselected", 12))
0198             return SHADE_SELECTED;
0199         if(allowMenu && (0==strncmp(str, "darken", 6) || (menuShade && 0==strncmp(str, "true", 4))))
0200             return SHADE_DARKEN;
0201         if(allowMenu && 0==strncmp(str, "wborder", 7))
0202             return SHADE_WINDOW_BORDER;
0203         if(0==strncmp(str, "custom", 6))
0204             return SHADE_CUSTOM;
0205         if('#'==str[0] && col)
0206         {
0207             qtcSetRgb(col, str);
0208             return SHADE_CUSTOM;
0209         }
0210         if(0==strncmp(str, "none", 4))
0211             return SHADE_NONE;
0212     }
0213 
0214     return def;
0215 }
0216 
0217 /* Prior to 0.42 round was a bool - so need to read 'false' as 'none' */
0218 static ERound toRound(const char *str, ERound def)
0219 {
0220     if(str && 0!=str[0])
0221     {
0222         if(0==strncmp(str, "none", 4) || 0==strncmp(str, "false", 5))
0223             return ROUND_NONE;
0224         if(0==strncmp(str, "slight", 6))
0225             return ROUND_SLIGHT;
0226         if(0==strncmp(str, "full", 4))
0227             return ROUND_FULL;
0228         if(0==strncmp(str, "extra", 5))
0229             return ROUND_EXTRA;
0230         if(0==strncmp(str, "max", 3))
0231             return ROUND_MAX;
0232     }
0233 
0234     return def;
0235 }
0236 
0237 static EScrollbar
0238 toScrollbar(const char *str, EScrollbar def)
0239 {
0240     return QtCurve::Config::loadValue<EScrollbar>(str, def);
0241 }
0242 
0243 static EFrame
0244 toFrame(const char *str, EFrame def)
0245 {
0246     return QtCurve::Config::loadValue<EFrame>(str, def);
0247 }
0248 
0249 static EEffect toEffect(const char *str, EEffect def)
0250 {
0251     if(str && 0!=str[0])
0252     {
0253         if(0==strncmp(str, "none", 4))
0254             return EFFECT_NONE;
0255         if(0==strncmp(str, "shadow", 6))
0256             return EFFECT_SHADOW;
0257         if(0==strncmp(str, "etch", 4))
0258             return EFFECT_ETCH;
0259     }
0260 
0261     return def;
0262 }
0263 
0264 static Shading
0265 toShading(const char *str, Shading def)
0266 {
0267     return QtCurve::Config::loadValue<Shading>(str, def);
0268 }
0269 
0270 static EStripe toStripe(const char *str, EStripe def)
0271 {
0272     if(str && 0!=str[0])
0273     {
0274         if(0==strncmp(str, "plain", 5) || 0==strncmp(str, "true", 4))
0275             return STRIPE_PLAIN;
0276         if(0==strncmp(str, "none", 4) || 0==strncmp(str, "false", 5))
0277             return STRIPE_NONE;
0278         if(0==strncmp(str, "diagonal", 8))
0279             return STRIPE_DIAGONAL;
0280         if(0==strncmp(str, "fade", 4))
0281             return STRIPE_FADE;
0282     }
0283 
0284     return def;
0285 }
0286 
0287 static ESliderStyle toSlider(const char *str, ESliderStyle def)
0288 {
0289     if(str && 0!=str[0])
0290     {
0291         if(0==strncmp(str, "round", 5))
0292             return SLIDER_ROUND;
0293         if(0==strncmp(str, "plain", 5))
0294             return SLIDER_PLAIN;
0295         if(0==strncmp(str, "r-round", 7))
0296             return SLIDER_ROUND_ROTATED;
0297         if(0==strncmp(str, "r-plain", 7))
0298             return SLIDER_PLAIN_ROTATED;
0299         if(0==strncmp(str, "triangular", 10))
0300             return SLIDER_TRIANGULAR;
0301         if(0==strncmp(str, "circular", 8))
0302             return SLIDER_CIRCULAR;
0303     }
0304 
0305     return def;
0306 }
0307 
0308 static EColor toEColor(const char *str, EColor def)
0309 {
0310     if(str && 0!=str[0])
0311     {
0312         if(0==strncmp(str, "base", 4))
0313             return ECOLOR_BASE;
0314         if(0==strncmp(str, "dark", 4))
0315             return ECOLOR_DARK;
0316         if(0==strncmp(str, "background", 10))
0317             return ECOLOR_BACKGROUND;
0318     }
0319 
0320     return def;
0321 }
0322 
0323 static EFocus toFocus(const char *str, EFocus def)
0324 {
0325     if(str && 0!=str[0])
0326     {
0327         if(0==strncmp(str, "standard", 8))
0328             return FOCUS_STANDARD;
0329         if(0==strncmp(str, "rect", 4) || 0==strncmp(str, "highlight", 9))
0330             return FOCUS_RECTANGLE;
0331         if(0==strncmp(str, "filled", 6))
0332             return FOCUS_FILLED;
0333         if(0==strncmp(str, "full", 4))
0334             return FOCUS_FULL;
0335         if(0==strncmp(str, "line", 4))
0336             return FOCUS_LINE;
0337         if(0==strncmp(str, "glow", 4))
0338             return FOCUS_GLOW;
0339         if(0==strncmp(str, "none", 4))
0340             return FOCUS_NONE;
0341     }
0342 
0343     return def;
0344 }
0345 
0346 static ETabMo toTabMo(const char *str, ETabMo def)
0347 {
0348     if(str && 0!=str[0])
0349     {
0350         if(0==strncmp(str, "top", 3))
0351             return TAB_MO_TOP;
0352         if(0==strncmp(str, "bot", 3))
0353             return TAB_MO_BOTTOM;
0354         if(0==strncmp(str, "glow", 4))
0355             return TAB_MO_GLOW;
0356     }
0357 
0358     return def;
0359 }
0360 
0361 static EGradType toGradType(const char *str, EGradType def)
0362 {
0363     if(str && 0!=str[0])
0364     {
0365         if(0==strncmp(str, "horiz", 5))
0366             return GT_HORIZ;
0367         if(0==strncmp(str, "vert", 4))
0368             return GT_VERT;
0369     }
0370     return def;
0371 }
0372 
0373 static bool toLvLines(const char *str, bool def)
0374 {
0375     if(str && 0!=str[0])
0376     {
0377 #if 0
0378         if(0==strncmp(str, "true", 4) || 0==strncmp(str, "new", 3))
0379             return LV_NEW;
0380         if(0==strncmp(str, "old", 3))
0381             return LV_OLD;
0382         if(0==strncmp(str, "false", 5) || 0==strncmp(str, "none", 4))
0383             return LV_NONE;
0384 #else
0385         return 0!=strncmp(str, "false", 5);
0386 #endif
0387     }
0388     return def;
0389 }
0390 
0391 static EGradientBorder toGradientBorder(const char *str, bool *haveAlpha)
0392 {
0393     if (str && str[0]) {
0394         *haveAlpha = strstr(str, "-alpha") ? true : false;
0395         if(0==strncmp(str, "light", 5) || 0==strncmp(str, "true", 4))
0396             return GB_LIGHT;
0397         if(0==strncmp(str, "none", 4))
0398             return GB_NONE;
0399         if(0==strncmp(str, "3dfull", 6))
0400             return GB_3D_FULL;
0401         if(0==strncmp(str, "3d", 2) || 0==strncmp(str, "false", 5))
0402             return GB_3D;
0403         if(0==strncmp(str, "shine", 5))
0404             return GB_SHINE;
0405     }
0406     return GB_3D;
0407 }
0408 
0409 #if defined CONFIG_DIALOG
0410 static ETitleBarIcon toTitlebarIcon(const char *str, ETitleBarIcon def)
0411 {
0412     if(str && 0!=str[0])
0413     {
0414         if(0==strncmp(str, "none", 4))
0415             return TITLEBAR_ICON_NONE;
0416         if(0==strncmp(str, "menu", 4))
0417             return TITLEBAR_ICON_MENU_BUTTON;
0418         if(0==strncmp(str, "title", 5))
0419             return TITLEBAR_ICON_NEXT_TO_TITLE;
0420     }
0421     return def;
0422 }
0423 #endif
0424 
0425 static EImageType toImageType(const char *str, EImageType def)
0426 {
0427     if(str && 0!=str[0])
0428     {
0429         if(0==strncmp(str, "none", 4))
0430             return IMG_NONE;
0431         if(0==strncmp(str, "plainrings", 10))
0432             return IMG_PLAIN_RINGS;
0433         if(0==strncmp(str, "rings", 5))
0434             return IMG_BORDERED_RINGS;
0435         if(0==strncmp(str, "squarerings", 11))
0436             return IMG_SQUARE_RINGS;
0437         if(0==strncmp(str, "file", 4))
0438             return IMG_FILE;
0439     }
0440     return def;
0441 }
0442 
0443 static EGlow toGlow(const char *str, EGlow def)
0444 {
0445     if(str && 0!=str[0])
0446     {
0447         if(0==strncmp(str, "none", 4))
0448             return GLOW_NONE;
0449         if(0==strncmp(str, "start", 5))
0450             return GLOW_START;
0451         if(0==strncmp(str, "middle", 6))
0452             return GLOW_MIDDLE;
0453         if(0==strncmp(str, "end", 3))
0454             return GLOW_END;
0455     }
0456     return def;
0457 }
0458 
0459 static ETBarBtn toTBarBtn(const char *str, ETBarBtn def)
0460 {
0461     if(str && 0!=str[0])
0462     {
0463         if(0==strncmp(str, "standard", 8))
0464             return TBTN_STANDARD;
0465         if(0==strncmp(str, "raised", 6))
0466             return TBTN_RAISED;
0467         if(0==strncmp(str, "joined", 6))
0468             return TBTN_JOINED;
0469     }
0470     return def;
0471 }
0472 
0473 WindowBorders
0474 qtcGetWindowBorderSize(bool force)
0475 {
0476     static WindowBorders def = {24, 18, 4, 4};
0477     static WindowBorders sizes = {-1, -1, -1, -1};
0478 
0479     if (sizes.titleHeight == -1 || force) {
0480         std::ifstream f(QtCurve::getConfFile(std::string(BORDER_SIZE_FILE)));
0481         if (f) {
0482             std::string line;
0483             std::getline(f, line);
0484             sizes.titleHeight = std::stoi(line);
0485             std::getline(f, line);
0486             sizes.toolTitleHeight = std::stoi(line);
0487             std::getline(f, line);
0488             sizes.bottom = std::stoi(line);
0489             std::getline(f, line);
0490             sizes.sides = std::stoi(line);
0491         }
0492     }
0493 
0494     return sizes.titleHeight<12 ? def : sizes;
0495 }
0496 
0497 static char*
0498 qtcGetBarFileName(const char *app, const char *prefix)
0499 {
0500     QtCurve::Str::Buff<1024> filename;
0501     return filename.cat(QtCurve::getConfDir(), prefix, app);
0502 }
0503 
0504 bool qtcBarHidden(const char *app, const char *prefix)
0505 {
0506     return QtCurve::isRegFile(qtcGetBarFileName(app, prefix));
0507 }
0508 
0509 void qtcSetBarHidden(const char *app, bool hidden, const char *prefix)
0510 {
0511     if(!hidden)
0512         unlink(qtcGetBarFileName(app, prefix));
0513     else
0514     {
0515         FILE *f=fopen(qtcGetBarFileName(app, prefix), "w");
0516 
0517         if(f)
0518             fclose(f);
0519     }
0520 }
0521 
0522 void qtcLoadBgndImage(QtCImage *img)
0523 {
0524     if (!img->loaded &&
0525         ((img->width > 16 && img->width < 1024 && img->height > 16 &&
0526           img->height < 1024) || (img->width == 0 && img->height == 0))) {
0527         img->loaded = true;
0528         img->pixmap.img = nullptr;
0529         if (img->pixmap.file) {
0530             auto file = QtCurve::getConfFile(std::string(img->pixmap.file));
0531             img->pixmap.img = (img->width == 0) ?
0532                 gdk_pixbuf_new_from_file(file.c_str(), nullptr) :
0533                 gdk_pixbuf_new_from_file_at_scale(file.c_str(), img->width,
0534                                                   img->height, false, nullptr);
0535             if (img->pixmap.img && 0==img->width && img->pixmap.img) {
0536                 img->width = gdk_pixbuf_get_width(img->pixmap.img);
0537                 img->height = gdk_pixbuf_get_height(img->pixmap.img);
0538             }
0539         }
0540     }
0541 }
0542 
0543 static void
0544 checkColor(EShade *s, GdkColor *c)
0545 {
0546     if (*s == SHADE_CUSTOM && QtCurve::isBlack(*c)) {
0547         *s = SHADE_NONE;
0548     }
0549 }
0550 
0551 static char*
0552 lookupCfgHash(GHashTable **cfg, const char *key, char *val)
0553 {
0554     char *rv = nullptr;
0555 
0556     if (!*cfg) {
0557         *cfg = g_hash_table_new(g_str_hash, g_str_equal);
0558     } else {
0559         rv = (char*)g_hash_table_lookup(*cfg, key);
0560     }
0561 
0562     if (!rv && val) {
0563         g_hash_table_insert(*cfg, g_strdup(key), g_strdup(val));
0564         rv = (char *)g_hash_table_lookup(*cfg, key);
0565     }
0566     return rv;
0567 }
0568 
0569 static GHashTable * loadConfig(const char *filename)
0570 {
0571     FILE       *f=fopen(filename, "r");
0572     GHashTable *cfg=nullptr;
0573 
0574     if(f)
0575     {
0576         char line[MAX_CONFIG_INPUT_LINE_LEN];
0577 
0578         while(nullptr!=fgets(line, MAX_CONFIG_INPUT_LINE_LEN-1, f))
0579         {
0580             char *eq=strchr(line, '=');
0581             int  pos=eq ? eq-line : -1;
0582 
0583             if(pos>0)
0584             {
0585                 char *endl=strchr(line, '\n');
0586 
0587                 if(endl)
0588                     *endl='\0';
0589 
0590                 line[pos]='\0';
0591 
0592                 lookupCfgHash(&cfg, line, &line[pos+1]);
0593             }
0594         }
0595 
0596         fclose(f);
0597     }
0598 
0599     return cfg;
0600 }
0601 
0602 static void
0603 releaseConfig(GHashTable *cfg)
0604 {
0605     g_hash_table_destroy(cfg);
0606 }
0607 
0608 static char*
0609 readStringEntry(GHashTable *cfg, const char *key)
0610 {
0611     return lookupCfgHash(&cfg, key, nullptr);
0612 }
0613 
0614 static int
0615 readNumEntry(GHashTable *cfg, const char *key, int def)
0616 {
0617     char *str = readStringEntry(cfg, key);
0618 
0619     return str ? atoi(str) : def;
0620 }
0621 
0622 static int
0623 readVersionEntry(GHashTable *cfg, const char *key)
0624 {
0625     char *str = readStringEntry(cfg, key);
0626     int major, minor, patch;
0627 
0628     return str && 3==sscanf(str, "%d.%d.%d", &major, &minor, &patch)
0629             ? qtcMakeVersion(major, minor, patch)
0630             : 0;
0631 }
0632 
0633 static bool
0634 readBoolEntry(GHashTable *cfg, const char *key, bool def)
0635 {
0636     char *str = readStringEntry(cfg, key);
0637     return str ? (strncmp(str, "true", 4) == 0 ? true : false) : def;
0638 }
0639 
0640 static void
0641 readDoubleList(GHashTable *cfg, const char *key, double *list, int count)
0642 {
0643     char *str=readStringEntry(cfg, key);
0644 
0645     if(str && 0!=str[0])
0646     {
0647         int  j,
0648              comma=0;
0649         bool ok=true;
0650 
0651         for(j=0; str[j]; ++j)
0652             if(','==str[j])
0653                 comma++;
0654 
0655         ok=(count-1)==comma;
0656         if(ok)
0657         {
0658             for(j=0; j<comma+1 && str && ok; ++j)
0659             {
0660                 char *c=strchr(str, ',');
0661 
0662                 if(c || (str && count-1==comma))
0663                 {
0664                     if(c)
0665                         *c='\0';
0666                     list[j]=g_ascii_strtod(str, nullptr);
0667                     str=c+1;
0668                 }
0669                 else
0670                     ok=false;
0671             }
0672         }
0673 
0674         if(!ok)
0675             list[0]=0;
0676     }
0677 }
0678 
0679 #define TO_LATIN1(A) (A)
0680 
0681 #define CFG_READ_COLOR(ENTRY) do {                        \
0682         const char *str = readStringEntry(cfg, #ENTRY);   \
0683         if (str && 0 != str[0]) {                         \
0684             qtcSetRgb(&opts->ENTRY, str);                 \
0685         } else {                                          \
0686             opts->ENTRY = def->ENTRY;                     \
0687         }                                                 \
0688     } while (0)
0689 
0690 #define CFG_READ_IMAGE(ENTRY) do {                                      \
0691         opts->ENTRY.type =                                              \
0692             toImageType(TO_LATIN1(readStringEntry(cfg, #ENTRY)),        \
0693                         def->ENTRY.type);                               \
0694         opts->ENTRY.loaded = false;                                     \
0695         if (IMG_FILE == opts->ENTRY.type) {                             \
0696             const char *file = readStringEntry(cfg, #ENTRY ".file");    \
0697             if (file) {                                                 \
0698                 opts->ENTRY.pixmap.file = file;                         \
0699                 opts->ENTRY.width = readNumEntry(cfg, #ENTRY ".width", 0); \
0700                 opts->ENTRY.height = readNumEntry(cfg, #ENTRY ".height", 0); \
0701                 opts->ENTRY.onBorder = readBoolEntry(cfg, #ENTRY ".onBorder", \
0702                                                      false);            \
0703                 opts->ENTRY.pos = (EPixPos)readNumEntry(cfg, #ENTRY ".pos", \
0704                                                         (int)PP_TR);    \
0705             } else {                                                    \
0706                 opts->ENTRY.type = IMG_NONE;                            \
0707             }                                                           \
0708         }                                                               \
0709     } while (0)
0710 
0711 #define CFG_READ_STRING_LIST(ENTRY) do {                 \
0712         const char *str = readStringEntry(cfg, #ENTRY); \
0713         if (str && 0 != str[0]) {                        \
0714             opts->ENTRY = g_strsplit(str, ",", -1);      \
0715         } else if (def->ENTRY) {                         \
0716             opts->ENTRY = def->ENTRY;                    \
0717             def->ENTRY = nullptr;                           \
0718         }                                                \
0719     } while (0)
0720 
0721 #define CFG_READ_BOOL(ENTRY) do {                               \
0722         opts->ENTRY = readBoolEntry(cfg, #ENTRY, def->ENTRY);   \
0723     } while (0)
0724 
0725 #define CFG_READ_ROUND(ENTRY) do {                                      \
0726         opts->ENTRY = toRound(TO_LATIN1(readStringEntry(cfg, #ENTRY)),  \
0727                               def->ENTRY);                              \
0728     } while (0)
0729 
0730 #define CFG_READ_INT(ENTRY) do {                                \
0731         opts->ENTRY = readNumEntry(cfg, #ENTRY, def->ENTRY);    \
0732     } while (0)
0733 
0734 #define CFG_READ_INT_BOOL(ENTRY, DEF) do {                              \
0735         if (readBoolEntry(cfg, #ENTRY, false)) {                        \
0736             opts->ENTRY = DEF;                                          \
0737         } else {                                                        \
0738             opts->ENTRY = readNumEntry(cfg, #ENTRY, def->ENTRY);        \
0739         }                                                               \
0740     } while (0)
0741 
0742 #define CFG_READ_TB_BORDER(ENTRY) do {                                  \
0743         opts->ENTRY = toTBarBorder(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0744                                    def->ENTRY);                         \
0745     } while (0)
0746 
0747 #define CFG_READ_MOUSE_OVER(ENTRY) do {                                 \
0748         opts->ENTRY = toMouseOver(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0749                                   def->ENTRY);                          \
0750     } while (0)
0751 
0752 #define CFG_READ_APPEARANCE(ENTRY, ALLOW) do {                          \
0753         opts->ENTRY = toAppearance(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0754                                    def->ENTRY, ALLOW, nullptr, false);     \
0755     } while (0)
0756 
0757 #define CFG_READ_APPEARANCE_PIXMAP(ENTRY, ALLOW, PIXMAP, CHECK) do {    \
0758         opts->ENTRY = toAppearance(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0759                                    def->ENTRY, ALLOW, PIXMAP, CHECK);   \
0760     } while (0)
0761 
0762 #define CFG_READ_STRIPE(ENTRY) do {                                     \
0763         opts->ENTRY = toStripe(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0764                                def->ENTRY);                             \
0765     } while (0)
0766 
0767 #define CFG_READ_SLIDER(ENTRY) do {                                     \
0768         opts->ENTRY = toSlider(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0769                              def->ENTRY);                               \
0770     } while (0)
0771 
0772 #define CFG_READ_DEF_BTN(ENTRY) do {                                    \
0773         opts->ENTRY = toInd(TO_LATIN1(readStringEntry(cfg, #ENTRY)),    \
0774                             def->ENTRY);                                \
0775     } while (0)
0776 
0777 #define CFG_READ_LINE(ENTRY) do {                                       \
0778         opts->ENTRY = toLine(TO_LATIN1(readStringEntry(cfg, #ENTRY)),   \
0779                              def->ENTRY);                               \
0780     } while (0)
0781 
0782 #define CFG_READ_SHADE(ENTRY, AD, MENU_STRIPE, COL) do {                \
0783         opts->ENTRY = toShade(TO_LATIN1(readStringEntry(cfg, #ENTRY)), AD, \
0784                               def->ENTRY, MENU_STRIPE, COL);            \
0785     } while (0)
0786 
0787 #define CFG_READ_SCROLLBAR(ENTRY) do {                                  \
0788         opts->ENTRY = toScrollbar(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0789                                   def->ENTRY);                          \
0790     } while (0)
0791 
0792 #define CFG_READ_FRAME(ENTRY) do {                                      \
0793         opts->ENTRY = toFrame(TO_LATIN1(readStringEntry(cfg, #ENTRY)),  \
0794                               def->ENTRY);                              \
0795     } while (0)
0796 
0797 #define CFG_READ_EFFECT(ENTRY) do {                                     \
0798         opts->ENTRY = toEffect(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0799                                def->ENTRY);                             \
0800     } while (0)
0801 
0802 #define CFG_READ_SHADING(ENTRY) do {                                    \
0803         opts->ENTRY = toShading(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0804                                 def->ENTRY);                            \
0805     } while (0)
0806 
0807 #define CFG_READ_ECOLOR(ENTRY) do {                                     \
0808         opts->ENTRY = toEColor(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0809                                def->ENTRY);                             \
0810     } while (0)
0811 
0812 #define CFG_READ_FOCUS(ENTRY) do {                                      \
0813         opts->ENTRY = toFocus(TO_LATIN1(readStringEntry(cfg, #ENTRY)),  \
0814                               def->ENTRY);                              \
0815     } while (0)
0816 
0817 #define CFG_READ_TAB_MO(ENTRY) do {                                     \
0818         opts->ENTRY = toTabMo(TO_LATIN1(readStringEntry(cfg, #ENTRY)),  \
0819                               def->ENTRY);                              \
0820     } while (0)
0821 
0822 #define CFG_READ_GRAD_TYPE(ENTRY) do {                                  \
0823         opts->ENTRY = toGradType(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0824                                  def->ENTRY);                           \
0825     } while (0)
0826 
0827 #define CFG_READ_LV_LINES(ENTRY) do {                                   \
0828         opts->ENTRY = toLvLines(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0829                                 def->ENTRY);                            \
0830     } while (0)
0831 
0832 #if defined CONFIG_DIALOG
0833 #define CFG_READ_TB_ICON(ENTRY) do {                                    \
0834         opts->ENTRY = toTitlebarIcon(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0835                                      def->ENTRY);                       \
0836     } while (0)
0837 #endif
0838 
0839 #define CFG_READ_GLOW(ENTRY) do {                                       \
0840         opts->ENTRY = toGlow(TO_LATIN1(readStringEntry(cfg, #ENTRY)),   \
0841                              def->ENTRY);                               \
0842     } while (0)
0843 
0844 #define CFG_READ_TBAR_BTN(ENTRY) do {                                   \
0845         opts->ENTRY = toTBarBtn(TO_LATIN1(readStringEntry(cfg, #ENTRY)), \
0846                                 def->ENTRY);                            \
0847     } while (0)
0848 
0849 static void
0850 checkAppearance(EAppearance *ap, Options *opts)
0851 {
0852     if (*ap >= APPEARANCE_CUSTOM1 &&
0853         *ap < (APPEARANCE_CUSTOM1 + NUM_CUSTOM_GRAD)) {
0854         if (!opts->customGradient[*ap - APPEARANCE_CUSTOM1]) {
0855             if (ap == &opts->appearance) {
0856                 *ap = APPEARANCE_FLAT;
0857             } else {
0858                 *ap = opts->appearance;
0859             }
0860         }
0861     }
0862 }
0863 
0864 void qtcDefaultSettings(Options *opts);
0865 
0866 static void
0867 copyGradients(Options *src, Options *dest)
0868 {
0869     if (src && dest && src != dest) {
0870         for (int i = 0;i < NUM_CUSTOM_GRAD;i++) {
0871             auto &srcGrad = src->customGradient[i];
0872             auto &destGrad = dest->customGradient[i];
0873             if (srcGrad && srcGrad->numStops > 0) {
0874                 destGrad = qtcNew(Gradient);
0875                 destGrad->numStops = srcGrad->numStops;
0876                 destGrad->stops = qtcNew(GradientStop, destGrad->numStops);
0877                 memcpy(destGrad->stops, srcGrad->stops,
0878                        sizeof(GradientStop) * destGrad->numStops);
0879                 destGrad->border = srcGrad->border;
0880             } else {
0881                 destGrad = nullptr;
0882             }
0883         }
0884     }
0885 }
0886 
0887 static void copyOpts(Options *src, Options *dest)
0888 {
0889     if(src && dest && src!=dest)
0890     {
0891         memcpy(dest, src, sizeof(Options));
0892         dest->noBgndGradientApps=src->noBgndGradientApps;
0893         dest->noBgndOpacityApps=src->noBgndOpacityApps;
0894         dest->noMenuBgndOpacityApps=src->noMenuBgndOpacityApps;
0895         dest->noBgndImageApps=src->noBgndImageApps;
0896         dest->noMenuStripeApps=src->noMenuStripeApps;
0897         src->noBgndGradientApps=src->noBgndOpacityApps=src->noMenuBgndOpacityApps=src->noBgndImageApps=src->noMenuStripeApps=nullptr;
0898         memcpy(dest->customShades, src->customShades,
0899                sizeof(double) * QTC_NUM_STD_SHADES);
0900         memcpy(dest->customAlphas, src->customAlphas,
0901                sizeof(double) * NUM_STD_ALPHAS);
0902         copyGradients(src, dest);
0903     }
0904 }
0905 
0906 static void
0907 freeOpts(Options *opts)
0908 {
0909     if (opts) {
0910         if (opts->noBgndGradientApps)
0911             g_strfreev(opts->noBgndGradientApps);
0912         if (opts->noBgndOpacityApps)
0913             g_strfreev(opts->noBgndOpacityApps);
0914         if (opts->noMenuBgndOpacityApps)
0915             g_strfreev(opts->noMenuBgndOpacityApps);
0916         if (opts->noBgndImageApps)
0917             g_strfreev(opts->noBgndImageApps);
0918         if (opts->noMenuStripeApps)
0919             g_strfreev(opts->noMenuStripeApps);
0920         opts->noBgndGradientApps = nullptr;
0921         opts->noBgndOpacityApps = nullptr;
0922         opts->noMenuBgndOpacityApps = nullptr;
0923         opts->noBgndImageApps = nullptr;
0924         opts->noMenuStripeApps = nullptr;
0925         for (int i = 0;i < NUM_CUSTOM_GRAD;++i) {
0926             if (auto &grad = opts->customGradient[i]) {
0927                 free(grad->stops);
0928                 free(grad);
0929                 grad = nullptr;
0930             }
0931         }
0932     }
0933 }
0934 
0935 void qtcCheckConfig(Options *opts)
0936 {
0937     /* **Must** check appearance first, as the rest will default to this */
0938     checkAppearance(&opts->appearance, opts);
0939     checkAppearance(&opts->bgndAppearance, opts);
0940     checkAppearance(&opts->menuBgndAppearance, opts);
0941     checkAppearance(&opts->menubarAppearance, opts);
0942     checkAppearance(&opts->menuitemAppearance, opts);
0943     checkAppearance(&opts->toolbarAppearance, opts);
0944     checkAppearance(&opts->lvAppearance, opts);
0945     checkAppearance(&opts->tabAppearance, opts);
0946     checkAppearance(&opts->activeTabAppearance, opts);
0947     checkAppearance(&opts->sliderAppearance, opts);
0948     checkAppearance(&opts->selectionAppearance, opts);
0949     checkAppearance(&opts->titlebarAppearance, opts);
0950     checkAppearance(&opts->inactiveTitlebarAppearance, opts);
0951     checkAppearance(&opts->menuStripeAppearance, opts);
0952     checkAppearance(&opts->progressAppearance, opts);
0953     checkAppearance(&opts->progressGrooveAppearance, opts);
0954     checkAppearance(&opts->grooveAppearance, opts);
0955     checkAppearance(&opts->sunkenAppearance, opts);
0956     checkAppearance(&opts->sbarBgndAppearance, opts);
0957     checkAppearance(&opts->sliderFill, opts);
0958     checkAppearance(&opts->tooltipAppearance, opts);
0959 
0960     if(SHADE_BLEND_SELECTED==opts->shadeCheckRadio)
0961         opts->shadeCheckRadio=SHADE_SELECTED;
0962 
0963     checkColor(&opts->shadeMenubars, &opts->customMenubarsColor);
0964     checkColor(&opts->shadeSliders, &opts->customSlidersColor);
0965     checkColor(&opts->shadeCheckRadio, &opts->customCheckRadioColor);
0966     checkColor(&opts->menuStripe, &opts->customMenuStripeColor);
0967     checkColor(&opts->comboBtn, &opts->customComboBtnColor);
0968     checkColor(&opts->sortedLv, &opts->customSortedLvColor);
0969     if(APPEARANCE_BEVELLED==opts->toolbarAppearance)
0970         opts->toolbarAppearance=APPEARANCE_GRADIENT;
0971     else if(APPEARANCE_RAISED==opts->toolbarAppearance)
0972         opts->toolbarAppearance=APPEARANCE_FLAT;
0973 
0974     if(APPEARANCE_BEVELLED==opts->menubarAppearance)
0975         opts->menubarAppearance=APPEARANCE_GRADIENT;
0976     else if(APPEARANCE_RAISED==opts->menubarAppearance)
0977         opts->menubarAppearance=APPEARANCE_FLAT;
0978 
0979     if(APPEARANCE_BEVELLED==opts->sliderAppearance)
0980         opts->sliderAppearance=APPEARANCE_GRADIENT;
0981 
0982     if(APPEARANCE_BEVELLED==opts->tabAppearance)
0983         opts->tabAppearance=APPEARANCE_GRADIENT;
0984 
0985     if(APPEARANCE_BEVELLED==opts->activeTabAppearance)
0986         opts->activeTabAppearance=APPEARANCE_GRADIENT;
0987 
0988     if(APPEARANCE_RAISED==opts->selectionAppearance)
0989         opts->selectionAppearance=APPEARANCE_FLAT;
0990     else if(APPEARANCE_BEVELLED==opts->selectionAppearance)
0991         opts->selectionAppearance=APPEARANCE_GRADIENT;
0992 
0993     if(APPEARANCE_RAISED==opts->menuStripeAppearance)
0994         opts->menuStripeAppearance=APPEARANCE_FLAT;
0995     else if(APPEARANCE_BEVELLED==opts->menuStripeAppearance)
0996         opts->menuStripeAppearance=APPEARANCE_GRADIENT;
0997 
0998     if(opts->highlightFactor<MIN_HIGHLIGHT_FACTOR || opts->highlightFactor>MAX_HIGHLIGHT_FACTOR)
0999         opts->highlightFactor=DEFAULT_HIGHLIGHT_FACTOR;
1000 
1001     if(opts->crHighlight<MIN_HIGHLIGHT_FACTOR || opts->crHighlight>MAX_HIGHLIGHT_FACTOR)
1002         opts->crHighlight=DEFAULT_CR_HIGHLIGHT_FACTOR;
1003 
1004     if(opts->splitterHighlight<MIN_HIGHLIGHT_FACTOR || opts->splitterHighlight>MAX_HIGHLIGHT_FACTOR)
1005         opts->splitterHighlight=DEFAULT_SPLITTER_HIGHLIGHT_FACTOR;
1006 
1007     if(opts->expanderHighlight<MIN_HIGHLIGHT_FACTOR || opts->expanderHighlight>MAX_HIGHLIGHT_FACTOR)
1008         opts->expanderHighlight=DEFAULT_EXPANDER_HIGHLIGHT_FACTOR;
1009 
1010     if(0==opts->menuDelay) /* Qt seems to have issues if delay is 0 - so set this to 1 :-) */
1011         opts->menuDelay=MIN_MENU_DELAY;
1012     else if(opts->menuDelay<MIN_MENU_DELAY || opts->menuDelay>MAX_MENU_DELAY)
1013         opts->menuDelay=DEFAULT_MENU_DELAY;
1014 
1015     if(0==opts->sliderWidth%2)
1016         opts->sliderWidth++;
1017 
1018     if(opts->sliderWidth<MIN_SLIDER_WIDTH || opts->sliderWidth>MAX_SLIDER_WIDTH)
1019         opts->sliderWidth=DEFAULT_SLIDER_WIDTH;
1020 
1021     if(opts->sliderWidth<MIN_SLIDER_WIDTH_ROUND)
1022         opts->square|=SQUARE_SB_SLIDER;
1023 
1024     if(opts->sliderWidth<MIN_SLIDER_WIDTH_THIN_GROOVE)
1025         opts->thinSbarGroove=false;
1026 
1027     if(opts->sliderWidth<DEFAULT_SLIDER_WIDTH)
1028         opts->sliderThumbs=LINE_NONE;
1029 
1030     if(opts->lighterPopupMenuBgnd<MIN_LIGHTER_POPUP_MENU || opts->lighterPopupMenuBgnd>MAX_LIGHTER_POPUP_MENU)
1031         opts->lighterPopupMenuBgnd=DEF_POPUPMENU_LIGHT_FACTOR;
1032 
1033     if(opts->tabBgnd<MIN_TAB_BGND || opts->tabBgnd>MAX_TAB_BGND)
1034         opts->tabBgnd=DEF_TAB_BGND;
1035 
1036     if(opts->animatedProgress && !opts->stripedProgress)
1037         opts->animatedProgress=false;
1038 
1039     if(0==opts->gbFactor && FRAME_SHADED==opts->groupBox)
1040         opts->groupBox=FRAME_PLAIN;
1041 
1042     if(opts->gbFactor<MIN_GB_FACTOR || opts->gbFactor>MAX_GB_FACTOR)
1043         opts->gbFactor=DEF_GB_FACTOR;
1044 
1045     if(!opts->gtkComboMenus)
1046         opts->doubleGtkComboArrow=false;
1047 
1048     /* For now, only 2 sizes... */
1049     if(opts->crSize!=CR_SMALL_SIZE && opts->crSize!=CR_LARGE_SIZE)
1050         opts->crSize=CR_SMALL_SIZE;
1051 
1052 /*
1053 ??
1054     if(SHADE_CUSTOM==opts->shadeMenubars || SHADE_BLEND_SELECTED==opts->shadeMenubars || !opts->borderMenuitems)
1055         opts->colorMenubarMouseOver=true;
1056 */
1057 
1058 #ifndef CONFIG_DIALOG
1059     if(MO_GLOW==opts->coloredMouseOver && EFFECT_NONE==opts->buttonEffect)
1060         opts->coloredMouseOver=MO_COLORED_THICK;
1061 
1062     if(IND_GLOW==opts->defBtnIndicator && EFFECT_NONE==opts->buttonEffect)
1063         opts->defBtnIndicator=IND_TINT;
1064 
1065     if(opts->round>ROUND_EXTRA && FOCUS_GLOW!=opts->focus)
1066         opts->focus=FOCUS_LINE;
1067 
1068     if(EFFECT_NONE==opts->buttonEffect)
1069     {
1070         opts->etchEntry=false;
1071         if(FOCUS_GLOW==opts->focus)
1072             opts->focus=FOCUS_FULL;
1073     }
1074 
1075 //     if(opts->squareScrollViews)
1076 //         opts->highlightScrollViews=false;
1077 
1078     if(SHADE_WINDOW_BORDER==opts->shadeMenubars)
1079         opts->shadeMenubarOnlyWhenActive=true;
1080 
1081     if(MO_GLOW==opts->coloredMouseOver)
1082         opts->coloredTbarMo=true;
1083 
1084     if(ROUND_NONE==opts->round)
1085         opts->square=SQUARE_ALL;
1086 #endif
1087 
1088     if(opts->bgndOpacity<0 || opts->bgndOpacity>100)
1089         opts->bgndOpacity=100;
1090     if(opts->dlgOpacity<0 || opts->dlgOpacity>100)
1091         opts->dlgOpacity=100;
1092     if(opts->menuBgndOpacity<0 || opts->menuBgndOpacity>100)
1093         opts->menuBgndOpacity = 100;
1094 
1095 #ifndef CONFIG_DIALOG
1096     opts->bgndAppearance=MODIFY_AGUA(opts->bgndAppearance);
1097     opts->selectionAppearance=MODIFY_AGUA(opts->selectionAppearance);
1098     opts->lvAppearance=MODIFY_AGUA_X(opts->lvAppearance, APPEARANCE_LV_AGUA);
1099     opts->sbarBgndAppearance=MODIFY_AGUA(opts->sbarBgndAppearance);
1100     opts->tooltipAppearance=MODIFY_AGUA(opts->tooltipAppearance);
1101     opts->progressGrooveAppearance=MODIFY_AGUA(opts->progressGrooveAppearance);
1102     opts->menuBgndAppearance=MODIFY_AGUA(opts->menuBgndAppearance);
1103     opts->menuStripeAppearance=MODIFY_AGUA(opts->menuStripeAppearance);
1104     opts->grooveAppearance=MODIFY_AGUA(opts->grooveAppearance);
1105     opts->progressAppearance=MODIFY_AGUA(opts->progressAppearance);
1106     opts->sliderFill=MODIFY_AGUA(opts->sliderFill);
1107     opts->tabAppearance=MODIFY_AGUA(opts->tabAppearance);
1108     opts->activeTabAppearance=MODIFY_AGUA(opts->activeTabAppearance);
1109     opts->menuitemAppearance=MODIFY_AGUA(opts->menuitemAppearance);
1110 
1111     if(!opts->borderProgress && (!opts->fillProgress || !(opts->square&SQUARE_PROGRESS)))
1112         opts->borderProgress=true;
1113 
1114     opts->titlebarAppearance=MODIFY_AGUA(opts->titlebarAppearance);
1115     opts->inactiveTitlebarAppearance=MODIFY_AGUA(opts->inactiveTitlebarAppearance);
1116 
1117     if(opts->shadePopupMenu && SHADE_NONE==opts->shadeMenubars)
1118         opts->shadePopupMenu=false;
1119 
1120     if(opts->windowBorder&WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR &&
1121         (opts->windowBorder&WINDOW_BORDER_BLEND_TITLEBAR || SHADE_WINDOW_BORDER==opts->shadeMenubars))
1122         opts->windowBorder-=WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR;
1123 
1124     if(APPEARANCE_FLAT==opts->tabAppearance)
1125         opts->tabAppearance=APPEARANCE_RAISED;
1126     if(EFFECT_NONE==opts->buttonEffect)
1127         opts->etchEntry=false;
1128     if(opts->colorSliderMouseOver &&
1129         (SHADE_NONE==opts->shadeSliders || SHADE_DARKEN==opts->shadeSliders))
1130         opts->colorSliderMouseOver=false;
1131 #endif /* ndef CONFIG_DIALOG */
1132 
1133     if(LINE_1DOT==opts->toolbarSeparators)
1134         opts->toolbarSeparators=LINE_DOTS;
1135 }
1136 
1137 bool qtcReadConfig(const char *file, Options *opts, Options *defOpts)
1138 {
1139     bool checkImages=true;
1140     if (!file) {
1141         const char *env = getenv("QTCURVE_CONFIG_FILE");
1142         if (env && *env)
1143             return qtcReadConfig(env, opts, defOpts);
1144         auto filename = QtCurve::getConfFile(std::string(CONFIG_FILE));
1145         if (!QtCurve::isRegFile(filename.c_str())) {
1146             filename = QtCurve::getConfFile(std::string("/../"
1147                                                         OLD_CONFIG_FILE));
1148         }
1149         return qtcReadConfig(filename.c_str(), opts, defOpts);
1150     } else {
1151         GHashTable *cfg = loadConfig(file);
1152 
1153         if (cfg) {
1154             opts->version = readVersionEntry(cfg, VERSION_KEY);
1155 
1156             Options newOpts;
1157             Options *def=&newOpts;
1158             opts->noBgndGradientApps=opts->noBgndOpacityApps=opts->noMenuBgndOpacityApps=opts->noBgndImageApps=opts->noMenuStripeApps=nullptr;
1159             for (int i = 0;i < NUM_CUSTOM_GRAD;++i) {
1160                 opts->customGradient[i] = nullptr;
1161             }
1162 
1163             if(defOpts)
1164                 copyOpts(defOpts, &newOpts);
1165             else
1166                 qtcDefaultSettings(&newOpts);
1167             if(opts!=def)
1168                 copyGradients(def, opts);
1169 
1170             /* Check if the config file expects old default values... */
1171             if(opts->version<qtcMakeVersion(1, 6))
1172             {
1173                 bool framelessGroupBoxes=readBoolEntry(cfg, "framelessGroupBoxes", true),
1174                      groupBoxLine=readBoolEntry(cfg, "groupBoxLine", true);
1175                 opts->groupBox=framelessGroupBoxes ? (groupBoxLine ? FRAME_LINE : FRAME_NONE) : FRAME_PLAIN;
1176                 opts->gbLabel=framelessGroupBoxes ? GB_LBL_BOLD : 0;
1177                 opts->gbFactor=0;
1178                 def->focus=FOCUS_LINE;
1179                 def->crHighlight=3;
1180             } else {
1181                 CFG_READ_FRAME(groupBox);
1182                 CFG_READ_INT(gbLabel);
1183             }
1184 
1185             if(opts->version<qtcMakeVersion(1, 5))
1186             {
1187                 opts->windowBorder=
1188                     (readBoolEntry(cfg, "colorTitlebarOnly", def->windowBorder&WINDOW_BORDER_COLOR_TITLEBAR_ONLY)
1189                                                                 ? WINDOW_BORDER_COLOR_TITLEBAR_ONLY : 0)+
1190                     (readBoolEntry(cfg, "titlebarBorder", def->windowBorder&WINDOW_BORDER_ADD_LIGHT_BORDER)
1191                                                                 ? WINDOW_BORDER_ADD_LIGHT_BORDER : 0)+
1192                     (readBoolEntry(cfg, "titlebarBlend", def->windowBorder&WINDOW_BORDER_BLEND_TITLEBAR)
1193                                                                 ? WINDOW_BORDER_BLEND_TITLEBAR : 0);
1194             }
1195             else
1196                 CFG_READ_INT(windowBorder);
1197 
1198             if(opts->version<qtcMakeVersion(1, 7))
1199             {
1200                 opts->windowBorder|=WINDOW_BORDER_FILL_TITLEBAR;
1201                 def->square=SQUARE_POPUP_MENUS;
1202             }
1203 
1204             if(opts->version<qtcMakeVersion(1, 4))
1205             {
1206                 opts->square=
1207                     (readBoolEntry(cfg, "squareLvSelection", def->square&SQUARE_LISTVIEW_SELECTION) ? SQUARE_LISTVIEW_SELECTION : SQUARE_NONE)+
1208                     (readBoolEntry(cfg, "squareScrollViews", def->square&SQUARE_SCROLLVIEW) ? SQUARE_SCROLLVIEW : SQUARE_NONE)+
1209                     (readBoolEntry(cfg, "squareProgress", def->square&SQUARE_PROGRESS) ? SQUARE_PROGRESS : SQUARE_NONE)+
1210                     (readBoolEntry(cfg, "squareEntry", def->square&SQUARE_ENTRY)? SQUARE_ENTRY : SQUARE_NONE);
1211             }
1212             else
1213                 CFG_READ_INT(square);
1214             if(opts->version<qtcMakeVersion(1, 7))
1215             {
1216                 def->tbarBtns=TBTN_STANDARD;
1217                 opts->thin=(readBoolEntry(cfg, "thinnerMenuItems", def->thin&THIN_MENU_ITEMS) ? THIN_MENU_ITEMS : 0)+
1218                            (readBoolEntry(cfg, "thinnerBtns", def->thin&THIN_BUTTONS) ? THIN_BUTTONS : 0);
1219             }
1220             else
1221             {
1222                 CFG_READ_INT(thin);
1223             }
1224             if (opts->version < qtcMakeVersion(1, 6))
1225                 opts->square |= SQUARE_TOOLTIPS;
1226             if (opts->version < qtcMakeVersion(1, 6, 1))
1227                 opts->square |= SQUARE_POPUP_MENUS;
1228             if (opts->version < qtcMakeVersion(1, 2))
1229                 def->crSize = CR_SMALL_SIZE;
1230             if (opts != def) {
1231                 opts->customShades[0] = 0;
1232                 opts->customAlphas[0] = 0;
1233                 if (USE_CUSTOM_SHADES(*def)) {
1234                     memcpy(opts->customShades, def->customShades,
1235                            sizeof(double) * QTC_NUM_STD_SHADES);
1236                 }
1237             }
1238 
1239             CFG_READ_INT(gbFactor);
1240             CFG_READ_INT(passwordChar);
1241             CFG_READ_ROUND(round);
1242             CFG_READ_INT(highlightFactor);
1243             CFG_READ_INT(menuDelay);
1244             CFG_READ_INT(menuCloseDelay);
1245             CFG_READ_INT(sliderWidth);
1246             CFG_READ_INT(tabBgnd);
1247             CFG_READ_TB_BORDER(toolbarBorders);
1248             CFG_READ_APPEARANCE(appearance, APP_ALLOW_BASIC);
1249             if (opts->version<qtcMakeVersion(1, 8)) {
1250                 opts->tbarBtnAppearance = APPEARANCE_NONE;
1251                 opts->tbarBtnEffect = EFFECT_NONE;
1252             } else {
1253                 CFG_READ_APPEARANCE(tbarBtnAppearance, APP_ALLOW_NONE);
1254                 CFG_READ_EFFECT(tbarBtnEffect);
1255             }
1256             CFG_READ_APPEARANCE_PIXMAP(bgndAppearance, APP_ALLOW_STRIPED,
1257                                        &opts->bgndPixmap, checkImages);
1258             CFG_READ_GRAD_TYPE(bgndGrad);
1259             CFG_READ_GRAD_TYPE(menuBgndGrad);
1260             CFG_READ_INT_BOOL(lighterPopupMenuBgnd, def->lighterPopupMenuBgnd);
1261             CFG_READ_APPEARANCE_PIXMAP(menuBgndAppearance, APP_ALLOW_STRIPED,
1262                                        &opts->menuBgndPixmap, checkImages);
1263 
1264             if (opts->menuBgndAppearance == APPEARANCE_FLAT &&
1265                 opts->lighterPopupMenuBgnd == 0 &&
1266                 opts->version<qtcMakeVersion(1, 7)) {
1267                 opts->menuBgndAppearance = APPEARANCE_RAISED;
1268             }
1269 
1270             CFG_READ_STRIPE(stripedProgress);
1271             CFG_READ_SLIDER(sliderStyle);
1272             CFG_READ_BOOL(animatedProgress);
1273             CFG_READ_BOOL(embolden);
1274             CFG_READ_DEF_BTN(defBtnIndicator);
1275             CFG_READ_LINE(sliderThumbs);
1276             CFG_READ_LINE(handles);
1277             CFG_READ_BOOL(highlightTab);
1278             CFG_READ_INT_BOOL(colorSelTab, DEF_COLOR_SEL_TAB_FACTOR);
1279             CFG_READ_BOOL(roundAllTabs);
1280             CFG_READ_TAB_MO(tabMouseOver);
1281             CFG_READ_SHADE(shadeSliders, true, false,
1282                            &opts->customSlidersColor);
1283             CFG_READ_SHADE(shadeMenubars, true, false,
1284                            &opts->customMenubarsColor);
1285             CFG_READ_SHADE(shadeCheckRadio, false, false,
1286                            &opts->customCheckRadioColor);
1287             CFG_READ_SHADE(sortedLv, true, false, &opts->customSortedLvColor);
1288             CFG_READ_SHADE(crColor,  true, false, &opts->customCrBgndColor);
1289             CFG_READ_SHADE(progressColor, false, false,
1290                            &opts->customProgressColor);
1291             CFG_READ_APPEARANCE(menubarAppearance, APP_ALLOW_BASIC);
1292             CFG_READ_APPEARANCE(menuitemAppearance, APP_ALLOW_FADE);
1293             CFG_READ_APPEARANCE(toolbarAppearance, APP_ALLOW_BASIC);
1294             CFG_READ_APPEARANCE(selectionAppearance, APP_ALLOW_BASIC);
1295             CFG_READ_LINE(toolbarSeparators);
1296             CFG_READ_LINE(splitters);
1297             CFG_READ_BOOL(customMenuTextColor);
1298             CFG_READ_MOUSE_OVER(coloredMouseOver);
1299             CFG_READ_BOOL(menubarMouseOver);
1300             CFG_READ_BOOL(useHighlightForMenu);
1301             CFG_READ_BOOL(shadeMenubarOnlyWhenActive);
1302             CFG_READ_TBAR_BTN(tbarBtns);
1303             CFG_READ_COLOR(customMenuSelTextColor);
1304             CFG_READ_COLOR(customMenuNormTextColor);
1305             CFG_READ_SCROLLBAR(scrollbarType);
1306             CFG_READ_EFFECT(buttonEffect);
1307             CFG_READ_APPEARANCE(lvAppearance, APP_ALLOW_BASIC);
1308             CFG_READ_APPEARANCE(tabAppearance, APP_ALLOW_BASIC);
1309             CFG_READ_APPEARANCE(activeTabAppearance, APP_ALLOW_BASIC);
1310             CFG_READ_APPEARANCE(sliderAppearance, APP_ALLOW_BASIC);
1311             CFG_READ_APPEARANCE(progressAppearance, APP_ALLOW_BASIC);
1312             CFG_READ_APPEARANCE(progressGrooveAppearance, APP_ALLOW_BASIC);
1313             CFG_READ_APPEARANCE(grooveAppearance, APP_ALLOW_BASIC);
1314             CFG_READ_APPEARANCE(sunkenAppearance, APP_ALLOW_BASIC);
1315             CFG_READ_APPEARANCE(sbarBgndAppearance, APP_ALLOW_BASIC);
1316             if (opts->version < qtcMakeVersion(1, 6)) {
1317                 opts->tooltipAppearance = APPEARANCE_FLAT;
1318             } else {
1319                 CFG_READ_APPEARANCE(tooltipAppearance, APP_ALLOW_BASIC);
1320             }
1321 
1322             CFG_READ_APPEARANCE(sliderFill, APP_ALLOW_BASIC);
1323             CFG_READ_ECOLOR(progressGrooveColor);
1324             CFG_READ_FOCUS(focus);
1325             CFG_READ_BOOL(lvButton);
1326             CFG_READ_LV_LINES(lvLines);
1327             CFG_READ_BOOL(drawStatusBarFrames);
1328             CFG_READ_BOOL(fillSlider);
1329             CFG_READ_BOOL(roundMbTopOnly);
1330             CFG_READ_BOOL(borderMenuitems);
1331             CFG_READ_BOOL(darkerBorders);
1332             CFG_READ_BOOL(vArrows);
1333             CFG_READ_BOOL(xCheck);
1334             CFG_READ_BOOL(fadeLines);
1335             CFG_READ_GLOW(glowProgress);
1336             CFG_READ_BOOL(colorMenubarMouseOver);
1337             CFG_READ_INT_BOOL(crHighlight, opts->highlightFactor);
1338             CFG_READ_BOOL(crButton);
1339             CFG_READ_BOOL(smallRadio);
1340             CFG_READ_BOOL(fillProgress);
1341             CFG_READ_BOOL(comboSplitter);
1342             CFG_READ_BOOL(highlightScrollViews);
1343             CFG_READ_BOOL(etchEntry);
1344             CFG_READ_INT_BOOL(splitterHighlight, opts->highlightFactor);
1345             CFG_READ_INT(crSize);
1346             CFG_READ_BOOL(flatSbarButtons);
1347             CFG_READ_BOOL(borderSbarGroove);
1348             CFG_READ_BOOL(borderProgress);
1349             CFG_READ_BOOL(popupBorder);
1350             CFG_READ_BOOL(unifySpinBtns);
1351             CFG_READ_BOOL(unifySpin);
1352             CFG_READ_BOOL(unifyCombo);
1353             CFG_READ_BOOL(borderTab);
1354             CFG_READ_BOOL(borderInactiveTab);
1355             CFG_READ_BOOL(thinSbarGroove);
1356             CFG_READ_BOOL(colorSliderMouseOver);
1357             CFG_READ_BOOL(menuIcons);
1358             CFG_READ_BOOL(onlyTicksInMenu);
1359             CFG_READ_BOOL(buttonStyleMenuSections);
1360             CFG_READ_BOOL(forceAlternateLvCols);
1361             CFG_READ_BOOL(invertBotTab);
1362             CFG_READ_INT_BOOL(menubarHiding, HIDE_KEYBOARD);
1363             CFG_READ_INT_BOOL(statusbarHiding, HIDE_KEYBOARD);
1364             CFG_READ_BOOL(boldProgress);
1365             CFG_READ_BOOL(coloredTbarMo);
1366             CFG_READ_BOOL(borderSelection);
1367             CFG_READ_BOOL(stripedSbar);
1368             CFG_READ_INT_BOOL(windowDrag, WM_DRAG_MENUBAR);
1369             CFG_READ_BOOL(shadePopupMenu);
1370             CFG_READ_BOOL(hideShortcutUnderline);
1371 
1372 #if defined CONFIG_DIALOG
1373             CFG_READ_BOOL(stdBtnSizes);
1374             CFG_READ_INT(titlebarButtons);
1375             CFG_READ_TB_ICON(titlebarIcon);
1376 #endif
1377             CFG_READ_INT(bgndOpacity);
1378             CFG_READ_INT(menuBgndOpacity);
1379             CFG_READ_INT(dlgOpacity);
1380             CFG_READ_INT(shadowSize);
1381             qtcX11SetShadowSize(opts->shadowSize);
1382             CFG_READ_SHADE(menuStripe, true, true, &opts->customMenuStripeColor);
1383             CFG_READ_APPEARANCE(menuStripeAppearance, APP_ALLOW_BASIC);
1384             CFG_READ_SHADE(comboBtn, true, false, &opts->customComboBtnColor);
1385             CFG_READ_BOOL(gtkScrollViews);
1386             CFG_READ_BOOL(doubleGtkComboArrow);
1387             CFG_READ_BOOL(stdSidebarButtons);
1388             CFG_READ_BOOL(toolbarTabs);
1389             CFG_READ_BOOL(gtkComboMenus);
1390             CFG_READ_INT(expanderHighlight);
1391             CFG_READ_BOOL(mapKdeIcons);
1392             CFG_READ_BOOL(gtkButtonOrder);
1393             CFG_READ_BOOL(reorderGtkButtons);
1394             CFG_READ_APPEARANCE(titlebarAppearance, APP_ALLOW_NONE);
1395             CFG_READ_APPEARANCE(inactiveTitlebarAppearance, APP_ALLOW_NONE);
1396 
1397             if(APPEARANCE_BEVELLED==opts->titlebarAppearance)
1398                 opts->titlebarAppearance=APPEARANCE_GRADIENT;
1399             else if(APPEARANCE_RAISED==opts->titlebarAppearance)
1400                 opts->titlebarAppearance=APPEARANCE_FLAT;
1401             if((opts->windowBorder&WINDOW_BORDER_BLEND_TITLEBAR) && !(opts->windowBorder&WINDOW_BORDER_COLOR_TITLEBAR_ONLY))
1402                 opts->windowBorder-=WINDOW_BORDER_BLEND_TITLEBAR;
1403             if(APPEARANCE_BEVELLED==opts->inactiveTitlebarAppearance)
1404                 opts->inactiveTitlebarAppearance=APPEARANCE_GRADIENT;
1405             else if(APPEARANCE_RAISED==opts->inactiveTitlebarAppearance)
1406                 opts->inactiveTitlebarAppearance=APPEARANCE_FLAT;
1407             CFG_READ_SHADING(shading);
1408             CFG_READ_IMAGE(bgndImage);
1409             CFG_READ_IMAGE(menuBgndImage);
1410             CFG_READ_STRING_LIST(noMenuStripeApps);
1411             CFG_READ_STRING_LIST(noBgndGradientApps);
1412             CFG_READ_STRING_LIST(noBgndOpacityApps);
1413             CFG_READ_STRING_LIST(noMenuBgndOpacityApps);
1414             CFG_READ_STRING_LIST(noBgndImageApps);
1415 #ifdef CONFIG_DIALOG
1416             if (opts->version < qtcMakeVersion(1, 7, 2)) {
1417                 opts->noMenuBgndOpacityApps << "gtk";
1418             }
1419 #endif
1420             readDoubleList(cfg, "customShades", opts->customShades,
1421                            QTC_NUM_STD_SHADES);
1422             readDoubleList(cfg, "customAlphas", opts->customAlphas,
1423                            NUM_STD_ALPHAS);
1424 
1425             for (int i = 0;i < NUM_CUSTOM_GRAD;++i) {
1426                 char gradKey[18];
1427                 sprintf(gradKey, "customgradient%d", i + 1);
1428                 if (char *str = readStringEntry(cfg, gradKey)) {
1429                     auto &grad = opts->customGradient[i];
1430                     int comma = 0;
1431 
1432                     for (int j = 0;str[j];j++) {
1433                         if (str[j] == ',') {
1434                             comma++;
1435                         }
1436                     }
1437 
1438                     if (comma && grad) {
1439                         free(grad->stops);
1440                         free(grad);
1441                         grad = nullptr;
1442                     }
1443 
1444                     if (comma>=4) {
1445                         char *c = strchr(str, ',');
1446 
1447                         if (c) {
1448                             bool haveAlpha = false;
1449                             EGradientBorder border =
1450                                 toGradientBorder(str, &haveAlpha);
1451                             int parts = haveAlpha ? 3 : 2;
1452                             bool ok = 0 == comma % parts;
1453 
1454                             *c = '\0';
1455 
1456                             if (ok) {
1457                                 grad = qtcNew(Gradient);
1458                                 grad->numStops = comma / parts;
1459                                 grad->stops = qtcNew(GradientStop,
1460                                                      grad->numStops);
1461                                 grad->border = border;
1462                                 str = c + 1;
1463                                 for (int j = 0;j < comma && str && ok;
1464                                      j += parts) {
1465                                     int stop = j / parts;
1466                                     c = strchr(str, ',');
1467 
1468                                     if (c) {
1469                                         *c = '\0';
1470                                         grad->stops[stop].pos =
1471                                             g_ascii_strtod(str, nullptr);
1472                                         str = c + 1;
1473                                         c = str ? strchr(str, ',') : nullptr;
1474 
1475                                         if (c || str) {
1476                                             if (c) {
1477                                                 *c = '\0';
1478                                             }
1479                                             grad->stops[stop].val =
1480                                                 g_ascii_strtod(str, nullptr);
1481                                             str = c ? c + 1 : c;
1482                                             if (haveAlpha) {
1483                                                 c = str ? strchr(str, ',') : nullptr;
1484                                                 if (c || str) {
1485                                                     if (c) {
1486                                                         *c = '\0';
1487                                                     }
1488                                                     grad->stops[stop].alpha =
1489                                                         g_ascii_strtod(str, nullptr);
1490                                                     str = c ? c + 1 : c;
1491                                                 } else {
1492                                                     ok = false;
1493                                                 }
1494                                             } else {
1495                                                 grad->stops[stop].alpha = 1.0;
1496                                             }
1497                                         } else {
1498                                             ok = false;
1499                                         }
1500                                     } else {
1501                                         ok = false;
1502                                     }
1503                                     ok = (ok && grad->stops[stop].pos >= 0 &&
1504                                           grad->stops[stop].pos <= 1.0 &&
1505                                           grad->stops[stop].val >= 0.0 &&
1506                                           grad->stops[stop].val <= 2.0 &&
1507                                           grad->stops[stop].alpha >= 0.0 &&
1508                                           grad->stops[stop].alpha <= 1.0);
1509                                 }
1510 
1511                                 if (ok) {
1512                                     int addStart = 0;
1513                                     int addEnd = 0;
1514                                     if (grad->stops[0].pos > 0.001)
1515                                         addStart = 1;
1516                                     if (grad->stops[grad->numStops - 1].pos
1517                                         < 0.999)
1518                                         addEnd = 1;
1519 
1520                                     if (addStart || addEnd) {
1521                                         int newSize = (grad->numStops +
1522                                                        addStart + addEnd);
1523                                         GradientStop *stops =
1524                                             qtcNew(GradientStop, newSize);
1525                                         if (addStart) {
1526                                             stops[0].pos = 0.0;
1527                                             stops[0].val = 1.0;
1528                                             stops[0].alpha = 1.0;
1529                                         }
1530                                         memcpy(&stops[addStart], grad->stops,
1531                                                sizeof(GradientStop) *
1532                                                grad->numStops);
1533                                         if (addEnd) {
1534                                             auto &stop =
1535                                                 stops[grad->numStops + addStart];
1536                                             stop.pos = 1.0;
1537                                             stop.val = 1.0;
1538                                             stop.alpha = 1.0;
1539                                         }
1540                                         grad->numStops = newSize;
1541                                         free(grad->stops);
1542                                         grad->stops = stops;
1543                                     }
1544                                 } else {
1545                                     free(grad->stops);
1546                                     free(grad);
1547                                     grad = nullptr;
1548                                 }
1549                             }
1550                         }
1551                     }
1552                 }
1553             }
1554 
1555             qtcCheckConfig(opts);
1556 
1557             if (!defOpts) {
1558                 for (int i = 0;i < NUM_CUSTOM_GRAD;++i) {
1559                     free(def->customGradient[i]);
1560                 }
1561             }
1562             releaseConfig(cfg);
1563             freeOpts(defOpts);
1564             return true;
1565         } else {
1566             if (defOpts) {
1567                 copyOpts(defOpts, opts);
1568             } else {
1569                 qtcDefaultSettings(opts);
1570             }
1571             return true;
1572         }
1573     }
1574     return false;
1575 }
1576 
1577 static const char * getSystemConfigFile()
1578 {
1579     static const char *constFiles[] = {
1580         /* "/etc/qt4/"OLD_CONFIG_FILE,
1581            "/etc/qt3/"OLD_CONFIG_FILE,
1582            "/etc/qt/"OLD_CONFIG_FILE, */
1583         "/etc/" OLD_CONFIG_FILE,
1584         nullptr};
1585 
1586     for (int i = 0;constFiles[i];i++) {
1587         if (QtCurve::isRegFile(constFiles[i])) {
1588             return constFiles[i];
1589         }
1590     }
1591     return nullptr;
1592 }
1593 
1594 void qtcDefaultSettings(Options *opts)
1595 {
1596     /* Set hard-coded defaults... */
1597     for (int i = 0;i < NUM_CUSTOM_GRAD;++i) {
1598         opts->customGradient[i] = nullptr;
1599     }
1600     opts->customGradient[APPEARANCE_CUSTOM1] = qtcNew(Gradient);
1601     opts->customGradient[APPEARANCE_CUSTOM2] = qtcNew(Gradient);
1602     qtcSetupGradient(opts->customGradient[APPEARANCE_CUSTOM1], GB_3D,3,0.0,1.2,0.5,1.0,1.0,1.0);
1603     qtcSetupGradient(opts->customGradient[APPEARANCE_CUSTOM2], GB_3D,3,0.0,0.9,0.5,1.0,1.0,1.0);
1604     opts->customShades[0]=1.16;
1605     opts->customShades[1]=1.07;
1606     opts->customShades[2]=0.9;
1607     opts->customShades[3]=0.78;
1608     opts->customShades[4]=0.84;
1609     opts->customShades[5]=0.75;
1610     opts->customAlphas[0]=0;
1611     opts->contrast=7;
1612     opts->passwordChar=0x25CF;
1613     opts->gbFactor=DEF_GB_FACTOR;
1614     opts->highlightFactor=DEFAULT_HIGHLIGHT_FACTOR;
1615     opts->crHighlight=DEFAULT_CR_HIGHLIGHT_FACTOR;
1616     opts->splitterHighlight=DEFAULT_SPLITTER_HIGHLIGHT_FACTOR;
1617     opts->crSize=CR_LARGE_SIZE;
1618     opts->menuDelay=DEFAULT_MENU_DELAY;
1619     opts->menuCloseDelay=-1; // unused
1620     opts->sliderWidth=DEFAULT_SLIDER_WIDTH;
1621     opts->selectionAppearance=APPEARANCE_HARSH_GRADIENT;
1622     opts->fadeLines=true;
1623     opts->glowProgress=GLOW_NONE;
1624     opts->round=ROUND_EXTRA;
1625     opts->gtkButtonOrder=false;
1626     opts->reorderGtkButtons=false;
1627     opts->bgndImage.type=IMG_NONE;
1628     opts->bgndImage.width=opts->bgndImage.height=0;
1629     opts->bgndImage.onBorder=false;
1630     opts->bgndImage.pos=PP_TR;
1631     opts->menuBgndImage.type=IMG_NONE;
1632     opts->menuBgndImage.width=opts->menuBgndImage.height=0;
1633     opts->menuBgndImage.onBorder=false;
1634     opts->menuBgndImage.pos=PP_TR;
1635     opts->lighterPopupMenuBgnd=DEF_POPUPMENU_LIGHT_FACTOR;
1636     opts->tabBgnd=DEF_TAB_BGND;
1637     opts->animatedProgress=false;
1638     opts->stripedProgress=STRIPE_NONE;
1639     opts->sliderStyle=SLIDER_PLAIN;
1640     opts->highlightTab=false;
1641     opts->colorSelTab=0;
1642     opts->roundAllTabs=true;
1643     opts->tabMouseOver=TAB_MO_GLOW;
1644     opts->embolden=false;
1645     opts->bgndGrad=GT_HORIZ;
1646     opts->menuBgndGrad=GT_HORIZ;
1647     opts->appearance=APPEARANCE_SOFT_GRADIENT;
1648     opts->tbarBtnAppearance=APPEARANCE_NONE;
1649     opts->tbarBtnEffect=EFFECT_NONE;
1650     opts->bgndAppearance=APPEARANCE_FLAT;
1651     opts->menuBgndAppearance=APPEARANCE_FLAT;
1652     opts->lvAppearance=APPEARANCE_BEVELLED;
1653     opts->tabAppearance=APPEARANCE_SOFT_GRADIENT;
1654     opts->activeTabAppearance=APPEARANCE_SOFT_GRADIENT;
1655     opts->sliderAppearance=APPEARANCE_SOFT_GRADIENT;
1656     opts->menubarAppearance=APPEARANCE_FLAT;
1657     opts->menuitemAppearance=APPEARANCE_FADE;
1658     opts->toolbarAppearance=APPEARANCE_FLAT;
1659     opts->progressAppearance=APPEARANCE_DULL_GLASS;
1660     opts->progressGrooveAppearance=APPEARANCE_INVERTED;
1661     opts->progressGrooveColor=ECOLOR_DARK;
1662     opts->grooveAppearance=APPEARANCE_INVERTED;
1663     opts->sunkenAppearance=APPEARANCE_SOFT_GRADIENT;
1664     opts->sbarBgndAppearance=APPEARANCE_FLAT;
1665     opts->tooltipAppearance=APPEARANCE_GRADIENT;
1666     opts->sliderFill=APPEARANCE_GRADIENT;
1667     opts->defBtnIndicator=IND_GLOW;
1668     opts->sliderThumbs=LINE_FLAT;
1669     opts->handles=LINE_1DOT;
1670     opts->shadeSliders=SHADE_NONE;
1671     opts->shadeMenubars=SHADE_NONE;
1672     opts->shadeCheckRadio=SHADE_NONE;
1673     opts->sortedLv=SHADE_NONE;
1674     opts->toolbarBorders=TB_NONE;
1675     opts->toolbarSeparators=LINE_SUNKEN;
1676     opts->splitters=LINE_1DOT;
1677     opts->customMenuTextColor=false;
1678     opts->coloredMouseOver=MO_GLOW;
1679     opts->menubarMouseOver=true;
1680     opts->useHighlightForMenu=false;
1681     opts->shadeMenubarOnlyWhenActive=false;
1682     opts->thin=THIN_BUTTONS;
1683     opts->tbarBtns=TBTN_STANDARD;
1684     opts->scrollbarType=SCROLLBAR_KDE;
1685     opts->buttonEffect=EFFECT_SHADOW;
1686     opts->focus=FOCUS_GLOW;
1687     opts->lvButton=false;
1688     opts->lvLines=false; /*LV_NONE;*/
1689     opts->drawStatusBarFrames=false;
1690     opts->fillSlider=true;
1691     opts->roundMbTopOnly=true;
1692     opts->borderMenuitems=false;
1693     opts->darkerBorders=false;
1694     opts->vArrows=true;
1695     opts->xCheck=false;
1696     opts->colorMenubarMouseOver=true;
1697     opts->crButton=true;
1698     opts->crColor=SHADE_NONE;
1699     opts->progressColor=SHADE_SELECTED;
1700     opts->smallRadio=true;
1701     opts->fillProgress=true;
1702     opts->comboSplitter=false;
1703     opts->highlightScrollViews=false;
1704     opts->etchEntry=false;
1705     opts->flatSbarButtons=true;
1706     opts->borderSbarGroove=true;
1707     opts->borderProgress=true;
1708     opts->popupBorder=true;
1709     opts->unifySpinBtns=false;
1710     opts->unifySpin=true;
1711     opts->unifyCombo=true;
1712     opts->borderTab=true;
1713     opts->borderInactiveTab=false;
1714     opts->thinSbarGroove=true;
1715     opts->colorSliderMouseOver=false;
1716     opts->menuIcons=true;
1717 #ifdef __APPLE__
1718     opts->onlyTicksInMenu=true;
1719     opts->buttonStyleMenuSections=false;
1720 #else
1721     opts->onlyTicksInMenu=false;
1722     opts->buttonStyleMenuSections=true;
1723 #endif
1724     opts->forceAlternateLvCols=false;
1725     opts->invertBotTab=true;
1726     opts->menubarHiding=HIDE_NONE;
1727     opts->statusbarHiding=HIDE_NONE;
1728     opts->boldProgress=true;
1729     opts->coloredTbarMo=false;
1730     opts->borderSelection=false;
1731     opts->square=SQUARE_POPUP_MENUS|SQUARE_TOOLTIPS;
1732     opts->stripedSbar=false;
1733     opts->windowDrag=WM_DRAG_NONE;
1734     opts->shadePopupMenu=false;
1735     opts->hideShortcutUnderline=false;
1736     opts->windowBorder=WINDOW_BORDER_ADD_LIGHT_BORDER|WINDOW_BORDER_FILL_TITLEBAR;
1737     opts->groupBox=FRAME_FADED;
1738     opts->gbFactor=DEF_GB_FACTOR;
1739     opts->gbLabel=GB_LBL_BOLD|GB_LBL_OUTSIDE;
1740 #if defined CONFIG_DIALOG
1741     opts->stdBtnSizes=false;
1742     opts->titlebarButtons=TITLEBAR_BUTTON_ROUND|TITLEBAR_BUTTON_HOVER_SYMBOL;
1743     opts->titlebarIcon=TITLEBAR_ICON_NEXT_TO_TITLE;
1744 #endif
1745     opts->menuStripe=SHADE_NONE;
1746     opts->menuStripeAppearance=APPEARANCE_DARK_INVERTED;
1747     opts->shading=Shading::HSL;
1748     opts->gtkScrollViews=true;
1749     opts->comboBtn=SHADE_NONE;
1750     opts->doubleGtkComboArrow=true;
1751     opts->stdSidebarButtons=false;
1752     opts->toolbarTabs=false;
1753     opts->bgndOpacity = opts->dlgOpacity = opts->menuBgndOpacity = 100;
1754     opts->shadowSize = qtcX11ShadowSize();
1755     opts->gtkComboMenus=false;
1756     opts->noBgndGradientApps=nullptr;
1757     opts->noBgndOpacityApps=g_strsplit("sonata,totem,vmware,vmplayer",",", -1);;
1758     opts->noBgndImageApps=nullptr;
1759     opts->noMenuStripeApps=g_strsplit("gtk",",", -1);
1760     opts->noMenuBgndOpacityApps=g_strsplit("sonata,totem,vmware,vmplayer,gtk",",", -1);
1761 /*
1762     opts->setDialogButtonOrder=false;
1763 */
1764     opts->customMenubarsColor.red=opts->customMenubarsColor.green=opts->customMenubarsColor.blue=0;
1765     opts->customSlidersColor.red=opts->customSlidersColor.green=opts->customSlidersColor.blue=0;
1766     opts->customMenuNormTextColor.red=opts->customMenuNormTextColor.green=opts->customMenuNormTextColor.blue=0;
1767     opts->customMenuSelTextColor.red=opts->customMenuSelTextColor.green=opts->customMenuSelTextColor.blue=0;
1768     opts->customCheckRadioColor.red=opts->customCheckRadioColor.green=opts->customCheckRadioColor.blue=0;
1769     opts->customComboBtnColor.red=opts->customCheckRadioColor.green=opts->customCheckRadioColor.blue=0;
1770     opts->customMenuStripeColor.red=opts->customMenuStripeColor.green=opts->customMenuStripeColor.blue=0;
1771     opts->customProgressColor.red=opts->customProgressColor.green=opts->customProgressColor.blue=0;
1772 
1773     opts->mapKdeIcons=true;
1774     opts->expanderHighlight=DEFAULT_EXPANDER_HIGHLIGHT_FACTOR;
1775     opts->titlebarAppearance=APPEARANCE_CUSTOM1;
1776     opts->inactiveTitlebarAppearance=APPEARANCE_CUSTOM1;
1777     /* Read system config file... */
1778     static const char *systemFilename = nullptr;
1779 
1780     if (!systemFilename) {
1781         systemFilename = getSystemConfigFile();
1782     }
1783     if (systemFilename) {
1784         qtcReadConfig(systemFilename, opts, opts);
1785     }
1786 }