1
//MountManager - the program for easy mounting of storage devices in Linux
2
//Copyright (C) 2007-2008 Tikhonov Sergey
4
//This file is part of MountManager Gui
6
//This program is free software; you can redistribute it and/or
7
//modify it under the terms of the GNU General Public License
8
//as published by the Free Software Foundation; either version 2
9
//of the License, or (at your option) any later version.
11
//This program is distributed in the hope that it will be useful,
12
//but WITHOUT ANY WARRANTY; without even the implied warranty of
13
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
//GNU General Public License for more details.
16
//You should have received a copy of the GNU General Public License
17
//along with this program; if not, write to the Free Software
18
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
#include <QtGui/QLabel>
20
#include <QtGui/QLineEdit>
21
#include <QtGui/QPushButton>
22
#include <QtGui/QIcon>
23
#include <QtGui/QGridLayout>
25
#include "../core/diskcore.h"
26
#include "../core/diskdevice.h"
28
#include "choosemountpointwidget.h"
29
#include "widgetformount.h"
31
WidgetForMount::WidgetForMount(DiskCore *diskCore) {
34
headerLabel = new QLabel;
36
mountPointLabel = new QLabel(tr("Choose mount point, please") + ":");
37
mountPointLine = new ChooseMountPointWidget;
38
mountPointLine->setReadOnly(false);
40
optionsLabel = new QLabel(tr("Options") + ":");
41
optionsLine = new QLineEdit;
43
hideButton = new QPushButton;
44
hideButton->setIcon(QIcon(ICONS_PATH"cancel.png"));
45
hideButton->setFlat(true);
46
connect(hideButton,SIGNAL(clicked()),this,SLOT(hide()));
48
mountButton = new QPushButton(tr("Mount"));
49
mountButton->setIcon(QIcon(ICONS_PATH"mount.png"));
50
connect(mountButton,SIGNAL(clicked()),this,SLOT(mount()));
51
connect(mountPointLine,SIGNAL(mountPointValidSignal(bool)),mountButton,SLOT(setEnabled(bool)));
52
mountButton->setEnabled(false);
54
QGridLayout *mainLayout = new QGridLayout;
55
mainLayout->setMargin(0);
57
QHBoxLayout *buttonsLayout = new QHBoxLayout;
58
buttonsLayout->addStretch();
59
buttonsLayout->addWidget(mountButton);
61
QHBoxLayout *hideButtonLayout = new QHBoxLayout;
62
hideButtonLayout->setMargin(0);
63
hideButtonLayout->addWidget(headerLabel);
64
hideButtonLayout->addStretch();
65
hideButtonLayout->addWidget(hideButton);
67
mainLayout->addLayout(hideButtonLayout,0,0,1,2);
68
mainLayout->addWidget(mountPointLabel,1,0);
69
mainLayout->addWidget(mountPointLine,1,1);
70
mainLayout->addWidget(optionsLabel,2,0);
71
mainLayout->addWidget(optionsLine,2,1);
72
mainLayout->addLayout(buttonsLayout,3,0,1,2);
73
mainLayout->addWidget(new QLabel("<hr>"),4,0,1,2);
74
mainLayout->setColumnStretch(1,1);
76
setLayout(mainLayout);
79
WidgetForMount::~WidgetForMount() {
80
delete mountPointLabel;
81
delete mountPointLine;
89
void WidgetForMount::setOptionsForMount(const QString& blockName,const QString& mountPoint,const QString& fileSystem,const QString& options) {
90
headerLabel->setText("<b><font size=4>" + tr("Mounting of partition %1").arg(blockName) + "</font></b>");
91
mountPointLine->setMountPoint(mountPoint);
92
if (options.isEmpty())
93
optionsLine->setText("defaults");
95
optionsLine->setText(options);
96
currentFileSystem = fileSystem;
97
currentBlockName = blockName;
100
void WidgetForMount::mount() {
101
qDebug() << "[I] Mount the partition" << currentBlockName << "with options" << optionsLine->text() << "to" << mountPointLine->mountPoint();
102
core->mount(currentBlockName,mountPointLine->mountPoint(),currentFileSystem,optionsLine->text());