Restore --background-mode

For now restore this option that was removed for 2.11.  This option
is somewhat a hack and abnormal feature.  However, it seems a number
of people use it and I can see how it would be useful.  So instead of
spending a lot of time right now trying to correct the issues, just
restore the previous code.
Ideally for KDE 5, this portion of the code can be better handled.

35bb9cf9e7

BUG: 320783
FIXED-IN: 2.13#
wilder-portage
Kurt Hindenburg 12 years ago
parent db6d9de83e
commit cfbfb0fd8c
  1. 6
      doc/manual/index.docbook
  2. 40
      src/Application.cpp
  3. 5
      src/Application.h
  4. 3
      src/main.cpp

@ -1040,6 +1040,12 @@ For more information, please visit
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--background-mode</option></term>
<listitem><para><action>Start &konsole;</action> in the background and bring to the front when <keycombo action="simul">&Ctrl;&Shift;<keycap>F12</keycap></keycombo> (by default) is pressed.
</para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>--new-tab</option></term> <term><option>--new-tab</option></term>
<listitem><para><action>Create a new tab</action> in an existing window rather than creating a new window. <listitem><para><action>Create a new tab</action> in an existing window rather than creating a new window.

@ -46,6 +46,8 @@ Application::Application() : KUniqueApplication()
void Application::init() void Application::init()
{ {
_backgroundInstance = 0;
#if defined(Q_WS_MAC) #if defined(Q_WS_MAC)
// this ensures that Ctrl and Meta are not swapped, so CTRL-C and friends // this ensures that Ctrl and Meta are not swapped, so CTRL-C and friends
// will work correctly in the terminal // will work correctly in the terminal
@ -125,6 +127,11 @@ int Application::newInstance()
} }
} }
// if the background-mode argument is supplied, start the background
// session ( or bring to the front if it already exists )
if (args->isSet("background-mode")) {
startBackgroundMode(window);
} else {
// Qt constrains top-level windows which have not been manually // Qt constrains top-level windows which have not been manually
// resized (via QWidget::resize()) to a maximum of 2/3rds of the // resized (via QWidget::resize()) to a maximum of 2/3rds of the
// screen size. // screen size.
@ -142,6 +149,7 @@ int Application::newInstance()
window->show(); window->show();
} }
}
firstInstance = false; firstInstance = false;
args->clear(); args->clear();
@ -425,5 +433,37 @@ Profile::Ptr Application::processProfileChangeArgs(KCmdLineArgs* args, Profile::
} }
} }
void Application::startBackgroundMode(MainWindow* window)
{
if (_backgroundInstance) {
return;
}
KAction* action = window->actionCollection()->addAction("toggle-background-window");
action->setObjectName(QLatin1String("Konsole Background Mode"));
action->setText(i18n("Toggle Background Window"));
action->setGlobalShortcut(KShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_F12)));
connect(action, SIGNAL(triggered()),
this, SLOT(toggleBackgroundInstance()));
_backgroundInstance = window;
}
void Application::toggleBackgroundInstance()
{
Q_ASSERT(_backgroundInstance);
if (!_backgroundInstance->isVisible()) {
_backgroundInstance->show();
// ensure that the active terminal display has the focus. Without
// this, an odd problem occurred where the focus widget would change
// each time the background instance was shown
_backgroundInstance->setFocus();
} else {
_backgroundInstance->hide();
}
}
#include "Application.moc" #include "Application.moc"

@ -69,10 +69,13 @@ private slots:
void createWindow(Profile::Ptr profile , const QString& directory); void createWindow(Profile::Ptr profile , const QString& directory);
void detachView(Session* session); void detachView(Session* session);
void toggleBackgroundInstance();
private: private:
void init(); void init();
void listAvailableProfiles(); void listAvailableProfiles();
void listProfilePropertyInfo(); void listProfilePropertyInfo();
void startBackgroundMode(MainWindow* window);
bool processHelpArgs(KCmdLineArgs* args); bool processHelpArgs(KCmdLineArgs* args);
MainWindow* processWindowArgs(KCmdLineArgs* args); MainWindow* processWindowArgs(KCmdLineArgs* args);
Profile::Ptr processProfileSelectArgs(KCmdLineArgs* args); Profile::Ptr processProfileSelectArgs(KCmdLineArgs* args);
@ -80,6 +83,8 @@ private:
void processTabsFromFileArgs(KCmdLineArgs* args, MainWindow* window); void processTabsFromFileArgs(KCmdLineArgs* args, MainWindow* window);
void createTabFromArgs(KCmdLineArgs* args, MainWindow* window, void createTabFromArgs(KCmdLineArgs* args, MainWindow* window,
const QHash<QString, QString>&); const QHash<QString, QString>&);
MainWindow* _backgroundInstance;
}; };
} }
#endif // APPLICATION_H #endif // APPLICATION_H

@ -170,6 +170,9 @@ void fillCommandLineOptions(KCmdLineOptions& options)
options.add("tabs-from-file <file>", options.add("tabs-from-file <file>",
ki18nc("@info:shell", "Create tabs as specified in given tabs configuration" ki18nc("@info:shell", "Create tabs as specified in given tabs configuration"
" file")); " file"));
options.add("background-mode",
ki18nc("@info:shell", "Start Konsole in the background and bring to the front"
" when Ctrl+Shift+F12 (by default) is pressed"));
options.add("show-menubar", ki18nc("@info:shell", "Show the menubar, overriding the default setting")); options.add("show-menubar", ki18nc("@info:shell", "Show the menubar, overriding the default setting"));
options.add("hide-menubar", ki18nc("@info:shell", "Hide the menubar, overriding the default setting")); options.add("hide-menubar", ki18nc("@info:shell", "Hide the menubar, overriding the default setting"));
options.add("show-tabbar", ki18nc("@info:shell", "Show the tabbar, overriding the default setting")); options.add("show-tabbar", ki18nc("@info:shell", "Show the tabbar, overriding the default setting"));

Loading…
Cancel
Save