mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-24 04:36:34 +01:00
Added support for creating and deleting new profiles
This commit is contained in:
parent
1d8cb36148
commit
23c1a80165
@ -48,11 +48,8 @@
|
|||||||
#include "clickablelabel.h"
|
#include "clickablelabel.h"
|
||||||
|
|
||||||
const QString QupZilla::VERSION = "0.9.9";
|
const QString QupZilla::VERSION = "0.9.9";
|
||||||
#ifdef Q_WS_X11
|
//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 = QLocale(QLocale::English).toDateTime(__DATE__" "__TIME__, "MMM dd yyyy hh:mm:ss").toString("MM/dd/yyyy hh:ss");
|
const QString QupZilla::BUILDTIME = __DATE__" "__TIME__;
|
||||||
#else
|
|
||||||
const QString QupZilla::BUILDTIME = __DATE__" "__TIME__;
|
|
||||||
#endif
|
|
||||||
const QString QupZilla::AUTHOR = "nowrep";
|
const QString QupZilla::AUTHOR = "nowrep";
|
||||||
const QString QupZilla::COPYRIGHT = "2010-2011";
|
const QString QupZilla::COPYRIGHT = "2010-2011";
|
||||||
const QString QupZilla::WWWADDRESS = "http://qupzilla.ic.cz";
|
const QString QupZilla::WWWADDRESS = "http://qupzilla.ic.cz";
|
||||||
|
@ -49,7 +49,7 @@ void AboutDialog::showAbout()
|
|||||||
m_aboutHtml.append(tr("<p><b>Application version %1</b><br/>").arg(QupZilla::VERSION));
|
m_aboutHtml.append(tr("<p><b>Application version %1</b><br/>").arg(QupZilla::VERSION));
|
||||||
m_aboutHtml.append(tr("<b>WebKit version %1</b></p>").arg(QupZilla::WEBKITVERSION));
|
m_aboutHtml.append(tr("<b>WebKit version %1</b></p>").arg(QupZilla::WEBKITVERSION));
|
||||||
m_aboutHtml.append(tr("<p>© %1 %2<br/>All rights reserved.<br/>").arg(QupZilla::COPYRIGHT, QupZilla::AUTHOR));
|
m_aboutHtml.append(tr("<p>© %1 %2<br/>All rights reserved.<br/>").arg(QupZilla::COPYRIGHT, QupZilla::AUTHOR));
|
||||||
m_aboutHtml.append(tr("Build time: %1 </p>").arg(QupZilla::BUILDTIME));
|
m_aboutHtml.append(tr("<small>Build time: %1 </small></p>").arg(QupZilla::BUILDTIME));
|
||||||
m_aboutHtml.append(QString("<p><a href=%1>%1</a></p>").arg(QupZilla::WWWADDRESS));
|
m_aboutHtml.append(QString("<p><a href=%1>%1</a></p>").arg(QupZilla::WWWADDRESS));
|
||||||
m_aboutHtml.append("<p>"+mApp->getWindow()->weView()->webPage()->userAgentForUrl(QUrl())+"</p>");
|
m_aboutHtml.append("<p>"+mApp->getWindow()->weView()->webPage()->userAgentForUrl(QUrl())+"</p>");
|
||||||
m_aboutHtml.append("</div>");
|
m_aboutHtml.append("</div>");
|
||||||
|
@ -31,6 +31,35 @@
|
|||||||
#include "pluginproxy.h"
|
#include "pluginproxy.h"
|
||||||
#include "sslmanager.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) :
|
Preferences::Preferences(QupZilla* mainClass, QWidget* parent) :
|
||||||
QDialog(parent)
|
QDialog(parent)
|
||||||
,ui(new Ui::Preferences)
|
,ui(new Ui::Preferences)
|
||||||
@ -48,6 +77,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) :
|
|||||||
ui->homepage->setText(m_homepage);
|
ui->homepage->setText(m_homepage);
|
||||||
ui->newTabUrl->setText(m_newTabUrl);
|
ui->newTabUrl->setText(m_newTabUrl);
|
||||||
int afterLaunch = settings.value("afterLaunch",1).toInt();
|
int afterLaunch = settings.value("afterLaunch",1).toInt();
|
||||||
|
settings.endGroup();
|
||||||
ui->afterLaunch->setCurrentIndex(afterLaunch);
|
ui->afterLaunch->setCurrentIndex(afterLaunch);
|
||||||
|
|
||||||
ui->newTabFrame->setVisible(false);
|
ui->newTabFrame->setVisible(false);
|
||||||
@ -64,10 +94,21 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) :
|
|||||||
connect(ui->newTabUseActual, SIGNAL(clicked()), this, SLOT(useActualNewTab()));
|
connect(ui->newTabUseActual, SIGNAL(clicked()), this, SLOT(useActualNewTab()));
|
||||||
|
|
||||||
//PROFILES
|
//PROFILES
|
||||||
ui->startPRofile->setEnabled(false);
|
m_actProfileName = mApp->getActiveProfil();
|
||||||
ui->createProfile->setEnabled(false);
|
m_actProfileName = m_actProfileName.left(m_actProfileName.length()-1);
|
||||||
ui->deleteProfile->setEnabled(false);
|
m_actProfileName = m_actProfileName.mid(m_actProfileName.lastIndexOf("/"));
|
||||||
settings.endGroup();
|
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
|
//WINDOW
|
||||||
settings.beginGroup("Browser-View-Settings");
|
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()
|
void Preferences::saveSettings()
|
||||||
{
|
{
|
||||||
QSettings settings(mApp->getActiveProfil()+"settings.ini", QSettings::IniFormat);
|
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.setValue("language",ui->languages->itemData(ui->languages->currentIndex()).toString());
|
||||||
settings.endGroup();
|
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();
|
m_pluginsList->save();
|
||||||
p_QupZilla->loadSettings();
|
p_QupZilla->loadSettings();
|
||||||
p_QupZilla->tabWidget()->loadSettings();
|
p_QupZilla->tabWidget()->loadSettings();
|
||||||
|
@ -65,6 +65,10 @@ private slots:
|
|||||||
void cacheValueChanged(int value);
|
void cacheValueChanged(int value);
|
||||||
void pageCacheValueChanged(int value);
|
void pageCacheValueChanged(int value);
|
||||||
|
|
||||||
|
void createProfile();
|
||||||
|
void deleteProfile();
|
||||||
|
void startProfileIndexChanged(QString index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateBgLabel();
|
void updateBgLabel();
|
||||||
Ui::Preferences* ui;
|
Ui::Preferences* ui;
|
||||||
@ -75,6 +79,7 @@ private:
|
|||||||
QColor m_menuTextColor;
|
QColor m_menuTextColor;
|
||||||
QString m_homepage;
|
QString m_homepage;
|
||||||
QString m_newTabUrl;
|
QString m_newTabUrl;
|
||||||
|
QString m_actProfileName;
|
||||||
int m_afterLaunch;
|
int m_afterLaunch;
|
||||||
int m_onNewTab;
|
int m_onNewTab;
|
||||||
QSize m_bgLabelSize;
|
QSize m_bgLabelSize;
|
||||||
|
@ -331,13 +331,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="2">
|
<item row="7" column="2">
|
||||||
<widget class="QComboBox" name="startPRofile">
|
<widget class="QComboBox" name="startProfile"/>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>default</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="2" colspan="2">
|
<item row="8" column="2" colspan="2">
|
||||||
<widget class="QFrame" name="frame">
|
<widget class="QFrame" name="frame">
|
||||||
@ -388,6 +382,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="deleteProfile">
|
<widget class="QPushButton" name="deleteProfile">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -402,7 +399,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="1">
|
<item row="10" column="1">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -450,6 +447,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="9" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="label_36">
|
||||||
|
<property name="text">
|
||||||
|
<string>Note: You cannot delete active profile.</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="stackedWidgetPage2">
|
<widget class="QWidget" name="stackedWidgetPage2">
|
||||||
|
@ -495,7 +495,7 @@ void WebView::contextMenuEvent(QContextMenuEvent* event)
|
|||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
QString selectedText = page()->selectedText();
|
QString selectedText = page()->selectedText();
|
||||||
selectedText.truncate(20);
|
selectedText.truncate(20);
|
||||||
menu->addAction(QIcon(":icons/used/google.png"), tr("Search ")+selectedText+tr("... on Google"), this, SLOT(searchOnGoogle()))->setData(page()->selectedText());
|
menu->addAction(QIcon(":icons/menu/google.png"), tr("Search \"%1 ..\" on Google").arg(selectedText), this, SLOT(searchOnGoogle()))->setData(page()->selectedText());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!menu->isEmpty()) {
|
if (!menu->isEmpty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user