diff --git a/src/3rdparty/ecwin7.cpp b/src/3rdparty/ecwin7.cpp index e7f91fe91..afae79ad0 100644 --- a/src/3rdparty/ecwin7.cpp +++ b/src/3rdparty/ecwin7.cpp @@ -1,96 +1,96 @@ -/* EcWin7 - Support library for integrating Windows 7 taskbar features - * into any Qt application - * Copyright (C) 2010 Emanuele Colombo - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "ecwin7.h" - -// Windows only definitions -#ifdef W7TASKBAR -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); - -// Constructor: variabiles initialization -EcWin7::EcWin7() -{ - mOverlayIcon = NULL; -} - -// Init taskbar communication -void EcWin7::init(WId wid) -{ - mWindowId = wid; - mTaskbarMessageId = RegisterWindowMessage(L"TaskbarButtonCreated"); -} - -// Windows event handler callback function -// (handles taskbar communication initial message) -bool EcWin7::winEvent(MSG * message, long * result) -{ - if (message->message == mTaskbarMessageId) - { - HRESULT hr = CoCreateInstance(CLSID_TaskbarList, - 0, - CLSCTX_INPROC_SERVER, - IID_ITaskbarList3, - reinterpret_cast (&(mTaskbar))); - *result = hr; - return true; - } - return false; -} - -// Set progress bar current value -void EcWin7::setProgressValue(int value, int max) -{ - mTaskbar->SetProgressValue(mWindowId, value, max); - -} - -// Set progress bar current state (active, error, pause, ecc...) -void EcWin7::setProgressState(ToolBarProgressState state) -{ - mTaskbar->SetProgressState(mWindowId, (TBPFLAG)state); -} - -// Set new overlay icon and corresponding description (for accessibility) -// (call with iconName == "" and description == "" to remove any previous overlay icon) -void EcWin7::setOverlayIcon(QString iconName, QString description) -{ - HICON oldIcon = NULL; - if (mOverlayIcon != NULL) oldIcon = mOverlayIcon; - if (iconName == "") - { - mTaskbar->SetOverlayIcon(mWindowId, NULL, NULL); - mOverlayIcon = NULL; - } - else - { - mOverlayIcon = (HICON) LoadImage(GetModuleHandle(NULL), - iconName.toStdWString().c_str(), - IMAGE_ICON, - 0, - 0, - NULL); - mTaskbar->SetOverlayIcon(mWindowId, mOverlayIcon, description.toStdWString().c_str()); - } - if ((oldIcon != NULL) && (oldIcon != mOverlayIcon)) - { - DestroyIcon(oldIcon); - } -} -#endif +/* EcWin7 - Support library for integrating Windows 7 taskbar features + * into any Qt application + * Copyright (C) 2010 Emanuele Colombo + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "ecwin7.h" + +// Windows only definitions +#ifdef W7API +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); + +// Constructor: variabiles initialization +EcWin7::EcWin7() +{ + mOverlayIcon = NULL; +} + +// Init taskbar communication +void EcWin7::init(WId wid) +{ + mWindowId = wid; + mTaskbarMessageId = RegisterWindowMessage(L"TaskbarButtonCreated"); +} + +// Windows event handler callback function +// (handles taskbar communication initial message) +bool EcWin7::winEvent(MSG * message, long * result) +{ + if (message->message == mTaskbarMessageId) + { + HRESULT hr = CoCreateInstance(CLSID_TaskbarList, + 0, + CLSCTX_INPROC_SERVER, + IID_ITaskbarList3, + reinterpret_cast (&(mTaskbar))); + *result = hr; + return true; + } + return false; +} + +// Set progress bar current value +void EcWin7::setProgressValue(int value, int max) +{ + mTaskbar->SetProgressValue(mWindowId, value, max); + +} + +// Set progress bar current state (active, error, pause, ecc...) +void EcWin7::setProgressState(ToolBarProgressState state) +{ + mTaskbar->SetProgressState(mWindowId, (TBPFLAG)state); +} + +// Set new overlay icon and corresponding description (for accessibility) +// (call with iconName == "" and description == "" to remove any previous overlay icon) +void EcWin7::setOverlayIcon(QString iconName, QString description) +{ + HICON oldIcon = NULL; + if (mOverlayIcon != NULL) oldIcon = mOverlayIcon; + if (iconName == "") + { + mTaskbar->SetOverlayIcon(mWindowId, NULL, NULL); + mOverlayIcon = NULL; + } + else + { + mOverlayIcon = (HICON) LoadImage(GetModuleHandle(NULL), + iconName.toStdWString().c_str(), + IMAGE_ICON, + 0, + 0, + NULL); + mTaskbar->SetOverlayIcon(mWindowId, mOverlayIcon, description.toStdWString().c_str()); + } + if ((oldIcon != NULL) && (oldIcon != mOverlayIcon)) + { + DestroyIcon(oldIcon); + } +} +#endif diff --git a/src/3rdparty/ecwin7.h b/src/3rdparty/ecwin7.h index 6877faf22..de83ca779 100644 --- a/src/3rdparty/ecwin7.h +++ b/src/3rdparty/ecwin7.h @@ -24,7 +24,7 @@ #include // Windows only data definitions -#ifdef W7TASKBAR +#ifdef W7API #include #include diff --git a/src/QupZilla.pro b/src/QupZilla.pro index 77ebcff84..27f1178da 100644 --- a/src/QupZilla.pro +++ b/src/QupZilla.pro @@ -210,4 +210,5 @@ OTHER_FILES += \ include(3rdparty/qtsingleapplication.pri) win32:RC_FILE = appicon.rc -#win32:LIBS += libole32 +win32:LIBS += User32.lib +win32:LIBS += Ole32.lib diff --git a/src/app/commandlineoptions.cpp b/src/app/commandlineoptions.cpp index 5e6e45bdb..494f27c1f 100644 --- a/src/app/commandlineoptions.cpp +++ b/src/app/commandlineoptions.cpp @@ -20,10 +20,8 @@ CommandLineOptions::CommandLineOptions(int &argc, char **argv) : QObject(0) - ,m_actionString("") ,m_argc(argc) ,m_argv(argv) - ,m_action(NoAction) { parseActions(); } @@ -43,9 +41,11 @@ void CommandLineOptions::showHelp() "\n" " QupZilla is a new, fast and secure web browser\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() @@ -80,13 +80,18 @@ void CommandLineOptions::parseActions() arg.remove("-profile="); found = true; cout << "starting with profile " << arg.toAscii().data() << endl; - m_actionString = arg; - m_action = StartWithProfile; + QPair pair; + pair.first = StartWithProfile; + pair.second = arg; + m_actions.append(pair); } if (arg.startsWith("-np") || arg.startsWith("-no-plugins")) { found = true; - m_action = StartWithoutAddons; + QPair 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("-")) { found = true; cout << "starting with url " << url.toAscii().data() << endl; - m_actionString = url; - m_action = OpenUrl; + QPair pair; + pair.first = OpenUrl; + pair.second = url; + m_actions.append(pair); } 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; -} - - diff --git a/src/app/commandlineoptions.h b/src/app/commandlineoptions.h index 4b3611359..7443a79ef 100644 --- a/src/app/commandlineoptions.h +++ b/src/app/commandlineoptions.h @@ -19,7 +19,7 @@ #define COMMANDLINEOPTIONS_H #include - +#include #include class CommandLineOptions : public QObject @@ -28,17 +28,15 @@ class CommandLineOptions : public QObject public: enum Action {NoAction, OpenUrl, StartWithProfile, StartWithoutAddons}; explicit CommandLineOptions(int &argc, char **argv); - Action getAction(); - QString getActionString(); + QList > getActions() { return m_actions; } private: void showHelp(); void parseActions(); - QString m_actionString; int m_argc; char **m_argv; - Action m_action; + QList > m_actions; }; #endif // COMMANDLINEOPTIONS_H diff --git a/src/app/mainapplication.cpp b/src/app/mainapplication.cpp index 0ac2c0bf9..b40dbc799 100644 --- a/src/app/mainapplication.cpp +++ b/src/app/mainapplication.cpp @@ -64,20 +64,28 @@ MainApplication::MainApplication(int &argc, char **argv) bool noAddons = false; QUrl startUrl(""); QString message; + QString startProfile; if (argc > 1) { CommandLineOptions cmd(argc, argv); - switch (cmd.getAction()) { - case CommandLineOptions::StartWithoutAddons: - noAddons = true; - break; - case CommandLineOptions::OpenUrl: - startUrl = QUrl(cmd.getActionString()); - message = "URL:"+startUrl.toString(); - break; - default: - m_isExited = true; - return; - break; + QList > cmdActions = cmd.getActions(); + for (int i = 0; i < cmdActions.count(); i++) { + QPair act = cmdActions.at(i); + switch (act.first) { + case CommandLineOptions::StartWithoutAddons: + noAddons = true; + break; + case CommandLineOptions::OpenUrl: + startUrl = act.second; + message = "URL:"+startUrl.toString(); + 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(); QSettings::setDefaultFormat(QSettings::IniFormat); - QSettings settings(homePath+"profiles/profiles.ini", QSettings::IniFormat); - if (settings.value("Profiles/startProfile","default").toString().contains("/")) - m_activeProfil=homePath+"profiles/default/"; - else - m_activeProfil=homePath+"profiles/"+settings.value("Profiles/startProfile","default").toString()+"/"; + if (startProfile.isEmpty()) { + QSettings settings(homePath+"profiles/profiles.ini", QSettings::IniFormat); + if (settings.value("Profiles/startProfile","default").toString().contains("/")) + m_activeProfil=homePath+"profiles/default/"; + else + m_activeProfil=homePath+"profiles/"+settings.value("Profiles/startProfile","default").toString()+"/"; + } else + m_activeProfil = homePath+"profiles/"+startProfile+"/"; + if (!QDir(m_activeProfil).exists()) m_activeProfil=homePath+"profiles/default/"; diff --git a/src/app/qupzilla.cpp b/src/app/qupzilla.cpp index 3c47411dd..cd4fe3f09 100644 --- a/src/app/qupzilla.cpp +++ b/src/app/qupzilla.cpp @@ -48,7 +48,11 @@ #include "clickablelabel.h" 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"); +#else +const QString QupZilla::BUILDTIME = __DATE__" "__TIME__; +#endif const QString QupZilla::AUTHOR = "nowrep"; const QString QupZilla::COPYRIGHT = "2010-2011"; const QString QupZilla::WWWADDRESS = "http://qupzilla.ic.cz"; diff --git a/src/downloads/downloadmanager.cpp b/src/downloads/downloadmanager.cpp index d60358296..13118321f 100644 --- a/src/downloads/downloadmanager.cpp +++ b/src/downloads/downloadmanager.cpp @@ -46,12 +46,12 @@ DownloadManager::DownloadManager(QWidget* parent) : connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearList())); -#ifdef W7TASKBAR +#ifdef W7API win7.init(this->winId()); #endif } -#ifdef W7TASKBAR +#ifdef W7API bool DownloadManager::winEvent(MSG* message, long* result) { return win7.winEvent(message, result); @@ -107,7 +107,7 @@ void DownloadManager::timerEvent(QTimerEvent* event) DownloadItem::currentSpeedToString(speed), DownloadItem::remaingTimeToString(remaining))); setWindowTitle(QString::number(progress) + tr("% - Download Manager")); -#ifdef W7TASKBAR +#ifdef W7API win7.setProgressValue(progress, 100); win7.setProgressState(win7.Normal); #endif diff --git a/src/downloads/downloadmanager.h b/src/downloads/downloadmanager.h index b42cbb772..fb360c06c 100644 --- a/src/downloads/downloadmanager.h +++ b/src/downloads/downloadmanager.h @@ -59,7 +59,7 @@ public: void show() { m_timer.start(1000*2, this); QWidget::show(); } -#ifdef W7TASKBAR +#ifdef W7API protected: virtual bool winEvent(MSG* message, long* result); #endif @@ -69,7 +69,7 @@ private slots: void deleteItem(DownloadItem* item); private: -#ifdef W7TASKBAR +#ifdef W7API EcWin7 win7; #endif void timerEvent(QTimerEvent* event); diff --git a/src/webview/siteinfo.ui b/src/webview/siteinfo.ui index 52bcdf330..f68bd55cf 100644 --- a/src/webview/siteinfo.ui +++ b/src/webview/siteinfo.ui @@ -71,7 +71,7 @@ QListView::IconMode - true + false 0 diff --git a/src/webview/tabwidget.cpp b/src/webview/tabwidget.cpp index 6a67fc5cb..2df8a662e 100644 --- a/src/webview/tabwidget.cpp +++ b/src/webview/tabwidget.cpp @@ -35,7 +35,11 @@ public: QSize sizeHint() const { QSize siz = QToolButton::sizeHint(); +#ifdef Q_WS_X11 siz.setWidth(25); +#else + siz.setWidth(26); +#endif return siz; } @@ -50,7 +54,11 @@ private: QPixmap pix(":/icons/other/list-add.png"); QRect r = this->rect(); r.setHeight(r.height()+3); +#ifdef Q_WS_X11 r.setWidth(r.width()-1); +#else + r.setWidth(r.width()+3); +#endif style()->drawItemPixmap(&p, r, Qt::AlignCenter, pix); } };