summaryrefslogtreecommitdiffstats
path: root/kdesktop
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-12-11 20:21:27 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-12-11 20:21:27 +0000
commit10e41144596fc9ced40fc349d9ecd099b1c2ea19 (patch)
tree88ab04e475ff5a4cd889cb082f5760b6e0bf5e4e /kdesktop
parent4aed2c8219774f5d797760606b8489a92ddc5163 (diff)
downloadtdebase-10e41144596fc9ced40fc349d9ecd099b1c2ea19.tar.gz
tdebase-10e41144596fc9ced40fc349d9ecd099b1c2ea19.zip
Initial import of Trinity 3.5.11 to kdebase
Extends krandrtray, adds iccconfig kcontrol module, adds run dialog autocomplete and lots of bugfixes Will need to check for commit warnings and repair as encountered Also needs full compile test git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1061475 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdesktop')
-rw-r--r--kdesktop/bgmanager.cc146
-rw-r--r--kdesktop/bgmanager.h2
-rw-r--r--kdesktop/desktop.cc9
-rw-r--r--kdesktop/kdesktop.kcfg21
-rw-r--r--kdesktop/kdiconview.cc4
-rw-r--r--kdesktop/kfileividesktop.cpp38
-rw-r--r--kdesktop/kfileividesktop.h5
-rw-r--r--kdesktop/krootwm.cc2
-rw-r--r--kdesktop/krootwm.h1
-rw-r--r--kdesktop/minicli.cpp139
-rw-r--r--kdesktop/minicli.h11
-rw-r--r--kdesktop/minicli_ui.ui26
12 files changed, 338 insertions, 66 deletions
diff --git a/kdesktop/bgmanager.cc b/kdesktop/bgmanager.cc
index 62f97cecc..6274cf757 100644
--- a/kdesktop/bgmanager.cc
+++ b/kdesktop/bgmanager.cc
@@ -62,7 +62,7 @@ KBackgroundManager::KBackgroundManager(QWidget *desktop, KWinModule* kwinModule)
m_pDesktop = desktop;
if (desktop == 0L)
- desktop = QApplication::desktop()->screen();
+ desktop = KApplication::desktop()->screen();
m_Renderer.resize( 1 );
m_Cache.resize( 1 );
@@ -95,6 +95,9 @@ KBackgroundManager::KBackgroundManager(QWidget *desktop, KWinModule* kwinModule)
SLOT(slotChangeDesktop(int)));
connect(m_pKwinmodule, SIGNAL(numberOfDesktopsChanged(int)),
SLOT(slotChangeNumberOfDesktops(int)));
+ connect(m_pKwinmodule, SIGNAL(currentDesktopViewportChanged(int, const QPoint&)),
+ SLOT(slotChangeViewport(int, const QPoint&)));
+
#if (QT_VERSION-0 >= 0x030200)
connect( kapp->desktop(), SIGNAL( resized( int )), SLOT( desktopResized())); // RANDR support
@@ -227,7 +230,21 @@ int KBackgroundManager::realDesktop()
int KBackgroundManager::effectiveDesktop()
{
- return m_bCommon ? 0 : realDesktop();
+ QSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop()));
+ m_numberOfViewports = s.width() * s.height();
+
+ if (m_numberOfViewports > 1) {
+ if (m_bCommon) {
+ return 0;
+ }
+ else {
+ QPoint vx(m_pKwinmodule->currentViewport(m_pKwinmodule->currentDesktop()));
+ return (realDesktop() * m_numberOfViewports) + ((vx.x() * vx.y()) - 1);
+ }
+ }
+ else {
+ return m_bCommon ? 0 : realDesktop();
+ }
}
@@ -236,6 +253,13 @@ int KBackgroundManager::effectiveDesktop()
*/
void KBackgroundManager::slotChangeNumberOfDesktops(int num)
{
+ QSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop()));
+ m_numberOfViewports = s.width() * s.height();
+ if (m_numberOfViewports < 1) {
+ m_numberOfViewports = 1;
+ }
+ num = (num * m_numberOfViewports);
+
if (m_Renderer.size() == (unsigned) num)
return;
@@ -278,20 +302,26 @@ void KBackgroundManager::slotChangeNumberOfDesktops(int num)
*/
void KBackgroundManager::slotChangeDesktop(int desk)
{
+ QSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop()));
+ m_numberOfViewports = s.width() * s.height();
+ if (m_numberOfViewports < 1) {
+ m_numberOfViewports = 1;
+ }
+
if (desk == 0)
desk = realDesktop();
else
desk--;
// Lazy initialisation of # of desktops
- if ((unsigned) desk >= m_Renderer.size())
- slotChangeNumberOfDesktops( m_pKwinmodule->numberOfDesktops() );
+ if ((m_pKwinmodule->numberOfDesktops() * m_numberOfViewports) >= m_Renderer.size())
+ slotChangeNumberOfDesktops( m_pKwinmodule->numberOfDesktops() * m_numberOfViewports);
int edesk = effectiveDesktop();
m_Serial++;
// If the background is the same: do nothing
- if (m_Hash == m_Renderer[edesk]->hash())
+ if ((m_Hash == m_Renderer[edesk]->hash()) && (desk != 0))
{
exportBackground(m_Current, desk);
return;
@@ -306,6 +336,8 @@ void KBackgroundManager::slotChangeDesktop(int desk)
continue;
if (m_Cache[i]->hash != m_Renderer[edesk]->hash())
continue;
+ if (desk == 0)
+ continue;
// kdDebug() << "slotChangeDesktop i=" << i << endl;
setPixmap(m_Cache[i]->pixmap, m_Cache[i]->hash, i);
m_Cache[i]->atime = m_Serial;
@@ -316,8 +348,72 @@ void KBackgroundManager::slotChangeDesktop(int desk)
// Do we have this or an identical config already running?
for (unsigned i=0; i<m_Renderer.size(); i++)
{
- if ((m_Renderer[i]->hash() == m_Renderer[edesk]->hash()) &&
- (m_Renderer[i]->isActive()))
+ if (((m_Renderer[i]->hash() == m_Renderer[edesk]->hash()) && (m_Renderer[i]->isActive())) && (desk != 0))
+ return;
+ }
+
+ renderBackground(edesk);
+}
+
+/*
+ * Call this when the viewport has been changed.
+ * Desk is in KWin convention: [1..desks], instead of [0..desks-1].
+ * 0 repaints the current viewport.
+ */
+void KBackgroundManager::slotChangeViewport(int desk, const QPoint& viewport)
+{
+ QSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop()));
+ m_numberOfViewports = s.width() * s.height();
+ if (m_numberOfViewports < 1) {
+ m_numberOfViewports = 1;
+ }
+
+ if (desk == 0)
+ desk = realDesktop();
+ else
+ desk--;
+
+ // Lazy initialisation of # of desktops
+ if ((m_pKwinmodule->numberOfDesktops() * m_numberOfViewports) >= m_Renderer.size())
+ slotChangeNumberOfDesktops( m_pKwinmodule->numberOfDesktops() * m_numberOfViewports );
+
+ int edesk = effectiveDesktop();
+ m_Serial++;
+
+ // If the background is the same: do nothing
+ if ((m_Hash == m_Renderer[edesk]->hash()) && (desk != 0))
+ {
+ exportBackground(m_Current, desk);
+ return;
+ }
+ m_Renderer[edesk]->stop();
+ m_Renderer[edesk]->cleanup();
+
+ // If we have the background already rendered: set it
+ for (unsigned i=0; i<m_Cache.size(); i++)
+ {
+ if (!m_Cache[i]->pixmap)
+ continue;
+ if (m_Cache[i]->hash != m_Renderer[edesk]->hash())
+ continue;
+ if (desk == 0)
+ continue;
+// kdDebug() << "slotChangeDesktop i=" << i << endl;
+
+ //KPixmap * viewport_background = new KPixmap(QPixmap(m_Cache[i]->pixmap->width()*s.width(), m_Cache[i]->pixmap->height()*s.height()));
+ //setPixmap(viewport_background, m_Cache[i]->hash, i);
+ //delete viewport_background;
+
+ setPixmap(m_Cache[i]->pixmap, m_Cache[i]->hash, i);
+ m_Cache[i]->atime = m_Serial;
+ exportBackground(i, desk);
+ return;
+ }
+
+ // Do we have this or an identical config already running?
+ for (unsigned i=0; i<m_Renderer.size(); i++)
+ {
+ if (((m_Renderer[i]->hash() == m_Renderer[edesk]->hash()) && (m_Renderer[i]->isActive())) && (desk != 0))
return;
}
@@ -360,14 +456,14 @@ void KBackgroundManager::setPixmap(KPixmap *pm, int hash, int desk)
root_cleared = true;
QTimer::singleShot( 0, this, SLOT( clearRoot()));
// but make the pixmap visible until m_pDesktop is visible
- QApplication::desktop()->screen()->setErasePixmap(*pm);
- QApplication::desktop()->screen()->erase();
+ KApplication::desktop()->screen()->setErasePixmap(*pm);
+ KApplication::desktop()->screen()->erase();
}
}
else
{
- QApplication::desktop()->screen()->setErasePixmap(*pm);
- QApplication::desktop()->screen()->erase();
+ KApplication::desktop()->screen()->setErasePixmap(*pm);
+ KApplication::desktop()->screen()->erase();
}
// and export it via Esetroot-style for gnome/GTK apps to share in the pretties
@@ -387,8 +483,8 @@ void KBackgroundManager::setPixmap(KPixmap *pm, int hash, int desk)
void KBackgroundManager::clearRoot()
{
- QApplication::desktop()->screen()->setErasePixmap( QPixmap());
- QApplication::desktop()->screen()->erase();
+ KApplication::desktop()->screen()->setErasePixmap( QPixmap());
+ KApplication::desktop()->screen()->erase();
}
/*
@@ -412,6 +508,14 @@ void KBackgroundManager::renderBackground(int desk)
*/
void KBackgroundManager::slotImageDone(int desk)
{
+ bool t_useViewports = 1;
+ QSize s(m_pKwinmodule->numberOfViewports(m_pKwinmodule->currentDesktop()));
+ m_numberOfViewports = s.width() * s.height();
+ if (m_numberOfViewports < 1) {
+ m_numberOfViewports = 1;
+ t_useViewports = 0;
+ }
+
KPixmap *pm = new KPixmap();
KVirtualBGRenderer *r = m_Renderer[desk];
bool do_cleanup = true;
@@ -421,6 +525,11 @@ void KBackgroundManager::slotImageDone(int desk)
bool current = (r->hash() == m_Renderer[effectiveDesktop()]->hash());
if (current)
{
+ //KPixmap * viewport_background = new KPixmap(QPixmap(pm->width()*s.width(), pm->height()*s.height()));
+ //printf("slotImageDone(): x: %d y: %d\n\r", viewport_background->size().width(), viewport_background->size().height());
+ //setPixmap(viewport_background, r->hash(), desk);
+ //delete viewport_background;
+
setPixmap(pm, r->hash(), desk);
if (!m_bBgInitDone)
{
@@ -742,7 +851,7 @@ void KBackgroundManager::repaintBackground()
if (m_pDesktop)
m_pDesktop->repaint();
else
- QApplication::desktop()->screen()->erase();
+ KApplication::desktop()->screen()->erase();
}
void KBackgroundManager::desktopResized()
@@ -755,12 +864,19 @@ void KBackgroundManager::desktopResized()
removeCache(i);
// make the renderer update its desktop size
r->desktopResized();
+ for (unsigned j=0; j<(r->numRenderers()); ++j) {
+ r->renderer(j)->desktopResized();
+ }
}
m_Hash = 0;
if( m_pDesktop )
- m_pDesktop->resize( kapp->desktop()->size());
+ m_pDesktop->resize( kapp->desktop()->geometry().size());
// Repaint desktop
slotChangeDesktop(0);
+ repaintBackground();
+
+ // Signal KWin that the usable desktop area has probably changed...
+ // Use the DCOP signal kDestopResized
}
// DCOP exported
diff --git a/kdesktop/bgmanager.h b/kdesktop/bgmanager.h
index e029cf6cd..53787e501 100644
--- a/kdesktop/bgmanager.h
+++ b/kdesktop/bgmanager.h
@@ -78,6 +78,7 @@ private slots:
void slotTimeout();
void slotImageDone(int desk);
void slotChangeDesktop(int);
+ void slotChangeViewport(int, const QPoint&);
void slotChangeNumberOfDesktops(int);
void repaintBackground();
void desktopResized();
@@ -92,6 +93,7 @@ private:
int realDesktop();
int effectiveDesktop();
int validateDesk(int desk);
+ int m_numberOfViewports;
void renderBackground(int desk);
void exportBackground(int pixmap, int desk);
diff --git a/kdesktop/desktop.cc b/kdesktop/desktop.cc
index 6e2b1e9c0..18cb69fb4 100644
--- a/kdesktop/desktop.cc
+++ b/kdesktop/desktop.cc
@@ -516,9 +516,12 @@ void KDesktop::popupExecuteCommand(const QString& command)
if ( m_miniCli->isVisible() ) {
KWin::forceActiveWindow( m_miniCli->winId() );
} else {
- QRect rect = KGlobalSettings::desktopGeometry(QCursor::pos());
- m_miniCli->move(rect.x() + (rect.width() - m_miniCli->width())/2,
- rect.y() + (rect.height() - m_miniCli->height())/2);
+ NETRootInfo i( qt_xdisplay(), NET::Supported );
+ if( !i.isSupported( NET::WM2FullPlacement )) {
+ QRect rect = KGlobalSettings::desktopGeometry(QCursor::pos());
+ m_miniCli->move(rect.x() + (rect.width() - m_miniCli->width())/2,
+ rect.y() + (rect.height() - m_miniCli->height())/2);
+ }
m_miniCli->show(); // non-modal
}
}
diff --git a/kdesktop/kdesktop.kcfg b/kdesktop/kdesktop.kcfg
index 597377661..b949efbea 100644
--- a/kdesktop/kdesktop.kcfg
+++ b/kdesktop/kdesktop.kcfg
@@ -331,6 +331,27 @@
<!-- minicli.cpp:192 -->
<!-- int maxHistory = config->readNumEntry("HistoryLength", 50); -->
</entry>
+ <entry key="MiniCLIAutocompletionLength" type="Int">
+ <default>10</default>
+ <label></label>
+ <whatsthis></whatsthis>
+ <!-- minicli.cpp:651 -->
+ <!-- int maxAutocompletion = KDesktopSettings::MiniCLIAutocompletionLength(); -->
+ </entry>
+ <entry key="MiniCLIFilesystemAutoComplete" type="Bool">
+ <default>false</default>
+ <label></label>
+ <whatsthis></whatsthis>
+ <!-- minicli.cpp:216 -->
+ <!-- m_dlg->cbAutocomplete->setChecked( KDesktopSettings::miniCLIFilesystemAutoComplete() ); -->
+ </entry>
+ <entry key="MiniCLIHistoryAndFilesystemAutoComplete" type="Bool">
+ <default>false</default>
+ <label></label>
+ <whatsthis></whatsthis>
+ <!-- minicli.cpp:217 -->
+ <!-- m_dlg->cbAutohistory->setChecked( KDesktopSettings::miniCLIHistoryAndFilesystemAutoComplete() ); -->
+ </entry>
<entry key="TerminalApps" type="PathList">
<default></default>
<label></label>
diff --git a/kdesktop/kdiconview.cc b/kdesktop/kdiconview.cc
index f9ca6c446..b143dc231 100644
--- a/kdesktop/kdiconview.cc
+++ b/kdesktop/kdiconview.cc
@@ -485,7 +485,7 @@ void KDIconView::setAutoAlign( bool b )
// Auto line-up icons
if ( b ) {
- lineupIcons();
+ if (!KRootWm::self()->startup) lineupIcons(); else KRootWm::self()->startup = false;
connect( this, SIGNAL( iconMoved() ),
this, SLOT( lineupIcons() ) );
}
@@ -1440,7 +1440,7 @@ void KDIconView::updateWorkArea( const QRect &wr )
<< " " << oldArea.width() << "x" << oldArea.height() << endl;
if ( m_autoAlign )
- lineupIcons();
+ int dummy = 0; //lineupIcons();
else {
bool needRepaint = false;
QIconViewItem* item;
diff --git a/kdesktop/kfileividesktop.cpp b/kdesktop/kfileividesktop.cpp
index 28bf51105..f9ea12a51 100644
--- a/kdesktop/kfileividesktop.cpp
+++ b/kdesktop/kfileividesktop.cpp
@@ -134,40 +134,11 @@ bool KFileIVIDesktop::shouldUpdateShadow(bool selected)
return false;
}
-void KFileIVIDesktop::paintFocus( QPainter *p, const QColorGroup &cg )
-{
- if ( !iconView() )
- return;
-
- if ( !m_shadow || !wordWrap() ||
- !( static_cast<KDesktopShadowSettings *>
- ( m_shadow->shadowSettings() ) )->isEnabled() ) {
- QIconViewItem::paintFocus( p, cg );
- return;
- }
-
- int spread = shadowThickness();
-
- iconView()->style().drawPrimitive( QStyle::PE_FocusRect, p,
- QRect( textRect( false ).x(), textRect( false ).y(),
- textRect( false ).width() - spread,
- textRect( false ).height() - spread + 1 ),
- cg,
- isSelected() ? QStyle::Style_FocusAtBorder : QStyle::Style_Default,
- QStyleOption( isSelected() ? cg.highlight() : cg.base() ) );
-
- if ( this != iconView()->currentItem() ) {
- iconView()->style().drawPrimitive( QStyle::PE_FocusRect, p,
- QRect( pixmapRect( false ).x(), pixmapRect( false ).y(),
- pixmapRect( false ).width(), pixmapRect( false ).height() ),
- cg, QStyle::Style_Default, QStyleOption( cg.base() ) );
- }
-}
void KFileIVIDesktop::drawShadowedText( QPainter *p, const QColorGroup &cg )
{
- int textX = textRect( FALSE ).x() + 2;
+ int textX = textRect( FALSE ).x() + 4;
int textY = textRect( FALSE ).y();
int align = ((KIconView *) iconView())->itemTextPos() == QIconView::Bottom
? AlignHCenter : AlignAuto;
@@ -184,12 +155,15 @@ void KFileIVIDesktop::drawShadowedText( QPainter *p, const QColorGroup &cg )
int spread = shadowThickness();
if ( isSelected() && settings->selectionType() != KShadowSettings::InverseVideoOnSelection ) {
- // select using a filled rect
text = cg.highlightedText();
QRect rect = textRect( false );
rect.setRight( rect.right() - spread );
rect.setBottom( rect.bottom() - spread + 1 );
- p->fillRect( rect, cg.highlight() );
+ p->setBrush( QBrush( cg.highlight() ) );
+ p->setPen( QPen( cg.highlight() ) );
+ p->drawRoundRect( rect,
+ 1000 / rect.width(),
+ 1000 / rect.height() );
}
else {
// use shadow
diff --git a/kdesktop/kfileividesktop.h b/kdesktop/kfileividesktop.h
index 0fb764cd0..c245a6800 100644
--- a/kdesktop/kfileividesktop.h
+++ b/kdesktop/kfileividesktop.h
@@ -80,12 +80,7 @@ class KFileIVIDesktop : public KFileIVI
virtual void paintItem(QPainter *p, const QColorGroup &cg);
/**
- * Reimplements QIconView::paintFocus() to take the shadow
- * metrics into account();
- */
- virtual void paintFocus( QPainter *p, const QColorGroup &cg );
- /**
* Draws the shadow text.
* @param p the painter for drawing the item
* @param cg the base color group
diff --git a/kdesktop/krootwm.cc b/kdesktop/krootwm.cc
index 51586f878..fa22ab146 100644
--- a/kdesktop/krootwm.cc
+++ b/kdesktop/krootwm.cc
@@ -241,7 +241,7 @@ void KRootWm::initConfig()
// Read configuration for icons alignment
if ( m_bDesktopEnabled ) {
- m_pDesktop->iconView()->setAutoAlign( KDesktopSettings::autoLineUpIcons() );
+ bool startup = true; m_pDesktop->iconView()->setAutoAlign( KDesktopSettings::autoLineUpIcons() );
if ( kapp->authorize( "editable_desktop_icons" ) ) {
m_pDesktop->iconView()->setItemsMovable( !KDesktopSettings::lockIcons() );
KToggleAction *aLockIcons = static_cast<KToggleAction*>(m_actionCollection->action("lock_icons"));
diff --git a/kdesktop/krootwm.h b/kdesktop/krootwm.h
index 9231b4bb6..3363fbf42 100644
--- a/kdesktop/krootwm.h
+++ b/kdesktop/krootwm.h
@@ -66,6 +66,7 @@ public:
KRootWm(KDesktop*);
~KRootWm();
+ bool startup;
void mousePressed( const QPoint& _global, int _button );
bool hasLeftButtonMenu() { return leftButtonChoice != NOTHING; }
diff --git a/kdesktop/minicli.cpp b/kdesktop/minicli.cpp
index 096b293d0..2cf225bcc 100644
--- a/kdesktop/minicli.cpp
+++ b/kdesktop/minicli.cpp
@@ -1,5 +1,8 @@
/* This file is part of the KDE project
+ Autocompletion code:
+ Copyright (C) 2009 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+
Copyright (C) 1999-2002,2003 Dawit Alemayehu <adawit@kde.org>
Copyright (C) 2000 Malte Starostik <starosti@zedat.fu-berlin.de>
Copyright (C) 2003 Sven Leiber <s.leiber@web.de>
@@ -76,6 +79,8 @@ Minicli::Minicli( QWidget *parent, const char *name)
:KDialog( parent, name, false, WType_TopLevel ),
m_autoCheckedRunInTerm(false)
{
+ m_pURLCompletion = 0L;
+
setPlainCaption( i18n("Run Command") );
KWin::setIcons( winId(), DesktopIcon("run"), SmallIcon("run") );
@@ -121,6 +126,13 @@ Minicli::Minicli( QWidget *parent, const char *name)
m_dlg->leUsername->setText("root");
+ // Autocomplete system
+ m_filesystemAutocomplete = 0;
+ m_histfilesystemAutocomplete = 0;
+ m_pURLCompletion = new KURLCompletion();
+ //m_pURLCompletion->setCompletionMode( KGlobalSettings::completionMode() );
+ connect( m_pURLCompletion, SIGNAL( match(const QString&) ), SLOT( slotMatch(const QString&) ));
+
// Main widget buttons...
connect( m_dlg->pbRun, SIGNAL(clicked()), this, SLOT(accept()) );
connect( m_dlg->pbCancel, SIGNAL(clicked()), this, SLOT(reject()) );
@@ -137,6 +149,8 @@ Minicli::Minicli( QWidget *parent, const char *name)
connect(m_dlg->cbPriority, SIGNAL(toggled(bool)), SLOT(slotChangeScheduler(bool)));
connect(m_dlg->slPriority, SIGNAL(valueChanged(int)), SLOT(slotPriority(int)));
connect(m_dlg->cbRealtime, SIGNAL(toggled(bool)), SLOT(slotRealtime(bool)));
+ connect(m_dlg->cbAutocomplete, SIGNAL(toggled(bool)), SLOT(slotAutocompleteToggled(bool)));
+ connect(m_dlg->cbAutohistory, SIGNAL(toggled(bool)), SLOT(slotAutohistoryToggled(bool)));
connect(m_dlg->cbRunAsOther, SIGNAL(toggled(bool)), SLOT(slotChangeUid(bool)));
connect(m_dlg->leUsername, SIGNAL(lostFocus()), SLOT(updateAuthLabel()));
connect(m_dlg->cbRunInTerminal, SIGNAL(toggled(bool)), SLOT(slotTerminal(bool)));
@@ -149,6 +163,7 @@ Minicli::Minicli( QWidget *parent, const char *name)
Minicli::~Minicli()
{
delete m_filterData;
+ delete m_pURLCompletion;
}
void Minicli::setCommand(const QString& command)
@@ -198,6 +213,19 @@ void Minicli::loadConfig()
m_dlg->cbCommand->setHistoryItems( histList );
m_dlg->cbCommand->blockSignals( block );
+ m_dlg->cbAutocomplete->setChecked( KDesktopSettings::miniCLIFilesystemAutoComplete() );
+ m_dlg->cbAutohistory->setChecked( KDesktopSettings::miniCLIHistoryAndFilesystemAutoComplete() );
+
+ m_filesystemAutocomplete = KDesktopSettings::miniCLIFilesystemAutoComplete();
+ m_histfilesystemAutocomplete = KDesktopSettings::miniCLIHistoryAndFilesystemAutoComplete();
+
+ if (m_histfilesystemAutocomplete == true) {
+ m_dlg->cbAutocomplete->setDisabled( true );
+ }
+ else {
+ m_dlg->cbAutocomplete->setDisabled( false );
+ }
+
QStringList compList = KDesktopSettings::completionItems();
if( compList.isEmpty() )
m_dlg->cbCommand->completionObject()->setItems( histList );
@@ -241,8 +269,10 @@ void Minicli::saveConfig()
{
KDesktopSettings::setHistory( m_dlg->cbCommand->historyItems() );
KDesktopSettings::setTerminalApps( m_terminalAppList );
- KDesktopSettings::setCompletionItems( m_dlg->cbCommand->completionObject()->items() );
+ //KDesktopSettings::setCompletionItems( m_dlg->cbCommand->completionObject()->items() );
KDesktopSettings::setCompletionMode( m_dlg->cbCommand->completionMode() );
+ KDesktopSettings::setMiniCLIFilesystemAutoComplete( m_filesystemAutocomplete );
+ KDesktopSettings::setMiniCLIHistoryAndFilesystemAutoComplete( m_histfilesystemAutocomplete );
KDesktopSettings::writeConfig();
}
@@ -369,6 +399,17 @@ int Minicli::runCommand()
cmd = uri.path();
else
cmd = uri.url();
+
+ QCString asn;
+ if( qApp->desktop()->isVirtualDesktop())
+ {
+ asn = KStartupInfo::createNewStartupId();
+ KStartupInfoId id;
+ id.initId( asn );
+ KStartupInfoData data;
+ data.setXinerama( qApp->desktop()->screenNumber( this ));
+ KStartupInfo::sendChange( id, data );
+ }
// Determine whether the application should be run through
// the command line (terminal) interface...
@@ -504,7 +545,7 @@ int Minicli::runCommand()
case KURIFilterData::HELP:
{
// No need for kfmclient, KRun does it all (David)
- (void) new KRun( m_filterData->uri(), parentWidget());
+ (void) new KRun( m_filterData->uri(), parentWidget(), asn );
return 0;
}
case KURIFilterData::EXECUTABLE:
@@ -516,7 +557,7 @@ int Minicli::runCommand()
if (service && service->isValid() && service->type() == "Application")
{
notifyServiceStarted(service);
- KRun::run(*service, KURL::List());
+ KRun::run(*service, KURL::List(), parentWidget(), asn );
return 0;
}
}
@@ -551,7 +592,7 @@ int Minicli::runCommand()
if (service && service->isValid() && service->type() == "Application")
{
notifyServiceStarted(service);
- KRun::run(*service, KURL::List(), this);
+ KRun::run(*service, KURL::List(), parentWidget(), asn );
return 0;
}
@@ -559,7 +600,7 @@ int Minicli::runCommand()
if (service && service->isValid() && service->type() == "Application")
{
notifyServiceStarted(service);
- KRun::run(*service, KURL::List(), this);
+ KRun::run(*service, KURL::List(), parentWidget(), asn );
return 0;
}
@@ -571,7 +612,7 @@ int Minicli::runCommand()
}
}
- if ( KRun::runCommand( cmd, exec, m_iconName ) )
+ if ( KRun::runCommand( cmd, exec, m_iconName, parentWidget(), asn ) )
return 0;
else
{
@@ -615,10 +656,58 @@ void Minicli::slotCmdChanged(const QString& text)
return;
}
+ else if ((m_filesystemAutocomplete == true) && ( m_pURLCompletion )) {
+ // Attempt to autocomplete the entered URL if it starts with the / character, meaning I am looking for something on the filesystem
+ // Also use autocompletion if it appears that I am using some kind of ioslave, except the http:// ioslave
+ m_urlCompletionStarted = true; // flag for slotMatch()
+
+ if ((text.startsWith( "/" ) || text.startsWith( "~" ) || (text.contains("://", false) != 0)) && (text.contains("http://", false) == 0)) {
+ QString completion = m_pURLCompletion->makeCompletion( text );
+ }
+ }
m_parseTimer->start(250, true);
}
+// Handle match() from m_pURLCompletion
+void Minicli::slotMatch( const QString &match )
+{
+ QString current_text;
+ QStringList histList = KDesktopSettings::history();
+ int maxHistory = KDesktopSettings::historyLength();
+ int maxAutocompletion = KDesktopSettings::miniCLIAutocompletionLength();
+
+ if ( match.isEmpty() ) // this case is handled directly
+ return;
+
+ // Check flag to avoid match() raised by rotation
+ if ( m_urlCompletionStarted ) {
+ m_urlCompletionStarted = false;
+
+ if (m_filesystemAutocomplete == true) {
+ bool block = m_dlg->cbCommand->signalsBlocked();
+ m_dlg->cbCommand->blockSignals( true );
+ QStringList items = m_pURLCompletion->allMatches();
+ items.sort();
+ if (m_histfilesystemAutocomplete == true) {
+ // Add the history to the list
+ histList += items;
+ maxHistory += maxAutocompletion;
+ }
+ else {
+ histList = items;
+ maxHistory = maxAutocompletion;
+ }
+ current_text = m_dlg->cbCommand->currentText();
+ //histList.prepend ( current_text ); // Add the current text to the autocompletion list
+ m_dlg->cbCommand->setMaxCount( maxHistory );
+ m_dlg->cbCommand->completionObject()->setItems( histList );
+ m_dlg->cbCommand->setCurrentText( current_text );
+ m_dlg->cbCommand->blockSignals( block );
+ }
+ }
+}
+
void Minicli::slotAdvanced()
{
if (m_dlg->gbAdvanced->isHidden())
@@ -722,7 +811,7 @@ void Minicli::setIcon ()
void Minicli::updateAuthLabel()
{
- if (m_dlg->cbPriority->isChecked() && (m_iPriority > 50) ||
+ if ((m_dlg->cbPriority->isChecked() && (m_iPriority > 50)) ||
(m_iScheduler != StubProcess::SchedNormal))
{
if (!m_prevCached && !m_dlg->leUsername->text().isEmpty())
@@ -843,6 +932,42 @@ void Minicli::slotRealtime(bool enabled)
updateAuthLabel();
}
+void Minicli::slotAutocompleteToggled(bool enabled)
+{
+ if (enabled)
+ {
+ // Enable filesystem autocompletion
+ m_filesystemAutocomplete = true;
+ }
+ else {
+ // Enable history only autocompletion
+ m_filesystemAutocomplete = false;
+ }
+
+ QString current_text = m_dlg->cbCommand->currentText();
+ m_dlg->cbCommand->setCurrentText( current_text ); // Force an update of the autocompletion list
+}
+
+void Minicli::slotAutohistoryToggled(bool enabled)
+{
+ if (enabled)
+ {
+ // Enable history and filesystem autocompletion
+ m_histfilesystemAutocomplete = true;
+ m_filesystemAutocomplete = true;
+ m_dlg->cbAutocomplete->setChecked( true );
+ m_dlg->cbAutocomplete->setDisabled ( true );
+ }
+ else {
+ // Disable history and filesystem autocompletion
+ m_histfilesystemAutocomplete = false;
+ m_dlg->cbAutocomplete->setDisabled ( false );
+ }
+
+ QString current_text = m_dlg->cbCommand->currentText();
+ m_dlg->cbCommand->setCurrentText( current_text ); // Force an update of the autocompletion list
+}
+
void Minicli::slotPriority(int priority)
{
// Provide a way to easily return to the default priority
diff --git a/kdesktop/minicli.h b/kdesktop/minicli.h
index 8f98fe3ea..a4215582f 100644
--- a/kdesktop/minicli.h
+++ b/kdesktop/minicli.h
@@ -37,6 +37,8 @@
#include <kdialog.h>
#include <kservice.h>
+#include <kurlcompletion.h>
+
class QTimer;
class QWidget;
class MinicliDlgUI;
@@ -74,10 +76,13 @@ private slots:
void slotParseTimer();
void slotPriority(int);
void slotRealtime(bool);
+ void slotAutocompleteToggled(bool);
+ void slotAutohistoryToggled(bool);
void slotTerminal(bool);
void slotChangeUid(bool);
void slotChangeScheduler(bool);
void slotCmdChanged(const QString&);
+ void slotMatch( const QString&);
private:
void setIcon();
@@ -108,5 +113,11 @@ private:
bool m_prevChecked;
bool m_prevCached;
bool m_autoCheckedRunInTerm;
+
+ // Autocomplete
+ KURLCompletion *m_pURLCompletion;
+ bool m_filesystemAutocomplete;
+ bool m_histfilesystemAutocomplete;
+ bool m_urlCompletionStarted;
};
#endif
diff --git a/kdesktop/minicli_ui.ui b/kdesktop/minicli_ui.ui
index 32416b8f3..3809eb852 100644
--- a/kdesktop/minicli_ui.ui
+++ b/kdesktop/minicli_ui.ui
@@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>325</width>
- <height>370</height>
+ <height>390</height>
</rect>
</property>
<property name="sizePolicy">
@@ -180,6 +180,30 @@
&lt;/qt&gt;</string>
</property>
</widget>
+ <widget class="QCheckBox" row="8" column="0" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>cbAutocomplete</cstring>
+ </property>
+ <property name="text">
+ <string>Autocomplete uses &amp;filesystem instead of history</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;This selects whether the filesystem or the past command history will be used for autocompletion.
+ &lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="9" column="0" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>cbAutohistory</cstring>
+ </property>
+ <property name="text">
+ <string>Autocomplete uses &amp;both history and filesystem</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;This selects whether the filesystem and the past command history will be used for autocompletion.
+ &lt;/qt&gt;</string>
+ </property>
+ </widget>
<widget class="QLabel" row="3" column="1">
<property name="name">
<cstring>lbUsername</cstring>