1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

SearchEnginesDialog: Default search engine is now painted with bold font

+ coding style
This commit is contained in:
nowrep 2012-09-28 18:44:45 +02:00
parent 06bf7d845f
commit 0459f0864c
5 changed files with 132 additions and 135 deletions

View File

@ -38,66 +38,66 @@ typedef interface IObjectCollection IObjectCollection;
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************************************
IObjectArray
/*
****************************************************************************************************
IObjectArray
<from ObjectArray.h>
****************************************************************************************************
*/
<from ObjectArray.h>
****************************************************************************************************
*/
#ifndef __IObjectArray_INTERFACE_DEFINED__
#define __IObjectArray_INTERFACE_DEFINED__
/* interface IObjectArray */
/* [unique][object][uuid][helpstring] */
/* interface IObjectArray */
/* [unique][object][uuid][helpstring] */
EXTERN_C const IID IID_IObjectArray;
EXTERN_C const IID IID_IObjectArray;
MIDL_INTERFACE("92CA9DCD-5622-4bba-A805-5E9F541BD8C9")
MIDL_INTERFACE("92CA9DCD-5622-4bba-A805-5E9F541BD8C9")
IObjectArray : public IUnknown {
public:
virtual HRESULT STDMETHODCALLTYPE GetCount(
/* [out] */ __RPC__out UINT * pcObjects) = 0;
public:
virtual HRESULT STDMETHODCALLTYPE GetCount(
/* [out] */ __RPC__out UINT * pcObjects) = 0;
virtual HRESULT STDMETHODCALLTYPE GetAt(
/* [in] */ UINT uiIndex,
/* [in] */ __RPC__in REFIID riid,
/* [iid_is][out] */ __RPC__deref_out_opt void** ppv) = 0;
virtual HRESULT STDMETHODCALLTYPE GetAt(
/* [in] */ UINT uiIndex,
/* [in] */ __RPC__in REFIID riid,
/* [iid_is][out] */ __RPC__deref_out_opt void** ppv) = 0;
};
};
#endif /* __IObjectArray_INTERFACE_DEFINED__ */
#ifndef __IObjectCollection_INTERFACE_DEFINED__
#define __IObjectCollection_INTERFACE_DEFINED__
/* interface IObjectCollection */
/* [unique][object][uuid] */
/* interface IObjectCollection */
/* [unique][object][uuid] */
EXTERN_C const IID IID_IObjectCollection;
EXTERN_C const IID IID_IObjectCollection;
MIDL_INTERFACE("5632b1a4-e38a-400a-928a-d4cd63230295")
MIDL_INTERFACE("5632b1a4-e38a-400a-928a-d4cd63230295")
IObjectCollection : public IObjectArray {
public:
virtual HRESULT STDMETHODCALLTYPE AddObject(
/* [in] */ __RPC__in_opt IUnknown * punk) = 0;
public:
virtual HRESULT STDMETHODCALLTYPE AddObject(
/* [in] */ __RPC__in_opt IUnknown * punk) = 0;
virtual HRESULT STDMETHODCALLTYPE AddFromArray(
/* [in] */ __RPC__in_opt IObjectArray * poaSource) = 0;
virtual HRESULT STDMETHODCALLTYPE AddFromArray(
/* [in] */ __RPC__in_opt IObjectArray * poaSource) = 0;
virtual HRESULT STDMETHODCALLTYPE RemoveObjectAt(
/* [in] */ UINT uiIndex) = 0;
virtual HRESULT STDMETHODCALLTYPE RemoveObjectAt(
/* [in] */ UINT uiIndex) = 0;
virtual HRESULT STDMETHODCALLTYPE Clear(void) = 0;
virtual HRESULT STDMETHODCALLTYPE Clear(void) = 0;
};
};
#endif /* __IObjectCollection_INTERFACE_DEFINED__ */
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
@ -189,13 +189,13 @@ class DECLSPEC_UUID("77f10cf0-3db5-4966-b520-b7c54fd35ed6")
*/
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
extern "C++" { \
inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) | ((int)b)); } \
inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) & ((int)b)); } \
inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \
inline ENUMTYPE operator ~ (ENUMTYPE a) { return ENUMTYPE(~((int)a)); } \
inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) ^ ((int)b)); } \
inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \
inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) | ((int)b)); } \
inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) & ((int)b)); } \
inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \
inline ENUMTYPE operator ~ (ENUMTYPE a) { return ENUMTYPE(~((int)a)); } \
inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) ^ ((int)b)); } \
inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \
}
#ifdef MIDL_PASS
@ -261,57 +261,57 @@ EXTERN_C const IID IID_ITaskbarList3;
MIDL_INTERFACE("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf")
ITaskbarList3 : public ITaskbarList2 {
public:
virtual HRESULT STDMETHODCALLTYPE SetProgressValue(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ ULONGLONG ullCompleted,
/* [in] */ ULONGLONG ullTotal) = 0;
virtual HRESULT STDMETHODCALLTYPE SetProgressValue(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ ULONGLONG ullCompleted,
/* [in] */ ULONGLONG ullTotal) = 0;
virtual HRESULT STDMETHODCALLTYPE SetProgressState(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ TBPFLAG tbpFlags) = 0;
virtual HRESULT STDMETHODCALLTYPE SetProgressState(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ TBPFLAG tbpFlags) = 0;
virtual HRESULT STDMETHODCALLTYPE RegisterTab(
/* [in] */ __RPC__in HWND hwndTab,
/* [in] */ __RPC__in HWND hwndMDI) = 0;
virtual HRESULT STDMETHODCALLTYPE RegisterTab(
/* [in] */ __RPC__in HWND hwndTab,
/* [in] */ __RPC__in HWND hwndMDI) = 0;
virtual HRESULT STDMETHODCALLTYPE UnregisterTab(
/* [in] */ __RPC__in HWND hwndTab) = 0;
virtual HRESULT STDMETHODCALLTYPE UnregisterTab(
/* [in] */ __RPC__in HWND hwndTab) = 0;
virtual HRESULT STDMETHODCALLTYPE SetTabOrder(
/* [in] */ __RPC__in HWND hwndTab,
/* [in] */ __RPC__in HWND hwndInsertBefore) = 0;
virtual HRESULT STDMETHODCALLTYPE SetTabOrder(
/* [in] */ __RPC__in HWND hwndTab,
/* [in] */ __RPC__in HWND hwndInsertBefore) = 0;
virtual HRESULT STDMETHODCALLTYPE SetTabActive(
/* [in] */ __RPC__in HWND hwndTab,
/* [in] */ __RPC__in HWND hwndMDI,
/* [in] */ DWORD dwReserved) = 0;
virtual HRESULT STDMETHODCALLTYPE SetTabActive(
/* [in] */ __RPC__in HWND hwndTab,
/* [in] */ __RPC__in HWND hwndMDI,
/* [in] */ DWORD dwReserved) = 0;
virtual HRESULT STDMETHODCALLTYPE ThumbBarAddButtons(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ UINT cButtons,
/* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton) = 0;
virtual HRESULT STDMETHODCALLTYPE ThumbBarAddButtons(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ UINT cButtons,
/* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton) = 0;
virtual HRESULT STDMETHODCALLTYPE ThumbBarUpdateButtons(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ UINT cButtons,
/* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton) = 0;
virtual HRESULT STDMETHODCALLTYPE ThumbBarUpdateButtons(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ UINT cButtons,
/* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton) = 0;
virtual HRESULT STDMETHODCALLTYPE ThumbBarSetImageList(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ __RPC__in_opt HIMAGELIST himl) = 0;
virtual HRESULT STDMETHODCALLTYPE ThumbBarSetImageList(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ __RPC__in_opt HIMAGELIST himl) = 0;
virtual HRESULT STDMETHODCALLTYPE SetOverlayIcon(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ __RPC__in HICON hIcon,
/* [string][unique][in] */ __RPC__in_opt_string LPCWSTR pszDescription) = 0;
virtual HRESULT STDMETHODCALLTYPE SetOverlayIcon(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ __RPC__in HICON hIcon,
/* [string][unique][in] */ __RPC__in_opt_string LPCWSTR pszDescription) = 0;
virtual HRESULT STDMETHODCALLTYPE SetThumbnailTooltip(
/* [in] */ __RPC__in HWND hwnd,
/* [string][unique][in] */ __RPC__in_opt_string LPCWSTR pszTip) = 0;
virtual HRESULT STDMETHODCALLTYPE SetThumbnailTooltip(
/* [in] */ __RPC__in HWND hwnd,
/* [string][unique][in] */ __RPC__in_opt_string LPCWSTR pszTip) = 0;
virtual HRESULT STDMETHODCALLTYPE SetThumbnailClip(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ __RPC__in RECT * prcClip) = 0;
virtual HRESULT STDMETHODCALLTYPE SetThumbnailClip(
/* [in] */ __RPC__in HWND hwnd,
/* [in] */ __RPC__in RECT * prcClip) = 0;
};
#endif //_MSC_VER >= 1500 && _MSC_VER < 1600

