|
|
|
@ -62,28 +62,17 @@ extern "C"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KatePluginFactory::KatePluginFactory()
|
|
|
|
|
TQObject* KatePluginFactory::createObject(TQObject *parent,
|
|
|
|
|
const char *name, const char*, const TQStringList&)
|
|
|
|
|
{
|
|
|
|
|
s_instance = new TDEInstance( "kate" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KatePluginFactory::~KatePluginFactory()
|
|
|
|
|
{
|
|
|
|
|
delete s_instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQObject* KatePluginFactory::createObject(
|
|
|
|
|
TQObject* parent, const char* name, const char*, const TQStringList & )
|
|
|
|
|
{
|
|
|
|
|
return new KatePluginTabBarExtension( parent, name );
|
|
|
|
|
return new KatePluginTabBarExtension(parent, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDEInstance* KatePluginFactory::s_instance = 0L;
|
|
|
|
|
|
|
|
|
|
// BEGIN KatePluginTabBarExtension
|
|
|
|
|
KatePluginTabBarExtension::KatePluginTabBarExtension(
|
|
|
|
|
TQObject* parent, const char* name )
|
|
|
|
|
: Kate::Plugin ( (Kate::Application*)parent, name ),
|
|
|
|
|
KatePluginTabBarExtension::KatePluginTabBarExtension(TQObject *parent, const char *name)
|
|
|
|
|
: Kate::Plugin((Kate::Application*)parent, name),
|
|
|
|
|
pConfig(new TDEConfig("katetabbarextensionpluginrc"))
|
|
|
|
|
{
|
|
|
|
|
pConfig->setGroup("global");
|
|
|
|
@ -93,7 +82,7 @@ KatePluginTabBarExtension::~KatePluginTabBarExtension()
|
|
|
|
|
{
|
|
|
|
|
while (m_views.count() > 0)
|
|
|
|
|
{
|
|
|
|
|
removeView(m_views.at(0)->win);
|
|
|
|
|
removeView(m_views.at(0)->win);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete pConfig;
|
|
|
|
@ -103,11 +92,12 @@ void KatePluginTabBarExtension::addView(Kate::MainWindow *win)
|
|
|
|
|
{
|
|
|
|
|
PluginView *view = new PluginView ();
|
|
|
|
|
|
|
|
|
|
bool bHoriz = pConfig->readBoolEntry("horizontal orientation", true);
|
|
|
|
|
bool sort = pConfig->readBoolEntry("sort", true);
|
|
|
|
|
bool bHoriz = pConfig->readBoolEntry("horizontal orientation", true);
|
|
|
|
|
bool bSort = pConfig->readBoolEntry("sort", true);
|
|
|
|
|
bool bCloseOnMiddleClick = pConfig->readBoolEntry("closeOnMiddleClick", false);
|
|
|
|
|
|
|
|
|
|
view->tabbar = new KateTabBarExtension( application()->documentManager(),
|
|
|
|
|
win, bHoriz, sort, 0, "tabs_hbox");
|
|
|
|
|
view->tabbar = new KateTabBarExtension(application()->documentManager(),
|
|
|
|
|
win, bHoriz, bSort, bCloseOnMiddleClick, 0, "tabs_hbox");
|
|
|
|
|
|
|
|
|
|
new KWidgetAction(view->tabbar, "tab_bar_widget",
|
|
|
|
|
TDEShortcut::null(), 0, 0, view->actionCollection(), "tabbar_widget");
|
|
|
|
@ -122,8 +112,8 @@ void KatePluginTabBarExtension::addView(Kate::MainWindow *win)
|
|
|
|
|
TDEToolBar* toolbar = dynamic_cast<TDEToolBar*>
|
|
|
|
|
(win->guiFactory()->container("tabbarExtensionToolBar", view));
|
|
|
|
|
if (toolbar) {
|
|
|
|
|
connect(toolbar, TQT_SIGNAL( orientationChanged(Qt::Orientation) ),
|
|
|
|
|
view->tabbar, TQT_SLOT( slotMoved(Qt::Orientation) ));
|
|
|
|
|
connect(toolbar, TQT_SIGNAL(orientationChanged(Qt::Orientation)),
|
|
|
|
|
view->tabbar, TQT_SLOT(slotMoved(Qt::Orientation)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -140,6 +130,7 @@ void KatePluginTabBarExtension::removeView(Kate::MainWindow *win)
|
|
|
|
|
pConfig->writeEntry("horizontal orientation",
|
|
|
|
|
view->tabbar->orientation()==Qt::Horizontal?true:false);
|
|
|
|
|
pConfig->writeEntry("sort", view->tabbar->sortByName());
|
|
|
|
|
pConfig->writeEntry("closeOnMiddleClick", view->tabbar->closeOnMiddleClick());
|
|
|
|
|
pConfig->sync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -161,14 +152,16 @@ Kate::PluginConfigPage* KatePluginTabBarExtension::configPage(
|
|
|
|
|
return (Kate::PluginConfigPage*)p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KatePluginTabBarExtension::initConfigPage( KateTabBarExtensionConfigPage* p )
|
|
|
|
|
void KatePluginTabBarExtension::initConfigPage(KateTabBarExtensionConfigPage *p)
|
|
|
|
|
{
|
|
|
|
|
p->pSortAlpha->setChecked(m_views.at(0)->tabbar->sortByName());
|
|
|
|
|
p->pCloseOnMiddleClick->setChecked(m_views.at(0)->tabbar->closeOnMiddleClick());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KatePluginTabBarExtension::applyConfig( KateTabBarExtensionConfigPage* p )
|
|
|
|
|
void KatePluginTabBarExtension::applyConfig(KateTabBarExtensionConfigPage *p)
|
|
|
|
|
{
|
|
|
|
|
m_views.at(0)->tabbar->setSortByName(p->pSortAlpha->isChecked());
|
|
|
|
|
m_views.at(0)->tabbar->setCloseOnMiddleClick(p->pCloseOnMiddleClick->isChecked());
|
|
|
|
|
// sync m_config in destructor
|
|
|
|
|
}
|
|
|
|
|
// END KatePluginTabBarExtension
|
|
|
|
@ -191,13 +184,6 @@ KateTabBarButton::KateTabBarButton(Kate::ViewManager* pViewManager,
|
|
|
|
|
connect(this, TQT_SIGNAL(toggled(bool)), TQT_SLOT(setOn(bool)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KateTabBarButton::~KateTabBarButton() {}
|
|
|
|
|
|
|
|
|
|
uint KateTabBarButton::documentNumber()
|
|
|
|
|
{
|
|
|
|
|
return myDocID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KateTabBarButton::setDirty(bool d)
|
|
|
|
|
{
|
|
|
|
|
if (d) {
|
|
|
|
@ -221,6 +207,20 @@ void KateTabBarButton::setText( const TQString& newText)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KateTabBarButton::mouseReleaseEvent(TQMouseEvent *e)
|
|
|
|
|
{
|
|
|
|
|
// Only handle middle click events when no keyboard modifier is pressed
|
|
|
|
|
if (e->button() == TQt::MidButton && !(e->state() & TQt::KeyButtonMask))
|
|
|
|
|
{
|
|
|
|
|
emit middleButtonPressed(this);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Invoke parent handler for unwanted events
|
|
|
|
|
TQPushButton::mouseReleaseEvent(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQString KateTabBarButton::fullName() const
|
|
|
|
|
{
|
|
|
|
|
if (doc) {
|
|
|
|
@ -262,9 +262,9 @@ void KateTabBarButton::setOn(bool on)
|
|
|
|
|
// END KateTabBarButton
|
|
|
|
|
|
|
|
|
|
// BEGIN KateTabBarExtension
|
|
|
|
|
KateTabBarExtension::KateTabBarExtension( Kate::DocumentManager *pDocManager,
|
|
|
|
|
KateTabBarExtension::KateTabBarExtension(Kate::DocumentManager *pDocManager,
|
|
|
|
|
Kate::MainWindow *win, bool bHorizOrientation, bool bSort,
|
|
|
|
|
TQWidget* parent, const char* name, WFlags f )
|
|
|
|
|
bool bCloseOnMiddleClick, TQWidget* parent, const char* name, WFlags f)
|
|
|
|
|
: TQWidget(parent, name, f),
|
|
|
|
|
pCurrentTab(0), m_win(win), m_docManager(pDocManager), m_sort(false)
|
|
|
|
|
{
|
|
|
|
@ -291,10 +291,9 @@ KateTabBarExtension::KateTabBarExtension( Kate::DocumentManager *pDocManager,
|
|
|
|
|
TQT_SLOT(slotDocumentDeleted(uint)));
|
|
|
|
|
|
|
|
|
|
setSortByName(bSort);
|
|
|
|
|
setCloseOnMiddleClick(bCloseOnMiddleClick);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KateTabBarExtension::~KateTabBarExtension() {}
|
|
|
|
|
|
|
|
|
|
void KateTabBarExtension::slotMoved(Qt::Orientation o)
|
|
|
|
|
{
|
|
|
|
|
// the tabbar moved (top, right, bottom, left or fluently)
|
|
|
|
@ -311,16 +310,6 @@ void KateTabBarExtension::slotMoved(Qt::Orientation o)
|
|
|
|
|
m_orientation = o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt::Orientation KateTabBarExtension::orientation() const
|
|
|
|
|
{
|
|
|
|
|
return m_orientation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool KateTabBarExtension::sortByName() const
|
|
|
|
|
{
|
|
|
|
|
return m_sort;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KateTabBarExtension::setSortByName(bool sbn)
|
|
|
|
|
{
|
|
|
|
|
if (m_sort != sbn) {
|
|
|
|
@ -359,6 +348,8 @@ void KateTabBarExtension::slotDocumentCreated (Kate::Document *doc)
|
|
|
|
|
KateTabBarButton* tab = new KateTabBarButton(m_win->viewManager(), doc, this);
|
|
|
|
|
connect(tab, TQT_SIGNAL(myToggled(KateTabBarButton*)),
|
|
|
|
|
TQT_SLOT(slotActivateView(KateTabBarButton*)));
|
|
|
|
|
connect(tab, TQT_SIGNAL(middleButtonPressed(KateTabBarButton*)),
|
|
|
|
|
TQT_SLOT(slotRequestDocClose(KateTabBarButton*)));
|
|
|
|
|
connect(doc, TQT_SIGNAL(nameChanged(Kate::Document *)),
|
|
|
|
|
TQT_SLOT(slotNameChanged(Kate::Document *)));
|
|
|
|
|
connect(doc, TQT_SIGNAL(modStateChanged(Kate::Document *)),
|
|
|
|
@ -471,6 +462,14 @@ void KateTabBarExtension::slotViewChanged ()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KateTabBarExtension::slotRequestDocClose(KateTabBarButton *tab)
|
|
|
|
|
{
|
|
|
|
|
if (closeOnMiddleClick() && tab)
|
|
|
|
|
{
|
|
|
|
|
m_docManager->closeDocument(tab->document());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// END KateTabBarExtension
|
|
|
|
|
|
|
|
|
|
// BEGIN KateTabBarExtensionConfigPage
|
|
|
|
@ -481,23 +480,17 @@ KateTabBarExtensionConfigPage::KateTabBarExtensionConfigPage(
|
|
|
|
|
TQVBoxLayout* top = new TQVBoxLayout(this, 0,
|
|
|
|
|
KDialogBase::spacingHint());
|
|
|
|
|
|
|
|
|
|
TQGroupBox* gb = new TQGroupBox( i18n("Sorting Behavior"),
|
|
|
|
|
this, "tab_bar_extension_config_page_layout" );
|
|
|
|
|
gb->setColumnLayout(1, Qt::Vertical);
|
|
|
|
|
TQGroupBox* gb = new TQGroupBox(1, Qt::Horizontal, i18n("Behavior options"),
|
|
|
|
|
this, "tab_bar_extension_config_page_layout" );
|
|
|
|
|
gb->setInsideSpacing(KDialogBase::spacingHint());
|
|
|
|
|
pSortAlpha = new TQCheckBox(i18n("Sort files alphabetically"), gb);
|
|
|
|
|
pCloseOnMiddleClick = new TQCheckBox(i18n("Close document on mouse middle click"), gb);
|
|
|
|
|
|
|
|
|
|
top->add(gb);
|
|
|
|
|
top->addStretch(1);
|
|
|
|
|
// throw signal changed
|
|
|
|
|
connect(pSortAlpha, TQT_SIGNAL(toggled(bool)), this, TQT_SIGNAL(changed()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KateTabBarExtensionConfigPage::~KateTabBarExtensionConfigPage() {}
|
|
|
|
|
|
|
|
|
|
void KateTabBarExtensionConfigPage::apply()
|
|
|
|
|
{
|
|
|
|
|
emit configPageApplyRequest( this );
|
|
|
|
|
connect(pCloseOnMiddleClick, TQT_SIGNAL(toggled(bool)), this, TQT_SIGNAL(changed()));
|
|
|
|
|
}
|
|
|
|
|
// END KateTabBarExtensionConfigPage
|
|
|
|
|
|
|
|
|
|