Commit 58a8db42 authored by captainwong's avatar captainwong

update

parent 47972811
...@@ -8,20 +8,20 @@ JLIBQT_NAMESPACE_BEGIN ...@@ -8,20 +8,20 @@ JLIBQT_NAMESPACE_BEGIN
namespace def_sizes { namespace def_sizes {
static const int window_width = 646; constexpr int window_width = 646;
static const int window_height = 424; constexpr int window_height = 424;
static const int title_height = 54; constexpr int title_height = 54;
static const int content_height = window_height - title_height; constexpr int content_height = window_height - title_height;
static const int control_height = 24; constexpr int control_height = 24;
static const int big_window_width = 1022; constexpr int big_window_width = 1022;
static const int big_window_height = 670; constexpr int big_window_height = 670;
static const int big_content_height = big_window_height - title_height; constexpr int big_content_height = big_window_height - title_height;
static const int device_view_width = 306; constexpr int device_view_width = 306;
static const int device_view_height = 236; constexpr int device_view_height = 236;
} // namespace def_sizes } // namespace def_sizes
...@@ -76,7 +76,7 @@ static const auto ptz_back = QColor(0x2d2e31); ...@@ -76,7 +76,7 @@ static const auto ptz_back = QColor(0x2d2e31);
namespace def_font_families { namespace def_font_families {
static const char* const yahei = "Microsoft YaHei"; constexpr auto yahei = "Microsoft YaHei";
} // namespace def_font_families } // namespace def_font_families
...@@ -170,7 +170,7 @@ inline QString unkonwn_trans() { ...@@ -170,7 +170,7 @@ inline QString unkonwn_trans() {
return build_bg_style() + build_style(def_colors::unknown_trans, 18); return build_bg_style() + build_style(def_colors::unknown_trans, 18);
} }
static const auto vertical_scroll_bar = R"( constexpr auto vertical_scroll_bar = R"(
QScrollBar:vertical QScrollBar:vertical
{ {
width:8px; width:8px;
...@@ -236,16 +236,17 @@ QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical ...@@ -236,16 +236,17 @@ QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical
)"; )";
static const auto search_bar_edit = R"( constexpr auto search_bar_edit = R"(
border: 0px; border: 0px;
background: transparent; background: transparent;
selection-background-color: white; selection-background-color: white;
selection-color: black;
color: #a8a9a9; color: #a8a9a9;
font-family: Microsoft Yahei; font-family: Microsoft Yahei;
font-size: 14px; font-size: 14px;
)"; )";
static const auto progress_bar = R"( constexpr auto progress_bar = R"(
QProgressBar{ QProgressBar{
background-color:#dedede;border-radius:3px; background-color:#dedede;border-radius:3px;
} }
...@@ -254,7 +255,7 @@ QProgressBar::chunk{ ...@@ -254,7 +255,7 @@ QProgressBar::chunk{
} }
)"; )";
static const auto slider = R"( constexpr auto slider = R"(
QSlider::groove:horizontal QSlider::groove:horizontal
{ {
border:0px; border:0px;
...@@ -278,7 +279,7 @@ QSlider::handle:horizontal ...@@ -278,7 +279,7 @@ QSlider::handle:horizontal
} }
)"; )";
static const auto menu = R"( constexpr auto menu = R"(
QMenu::item QMenu::item
{ {
font-family: Microsoft Yahei; font-family: Microsoft Yahei;
...@@ -293,7 +294,7 @@ QMenu::item:hover ...@@ -293,7 +294,7 @@ QMenu::item:hover
} }
)"; )";
static const auto group_box = R"( constexpr auto group_box = R"(
QGroupBox { QGroupBox {
border: 1px solid gray; border: 1px solid gray;
border-radius: 9px; border-radius: 9px;
...@@ -309,7 +310,7 @@ QGroupBox::title { ...@@ -309,7 +310,7 @@ QGroupBox::title {
} }
)"; )";
static const auto listWidgetStyleSheet = R"( constexpr auto listWidgetStyleSheet = R"(
QListWidget QListWidget
{ {
font:12pt; font:12pt;
...@@ -332,7 +333,7 @@ QListWidget::item::selected ...@@ -332,7 +333,7 @@ QListWidget::item::selected
)"; )";
static const auto check_box = R"( constexpr auto check_box = R"(
QCheckBox QCheckBox
{ {
font-size: 16px; font-size: 16px;
...@@ -354,7 +355,7 @@ QCheckBox::indicator:unchecked ...@@ -354,7 +355,7 @@ QCheckBox::indicator:unchecked
)"; )";
static const auto check_box_48px = R"( constexpr auto check_box_48px = R"(
QCheckBox QCheckBox
{ {
font-size: 16px; font-size: 16px;
......
...@@ -23,7 +23,7 @@ JLIBQT_NAMESPACE_BEGIN ...@@ -23,7 +23,7 @@ JLIBQT_NAMESPACE_BEGIN
* @brief 阻塞等待一段时间 * @brief 阻塞等待一段时间
* @param ms 等待的毫秒数 * @param ms 等待的毫秒数
*/ */
static inline void blocking_wait(int ms, QString log = "") { inline void blocking_wait(int ms, QString log = "") {
if (!log.isEmpty()) { if (!log.isEmpty()) {
MYQDEBUG << log << "in"; MYQDEBUG << log << "in";
} }
...@@ -37,7 +37,7 @@ static inline void blocking_wait(int ms, QString log = "") { ...@@ -37,7 +37,7 @@ static inline void blocking_wait(int ms, QString log = "") {
* @brief 不阻塞UI响应的情况下,等待一段时间 * @brief 不阻塞UI响应的情况下,等待一段时间
* @param ms 等待的毫秒数 * @param ms 等待的毫秒数
*/ */
static inline void non_blocking_wait_in_ui_thread(int ms, QString log = "") { inline void non_blocking_wait_in_ui_thread(int ms, QString log = "") {
if (!log.isEmpty()) { if (!log.isEmpty()) {
MYQDEBUG << log << "in"; MYQDEBUG << log << "in";
} }
...@@ -56,7 +56,7 @@ static inline void non_blocking_wait_in_ui_thread(int ms, QString log = "") { ...@@ -56,7 +56,7 @@ static inline void non_blocking_wait_in_ui_thread(int ms, QString log = "") {
* @brief 在文件夹中显示 * @brief 在文件夹中显示
* @param pathIn 若为文件路径则在文件夹中显示,若为文件夹路径则打开改文件夹 * @param pathIn 若为文件路径则在文件夹中显示,若为文件夹路径则打开改文件夹
*/ */
static inline void showInGraphicalShell(const QString &pathIn) { inline void showInGraphicalShell(const QString &pathIn) {
QString param; QString param;
if (!QFileInfo(pathIn).isDir()) if (!QFileInfo(pathIn).isDir())
param = QLatin1String("/select,"); param = QLatin1String("/select,");
...@@ -65,7 +65,7 @@ static inline void showInGraphicalShell(const QString &pathIn) { ...@@ -65,7 +65,7 @@ static inline void showInGraphicalShell(const QString &pathIn) {
QProcess::startDetached(command); QProcess::startDetached(command);
} }
static inline bool warn_if_load_pixmap_failed(QPixmap& pixmap, QString icon_path, QString file_line, bool forceUseQss = true) inline bool warn_if_load_pixmap_failed(QPixmap& pixmap, QString icon_path, QString file_line, bool forceUseQss = true)
{ {
/*if (!QDir().isAbsolutePath(icon_path)) { /*if (!QDir().isAbsolutePath(icon_path)) {
icon_path = PathHelper::program() + "/" + icon_path; icon_path = PathHelper::program() + "/" + icon_path;
...@@ -86,13 +86,13 @@ static inline bool warn_if_load_pixmap_failed(QPixmap& pixmap, QString icon_path ...@@ -86,13 +86,13 @@ static inline bool warn_if_load_pixmap_failed(QPixmap& pixmap, QString icon_path
#define LOAD_PIXMAP_EX(icon_path) JLIBQT_NAMESPACE warn_if_load_pixmap_failed(pixmap, icon_path, JLIBQT_QDEBUG_FILE_LINE_VALUE) #define LOAD_PIXMAP_EX(icon_path) JLIBQT_NAMESPACE warn_if_load_pixmap_failed(pixmap, icon_path, JLIBQT_QDEBUG_FILE_LINE_VALUE)
#define LOAD_PIXMAP_EX2(icon_path) JLIBQT_NAMESPACE warn_if_load_pixmap_failed(pixmap, icon_path, JLIBQT_QDEBUG_FILE_LINE_VALUE, false) #define LOAD_PIXMAP_EX2(icon_path) JLIBQT_NAMESPACE warn_if_load_pixmap_failed(pixmap, icon_path, JLIBQT_QDEBUG_FILE_LINE_VALUE, false)
static QIcon icon_from_path(QString path, QSize icon_sz) { inline QIcon icon_from_path(QString path, QSize icon_sz) {
QPixmap pixmap; QPixmap pixmap;
LOAD_PIXMAP_EX(path); LOAD_PIXMAP_EX(path);
return QIcon(pixmap.scaled(icon_sz, Qt::KeepAspectRatio, Qt::SmoothTransformation)); return QIcon(pixmap.scaled(icon_sz, Qt::KeepAspectRatio, Qt::SmoothTransformation));
} }
static inline void fill_bg_with_color(QWidget * widget, QColor color) inline void fill_bg_with_color(QWidget * widget, QColor color)
{ {
if (!widget) { return; } if (!widget) { return; }
...@@ -102,14 +102,14 @@ static inline void fill_bg_with_color(QWidget * widget, QColor color) ...@@ -102,14 +102,14 @@ static inline void fill_bg_with_color(QWidget * widget, QColor color)
widget->setPalette(palette); widget->setPalette(palette);
} }
static inline void set_pos(QWidget * widget, QRect pos) inline void set_pos(QWidget * widget, QRect pos)
{ {
if (!widget) { return; } if (!widget) { return; }
widget->setFixedSize(pos.width(), pos.height()); widget->setFixedSize(pos.width(), pos.height());
widget->move(pos.left(), pos.top()); widget->move(pos.left(), pos.top());
} }
static inline void set_image_bg(QWidget* widget, QPixmap pixmap) inline void set_image_bg(QWidget* widget, QPixmap pixmap)
{ {
if (!widget || pixmap.isNull())return; if (!widget || pixmap.isNull())return;
QPalette palette; QPalette palette;
...@@ -117,28 +117,28 @@ static inline void set_image_bg(QWidget* widget, QPixmap pixmap) ...@@ -117,28 +117,28 @@ static inline void set_image_bg(QWidget* widget, QPixmap pixmap)
widget->setPalette(palette); widget->setPalette(palette);
} }
static inline void set_image_bg(QWidget* widget, QString icon_path) inline void set_image_bg(QWidget* widget, QString icon_path)
{ {
QPixmap pixmap; QPixmap pixmap;
if (!LOAD_PIXMAP_EX(icon_path)) { return; } if (!LOAD_PIXMAP_EX(icon_path)) { return; }
set_image_bg(widget, pixmap); set_image_bg(widget, pixmap);
} }
static inline void center_to_parent(QWidget* widget, QWidget* parent) inline void center_to_parent(QWidget* widget, QWidget* parent)
{ {
if (!widget || !parent) { return; } if (!widget || !parent) { return; }
auto center = parent->rect().center(); auto center = parent->rect().center();
widget->move(center.x() - widget->width() / 2, center.y() - widget->height() / 2); widget->move(center.x() - widget->width() / 2, center.y() - widget->height() / 2);
} }
static inline void center_to_desktop(QWidget* widget) inline void center_to_desktop(QWidget* widget)
{ {
if (!widget) { return; } if (!widget) { return; }
auto center = QApplication::desktop()->availableGeometry(widget).center(); auto center = QApplication::desktop()->availableGeometry(widget).center();
widget->move(center.x() - widget->width() / 2, center.y() - widget->height() / 2); widget->move(center.x() - widget->width() / 2, center.y() - widget->height() / 2);
} }
static inline void center_to_desktop(QWidget* widget, int new_width, int new_height) inline void center_to_desktop(QWidget* widget, int new_width, int new_height)
{ {
if (!widget) { return; } if (!widget) { return; }
auto center = QApplication::desktop()->availableGeometry(widget).center(); auto center = QApplication::desktop()->availableGeometry(widget).center();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment