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

Added processing multiple commandline arguments + implemented -p= (-

This commit is contained in:
nowrep 2011-04-03 21:50:44 +02:00
parent 54c05b91f8
commit aedfdd3309
11 changed files with 165 additions and 146 deletions

View File

@ -1,96 +1,96 @@
/* EcWin7 - Support library for integrating Windows 7 taskbar features /* EcWin7 - Support library for integrating Windows 7 taskbar features
* into any Qt application * into any Qt application
* Copyright (C) 2010 Emanuele Colombo * Copyright (C) 2010 Emanuele Colombo
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "ecwin7.h" #include "ecwin7.h"
// Windows only definitions // Windows only definitions
#ifdef W7TASKBAR #ifdef W7API
DEFINE_GUID(CLSID_TaskbarList,0x56fdf344,0xfd6d,0x11d0,0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90); DEFINE_GUID(CLSID_TaskbarList,0x56fdf344,0xfd6d,0x11d0,0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90);
DEFINE_GUID(IID_ITaskbarList3,0xea1afb91,0x9e28,0x4b86,0x90,0xE9,0x9e,0x9f,0x8a,0x5e,0xef,0xaf); DEFINE_GUID(IID_ITaskbarList3,0xea1afb91,0x9e28,0x4b86,0x90,0xE9,0x9e,0x9f,0x8a,0x5e,0xef,0xaf);
// Constructor: variabiles initialization // Constructor: variabiles initialization
EcWin7::EcWin7() EcWin7::EcWin7()
{ {
mOverlayIcon = NULL; mOverlayIcon = NULL;
} }
// Init taskbar communication // Init taskbar communication
void EcWin7::init(WId wid) void EcWin7::init(WId wid)
{ {
mWindowId = wid; mWindowId = wid;
mTaskbarMessageId = RegisterWindowMessage(L"TaskbarButtonCreated"); mTaskbarMessageId = RegisterWindowMessage(L"TaskbarButtonCreated");
} }
// Windows event handler callback function // Windows event handler callback function
// (handles taskbar communication initial message) // (handles taskbar communication initial message)
bool EcWin7::winEvent(MSG * message, long * result) bool EcWin7::winEvent(MSG * message, long * result)
{ {
if (message->message == mTaskbarMessageId) if (message->message == mTaskbarMessageId)
{ {
HRESULT hr = CoCreateInstance(CLSID_TaskbarList, HRESULT hr = CoCreateInstance(CLSID_TaskbarList,
0, 0,
CLSCTX_INPROC_SERVER, CLSCTX_INPROC_SERVER,
IID_ITaskbarList3, IID_ITaskbarList3,
reinterpret_cast<void**> (&(mTaskbar))); reinterpret_cast<void**> (&(mTaskbar)));
*result = hr; *result = hr;
return true; return true;
} }
return false; return false;
} }
// Set progress bar current value // Set progress bar current value
void EcWin7::setProgressValue(int value, int max) void EcWin7::setProgressValue(int value, int max)
{ {
mTaskbar->SetProgressValue(mWindowId, value, max); mTaskbar->SetProgressValue(mWindowId, value, max);
} }
// Set progress bar current state (active, error, pause, ecc...) // Set progress bar current state (active, error, pause, ecc...)
void EcWin7::setProgressState(ToolBarProgressState state) void EcWin7::setProgressState(ToolBarProgressState state)
{ {
mTaskbar->SetProgressState(mWindowId, (TBPFLAG)state); mTaskbar->SetProgressState(mWindowId, (TBPFLAG)state);
} }
// Set new overlay icon and corresponding description (for accessibility) // Set new overlay icon and corresponding description (for accessibility)
// (call with iconName == "" and description == "" to remove any previous overlay icon) // (call with iconName == "" and description == "" to remove any previous overlay icon)
void EcWin7::setOverlayIcon(QString iconName, QString description) void EcWin7::setOverlayIcon(QString iconName, QString description)
{ {
HICON oldIcon = NULL; HICON oldIcon = NULL;
if (mOverlayIcon != NULL) oldIcon = mOverlayIcon; if (mOverlayIcon != NULL) oldIcon = mOverlayIcon;
if (iconName == "") if (iconName == "")
{ {
mTaskbar->SetOverlayIcon(mWindowId, NULL, NULL); mTaskbar->SetOverlayIcon(mWindowId, NULL, NULL);
mOverlayIcon = NULL; mOverlayIcon = NULL;
} }
else else
{ {
mOverlayIcon = (HICON) LoadImage(GetModuleHandle(NULL), mOverlayIcon = (HICON) LoadImage(GetModuleHandle(NULL),
iconName.toStdWString().c_str(), iconName.toStdWString().c_str(),
IMAGE_ICON, IMAGE_ICON,
0, 0,
0, 0,
NULL); NULL);
mTaskbar->SetOverlayIcon(mWindowId, mOverlayIcon, description.toStdWString().c_str()); mTaskbar->SetOverlayIcon(mWindowId, mOverlayIcon, description.toStdWString().c_str());
} }
if ((oldIcon != NULL) && (oldIcon != mOverlayIcon)) if ((oldIcon != NULL) && (oldIcon != mOverlayIcon))
{ {
DestroyIcon(oldIcon); DestroyIcon(oldIcon);
} }
} }
#endif #endif

View File

@ -24,7 +24,7 @@
#include <QWidget> #include <QWidget>
// Windows only data definitions // Windows only data definitions
#ifdef W7TASKBAR #ifdef W7API
#include <windows.h> #include <windows.h>
#include <initguid.h> #include <initguid.h>

View File

@ -210,4 +210,5 @@ OTHER_FILES += \
include(3rdparty/qtsingleapplication.pri) include(3rdparty/qtsingleapplication.pri)
win32:RC_FILE = appicon.rc win32:RC_FILE = appicon.rc
#win32:LIBS += libole32 win32:LIBS += User32.lib
win32:LIBS += Ole32.lib

View File

@ -20,10 +20,8 @@
CommandLineOptions::CommandLineOptions(int &argc, char **argv) : CommandLineOptions::CommandLineOptions(int &argc, char **argv) :
QObject(0) QObject(0)
,m_actionString("")
,m_argc(argc) ,m_argc(argc)
,m_argv(argv) ,m_argv(argv)
,m_action(NoAction)
{ {
parseActions(); parseActions();
} }
@ -43,9 +41,11 @@ void CommandLineOptions::showHelp()
"\n" "\n"
" QupZilla is a new, fast and secure web browser\n" " QupZilla is a new, fast and secure web browser\n"
" based on WebKit core (http://webkit.org) and\n" " based on WebKit core (http://webkit.org) and\n"
" written in Qt Framework (http://qt.nokia.com) \n" " written in Qt Framework (http://qt.nokia.com) \n\n"
" For more informations please visit wiki at \n"
" https://github.com/nowrep/QupZilla/wiki \n"
; ;
cout << help << " " << QupZilla::WWWADDRESS.toAscii().data() << endl; cout << help << " > " << QupZilla::WWWADDRESS.toAscii().data() << endl;
} }
void CommandLineOptions::parseActions() void CommandLineOptions::parseActions()
@ -80,13 +80,18 @@ void CommandLineOptions::parseActions()
arg.remove("-profile="); arg.remove("-profile=");
found = true; found = true;
cout << "starting with profile " << arg.toAscii().data() << endl; cout << "starting with profile " << arg.toAscii().data() << endl;
m_actionString = arg; QPair<int, QString> pair;
m_action = StartWithProfile; pair.first = StartWithProfile;
pair.second = arg;
m_actions.append(pair);
} }
if (arg.startsWith("-np") || arg.startsWith("-no-plugins")) { if (arg.startsWith("-np") || arg.startsWith("-no-plugins")) {
found = true; found = true;
m_action = StartWithoutAddons; QPair<int, QString> pair;
pair.first = StartWithoutAddons;
pair.second = "";
m_actions.append(pair);
} }
} }
@ -94,8 +99,10 @@ void CommandLineOptions::parseActions()
if (m_argc > 1 && !url.isEmpty() && !url.startsWith("-")) { if (m_argc > 1 && !url.isEmpty() && !url.startsWith("-")) {
found = true; found = true;
cout << "starting with url " << url.toAscii().data() << endl; cout << "starting with url " << url.toAscii().data() << endl;
m_actionString = url; QPair<int, QString> pair;
m_action = OpenUrl; pair.first = OpenUrl;
pair.second = url;
m_actions.append(pair);
} }
if (m_argc > 1 && !found) { if (m_argc > 1 && !found) {
@ -104,14 +111,3 @@ void CommandLineOptions::parseActions()
} }
} }
CommandLineOptions::Action CommandLineOptions::getAction()
{
return m_action;
}
QString CommandLineOptions::getActionString()
{
return m_actionString;
}

View File

@ -19,7 +19,7 @@
#define COMMANDLINEOPTIONS_H #define COMMANDLINEOPTIONS_H
#include <QObject> #include <QObject>
#include <QPair>
#include <iostream> #include <iostream>
class CommandLineOptions : public QObject class CommandLineOptions : public QObject
@ -28,17 +28,15 @@ class CommandLineOptions : public QObject
public: public:
enum Action {NoAction, OpenUrl, StartWithProfile, StartWithoutAddons}; enum Action {NoAction, OpenUrl, StartWithProfile, StartWithoutAddons};
explicit CommandLineOptions(int &argc, char **argv); explicit CommandLineOptions(int &argc, char **argv);
Action getAction(); QList<QPair<int, QString> > getActions() { return m_actions; }
QString getActionString();
private: private:
void showHelp(); void showHelp();
void parseActions(); void parseActions();
QString m_actionString;
int m_argc; int m_argc;
char **m_argv; char **m_argv;
Action m_action; QList<QPair<int, QString> > m_actions;
}; };
#endif // COMMANDLINEOPTIONS_H #endif // COMMANDLINEOPTIONS_H

View File

@ -64,20 +64,28 @@ MainApplication::MainApplication(int &argc, char **argv)
bool noAddons = false; bool noAddons = false;
QUrl startUrl(""); QUrl startUrl("");
QString message; QString message;
QString startProfile;
if (argc > 1) { if (argc > 1) {
CommandLineOptions cmd(argc, argv); CommandLineOptions cmd(argc, argv);
switch (cmd.getAction()) { QList<QPair<int, QString> > cmdActions = cmd.getActions();
case CommandLineOptions::StartWithoutAddons: for (int i = 0; i < cmdActions.count(); i++) {
noAddons = true; QPair<int, QString> act = cmdActions.at(i);
break; switch (act.first) {
case CommandLineOptions::OpenUrl: case CommandLineOptions::StartWithoutAddons:
startUrl = QUrl(cmd.getActionString()); noAddons = true;
message = "URL:"+startUrl.toString(); break;
break; case CommandLineOptions::OpenUrl:
default: startUrl = act.second;
m_isExited = true; message = "URL:"+startUrl.toString();
return; break;
break; case CommandLineOptions::StartWithProfile:
startProfile = act.second;
break;
default:
m_isExited = true;
return;
break;
}
} }
} }
@ -100,11 +108,15 @@ MainApplication::MainApplication(int &argc, char **argv)
checkProfileDir(); checkProfileDir();
QSettings::setDefaultFormat(QSettings::IniFormat); QSettings::setDefaultFormat(QSettings::IniFormat);
QSettings settings(homePath+"profiles/profiles.ini", QSettings::IniFormat); if (startProfile.isEmpty()) {
if (settings.value("Profiles/startProfile","default").toString().contains("/")) QSettings settings(homePath+"profiles/profiles.ini", QSettings::IniFormat);
m_activeProfil=homePath+"profiles/default/"; if (settings.value("Profiles/startProfile","default").toString().contains("/"))
else m_activeProfil=homePath+"profiles/default/";
m_activeProfil=homePath+"profiles/"+settings.value("Profiles/startProfile","default").toString()+"/"; else
m_activeProfil=homePath+"profiles/"+settings.value("Profiles/startProfile","default").toString()+"/";
} else
m_activeProfil = homePath+"profiles/"+startProfile+"/";
if (!QDir(m_activeProfil).exists()) if (!QDir(m_activeProfil).exists())
m_activeProfil=homePath+"profiles/default/"; m_activeProfil=homePath+"profiles/default/";

View File

@ -48,7 +48,11 @@
#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 dd 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");
#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";

View File

@ -46,12 +46,12 @@ DownloadManager::DownloadManager(QWidget* parent) :
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearList())); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearList()));
#ifdef W7TASKBAR #ifdef W7API
win7.init(this->winId()); win7.init(this->winId());
#endif #endif
} }
#ifdef W7TASKBAR #ifdef W7API
bool DownloadManager::winEvent(MSG* message, long* result) bool DownloadManager::winEvent(MSG* message, long* result)
{ {
return win7.winEvent(message, result); return win7.winEvent(message, result);
@ -107,7 +107,7 @@ void DownloadManager::timerEvent(QTimerEvent* event)
DownloadItem::currentSpeedToString(speed), DownloadItem::currentSpeedToString(speed),
DownloadItem::remaingTimeToString(remaining))); DownloadItem::remaingTimeToString(remaining)));
setWindowTitle(QString::number(progress) + tr("% - Download Manager")); setWindowTitle(QString::number(progress) + tr("% - Download Manager"));
#ifdef W7TASKBAR #ifdef W7API
win7.setProgressValue(progress, 100); win7.setProgressValue(progress, 100);
win7.setProgressState(win7.Normal); win7.setProgressState(win7.Normal);
#endif #endif

View File

@ -59,7 +59,7 @@ public:
void show() { m_timer.start(1000*2, this); QWidget::show(); } void show() { m_timer.start(1000*2, this); QWidget::show(); }
#ifdef W7TASKBAR #ifdef W7API
protected: protected:
virtual bool winEvent(MSG* message, long* result); virtual bool winEvent(MSG* message, long* result);
#endif #endif
@ -69,7 +69,7 @@ private slots:
void deleteItem(DownloadItem* item); void deleteItem(DownloadItem* item);
private: private:
#ifdef W7TASKBAR #ifdef W7API
EcWin7 win7; EcWin7 win7;
#endif #endif
void timerEvent(QTimerEvent* event); void timerEvent(QTimerEvent* event);

View File

@ -71,7 +71,7 @@
<enum>QListView::IconMode</enum> <enum>QListView::IconMode</enum>
</property> </property>
<property name="uniformItemSizes"> <property name="uniformItemSizes">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="currentRow"> <property name="currentRow">
<number>0</number> <number>0</number>

View File

@ -35,7 +35,11 @@ public:
QSize sizeHint() const QSize sizeHint() const
{ {
QSize siz = QToolButton::sizeHint(); QSize siz = QToolButton::sizeHint();
#ifdef Q_WS_X11
siz.setWidth(25); siz.setWidth(25);
#else
siz.setWidth(26);
#endif
return siz; return siz;
} }
@ -50,7 +54,11 @@ private:
QPixmap pix(":/icons/other/list-add.png"); QPixmap pix(":/icons/other/list-add.png");
QRect r = this->rect(); QRect r = this->rect();
r.setHeight(r.height()+3); r.setHeight(r.height()+3);
#ifdef Q_WS_X11
r.setWidth(r.width()-1); r.setWidth(r.width()-1);
#else
r.setWidth(r.width()+3);
#endif
style()->drawItemPixmap(&p, r, Qt::AlignCenter, pix); style()->drawItemPixmap(&p, r, Qt::AlignCenter, pix);
} }
}; };