[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/kpdf
From: Albert Astals Cid <tsdgeos () terra ! es>
Date: 2005-10-04 18:53:17
Message-ID: 1128451997.734852.13397.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 467259 by aacid:
Q3PopupMenu -> KMenu
M +14 -20 part.cpp
M +15 -15 ui/pageview.cpp
--- trunk/KDE/kdegraphics/kpdf/part.cpp #467258:467259
@@ -22,7 +22,6 @@
***************************************************************************/
// qt/kde includes
-#include <q3popupmenu.h>
#include <qsplitter.h>
#include <qpainter.h>
#include <qlayout.h>
@@ -36,6 +35,7 @@
#include <kaction.h>
#include <kdirwatch.h>
#include <kinstance.h>
+#include <kmenu.h>
#include <kprinter.h>
#include <kstdaction.h>
#include <kdeversion.h>
@@ -808,16 +808,19 @@
}
- Q3PopupMenu *popup = new Q3PopupMenu( widget() );
+ KMenu *popup = new KMenu( widget() );
+ QAction *toggleBookmark, *fitPageWidth;
+ toggleBookmark = 0;
+ fitPageWidth = 0;
if (page)
{
- popup->setTitle( i18n( "Page %1" ).arg( page->number() + 1 ) );
- if ( page->hasBookmark() )
- popup->insertItem( QIcon(SmallIcon("bookmark")), i18n("Remove Bookmark"), 1 );
+ popup->addTitle( i18n( "Page %1" ).arg( page->number() + 1 ) );
+ if ( page->hasBookmark() )
+ toggleBookmark = popup->addAction( QIcon(SmallIcon("bookmark")), i18n("Remove \
Bookmark") ); else
- popup->insertItem( QIcon(SmallIcon("bookmark_add")), i18n("Add Bookmark"), 1 );
+ toggleBookmark = popup->addAction( QIcon(SmallIcon("bookmark_add")), i18n("Add \
Bookmark") ); if ( m_pageView->canFitPageWidth() )
- popup->insertItem( QIcon(SmallIcon("viewmagfit")), i18n("Fit Width"), 2 );
+ fitPageWidth = popup->addAction( QIcon(SmallIcon("viewmagfit")), i18n("Fit \
Width") ); //popup->insertItem( SmallIcon("pencil"), i18n("Edit"), 3 );
//popup->setItemEnabled( 3, false );
reallyShow = true;
@@ -832,8 +835,7 @@
if ((m_showMenuBarAction && !m_showMenuBarAction->isChecked()) || \
(m_showFullScreenAction && m_showFullScreenAction->isChecked())) {
-#warning this is not going to work KPopupMenu supported multiple titles and now it's \
gone :-/
- popup->setTitle( i18n( "Tools" ) );
+ popup->addTitle( i18n( "Tools" ) );
if (m_showMenuBarAction && !m_showMenuBarAction->isChecked()) \
m_showMenuBarAction->plug(popup); if (m_showFullScreenAction && \
m_showFullScreenAction->isChecked()) m_showFullScreenAction->plug(popup); reallyShow \
= true; @@ -842,17 +844,9 @@
if (reallyShow)
{
- switch ( popup->exec(point) )
- {
- case 1:
- m_document->toggleBookmark( page->number() );
- break;
- case 2:
- m_pageView->fitPageWidth( page->number() );
- break;
- // case 3: // switch to edit mode
- // break;
- }
+ QAction *res = popup->exec(point);
+ if (res == toggleBookmark) m_document->toggleBookmark( page->number() );
+ else if (res == fitPageWidth) m_pageView->fitPageWidth( page->number() );
}
delete popup;
}
--- trunk/KDE/kdegraphics/kpdf/ui/pageview.cpp #467258:467259
@@ -19,7 +19,6 @@
// qt/kde includes
#include <qcursor.h>
#include <qevent.h>
-#include <q3popupmenu.h>
#include <qpainter.h>
#include <qtimer.h>
#include <qdatetime.h>
@@ -29,6 +28,7 @@
#include <dcopclient.h>
#include <kiconloader.h>
#include <kaction.h>
+#include <kmenu.h>
#include <kstdaccel.h>
#include <kactioncollection.h>
#include <klocale.h>
@@ -1022,23 +1022,23 @@
}
// popup that ask to copy:text and copy/save:image
- Q3PopupMenu menu( this );
+ KMenu menu( this );
+ QAction *textToClipboard = 0, *speakText = 0, *imageToClipboard = 0, \
*imageToFile = 0; if ( !selectedText.isEmpty() )
{
- menu.setTitle( i18n( "Text (1 character)", "Text (%n characters)", \
selectedText.length() ) );
- menu.insertItem( QIcon(SmallIcon("editcopy")), i18n( "Copy to \
Clipboard" ), 1 ); + menu.addTitle( i18n( "Text (1 character)", "Text \
(%n characters)", selectedText.length() ) ); + textToClipboard = \
menu.addAction( QIcon(SmallIcon("editcopy")), i18n( "Copy to Clipboard" ) ); if ( \
!d->document->isAllowed( KPDFDocument::AllowCopy ) ) menu.setItemEnabled( 1, false \
); if ( KpdfSettings::useKTTSD() )
- menu.insertItem( QIcon(SmallIcon("kttsd")), i18n( "Speak Text" \
), 2 ); + speakText = menu.addAction( QIcon(SmallIcon("kttsd")), \
i18n( "Speak Text" ) ); }
-#warning this is not going to work KPopupMenu supported multiple titles and now it's \
gone :-/
- menu.setTitle( i18n( "Image (%1 by %2 pixels)" ).arg( \
selectionRect.width() ).arg( selectionRect.height() ) );
- menu.insertItem( QIcon(SmallIcon("image")), i18n( "Copy to Clipboard" ), \
3 );
- menu.insertItem( QIcon(SmallIcon("filesave")), i18n( "Save to File..." \
), 4 );
- int choice = menu.exec( e->globalPos() );
+ menu.addTitle( i18n( "Image (%1 by %2 pixels)" ).arg( \
selectionRect.width() ).arg( selectionRect.height() ) ); + \
imageToClipboard = menu.addAction( QIcon(SmallIcon("image")), i18n( "Copy to \
Clipboard" ) ); + imageToFile = menu.addAction( \
QIcon(SmallIcon("filesave")), i18n( "Save to File..." ) ); + QAction \
*choice = menu.exec( e->globalPos() ); // IMAGE operation choosen
- if ( choice > 2 )
+ if ( choice == imageToClipboard || choice == imageToFile )
{
// renders page into a pixmap
QPixmap copyPix( selectionRect.width(), selectionRect.height() );
@@ -1046,7 +1046,7 @@
copyPainter.translate( -selectionRect.left(), -selectionRect.top() \
); paintItems( ©Painter, selectionRect );
- if ( choice == 3 )
+ if ( choice == imageToClipboard )
{
// [2] copy pixmap to clipboard
QClipboard *cb = QApplication::clipboard();
@@ -1055,7 +1055,7 @@
cb->setPixmap( copyPix, QClipboard::Selection );
d->messageWindow->display( i18n( "Image [%1x%2] copied to \
clipboard." ).arg( copyPix.width() ).arg( copyPix.height() ) ); }
- else if ( choice == 4 )
+ else if ( choice == imageToFile )
{
// [3] save pixmap to file
QString fileName = KFileDialog::getSaveFileName( QString::null, \
"image/png image/jpeg", this ); @@ -1074,7 +1074,7 @@
// TEXT operation choosen
else
{
- if ( choice == 1 )
+ if ( choice == textToClipboard )
{
// [1] copy text to clipboard
QClipboard *cb = QApplication::clipboard();
@@ -1082,7 +1082,7 @@
if ( cb->supportsSelection() )
cb->setText( selectedText, QClipboard::Selection );
}
- else if ( choice == 2 )
+ else if ( choice == speakText )
{
// [2] speech selection using KTTSD
DCOPClient * client = DCOPClient::mainClient();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic