Diffstat (limited to 'noncore/apps/confedit/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/confedit/mainwindow.cpp | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp index 47d9518..77b91f6 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp | |||
@@ -35,15 +35,12 @@ | |||
35 | 35 | ||
36 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | 36 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : |
37 | QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) | 37 | QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) |
38 | { | 38 | { |
39 | setCaption( tr("Conf File Editor") ); | 39 | setCaption( tr("Conf File Editor") ); |
40 | 40 | ||
41 | popupTimer = new QTimer(this); | ||
42 | popupMenu = new QPopupMenu(this); | ||
43 | |||
44 | QWidget *mainWidget = new QWidget(this); | 41 | QWidget *mainWidget = new QWidget(this); |
45 | setCentralWidget( mainWidget); | 42 | setCentralWidget( mainWidget); |
46 | 43 | ||
47 | QGridLayout *mainLayout = new QGridLayout( mainWidget ); | 44 | QGridLayout *mainLayout = new QGridLayout( mainWidget ); |
48 | mainLayout->setSpacing( 3 ); | 45 | mainLayout->setSpacing( 3 ); |
49 | mainLayout->setMargin( 3 ); | 46 | mainLayout->setMargin( 3 ); |
@@ -55,16 +52,12 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
55 | editor = new EditWidget(this); | 52 | editor = new EditWidget(this); |
56 | mainLayout->addWidget( editor, 1, 0 ); | 53 | mainLayout->addWidget( editor, 1, 0 ); |
57 | 54 | ||
58 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), | 55 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), |
59 | this, SLOT(setCurrent(QListViewItem*))); | 56 | this, SLOT(setCurrent(QListViewItem*))); |
60 | 57 | ||
61 | connect( popupTimer, SIGNAL(timeout()), | ||
62 | this, SLOT(showPopup()) ); | ||
63 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), | ||
64 | this, SLOT( stopTimer( QListViewItem* ) ) ); | ||
65 | 58 | ||
66 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), | 59 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), |
67 | SLOT( groupChanged(const QString&) ) ); | 60 | SLOT( groupChanged(const QString&) ) ); |
68 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), | 61 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), |
69 | SLOT( keyChanged(const QString&) ) ); | 62 | SLOT( keyChanged(const QString&) ) ); |
70 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), | 63 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), |
@@ -73,12 +66,28 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
73 | } | 66 | } |
74 | 67 | ||
75 | void MainWindow::makeMenu() | 68 | void MainWindow::makeMenu() |
76 | { | 69 | { |
77 | 70 | ||
78 | 71 | ||
72 | popupTimer = new QTimer(this); | ||
73 | popupMenuFile = new QPopupMenu(this); | ||
74 | |||
75 | popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); | ||
76 | popupActionSave->addTo( popupMenuFile ); | ||
77 | connect( popupActionSave, SIGNAL( activated() ), | ||
78 | this , SLOT( saveConfFile() ) ); | ||
79 | popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); | ||
80 | popupActionRevert->addTo( popupMenuFile ); | ||
81 | connect( popupActionRevert, SIGNAL( activated() ), | ||
82 | this , SLOT( revertConfFile() ) ); | ||
83 | |||
84 | connect( popupTimer, SIGNAL(timeout()), | ||
85 | this, SLOT(showPopup()) ); | ||
86 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), | ||
87 | this, SLOT( stopTimer( QListViewItem* ) ) ); | ||
79 | } | 88 | } |
80 | 89 | ||
81 | MainWindow::~MainWindow() | 90 | MainWindow::~MainWindow() |
82 | { | 91 | { |
83 | } | 92 | } |
84 | 93 | ||
@@ -148,21 +157,25 @@ void MainWindow::stopTimer( QListViewItem* ) | |||
148 | void MainWindow::saveConfFile() | 157 | void MainWindow::saveConfFile() |
149 | { | 158 | { |
150 | if (!_fileItem) return; | 159 | if (!_fileItem) return; |
151 | _fileItem->save(); | 160 | _fileItem->save(); |
152 | } | 161 | } |
153 | 162 | ||
154 | void MainWindow::showPopup() | 163 | void MainWindow::revertConfFile() |
155 | { | 164 | { |
156 | qDebug("showPopup"); | ||
157 | if (!_fileItem) return; | 165 | if (!_fileItem) return; |
158 | popupMenu->clear(); | 166 | _fileItem->revert(); |
159 | 167 | } | |
160 | QAction *popupAction; | ||
161 | popupAction = new QAction( tr("Save"),QString::null, 0, this, 0 ); | ||
162 | popupAction->addTo( popupMenu ); | ||
163 | connect( popupAction, SIGNAL( activated() ), | ||
164 | this , SLOT( saveConfFile() ) ); | ||
165 | 168 | ||
169 | void MainWindow::showPopup() | ||
170 | { | ||
171 | qDebug("showPopup"); | ||
172 | if (_fileItem) | ||
173 | { | ||
174 | popupActionSave->setEnabled(_fileItem->isChanged()); | ||
175 | popupActionRevert->setEnabled(_fileItem->revertable()); | ||
176 | popupMenuFile->popup( QCursor::pos() ); | ||
177 | }else if(_currentItem->isChanged()) | ||
178 | { | ||
166 | 179 | ||
167 | popupMenu->popup( QCursor::pos() ); | 180 | } |
168 | } | 181 | } |