Changeset ac76a6a753 in tspsg for src


Ignore:
Timestamp:
Sep 2, 2010, 3:48:11 PM (14 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
Children:
7cd6da5021
Parents:
e26679937d
git-author:
Oleksii Serdiuk <contacts@…> (09/02/10 15:48:11)
git-committer:
Oleksii Serdiuk <contacts@…> (06/29/12 19:45:57)
Message:

+ Added an option to remember last used directory when saving and opening.

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/defaults.h

    re26679937d rac76a6a753  
    3636//! Default for "Automatically resize rows and columns to their contents"
    3737#define DEF_AUTOSIZE true
     38//! Default for "Remember last used directories"
     39#define DEF_SAVE_LAST_USED true
    3840/*!
    3941 * \def DEF_USE_NATIVE_DIALOGS
  • src/mainwindow.cpp

    re26679937d rac76a6a753  
    158158        filters.append(tr("All Files") + " (*)");
    159159
    160 QString file = QFileInfo(fileName).canonicalPath();
     160QString file;
     161        if ((fileName == tr("Untitled") + ".tspt") && settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool())
     162                file = settings->value("LastUsed/TaskLoadPath").toString();
     163        else
     164                file = QFileInfo(fileName).path();
    161165QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog;
    162166        file = QFileDialog::getOpenFileName(this, tr("Task Load"), file, filters.join(";;"), NULL, opts);
    163167        if (file.isEmpty() || !QFileInfo(file).isFile())
    164168                return;
     169        if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool())
     170                settings->setValue("LastUsed/TaskLoadPath", QFileInfo(file).path());
     171
    165172        if (!tspmodel->loadTask(file))
    166173                return;
     
    174181bool MainWindow::actionFileSaveTriggered()
    175182{
    176         if ((fileName == tr("Untitled") + ".tspt") || (!fileName.endsWith(".tspt", Qt::CaseInsensitive)))
     183        if ((fileName == tr("Untitled") + ".tspt") || !fileName.endsWith(".tspt", Qt::CaseInsensitive))
    177184                return saveTask();
    178185        else
     
    192199{
    193200static QString selectedFile;
    194         if (selectedFile.isEmpty())
    195                 selectedFile = QFileInfo(fileName).canonicalPath();
    196         else
    197                 selectedFile = QFileInfo(selectedFile).canonicalPath();
     201        if (selectedFile.isEmpty()) {
     202                if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) {
     203                        selectedFile = settings->value("LastUsed/SolutionSavePath").toString();
     204                }
     205        } else
     206                selectedFile = QFileInfo(selectedFile).path();
    198207        if (!selectedFile.isEmpty())
    199                 selectedFile += "/";
     208                selectedFile.append("/");
    200209        if (fileName == tr("Untitled") + ".tspt") {
    201210#ifndef QT_NO_PRINTER
     
    227236                return;
    228237        selectedFile = file;
     238        if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool())
     239                settings->setValue("LastUsed/SolutionSavePath", QFileInfo(selectedFile).path());
    229240        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    230241#ifndef QT_NO_PRINTER
     
    14321443        filters.append(tr("All Files") + " (*)");
    14331444QString file;
    1434         if (fileName.endsWith(".tspt", Qt::CaseInsensitive))
     1445        if ((fileName == tr("Untitled") + ".tspt") && settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) {
     1446                file = settings->value("LastUsed/TaskSavePath").toString();
     1447                if (!file.isEmpty())
     1448                        file.append("/");
     1449                file.append(fileName);
     1450        } else if (fileName.endsWith(".tspt", Qt::CaseInsensitive))
    14351451                file = fileName;
    14361452        else
    1437                 file = QFileInfo(fileName).canonicalPath() + "/" + QFileInfo(fileName).completeBaseName() + ".tspt";
     1453                file = QFileInfo(fileName).path() + "/" + QFileInfo(fileName).completeBaseName() + ".tspt";
    14381454
    14391455QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog;
    14401456        file = QFileDialog::getSaveFileName(this, tr("Task Save"), file, filters.join(";;"), NULL, opts);
    1441 
    14421457        if (file.isEmpty())
    14431458                return false;
     1459        else if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool())
     1460                settings->setValue("LastUsed/TaskSavePath", QFileInfo(file).path());
     1461
    14441462        if (tspmodel->saveTask(file)) {
    14451463                setFileName(file);
  • src/settingsdialog.cpp

    re26679937d rac76a6a753  
    200200
    201201        cbAutosize->setChecked(settings->value("Autosize", DEF_AUTOSIZE).toBool());
     202        cbSaveLastUsed->setChecked(settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool());
    202203        cbUseNativeDialogs->setChecked(settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool());
    203204#ifdef Q_OS_WIN32
     
    310311                        return;
    311312        }
    312 #ifndef HANDHELD
    313         settings->setValue("SavePos", cbSaveState->isChecked());
    314 #endif // HANDHELD
     313        settings->setValue("Autosize", cbAutosize->isChecked());
     314        settings->setValue("SaveLastUsed", cbSaveLastUsed->isChecked());
     315        settings->setValue("UseNativeDialogs", cbUseNativeDialogs->isChecked());
    315316#ifdef Q_OS_WIN32
    316317        if (QtWin::isCompositionEnabled()) {
     
    323324        }
    324325#endif // Q_OS_WIN32
    325         settings->setValue("Autosize", cbAutosize->isChecked());
    326         settings->setValue("UseNativeDialogs", cbUseNativeDialogs->isChecked());
     326#ifndef HANDHELD
     327        settings->setValue("SavePos", cbSaveState->isChecked());
     328#endif // HANDHELD
    327329
    328330        settings->beginGroup("Task");
Note: See TracChangeset for help on using the changeset viewer.