Tableview resizing and checkbox removal
Change-Id: I4a6641d7b043888718cff77e2f07823aef1b75f2
diff --git a/linux/tray-menu.cpp b/linux/tray-menu.cpp
index 1fc0692..b6c405e 100644
--- a/linux/tray-menu.cpp
+++ b/linux/tray-menu.cpp
@@ -23,7 +23,8 @@
#include <QLineEdit>
#include <QDir>
#include <QScrollBar>
-
+#include <QHBoxLayout>
+#include <QVBoxLayout>
TrayMenu::TrayMenu(QWidget *parent) :
QMainWindow(parent),
@@ -50,10 +51,8 @@
connect(ui->openRoutingStatusButton, SIGNAL(pressed()), this, SLOT(openRoutingStatus()));
connect(ui->addFibButton, SIGNAL(pressed()), this, SLOT(showFibInputDialog()));
connect(ui->deleteFibButton, SIGNAL(released()), this, SLOT(deleteFibEntry()));
- connect(ui->softwareUpdateCheckbox, SIGNAL(stateChanged(int)), this, SLOT(changeSoftwareUpdate()));
connect(ui->hubDiscoveryCheckbox, SIGNAL(stateChanged(int)), this, SLOT(changeHubDiscovery()));
connect(ui->loginStartCheckbox, SIGNAL(stateChanged(int)), this, SLOT(changeLoginStart()));
- connect(ui->shutdownCheckbox, SIGNAL(stateChanged(int)), this, SLOT(changeShutdownExit()));
connect(ui->tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectTableRow()));
connect(ui->openNdnCertificationButton, SIGNAL(released()), this, SLOT(openCertificationPage()));
@@ -76,18 +75,6 @@
{
QVariant value;
- value = persistentSettings->value(ALLOW_SOFTWARE_UPDATES);
- if(!value.isNull())
- {
- allowAutomaticUpdates = value.toBool();
- ui->softwareUpdateCheckbox->setChecked(allowAutomaticUpdates);
- }
- else
- {
- ui->softwareUpdateCheckbox->setChecked(true);
- changeSoftwareUpdate();
- }
-
value = persistentSettings->value(ENABLE_HUB_DISCOVERY);
if(!value.isNull())
{
@@ -111,32 +98,6 @@
ui->loginStartCheckbox->setChecked(false);
changeLoginStart();
}
-
- value = persistentSettings->value(SHUTDOWN_ON_EXIT);
- if(!value.isNull())
- {
- shutdownOnExit = value.toBool();
- ui->shutdownCheckbox->setChecked(shutdownOnExit);
- }
- else
- {
- ui->shutdownCheckbox->setChecked(false);
- changeShutdownExit();
- }
-}
-
-void TrayMenu::changeSoftwareUpdate()
-{
- if(ui->softwareUpdateCheckbox->isChecked())
- {
- allowAutomaticUpdates = true;
- persistentSettings->setValue(ALLOW_SOFTWARE_UPDATES, true);
- }
- else
- {
- allowAutomaticUpdates = false;
- persistentSettings->setValue(ALLOW_SOFTWARE_UPDATES, false);
- }
}
void TrayMenu::changeHubDiscovery()
@@ -193,20 +154,6 @@
process->start("cp",arguments);
}
-void TrayMenu::changeShutdownExit()
-{
- if(ui->shutdownCheckbox->isChecked())
- {
- shutdownOnExit = true;
- persistentSettings->setValue(SHUTDOWN_ON_EXIT, true);
- }
- else
- {
- shutdownOnExit = false;
- persistentSettings->setValue(SHUTDOWN_ON_EXIT, false);
- }
-}
-
void TrayMenu::showFibInputDialog()
{
dialog->clear();
@@ -250,7 +197,7 @@
connect(open, SIGNAL(triggered()), this, SLOT(show()));
trayIconMenu->addAction(open);
- close = new QAction("Quit...", this);
+ close = new QAction("Quit", this);
// connect(close, SIGNAL(triggered()), this, SLOT(confirmQuit()));
connect(close, SIGNAL(triggered()), qApp, SLOT(quit()));
trayIconMenu->addAction(close);
@@ -268,14 +215,13 @@
void TrayMenu::createToolbar()
{
- toolBar = new QToolBar(this);
- toolBar->setFloatable(false);
- toolBar->setMovable(false);
- toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
- toolBar->setAllowedAreas(Qt::TopToolBarArea);
- toolBar->setOrientation(Qt::Horizontal);
- toolBar->setIconSize(QSize(32,32));
- toolBar->resize(this->width(), 64);
+ ui->toolBar->setFloatable(false);
+ ui->toolBar->setMovable(false);
+ ui->toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ ui->toolBar->setAllowedAreas(Qt::TopToolBarArea);
+ ui->toolBar->setOrientation(Qt::Horizontal);
+ ui->toolBar->setIconSize(QSize(32,32));
+ ui->toolBar->resize(this->width(), 64);
openGeneralSettings = new QAction("General", this);
openGeneralSettings->setIcon(QIcon(":/resource/Resources/preferences-desktop.png"));
@@ -289,9 +235,9 @@
openSecuritySettings->setIcon(QIcon(":/resource/Resources/emblem-system.png"));
connect(openSecuritySettings,SIGNAL(triggered()),this, SLOT(securitySettingsClicked()));
- toolBar->addAction(openGeneralSettings);
- toolBar->addAction(openForwardingSettings);
- toolBar->addAction(openSecuritySettings);
+ ui->toolBar->addAction(openGeneralSettings);
+ ui->toolBar->addAction(openForwardingSettings);
+ ui->toolBar->addAction(openSecuritySettings);
}
void TrayMenu::generalSettingsClicked()
@@ -336,25 +282,6 @@
process->start(NDND_FIB_COMMAND, arguments);
}
-// void TrayMenu::confirmQuit()
-// {
-// if(shutdownOnExit)
-// terminateDaemonAndClose();
-// else
-// {
-// QuitDialog dialog(this);
-// dialog.exec();
-// }
-// }
-
-// void TrayMenu::terminateDaemonAndClose()
-// {
-// QProcess *process = new QProcess(this);
-// process->start(NDND_STOP_COMMAND);
-// connect(process,SIGNAL(finished(int)), qApp, SLOT(quit()));
-// connect(process,SIGNAL(finished(int)), process, SLOT(deleteLater()));
-// }
-
void TrayMenu::closeEvent(QCloseEvent *event)
{
if (trayIcon->isVisible())
@@ -550,12 +477,10 @@
}
ui->tableView->setModel(model);
- //ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
- ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::Fixed);
- ui->tableView->setColumnWidth(0, 260);
- ui->tableView->setColumnWidth(1, 57);
- ui->tableView->setColumnWidth(2, 150);
+ ui->tableView->setColumnWidth(0, ui->tableView->size().width() / 2 );
+ ui->tableView->setColumnWidth(1, ui->tableView->size().width() / 6 );
+
if(selectedRow >= 0)
ui->tableView->selectRow(selectedRow);
@@ -565,12 +490,28 @@
void TrayMenu::createTableView()
{
- ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
+ ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::Fixed);
+ ui->tableView->horizontalHeader()->setStretchLastSection(true);
ui->tableView->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
selectedRow = -1;
scrollPosition = -1;
+
+ QHBoxLayout *hlayout = new QHBoxLayout();
+ hlayout->addWidget(ui->addFibButton,0, Qt::AlignLeft);
+ hlayout->addWidget(ui->deleteFibButton, 20, Qt::AlignLeft);
+
+ QVBoxLayout *vlayout = new QVBoxLayout();
+ vlayout->addWidget(ui->label);
+ vlayout->addWidget(ui->tableView);
+ vlayout->addLayout(hlayout);
+
+ ui->forwardingSettingsWidget->setLayout(vlayout);
+
+ QVBoxLayout *expanding = new QVBoxLayout();
+ expanding->addWidget(ui->forwardingSettingsWidget);
+ ui->centralWidget->setLayout(expanding);
}
void TrayMenu::selectTableRow()
@@ -599,6 +540,15 @@
process->start(NDND_FIB_COMMAND, arguments);
}
+void TrayMenu::resizeEvent(QResizeEvent * event)
+{
+ ui->tableView->setColumnWidth(0, ui->tableView->size().width() / 2);
+ ui->tableView->setColumnWidth(1, ui->tableView->size().width() / 6);
+}
+
+
+
+
TrayMenu::~TrayMenu()
{
daemonStatusTimer->stop();
@@ -611,7 +561,6 @@
delete openGeneralSettings;
delete openForwardingSettings;
delete openSecuritySettings;
- delete toolBar;
delete statusUpdateThread;
delete dialog;
delete networkManager;
diff --git a/linux/tray-menu.h b/linux/tray-menu.h
index fa28471..3a8110a 100644
--- a/linux/tray-menu.h
+++ b/linux/tray-menu.h
@@ -63,13 +63,14 @@
void loadSettings();
void makeAutostartDirectory();
+ void resizeEvent (QResizeEvent * event);
+
bool daemonStarted;
QSettings *persistentSettings;
QSystemTrayIcon *trayIcon;
QMenu *trayIconMenu;
- QToolBar *toolBar;
QTimer *daemonStatusTimer;
QThread *statusUpdateThread;
@@ -96,10 +97,8 @@
FibInputDialog *dialog;
- bool allowAutomaticUpdates;
bool enableHubDiscovery;
bool enableStartOnLogin;
- bool shutdownOnExit;
NetworkManager *networkManager;
QNetworkAccessManager *urlManager;
@@ -120,10 +119,8 @@
void daemonStatusUpdate();
void selectTableRow();
void deleteFibEntry();
- void changeSoftwareUpdate();
void changeHubDiscovery();
void changeLoginStart();
- void changeShutdownExit();
void copyFile();
void runXmlProc(QNetworkReply *reply);
void parseStatusXml();
diff --git a/linux/traymenu.ui b/linux/traymenu.ui
index 63f586a..9861777 100644
--- a/linux/traymenu.ui
+++ b/linux/traymenu.ui
@@ -27,7 +27,7 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -38,12 +38,6 @@
<height>300</height>
</size>
</property>
- <property name="maximumSize">
- <size>
- <width>550</width>
- <height>300</height>
- </size>
- </property>
<property name="baseSize">
<size>
<width>0</width>
@@ -54,7 +48,7 @@
<property name="geometry">
<rect>
<x>10</x>
- <y>50</y>
+ <y>0</y>
<width>520</width>
<height>240</height>
</rect>
@@ -77,7 +71,7 @@
<x>10</x>
<y>10</y>
<width>500</width>
- <height>141</height>
+ <height>100</height>
</rect>
</property>
<property name="styleSheet">
@@ -92,42 +86,6 @@
<property name="flat">
<bool>false</bool>
</property>
- <widget class="QCheckBox" name="shutdownCheckbox">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>110</y>
- <width>441</width>
- <height>22</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <pointsize>13</pointsize>
- </font>
- </property>
- <property name="text">
- <string>Shutdown NDN daemon on exit</string>
- </property>
- </widget>
- <widget class="QCheckBox" name="softwareUpdateCheckbox">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>80</y>
- <width>441</width>
- <height>22</height>
- </rect>
- </property>
- <property name="font">
- <font>
- <pointsize>13</pointsize>
- </font>
- </property>
- <property name="text">
- <string>Check for software updates</string>
- </property>
- </widget>
<widget class="QCheckBox" name="hubDiscoveryCheckbox">
<property name="geometry">
<rect>
@@ -169,7 +127,7 @@
<property name="geometry">
<rect>
<x>10</x>
- <y>160</y>
+ <y>120</y>
<width>500</width>
<height>75</height>
</rect>
@@ -215,21 +173,21 @@
<property name="geometry">
<rect>
<x>10</x>
- <y>50</y>
- <width>530</width>
- <height>250</height>
+ <y>0</y>
+ <width>520</width>
+ <height>240</height>
</rect>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="maximumSize">
+ <property name="minimumSize">
<size>
- <width>530</width>
- <height>250</height>
+ <width>520</width>
+ <height>240</height>
</size>
</property>
<widget class="QLabel" name="label">
@@ -253,10 +211,16 @@
<rect>
<x>10</x>
<y>30</y>
- <width>511</width>
- <height>181</height>
+ <width>500</width>
+ <height>180</height>
</rect>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
</widget>
<widget class="QToolButton" name="addFibButton">
<property name="geometry">
@@ -289,7 +253,7 @@
<property name="geometry">
<rect>
<x>10</x>
- <y>50</y>
+ <y>0</y>
<width>520</width>
<height>240</height>
</rect>
@@ -312,7 +276,7 @@
<x>10</x>
<y>10</y>
<width>500</width>
- <height>200</height>
+ <height>75</height>
</rect>
</property>
<property name="styleSheet">