浏览代码

UI: Use new truncate function with hotkeys

This updates the hotkeys to use the new truncate label
function in qt-wrappers.cpp
Clayton Groeneveld 3 年之前
父节点
当前提交
e40a6be031
共有 1 个文件被更改,包括 2 次插入17 次删除
  1. 2 17
      UI/window-basic-settings.cpp

+ 2 - 17
UI/window-basic-settings.cpp

@@ -2728,8 +2728,6 @@ void OBSBasicSettings::LoadAdvancedSettings()
 	loading = false;
 }
 
-#define TRUNCATE_TEXT_LENGTH 80
-
 template<typename Func>
 static inline void
 LayoutHotkey(OBSBasicSettings *settings, obs_hotkey_id id, obs_hotkey_t *key,
@@ -2740,13 +2738,7 @@ LayoutHotkey(OBSBasicSettings *settings, obs_hotkey_id id, obs_hotkey_t *key,
 	QString text = QT_UTF8(obs_hotkey_get_description(key));
 
 	label->setProperty("fullName", text);
-
-	if (text.length() > TRUNCATE_TEXT_LENGTH) {
-		text = text.left(TRUNCATE_TEXT_LENGTH);
-		text += "...'";
-	}
-
-	label->setText(text);
+	TruncateLabel(label, text);
 
 	OBSHotkeyWidget *hw = nullptr;
 
@@ -2778,14 +2770,7 @@ static QLabel *makeLabel(const OBSSource &source, Func &&)
 	OBSSourceLabel *label = new OBSSourceLabel(source);
 	label->setStyleSheet("font-weight: bold;");
 	QString name = QT_UTF8(obs_source_get_name(source));
-
-	if (name.length() > TRUNCATE_TEXT_LENGTH) {
-		label->setToolTip(name);
-		name = name.left(TRUNCATE_TEXT_LENGTH);
-		name += "...";
-	}
-
-	label->setText(name);
+	TruncateLabel(label, name);
 
 	return label;
 }