Skip to content

Commit

Permalink
added css styling support
Browse files Browse the repository at this point in the history
  • Loading branch information
wadealer committed Jun 15, 2017
1 parent c95bc14 commit a84f572
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 0 deletions.
4 changes: 4 additions & 0 deletions options/default.xml
Expand Up @@ -122,6 +122,7 @@
<scaled-message-icons type="bool">false</scaled-message-icons>
<show-status-changes type="bool">true</show-status-changes>
<warn-before-clear type="bool">true</warn-before-clear>
<css type="QString" />
<hide-when-closing type="bool">false</hide-when-closing>
<status-with-priority comment="Show priority with status change" type="bool">false</status-with-priority>
<default-jid-mode comment="Default jid mode: barejid | auto" type="QString">auto</default-jid-mode>
Expand All @@ -146,6 +147,7 @@
<show comment="Show status messages" type="bool">false</show>
</status-messages>
<tooltip comment="Display options for the contact list tooltips">
<css type="QString"></css>
<avatar comment="Display avatar" type="bool">true</avatar>
<client-version comment="Display client version information" type="bool">true</client-version>
<geolocation comment="Display geolocation information" type="bool">true</geolocation>
Expand Down Expand Up @@ -411,6 +413,7 @@ QLineEdit#le_status_text {
<message type="QString">Sans Serif,9,-1,5,50,0,0,0,0,0</message>
<passive-popup type="QString">Sans Serif,7,-1,5,50,0,0,0,0,0</passive-popup>
</font>
<css type="QString" />
</look>
<notifications>
<send-receipts type="bool" >true</send-receipts>
Expand All @@ -427,6 +430,7 @@ QLineEdit#le_status_text {
<status type="int">2000</status>
</delays>
<enabled type="bool">false</enabled>
<css type="QString"></css>
<top-to-bottom type="bool">false</top-to-bottom>
<at-left-corner type="bool">false</at-left-corner>
<incoming-chat type="bool">true</incoming-chat>
Expand Down
4 changes: 4 additions & 0 deletions src/gcuserview.cpp
Expand Up @@ -741,6 +741,10 @@ void GCUserView::doContextMenu(QTreeWidgetItem *i)
pm->addAction(act);
act->setData(3);

const QString css = PsiOptions::instance()->getOption("options.ui.chat.css").toString();
if (!css.isEmpty()) {
pm->setStyleSheet(css);
}
int x = -1;
bool enabled = false;
act = pm->exec(QCursor::pos());
Expand Down
5 changes: 5 additions & 0 deletions src/groupchatdlg.cpp
Expand Up @@ -2037,6 +2037,11 @@ QString GCMainDlg::desiredCaption() const

void GCMainDlg::setLooks()
{
const QString css = PsiOptions::instance()->getOption("options.ui.chat.css").toString();
if (!css.isEmpty()) {
setStyleSheet(css);
d->mle()->setCssString(css);
}
ui_.vsplitter->optionsChanged();
ui_.mle->optionsChanged();

Expand Down
16 changes: 16 additions & 0 deletions src/mainwin.cpp
Expand Up @@ -338,6 +338,8 @@ MainWin::MainWin(bool _onTop, bool _asTool, PsiCon* psi)
} else
setCentralWidget(rosterBar);

connect(PsiOptions::instance(), SIGNAL(optionChanged(const QString&)), SLOT(optionChanged(const QString&)));

d->vb_roster = new QVBoxLayout(rosterBar);
d->rosterWidget_ = new PsiRosterWidget(rosterBar);
d->rosterWidget_->setContactList(psi->contactList());
Expand Down Expand Up @@ -515,6 +517,7 @@ MainWin::MainWin(bool _onTop, bool _asTool, PsiCon* psi)

/*QShortcut *sp_ss = new QShortcut(QKeySequence(tr("Ctrl+Shift+N")), this);
connect(sp_ss, SIGNAL(triggered()), SLOT(avcallConfig()));*/
optionChanged("options.ui.contactlist.css");

