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 
File name manipulation and expansion.
Definition: FileName.h:116
void writeSettings()
This method is called when the Palette window is closed or hidden to write the size and location sett...
bool eventFilter(QObject *o, QEvent *e)
This event filter is installed on the parent of this window.
PaletteWindow(QWidget *parent=0)
PaletteWindow constructor.
void hideEvent(QHideEvent *event)
This method ensure that the settings get written even if the Palette window was only hidden...
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:212
QString p_appName
Application name.
Definition: PaletteWindow.h:28
void closeEvent(QCloseEvent *event)
This method is overridden so that we can be sure to write the current settings of the Palette window...
void readSettings()
This method is called from the constructor so that when the Palette window is created, it know's it's size and location.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31