1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Fixed tab logic

This commit is contained in:
Martin Tůma 2016-03-23 20:56:39 +01:00
parent ac93ccba29
commit 64a343dd2e
2 changed files with 25 additions and 17 deletions

View File

@ -161,7 +161,7 @@ void GUI::createActions()
// General actions // General actions
_exitAction = new QAction(QIcon(QPixmap(QUIT_ICON)), tr("Quit"), this); _exitAction = new QAction(QIcon(QPixmap(QUIT_ICON)), tr("Quit"), this);
_exitAction->setShortcut(QKeySequence::Quit); _exitAction->setShortcut(QKeySequence::Quit);
connect(_exitAction, SIGNAL(triggered()), this, SLOT(close())); connect(_exitAction, SIGNAL(triggered()), this, SLOT(closeAll()));
// Help & About // Help & About
_dataSourcesAction = new QAction(tr("Data sources"), this); _dataSourcesAction = new QAction(tr("Data sources"), this);
@ -193,7 +193,7 @@ void GUI::createActions()
tr("Close"), this); tr("Close"), this);
_closeFileAction->setShortcut(QKeySequence::Close); _closeFileAction->setShortcut(QKeySequence::Close);
_closeFileAction->setActionGroup(_fileActionGroup); _closeFileAction->setActionGroup(_fileActionGroup);
connect(_closeFileAction, SIGNAL(triggered()), this, SLOT(closeFile())); connect(_closeFileAction, SIGNAL(triggered()), this, SLOT(closeAll()));
_reloadFileAction = new QAction(QIcon(QPixmap(RELOAD_FILE_ICON)), _reloadFileAction = new QAction(QIcon(QPixmap(RELOAD_FILE_ICON)),
tr("Reload"), this); tr("Reload"), this);
_reloadFileAction->setShortcut(QKeySequence::Refresh); _reloadFileAction->setShortcut(QKeySequence::Refresh);
@ -464,22 +464,24 @@ void GUI::openFile()
bool GUI::openFile(const QString &fileName) bool GUI::openFile(const QString &fileName)
{ {
bool ret = true;
if (fileName.isEmpty() || _files.contains(fileName)) if (fileName.isEmpty() || _files.contains(fileName))
return false; return false;
if (loadFile(fileName)) { if (loadFile(fileName)) {
_files.append(fileName); _files.append(fileName);
_browser->setCurrent(fileName); _browser->setCurrent(fileName);
updateStatusBarInfo();
_fileActionGroup->setEnabled(true); _fileActionGroup->setEnabled(true);
_navigationActionGroup->setEnabled(true); _navigationActionGroup->setEnabled(true);
} else
ret = false;
updateNavigationActions(); updateNavigationActions();
updateStatusBarInfo();
updateGraphTabs(); updateGraphTabs();
return true;
} else { return ret;
updateNavigationActions();
return false;
}
} }
bool GUI::loadFile(const QString &fileName) bool GUI::loadFile(const QString &fileName)
@ -651,7 +653,7 @@ void GUI::reloadFile()
_browser->setCurrent(_files.last()); _browser->setCurrent(_files.last());
} }
void GUI::closeFile() void GUI::closeFiles()
{ {
_distance = 0; _distance = 0;
_time = 0; _time = 0;
@ -663,6 +665,11 @@ void GUI::closeFile()
_track->clear(); _track->clear();
_files.clear(); _files.clear();
}
void GUI::closeAll()
{
closeFiles();
_track->setEnabled(false); _track->setEnabled(false);
_fileActionGroup->setEnabled(false); _fileActionGroup->setEnabled(false);
@ -807,7 +814,7 @@ void GUI::next()
if (file.isNull()) if (file.isNull())
return; return;
closeFile(); closeFiles();
openFile(file); openFile(file);
} }
@ -817,7 +824,7 @@ void GUI::prev()
if (file.isNull()) if (file.isNull())
return; return;
closeFile(); closeFiles();
openFile(file); openFile(file);
} }
@ -827,7 +834,7 @@ void GUI::last()
if (file.isNull()) if (file.isNull())
return; return;
closeFile(); closeFiles();
openFile(file); openFile(file);
} }
@ -837,7 +844,7 @@ void GUI::first()
if (file.isNull()) if (file.isNull())
return; return;
closeFile(); closeFiles();
openFile(file); openFile(file);
} }
@ -862,7 +869,7 @@ void GUI::keyPressEvent(QKeyEvent *event)
if (!file.isNull()) { if (!file.isNull()) {
if (!(event->modifiers() & MODIFIER)) if (!(event->modifiers() & MODIFIER))
closeFile(); closeFiles();
openFile(file); openFile(file);
} }
} }

View File

@ -37,7 +37,7 @@ private slots:
void saveFile(); void saveFile();
void saveAs(); void saveAs();
void openFile(); void openFile();
void closeFile(); void closeAll();
void reloadFile(); void reloadFile();
void openPOIFile(); void openPOIFile();
void closePOIFiles(); void closePOIFiles();
@ -60,6 +60,7 @@ private slots:
private: private:
void loadFiles(); void loadFiles();
void closeFiles();
QAction *createPOIFileAction(int index); QAction *createPOIFileAction(int index);
void createPOIFilesActions(); void createPOIFilesActions();