MainWindow::MainWindow()
{
createLayout();
settings = new QSettings(QSettings::IniFormat, QSettings::UserScope,
"wallpapers-changer", "wallchanger");
//Timer
switchTimer = new QTimer(this);
connect(switchTimer, SIGNAL(timeout()), this, SLOT(set_image()));
connect(closeButton,SIGNAL(clicked()),this,SLOT(quitButton_clicked()));
connect(startButton,SIGNAL(clicked()),this,SLOT(start_clicked()));
connect(clearButton,SIGNAL(clicked()),this,SLOT(clear_clicked()));
connect(addButton,SIGNAL(clicked()),this,SLOT(add_clicked()));
connect(onlynames_checkBox,SIGNAL(stateChanged(int)),this,
SLOT(on_onlynames_checkBox_stateChanged(int)));
connect(timeBox,SIGNAL(valueChanged(int)),this,SLOT(on_timeBox_valueChanged(int)));
connect(tableWidget,SIGNAL(cellDoubleClicked(int,int)),this,
SLOT(on_tableWidget_cellDoubleClicked(int,int)));
connect(pos_comboBox,SIGNAL(currentIndexChanged(QString)),this,
SLOT(on_pos_comboBox_currentIndexChanged(QString)));
connect(order_comboBox,SIGNAL(currentIndexChanged(QString)),this,
SLOT(order_comboBox_currentIndexChanged(QString)));
//Tray menu
QAction* restoreAction = new QAction(tr("&Restore"), this);
connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal()));
QAction* quitAction = new QAction(tr("&Quit"), this);
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
QMenu* trayIconMenu = new QMenu(this);
trayIconMenu->addAction(restoreAction);
trayIconMenu->addAction(quitAction);
delicon = new QIcon("/usr/share/icons/gnome/48x48/actions/edit-delete.png");
if (settings->value("settings/show_only_names")==true)
onlynames_checkBox->setCheckState(Qt::Checked);
timeBox->setValue(settings->value("settings/scroll_time", 10).toInt());
scroll_label->setText(settings->value("settings/in", "Scroll time(minutes):").toString());
pos_comboBox->setCurrentIndex(settings->value("settings/img_position", 0).toInt());
order_comboBox->setCurrentIndex(settings->value("settings/img_order",0).toInt());
//Set tray icon
trayIcon = new QSystemTrayIcon(this);
trayIcon->setContextMenu(trayIconMenu);
trayicon = new QIcon("../wall/icon.png");
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
setWindowTitle(tr("Wallpapers Changer [beta2]"));
allFiles=load_and_show();
rand_numbers=create_randlist();
if (allFiles.count()!=0) start_clicked();
trayIcon->setIcon(*trayicon);
setWindowIcon(*trayicon);
trayIcon->show();
}