From d4c0676c9089fed06697ab1abee6e54c0f96dbea Mon Sep 17 00:00:00 2001 From: nowrep Date: Tue, 27 Dec 2011 15:26:32 +0100 Subject: [PATCH] Fixed availability to delete profile in Preferences. - it is now available only on non-active profile - also moved browsedata.db + profiles.ini from data/ folder into binary --- src/app/mainapplication.cpp | 14 ++++++---- src/app/profileupdater.cpp | 6 ++--- src/app/profileupdater.h | 4 +-- src/data/data.qrc | 6 +++++ .../default => src/data/data}/browsedata.db | Bin 20480 -> 20480 bytes .../profiles => src/data/data}/profiles.ini | 0 src/main.cpp | 1 + src/preferences/preferences.cpp | 17 ++++++++++--- src/preferences/preferences.ui | 24 ++++++++++++++---- src/src.pro | 4 +-- 10 files changed, 54 insertions(+), 22 deletions(-) create mode 100644 src/data/data.qrc rename {bin/data/default/profiles/default => src/data/data}/browsedata.db (99%) rename {bin/data/default/profiles => src/data/data}/profiles.ini (100%) diff --git a/src/app/mainapplication.cpp b/src/app/mainapplication.cpp index 110252608..69d239438 100644 --- a/src/app/mainapplication.cpp +++ b/src/app/mainapplication.cpp @@ -154,7 +154,7 @@ MainApplication::MainApplication(const QList &cm m_activeProfil = homePath + "profiles/" + startProfile + "/"; } - ProfileUpdater u(m_activeProfil, DATADIR); + ProfileUpdater u(m_activeProfil); u.checkProfile(); connectDatabase(); @@ -430,7 +430,9 @@ void MainApplication::connectDatabase() QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(m_activeProfil + "browsedata.db"); if (!QFile::exists(m_activeProfil + "browsedata.db")) { - QFile(DATADIR + "data/default/profiles/default/browsedata.db").copy(m_activeProfil + "browsedata.db"); + QFile(":data/browsedata.db").copy(m_activeProfil + "browsedata.db"); + QFile(m_activeProfil + "browsedata.db").setPermissions(QFile::ReadUser | QFile::WriteUser); + db.setDatabaseName(m_activeProfil + "browsedata.db"); qWarning("Cannot find SQLite database file! Copying and using the defaults!"); } @@ -454,7 +456,7 @@ void MainApplication::translateApp() } QTranslator* app = new QTranslator(); - app->load(DATADIR + "locale/" + file); + app->load(TRANSLATIONSDIR + file); QTranslator* sys = new QTranslator(); if (QFile::exists(TRANSLATIONSDIR + "qt_" + shortLoc + ".qm")) { @@ -766,14 +768,16 @@ bool MainApplication::checkSettingsDir() //.qupzilla/profiles QFile(homePath + "profiles/profiles.ini").remove(); - QFile(DATADIR + "data/default/profiles/profiles.ini").copy(homePath + "profiles/profiles.ini"); + QFile(":data/profiles.ini").copy(homePath + "profiles/profiles.ini"); + QFile(homePath + "profiles/profiles.ini").setPermissions(QFile::ReadUser | QFile::WriteUser); dir.mkdir("default"); dir.cd("default"); //.qupzilla/profiles/default QFile(homePath + "profiles/default/browsedata.db").remove(); - QFile(DATADIR + "data/default/profiles/default/browsedata.db").copy(homePath + "profiles/default/browsedata.db"); + QFile(":data/browsedata.db").copy(homePath + "profiles/default/browsedata.db"); + QFile(homePath + "profiles/default/browsedata.db").setPermissions(QFile::ReadUser | QFile::WriteUser); return dir.isReadable(); } diff --git a/src/app/profileupdater.cpp b/src/app/profileupdater.cpp index 7eb6eae6a..7731eb78c 100644 --- a/src/app/profileupdater.cpp +++ b/src/app/profileupdater.cpp @@ -20,10 +20,9 @@ #include "updater.h" #include "mainapplication.h" -ProfileUpdater::ProfileUpdater(const QString &profilePath, const QString &dataPath) +ProfileUpdater::ProfileUpdater(const QString &profilePath) : QObject() , m_profilePath(profilePath) - , m_dataPath(dataPath) { } @@ -93,7 +92,8 @@ void ProfileUpdater::copyDataToProfile() profileDir.mkdir("certificates"); QFile(m_profilePath + "browsedata.db").remove(); - QFile(m_dataPath + "data/default/profiles/default/browsedata.db").copy(m_profilePath + "browsedata.db"); + QFile(":data/browsedata.db").copy(m_profilePath + "browsedata.db"); + QFile(m_profilePath + "browsedata.db").setPermissions(QFile::ReadUser | QFile::WriteUser); } void ProfileUpdater::update100b4() diff --git a/src/app/profileupdater.h b/src/app/profileupdater.h index e5c183350..36d2b5703 100644 --- a/src/app/profileupdater.h +++ b/src/app/profileupdater.h @@ -26,7 +26,7 @@ class ProfileUpdater : public QObject { Q_OBJECT public: - explicit ProfileUpdater(const QString &profilePath, const QString &dataPath); + explicit ProfileUpdater(const QString &profilePath); void checkProfile(); signals: @@ -42,8 +42,6 @@ private: void update100(); QString m_profilePath; - QString m_dataPath; - }; #endif // PROFILEUPDATER_H diff --git a/src/data/data.qrc b/src/data/data.qrc new file mode 100644 index 000000000..1ec12063e --- /dev/null +++ b/src/data/data.qrc @@ -0,0 +1,6 @@ + + + data/browsedata.db + data/profiles.ini + + diff --git a/bin/data/default/profiles/default/browsedata.db b/src/data/data/browsedata.db similarity index 99% rename from bin/data/default/profiles/default/browsedata.db rename to src/data/data/browsedata.db index 8b42d2d50a3c3f3349ebba8a5c174a8e112e9bf3..6255c48c11fd78a11b780d12f85283b9d2ba66cd 100644 GIT binary patch delta 35 jcmZozz}T>Wae}lU8v_G_2oOU7Q`JNrV@9@(2@CuIbTkHx delta 35 jcmZozz}T>Wae}lUD+2?A2oOU7Q{_Y*V@B4E2@CuIbPEQF diff --git a/bin/data/default/profiles/profiles.ini b/src/data/data/profiles.ini similarity index 100% rename from bin/data/default/profiles/profiles.ini rename to src/data/data/profiles.ini diff --git a/src/main.cpp b/src/main.cpp index e9b4df755..28f9a1836 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,7 @@ int main(int argc, char* argv[]) { + Q_INIT_RESOURCE(data); Q_INIT_RESOURCE(icons); Q_INIT_RESOURCE(html); diff --git a/src/preferences/preferences.cpp b/src/preferences/preferences.cpp index f136405af..efb1b0a2f 100644 --- a/src/preferences/preferences.cpp +++ b/src/preferences/preferences.cpp @@ -143,16 +143,23 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) connect(ui->newTabUseActual, SIGNAL(clicked()), this, SLOT(useActualNewTab())); //PROFILES + m_actProfileName = mApp->getActiveProfilPath(); + m_actProfileName = m_actProfileName.left(m_actProfileName.length()-1); + m_actProfileName = m_actProfileName.mid(m_actProfileName.lastIndexOf("/")); + m_actProfileName.remove("/"); + + ui->activeProfile->setText("" + m_actProfileName + ""); + QString homePath = QDir::homePath(); homePath += "/.qupzilla/"; QSettings profileSettings(homePath + "profiles/profiles.ini", QSettings::IniFormat); - m_actProfileName = profileSettings.value("Profiles/startProfile", "default").toString(); + QString actProfileName = profileSettings.value("Profiles/startProfile", "default").toString(); - ui->startProfile->addItem(m_actProfileName); + ui->startProfile->addItem(actProfileName); QDir profilesDir(QDir::homePath() + "/.qupzilla/profiles/"); QStringList list_ = profilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); foreach(QString name, list_) { - if (m_actProfileName == name) { + if (actProfileName == name) { continue; } ui->startProfile->addItem(name); @@ -160,6 +167,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) 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))); + startProfileIndexChanged(ui->startProfile->currentText()); //APPEREANCE m_themesManager = new ThemeManager(ui->themesWidget); @@ -583,7 +591,8 @@ void Preferences::createProfile() return; } dir.cd(name); - QFile(mApp->DATADIR + "data/default/profiles/default/browsedata.db").copy(dir.absolutePath() + "/browsedata.db"); + QFile(":data/browsedata.db").copy(dir.absolutePath() + "/browsedata.db"); + QFile(dir.absolutePath() + "/browsedata.db").setPermissions(QFile::ReadUser | QFile::WriteUser); ui->startProfile->insertItem(0, name); ui->startProfile->setCurrentIndex(0); diff --git a/src/preferences/preferences.ui b/src/preferences/preferences.ui index 7e46a3d25..f5dc1da6f 100644 --- a/src/preferences/preferences.ui +++ b/src/preferences/preferences.ui @@ -303,17 +303,17 @@ - + Startup profile: - + - + QFrame::NoFrame @@ -379,7 +379,7 @@ - + Qt::Vertical @@ -427,7 +427,7 @@ - + Note: You cannot delete active profile. @@ -444,6 +444,20 @@ + + + + Active profile: + + + + + + + + + + diff --git a/src/src.pro b/src/src.pro index b5d2a02d9..4d7bc16a4 100644 --- a/src/src.pro +++ b/src/src.pro @@ -346,7 +346,8 @@ FORMS += \ RESOURCES += \ data/icons.qrc \ - data/html.qrc + data/html.qrc \ + data/data.qrc OTHER_FILES += \ appicon.rc @@ -373,7 +374,6 @@ unix { target.path = $$binary_folder - target1.files = ../bin/data target1.files += ../bin/locale target1.files += ../bin/plugins target1.files += ../bin/themes