|
Lines 4-9
Link Here
|
| 4 |
begin : 2004-04-20 |
4 |
begin : 2004-04-20 |
| 5 |
copyright : (C) 2004 by Dominik Haumann |
5 |
copyright : (C) 2004 by Dominik Haumann |
| 6 |
email : dhdev@gmx.de |
6 |
email : dhdev@gmx.de |
|
|
7 |
updated : 2013-09-18 by Michele Calgaro |
| 8 |
- added "close document on mouse middle click" feature |
| 7 |
***************************************************************************/ |
9 |
***************************************************************************/ |
| 8 |
|
10 |
|
| 9 |
/*************************************************************************** |
11 |
/*************************************************************************** |
|
Lines 62-89
Link Here
|
| 62 |
} |
64 |
} |
| 63 |
} |
65 |
} |
| 64 |
|
66 |
|
| 65 |
KatePluginFactory::KatePluginFactory() |
67 |
TQObject* KatePluginFactory::createObject(TQObject *parent, |
|
|
68 |
const char *name, const char*, const TQStringList&) |
| 66 |
{ |
69 |
{ |
| 67 |
s_instance = new TDEInstance( "kate" ); |
70 |
return new KatePluginTabBarExtension(parent, name); |
| 68 |
} |
|
|
| 69 |
|
| 70 |
KatePluginFactory::~KatePluginFactory() |
| 71 |
{ |
| 72 |
delete s_instance; |
| 73 |
} |
| 74 |
|
| 75 |
TQObject* KatePluginFactory::createObject( |
| 76 |
TQObject* parent, const char* name, const char*, const TQStringList & ) |
| 77 |
{ |
| 78 |
return new KatePluginTabBarExtension( parent, name ); |
| 79 |
} |
71 |
} |
| 80 |
|
72 |
|
| 81 |
TDEInstance* KatePluginFactory::s_instance = 0L; |
73 |
TDEInstance* KatePluginFactory::s_instance = 0L; |
| 82 |
|
74 |
|
| 83 |
// BEGIN KatePluginTabBarExtension |
75 |
// BEGIN KatePluginTabBarExtension |
| 84 |
KatePluginTabBarExtension::KatePluginTabBarExtension( |
76 |
KatePluginTabBarExtension::KatePluginTabBarExtension(TQObject *parent, const char *name) |
| 85 |
TQObject* parent, const char* name ) |
77 |
: Kate::Plugin((Kate::Application*)parent, name), |
| 86 |
: Kate::Plugin ( (Kate::Application*)parent, name ), |
|
|
| 87 |
pConfig(new TDEConfig("katetabbarextensionpluginrc")) |
78 |
pConfig(new TDEConfig("katetabbarextensionpluginrc")) |
| 88 |
{ |
79 |
{ |
| 89 |
pConfig->setGroup("global"); |
80 |
pConfig->setGroup("global"); |
|
Lines 93-99
Link Here
|
| 93 |
{ |
84 |
{ |
| 94 |
while (m_views.count() > 0) |
85 |
while (m_views.count() > 0) |
| 95 |
{ |
86 |
{ |
| 96 |
removeView(m_views.at(0)->win); |
87 |
removeView(m_views.at(0)->win); |
| 97 |
} |
88 |
} |
| 98 |
|
89 |
|
| 99 |
delete pConfig; |
90 |
delete pConfig; |
|
Lines 103-113
Link Here
|
| 103 |
{ |
94 |
{ |
| 104 |
PluginView *view = new PluginView (); |
95 |
PluginView *view = new PluginView (); |
| 105 |
|
96 |
|
| 106 |
bool bHoriz = pConfig->readBoolEntry("horizontal orientation", true); |
97 |
bool bHoriz = pConfig->readBoolEntry("horizontal orientation", true); |
| 107 |
bool sort = pConfig->readBoolEntry("sort", true); |
98 |
bool bSort = pConfig->readBoolEntry("sort", true); |
|
|
99 |
bool bCloseOnMiddleClick = pConfig->readBoolEntry("closeOnMiddleClick", false); |
| 108 |
|
100 |
|
| 109 |
view->tabbar = new KateTabBarExtension( application()->documentManager(), |
101 |
view->tabbar = new KateTabBarExtension(application()->documentManager(), |
| 110 |
win, bHoriz, sort, 0, "tabs_hbox"); |
102 |
win, bHoriz, bSort, bCloseOnMiddleClick, 0, "tabs_hbox"); |
| 111 |
|
103 |
|
| 112 |
new KWidgetAction(view->tabbar, "tab_bar_widget", |
104 |
new KWidgetAction(view->tabbar, "tab_bar_widget", |
| 113 |
TDEShortcut::null(), 0, 0, view->actionCollection(), "tabbar_widget"); |
105 |
TDEShortcut::null(), 0, 0, view->actionCollection(), "tabbar_widget"); |
|
Lines 122-129
Link Here
|
| 122 |
TDEToolBar* toolbar = dynamic_cast<TDEToolBar*> |
114 |
TDEToolBar* toolbar = dynamic_cast<TDEToolBar*> |
| 123 |
(win->guiFactory()->container("tabbarExtensionToolBar", view)); |
115 |
(win->guiFactory()->container("tabbarExtensionToolBar", view)); |
| 124 |
if (toolbar) { |
116 |
if (toolbar) { |
| 125 |
connect(toolbar, TQT_SIGNAL( orientationChanged(Qt::Orientation) ), |
117 |
connect(toolbar, TQT_SIGNAL(orientationChanged(Qt::Orientation)), |
| 126 |
view->tabbar, TQT_SLOT( slotMoved(Qt::Orientation) )); |
118 |
view->tabbar, TQT_SLOT(slotMoved(Qt::Orientation))); |
| 127 |
} |
119 |
} |
| 128 |
} |
120 |
} |
| 129 |
|
121 |
|
|
Lines 140-145
Link Here
|
| 140 |
pConfig->writeEntry("horizontal orientation", |
132 |
pConfig->writeEntry("horizontal orientation", |
| 141 |
view->tabbar->orientation()==Qt::Horizontal?true:false); |
133 |
view->tabbar->orientation()==Qt::Horizontal?true:false); |
| 142 |
pConfig->writeEntry("sort", view->tabbar->sortByName()); |
134 |
pConfig->writeEntry("sort", view->tabbar->sortByName()); |
|
|
135 |
pConfig->writeEntry("closeOnMiddleClick", view->tabbar->closeOnMiddleClick()); |
| 143 |
pConfig->sync(); |
136 |
pConfig->sync(); |
| 144 |
} |
137 |
} |
| 145 |
|
138 |
|
|
Lines 161-174
Link Here
|
| 161 |
return (Kate::PluginConfigPage*)p; |
154 |
return (Kate::PluginConfigPage*)p; |
| 162 |
} |
155 |
} |
| 163 |
|
156 |
|
| 164 |
void KatePluginTabBarExtension::initConfigPage( KateTabBarExtensionConfigPage* p ) |
157 |
void KatePluginTabBarExtension::initConfigPage(KateTabBarExtensionConfigPage *p) |
| 165 |
{ |
158 |
{ |
| 166 |
p->pSortAlpha->setChecked(m_views.at(0)->tabbar->sortByName()); |
159 |
p->pSortAlpha->setChecked(m_views.at(0)->tabbar->sortByName()); |
|
|
160 |
p->pCloseOnMiddleClick->setChecked(m_views.at(0)->tabbar->closeOnMiddleClick()); |
| 167 |
} |
161 |
} |
| 168 |
|
162 |
|
| 169 |
void KatePluginTabBarExtension::applyConfig( KateTabBarExtensionConfigPage* p ) |
163 |
void KatePluginTabBarExtension::applyConfig(KateTabBarExtensionConfigPage *p) |
| 170 |
{ |
164 |
{ |
| 171 |
m_views.at(0)->tabbar->setSortByName(p->pSortAlpha->isChecked()); |
165 |
m_views.at(0)->tabbar->setSortByName(p->pSortAlpha->isChecked()); |
|
|
166 |
m_views.at(0)->tabbar->setCloseOnMiddleClick(p->pCloseOnMiddleClick->isChecked()); |
| 172 |
// sync m_config in destructor |
167 |
// sync m_config in destructor |
| 173 |
} |
168 |
} |
| 174 |
// END KatePluginTabBarExtension |
169 |
// END KatePluginTabBarExtension |
|
Lines 191-203
Link Here
|
| 191 |
connect(this, TQT_SIGNAL(toggled(bool)), TQT_SLOT(setOn(bool))); |
186 |
connect(this, TQT_SIGNAL(toggled(bool)), TQT_SLOT(setOn(bool))); |
| 192 |
} |
187 |
} |
| 193 |
|
188 |
|
| 194 |
KateTabBarButton::~KateTabBarButton() {} |
|
|
| 195 |
|
| 196 |
uint KateTabBarButton::documentNumber() |
| 197 |
{ |
| 198 |
return myDocID; |
| 199 |
} |
| 200 |
|
| 201 |
void KateTabBarButton::setDirty(bool d) |
189 |
void KateTabBarButton::setDirty(bool d) |
| 202 |
{ |
190 |
{ |
| 203 |
if (d) { |
191 |
if (d) { |
|
Lines 221-226
Link Here
|
| 221 |
} |
209 |
} |
| 222 |
} |
210 |
} |
| 223 |
|
211 |
|
|
|
212 |
void KateTabBarButton::mouseReleaseEvent(TQMouseEvent *e) |
| 213 |
{ |
| 214 |
// Only handle middle click events when no keyboard modifier is pressed |
| 215 |
if (e->button() == TQt::MidButton && !(e->state() & TQt::KeyButtonMask)) |
| 216 |
{ |
| 217 |
emit middleButtonPressed(this); |
| 218 |
} |
| 219 |
else |
| 220 |
{ |
| 221 |
// Invoke parent handler for unwanted events |
| 222 |
TQPushButton::mouseReleaseEvent(e); |
| 223 |
} |
| 224 |
} |
| 225 |
|
| 224 |
TQString KateTabBarButton::fullName() const |
226 |
TQString KateTabBarButton::fullName() const |
| 225 |
{ |
227 |
{ |
| 226 |
if (doc) { |
228 |
if (doc) { |
|
Lines 262-270
Link Here
|
| 262 |
// END KateTabBarButton |
264 |
// END KateTabBarButton |
| 263 |
|
265 |
|
| 264 |
// BEGIN KateTabBarExtension |
266 |
// BEGIN KateTabBarExtension |
| 265 |
KateTabBarExtension::KateTabBarExtension( Kate::DocumentManager *pDocManager, |
267 |
KateTabBarExtension::KateTabBarExtension(Kate::DocumentManager *pDocManager, |
| 266 |
Kate::MainWindow *win, bool bHorizOrientation, bool bSort, |
268 |
Kate::MainWindow *win, bool bHorizOrientation, bool bSort, |
| 267 |
TQWidget* parent, const char* name, WFlags f ) |
269 |
bool bCloseOnMiddleClick, TQWidget* parent, const char* name, WFlags f) |
| 268 |
: TQWidget(parent, name, f), |
270 |
: TQWidget(parent, name, f), |
| 269 |
pCurrentTab(0), m_win(win), m_docManager(pDocManager), m_sort(false) |
271 |
pCurrentTab(0), m_win(win), m_docManager(pDocManager), m_sort(false) |
| 270 |
{ |
272 |
{ |
|
Lines 291-300
Link Here
|
| 291 |
TQT_SLOT(slotDocumentDeleted(uint))); |
293 |
TQT_SLOT(slotDocumentDeleted(uint))); |
| 292 |
|
294 |
|
| 293 |
setSortByName(bSort); |
295 |
setSortByName(bSort); |
|
|
296 |
setCloseOnMiddleClick(bCloseOnMiddleClick); |
| 294 |
} |
297 |
} |
| 295 |
|
298 |
|
| 296 |
KateTabBarExtension::~KateTabBarExtension() {} |
|
|
| 297 |
|
| 298 |
void KateTabBarExtension::slotMoved(Qt::Orientation o) |
299 |
void KateTabBarExtension::slotMoved(Qt::Orientation o) |
| 299 |
{ |
300 |
{ |
| 300 |
// the tabbar moved (top, right, bottom, left or fluently) |
301 |
// the tabbar moved (top, right, bottom, left or fluently) |
|
Lines 311-326
Link Here
|
| 311 |
m_orientation = o; |
312 |
m_orientation = o; |
| 312 |
} |
313 |
} |
| 313 |
|
314 |
|
| 314 |
Qt::Orientation KateTabBarExtension::orientation() const |
|
|
| 315 |
{ |
| 316 |
return m_orientation; |
| 317 |
} |
| 318 |
|
| 319 |
bool KateTabBarExtension::sortByName() const |
| 320 |
{ |
| 321 |
return m_sort; |
| 322 |
} |
| 323 |
|
| 324 |
void KateTabBarExtension::setSortByName(bool sbn) |
315 |
void KateTabBarExtension::setSortByName(bool sbn) |
| 325 |
{ |
316 |
{ |
| 326 |
if (m_sort != sbn) { |
317 |
if (m_sort != sbn) { |
|
Lines 359-364
Link Here
|
| 359 |
KateTabBarButton* tab = new KateTabBarButton(m_win->viewManager(), doc, this); |
350 |
KateTabBarButton* tab = new KateTabBarButton(m_win->viewManager(), doc, this); |
| 360 |
connect(tab, TQT_SIGNAL(myToggled(KateTabBarButton*)), |
351 |
connect(tab, TQT_SIGNAL(myToggled(KateTabBarButton*)), |
| 361 |
TQT_SLOT(slotActivateView(KateTabBarButton*))); |
352 |
TQT_SLOT(slotActivateView(KateTabBarButton*))); |
|
|
353 |
connect(tab, TQT_SIGNAL(middleButtonPressed(KateTabBarButton*)), |
| 354 |
TQT_SLOT(slotRequestDocClose(KateTabBarButton*))); |
| 362 |
connect(doc, TQT_SIGNAL(nameChanged(Kate::Document *)), |
355 |
connect(doc, TQT_SIGNAL(nameChanged(Kate::Document *)), |
| 363 |
TQT_SLOT(slotNameChanged(Kate::Document *))); |
356 |
TQT_SLOT(slotNameChanged(Kate::Document *))); |
| 364 |
connect(doc, TQT_SIGNAL(modStateChanged(Kate::Document *)), |
357 |
connect(doc, TQT_SIGNAL(modStateChanged(Kate::Document *)), |
|
Lines 471-476
Link Here
|
| 471 |
} |
464 |
} |
| 472 |
} |
465 |
} |
| 473 |
} |
466 |
} |
|
|
467 |
|
| 468 |
void KateTabBarExtension::slotRequestDocClose(KateTabBarButton *tab) |
| 469 |
{ |
| 470 |
if (closeOnMiddleClick() && tab) |
| 471 |
{ |
| 472 |
m_docManager->closeDocument(tab->document()); |
| 473 |
} |
| 474 |
} |
| 474 |
// END KateTabBarExtension |
475 |
// END KateTabBarExtension |
| 475 |
|
476 |
|
| 476 |
// BEGIN KateTabBarExtensionConfigPage |
477 |
// BEGIN KateTabBarExtensionConfigPage |
|
Lines 481-503
Link Here
|
| 481 |
TQVBoxLayout* top = new TQVBoxLayout(this, 0, |
483 |
TQVBoxLayout* top = new TQVBoxLayout(this, 0, |
| 482 |
KDialogBase::spacingHint()); |
484 |
KDialogBase::spacingHint()); |
| 483 |
|
485 |
|
| 484 |
TQGroupBox* gb = new TQGroupBox( i18n("Sorting Behavior"), |
486 |
TQGroupBox* gb = new TQGroupBox(1, Qt::Horizontal, i18n("Behavior options"), |
| 485 |
this, "tab_bar_extension_config_page_layout" ); |
487 |
this, "tab_bar_extension_config_page_layout" ); |
| 486 |
gb->setColumnLayout(1, Qt::Vertical); |
|
|
| 487 |
gb->setInsideSpacing(KDialogBase::spacingHint()); |
488 |
gb->setInsideSpacing(KDialogBase::spacingHint()); |
| 488 |
pSortAlpha = new TQCheckBox(i18n("Sort files alphabetically"), gb); |
489 |
pSortAlpha = new TQCheckBox(i18n("Sort files alphabetically"), gb); |
|
|
490 |
pCloseOnMiddleClick = new TQCheckBox(i18n("Close document on mouse middle click"), gb); |
| 489 |
|
491 |
|
| 490 |
top->add(gb); |
492 |
top->add(gb); |
| 491 |
top->addStretch(1); |
493 |
top->addStretch(1); |
| 492 |
// throw signal changed |
494 |
// throw signal changed |
| 493 |
connect(pSortAlpha, TQT_SIGNAL(toggled(bool)), this, TQT_SIGNAL(changed())); |
495 |
connect(pSortAlpha, TQT_SIGNAL(toggled(bool)), this, TQT_SIGNAL(changed())); |
| 494 |
} |
496 |
connect(pCloseOnMiddleClick, TQT_SIGNAL(toggled(bool)), this, TQT_SIGNAL(changed())); |
| 495 |
|
|
|
| 496 |
KateTabBarExtensionConfigPage::~KateTabBarExtensionConfigPage() {} |
| 497 |
|
| 498 |
void KateTabBarExtensionConfigPage::apply() |
| 499 |
{ |
| 500 |
emit configPageApplyRequest( this ); |
| 501 |
} |
497 |
} |
| 502 |
// END KateTabBarExtensionConfigPage |
498 |
// END KateTabBarExtensionConfigPage |
| 503 |
|
499 |
|