reinitAutoHide();
}
Expand Down Expand Up @@ -543,6 +546,19 @@ void MainWin::splitterMoved()
d->tabsSize = d->isLeftRoster ? list.last() : list.first();
}

void MainWin::optionChanged(const QString& option)
{
if (option == toolbarsStateOptionPath) {
loadToolbarsState();
}
else if (option == "options.ui.contactlist.css") {
const QString css = PsiOptions::instance()->getOption("options.ui.contactlist.css").toString();
if (!css.isEmpty()) {
setStyleSheet(css);
}
}
}

void MainWin::registerAction( IconAction* action )
{
const char *activated = SIGNAL( triggered() );
Expand Down
2 changes: 2 additions & 0 deletions src/mainwin.h
Expand Up @@ -166,6 +166,8 @@ private slots:

void hideTimerTimeout();

void optionChanged(const QString&);

public slots:
void setWindowIcon(const QPixmap&);
void showNoFocus();
Expand Down
5 changes: 5 additions & 0 deletions src/psichatdlg.cpp
Expand Up @@ -294,6 +294,11 @@ void PsiChatDlg::setLooks()
{
ChatDlg::setLooks();

const QString css = PsiOptions::instance()->getOption("options.ui.chat.css").toString();
if (!css.isEmpty()) {
setStyleSheet(css);
chatEdit()->setCssString(css);
}
ui_.splitter->optionsChanged();
ui_.mle->optionsChanged();

Expand Down
11 changes: 11 additions & 0 deletions src/psicon.cpp
Expand Up @@ -505,6 +505,10 @@ bool PsiCon::init()
d->iconSelect = new IconSelectPopup(0);
connect(PsiIconset::instance(), SIGNAL(emoticonsChanged()), d, SLOT(updateIconSelect()));

const QString css = options->getOption("options.ui.chat.css").toString();
if (!css.isEmpty())
d->iconSelect->setStyleSheet(css);

// first thing, try to load the iconset
bool result = true;;
if( !PsiIconset::instance()->loadAll() ) {
Expand Down Expand Up @@ -1399,6 +1403,13 @@ void PsiCon::optionChanged(const QString& option)
s5b_init();
}

if (option == "options.ui.chat.css") {
QString css = PsiOptions::instance()->getOption(option).toString();
if (!css.isEmpty())
d->iconSelect->setStyleSheet(css);
return;
}

if (option == "options.ui.spell-check.langs") {
QStringList langs = PsiOptions::instance()->getOption(option).toString().split(QRegExp("\\s+"), QString::SkipEmptyParts);
if(langs.isEmpty()) {
Expand Down
8 changes: 8 additions & 0 deletions src/statusmenu.cpp
Expand Up @@ -36,6 +36,10 @@
StatusMenu::StatusMenu(QWidget* parent, PsiCon* _psi )
: QMenu(parent), psi(_psi)
{
const QString css = PsiOptions::instance()->getOption("options.ui.contactlist.css").toString();
if (!css.isEmpty()) {
setStyleSheet(css);
}
connect(psi, SIGNAL(statusPresetsChanged()), this, SLOT(presetsChanged()));
installEventFilter(this);
}
Expand Down Expand Up @@ -65,6 +69,10 @@ void StatusMenu::fill()
IconActionGroup* submenu = new IconActionGroup(this);
submenu->setText(tr("Presets"));
submenu->setPsiIcon("psi/action_templates");
const QString css = o->getOption("options.ui.contactlist.css").toString();
if (!css.isEmpty()) {
submenu->popup()->setStyleSheet(css);
}
addPresets(submenu);
submenu->popup()->installEventFilter(this);
}
Expand Down
5 changes: 5 additions & 0 deletions src/tabs/tabdlg.cpp
Expand Up @@ -374,6 +374,11 @@ void TabDlg::setLooks()
tabWidget_->setTabPosition(QTabWidget::South);

setWindowOpacity(double(qMax(MINIMUM_OPACITY,PsiOptions::instance()->getOption("options.ui.chat.opacity").toInt()))/100);

const QString css = PsiOptions::instance()->getOption("options.ui.chat.css").toString();
if (!css.isEmpty()) {
setStyleSheet(css);
}
}

void TabDlg::tabSelected(QWidget* _selected)
Expand Down
5 changes: 5 additions & 0 deletions src/widgets/fancypopup.cpp
Expand Up @@ -213,6 +213,11 @@ void FancyPopup::Private::initContents(QString title, const PsiIcon *icon, bool
ui_.closeButton->setIcon( popup->style()->standardPixmap(QStyle::SP_TitleBarCloseButton) );
ui_.closeButton->setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
connect(ui_.closeButton, SIGNAL(clicked()), popup, SLOT(hide()));

const QString css = PsiOptions::instance()->getOption("options.ui.notifications.passive-popups.css").toString();
if (!css.isEmpty()) {
popup->setStyleSheet(css);
}
}

bool FancyPopup::Private::eventFilter(QObject *o, QEvent *e)
Expand Down
7 changes: 7 additions & 0 deletions src/widgets/iconaction.cpp
Expand Up @@ -30,6 +30,8 @@ class PsiIcon;
class Iconset;
#endif

#include "psioptions.h"

#include <QLayout>
#include <QMenu>
#include <QTimer>
Expand Down Expand Up @@ -441,6 +443,11 @@ IconActionGroup::IconActionGroup(QObject *parent, const char *name, bool exclusi
d->updatePopup();

d->exclusive = exclusive;

const QString css = PsiOptions::instance()->getOption("options.ui.contactlist.css").toString();
if (!css.isEmpty()) {
d->popup->setStyleSheet(css);
}
}

IconActionGroup::~IconActionGroup()
Expand Down
10 changes: 10 additions & 0 deletions src/widgets/psitabwidget.cpp
Expand Up @@ -74,6 +74,7 @@ PsiTabWidget::PsiTabWidget(QWidget *parent)
stacked_ = new QStackedLayout(layout_);

setTabPosition(QTabWidget::North);
setLooks();

if (!PsiOptions::instance()->getOption("options.ui.tabs.show-tab-close-buttons").toBool()){
tabBar_->setTabsClosable(false);
Expand Down Expand Up @@ -173,9 +174,18 @@ void PsiTabWidget::addTab(QWidget *widget, QString name, const QIcon &icon)
tabBar_->addTab(icon, name);
else
tabBar_->addTab(name);
setLooks();
showPage(currentPage());
}

void PsiTabWidget::setLooks()
{
const QString css = PsiOptions::instance()->getOption("options.ui.chat.css").toString();
if (!css.isEmpty()) {
setStyleSheet(css);
}
}

/**
* Selects the page for the specified widget.
*/
Expand Down
1 change: 1 addition & 0 deletions src/widgets/psitabwidget.h
Expand Up @@ -67,6 +67,7 @@ class PsiTabWidget : public QWidget //: public QTabWidget
public slots:
void setCurrentPage(int);
void removeCurrentPage();
void setLooks();

signals:
void mouseDoubleClickTab(QWidget *tab);
Expand Down
4 changes: 4 additions & 0 deletions src/widgets/psitiplabel.cpp
Expand Up @@ -55,6 +55,10 @@ void PsiTipLabel::init(const QString& text)
enableColoring_ = false;
}
}
const QString css = PsiOptions::instance()->getOption("options.ui.contactlist.tooltip.css").toString();
if (!css.isEmpty()) {
setStyleSheet(css);
}
}

void PsiTipLabel::setText(const QString& text)
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/urlobject.cpp
Expand Up @@ -19,6 +19,7 @@
*/

#include "urlobject.h"
#include "psioptions.h"

#include <QApplication>
#include <QClipboard>
Expand Down Expand Up @@ -231,6 +232,7 @@ QMenu *URLObject::createPopupMenu(const QString &lnk)
}

m->addAction(d->act_copy);
m->setStyleSheet(PsiOptions::instance()->getOption("options.ui.look.css").toString());
return m;
}

Expand Down

0 comments on commit a84f572

Please sign in to comment.