# HG changeset patch # User Jacob Dawid # Date 1337854133 -7200 # Node ID 628eeaf879f761b128eadda3c4c3a02aff293a71 # Parent 9fa8955ea79d444a0739224bf2870852171ac9ed Copy/Paste buttons get greyed out in the editor correctly again. Removed margin in editor tabs and status bar. * FileEditor: Removed status bar and added slot to handle changes in tabs. * FileEditorTab: Removed margen and added signal when copying is possible. diff -r 9fa8955ea79d -r 628eeaf879f7 gui/src/editor/FileEditor.cpp --- a/gui/src/editor/FileEditor.cpp Wed May 23 16:20:29 2012 -0400 +++ b/gui/src/editor/FileEditor.cpp Thu May 24 12:08:53 2012 +0200 @@ -232,6 +232,25 @@ } void +FileEditor::activeTabChanged (int index) +{ + Q_UNUSED (index); + handleEditorStateChanged (); +} + +void +FileEditor::handleEditorStateChanged () +{ + FileEditorTab *fileEditorTab = activeEditorTab (); + if (fileEditorTab) + { + bool copyAvailable = fileEditorTab->copyAvailable (); + m_copyAction->setEnabled (copyAvailable); + m_cutAction->setEnabled (copyAvailable); + } +} + +void FileEditor::construct () { QSettings *settings = ResourceManager::instance ()->settings (); @@ -239,7 +258,6 @@ m_menuBar = new QMenuBar (this); m_toolBar = new QToolBar (this); - m_statusBar = new QStatusBar (this); m_tabWidget = new QTabWidget (this); m_tabWidget->setTabsClosable (true); //m_longTitle = settings->value ("editor/longWindowTitle",true).toBool (); @@ -353,7 +371,6 @@ layout->addWidget (m_menuBar); layout->addWidget (m_toolBar); layout->addWidget (m_tabWidget); - layout->addWidget (m_statusBar); layout->setMargin (0); setLayout (layout); @@ -374,6 +391,7 @@ connect (commentSelectedAction, SIGNAL (triggered ()), this, SLOT (requestCommentSelectedText ())); connect (uncommentSelectedAction, SIGNAL (triggered ()), this, SLOT (requestUncommentSelectedText ())); connect (m_tabWidget, SIGNAL (tabCloseRequested (int)), this, SLOT (handleTabCloseRequest (int))); + connect (m_tabWidget, SIGNAL (currentChanged(int)), this, SLOT (activeTabChanged (int))); // this has to be done only once, not for each editor m_lexer = new LexerOctaveGui (); @@ -414,9 +432,10 @@ FileEditor::addFileEditorTab (FileEditorTab *fileEditorTab) { m_tabWidget->addTab (fileEditorTab, ""); - connect (fileEditorTab, SIGNAL(fileNameChanged(QString)), + connect (fileEditorTab, SIGNAL (fileNameChanged(QString)), this, SLOT(handleFileNameChanged(QString))); - + connect (fileEditorTab, SIGNAL (editorStateChanged ()), + this, SLOT (handleEditorStateChanged ())); m_tabWidget->setCurrentWidget (fileEditorTab); } diff -r 9fa8955ea79d -r 628eeaf879f7 gui/src/editor/FileEditor.h --- a/gui/src/editor/FileEditor.h Wed May 23 16:20:29 2012 -0400 +++ b/gui/src/editor/FileEditor.h Thu May 24 12:08:53 2012 +0200 @@ -75,6 +75,8 @@ void handleFileNameChanged (QString fileName); void handleTabCloseRequest (int index); + void activeTabChanged (int index); + void handleEditorStateChanged (); private: void construct (); @@ -83,7 +85,6 @@ QMenuBar *m_menuBar; QToolBar *m_toolBar; - QStatusBar *m_statusBar; QAction* m_copyAction; QAction* m_cutAction; QTabWidget *m_tabWidget; diff -r 9fa8955ea79d -r 628eeaf879f7 gui/src/editor/FileEditorTab.cpp --- a/gui/src/editor/FileEditorTab.cpp Wed May 23 16:20:29 2012 -0400 +++ b/gui/src/editor/FileEditorTab.cpp Thu May 24 12:08:53 2012 +0200 @@ -74,6 +74,7 @@ QVBoxLayout *layout = new QVBoxLayout (); layout->addWidget (m_editArea); + layout->setMargin (0); setLayout (layout); // connect modified signal @@ -86,8 +87,14 @@ newTitle (false); } +bool +FileEditorTab::copyAvailable () +{ + return m_copyAvailable; +} + void -FileEditorTab::closeEvent(QCloseEvent *event) +FileEditorTab::closeEvent (QCloseEvent *event) { if (m_fileEditor->mainWindow ()->closing ()) { @@ -184,10 +191,8 @@ void FileEditorTab::handleCopyAvailable(bool enableCopy) { - /* - m_copyAction->setEnabled(enableCopy); - m_cutAction->setEnabled(enableCopy); - */ + m_copyAvailable = enableCopy; + emit editorStateChanged (); } int diff -r 9fa8955ea79d -r 628eeaf879f7 gui/src/editor/FileEditorTab.h --- a/gui/src/editor/FileEditorTab.h Wed May 23 16:20:29 2012 -0400 +++ b/gui/src/editor/FileEditorTab.h Thu May 24 12:08:53 2012 +0200 @@ -28,6 +28,7 @@ Q_OBJECT public: FileEditorTab (FileEditor *fileEditor); + bool copyAvailable (); public slots: void newTitle(bool modified); @@ -56,10 +57,11 @@ void runFile (); signals: - void fileNameChanged(QString fileName); + void fileNameChanged (QString fileName); + void editorStateChanged (); protected: - void closeEvent(QCloseEvent *event); + void closeEvent (QCloseEvent *event); private: int checkFileModified (QString msg, int cancelButton); @@ -73,6 +75,7 @@ bool m_modified; bool m_longTitle; + bool m_copyAvailable; // TODO: Use QFileSystemWatcher to sync with disc. };