# HG changeset patch # User sheepluva # Date 1319244119 -7200 # Node ID affa860f29832850f7068a986f64b80f53565723 # Parent 5eba8970e8ae2a2cde7e03feca1c126db64aae41 BOOOOooOM ! removing default stylesheets from c++ code and adding them as text files to the qt resources diff -r 5eba8970e8ae -r affa860f2983 QTfrontend/hedgewars.qrc --- a/QTfrontend/hedgewars.qrc Sat Oct 22 01:53:14 2011 +0200 +++ b/QTfrontend/hedgewars.qrc Sat Oct 22 02:41:59 2011 +0200 @@ -1,6 +1,8 @@ ../share/hedgewars/Data/Graphics/AmmoMenu/Ammos.png + res/css/qt.css + res/css/chat.css res/hh25x25.png res/hh25x25grey.png res/ammopic.png diff -r 5eba8970e8ae -r affa860f2983 QTfrontend/main.cpp --- a/QTfrontend/main.cpp Sat Oct 22 01:53:14 2011 +0200 +++ b/QTfrontend/main.cpp Sat Oct 22 02:41:59 2011 +0200 @@ -98,234 +98,6 @@ Q_INIT_RESOURCE(hedgewars); - QString styleSheetFromHell = - QString( - "HWForm,QDialog{" - "background-image: url(\":/res/Background.png\");" - "background-position: bottom center;" - "background-repeat: repeat-x;" - "background-color: #141250;" - "}" - - "* {" - "color: #ffcc00;" - "selection-background-color: #ffcc00;" - "selection-color: #00351d;" - "}" - - "QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox, " - "QComboBox QAbstractItemView, QMenu::item {" - "background-color: rgba(13, 5, 68, 70%);" - "}" - - "QComboBox::separator {" - "border: solid; border-width: 3px; border-color: #ffcc00;" - "}" - - "QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, " - "QTextBrowser, QSpinBox, QToolBox, QComboBox, " - "QComboBox QAbstractItemView, IconedGroupBox, " - ".QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, " - "QTabWidget::pane, QTabBar::tab {" - "border: solid;" - "border-width: 3px;" - "border-color: #ffcc00;" - "}" - - "QPushButton:hover, QLineEdit:hover, QListWidget:hover, " - "QSpinBox:hover, QToolBox:hover, QComboBox:hover {" - "border-color: yellow;" - "}" - - "QLineEdit, QListWidget,QTableView, QTextBrowser, " - "QSpinBox, QToolBox { " - "border-radius: 10px;" - "}" - - "QLineEdit, QLabel, QHeaderView, QListWidget, QTableView, " - "QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView, " - "IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, " - "SelWeaponWidget, QCheckBox, QRadioButton, QPushButton {" - "font: bold 13px;" - "}" - "SelWeaponWidget QTabWidget::pane, SelWeaponWidget QTabBar::tab:selected {" - "background-position: bottom center;" - "background-repeat: repeat-x;" - "background-color: #000000;" - "}" - ".QGroupBox,GameCFGWidget,TeamSelWidget,SelWeaponWidget {" - "background-position: bottom center;" - "background-repeat: repeat-x;" - "border-radius: 16px;" - "background-color: rgba(13, 5, 68, 70%);" - "padding: 6px;" - "}" -/* Experimenting with PaintOnScreen and border-radius on IconedGroupBox children didn't work out well - "IconedGroupBox QComboBox, IconedGroupBox QPushButton, IconedGroupBox QLineEdit, " - "IconedGroupBox QSpinBox {" - "border-radius: 0;" - "}" - "IconedGroupBox, IconedGroupBox *, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" */ - "IconedGroupBox, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" - "background-color: #130f2c;" - "}" - - - "QPushButton {" - "border-radius: 8px;" - "background-origin: margin;" - "background-position: top left;" - "background-color: rgba(18, 42, 5, 70%);" - "}" - - "QPushButton:pressed{" - "border-color: white;" - "}" - - "QPushButton:focus {" - "outline: none;" - "}" - - - "QHeaderView {" - "border-radius: 0;" - "border-width: 0;" - "border-bottom-width: 3px;" - "background-color: #00351d;" - "}" - "QTableView {" - "alternate-background-color: #2f213a;" - "gridline-color: transparent;" - "}" - - "QTabBar::tab {" - "border-bottom-width: 0;" - "border-radius: 0;" - "border-top-left-radius: 6px;" - "border-top-right-radius: 6px;" - "padding: 3px;" - "}" - "QTabBar::tab:!selected {" - "color: #0d0544;" - "background-color: #ffcc00;" - "}" - "QSpinBox::up-button{" - "background: transparent;" - "width: 16px;" - "height: 10px;" - "}" - - "QSpinBox::up-arrow {" - "image: url(\":/res/spin_up.png\");" - "}" - - "QSpinBox::down-arrow {" - "image: url(\":/res/spin_down.png\");" - "}" - - "QSpinBox::down-button {" - "background: transparent;" - "width: 16px;" - "height: 10px;" - "}" - - "QComboBox {" - "border-radius: 10px;" - "padding: 3px;" - "}" - "QComboBox:pressed{" - "border-color: white;" - "}" - "QComboBox::drop-down{" - "border: transparent;" - "width: 25px;" - "}" - "QComboBox::down-arrow {" - "image: url(\":/res/dropdown.png\");" - "}" - - "VertScrArea {" - "background-position: bottom center;" - "background-repeat: repeat-x;" - "}" - - "IconedGroupBox {" - "border-radius: 16px;" - "padding: 2px;" - "}" - - "QGroupBox::title{" - "subcontrol-origin: margin;" - "subcontrol-position: top left;" - "text-align: left;" - "left: 15px;" - "top: -4px;" - "}" - - "QCheckBox::indicator:checked{" - "image: url(\":/res/checked.png\");" - "}" - "QCheckBox::indicator:unchecked{" - "image: url(\":/res/unchecked.png\");" - "}" - - ".QWidget{" - "background: transparent;" - "}" - - "QTabWidget::pane {" - "border-top-width: 2px;" - "}" - - "QMenu{" - "background-color: #ffcc00;" - "margin: 3px;" - "}" - "QMenu::item {" - "background-color: #0d0544;" - "border: 1px solid transparent;" - "font: bold;" - "padding: 2px 25px 2px 20px;" - "}" - "QMenu::item:selected {" - "background-color: #2d2564;" - "}" - "QMenu::indicator {" - "width: 16px;" - "height: 16px;" - "}" - "QMenu::indicator:non-exclusive:checked{" - "image: url(\":/res/checked.png\");" - "}" - "QMenu::indicator:non-exclusive:unchecked{" - "image: url(\":/res/unchecked.png\");" - "}" - - "QToolTip{" - "background-color: #0d0544;" - "border: 1px solid #ffcc00;" - "}" - - ":disabled{" - "color: #a0a0a0;" - "}" - "SquareLabel, ItemNum {" - "background-color: #000000;" - "}" - "QSlider::groove::horizontal {" - "height: 2px;" - "margin: 2px 0px;" - "background-color: #ffcc00;" - "}" - "QSlider::handle::horizontal {" - "border: 0px;" - "margin: -2px 0px;" - "border-radius: 3px;" - "background-color: #ffcc00;" - "width: 8px;" - "}" - ); - bindir->cd("bin"); // workaround over NSIS installer if(cConfigDir->length() == 0) @@ -481,25 +253,28 @@ // this creates the autoreleasepool that prevents leaking CocoaInitializer initializer; #endif + + QString style = ""; + // load external stylesheet if there is any - QFile * file = - new QFile(HWDataManager::instance().findFileForRead("css/qt.css")); + QFile extFile(HWDataManager::instance().findFileForRead("css/qt.css")); - if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) + QFile resFile(":/res/css/qt.css"); + + QFile & file = (extFile.exists()?extFile:resFile); + + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QString style = ""; - QTextStream in(file); + QTextStream in(&file); while (!in.atEnd()) { QString line = in.readLine(); if(!line.isEmpty()) style.append(line); } - app.form = new HWForm(NULL, style); } - else - app.form = new HWForm(NULL, styleSheetFromHell); + app.form = new HWForm(NULL, style); app.form->show(); return app.exec(); } diff -r 5eba8970e8ae -r affa860f2983 QTfrontend/res/css/chat.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/res/css/chat.css Sat Oct 22 02:41:59 2011 +0200 @@ -0,0 +1,21 @@ +/* + * see http://doc.qt.nokia.com/4.5/richtext-html-subset.html#css-properties + */ + +a { color:#c8c8ff; } +.nick { text-decoration: none; } +.UserChat { } +.UserChat .nick { color:#ffec20; } +.FriendChat { color: #08e008; } +.FriendChat .nick { color: #20ff20; } +.UserJoin { color: #c0c0c0; } +.UserJoin .nick { color: #d0d0d0; } +.FriendJoin { color: #c0e0c0; } +.FriendJoin .nick { color: #d0f0d0; } +.UserAction { color: #ff80ff; } +.UserAction .nick { color: #ffa0ff; } +.FriendAction { color: #ff00ff; } +.FriendAction .nick { color: #ff30ff; } +.Error { color: #ff0000 } +.Warning { color: #ff8000 } +.Notice { color: #fefefe } diff -r 5eba8970e8ae -r affa860f2983 QTfrontend/res/css/qt.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/res/css/qt.css Sat Oct 22 02:41:59 2011 +0200 @@ -0,0 +1,226 @@ +HWForm,QDialog { +background-image: url(":/res/Background.png"); +background-position: bottom center; +background-repeat: repeat-x; +background-color: #141250; +} + +* { +color: #ffcc00; +selection-background-color: #ffcc00; +selection-color: #00351d; +} + +QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox, +QComboBox QAbstractItemView, QMenu::item { +background-color: rgba(13, 5, 68, 70%); +} + +QComboBox::separator { +border: solid; border-width: 3px; border-color: #ffcc00; +} + +QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, +QTextBrowser, QSpinBox, QToolBox, QComboBox, +QComboBox QAbstractItemView, IconedGroupBox, +.QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, +QTabWidget::pane, QTabBar::tab { +border: solid; +border-width: 3px; +border-color: #ffcc00; +} + +QPushButton:hover, QLineEdit:hover, QListWidget:hover, +QSpinBox:hover, QToolBox:hover, QComboBox:hover { +border-color: yellow; +} + +QLineEdit, QListWidget,QTableView, QTextBrowser, +QSpinBox, QToolBox { +border-radius: 10px; +} + +QLineEdit, QLabel, QHeaderView, QListWidget, QTableView, +QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView, +IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, +SelWeaponWidget, QCheckBox, QRadioButton, QPushButton { +font: bold 13px; +} +SelWeaponWidget QTabWidget::pane, SelWeaponWidget QTabBar::tab:selected { +background-position: bottom center; +background-repeat: repeat-x; +background-color: #000000; +} +.QGroupBox,GameCFGWidget,TeamSelWidget,SelWeaponWidget { +background-position: bottom center; +background-repeat: repeat-x; +border-radius: 16px; +background-color: rgba(13, 5, 68, 70%); +padding: 6px; +} +/* Experimenting with PaintOnScreen and border-radius on IconedGroupBox children didn't work out well +IconedGroupBox QComboBox, IconedGroupBox QPushButton, IconedGroupBox QLineEdit, +IconedGroupBox QSpinBox { +border-radius: 0; +} +IconedGroupBox, IconedGroupBox *, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" */ +IconedGroupBox, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{ +background-color: #130f2c; +} + + +QPushButton { +border-radius: 8px; +background-origin: margin; +background-position: top left; +background-color: rgba(18, 42, 5, 70%); +} + +QPushButton:pressed{ +border-color: white; +} + +QPushButton:focus { +outline: none; +} + + +QHeaderView { +border-radius: 0; +border-width: 0; +border-bottom-width: 3px; +background-color: #00351d; +} +QTableView { +alternate-background-color: #2f213a; +gridline-color: transparent; +} + +QTabBar::tab { +border-bottom-width: 0; +border-radius: 0; +border-top-left-radius: 6px; +border-top-right-radius: 6px; +padding: 3px; +} +QTabBar::tab:!selected { +color: #0d0544; +background-color: #ffcc00; +} +QSpinBox::up-button{ +background: transparent; +width: 16px; +height: 10px; +} + +QSpinBox::up-arrow { +image: url(":/res/spin_up.png"); +} + +QSpinBox::down-arrow { +image: url(":/res/spin_down.png"); +} + +QSpinBox::down-button { +background: transparent; +width: 16px; +height: 10px; +} + +QComboBox { +border-radius: 10px; +padding: 3px; +} +QComboBox:pressed{ +border-color: white; +} +QComboBox::drop-down{ +border: transparent; +width: 25px; +} +QComboBox::down-arrow { +image: url(":/res/dropdown.png"); +} + +VertScrArea { +background-position: bottom center; +background-repeat: repeat-x; +} + +IconedGroupBox { +border-radius: 16px; +padding: 2px; +} + +QGroupBox::title{ +subcontrol-origin: margin; +subcontrol-position: top left; +text-align: left; +left: 15px; +top: -4px; +} + +QCheckBox::indicator:checked{ +image: url(":/res/checked.png"); +} +QCheckBox::indicator:unchecked{ +image: url(":/res/unchecked.png"); +} + +.QWidget{ +background: transparent; +} + +QTabWidget::pane { +border-top-width: 2px; +} + +QMenu{ +background-color: #ffcc00; +margin: 3px; +} +QMenu::item { +background-color: #0d0544; +border: 1px solid transparent; +font: bold; +padding: 2px 25px 2px 20px; +} +QMenu::item:selected { +background-color: #2d2564; +} +QMenu::indicator { +width: 16px; +height: 16px; +} +QMenu::indicator:non-exclusive:checked{ +image: url(":/res/checked.png"); +} +QMenu::indicator:non-exclusive:unchecked{ +image: url(":/res/unchecked.png"); +} + +QToolTip{ +background-color: #0d0544; +border: 1px solid #ffcc00; +} + +:disabled{ +color: #a0a0a0; +} +SquareLabel, ItemNum { +background-color: #000000; +} + +QSlider::groove::horizontal { +height: 2px; +margin: 2px 0px; +background-color: #ffcc00; +} + +QSlider::handle::horizontal { +border: 0px; +margin: -2px 0px; +border-radius: 3px; +background-color: #ffcc00; +width: 8px; +} \ No newline at end of file diff -r 5eba8970e8ae -r affa860f2983 QTfrontend/ui/page/pageadmin.cpp --- a/QTfrontend/ui/page/pageadmin.cpp Sat Oct 22 01:53:14 2011 +0200 +++ b/QTfrontend/ui/page/pageadmin.cpp Sat Oct 22 02:41:59 2011 +0200 @@ -64,7 +64,8 @@ tb = new QTextBrowser(this); tb->setOpenExternalLinks(true); - tb->document()->setDefaultStyleSheet(HWChatWidget::STYLE); + // TODO this work-around to apply chat css to preview won't work anymore + // tb->document()->setDefaultStyleSheet(HWChatWidget::STYLE); pageLayout->addWidget(tb, 4, 1, 1, 2); // 5 diff -r 5eba8970e8ae -r affa860f2983 QTfrontend/ui/widget/chatwidget.cpp --- a/QTfrontend/ui/widget/chatwidget.cpp Sat Oct 22 01:53:14 2011 +0200 +++ b/QTfrontend/ui/widget/chatwidget.cpp Sat Oct 22 02:41:59 2011 +0200 @@ -96,25 +96,6 @@ return firstIsShorter; } -const char* HWChatWidget::STYLE = -"\ -a { color:#c8c8ff; }\ -.nick { text-decoration: none; }\ -.UserChat .nick { color:#ffec20; }\ -.FriendChat { color: #08e008; }\ -.FriendChat .nick { color: #20ff20; }\ -.UserJoin { color: #c0c0c0; }\ -.UserJoin .nick { color: #d0d0d0; }\ -.FriendJoin { color: #c0e0c0; }\ -.FriendJoin .nick { color: #d0f0d0; }\ -.UserAction { color: #ff80ff; }\ -.UserAction .nick { color: #ffa0ff; }\ -.FriendAction { color: #ff00ff; }\ -.FriendAction .nick { color: #ff30ff; }\ -.Error { color: #ff0000 }\ -.Warning { color: #ff8000 }\ -.Notice { color: #fefefe }\ -"; HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify) : QWidget(parent), @@ -141,24 +122,27 @@ chatText = new QTextBrowser(this); + QString style; + // load external stylesheet if there is any - QFile * file = - new QFile(HWDataManager::instance().findFileForRead("css/chat.css")); + QFile extFile(HWDataManager::instance().findFileForRead("css/chat.css")); - if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) + QFile resFile(":/res/css/chat.css"); + + QFile & file = (extFile.exists()?extFile:resFile); + + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QString style = ""; - QTextStream in(file); + QTextStream in(&file); while (!in.atEnd()) { QString line = in.readLine(); if(!line.isEmpty()) style.append(line); } - chatText->document()->setDefaultStyleSheet(style); } - else - chatText->document()->setDefaultStyleSheet(STYLE); + + chatText->document()->setDefaultStyleSheet(style); chatText->setMinimumHeight(20); chatText->setMinimumWidth(10); @@ -208,6 +192,7 @@ setShowFollow(true); } + void HWChatWidget::linkClicked(const QUrl & link) { if (link.scheme() == "http")