1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

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
This commit is contained in:
nowrep 2011-12-27 15:26:32 +01:00
parent ef28d2b00e
commit d4c0676c90
10 changed files with 54 additions and 22 deletions

View File

@ -154,7 +154,7 @@ MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &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();
}

View File

@ -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()

View File

@ -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

6
src/data/data.qrc Normal file
View File

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/">
<file>data/browsedata.db</file>
<file>data/profiles.ini</file>
</qresource>
</RCC>

View File

@ -25,6 +25,7 @@
int main(int argc, char* argv[])
{
Q_INIT_RESOURCE(data);
Q_INIT_RESOURCE(icons);
Q_INIT_RESOURCE(html);

View File

@ -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("<b>" + m_actProfileName + "</b>");
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);

View File

@ -303,17 +303,17 @@
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Startup profile:</string>
</property>
</widget>
</item>
<item row="8" column="2">
<item row="9" column="2">
<widget class="QComboBox" name="startProfile"/>
</item>
<item row="9" column="2" colspan="2">
<item row="10" column="2" colspan="2">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@ -379,7 +379,7 @@
</layout>
</widget>
</item>
<item row="11" column="1">
<item row="12" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -427,7 +427,7 @@
</property>
</spacer>
</item>
<item row="10" column="1" colspan="2">
<item row="11" column="1" colspan="2">
<widget class="QLabel" name="cannotDeleteActiveProfileLabel">
<property name="text">
<string>Note: You cannot delete active profile.</string>
@ -444,6 +444,20 @@
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="label_45">
<property name="text">
<string>Active profile:</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLabel" name="activeProfile">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="stackedWidgetPage2">

View File

@ -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