1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Improved commandline options. Possibility to use more than at once.

- it is also now possible to start in private mode from commandline
This commit is contained in:
nowrep 2011-12-30 16:54:37 +01:00
parent 6eb4f7bb3b
commit b8a0b52982
4 changed files with 42 additions and 6 deletions

View File

@ -37,7 +37,7 @@ void CommandLineOptions::showHelp()
" -a or --authors print QupZilla authors \n"
" -v or --version print QupZilla version \n"
"\n"
" -p or --profile=PROFILE start with specified profile \n"
" -p or --profile=<profile> start with specified profile \n"
" -np or --no-plugins start without plugins \n"
"\n"
" Options to control running QupZilla:\n"

View File

@ -115,15 +115,18 @@ MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &cm
break;
case CommandLineOptions::NewTab:
messages.append("ACTION:NewTab");
m_postLaunchActions.append(OpenNewTab);
break;
case CommandLineOptions::NewWindow:
messages.append("ACTION:NewWindow");
break;
case CommandLineOptions::ShowDownloadManager:
messages.append("ACTION:ShowDownloadManager");
m_postLaunchActions.append(OpenDownloadManager);
break;
case CommandLineOptions::StartPrivateBrowsing:
messages.append("ACTION:StartPrivateBrowsing");
m_postLaunchActions.append(PrivateBrowsing);
break;
case CommandLineOptions::OpenUrl:
startUrl = pair.text;
@ -208,8 +211,26 @@ MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &cm
plugins()->loadPlugins();
loadSettings();
QTimer::singleShot(0, this, SLOT(postLaunch()));
QTimer::singleShot(2000, this, SLOT(restoreCursor()));
#ifdef Q_WS_WIN
QTimer::singleShot(10 * 1000, this, SLOT(setupJumpList()));
#endif
}
void MainApplication::postLaunch()
{
if (m_postLaunchActions.contains(PrivateBrowsing)) {
togglePrivateBrowsingMode(true);
}
if (m_postLaunchActions.contains(OpenDownloadManager)) {
downManager()->show();
}
if (m_postLaunchActions.contains(OpenNewTab)) {
getWindow()->tabWidget()->addView();
}
}
void MainApplication::loadSettings()
@ -356,6 +377,15 @@ bool MainApplication::isStateChanged()
return false;
}
void MainApplication::togglePrivateBrowsingMode(bool state)
{
webSettings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, state);
history()->setSaving(!state);
cookieJar()->turnPrivateJar(state);
emit message(MainApplication::CheckPrivateBrowsing, state);
}
void MainApplication::sendMessages(MainApplication::MessageType mes, bool state)
{
emit message(mes, state);
@ -674,6 +704,10 @@ bool MainApplication::saveStateSlot()
bool MainApplication::restoreStateSlot(QupZilla* window)
{
if (m_postLaunchActions.contains(PrivateBrowsing)) {
return false;
}
m_isRestoring = true;
QSettings settings(m_activeProfil + "settings.ini", QSettings::IniFormat);
int afterStart = settings.value("Web-URL-Settings/afterLaunch", 1).toInt();

View File

@ -82,9 +82,10 @@ public:
inline int windowCount() { return m_mainWindows.count(); }
bool checkSettingsDir();
int defaultZoom() { return m_defaultZoom; }
void togglePrivateBrowsingMode(bool state);
QupZilla* getWindow();
CookieManager* cookieManager();
BrowsingLibrary* browsingLibrary();
@ -116,10 +117,13 @@ signals:
void message(MainApplication::MessageType mes, bool state);
private slots:
void postLaunch();
void setupJumpList();
void restoreCursor();
private:
enum PostLaunchAction { PrivateBrowsing, OpenDownloadManager, OpenNewTab };
void translateApp();
void restoreOtherWindows();
@ -154,6 +158,7 @@ private:
bool m_isRestoring;
bool m_databaseConnected;
QList<PostLaunchAction> m_postLaunchActions;
};
#endif // MAINAPPLICATION_H

View File

@ -1326,10 +1326,7 @@ void QupZilla::startPrivate(bool state)
}
}
mApp->webSettings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, state);
mApp->history()->setSaving(!state);
mApp->cookieJar()->turnPrivateJar(state);
emit message(MainApplication::CheckPrivateBrowsing, state);
mApp->togglePrivateBrowsingMode(state);
}
void QupZilla::resizeEvent(QResizeEvent *event)