summaryrefslogtreecommitdiff
path: root/src/tabwindow
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-09-19 23:22:13 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:05 +0100
commite315ff15daf26cbc70b6f2da50e6ca18081fc7c4 (patch)
tree6da0556f2c5c7efb13d8e8b03ba0092e7a5838d3 /src/tabwindow
parentImplement RekonqWindow (diff)
downloadrekonq-e315ff15daf26cbc70b6f2da50e6ca18081fc7c4.tar.xz
Integrated spell checking for rekonq2 (lindsay's work imported)
- inline spell highlighter. This requires WebKit 2.3 to work. - Addition of a suggested replacement word list to the context menu, for the word right clicked on - A standard modeless spell check dialog that works on the current editable text (or selection). Heavily cribbed from Dawit's work on kdewebkitpart. oops... also a codingstyle script round here... :)
Diffstat (limited to 'src/tabwindow')
-rw-r--r--src/tabwindow/rekonqwindow.cpp90
-rw-r--r--src/tabwindow/rekonqwindow.h26
-rw-r--r--src/tabwindow/tabbar.cpp10
-rw-r--r--src/tabwindow/tabbar.h6
-rw-r--r--src/tabwindow/tabpreviewpopup.h2
-rw-r--r--src/tabwindow/tabwindow.cpp18
-rw-r--r--src/tabwindow/tabwindow.h2
7 files changed, 81 insertions, 73 deletions
diff --git a/src/tabwindow/rekonqwindow.cpp b/src/tabwindow/rekonqwindow.cpp
index f3e321bb..970c73e5 100644
--- a/src/tabwindow/rekonqwindow.cpp
+++ b/src/tabwindow/rekonqwindow.cpp
@@ -53,33 +53,40 @@ public:
{
}
- bool dummyInit() { return true; }
+ bool dummyInit()
+ {
+ return true;
+ }
- bool saveState( QSessionManager& )
+ bool saveState(QSessionManager&)
{
KConfig* config = KApplication::kApplication()->sessionConfig();
int n = 0;
- Q_FOREACH (RekonqWindow* rw, RekonqWindow::windowList()) {
+ Q_FOREACH(RekonqWindow * rw, RekonqWindow::windowList())
+ {
n++;
rw->savePropertiesInternal(config, n);
}
- KConfigGroup group( config, "Number" );
- group.writeEntry("NumberOfWindows", n );
+ KConfigGroup group(config, "Number");
+ group.writeEntry("NumberOfWindows", n);
return true;
}
- bool commitData( QSessionManager& sm )
+ bool commitData(QSessionManager& sm)
{
// not really a fast method but the only compatible one
- if ( sm.allowsInteraction() ) {
+ if (sm.allowsInteraction())
+ {
bool canceled = false;
::s_no_query_exit = true;
- Q_FOREACH (RekonqWindow *window, RekonqWindow::windowList()) {
- if ( !window->testAttribute( Qt::WA_WState_Hidden ) ) {
+ Q_FOREACH(RekonqWindow * window, RekonqWindow::windowList())
+ {
+ if (!window->testAttribute(Qt::WA_WState_Hidden))
+ {
QCloseEvent e;
- QApplication::sendEvent( window, &e );
+ QApplication::sendEvent(window, &e);
canceled = !e.isAccepted();
if (canceled)
break;
@@ -87,7 +94,7 @@ public:
}
::s_no_query_exit = false;
if (canceled)
- return false;
+ return false;
return true;
}
@@ -123,7 +130,7 @@ RekonqWindow::RekonqWindow(QWidget* parent)
if (args && args->isSet("geometry"))
geometry = args->getOption("geometry");
- if ( geometry.isNull() ) // if there is no geometry, it doesn't matter
+ if (geometry.isNull()) // if there is no geometry, it doesn't matter
{
KSharedConfig::Ptr cf = KGlobal::config();
KConfigGroup cg(cf, QL1S("TabWindow"));
@@ -133,14 +140,14 @@ RekonqWindow::RekonqWindow(QWidget* parent)
{
parseGeometry();
}
-
- setWindowTitle( KGlobal::caption() );
+
+ setWindowTitle(KGlobal::caption());
}
RekonqWindow::~RekonqWindow()
{
- sWindowList->removeAll( this );
+ sWindowList->removeAll(this);
KSharedConfig::Ptr cf = KGlobal::config();
KConfigGroup cg(cf, QL1S("TabWindow"));
@@ -150,11 +157,11 @@ RekonqWindow::~RekonqWindow()
QList<RekonqWindow*> RekonqWindow::windowList()
{
- return *sWindowList;
+ return *sWindowList;
}
-void RekonqWindow::savePropertiesInternal( KConfig *config, int number )
+void RekonqWindow::savePropertiesInternal(KConfig *config, int number)
{
QString s;
s.setNum(number);
@@ -174,7 +181,7 @@ void RekonqWindow::savePropertiesInternal( KConfig *config, int number )
}
-bool RekonqWindow::readPropertiesInternal( KConfig *config, int number )
+bool RekonqWindow::readPropertiesInternal(KConfig *config, int number)
{
// in order they are in toolbar list
QString s;
@@ -184,8 +191,8 @@ bool RekonqWindow::readPropertiesInternal( KConfig *config, int number )
KConfigGroup cg(config, s);
// restore the object name (window role)
- if ( cg.hasKey(QL1S("ObjectName" )) )
- setObjectName( cg.readEntry("ObjectName").toLatin1()); // latin1 is right here
+ if (cg.hasKey(QL1S("ObjectName")))
+ setObjectName(cg.readEntry("ObjectName").toLatin1()); // latin1 is right here
restoreWindowSize(cg);
@@ -197,7 +204,7 @@ bool RekonqWindow::readPropertiesInternal( KConfig *config, int number )
}
-void RekonqWindow::restoreWindowSize( const KConfigGroup & _cg )
+void RekonqWindow::restoreWindowSize(const KConfigGroup & _cg)
{
int scnum = QApplication::desktop()->screenNumber(window());
QRect desktopRect = QApplication::desktop()->screenGeometry(scnum);
@@ -207,22 +214,22 @@ void RekonqWindow::restoreWindowSize( const KConfigGroup & _cg )
KConfigGroup cg(_cg);
QString widthString = QString::fromLatin1("Width %1").arg(desktopRect.width());
- int w = cg.readEntry(widthString, defaultSize.width() );
+ int w = cg.readEntry(widthString, defaultSize.width());
QString heightString = QString::fromLatin1("Height %1").arg(desktopRect.height());
- int h = cg.readEntry(heightString, defaultSize.height() );
+ int h = cg.readEntry(heightString, defaultSize.height());
resize(w, h);
QString geometryKey = QString::fromLatin1("geometry-%1-%2").arg(desktopRect.width()).arg(desktopRect.height());
- QByteArray geometry = cg.readEntry( geometryKey, QByteArray() );
+ QByteArray geometry = cg.readEntry(geometryKey, QByteArray());
// if first time run, center window
- if (!restoreGeometry( QByteArray::fromBase64(geometry) ))
- move( (desktopRect.width()-width())/2, (desktopRect.height()-height())/2 );
+ if (!restoreGeometry(QByteArray::fromBase64(geometry)))
+ move((desktopRect.width() - width()) / 2, (desktopRect.height() - height()) / 2);
}
-void RekonqWindow::saveWindowSize( const KConfigGroup & _cg ) const
+void RekonqWindow::saveWindowSize(const KConfigGroup & _cg) const
{
int scnum = QApplication::desktop()->screenNumber(window());
QRect desktopRect = QApplication::desktop()->screenGeometry(scnum);
@@ -242,15 +249,15 @@ void RekonqWindow::saveWindowSize( const KConfigGroup & _cg ) const
KConfigGroup cg(_cg);
QString widthString = QString::fromLatin1("Width %1").arg(desktopRect.width());
- cg.writeEntry(widthString, w );
+ cg.writeEntry(widthString, w);
QString heightString = QString::fromLatin1("Height %1").arg(desktopRect.height());
- cg.writeEntry(heightString, h );
+ cg.writeEntry(heightString, h);
// geometry is saved separately for each resolution
QString geometryKey = QString::fromLatin1("geometry-%1-%2").arg(desktopRect.width()).arg(desktopRect.height());
QByteArray geometry = saveGeometry();
- cg.writeEntry( geometryKey, geometry.toBase64() );
+ cg.writeEntry(geometryKey, geometry.toBase64());
}
@@ -261,7 +268,7 @@ void RekonqWindow::parseGeometry()
if (args->isSet("geometry"))
cmdlineGeometry = args->getOption("geometry");
- Q_ASSERT ( !cmdlineGeometry.isNull() );
+ Q_ASSERT(!cmdlineGeometry.isNull());
// #if defined Q_WS_X11
// int x, y;
@@ -288,7 +295,7 @@ void RekonqWindow::parseGeometry()
// y = KApplication::desktop()->height() + y - h;
// else if ( (m & YValue) )
// y = geometry().y();
-//
+//
// move(x, y);
// }
// #endif
@@ -312,27 +319,28 @@ void RekonqWindow::saveAutoSaveSettings()
}
-bool RekonqWindow::canBeRestored( int number )
+bool RekonqWindow::canBeRestored(int number)
{
- if ( !qApp->isSessionRestored() )
+ if (!qApp->isSessionRestored())
return false;
KConfig *config = kapp->sessionConfig();
- if ( !config )
+ if (!config)
return false;
- KConfigGroup group( config, "Number" );
- const int n = group.readEntry( "NumberOfWindows", 1 );
+ KConfigGroup group(config, "Number");
+ const int n = group.readEntry("NumberOfWindows", 1);
return number >= 1 && number <= n;
}
-bool RekonqWindow::restore( int number, bool show )
+bool RekonqWindow::restore(int number, bool show)
{
- if ( !canBeRestored( number ) )
+ if (!canBeRestored(number))
return false;
KConfig *config = kapp->sessionConfig();
- if ( readPropertiesInternal( config, number ) ){
- if ( show )
+ if (readPropertiesInternal(config, number))
+ {
+ if (show)
RekonqWindow::show();
return false;
}
diff --git a/src/tabwindow/rekonqwindow.h b/src/tabwindow/rekonqwindow.h
index b3f2f698..c7fe80d1 100644
--- a/src/tabwindow/rekonqwindow.h
+++ b/src/tabwindow/rekonqwindow.h
@@ -52,11 +52,11 @@
class RekonqWindow : public KTabWidget
{
friend class KRWSessionManager;
-
+
Q_OBJECT
public:
- explicit RekonqWindow( QWidget* parent = 0 );
+ explicit RekonqWindow(QWidget* parent = 0);
virtual ~RekonqWindow();
@@ -70,16 +70,16 @@ public:
* else @p false.
* @see restore()
**/
- static bool canBeRestored( int number );
+ static bool canBeRestored(int number);
/**
* Try to restore the toplevel widget as defined by @p number (1..X).
*
* You should call canBeRestored() first.
- *
+ *
**/
- bool restore( int number, bool show = true );
-
+ bool restore(int number, bool show = true);
+
protected:
/**
* Save your instance-specific properties. The function is
@@ -92,33 +92,33 @@ protected:
* in this function!
*
*/
- virtual void saveProperties( KConfigGroup & ) {}
+ virtual void saveProperties(KConfigGroup &) {}
/**
* Read your instance-specific properties.
*
* Is called indirectly by restore().
*/
- virtual void readProperties( const KConfigGroup & ) {}
+ virtual void readProperties(const KConfigGroup &) {}
- void savePropertiesInternal( KConfig*, int );
- bool readPropertiesInternal( KConfig*, int );
+ void savePropertiesInternal(KConfig*, int);
+ bool readPropertiesInternal(KConfig*, int);
/**
* For inherited classes
*/
- void saveWindowSize( const KConfigGroup &config ) const;
+ void saveWindowSize(const KConfigGroup &config) const;
/**
* For inherited classes
* Note that a -geometry on the command line has priority.
*/
- void restoreWindowSize( const KConfigGroup & config );
+ void restoreWindowSize(const KConfigGroup & config);
/// parse the geometry from the geometry command line argument
void parseGeometry();
virtual void resizeEvent(QResizeEvent *);
-
+
private Q_SLOTS:
void saveAutoSaveSettings();
diff --git a/src/tabwindow/tabbar.cpp b/src/tabwindow/tabbar.cpp
index 91d5e402..18393cf9 100644
--- a/src/tabwindow/tabbar.cpp
+++ b/src/tabwindow/tabbar.cpp
@@ -304,7 +304,7 @@ void TabBar::setTabHighlighted(int index, bool b)
connect(anim, SIGNAL(finished()), m_animationMapper, SLOT(map()));
setTabTextColor(index, highlightColor);
- }
+ }
}
@@ -354,7 +354,7 @@ void TabBar::mouseMoveEvent(QMouseEvent *event)
&& tabIndex != currentIndex()
&& m_currentTabPreviewIndex != tabIndex
&& event->buttons() == Qt::NoButton
- )
+ )
{
m_currentTabPreviewIndex = tabIndex;
@@ -384,7 +384,7 @@ void TabBar::leaveEvent(QEvent *event)
void TabBar::mousePressEvent(QMouseEvent *event)
{
hideTabPreview();
-
+
// just close tab on middle mouse click
if (event->button() == Qt::MidButton)
return;
@@ -424,8 +424,8 @@ void TabBar::showTabPreview()
int w = c_baseTabWidth;
int h = w * tabW->size().height() / tabW->size().width();
-
- m_previewPopup = new TabPreviewPopup(indexedTab->tabPreview(w,h), indexedTab->url().url() , this);
+
+ m_previewPopup = new TabPreviewPopup(indexedTab->tabPreview(w, h), indexedTab->url().url() , this);
int tabBarWidth = tabW->size().width();
int leftIndex = tabRect(m_currentTabPreviewIndex).x() + (tabRect(m_currentTabPreviewIndex).width() - w) / 2;
diff --git a/src/tabwindow/tabbar.h b/src/tabwindow/tabbar.h
index 8dcab051..d0228683 100644
--- a/src/tabwindow/tabbar.h
+++ b/src/tabwindow/tabbar.h
@@ -42,7 +42,7 @@ class TabPreviewPopup;
class TabHighlightEffect;
class QSignalMapper;
-
+
class TabBar : public KTabBar
{
@@ -63,7 +63,7 @@ protected:
virtual void tabRemoved(int index);
virtual void tabLayoutChange();
-
+
Q_SIGNALS:
void cloneTab(int);
void closeTab(int);
@@ -72,7 +72,7 @@ Q_SIGNALS:
void detachTab(int);
void restoreClosedTab(int);
void tabLayoutChanged();
-
+
private Q_SLOTS:
void cloneTab();
void closeTab();
diff --git a/src/tabwindow/tabpreviewpopup.h b/src/tabwindow/tabpreviewpopup.h
index 37d270c7..3269f3de 100644
--- a/src/tabwindow/tabpreviewpopup.h
+++ b/src/tabwindow/tabpreviewpopup.h
@@ -44,7 +44,7 @@ class QString;
class TabPreviewPopup : public KPassivePopup
{
Q_OBJECT
-
+
public:
TabPreviewPopup(const QPixmap &pixmap, const QString &urlText, QWidget *parent = 0);
virtual ~TabPreviewPopup();
diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp
index 4d4cdab3..ba355e51 100644
--- a/src/tabwindow/tabwindow.cpp
+++ b/src/tabwindow/tabwindow.cpp
@@ -88,7 +88,7 @@ TabWindow::TabWindow(bool withTab, QWidget *parent)
connect(tabBar, SIGNAL(restoreClosedTab(int)), this, SLOT(restoreClosedTab(int)));
connect(tabBar, SIGNAL(tabLayoutChanged()), this, SLOT(updateNewTabButtonPosition()));
-
+
// new tab button
KAction* a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this);
_addTabButton->setDefaultAction(a);
@@ -160,7 +160,7 @@ void TabWindow::loadUrl(const KUrl &url, Rekonq::OpenType type, TabHistory *hist
tab = prepareNewTab();
addTab(tab, i18n("new tab"));
break;
-
+
case Rekonq::NewFocusedTab:
tab = prepareNewTab();
addTab(tab, i18n("new tab"));
@@ -207,7 +207,7 @@ void TabWindow::pageCreated(WebPage *page)
void TabWindow::currentChanged(int newIndex)
{
_openedTabsCounter = 0;
-
+
tabBar()->setTabHighlighted(newIndex, false);
// update window title & icon
@@ -217,8 +217,8 @@ void TabWindow::currentChanged(int newIndex)
QString t = tab->title();
(t.isEmpty())
- ? setWindowTitle(QL1S("rekonq"))
- : setWindowTitle(t + QL1S(" - rekonq"));
+ ? setWindowTitle(QL1S("rekonq"))
+ : setWindowTitle(t + QL1S(" - rekonq"));
}
@@ -248,7 +248,7 @@ void TabWindow::tabTitleChanged(const QString &title)
return;
bool emptyTitle = title.isEmpty();
-
+
QString tabTitle = emptyTitle ? tab->url().url() : title;
tabTitle.replace('&', "&&");
@@ -266,8 +266,8 @@ void TabWindow::tabTitleChanged(const QString &title)
else
{
emptyTitle
- ? setWindowTitle(QL1S("rekonq"))
- : setWindowTitle(tabTitle + QL1S(" - rekonq"));
+ ? setWindowTitle(QL1S("rekonq"))
+ : setWindowTitle(tabTitle + QL1S(" - rekonq"));
}
}
@@ -423,7 +423,7 @@ void TabWindow::detachTab(int index, TabWindow *toWindow)
// else
closeTab(index, false);
-
+
TabWindow *w = 0;
w = (toWindow == 0)
? new TabWindow(false)
diff --git a/src/tabwindow/tabwindow.h b/src/tabwindow/tabwindow.h
index 9dda54c3..750cac5f 100644
--- a/src/tabwindow/tabwindow.h
+++ b/src/tabwindow/tabwindow.h
@@ -60,7 +60,7 @@ class TabWindow : public RekonqWindow
public:
TabWindow(bool withTab = true, QWidget *parent = 0);
-
+
WebWindow* currentWebWindow() const;
WebWindow* webWindow(int index) const;