keep recent filenames from being absurdly long in the menu
This commit is contained in:
parent
7e6cf61b4c
commit
284a9b73b0
|
@ -752,7 +752,7 @@ void ScreenHandler::screenOnMouseRelease(QMouseEvent* event)
|
||||||
void ScreenHandler::screenOnMouseMove(QMouseEvent* event)
|
void ScreenHandler::screenOnMouseMove(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
showCursor();
|
showCursor();
|
||||||
|
|
||||||
if (!(event->buttons() & Qt::LeftButton)) return;
|
if (!(event->buttons() & Qt::LeftButton)) return;
|
||||||
|
@ -892,7 +892,7 @@ ScreenPanelGL::ScreenPanelGL(QWidget* parent) : QOpenGLWidget(parent)
|
||||||
ScreenPanelGL::~ScreenPanelGL()
|
ScreenPanelGL::~ScreenPanelGL()
|
||||||
{
|
{
|
||||||
mouseTimer->stop();
|
mouseTimer->stop();
|
||||||
|
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
|
|
||||||
OSD::DeInit(this);
|
OSD::DeInit(this);
|
||||||
|
@ -1134,15 +1134,16 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
||||||
|
|
||||||
actOpenROM = menu->addAction("Open ROM...");
|
actOpenROM = menu->addAction("Open ROM...");
|
||||||
connect(actOpenROM, &QAction::triggered, this, &MainWindow::onOpenFile);
|
connect(actOpenROM, &QAction::triggered, this, &MainWindow::onOpenFile);
|
||||||
|
|
||||||
actOpenROMArchive = menu->addAction("Open ROM inside Archive...");
|
actOpenROMArchive = menu->addAction("Open ROM inside Archive...");
|
||||||
connect(actOpenROMArchive, &QAction::triggered, this, &MainWindow::onOpenFileArchive);
|
connect(actOpenROMArchive, &QAction::triggered, this, &MainWindow::onOpenFileArchive);
|
||||||
|
|
||||||
recentMenu = menu->addMenu("Open Recent");
|
recentMenu = menu->addMenu("Open Recent");
|
||||||
for(int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
if(strlen(Config::RecentROMList[i]) > 0)
|
char* item = Config::RecentROMList[i];
|
||||||
recentFileList.push_back(Config::RecentROMList[i]);
|
if (strlen(item) > 0)
|
||||||
|
recentFileList.push_back(item);
|
||||||
}
|
}
|
||||||
updateRecentFilesMenu();
|
updateRecentFilesMenu();
|
||||||
|
|
||||||
|
@ -1236,7 +1237,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
||||||
|
|
||||||
actWifiSettings = menu->addAction("Wifi settings");
|
actWifiSettings = menu->addAction("Wifi settings");
|
||||||
connect(actWifiSettings, &QAction::triggered, this, &MainWindow::onOpenWifiSettings);
|
connect(actWifiSettings, &QAction::triggered, this, &MainWindow::onOpenWifiSettings);
|
||||||
|
|
||||||
actInterfaceSettings = menu->addAction("Interface settings");
|
actInterfaceSettings = menu->addAction("Interface settings");
|
||||||
connect(actInterfaceSettings, &QAction::triggered, this, &MainWindow::onOpenInterfaceSettings);
|
connect(actInterfaceSettings, &QAction::triggered, this, &MainWindow::onOpenInterfaceSettings);
|
||||||
|
|
||||||
|
@ -1308,7 +1309,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(grpScreenLayout, &QActionGroup::triggered, this, &MainWindow::onChangeScreenLayout);
|
connect(grpScreenLayout, &QActionGroup::triggered, this, &MainWindow::onChangeScreenLayout);
|
||||||
|
|
||||||
submenu->addSeparator();
|
submenu->addSeparator();
|
||||||
|
|
||||||
actScreenSwap = submenu->addAction("Swap screens");
|
actScreenSwap = submenu->addAction("Swap screens");
|
||||||
|
@ -1455,7 +1456,7 @@ void MainWindow::createScreenPanel()
|
||||||
{
|
{
|
||||||
panelGL = new ScreenPanelGL(this);
|
panelGL = new ScreenPanelGL(this);
|
||||||
panelGL->show();
|
panelGL->show();
|
||||||
|
|
||||||
panel = panelGL;
|
panel = panelGL;
|
||||||
panelGL->setMouseTracking(true);
|
panelGL->setMouseTracking(true);
|
||||||
mouseTimer = panelGL->setupMouseTimer();
|
mouseTimer = panelGL->setupMouseTimer();
|
||||||
|
@ -1479,7 +1480,7 @@ void MainWindow::createScreenPanel()
|
||||||
panelNative = new ScreenPanelNative(this);
|
panelNative = new ScreenPanelNative(this);
|
||||||
panel = panelNative;
|
panel = panelNative;
|
||||||
panel->show();
|
panel->show();
|
||||||
|
|
||||||
panelNative->setMouseTracking(true);
|
panelNative->setMouseTracking(true);
|
||||||
mouseTimer = panelNative->setupMouseTimer();
|
mouseTimer = panelNative->setupMouseTimer();
|
||||||
connect(mouseTimer, &QTimer::timeout, [=] { if (Config::MouseHide) panelNative->setCursor(Qt::BlankCursor);});
|
connect(mouseTimer, &QTimer::timeout, [=] { if (Config::MouseHide) panelNative->setCursor(Qt::BlankCursor);});
|
||||||
|
@ -1729,7 +1730,7 @@ void MainWindow::loadROM(QString filename)
|
||||||
recentFileList.removeAll(filename);
|
recentFileList.removeAll(filename);
|
||||||
recentFileList.prepend(filename);
|
recentFileList.prepend(filename);
|
||||||
updateRecentFilesMenu();
|
updateRecentFilesMenu();
|
||||||
|
|
||||||
// TODO: validate the input file!!
|
// TODO: validate the input file!!
|
||||||
// * check that it is a proper ROM
|
// * check that it is a proper ROM
|
||||||
// * ensure the binary offsets are sane
|
// * ensure the binary offsets are sane
|
||||||
|
@ -1881,8 +1882,30 @@ void MainWindow::updateRecentFilesMenu()
|
||||||
|
|
||||||
for(int i = 0; i < recentFileList.size(); ++i)
|
for(int i = 0; i < recentFileList.size(); ++i)
|
||||||
{
|
{
|
||||||
QAction *actRecentFile_i = recentMenu->addAction(QString("%1. %2").arg(i+1).arg(recentFileList.at(i)));
|
QString item_full = recentFileList.at(i);
|
||||||
actRecentFile_i->setData(recentFileList.at(i));
|
QString item_display = item_full;
|
||||||
|
int itemlen = item_full.length();
|
||||||
|
const int maxlen = 100;
|
||||||
|
if (itemlen > maxlen)
|
||||||
|
{
|
||||||
|
int cut_start = 0;
|
||||||
|
while (item_full[cut_start] != '/' && item_full[cut_start] != '\\' &&
|
||||||
|
cut_start < itemlen)
|
||||||
|
cut_start++;
|
||||||
|
|
||||||
|
int cut_end = itemlen-1;
|
||||||
|
while (((item_full[cut_end] != '/' && item_full[cut_end] != '\\') ||
|
||||||
|
(cut_start+4+(itemlen-cut_end) < maxlen)) &&
|
||||||
|
cut_end > 0)
|
||||||
|
cut_end--;
|
||||||
|
|
||||||
|
item_display.truncate(cut_start+1);
|
||||||
|
item_display += "...";
|
||||||
|
item_display += item_full.remove(0, cut_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
QAction *actRecentFile_i = recentMenu->addAction(QString("%1. %2").arg(i+1).arg(item_display));
|
||||||
|
actRecentFile_i->setData(item_full);
|
||||||
connect(actRecentFile_i, &QAction::triggered, this, &MainWindow::onClickRecentFile);
|
connect(actRecentFile_i, &QAction::triggered, this, &MainWindow::onClickRecentFile);
|
||||||
|
|
||||||
if(i < 10)
|
if(i < 10)
|
||||||
|
@ -2440,7 +2463,7 @@ void MainWindow::onUpdateVideoSettings(bool glchange)
|
||||||
{
|
{
|
||||||
emuThread->emuPause();
|
emuThread->emuPause();
|
||||||
|
|
||||||
if (hasOGL)
|
if (hasOGL)
|
||||||
{
|
{
|
||||||
emuThread->deinitOpenGL();
|
emuThread->deinitOpenGL();
|
||||||
delete panelGL;
|
delete panelGL;
|
||||||
|
|
Loading…
Reference in New Issue