mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Added possibility to change prefix for installation + improved checking
profile versions (every profile will now be checked, not only default)
This commit is contained in:
parent
12fb69a2fd
commit
2c9dc68c3e
20
BUILDING
20
BUILDING
@ -49,27 +49,45 @@ Available Defines
|
||||
You can set define directly in project file (QupZilla.pro)
|
||||
or set environment variable by
|
||||
|
||||
$ export NAME="true"
|
||||
$ export NAME="value"
|
||||
|
||||
General:
|
||||
UNRELEASED_BUILD QupZilla won't check profile version,
|
||||
thus, it won't reset your profile is lower version
|
||||
(disabled by default)
|
||||
|
||||
example:
|
||||
$ export UNRELEASED_BUILD="true"
|
||||
|
||||
USE_WEBGL Enable WebGL. You need to build QupZilla with WebKit built
|
||||
with WebGL support, otherwise you won't be able to compile
|
||||
without errors.
|
||||
(disabled by default)
|
||||
|
||||
example:
|
||||
$ export USE_WEBGL="true"
|
||||
|
||||
Windows specific defines
|
||||
W7API Enable Windows 7 API support
|
||||
Requires linking against libraries from Microsoft Visual C++
|
||||
Compiler 2010
|
||||
(disabled by default)
|
||||
|
||||
|
||||
Linux / Unix specific defines:
|
||||
NO_SYSTEM_DATAPATH By default, QupZilla is using /usr/share/qupzilla/ path
|
||||
for storing themes, translations and plugins.
|
||||
By setting this define, QupZilla will use path of execution.
|
||||
(disabled by default)
|
||||
|
||||
example:
|
||||
$ export NO_SYSTEM_DATAPATH="true"
|
||||
|
||||
QUPZILLA_PREFIX You can define different prefix. Prefix must contain ending slash.
|
||||
(default prefix is "/usr/")
|
||||
value:
|
||||
|
||||
example:
|
||||
$ export NO_SYSTEM_DATAPATH="/usr/"
|
||||
|
||||
|
||||
|
@ -149,7 +149,8 @@ SOURCES += main.cpp\
|
||||
other/pagescreen.cpp \
|
||||
downloads/downloadfilehelper.cpp \
|
||||
tools/certificateinfowidget.cpp \
|
||||
webview/webinspectordockwidget.cpp
|
||||
webview/webinspectordockwidget.cpp \
|
||||
app/profileupdater.cpp
|
||||
|
||||
HEADERS += \
|
||||
3rdparty/qtwin.h \
|
||||
@ -248,7 +249,8 @@ HEADERS += \
|
||||
downloads/downloadfilehelper.h \
|
||||
tools/certificateinfowidget.h \
|
||||
webview/webinspectordockwidget.h \
|
||||
3rdparty/msvc2008.h
|
||||
3rdparty/msvc2008.h \
|
||||
app/profileupdater.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
@ -296,19 +298,34 @@ OTHER_FILES += \
|
||||
include(3rdparty/qtsingleapplication.pri)
|
||||
|
||||
unix {
|
||||
target.path = /usr/bin
|
||||
d_prefix = $$(QUPZILLA_PREFIX)
|
||||
binary_folder = /usr/bin
|
||||
data_folder = /usr/share/qupzilla
|
||||
launcher_folder = /usr/share/applications
|
||||
icon_folder = /usr/share/pixmaps
|
||||
|
||||
!equals(d_prefix, "") {
|
||||
binary_folder = "$$d_prefix"bin
|
||||
data_folder = "$$d_prefix"share/qupzilla
|
||||
launcher_folder = "$$d_prefix"share/applications
|
||||
icon_folder = "$$d_prefix"share/pixmaps
|
||||
}
|
||||
|
||||
DEFINES += USE_DATADIR=\""$$data_folder"/\"
|
||||
|
||||
target.path = $$binary_folder
|
||||
|
||||
target1.files = ../bin/data
|
||||
target1.files += ../bin/locale
|
||||
target1.files += ../bin/plugins
|
||||
target1.files += ../bin/themes
|
||||
target1.path = /usr/share/qupzilla
|
||||
target1.path = $$data_folder
|
||||
|
||||
target2.files = ../linux/applications/qupzilla.desktop
|
||||
target2.path = /usr/share/applications
|
||||
target2.path = $$launcher_folder
|
||||
|
||||
target3.files = ../linux/pixmaps/qupzilla.png
|
||||
target3.path = /usr/share/pixmaps
|
||||
target3.path = $$icon_folder
|
||||
|
||||
INSTALLS += target target1 target2 target3
|
||||
}
|
||||
@ -327,3 +344,5 @@ message(Using following defines)
|
||||
message($$DEFINES)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "mainapplication.h"
|
||||
#include "webhistoryinterface.h"
|
||||
#include "globalfunctions.h"
|
||||
#include "profileupdater.h"
|
||||
|
||||
MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &cmdActions, int &argc, char **argv)
|
||||
: QtSingleApplication("QupZillaWebBrowser", argc, argv)
|
||||
@ -63,7 +64,7 @@ MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &cm
|
||||
{
|
||||
setOverrideCursor(Qt::WaitCursor);
|
||||
#if defined(Q_WS_X11) & !defined(NO_SYSTEM_DATAPATH)
|
||||
DATADIR = "/usr/share/qupzilla/";
|
||||
DATADIR = USE_DATADIR;
|
||||
#else
|
||||
DATADIR = qApp->applicationDirPath() + "/";
|
||||
#endif
|
||||
@ -133,8 +134,11 @@ MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &cm
|
||||
} else
|
||||
m_activeProfil = homePath+"profiles/"+startProfile+"/";
|
||||
|
||||
if (!QDir(m_activeProfil).exists())
|
||||
m_activeProfil=homePath+"profiles/default/";
|
||||
ProfileUpdater u(m_activeProfil, DATADIR);
|
||||
u.checkProfile();
|
||||
|
||||
// if (!QDir(m_activeProfil).exists())
|
||||
// m_activeProfil=homePath+"profiles/default/";
|
||||
|
||||
QSettings settings2(m_activeProfil+"settings.ini", QSettings::IniFormat);
|
||||
settings2.beginGroup("SessionRestore");
|
||||
@ -617,23 +621,6 @@ bool MainApplication::restoreStateSlot(QupZilla* window)
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainApplication::checkProfile(QString path)
|
||||
{
|
||||
QByteArray rData;
|
||||
QFile versionFile(path+"version");
|
||||
versionFile.open(QFile::ReadOnly);
|
||||
rData = versionFile.readAll();
|
||||
if (rData.contains(QupZilla::VERSION.toAscii())) {
|
||||
versionFile.close();
|
||||
return;
|
||||
}
|
||||
versionFile.close();
|
||||
#ifdef UNRELEASED_BUILD
|
||||
return;
|
||||
#endif
|
||||
//Starting profile migration manager
|
||||
}
|
||||
|
||||
bool MainApplication::checkSettingsDir()
|
||||
{
|
||||
/*
|
||||
@ -644,23 +631,13 @@ bool MainApplication::checkSettingsDir()
|
||||
profiles/-----------
|
||||
| |
|
||||
default/ profiles.ini
|
||||
| ---------------
|
||||
| |
|
||||
browsedata.db background.png
|
||||
|
|
||||
browsedata.db
|
||||
*/
|
||||
QString homePath = QDir::homePath();
|
||||
homePath+="/.qupzilla/";
|
||||
QString homePath = QDir::homePath() + "/.qupzilla/";
|
||||
|
||||
QString profileVersion;
|
||||
if (QDir(homePath).exists()) {
|
||||
profileVersion = qz_readAllFileContents(homePath + "version");
|
||||
|
||||
if (profileVersion == QupZilla::VERSION)
|
||||
if (QDir(homePath).exists() && QFile(homePath + "profiles/profiles.ini").exists())
|
||||
return true;
|
||||
#ifdef UNRELEASED_BUILD
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::cout << "Creating new profile directory" << std::endl;
|
||||
|
||||
@ -668,16 +645,6 @@ bool MainApplication::checkSettingsDir()
|
||||
dir.mkdir(".qupzilla");
|
||||
dir.cd(".qupzilla");
|
||||
|
||||
//.qupzilla
|
||||
QFile(homePath + "version").remove();
|
||||
QFile versionFile(homePath + "version");
|
||||
versionFile.open(QFile::WriteOnly);
|
||||
versionFile.write(QupZilla::VERSION.toAscii());
|
||||
versionFile.close();
|
||||
|
||||
if (Updater::parseVersionFromString(QupZilla::VERSION) >= Updater::parseVersionFromString("1.0.0-b3") ) // Data not changed from this version
|
||||
return true;
|
||||
|
||||
dir.mkdir("profiles");
|
||||
dir.cd("profiles");
|
||||
|
||||
@ -691,8 +658,6 @@ bool MainApplication::checkSettingsDir()
|
||||
//.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(homePath + "profiles/default/background.png").remove();
|
||||
QFile(DATADIR + "data/default/profiles/default/background.png").copy(homePath + "profiles/default/background.png");
|
||||
|
||||
return dir.isReadable();
|
||||
}
|
||||
|
@ -75,7 +75,6 @@ public:
|
||||
inline int windowCount() { return m_mainWindows.count(); }
|
||||
|
||||
bool checkSettingsDir();
|
||||
void checkProfile(QString path);
|
||||
|
||||
QupZilla* getWindow();
|
||||
CookieManager* cookieManager();
|
||||
|
61
src/app/profileupdater.cpp
Normal file
61
src/app/profileupdater.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
#include "profileupdater.h"
|
||||
#include "qupzilla.h"
|
||||
#include "updater.h"
|
||||
|
||||
ProfileUpdater::ProfileUpdater(const QString &profilePath, const QString &dataPath)
|
||||
: QObject()
|
||||
, m_profilePath(profilePath)
|
||||
, m_dataPath(dataPath)
|
||||
{
|
||||
}
|
||||
|
||||
void ProfileUpdater::checkProfile()
|
||||
{
|
||||
QDir profileDir(m_profilePath);
|
||||
|
||||
if (!profileDir.exists()) {
|
||||
QDir newDir(profileDir.path().remove(profileDir.dirName()));
|
||||
newDir.mkdir(profileDir.dirName());
|
||||
}
|
||||
|
||||
QFile versionFile(m_profilePath + "version");
|
||||
if (versionFile.exists()) {
|
||||
versionFile.open(QFile::ReadOnly);
|
||||
QString profileVersion = versionFile.readAll();
|
||||
versionFile.close();
|
||||
versionFile.remove();
|
||||
|
||||
updateProfile(QupZilla::VERSION, profileVersion);
|
||||
} else
|
||||
copyDataToProfile();
|
||||
|
||||
versionFile.open(QFile::WriteOnly);
|
||||
versionFile.write(QupZilla::VERSION.toAscii());
|
||||
versionFile.close();
|
||||
}
|
||||
|
||||
void ProfileUpdater::updateProfile(const QString ¤t, const QString &profile)
|
||||
{
|
||||
if (current == profile)
|
||||
return;
|
||||
|
||||
// Updater::Version currentVersion = Updater::parseVersionFromString(current);
|
||||
Updater::Version profileVersion = Updater::parseVersionFromString(profile);
|
||||
|
||||
if (profileVersion >= Updater::parseVersionFromString("1.0.0-b3"))
|
||||
//Data not changed from 1.0.0-b3
|
||||
return;
|
||||
|
||||
std::cout << "incompatible profile version detected, updating profile data..." << std::endl;
|
||||
|
||||
copyDataToProfile();
|
||||
}
|
||||
|
||||
void ProfileUpdater::copyDataToProfile()
|
||||
{
|
||||
QDir profileDir(m_profilePath);
|
||||
profileDir.mkdir("certificates");
|
||||
|
||||
QFile(m_profilePath + "browsedata.db").remove();
|
||||
QFile(m_dataPath + "data/default/profiles/default/browsedata.db").copy(m_profilePath + "browsedata.db");
|
||||
}
|
28
src/app/profileupdater.h
Normal file
28
src/app/profileupdater.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef PROFILEUPDATER_H
|
||||
#define PROFILEUPDATER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
#include <iostream>
|
||||
|
||||
class ProfileUpdater : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ProfileUpdater(const QString &profilePath, const QString &dataPath);
|
||||
void checkProfile();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
void updateProfile(const QString ¤t, const QString &profile);
|
||||
void copyDataToProfile();
|
||||
|
||||
QString m_profilePath;
|
||||
QString m_dataPath;
|
||||
|
||||
};
|
||||
|
||||
#endif // PROFILEUPDATER_H
|
@ -154,10 +154,11 @@ void DownloadFileHelper::fileNameChoosed(const QString &name, bool fileNameAutoG
|
||||
if (!m_path.contains(QDir::tempPath()))
|
||||
m_lastDownloadPath = m_path;
|
||||
|
||||
QSettings settings(mApp->getActiveProfilPath()+"settings.ini", QSettings::IniFormat);
|
||||
QSettings settings(mApp->getActiveProfilPath() + "settings.ini", QSettings::IniFormat);
|
||||
settings.beginGroup("DownloadManager");
|
||||
settings.setValue("lastDownloadPath", m_lastDownloadPath);
|
||||
settings.endGroup();
|
||||
m_manager->setLastDownloadPath(m_lastDownloadPath);
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem(m_listWidget);
|
||||
DownloadItem* downItem = new DownloadItem(item, m_reply, m_path, m_fileName, m_fileIcon, m_timer, m_openFileChoosed, m_downloadPage, m_manager);
|
||||
|
@ -70,6 +70,13 @@ void DownloadManager::loadSettings()
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void DownloadManager::show()
|
||||
{
|
||||
m_timer.start(1000*2, this);
|
||||
|
||||
QWidget::show();
|
||||
}
|
||||
|
||||
void DownloadManager::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QWidget::resizeEvent(e);
|
||||
|
@ -55,8 +55,10 @@ public:
|
||||
void download(const QNetworkRequest &request, bool askWhatToDo = true);
|
||||
void handleUnsupportedContent(QNetworkReply* reply, bool askWhatToDo = true);
|
||||
bool canClose();
|
||||
void setLastDownloadPath(const QString &lastPath) { m_lastDownloadPath = lastPath; }
|
||||
|
||||
void show() { m_timer.start(1000*2, this); QWidget::show(); }
|
||||
public slots:
|
||||
void show();
|
||||
|
||||
#ifdef W7API
|
||||
protected:
|
||||
|
@ -57,6 +57,12 @@ bool Updater::isBiggerThan_SpecialSymbol(QString one, QString two)
|
||||
if (one.contains("b") && two.contains("rc"))
|
||||
return false;
|
||||
|
||||
if (one.isEmpty())
|
||||
return true;
|
||||
|
||||
if (two.isEmpty())
|
||||
return false;
|
||||
|
||||
if (one.contains("b")) {
|
||||
int o = one.remove("b").toInt();
|
||||
int t = two.remove("b").toInt();
|
||||
|
@ -48,7 +48,6 @@ public:
|
||||
return true;
|
||||
if (this->revisionNumber < other.revisionNumber)
|
||||
return true;
|
||||
|
||||
if (this->revisionNumber == other.revisionNumber)
|
||||
return !isBiggerThan_SpecialSymbol(this->specialSymbol, other.specialSymbol);
|
||||
|
||||
|
@ -495,7 +495,6 @@ void Preferences::createProfile()
|
||||
}
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user