summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-10-04 02:35:28 +0200
committerPetr Mrázek <peterix@gmail.com>2017-10-04 02:35:28 +0200
commit4b90a078de96bf690bcb34e309138b7cbd5cfc07 (patch)
treebd17b9de61ac64caf3957af2b849f049e2cc4e0d
parentd8c8a41dfa04e82977c3b677a57c30c1f5b218bd (diff)
downloadMultiMC-4b90a078de96bf690bcb34e309138b7cbd5cfc07.tar
MultiMC-4b90a078de96bf690bcb34e309138b7cbd5cfc07.tar.gz
MultiMC-4b90a078de96bf690bcb34e309138b7cbd5cfc07.tar.lz
MultiMC-4b90a078de96bf690bcb34e309138b7cbd5cfc07.tar.xz
MultiMC-4b90a078de96bf690bcb34e309138b7cbd5cfc07.zip
NOISSUE add tooltips to new menu buttons and make them translateable
-rw-r--r--application/MainWindow.cpp49
1 files changed, 28 insertions, 21 deletions
diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp
index c44db4f8..0d8d7dbb 100644
--- a/application/MainWindow.cpp
+++ b/application/MainWindow.cpp
@@ -91,17 +91,14 @@
#include "UpdateController.h"
// WHY: to hold the pre-translation strings together with the QAction pointer, so it can be retranslated without a lot of ugly code
-class TranslatedAction
+template <typename T>
+class Translated
{
public:
- TranslatedAction(){}
- TranslatedAction(QWidget *parent)
+ Translated(){}
+ Translated(QWidget *parent)
{
- m_contained = new QAction(parent);
- }
- ~TranslatedAction()
- {
-
+ m_contained = new T(parent);
}
void setTooltipId(const char * tooltip)
{
@@ -111,11 +108,11 @@ public:
{
m_text = text;
}
- operator QAction*()
+ operator T*()
{
return m_contained;
}
- QAction * operator->()
+ T * operator->()
{
return m_contained;
}
@@ -131,10 +128,12 @@ public:
}
}
private:
- QAction * m_contained = nullptr;
+ T * m_contained = nullptr;
const char * m_text = nullptr;
const char * m_tooltip = nullptr;
};
+using TranslatedAction = Translated<QAction>;
+using TranslatedToolButton = Translated<QToolButton>;
// WHY: to hold the pre-translation strings together with the QToolbar pointer, so it can be retranslated without a lot of ugly code
class TranslatedToolbar
@@ -145,10 +144,6 @@ public:
{
m_contained = new QToolBar(parent);
}
- ~TranslatedToolbar()
- {
-
- }
void setWindowTitleId(const char * title)
{
m_title = title;
@@ -205,17 +200,19 @@ public:
LabeledToolButton *changeIconButton = nullptr;
QMenu * foldersMenu = nullptr;
- QToolButton * foldersMenuButton = nullptr;
+ TranslatedToolButton foldersMenuButton;
TranslatedAction actionViewInstanceFolder;
TranslatedAction actionViewCentralModsFolder;
QMenu * helpMenu = nullptr;
- QToolButton * helpMenuButton = nullptr;
+ TranslatedToolButton helpMenuButton;
TranslatedAction actionReportBug;
TranslatedAction actionDISCORD;
TranslatedAction actionREDDIT;
TranslatedAction actionAbout;
+ QVector<TranslatedToolButton *> all_toolbuttons;
+
QWidget *centralWidget = nullptr;
QHBoxLayout *horizontalLayout = nullptr;
QStatusBar *statusBar = nullptr;
@@ -267,6 +264,7 @@ public:
mainToolBar->addSeparator();
foldersMenu = new QMenu(MainWindow);
+ foldersMenu->setToolTipsVisible(true);
actionViewInstanceFolder = TranslatedAction(MainWindow);
actionViewInstanceFolder->setObjectName(QStringLiteral("actionViewInstanceFolder"));
@@ -284,17 +282,20 @@ public:
all_actions.append(&actionViewCentralModsFolder);
foldersMenu->addAction(actionViewCentralModsFolder);
- foldersMenuButton = new QToolButton(MainWindow);
- foldersMenuButton->setText(QT_TRANSLATE_NOOP("MainWindow", "Folders"));
+ foldersMenuButton = TranslatedToolButton(MainWindow);
+ foldersMenuButton.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Folders"));
+ foldersMenuButton.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open one of the folders shared between instances."));
foldersMenuButton->setMenu(foldersMenu);
foldersMenuButton->setPopupMode(QToolButton::InstantPopup);
foldersMenuButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
foldersMenuButton->setIcon(MMC->getThemedIcon("viewfolder"));
+ all_toolbuttons.append(&foldersMenuButton);
QWidgetAction* foldersButtonAction = new QWidgetAction(MainWindow);
foldersButtonAction->setDefaultWidget(foldersMenuButton);
mainToolBar->addAction(foldersButtonAction);
helpMenu = new QMenu(MainWindow);
+ helpMenu->setToolTipsVisible(true);
actionReportBug = TranslatedAction(MainWindow);
actionReportBug->setObjectName(QStringLiteral("actionReportBug"));
@@ -329,12 +330,14 @@ public:
all_actions.append(&actionAbout);
helpMenu->addAction(actionAbout);
- helpMenuButton = new QToolButton(MainWindow);
- helpMenuButton->setText(QT_TRANSLATE_NOOP("MainWindow", "Help"));
+ helpMenuButton = TranslatedToolButton(MainWindow);
+ helpMenuButton.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Help"));
+ helpMenuButton.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Get help with MultiMC or Minecraft."));
helpMenuButton->setMenu(helpMenu);
helpMenuButton->setPopupMode(QToolButton::InstantPopup);
helpMenuButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
helpMenuButton->setIcon(MMC->getThemedIcon("help"));
+ all_toolbuttons.append(&helpMenuButton);
QWidgetAction* helpButtonAction = new QWidgetAction(MainWindow);
helpButtonAction->setDefaultWidget(helpMenuButton);
mainToolBar->addAction(helpButtonAction);
@@ -623,6 +626,10 @@ public:
{
item->retranslate();
}
+ for(auto * item: all_toolbuttons)
+ {
+ item->retranslate();
+ }
// submenu buttons
foldersMenuButton->setText(tr("Folders"));
helpMenuButton->setText(tr("Help"));