diff --git a/src/app/qupzilla.cpp b/src/app/qupzilla.cpp index cd4fe3f09..d67927462 100644 --- a/src/app/qupzilla.cpp +++ b/src/app/qupzilla.cpp @@ -48,11 +48,8 @@ #include "clickablelabel.h" const QString QupZilla::VERSION = "0.9.9"; -#ifdef Q_WS_X11 -const QString QupZilla::BUILDTIME = QLocale(QLocale::English).toDateTime(__DATE__" "__TIME__, "MMM dd yyyy hh:mm:ss").toString("MM/dd/yyyy hh:ss"); -#else -const QString QupZilla::BUILDTIME = __DATE__" "__TIME__; -#endif +//const QString QupZilla::BUILDTIME = QLocale(QLocale::English).toDateTime(__DATE__" "__TIME__, "MMM d yyyy hh:mm:ss").toString("MM/dd/yyyy hh:ss"); +const QString QupZilla::BUILDTIME = __DATE__" "__TIME__; const QString QupZilla::AUTHOR = "nowrep"; const QString QupZilla::COPYRIGHT = "2010-2011"; const QString QupZilla::WWWADDRESS = "http://qupzilla.ic.cz"; diff --git a/src/other/aboutdialog.cpp b/src/other/aboutdialog.cpp index c4b1ef933..70cbde277 100644 --- a/src/other/aboutdialog.cpp +++ b/src/other/aboutdialog.cpp @@ -49,7 +49,7 @@ void AboutDialog::showAbout() m_aboutHtml.append(tr("
Application version %1
").arg(QupZilla::VERSION));
m_aboutHtml.append(tr("WebKit version %1
© %1 %2
All rights reserved.
").arg(QupZilla::COPYRIGHT, QupZilla::AUTHOR));
- m_aboutHtml.append(tr("Build time: %1
"+mApp->getWindow()->weView()->webPage()->userAgentForUrl(QUrl())+"
"); m_aboutHtml.append(""); diff --git a/src/preferences/preferences.cpp b/src/preferences/preferences.cpp index ce155048f..7fcbb4072 100644 --- a/src/preferences/preferences.cpp +++ b/src/preferences/preferences.cpp @@ -31,6 +31,35 @@ #include "pluginproxy.h" #include "sslmanager.h" +bool removeFile(QString fullFileName) +{ + QFile f(fullFileName); + if (f.exists()) + return f.remove(); + else return false; +} + +void removeDir(const QString d) +{ + QDir dir(d); + if (dir.exists()) + { + const QFileInfoList list = dir.entryInfoList(); + QFileInfo fi; + for (int l = 0; l < list.size(); l++) + { + fi = list.at(l); + if (fi.isDir() && fi.fileName() != "." && fi.fileName() != "..") + removeDir(fi.absoluteFilePath()); + else if (fi.isFile()) + removeFile(fi.absoluteFilePath()); + + } + dir.rmdir(d); + + } +} + Preferences::Preferences(QupZilla* mainClass, QWidget* parent) : QDialog(parent) ,ui(new Ui::Preferences) @@ -48,6 +77,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) : ui->homepage->setText(m_homepage); ui->newTabUrl->setText(m_newTabUrl); int afterLaunch = settings.value("afterLaunch",1).toInt(); + settings.endGroup(); ui->afterLaunch->setCurrentIndex(afterLaunch); ui->newTabFrame->setVisible(false); @@ -64,10 +94,21 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) : connect(ui->newTabUseActual, SIGNAL(clicked()), this, SLOT(useActualNewTab())); //PROFILES - ui->startPRofile->setEnabled(false); - ui->createProfile->setEnabled(false); - ui->deleteProfile->setEnabled(false); - settings.endGroup(); + m_actProfileName = mApp->getActiveProfil(); + m_actProfileName = m_actProfileName.left(m_actProfileName.length()-1); + m_actProfileName = m_actProfileName.mid(m_actProfileName.lastIndexOf("/")); + m_actProfileName.remove("/"); + ui->startProfile->addItem(m_actProfileName); + QDir profilesDir(QDir::homePath()+"/.qupzilla/profiles/"); + QStringList list_ = profilesDir.entryList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot); + foreach (QString name, list_) { + if (m_actProfileName == name) + continue; + ui->startProfile->addItem(name); + } + connect(ui->createProfile, SIGNAL(clicked()), this, SLOT(createProfile())); + connect(ui->deleteProfile, SIGNAL(clicked()), this, SLOT(deleteProfile())); + connect(ui->startProfile, SIGNAL(currentIndexChanged(QString)), this, SLOT(startProfileIndexChanged(QString))); //WINDOW settings.beginGroup("Browser-View-Settings"); @@ -388,6 +429,45 @@ void Preferences::buttonClicked(QAbstractButton* button) } } +void Preferences::createProfile() +{ + QString name = QInputDialog::getText(this, tr("New Profile"), tr("Enter the new profile's name:")); + if (name.contains("/") || name.contains("\\")) + return; + QDir dir(QDir::homePath()+"/.qupzilla/profiles/"); + if (QDir(dir.absolutePath() + "/" + name).exists()) { + QMessageBox::warning(this, tr("Error!"), tr("This profile already exists!")); + return; + } + if (!dir.mkdir(name)) { + QMessageBox::warning(this, tr("Error!"), tr("Cannot create profile directory!")); + return; + } + dir.cd(name); + QFile(mApp->DATADIR+"data/default/profiles/default/browsedata.db").copy(dir.absolutePath()+"/browsedata.db"); + QFile(mApp->DATADIR+"data/default/profiles/default/background.png").copy(dir.absolutePath()+"/background.png"); + + ui->startProfile->insertItem(0, name); + ui->startProfile->setCurrentIndex(0); +} + +void Preferences::deleteProfile() +{ + QString name = ui->startProfile->currentText(); + QMessageBox::StandardButton button = QMessageBox::warning(this, tr("Confirmation"), + tr("Are you sure to permanently delete \"%1\" profile? This action cannot be undone!").arg(name), QMessageBox::Yes | QMessageBox::No); + if (button != QMessageBox::Yes) + return; + + removeDir(QDir::homePath()+"/.qupzilla/profiles/"+name); + ui->startProfile->removeItem(ui->startProfile->currentIndex()); +} + +void Preferences::startProfileIndexChanged(QString index) +{ + ui->deleteProfile->setEnabled(m_actProfileName != index); +} + void Preferences::saveSettings() { QSettings settings(mApp->getActiveProfil()+"settings.ini", QSettings::IniFormat); @@ -500,6 +580,12 @@ void Preferences::saveSettings() settings.setValue("language",ui->languages->itemData(ui->languages->currentIndex()).toString()); settings.endGroup(); + //Profiles + QString homePath = QDir::homePath(); + homePath+="/.qupzilla/"; + QSettings profileSettings(homePath+"profiles/profiles.ini", QSettings::IniFormat); + profileSettings.setValue("Profiles/startProfile",ui->startProfile->currentText()); + m_pluginsList->save(); p_QupZilla->loadSettings(); p_QupZilla->tabWidget()->loadSettings(); diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index f887a76a7..aedc0361b 100644 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -65,6 +65,10 @@ private slots: void cacheValueChanged(int value); void pageCacheValueChanged(int value); + void createProfile(); + void deleteProfile(); + void startProfileIndexChanged(QString index); + private: void updateBgLabel(); Ui::Preferences* ui; @@ -75,6 +79,7 @@ private: QColor m_menuTextColor; QString m_homepage; QString m_newTabUrl; + QString m_actProfileName; int m_afterLaunch; int m_onNewTab; QSize m_bgLabelSize; diff --git a/src/preferences/preferences.ui b/src/preferences/preferences.ui index f57ad27b6..ebcc28c2c 100644 --- a/src/preferences/preferences.ui +++ b/src/preferences/preferences.ui @@ -331,13 +331,7 @@