示例#1
0
IdSelectionDialog::IdSelectionDialog(QLabel * label, QWidget * parent)
	: info_label_(label), parent_(parent), dlg_(new Ui::dlg_idselection) {
	// TODO Auto-generated constructor stub
	dlg_->setupUi(this);

	setWindowFlags(windowFlags()|Qt::WindowStaysOnTopHint);
	setWindowModality(Qt::NonModal);
	setModal(false);

	connect(dlg_->btb_idselection, SIGNAL(accepted()), this, SLOT(HandleSaveButton()), Qt::UniqueConnection);
	connect(dlg_->btb_idselection, SIGNAL(rejected()), this, SLOT(HandleDiscardButton()), Qt::UniqueConnection);
}
示例#2
0
void
TFilePanel::MessageReceived(BMessage* message)
{
	entry_ref ref;

	switch (message->what) {
		case B_REFS_RECEIVED:
			// item was double clicked in file panel (PoseView)
			if (message->FindRef("refs", &ref) == B_OK) {
				BEntry entry(&ref, true);
				if (entry.InitCheck() == B_OK) {
					// Double-click on dir or link-to-dir ALWAYS opens the
					// dir. If more than one dir is selected, the first is
					// entered.
					if (entry.IsDirectory()) {
						entry.GetRef(&ref);
						bool isDesktop = SwitchDirToDesktopIfNeeded(ref);

						PoseView()->SetIsDesktop(isDesktop);
						entry.SetTo(&ref);
						PoseView()->SwitchDir(&ref);
						SwitchDirMenuTo(&ref);
					} else {
						// Otherwise, we have a file or a link to a file.
						// AdjustButton has already tested the flavor;
						// all we have to do is see if the button is enabled.
						BButton* button = dynamic_cast<BButton*>(
							FindView("default button"));
						if (button == NULL)
							break;

						if (IsSavePanel()) {
							int32 count = 0;
							type_code type;
							message->GetInfo("refs", &type, &count);

							// Don't allow saves of multiple files
							if (count > 1) {
								ShowCenteredAlert(
									B_TRANSLATE(
										"Sorry, saving more than one "
										"item is not allowed."),
									B_TRANSLATE("Cancel"));
							} else {
								// if we are a savepanel, set up the
								// filepanel correctly then pass control
								// so we follow the same path as if the user
								// clicked the save button

								// set the 'name' fld to the current ref's
								// name notify the panel that the default
								// button should be enabled
								SetSaveText(ref.name);
								SelectionChanged();

								HandleSaveButton();
							}
							break;
						}

					  	// send handler a message and close
						BMessage openMessage(*fMessage);
						for (int32 index = 0; ; index++) {
					  		if (message->FindRef("refs", index, &ref) != B_OK)
								break;
							openMessage.AddRef("refs", &ref);
					  	}
						OpenSelectionCommon(&openMessage);
					}
				}
			}
			break;

		case kSwitchDirectory:
		{
			entry_ref ref;
			// this comes from dir menu or nav menu, so switch directories
			if (message->FindRef("refs", &ref) == B_OK) {
				BEntry entry(&ref, true);
				if (entry.GetRef(&ref) == B_OK)
					SetTo(&ref);
			}
			break;
		}

		case kSwitchToHome:
		{
			BPath homePath;
			entry_ref ref;
			if (find_directory(B_USER_DIRECTORY, &homePath) != B_OK
				|| get_ref_for_path(homePath.Path(), &ref) != B_OK) {
				break;
			}

			SetTo(&ref);
			break;
		}

		case kAddCurrentDir:
		{
			BPath path;
			if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true)
					!= B_OK) {
				break;
			}

			path.Append(kGoDirectory);
			BDirectory goDirectory(path.Path());

			if (goDirectory.InitCheck() == B_OK) {
				BEntry entry(TargetModel()->EntryRef());
				entry.GetPath(&path);

				BSymLink link;
				goDirectory.CreateSymLink(TargetModel()->Name(), path.Path(),
					&link);
			}
			break;
		}

		case kEditFavorites:
		{
			BPath path;
			if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true)
					!= B_OK) {
				break;
			}

			path.Append(kGoDirectory);
			BMessenger msgr(kTrackerSignature);
			if (msgr.IsValid()) {
				BMessage message(B_REFS_RECEIVED);
				entry_ref ref;
				if (get_ref_for_path(path.Path(), &ref) == B_OK) {
					message.AddRef("refs", &ref);
					msgr.SendMessage(&message);
				}
			}
			break;
		}

		case kCancelButton:
			PostMessage(B_QUIT_REQUESTED);
			break;

		case kResizeToFit:
			ResizeToFit();
			break;

		case kOpenDir:
			OpenDirectory();
			break;

		case kOpenParentDir:
			OpenParent();
			break;

		case kDefaultButton:
			if (fIsSavePanel) {
				if (PoseView()->IsFocus()
					&& PoseView()->SelectionList()->CountItems() == 1) {
					Model* model = (PoseView()->SelectionList()->
						FirstItem())->TargetModel();
					if (model->ResolveIfLink()->IsDirectory()) {
						PoseView()->CommitActivePose();
						PoseView()->OpenSelection();
						break;
					}
				}

				HandleSaveButton();
			} else
				HandleOpenButton();
			break;

		case B_OBSERVER_NOTICE_CHANGE:
		{
			int32 observerWhat;
			if (message->FindInt32("be:observe_change_what", &observerWhat)
					== B_OK) {
				switch (observerWhat) {
					case kDesktopFilePanelRootChanged:
					{
						bool desktopIsRoot = true;
						if (message->FindBool("DesktopFilePanelRoot",
								&desktopIsRoot) == B_OK) {
							TrackerSettings().
								SetDesktopFilePanelRoot(desktopIsRoot);
						}
						SetTo(TargetModel()->EntryRef());
						break;
					}
				}
			}
			break;
		}

		default:
			_inherited::MessageReceived(message);
			break;
	}
}