TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttkglobalhelper.cpp
Go to the documentation of this file.
1 #include "ttkglobalhelper.h"
2 
3 #include <QWidget>
4 #include <QApplication>
5 #include <QFontDatabase>
6 
7 static constexpr int WIDTH = 4;
8 static constexpr int HEIGHT = 4;
9 
11 {
12  QFont font = QApplication::font();
13  for(const QString &family : QFontDatabase().families())
14  {
15  if(family == "微软雅黑" ||
16  family == QString::fromUtf8("微软雅黑") ||
17  family == QString::fromLocal8Bit("微软雅黑") ||
18  family == "Microsoft YaHei")
19  {
20  font.setFamily(family);
21  QApplication::setFont(font);
22  TTK_INFO_STREAM("TTK application use 'Microsoft YaHei' font");
23  break;
24  }
25  }
26 }
27 
28 void TTK::setBorderShadow(QWidget *widget, QPainter *painter)
29 {
30  painter->drawPixmap(0, 0, WIDTH, HEIGHT, QPixmap(":/shadow/lb_left_top"));
31  painter->drawPixmap(widget->width() - WIDTH, 0, WIDTH, HEIGHT, QPixmap(":/shadow/lb_right_top"));
32  painter->drawPixmap(0, widget->height() - HEIGHT, WIDTH, HEIGHT, QPixmap(":/shadow/lb_left_bottom"));
33  painter->drawPixmap(widget->width() - WIDTH, widget->height() - HEIGHT, WIDTH, HEIGHT, QPixmap(":/shadow/lb_right_bottom"));
34 
35  painter->drawPixmap(0, WIDTH, HEIGHT, widget->height() - 2 * WIDTH, QPixmap(":/shadow/lb_left").scaled(WIDTH, widget->height() - 2 * HEIGHT));
36  painter->drawPixmap(widget->width() - WIDTH, WIDTH, HEIGHT, widget->height() - 2 * HEIGHT, QPixmap(":/shadow/lb_right").scaled(WIDTH, widget->height() - 2 * HEIGHT));
37  painter->drawPixmap(HEIGHT, 0, widget->width() - 2 * WIDTH, HEIGHT, QPixmap(":/shadow/lb_top").scaled(widget->width() - 2 * WIDTH, HEIGHT));
38  painter->drawPixmap(WIDTH, widget->height() - HEIGHT, widget->width() - 2 * WIDTH, HEIGHT, QPixmap(":/shadow/lb_bottom").scaled(widget->width() - 2 * WIDTH, HEIGHT));
39 }
TTK_MODULE_EXPORT void setBorderShadow(QWidget *widget, QPainter *painter)
TTK_MODULE_EXPORT void setApplicationFont()
#define TTK_INFO_STREAM(msg)
Definition: ttklogger.h:67
static constexpr int WIDTH
static constexpr int HEIGHT