mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 17:25:13 +03:00
Profile date is now type safe. Semi working, not complete yet.
This commit is contained in:
parent
acbe17e4bc
commit
fdc9873ab8
5 changed files with 396 additions and 264 deletions
|
@ -90,23 +90,23 @@ MainWindow::MainWindow():
|
|||
mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
setCentralWidget(mdiArea);
|
||||
connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),
|
||||
this, SLOT(updateMenus()));
|
||||
connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(updateMenus()));
|
||||
windowMapper = new QSignalMapper(this);
|
||||
connect(windowMapper, SIGNAL(mapped(QWidget*)),
|
||||
this, SLOT(setActiveSubWindow(QWidget*)));
|
||||
connect(windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(setActiveSubWindow(QWidget*)));
|
||||
|
||||
MaxRecentFiles=MAX_RECENT;
|
||||
QSettings settings;
|
||||
|
||||
restoreGeometry(settings.value("mainWindowGeometry").toByteArray());
|
||||
createActions();
|
||||
|
||||
createMenus();
|
||||
createToolBars();
|
||||
createStatusBar();
|
||||
updateMenus();
|
||||
readSettings();
|
||||
|
||||
restoreState(glob.mainWindowState());
|
||||
|
||||
if (glob.profileId() == 0)
|
||||
{
|
||||
createProfile();
|
||||
glob.profileId( 1 );
|
||||
}
|
||||
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
this->setWindowIcon(QIcon(":/icon.png"));
|
||||
|
@ -116,7 +116,7 @@ MainWindow::MainWindow():
|
|||
|
||||
// give time to the splash to disappear and main window to open before starting updates
|
||||
int updateDelay = 1000;
|
||||
bool showSplash = settings.value("show_splash", true).toBool();
|
||||
bool showSplash = glob.show_splash();
|
||||
if (showSplash) {
|
||||
updateDelay += (SPLASH_TIME*1000);
|
||||
}
|
||||
|
@ -169,8 +169,7 @@ MainWindow::MainWindow():
|
|||
|
||||
void MainWindow::displayWarnings()
|
||||
{
|
||||
QSettings settings;
|
||||
int warnId=settings.value("warningId", 0 ).toInt();
|
||||
int warnId=glob.warningId();
|
||||
if (warnId<WARNING_ID && warnId!=0) {
|
||||
int res=0;
|
||||
if (WARNING_LEVEL>0) {
|
||||
|
@ -181,10 +180,10 @@ void MainWindow::displayWarnings()
|
|||
res = QMessageBox::question(this, "Companion",tr("Display previous message again at startup ?"),QMessageBox::Yes | QMessageBox::No);
|
||||
}
|
||||
if (res == QMessageBox::No) {
|
||||
settings.setValue("warningId", WARNING_ID);
|
||||
glob.warningId(WARNING_ID);
|
||||
}
|
||||
} else if (warnId==0) {
|
||||
settings.setValue("warningId", WARNING_ID);
|
||||
glob.warningId(WARNING_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,12 +202,11 @@ void MainWindow::checkForUpdates(bool ignoreSettings, QString & fwId)
|
|||
showcheckForUpdatesResult = ignoreSettings;
|
||||
check1done = true;
|
||||
check2done = true;
|
||||
QSettings settings;
|
||||
fwToUpdate = fwId;
|
||||
QString stamp = GetFirmware(fwToUpdate)->stamp;
|
||||
|
||||
if (!stamp.isEmpty()) {
|
||||
if (checkFW || ignoreSettings) {
|
||||
if (glob.startup_check_fw() || ignoreSettings) {
|
||||
check1done=false;
|
||||
manager1 = new QNetworkAccessManager(this);
|
||||
connect(manager1, SIGNAL(finished(QNetworkReply*)), this, SLOT(reply1Finished(QNetworkReply*)));
|
||||
|
@ -219,7 +217,7 @@ void MainWindow::checkForUpdates(bool ignoreSettings, QString & fwId)
|
|||
}
|
||||
}
|
||||
|
||||
if (checkCompanion || ignoreSettings) {
|
||||
if (glob.startup_check_companion() || ignoreSettings) {
|
||||
check2done = false;
|
||||
manager2 = new QNetworkAccessManager(this);
|
||||
connect(manager2, SIGNAL(finished(QNetworkReply*)),this, SLOT(checkForUpdateFinished(QNetworkReply*)));
|
||||
|
@ -269,16 +267,14 @@ void MainWindow::checkForUpdateFinished(QNetworkReply * reply)
|
|||
"Would you like to download it?").arg(version) ,
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
QSettings settings;
|
||||
|
||||
if (ret == QMessageBox::Yes) {
|
||||
#if defined __APPLE__
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastUpdatesDir").toString() + QString(C9X_INSTALLER).arg(version));
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastUpdatesDir() + QString(C9X_INSTALLER).arg(version));
|
||||
#else
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastUpdatesDir").toString() + QString(C9X_INSTALLER).arg(version), tr("Executable (*.exe)"));
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastUpdatesDir() + QString(C9X_INSTALLER).arg(version), tr("Executable (*.exe)"));
|
||||
#endif
|
||||
if (!fileName.isEmpty()) {
|
||||
settings.setValue("lastUpdatesDir", QFileInfo(fileName).dir().absolutePath());
|
||||
glob.lastUpdatesDir(QFileInfo(fileName).dir().absolutePath());
|
||||
downloadDialog * dd = new downloadDialog(this, QString(OPENTX_COMPANION_DOWNLOADS C9X_INSTALLER).arg(version), fileName);
|
||||
installer_fileName = fileName;
|
||||
connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded()));
|
||||
|
@ -311,11 +307,10 @@ void MainWindow::updateDownloaded()
|
|||
void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmwareId)
|
||||
{
|
||||
QString url, ext, cpuid;
|
||||
QSettings settings;
|
||||
url = firmware->getUrl(firmwareId);
|
||||
cpuid=settings.value("cpuid","").toString();
|
||||
cpuid=glob.cpu_id();
|
||||
ext = url.mid(url.lastIndexOf("."));
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastFlashDir").toString() + "/" + firmwareId + ext);
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastFlashDir() + "/" + firmwareId + ext);
|
||||
if (!fileName.isEmpty()) {
|
||||
downloadedFW = firmwareId;
|
||||
needRename=true;
|
||||
|
@ -324,7 +319,7 @@ void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmw
|
|||
url.append("&cpuid=");
|
||||
url.append(cpuid);
|
||||
}
|
||||
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
|
||||
glob.lastFlashDir(QFileInfo(fileName).dir().absolutePath());
|
||||
downloadDialog * dd = new downloadDialog(this, url, fileName);
|
||||
connect(dd, SIGNAL(accepted()), this, SLOT(reply1Accepted()));
|
||||
dd->exec();
|
||||
|
@ -457,7 +452,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
|
|||
}
|
||||
|
||||
QSettings settings;
|
||||
cpuid=settings.value("cpuid","").toString();
|
||||
cpuid=glob.cpu_id();
|
||||
QByteArray qba = reply->readAll();
|
||||
int i = qba.indexOf("SVN_VERS");
|
||||
int warning = qba.indexOf("WARNING");
|
||||
|
@ -471,9 +466,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
|
|||
|
||||
if(!cres) {
|
||||
QMessageBox::warning(this, "Companion", tr("Unable to check for updates."));
|
||||
int server = settings.value("fwserver",0).toInt();
|
||||
server++;
|
||||
settings.setValue("fwserver",server);
|
||||
glob.fwserver(glob.fwserver()+1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -571,12 +564,12 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
|
|||
QString url = GetFirmware(fwToUpdate)->getUrl(fwToUpdate);
|
||||
QString ext = url.mid(url.lastIndexOf("."));
|
||||
needRename=false;
|
||||
bool addversion=settings.value("rename_firmware_files", false).toBool();
|
||||
bool addversion=glob.rename_firmware_files();
|
||||
QString fileName;
|
||||
if (addversion) {
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastFlashDir").toString() + "/" + fwToUpdate + newrev + ext);
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastFlashDir() + "/" + fwToUpdate + newrev + ext);
|
||||
} else {
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastFlashDir").toString() + "/" + fwToUpdate + ext);
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), glob.lastFlashDir() + "/" + fwToUpdate + ext);
|
||||
}
|
||||
if (!fileName.isEmpty()) {
|
||||
if (!cpuid.isEmpty()) {
|
||||
|
@ -584,7 +577,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
|
|||
url.append(cpuid);
|
||||
}
|
||||
downloadedFWFilename = fileName;
|
||||
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
|
||||
glob.lastFlashDir(QFileInfo(fileName).dir().absolutePath());
|
||||
downloadDialog * dd = new downloadDialog(this, url, fileName);
|
||||
currentFWrev_temp = NewFwRev;
|
||||
connect(dd, SIGNAL(accepted()), this, SLOT(reply1Accepted()));
|
||||
|
@ -598,9 +591,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
|
|||
} else {
|
||||
if(check1done && check2done) {
|
||||
QMessageBox::warning(this, "Companion", tr("Unable to check for updates."));
|
||||
int server = settings.value("fwserver",0).toInt();
|
||||
server++;
|
||||
settings.setValue("fwserver",server);
|
||||
glob.fwserver(glob.fwserver()+1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -608,9 +599,8 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
|
|||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("mainWindowGeometry", saveGeometry());
|
||||
settings.setValue("mainWindowState", saveState());
|
||||
glob.mainWindowGeometry(saveGeometry());
|
||||
glob.mainWindowState(saveState());
|
||||
mdiArea->closeAllSubWindows();
|
||||
if (mdiArea->currentSubWindow()) {
|
||||
event->ignore();
|
||||
|
@ -622,8 +612,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
|
||||
void MainWindow::setLanguage(QString langString)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("locale", langString );
|
||||
glob.locale( langString );
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("The selected language will be used the next time you start Companion."));
|
||||
|
@ -634,8 +623,7 @@ void MainWindow::setLanguage(QString langString)
|
|||
|
||||
void MainWindow::setTheme(int index)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("theme", index );
|
||||
glob.theme( index );
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("The new theme will be loaded the next time you start Companion."));
|
||||
|
@ -646,8 +634,7 @@ void MainWindow::setTheme(int index)
|
|||
|
||||
void MainWindow::setIconThemeSize(int index)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("icon_size", index );
|
||||
glob.icon_size( index );
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("The icon size will be used the next time you start Companion."));
|
||||
|
@ -671,10 +658,9 @@ void MainWindow::openDocURL()
|
|||
|
||||
void MainWindow::openFile()
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER));
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), glob.lastDir(), tr(EEPROM_FILES_FILTER));
|
||||
if (!fileName.isEmpty()) {
|
||||
settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
|
||||
glob.lastDir(QFileInfo(fileName).dir().absolutePath());
|
||||
|
||||
QMdiSubWindow *existing = findMdiChild(fileName);
|
||||
if (existing) {
|
||||
|
@ -704,11 +690,9 @@ void MainWindow::saveAs()
|
|||
|
||||
void MainWindow::openRecentFile()
|
||||
{
|
||||
QSettings settings;
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
if (action) {
|
||||
QString fileName=action->data().toString();
|
||||
// settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
|
||||
|
||||
QMdiSubWindow *existing = findMdiChild(fileName);
|
||||
if (existing) {
|
||||
|
@ -1113,14 +1097,14 @@ void MainWindow::writeFileToEeprom()
|
|||
burnDialog *cd = new burnDialog(this, 1, &fileName, &backup);
|
||||
cd->exec();
|
||||
if (!fileName.isEmpty()) {
|
||||
settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
|
||||
glob.lastDir(QFileInfo(fileName).dir().absolutePath());
|
||||
int ret = QMessageBox::question(this, "Companion", tr("Write Models and settings from %1 to the Tx?").arg(QFileInfo(fileName).fileName()), QMessageBox::Yes | QMessageBox::No);
|
||||
if (ret != QMessageBox::Yes) return;
|
||||
if (!isValidEEPROM(fileName))
|
||||
ret = QMessageBox::question(this, "Companion", tr("The file %1\nhas not been recognized as a valid Models and Settings file\nWrite anyway ?").arg(QFileInfo(fileName).fileName()), QMessageBox::Yes | QMessageBox::No);
|
||||
if (ret != QMessageBox::Yes) return;
|
||||
bool backupEnable = settings.value("backupEnable", true).toBool();
|
||||
QString backupPath = settings.value("backupPath", "").toString();
|
||||
bool backupEnable = glob.backupEnable();
|
||||
QString backupPath = glob.backupPath();
|
||||
if (!backupPath.isEmpty()) {
|
||||
if (!QDir(backupPath).exists()) {
|
||||
if (backupEnable) {
|
||||
|
@ -1361,9 +1345,8 @@ bool MainWindow::convertEEPROM(QString backupFile, QString restoreFile, QString
|
|||
|
||||
void MainWindow::writeFlash(QString fileToFlash)
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName;
|
||||
bool backup = settings.value("backupOnFlash", false).toBool();
|
||||
bool backup = glob.backupOnFlash();
|
||||
if(!fileToFlash.isEmpty())
|
||||
fileName = fileToFlash;
|
||||
burnDialog *cd = new burnDialog(this, 2, &fileName, &backup);
|
||||
|
@ -1371,12 +1354,12 @@ void MainWindow::writeFlash(QString fileToFlash)
|
|||
if (IS_TARANIS(GetEepromInterface()->getBoard()))
|
||||
backup=false;
|
||||
if (!fileName.isEmpty()) {
|
||||
settings.setValue("backupOnFlash", backup);
|
||||
glob.backupOnFlash(backup);
|
||||
if (backup) {
|
||||
QString tempDir = QDir::tempPath();
|
||||
QString backupFile = tempDir + "/backup.bin";
|
||||
bool backupEnable=settings.value("backupEnable", true).toBool();
|
||||
QString backupPath=settings.value("backupPath", "").toString();
|
||||
bool backupEnable=glob.backupEnable();
|
||||
QString backupPath=glob.backupPath();
|
||||
if (!backupPath.isEmpty() && !IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||
if (!QDir(backupPath).exists()) {
|
||||
if (backupEnable) {
|
||||
|
@ -1430,8 +1413,8 @@ void MainWindow::writeFlash(QString fileToFlash)
|
|||
}
|
||||
}
|
||||
else {
|
||||
bool backupEnable=settings.value("backupEnable", true).toBool();
|
||||
QString backupPath=settings.value("backupPath", "").toString();
|
||||
bool backupEnable=glob.backupEnable();
|
||||
QString backupPath=glob.backupPath();
|
||||
if (!QDir(backupPath).exists()) {
|
||||
if (backupEnable) {
|
||||
QMessageBox::warning(this, tr("Backup is impossible"), tr("The backup dir set in preferences does not exist"));
|
||||
|
@ -1460,8 +1443,7 @@ void MainWindow::writeFlash(QString fileToFlash)
|
|||
|
||||
void MainWindow::readEepromToFile()
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save transmitter Models and Settings to File"), settings.value("lastDir").toString(), tr(EXTERNAL_EEPROM_FILES_FILTER));
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save transmitter Models and Settings to File"), glob.lastDir(), tr(EXTERNAL_EEPROM_FILES_FILTER));
|
||||
if (!fileName.isEmpty()) {
|
||||
EEPROMInterface *eepromInterface = GetEepromInterface();
|
||||
if (IS_TARANIS(eepromInterface->getBoard())) {
|
||||
|
@ -1480,7 +1462,7 @@ void MainWindow::readEepromToFile()
|
|||
}
|
||||
}
|
||||
else {
|
||||
settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
|
||||
glob.lastDir(QFileInfo(fileName).dir().absolutePath());
|
||||
QStringList str = GetReceiveEEpromCommand(fileName);
|
||||
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Read Models and Settings From Tx"));
|
||||
ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
|
||||
|
@ -1492,14 +1474,13 @@ void MainWindow::readEepromToFile()
|
|||
|
||||
void MainWindow::readFlash()
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName = QFileDialog::getSaveFileName(this,tr("Read Tx Firmware to File"), settings.value("lastFlashDir").toString(),tr(FLASH_FILES_FILTER));
|
||||
QString fileName = QFileDialog::getSaveFileName(this,tr("Read Tx Firmware to File"), glob.lastFlashDir(),tr(FLASH_FILES_FILTER));
|
||||
if (!fileName.isEmpty()) {
|
||||
QFile file(fileName);
|
||||
if (file.exists()) {
|
||||
file.remove();
|
||||
}
|
||||
settings.setValue("lastFlashDir",QFileInfo(fileName).dir().absolutePath());
|
||||
glob.lastFlashDir(QFileInfo(fileName).dir().absolutePath());
|
||||
QStringList str = GetReceiveFlashCommand(fileName);
|
||||
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Read Firmware From Tx");
|
||||
ad->setWindowIcon(CompanionIcon("read_flash.png"));
|
||||
|
@ -1578,8 +1559,7 @@ void MainWindow::updateMenus()
|
|||
updateIconSizeActions();
|
||||
updateIconThemeActions();
|
||||
|
||||
QSettings settings;
|
||||
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg(settings.value("profileId").toString()));
|
||||
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg( QString("%1").arg(glob.profileId()) ));
|
||||
}
|
||||
|
||||
MdiChild *MainWindow::createMdiChild()
|
||||
|
@ -1630,7 +1610,7 @@ void MainWindow::createActions()
|
|||
separatorAct = new QAction(this);
|
||||
separatorAct->setSeparator(true);
|
||||
|
||||
for (int i = 0; i < MaxRecentFiles; ++i) {
|
||||
for (int i = 0; i < MAX_RECENT; ++i) {
|
||||
recentFileActs[i] = new QAction(this);
|
||||
recentFileActs[i]->setVisible(false);
|
||||
connect(recentFileActs[i], SIGNAL(triggered()), this, SLOT(openRecentFile()));
|
||||
|
@ -1728,7 +1708,7 @@ void MainWindow::createMenus()
|
|||
fileMenu->addAction(saveAsAct);
|
||||
fileMenu->addMenu(recentFileMenu);
|
||||
recentFileMenu->setIcon(CompanionIcon("recentdocument.png"));
|
||||
for (int i=0; i<MaxRecentFiles; ++i)
|
||||
for (int i=0; i<MAX_RECENT; ++i)
|
||||
recentFileMenu->addAction(recentFileActs[i]);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(logsAct);
|
||||
|
@ -1810,7 +1790,7 @@ void MainWindow::createMenus()
|
|||
QMenu *MainWindow::createRecentFileMenu()
|
||||
{
|
||||
QMenu *recentFileMenu = new QMenu(this);
|
||||
for ( int i = 0; i < MaxRecentFiles; ++i)
|
||||
for ( int i = 0; i < MAX_RECENT; ++i)
|
||||
recentFileMenu->addAction(recentFileActs[i]);
|
||||
return recentFileMenu;
|
||||
}
|
||||
|
@ -1831,10 +1811,8 @@ QMenu *MainWindow::createProfilesMenu()
|
|||
|
||||
void MainWindow::createToolBars()
|
||||
{
|
||||
QSettings settings;
|
||||
int icon_size=settings.value("icon_size",2 ).toInt();
|
||||
QSize size;
|
||||
switch(icon_size) {
|
||||
switch(glob.icon_size()) {
|
||||
case 0:
|
||||
size=QSize(16,16);
|
||||
break;
|
||||
|
@ -1919,20 +1897,6 @@ void MainWindow::createStatusBar()
|
|||
statusBar()->showMessage(tr("Ready"));
|
||||
}
|
||||
|
||||
void MainWindow::readSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
restoreState(settings.value("mainWindowState").toByteArray());
|
||||
checkCompanion = settings.value("startup_check_companion", true).toBool();
|
||||
checkFW = settings.value("startup_check_fw", true).toBool();
|
||||
MaxRecentFiles =settings.value("history_size",10).toInt();
|
||||
if (settings.value("profileId",0).toInt() == 0)
|
||||
{
|
||||
createProfile();
|
||||
settings.setValue("profileId", "1");
|
||||
}
|
||||
}
|
||||
|
||||
MdiChild *MainWindow::activeMdiChild()
|
||||
{
|
||||
if (QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow())
|
||||
|
@ -1965,7 +1929,7 @@ void MainWindow::updateRecentFileActions()
|
|||
QSettings settings;
|
||||
QStringList files = settings.value("recentFileList").toStringList();
|
||||
|
||||
numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
|
||||
numRecentFiles = qMin(files.size(), glob.history_size());
|
||||
|
||||
for ( i = 0; i < numRecentFiles; ++i) {
|
||||
QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
|
||||
|
@ -1973,15 +1937,14 @@ void MainWindow::updateRecentFileActions()
|
|||
recentFileActs[i]->setData(files[i]);
|
||||
recentFileActs[i]->setVisible(true);
|
||||
}
|
||||
for ( j = numRecentFiles; j < MaxRecentFiles; ++j)
|
||||
for ( j = numRecentFiles; j < glob.history_size(); ++j)
|
||||
recentFileActs[j]->setVisible(false);
|
||||
}
|
||||
|
||||
void MainWindow::updateIconSizeActions()
|
||||
{
|
||||
QSettings settings;
|
||||
int size = settings.value("icon_size","0").toInt();
|
||||
switch (size){
|
||||
switch (glob.icon_size())
|
||||
{
|
||||
case 0: smallIconAct->setChecked(true); break;
|
||||
case 1: normalIconAct->setChecked(true); break;
|
||||
case 2: bigIconAct->setChecked(true); break;
|
||||
|
@ -1991,8 +1954,7 @@ void MainWindow::updateIconSizeActions()
|
|||
|
||||
void MainWindow::updateLanguageActions()
|
||||
{
|
||||
QSettings settings;
|
||||
QString langId = settings.value("locale","").toString();
|
||||
QString langId = glob.locale();
|
||||
|
||||
if (langId=="")
|
||||
sysLangAct->setChecked(true);
|
||||
|
@ -2022,9 +1984,8 @@ void MainWindow::updateLanguageActions()
|
|||
|
||||
void MainWindow::updateIconThemeActions()
|
||||
{
|
||||
QSettings settings;
|
||||
int size = settings.value("theme","1").toInt();
|
||||
switch (size){
|
||||
switch (glob.theme())
|
||||
{
|
||||
case 0: classicThemeAct->setChecked(true); break;
|
||||
case 1: newThemeAct->setChecked(true); break;
|
||||
case 2: monoWhiteAct->setChecked(true); break;
|
||||
|
@ -2037,7 +1998,7 @@ void MainWindow::updateProfilesActions()
|
|||
{
|
||||
int i;
|
||||
QSettings settings;
|
||||
int activeProfile = settings.value("profileId").toInt();
|
||||
int activeProfile = glob.profileId();
|
||||
|
||||
settings.beginGroup("Profiles");
|
||||
for (i=0; i<MAX_PROFILES; i++) {
|
||||
|
@ -2182,8 +2143,7 @@ void MainWindow::dropEvent(QDropEvent *event)
|
|||
QString fileName = urls.first().toLocalFile();
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
QSettings settings;
|
||||
settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
|
||||
glob.lastDir(QFileInfo(fileName).dir().absolutePath());
|
||||
|
||||
QMdiSubWindow *existing = findMdiChild(fileName);
|
||||
if (existing) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue