2018-01-31 17:35:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <queue>
|
|
|
|
#include <mutex>
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-11-20 01:50:16 +00:00
|
|
|
#include <QtCore>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QActionGroup>
|
|
|
|
|
2020-10-04 08:30:18 +00:00
|
|
|
#include "Common/System/System.h"
|
|
|
|
#include "Common/System/NativeApp.h"
|
2013-11-19 04:02:24 +00:00
|
|
|
#include "ConsoleListener.h"
|
2013-01-13 23:29:42 +00:00
|
|
|
#include "Core/Core.h"
|
2013-11-19 04:02:24 +00:00
|
|
|
#include "Core/Config.h"
|
2014-06-24 14:34:13 +00:00
|
|
|
#include "Core/System.h"
|
2017-12-19 17:04:26 +00:00
|
|
|
#include "Qt/QtMain.h"
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-12-07 18:57:06 +00:00
|
|
|
extern bool g_TakeScreenshot;
|
|
|
|
|
2013-11-22 04:05:36 +00:00
|
|
|
class MenuAction;
|
|
|
|
class MenuTree;
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2020-04-14 01:24:30 +00:00
|
|
|
enum {
|
|
|
|
FB_NON_BUFFERED_MODE = 0,
|
|
|
|
FB_BUFFERED_MODE = 1,
|
|
|
|
};
|
|
|
|
|
2018-01-31 17:35:48 +00:00
|
|
|
// hacky, should probably use qt signals or something, but whatever..
|
|
|
|
enum class MainWindowMsg {
|
2018-03-03 07:52:39 +00:00
|
|
|
BOOT_DONE,
|
|
|
|
WINDOW_TITLE_CHANGED,
|
2018-01-31 17:35:48 +00:00
|
|
|
};
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
{
|
2013-11-19 11:02:43 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
public:
|
2018-06-09 23:28:15 +00:00
|
|
|
explicit MainWindow(QWidget *parent = nullptr, bool fullscreen = false);
|
2013-11-19 10:18:11 +00:00
|
|
|
~MainWindow() { };
|
2013-01-13 23:29:42 +00:00
|
|
|
|
|
|
|
CoreState GetNextState() { return nextState; }
|
2013-02-19 20:59:53 +00:00
|
|
|
|
2020-04-17 23:46:11 +00:00
|
|
|
void updateMenuGroupInt(QActionGroup *group, int value);
|
|
|
|
|
2013-11-19 10:18:11 +00:00
|
|
|
void updateMenus();
|
2013-02-19 20:59:53 +00:00
|
|
|
|
2018-01-31 17:35:48 +00:00
|
|
|
void Notify(MainWindowMsg msg) {
|
|
|
|
std::unique_lock<std::mutex> lock(msgMutex_);
|
|
|
|
msgQueue_.push(msg);
|
|
|
|
}
|
|
|
|
|
2018-03-03 07:52:39 +00:00
|
|
|
void SetWindowTitleAsync(std::string title) {
|
|
|
|
std::unique_lock<std::mutex> lock(titleMutex_);
|
|
|
|
newWindowTitle_ = title;
|
|
|
|
Notify(MainWindowMsg::WINDOW_TITLE_CHANGED);
|
|
|
|
}
|
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
protected:
|
2014-06-29 14:17:34 +00:00
|
|
|
void changeEvent(QEvent *e)
|
|
|
|
{
|
|
|
|
QMainWindow::changeEvent(e);
|
|
|
|
// Does not work on Linux for Qt5.2 or Qt5.3 (Qt bug)
|
|
|
|
if(e->type() == QEvent::WindowStateChange)
|
|
|
|
Core_NotifyWindowHidden(isMinimized());
|
|
|
|
}
|
|
|
|
|
2013-11-26 15:45:38 +00:00
|
|
|
void closeEvent(QCloseEvent *) { exitAct(); }
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-11-21 16:32:46 +00:00
|
|
|
signals:
|
|
|
|
void retranslate();
|
2013-11-22 04:05:36 +00:00
|
|
|
void updateMenu();
|
2013-11-21 16:32:46 +00:00
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
public slots:
|
2013-11-28 03:27:10 +00:00
|
|
|
void newFrame();
|
2013-01-13 23:29:42 +00:00
|
|
|
|
|
|
|
private slots:
|
2013-02-19 20:59:53 +00:00
|
|
|
// File
|
2020-04-12 17:12:42 +00:00
|
|
|
void loadAct();
|
2013-11-22 04:05:36 +00:00
|
|
|
void closeAct();
|
2020-04-12 17:12:42 +00:00
|
|
|
void openmsAct();
|
|
|
|
void saveStateGroup_triggered(QAction *action) { g_Config.iCurrentStateSlot = action->data().toInt(); }
|
2013-11-22 04:05:36 +00:00
|
|
|
void qlstateAct();
|
|
|
|
void qsstateAct();
|
|
|
|
void lstateAct();
|
|
|
|
void sstateAct();
|
2020-04-16 14:14:56 +00:00
|
|
|
void recordDisplayAct();
|
|
|
|
void useLosslessVideoCodecAct();
|
|
|
|
void useOutputBufferAct();
|
|
|
|
void recordAudioAct();
|
2013-11-22 04:05:36 +00:00
|
|
|
void exitAct();
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
// Emulation
|
2013-11-22 04:05:36 +00:00
|
|
|
void runAct();
|
|
|
|
void pauseAct();
|
2020-04-16 16:49:18 +00:00
|
|
|
void stopAct();
|
2013-11-22 04:05:36 +00:00
|
|
|
void resetAct();
|
2020-04-18 18:08:20 +00:00
|
|
|
void switchUMDAct();
|
2020-04-12 16:26:44 +00:00
|
|
|
void displayRotationGroup_triggered(QAction *action) { g_Config.iInternalScreenRotation = action->data().toInt(); }
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
// Debug
|
2020-04-12 15:49:10 +00:00
|
|
|
void breakonloadAct();
|
|
|
|
void ignoreIllegalAct() { g_Config.bIgnoreBadMemAccess = !g_Config.bIgnoreBadMemAccess; }
|
2013-11-22 04:05:36 +00:00
|
|
|
void lmapAct();
|
|
|
|
void smapAct();
|
2020-04-12 15:49:10 +00:00
|
|
|
void lsymAct();
|
|
|
|
void ssymAct();
|
2013-11-22 04:05:36 +00:00
|
|
|
void resetTableAct();
|
|
|
|
void dumpNextAct();
|
2013-12-07 18:57:06 +00:00
|
|
|
void takeScreen() { g_TakeScreenshot = true; }
|
2013-11-22 04:05:36 +00:00
|
|
|
void consoleAct();
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2020-04-12 15:17:36 +00:00
|
|
|
// Game settings
|
|
|
|
void languageAct() { NativeMessageReceived("language screen", ""); }
|
|
|
|
void controlMappingAct() { NativeMessageReceived("control mapping", ""); }
|
|
|
|
void displayLayoutEditorAct() { NativeMessageReceived("display layout editor", ""); }
|
|
|
|
void moreSettingsAct() { NativeMessageReceived("settings", ""); }
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2018-06-09 23:35:13 +00:00
|
|
|
void bufferRenderAct() {
|
|
|
|
g_Config.iRenderingMode = !g_Config.iRenderingMode;
|
|
|
|
NativeMessageReceived("gpu_resized", "");
|
|
|
|
}
|
2013-11-22 04:05:36 +00:00
|
|
|
void linearAct() { g_Config.iTexFiltering = (g_Config.iTexFiltering != 0) ? 0 : 3; }
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2020-04-12 22:48:19 +00:00
|
|
|
void renderingResolutionGroup_triggered(QAction *action) {
|
|
|
|
g_Config.iInternalResolution = action->data().toInt();
|
|
|
|
NativeMessageReceived("gpu_resized", "");
|
|
|
|
}
|
2020-04-12 15:17:36 +00:00
|
|
|
void windowGroup_triggered(QAction *action) { SetWindowScale(action->data().toInt()); }
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2018-06-09 23:35:13 +00:00
|
|
|
void displayLayoutGroup_triggered(QAction *action) {
|
|
|
|
g_Config.iSmallDisplayZoomType = action->data().toInt();
|
|
|
|
NativeMessageReceived("gpu_resized", "");
|
|
|
|
}
|
2020-04-12 22:48:19 +00:00
|
|
|
void renderingModeGroup_triggered(QAction *action) {
|
|
|
|
g_Config.iRenderingMode = action->data().toInt();
|
|
|
|
g_Config.bAutoFrameSkip = false;
|
|
|
|
NativeMessageReceived("gpu_resized", "");
|
|
|
|
}
|
|
|
|
void autoframeskipAct() {
|
|
|
|
g_Config.bAutoFrameSkip = !g_Config.bAutoFrameSkip;
|
|
|
|
if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
|
|
|
|
g_Config.iRenderingMode = FB_BUFFERED_MODE;
|
|
|
|
NativeMessageReceived("gpu_resized", "");
|
2020-04-13 11:40:47 +00:00
|
|
|
}
|
2020-04-12 22:48:19 +00:00
|
|
|
}
|
2020-04-12 15:17:36 +00:00
|
|
|
void frameSkippingGroup_triggered(QAction *action) { g_Config.iFrameSkip = action->data().toInt(); }
|
|
|
|
void frameSkippingTypeGroup_triggered(QAction *action) { g_Config.iFrameSkipType = action->data().toInt(); }
|
|
|
|
void textureFilteringGroup_triggered(QAction *action) { g_Config.iTexFiltering = action->data().toInt(); }
|
|
|
|
void screenScalingFilterGroup_triggered(QAction *action) { g_Config.iBufFilter = action->data().toInt(); }
|
2020-04-12 22:48:19 +00:00
|
|
|
void textureScalingLevelGroup_triggered(QAction *action) {
|
|
|
|
g_Config.iTexScalingLevel = action->data().toInt();
|
|
|
|
NativeMessageReceived("gpu_clearCache", "");
|
|
|
|
}
|
|
|
|
void textureScalingTypeGroup_triggered(QAction *action) {
|
|
|
|
g_Config.iTexScalingType = action->data().toInt();
|
|
|
|
NativeMessageReceived("gpu_clearCache", "");
|
|
|
|
}
|
|
|
|
void deposterizeAct() {
|
|
|
|
g_Config.bTexDeposterize = !g_Config.bTexDeposterize;
|
|
|
|
NativeMessageReceived("gpu_clearCache", "");
|
|
|
|
}
|
2020-04-05 22:23:46 +00:00
|
|
|
void transformAct() {
|
|
|
|
g_Config.bHardwareTransform = !g_Config.bHardwareTransform;
|
|
|
|
NativeMessageReceived("gpu_resized", "");
|
|
|
|
}
|
2013-11-22 04:05:36 +00:00
|
|
|
void vertexCacheAct() { g_Config.bVertexCache = !g_Config.bVertexCache; }
|
|
|
|
void frameskipAct() { g_Config.iFrameSkip = !g_Config.iFrameSkip; }
|
2018-11-03 01:33:41 +00:00
|
|
|
void frameskipTypeAct() { g_Config.iFrameSkipType = !g_Config.iFrameSkipType; }
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
// Sound
|
2020-04-12 22:48:19 +00:00
|
|
|
void audioAct() {
|
|
|
|
g_Config.bEnableSound = !g_Config.bEnableSound;
|
|
|
|
if (PSP_IsInited() && !IsAudioInitialised())
|
|
|
|
Audio_Init();
|
|
|
|
}
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2020-04-12 15:17:36 +00:00
|
|
|
// Cheats
|
|
|
|
void cheatsAct() { g_Config.bEnableCheats = !g_Config.bEnableCheats; }
|
|
|
|
|
2020-04-15 15:16:14 +00:00
|
|
|
// Chat
|
2021-02-17 18:30:52 +00:00
|
|
|
void chatAct() {
|
2021-09-15 12:32:54 +00:00
|
|
|
if (GetUIState() == UISTATE_INGAME) {
|
|
|
|
NativeMessageReceived("chat screen", "");
|
|
|
|
}
|
2021-02-17 18:30:52 +00:00
|
|
|
}
|
2020-04-15 15:16:14 +00:00
|
|
|
|
2013-11-22 04:05:36 +00:00
|
|
|
void fullscrAct();
|
2014-09-23 20:27:18 +00:00
|
|
|
void raiseTopMost();
|
2018-06-09 23:35:13 +00:00
|
|
|
void statsAct() {
|
|
|
|
g_Config.bShowDebugStats = !g_Config.bShowDebugStats;
|
|
|
|
NativeMessageReceived("clear jit", "");
|
|
|
|
}
|
2020-04-12 22:48:19 +00:00
|
|
|
void showFPSAct() { g_Config.iShowFPSCounter = g_Config.iShowFPSCounter ? 0 : 3; } // 3 = both speed and FPS
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
// Help
|
2013-11-22 04:05:36 +00:00
|
|
|
void websiteAct();
|
2014-07-10 12:41:26 +00:00
|
|
|
void forumAct();
|
2020-04-12 14:03:47 +00:00
|
|
|
void goldAct();
|
2017-02-05 13:16:22 +00:00
|
|
|
void gitAct();
|
2020-04-12 14:03:47 +00:00
|
|
|
void discordAct();
|
2013-11-22 04:05:36 +00:00
|
|
|
void aboutAct();
|
2013-02-03 23:45:37 +00:00
|
|
|
|
2013-02-19 20:59:53 +00:00
|
|
|
// Others
|
2013-11-19 09:32:31 +00:00
|
|
|
void langChanged(QAction *action) { loadLanguage(action->data().toString(), true); }
|
2013-02-06 17:49:20 +00:00
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
private:
|
2018-01-31 17:35:48 +00:00
|
|
|
void bootDone();
|
2016-05-21 16:22:14 +00:00
|
|
|
void SetWindowScale(int zoom);
|
2013-02-19 20:59:53 +00:00
|
|
|
void SetGameTitle(QString text);
|
2018-06-09 23:28:15 +00:00
|
|
|
void SetFullScreen(bool fullscreen);
|
2013-11-19 09:32:31 +00:00
|
|
|
void loadLanguage(const QString &language, bool retranslate);
|
2013-11-19 10:18:11 +00:00
|
|
|
void createMenus();
|
2013-02-06 17:49:20 +00:00
|
|
|
|
|
|
|
QTranslator translator;
|
|
|
|
QString currentLanguage;
|
|
|
|
|
2013-01-13 23:29:42 +00:00
|
|
|
CoreState nextState;
|
2013-04-20 10:43:55 +00:00
|
|
|
GlobalUIState lastUIState;
|
2013-01-13 23:29:42 +00:00
|
|
|
|
2020-04-12 22:48:19 +00:00
|
|
|
QActionGroup *windowGroup,
|
2020-04-12 15:17:36 +00:00
|
|
|
*textureScalingLevelGroup, *textureScalingTypeGroup,
|
|
|
|
*screenScalingFilterGroup, *textureFilteringGroup,
|
|
|
|
*frameSkippingTypeGroup, *frameSkippingGroup,
|
2020-04-12 16:26:44 +00:00
|
|
|
*renderingModeGroup, *renderingResolutionGroup,
|
2020-04-12 17:12:42 +00:00
|
|
|
*displayRotationGroup, *saveStateGroup;
|
2018-01-31 17:35:48 +00:00
|
|
|
|
|
|
|
std::queue<MainWindowMsg> msgQueue_;
|
|
|
|
std::mutex msgMutex_;
|
2018-03-03 07:52:39 +00:00
|
|
|
|
|
|
|
std::string newWindowTitle_;
|
|
|
|
std::mutex titleMutex_;
|
2013-01-13 23:29:42 +00:00
|
|
|
};
|
|
|
|
|
2013-11-21 16:32:46 +00:00
|
|
|
class MenuAction : public QAction
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2013-11-22 04:05:36 +00:00
|
|
|
// Add to QMenu
|
2014-02-15 09:47:14 +00:00
|
|
|
MenuAction(QWidget* parent, const char *callback, const char *text, QKeySequence key = 0) :
|
2021-09-15 12:32:54 +00:00
|
|
|
QAction(parent), _text(text)
|
2013-11-21 16:32:46 +00:00
|
|
|
{
|
2013-11-22 04:05:36 +00:00
|
|
|
if (key != (QKeySequence)0) {
|
2013-11-21 16:32:46 +00:00
|
|
|
this->setShortcut(key);
|
|
|
|
parent->addAction(this); // So we don't lose the shortcut when menubar is hidden
|
|
|
|
}
|
|
|
|
connect(this, SIGNAL(triggered()), parent, callback);
|
|
|
|
connect(parent, SIGNAL(retranslate()), this, SLOT(retranslate()));
|
2013-11-22 04:05:36 +00:00
|
|
|
connect(parent, SIGNAL(updateMenu()), this, SLOT(update()));
|
2013-11-21 16:32:46 +00:00
|
|
|
}
|
2013-11-22 04:05:36 +00:00
|
|
|
// Add to QActionGroup
|
2013-11-21 16:32:46 +00:00
|
|
|
MenuAction(QWidget* parent, QActionGroup* group, QVariant data, QString text, QKeySequence key = 0) :
|
2021-09-15 12:32:54 +00:00
|
|
|
QAction(parent)
|
2013-11-21 16:32:46 +00:00
|
|
|
{
|
|
|
|
this->setCheckable(true);
|
|
|
|
this->setData(data);
|
|
|
|
this->setText(text); // Not translatable, yet
|
2013-11-22 04:05:36 +00:00
|
|
|
if (key != (QKeySequence)0) {
|
2013-11-21 16:32:46 +00:00
|
|
|
this->setShortcut(key);
|
|
|
|
parent->addAction(this); // So we don't lose the shortcut when menubar is hidden
|
|
|
|
}
|
|
|
|
group->addAction(this);
|
|
|
|
}
|
2013-11-22 04:05:36 +00:00
|
|
|
// Event which causes it to be checked
|
|
|
|
void addEventChecked(bool* event) {
|
|
|
|
this->setCheckable(true);
|
|
|
|
_eventCheck = event;
|
|
|
|
}
|
|
|
|
// TODO: Possibly handle compares
|
|
|
|
void addEventChecked(int* event) {
|
|
|
|
this->setCheckable(true);
|
|
|
|
_eventCheck = (bool*)event;
|
|
|
|
}
|
2020-04-13 11:40:47 +00:00
|
|
|
// Event which causes it to be unchecked
|
|
|
|
void addEventUnchecked(bool* event) {
|
|
|
|
this->setCheckable(true);
|
|
|
|
_eventUncheck = event;
|
|
|
|
}
|
2013-11-22 04:05:36 +00:00
|
|
|
// UI State which causes it to be enabled
|
|
|
|
void addEnableState(int state) {
|
2021-09-15 12:32:54 +00:00
|
|
|
_enabledFunc = nullptr;
|
2013-11-22 04:05:36 +00:00
|
|
|
_stateEnable = state;
|
2021-09-15 12:32:54 +00:00
|
|
|
_stateDisable = -1;
|
2013-11-22 04:05:36 +00:00
|
|
|
}
|
|
|
|
void addDisableState(int state) {
|
2021-09-15 12:32:54 +00:00
|
|
|
_enabledFunc = nullptr;
|
|
|
|
_stateEnable = -1;
|
2013-11-22 04:05:36 +00:00
|
|
|
_stateDisable = state;
|
|
|
|
}
|
2021-09-15 12:32:54 +00:00
|
|
|
void SetEnabledFunc(std::function<bool()> func) {
|
|
|
|
_enabledFunc = func;
|
|
|
|
_stateEnable = -1;
|
|
|
|
_stateDisable = -1;
|
2013-11-22 04:05:36 +00:00
|
|
|
}
|
2013-11-21 16:32:46 +00:00
|
|
|
public slots:
|
|
|
|
void retranslate() {
|
|
|
|
setText(qApp->translate("MainWindow", _text));
|
|
|
|
}
|
2013-11-22 04:05:36 +00:00
|
|
|
void update() {
|
|
|
|
if (_eventCheck)
|
|
|
|
setChecked(*_eventCheck);
|
2020-04-13 11:40:47 +00:00
|
|
|
if (_eventUncheck)
|
2020-04-14 01:24:30 +00:00
|
|
|
setChecked(!*_eventUncheck);
|
2013-11-22 04:05:36 +00:00
|
|
|
if (_stateEnable >= 0)
|
2014-06-24 14:34:13 +00:00
|
|
|
setEnabled(GetUIState() == _stateEnable);
|
2013-11-22 04:05:36 +00:00
|
|
|
if (_stateDisable >= 0)
|
2014-06-24 14:34:13 +00:00
|
|
|
setEnabled(GetUIState() != _stateDisable);
|
2021-09-15 12:32:54 +00:00
|
|
|
if (_enabledFunc)
|
|
|
|
setEnabled(_enabledFunc());
|
2013-11-22 04:05:36 +00:00
|
|
|
}
|
|
|
|
private:
|
2014-02-15 09:47:14 +00:00
|
|
|
const char *_text;
|
2021-09-15 12:32:54 +00:00
|
|
|
bool *_eventCheck = nullptr;
|
|
|
|
bool *_eventUncheck = nullptr;
|
|
|
|
int _stateEnable = -1;
|
|
|
|
int _stateDisable = -1;
|
|
|
|
std::function<bool()> _enabledFunc;
|
2013-11-22 04:05:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class MenuActionGroup : public QActionGroup
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
MenuActionGroup(QWidget* parent, QMenu* menu, const char* callback, QStringList nameList,
|
|
|
|
QList<int> valueList, QList<int> keyList = QList<int>()) :
|
|
|
|
QActionGroup(parent)
|
|
|
|
{
|
|
|
|
QListIterator<int> i(valueList);
|
|
|
|
QListIterator<int> k(keyList);
|
|
|
|
foreach(QString name, nameList) {
|
2014-07-10 12:41:26 +00:00
|
|
|
new MenuAction(parent, this, i.next(), name, keyList.size() ? k.next() : 0);
|
2013-11-22 04:05:36 +00:00
|
|
|
}
|
|
|
|
connect(this, SIGNAL(triggered(QAction *)), parent, callback);
|
|
|
|
menu->addActions(this->actions());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class MenuTree : public QMenu
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-15 09:47:14 +00:00
|
|
|
MenuTree(QWidget* parent, QMenuBar* menu, const char *text) :
|
2013-11-22 04:05:36 +00:00
|
|
|
QMenu(parent), _text(text)
|
|
|
|
{
|
|
|
|
menu->addMenu(this);
|
|
|
|
connect(parent, SIGNAL(retranslate()), this, SLOT(retranslate()));
|
|
|
|
}
|
2014-02-15 09:47:14 +00:00
|
|
|
MenuTree(QWidget* parent, QMenu* menu, const char *text) :
|
2013-11-22 04:05:36 +00:00
|
|
|
QMenu(parent), _text(text)
|
|
|
|
{
|
|
|
|
menu->addMenu(this);
|
|
|
|
connect(parent, SIGNAL(retranslate()), this, SLOT(retranslate()));
|
|
|
|
}
|
|
|
|
MenuAction* add(MenuAction* action)
|
|
|
|
{
|
|
|
|
addAction(action);
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
public slots:
|
|
|
|
void retranslate() {
|
|
|
|
setTitle(qApp->translate("MainWindow", _text));
|
|
|
|
}
|
2013-11-21 16:32:46 +00:00
|
|
|
private:
|
2014-02-15 09:47:14 +00:00
|
|
|
const char *_text;
|
2013-11-21 16:32:46 +00:00
|
|
|
};
|