Diffstat (limited to 'noncore/net/opieirc/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 32 |
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 | |||
@@ -39,55 +39,67 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow( | |||
39 | 39 | ||
40 | void MainWindow::loadSettings() { | 40 | void MainWindow::loadSettings() { |
41 | Config config("OpieIRC"); | 41 | Config config("OpieIRC"); |
42 | config.setGroup("OpieIRC"); | 42 | config.setGroup("OpieIRC"); |
43 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); | 43 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); |
44 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); | 44 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); |
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 | ||
53 | void MainWindow::selected(QWidget *) { | 54 | void 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 | ||
58 | void MainWindow::addTab(IRCTab *tab) { | 59 | void 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 | ||
71 | void MainWindow::changeEvent(IRCTab *tab) { | 71 | void 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 | ||
76 | void MainWindow::killTab(IRCTab *tab) { | 76 | void 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 | |||
85 | void 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 | ||
84 | void MainWindow::newConnection() { | 96 | void 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); |
88 | addTab(serverTab); | 100 | addTab(serverTab); |
89 | serverTab->doConnect(); | 101 | serverTab->doConnect(); |
90 | } | 102 | } |
91 | } | 103 | } |
92 | 104 | ||
93 | void MainWindow::settings() { | 105 | void MainWindow::settings() { |
@@ -108,22 +120,16 @@ void MainWindow::slotNextTab() { | |||
108 | 120 | ||
109 | int j = m_tabWidget->currentPageIndex (); | 121 | int j = m_tabWidget->currentPageIndex (); |
110 | if ( i == j ) | 122 | if ( i == j ) |
111 | m_tabWidget->setCurrentPage ( 1 ); | 123 | m_tabWidget->setCurrentPage ( 1 ); |
112 | } | 124 | } |
113 | 125 | ||
114 | void MainWindow::slotPrevTab() { | 126 | void 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 | ||
120 | void MainWindow::slotCloseTab() { | 132 | void MainWindow::slotPing( const QString& /*channel*/ ) { |
121 | IRCTab *tab = (IRCTab *) m_tabWidget->currentPage (); | ||
122 | if ( tab ) | ||
123 | killTab ( tab ); | ||
124 | } | ||
125 | |||
126 | void MainWindow::slotPing( const QString& channel ) { | ||
127 | raise(); | 133 | raise(); |
128 | } | 134 | } |
129 | 135 | ||