Isis 3 Programmer Reference
PaletteWindow.cpp
1 #include "PaletteWindow.h"
2 
3 #include "IString.h"
4 
5 namespace Isis {
13  readSettings();
14  parent->installEventFilter(this);
15  p_appName = parent->windowTitle();
16  }
17 
18 
25  void PaletteWindow::closeEvent(QCloseEvent *event) {
26  writeSettings();
27  }
28 
29 
36  void PaletteWindow::hideEvent(QHideEvent *event) {
37  writeSettings();
38  }
39 
40 
47  QString instanceName = this->windowTitle();
48  FileName config("$HOME/.Isis/" + p_appName + "/" + instanceName + ".config");
49  QSettings settings(config.expanded(), QSettings::NativeFormat);
50  QPoint pos = settings.value("pos", QPoint(300, 100)).toPoint();
51  QSize size = settings.value("size", QSize(900, 500)).toSize();
52  resize(size);
53  move(pos);
54  }
55 
56 
64  /*We do not want to write the settings unless the window is
65  visible at the time of closing the application*/
66  if(!this->isVisible()) return;
67 
68  QString instanceName = this->windowTitle();
69  FileName config("$HOME/.Isis/" + p_appName + "/" + instanceName + ".config");
70  QSettings settings(config.expanded(), QSettings::NativeFormat);
71  settings.setValue("pos", pos());
72  settings.setValue("size", size());
73  }
74 
75 
87  bool PaletteWindow::eventFilter(QObject *o, QEvent *e) {
88  switch(e->type()) {
89  case QEvent::Close: {
90  writeSettings();
91  }
92 
93  default: {
94  return false;
95  }
96  }
97  }
98 
99 }
100 
QWidget
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
QMainWindow
Isis::PaletteWindow::PaletteWindow
PaletteWindow(QWidget *parent=0)
PaletteWindow constructor.
Definition: PaletteWindow.cpp:12
Isis::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
Isis::PaletteWindow::eventFilter
bool eventFilter(QObject *o, QEvent *e)
This event filter is installed on the parent of this window.
Definition: PaletteWindow.cpp:87
Isis::PaletteWindow::hideEvent
void hideEvent(QHideEvent *event)
This method ensure that the settings get written even if the Palette window was only hidden,...
Definition: PaletteWindow.cpp:36
Isis::PaletteWindow::p_appName
QString p_appName
Application name.
Definition: PaletteWindow.h:28
Isis::PaletteWindow::closeEvent
void closeEvent(QCloseEvent *event)
This method is overridden so that we can be sure to write the current settings of the Palette window.
Definition: PaletteWindow.cpp:25
Isis::PaletteWindow::readSettings
void readSettings()
This method is called from the constructor so that when the Palette window is created,...
Definition: PaletteWindow.cpp:46
Isis::PaletteWindow::writeSettings
void writeSettings()
This method is called when the Palette window is closed or hidden to write the size and location sett...
Definition: PaletteWindow.cpp:63
QObject
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16