View File

@ -28,6 +28,8 @@
#include <QSqlQuery>
#include <QTimer>
#define HIDE_DELAY 270
BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* parent)
: LocationBarPopup(parent)
, ui(new Ui::BookmarksWidget)
@ -84,11 +86,6 @@ void BookmarksWidget::loadBookmark()
ui->name->setCursorPosition(0);
}
namespace
{
const int hideDelay = 270;
}
void BookmarksWidget::toggleSpeedDial()
{
const SpeedDial::Page &page = m_speedDial->pageForUrl(m_url);
@ -101,7 +98,7 @@ void BookmarksWidget::toggleSpeedDial()
else {
m_speedDial->removePage(page);
}
QTimer::singleShot(hideDelay, this, SLOT(close()));
QTimer::singleShot(HIDE_DELAY, this, SLOT(close()));
}
void BookmarksWidget::bookmarkEdited()
@ -128,7 +125,7 @@ void BookmarksWidget::on_saveRemove_clicked(bool)
else {
m_bookmarksModel->saveBookmark(m_url, ui->name->text(), m_view->icon(), ui->folder->currentText());
}
QTimer::singleShot(hideDelay, this, SLOT(close()));
QTimer::singleShot(HIDE_DELAY, this, SLOT(close()));
}
BookmarksWidget::~BookmarksWidget()

