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