QTfrontend/main.cpp
changeset 6178 affa860f2983
parent 6177 5eba8970e8ae
child 6186 255aff92216d
equal deleted inserted replaced
6177:5eba8970e8ae 6178:affa860f2983
    96     srand(now.toTime_t());
    96     srand(now.toTime_t());
    97     rand();
    97     rand();
    98 
    98 
    99     Q_INIT_RESOURCE(hedgewars);
    99     Q_INIT_RESOURCE(hedgewars);
   100 
   100 
   101     QString styleSheetFromHell =
       
   102         QString(
       
   103             "HWForm,QDialog{"
       
   104                 "background-image: url(\":/res/Background.png\");"
       
   105                 "background-position: bottom center;"
       
   106                 "background-repeat: repeat-x;"
       
   107                 "background-color: #141250;"
       
   108                 "}"
       
   109 
       
   110             "* {"
       
   111                 "color: #ffcc00;"
       
   112                 "selection-background-color: #ffcc00;"
       
   113                 "selection-color: #00351d;"
       
   114             "}"
       
   115 
       
   116             "QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox, "
       
   117             "QComboBox QAbstractItemView, QMenu::item {"
       
   118                 "background-color: rgba(13, 5, 68, 70%);"
       
   119             "}"
       
   120 
       
   121             "QComboBox::separator {"
       
   122                 "border: solid; border-width: 3px; border-color: #ffcc00;"
       
   123             "}"
       
   124 
       
   125             "QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, "
       
   126             "QTextBrowser, QSpinBox, QToolBox, QComboBox, "
       
   127             "QComboBox QAbstractItemView, IconedGroupBox, "
       
   128             ".QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, "
       
   129             "QTabWidget::pane, QTabBar::tab {"
       
   130                 "border: solid;"
       
   131                 "border-width: 3px;"
       
   132                 "border-color: #ffcc00;"
       
   133             "}"
       
   134 
       
   135             "QPushButton:hover, QLineEdit:hover, QListWidget:hover, "
       
   136             "QSpinBox:hover, QToolBox:hover, QComboBox:hover {"
       
   137                 "border-color: yellow;"
       
   138             "}"
       
   139 
       
   140             "QLineEdit, QListWidget,QTableView, QTextBrowser, "
       
   141             "QSpinBox, QToolBox { "
       
   142                 "border-radius: 10px;"
       
   143             "}"
       
   144 
       
   145             "QLineEdit, QLabel, QHeaderView, QListWidget, QTableView, "
       
   146             "QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView, "
       
   147             "IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, "
       
   148             "SelWeaponWidget, QCheckBox, QRadioButton, QPushButton {"
       
   149                 "font: bold 13px;"
       
   150             "}"
       
   151             "SelWeaponWidget QTabWidget::pane, SelWeaponWidget QTabBar::tab:selected {"
       
   152                 "background-position: bottom center;"
       
   153                 "background-repeat: repeat-x;"
       
   154                 "background-color: #000000;"
       
   155             "}"
       
   156             ".QGroupBox,GameCFGWidget,TeamSelWidget,SelWeaponWidget {"
       
   157                 "background-position: bottom center;"
       
   158                 "background-repeat: repeat-x;"
       
   159                 "border-radius: 16px;"
       
   160                 "background-color: rgba(13, 5, 68, 70%);"
       
   161                 "padding: 6px;"
       
   162             "}"
       
   163 /*  Experimenting with PaintOnScreen and border-radius on IconedGroupBox children didn't work out well
       
   164             "IconedGroupBox QComboBox, IconedGroupBox QPushButton, IconedGroupBox QLineEdit, "
       
   165             "IconedGroupBox QSpinBox {"
       
   166                 "border-radius: 0;"
       
   167             "}"
       
   168             "IconedGroupBox, IconedGroupBox *, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" */
       
   169             "IconedGroupBox, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{"
       
   170                 "background-color: #130f2c;"
       
   171             "}"
       
   172 
       
   173 
       
   174             "QPushButton {"
       
   175                 "border-radius: 8px;"
       
   176                 "background-origin: margin;"
       
   177                 "background-position: top left;"
       
   178                 "background-color: rgba(18, 42, 5, 70%);"
       
   179             "}"
       
   180 
       
   181             "QPushButton:pressed{"
       
   182                 "border-color: white;"
       
   183             "}"
       
   184 
       
   185             "QPushButton:focus {"
       
   186                 "outline: none;"
       
   187             "}"
       
   188 
       
   189 
       
   190             "QHeaderView {"
       
   191                 "border-radius: 0;"
       
   192                 "border-width: 0;"
       
   193                 "border-bottom-width: 3px;"
       
   194                 "background-color: #00351d;"
       
   195             "}"
       
   196             "QTableView {"
       
   197                 "alternate-background-color: #2f213a;"
       
   198                 "gridline-color: transparent;"
       
   199             "}"
       
   200 
       
   201             "QTabBar::tab {"
       
   202                  "border-bottom-width: 0;"
       
   203                  "border-radius: 0;"
       
   204                  "border-top-left-radius: 6px;"
       
   205                  "border-top-right-radius: 6px;"
       
   206                  "padding: 3px;"
       
   207             "}"
       
   208             "QTabBar::tab:!selected {"
       
   209                  "color: #0d0544;"
       
   210                  "background-color: #ffcc00;"
       
   211             "}"
       
   212             "QSpinBox::up-button{"
       
   213                 "background: transparent;"
       
   214                 "width: 16px;"
       
   215                 "height: 10px;"
       
   216             "}"
       
   217 
       
   218             "QSpinBox::up-arrow {"
       
   219                 "image: url(\":/res/spin_up.png\");"
       
   220             "}"
       
   221 
       
   222             "QSpinBox::down-arrow {"
       
   223                 "image: url(\":/res/spin_down.png\");"
       
   224             "}"
       
   225 
       
   226             "QSpinBox::down-button {"
       
   227                 "background: transparent;"
       
   228                 "width: 16px;"
       
   229                 "height: 10px;"
       
   230             "}"
       
   231 
       
   232             "QComboBox {"
       
   233                 "border-radius: 10px;"
       
   234                 "padding: 3px;"
       
   235             "}"
       
   236             "QComboBox:pressed{"
       
   237                 "border-color: white;"
       
   238             "}"
       
   239             "QComboBox::drop-down{"
       
   240                 "border: transparent;"
       
   241                 "width: 25px;"
       
   242             "}"
       
   243             "QComboBox::down-arrow {"
       
   244                 "image: url(\":/res/dropdown.png\");"
       
   245             "}"
       
   246 
       
   247             "VertScrArea {"
       
   248                 "background-position: bottom center;"
       
   249                 "background-repeat: repeat-x;"
       
   250             "}"
       
   251 
       
   252             "IconedGroupBox {"
       
   253                 "border-radius: 16px;"
       
   254                 "padding: 2px;"
       
   255             "}"
       
   256 
       
   257             "QGroupBox::title{"
       
   258                 "subcontrol-origin: margin;"
       
   259                 "subcontrol-position: top left;"
       
   260                 "text-align: left;"
       
   261                 "left: 15px;"
       
   262                 "top: -4px;"
       
   263                 "}"
       
   264 
       
   265             "QCheckBox::indicator:checked{"
       
   266                 "image: url(\":/res/checked.png\");"
       
   267                 "}"
       
   268             "QCheckBox::indicator:unchecked{"
       
   269                 "image: url(\":/res/unchecked.png\");"
       
   270                 "}"
       
   271 
       
   272             ".QWidget{"
       
   273                 "background: transparent;"
       
   274                 "}"
       
   275 
       
   276             "QTabWidget::pane {"
       
   277                 "border-top-width: 2px;"
       
   278             "}"
       
   279 
       
   280             "QMenu{"
       
   281                 "background-color: #ffcc00;"
       
   282                 "margin: 3px;"
       
   283             "}"
       
   284             "QMenu::item {"
       
   285                 "background-color: #0d0544;"
       
   286                 "border: 1px solid transparent;"
       
   287                 "font: bold;"
       
   288                 "padding: 2px 25px 2px 20px;"
       
   289             "}"
       
   290             "QMenu::item:selected {"
       
   291                 "background-color: #2d2564;"
       
   292             "}"
       
   293             "QMenu::indicator {"
       
   294                 "width: 16px;"
       
   295                 "height: 16px;"
       
   296             "}"
       
   297             "QMenu::indicator:non-exclusive:checked{"
       
   298                 "image: url(\":/res/checked.png\");"
       
   299             "}"
       
   300             "QMenu::indicator:non-exclusive:unchecked{"
       
   301                 "image: url(\":/res/unchecked.png\");"
       
   302             "}"
       
   303 
       
   304             "QToolTip{"
       
   305                 "background-color: #0d0544;"
       
   306                 "border: 1px solid #ffcc00;"
       
   307             "}"
       
   308 
       
   309             ":disabled{"
       
   310                 "color: #a0a0a0;"
       
   311             "}"
       
   312             "SquareLabel, ItemNum {"
       
   313                 "background-color: #000000;"
       
   314             "}"
       
   315             "QSlider::groove::horizontal {"
       
   316                 "height: 2px;"
       
   317                 "margin: 2px 0px;"
       
   318                 "background-color: #ffcc00;"
       
   319             "}"
       
   320             "QSlider::handle::horizontal {"
       
   321                 "border: 0px;"
       
   322                 "margin: -2px 0px;"
       
   323                 "border-radius: 3px;"
       
   324                 "background-color: #ffcc00;"
       
   325                 "width: 8px;"
       
   326             "}"
       
   327             );
       
   328 
       
   329     bindir->cd("bin"); // workaround over NSIS installer
   101     bindir->cd("bin"); // workaround over NSIS installer
   330 
   102 
   331     if(cConfigDir->length() == 0)
   103     if(cConfigDir->length() == 0)
   332         cfgdir->setPath(cfgdir->homePath());
   104         cfgdir->setPath(cfgdir->homePath());
   333     else
   105     else
   479 #endif
   251 #endif
   480 #ifdef __APPLE__
   252 #ifdef __APPLE__
   481     // this creates the autoreleasepool that prevents leaking
   253     // this creates the autoreleasepool that prevents leaking
   482     CocoaInitializer initializer;
   254     CocoaInitializer initializer;
   483 #endif
   255 #endif
       
   256 
       
   257     QString style = "";
       
   258 
   484     // load external stylesheet if there is any
   259     // load external stylesheet if there is any
   485     QFile * file =
   260     QFile extFile(HWDataManager::instance().findFileForRead("css/qt.css"));
   486         new QFile(HWDataManager::instance().findFileForRead("css/qt.css"));
   261 
   487 
   262     QFile resFile(":/res/css/qt.css");
   488     if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text))
   263 
   489     {
   264     QFile & file = (extFile.exists()?extFile:resFile);
   490         QString style = "";
   265 
   491         QTextStream in(file);
   266     if (file.open(QIODevice::ReadOnly | QIODevice::Text))
       
   267     {
       
   268         QTextStream in(&file);
   492         while (!in.atEnd())
   269         while (!in.atEnd())
   493         {
   270         {
   494             QString line = in.readLine();
   271             QString line = in.readLine();
   495             if(!line.isEmpty())
   272             if(!line.isEmpty())
   496                 style.append(line);
   273                 style.append(line);
   497         }
   274         }
   498         app.form = new HWForm(NULL, style);
   275     }
   499     }
   276 
   500     else
   277     app.form = new HWForm(NULL, style);
   501         app.form = new HWForm(NULL, styleSheetFromHell);
       
   502 
       
   503     app.form->show();
   278     app.form->show();
   504     return app.exec();
   279     return app.exec();
   505 }
   280 }