summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/net/opieirc/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieirc/mainwindow.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp
index 2e674c5..2562f33 100644
--- a/noncore/net/opieirc/mainwindow.cpp
+++ b/noncore/net/opieirc/mainwindow.cpp
@@ -45,43 +45,55 @@ void MainWindow::loadSettings() {
45 IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); 45 IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000");
46 IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); 46 IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000");
47 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); 47 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB");
48 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); 48 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF");
49 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); 49 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300");
50 IRCTab::m_maxLines = config.readNumEntry("Lines", 100); 50 IRCTab::m_maxLines = config.readNumEntry("Lines", 100);
51 IRCTab::setUseTimeStamps( config.readBoolEntry("DisplayTime", false ) );
51} 52}
52 53
53void MainWindow::selected(QWidget *) { 54void MainWindow::selected(QWidget *) {
54 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); 55 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black);
55 emit updateScroll(); 56 emit updateScroll();
56} 57}
57 58
58void MainWindow::addTab(IRCTab *tab) { 59void MainWindow::addTab(IRCTab *tab) {
59 connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*))); 60 connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*)));
60 connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&))); 61 connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&)));
61 connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab())); 62 connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab()));
62 connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab())); 63 connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab()));
63 connect(tab, SIGNAL(closeTab()), this, SLOT(slotCloseTab()));
64 64
65 m_tabWidget->addTab(tab, tab->title()); 65 m_tabWidget->addTab(tab, tab->title());
66 m_tabWidget->showPage(tab); 66 m_tabWidget->showPage(tab);
67 tab->setID(m_tabWidget->currentPageIndex()); 67 tab->setID(m_tabWidget->currentPageIndex());
68 m_tabs.append(tab); 68 m_tabs.append(tab);
69} 69}
70 70
71void MainWindow::changeEvent(IRCTab *tab) { 71void MainWindow::changeEvent(IRCTab *tab) {
72 if (tab->id() != m_tabWidget->currentPageIndex()) 72 if (tab->id() != m_tabWidget->currentPageIndex())
73 m_tabWidget->setTabColor(tab->id(), blue); 73 m_tabWidget->setTabColor(tab->id(), blue);
74} 74}
75 75
76void MainWindow::killTab(IRCTab *tab) { 76void MainWindow::killTab(IRCTab *tab, bool imediate) {
77 m_tabWidget->removePage(tab); 77 m_toDelete.append( tab );
78 m_tabs.remove(tab);
79 78
80 /* there might be nicer ways to do this .. */ 79 if ( imediate )
81 delete tab; 80 slotKillTabsLater();
81 else
82 QTimer::singleShot(0, this, SLOT(slotKillTabsLater()) );
83}
84
85void MainWindow::slotKillTabsLater() {
86 for ( QListIterator<IRCTab> it(m_toDelete); it.current(); ++it ) {
87 m_tabWidget->removePage( it.current() );
88 m_tabs.remove( it.current() );
89 }
90
91 m_toDelete.setAutoDelete( true );
92 m_toDelete.clear();
93 m_toDelete.setAutoDelete( false );
82} 94}
83 95
84void MainWindow::newConnection() { 96void MainWindow::newConnection() {
85 IRCServerList list(this, "ServerList", TRUE); 97 IRCServerList list(this, "ServerList", TRUE);
86 if (list.exec() == QDialog::Accepted && list.hasServer()) { 98 if (list.exec() == QDialog::Accepted && list.hasServer()) {
87 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); 99 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget);
@@ -114,16 +126,10 @@ void MainWindow::slotNextTab() {
114void MainWindow::slotPrevTab() { 126void MainWindow::slotPrevTab() {
115 int i = m_tabWidget->currentPageIndex (); 127 int i = m_tabWidget->currentPageIndex ();
116 if ( i > 1 ) 128 if ( i > 1 )
117 m_tabWidget->setCurrentPage ( i-1 ); 129 m_tabWidget->setCurrentPage ( i-1 );
118} 130}
119 131
120void MainWindow::slotCloseTab() { 132void MainWindow::slotPing( const QString& /*channel*/ ) {
121 IRCTab *tab = (IRCTab *) m_tabWidget->currentPage ();
122 if ( tab )
123 killTab ( tab );
124}
125
126void MainWindow::slotPing( const QString& channel ) {
127 raise(); 133 raise();
128} 134}
129 135