View File

@ -18,44 +18,9 @@
#include "searchenginesdialog.h"
#include "ui_searchenginesdialog.h"
#include "editsearchengine.h"
#include "searchenginesmanager.h"
#include "mainapplication.h"
#include <QMessageBox>
namespace
{
const int EngineRole = Qt::UserRole;
const int DefaultRole = Qt::UserRole + 1;
bool isDefault(QTreeWidgetItem* item)
{
return item->data(0, DefaultRole).toBool();
}
SearchEngine getEngine(QTreeWidgetItem* item)
{
return item->data(0, EngineRole).value<SearchEngine>();
}
void setEngine(QTreeWidgetItem* item, SearchEngine engine)
{
QVariant v;
v.setValue<SearchEngine>(engine);
item->setData(0, EngineRole, v);
}
void changeItemToDefault(QTreeWidgetItem* item, bool isDefault)
{
QString txt = item->data(0, EngineRole).value<SearchEngine>().name;
if (isDefault) {
txt.append(QString(" (%1)").arg(QObject::tr("Default")));
}
item->setText(0, txt);
item->setData(0, DefaultRole, isDefault);
}
}
SearchEnginesDialog::SearchEnginesDialog(QWidget* parent)
: QDialog(parent)
, ui(new Ui::SearchEnginesDialog)
@ -114,7 +79,7 @@ void SearchEnginesDialog::removeEngine()
return;
}
if (isDefault(item)) {
if (isDefaultEngine(item)) {
SearchEngine en = getEngine(item);
QMessageBox::warning(this, tr("Remove Engine"),
tr("You can't remove the default search engine.<br>"
@ -156,7 +121,7 @@ void SearchEnginesDialog::editEngine()
setEngine(item, engine);
changeItemToDefault(item, isDefault(item));
changeItemToDefault(item, isDefaultEngine(item));
item->setIcon(0, engine.icon);
item->setText(1, engine.shortcut);
}
@ -170,7 +135,7 @@ void SearchEnginesDialog::setDefaultEngine()
for (int j = 0; j < ui->treeWidget->topLevelItemCount(); ++j) {
QTreeWidgetItem* i = ui->treeWidget->topLevelItem(j);
if (isDefault(i)) {
if (isDefaultEngine(i)) {
if (i == item) {
return;
}
@ -188,6 +153,34 @@ void SearchEnginesDialog::defaults()
reloadEngines();
}
bool SearchEnginesDialog::isDefaultEngine(QTreeWidgetItem* item)
{
return item->data(0, DefaultRole).toBool();
}
SearchEngine SearchEnginesDialog::getEngine(QTreeWidgetItem* item)
{
return item->data(0, EngineRole).value<SearchEngine>();
}
void SearchEnginesDialog::setEngine(QTreeWidgetItem* item, SearchEngine engine)
{
QVariant v;
v.setValue<SearchEngine>(engine);
item->setData(0, EngineRole, v);
item->setText(0, engine.name);
}
void SearchEnginesDialog::changeItemToDefault(QTreeWidgetItem* item, bool isDefault)
{
QFont font = item->font(0);
font.setBold(isDefault);
item->setFont(0, font);
item->setFont(1, font);
item->setData(0, DefaultRole, isDefault);
}
void SearchEnginesDialog::moveUp()
{
QTreeWidgetItem* currentItem = ui->treeWidget->currentItem();
@ -249,7 +242,7 @@ void SearchEnginesDialog::accept()
SearchEngine engine = getEngine(item);
allEngines.append(engine);
if (isDefault(item)) {
if (isDefaultEngine(item)) {
m_manager->setDefaultEngine(engine);
}
}

View File

@ -19,6 +19,7 @@
#define SEARCHENGINESDIALOG_H
#include "qz_namespace.h"
#include "searchenginesmanager.h"
#include <QDialog>
@ -29,7 +30,6 @@ namespace Ui
class SearchEnginesDialog;
}
class SearchEnginesManager;
class QT_QUPZILLA_EXPORT SearchEnginesDialog : public QDialog
{
Q_OBJECT
@ -53,10 +53,17 @@ private slots:
void defaults();
private:
enum TreeRole { EngineRole = Qt::UserRole, DefaultRole = Qt::UserRole + 1 };
bool isDefaultEngine(QTreeWidgetItem* item);
SearchEngine getEngine(QTreeWidgetItem* item);
void setEngine(QTreeWidgetItem* item, SearchEngine engine);
void changeItemToDefault(QTreeWidgetItem* item, bool isDefault);
void reloadEngines();
Ui::SearchEnginesDialog* ui;
SearchEnginesManager* m_manager;
};

View File

@ -37,13 +37,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="setAsDefault">
<property name="text">
<string>Set as Default</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@ -57,6 +50,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="setAsDefault">
<property name="text">
<string>Set as Default</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moveUp">
<property name="text">