diff --git a/Source/Core/DolphinQt2/CMakeLists.txt b/Source/Core/DolphinQt2/CMakeLists.txt
index faf8b468f5..e9886ea4e0 100644
--- a/Source/Core/DolphinQt2/CMakeLists.txt
+++ b/Source/Core/DolphinQt2/CMakeLists.txt
@@ -39,6 +39,7 @@ set(SRCS
GameList/GameListModel.cpp
GameList/GameTracker.cpp
GameList/ListProxyModel.cpp
+ QtUtils/ElidedButton.cpp
Settings/GeneralPane.cpp
Settings/InterfacePane.cpp
)
diff --git a/Source/Core/DolphinQt2/DolphinQt2.vcxproj b/Source/Core/DolphinQt2/DolphinQt2.vcxproj
index e0cd0e09b3..f807140e73 100644
--- a/Source/Core/DolphinQt2/DolphinQt2.vcxproj
+++ b/Source/Core/DolphinQt2/DolphinQt2.vcxproj
@@ -157,6 +157,7 @@
+
@@ -257,4 +258,4 @@
-
\ No newline at end of file
+
diff --git a/Source/Core/DolphinQt2/DolphinQt2.vcxproj.filters b/Source/Core/DolphinQt2/DolphinQt2.vcxproj.filters
index 0a4627d729..5e25b8b58f 100644
--- a/Source/Core/DolphinQt2/DolphinQt2.vcxproj.filters
+++ b/Source/Core/DolphinQt2/DolphinQt2.vcxproj.filters
@@ -116,6 +116,9 @@
+
+ QtUtils
+
@@ -177,6 +180,9 @@
{42f8a963-563e-420d-8aca-5761657dcff5}
+
+ {fb4b5691-df66-4984-af40-fcc2b37f3622}
+
{d2a31121-7903-4a66-9b42-9358e92d36ff}
@@ -184,4 +190,4 @@
-
\ No newline at end of file
+
diff --git a/Source/Core/DolphinQt2/QtUtils/ElidedButton.cpp b/Source/Core/DolphinQt2/QtUtils/ElidedButton.cpp
new file mode 100644
index 0000000000..309c4b5d29
--- /dev/null
+++ b/Source/Core/DolphinQt2/QtUtils/ElidedButton.cpp
@@ -0,0 +1,40 @@
+// Copyright 2017 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#include "DolphinQt2/QtUtils/ElidedButton.h"
+
+#include
+#include
+#include
+
+ElidedButton::ElidedButton(const QString& text, Qt::TextElideMode elide_mode)
+ : QPushButton(text, nullptr), m_elide_mode{elide_mode}
+{
+}
+
+Qt::TextElideMode ElidedButton::elideMode() const
+{
+ return m_elide_mode;
+}
+
+void ElidedButton::setElideMode(Qt::TextElideMode elide_mode)
+{
+ if (elide_mode == m_elide_mode)
+ return;
+
+ m_elide_mode = elide_mode;
+ repaint();
+}
+
+void ElidedButton::paintEvent(QPaintEvent* event)
+{
+ QStyleOptionButton option;
+ initStyleOption(&option);
+
+ option.text = fontMetrics().elidedText(
+ text(), m_elide_mode,
+ style()->subElementRect(QStyle::SE_PushButtonContents, &option, this).width());
+
+ QStylePainter{this}.drawControl(QStyle::CE_PushButton, option);
+}
diff --git a/Source/Core/DolphinQt2/QtUtils/ElidedButton.h b/Source/Core/DolphinQt2/QtUtils/ElidedButton.h
new file mode 100644
index 0000000000..bce6593f8d
--- /dev/null
+++ b/Source/Core/DolphinQt2/QtUtils/ElidedButton.h
@@ -0,0 +1,20 @@
+// Copyright 2017 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include
+
+class ElidedButton : public QPushButton
+{
+public:
+ ElidedButton(const QString& text = QStringLiteral(""),
+ Qt::TextElideMode elide_mode = Qt::ElideRight);
+ Qt::TextElideMode elideMode() const;
+ void setElideMode(Qt::TextElideMode elide_mode);
+
+private:
+ void paintEvent(QPaintEvent* event);
+ Qt::TextElideMode m_elide_mode;
+};